S_223FA

LANSA

S_223FA
* ===================================================================
*
* Component : S_223FA
* Type : Form
* Ancestor : PRIM_FORM
*
* Description : Advanced List Views - Using Check Boxes
*
* Disclaimer : The following material is supplied as example material
* only. No warranty concerning this material or its use
* in any way whatsoever is expressed or implied.
*
* ===================================================================
Function Options(*DIRECT)
BEGIN_COM Role(*EXTENDS #PRIM_FORM) Height(346) Left(249) Top(136) Visualstyle(#VS_NORM) Width(721)

* List view definition. Note the use of Checkboxes(True)

DEFINE_COM Class(#PRIM_LTVW) Name(#EMPLIST) Checkboxes(True) Displayposition(1) Fullrowselect(True) Height(285) Left(8) Parent(#COM_OWNER) Tabposition(1) Top(28) Width(601)
DEFINE_COM Class(#PRIM_LVCL) Name(#LVCL_1) Displayposition(1) Parent(#EMPLIST) Source(#EMPNO) Width(17)
DEFINE_COM Class(#PRIM_LVCL) Name(#LVCL_2) Displayposition(2) Parent(#EMPLIST) Source(#SURNAME) Width(25)
DEFINE_COM Class(#PRIM_LVCL) Name(#LVCL_3) Displayposition(3) Parent(#EMPLIST) Source(#GIVENAME) Width(27)
DEFINE_COM Class(#PRIM_LVCL) Name(#LVCL_4) Displayposition(4) Parent(#EMPLIST) Source(#SALARY) Width(17)
DEFINE_COM Class(#PRIM_LVCL) Name(#LVCL_5) Caption('Raise Given') Captiontype(Caption) Columnalign(Center) Displayposition(5) Parent(#EMPLIST) Source(#STD_BOOL) Width(14) Widthtype(Remainder)

DEFINE_COM Class(#PRIM_PHBN) Name(#PB_RAISE) Caption('Give Raise') Displayposition(2) Left(624) Parent(#COM_OWNER) Tabposition(2) Top(280)

* ===============================
* Handle main form initialization
* ===============================

Evtroutine Handling(#Com_Owner.Initialize)

* Fill the list view with details of all employees

Change Field(#Std_Bool) To(NO)

Select Fields(#EmpList) From_File(PSLMST)
Add_Entry To_List(#EmpList)
Endselect

Endroutine

* =======================================
* Handle click of the "Give Raise" button
* =======================================

Evtroutine Handling(#PB_Raise.Click)

Define #SelCount Reffld(#Std_Num) Desc('Employees Updated')
Define #UpCount Reffld(#Std_Num) Desc('Employees Updated')
Define #NoUpCount Reffld(#Std_Num) Desc('Employees Not Updated')

* Process all employees in the list view

Change (#SelCount #UpCount #NoUpCount) 0

Selectlist Named(#EmpList)

* Only give raise to employees that are checked

Continue If('#EmpList.CurrentItem.Checked *ne True')

* Count selections made

Change #SelCount '#SelCount + 1'

* If raise has already been given show a warning

If Cond('#Std_Bool = Yes')

Change #NoUpCount '#NoUpCount + 1'
Use Message_Box_Add (#GiveName #SUrname 'has already had a raise !')
Use Message_Box_Show (OK OK WARN 'Warning')

Else

* else give the employee a raise

Change #UpCount '#UpCount + 1'
Change Field(#Salary) To('#Salary * 1.10')
Change Field(#Std_Bool) To(Yes)
Upd_Entry In_List(#EmpList)

Endif

Endselect

* Show a summary of the actions in a message box

Use Message_Box_Add (#SelCount 'employees were selected for raises')
Use Message_Box_Add (#UpCount 'were given raises')
If '#NoUpCount > 0'
Use Message_Box_Add (#NoUpCount 'were NOT given raises')
Endif
Use Message_Box_Show (OK OK INFO 'Updates')

Endroutine

End_Com