Example #1
0
        public bool SalesInvoiceEditing_UpdateGUI()
        {
            popupInvoiceEditingForm.ShowOnPageLoad = true;

            NAS.BO.Invoice.SalesInvoiceBO salesInvoiceBO = new NAS.BO.Invoice.SalesInvoiceBO();
            NAS.DAL.Invoice.SalesInvoice  bill           =
                (NAS.DAL.Invoice.SalesInvoice)salesInvoiceBO.GetBillById(session, BillId);
            popupInvoiceEditingForm.HeaderText = String.Format("Thông tin phiếu bán hàng - {0}", bill.Code);

            ButtonShowBookingEntries.Enabled = true;
            ButtonDeclareTax.Enabled         = true;
            ButtonPrint.Enabled = true;
            ButtonCreateInventoryCommand.Enabled = true;
            ButtonCreateVoucher.Enabled          = true;
            return(true);
        }
Example #2
0
        public bool SalesInvoiceLocked_UpdateGUI()
        {
            popupInvoiceEditingForm.ShowOnPageLoad = true;

            NAS.BO.Invoice.SalesInvoiceBO salesInvoiceBO = new NAS.BO.Invoice.SalesInvoiceBO();
            NAS.DAL.Invoice.SalesInvoice  bill           =
                (NAS.DAL.Invoice.SalesInvoice)salesInvoiceBO.GetBillById(session, BillId);
            popupInvoiceEditingForm.HeaderText = String.Format("Thông tin phiếu bán hàng - {0}", bill.Code);

            //ButtonDeclareTax.Visible = false;
            ButtonSave.Visible = false;

            txtCode.Enabled           = false;
            txtIssuedDate.Enabled     = false;
            comboOrganization.Enabled = false;
            return(true);
        }
Example #3
0
        protected void panelBookingEntriesPopup_Callback(object sender, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e)
        {
            string[] args    = e.Parameter.Split('|');
            string   command = args[0];

            NAS.BO.Invoice.SalesInvoiceBO salesInvoiceBO
                = new NAS.BO.Invoice.SalesInvoiceBO();
            switch (command)
            {
            case "Show":
                popupBookingEntriesForm.ShowOnPageLoad = true;
                BillId = Guid.Parse(args[1]);
                BindData();
                popupBookingEntriesForm.HeaderText = String.Format("Hạch toán phiếu bán hàng - {0}",
                                                                   salesInvoiceBO.GetBillById(session, BillId).Code);
                break;

            case "Book":
                /*2014-02-13 ERP-1417 Duc.Vo INS START*/
                BusinessObjectBO BusinessObjectBO = new BusinessObjectBO();
                int objectInventoryFinacialType   = int.MinValue;
                //int objectInventoryItemType = int.MinValue;
                int objectInvoiceFinacialType = int.MinValue;
                int objectVoucherItemType     = int.MinValue;
                /*2014-02-13 ERP-1417 Duc.Vo INS END*/

                popupBookingEntriesForm.ShowOnPageLoad = true;
                string messages = null;

                UnitOfWork uow = null;
                try
                {
                    uow = XpoHelper.GetNewUnitOfWork();
                    Bill bill = salesInvoiceBO.GetBillById(uow, BillId);

                    popupBookingEntriesForm.HeaderText = String.Format("Hạch toán phiếu bán hàng - {0}", bill.Code);

                    if (bill.RowStatus.Equals(Utility.Constant.ROWSTATUS_BOOKED_ENTRY))
                    {
                        messages = String.Format("Phiếu bán hàng '{0}' đã được ghi sổ", bill.Code);
                    }
                    else
                    {
                        IEnumerable <string> temp;
                        List <string>        errorList = new List <string>();
                        bool canBookEntriesTemp;
                        bool canBookEntries = true;

                        canBookEntriesTemp = gridviewBookingEntriesForm.CanBookEntries(out temp);
                        canBookEntries     = canBookEntries & canBookEntriesTemp;
                        errorList.AddRange(temp);

                        canBookEntriesTemp = gridviewVoucherBookingEntriesForm.CanBookEntries(out temp);
                        canBookEntries     = canBookEntries & canBookEntriesTemp;
                        errorList.AddRange(temp);

                        canBookEntriesTemp = gridviewInventoryBookingEntriesForm.CanBookEntries(out temp);
                        canBookEntries     = canBookEntries & canBookEntriesTemp;
                        errorList.AddRange(temp);

                        /*2014-02-13 ERP-1417 Duc.Vo INS START*/
                        if (bill is NAS.DAL.Invoice.PurchaseInvoice)
                        {
                            objectInventoryFinacialType = Utility.Constant.BusinessObjectType_InputInventoryCommandFinancialTransaction;
                            //objectInventoryItemType = Utility.Constant.BusinessObjectType_InputInventoryCommandItemTransaction;
                            objectInvoiceFinacialType = Utility.Constant.BusinessObjectType_PurcharseFinancialTransaction;
                            objectVoucherItemType     = Utility.Constant.BusinessObjectType_PaymentVoucherTransaction;
                        }
                        else if (bill is NAS.DAL.Invoice.SalesInvoice)
                        {
                            objectInventoryFinacialType = Utility.Constant.BusinessObjectType_OutputInventoryCommandFinancialTransaction;
                            //objectInventoryItemType = Utility.Constant.BusinessObjectType_OutputInventoryCommandItemTransaction;
                            objectInvoiceFinacialType = Utility.Constant.BusinessObjectType_SalesFinancialTransaction;
                            objectVoucherItemType     = Utility.Constant.BusinessObjectType_ReceiptVoucherTransaction;
                        }
                        /*2014-02-13 ERP-1417 Duc.Vo INS END*/

                        if (canBookEntries)
                        {
                            TransactionBOBase transactionBOBase = new TransactionBOBase();

                            bill.RowStatus = Utility.Constant.ROWSTATUS_BOOKED_ENTRY;
                            //Book entries
                            //var transactions = new XPCollection<Transaction>(uow,
                            //    gridviewBookingEntriesForm.GetDataSource());

                            var transactions1 = gridviewBookingEntriesForm.GetDataSource();
                            foreach (var transaction in transactions1)
                            {
                                transactionBOBase.BookEntry(uow, transaction.TransactionId);
                            }

                            var transactions2 = gridviewVoucherBookingEntriesForm.GetDataSource();
                            foreach (var transaction in transactions2)
                            {
                                transactionBOBase.BookEntry(uow, transaction.TransactionId);
                            }

                            var transactions3 = gridviewInventoryBookingEntriesForm.GetDataSource();
                            foreach (var transaction in transactions3)
                            {
                                transactionBOBase.BookEntry(uow, transaction.TransactionId);
                            }

                            /*2014-02-13 ERP-1417 Duc.Vo INS START*/
                            foreach (var transaction in transactions1)
                            {
                                BusinessObjectBO.CreateBusinessObject(uow,
                                                                      objectInvoiceFinacialType,
                                                                      transaction.TransactionId,
                                                                      transaction.IssueDate);
                            }

                            foreach (var transaction in transactions2)
                            {
                                BusinessObjectBO.CreateBusinessObject(uow,
                                                                      objectVoucherItemType,
                                                                      transaction.TransactionId,
                                                                      transaction.IssueDate);
                            }

                            foreach (var transaction in transactions3)
                            {
                                BusinessObjectBO.CreateBusinessObject(uow,
                                                                      objectInventoryFinacialType,
                                                                      transaction.TransactionId,
                                                                      transaction.IssueDate);
                            }
                            /*2014-02-13 ERP-1417 Duc.Vo INS END*/
                        }
                        else
                        {
                            foreach (var message in errorList)
                            {
                                messages += message + "\n";
                            }
                        }
                    }

                    uow.CommitChanges();

                    BindData();
                }
                catch (Exception)
                {
                    throw;
                }
                finally
                {
                    if (uow != null)
                    {
                        uow.Dispose();
                    }

                    if (messages != null)
                    {
                        panelBookingEntriesPopup.JSProperties["cpError"] = messages;
                    }
                }
                break;

            case "Cancel":
                popupBookingEntriesForm.ShowOnPageLoad = false;
                BillId = Guid.Empty;
                panelBookingEntriesPopup.JSProperties["cpEvent"] = "Closing";
                break;

            default:
                break;
            }
        }
Example #4
0
        private void formlayoutInvoiceEditingForm_LoadData()
        {
            NAS.BO.Invoice.SalesInvoiceBO salesInvoiceBO = new NAS.BO.Invoice.SalesInvoiceBO();
            Bill bill = salesInvoiceBO.GetBillById(session, BillId);

            txtCode.Text       = bill.Code;
            txtIssuedDate.Date = bill.IssuedDate;
            if (bill.SourceOrganizationId != null)
            {
                comboOrganization.Value = bill.SourceOrganizationId.OrganizationId;
                comboOrganization.DataBindItems();
            }
            else
            {
                comboOrganization.SelectedIndex = -1;
            }

            int           countExistType;
            BillActorType billActorType;

            //Update index of creator combobox
            billActorType  = BillActorType.GetDefault(session, BillActorTypeEnum.CREATOR);
            countExistType = bill.BillActors.Count(r => r.BillActorTypeId == billActorType);
            if (countExistType == 0)
            {
                comboCreator.SelectedIndex = -1;
            }
            else
            {
                Person person = bill.BillActors
                                .FirstOrDefault(r => r.BillActorTypeId == billActorType).PersonId;
                if (person == null)
                {
                    comboCreator.SelectedIndex = -1;
                }
                else
                {
                    comboCreator.Value = person.PersonId;
                }
                comboCreator.DataBindItems();
            }

            //Update index of buyer combobox
            billActorType  = BillActorType.GetDefault(session, BillActorTypeEnum.SALES);
            countExistType = bill.BillActors.Count(r => r.BillActorTypeId == billActorType);
            if (countExistType == 0)
            {
                comboSales.SelectedIndex = -1;
            }
            else
            {
                Person person = bill.BillActors
                                .FirstOrDefault(r => r.BillActorTypeId == billActorType).PersonId;
                if (person == null)
                {
                    comboSales.SelectedIndex = -1;
                }
                else
                {
                    comboSales.Value = person.PersonId;
                }
                comboSales.DataBindItems();
            }

            //Update index of chief accountant combobox
            billActorType  = BillActorType.GetDefault(session, BillActorTypeEnum.CHIEFACCOUNTANT);
            countExistType = bill.BillActors.Count(r => r.BillActorTypeId == billActorType);
            if (countExistType == 0)
            {
                comboChiefAccountant.SelectedIndex = -1;
            }
            else
            {
                Person person = bill.BillActors
                                .FirstOrDefault(r => r.BillActorTypeId == billActorType).PersonId;
                if (person == null)
                {
                    comboChiefAccountant.SelectedIndex = -1;
                }
                else
                {
                    comboChiefAccountant.Value = person.PersonId;
                }
                comboChiefAccountant.DataBindItems();
            }

            //Update index of creator combobox
            billActorType  = BillActorType.GetDefault(session, BillActorTypeEnum.DIRECTOR);
            countExistType = bill.BillActors.Count(r => r.BillActorTypeId == billActorType);
            if (countExistType == 0)
            {
                comboDirector.SelectedIndex = -1;
            }
            else
            {
                Person person = bill.BillActors
                                .FirstOrDefault(r => r.BillActorTypeId == billActorType).PersonId;
                if (person == null)
                {
                    comboDirector.SelectedIndex = -1;
                }
                else
                {
                    comboDirector.Value = person.PersonId;
                }
                comboDirector.DataBindItems();
            }
        }