Step 4. Code iiiFRM03 Client Wrapper Form

INT008 – Department & Employee Client (Optional)

In this step, you will create a visual Form for your client. This will allow you to interact with your server from a simple Windows program.

1.  Create a new LANSA form named iiiFRM03 Display Department Employees, where iii is your unique 3 characters. (If the form already exists, select a different set of characters for iii.).

2.  Drag a List View onto your form.

3.  Drag the fields FULLNAME and SKILDESC onto the List View and adjust the column widths.

4.     Drag the field DEPTMENT above the List View.

5.     Drag a push button to the right of the DEPTMENT field and give it a caption of Refresh.

6.     Add a click event to the push button.

7.  The basic logic for this form accepts Department Codes input from the user, calls RDMLX function iiiFN07 and then displays the resulting employees list. You will need a working list to hold the data returned by iiiFN07.

a.  After the DEFINE_COM statements, define WL_EMPSKL as a working list containing fields FULLNAME and SKILDESC, with the keyword Entrys(*max).

8.   Add logic to the click event of the push button to call the function.

a.  Clear the working list.

b.  Exchange field DEPTMENT.

c.  Call function iiiFN07, passing the working list WL_EMPSKL (to allow the populated data to return).

d.  Loop through the working list, adding entries to the list view on each iteration.

         Your finished code should look something like this:

Function Function Options(*DIRECT)

Begin_Com Role(*EXTENDS #PRIM_FORM) Clientwidth(484) Clientheight(301) Componentversion(2) Left(751) Top(223)

Define_Com Class(#PRIM_LTVW) Name(#ListView1) Columnbuttonheight(18) Componentversion(2) Displayposition(1) Fullrowselect(True) Keyboardpositioning(SortColumn) Left(28) Parent(#COM_OWNER) Showsortarrow(True) Tabposition(1) Top(48) Width(397) Height(217)

Define_Com Class(#PRIM_LVCL) Name(#LVCL1) Displayposition(1) Parent(#ListView1) Source(#EMPNO)

Define_Com Class(#PRIM_LVCL) Name(#LVCL2) Displayposition(2) Parent(#ListView1) Source(#FULLNAME) Width(64)

Define_Com Class(#DEPTMENT.Visual) Name(#DEPTMENT) Displayposition(2) Left(21) Parent(#COM_OWNER) Tabposition(2) Top(18)

Define_Com Class(#PRIM_PHBN) Name(#Button1) Caption('Refresh') Displayposition(3) Left(285) Parent(#COM_OWNER) Tabposition(3) Top(13)

Def_List Name(#WL_EMPSKL) Fields(#fullname #skildesc) Type(*working) Entrys(*max)

 

Evtroutine Handling(#com_owner.CreateInstance)

 

Set Com(#com_owner) Caption(*component_desc)

 

Endroutine

 

Evtroutine Handling(#Button1.Click)

Clr_List Named(#WL_EMPSKL)

Exchange Fields(#DEPTMENT)

Call Process(*direct) Function(iiiFN07) Pass_Lst(#WL_EMPSKL)

Clr_List Named(#ListView1)

Selectlist Named(#WL_EMPSKL)

Add_Entry To_List(#ListView1)

Endselect

Endroutine

End_Com

 

5.  Save, compile and close the function.