Example #1
0
        private void BindData()
        {
            if (BillId != null && !BillId.Equals(Guid.Empty))
            {
                PurchaseInvoiceBO purchaseInvoiceBO = new PurchaseInvoiceBO();
                //Bind data to purchase invoice information
                Bill bill = purchaseInvoiceBO.GetBillById(session, BillId);
                lblCode.Text           = bill.Code;
                lblIssuedDate.Text     = bill.IssuedDate.ToString();
                lblSumOfPromotion.Text =
                    bill.SumOfPromotion != 0 ? String.Format("{0:#,###}", bill.SumOfPromotion) : "0";
                lblSumOfTax.Text        = bill.SumOfTax != 0 ? String.Format("{0:#,###}", bill.SumOfTax) : "0";
                lblSumOfTotalPrice.Text = bill.SumOfItemPrice != 0 ? String.Format("{0:#,###}", bill.SumOfItemPrice) : "0";
                lblTotal.Text           = bill.Total != 0 ? String.Format("{0:#,###}", bill.Total) : "0";
                lblOrganization.Text    = String.Format("{0} - {1}",
                                                        bill.SourceOrganizationId.Code,
                                                        bill.SourceOrganizationId.Name);
                if (bill.RowStatus.Equals(Utility.Constant.ROWSTATUS_BOOKED_ENTRY))
                {
                    lblBookingStatus.Text = "Đã ghi sổ";
                }
                else
                {
                    lblBookingStatus.Text = "Chưa ghi sổ";
                }

                PurchaseInvoiceTransactionBO purchaseInvoiceTransactionBO = new PurchaseInvoiceTransactionBO();
                //Bind data to booking entries gridview
                var datasource = //session.GetObjectByKey<NAS.DAL.Invoice.PurchaseInvoice>(BillId).PurchaseInvoiceTransactions;
                                 purchaseInvoiceTransactionBO.GetTransactions(session, BillId);
                gridviewBookingEntriesForm.SetDataSource(datasource);

                /*2014-01-15 ERP-1396 Khoa.Truong INS START*/
                //Bind data to voucher booking entries gridview
                datasource = purchaseInvoiceTransactionBO.GetVoucherTransactions(session, BillId);
                gridviewVoucherBookingEntriesForm.SetDataSource(datasource);

                //Bind data to inventory booking entries gridview
                datasource = purchaseInvoiceTransactionBO.GetInventoryTransactions(session, BillId);
                gridviewInventoryBookingEntriesForm.SetDataSource(datasource);
                /*2014-01-15 ERP-1396 Khoa.Truong INS END*/
            }
        }
Example #2
0
        protected override void CloneBillTransaction(Session session, Guid billId, ref Bill ret)
        {
            PurchaseInvoiceTransactionBO invoiceTransactionBO = new PurchaseInvoiceTransactionBO();
            var      transactions = invoiceTransactionBO.GetTransactions(session, billId);
            ObjectBO objectBO     = new ObjectBO();

            foreach (var invoiceTransaction in transactions)
            {
                PurchaseInvoiceTransaction sourcePurchaseInvoiceTransaction =
                    (PurchaseInvoiceTransaction)invoiceTransaction;
                PurchaseInvoiceTransaction purchaseInvoiceTransaction = new PurchaseInvoiceTransaction(session)
                {
                    Amount            = sourcePurchaseInvoiceTransaction.Amount,
                    Code              = String.Format("BT_{0}", ret.Code),
                    CreateDate        = DateTime.Now,
                    Description       = String.Format("BT_{0}", ret.Code),
                    IssueDate         = sourcePurchaseInvoiceTransaction.IssueDate,
                    PurchaseInvoiceId = (NAS.DAL.Invoice.PurchaseInvoice)ret,
                    RowStatus         = Utility.Constant.ROWSTATUS_ACTIVE,
                    UpdateDate        = DateTime.Now
                };
                purchaseInvoiceTransaction.Save();
                //Create CMS Object for Transaction
                NAS.DAL.CMS.ObjectDocument.Object transactionCMSObject =
                    objectBO.CreateCMSObject(session, DAL.CMS.ObjectDocument.ObjectTypeEnum.INVOICE_PURCHASE);
                TransactionObject transactionObject = new TransactionObject(session)
                {
                    ObjectId      = transactionCMSObject,
                    TransactionId = purchaseInvoiceTransaction
                };
                transactionObject.Save();
                //Clone GeneralJournal
                var generalJournals = sourcePurchaseInvoiceTransaction.GeneralJournals
                                      .Where(r => r.RowStatus >= Utility.Constant.ROWSTATUS_ACTIVE);
                foreach (var sourceGeneralJournal in generalJournals)
                {
                    GeneralJournal generalJournal = new GeneralJournal(session)
                    {
                        AccountId     = sourceGeneralJournal.AccountId,
                        CreateDate    = DateTime.Now,
                        Credit        = sourceGeneralJournal.Credit,
                        CurrencyId    = sourceGeneralJournal.CurrencyId,
                        Debit         = sourceGeneralJournal.Debit,
                        Description   = sourceGeneralJournal.Description,
                        JournalType   = sourceGeneralJournal.JournalType,
                        RowStatus     = Utility.Constant.ROWSTATUS_ACTIVE,
                        TransactionId = purchaseInvoiceTransaction
                    };
                    generalJournal.Save();
                    //Create CMS object for GeneralJournal
                    NAS.DAL.CMS.ObjectDocument.Object generalJournalCMSObject =
                        objectBO.CreateCMSObject(session, DAL.CMS.ObjectDocument.ObjectTypeEnum.INVOICE_PURCHASE);
                    GeneralJournalObject generalJournalObject = new GeneralJournalObject(session)
                    {
                        GeneralJournalId = generalJournal,
                        ObjectId         = generalJournalCMSObject
                    };
                    generalJournalObject.Save();
                }
            }
        }