public static List<LabMS.Model.Function> GetManaFunctionByUserID(string strUserID) { List<LabMS.Model.UserRole> listuRole = new List<LabMS.Model.UserRole>(); LabMS.BLL.UserRole buRole = new LabMS.BLL.UserRole(); List<LabMS.Model.RoleFucntion> listRoleF = new List<LabMS.Model.RoleFucntion>(); LabMS.BLL.RoleFucntion bRoleF = new LabMS.BLL.RoleFucntion(); listuRole = buRole.GetModelList("UserID = " + strUserID); string strWhere = " 1<>1 "; foreach (LabMS.Model.UserRole ur in listuRole) { strWhere += " or RoleID = " + ur.RoleID.Value.ToString(); } listRoleF = bRoleF.GetModelList(strWhere); List<LabMS.Model.Function> listFunction = new List<LabMS.Model.Function>(); LabMS.BLL.Function bFunction = new LabMS.BLL.Function(); strWhere = " 1<>1 "; foreach (LabMS.Model.RoleFucntion rf in listRoleF) { strWhere += " or Code = '" + rf.FCode.ToString()+"'"; } listFunction = bFunction.GetModelList(strWhere); return listFunction; }
/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { lbErr.Visible = false; if (string.IsNullOrEmpty(tbRoleName.Text.Trim())) { Common.JShelper.JSAlert(this.Page, "err", "角色名不能为空!"); tbRoleName.Focus(); } else if (string.IsNullOrEmpty(tbRoleDetails.Text.Trim())) { Common.JShelper.JSAlert(this.Page,"err","角色描述不能为空!"); } else { LabMS.BLL.RoleTable BRT = new LabMS.BLL.RoleTable(); LabMS.Model.RoleTable Mrt = new LabMS.Model.RoleTable(); Mrt.RoleName = tbRoleName.Text.Trim(); Mrt.RoleDetails = tbRoleDetails.Text.Trim(); try { int iRid = BRT.Add(Mrt); if (iRid == 0) { lbErr.Visible = true; lbErr.Text = "角色添加失败"; return; } List<string> liststrFunction = GetPrivaily(); LabMS.BLL.RoleFucntion brf = new LabMS.BLL.RoleFucntion(); LabMS.Model.RoleFucntion mrf = new LabMS.Model.RoleFucntion(); for (int i = 0; i < liststrFunction.Count; ++i) { mrf.FCode = liststrFunction[i].ToString(); mrf.RoleID = iRid; brf.Add(mrf); } Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script type='text/javascript'>alert('新增角色成功!');window.location.href='RoleList.aspx';</script>"); } catch { } } }
/// <summary> /// 保存修改 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(tbRoleName.Text.Trim())) { Common.JShelper.JSAlert(this.Page, "err", "角色名不能为空!"); tbRoleName.Focus(); } else if (string.IsNullOrEmpty(tbRoleDetails.Text.Trim())) { Common.JShelper.JSAlert(this.Page, "err", "角色描述不能为空!"); } else { LabMS.BLL.RoleTable BRT = new LabMS.BLL.RoleTable(); LabMS.Model.RoleTable Mrt = new LabMS.Model.RoleTable(); int RoleId = int.Parse(Request.QueryString["RoleId"].ToString()); Mrt.RoleId = RoleId; Mrt.RoleName = EBrt.GetRoleNameByRoleID(RoleId); Mrt.RoleName = tbRoleName.Text.Trim(); Mrt.RoleDetails = tbRoleDetails.Text.Trim(); try { BRT.Update(Mrt); ExtendBLL.RoleFucntion erf = new ExtendBLL.RoleFucntion(); erf.delbyWhere("RoleID=" + RoleId.ToString()); List<string> liststrFunction = GetPrivaily(); LabMS.BLL.RoleFucntion brf = new LabMS.BLL.RoleFucntion(); LabMS.Model.RoleFucntion mrf = new LabMS.Model.RoleFucntion(); for (int i = 0; i < liststrFunction.Count; ++i) { mrf.FCode = liststrFunction[i].ToString(); mrf.RoleID = RoleId; brf.Add(mrf); } //Common.JShelper.JSAlert(this.Page, "", "修改角色成功!"); Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script type='text/javascript'>alert('修改角色成功!');window.location.href='RoleList.aspx';</script>"); } catch { } } }
protected void Page_Load(object sender, EventArgs e) { strPagePrivilege.Add("JSGL"); strPageUserType.Add("mana"); if (!IsPostBack) { if (Request.QueryString["RoleId"] == null) { Common.JShelper.JSAlert(this.Page, "", "你无权查看此页面!"); } else { int RoleId = int.Parse(Request.QueryString["RoleId"].ToString()); InitBind(RoleId); } } int otherRoleId = int.Parse(Request.QueryString["RoleId"].ToString()); List<LabMS.Model.RoleFucntion> listRF = new List<LabMS.Model.RoleFucntion>(); LabMS.BLL.RoleFucntion bRF = new LabMS.BLL.RoleFucntion(); listRF = bRF.GetModelList(" RoleID = " + otherRoleId.ToString()); CreatePrivailyPanel(listRF); }