zoukankan      html  css  js  c++  java
  • Save the users last values in a dialog

    Had a case then I needed to do a modification to a report with a custom dialog where the user could make some changes to the information that teh report would show.

    I needed the same behavioure as you get from a RunBase class but I needed to use it in a report. Tha solution was to use the xSysLastValue class.

    1 client server public static container getValue(CompanyId _company,
    2 userId _userId, UtilElementType _type, identifiername _elementName
    3 [, identifiername _designName])

    The usage is pretty simple, the parameters is used to identify the correct data. One thing to remember is that if you use this method to retrieve the user data for a dialog in a report for example don't use the reports name as _elementName because you can end up with the user data for the report instead.

    To save the data you use the:

     1 client server public static void putValue(container _value, CompanyId _company,
     2 userId _userId, UtilElementType _type, identifiername _elementName
     3 [, identifiername _designName])
     4 
     5 Example: 
     6 
     7 static void SaveLastValues(Args _args)
     8 {
     9   Dialog      _dlg;
    10   DialogGroup _dlgGroup;
    11   DialogField _dlgField1;
    12   DialogField _dlgField2;
    13   container   _dialogValues;
    14   NoYesId     _choice1;
    15   NoYesId     _choice2;
    16   ;
    17 
    18   _dlg = new dialog();
    19 
    20   _dlgGroup  = _dlg.addGroup("Group");
    21   _dlgField1 = _dlg.addField(typeid(NoYesId),"Choice 1");
    22   _dlgField2 = _dlg.addField(typeid(NoYesId),"Choice 2");
    23 
    24   //Get the previouse values
    25   _dialogValues = xSysLastValue::getValue(curExt(), curUserId(), UtilElementType::Job, "SaveLastValue");
    26 
    27   //Check if we have previouse values
    28   if (_dialogValues != conNull())
    29   {
    30     _dlgField1.value(conPeek(_dialogValues, 1));
    31     _dlgField2.value(conPeek(_dialogValues, 2));
    32   }
    33 
    34   if (_dlg.run())
    35   {
    36     //Save the user choices
    37     _dialogValues = conNull();
    38     _dialogValues += _dlgField1.value();
    39     _dialogValues += _dlgField2.value();
    40 
    41     xSysLastValue::putValue(_dialogValues,curExt(),curUserId(),UtilElementType::Job,"SaveLastValue");
    42 
    43     //Do what ever
    44   }
    45 }
  • 相关阅读:
    第九周PSP
    c++的继承方式
    matlab的应用
    beta发布的评论
    本周psp
    历年作品点评
    JSON解析数据
    每周工作量及代码统计(第七周)
    词频统计(WEB)版
    评论alpha发布
  • 原文地址:https://www.cnblogs.com/Jinnchu/p/2659708.html
Copyright © 2011-2022 走看看