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 btnSubmit_Click(object sender, EventArgs e) { if (UserInputCheck()) { if (!_isModify) { if (OracleHelper.Exists(OracleHelper.conn, string.Format("SELECT COUNT(*) FROM SYS_USERINFO WHERE USERNAME='******'", this.txtOperatorName.Text))) { MessageBox.Show(string.Format("用户名{0}已存在", this.txtOperatorName.Text), "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } using (OracleConnection con = new OracleConnection(OracleHelper.conn)) { con.Open(); if (string.IsNullOrEmpty(userId)) { userId = "SEQ_SYS_USERINFO.nextval"; } string OperatorName = this.txtOperatorName.Text.Trim(); string Password = this.txtOperatorPwd.Text.Trim(); string UserName = this.txtUserName.Text.Trim(); string Phone = this.txtPhone.Text.Trim(); bool status = this.chkOperatorState.Checked; string strInsSQL = "INSERT INTO SYS_USERINFO (ID,USERNAME,PWD,NAME,PHONE,AUTHORITY,STATUS) VALUES ({0},'{1}','{2}','{3}','{4}','{5}',{6})"; strInsSQL = string.Format(strInsSQL, userId, OperatorName, Password, UserName, Phone, "", status ? 1 : 0); string strUpdSQL = "UPDATE SYS_USERINFO SET USERNAME='******',PWD='{1}',NAME='{2}',PHONE='{3}',STATUS='{4}' WHERE ID={5}"; strUpdSQL = string.Format(strUpdSQL, OperatorName, Password, UserName, Phone, status ? 1 : 0, userId); int count = OracleHelper.ExecuteNonQuery(con, _isModify ? strUpdSQL : strInsSQL, null); if (count > 0) { this.Close(); AuthorityForm af = new AuthorityForm(); af.ResfurbishData(); MessageBox.Show("操作成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { MessageBox.Show("操作失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } }
// 获取菜单权限 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; // } //} }