zoukankan      html  css  js  c++  java
  • 获取Form多条选中记录

    1、通过数据源获取记录,以EmplTable为例。

    1 EMPlTable emp;
    2 ;
    3 
    4 for (emp = EmplTable_ds.getFirst(1); emp; emp = EmplTable_ds.getNext())
    5 {
    6   //do something
    7 }
     1 voidclicked()
     2 {
     3   CustTablecustTable;
     4   ;
     5   for (custTable = CustTable_ds.getFirst(true)?CustTable_ds.getFirst(true):CustTable_ds.cursor();  //从当前记录开始,如果当前记录不是第一条
     6      custTable;
     7      custTable = CustTable_ds.getNext())
     8   {
     9     //dosomethingwithcustTable
    10     info(custTable.accountNum);
    11     custTable_ds.research();
    12   }
    13 }

    2、通过勾选CheckBox,获取选中记录。

    (1)先在Form数据源(表中也可以)中创建Eidt()方法。将选中的记录添加到集合中,返回选中记录。

     1 Edit noYes editMark(noYes _set, PriceDiscTable _PriceDiscTable, noYes _mark)
     2 {
     3     ;
     4 
     5     if (_set)
     6     {
     7         if (_mark)
     8             set_PriceRecid.add(_PriceDiscTable.RecId);  //set_PriceRecid是Set集合,使用前要先实例化
     9         else
    10             set_PriceRecid.remove(_PriceDiscTable.RecId);
    11     }
    12 
    13     return set_PriceRecid.in(_PriceDiscTable.RecId);
    14 }

    (2)在Form的Grid中添加CheckBox,并绑定数据源及方法。

    (3)由于是自定义式,全部选择要添加额外的代码。

     1 void clicked()
     2 {
     3     QueryRun        QR;
     4     PriceDiscTable  m_PriceDiscTable;
     5     ;
     6     if (!b_SelectedAll)
     7     {
     8         QR             = new QueryRun(PriceDiscTable_Q);
     9         set_PriceRecid = new Set(Types::Int64);
    10         while (QR.next())
    11         {
    12             m_PriceDiscTable = QR.get(tablenum(PriceDiscTable));
    13             set_PriceRecid.add(m_PriceDiscTable.RecId);
    14         }
    15         PriceDiscTable_DS.research();
    16         b_SelectedAll = true;
    17     }
    18     else
    19     {
    20         set_PriceRecid = new Set(Types::Int64);
    21         PriceDiscTable_DS.research();
    22         b_SelectedAll = false;
    23     }
    24 }
  • 相关阅读:
    我喜欢的女孩有了男友 :(
    两个月后,我又回来了。
    准备辞职,想看看老板知道我要辞职之后的表情。
    已经交了辞职报告,今天下午跟老板谈一谈。
    上班第十天
    一年了,回来看看。
    上班第十一天
    领到了离职通知单
    对上班失去了兴趣
    还没有拿到回家的火车票,惨了啊。
  • 原文地址:https://www.cnblogs.com/Jinnchu/p/2658713.html
Copyright © 2011-2022 走看看