Difference between revisions of "TGEntryPanel"
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
TGEntryPanel is designed to read data from a [[TGTable]], and to insert or update data to it, very efficiently. | TGEntryPanel is designed to read data from a [[TGTable]], and to insert or update data to it, very efficiently. | ||
− | |||
− | |||
A TGEntryPanel has a Table property. You need one TGEntryPanel for each table, but a form can have several TGEntryPanel. | A TGEntryPanel has a Table property. You need one TGEntryPanel for each table, but a form can have several TGEntryPanel. | ||
Line 7: | Line 5: | ||
For each data fields of the TGTable to be displayed or saved, must exist a Control named after the field name with the prefix 'Edit' (except TGEditButton, see below). We do not have added a property to allow other names, to avoid complex mapping. Any error will be visible very early during development (if Assert is enabled). | For each data fields of the TGTable to be displayed or saved, must exist a Control named after the field name with the prefix 'Edit' (except TGEditButton, see below). We do not have added a property to allow other names, to avoid complex mapping. Any error will be visible very early during development (if Assert is enabled). | ||
− | The | + | The controls can be : |
* [[TGEdit]] | * [[TGEdit]] | ||
Line 20: | Line 18: | ||
ReadFromQuery requires a Sql Query. This is to handle [[TGEditButton]] in one SELECT, more efficient than several. In the future, we could parse the foreign key constraints to find the data automatically... | ReadFromQuery requires a Sql Query. This is to handle [[TGEditButton]] in one SELECT, more efficient than several. In the future, we could parse the foreign key constraints to find the data automatically... | ||
− | For a TGEdit, 2 events can be specified to allow some specific transformation of data (e.g. a percent displayed as 12.3% and saved as 1230 in the database, see FormTax). This could be extended to other components in the future, if useful. | + | For a [[TGEdit]], 2 events can be specified to allow some specific transformation of data (e.g. a percent displayed as 12.3% and saved as 1230 in the database, see FormTax). This could be extended to other components in the future, if useful. |
− | A [[TGComboBox]] must be filled with AddItem | + | A [[TGComboBox]] must be filled with AddItem or InsertItem. These methods associate to each visible ans translated item the corresponding code in the database. This must be done in form's events : FormCreate or Translate. |
For a [[TGEditButton]], The SQL query must return 2 fields : <ControlName>Id and <ControlName>Text and the [[TGTable]] must have a <ControlName>Id to save the data (See FormTax). | For a [[TGEditButton]], The SQL query must return 2 fields : <ControlName>Id and <ControlName>Text and the [[TGTable]] must have a <ControlName>Id to save the data (See FormTax). | ||
Warning : The Save method don't perform a Commit, since other data could be saved in the same transaction. | Warning : The Save method don't perform a Commit, since other data could be saved in the same transaction. |
Latest revision as of 13:44, 25 May 2018
TGEntryPanel is designed to read data from a TGTable, and to insert or update data to it, very efficiently.
A TGEntryPanel has a Table property. You need one TGEntryPanel for each table, but a form can have several TGEntryPanel.
For each data fields of the TGTable to be displayed or saved, must exist a Control named after the field name with the prefix 'Edit' (except TGEditButton, see below). We do not have added a property to allow other names, to avoid complex mapping. Any error will be visible very early during development (if Assert is enabled).
The controls can be :
To be eligible, a control must inherit from TCustomGLabelEdit and implement 3 methods : Clear, ReadFromQuery and Save.
ReadFromQuery requires a Sql Query. This is to handle TGEditButton in one SELECT, more efficient than several. In the future, we could parse the foreign key constraints to find the data automatically...
For a TGEdit, 2 events can be specified to allow some specific transformation of data (e.g. a percent displayed as 12.3% and saved as 1230 in the database, see FormTax). This could be extended to other components in the future, if useful.
A TGComboBox must be filled with AddItem or InsertItem. These methods associate to each visible ans translated item the corresponding code in the database. This must be done in form's events : FormCreate or Translate.
For a TGEditButton, The SQL query must return 2 fields : <ControlName>Id and <ControlName>Text and the TGTable must have a <ControlName>Id to save the data (See FormTax).
Warning : The Save method don't perform a Commit, since other data could be saved in the same transaction.