private void toolbtnSave_Click(object sender, EventArgs e) { if (this.m_lstCheckHdpRoleUser == null) { this.m_lstCheckHdpRoleUser = new List <HdpRoleUser>(); } m_lstCheckHdpRoleUser.Clear(); for (int index = 0; index < this.dataGridView1.Rows.Count; index++) { HdpRole hdpRole = this.dataGridView1.Rows[index].Tag as HdpRole; if ((bool)this.dataGridView1.Rows[index].Cells[this.colCheckBox.Index].Value == true) { HdpRoleUser hdpRoleUser = new HdpRoleUser(); hdpRoleUser.UserID = this.m_UserInfo.USER_ID; hdpRoleUser.RoleCode = hdpRole.RoleCode; m_lstCheckHdpRoleUser.Add(hdpRoleUser); } } short shRet = HdpRoleUserAccess.Instance.SaveRoleUserList(this.m_UserInfo.USER_ID, CheckHdpRoleUserList); //兼容用户登录,插入一条用户账号密码信息到USER_RIGHT_T表中 UserRightBase userRight = UserRightBase.Create(UserRightType.MedQC); userRight.UserID = this.m_UserInfo.USER_ID; userRight.RightType = UserRightType.MedQC; shRet = RightAccess.Instance.GetUserRight(this.m_UserInfo.USER_ID, UserRightType.MedQC, ref userRight); shRet = RightAccess.Instance.SaveUserRight(userRight); if (shRet != SystemData.ReturnValue.OK) { MessageBoxEx.ShowError("授权失败"); return; } MessageBoxEx.ShowMessage("授权成功"); this.DialogResult = DialogResult.OK; }
/// <summary> /// 管理平台,保存一条用户角色授权信息 /// </summary> /// <param name="HdpUIConfig">角色信息</param> /// <returns>SystemData.ReturnValue</returns> public short SaveHdpRoleUser(HdpRoleUser hdpRoleUser) { if (base.MedQCAccess == null) { return(SystemData.ReturnValue.PARAM_ERROR); } string szField = string.Format("{0},{1}" , SystemData.HdpRoleUserTable.ROLE_CODE , SystemData.HdpRoleUserTable.USER_ID); string szValue = string.Format("'{0}','{1}'" , hdpRoleUser.RoleCode , hdpRoleUser.UserID); string szSQL = string.Format(SystemData.SQL.INSERT, SystemData.DataTable.HDP_ROLE_USER_T, szField, szValue); int nCount = 0; try { nCount = base.MedQCAccess.ExecuteNonQuery(szSQL, CommandType.Text); } catch (Exception ex) { LogManager.Instance.WriteLog("HDPDBAccess.SaveHdpRoleUser", new string[] { "SQL" }, new object[] { szSQL }, "SQL执行失败!", ex); return(SystemData.ReturnValue.EXCEPTION); } return(nCount > 0 ? SystemData.ReturnValue.OK : SystemData.ReturnValue.EXCEPTION); }
private void UserGrantForm_FormClosing(object sender, FormClosingEventArgs e) { if (this.m_lstCheckHdpRoleUser == null) { this.m_lstCheckHdpRoleUser = new List <HdpRoleUser>(); } this.m_lstCheckHdpRoleUser.Clear(); for (int index = 0; index < this.dataGridView1.Rows.Count; index++) { HdpRole hdpRole = this.dataGridView1.Rows[index].Tag as HdpRole; if ((bool)this.dataGridView1.Rows[index].Cells[this.colCheckBox.Index].Value == true) { HdpRoleUser hdpRoleUser = new HdpRoleUser(); hdpRoleUser.UserID = this.m_UserInfo.USER_ID; hdpRoleUser.RoleCode = hdpRole.RoleCode; hdpRoleUser.RoleName = this.dataGridView1.Rows[index].Cells[this.colRoleName.Index].Value.ToString(); this.m_lstCheckHdpRoleUser.Add(hdpRoleUser); } } }
/// <summary> /// 管理平台,获取用户角色关联列表 /// </summary> /// <param name="szRoleName"></param> /// <param name="lstHdpRole"></param> /// <returns></returns> public short GetHdpRoleUserList(string szUserID, ref List <HdpRoleUser> lstHdpRoleUser) { if (base.MedQCAccess == null) { return(SystemData.ReturnValue.PARAM_ERROR); } string szField = string.Format("A.{0},A.{1},B.{2}" , SystemData.HdpRoleUserTable.USER_ID , SystemData.HdpRoleUserTable.ROLE_CODE , SystemData.HdpRoleUserTable.ROLE_NAME ); string szTable = string.Format("{0} A, {1} B" , SystemData.DataTable.HDP_ROLE_USER_T, SystemData.DataTable.HDP_ROLE_T); string szCondition = string.Format(" B.STATUS = 1 And A.{0}=B.{1}" , SystemData.HdpRoleUserTable.ROLE_CODE, SystemData.HdpRoleTable.ROLE_CODE); if (!string.IsNullOrEmpty(szUserID)) { szCondition = string.Format("{0} and A.{1}='{2}'" , szCondition , SystemData.HdpRoleUserTable.USER_ID, szUserID); } string szSQL = string.Format(SystemData.SQL.SELECT_WHERE, szField , szTable , szCondition); IDataReader dataReader = null; try { dataReader = base.MedQCAccess.ExecuteReader(szSQL, CommandType.Text); if (dataReader == null || dataReader.IsClosed || !dataReader.Read()) { return(SystemData.ReturnValue.RES_NO_FOUND); } if (lstHdpRoleUser == null) { lstHdpRoleUser = new List <HdpRoleUser>(); } do { HdpRoleUser hdpRoleUser = new HdpRoleUser(); if (!dataReader.IsDBNull(0)) { hdpRoleUser.UserID = dataReader.GetString(0); } if (!dataReader.IsDBNull(1)) { hdpRoleUser.RoleCode = dataReader.GetString(1); } if (!dataReader.IsDBNull(1)) { hdpRoleUser.RoleName = dataReader.GetString(2); } lstHdpRoleUser.Add(hdpRoleUser); } while (dataReader.Read()); return(SystemData.ReturnValue.OK); } catch (Exception ex) { LogManager.Instance.WriteLog("HDPDBAccess.GetHdpRoleUserList", new string[] { "szSQL" }, new object[] { szSQL }, ex); return(SystemData.ReturnValue.EXCEPTION); } finally { if (dataReader != null) { dataReader.Close(); dataReader.Dispose(); dataReader = null; } base.MedQCAccess.CloseConnnection(false); } }