public bool PurchaseInvoiceEditing_UpdateGUI()
        {
            popupInvoiceEditingForm.ShowOnPageLoad = true;

            NAS.BO.Invoice.PurchaseInvoiceBO purchaseInvoiceBO = new NAS.BO.Invoice.PurchaseInvoiceBO();
            NAS.DAL.Invoice.PurchaseInvoice  bill =
                (NAS.DAL.Invoice.PurchaseInvoice)purchaseInvoiceBO.GetBillById(session, BillId);
            popupInvoiceEditingForm.HeaderText = String.Format("Thông tin phiếu mua hàng - {0}", bill.Code);

            ButtonShowBookingEntries.Enabled = true;
            ButtonDeclareTax.Enabled         = true;
            ButtonPrint.Enabled = true;
            ButtonCreateInventoryCommand.Enabled = true;
            ButtonCreateVoucher.Enabled          = true;
            return(true);
        }
        public bool PurchaseInvoiceLocked_UpdateGUI()
        {
            popupInvoiceEditingForm.ShowOnPageLoad = true;

            NAS.BO.Invoice.PurchaseInvoiceBO purchaseInvoiceBO = new NAS.BO.Invoice.PurchaseInvoiceBO();
            NAS.DAL.Invoice.PurchaseInvoice  bill =
                (NAS.DAL.Invoice.PurchaseInvoice)purchaseInvoiceBO.GetBillById(session, BillId);
            popupInvoiceEditingForm.HeaderText = String.Format("Thông tin phiếu mua hàng - {0}", bill.Code);

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

            txtCode.Enabled           = false;
            txtIssuedDate.Enabled     = false;
            comboOrganization.Enabled = false;
            return(true);
        }
示例#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.PurchaseInvoiceBO purchaseInvoiceBO
                = new NAS.BO.Invoice.PurchaseInvoiceBO();
            switch (command)
            {
            case "Show":
                popupBookingEntriesForm.ShowOnPageLoad = true;
                BillId = Guid.Parse(args[1]);
                BindData();
                popupBookingEntriesForm.HeaderText = String.Format("Hạch toán phiếu mua hàng - {0}",
                                                                   purchaseInvoiceBO.GetBillById(session, BillId).Code);
                break;

            case "Book":
                popupBookingEntriesForm.ShowOnPageLoad = true;
                /*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*/
                string messages = null;

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

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

                    if (bill.RowStatus.Equals(Utility.Constant.ROWSTATUS_BOOKED_ENTRY))
                    {
                        messages = String.Format("Phiếu mua 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;
            }
        }
示例#4
0
        protected void panelBookingEntriesPopup_Callback(object sender, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e)
        {
            string[] args    = e.Parameter.Split('|');
            string   command = args[0];

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

            case "Book":
                popupBookingEntriesForm.ShowOnPageLoad = true;
                string messages = null;

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

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

                    if (bill.RowStatus.Equals(Utility.Constant.ROWSTATUS_BOOKED_ENTRY))
                    {
                        messages = String.Format("Phiếu mua hàng '{0}' đã được ghi sổ", bill.Code);
                    }
                    else
                    {
                        IEnumerable <string> temp;
                        bool canBookEntries = gridviewBookingEntriesForm.CanBookEntries(out temp);
                        if (canBookEntries)
                        {
                            bill.RowStatus = Utility.Constant.ROWSTATUS_BOOKED_ENTRY;
                            //Book entries
                            //var transactions = new XPCollection<Transaction>(uow,
                            //    gridviewBookingEntriesForm.GetDataSource());

                            var transactions = gridviewBookingEntriesForm.GetDataSource();

                            foreach (var transaction in transactions)
                            {
                                TransactionBOBase transactionBOBase = new TransactionBOBase();
                                transactionBOBase.BookEntry(uow, transaction.TransactionId);
                            }
                        }
                        else
                        {
                            foreach (var message in temp)
                            {
                                messages += message + "\n";
                            }
                        }
                    }

                    uow.CommitChanges();
                }
                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;
            }
        }
        private void formlayoutInvoiceEditingForm_LoadData()
        {
            NAS.BO.Invoice.PurchaseInvoiceBO purchaseInvoiceBO = new NAS.BO.Invoice.PurchaseInvoiceBO();
            Bill bill = purchaseInvoiceBO.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.BUYER);
            countExistType = bill.BillActors.Count(r => r.BillActorTypeId == billActorType);
            if (countExistType == 0)
            {
                comboBuyer.SelectedIndex = -1;
            }
            else
            {
                Person person = bill.BillActors
                                .FirstOrDefault(r => r.BillActorTypeId == billActorType).PersonId;
                if (person == null)
                {
                    comboBuyer.SelectedIndex = -1;
                }
                else
                {
                    comboBuyer.Value = person.PersonId;
                }
                comboBuyer.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();
            }
        }