Beispiel #1
0
        protected void colBillActorTypeItemRequestedByValue(object source, ListEditItemRequestedByValueEventArgs e)
        {
            ASPxComboBox comboItemUnit = source as ASPxComboBox;

            if (e.Value == null)
            {
                return;
            }

            BillActorType obj = session.GetObjectByKey <BillActorType>(Guid.Parse(e.Value.ToString()));

            if (obj != null)
            {
                comboItemUnit.DataSource = new BillActorType[] { obj };
                comboItemUnit.DataBindItems();
            }
        }
Beispiel #2
0
        public bool UpdateBillActor(Session session, Guid billId, Guid creatorPersonId,
                                    Guid salesPersonId, Guid chiefAccountantPersonId, Guid directorPersonId)
        {
            try
            {
                //Get bill
                Bill bill = session.GetObjectByKey <Bill>(billId);
                if (bill == null)
                {
                    throw new Exception("Could not foung bill");
                }

                //Get creator
                Person creator         = session.GetObjectByKey <Person>(creatorPersonId);
                Person sales           = session.GetObjectByKey <Person>(salesPersonId);
                Person chiefAccountant = session.GetObjectByKey <Person>(chiefAccountantPersonId);
                Person director        = session.GetObjectByKey <Person>(directorPersonId);

                int           countExistType;
                BillActorType creatorType;
                //Update CREATOR bill actor type
                creatorType    = BillActorType.GetDefault(session, BillActorTypeEnum.CREATOR);
                countExistType = bill.BillActors.Count(r => r.BillActorTypeId == creatorType);
                if (countExistType == 0)
                {
                    BillActor billActor = new BillActor(session)
                    {
                        BillActorTypeId = creatorType,
                        PersonId        = creator,
                        BillId          = bill
                    };
                }
                else
                {
                    BillActor billActor = bill.BillActors.FirstOrDefault(r => r.BillActorTypeId == creatorType);
                    billActor.PersonId = creator;
                }
                session.FlushChanges();

                //Update SALES bill actor type
                creatorType    = BillActorType.GetDefault(session, BillActorTypeEnum.SALES);
                countExistType = bill.BillActors.Count(r => r.BillActorTypeId == creatorType);
                if (countExistType == 0)
                {
                    BillActor billActor = new BillActor(session)
                    {
                        BillActorTypeId = creatorType,
                        PersonId        = sales,
                        BillId          = bill
                    };
                }
                else
                {
                    BillActor billActor = bill.BillActors.FirstOrDefault(r => r.BillActorTypeId == creatorType);
                    billActor.PersonId = sales;
                }
                session.FlushChanges();

                //Update CHIEFACCOUNTANT bill actor type
                creatorType    = BillActorType.GetDefault(session, BillActorTypeEnum.CHIEFACCOUNTANT);
                countExistType = bill.BillActors.Count(r => r.BillActorTypeId == creatorType);
                if (countExistType == 0)
                {
                    BillActor billActor = new BillActor(session)
                    {
                        BillActorTypeId = creatorType,
                        PersonId        = chiefAccountant,
                        BillId          = bill
                    };
                }
                else
                {
                    BillActor billActor = bill.BillActors.FirstOrDefault(r => r.BillActorTypeId == creatorType);
                    billActor.PersonId = chiefAccountant;
                }
                session.FlushChanges();

                //Update DIRECTOR bill actor type
                creatorType    = BillActorType.GetDefault(session, BillActorTypeEnum.DIRECTOR);
                countExistType = bill.BillActors.Count(r => r.BillActorTypeId == creatorType);
                if (countExistType == 0)
                {
                    BillActor billActor = new BillActor(session)
                    {
                        BillActorTypeId = creatorType,
                        PersonId        = director,
                        BillId          = bill
                    };
                }
                else
                {
                    BillActor billActor = bill.BillActors.FirstOrDefault(r => r.BillActorTypeId == creatorType);
                    billActor.PersonId = director;
                }
                session.FlushChanges();

                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #3
0
        /////////////////////////////////////////////////

        public Guid insertEmptyPurchaseInvoice(Session session)
        {
            NAS.DAL.Invoice.PurchaseInvoice purchaseInvoice = new NAS.DAL.Invoice.PurchaseInvoice(session);

            purchaseInvoice.BillId           = Guid.NewGuid();
            purchaseInvoice.RowStatus        = -1;
            purchaseInvoice.PurchasingStatus = "PO";
            purchaseInvoice.Save();

            XPCollection <BillActorType> collectBillActorType = new XPCollection <BillActorType>(session);

            if (collectBillActorType.Count <= 0)
            {
                BillActorType billActorType = new BillActorType(session);

                billActorType.Description = "Người lập phiếu";
                billActorType.Name        = "CREATOR";
                billActorType.RowStatus   = Constant.ROWSTATUS_ACTIVE;

                billActorType.Save();

                billActorType = new BillActorType(session);

                billActorType.Description = "Người mua hàng";
                billActorType.Name        = "BUYER";
                billActorType.RowStatus   = Constant.ROWSTATUS_ACTIVE;

                billActorType.Save();

                billActorType             = new BillActorType(session);
                billActorType.Description = "Người bán hàng";
                billActorType.Name        = "SALES";
                billActorType.RowStatus   = Constant.ROWSTATUS_ACTIVE;

                billActorType.Save();

                billActorType             = new BillActorType(session);
                billActorType.Description = "Kế toán trưởng";
                billActorType.Name        = "CHIEFACCOUNTANT";
                billActorType.RowStatus   = Constant.ROWSTATUS_ACTIVE;

                billActorType.Save();

                billActorType             = new BillActorType(session);
                billActorType.Description = "Giám đốc";
                billActorType.Name        = "DIRECTOR";
                billActorType.RowStatus   = Constant.ROWSTATUS_ACTIVE;

                billActorType.Save();
            }

            collectBillActorType = new XPCollection <BillActorType>(session);
            foreach (BillActorType billActorType in collectBillActorType)
            {
                BillActor billActor = new BillActor(session);
                billActor.BillId          = purchaseInvoice;
                billActor.BillActorTypeId = billActorType;
                billActor.Save();
            }

            return(purchaseInvoice.BillId);
        }
        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();
            }
        }