Ejemplo n.º 1
0
        protected void trlDepartment_NodeInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
        {
            e.NewValues["RowCreationTimeStamp"] = DateTime.Now;
            e.NewValues["RowStatus"]            = Constant.ROWSTATUS_ACTIVE;
            NAS.DAL.Nomenclature.Organization.DepartmentType departmenttype =
                Util.getXPCollection <NAS.DAL.Nomenclature.Organization.DepartmentType>(session, "Name", NAS.DAL.Nomenclature.Organization.DepartmentTypeConstant.NAAN_DEFAULT.Value).FirstOrDefault();
            e.NewValues["DepartmentTypeId"]   = departmenttype;
            e.NewValues["OrganizationId!Key"] = Utility.CurrentSession.Instance.AccessingOrganizationId.ToString();
            string parentKey = trlDepartment.NewNodeParentKey;

            if (parentKey.Equals(String.Empty))
            {
                e.NewValues["ParentDepartmentId!Key"] = trlDepartment.RootValue;
            }
        }
Ejemplo n.º 2
0
        public static void Populate()
        {
            Session session = null;

            try
            {
                session = XpoHelper.GetNewSession();
                //insert default data into Organization table
                if (!Util.isExistXpoObject <Department>("Code", Utility.Constant.NAAN_DEFAULT_CODE))
                {
                    XPQuery <Organization>   organizationQuery   = session.Query <Organization>();
                    XPQuery <DepartmentType> departmentTypeQuery = session.Query <DepartmentType>();

                    DepartmentType.Populate();
                    Organization.Populate();

                    Organization organization =
                        organizationQuery.Where(r => r.Code == Utility.Constant.NAAN_DEFAULT_CODE).FirstOrDefault();

                    DepartmentType departmentType =
                        departmentTypeQuery.Where(r => r.Code == Utility.Constant.NAAN_DEFAULT_CODE).FirstOrDefault();

                    Department department = new Department(session)
                    {
                        Code                 = Utility.Constant.NAAN_DEFAULT_CODE,
                        Name                 = Utility.Constant.NAAN_DEFAULT_NAME,
                        DepartmentTypeId     = departmentType,
                        OrganizationId       = organization,
                        Description          = "",
                        RowStatus            = -1,
                        RowCreationTimeStamp = DateTime.Now
                    };

                    department.Save();
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (session != null)
                {
                    session.Dispose();
                }
            }
        }
Ejemplo n.º 3
0
        public static void Populate()
        {
            Session session = null;

            try
            {
                session = XpoHelper.GetNewSession();
                //insert default data into DepartmentType table
                if (!Util.isExistXpoObject <DepartmentType>("Code", Utility.Constant.NAAN_DEFAULT_CODE))
                {
                    DepartmentType departmentType = new DepartmentType(session)
                    {
                        Code                 = Utility.Constant.NAAN_DEFAULT_CODE,
                        Name                 = Utility.Constant.NAAN_DEFAULT_NAME,
                        Description          = "",
                        RowStatus            = -1,
                        RowCreationTimeStamp = DateTime.Now
                    };
                    departmentType.Save();
                }

                //insert SUPPER_USER department type
                if (!Util.isExistXpoObject <DepartmentType>("Code", "SUPPER_USER"))
                {
                    DepartmentType departmentType = new DepartmentType(session)
                    {
                        Code                 = "SUPPER_USER",
                        Name                 = "SUPPER_USER",
                        Description          = "Quản trị viên tổ chức",
                        RowStatus            = 1,
                        RowCreationTimeStamp = DateTime.Now
                    };
                    departmentType.Save();
                }

                //insert ORPHAN department type
                if (!Util.isExistXpoObject <DepartmentType>("Code", "ORPHAN"))
                {
                    DepartmentType departmentType = new DepartmentType(session)
                    {
                        Code                 = "ORPHAN",
                        Name                 = "ORPHAN",
                        Description          = "Chưa được phân bổ vào tổ chức",
                        RowStatus            = 1,
                        RowCreationTimeStamp = DateTime.Now
                    };
                    departmentType.Save();
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (session != null)
                {
                    session.Dispose();
                }
            }
        }