public bool Update(HR_Stuff model) { if (instance.Update(model) > 0) { return(true); } return(false); }
public bool Add(HR_Stuff model) { if (instance.Add(model) > 0) { return(true); } return(false); }
/// <summary> /// 角色权限分配 /// </summary> /// <param name="UCode"></param> /// <param name="role"></param> /// <returns></returns> public ActionResult AllotRole(string UCode, string role) { HR_Stuff stuff = hrInstance.GetModel(string.Format("AND Stuff_Code='{0}'", UCode)); Sys_Role rl = rInstance.GetModel(string.Format("AND SRole_Code='{0}'", role)); stuff.Stuff_Role = rl.SRole_Code; stuff.Stuff_RoleName = rl.SRole_Name; hrInstance.Update(stuff); return(new JsonResult { Data = new { result = "success", Msg = "数据更新成功!" } }); }
public ActionResult StuffOperation(HR_Stuff model) { var flag = false; //如果Dict_ID 为0,则表示为添加 if (model.Stuff_ID == 0) { var temp = hrInstance.GetModel(string.Format(" AND Stuff_UserName='******'", model.Stuff_UserName)); if (temp != null) { return(Json(new { result = "fail", Msg = "当前用户名已存在,请确认!" })); } model.Stuff_Password = Md5.MD5(model.Stuff_Password); flag = hrInstance.Add(model); } else { var oldstuff = hrInstance.GetModel(string.Format("AND Stuff_Code='{0}'", model.Stuff_Code)); var temp = hrInstance.GetModel(string.Format(" AND Stuff_UserName='******'", model.Stuff_UserName)); if (temp != null && oldstuff.Stuff_UserName != temp.Stuff_UserName) { return(Json(new { result = "fail", Msg = "当前用户名已存在,请确认!" })); } if (!string.IsNullOrEmpty(model.Stuff_Password)) { if (model.Stuff_Password != oldstuff.Stuff_Password) { model.Stuff_Password = Md5.MD5(model.Stuff_Password); } } else { model.Stuff_Password = oldstuff.Stuff_Password; } flag = hrInstance.Update(model); } if (flag) { return(Json(new { result = "success", target = model })); } else { return(Json(new { result = "fail" })); } }
/// <summary> /// 获取用户所拥有的区域权限 /// </summary> /// <param name="usercode"></param> /// <returns></returns> public List <Sys_UserPermission> GetUserPermissionForArea(string usercode) { HR_Stuff stuff = sInstance.GetModel(string.Format("AND Stuff_Code='{0}'", usercode)); var list = instance.GetUserPerimissionEx(string.Format("AND isnull(Fun_iType,'') in ('Area','Station') AND PU_UserCode='{0}'", usercode)); if (stuff == null || string.IsNullOrEmpty(stuff.Stuff_Role)) { return(new List <Sys_UserPermission>()); } if (!string.IsNullOrEmpty(stuff.Stuff_Role)) { var list2 = instance.GetUserPerimissionEx(string.Format("AND isnull(Fun_iType,'') in ('Area','Station') AND PU_UserCode='{0}'", stuff.Stuff_Role)); var result = list.Union(list2); return(result.Distinct(new CommonEqualityComparer <Sys_UserPermission, string>(o => o.PU_FunCode)).ToList()); } else { return(list); } }
//登陆 public ActionResult LoginBtn() { //TODO:corporation string result = "fail"; string msg = string.Empty; string company = Request["company"]; string userName = Request["userName"]; string userPwd = Request["pwd"]; //string userRole = Request["role"]; //string result = ""; if (!Net.CheckConn()) { return(Json(new { result = result, msg = "无法连接到服务器!请检查网络情况。" })); } try { if (userName == null || userPwd == null) { result = "fail"; msg = "用户名或密码不能为空"; //return Content("Null"); } else { //TODO:1.4 //得到公司 string pwd = Md5.MD5(userPwd); //角色Stuff_LoginType and Stuff_LoginType='" + userRole + "' //HR_Stuff = instanceHR_Stuff.GetModel(string.Format(" and Stuff_UserName='******' and Stuff_Password='******'",userName,pwd)); Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("Stuff_UserName", userName); dic.Add("Stuff_Password", pwd); HR_Stuff = instanceHR_Stuff.GetModel(string.Format("AND Stuff_UserName=@Stuff_UserName AND Stuff_Password=@Stuff_Password"), dic); if (HR_Stuff == null) { result = "fail"; msg = "用户名或密码不正确 "; } else { //用户名 this.SetSession <string>("UserName", HR_Stuff.Stuff_Name); //员工编码 this.SetSession <string>("UserId", HR_Stuff.Stuff_Code); //员工登录名 this.SetSession <string>("LoginName", HR_Stuff.Stuff_UserName); //登录IP this.SetSession <string>("IP", HttpContext.Request.UserHostAddress); //部门信息 HR_Department = instanceHR_Department.GetModel(" and Dept_Code='" + HR_Stuff.Stuff_DepCode + "'"); if (HR_Department != null) { //部门id this.SetSession <string>("DeptId", HR_Department.Dept_Code.ToString()); //部门名称 this.SetSession <string>("DeptName", HR_Department.Dept_Name); //用户角色 this.SetSession <string>("UserRole", HR_Stuff.Stuff_LoginType); //DODO:hao HR_Department fagTemp = instanceHR_Department.GetModel(" and Dept_Code='" + HR_Department.Dept_PCode.ToString() + "'"); while (!string.IsNullOrEmpty(fagTemp.Dept_PCode)) { fagTemp = instanceHR_Department.GetModel(" and Dept_Code='" + fagTemp.Dept_PCode + "'"); } string companyUser = fagTemp.Dept_Name.ToString(); //公司编码 string companyCode = fagTemp.Dept_Code.ToString(); //this.SetSession<string>("Company", company); this.SetSession <string>("CompanyCode", companyCode); //部门编码 this.SetSession <string>("DeptCode", HR_Department.Dept_Code); //TODO:得到公司问题 //companyCode=new BLL.Bll_HR_Department().GetCompanyName("" + HR_Department.Dept_Code + ""); this.SetSession <string>("Company", companyUser); result = "success"; msg = ""; } else { result = "fail"; msg = "用户信息配置错误"; } } } } catch (System.Exception ex) { result = "fail"; msg = "网络连接不通,请重试"; //CommLog.Error(ex.Message); //PlateLog.Write("连接异常:", PlateLog.LogMessageType.Error,ex); } //写入登录日志 //Bll_Comm.LoginLog(userName,msg); return(Json(new { result = result, msg = msg })); }