【问题标题】:where can I find the code for grid Action buttons in acumatica在哪里可以找到 acumatica 中网格操作按钮的代码
【发布时间】:2020-01-20 13:51:23
【问题描述】:

我想查看网格操作按钮背后的代码。假设账单和调整屏幕的网格部分中的按钮标有橙色框。

我想看看按钮后面的代码是如何配置的。 我在哪里可以找到 Acumatica 网站文件夹中的文件或代码?

特别是我想要“添加子合同”按钮后面的代码。

【问题讨论】:

    标签: acumatica


    【解决方案1】:

    按钮/操作的代码看起来像是来自 PX.Objects.CN.Subcontracts.AP.GraphExtensions.ApInvoiceEntryAddSubcontractsExtension (PX.Objects.CN.dll) 中的构建版本

    相关代码片段:

    [PXButton]
        [PXUIField(DisplayName = "Add Subcontracts", FieldClass = "DISTR", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
        public virtual IEnumerable addSubcontracts(PXAdapter adapter)
        {
          this.Base.checkTaxCalcMode();
          if (!this.ShouldAddSubcontracts())
            return adapter.Get();
          this.Base.updateTaxCalcMode();
          return this.addSubcontract(adapter);
        }
    
    [PXButton]
        [PXUIField(DisplayName = "Add Subcontract", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select, Visible = false)]
        public virtual IEnumerable addSubcontract(PXAdapter adapter)
        {
          return ApInvoiceEntryAddSubcontractsExtension.AddLines(new Func<PXAdapter, IEnumerable>(this.Base1.AddPOOrder2), adapter);
        }
    
        [PXButton]
        [PXUIField(DisplayName = "Add Subcontract Line", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
        public virtual IEnumerable addSubcontractLines(PXAdapter adapter)
        {
          this.Base.checkTaxCalcMode();
          return this.ShouldAddSubcontractLines() ? this.addSubcontractLine(adapter) : adapter.Get();
        }
    
        [PXButton]
        [PXUIField(DisplayName = "Add Subcontract Line", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select, Visible = false)]
        public virtual IEnumerable addSubcontractLine(PXAdapter adapter)
        {
          return ApInvoiceEntryAddSubcontractsExtension.AddLines(new Func<PXAdapter, IEnumerable>(this.Base2.AddPOOrderLine2), adapter);
        }
    
        private static IEnumerable AddLines(
          Func<PXAdapter, IEnumerable> addLine,
          PXAdapter adapter)
        {
          try
          {
            return addLine(adapter);
          }
          catch (PXException ex) when (ex.MessageNoPrefix == "Failed to add one or more lines from the PO order. Please check the Trace for details.")
          {
            throw new Exception("SC Error: Failed to add one or more lines from the Subcontract. Please check the Trace for details.");
          }
        }
    

    查看这段代码,我们可以看到它将使用来自 PX.Objects.PO.GraphExtensions.AInvoiceSmartPanel.AddPOOrderExtension 的 PX.Objects.dll 中的 AddPOOrder2

    此代码在 Acumatica 的可用源代码中找到:

    [PXUIField(DisplayName = Messages.AddPOOrder, MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select, Visible = false)]
            [PXLookupButton]
            [APMigrationModeDependentActionRestriction(
                restrictInMigrationMode: true,
                restrictForRegularDocumentInMigrationMode: true,
                restrictForUnreleasedMigratedDocumentInNormalMode: true)]
            public virtual IEnumerable AddPOOrder2(PXAdapter adapter)
            {
                bool isInvoice = (Base.Document.Current.DocType == APDocType.Invoice),
                    isPrepayment = (Base.Document.Current.DocType == APDocType.Prepayment);
                if (Base.Document.Current != null &&
                    isInvoice &&
                    Base.Document.Current.Released == false &&
                    Base.Document.Current.Prebooked == false)
                {
                    List<POOrder> orders = poorderslist.Cache.Updated.RowCast<POOrder>().Where(rc => rc.Selected == true).ToList();
                    foreach (POOrder rc in orders)
                    {
                        Base.InvoicePOOrder(rc, false);
                    }
                    Base.AttachPrepayment(orders);
                }
                return adapter.Get();
            }
    

    这里的基本调用是指APInvoiceEntry

    【讨论】:

      【解决方案2】:

      当您反编译 PX.Objects.dll 文件时,我们可以找到 "ADD PO" 的代码

      PX.Objects.PO.GraphExtensions.AInvoiceSmartPanel.AddPOOrderExtension

      但是,我需要 ADD Subcontracts

      的代码

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-02-03
        • 2016-09-02
        相关资源
        最近更新 更多