Step 2 Implement Time Employed calculation in Employee Details Command Handler

VLF Windows Application Development

Step 2. Implement Time Employed calculation in Employee Details Command Handler

VFW070 – Create Time Employed Reusable Part

1.  Open the Employee Details command handler in the editor (iiiVFW06).

2.  Add a Group Box component to the main panel (BODY_HEAD) and change its Caption to Time Employed.

3.  Add field STD_NUM to the group box. Set up the followings properties:

Property

Value

Caption

Years

LabelType

Caption

Name

EMP_YEARS

MarginLeft

50

 

     Reduce the field's width as necessary.

4.  Add another STD_NUM field to the group box and repeat step 3 the above steps except:

a.  Change Name to EMP_MONTHS

b.  Change Caption to Months

5.  Add another STD_NUM field to the group box and repeat step 3, except:

a.  Change Name to EMP_DAYS

b.  Change Caption to Days

6.  Adjust the width of each field as required.

7.  On the Design ribbon, use Edit / Align button to arrange the fields.

8.  Save your changes.

     Your design should look like the following:

9.  In the Design view, drag and drop your Time Employed reusable part onto Employee Details component. This will create a Define_Com for iiiVFW12. Change its Name to EMPLOY_CALC

10.Change the Group_By XG_HEAD to include STARTDTER.

11. In the uExecute method routine add the following code, following the FETCH command:

If_Status Is(*okay)
Invoke Method(#EMPLOY_CALC.uEmployTime) I_Strdte(#STARTDTER) O_Year(#EMP_YEARS) O_Month(#EMP_MONTHS) O_Days(#EMP_DAYS)
Endif

 

12. In the SAVE_BUTTON Click event routine, add the following logic, after the UPDATE command:

If_Status Is(*OKAY)
Invoke Method(#EMPLOY_CALC.uEmployTime) I_Strdte(#STARTDTER) O_Year(#EMP_YEARS) O_Month(#EMP_MONTHS) O_Days(#EMP_DAYS)
Endif

 

13. Compile the Employee Details command handler.

14. Execute the Framework as an End User and test the Time Employed calculator.

15. Change Start Date for an employee to a recent date, for example, 2012 or 2013, to easily check the results are as expected. Note, this is a 6 digit date.