我正在尝试使用SOOrder表中的用户定义字段过滤Process Shipment过滤器中的记录。 我已经覆盖了SOShipmentFilter扩展中的整个Order函数,并添加了我的条件来根据SOOrder自定义字段过滤数据。
switch (sAlias)
{
case "EMB": ((PXSelectBase<SOShipment>)cmd).WhereAnd<Where<SOOrderExtNV.usrIsEmbroidery, Equal<True>>>(); break;
case "SNP": ((PXSelectBase<SOShipment>)cmd).WhereAnd<Where<SOOrderExtNV.usrIsScreenPrint, Equal<True>>>(); break;
case "PRO": ((PXSelectBase<SOShipment>)cmd).WhereAnd<Where<SOOrderExtNV.usrIsPromo, Equal<True>>>(); break;
case "FUL": ((PXSelectBase<SOShipment>)cmd).WhereAnd<Where<SOOrderExtNV.usrIsFulfilment, Equal<True>>>(); break;
case "BLK": ((PXSelectBase<SOShipment>)cmd).WhereAnd<Where<SOOrderExtNV.usrIsBlank, Equal<True>>>(); break;
case "SMP": ((PXSelectBase<SOShipment>)cmd).WhereAnd<Where<SOOrderExtNV.usrIsSample, Equal<True>>>(); break;
case "IRN": ((PXSelectBase<SOShipment>)cmd).WhereAnd<Where<SOOrderExtNV.usrIsOronOn, Equal<True>>>(); break;
case "DP": ((PXSelectBase<SOShipment>)cmd).WhereAnd<Where<SOOrderExtNV.usrIsDigitalPrint, Equal<True>>>(); break;
case "BAN": ((PXSelectBase<SOShipment>)cmd).WhereAnd<Where<SOOrderExtNV.usrIsBanners, Equal<True>>>(); break;
case "DCL": ((PXSelectBase<SOShipment>)cmd).WhereAnd<Where<SOOrderExtNV.usrIsDealer, Equal<True>>>(); break;
case "LSR": ((PXSelectBase<SOShipment>)cmd).WhereAnd<Where<SOOrderExtNV.usrIsLaser, Equal<True>>>(); break;
case "SVR": ((PXSelectBase<SOShipment>)cmd).WhereAnd<Where<SOOrderExtNV.usrIsService, Equal<True>>>(); break;
default: break;
}
我已经调试了代码,当它通过记录集迭代时它会失效
foreach (object res in ((PXSelectBase<SOShipment>)cmd).View.Select(null, null, PXView.Searches, PXView.SortColumns, PXView.Descendings, newFilters.ToArray(), ref startRow, PXView.MaximumRows, ref totalRows))
{
SOShipment order = PXResult.Unwrap<SOShipment>(res);
SOOrder so = PXResult.Unwrap<SOOrder>(res);
if (order.BilledOrderCntr + order.UnbilledOrderCntr + order.ReleasedOrderCntr == 1)
{
order.CustomerOrderNbr = so.CustomerOrderNbr;
}
SOShipment cached = (SOShipment)Base.Orders.Cache.Locate(order);
if (cached != null)
order.Selected = cached.Selected;
yield return order;
}
记录了跟踪错误的跟踪
Incorrect syntax near '='.
我已经使用SQL Profiler进行了分析,添加的条件是
( = CONVERT(BIT, 1))
我已复制SOOrderExtNV代码以供参考
using System;
using PX.Data;
using PX.Objects.CM;
using PX.Objects.AR;
using PX.Objects.CS;
using PX.Objects.CR;
using PX.Objects.TX;
using PX.Objects.GL;
using PX.Objects.IN;
using PX.Objects.CA;
using PX.Objects.PM;
using PX.Objects.EP;
using System.Diagnostics;
using System.Collections.Generic;
using PX.Objects;
using PX.Objects.SO;
using PX.Objects.SM;
using KevinCustomNew;
namespace KevinCustomNew
{
[PXKeyValueStorage]
public class SOOrderExtNV: PXCacheExtension<PX.Objects.SO.SOOrder>
{
// Sales Order Header
#region SO Order Header
#region UsrOrderNature
[PXDBString(5)]
[PXUIField(DisplayName = "Order Nature")]
[PXDefault("HA")]
[PXStringList(
new[] { "HA", "CO" },
new[] { "House Account", "Contract order" }
)]
public virtual string UsrOrderNature { get; set; }
public abstract class usrOrderNature : IBqlField { }
#endregion
#region UsrIsNewCustomer
[PXDBBool]
[PXUIField(DisplayName = "New Customer Order")]
public virtual bool? UsrIsNewCustomer { get; set; }
public abstract class usrIsNewCustomer : IBqlField { }
#endregion
#region UsrIsScreenPrint
[PXDBBool]
[PXUIField(DisplayName = "Screen Print")]
[PXDefault(false)]
public virtual bool? UsrIsScreenPrint { get; set; }
public abstract class usrIsScreenPrint : IBqlField { }
#endregion
#region UsrIsEmbroidery
[PXDBBool]
[PXUIField(DisplayName = "Embroidery")]
[PXDefault(false)]
public virtual bool? UsrIsEmbroidery { get; set; }
public abstract class usrIsEmbroidery : IBqlField { }
#endregion
#region UsrIsPromo
[PXDBBool]
[PXUIField(DisplayName = "Promotional")]
[PXDefault(false)]
public virtual bool? UsrIsPromo { get; set; }
public abstract class usrIsPromo : IBqlField { }
#endregion
#region UsrIsBlank
[PXDBBool]
[PXUIField(DisplayName = "Blank")]
[PXDefault(false)]
public virtual bool? UsrIsBlank { get; set; }
public abstract class usrIsBlank : IBqlField { }
#endregion
#region UsrIsService
[PXDBBool]
[PXUIField(DisplayName = "Service")]
[PXDefault(false)]
public virtual bool? UsrIsService { get; set; }
public abstract class usrIsService : IBqlField { }
#endregion
#region UsrIsDealer
[PXDBBool]
[PXUIField(DisplayName = "Decal")]
[PXDefault(false)]
public virtual bool? UsrIsDealer { get; set; }
public abstract class usrIsDealer : IBqlField { }
#endregion
#region UsrIsDigitalPrint
[PXDBBool]
[PXUIField(DisplayName = "Digital Print")]
[PXDefault(false)]
public virtual bool? UsrIsDigitalPrint { get; set; }
public abstract class usrIsDigitalPrint : IBqlField { }
#endregion
#region UsrIsBanners
[PXDBBool]
[PXUIField(DisplayName = "Banners")]
[PXDefault(false)]
public virtual bool? UsrIsBanners { get; set; }
public abstract class usrIsBanners : IBqlField { }
#endregion
#region UsrIsSample
[PXDBBool]
[PXUIField(DisplayName = "Sample")]
[PXDefault(false)]
public virtual bool? UsrIsSample { get; set; }
public abstract class usrIsSample : IBqlField { }
#endregion
#region UsrIsFulfilment
[PXDBBool]
[PXUIField(DisplayName = "Fulfillment")]
[PXDefault(false)]
public virtual bool? UsrIsFulfilment { get; set; }
public abstract class usrIsFulfilment : IBqlField { }
#endregion
#region UsrIsOronOn
[PXDBBool]
[PXUIField(DisplayName = "Iron On")]
[PXDefault(false)]
public virtual bool? UsrIsOronOn { get; set; }
public abstract class usrIsOronOn : IBqlField { }
#endregion
#region UsrIsRushJob
[PXDBBool]
[PXUIField(DisplayName = "Rush Job")]
[PXDefault(false)]
public virtual bool? UsrIsRushJob { get; set; }
public abstract class usrIsRushJob : IBqlField { }
#endregion
#region UsrIsLaser
[PXDBBool]
[PXUIField(DisplayName = "Laser")]
public virtual bool? UsrIsLaser { get; set; }
public abstract class usrIsLaser : IBqlField { }
#endregion
#region UsrIsInHandsDate
[PXDBDate]
[PXUIField(DisplayName = "In-Hands Date")]
public virtual DateTime? UsrIsInHandsDate { get; set; }
public abstract class usrIsInHandsDate : IBqlField { }
#endregion
#region UsrOpportunityID
[PXDBString(20)]
[PXUIField(DisplayName = "Opportunity",Enabled=false)]
[PXSelector(typeof(CROpportunity.opportunityID),
new Type[]
{
typeof(CROpportunity.opportunityID),
typeof(CROpportunity.opportunityName)
},
DescriptionField = typeof(CROpportunity.opportunityName))]
public virtual string UsrOpportunityID { get; set; }
public abstract class usrOpportunityID : IBqlField { }
#endregion
#region UsrHardDate
[PXDBBool]
[PXUIField(DisplayName = "Hard Date")]
[PXDefault(false)]
public virtual bool? UsrHardDate { get; set; }
public abstract class usrHardDate : IBqlField { }
#endregion
#region UsrEventDate
[PXDBDate]
[PXUIField(DisplayName = "Event Date")]
public virtual DateTime? UsrEventDate { get; set; }
public abstract class usrEventDate : IBqlField { }
#endregion
#region UsrEventDescription
[PXDBString(512)]
[PXUIField(DisplayName = "Event Description")]
public virtual string UsrEventDescription { get; set; }
public abstract class usrEventDescription : IBqlField { }
#endregion
#region UsrSoHeaderNoOfPieces
[PXDBInt]
[PXUIField(DisplayName = "No. Of Pieces")]
public virtual int? UsrSoHeaderNoOfPieces { get; set; }
public abstract class usrSoHeaderNoOfPieces : IBqlField { }
#endregion
#region UsrShipDate
[PXDBDate]
[PXUIField(DisplayName = "Ship Date")]
public virtual DateTime? UsrShipDate { get; set; }
public abstract class usrShipDate : IBqlField { }
#endregion
#region UsrHoldUntil
[PXDBDate]
[PXUIField(DisplayName = "Hold Until")]
public virtual DateTime? UsrHoldUntil { get; set; }
public abstract class usrHoldUntil : IBqlField { }
#endregion
#region UsrCustomerContact
[PXDBInt]
[PXUIField(DisplayName = "Contact")]
[PXSelector(
typeof(Search<Contact.contactID,
Where<Contact.bAccountID, Equal<Current<SOOrder.customerID>>,And<Contact.contactType,Equal<DownLoadValueType.CustomerContactType>>>>),
DescriptionField = typeof(Contact.displayName))]
public virtual int? UsrCustomerContact { get; set; }
public abstract class usrCustomerContact : IBqlField { }
#endregion
#region UsrBatchShip
[PXDBBool]
[PXUIField(DisplayName = "Batch Ship")]
public virtual bool? UsrBatchShip { get; set; }
public abstract class usrBatchShip : IBqlField { }
#endregion
#region UsrReadyForProduction
[PXDBBool]
[PXUIField(DisplayName = "Ready for Production")]
public virtual bool? UsrReadyForProduction { get; set; }
public abstract class usrReadyForProduction : IBqlField { }
#endregion
#region UsrEditInstructions
[PXDBString(2000)]
[PXUIField(DisplayName = "Revision Instructions")]
public virtual string UsrEditInstructions { get; set; }
public abstract class usrEditInstructions : IBqlField { }
#endregion
#endregion
}
}
此致 R.Muralidharan
答案 0 :(得分:2)
您不应在Extension中重新声明视图委托的整个基本代码,而应使用扩展类中的Base.Orders.Select()通过基类执行相同的数据视图,并应用自定义过滤器。
下面的代码段显示了实现您所需内容的概念(并可根据需要随意调整):
为SOShipmentFilter DAC创建DAC扩展
public class SOShipmentFilterPXExt : PXCacheExtension<SOShipmentFilter>
{
#region UsrFilterByAlias
public abstract class usrFilterByAlias : IBqlField { }
[PXDBString(2)]
[PXStringList(
new[] {"A0", "A1", "A2" },
new[] {"All", "UsrZField1", "UsrZField2" }
)]
[PXDefault("A0")]
public virtual String UsrFilterByAlias { get; set; }
#endregion
}
为SOOrder DAC创建DAC扩展
[PXKeyValueStorage]
public class SOOrderExtNV : PXCacheExtension<PX.Objects.SO.SOOrder>
{
#region UsrZField1
public abstract class usrZField1 : IBqlField { }
[PXDBBool]
[PXUIField(DisplayName = "ZField1")]
public virtual bool? UsrZField1 { get; set; }
#endregion
#region UsrZField2
public abstract class usrZField2 : IBqlField { }
[PXDBBool]
[PXUIField(DisplayName = "ZField2")]
public virtual bool? UsrZField2 { get; set; }
#endregion
}
为SOShipment DAC创建DAC扩展
public class SOShipmentExt : PXCacheExtension<SOShipment>
{
#region UsrZField1
public abstract class usrZField1 : IBqlField { }
[PXBool]
[PXDefault(false, PersistingCheck = PXPersistingCheck.Nothing)]
[PXUIField(DisplayName = "ZField1")]
public virtual bool? UsrZField1 { get; set; }
#endregion
#region UsrZField2
public abstract class usrZField2 : IBqlField { }
[PXBool]
[PXDefault(false, PersistingCheck = PXPersistingCheck.Nothing)]
[PXUIField(DisplayName = "ZField2")]
public virtual bool? UsrZField2 { get; set; }
#endregion
}
创建图表扩展
public class SOInvoiceShipmentPXExt : PXGraphExtension<SOInvoiceShipment>
{
[PXFilterable]
public PXFilteredProcessing<SOShipment, SOShipmentFilter> Orders;
public virtual void SOShipment_RowSelecting(PXCache sender, PXRowSelectingEventArgs e, PXRowSelecting BaseInvoke)
{
if (BaseInvoke != null)
BaseInvoke(sender, e);
if (e.Row == null) return;
SOShipment shipment = (SOShipment)e.Row;
SOShipmentExt shipmentExt = PXCache<SOShipment>.GetExtension<SOShipmentExt>(shipment);
SOOrder soData = PXSelectJoin<SOOrder,
InnerJoin<SOOrderShipment, On<SOOrderShipment.orderType, Equal<SOOrder.orderType>,
And<SOOrderShipment.orderNbr, Equal<SOOrder.orderNbr>>>>,
Where<SOOrderShipment.shipmentType, Equal<Required<SOOrderShipment.shipmentType>>,
And<SOOrderShipment.shipmentNbr, Equal<Required<SOOrderShipment.shipmentNbr>>>>>
.Select(Base, shipment.ShipmentType, shipment.ShipmentNbr);
if (soData != null)
{
SOOrderExtNV soDataExt = PXCache<SOOrder>.GetExtension<SOOrderExtNV>(soData);
shipmentExt.UsrZField1 = soDataExt.UsrZField1;
shipmentExt.UsrZField2 = soDataExt.UsrZField2;
}
}
protected IEnumerable orders()
{
SOShipmentFilterPXExt filterExt = PXCache<SOShipmentFilter>.GetExtension<SOShipmentFilterPXExt>(Base.Filter.Current);
if (filterExt.UsrFilterByAlias == "A1")
{
var list = new ArrayList();
foreach (PXResult record in Base.Orders.Select())
{
SOShipment shipment = record.GetItem<SOShipment>();
if (shipment != null)
{
SOShipmentExt shipmentExt = PXCache<SOShipment>.GetExtension<SOShipmentExt>(shipment);
if (shipmentExt.UsrZField1.HasValue && shipmentExt.UsrZField1.Value)
list.Add(shipment);
}
}
return list;
}
else if (filterExt.UsrFilterByAlias == "A2")
{
var list = new ArrayList();
foreach (PXResult record in Base.Orders.Select())
{
SOShipment shipment = record.GetItem<SOShipment>();
if (shipment != null)
{
SOShipmentExt shipmentExt = PXCache<SOShipment>.GetExtension<SOShipmentExt>(shipment);
if (shipmentExt.UsrZField2.HasValue && shipmentExt.UsrZField2.Value)
list.Add(shipment);
}
}
return list;
}
else
{
return Base.Orders.Select();
}
}
}