示例#1
0
 private void Delete()
 {
     try
     {
         if (CompanyConfig.HasHrmisSystem &&
             InstanceFactory.CreateCompanyInvolveFacade().GetEmployeeBasicInfoByCompanyID(
                 Convert.ToInt32(Request.Params["DepartmentID"])).Count > 0)
         {
             throw new ApplicationException("该公司下存在员工,禁止删除!");
         }
         using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required))
         {
             _DepartmentBll.DeleteDept(Convert.ToInt32(Request.Params["DepartmentID"]), _LoginUser);
             IDepartmentHistoryFacade hrmisDepartmentHistoryFacade =
                 InstanceFactory.CreateDepartmentHistoryFacade();
             hrmisDepartmentHistoryFacade.AddDepartmentHistory(_LoginUser);
             ts.Complete();
         }
         Response.Write("success");
     }
     catch (Exception ae)
     {
         Response.Write(ae.Message);
     }
     Response.End();
 }
示例#2
0
        private void Update()
        {
            string       s;
            List <Error> errors = new List <Error>();

            Valide(errors);
            if (errors.Count <= 0)
            {
                //数据收集过程
                Department theObject =
                    new Department(Convert.ToInt32(Request.Params["DepartmentID"]), Request.Params["DepartmentName"]);
                CompleteTheObject(theObject);
                //执行事务过程
                try
                {
                    using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required))
                    {
                        Department theOldObject =
                            _DepartmentBll.GetDepartmentById(Convert.ToInt32(Request.Params["DepartmentID"]), null);
                        _DepartmentBll.UpdateDept(theObject, _LoginUser);
                        if (CompanyConfig.HasHrmisSystem)
                        {
                            if (!theOldObject.IsEqual(theObject))
                            {
                                IDepartmentHistoryFacade hrmisDepartmentHistoryFacade =
                                    InstanceFactory.CreateDepartmentHistoryFacade();
                                hrmisDepartmentHistoryFacade.AddDepartmentHistory(_LoginUser);
                            }
                            if (theOldObject.Name != theObject.Name)
                            {
                                IEmployeeHistoryFacade hrmisEmployeeHistoryFacade =
                                    InstanceFactory.CreateEmployeeHistoryFacade();
                                hrmisEmployeeHistoryFacade.AddEmployeeHistoryByDepartment(theObject, _LoginUser);
                            }
                        }
                        ts.Complete();
                    }
                    s = "[]";
                }
                catch (Exception ae)
                {
                    errors.Add(new Error("lblMessage", ae.Message));
                    s = JsonConvert.SerializeObject(errors);
                }
            }
            else
            {
                s = JsonConvert.SerializeObject(errors);
            }
            Response.Write(s);
            Response.End();
        }
示例#3
0
        private void Add()
        {
            string       s;
            List <Error> errors = new List <Error>();

            Valide(errors);
            if (errors.Count <= 0)
            {
                //数据收集过程
                Department theObject = new Department(0, "");
                CompleteTheObject(theObject);
                try
                {
                    using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required))
                    {
                        int departmentid =
                            _DepartmentBll.CreateDept(Convert.ToInt32(Request.Params["ParentDepartmentID"]), theObject,
                                                      _LoginUser);
                        if (CompanyConfig.HasHrmisSystem)
                        {
                            IDepartmentHistoryFacade hrmisDepartmentHistoryFacade =
                                InstanceFactory.CreateDepartmentHistoryFacade();
                            hrmisDepartmentHistoryFacade.AddDepartmentHistory(_LoginUser);
                        }
                        ts.Complete();
                        s = "[{DepartmentID:" + departmentid + "}]";
                    }
                }
                catch (Exception e)
                {
                    errors.Add(new Error("lblMessage", e.Message));
                    s = JsonConvert.SerializeObject(errors);
                }
            }
            else
            {
                s = JsonConvert.SerializeObject(errors);
            }
            Response.Write(s);
            Response.End();
        }
示例#4
0
        private void Move()
        {
            string       s;
            List <Error> errors = new List <Error>();

            try
            {
                using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required))
                {
                    int        parentDepid  = Convert.ToInt32(Request.Params["ParentDepartmentID"]);
                    Department theOldObject =
                        _DepartmentBll.GetDepartmentById(Convert.ToInt32(Request.Params["DepartmentID"]), null);
                    if (parentDepid != theOldObject.Id)
                    {
                        _DepartmentBll.UpdateDept(parentDepid, theOldObject, _LoginUser);
                        if (CompanyConfig.HasHrmisSystem)
                        {
                            IDepartmentHistoryFacade hrmisDepartmentHistoryFacade =
                                InstanceFactory.CreateDepartmentHistoryFacade();
                            hrmisDepartmentHistoryFacade.AddDepartmentHistory(_LoginUser);

                            IEmployeeHistoryFacade hrmisEmployeeHistoryFacade =
                                InstanceFactory.CreateEmployeeHistoryFacade();
                            hrmisEmployeeHistoryFacade.AddEmployeeHistoryByDepartment(theOldObject, _LoginUser);
                        }
                    }
                    ts.Complete();
                }
                s = "[]";
            }
            catch (Exception ae)
            {
                errors.Add(new Error("trMessage", ae.Message));
                s = JsonConvert.SerializeObject(errors);
            }

            Response.Write(s);
            Response.End();
        }