Form S_202FDL

LANSA

Form S_202FDL
* ===================================================================;
*;
* Component : S_202FDL;
* Type : Form;
* Ancestor : PRIM_FORM (Primitive Form);
*;
* Description : Product Destroyer View;
*;
* This reusable component represents the destroyer "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 Deleter') Formstyle(OwnedChild) Height(168) Left(378) Top(213) Visualstyle(#VS_NORM) Width(357);
Define_Com Class(#PRIM_FWLM) Name(#FWLM_1) Flowoperation(Center) Margintop(8) Spacing(4) Spacingitems(20);
Define_Com Class(#S_202NUM.Visual) Name(#S_202NUM) Displayposition(1) Height(19) Parent(#COM_OWNER) Tabposition(1) Top(11) Width(224);
Define_Com Class(#PRIM_FWLI) Name(#FWLI_1) Manage(#S_202NUM) Parent(#FWLM_1);
Define_Com Class(#S_202DES.Visual) Name(#S_202DES) Displayposition(2) Height(19) Parent(#COM_OWNER) Readonly(True) Tabposition(2) Tabstop(False) Top(34) Visualstyle(#VS_NOREAD) Width(324);
Define_Com Class(#PRIM_FWLI) Name(#FWLI_2) Manage(#S_202DES) Parent(#FWLM_1);
Define_Com Class(#S_202PRC.Visual) Name(#S_202PRC) Displayposition(3) Height(19) Parent(#COM_OWNER) Readonly(True) Tabposition(3) Tabstop(False) Top(56) Visualstyle(#VS_NOREAD) Width(225);
Define_Com Class(#PRIM_FWLI) Name(#FWLI_3) Manage(#S_202PRC) Parent(#FWLM_1);
Define_Com Class(#S_202QTY.Visual) Name(#S_202QTY) Displayposition(4) Height(19) Parent(#COM_OWNER) Readonly(True) Tabposition(4) Tabstop(False) Top(80) Visualstyle(#VS_NOREAD) Width(209);
Define_Com Class(#PRIM_FWLI) Name(#FWLI_4) Manage(#S_202QTY) Parent(#FWLM_1);
Define_Com Class(#PRIM_PHBN) Name(#DELETE_BUTTON) Buttondefault(True) Caption('Delete Product') Displayposition(5) Enabled(False) Left(244) Parent(#COM_OWNER) Tabposition(5) Top(80);
Define_Com Class(#PRIM_FWLI) Name(#FWLI_5) Manage(#DELETE_BUTTON) Parent(#FWLM_1);
Define_Com Class(#PRIM_STBR) Name(#STBR_1) Displayposition(6) Height(24) Left(0) Messageposition(1) Parent(#COM_OWNER) Tabposition(6) Tabstop(False) Top(117) Width(349);
Define_Com Class(#PRIM_FWLI) Name(#FWLI_6) Manage(#STBR_1) Parent(#FWLM_1);
;
* 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);
;
* ===============================================================================;
* Handle initialization by setting up the reference to the shared product model;
* ===============================================================================;
;
Evtroutine Handling(#COM_OWNER.Initialize) Options(*NOCLEARMESSAGES *NOCLEARERRORS);
Set_Ref Com(#Product_View) To(#Product_Controller.ProductModel);
Endroutine;
;
* ===============================================================================;
* Handle a change to the prodcut number by disabling the delete button, clearing;
* all the details and asking the controller to fetch the product details;
* ===============================================================================;
;
Evtroutine Handling(#S_202NUM.Changed) Options(*NOCLEARMESSAGES *NOCLEARERRORS);
Set Com(#Delete_Button) Enabled(False);
Change Field(#S_202Des #S_202Qty #S_202Prc) To(*Null);
Invoke Method(#Product_Controller.Fetch) Number(#S_202Num) Requestedby(*Component);
Endroutine;
;
* ===============================================================================;
* If a product has been found, created or updated and its product number is the;
* same as the product number currently being displayed on this form, update the;
* panel with the products details and enable the delete button;
* ===============================================================================;
;
Evtroutine Handling(#PRODUCT_VIEW.ProductFound #PRODUCT_VIEW.ProductCreated #PRODUCT_VIEW.ProductUpdated) Number(#CS_202NUM) Description(#CS_202DES) Price(#CS_202PRC) Available(#CS_202QTY);
If Cond('#CS_202Num.Value = #S_202Num');
Change Field(#S_202DES) To(#CS_202Des.Value);
Change Field(#S_202PRC) To(#CS_202Prc.Value);
Change Field(#S_202QTY) To(#CS_202Qty.Value);
Set Com(#Delete_Button) Enabled(True);
Endif;
Endroutine;
;
* ===============================================================================;
* Handle the delete button;
* ===============================================================================;
;
Evtroutine Handling(#Delete_BUTTON.Click);
Invoke Method(#Product_Controller.Delete) Number(#S_202NUM);
Endroutine;
;
* ===============================================================================;
* If a product is destroyed with a number matching the one currently being;
* shown, clear all displayed details, disable the delete button and set;
* entry focus into the product number field.;
* ===============================================================================;
;
Evtroutine Handling(#PRODUCT_VIEW.ProductDestroyed) Number(#CS_202NUM);
If Cond('#CS_202Num = #S_202Num');
Change Field(#S_202Num #S_202Des #S_202Qty #S_202Prc) To(*Null);
Set Com(#Delete_Button) Enabled(False);
Invoke Method(#S_202Num.SetFocus);
Endif;
Endroutine;
;
End_Com;