C++ Builder Convert TIBQuery to TIBTable - c++

How to convert TIBQuery to TIBTable, additionally to display it in DBGrib?
I want to sort data in DBGrid and I used TIBQuery to take sort data from database, and I have problem to convert data from TIBQuery to TIBTable.

Create a VCL C++Builder app - Drop in TIBDatabase, TIBTable, TDataSource and TDBGrid on your form. Make active the TIBDatabase and TIBTable connections. Right mouse click on the TIBTable to add the columns you want to have appear in your TDBGrid. Leave the Column Header text to be the same as the Column Names.
Add the following line of code to the onTitleClick for the DBGrid:
void __fastcall TForm1::DBGrid1TitleClick(TColumn *Column)
{
// set TIBTable's IndexFieldNames property to the column title field name
// this will sort ascending all of the data in the DBGrid
IBTable1->IndexFieldNames = Column->FieldName;
}
If you want to do even more, I suggest that you add a TDataSetProvider and TClientDataSet to your form and then you can do more with your app.

Related

Oracle Apex- Enter a value and convert it to a link

I have a Master Detial with 2 interactive grids.
I would like to be able to genrate a link based on user input....is that at all possible?
To give a simple example:
Lets say I have website like https://www.google.com/
I would like a user to enter anything...for example "Prague"
Once this is entered, I would like APEX to generate a URL from it to result in: https://www.google.com/Prague
Now I know that Google search does not work like that, but I need that sort of mechanism for our internal company app. Is this possible?
Ideally , once the grid is saved the link in the Interactive grid only said "Prague" but if I click it, it would direct me to https://www.google.com/Prague
This can be achieved using the "JavaScript Initialization Code" attribute of the column.
Example on the EMP sample table (*). Functionality is that when a user enters a value in the ENAME column, it is converted to a google search url.
Create an editable IG on table EMP
Set the type of column ENAME to "Text Field"
Set "Javascript Initialization Code" for column "ENAME" to
function(config) {
config.defaultGridColumnOptions = {
cellTemplate: '&ENAME.'
};
return config;
}
Notice that the column now is a link. A user will have to open in new window to get the actual link value, since clicking the column will active the edit mode.
(*) Sample dataset can be installed using SQL Workshop > UTILITIES > Sample Data Sets > EMP/DEPT
yes, you can let user enter the value and by creating a dynamic action(choose the when attribute as whatever suits you) you can take that value and on another column, use that column as &Columnvalue. for example and concatanate it by using to base url using ||

Converting JSON into Table (PowerQuery)

What would be a correct PowerQuery syntax to extract the information from this Web JSON into a table:
I'm not very familiar with PowerQuery, and this is probably the only time I'll need this, so I'd be grateful if someone would help me out without refering me to documentation. Thanks
[{"time_entry_group": {"minutes": 301,"time_entries_params": {"locked": "0","from": "2021-02-01","to": "2021-02-28","customer_id": "11223344","project_id": "223388","service_id": "435248"},"revenue": 57691.6666666667,"project_id": 223388,"project_name": "Scrb","service_id": 435248,"service_name": "Meetings","month": "202102"}}
, {"time_entry_group": {"minutes": 1175,"time_entries_params": {"locked": "1","from": "2021-01-01","to": "2021-01-31","customer_id": "11223344","project_id": "223388","service_id": "421393"},"revenue": 225208.333333333,"project_id": 223388,"project_name": "Scrb","service_id": 421393,"service_name": "Design","month": "202101"}}
, {"time_entry_group": {"minutes": 24,"time_entries_params": {"locked": "1","from": "2021-01-01","to": "2021-01-31","customer_id": "11223344","project_id": "3168911","service_id": "95033"},"revenue": 4600.0,"project_id": 3168911,"project_name": "youkn Dev","service_id": 95033,"service_name": "Reviews","month": "202101"}}]
For future reference, if you have a column that you need to expand, you can instead click this arrow icon to the right of the column name. Clicking it should display a menu that should then allow you to specify which nested columns you want to get expand or get at. To be clear, it will expand that column for all rows in that table, not just one.
The JSON you've included is basically an array of objects, so maybe use:
Json.Document to parse the JSON, which should give you a list of records
Table.FromRecords to turn the list of records into a table.
Table.ExpandRecordColumn to expand a nested record columns.
Example implementation:
let
json = "[{""time_entry_group"":{""minutes"":301,""time_entries_params"":{""locked"":""0"",""from"":""2021-02-01"",""to"":""2021-02-28"",""customer_id"":""11223344"",""project_id"":""223388"",""service_id"":""435248""},""revenue"":57691.6666666667,""project_id"":223388,""project_name"":""Scrb"",""service_id"":435248,""service_name"":""Meetings"",""month"":""202102""}},{""time_entry_group"":{""minutes"":1175,""time_entries_params"":{""locked"":""1"",""from"":""2021-01-01"",""to"":""2021-01-31"",""customer_id"":""11223344"",""project_id"":""223388"",""service_id"":""421393""},""revenue"":225208.333333333,""project_id"":223388,""project_name"":""Scrb"",""service_id"":421393,""service_name"":""Design"",""month"":""202101""}},{""time_entry_group"":{""minutes"":24,""time_entries_params"":{""locked"":""1"",""from"":""2021-01-01"",""to"":""2021-01-31"",""customer_id"":""11223344"",""project_id"":""3168911"",""service_id"":""95033""},""revenue"":4600,""project_id"":3168911,""project_name"":""youkn Dev"",""service_id"":95033,""service_name"":""Reviews"",""month"":""202101""}}]",
parsed = Json.Document(json),
initialTable = Table.FromRecords(List.Transform(parsed, each [time_entry_group])),
expanded = Table.ExpandRecordColumn(initialTable, "time_entries_params", {"locked", "from", "to", "customer_id"})
in
expanded
One thing about the code above is that it doesn't expand nested fields project_id and service_id (present within time_entries_params). This is because these columns already exist in the table (and having duplicate column names would cause an error). I've assumed this isn't a problem, as the nested values aren't different.

Filling a DataGridView ComboBox with values in C/C++

I'm creating a windows forms application for university. My data is stored in multible c arrays of abstract data types. Each array is displayed in it's own datagridview. This all works no problem.
Since the data is connected like in a database I added a new column to my parent table and set the ColumnType to DataGridViewComboBoxColumn. Now I need to fill this combobox with the data of a different array / datagridview.
I've already tried to add the options manually from my array as discribed in this question: Filling DataGridView ComboBox programatically in unbound mode?. Since I need to use C/C++ and this example uses vb the used functions are not availible. I can select my column dataGridView1->Columns[0] but the ->Items does not exist.
Is it possible to create a datasource from my arrays to link them directly? Or have I overlooked a way to add them manually from my array?
You don't provide any code, neither you describe well where did you ran into a problem. Assuming you're after unbound list to be filled into the DataGridViewComboBoxColumn, here is a simple example.
C#:
DataTable dt;
dt.Columns.Add("ID", typeof(Int32));
dt.Columns.Add("Category", typeof(string));
dt.Rows.Add({1, "Fruits"});
dt.Rows.Add({2, "Vegetables"});
dt.Rows.Add({3, "Trees"});
DataGridViewComboBoxColumn dgCol = this.DataGridView1.columns("Category");
dgCol.ValueMember = "ID";
dgCol.DisplayMember = "Category";
dgCol.DataSource = dt;
In this example, we create a DataTable, fill it with desired values and use it as a DataSource of the DataGridViewComboBoxColumn. Obviously, your values provided to this column in the DataGridView DataSource must match IDs in the list in new DataTable "dt".
You can convert an array or other data into DataTable or even use them directly as DataSource. It depends on what data you have. The principle will be very similar, though.
VB.NET:
Dim dt As DataTable
dt.Columns.Add("ID", GetType(Int32))
dt.Columns.Add("Category", GetType(String))
dt.Rows.Add({1, "Fruits"})
dt.Rows.Add({2, "Vegetables"})
dt.Rows.Add({3, "Trees"})
Dim dgCol As DataGridViewComboBoxColumn = Me.DataGridView1.columns("Category")
dgCol.ValueMember = "ID"
dgCol.DisplayMember = "Category"
dgCol.DataSource = dt

How to write a query based on the Date item, in interactive grid

I have a date field and a interactive grid. I am trying to generate the Interactive grid based on the value inputted in the date field.
I am trying to write the query as below :
select pap.effective_start_date , pap.effective_end_date
from per_all_people_f pap
where :SELECT_DATE between pap.effective_start_date and
pap.effective_end_date
Here, SELECT_DATE is the name of the Date field (datatype Date picker). I am writing a dynamic action on Change of Date field, and refreshing the interactive grid region.
But when I change the value in Date field, it doesn't return any rows.
I have done a similar change where my interactive grid was based on a dropdown. There I had to set the "page action on selection" to Submit, and it worked. But here, since it is a Date field, the "Page Action on selection" property doesn't appear on the page .
Can somebody please suggest, how can I achieve this.
You need to explicitly convert your bind variables, which are treated as strings, to dates.
to_date(:SELECT_DATE)
The format mask will come from the application properties, or you can be explicit with that, too.

QDate empty value on add product page

I have a form to insert a product on vector. My form is a QT dialog form and I'd like that the space where I insert the date of purchase is blank and when I click on the QDateEdit the current date appears and I can set the date I prefer.
When I add the date to the vector ( both blank and setted date) I show it on QTableWidget. the column of purchase date must show me that value and if it is blank I'd like to be able to set the date I prefer ( after this I have a function to update the info on the vector).
How can I do this? Because on Qdate Class I have nothing that allows me to do this thing (http://doc.qt.io/qt-5/qdate.html).
I have to use qt and c++
thank you, I hope I explained the problem in a good way.
An easy way: use a customized QDateEdit and enable the QCalendarWidget popup, you can customize it using QSS. Example:
When the user sets the new date, just connect the signal dateChanged() whit your own slot and update your data.