• 转到主表窗口


    今天我向大家介绍一种方法,用X++写一个方法就可以完成上述功能。
    1、在窗体下写下如下两个方法:

     1 1 2 
     3 public void gotoMainTable(Object ctrl, boolean isParmObject=false, container refFrom=connull())
     4 {
     5     TableName       tableName;
     6     FormName        formName;
     7     int             tableID;
     8     int             fieldID;
     9     int             i, selectedMenu;
    10     Args            args;
    11     FormRun         formrun;
    12     QueryBuildDataSource qbs;
    13     FormDataSource  formDataSource;
    14     PopupMenu       master     = new PopupMenu(element.hWnd());
    15     int             masterItem = master.insertItem('@SYS7706');
    16     int             breakItem  = master.insertBreak();
    17     int             CancelItem = master.insertItem('@SYS50163');
    18     ;
    19     selectedMenu = master.draw();
    20     if(refFrom!=connull())
    21     {
    22         switch(selectedMenu)
    23         {
    24             case -1: break;
    25             case masterItem:
    26                 formName = conpeek(refFrom, 1);
    27                 tableID = conpeek(refFrom, 2);
    28                 fieldID = conpeek(refFrom, 3);
    29                 tableName = tableid2name(tableID);
    30                 if(formName && TreeNode::findNode('\\Forms\\'+formName))
    31                 {
    32                     args = new args(formName);
    33                     if(isParmObject)args.parmObject(ctrl);
    34                     args.parm("showALL");
    35                     formrun = ClassFactory.FormRunClass(args);
    36                     formrun.init();
    37                     formDataSource = SysFormDataSource::findDataSource(formRun, tableID);
    38                     qbs = formDataSource.query().dataSourceTable(tableID);
    39                     qbs.addRange(fieldID).value(ctrl.text());
    40                     formrun.run();
    41                     formrun.detach();
    42                 }
    43                 break;
    44         }
    45     }
    46 }
    47 248 public container getJournalType(HnTransType _transType)
    49 {
    50     container refFrom;
    51     ;
    52     switch(_transType)
    53     {
    54         case HnTransType::Purch :
    55             refFrom=[formstr(PurchTable),tableNum(PurchTable), fieldNum(PurchTable, PurchId)];
    56             break;
    57         case HnTransType::Sales :
    58             refFrom=[formstr(SalesTable),tableNum(SalesTable), fieldNum(SalesTable, SalesId)];
    59             break;
    60         case HnTransType::Prod :
    61             refFrom=[formstr(ProdTable),tableNum(ProdTable), fieldNum(ProdTable, ProdId)];
    62             break;
    63         default :
    64             refFrom=connull();
    65             break;
    66     }
    67     return refFrom;
    68 }

    2、重载控件的 context方法。

    1 public void context()
    2 {
    3     ;
    4     element.gotoMainTable(this,false,element.getJournalType(HnTransTable.TransType));
    5 }

      摘自秋毫Hank

  • 相关阅读:
    jar命令
    python的实例方法,类方法和静态方法区别
    修饰器学习
    人生感悟的句子
    html+css学习
    url编码
    正向代理和反向代理
    web基础
    dns解析域名过程
    关于csrf
  • 原文地址:https://www.cnblogs.com/Jinnchu/p/2663583.html
Copyright © 2020-2023  润新知