Step 4 Complete the Section Employees Component

VLF Windows Application Development

Step 4. Complete the Section Employees Component

VFW112 – Drag and Drop between Components

Switch to the Section Employees component, iiiVFW37.

1.  On the Design tab, select the DRAG_TO list view and create DragOver and EndDrag event routines.

2.  Complete the Drag_Over event by defining Payload and AcceptDrop 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 DragResult and Payload parameters for the DragDrop routine.

     As for the DragOver routine, define a dynamic Payload_Employee object with a class of iiiVFW36.

     Create Payload_Employee using Set_Ref to Payload.

     Your code should look like the following:

Evtroutine Handling(#DRAG_TO.DragDrop) Options(*NOCLEARMESSAGES *NOCLEARERRORS) Dragresult(#Dragresult) Payload(#Payload)
Define_Com Class(#iiiVFW3
6) 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 SaveChanges method routine to be invoked via the Transfer Employees to Section command handler Save 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.