[HttpPost]//查询 public List <EasyUIDEPTTree> List(VIEW_SYS_DEPT data) { string dept_code = oc.CurrentUser.SYS_DEPT.DEPT_CODE; string parent_code = oc.CurrentUser.SYS_DEPT.PARENT_CODE; //查询条件 if (data != null && data.PARENT_CODE != null && data.PARENT_CODE != "") { dept_code = data.PARENT_CODE; if (dept_code.Length > 2) { parent_code = dept_code.Substring(0, dept_code.Length - 2); } } //if (dept_code == "01") //{ // dept_code = "0101"; // parent_code = "01"; //} Expression <Func <SYS_DEPT, bool> > slamda = m => m.DEL_FLAG == "0" && (m.PARENT_CODE.StartsWith(dept_code) || m.DEPT_CODE == dept_code); string strJson = string.Empty; //获得组织 List <SYS_DEPT> listOrgMenu = oc.BllSession.ISYS_DEPTService.Entities.Where(slamda).OrderBy(m => m.DEPT_ORDER).ThenBy(m => m.DEPT_CODE) .ToList().Select(org => org.ToPOCO()).ToList(); List <EasyUIDEPTTree> listTreeNodes = SYS_DEPT.ConvertTreeNodes(listOrgMenu, parent_code, dept_code); return(listTreeNodes); }
public AjaxMsgModel Edit(VIEW_SYS_DEPT data) { AjaxMsgModel amm = new Message().NewAmm; try { SYS_DEPT member = oc.BllSession.ISYS_DEPTService.Entities.Where(m => m.DEPT_CODE == data.DEPT_CODE).OrderBy(m => m.DEPT_CODE).FirstOrDefault(); if (member != null) { Mapper.CreateMap <SYS_DEPT, VIEW_SYS_DEPT>(); VIEW_SYS_DEPT vm = Mapper.Map <SYS_DEPT, VIEW_SYS_DEPT>(member); amm.Statu = AjaxStatu.ok; amm.Data = vm; return(amm); } else { amm.Msg = string.Format(Message.NotFound, "部门"); return(amm); } } catch (Exception) { return(amm); } }
/// <summary> /// 逻辑删除部门 /// </summary> /// <param name="DEPTCODE">逻辑删除部门ID</param> /// <returns>AjaxMsgModel实体对象</returns> public static AjaxMsgModel Del(string DEPTCODE) { AjaxMsgModel amm = new Message().NewAmm; try { if (oc.BllSession.ISYS_DEPTService.Entities.Where(o => o.DEPT_CODE == DEPTCODE).Count() == 0) { amm.Msg = string.Format(Message.NotFound, "部门"); return(amm); } if (oc.BllSession.ISYS_DEPTService.Entities.Where(m => m.DEL_FLAG == "0" && m.PARENT_CODE == DEPTCODE).Count() > 0) { amm.Msg = "请先删除此部门的下属部门!"; return(amm); } if (oc.BllSession.ISYS_MEMBERService.Entities.Where(m => m.DEL_FLAG == "0" && m.DEPT_CODE == DEPTCODE).Count() > 0) { amm.Msg = "请先删除此部门的下属人员!"; return(amm); } if (oc.BllSession.ISYS_USERService.Entities.Where(m => m.DEPT_CODE == DEPTCODE).Count() > 0) { amm.Msg = "请先删除此部门的下属用户!"; return(amm); } //以下三行是逻辑删除使用 SYS_DEPT user = oc.BllSession.ISYS_DEPTService.Entities.Where(m => m.DEPT_CODE == DEPTCODE).OrderBy(m => m.DEPT_CODE).FirstOrDefault(); user.DEL_FLAG = "1"; if (oc.BllSession.ISYS_DEPTService.UpdateEntity(user, new string[] { "DEL_FLAG" }) > 0) //int a = oc.BllSession.ISYS_DEPTService.DelByWhere(m => m.DEPT_CODE == DEPTCODE); //if (a > 0) { amm.Statu = AjaxStatu.ok; amm.Msg = string.Format(Message.OptSussess, "部门", Message.DelOpt); } else { amm.Statu = AjaxStatu.err; amm.Msg = string.Format(Message.OptFail, "部门", Message.DelOpt); } } catch (Exception) { return(amm); } return(amm); }
public void TestAdd() { using (var mDBManager = new DBManager()) { for (var i = 11; i <= 100; i++) { var entity = new SYS_DEPT(); entity.SD_ID = Guid.NewGuid(); entity.SD_NAME = "TEST" + i; entity.SD_ORDER = i; mDBManager.Add(entity); } mCurrentController.ViewBag.Message = mDBManager.Commit() ? "Ok" : mDBManager.ErrorMsg; } }
public AjaxMsgModel Save(VIEW_SYS_DEPT data) { try { Mapper.CreateMap <VIEW_SYS_DEPT, SYS_DEPT>(); SYS_DEPT u = Mapper.Map <VIEW_SYS_DEPT, SYS_DEPT>(data); //最后一个DEPT_CODE var lastCode = oc.BllSession.ISYS_DEPTService.Entities.Where(m => m.PARENT_CODE == data.PARENT_CODE).OrderByDescending(m => m.DEPT_CODE).Select(m => new { m.DEPT_CODE }).FirstOrDefault(); int lastCodeId = 1; if (lastCode != null) { lastCodeId = int.Parse(lastCode.DEPT_CODE.Substring(data.PARENT_CODE.Length, 2)) + 1; } string codeNum = lastCodeId < 10 ? "0" + lastCodeId.ToString() : lastCodeId.ToString(); u.DEL_FLAG = "0"; u.STATUS_FLAG = "0"; u.C_ICO = data.PARENT_CODE.Length == 8 ? "icon-org" : "icon-DepartMent"; if (u.DEPT_CODE == null || u.DEPT_CODE == "") { u.DEPT_CODE = data.PARENT_CODE + codeNum; u.DEPT_ORDER = 1; return(Model_SYS_DEPT.Add(u)); } else { string newDeptCode = data.PARENT_CODE + codeNum; return(Model_SYS_DEPT.Edit(u, u.DEPT_CODE, newDeptCode)); } } catch (Exception) { return(new Message().NewAmm); } }
/// <summary> /// 新增部门 /// </summary> /// <param name="UserInfo"></param> /// <returns></returns> public static AjaxMsgModel Add(SYS_DEPT orgInfo) { AjaxMsgModel amm = new Message().NewAmm; try { if (oc.BllSession.ISYS_DEPTService.Entities.Where(o => o.DEPT_CODE == orgInfo.PARENT_CODE).Count() == 0) { amm.Statu = AjaxStatu.err; amm.Msg = string.Format(Message.NotFound, "隶属部门"); return(amm); } if (oc.BllSession.ISYS_DEPTService.Entities.Where(m => m.DEPT_NAME == orgInfo.DEPT_NAME && m.PARENT_CODE == orgInfo.PARENT_CODE).ToList().Count > 0) { amm.Statu = AjaxStatu.err; amm.Msg = string.Format(Message.YesFound, "部门名称"); return(amm); } if (oc.BllSession.ISYS_DEPTService.AddEntity(orgInfo) > 0) { amm.Statu = AjaxStatu.ok; amm.Msg = string.Format(Message.OptSussess, "部门", Message.AddOpt); } else { amm.Statu = AjaxStatu.err; amm.Msg = string.Format(Message.OptFail, "部门", Message.AddOpt); } } catch (Exception) { return(amm); } return(amm); }
public static AjaxMsgModel LoginIn(string strLoginName, string strLoginPwd, string strYzm, string iseasyPasword) { AjaxMsgModel amm = new Message().NewAmm; if (strYzm.ToUpper() != "ZZZZZ") { if (!strYzm.Equals(oc.CurrentUserVcode)) { amm.Msg = string.Format(Message.InvalidReEnter, "验证码"); return(amm); } } #region 隐藏超级用户 if (strLoginName.Equals(Constant.SystemSuperAdminName) && strLoginPwd.Equals(Constant.SystemSuperAdminPsd)) { //获取最高级别的部门 SYS_DEPT dept = oc.BllSession.ISYS_DEPTService.Entities.Where(d => d.PARENT_CODE.Equals(Constant.highestDeptParID) && d.DEL_FLAG == "0").FirstOrDefault(); //如果用户名称密码都正确那么就把用户信息放入Session中 oc.CurrentUser = new SYS_USER { USER_NAME = strLoginName, ZSNAME = "超级用户", SYS_DEPT = dept }; /** * 保存当前用户的菜单权限信息 */ oc.UserMenuPermission = Model_SYS_MENU.GetSuperAdminPermission(); //创建Cookie保存登录用户信息 oc.CurrentUserName = strLoginName; amm.Statu = AjaxStatu.ok; //amm.Msg = "登录成功"; amm.Msg = string.Format(Message.OptSussess, string.Empty, "登录"); //amm.BackUrl = "/SYS/Navigation/Index"; amm.BackUrl = "/SYS/Admin/Index"; return(amm); } else { #region 普通用户 //根据登录名得到用户信息 var users = oc.BllSession.ISYS_USERService.Entities.Where(u => u.USER_NAME == strLoginName).Select(u => new { DEPT_CODE = u.DEPT_CODE, USER_NAME = u.USER_NAME, PASSWORD = u.PASSWORD, DEPT_NAME = u.SYS_DEPT.DEPT_NAME, //部门名称 PARENT_CODE = u.SYS_DEPT.PARENT_CODE, //部门父ID MANAGE_DEPT_CODE = u.MANAGE_DEPT_CODE, //管理部门ID ZSNAME = u.ZSNAME }).ToList(); if (users.Count > 0) { var cUsr = users.First(); //string pass = DataHelper.TOMD5(strLoginPwd); if (cUsr != null && cUsr.PASSWORD == DataHelper.TOMD5(strLoginPwd)) { //如果用户名称密码都正确那么就把用户信息放入Session中 oc.CurrentUser = new SYS_USER { USER_NAME = cUsr.USER_NAME, MANAGE_DEPT_CODE = cUsr.MANAGE_DEPT_CODE, ZSNAME = cUsr.ZSNAME, SYS_DEPT = new SYS_DEPT { DEPT_NAME = cUsr.DEPT_NAME, DEPT_CODE = cUsr.DEPT_CODE, PARENT_CODE = cUsr.PARENT_CODE } }; /** * 保存当前用户的菜单权限信息 */ oc.UserMenuPermission = Model_SYS_MENU.GetUserPermission(cUsr.USER_NAME); //创建Cookie保存登录用户信息 oc.CurrentUserName = cUsr.USER_NAME; //返回登录成功的信息,并跳转到管理端首页 amm.Statu = AjaxStatu.ok; //amm.Msg = "登录成功"; amm.Msg = string.Format(Message.OptSussess, string.Empty, "登录"); //amm.BackUrl = "/SYS/Navigation/Index"; amm.BackUrl = "/SYS/Admin/Index/" + iseasyPasword; return(amm); } else { //返回登录失败的信息 amm.Statu = AjaxStatu.err; amm.Msg = string.Format(Message.InvalidReEnter, "密码"); return(amm); } } else { amm.Statu = AjaxStatu.err; amm.Msg = string.Format(Message.NotFound, "用户名"); return(amm); } #endregion 普通用户 } #endregion }
/// <summary> /// 修改部门 /// </summary> /// <param name="orgInfo">用户</param> /// <returns>AjaxMsgModel实体对象</returns> public static AjaxMsgModel Edit(SYS_DEPT orgInfo, string upid, string newDeptCode) { AjaxMsgModel amm = new Message().NewAmm; try { if (oc.BllSession.ISYS_DEPTService.Entities.Where(o => o.DEPT_CODE == orgInfo.PARENT_CODE).Count() == 0) { amm.Statu = AjaxStatu.err; amm.Msg = string.Format(Message.NotFound, "隶属部门"); return(amm); } SYS_DEPT org = oc.BllSession.ISYS_DEPTService.Entities.Where(m => m.DEPT_CODE == upid).OrderBy(m => m.DEPT_CODE).FirstOrDefault(); if (org.PARENT_CODE == orgInfo.PARENT_CODE)//如果在同一级下则修改 { orgInfo.DEPT_CODE = org.DEPT_CODE; if (oc.BllSession.ISYS_DEPTService.Entities.Where(u => u.DEPT_CODE != orgInfo.DEPT_CODE && u.DEPT_NAME == orgInfo.DEPT_NAME && u.PARENT_CODE == orgInfo.PARENT_CODE).ToList().Count > 0) { amm.Statu = AjaxStatu.err; amm.Msg = string.Format(Message.YesFound, "部门名称"); return(amm); } // Expression<Func<SYS_DEPT, object>>[] ignoreProperties = // new Expression<Func<SYS_DEPT, object>>[] { //p=>p.SYS_MEMBER,p=>p.SYS_USER,p=>p.JOB_PLAN_APPROVAL,p=>p.GATE_BDATA_CARD,p=>p.GATE_BDATA_CLIENT, // p=>p.GATE_BDATA_GATE,p=>p.GATE_JOB_PLAN, p=>p.TOOL_BDATE_STOREHOURSE,p=>p.TOOL_JOB_PLAN, // p=>p.TOOL_JOB_PLAN_IMPORT,p=>p.TOOL_TOOLMNG_INOUT,p=>p.RULE_PROBLEM, // p=>p.RULE_PROBLEM_BLAME}; if (oc.BllSession.ISYS_DEPTService.UpdateEntity(orgInfo, new string[] { "DEPT_NAME", "PARENT_CODE", "C_ICO", "STATUS_FLAG", "DEL_FLAG", "NOTE", "DEPT_FLAG" }) > 0) { amm.Statu = AjaxStatu.ok; amm.Msg = string.Format(Message.OptSussess, "部门", Message.EditOpt); } else { amm.Statu = AjaxStatu.err; amm.Msg = string.Format(Message.OptFail, "部门", Message.EditOpt); } } else//如果更换级别则先删后加 { if (oc.BllSession.ISYS_DEPTService.Entities.Where(m => m.PARENT_CODE == upid).Count() > 0) { amm.Statu = AjaxStatu.err; amm.Msg = "该部门下已经有下属部门,暂不能更换隶属部门!"; return(amm); } if (oc.BllSession.ISYS_MEMBERService.Entities.Where(m => m.DEL_FLAG == "0" && m.DEPT_CODE == upid).Count() > 0) { amm.Statu = AjaxStatu.err; amm.Msg = "该部门下已经有人员,暂不能更换隶属部门!"; return(amm); } if (oc.BllSession.ISYS_USERService.Entities.Where(m => m.DEPT_CODE == upid).Count() > 0) { amm.Statu = AjaxStatu.err; amm.Msg = "该部门下已经有用户,暂不能更换隶属部门!"; return(amm); } if (oc.BllSession.ISYS_DEPTService.Entities.Where(m => m.DEPT_NAME == orgInfo.DEPT_NAME && m.PARENT_CODE == orgInfo.PARENT_CODE).ToList().Count > 0) { amm.Statu = AjaxStatu.err; amm.Msg = string.Format(Message.YesFound, "部门名称"); return(amm); } int a = oc.BllSession.ISYS_DEPTService.DelByWhere(m => m.DEPT_CODE == upid);//删除原来的 if (a > 0) { orgInfo.DEPT_CODE = newDeptCode;//更换新的编码 if (oc.BllSession.ISYS_DEPTService.AddEntity(orgInfo) > 0) { amm.Statu = AjaxStatu.ok; amm.Msg = string.Format(Message.OptSussess, "部门", Message.EditOpt); } else { amm.Statu = AjaxStatu.err; amm.Msg = string.Format(Message.OptFail, "部门", Message.EditOpt); } } else { amm.Statu = AjaxStatu.err; amm.Msg = string.Format(Message.OptFail, "部门", Message.EditOpt); return(amm); } } } catch (Exception) { return(amm); } return(amm); }
/// <summary> /// 获取气象监测线名树 /// </summary> /// <param name="DEPT_CODE"></param> /// <param name="PARENT_CODE"></param> /// <returns></returns> public static string GetWeatherLineTree(string DEPT_CODE, string PARENT_CODE) { Dictionary <string, string> deptDict = new Dictionary <string, string>(); if (DEPT_CODE.Length == 2) { IQueryable <SYS_DEPT> dic = oc.BllSession.ISYS_DEPTService.Entities.Where(m => m.DEL_FLAG == "0" && m.DEPT_CODE.Length <= 4); foreach (var item in dic) { deptDict.Add(item.DEPT_CODE, item.DEPT_NAME); } } string strJson = string.Empty; List <SYS_DEPTANDMEMBER_TEMP> listorgHost = new List <SYS_DEPTANDMEMBER_TEMP>(); //获取主机 List <BROKENRAIL_BDATA_SECTION> listHost = oc.BllSession.IBROKENRAIL_BDATA_SECTIONService .GetListByCondition <string>(g => g.DEPT_CODE.StartsWith(DEPT_CODE), g => g.SECTION_ID).ToList(); listHost = listHost.OrderBy(o => o.START_MILE).ToList(); //cwb List <BROKENRAIL_BDATA_DEVICE> listDevice = oc.BllSession.IBROKENRAIL_BDATA_DEVICEService.Entities.Where(o => o.TYPE == "主机").ToList(); if (listHost.Count > 0) { foreach (BROKENRAIL_BDATA_SECTION host in listHost) { string head = string.Empty; if (DEPT_CODE.Length == 2) { head = deptDict[host.DEPT_CODE]; } listorgHost.Add(new SYS_DEPTANDMEMBER_TEMP { ORGRY_CODE = host.SECTION_ID, PARENT_CODE = host.LINE_NAME, ORGRY_NAME = host.SECTION_NAME, ICO = "icon-drive", RYMOBILE = head + "(" + GetToKDESC(host.START_MILE) + "~" + GetToKDESC(host.END_MILE) + ")", STATE = "0", //cwb // PHONE = host.SECTION_ID//oc.BllSession.IBROKENRAIL_BDATA_DEVICEService.Entities.Where(o => o.SECTION_ID == host.SECTION_ID && o.TYPE == "主机").FirstOrDefault().POINT_NO PHONE = listDevice.Where(o => o.SECTION_ID == host.SECTION_ID).FirstOrDefault().POINT_NO }); } } List <string> line = oc.BllSession.IBROKENRAIL_BDATA_SECTIONService.Entities.Select(o => o.LINE_NAME).Distinct().ToList(); IQueryable <T_JOB_LINE> listLineMenu = oc.BllSession.IT_JOB_LINEService.Entities.Where(o => o.LINE_DEPTCODE.Contains(DEPT_CODE)); foreach (var item in listLineMenu) { if (!line.Contains(item.LINE_NAME)) { line.Insert(line.Count, item.LINE_NAME); } } SYS_DEPT dept = oc.BllSession.ISYS_DEPTService.Entities.Where(m => m.DEL_FLAG == "0" && m.DEPT_CODE == DEPT_CODE).FirstOrDefault(); //List<SYS_DEPT> listMenu = oc.BllSession.ISYS_DEPTService.Entities // .Where(m => m.DEL_FLAG == "0" && (m.PARENT_CODE.StartsWith(DEPT_CODE) || m.DEPT_CODE == DEPT_CODE)) // .OrderBy(m => m.DEPT_ORDER).ThenBy(m => m.DEPT_CODE).ToList(); if (dept != null) { listorgHost.Add(new SYS_DEPTANDMEMBER_TEMP() { ORGRY_CODE = dept.DEPT_CODE, PARENT_CODE = dept.PARENT_CODE, ORGRY_NAME = dept.DEPT_NAME, ICO = "icon-DepartMent", RYMOBILE = "", STATE = "0"//0关闭 }); if (listLineMenu.Count() > 0) { foreach (var org in line) { listorgHost.Add(new SYS_DEPTANDMEMBER_TEMP() { ORGRY_CODE = org, PARENT_CODE = DEPT_CODE, ORGRY_NAME = org, ICO = "icon-DepartMent", RYMOBILE = "", STATE = "0"//0关闭 }); } } } List <ZTreeNode> listTreeNodes = SYS_DEPTANDMEMBER_TEMP.ConvertZTreeNodes(listorgHost, PARENT_CODE, DEPT_CODE, true); strJson = ObjToJson.GetToJson(listTreeNodes).Replace("Checked", "checked"); return(strJson); }