Acumatica以编程方式从表中获取值的总和 [英] Acumatica Programmatically getting sum of values from table

查看:89
本文介绍了Acumatica以编程方式从表中获取值的总和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的FieldDefaulting事件中,我有以下代码

  var row =(PMProject)e.Row; 
十进制? dec = 0;
foreach(ProjectLines.Select(this)中的atcProjectLinesTable tb)
{
dec + = tb.UnPrice;
}
抛出new PXException( Total is + dec);
e.NewValue = dec;

我在Visual Studio中收到无法访问的代码警告,并且在发布项目时字段值为零。



解决方案

Visual Studio报告由于在FieldDefaulting事件处理程序中间抛出PXException而导致的代码无法访问:

  throw new PXException(总计为 + dec); 

要分析中间值,您可以看一下PXTrace类。以下示例显示了如何在Acumatica中写入销售订单描述的跟踪值生成值:

 公共类SOOrderEntryExt: 
{
public void SOOrder_OrderDesc_FieldDefaulting(PXCache sender,PXFieldDefaultingEventArgs e)
{
var testDescr =测试订单说明;
PXTrace.WriteInformation(string.Format(销售订单说明:{0},testDescr));
e.NewValue = testDescr;
}
}


In my FieldDefaulting event I have the below code

   var row = (PMProject)e.Row;
     decimal? dec = 0;
        foreach (atcProjectLinesTable tb in ProjectLines.Select(this))
        {
            dec += tb.UnPrice;
        }
        throw new PXException("Total is "+dec);
          e.NewValue = dec;

Im getting an unreachable code warning in Visual Studio and when I publish my project the fields value is zero.

解决方案

Visual Studio reports about unreachable code due to PXException thrown in the middle of your FieldDefaulting event handler:

throw new PXException("Total is "+dec);

To profile intermediate values, you might take a look at the PXTrace class. The sample below shows how to write in Acumatica Trace value generated value for Sales Order Description:

public class SOOrderEntryExt : PXGraphExtension<SOOrderEntry>
{
    public void SOOrder_OrderDesc_FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e)
    {
        var testDescr = "Test Order Description";
        PXTrace.WriteInformation(string.Format("Sales Order Description: {0}", testDescr));
        e.NewValue = testDescr;
    }
}

这篇关于Acumatica以编程方式从表中获取值的总和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆