/// <summary> /// 获取角色Options /// </summary> /// <returns></returns> protected string GetRoleOptions() { System.Text.StringBuilder s = new System.Text.StringBuilder(); var items = new EyouSoft.BLL.ComStructure.BComRole().GetList(CurrentUserCompanyID); s.Append("<option value=''>请选择</option>"); string _v = Utils.GetQueryStringValue("txtRoleId"); if (_v == "0") { s.Append("<option value='0' selected='selected'>空白角色(未授权)</option>"); } else { s.Append("<option value='0'>空白角色(未授权)</option>"); } if (items != null && items.Count > 0) { foreach (var item in items) { if (_v == item.Id.ToString()) { s.AppendFormat("<option value='{0}' selected='selected'>{1}</option>", item.Id, item.RoleName); } else { s.AppendFormat("<option value='{0}'>{1}</option>", item.Id, item.RoleName); } } } return(s.ToString()); }
/// <summary> /// 角色删除 /// </summary> protected void DelRole() { int[] ids = Utils.GetIntArray(Utils.GetQueryStringValue("ids"), ","); bool result = new EyouSoft.BLL.ComStructure.BComRole().Delete(ids); if (result) { Response.Write(UtilsCommons.AjaxReturnJson("1", "删除成功!")); } else { Response.Write(UtilsCommons.AjaxReturnJson("0", "删除失败!")); } }
/// <summary> /// 页面初始化 /// </summary> protected void PageInit() { IList <EyouSoft.Model.ComStructure.MComRole> list = new EyouSoft.BLL.ComStructure.BComRole().GetList(SiteUserInfo.CompanyId); if (list == null || list.Count == 0) { this.repList.EmptyText = "<tr align=\"center\"><td colspan=\"6\">暂无角色信息!</td></tr>"; } else { i = list.Count; this.repList.DataSource = list; this.repList.DataBind(); } }
/// <summary> /// 页面初始化 /// </summary> /// <param name="id">操作ID</param> protected void PageInit() { System.Text.StringBuilder RolePower = new System.Text.StringBuilder(); IList <EyouSoft.Model.ComStructure.MComRole> RoleList = new EyouSoft.BLL.ComStructure.BComRole().GetList(SiteUserInfo.CompanyId); if (RoleList != null && RoleList.Count > 0) { RolePower.Append("["); foreach (var item in RoleList) { RolePower.Append("{"); RolePower.AppendFormat("RoleId: '{0}',PowerIds: '{1}'", item.Id, item.RoleChilds); RolePower.Append("},"); } RolePower.Append("]"); } hidPower.Value = RolePower.ToString(); this.ddlRole.DataTextField = "RoleName"; this.ddlRole.DataValueField = "Id"; this.ddlRole.DataSource = RoleList; this.ddlRole.DataBind(); this.ddlRole.Items.Insert(0, new ListItem("请选择", "0")); if (ddlRole.Items.FindByValue(RoleID) != null) { ddlRole.Items.FindByValue(RoleID).Selected = true; } string[] PowerIds = new EyouSoft.BLL.ComStructure.BComUser().GetPrivs(UserID, SiteUserInfo.CompanyId).Split(','); if (PowerIds == null || PowerIds[0] == "") { if (!string.IsNullOrEmpty(RoleID)) { EyouSoft.Model.ComStructure.MComRole model = new EyouSoft.BLL.ComStructure.BComRole().GetModel(Utils.GetInt(RoleID), SiteUserInfo.CompanyId); if (model != null) { PowerIds = model.RoleChilds.Split(','); } } } System.Text.StringBuilder str = new System.Text.StringBuilder(); System.Text.StringBuilder Privs = null; EyouSoft.BLL.SysStructure.BSysMenu BSysMenuBll = new EyouSoft.BLL.SysStructure.BSysMenu(); IList <EyouSoft.Model.SysStructure.MComMenu1Info> list = BSysMenuBll.GetComMenus(SiteUserInfo.SysId); if (list != null) { //一级栏目 for (int i = 0; i < list.Count; i++) { str.Append("<table width=\"99%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" align=\"center\" class=\"quanxian_add_bottom\"> <tbody><tr>"); str.AppendFormat(" <td width=\"92\" height=\"25\" align=\"center\" class=\"quanxian_add\">{0}</td>", list[i].Name); str.AppendFormat("<td><span> <input type=\"checkbox\" name=\"chkAll\" value=\"{0}\"/></span>全选</td>", list[i].MenuId); str.Append(" </tr></tbody></table>"); str.Append("<div class=\"hr_5\"></div>"); str.Append(" <table width=\"99%\" cellspacing=\"1\" cellpadding=\"0\" border=\"0\" bgcolor=\"#85c1dd\" align=\"center\"><tbody>"); if (list[i].Menu2s != null) { //每行显示4列,共循环多少次 for (int k = 0; k <= list[i].Menu2s.Count / 4; k++) { Privs = new System.Text.StringBuilder(); str.Append("<tr>"); Privs.Append("<tr>"); for (int j = k * 4; j < list[i].Menu2s.Count; j++) { //当前权限是否选中 bool check = false; str.AppendFormat("<th width=\"25%\" height=\"26\" bgcolor=\"#BDDCF4\" align=\"left\"> <input type=\"checkbox\" MenuId =\"{0}\" Menu2Id=\"{1}\" name=\"chkMenu\" />{2}</th>", list[i].MenuId, list[i].Menu2s[j].MenuId, list[i].Menu2s[j].Name); Privs.Append("<td style=\" vertical-align:top;\"><table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">"); for (int t = 0; t < list[i].Menu2s[j].Privs.Count; t++) { for (int p = 0; p < PowerIds.Length; p++) { check = false; if (Utils.GetInt(PowerIds[p]) == list[i].Menu2s[j].Privs[t].PrivsId) { check = true; break; } } Privs.AppendFormat("<tr><td width=\"25%\" height=\"26\" bgcolor=\"#FFFFFF\" align=\"left\"> <input type=\"checkbox\" name=\"chkPower\" Menu2Id=\"{0}\" value=\"{1}\" {2}/>{3}</td></tr>", list[i].Menu2s[j].MenuId, list[i].Menu2s[j].Privs[t].PrivsId, check ? "checked=\"checked\"" : "", list[i].Menu2s[j].Privs[t].Name); } Privs.Append("</table></td>"); if ((j != 0 && (j + 1) % 4 == 0) || j + 1 == list[i].Menu2s.Count) { str.Append("</tr>"); Privs.Append("<tr>"); str.Append(Privs.ToString()); break; } } } } str.Append("</tbody></table><div class=\"hr_5\"></div>"); PowerStr = str.ToString(); } } }
/// <summary> /// 页面初始化 /// </summary> /// <param name="id">操作ID</param> protected void PageInit() { int RoleId = Utils.GetInt(EyouSoft.Common.Utils.GetQueryStringValue("id")); //当前角色的所有权限ID string[] PowerIds = { }; System.Text.StringBuilder str = new System.Text.StringBuilder(); System.Text.StringBuilder Privs = null; EyouSoft.BLL.SysStructure.BSysMenu BSysMenuBll = new EyouSoft.BLL.SysStructure.BSysMenu(); EyouSoft.BLL.ComStructure.BComRole BComRoleBll = new EyouSoft.BLL.ComStructure.BComRole(); IList <EyouSoft.Model.SysStructure.MComMenu1Info> list = BSysMenuBll.GetComMenus(SiteUserInfo.SysId); if (RoleId != 0) { EyouSoft.Model.ComStructure.MComRole model = BComRoleBll.GetModel(RoleId, SiteUserInfo.CompanyId); if (model != null) { txtRoleName.Value = model.RoleName; PowerIds = model.RoleChilds.Split(','); } } else { txtRoleName.Value = ""; } if (list != null) { //一级栏目 for (int i = 0; i < list.Count; i++) { str.Append("<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" align=\"center\" class=\"quanxian_add_bottom\"> <tbody><tr>"); str.AppendFormat(" <td width=\"92\" height=\"25\" align=\"center\" class=\"quanxian_add\">{0}</td>", list[i].Name); str.AppendFormat("<td><label><input type=\"checkbox\" name=\"chkAll\" value=\"{0}\"/> 全选</label></td>", list[i].MenuId); str.Append(" </tr></tbody></table>"); str.Append("<div class=\"hr_5\"></div>"); str.Append(" <table width=\"100%\" cellspacing=\"1\" cellpadding=\"0\" border=\"0\" align=\"center\" bgcolor=\"#85c1dd\"><tbody>"); if (list[i].Menu2s != null) { //每行显示4列,共循环多少次 for (int k = 0; k <= list[i].Menu2s.Count / 4; k++) { Privs = new System.Text.StringBuilder(); str.Append("<tr>"); Privs.Append("<tr>"); for (int j = k * 4; j < list[i].Menu2s.Count; j++) { //当前权限是否选中 bool check = false; str.AppendFormat("<th width=\"25%\" height=\"26\" bgcolor=\"#BDDCF4\" align=\"left\"><label> <input type=\"checkbox\" MenuId =\"{0}\" Menu2Id=\"{1}\" name=\"chkMenu\" /> {2}</label></th>", list[i].MenuId, list[i].Menu2s[j].MenuId, list[i].Menu2s[j].Name); Privs.Append("<td align='left' style=\" vertical-align:top;\" bgcolor=\"#FFFFFF\"><table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">"); for (int t = 0; t < list[i].Menu2s[j].Privs.Count; t++) { for (int p = 0; p < PowerIds.Length; p++) { check = false; if (Utils.GetInt(PowerIds[p]) == list[i].Menu2s[j].Privs[t].PrivsId) { check = true; break; } } Privs.AppendFormat("<tr><td width=\"25%\" height=\"26\" bgcolor=\"#FFFFFF\" align=\"left\"><label> <input type=\"checkbox\" name=\"chkPower\" Menu2Id=\"{0}\" value=\"{1}\" {2}/> {3}</label></td></tr>", list[i].Menu2s[j].MenuId, list[i].Menu2s[j].Privs[t].PrivsId, check ? "checked=\"checked\"" : "", list[i].Menu2s[j].Privs[t].Name); } Privs.Append("</table></td>"); if ((j != 0 && (j + 1) % 4 == 0) || j + 1 == list[i].Menu2s.Count) { int AddThTd = 4 - list[i].Menu2s.Count % 4; if (AddThTd > 0 && list[i].Menu2s.Count > 4) { for (int s = 0; s < AddThTd; s++) { str.Append("<th width=\"25%\" height=\"26\" bgcolor=\"#BDDCF4\" align=\"left\"></th>"); Privs.Append("<td width=\"25%\" height=\"26\" bgcolor=\"#FFFFFF\" align=\"left\"></td>"); } } str.Append("</tr>"); Privs.Append("<tr>"); str.Append(Privs.ToString()); break; } } } } str.Append("</tbody></table><div class=\"hr_5\"></div>"); PowerStr = str.ToString(); } } }
protected void Save() { int Result = 0; string dotype = Utils.GetQueryStringValue("dotype"); EyouSoft.Model.ComStructure.MComRole model = new EyouSoft.Model.ComStructure.MComRole(); EyouSoft.BLL.ComStructure.BComRole BComRoleBll = new EyouSoft.BLL.ComStructure.BComRole(); string RoleId = Utils.GetQueryStringValue("id"); int length = Utils.GetFormValues("chkPower").Length; for (int i = 0; i < length; i++) { model.RoleChilds += Utils.GetFormValues("chkPower")[i] + ","; } if (!string.IsNullOrEmpty(model.RoleChilds)) { model.RoleChilds = model.RoleChilds.Trim(','); } string msg = string.Empty; if (model.RoleChilds == "") { msg += "请选择权限!<br/>"; } if (txtRoleName.Value == "") { msg += "权限组名称不能为空!<br/>"; } if (!string.IsNullOrEmpty(msg)) { Response.Clear(); Response.Write(UtilsCommons.AjaxReturnJson("0", msg)); Response.End(); } if (RoleId == "" || dotype == "copy") { model.CompanyId = SiteUserInfo.CompanyId; model.RoleName = txtRoleName.Value; Response.Clear(); Result = BComRoleBll.Add(model); switch (Result) { case 0: { Response.Write(UtilsCommons.AjaxReturnJson("0", "添加失败!")); break; } case 1: { Response.Write(UtilsCommons.AjaxReturnJson("1", "添加成功!")); break; } case 2: { Response.Write(UtilsCommons.AjaxReturnJson("0", "角色名重复!")); break; } } } else { model.Id = EyouSoft.Common.Utils.GetInt(RoleId); model.CompanyId = SiteUserInfo.CompanyId; model.RoleName = txtRoleName.Value; Result = BComRoleBll.Update(model); switch (Result) { case 0: { Response.Write(UtilsCommons.AjaxReturnJson("0", "修改失败!")); break; } case 1: { Response.Write(UtilsCommons.AjaxReturnJson("1", "修改成功!")); break; } case 2: { Response.Write(UtilsCommons.AjaxReturnJson("0", "角色名重复!")); break; } } } Response.End(); }
/// <summary> /// 页面初始化 /// </summary> protected void PageInit() { this.HrSelect1.Isshow = false; string iframeId = Utils.GetQueryStringValue("iframeId"); this.HrSelect1.SetTitle = "姓名"; this.HrSelect1.SModel = "1"; this.HrSelect1.ParentIframeID = iframeId; this.HrSelect1.CallBackFun = "UserEdit.BindGovFile"; this.ddlSex.DataTextField = "Text"; this.ddlSex.DataValueField = "Value"; this.ddlSex.DataSource = EyouSoft.Common.EnumObj.GetList(typeof(EyouSoft.Model.EnumType.GovStructure.Gender)); this.ddlSex.DataBind(); this.ddlSex.Items.Insert(0, new ListItem("请选择", "")); IList <EyouSoft.Model.ComStructure.MComRole> rolelist = new EyouSoft.BLL.ComStructure.BComRole().GetList(SiteUserInfo.CompanyId); this.ddlRoleList.DataTextField = "RoleName"; this.ddlRoleList.DataValueField = "Id"; this.ddlRoleList.DataSource = rolelist; this.ddlRoleList.DataBind(); this.ddlRoleList.Items.Insert(0, new ListItem("请选择", "")); this.ManageDepart.IsNotValid = false; if (!string.IsNullOrEmpty(UserID)) { EyouSoft.Model.ComStructure.MComUser model = new EyouSoft.BLL.ComStructure.BComUser().GetModel(UserID, SiteUserInfo.CompanyId); txtUserName.Text = model.UserName; txtUserName.ReadOnly = true; HrSelect1.HrSelectName = model.ContactName; HrSelect1.HrSelectID = model.GovFileId; HrSelect1.IsDisplay = true; if (this.ddlSex.Items.FindByValue(model.ContactSex.ToString()) != null) { this.ddlSex.SelectedValue = model.ContactSex.ToString(); } this.BelongDepart.SectionID = model.DeptId.ToString(); this.BelongDepart.SectionName = model.DeptName; this.ManageDepart.SectionID = model.DeptIdJG.ToString(); this.ManageDepart.SectionName = model.JGDeptName; if (this.ddlRoleList.Items.FindByValue(model.RoleId.ToString()) != null) { this.ddlRoleList.SelectedValue = model.RoleId.ToString(); } txtDebt.Value = Utils.FilterEndOfTheZeroString(model.Arrears.ToString()); txtPhone.Value = model.ContactTel; txtFax.Value = model.ContactFax; txtMobile.Value = model.ContactMobile; txtQQ.Value = model.QQ; txtMSN.Value = model.MSN; txtEmail.Value = model.ContactEmail; txtIntroduction.Text = model.PeopProfile; txtRemark.Text = model.Remark; //chkState.Checked = model.IsEnable; txtUserName.Enabled = false; Pwd = model.Password; } else { ddlSex.Items[0].Selected = true; txtUserName.Enabled = true; //chkState.Checked = false; } }