Difference between revisions of "TGEntryPanel"

From Gestinux Wiki
Jump to navigation Jump to search
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.
 
It is currently under development in version trunk (Gestinux_util 1.4).
 
  
 
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.  

Revision as of 15:07, 18 October 2016

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 control fields 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.