Exemple #1
0
 public void DataBind()
 {
     if (BillId != null)
     {
         PurchaseInvoiceTransactionBO purchaseInvoiceTransactionBO = new PurchaseInvoiceTransactionBO();
         GridPlanning.DataSource = purchaseInvoiceTransactionBO.GetPlanningTransactionsOfBill(session, BillId);
         GridPlanning.DataBind();
         PaymentVoucherTransactionBO paymentVoucherTransactionBO = new PaymentVoucherTransactionBO();
         GridActual.DataSource   = paymentVoucherTransactionBO.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 = "Trả tiền hàng";

            //Fill voucher amount
            PaymentVoucherTransactionBO paymentVoucherTransactionBO = new PaymentVoucherTransactionBO();
            double amount         = 0;
            var    genaralJournal = paymentVoucherTransactionBO.GetActuallyCollectedOfBill(_session, bill.BillId);

            if (genaralJournal == null)
            {
                amount = bill.Total;
            }
            else
            {
                double actualPaymentAmount = genaralJournal.Sum(r => r.Credit);
                amount = bill.Total - actualPaymentAmount;
                if (amount <= 0)
                {
                    GUIContext.State = new PaymentVoucherCanceling(this);
                    throw new Exception(String.Format(
                                            "Không thể tạo thêm phiếu chi vì phiếu mua '{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();
        }