private string GetModuleList(int did, int rid) { IList all = Sys_Dep_Module.Init().GetAll("DepID=" + did, null); IList all2 = Sys_Role_Module.Init().GetAll("RoleID=" + rid, null); List <string> list = new List <string>(); foreach (object current in all) { Sys_Dep_ModuleInfo sys_Dep_ModuleInfo = current as Sys_Dep_ModuleInfo; if (!list.Contains(string.Concat(sys_Dep_ModuleInfo.ModuleID))) { list.Add(string.Concat(sys_Dep_ModuleInfo.ModuleID)); } } foreach (object current in all2) { Sys_Role_ModuleInfo sys_Role_ModuleInfo = current as Sys_Role_ModuleInfo; if (!list.Contains(string.Concat(sys_Role_ModuleInfo.ModuleID))) { list.Add(string.Concat(sys_Role_ModuleInfo.ModuleID)); } } string result; if (list.Count != 0) { result = string.Join(",", list.ToArray()); } else { result = ""; } return(result); }
private void Show(string id) { Sys_RoleInfo byId = Sys_Role.Init().GetById(Convert.ToInt32(id)); this.ViewState["sr"] = byId; this.RoleName.Value = byId.RoleName; this.Notes.Value = byId.Notes; IList all = Sys_Role_Module.Init().GetAll("RoleID=" + id, null); List <string> list = new List <string>(); for (int i = 0; i < all.Count; i++) { Sys_Role_ModuleInfo sys_Role_ModuleInfo = all[i] as Sys_Role_ModuleInfo; list.Add(string.Concat(sys_Role_ModuleInfo.ModuleID)); } this.ViewState["old_module"] = list; this.powerListBind(all, this.powerList); }
protected void Save_Btn(object sender, EventArgs e) { if (!string.IsNullOrEmpty(base.Request.QueryString["rid"])) { int num = Convert.ToInt32(base.Request.QueryString["rid"]); Sys_RoleInfo sys_RoleInfo = this.ViewState["sr"] as Sys_RoleInfo; sys_RoleInfo.RoleName = this.RoleName.Value; sys_RoleInfo.Notes = this.Notes.Value; Sys_Role.Init().Update(sys_RoleInfo); List <string> list = this.ViewState["old_module"] as List <string>; List <string> list2 = new List <string>(); for (int i = 0; i < this.powerList.Items.Count; i++) { if (this.powerList.Items[i].Selected) { list2.Add(this.powerList.Items[i].Value); } } for (int i = 0; i < list.Count; i++) { if (!list2.Contains(list[i])) { string cmdText = string.Concat(new object[] { "delete from Sys_Role_Module where RoleID=", num, " and ModuleID=", list[i] }); MsSqlOperate.ExecuteNonQuery(CommandType.Text, cmdText, null); } } for (int i = 0; i < list2.Count; i++) { if (!list.Contains(list2[i])) { Sys_Role_ModuleInfo sys_Role_ModuleInfo = new Sys_Role_ModuleInfo(); sys_Role_ModuleInfo.ModuleID = Convert.ToInt32(list2[i]); sys_Role_ModuleInfo.RoleID = num; Sys_Role_Module.Init().Add(sys_Role_ModuleInfo); } } string str = HttpContext.Current.Server.HtmlEncode("您好!角色已编辑成功!"); base.Response.Redirect("~/InfoTip/Operate_Success.aspx?returnpage=" + base.Request.Url.AbsoluteUri + "&tip=" + str); } else { Sys_RoleInfo sys_RoleInfo = new Sys_RoleInfo(); sys_RoleInfo.RoleName = this.RoleName.Value; sys_RoleInfo.Notes = this.Notes.Value; Sys_Role.Init().Add(sys_RoleInfo); for (int i = 0; i < this.powerList.Items.Count; i++) { if (this.powerList.Items[i].Selected) { Sys_Role_ModuleInfo sys_Role_ModuleInfo = new Sys_Role_ModuleInfo(); sys_Role_ModuleInfo.ModuleID = Convert.ToInt32(this.powerList.Items[i].Value); sys_Role_ModuleInfo.RoleID = sys_RoleInfo.id; Sys_Role_Module.Init().Add(sys_Role_ModuleInfo); } } string str = HttpContext.Current.Server.HtmlEncode("您好!角色已添加成功!"); base.Response.Redirect("~/InfoTip/Operate_Success.aspx?returnpage=" + base.Request.Url.AbsoluteUri + "&tip=" + str); } }