APInvoiceEntry BLC 为 poReceiptLinesSelection 数据视图添加了额外的限制
要向 poReceiptLinesSelection 数据视图添加其他限制,你应该在基本视图上调用 Select
方法并独立检查返回的 PXResultSet
中的每个项目以确定它是否符合其他限制:
public class APInvoiceEntryExt : PXGraphExtension<APInvoiceEntry>
{
[PXCopyPasteHiddenView]
public PXSelect<APInvoiceEntry.POReceiptLineAdd> poReceiptLinesSelection;
public virtual IEnumerable POReceiptLinesSelection()
{
foreach (var record in Base.poReceiptLinesSelection.Select())
{
// Additional restriction goes here
if (true == true)
{
yield return record;
}
}
}
}
由于在基本视图的实现中缺少分页和聚合,因此该方法与 poReceiptLinesSelection 数据视图完美配合。要编写结果集, poReceiptLinesSelection 视图从数据库请求必要的数据并在应用程序端执行所有计算。
public class APInvoiceEntry : APDataEntryGraph<APInvoiceEntry, APInvoice>, PXImportAttribute.IPXPrepareItems
{
...
[PXCopyPasteHiddenView]
public PXSelect<POReceiptLineAdd> poReceiptLinesSelection;
public virtual IEnumerable POReceiptLinesSelection()
{
APInvoice doc = this.Document.Current;
if (doc == null || doc.VendorID == null || doc.VendorLocationID == null) yield break;
if (doc.DocType != APDocType.Invoice && doc.DocType != APDocType.DebitAdj)
yield break;
string poReceiptType = (doc.DocType == APDocType.Invoice) ? POReceiptType.POReceipt : POReceiptType.POReturn;
HashSet<APTran> usedRecceiptLine = new HashSet<APTran>(new POReceiptLineComparer());
HashSet<APTran> unusedReceiptLine = new HashSet<APTran>(new POReceiptLineComparer());
foreach (APTran aPTran in Transactions.Cache.Inserted)
{
if (aPTran.ReceiptNbr != null && aPTran.ReceiptType != null && aPTran.ReceiptLineNbr != null)
usedRecceiptLine.Add(aPTran);
}
foreach (APTran aPTran in Transactions.Cache.Deleted)
{
if (aPTran.ReceiptNbr != null && aPTran.ReceiptType != null && aPTran.ReceiptLineNbr != null && Transactions.Cache.GetStatus(aPTran) != PXEntryStatus.InsertedDeleted)
if (!usedRecceiptLine.Remove(aPTran))
unusedReceiptLine.Add(aPTran);
}
foreach (APTran aPTran in Transactions.Cache.Updated)
{
APTran originAPTran = new APTran();
originAPTran.ReceiptNbr = (String)Transactions.Cache.GetValueOriginal<APTran.receiptNbr>(aPTran);
originAPTran.ReceiptType = (String)Transactions.Cache.GetValueOriginal<APTran.receiptType>(aPTran);
originAPTran.ReceiptLineNbr = (Int32?)Transactions.Cache.GetValueOriginal<APTran.receiptLineNbr>(aPTran);
if (originAPTran.ReceiptNbr != null && originAPTran.ReceiptType != null && originAPTran.ReceiptLineNbr != null)
{
if (!usedRecceiptLine.Remove(originAPTran))
unusedReceiptLine.Add(originAPTran);
}
if (aPTran.ReceiptNbr != null && aPTran.ReceiptType != null && aPTran.ReceiptLineNbr != null)
{
if (!unusedReceiptLine.Remove(aPTran))
usedRecceiptLine.Add(aPTran);
}
}
foreach (LinkLineReceipt item in PXSelect<LinkLineReceipt,
Where<LinkLineReceipt.vendorID, Equal<Current<APInvoice.vendorID>>,
And<LinkLineReceipt.vendorLocationID, Equal<Current<APInvoice.vendorLocationID>>,
And<LinkLineReceipt.receiptCuryID, Equal<Current<APInvoice.curyID>>,
And<LinkLineReceipt.receiptType, Equal<Required<POReceipt.receiptType>>,
And<Where<LinkLineReceipt.orderNbr, Equal<Current<POReceiptFilter.orderNbr>>, Or<Current<POReceiptFilter.orderNbr>, IsNull>>>
>>>>>.SelectMultiBound(this, new object[] { doc }, poReceiptType))
{
APTran aPTran = new APTran();
aPTran.ReceiptType = item.ReceiptType;
aPTran.ReceiptNbr = item.ReceiptNbr;
aPTran.ReceiptLineNbr = item.ReceiptLineNbr;
if (!usedRecceiptLine.Contains(aPTran))
yield return (PXResult<POReceiptLineAdd, POReceipt>)ReceipLineAdd.Select(item.ReceiptNbr, item.ReceiptType, item.ReceiptLineNbr);
}
foreach (APTran item in unusedReceiptLine)
{
yield return (PXResult<POReceiptLineAdd, POReceipt>)ReceipLineAdd.Select(item.ReceiptNbr, item.ReceiptType, item.ReceiptLineNbr);
}
}
...
}