protected void Del_Btn(object obj, EventArgs e) { LinkButton linkButton = obj as LinkButton; RepeaterItem repeaterItem = linkButton.Parent as RepeaterItem; HtmlInputCheckBox htmlInputCheckBox = repeaterItem.FindControl("chk") as HtmlInputCheckBox; int num = Convert.ToInt32(htmlInputCheckBox.Value); string cmdText = "delete from Sys_Role_Module where RoleID=" + num; MsSqlOperate.ExecuteNonQuery(CommandType.Text, cmdText, null); Sys_Role.Init().Delete(num); this.Show(); }
private void InitData() { IList all = Sys_Role.Init().GetAll(null, "order by id desc"); this.RoleID.DataSource = all; this.RoleID.DataTextField = "RoleName"; this.RoleID.DataValueField = "id"; this.RoleID.DataBind(); this.GetFirtNode(); this.parentID.DataSource = this.li; this.parentID.DataTextField = "Sh"; this.parentID.DataValueField = "ID"; this.parentID.DataBind(); }
protected void Del_All(object sender, EventArgs e) { foreach (RepeaterItem repeaterItem in this.rpt.Items) { HtmlInputCheckBox htmlInputCheckBox = repeaterItem.FindControl("chk") as HtmlInputCheckBox; if (htmlInputCheckBox.Checked) { int num = Convert.ToInt32(htmlInputCheckBox.Value); string cmdText = "delete from Sys_Role_Module where RoleID=" + num; MsSqlOperate.ExecuteNonQuery(CommandType.Text, cmdText, null); Sys_Role.Init().Delete(num); } } this.Show(); }
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); } }