Form S_199FB

LANSA

Form S_199FB
* ===================================================================;
*;
* Component : S_199FB;
* Type : Form;
* Ancestor : PRIM_FORM (Primitive Form);
*;
* Description : Simple Grids;
*;
* Full Description; This is a simple form with three grids.;
* 1) A grid filled up with all the records from the DEPTAB file (Departments);
* 2) A grid filled up with all the records from the SECTAB file (Sections);
* 3) A grid filled up with all the records from the PSLMST file (Employees);
*;
* Functionally this form is identical to S_199FA, except that three instances;
* of the "Grid Helper" (S_199RFC) have been added to it (S_199RFC is generic;
* and can work with any grid).;
*;
* You can compare the code of this form (S_199FB) with S_199FA to see what;
* extra code is required to plug the "Grid Helper" into it.;
*;
*;
* Disclaimer : The following material is supplied as sample material;
* only. No warranty concerning this material or its use;
* in any way whatsoever is expressed or implied.;
*;
* ===================================================================;
Function Options(*DIRECT);
Begin_Com Caption('S_199FB') Formposition(ScreenCenter) Height(577) Left(50) Top(95) Width(920);
* Department Grid and columns;
Define_Com Class(#PRIM_GRID) Name(#DEPT_GRID) Columnbuttonheight(32) Displayposition(1) Height(145) Left(16) Parent(#COM_OWNER) Tabposition(1) Top(16) Width(337);
Define_Com Class(#PRIM_GDCL) Name(#GDCL_1) Caption('Department Code') Captiontype(Caption) Displayposition(1) Parent(#DEPT_GRID) Sortposition(2) Source(#DEPTMENT) Width(30) Widthtype(Fixed);
Define_Com Class(#PRIM_GDCL) Name(#GDCL_2) Caption('DEPT DESC') Captiontype(Caption) Displayposition(2) Parent(#DEPT_GRID) Sortdirection(Descending) Sortposition(1) Source(#DEPTDESC) Width(71);
;
* Section Grid and columns;
Define_Com Class(#PRIM_GRID) Name(#EMP_GRID) Columnbuttonheight(31) Displayposition(2) Height(145) Left(16) Parent(#COM_OWNER) Tabposition(2) Top(360) Width(881);
Define_Com Class(#PRIM_GDCL) Name(#GDCL_5) Caption('Section Description') Captiontype(Caption) Displayposition(2) Parent(#SECT_GRID) Sortposition(1) Source(#SECDESC) Width(24);
Define_Com Class(#PRIM_GDCL) Name(#GDCL_6) Caption('Suburb or Town') Captiontype(Caption) Displayposition(3) Parent(#SECT_GRID) Sortposition(2) Source(#SECADDR2) Width(26);
Define_Com Class(#PRIM_GDCL) Name(#GDCL_7) Caption('Street Name and Number') Captiontype(Caption) Displayposition(1) Parent(#SECT_GRID) Sortposition(3) Source(#SECADDR1) Width(23);
Define_Com Class(#PRIM_GDCL) Name(#GDCL_8) Caption('State and Country') Captiontype(Caption) Displayposition(4) Parent(#SECT_GRID) Sortposition(4) Source(#SECADDR3) Width(28);
Define_Com Class(#PRIM_GDCL) Name(#GDCL_9) Caption('Employee Name') Captiontype(Caption) Displayposition(1) Parent(#EMP_GRID) Sortposition(1) Source(#FULLNAME) Width(16);
;
* Employee Grid and columns;
Define_Com Class(#PRIM_GRID) Name(#SECT_GRID) Columnbuttonheight(37) Displayposition(5) Height(145) Left(16) Parent(#COM_OWNER) Rowheight(17) Tabposition(5) Top(176) Width(753);
Define_Com Class(#PRIM_GDCL) Name(#GDCL_10) Caption('Street Number and Name') Captiontype(Caption) Displayposition(2) Parent(#EMP_GRID) Sortposition(2) Source(#ADDRESS1) Width(15);
Define_Com Class(#PRIM_GDCL) Name(#GDCL_11) Caption('Suburb or Town') Captiontype(Caption) Displayposition(3) Parent(#EMP_GRID) Sortposition(3) Source(#ADDRESS2) Width(15);
Define_Com Class(#PRIM_GDCL) Name(#GDCL_12) Caption('State and Country') Captiontype(Caption) Displayposition(4) Parent(#EMP_GRID) Sortposition(4) Source(#ADDRESS3) Width(16);
Define_Com Class(#PRIM_GDCL) Name(#GDCL_13) Caption('Post Code') Captiontype(Caption) Displayposition(5) Parent(#EMP_GRID) Sortposition(5) Source(#POSTCODE) Width(7);
Define_Com Class(#PRIM_GDCL) Name(#GDCL_14) Caption('Home Number') Captiontype(Caption) Displayposition(6) Parent(#EMP_GRID) Sortposition(6) Source(#PHONEHME) Width(10);
Define_Com Class(#PRIM_GDCL) Name(#GDCL_15) Caption('Business Number') Captiontype(Caption) Displayposition(7) Parent(#EMP_GRID) Sortposition(7) Source(#PHONEBUS) Width(14);
Define_Com Class(#PRIM_GDCL) Name(#GDCL_16) Caption('Salary') Captiontype(Caption) Displayposition(8) Parent(#EMP_GRID) Source(#SALARY) Width(20);
;
* Text;
;
Define_Com Class(#PRIM_GPBX) Name(#GPBX_1) Caption('Form S_199FB') Displayposition(4) Height(153) Left(384) Parent(#COM_OWNER) Tabposition(4) Tabstop(False) Top(16) Width(385);
Define_Com Class(#PRIM_LABL) Name(#LABL_1) Caption('This form is identical to S_199FA except that the reusable part S_199RFC (the "Grid Helper") has been added. To see the impact of what the "Grid Helper" does, right click on any of the column headings of any of the grids. The pop up menu gives you the options of not only sorting the columns in ascending or descending order, but also to move the columns to the right or left or to make them appear or disappear. The Grid Helper also remembers you preferences. When you close and reopen this form again later all your grid display preferences will be restored.') Displayposition(1) Height(129) Left(8) Parent(#GPBX_1) Tabposition(1) Tabstop(False) Top(16) Visualstyle(#VS_EMPH) Width(369);
Define_Com Class(#PRIM_ATLI) Name(#ATLI_1) Manage(#LABL_1) Parent(#ATLM_1);
Define_Com Class(#PRIM_ATLM) Name(#ATLM_1);
;
* Define 3 Grid Helpers (one for each grid shown on this form);
;
Define_Com Class(#S_199RFC) Name(#HELPER_DEPT) Displayposition(6) Parent(#COM_OWNER) Tabposition(6);
Define_Com Class(#S_199RFC) Name(#HELPER_SECT) Displayposition(7) Parent(#COM_OWNER) Tabposition(7);
Define_Com Class(#S_199RFC) Name(#HELPER_EMPNO) Displayposition(3) Parent(#COM_OWNER) Tabposition(3);
;
;
* ===================================================================;
* Initialize the form by filling all 3 grids from the database;
* and by describing the grids and columns to each of their;
* respective helpers.;
* ===================================================================;
;
Evtroutine Handling(#com_owner.Initialize);
;
* Tell the department grid helper about the department grid and its columns.;
;
* Note the use of the optional UseCaption argument to override the description;
* of the column that is used by the Grid Helper in its pop up menus.;
;
Set Com(#com_owner) Caption(*component_desc);
Invoke Method(#HELPER_DEPT.Define_grid) Form(#Com_Owner) Grid(#dept_grid);
Invoke Method(#HELPER_DEPT.Define_Column) Column(#GDCL_1);
Invoke Method(#HELPER_DEPT.Define_Column) Column(#GDCL_2) Usecaption('Department Description');
;
* Tell the section grid helper about the department grid and its columns.;
;
Invoke Method(#HELPER_SECT.Define_grid) Form(#Com_Owner) Grid(#sect_grid);
Invoke Method(#HELPER_SECT.Define_Column) Column(#GDCL_5);
Invoke Method(#HELPER_SECT.Define_Column) Column(#GDCL_6);
Invoke Method(#HELPER_SECT.Define_Column) Column(#GDCL_7);
Invoke Method(#HELPER_SECT.Define_Column) Column(#GDCL_8);
;
* Tell the employee grid helper about the department grid and its columns.;
;
Invoke Method(#HELPER_EMPNO.Define_grid) Form(#Com_Owner) Grid(#emp_grid);
Invoke Method(#HELPER_EMPNO.Define_Column) Column(#GDCL_9);
Invoke Method(#HELPER_EMPNO.Define_Column) Column(#GDCL_10);
Invoke Method(#HELPER_EMPNO.Define_Column) Column(#GDCL_11);
Invoke Method(#HELPER_EMPNO.Define_Column) Column(#GDCL_12);
Invoke Method(#HELPER_EMPNO.Define_Column) Column(#GDCL_13);
Invoke Method(#HELPER_EMPNO.Define_Column) Column(#GDCL_14);
Invoke Method(#HELPER_EMPNO.Define_Column) Column(#GDCL_15);
Invoke Method(#HELPER_EMPNO.Define_Column) Column(#GDCL_16);
;
* Fill the grids from the database using the same code as in form S_199FA.;
;
Group_By Name(#DEPT_FLDS) Fields(#DEPTMENT #DEPTDESC);
* Read Departments and add to the Department grid.;
Select Fields(#DEPT_FLDS) From_File(DEPTAB);
Add_Entry To_List(#DEPT_GRID);
Endselect;
;
Group_By Name(#SECT_FLDS) Fields(#SECDESC #SECADDR1 #SECADDR2 #SECADDR3);
* Read Sections and add to the Section grid.;
Select Fields(#SECT_FLDS) From_File(SECTAB);
Add_Entry To_List(#SECT_GRID);
Endselect;
;
Group_By Name(#EMPN_FLDS) Fields(#SURNAME #GIVENAME #ADDRESS1 #ADDRESS2 #ADDRESS3 #POSTCODE #PHONEHME #PHONEBUS);
* Read Employees and add to the Employee grid.;
Select Fields(*ALL) From_File(PSLMST);
Use Builtin(TCONCAT) With_Args(#SURNAME ', ' #GIVENAME) To_Get(#FULLNAME);
Add_Entry To_List(#EMP_GRID);
Endselect;
;
Endroutine;
;
End_Com