【问题标题】:Acumatica - Item Status on SOLineAcumatica - SOLine 上的项目状态
【发布时间】:2018-06-12 06:45:09
【问题描述】:

我创建了一个自定义项以将项目状态添加到 SOLine。图形代码和 DAC 编译得很好,没有错误。当我检查新的状态字段时,它只是空白。这是我的做法:

首先是 DAC:

public class SOLineExt : PXCacheExtension<PX.Objects.SO.SOLine>
  {
    #region ItemStatus
    public abstract class itemStatus : PX.Data.IBqlField
    {
    }
    protected string _ItemStatus;

    [PXString()]
    [PXDefault()]
    [PXUIField(DisplayName = "Status", IsReadOnly = true)]
    public virtual string ItemStatus
    {
      get
      {
        return this._ItemStatus;
      }
      set
      {
        this._ItemStatus = value;
      }
    }
    #endregion
  }

图表:

  public class SOOrderEntryExt : PXGraphExtension<SOOrderEntry>
  {
    #region Event Handlers
protected void SOLine_RowSelecting(PXCache cache, PXRowSelectingEventArgs e,PXRowSelecting InvokeBaseHandler)
    {
if(InvokeBaseHandler != null)
           InvokeBaseHandler(cache, e);
            var row = (SOLine)e.Row;
            if (row == null) return;

                    InventoryItem item = PXSelect<InventoryItem, Where<InventoryItem.inventoryID, Equal<Required<SOLine.inventoryID>>>>.Select(Base, row.InventoryID);
                    if(item != null){
                      SOLineExt soLinesExt = row.GetExtension<SOLineExt>();
                    if (soLinesExt != null){
                       if (item.ItemStatus == 'AC')
                        soLinesExt.ItemStatus = "Active";
                     if (item.ItemStatus == 'NS')
                      soLinesExt.ItemStatus = "No Sales"; 
                      if (item.ItemStatus == 'NP')
                      soLinesExt.ItemStatus = "No Purchases"; 
                      if (item.ItemStatus == 'NR')
                      soLinesExt.ItemStatus = "No Request"; 
                      if (item.ItemStatus == 'IN')
                      soLinesExt.ItemStatus = "Inatctive"; 
                      if (item.ItemStatus == 'DE')
                      soLinesExt.ItemStatus = "Marked for Deletion"; 

                    }  
                    }


    }
    #endregion
  }

我为此使用了类似的方法将其他字段添加到网格中,这只是我遇到的问题。注意到我确实希望显示完整的状态名称,而不仅仅是两个字符代码。

【问题讨论】:

    标签: c# acumatica


    【解决方案1】:

    选项#1

    您可以使用以下PXDBScalarPXDefault 来实现您的目标。您可以参考为此自定义字段修饰的每个属性的注释。

    public class SOLineExt : PXCacheExtension<PX.Objects.SO.SOLine>
    {
        #region UsrItemStatus
        public abstract class usrItemStatus : PX.Data.IBqlField
        {
        }
        protected string _UsrItemStatus;
    
        [PXString()]
        [PXUIField(DisplayName = "Status", IsReadOnly = true)]
        //Sub-Select or Sub Query - required to get value for Saved SO Lines
        [PXDBScalar(typeof(Search<InventoryItem.itemStatus, 
                 Where<InventoryItem.inventoryID, Equal<SOLine.inventoryID>>>))]
        //StringList Attribute so that you don’t need to convert value to display text
        [InventoryItemStatus.List]
        //Defaulted when inserting new SO Line
        [PXDefault(typeof(Search<InventoryItem.itemStatus, 
                 Where<InventoryItem.inventoryID, Equal<Current<SOLine.inventoryID>>>>),
                   PersistingCheck = PXPersistingCheck.Nothing)]
        //Triggering default assignment upon changing Inventory ID in SO Line 
        [PXFormula(typeof(Default<SOLine.inventoryID>))]
        public virtual string UsrItemStatus
        {
            get
            {
                return this._UsrItemStatus;
            }
            set
            {
                this._UsrItemStatus = value;
            }
        }
        #endregion
    }
    

    选项#2

    在数据视图中包含InventoryItem DAC(在此特定情况下为Transactions)与Document Details Grid 一起使用。并将InventoryItem__ItemStatus 字段添加到网格。开箱即用的 SOOrderEntry Graph 实现了 Transactions 的数据视图委托,因此我们也必须对其进行修改。

    public class SOOrderEntryPXDemoExt : PXGraphExtension<SOOrderEntry>
    {
        public override void Initialize()
        {
            Base.Transactions.Join<InnerJoin<InventoryItem, On<InventoryItem.inventoryID, Equal<SOLine.inventoryID>>>>();
        }
    
        [PX.Api.Export.PXOptimizationBehavior(IgnoreBqlDelegate = true)]
        protected virtual IEnumerable transactions()
        {
            PXSelectBase<SOLine> query =
                new PXSelectJoin<SOLine,
                        LeftJoin<INItemCost, On<INItemCost.inventoryID, Equal<SOLine.inventoryID>>,
                        InnerJoin<InventoryItem, On<InventoryItem.inventoryID, Equal<SOLine.inventoryID>>>>,
                        Where<SOLine.orderType, Equal<Current<SOOrder.orderType>>,
                            And<SOLine.orderNbr, Equal<Current<SOOrder.orderNbr>>>>,
                        OrderBy<Asc<SOLine.orderType, Asc<SOLine.orderNbr, Asc<SOLine.lineNbr>>>>>(Base);
    
            var ret = new List<PXResult<SOLine, INItemCost, InventoryItem>>();
            int startRow = PXView.StartRow;
            int totalRows = 0;
            foreach (PXResult<SOLine, INItemCost, InventoryItem> record in query.View.Select(
                PXView.Currents, PXView.Parameters, PXView.Searches, PXView.SortColumns,
                PXView.Descendings, PXView.Filters, ref startRow, PXView.MaximumRows, ref totalRows))
            {
                SOLine line = (SOLine)record;
                INItemCost itemCost = (INItemCost)record;
    
                Base.initemcost.StoreCached(new PXCommandKey(new object[] { line.InventoryID }), new List<object> { itemCost });
    
                ret.Add(record);
            }
            PXView.StartRow = 0;
            return ret;
        }
    }
    

    【讨论】:

    • 我使用了第一个选项并且效果很好,谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多