public JsonResult UpdateUserAction(MesWeb.Model.T_User user) { var retData = new VM_Result_Data(); var bllUser = new MesWeb.BLL.T_User(); retData.Content = "更新用户失败"; if (user != null) { var oldUser = bllUser.GetModel(user.UserID); if (oldUser != null) { //如果用户没有输入密码,则使用原来的密码 if (string.IsNullOrEmpty(user.Password)) { user.Password = oldUser.Password; } else { //对用户的密码进行第二次加密 user.Password = SecurityHelper.encryptMD5Pwd(user.Password); } try { if (bllUser.Update(user)) { retData.Code = RESULT_CODE.OK; retData.Content = "更新用户成功"; } } catch (Exception e) { log = LogFactory.GetLogger(MethodBase.GetCurrentMethod().DeclaringType.FullName + ":" + MethodBase.GetCurrentMethod().Name); log.Error("更新用户失败!", e); } } } return(Json(retData)); }
public JsonResult AddUserAction(MesWeb.Model.T_User user) { var retData = new VM_Result_Data(); if (!string.IsNullOrEmpty(user.UserName) && user.EmployeeID.Value > 0) { try { var bllUser = new MesWeb.BLL.T_User(); user.Password = SecurityHelper.encryptPlainPwd("123456"); if (bllUser.Add(user) > 0) { retData.Code = RESULT_CODE.OK; retData.Content = "添加用户成功"; } } catch (Exception e) { log = LogFactory.GetLogger(MethodBase.GetCurrentMethod().DeclaringType.FullName + ":" + MethodBase.GetCurrentMethod().Name); log.Error("添加用户失败!", e); } } else { retData.Content = "名称或绑定员工不能为空"; } return(Json(retData)); }
public JsonResult DeleteUser(int UserId) { var retData = new VM_Result_Data(); var bllUser = new MesWeb.BLL.T_User(); try { if (bllUser.Delete(UserId)) { retData.Code = RESULT_CODE.OK; retData.Content = "删除用户成功!"; } } catch (Exception e) { log = LogFactory.GetLogger(MethodBase.GetCurrentMethod().DeclaringType.FullName + ":" + MethodBase.GetCurrentMethod().Name); log.Error("删除用户失败!", e); } return(Json(retData)); }
public JsonResult GetSelEmployeeAction(int Id) { var bllUser = new MesWeb.BLL.T_User(); var user = bllUser.GetModel(Id); if (user != null) { var bllEmp = new MesWeb.BLL.T_Employee(); var empId = bllEmp.GetModel(user.EmployeeID.Value).EmployeeID; if (empId > 0) { return(new BasicDataController().GetSelEmployeeAction(empId)); } } log = LogFactory.GetLogger(MethodBase.GetCurrentMethod().DeclaringType.FullName + ":" + MethodBase.GetCurrentMethod().Name); log.Error("获取员工信息失败!"); return(null); }
public JsonResult Lgoin(MesWeb.Model.T_User user) { var isOpenVerify = false; var retData = new VM_Result_Data(); var bllUser = new MesWeb.BLL.T_User(); bool.TryParse(ConfigurationManager.AppSettings["openLoginVerify"], out isOpenVerify); //未开启登录验证 if (isOpenVerify == false) { retData.Code = RESULT_CODE.OK; retData.Content = "未开启登录验证,随意登录"; Session[SecurityHelper.isLoginSessionId] = bllUser.GetModelList("UserName = '******'").FirstOrDefault(); } else { retData.Content = "用户名或密码错误"; if (user != null) { var secUser = bllUser.GetModelList("UserName = '******'").FirstOrDefault(); if (secUser != null) { //允许登录 if (secUser.IsValidate == true) { user.Password = SecurityHelper.encryptMD5Pwd(user.Password); if (secUser.Password == user.Password) { //设置session Session[SecurityHelper.isLoginSessionId] = secUser; retData.Code = RESULT_CODE.OK; retData.Content = "登录成功"; } } else { retData.Content = "该用户禁止登陆,请联系管理员"; } } } } return(Json(retData)); }
public JsonResult GetUserPasswdAction(int userId) { var retData = new VM_Result_Data(); var bllUser = new MesWeb.BLL.T_User(); var user = bllUser.GetModel(userId); if (user != null) { retData.Appendix = user; user.Password = ""; retData.Code = RESULT_CODE.OK; retData.Content = "加载账号密码成功"; } else { retData.Content = "加载账号密码失败"; log = LogFactory.GetLogger(MethodBase.GetCurrentMethod().DeclaringType.FullName + ":" + MethodBase.GetCurrentMethod().Name); log.Error("加载账号密码失败!"); } return(Json(retData)); }
public JsonResult GetSelUserValidAction(int Id) { var vmCscDropList = new List <VM_CscDrop>(); var bllUser = new MesWeb.BLL.T_User(); var user = bllUser.GetModel(Id); vmCscDropList.Add(new VM_CscDrop { label = "是", value = "1" }); vmCscDropList.Add(new VM_CscDrop { label = "否", value = "0" }); if (user.IsValidate) { vmCscDropList[0].selected = true; } else { vmCscDropList[1].selected = true; } return(Json(vmCscDropList)); }
/// <summary> /// 用户配置 /// </summary> /// <returns></returns> public ActionResult UserConf() { var vmJstreeList = new List <VM_JSTree>(); var bllDept = new MesWeb.BLL.T_Department(); var bllEmp = new MesWeb.BLL.T_Employee(); var deptList = bllDept.GetModelList(""); var bllUser = new MesWeb.BLL.T_User(); var userList = bllUser.GetModelList(""); foreach (var dept in deptList) { var deptTree = new VM_JSTree { text = dept.DepartmentName, id = "dept_" + dept.DepartmentID.ToString() }; deptTree.children = new List <VM_JSTree>(); foreach (var user in userList) { if (!user.EmployeeID.HasValue) { continue; } var emp = bllEmp.GetModel(user.EmployeeID.Value); if (emp != null) { if (emp.DepartmentID == dept.DepartmentID) { deptTree.children.Add(new VM_JSTree { text = user.UserName, id = "user_" + user.UserID.ToString() }); // userList.Remove(user); } } } vmJstreeList.Add(deptTree); } return(View(vmJstreeList)); }