/// <summary> /// 获取用户组 /// </summary> /// <param name="RoleId">用户组Id</param> /// <returns>返回用户组</returns> public MasterRole GetRole(int RoleId) { MasterRole role = null; try { string sql = "select * from manager_role where id=@RoleId"; SqlParameter[] sp = new SqlParameter[] { new SqlParameter("@RoleId", RoleId) }; using (SqlDataReader reder = db.GetReader(sql, sp)) { while (reder.Read()) { role = new MasterRole((int)reder["id"], reder["role_name"].ToString()); } } } catch (SqlException ex) { throw new Exception("数据库异常!原因:" + ex.Message); } catch (Exception ex) { throw new Exception("未知异常!原因:" + ex.Message); } return role; }
/// <summary> /// 获取权限组数据 /// </summary> /// <returns>返回管理员日志数据集</returns> public List<MasterRole> GetAllMasterRole() { List<MasterRole> list = new List<MasterRole>(); try { string sql = "select * from manager_role"; using (SqlDataReader reder = db.GetReader(sql)) { while (reder.Read()) { MasterRole ml = new MasterRole(); ml.RoleId = (int)reder["id"]; ml.RoleName = reder["role_name"].ToString(); list.Add(ml); } } } catch (SqlException ex) { throw new Exception("数据库异常!原因:" + ex.Message); } catch (Exception ex) { throw new Exception("未知异常!原因:" + ex.Message); } return list; }
/// <summary> /// 通过分页获取权限组数据 /// </summary> /// <param name="PageSize">页大小</param> /// <param name="PageNum">页码</param> /// <param name="WhereStr">条件</param> /// <param name="OrderBy">排序</param> /// <returns>返回管理员日志数据集</returns> public List<MasterRole> GetAllMasterRole(int PageSize, int PageNum, string WhereStr, string OrderBy) { List<MasterRole> list = new List<MasterRole>(); try { SqlParameter[] sp = new SqlParameter[] { new SqlParameter("@PageSize",PageSize), new SqlParameter("@PageNum",PageNum), new SqlParameter("@TableName","manager_role"), new SqlParameter("@WhereStr",WhereStr), new SqlParameter("@OrderBy",OrderBy) }; using (SqlDataReader reder = db.GetReaderByProc("Proc_Page", sp)) { while (reder.Read()) { MasterRole ml = new MasterRole(); ml.RoleId = (int)reder["id"]; ml.RoleName = reder["role_name"].ToString(); list.Add(ml); } } } catch (SqlException ex) { throw new Exception("数据库异常!原因:" + ex.Message); } catch (Exception ex) { throw new Exception("未知异常!原因:" + ex.Message); } return list; }
public ActionResult EditRole(int R) { if (Session[Keys.SESSION_ADMIN_INFO] == null) { return RedirectToAction("Login", "Admin"); } else { Master master = Session[Keys.SESSION_ADMIN_INFO] as Master; if (rcm.GetRoleCompetence(master.RoleId, 1452)) { MasterRole mr = new MasterRole(); mr = mm.GetMasterRole(R); ViewData["RoleId"] = mr.RoleId; ViewData["RoleName"] = mr.RoleName; ViewData["Function"] = "UpdateData('/Master/UpdateMasterRole')"; return View(); } else { return RedirectToAction("Login", "Admin"); } } }
public Boolean DoAddMasterRole() { if (Session[Keys.SESSION_ADMIN_INFO] == null) { return false; } else { Master master = Session[Keys.SESSION_ADMIN_INFO] as Master; if (rcm.GetRoleCompetence(master.RoleId, 1452)) { string RItem = Request["RItem"]; string RoleName = Request["RoleName"]; if (mm.AddMasterRole(RoleName)) { MasterRole mr = new MasterRole(); mr = mm.GetMasterRole(RoleName); Boolean IsSuccess = false; string[] re = RItem.Split(','); foreach (string rc in re) { IsSuccess = rcm.AddCompentence(mr.RoleId, int.Parse(rc)); if (!IsSuccess) { rcm.DelAllCom(mr.RoleId); } } return IsSuccess; } else { return false; } } else { return false; } } }