Step 4. Complete the Section Employees Component
VFW112 – Drag and Drop between Components
Switch to the
component, iiiVFW37.1. On the
tab, select the DRAG_TO list view and create and event routines.2. Complete the
event by defining and parameters.Set AcceptDrop to true if the Payload_Employee object is component class iiiVFW36.
Your code should look like the following:
Evtroutine Handling(#DRAG_TO.DragOver) Options(*NOCLEARMESSAGES *NOCLEARERRORS) Payload(#Payload_Employee) Acceptdrop(#Acceptdrop)#Acceptdrop := #Payload_Employee *Is #iiiVFW36
Endroutine
3. Define
and parameters for the routine.As for the
routine, define a dynamic Payload_Employee object with a class of iiiVFW36.Create Payload_Employee using
to Payload.Your code should look like the following:
Evtroutine Handling(#DRAG_TO.DragDrop) Options(*NOCLEARMESSAGES *NOCLEARERRORS) Dragresult(#Dragresult) Payload(#Payload)
Define_Com Class(#iiiVFW36) Name(#Payload_Employee) Reference(*dynamic)
Set_Ref Com(#Payload_Employee) To(*dynamic #Payload)
Endroutine
4. Retrieve each payload entry using a For / Endfor loop and add an entry to the DRAG_TO list.
Set the STD_CODEL column to the payload department code.
Your code should look like the following:
Define #CurrDept Reffld(#Deptment)
#currdept := #deptment
For Each(#object) In(#Payload_Employee.pObjects)
#deptment := #currdept
#std_codel := #object.udepartment
#empno := #object.uempNum
#fullname := #object.ufullname
Add_Entry To_List(#DRAG_TO)
Endfor
5. Create a
method routine to be invoked via the command handler button.A transfer will be implemented by updating department and section code fields in the employee record.
Transferred employees have a non blank STD_CODEL column.
Issue a message if an update is not successful.
Your code should look like the following:
Mthroutine Name(SaveChanges)
Selectlist Named(#DRAG_TO)
If (#std_codel *NE *blanks)
Update Fields(#deptment #section) In_File(pslmst) With_Key(#empno) Val_Error(*next)
If_Status Is_Not(*okay)
Message Msgtxt('Transfer employee ' + #empno + 'to ' + #deptment + ' failed')
Endif
Endif
Endselect
Endroutine
6. Compile Section Employees, iiiVFW37.