出现这个错误通常的原因是尝试删除一个购买收据时,在与它相对应的采购订单中找不到相应的记录。可以通过以下代码示例来解决这个问题:
var receipt = PXSelect
if (receipt == null) { throw new PXException("Receipt {0} not found", receiptNbr); }
var poReceiptLine = PXSelect
if (poReceiptLine == null || poReceiptLine.Count() == 0) { throw new PXException("Receipt {0} has no lines", receiptNbr); }
var poReceiptLineSplit = PXSelect
if (poReceiptLineSplit == null || poReceiptLineSplit.Count() == 0) { throw new PXException("Receipt {0} has no splits", receiptNbr); }
这里的代码将查询指定的POReceipt,并检查它是否存在、是否有记录以及是否有拆分。通过对这些元素进行检查,可以避免"Sequence Contains No Matching Elements"这个错误的出现。