private void initAuthorityMenu() { var menuString = OracleHelper.ExecuteScalar(OracleHelper.conn, String.Format("SELECT AUTHORITY FROM SYS_USERINFO WHERE USERNAME='******'", Utils.localUserId), null); if (menuString != null) { string[] menuArr = menuString.ToString().Split(','); AuthorityForm af = new AuthorityForm(); List <string> listModel = af.ReadMenusXmlData().Where(c => menuArr.Contains(c.ID.ToString())).Select(c => c.MenuName).ToList <string>(); foreach (NavBarGroup g in navBarControl1.Groups) { foreach (NavBarItemLink i in g.ItemLinks) { if (listModel.Contains(i.Caption)) { i.Visible = true; g.Visible = true; } else { i.Visible = false; } } } } }
// 获取菜单权限 private void InitAuthority() { AuthorityManager.Authority am = Utils.serverAuthority; DataSet ds = am.QueryAuthorityByUserName(Utils.userId, Utils.password); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) { Dictionary <string, string> aDir = new Dictionary <string, string>(); foreach (DataTable dt in ds.Tables) { foreach (DataRow dr in dt.Rows) { aDir.Add(dr[0].ToString(), "true"); } } aDir.Add("navBarItem0705", "true"); //设置权限管理 if (aDir.ContainsKey("navBarItem0704")) { string sql = String.Format("SELECT AUTHORITY FROM SYS_USERINFO WHERE USERNAME='******'", Utils.localUserId); var result = AccessHelper.ExecuteScalar(AccessHelper.conn, sql, null); if (result != null) { string[] resultArr = result.ToString().Split(','); AuthorityForm af = new AuthorityForm(); List <string> listModel = af.ReadMenusXmlData().Where(c => resultArr.Contains(c.ID.ToString())).Select(c => c.ID).ToList <string>(); listModel.Add("navBarItem0705"); foreach (NavBarGroup g in navBarControl1.Groups) { foreach (NavBarItemLink i in g.ItemLinks) { if (listModel.Contains(i.ItemName)) { i.Visible = true; g.Visible = true; } else { i.Visible = false; } } } } } else { foreach (NavBarGroup g in navBarControl1.Groups) { foreach (NavBarItemLink i in g.ItemLinks) { if (aDir.ContainsKey(i.ItemName)) { i.Visible = true; g.Visible = true; } else { i.Visible = false; } } } } } //foreach (NavBarGroup g in navBarControl1.Groups) //{ // foreach (NavBarItemLink i in g.ItemLinks) // { // i.Visible = true; // g.Visible = true; // } //} }