示例#1
0
        public bool SalesInvoiceEditing_PreTransitionCRUD(string transition)
        {
            //Save data when transition is SAVE
            if (transition.ToUpper().Equals("SAVE"))
            {
                using (UnitOfWork uow = XpoHelper.GetNewUnitOfWork())
                {
                    try
                    {
                        //Get user input data
                        string       code               = txtCode.Text;
                        DateTime     issuedDate         = txtIssuedDate.Date;
                        Organization sourceOrganization = null;
                        Person       targetOrganization = null;
                        if (comboOrganization.Value != null)
                        {
                            sourceOrganization = uow.GetObjectByKey <Organization>(comboOrganization.Value);
                        }
                        NAS.BO.Invoice.SalesInvoiceBO salesInvoiceBO = new NAS.BO.Invoice.SalesInvoiceBO();
                        salesInvoiceBO.Save(uow, BillId, code, issuedDate, sourceOrganization, targetOrganization);

                        //Update bill actor
                        Guid creatorId         = Guid.Empty;
                        Guid salesId           = Guid.Empty;
                        Guid chiefAccountantId = Guid.Empty;
                        Guid directorId        = Guid.Empty;

                        if (comboCreator.Value != null)
                        {
                            creatorId = (Guid)comboCreator.Value;
                        }
                        if (comboSales.Value != null)
                        {
                            salesId = (Guid)comboSales.Value;
                        }
                        if (comboChiefAccountant.Value != null)
                        {
                            chiefAccountantId = (Guid)comboChiefAccountant.Value;
                        }
                        if (comboDirector.Value != null)
                        {
                            directorId = (Guid)comboDirector.Value;
                        }

                        salesInvoiceBO.UpdateBillActor(uow, BillId, creatorId, salesId, chiefAccountantId, directorId);

                        uow.CommitChanges();
                        return(true);
                    }
                    catch (Exception)
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
示例#2
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);
        }
示例#3
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);
        }
示例#4
0
 public bool SalesInvoiceCanceling_PreTransitionCRUD(string transition)
 {
     //Delete temporary bill when cancel for Creating state
     NAS.BO.Invoice.SalesInvoiceBO salesInvoiceBO = new NAS.BO.Invoice.SalesInvoiceBO();
     using (UnitOfWork uow = XpoHelper.GetNewUnitOfWork())
     {
         try
         {
             salesInvoiceBO.Delete(session, BillId);
             uow.CommitChanges();
             return(true);
         }
         catch (Exception)
         {
             return(false);
         }
     }
 }
示例#5
0
        public bool SalesInvoiceCreating_CRUD()
        {
            //Create new temporary bill
            NAS.BO.Invoice.SalesInvoiceBO salesInvoiceBO = new NAS.BO.Invoice.SalesInvoiceBO();
            Bill bill = salesInvoiceBO.InitTemporary(session, BillType);

            BillId             = bill.BillId;
            hfBillId["BillId"] = BillId.ToString();
            formlayoutInvoiceEditingForm_LoadData();

            //Get default code
            ArtifactCodeRuleBO artifactCodeRuleBO = new ArtifactCodeRuleBO();

            txtCode.Text = artifactCodeRuleBO.GetArtifactCodeOfArtifactType(ArtifactTypeEnum.INVOICE_SALE);

            SetControlsProperties();
            return(true);
        }
示例#6
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;
            }
        }
示例#7
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();
            }
        }