• Form中获取数据源及扩展方法中获取变量


    1.通过FormControl控件获取Form中的数据源

    获取数据源的主要方法:Form  formRun= sender.FormRun(); fromRun.datasourse('表名');

    可参考以下例子中的代码

        [FormControlEventHandler(formControlStr(BOMTable, BOMVersion_ItemId), FormControlEventType::Modified)]
        public static void BOMVersion_ItemId_OnModified(FormControl sender, FormControlEventArgs e)
        {
           
            BOMTable        bomTable;
            Name            itemName;
            FormRun         formRun     = sender.formRun();     
            FormObjectSet   dateSource  = formRun.dataSource(); 
            BOMVersion      bomVersion  = dateSource.cursor();
            FormDataSource  bomTable_ds = formRun.dataSource('BOMTable');
            //FormDataSource  bomTable_ds = formRun.dataSource(tableNum(BOMTable));//界面报错:未将对象引用设置到对象的实例
    
            bomTable    =   bomVersion.bomTable();
            itemName    =   InventTable::find(bomVersion.ItemId).itemName();
    
            //更新物料清单的名称
            ttsbegin;
            bomTable.selectForUpdate(true);
            bomTable.Name   = itemName;
            bomTable.doUpdate();
            ttscommit;
    
            bomTable_ds.reread();       //数据库取,这里从数据库取到刷新就可以
            bomTable_ds.research(true); //数据源取
        }

    2.根据控件FormControl,找到其他的控件

     [FormControlEventHandler(formControlStr(EcoResProductCreate, ItemCategroyType), FormControlEventType::Modified)]
        public static void ItemCategroyType_OnModified(FormControl sender, FormControlEventArgs e)
        {
            ItemCategroyType         itemCategroyType;
            FormComboBoxControl   comboxCategroyType;
            FormRun                     element = sender.formRun();//获取到FormRun
            FormStringControl strcontrol;
            comboxCategroyType =  element.design().controlName(formControlStr(EcoResProductCreate, ItemCategroyType)) as FormComboBoxControl;
            itemCategroyType = comboxCategroyType.selection();//获取选到的值
    
             strcontrol =  element.design().controlName(formControlStr(EcoResProductCreate, ItemCategoryName)) as FormStringControl;//其他控件
                strcontrol.mandatory(true);
                strcontrol.text("");
                strcontrol =  element.design().controlName(formControlStr(EcoResProductCreate, ItemBrandID)) as FormStringControl;
                strcontrol.mandatory(true);
                strcontrol.allowEdit(true);
                strcontrol.text("");
                strcontrol =  element.design().controlName(formControlStr(EcoResProductCreate, ProductLineID)) as FormStringControl;
                strcontrol.mandatory(true); 
    }   

    3.根据Form中某个数据源的触发事件获取FormRun

    fromRun.datasourse('表名');

    [PostHandlerFor(formStr(EcoResProductCreate), formMethodStr(EcoResProductCreate, write))]
        public static void EcoResProductCreate_Post_write(XppPrePostArgs args)
        {
            FormRun element = args.getThis();
        
        }
     

    4.扩展表方法中获取当前表中记录  args.getThis()

     [PostHandlerFor(tableStr(CustTable), tableMethodStr(CustTable, insert))]
        public static void CustTable_Post_insert(XppPrePostArgs args)
        {        
           
            CustTable                           custTable;
                       
            custTable = args.getThis();
        }
    

    5.扩展的类方法中,获取源方法中的变量:this.变量名

     protected void updateInventory(InventMovement _inventMovement)
        {
            InventSerial        inventSerial;
            InventDim           inventDim;
    
            next updateInventory(_inventMovement);
    
            if(this.custPackingSlipTrans)//获取到源方法的表变量名
            {
                inventDim   = this.custPackingSlipTrans.inventDim();
            }
        }
        

    6.Form数据源中的触发事件中获取当前记录:sender.cursor();

    [ExtensionOf(formstr(OMOperatingUnit))]
    final class OMOperatingUnit_Extension
    {        
        [FormDataSourceEventHandler(formDataSourceStr(OMOperatingUnit, OMOperatingUnit), FormDataSourceEventType::Activated)]
        public static void OMOperatingUnit_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)
        {                 
            OMOperatingUnit operatingUnit = sender.cursor();//获取当前记录
            FormControl deptCategoryControl = sender.formRun().design().controlName(formControlStr(OMOperatingUnit, OMOperatingUnit_DeptCategoryId));
    
            deptCategoryControl.visible(operatingUnit.OMOperatingUnitType == OMOperatingUnitType::OMDepartment);
        }
    
    }

     7.事件

    [PostHandlerFor(classStr(EcoResProductReleaseManager), methodStr(EcoResProductReleaseManager, release))]
    
    public static void EcoResProductReleaseManager_Post_release(XppPrePostArgs args){
    
         EcoResProductReleaseManager releaseMgr;
    
        //获取类
    
        releaseMgr     = args.getThis();
    
       //类中方法调用
    
       ItemId itemId  = releaseMgr.parmItemId();
    
       //获取当前方法的参数
    
        boolean itemCreation = args.getArg("_isCreation");
    
    }

    8.Form下的方法

     [PostHandlerFor(formStr(VendEditInvoice), formMethodStr(VendEditInvoice, run))]
        public static void VendEditInvoice_Post_run(XppPrePostArgs args)
        {
            PurchAgreementHeader    agreementHeader;
            PurchTable              purchTable;
            FormRun                 formRun = args.getThis();
            VendInvoiceInfoTable    vendInvoiceInfoTable;
    
            vendInvoiceInfoTable  = formRun.dataSource(formDataSourceStr(VendEditInvoice ,VendInvoiceInfoTable )).cursor();
            purchTable  = vendInvoiceInfoTable.purchTable();
    
    
        }

     9.Form中控制按钮的可编辑性:

      

    [
    ExtensionOf(classstr(LedgerJournalFormTrans_Payment))
    ]
    //付款日记账名称需要验证XX,则生成付款按钮不可用--sunny add
    final class LedgerJournalFormTrans_Payment_Extension
    {
        public void enableButtonsActive()
        {
            FormFunctionButtonControl   ctrlCreatePaymentButton;
            LedgerJournalName           ledgerJournalName;
            LedgerJournalTable          ledgerJournalTable = ledgerJournalEngine.parmLedgerJournalTable();
    
            next    enableButtonsActive();
            switch (ledgerJournalTable.JournalType)
            {
                case LedgerJournalType::Payment:
                    ledgerJournalName = LedgerJournalName::find(LedgerJournalTable.JournalName);
                    if(ledgerJournalName.ApproveStatus == NoYes::Yes && LedgerJournalTable.ApproveStatus != ApproveType::Approve)
                    {   
                        ctrlCreatePaymentButton = this.ctrlCreatePaymentButton;
                        ctrlCreatePaymentButton.enabled(false);
                    }    
            }
        }
    
    }
     

      也可参考这位大师的分享: https://blog.csdn.net/mahailiang/article/details/80080209

  • 相关阅读:
    java Semaphore的介绍和使用
    java CyclicBarrier的介绍和使用
    java CountDownLatch 使用介绍
    android模拟器不能上网设置
    计算几何题集
    BZOJ1004: [HNOI2008]Cards
    BZOJ1029: [JSOI2007]建筑抢修
    BZOJ1037: [ZJOI2008]生日聚会Party
    BZOJ1083: [SCOI2005]繁忙的都市
    Java开发笔记(一百一十四)利用Socket传输文本消息
  • 原文地址:https://www.cnblogs.com/sunny-technology/p/9318438.html
Copyright © 2020-2023  润新知