Я пытаюсь создать несколько записей при нажатии кнопки и отобразить их в виде сетки. Эти записи создаются при нажатии кнопки, однако создается и отображается только одна запись. В ходе тестирования я определил, что создается только финальная запись, которая будет создана этим процессом. Я не получаю никаких ошибок при нажатии кнопки, но все равно отображается только одна запись.
public PXSelect<TestDocument> Documents; //View of Grid
protected void CreateDocument(ARInvoice invoice, ARPayment payment)
{
TestDocument testDoc = new TestDocument();
//Creating TestDocument
testDoc.CustomerID = invoice.CustomerID;
testDoc.InvoiceID = invoice.RefNbr;
testDoc.PaymentID = payment.RefNbr;
testDoc.InvoiceTotal = invoice.CuryLineTotal;
testDoc.PaymentTotal = payment.CuryLineTotal;
testDoc.InvoiceDate = invoice.DocDate;
testDoc.PaymentDate = payment.DocDate;
Documents.Insert(testDoc);
Persist();
}
public PXAction<FilterTable> Preview;
[PXButton(CommitChanges = true)]
[PXUIField(DisplayName = "Preview")]
protected void preview()
{
foreach(PXResult<ARPayment> paymentResult in PXSelect<ARPayment,
Where<ARPayment.openDoc, Equal<True>>>.Select())
{
ARPayment payment = (ARPayment) paymentResult;
//ARInvoices that are open and share CustomerID with the ARPayment
foreach(PXResult<ARInvoice> invoiceResult in PXSelect<ARInvoice, Where<ARInvoice.customerID,
Equal<Required<ARPayment.customerID>>, And<ARInvoice.openDoc,Equal<True>>>>
.Select(this, payment.CustomerID))
{
ARInvoice invoice = (ARInvoice) invoiceResult;
CreateTransaction(invoice, payment);
}
}
}
public class TestDocument : IBqlTable
{
#region TransactionID
public abstract class transactionID : PX.Data.BQL.BqlInt.Field<transactionID> { }
[PXDBIdentity]
public virtual Int32? TransactionID { get; set; }
protected Int32? tranID;
#endregion
#region InvoiceID
[PXDBString(15, IsUnicode = true, InputMask = "")]
[PXUIField(DisplayName = "Invoice Ref. Nbr.")]
public virtual string InvoiceRefNbr{ get; set; }
public abstract class invoiceRefNbr: PX.Data.BQL.BqlString.Field<invoiceRefNbr> { }
#endregion
#region PaymentID
[PXDBString(15, IsUnicode = true, InputMask = "")]
[PXUIField(DisplayName = "Payment Ref. Nbr.")]
public virtual string PaymentRefNbr{ get; set; }
public abstract class paymentRefNbr: PX.Data.BQL.BqlString.Field<paymentRefNbr> { }
#endregion
#region CustomerID
[PXDBInt()]
[PXUIField(DisplayName = "CustomerID")]
[PXSelector(typeof(Customer.bAccountID), DescriptionField = typeof(Customer.acctCD))]
public virtual int? CustomerID{ get; set; }
public abstract class customerID: PX.Data.BQL.BqlInt.Field<customerID> { }
#endregion
#region InvoiceDate
[PXDBDate()]
[PXUIField(DisplayName = "Invoice Date")]
public virtual DateTime? InvoiceDate{ get; set; }
public abstract class invoiceDate: PX.Data.BQL.BqlDateTime.Field<invoiceDate> { }
#endregion
#region PaymentDate
[PXDBDate()]
[PXUIField(DisplayName = "Payment Date")]
public virtual DateTime? PaymentDate{ get; set; }
public abstract class paymentDate: PX.Data.BQL.BqlDateTime.Field<paymentDate> { }
#endregion
#region InvoiceTotal
[PXDBDecimal()]
[PXUIField(DisplayName = "Invoice Total")]
public virtual Decimal? InvoiceTotal{ get; set; }
public abstract class invoiceTotal: PX.Data.BQL.BqlDecimal.Field<invoiceTotal> { }
#endregion
#region PaymentTotal
[PXDBDecimal()]
[PXUIField(DisplayName = "Payment Total")]
public virtual Decimal? PaymentTotal{ get; set; }
public abstract class paymentTotal: PX.Data.BQL.BqlDecimal.Field<paymentTotal> { }
#endregion
}