public void DataBind() { if (BillId != null) { SaleInvoiceTransactionBO saleInvoiceTransactionBO = new SaleInvoiceTransactionBO(); GridPlanning.DataSource = saleInvoiceTransactionBO.GetPlanningTransactionsOfBill(session, BillId); GridPlanning.DataBind(); ReceiptVoucherTransactionBO receiptVoucherTransactionBO = new ReceiptVoucherTransactionBO(); GridActual.DataSource = receiptVoucherTransactionBO.GetActuallyCollectedOfBill(session, BillId); GridActual.KeyFieldName = "GeneralJournalId"; GridActual.DataBind(); } }
private void FillBillDataIntoVoucher(Session _session, Guid _billId) { //Get bill Bill bill = _session.GetObjectByKey <Bill>(_billId); //Fill description txtDescription.Text = "Thu tiền hàng"; //Fill voucher amount ReceiptVoucherTransactionBO receiptVoucherTransactionBO = new ReceiptVoucherTransactionBO(); double amount = 0; var genaralJournal = receiptVoucherTransactionBO.GetActuallyCollectedOfBill(_session, bill.BillId); if (genaralJournal == null) { amount = bill.Total; } else { double actualPaymentAmount = genaralJournal.Sum(r => r.Debit); amount = bill.Total - actualPaymentAmount; if (amount <= 0) { GUIContext.State = new ReceiptVoucherCanceling(this); throw new Exception(String.Format( "Không thể tạo thêm phiếu thu vì phiếu bán '{0}' đã được thanh toán đủ", bill.Code)); } } spinAmount.Number = (decimal)amount; //Fill organization information if (bill.SourceOrganizationId != null) { cboSourceOrganization.Value = bill.SourceOrganizationId.OrganizationId; cboSourceOrganization.DataBindItems(); txtAddress.Text = bill.SourceOrganizationId.Address; } gridviewReceiptVoucherAllocation.AddNewRow(); }