Acumatica GI定制 - 添加总行列

时间:2017-08-25 13:47:49

标签: acumatica

在为销售订单屏幕创建GI时,我想在文档详细信息选项卡中显示总行数。谁能建议一种方法来开始实现这个?

在GI中包含自定义字段后,它不会使用数据填充列。

打印行计数的代码如下所示,这也在Adding custom button in acumatica

中讨论
public void SOOrder_UsrTotalTransactions_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
  {
      e.ReturnValue = GetTotalTransactions(sender);
  }

  // Update values
  public void SOLine_RowDeleted(PXCache sender, PXRowDeletedEventArgs e)
  {
      UpdateTotals(sender, e.Row as SOOrder,  true);
  }

  public void SOLine_RowInserted(PXCache sender, PXRowInsertedEventArgs e)
  {
      UpdateTotals(sender, e.Row as SOOrder,  true);
}

  public void SOLine_OrderQty_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
  {
      UpdateTotals(sender, e.Row as SOOrder, false);
  }

  public void UpdateTotals(PXCache sender, SOOrder soOrder, bool isUpdateTranCount)
  {
      // Get SOOrder DAC extension
      if (soOrder != null)
      {
          SOOrderExt soOrderExt = sender.GetExtension<SOOrderExt>(soOrder);

          if (soOrderExt != null)
          {             
               if (isUpdateTranCount)
               {

                   sender.SetValueExt<SOOrderExt.usrTotalTransactions>(soOrder, GetTotalTransactions(sender));

               } 
          }
      }
  }



  public int? GetTotalTransactions(PXCache sender)
  {
      return Base.Transactions.Select().Count();
  }
 }
}

DAC代码是: [PXDBInt] [PXUIField(DisplayName =“Total Lines”,Enabled = false)]

1 个答案:

答案 0 :(得分:0)

如果您尝试设置值,我会尝试这样的简化版本...

namespace PX.Objects.SO
{
    public class SOOrderEntry_Extension : PXGraphExtension<SOOrderEntry>
    {
        public void SOLine_RowDeleted(PXCache sender, PXRowDeletedEventArgs e)
        {
            UpdateTotals(sender, e.Row as SOOrder);
        }

        public void SOLine_RowInserted(PXCache sender, PXRowInsertedEventArgs e)
        {
            UpdateTotals(sender, e.Row as SOOrder);
        }

        public void UpdateTotals(PXCache sender, SOOrder soOrder)
        {
            if (soOrder != null)
            {
                SOOrderExt soOrderExt = sender.GetExtension<SOOrderExt>(soOrder);

                if (soOrderExt != null)
                {
                    sender.SetValueExt<SOOrderExt.usrRowCount>(soOrder, GetRowCount());
                }
            }
        }

        public int GetRowCount()
        {
            return Base.Transactions?.Select().Count() ?? 0;
        }
    }
}

您可以使用FieldSelecting设置未绑定的字段值。因为您的字段已绑定,所以您不希望为您的示例调用fieldselecting。