Пример #1
0
        /// <summary>
        /// 管理平台,修改一条授权信息
        /// </summary>
        /// <param name="hdpUIConfig">产品信息</param>
        /// <param name="szOldNameShort">旧的产品缩写</param>
        /// <returns>SystemData.ReturnValue</returns>
        public short ModifyHdpRoleGrant(string szGrantID, HdpRoleGrant hdpRoleGrant)
        {
            if (base.MedQCAccess == null)
            {
                return(SystemData.ReturnValue.PARAM_ERROR);
            }

            string szField = string.Format("{0}='{1}',{2}='{3}',{4}='{5}',{6}='{7}',{8}='{9}'"
                                           , SystemData.HdpRoleGrantTable.PRODUCT, hdpRoleGrant.Product
                                           , SystemData.HdpRoleGrantTable.ROLE_CODE, hdpRoleGrant.RoleCode
                                           , SystemData.HdpRoleGrantTable.ROLE_RIGHT_COMMAND, hdpRoleGrant.RoleRightCommand
                                           , SystemData.HdpRoleGrantTable.ROLE_RIGHT_DESC, hdpRoleGrant.RoleRightDesc
                                           , SystemData.HdpRoleGrantTable.ROLE_RIGHT_KEY, hdpRoleGrant.RoleRightKey);
            string szCondition = string.Format("{0}='{1}'"
                                               , SystemData.HdpRoleGrantTable.GRANT_ID, szGrantID);
            string szSQL = string.Format(SystemData.SQL.UPDATE, SystemData.DataTable.HDP_ROLE_GRANT_T, szField, szCondition);

            int nCount = 0;

            try
            {
                nCount = base.MedQCAccess.ExecuteNonQuery(szSQL, CommandType.Text);
            }
            catch (Exception ex)
            {
                LogManager.Instance.WriteLog("HDPDBAccess.ModifyHdpRoleGrant", new string[] { "SQL" }, new object[] { szSQL }, "SQL执行失败!", ex);
                return(SystemData.ReturnValue.EXCEPTION);
            }
            return(nCount > 0 ? SystemData.ReturnValue.OK : SystemData.ReturnValue.EXCEPTION);
        }
Пример #2
0
        /// <summary>
        /// 装载病案质量问题分类信息
        /// </summary>
        private void LoadHdpRoleGrantList()
        {
            this.dataGridView1.Rows.Clear();
            if (this.toolcboProduct.SelectedItem == null)
            {
                return;
            }
            string szProduct = (this.toolcboProduct.SelectedItem as HdpProduct).NAME_SHORT;
            List <HdpRoleGrant> lstHdpRoleGrant = null;
            short shRet = HdpRoleGrantAccess.Instance.GetHdpRoleGrantList(this.m_roleInfo.RoleCode, szProduct, ref lstHdpRoleGrant);

            if (shRet != SystemData.ReturnValue.OK &&
                shRet != SystemData.ReturnValue.RES_NO_FOUND)
            {
                MessageBoxEx.Show("获取病案质量问题分类字典失败!");
                return;
            }
            if (lstHdpRoleGrant == null || lstHdpRoleGrant.Count <= 0)
            {
                return;
            }
            for (int index = 0; index < lstHdpRoleGrant.Count; index++)
            {
                HdpRoleGrant     hdpRoleGrant = lstHdpRoleGrant[index];
                int              nRowIndex    = this.dataGridView1.Rows.Add();
                DataTableViewRow row          = this.dataGridView1.Rows[nRowIndex];
                row.Tag = hdpRoleGrant; //将记录信息保存到该行
                this.SetRowData(row, hdpRoleGrant);
                this.dataGridView1.SetRowState(row, RowState.Normal);
            }
        }
Пример #3
0
        /// <summary>
        /// 获取指定行最新修改后的数据
        /// </summary>
        /// <param name="row">指定行</param>
        /// <param name="hdpResource">最新修改后的数据</param>
        /// <returns>bool</returns>
        private bool MakeRowData(DataTableViewRow row, ref HdpRoleGrant hdpRoleGrant)
        {
            if (row == null || row.Index < 0)
            {
                return(false);
            }
            hdpRoleGrant = new HdpRoleGrant();
            HdpRoleGrant oldHdpRoleGrant = row.Tag as HdpRoleGrant;

            if (!this.dataGridView1.IsNewRow(row))
            {
                if (oldHdpRoleGrant == null)
                {
                    MessageBoxEx.Show("角色授权信息为空!");
                    return(false);
                }
            }

            if (this.dataGridView1.IsDeletedRow(row))
            {
                hdpRoleGrant = oldHdpRoleGrant;
                return(true);
            }

            if (this.toolcboProduct.SelectedItem == null || this.toolcboProduct.Text == string.Empty)
            {
                MessageBoxEx.Show("您必须选择产品!");
                return(false);
            }
            if (GlobalMethods.Misc.IsEmptyString((string)row.Cells[this.colRoleRightKey.Index].Value))
            {
                this.dataGridView1.CurrentCell = row.Cells[this.colRoleRightKey.Index];
                this.dataGridView1.BeginEdit(true);
                MessageBoxEx.Show("您必须选择权限点!");
                return(false);
            }
            if (hdpRoleGrant == null)
            {
                hdpRoleGrant = new HdpRoleGrant();
            }

            hdpRoleGrant.GrantID  = oldHdpRoleGrant.GrantID;
            hdpRoleGrant.RoleCode = this.m_roleInfo.RoleCode;
            hdpRoleGrant.Product  = (this.toolcboProduct.SelectedItem as HdpProduct).NAME_SHORT;

            hdpRoleGrant.RoleRightKey = (string)row.Cells[this.colRoleRightKey.Index].Value;

            hdpRoleGrant.RoleRightDesc = (string)row.Cells[this.colRoleRightDesc.Index].Value;
            if (row.Cells[this.colRoleRightCommand.Index].Value != null)
            {
                hdpRoleGrant.RoleRightCommand = (string)row.Cells[this.colRoleRightCommand.Index].Value;
            }
            ;

            return(true);
        }
Пример #4
0
 /// <summary>
 /// 检查是否已经在列表中存在授权项
 /// </summary>
 /// <param name="hdpRoleGrant"></param>
 private bool CheckGrantRowData(HdpRoleGrant hdpRoleGrant)
 {
     foreach (DataGridViewRow item in this.dataGridView1.Rows)
     {
         HdpRoleGrant rowHdpRoleGrant = (item.Tag as HdpRoleGrant);
         if (rowHdpRoleGrant != null && rowHdpRoleGrant.RoleRightKey == hdpRoleGrant.RoleRightKey)
         {
             return(true);
         }
     }
     return(false);
 }
Пример #5
0
        /// <summary>
        /// 设置指定行显示的数据,以及绑定的数据
        /// </summary>
        /// <param name="row">指定行</param>
        /// <param name="hdpResource">绑定的数据</param>
        /// <returns>bool</returns>
        private bool SetRowData(DataGridViewRow row, HdpRoleGrant hdpRoleGrant)
        {
            if (row == null || row.Index < 0 || hdpRoleGrant == null)
            {
                return(false);
            }
            row.Tag = hdpRoleGrant;

            row.Cells[this.colRoleRightKey.Index].Value = hdpRoleGrant.RoleRightKey;

            row.Cells[this.colRoleRightDesc.Index].Value = hdpRoleGrant.RoleRightDesc;

            row.Cells[this.colRoleRightCommand.Index].Value = hdpRoleGrant.RoleRightCommand;
            return(true);
        }
Пример #6
0
        /// <summary>
        /// 增加一行记录
        /// </summary>
        private void AddNewItem()
        {
            //创建数据
            HdpRoleGrant hdpRoleGrant = new HdpRoleGrant();
            //创建行
            int index            = this.dataGridView1.Rows.Add();
            DataTableViewRow row = this.dataGridView1.Rows[index];

            hdpRoleGrant.GrantID = hdpRoleGrant.MakeGrantID();
            row.Tag = hdpRoleGrant;
            this.dataGridView1.SetRowState(row, RowState.New);
            this.UpdateUIState();

            this.dataGridView1.CurrentCell = row.Cells[this.colRoleRightKey.Index];
            this.dataGridView1.BeginEdit(true);
        }
Пример #7
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (this.cboProduct.SelectedItem == null)
            {
                MessageBoxEx.Show("请选择产品");
                return;
            }

            string szProduct = (this.cboProduct.SelectedItem as HdpProduct).NAME_SHORT;
            List <HdpRoleGrant> lstHdpRoleGrant = new List <HdpRoleGrant>();

            foreach (Control item in this.flpGrant.Controls)
            {
                CheckBox chk = item as CheckBox;
                if (item == null)
                {
                    continue;
                }
                if (chk.Checked == false)
                {
                    continue;
                }
                RightPoint   point        = chk.Tag as RightPoint;
                HdpRoleGrant hdpRoleGrant = new HdpRoleGrant();
                hdpRoleGrant.GrantID          = hdpRoleGrant.MakeGrantID();
                hdpRoleGrant.RoleCode         = this.m_roleInfo.RoleCode;
                hdpRoleGrant.Product          = szProduct;
                hdpRoleGrant.RoleRightCommand = point.RightCommand;
                hdpRoleGrant.RoleRightDesc    = point.RightDesc;
                hdpRoleGrant.RoleRightKey     = point.RightKey;
                lstHdpRoleGrant.Add(hdpRoleGrant);
            }
            short shRet = HdpRoleGrantAccess.Instance.SaveHdpRoleGrantList(this.m_roleInfo.RoleCode, szProduct, lstHdpRoleGrant);

            if (shRet != SystemData.ReturnValue.OK)
            {
                MessageBoxEx.Show("授权失败!");
                return;
            }
            MessageBoxEx.ShowMessage("授权成功!");
            this.DialogResult = DialogResult.OK;
        }
Пример #8
0
        /// <summary>
        /// 管理平台,保存一条角色信息
        /// </summary>
        /// <param name="HdpUIConfig">角色信息</param>
        /// <returns>SystemData.ReturnValue</returns>
        public short SaveHdpRoleGrant(HdpRoleGrant hdpRoleGrant)
        {
            if (base.MedQCAccess == null)
            {
                return(SystemData.ReturnValue.PARAM_ERROR);
            }

            string szField = string.Format("{0},{1},{2},{3},{4},{5}"
                                           , SystemData.HdpRoleGrantTable.GRANT_ID
                                           , SystemData.HdpRoleGrantTable.PRODUCT
                                           , SystemData.HdpRoleGrantTable.ROLE_CODE
                                           , SystemData.HdpRoleGrantTable.ROLE_RIGHT_COMMAND
                                           , SystemData.HdpRoleGrantTable.ROLE_RIGHT_DESC
                                           , SystemData.HdpRoleGrantTable.ROLE_RIGHT_KEY);
            string szValue = string.Format("'{0}','{1}','{2}','{3}','{4}','{5}'"
                                           , hdpRoleGrant.GrantID
                                           , hdpRoleGrant.Product
                                           , hdpRoleGrant.RoleCode
                                           , hdpRoleGrant.RoleRightCommand
                                           , hdpRoleGrant.RoleRightDesc
                                           , hdpRoleGrant.RoleRightKey);
            string szSQL = string.Format(SystemData.SQL.INSERT, SystemData.DataTable.HDP_ROLE_GRANT_T, szField, szValue);


            int nCount = 0;

            try
            {
                nCount = base.MedQCAccess.ExecuteNonQuery(szSQL, CommandType.Text);
            }
            catch (Exception ex)
            {
                LogManager.Instance.WriteLog("HDPDBAccess.SaveHdpRoleGrant", new string[] { "SQL" }, new object[] { szSQL }, "SQL执行失败!", ex);
                return(SystemData.ReturnValue.EXCEPTION);
            }
            return(nCount > 0 ? SystemData.ReturnValue.OK : SystemData.ReturnValue.EXCEPTION);
        }
Пример #9
0
        /// <summary>
        /// 获取角色权限列表
        /// </summary>
        private void LoadHdpRoleGrantList()
        {
            if (this.cboProduct.SelectedItem == null)
            {
                return;
            }
            string szProduct = (this.cboProduct.SelectedItem as HdpProduct).NAME_SHORT;
            List <HdpRoleGrant> lstHdpRoleGrant = null;
            short shRet = HdpRoleGrantAccess.Instance.GetHdpRoleGrantList(this.m_roleInfo.RoleCode, null, ref lstHdpRoleGrant);

            if (shRet != SystemData.ReturnValue.OK &&
                shRet != SystemData.ReturnValue.RES_NO_FOUND)
            {
                MessageBoxEx.Show("无法获取角色权限!");
                return;
            }
            if (dicHdpRoleGrant == null)
            {
                dicHdpRoleGrant = new Dictionary <string, HdpRoleGrant>();
            }

            dicHdpRoleGrant.Clear();
            if (lstHdpRoleGrant == null || lstHdpRoleGrant.Count <= 0)
            {
                return;
            }

            for (int index = 0; index < lstHdpRoleGrant.Count; index++)
            {
                HdpRoleGrant hdpRoleGrant = lstHdpRoleGrant[index];
                if (dicHdpRoleGrant.ContainsKey(hdpRoleGrant.RoleRightKey))
                {
                    continue;
                }
                dicHdpRoleGrant.Add(hdpRoleGrant.RoleRightKey, hdpRoleGrant);
            }
        }
Пример #10
0
        /// <summary>
        /// 管理平台,获取角色权限管理列表
        /// </summary>
        /// <param name="szRoleName"></param>
        /// <param name="lstHdpRole"></param>
        /// <returns></returns>
        public short GetHdpRoleGrantList(string szRoleCode, string szProduct, ref List <HdpRoleGrant> lstHdpRoleGrant)
        {
            if (base.MedQCAccess == null)
            {
                return(SystemData.ReturnValue.PARAM_ERROR);
            }

            string szField = string.Format("{0},{1},{2},{3},{4},{5}"
                                           , SystemData.HdpRoleGrantTable.ROLE_CODE
                                           , SystemData.HdpRoleGrantTable.ROLE_RIGHT_KEY
                                           , SystemData.HdpRoleGrantTable.ROLE_RIGHT_DESC
                                           , SystemData.HdpRoleGrantTable.ROLE_RIGHT_COMMAND
                                           , SystemData.HdpRoleGrantTable.PRODUCT
                                           , SystemData.HdpRoleGrantTable.GRANT_ID
                                           );
            string szCondition = string.Format(" 1=1 ");

            if (!string.IsNullOrEmpty(szRoleCode))
            {
                szCondition = string.Format("{0} and {1} in '{2}'"
                                            , szCondition
                                            , SystemData.HdpRoleGrantTable.ROLE_CODE, szRoleCode);
            }
            if (!string.IsNullOrEmpty(szProduct))
            {
                szCondition = string.Format("{0} and {1}='{2}'"
                                            , szCondition
                                            , SystemData.HdpRoleGrantTable.PRODUCT, szProduct);
            }
            string szSQL = string.Format(SystemData.SQL.SELECT_WHERE_ORDER_ASC, szField
                                         , SystemData.DataTable.HDP_ROLE_GRANT_T
                                         , szCondition
                                         , SystemData.HdpRoleGrantTable.ROLE_RIGHT_KEY);
            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 (lstHdpRoleGrant == null)
                {
                    lstHdpRoleGrant = new List <HdpRoleGrant>();
                }
                do
                {
                    HdpRoleGrant hdpRoleGrant = new HdpRoleGrant();
                    if (!dataReader.IsDBNull(0))
                    {
                        hdpRoleGrant.RoleCode = dataReader.GetValue(0).ToString();
                    }
                    if (!dataReader.IsDBNull(1))
                    {
                        hdpRoleGrant.RoleRightKey = dataReader.GetString(1);
                    }
                    if (!dataReader.IsDBNull(2))
                    {
                        hdpRoleGrant.RoleRightDesc = dataReader.GetString(2);
                    }
                    if (!dataReader.IsDBNull(3))
                    {
                        hdpRoleGrant.RoleRightCommand = dataReader.GetString(3);
                    }
                    if (!dataReader.IsDBNull(4))
                    {
                        hdpRoleGrant.Product = dataReader.GetString(4);
                    }

                    if (!dataReader.IsDBNull(5))
                    {
                        hdpRoleGrant.GrantID = dataReader.GetString(5);
                    }
                    lstHdpRoleGrant.Add(hdpRoleGrant);
                } while (dataReader.Read());
                return(SystemData.ReturnValue.OK);
            }
            catch (Exception ex)
            {
                LogManager.Instance.WriteLog("MedQCAccess.GetHdpRoleGrantList", 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);
            }
        }
Пример #11
0
        /// <summary>
        /// 保存指定行的数据到远程数据表,需要注意的是:行的删除状态会与其他状态共存
        /// </summary>
        /// <param name="row">指定行</param>
        /// <returns>SystemData.ReturnValue</returns>
        private short SaveRowData(DataTableViewRow row)
        {
            if (row == null || row.Index < 0)
            {
                return(SystemData.ReturnValue.FAILED);
            }
            if (this.dataGridView1.IsNormalRow(row) || this.dataGridView1.IsUnknownRow(row))
            {
                if (!this.dataGridView1.IsDeletedRow(row))
                {
                    return(SystemData.ReturnValue.CANCEL);
                }
            }

            HdpRoleGrant hdpRoleGrant = row.Tag as HdpRoleGrant;

            if (hdpRoleGrant == null)
            {
                return(SystemData.ReturnValue.FAILED);
            }
            string szGrantID = hdpRoleGrant.GrantID;

            hdpRoleGrant = null;
            if (!this.MakeRowData(row, ref hdpRoleGrant))
            {
                return(SystemData.ReturnValue.FAILED);
            }

            short shRet = SystemData.ReturnValue.OK;

            if (this.dataGridView1.IsDeletedRow(row))
            {
                if (!this.dataGridView1.IsNewRow(row))
                {
                    shRet = HdpRoleGrantAccess.Instance.DeleteHdpRoleGrant(szGrantID);
                }
                if (shRet != SystemData.ReturnValue.OK)
                {
                    this.dataGridView1.SelectRow(row);
                    MessageBoxEx.Show("无法删除当前记录!");
                    return(SystemData.ReturnValue.FAILED);
                }
                this.dataGridView1.Rows.Remove(row);
            }
            else if (this.dataGridView1.IsModifiedRow(row))
            {
                shRet = HdpRoleGrantAccess.Instance.ModifyHdpRoleGrant(szGrantID, hdpRoleGrant);
                if (shRet != SystemData.ReturnValue.OK)
                {
                    this.dataGridView1.SelectRow(row);
                    MessageBoxEx.Show("无法更新当前记录!");
                    return(SystemData.ReturnValue.FAILED);
                }
                row.Tag = hdpRoleGrant;
                this.dataGridView1.SetRowState(row, RowState.Normal);
            }
            else if (this.dataGridView1.IsNewRow(row))
            {
                shRet = HdpRoleGrantAccess.Instance.SaveHdpRoleGrant(hdpRoleGrant);
                if (shRet != SystemData.ReturnValue.OK)
                {
                    this.dataGridView1.SelectRow(row);
                    MessageBoxEx.Show("无法保存当前记录!");
                    return(SystemData.ReturnValue.FAILED);
                }
                row.Tag = hdpRoleGrant;
                this.dataGridView1.SetRowState(row, RowState.Normal);
            }
            return(SystemData.ReturnValue.OK);
        }