Adding a FillGrid to a TStruct (Using SQL)

Quick Guide >>

Scenario  : Retrieval of employee details for PaySlip generation.

In any organization,the monthly pay-slip generation task requires the employee details to be retrieved from the master into a tabular format. The scenario consists of two TStructs – an Employee Master  and a Payslip.The Employee Master contains the details of all the employees and the Payslip TStruct contains their salary details.

  • Create the Employee Master TStruct and  Payslip TStruct. The TStruct definitions are as given below.

Employee Master

Type Name Caption Properties
TStruct Emp Employee Master TransId = Emp
DC dc1 Master TableName=empmast
InputField EmpId Employee Id DataType = Character
DataWidth=15
AllowEmpty=False
AllowDuplicate = False
InputField EmpName Employee Name DataType = Character
DataWidth=50
AllowEmpty=False
InputField Basic Basic DataType = Numeric
InputField DA DA DataType = Numeric
InputField HRA HRA DataType = Numeric

Payslip

Type Name Caption Properties
TStruct Pay Payslip TransId = Pay
DC dc1 Month TableName=Month
AsGrid = False
InputField Month Month DataType = Character
DataWidth=15
AllowEmpty=False
InputField Year Year DataType = Character
DataWidth=15
AllowEmpty=False
DC dc2 Pay Details TableName=PayDet
AsGrid = True
InputField Employee Employee DataType = Character
DataWidth=50
InputField Basic Basic DataType = Numeric
InputField DA DA DataType = Numeric
InputField HRA HRA DataType = Numeric
  • In the Payslip TStruct, insert a FillGrid control .Set the properties as follows.
Type Name Properties
FillGrid Caption = Fill Employees
SQL = SELECT EmpId, EmpName, Basic,DA,HRA FROM empmast
TargetDC  = dc2
MapDetails :Source Field    Target Field
EmpName          Employee
Basic                 Basic
DA                    DA
HRA                  HRA

AutoShow = True

Adding a FillGrid to Tstruct

Adding a FillGrid to Tstruct

 

Fillgrid Properties

Fillgrid Properties

Mapping Details

Mapping Details

  • Save the TStructs and enter some records into the Employee Master.
  • During runtime, open the PaySlip Form and move the focus to the grid. The SQL specified is fired and the result set of the SQL(all the employee details) gets displayed. All or selected data can be filled into the grid from the pop up. Complex SQLs can also be written to retrieve all the required information.