예제 #1
0
        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;
        }
예제 #2
0
        /// <summary>
        /// 获取所有编辑器用户权限
        /// </summary>
        /// <param name="rightType">用户权限类型</param>
        /// <param name="lstUserRight">用户权限信息列表</param>
        /// <returns>SystemData.ReturnValue</returns>
        public short GetUserRight(UserRightType rightType, ref List<UserRightBase> lstUserRight)
        {
            if (base.MedQCAccess == null)
                return SystemData.ReturnValue.PARAM_ERROR;

            string szField = string.Format("{0},{1},{2}"
                , SystemData.UserRightTable.USER_ID, SystemData.UserRightTable.RIGHT_CODE
                , SystemData.UserRightTable.RIGHT_DESC);
            string szTable = SystemData.DataTable.USER_RIGHT;
            DbParameter[] param = new DbParameter[1]{new DbParameter(SystemData.UserRightTable.RIGHT_TYPE
                                                                 , UserRightBase.GetRightTypeName(rightType))};
            string szCondition = string.Format("{0}='{1}' or {0}='MRQC'", SystemData.UserRightTable.RIGHT_TYPE
                ,SystemData.UserRightTable.RIGHT_TYPE);
            string szSQL = string.Format(SystemData.SQL.SELECT_WHERE, szField, szTable, szCondition);

            IDataReader dataReader = null;
            try
            {
                dataReader = base.MedQCAccess.ExecuteReader(szSQL, CommandType.Text, ref param);
                if (dataReader == null || dataReader.IsClosed || !dataReader.Read())
                    return SystemData.ReturnValue.RES_NO_FOUND;

                if (lstUserRight == null)
                    lstUserRight = new List<UserRightBase>();
                lstUserRight.Clear();

                do
                {
                    UserRightBase userRight = UserRightBase.Create(rightType);
                    userRight.UserID = dataReader.GetString(0).Trim();
                    if (!dataReader.IsDBNull(2))
                        userRight.RightDesc = dataReader.GetString(2);
                    if (!dataReader.IsDBNull(1))
                        userRight.SetRightCode(dataReader.GetString(1));
                    lstUserRight.Add(userRight);
                } while (dataReader.Read());
                return SystemData.ReturnValue.OK;
            }
            catch (Exception ex)
            {
                LogManager.Instance.WriteLog("RightAccess.GetUserRight", new string[] { "szSQL" }, new object[] { szSQL }, ex);
                return SystemData.ReturnValue.EXCEPTION;
            }
            finally { base.MedQCAccess.CloseConnnection(false); }
        }