コード例 #1
0
        private void BindData()
        {
            if (BillId != null && !BillId.Equals(Guid.Empty))
            {
                SalesInvoiceBO salesInvoiceBO = new SalesInvoiceBO();
                //Bind data to purchase invoice information
                Bill bill = salesInvoiceBO.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ổ";
                }

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

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

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

            foreach (var invoiceTransaction in transactions)
            {
                SaleInvoiceTransaction sourceSaleInvoiceTransaction =
                    (SaleInvoiceTransaction)invoiceTransaction;
                SaleInvoiceTransaction saleInvoiceTransaction = new SaleInvoiceTransaction(session)
                {
                    Amount         = sourceSaleInvoiceTransaction.Amount,
                    Code           = String.Format("BT_{0}", ret.Code),
                    CreateDate     = DateTime.Now,
                    Description    = String.Format("BT_{0}", ret.Code),
                    IssueDate      = sourceSaleInvoiceTransaction.IssueDate,
                    SalesInvoiceId = (NAS.DAL.Invoice.SalesInvoice)ret,
                    RowStatus      = Utility.Constant.ROWSTATUS_ACTIVE,
                    UpdateDate     = DateTime.Now
                };
                saleInvoiceTransaction.Save();
                //Create CMS Object for Transaction
                NAS.DAL.CMS.ObjectDocument.Object transactionCMSObject =
                    objectBO.CreateCMSObject(session, DAL.CMS.ObjectDocument.ObjectTypeEnum.INVOICE_SALE);
                TransactionObject transactionObject = new TransactionObject(session)
                {
                    ObjectId      = transactionCMSObject,
                    TransactionId = saleInvoiceTransaction
                };
                transactionObject.Save();
                //Clone GeneralJournal
                var generalJournals = sourceSaleInvoiceTransaction.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 = saleInvoiceTransaction
                    };
                    generalJournal.Save();
                    //Create CMS object for GeneralJournal
                    NAS.DAL.CMS.ObjectDocument.Object generalJournalCMSObject =
                        objectBO.CreateCMSObject(session, DAL.CMS.ObjectDocument.ObjectTypeEnum.INVOICE_SALE);
                    GeneralJournalObject generalJournalObject = new GeneralJournalObject(session)
                    {
                        GeneralJournalId = generalJournal,
                        ObjectId         = generalJournalCMSObject
                    };
                    generalJournalObject.Save();
                }
            }
        }