Form S_202FBR

LANSA

Form S_202FBR
* ===================================================================;
*;
* Component : S_202FBR;
* Type : Form;
* Ancestor : PRIM_FORM (Primitive Form);
*;
* Description : Product Browser View;
*;
* This reusable component represents the browser "view" of a;
* "Product" for this simple MVC example.;
*;
* 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 Caption('Product Browser') Height(222) Layoutmanager(#ATLM_1) Left(450) Top(25) Width(459);
Define_Com Class(#PRIM_ATLM) Name(#ATLM_1);
Define_Com Class(#PRIM_LTVW) Name(#PROD_LIST) Displayposition(1) Fullrowselect(True) Height(195) Left(0) Parent(#COM_OWNER) Tabposition(1) Top(0) Width(451);
Define_Com Class(#PRIM_ATLI) Name(#ATLI_1) Attachment(Center) Manage(#PROD_LIST) Parent(#ATLM_1);
Define_Com Class(#PRIM_LVCL) Name(#LVCL_1) Displayposition(1) Parent(#PROD_LIST) Sortposition(1) Source(#S_202NUM) Width(20);
Define_Com Class(#PRIM_LVCL) Name(#LVCL_2) Displayposition(2) Parent(#PROD_LIST) Source(#S_202DES) Width(33);
Define_Com Class(#PRIM_LVCL) Name(#LVCL_3) Displayposition(3) Parent(#PROD_LIST) Source(#S_202PRC) Width(19);
Define_Com Class(#PRIM_LVCL) Name(#LVCL_4) Displayposition(4) Parent(#PROD_LIST) Source(#S_202QTY) Width(20) Widthtype(Remainder);
;
* Define an independent instance of the product controller;
;
Define_Com Class(#S_202RCO) Name(#PRODUCT_CONTROLLER);
;
* Define a reference to the shared product view;
;
Define_Com Class(#S_202RMO) Name(#PRODUCT_VIEW) Reference(*Dynamic);
;
* Define the additional product creator, deleter and updater forms;
;
Define_Com Class(#S_202FCR) Name(#PRODUCT_CREATOR);
Define_Com Class(#S_202FDL) Name(#PRODUCT_DELETER);
Define_Com Class(#S_202FUP) Name(#PRODUCT_UPDATER);
;
* ===============================================================================;
* At initialization, set up details of the shared product model and cause the;
* product creator, deleter and updater forms to show. Finall yask the product;
* controller to select details of all existing products;
* ===============================================================================;
;
Evtroutine Handling(#COM_OWNER.Initialize) Options(*NOCLEARMESSAGES *NOCLEARERRORS);
;
Set_Ref Com(#Product_View) To(#Product_Controller.ProductModel);
;
Invoke Method(#Product_Creator.ShowForm);
Invoke Method(#Product_Deleter.ShowForm);
Invoke Method(#Product_Updater.ShowForm);
;
Invoke Method(#Product_Controller.Select) Requestedby(*Component);
;
Endroutine;
;
* ===============================================================================;
* Handle a product found notification by checking the name of the component;
* that made the request. If the compone twas this component then add details;
* of the product to the visible list of products;
* ===============================================================================;
;
Evtroutine Handling(#PRODUCT_VIEW.ProductFound) Number(#CS_202NUM) Description(#CS_202DES) Price(#CS_202PRC) Available(#CS_202QTY) Requestedby(#RequestedBy);
;
If Cond('#RequestedBy.Value = *Component');
Change Field(#S_202NUM) To(#CS_202Num.Value);
Change Field(#S_202DES) To(#CS_202Des.Value);
Change Field(#S_202PRC) To(#CS_202Prc.Value);
Change Field(#S_202QTY) To(#CS_202Qty.Value);
Add_Entry To_List(#Prod_List);
Endif;
;
Endroutine;
;
* ===============================================================================;
* If a new product is created, add its details to the visible product list;
* ===============================================================================;
;
Evtroutine Handling(#PRODUCT_VIEW.ProductCreated) Number(#CS_202NUM) Description(#CS_202DES) Price(#CS_202PRC) Available(#CS_202QTY);
;
Change Field(#S_202NUM) To(#CS_202Num.Value);
Change Field(#S_202DES) To(#CS_202Des.Value);
Change Field(#S_202PRC) To(#CS_202Prc.Value);
Change Field(#S_202QTY) To(#CS_202Qty.Value);
Add_Entry To_List(#Prod_List);
;
Endroutine;
;
* ===============================================================================;
* If a product was updated, update its details in the visible product list;
* ===============================================================================;
;
Evtroutine Handling(#PRODUCT_VIEW.ProductUpdated) Number(#CS_202NUM) Description(#CS_202DES) Price(#CS_202PRC) Available(#CS_202QTY);
;
Selectlist Named(#Prod_List);
Continue If('#S_202Num *ne #CS_202Num.Value');
Change Field(#S_202DES) To(#CS_202Des.Value);
Change Field(#S_202PRC) To(#CS_202Prc.Value);
Change Field(#S_202QTY) To(#CS_202Qty.Value);
Upd_Entry In_List(#Prod_List);
Leave;
Endselect;
;
Endroutine;
;
* ===============================================================================;
* If a product was destroyed, delete its details from the visible product list;
* ===============================================================================;
;
Evtroutine Handling(#PRODUCT_VIEW.ProductDestroyed) Number(#CS_202NUM);
;
Selectlist Named(#Prod_List);
Continue If('#S_202Num *ne #CS_202Num.Value');
Dlt_Entry From_List(#Prod_List);
Leave;
Endselect;
;
Endroutine;
;
End_Com;