【问题标题】:Default a grid value from a prior line in Acumatica从 Acumatica 中的前一行默认网格值
【发布时间】:2020-01-20 09:38:33
【问题描述】:

您将如何编写代码以在网格上设置默认值,并使用其上方行中的字段值?

【问题讨论】:

    标签: acumatica


    【解决方案1】:

    一种方法是这样。让我们假设您希望将账单和调整屏幕上的数量默认为前一行中的数量。考虑使用下面的模式。

    public class APInvoiceEntry_Extension : PXGraphExtension<APInvoiceEntry>
    {
        #region Event Handlers
        protected void APTran_Qty_FieldDefaulting(PXCache cache, PXFieldDefaultingEventArgs e)
        {
            var row = (APTran)e.Row;
            if (row == null) return;
    
            // get prior qty and default it here, unless it is already set.
            if (row.Qty == null)
            {
                decimal? priorQty = GetPriorQtyInGrid(row);
                if (priorQty != null)
                {
                    e.NewValue = priorQty;
                }
            }
        }
        #endregion
    
        #region Functions
        public decimal? GetPriorQtyInGrid(APTran currentRow)
        {
            APTran lastline = null;
            foreach (APTran line in Base.Transactions.Select())
            {
                if (currentRow == line)
                {
                    break;
                }
                lastline = line;
            }
    
            if (lastline != null)
                return lastline.Qty;
            else
                return null;
    
        }
        #endregion
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-06-15
      • 1970-01-01
      • 2015-06-21
      • 2021-06-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-28
      相关资源
      最近更新 更多