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 did) { Sys_DepInfo byId = Sys_Dep.Init().GetById(Convert.ToInt32(did)); this.ViewState["sd"] = byId; this.parentID.SelectedValue = string.Concat(byId.ParentID); this.UDepName.Value = byId.DepName; this.Notes.Value = byId.Notes; this.IsPosition.SelectedValue = string.Concat(byId.IsPosition); this.Orders.Value = string.Concat(byId.Orders); this.Phone.Value = byId.Phone; IList all = Sys_Dep_Module.Init().GetAll("DepID=" + did, null); List <string> list = new List <string>(); for (int i = 0; i < all.Count; i++) { Sys_Dep_ModuleInfo sys_Dep_ModuleInfo = all[i] as Sys_Dep_ModuleInfo; list.Add(string.Concat(sys_Dep_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["did"])) { int num = Convert.ToInt32(base.Request.QueryString["did"]); Sys_DepInfo sys_DepInfo = this.ViewState["sd"] as Sys_DepInfo; sys_DepInfo.DepName = this.UDepName.Value.Replace("#", "").Replace(",", ""); sys_DepInfo.IsPosition = Convert.ToInt32(this.IsPosition.SelectedValue); sys_DepInfo.Orders = Convert.ToInt32(this.Orders.Value); sys_DepInfo.Notes = this.Notes.Value; sys_DepInfo.Phone = this.Phone.Value; if (sys_DepInfo.ParentID != 0) { sys_DepInfo.ParentID = Convert.ToInt32(this.parentID.SelectedValue); } Sys_Dep.Init().Update(sys_DepInfo); string cmdText = string.Concat(new object[] { "update Sys_User set DepName='", sys_DepInfo.DepName, "' where DepID=", sys_DepInfo.id }); MsSqlOperate.ExecuteNonQuery(CommandType.Text, cmdText, null); 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 cmdText2 = string.Concat(new object[] { "delete from Sys_Dep_Module where DepID=", num, " and ModuleID=", list[i] }); MsSqlOperate.ExecuteNonQuery(CommandType.Text, cmdText2, null); } } for (int i = 0; i < list2.Count; i++) { if (!list.Contains(list2[i])) { Sys_Dep_ModuleInfo sys_Dep_ModuleInfo = new Sys_Dep_ModuleInfo(); sys_Dep_ModuleInfo.ModuleID = Convert.ToInt32(list2[i]); sys_Dep_ModuleInfo.DepID = num; Sys_Dep_Module.Init().Add(sys_Dep_ModuleInfo); } } string str = HttpContext.Current.Server.HtmlEncode("您好!部门/职位已编辑成功!"); base.Response.Redirect("~/InfoTip/Operate_Success.aspx?returnpage=" + base.Request.Url.AbsoluteUri + "&tip=" + str); } else { Sys_DepInfo sys_DepInfo = new Sys_DepInfo(); sys_DepInfo.DepName = this.UDepName.Value.Replace("#", "").Replace(",", ""); sys_DepInfo.IsPosition = Convert.ToInt32(this.IsPosition.SelectedValue); sys_DepInfo.Orders = Convert.ToInt32(this.Orders.Value); sys_DepInfo.Notes = this.Notes.Value; sys_DepInfo.Phone = this.Phone.Value; sys_DepInfo.ParentID = Convert.ToInt32(this.parentID.SelectedValue); Sys_Dep.Init().Add(sys_DepInfo); for (int i = 0; i < this.powerList.Items.Count; i++) { if (this.powerList.Items[i].Selected) { Sys_Dep_ModuleInfo sys_Dep_ModuleInfo = new Sys_Dep_ModuleInfo(); sys_Dep_ModuleInfo.ModuleID = Convert.ToInt32(this.powerList.Items[i].Value); sys_Dep_ModuleInfo.DepID = sys_DepInfo.id; Sys_Dep_Module.Init().Add(sys_Dep_ModuleInfo); } } string str = HttpContext.Current.Server.HtmlEncode("您好!部门/职位已添加成功!"); base.Response.Redirect("~/InfoTip/Operate_Success.aspx?returnpage=" + base.Request.Url.AbsoluteUri + "&tip=" + str); } }