Form S_202FUP

LANSA

Form S_202FUP
* ===================================================================;
*;
* Component : S_202FUP;
* Type : Form;
* Ancestor : PRIM_FORM (Primitive Form);
*;
* Description : Product Updater View;
*;
* This reusable component represents the updater "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 Updater') Formstyle(OwnedChild) Height(168) Left(673) Top(151) 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) Tabposition(2) Top(34) Visualstyle(#VS_NORM) 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) Tabposition(3) Top(56) Visualstyle(#VS_NORM) 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) Tabposition(4) Top(80) Visualstyle(#VS_NORM) Width(209);
Define_Com Class(#PRIM_FWLI) Name(#FWLI_4) Manage(#S_202QTY) Parent(#FWLM_1);
Define_Com Class(#PRIM_PHBN) Name(#UPDATE_BUTTON) Buttondefault(True) Caption('Update Product') Displayposition(5) Enabled(False) Left(244) Parent(#COM_OWNER) Tabposition(5) Top(80) Width(93);
Define_Com Class(#PRIM_FWLI) Name(#FWLI_5) Manage(#UPDATE_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);
;
* The condition under which the data input is valid for updating;
;
Def_Cond Name(*valid) Cond('(#S_202NUm > 0) and (#S_202Des *ne *Blanks) and (#S_202Prc > 0) ');
;
* 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 of the product number by disabling the update button;
* clearing all exsiting details and asking the controller to fetch;
* the details of the product;
* ===============================================================================;
;
Evtroutine Handling(#S_202NUM.Changed) Options(*NOCLEARMESSAGES *NOCLEARERRORS);
Set Com(#Update_Button) Enabled(False);
Change Field(#S_202Des #S_202Qty #S_202Prc) To(*Null);
Invoke Method(#Product_Controller.Fetch) Number(#S_202Num) Requestedby(*Component);
Endroutine;
;
* ===============================================================================;
* Handle a change to the description, price and quantity by setting the;
* update button's enablement according to the validity of the data. If;
* the data is invalid you cannot click on the update button.;
* ===============================================================================;
;
Evtroutine Handling(#S_202DES.Changed #S_202PRC.Changed #S_202QTY.Changed) Options(*NOCLEARMESSAGES *NOCLEARERRORS);
Set Com(#Update_Button) Enabled(*Valid);
Endroutine;
;
* ===============================================================================;
* If a product is found or created with a number matching the number;
* currently being displayed, display the details and enable the;
* update 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(#Update_Button) Enabled(True);
Endif;
Endroutine;
;
* ===============================================================================;
* Handle the update button;
* ===============================================================================;
;
Evtroutine Handling(#Update_BUTTON.Click);
Invoke Method(#Product_Controller.Update) Number(#S_202NUM) Description(#S_202DES) Price(#S_202PRC) Available(#S_202QTY);
Endroutine;
;
* ===============================================================================;
* If a product is destroyed with a number matching the one currently being;
* show, clear all displayed details, disable the update 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(#Update_Button) Enabled(False);
Invoke Method(#S_202Num.SetFocus);
Endif;
Endroutine;
;
End_Com;