Ejemplo n.º 1
0
        public void updatePerson(Session session, List <Department> departments, Guid personId, string code, string name, short rowStatus)
        {
            try
            {
                session.BeginTransaction();
                Person p = session.GetObjectByKey <Person>(personId);

                if (p == null)
                {
                    throw new Exception(string.Format("Không tồn tại personId {0 trong hệ thống}", personId));
                }

                p.Code      = code;
                p.Name      = name;
                p.RowStatus = rowStatus;
                p.Save();

                XPCollection <DepartmentPerson> dplist = new XPCollection <DepartmentPerson>(session);
                dplist.Criteria = CriteriaOperator.And(
                    new BinaryOperator("RowStatus", 0, BinaryOperatorType.Greater),
                    new BinaryOperator("PersonId", p, BinaryOperatorType.Equal));

                foreach (DepartmentPerson dp in dplist)
                {
                    dp.RowStatus = Utility.Constant.ROWSTATUS_DELETED;
                    dp.Save();
                }

                foreach (Department d in departments)
                {
                    DepartmentPerson dp = session.FindObject <DepartmentPerson>(CriteriaOperator.And(
                                                                                    new BinaryOperator("PersonId!Key", p.PersonId, BinaryOperatorType.Equal),
                                                                                    new BinaryOperator("DepartmentId!Key", d.DepartmentId, BinaryOperatorType.Equal)
                                                                                    ));

                    if (dp != null)
                    {
                        dp.RowStatus = Utility.Constant.ROWSTATUS_ACTIVE;
                    }
                    else
                    {
                        dp = new DepartmentPerson(session);
                        dp.DepartmentId         = d;
                        dp.PersonId             = p;
                        dp.RowStatus            = Utility.Constant.ROWSTATUS_ACTIVE;
                        dp.RowCreationTimeStamp = DateTime.Now;
                    }
                    dp.Save();
                }
                session.CommitTransaction();
            }
            catch (Exception) {
                session.RollbackTransaction();
                throw;
            }
        }
Ejemplo n.º 2
0
        public bool PersonCreating_PreTransitionCRUD(string transition)
        {
            switch (transition)
            {
            case "Save":
                //session.BeginTransaction();
                if (!ASPxEdit.AreEditorsValid(popup_PersonCreate))
                {
                    return(false);
                }
                Person person = new Person(session)
                {
                    PersonId             = Guid.NewGuid(),
                    Code                 = txt_Code.Text,
                    Name                 = txt_Name.Text,
                    RowCreationTimeStamp = DateTime.Now,
                    RowStatus            = Utility.Constant.ROWSTATUS_ACTIVE
                };
                person.Save();

                foreach (TMPLoginAccount tmpAccount in Temp_LoginAccount)
                {
                    LoginAccount account = new LoginAccount(session);
                    //account.LoginAccountId = Guid.NewGuid();
                    account.Email                = tmpAccount.Email;
                    account.RowStatus            = Utility.Constant.ROWSTATUS_ACTIVE;
                    account.RowCreationTimeStamp = DateTime.Now;
                    account.PersonId             = person;
                    account.Save();
                }

                foreach (TreeListNode node in ASPxTreeList_OfDepartment.GetSelectedNodes())
                {
                    DepartmentPerson dp = new DepartmentPerson(session)
                    {
                        DepartmentId         = session.GetObjectByKey <NAS.DAL.Nomenclature.Organization.Department>(Guid.Parse(node.Key)),
                        DepartmentPersonId   = Guid.NewGuid(),
                        RowCreationTimeStamp = DateTime.Now,
                        PersonId             = person,
                        RowStatus            = Utility.Constant.ROWSTATUS_ACTIVE
                    };
                    dp.Save();
                }

                PersonId = person.PersonId;
                //session.CommitTransaction();
                return(true);
            }
            return(false);
        }
 public void Update(DepartmentPerson departmentPerson)
 {
     _departmentPersonsDAL.Update(departmentPerson);
 }
 public void Add(DepartmentPerson departmentPerson)
 {
     _departmentPersonsDAL.Add(departmentPerson);
 }
Ejemplo n.º 5
0
Archivo: Util.cs Proyecto: ewin66/dev
        /// <summary>
        /// Populate default data to database
        /// </summary>
        public static void Populate()
        {
            try
            {
                ////NAS.DAL.Accounting.AccountChart
                NAS.DAL.BI.Accounting.Account.CorrespondFinancialAccountDim.Populate();
                NAS.DAL.BI.Accounting.Account.FinancialAccountDim.Populate();
                Account.Populate();
                AccountType.Populate();
                AccountCategory.Populate();
                Currency.Populate();

                ////NAS.DAL.Accounting.Configure
                AllocationType.Populate();

                ////NAS.DAL.CMS.ObjectDocument
                ObjectType.Populate();
                CustomFieldType.Populate();
                ObjectTypeCustomField.Populate();

                ////NAS.DAL.Inventory.Item
                RecordedType.Populate();

                ////NAS.DAL.Inventory.Operation
                CommanderStockCartStatus.Populate();
                CommanderStockCartType.Populate();

                ////NAS.DAL.Inventory.StockCart
                StockCartActorType.Populate();

                ////NAS.DAL.Invoice
                TaxType.Populate();
                PromotionType.Populate();

                ////NAS.DAL.Nomenclature.Inventory
                Nomenclature.Inventory.Inventory.Populate();
                InventoryUnit.Populate();

                ////NAS.DAL.Nomenclature.Item
                ItemUnitRelationType.Populate();
                UnitType.Populate();
                Unit.Populate();
                ItemUnit.Populate();
                ItemTradingType.Populate();
                ItemCustomType.Populate();

                ////NAS.DAL.Nomenclature.Organization
                TradingCategory.Populate();
                AuthenticationProvider.Populate();
                DepartmentType.Populate();
                OrganizationType.Populate();
                Person.Populate();
                Organization.Populate();
                OwnerOrg.Populate();
                CustomerOrg.Populate();
                SupplierOrg.Populate();
                ManufacturerOrg.Populate();
                Department.Populate();
                DepartmentPerson.Populate();

                //NAS.DAL.Staging.Accounting.Journal
                AccountActorType.Populate();

                ////NAS.DAL.Vouches
                VouchesType.Populate();
                VouchesActorType.Populate();
                ReceiptVouchesType.Populate();
                PaymentVouchesType.Populate();
                ForeignCurrency.Populate();

                ////NAS.DAL.Accounting.Journal
                AccountingPeriod.Populate();
                //SalesInvoicePickingStockCart.Populate();

                ////NAS.DAL.System.ArtifactCode
                ArtifactType.Populate();
                CodeRuleDataType.Populate();
                CodeRuleDataFormat.Populate();
                RuleRepeaterType.Populate();

                //NAS.DAL.Sales.Price
                PricePolicyType.Populate();

                //NAS.DAL.Inventory.Lot.Lot
                NAS.DAL.Inventory.Lot.Lot.Populate();

                //NAS.DAL.Inventory.Command.InventoryCommandActorType
                NAS.DAL.Inventory.Command.InventoryCommandActorType.Populate();
                NAS.DAL.BI.Inventory.InventoryCommandDim.Populate();

                #region Other populate
                using (Session session = XpoHelper.GetNewSession())
                {
                    //Insert undefined supplier
                    if (!Util.isExistXpoObject <SupplierOrg>("OrganizationId",
                                                             Guid.Parse("3DEF2B62-2162-46CD-8418-DEE6F8E59E21")))
                    {
                        SupplierOrg undefinedSupplierOrg = new SupplierOrg(session)
                        {
                            OrganizationId       = Guid.Parse("3DEF2B62-2162-46CD-8418-DEE6F8E59E21"),
                            Name                 = "Mặc định",
                            Description          = "Mặc định",
                            Code                 = "MACDINH",
                            RowCreationTimeStamp = DateTime.Now,
                            RowStatus            = Constant.ROWSTATUS_ACTIVE,
                            OrganizationTypeId   =
                                NAS.DAL.Util.getDefaultXpoObject <OrganizationType>(session)
                        };
                        undefinedSupplierOrg.Save();
                    }
                }
                #endregion
            }
            catch (Exception)
            {
                throw new Exception("Populate failed");
            }
            finally
            {
            }
        }