Example #1
0
        public override JsonResult Save()
        {
            S_HR_EmployeeRetired model = UpdateEntity <S_HR_EmployeeRetired>();
            var employee = this.ComprehensiveDbContext.Set <S_HR_Employee>().Find(model.EmployeeID);

            if (employee == null)
            {
                throw new Formula.Exceptions.BusinessValidationException("找不到该员工!");
            }
            employee.IsDeleted = "1";
            if (model.Type == "退休")
            {
                employee.EmployeeState = EmployeeState.Retire.ToString();
            }
            else if (employee.EmployeeState == EmployeeState.ReEmploy.ToString())
            {
                employee.EmployeeState = EmployeeState.ReEmployDimission.ToString();
            }
            else
            {
                employee.EmployeeState = EmployeeState.Dimission.ToString();
            }
            employee.DeleteTime = DateTime.Now;
            this.ComprehensiveDbContext.SaveChanges();
            //同步到系统用户表
            EmployeeFo fo = new EmployeeFo();

            fo.EmployeeDeleteToUser(employee);
            return(Json(new { ID = model.ID }));
            //return base.Save();
        }
Example #2
0
        public override JsonResult Delete()
        {
            string listIDs = Request["ListIDs"];

            string[] idArray = listIDs.Split(',');
            ComprehensiveDbContext.Set <S_HR_Employee>().Where(c => idArray.Contains(c.ID)).Update(c =>
            {
                c.IsDeleted  = "1";
                c.DeleteTime = DateTime.Now;
            });
            ComprehensiveDbContext.SaveChanges();
            EmployeeFo fo = new EmployeeFo();

            fo.EmployeeDeleteToUser(listIDs);
            return(Json(""));
            //return base.Delete();
        }
Example #3
0
        public JsonResult SyncSystemUser()
        {
            string Ids = Request["IDs"];

            if (string.IsNullOrWhiteSpace(Ids))
            {
                return(Json(""));
            }
            BaseEntities         baseEntities = FormulaHelper.GetEntities <BaseEntities>();
            EmployeeFo           fo           = new EmployeeFo();
            List <S_HR_Employee> employeeList = this.ComprehensiveDbContext.Set <S_HR_Employee>().Where(c => c.IsHaveAccount == "1" && Ids.Contains(c.ID)).ToList();

            if (employeeList == null || employeeList.Count == 0)
            {
                return(Json(""));
            }
            foreach (S_HR_Employee employee in employeeList)
            {
                if (string.IsNullOrEmpty(employee.UserID))
                {
                    fo.EmployeeAddToUser(employee, FormsAuthentication.HashPasswordForStoringInConfigFile(employee.Code.ToLower(), "SHA1"));
                }
                else
                {
                    var user = baseEntities.Set <S_A_User>().Find(employee.UserID);
                    if (user == null)
                    {
                        fo.EmployeeAddToUser(employee, FormsAuthentication.HashPasswordForStoringInConfigFile(employee.Code.ToLower(), "SHA1"));
                    }
                    else if (employee.IsDeleted == "0") //Update
                    {
                        fo.EmployeeUpdateToUser(employee);
                    }
                    else
                    {
                        fo.EmployeeDeleteToUser(employee);//Delete
                    }
                }
            }
            return(Json(JsonAjaxResult.Successful()));
        }