2017-07-18 53 views
0

某些用户字段已添加到ARInvoice输入屏幕(AR301000)。用户字段存在于交易网格中。它们只是文本字段。没有关联的自定义逻辑,并绑定到数据库表。ARInvoice发布后如何在AR301000上启用自定义字段?

用户希望在发票发布后修改特定的用户文本字段 - 实现此目的的最佳方法是什么?

回答

0

谢天谢地,ARInvoces输入屏幕上的事务网格从未被自动化步骤禁用。所有的交易格UI演示逻辑是只有ARInvoiceEntry BLC中定义:

public class ARInvoiceEntry : ARDataEntryGraph<ARInvoiceEntry, ARInvoice>, PXImportAttribute.IPXPrepareItems 
{ 
    ... 
    protected virtual void ARInvoice_RowSelected(PXCache cache, PXRowSelectedEventArgs e) 
    { 
     ARInvoice doc = e.Row as ARInvoice; 
     if (doc == null) return; 

     ... 
     bool shouldDisable = doc.Released == true 
          || doc.Voided == true 
          || doc.DocType == ARDocType.SmallCreditWO 
          || doc.PendingPPD == true 
          || doc.DocType == ARDocType.FinCharge && !IsProcessingMode && cache.GetStatus(doc) == PXEntryStatus.Inserted; 
     if (shouldDisable) 
     { 
      ... 
      Transactions.Cache.AllowDelete = false; 
      Transactions.Cache.AllowUpdate = false; 
      Transactions.Cache.AllowInsert = false; 
      ... 
     } 
     else 
     { 
      ... 
      Transactions.Cache.AllowDelete = true; 
      Transactions.Cache.AllowUpdate = true; 
      Transactions.Cache.AllowInsert = 
       doc.CustomerID != null && 
       doc.CustomerLocationID != null && 
       doc.DocType != ARDocType.FinCharge && 
       (doc.ProjectID != null || !PM.ProjectAttribute.IsPMVisible(this, BatchModule.AR)); 
      ... 
     } 
     ... 
    } 

    protected virtual void ARTran_RowSelected(PXCache sender, PXRowSelectedEventArgs e) 
    { 
     ARTran row = e.Row as ARTran; 
     if (row != null) 
     { 
      PXUIFieldAttribute.SetEnabled<ARTran.defScheduleID>(sender, row, row.TranType == ARInvoiceType.CreditMemo || row.TranType == ARInvoiceType.DebitMemo); 
      PXUIFieldAttribute.SetEnabled<ARTran.deferredCode>(sender, row, row.DefScheduleID == null); 
     } 
    } 
    ... 
} 

要在AR301000启用自定义字段中的ARInvoice发布后,您应完成以下relatevely简单的步骤:

  1. 设置AllowUpdate真正为ARInvoice_RowSelected事件处理程序中的ARTran缓存

  2. 调用静态PXUIFieldAttribute.SetEnabled方法来禁用所有ARTran领域,除了特定的自定义文本字段,用户要修改

enter image description here

完整的代码片段如下:

public class ARInvoiceEntryExt : PXGraphExtension<ARInvoiceEntry> 
{ 
    private bool IsDisabled(ARInvoice doc) 
    { 
     return doc.Released == true 
      || doc.Voided == true 
      || doc.DocType == ARDocType.SmallCreditWO 
      || doc.PendingPPD == true 
      || doc.DocType == ARDocType.FinCharge 
      && !Base.IsProcessingMode 
      && Base.Document.Cache.GetStatus(doc) == PXEntryStatus.Inserted; 
    } 

    public void ARInvoice_RowSelected(PXCache cache, PXRowSelectedEventArgs e) 
    { 
     ARInvoice doc = e.Row as ARInvoice; 
     if (doc == null) return; 

     if (IsDisabled(doc)) 
     { 
      Base.Transactions.Cache.AllowUpdate = true; 
     } 
    } 

    public void ARTran_RowSelected(PXCache sender, PXRowSelectedEventArgs e) 
    { 
     var doc = Base.Document.Current; 
     ARTran row = e.Row as ARTran; 

     if (row != null && doc != null && IsDisabled(doc)) 
     { 
      PXUIFieldAttribute.SetEnabled(sender, row, false); 
      PXUIFieldAttribute.SetEnabled<ARTranExt.usrCustomTextField>(sender, row, true); 
     } 
    } 
} 
相关问题