在Acumatica中添加自定义按钮 [英] Adding custom button in acumatica

查看:92
本文介绍了在Acumatica中添加自定义按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Acumatica的新手,正在尝试探索一些自定义功能。

I am new to Acumatica and trying to explore some customization features.

我在销售订单屏幕上创建了2个标签-CstLabeltotal和CstLabelqty

I have created 2 labels on Sales Order screen - CstLabeltotal and CstLabelqty

我正在尝试找出一种方法,其中总标签将在文档详细信息选项卡中显示交易总数(第一列),而数量标签则显示文档详细信息选项卡(第9列)总数)

I am trying to figure out a way where besides the total label will show total number transactions(1st column) from the Document Details tab and Quantity label shows total quantity from the Document Details tab(9th Column)

有人可以帮我吗?

推荐答案

使用自定义未绑定字段(NonPersistedField)作为占位符以显示总计。

Use custom unbound fields (NonPersistedField) as placeholders to display the totals.

首先将这些自定义字段添加到SOOrder DAC扩展中:

自定义总数量字段:

总交易量自定义字段:

创建SOOrderEntry图形扩展以计算/更新总计:

将自定义字段添加到销售订单屏幕,无需使用标签控件,DAC DisplayName属性将用作字段标签:

找到包含所需详细数据的基础图Transactions DataView用于计算总数(仅供参考):

在您的SOOrderEntry扩展使用来自基础图的Transactions DataView来计算总数:

namespace PX.Objects.SO
{
  public class SOOrderEntry_Extension:PXGraphExtension<SOOrderEntry>
  {
      // Initialize unbound values in FieldSelecting events
      public void SOOrder_UsrTotalQty_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
      {
          e.ReturnValue = GetTotalQty(sender);
      }

      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, true);
      }

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

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

      public void UpdateTotals(PXCache sender, SOOrder soOrder, bool isUpdateQty, bool isUpdateTranCount)
      {
          // Get SOOrder DAC extension
          if (soOrder != null)
          {
              SOOrderExt soOrderExt = sender.GetExtension<SOOrderExt>(soOrder);
              
              if (soOrderExt != null)
              {
                   // Update values
                   if (isUpdateQty)
                   {
                       soOrderExt.UsrTotalQty = GetTotalQty(sender);
                   }
               
                   if (isUpdateTranCount)
                   {
                       soOrderExt.UsrTotalTransactions= GetTotalTransactions(sender);
                   } 
              }
          }
      }
            
      // Compute totals
      public decimal? GetTotalQty(PXCache sender)
      {
          decimal? totalQty = 0M;

          // Compute quantity from SOOrderEntry base graph Transactions DataView
          foreach (SOLine soLine in Base.Transactions.Select())
          {
              totalQty += soLine.OrderQty;
          }

          return totalQty;
      }

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

显示总计在销售订单屏幕中,它们将在插入/删除交易行和修改订单数量时更新:

这篇关于在Acumatica中添加自定义按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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