In this step, you will add a Save button for employee details and create an UpdateEmployee method routine. At this stage, employee notes will not be updated.
1. Add a push button to the top of row 4, column 1.
2. Change the button's Alignment to Top Right.
a. Give it a margin Right of 20 and a margin Top of 10.
b. Change its Caption to Save.
c. Change its Name to Save_Employee.
d. Give it an Image of xImageSave16.
e. Create a Click event for the Save button.
3. Create a SaveEmployee method routine, based on the following:
Map for input of class xEmployeeIdentification, Name EmployeeID
Define a component iiixEmployeeDataServer / Save srvroutine, with name UpdateEmployee.
Assign xEmployeeIdentification to value EmployeeID
Execute UpdateEmployee asynchronously, exchanging Group_By xEmployee and field IO$STS.
Within a Completed event routine for UpdateEmployee:
If IO$STS is equal OK
Assign fields in Group_By xEmployee the value null
Set Label_Details.Caption to blank.
End Routine
Your code should look like the following:
Mthroutine Name(SaveEmployee) Define_Map For(*INPUT) Class(#xEmployeeIdentification) Name(#EmployeeID) Define_Com Class(#iiixEmployeeDataServer.save) Name(#UpdateEmployee) #xEmployeeIdentification := #EmployeeID #UpdateEmployee.ExecuteAsync( #xEmployee #io$sts ) Evtroutine Handling(#UpdateEmployee.Completed) If (#io$sts = OK) #xEmployee := *null #Label_Details.Caption := "" Clr_List Named(#NotesList) Endif Endroutine Endroutine
4. Complete the Save_Employee button Click event by adding code to invoke the SaveEmployee method passing xEmployeeIndentification.
Your code should look like the following:
Evtroutine Handling(#Save_Employee.Click) #COM_SELF.SaveEmployee( #xEmployeeIdentification ) Endroutine
5. Compile and test the web page.
| Note: This application is a simple training exercise. Logic to update the employee entry in the EmployeeList dropdown hasn't been added, such as when Given Name or Surname is changed. This could easily be achieved. |