【问题标题】:How can I skip base logic in SOLine_RowUpdated event如何在 SOLine_RowUpdated 事件中跳过基本逻辑
【发布时间】:2020-10-19 17:06:56
【问题描述】:

我在 SOLine_RowUpdated 事件中有一个自定义代码,我的代码工作正常,这就是我所需要的,但是当我最终在 SOLine.curyUnitPrice 字段上获得预期值时,基本事件或基本逻辑会更改该值。

我想知道如何跳过基本事件或基本逻辑,以使我的值不会改变。

这是我的 SOOrderEntry_Extension 图:

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using PX.Common;
using PX.Data;
using PX.Objects.AP;
using PX.Objects.AR;
using PX.Objects.CA;
using PX.Objects.CM;
using PX.Objects.CR;
using PX.Objects.CS;
using PX.Objects.DR;
using PX.Objects.EP;
using PX.Objects.GL;
using PX.Objects.IN;
using PX.Objects.PM;
using PX.Objects.PO;
using PX.Objects.TX;
using POLine = PX.Objects.PO.POLine;
using POOrder = PX.Objects.PO.POOrder;
using System.Threading.Tasks;
using PX.CarrierService;
using CRLocation = PX.Objects.CR.Standalone.Location;
using PX.Objects.AR.CCPaymentProcessing;
using PX.Objects.AR.CCPaymentProcessing.Common;
using PX.Objects.AR.CCPaymentProcessing.Helpers;
using PX.Objects.AR.CCPaymentProcessing.Interfaces;
using ARRegisterAlias = PX.Objects.AR.Standalone.ARRegisterAlias;
using PX.Objects.AR.MigrationMode;
using PX.Objects.Common;
using PX.Objects.Common.Discount;
using PX.Objects.Common.Extensions;
using PX.Objects.IN.Overrides.INDocumentRelease;
using PX.CS.Contracts.Interfaces;
using Message = PX.CarrierService.Message;
using PX.TaxProvider;
using PX.Data.DependencyInjection;
using PX.LicensePolicy;
using PX.Objects.Extensions.PaymentTransaction;
using PX.Objects.SO.GraphExtensions.CarrierRates;
using PX.Objects.Common.Bql;
using PX.Objects;
using PX.Objects.SO;

namespace PX.Objects.SO
{
  public class SOOrderEntry_Extension : PXGraphExtension<SOOrderEntry>
  {
    #region Event Handlers

    protected void SOLine_RowUpdated(PXCache cache, PXRowUpdatedEventArgs e)
    {
        SOLine row = (SOLine)e.Row;

        if (row == null)
        {
            return;
        }

        if (row.SubItemID == null) 
        {
            row.CuryUnitPrice = (decimal?) 0.01;
            return;
        }

        if (row.SubItemID != null)
        {
            if (row.SiteID == null)
            {
                row.CuryUnitPrice = (decimal?) 0.01;
                return;
            }
            
            if (row.OrderQty > 0)
            {
                    return;
            }
            else 
            {
                    string cadena = "MAIN";
                    Location location = PXSelect<Location,
                                                Where<Location.bAccountID, Equal<Required<Location.bAccountID>>,
                                                  And<Location.locationCD, Equal<Required<Location.locationCD>>>
                                                >>.Select(Base, row.CustomerID, cadena);


                  ARSalesPrice salesprice = PXSelect<ARSalesPrice,
                                                    Where<ARSalesPrice.custPriceClassID, Equal<Required<ARSalesPrice.custPriceClassID>>,
                                                        And<ARSalesPrice.inventoryID, Equal<Required<ARSalesPrice.inventoryID>>, 
                                                        And<ARSalesPriceExt.usrSubItemID, Equal<Required<ARSalesPriceExt.usrSubItemID>>,
                                                            And<ARSalesPrice.breakQty, LessEqual<Required<ARSalesPrice.breakQty>>
                                                            >
                                                          >
                                                       >
                                                    >,
                                                    OrderBy<Desc<ARSalesPrice.breakQty>>
                                                >.Select(Base, location.CPriceClassID, row.InventoryID, row.SubItemID, row.Qty);
    
                  if(salesprice == null)
                  {
                      ARSalesPrice salesprice2 = PXSelect<ARSalesPrice,
                                                          Where<ARSalesPrice.custPriceClassID, Equal<Required<ARSalesPrice.custPriceClassID>>,
                                                              And<ARSalesPrice.inventoryID, Equal<Required<ARSalesPrice.inventoryID>>,
                                                              And<ARSalesPriceExt.usrSubItemID, Equal<Required<ARSalesPriceExt.usrSubItemID>>
                                                              >
                                                            >
                                                          >,
                                                          OrderBy<Asc<ARSalesPrice.breakQty>>
                                                      >.Select(Base, location.CPriceClassID, row.InventoryID, row.SubItemID);
                    
                      if (salesprice2 != null)
                      {
                          cache.SetValue<SOLine.curyUnitPrice>(row, salesprice2.SalesPrice);
                      }
                      else
                      {
                          row.CuryUnitPrice = (decimal?) 0.01;
                      }  
                  }
                  else
                  {
                      cache.SetValue<SOLine.curyUnitPrice>(row, salesprice.SalesPrice);
                  }
            }
        }
    }
    #endregion
  }
}

你能帮我解决这个问题吗?

【问题讨论】:

    标签: acumatica acumatica-kb


    【解决方案1】:

    您添加了一个事件而不是覆盖它。您需要在覆盖基本事件时指定适当的委托。然后你可以调用那个基本事件,或者在你的情况下,不是。

    using PX.Data;
    
    namespace PX.Objects.SO
    {
        public class SOOrderEntry_Extension : PXGraphExtension<SOOrderEntry>
        {
            #region Event Handlers
    
            protected void SOLine_RowUpdated(PXCache cache, PXRowUpdatedEventArgs e, PXRowUpdated baseEvent)
            {
                baseEvent.Invoke(cache, e);  //  <- comment out to prevent calling the base event
    
                // Insert my custom code here
            }
            #endregion
        }
    }
    

    【讨论】:

    • 你好,我已经这样做了,但我仍然有同样的问题,我没有调用基本事件。 @布莱恩史蒂文斯
    • 您发布的内容不使用 PXRowUpdated 作为代表。如果不指定 PXRowUpdated 委托,则不会覆盖基本事件,因此它将始终触发。您需要包含委托以将您的事件处理程序转换为覆盖。
    • 也许我没有解释自己,在你回答后我按照你的建议,但我仍然有同样的问题。目前这是我的代码的一部分:protected void SOLine_RowUpdated(PXCache cache, PXRowUpdatedEventArgs e, PXRowUpdated InvokeBaseHandler) { /*if(InvokeBaseHandler != null) InvokeBaseHandler(cache, e);*/ var row = (SOLine)e.Row; if (row == null) { return; } &lt;- more code below@BrianStevens
    • 明白了。在注释中注释掉该行后,基础不应触发。你能解释一下你看到的基地正在开火吗?另外,您确定您的图形扩展已发布到项目中吗?我的系统管理员在上周发布之前更新了我的定制项目(来自生产)中的文件,所以他在项目中丢失了我的 DLL。您可以使用 PXTrace.WriteInformation("you are here"); 进行确认在您的事件处理程序中,以确保您的覆盖实际上正在触发。
    • 经过深入调查,我发现了更改 CuryUnitPrice 字段值的事件处理程序,该事件称为“SOLine_OrderQty_FieldUpdated”,我能够覆盖此事件并放置适当的自定义和所有内容工作正常。感谢您的建议。 @布莱恩史蒂文斯
    猜你喜欢
    • 1970-01-01
    • 2022-10-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-06
    相关资源
    最近更新 更多