public JsonApproveEmployPassEntity ApproveEmployPass() { JsonApproveEmployPassEntity result = new JsonApproveEmployPassEntity(); long id = CommonHelper.GetPostValue("id").ToLong(-1); int status = CommonHelper.GetPostValue("status").ToInt(-1); if (id < 0 || status < 0) { result.ErrorCode = "E001"; result.ErrorMessage = "获得信息不全!"; return(result); } T_BG_User user = _bgUserService.GetUserById(id); if (user == null) { result.ErrorCode = "E002"; result.ErrorMessage = "该角色已经被删除!"; return(result); } if (user.Status != 0) { result.ErrorCode = "E004"; result.ErrorMessage = "该角色已经修改,请刷新页面!"; return(result); } user.Status = status; user.ApproveTime = DateTime.Now; user.ApproveName = LoginHelper.UserName; bool success = _bgUserService.Update(user); if (success) { result.ErrorCode = "E000"; result.ErrorMessage = "成功"; } else { result.ErrorCode = "E003"; result.ErrorMessage = "更新失败!"; } return(result); }
public JsonResult Pass() { JsonUserPassEntity json = new JsonUserPassEntity(); long id = CommonHelper.GetPostValue("id").ToLong(-1L); int state = CommonHelper.GetPostValue("state").ToInt(0); if (id < 0) { json.ErrorCode = "E001"; json.ErrorMessage = "参数不全!"; return(Json(json)); } T_BG_User user = _bgUserService.GetUserById(id); if (user == null) { json.ErrorCode = "E002"; json.ErrorMessage = "未获得该对象,请刷新页面!"; return(Json(json)); } user.Status = state; user.ApproveName = LoginHelper.UserName; user.ApproveTime = DateTime.Now; bool result = _bgUserService.Update(user); if (result) { json.ErrorCode = "E000"; json.ErrorMessage = "成功!"; } else { json.ErrorCode = "E002"; json.ErrorMessage = "失败,请刷新页面!"; } return(Json(json)); }
/// <summary> /// 添加或者修改用户 /// </summary> /// <returns></returns> public JsonResult AddOrUpdateUser() { JsonUserAddUserEntity json = new JsonUserAddUserEntity(); string realname = CommonHelper.GetPostValue("realname"); int gender = CommonHelper.GetPostValue("gender").ToInt(-1); long positionId = CommonHelper.GetPostValue("positionId").ToLong(-1); DateTime entryDate = CommonHelper.GetPostValue("entryDate").ToDateTime(DateTime.MaxValue); string identity = CommonHelper.GetPostValue("identity"); string phone = CommonHelper.GetPostValue("phone"); long educationId = CommonHelper.GetPostValue("educationId").ToLong(-1); long householdId = CommonHelper.GetPostValue("householdId").ToLong(-1); string school = CommonHelper.GetPostValue("school"); string email = CommonHelper.GetPostValue("email"); string emergency = CommonHelper.GetPostValue("emergency"); string address = CommonHelper.GetPostValue("address"); string remark = CommonHelper.GetPostValue("remark"); int add = CommonHelper.GetPostValue("add").ToInt(0); //0=添加 1=修改 long id = CommonHelper.GetPostValue("id").ToLong(-1); if ((string.IsNullOrEmpty(realname) || gender == -1 || positionId == -1 || entryDate == DateTime.MaxValue || string.IsNullOrEmpty(identity) || householdId == -1 || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(emergency) || string.IsNullOrEmpty(address)) || (add == 1 && id < 0)) { json.ErrorCode = "E001"; json.ErrorMessage = "参数不全!"; return(Json(json)); } realname = HttpUtility.UrlDecode(realname); school = HttpUtility.UrlDecode(school); emergency = HttpUtility.UrlDecode(emergency); address = HttpUtility.UrlDecode(address); remark = HttpUtility.UrlDecode(remark); T_BG_User user = null; if (add == 0) { user = new T_BG_User(); } else { user = _bgUserService.GetUserById(id); if (user == null) { json.ErrorCode = "E003"; json.ErrorMessage = "未获得该修改对象!"; return(Json(json)); } } T_BG_Position p = _bgPositionService.GetByPositionId(positionId); if (p == null) { json.ErrorCode = "E003"; json.ErrorMessage = "未获得该修改员工职位信息!"; return(Json(json)); } user.RealName = realname; user.Gender = gender; user.PositionId = positionId; user.EntryDate = entryDate; user.IP = identity; user.Phone = phone; user.EducationId = educationId; user.HouseholdId = householdId; user.School = school; user.Email = email; user.Emergency = emergency; user.Address = address; user.Remark = remark; user.Lvl = p.Lvl; bool result = false; if (add == 0) { user.DepartmentId = LoginHelper.DepartmentId; user.Status = 0; user.AddTime = DateTime.Now; user.IsDel = 0; user.AreaId = LoginHelper.AreaId; user.ShopID = LoginHelper.ShopID; //这个后期可能需要修改 user.RoleID = 2; result = _bgUserService.Add(user); } else { result = _bgUserService.Update(user); } if (result) { json.ErrorCode = "E000"; json.ErrorMessage = "成功!"; } else { json.ErrorCode = "E002"; json.ErrorMessage = "数据库操作失败!"; } return(Json(json)); }