protected void permission() { FunctionBll functionBll = new FunctionBll(); User user = (User)Session["user"]; Role role = new Role(); role = user.RoleId; int roleId = role.RoleId; dsPer = functionBll.SelectByRoleId(roleId); for (int i = 0; i < dsPer.Tables[0].Rows.Count; i++) { if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 1) { funcOrg = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 2) { funcRole = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 3) { funcUser = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 4) { funcGoods = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 5) { funcCustom = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 6) { funcLibrary = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 7) { funcBook = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 8) { funcPut = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 9) { funcOut = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 10) { funcSale = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 11) { funcSaleOff = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 12) { funcReturn = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 13) { funcSupply = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 14) { funcRetail = true; } } }
/// <summary> /// 权限控制 /// </summary> protected void permission() { userName = user.UserName; regionName = user.ReginId.RegionName; Role role = new Role(); role = user.RoleId; int roleId = role.RoleId; dsPer = functionBll.SelectByRoleId(roleId); string userId = user.UserId; DataSet dsRole = roleBll.selectRole(userId); string roleName = dsRole.Tables[0].Rows[0]["roleName"].ToString(); if (roleName == "超级管理员") { isAdmin = true; } for (int i = 0; i < dsPer.Tables[0].Rows.Count; i++) { if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 1) { funcOrg = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 2) { funcRole = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 3) { funcUser = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 4) { funcGoods = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 5) { funcCustom = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 6) { funcLibrary = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 7) { funcBook = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 8) { funcPut = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 9) { funcOut = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 10) { funcSale = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 11) { funcSaleOff = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 12) { funcReturn = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 13) { funcSupply = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 14) { funcRetail = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 15) { funcBookStock = true; } } }
/// <summary> /// 获取数据 /// </summary> protected string getData() { currentPage = Convert.ToInt32(Request["page"]); if (currentPage == 0) { currentPage = 1; } search = Request["search"]; if (search != "" && search != null) { search = String.Format(" roleName like '%{0}%'", search); } else { search = ""; } //获取分页数据 TableBuilder tbd = new TableBuilder(); tbd.StrTable = "T_Role"; tbd.OrderBy = "roleId"; tbd.StrColumnlist = "roleId,roleName"; tbd.IntPageSize = pageSize; tbd.StrWhere = search; tbd.IntPageNum = currentPage; //获取展示的用户数据 ds = userBll.selectByPage(tbd, out totalCount, out intPageCount); //生成table StringBuilder sb = new StringBuilder(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { int roleId = Convert.ToInt32(ds.Tables[0].Rows[i]["roleId"].ToString()); DataSet dsFunc = funBll.SelectByRoleId(roleId); string function = "", functions = "", funId = "", funIds = ""; int k = dsFunc.Tables[0].Rows.Count; int rows = 0; if (k > 0) { for (int j = 0; j < k; j++) { funId = dsFunc.Tables[0].Rows[j]["functionId"].ToString() + ","; function = dsFunc.Tables[0].Rows[j]["functionName"].ToString() + ","; functions = functions + function; funIds = funIds + funId; } functions = functions.Substring(0, functions.Length - 1); string[] row = functions.Split(','); rows = row.Length; } sb.Append("<tr><td>" + (i + 1 + ((currentPage - 1) * pageSize)) + "</td>"); sb.Append("<td>" + ds.Tables[0].Rows[i]["roleName"].ToString() + "</ td >"); sb.Append("<td style='width:500px;'>" + functions + "</ td >"); sb.Append("<td><input type='hidden' value='" + rows + "' />"); sb.Append("<input type='hidden' value='" + ds.Tables[0].Rows[i]["roleId"].ToString() + "' />"); sb.Append("<input type = 'hidden' value = '" + funIds + "' />"); sb.Append("<button class='btn btn-warning btn-sm btn-edit' data-toggle='modal' data-target='#myModa2'><i class='fa fa-pencil fa-lg'></i></button>"); sb.Append("<button class='btn btn-danger btn-sm btn-delete'><i class='fa fa-trash-o fa-lg'></i></button></td></ tr >"); } sb.Append("<input type='hidden' value='" + intPageCount + "' id='intPageCount' />"); string op = Request["op"]; if (op == "paging") { Response.Write(sb.ToString()); Response.End(); } return(sb.ToString()); }