public bool UpdateUserPermission(string AllNodeId, string RoleCode, string UserId) { pbs_sys_PermissionsService permissionsService = new pbs_sys_PermissionsService(); bool result = false; if (AllNodeId != null && AllNodeId != "" && RoleCode != null && RoleCode != "" && UserId != null && UserId != "") { ResultInfo <bool> resultDelete = permissionsService.DeletePermissions(Utility.Util.ParseHelper.ToInt(RoleCode), Utility.Util.ParseHelper.ToInt(UserId)); if (resultDelete.Result && resultDelete.Data) { result = resultDelete.Data; } string[] ClassList = AllNodeId.Split(','); for (int i = 0; i < ClassList.Length - 1; i++) { if (ClassList[i] != "") { string NodeId = ClassList[i]; ResultInfo <bool> resultAdd = permissionsService.AddPermissions(Utility.Util.ParseHelper.ToInt(RoleCode), NodeId, Utility.Util.ParseHelper.ToInt(UserId)); if (resultAdd.Result && resultAdd.Data) { result = resultAdd.Data; } } } } return(result); }
public string GetAllRoles() { DataTable pm = new DataTable(); pbs_sys_PermissionsService permissionsService = new pbs_sys_PermissionsService(); ResultInfo <DataTable> resultAllRole = permissionsService.GetAllRole(); if (resultAllRole.Result && resultAllRole.Data != null) { pm = resultAllRole.Data; } List <MembersRole> membersRoles = new List <MembersRole>(); if (pm != null) { foreach (DataRow prow in pm.Rows) //得到行集合 { MembersRole membersRole = new MembersRole(); membersRole.RoleId = prow[0].ToString(); membersRole.RoleName = prow[1].ToString(); membersRoles.Add(membersRole); } } return(Newtonsoft.Json.JsonConvert.SerializeObject(membersRoles)); }
public ActionResult UserManagerAdd(string id) { pbs_sys_users pbsSysUsers = new pbs_sys_users(); pbsSysUsers.id = 0; pbsSysUsers.loginId = string.Empty; pbsSysUsers.userPwd = string.Empty; pbsSysUsers.nickName = string.Empty; pbsSysUsers.addTime = DateTime.Now; pbsSysUsers.remark = string.Empty; pbsSysUsers.role = 0; pbsSysUsers.address = string.Empty; pbsSysUsers.phone = string.Empty; pbsSysUsers.email = string.Empty; pbsSysUsers.photo = string.Empty; pbs_sys_usersService pbsSysUsersService = new pbs_sys_usersService(); if (!string.IsNullOrEmpty(id)) { int sid = Utility.Util.ParseHelper.ToInt(id); ResultInfo <pbs_sys_users> resultItem = pbsSysUsersService.GetModel(sid); if (resultItem.Result && resultItem.Data != null) { pbsSysUsers.id = resultItem.Data.id; pbsSysUsers.loginId = resultItem.Data.loginId; pbsSysUsers.userPwd = resultItem.Data.userPwd; pbsSysUsers.nickName = resultItem.Data.nickName; pbsSysUsers.addTime = resultItem.Data.addTime; pbsSysUsers.remark = resultItem.Data.remark; pbsSysUsers.role = resultItem.Data.role; pbsSysUsers.address = resultItem.Data.address; pbsSysUsers.phone = resultItem.Data.phone; pbsSysUsers.email = resultItem.Data.email; pbsSysUsers.photo = resultItem.Data.photo; } ViewBag.PageTitle = "修改管理员"; } else { ViewBag.PageTitle = "添加管理员"; } ViewData["RoleDt"] = null; DataTable rdt = new DataTable(); pbs_sys_PermissionsService permissionsService = new pbs_sys_PermissionsService(); ResultInfo <DataTable> resultAllRole = permissionsService.GetAllRole(); if (resultAllRole.Result && resultAllRole.Data != null) { rdt = resultAllRole.Data; ViewData["RoleDt"] = rdt; } return(View(pbsSysUsers)); }
// GET: System public ActionResult UserPermissions(string roleCode) { if (string.IsNullOrEmpty(roleCode)) { roleCode = "1"; } pbs_sys_PermissionsService permissionsService = new pbs_sys_PermissionsService(); pbs_sys_MenuService mesMenuService = new pbs_sys_MenuService(); pbs_sys_users userDate = (pbs_sys_users)Session["USER"]; MenuModels models = new MenuModels(); models.ParentItemList = new List <ParentItem>(); if (userDate != null && !string.IsNullOrEmpty(userDate.role.ToString())) { models.UserId = userDate.id.ToString(); ResultInfo <DataTable> resultPm = mesMenuService.GetThisTreeNodeMenu("#", userDate.role.ToString()); if (resultPm.Result && resultPm.Data != null) { foreach (DataRow prow in resultPm.Data.Rows) //得到行集合 { ParentItem pi = new ParentItem(); pi.NodeId = prow[0].ToString(); pi.NodeName = prow[1].ToString(); pi.NodeGroup = prow[2].ToString(); pi.ParentId = prow[3].ToString(); pi.NodeUrl = prow[4].ToString(); pi.BrotherList = new List <BrotherItem>(); ResultInfo <bool> resultExistsPi = permissionsService.ExistsPermissions(Utility.Util.ParseHelper.ToInt(roleCode), prow[0].ToString(), Utility.Util.ParseHelper.ToInt(userDate.id)); if (resultExistsPi.Result && resultExistsPi.Data) { pi.IsOrNullExists = true; } else { pi.IsOrNullExists = false; } ResultInfo <DataTable> resultBm = mesMenuService.GetThisTreeNodeMenu(pi.NodeId, userDate.role.ToString()); if (resultBm.Result && resultBm.Data != null) { foreach (DataRow brow in resultBm.Data.Rows) { BrotherItem bi = new BrotherItem(); bi.NodeId = brow[0].ToString(); bi.NodeName = brow[1].ToString(); bi.NodeGroup = brow[2].ToString(); bi.ParentId = brow[3].ToString(); bi.NodeUrl = brow[4].ToString(); bi.ChildrenList = new List <ChildrenItem>(); ResultInfo <bool> resultExistsbi = permissionsService.ExistsPermissions(Utility.Util.ParseHelper.ToInt(roleCode), brow[0].ToString(), Utility.Util.ParseHelper.ToInt(userDate.id)); if (resultExistsbi.Result && resultExistsbi.Data) { bi.IsOrNullExists = true; } else { bi.IsOrNullExists = false; } ResultInfo <DataTable> resultCm = mesMenuService.GetThisTreeNodeMenu(bi.NodeId, userDate.role.ToString()); if (resultCm.Result && resultCm.Data != null) { foreach (DataRow crow in resultCm.Data.Rows) { ChildrenItem ci = new ChildrenItem(); ci.NodeId = crow[0].ToString(); ci.NodeName = crow[1].ToString(); ci.NodeGroup = crow[2].ToString(); ci.ParentId = crow[3].ToString(); ci.NodeUrl = crow[4].ToString(); ResultInfo <bool> resultExistsci = permissionsService.ExistsPermissions(Utility.Util.ParseHelper.ToInt(roleCode), crow[0].ToString(), Utility.Util.ParseHelper.ToInt(userDate.id)); if (resultExistsci.Result && resultExistsci.Data) { ci.IsOrNullExists = true; } else { ci.IsOrNullExists = false; } bi.ChildrenList.Add(ci); } } pi.BrotherList.Add(bi); } } models.ParentItemList.Add(pi); } } } models.RoleCode = roleCode; return(View(models)); }