protected void lstCat_SelectedIndexChanged(object sender, EventArgs e) { if (lstRoles.SelectedIndex >= 0) { //string userid = Request.Params.Get("id"); string userid = Session["id"] != null ? Session["id"].ToString() : ""; MainSecurity objscu = new MainSecurity(); lstPer.DataSource = objscu.GetPermissionAsTable(userid, 1, Int32.Parse(lstRoles.SelectedValue), Int32.Parse(lstCat.SelectedValue)); lstPer.DataTextField = "Permission_Name"; lstPer.DataValueField = "Permission_ID"; lstPer.DataBind(); } }
protected void lstRoles_SelectedIndexChanged(object sender, EventArgs e) { //string userid=Request.Params.Get("id"); string userid = Session["id"] != null ? Session["id"].ToString() : ""; MainSecurity objscu = new MainSecurity(); //lay thong tin ve chuyen muc cua thang hien tai lstCat.DataTextField = "Cat_Name"; lstCat.DataValueField = "Cat_ID"; lstCat.DataSource = objscu.GetCategoryByRoleAsTable(userid, Int32.Parse(lstRoles.SelectedValue)); lstCat.DataBind(); //lay thong tin ve toan bo quyen lstPer.DataSource = objscu.GetPermissionAsTable(userid, 1, -1); lstPer.DataTextField = "Permission_Name"; lstPer.DataValueField = "Permission_ID"; lstPer.DataBind(); }
private void LoadLtsBox() { //string userID = Request.Params.Get("id"); string userID = Session["id"] != null ? Session["id"].ToString() : ""; //khoi tao bien secu de lay toan bo roles cua thang hien tai lstRoles.Items.Clear(); lstCat.Items.Clear(); lstPer.Items.Clear(); MainSecurity objscu = new MainSecurity(); DataTable dt = objscu.GetRoleAsTableNoCache(userID, 1); if (dt.Rows.Count > 0) { lstRoles.DataSource = dt; lstRoles.DataTextField = "Role_Name"; lstRoles.DataValueField = "Role_ID"; lstRoles.DataBind(); } //lay thong tin ve chuyen muc cua thang hien tai dt = objscu.getParentCategoryAssigned(userID, 1); if (dt.Rows.Count > 0) { lstCat.DataTextField = "Cat_Name"; lstCat.DataValueField = "Cat_ID"; lstCat.DataSource = dt; lstCat.DataBind(); } //lay thong tin ve toan bo quyen dt = objscu.GetPermissionAsTable(userID, 1, -1); if (dt.Rows.Count > 0) { lstPer.DataSource = dt; lstPer.DataTextField = "Permission_Name"; lstPer.DataValueField = "Permission_ID"; lstPer.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["cpmode"] != null) { string strMode = Request.QueryString["cpmode"]; if (strMode.IndexOf(",") > 0) { strMode = strMode.Substring(0, strMode.IndexOf(",")); } Control ctrNewslist = null; // user cpMode to get path of usercontrol from xml config XmlDocument doc = MenuCommon.getXML(); XmlNode node = doc.SelectSingleNode("//row[Cpmode='" + strMode + "']"); if (node != null) { XmlNode path = node.SelectSingleNode("path"); bool ischeckpermission = bool.Parse(node.SelectSingleNode("../../@checkpermission").InnerText); if (path != null) { if (ischeckpermission) { XmlNode permissionId = node.SelectSingleNode("Permission_ID"); // check permission in database MainSecurity mainSecurity = new MainSecurity(); DataTable tblPermissions = mainSecurity.GetPermissionAsTable(HttpContext.Current.User.Identity.Name); if (tblPermissions.Select("Permission_ID=" + permissionId.InnerText).Length == 1) { try { ctrNewslist = LoadControl(path.InnerText); plcMain.Controls.Add(ctrNewslist); } catch (SecurityException sEx) { plcMain.Controls.Clear(); ctrNewslist = LoadControl("Statistic/MsgPermission.ascx"); plcMain.Controls.Add(ctrNewslist); } } else { ctrNewslist = LoadControl("Statistic/MsgPermission.ascx"); plcMain.Controls.Add(ctrNewslist); } } else { try { ctrNewslist = LoadControl(path.InnerText); plcMain.Controls.Add(ctrNewslist); } catch { } } } } if (ctrNewslist == null) { ctrNewslist = LoadControl("OnLoad/onload.ascx"); plcMain.Controls.Add(ctrNewslist); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { getCurrentMenuItem(); string userName = HttpContext.Current.User.Identity.Name; MainSecurity mainSecurity = new MainSecurity(); DataTable tblPermissions = mainSecurity.GetPermissionAsTable(userName); bool isClear = Request.RawUrl == "/office.aspx" ? true : false; if (tblPermissions != null) { doc = MenuCommon.getXML(); XmlNodeList boxes = doc.SelectNodes("boxes/box[@isvisible='true']"); bool isCheckPermisson = false, isCount = false; XmlNodeList rows = null; string a = string.Empty; foreach (XmlNode box in boxes) { StringBuilder html = new StringBuilder(); bool isPermision = false; StringBuilder htmlHeader = new StringBuilder(); htmlHeader.AppendLine("<li class=\"\"><a href=\"javascript:;\"><i class=\"icon-folder-open\"></i><span class=\"title\">"); htmlHeader.AppendLine(box.SelectSingleNode("name").InnerText); htmlHeader.AppendLine("</span><span class=\"arrow\"></span></a>"); htmlHeader.AppendLine("<ul class=\"sub-menu\">"); isCheckPermisson = bool.Parse(box.SelectSingleNode("@checkpermission").InnerText); rows = box.SelectNodes("rows/row"); foreach (XmlNode row in rows) { if (isCheckPermisson && tblPermissions.Select("Permission_ID=" + row.SelectSingleNode("Permission_ID").InnerText).Length == 1 || !isCheckPermisson) { isPermision = true; html.AppendLine("<li class=\"" + ((row.Attributes["isvisible"] != null) ? "hidden" : string.Empty) + " " + (row.SelectSingleNode("Cpmode").InnerText == CurrentMenuItem ? "active" : string.Empty) + "\">"); isCount = bool.Parse(row.SelectSingleNode("IsCount").InnerText); a = "<a href=\"/office/{0}.aspx\">{1} {2}</a>"; if (isCount) { a = string.Format(a, row.SelectSingleNode("Cpmode").InnerText, row.SelectSingleNode("MenuName").InnerText, "(<span>" + MenuCommon.getNewsCountStr(row.SelectSingleNode("Cpmode").InnerText, isClear) + "</span>)"); } else { a = string.Format(a, row.SelectSingleNode("Cpmode").InnerText, row.SelectSingleNode("MenuName").InnerText, string.Empty); } html.AppendLine(a); html.AppendLine("</li>"); } } if (isPermision) { htmlHeader.Append(html.ToString()); } htmlHeader.AppendLine("</ul></li>"); if (isPermision) { ltrHtml.Text += htmlHeader.ToString(); } } } MainSecurity objSecurity = new MainSecurity(); Role objRole = objSecurity.GetRole(Page.User.Identity.Name); if (Page.User.Identity.Name == "admin" || objRole.isAdministrator || objRole.isTongBienTap || objRole.isQuanTriKenh) { aUser.Visible = true; } } }