Exemplo n.º 1
0
        /// <summary>
        /// 修改配置字典表中指定的配置数据
        /// </summary>
        /// <param name="szGroupName">配置组</param>
        /// <param name="szConfigName">配置项</param>
        /// <param name="configInfo">配置项及其配置数据</param>
        /// <returns>SystemData.ReturnValue</returns>
        public short UpdateHdpParameter(string szGroupName, string szConfigName, HdpParameter hdpParameter)
        {
            string szField = string.Format("{0}='{1}',{2}='{3}',{4}={5},{6}='{7}',{8}='{9}'"
                                           , SystemData.HdpParameterTable.GROUP_NAME, hdpParameter.GROUP_NAME
                                           , SystemData.HdpParameterTable.CONFIG_NAME, hdpParameter.CONFIG_NAME
                                           , SystemData.HdpParameterTable.CONFIG_VALUE, base.MedQCAccess.GetSqlParamName("ConfigValue")
                                           , SystemData.HdpParameterTable.CONFIG_DESC, hdpParameter.CONFIG_DESC
                                           , SystemData.HdpParameterTable.PRODUCT, hdpParameter.PRODUCT == null ? "MedQC" : hdpParameter.PRODUCT);
            string szCondition = string.Format("{0}='{1}' and {2}='{3}' "
                                               , SystemData.HdpParameterTable.GROUP_NAME, szGroupName
                                               , SystemData.HdpParameterTable.CONFIG_NAME, szConfigName);
            string szSQL = string.Format(SystemData.SQL.UPDATE, SystemData.DataTable.HDP_PARAMETER_T, szField, szCondition);

            DbParameter[] pmi = new DbParameter[1];
            pmi[0] = new DbParameter("ConfigValue", hdpParameter.CONFIG_VALUE);

            int nCount = 0;

            try
            {
                nCount = base.MedQCAccess.ExecuteNonQuery(szSQL, CommandType.Text, ref pmi);
            }
            catch (Exception ex)
            {
                LogManager.Instance.WriteLog("HDPDBAccess.UpdateHdpParameter", new string[] { "SQL" }, new object[] { szSQL }, "SQL执行失败!", ex);
                return(SystemData.ReturnValue.EXCEPTION);
            }
            return(nCount > 0 ? SystemData.ReturnValue.OK : SystemData.ReturnValue.EXCEPTION);
        }
Exemplo n.º 2
0
        private void LoadParameterList()
        {
            this.dataGridView1.Rows.Clear();


            List <HdpParameter> lstHdpParameter = null;

            short shRet = HdpParameterAccess.Instance.GetHdpParameters(null, null, null, ref lstHdpParameter);

            if (shRet == SystemData.ReturnValue.RES_NO_FOUND)
            {
                return;
            }
            if (shRet != SystemData.ReturnValue.OK)
            {
                GlobalMethods.UI.SetCursor(this, Cursors.Default);
                MessageBoxEx.Show("配置字典表加载失败!");
            }
            if (lstHdpParameter == null)
            {
                GlobalMethods.UI.SetCursor(this, Cursors.Default);
                return;
            }

            for (int index = 0; index < lstHdpParameter.Count; index++)
            {
                HdpParameter hdpParameter = lstHdpParameter[index];
                if (hdpParameter == null)
                {
                    continue;
                }
                int nRowIndex        = this.dataGridView1.Rows.Add();
                DataTableViewRow row = this.dataGridView1.Rows[nRowIndex];
                this.SetRowData(row, hdpParameter);
                this.dataGridView1.SetRowState(row, RowState.Normal);

                if (nRowIndex <= 0)
                {
                    continue;
                }

                DataTableViewRow prevRow = this.dataGridView1.Rows[nRowIndex - 1];
                if (!string.Equals(row.Cells[this.colConfigGroup.Index].Value
                                   , prevRow.Cells[this.colConfigGroup.Index].Value))
                {
                    if (prevRow.DefaultCellStyle.BackColor == Color.Gainsboro)
                    {
                        row.DefaultCellStyle.BackColor = Color.White;
                    }
                    else
                    {
                        row.DefaultCellStyle.BackColor = Color.Gainsboro;
                    }
                }
                else
                {
                    row.DefaultCellStyle.BackColor = prevRow.DefaultCellStyle.BackColor;
                }
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 设置指定行显示的数据,以及绑定的数据
 /// </summary>
 /// <param name="row">指定行</param>
 /// <param name="configInfo">绑定的数据</param>
 private bool SetRowData(DataTableViewRow row, HdpParameter parameter)
 {
     if (row == null || row.Index < 0 || parameter == null)
     {
         return(false);
     }
     row.Tag = parameter;
     row.Cells[this.colConfigGroup.Index].Value = parameter.GROUP_NAME;
     row.Cells[this.colConfigName.Index].Value  = parameter.CONFIG_NAME;
     row.Cells[this.colConfigValue.Index].Value = parameter.CONFIG_VALUE;
     row.Cells[this.colConfigDesc.Index].Value  = parameter.CONFIG_DESC;
     return(true);
 }
Exemplo n.º 4
0
        /// <summary>
        /// 增加一行记录
        /// </summary>
        private void AddNewItem()
        {
            //创建数据
            HdpParameter hdpParameter = new HdpParameter();
            //创建行
            int index            = this.dataGridView1.Rows.Add();
            DataTableViewRow row = this.dataGridView1.Rows[index];

            row.Tag = hdpParameter;
            this.dataGridView1.SetRowState(row, RowState.New);
            this.UpdateUIState();

            this.dataGridView1.CurrentCell = row.Cells[this.colConfigGroup.Index];
            this.dataGridView1.BeginEdit(true);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 获取指定行最新修改后的数据
        /// </summary>
        /// <param name="row">指定行</param>
        /// <param name="configInfo">最新修改后的数据</param>
        /// <returns>bool</returns>
        private bool MakeRowData(DataTableViewRow row, ref HdpParameter hdpParameter)
        {
            if (row == null || row.Index < 0)
            {
                return(false);
            }
            hdpParameter = new HdpParameter();

            object cellValue = row.Cells[this.colConfigGroup.Index].Value;

            if (GlobalMethods.Misc.IsEmptyString(cellValue))
            {
                this.dataGridView1.SelectRow(row);
                MessageBoxEx.Show("您必须输入配置组名称!");
                return(false);
            }
            hdpParameter.GROUP_NAME = cellValue.ToString();

            cellValue = row.Cells[this.colConfigName.Index].Value;
            if (GlobalMethods.Misc.IsEmptyString(cellValue))
            {
                this.dataGridView1.SelectRow(row);
                MessageBoxEx.Show("您必须输入配置项名称!");
                return(false);
            }
            hdpParameter.CONFIG_NAME = cellValue.ToString();

            if (row.Cells[this.colConfigValue.Index].Value != null)
            {
                hdpParameter.CONFIG_VALUE = row.Cells[this.colConfigValue.Index].Value.ToString();
            }
            if (row.Cells[this.colConfigDesc.Index].Value != null)
            {
                hdpParameter.CONFIG_DESC = row.Cells[this.colConfigDesc.Index].Value.ToString();
            }
            return(true);
        }
Exemplo n.º 6
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);
                }
            }

            HdpParameter hdpParameter = row.Tag as HdpParameter;

            if (hdpParameter == null)
            {
                return(SystemData.ReturnValue.FAILED);
            }
            string szGroupName  = hdpParameter.GROUP_NAME;
            string szConfigName = hdpParameter.CONFIG_NAME;

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

            short shRet = SystemData.ReturnValue.OK;

            if (this.dataGridView1.IsDeletedRow(row))
            {
                if (!this.dataGridView1.IsNewRow(row))
                {
                    shRet = HdpParameterAccess.Instance.DeleteHdpParameter(szGroupName, szConfigName);
                }
                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 = HdpParameterAccess.Instance.UpdateHdpParameter(szGroupName, szConfigName, hdpParameter);
                if (shRet != SystemData.ReturnValue.OK)
                {
                    this.dataGridView1.SelectRow(row);
                    MessageBoxEx.Show("无法更新当前记录!");
                    return(SystemData.ReturnValue.FAILED);
                }
                row.Tag = hdpParameter;
                this.dataGridView1.SetRowState(row, RowState.Normal);
            }
            else if (this.dataGridView1.IsNewRow(row))
            {
                shRet = HdpParameterAccess.Instance.SaveHdpParameter(hdpParameter);
                if (shRet != SystemData.ReturnValue.OK)
                {
                    this.dataGridView1.SelectRow(row);
                    MessageBoxEx.Show("无法保存当前记录!");
                    return(SystemData.ReturnValue.FAILED);
                }
                row.Tag = hdpParameter;
                this.dataGridView1.SetRowState(row, RowState.Normal);
            }
            return(SystemData.ReturnValue.OK);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 查询配置参数表获取指定的配置数据
        /// </summary>
        /// <param name="szProduct">产品</param>
        /// <param name="szGroupName">配置组名称</param>
        /// <param name="szConfigName">配置项名称(为空时返回该组所有配置项)</param>
        /// <param name="lstConfigInfos">返回的配置项及其配置数据</param>
        /// <returns>SystemData.ReturnValue</returns>
        public short GetHdpParameters(string szProduct, string szGroupName, string szConfigName, ref List <HdpParameter> lstHdpParameter)
        {
            if (base.MedQCAccess == null)
            {
                return(SystemData.ReturnValue.PARAM_ERROR);
            }

            string szField = string.Format("{0},{1},{2},{3},{4}"
                                           , SystemData.HdpParameterTable.GROUP_NAME, SystemData.HdpParameterTable.CONFIG_NAME
                                           , SystemData.HdpParameterTable.CONFIG_VALUE, SystemData.HdpParameterTable.CONFIG_DESC
                                           , SystemData.HdpParameterTable.PRODUCT);

            string szCondition = String.Format("1=1");

            if (!GlobalMethods.Misc.IsEmptyString(szGroupName))
            {
                szCondition = string.Format("{0}='{1}'", SystemData.HdpParameterTable.GROUP_NAME, szGroupName);
                if (!GlobalMethods.Misc.IsEmptyString(szConfigName))
                {
                    szCondition = string.Format("{0} AND {1}='{2}'", szCondition
                                                , SystemData.HdpParameterTable.CONFIG_NAME, szConfigName);
                }
            }
            if (!GlobalMethods.Misc.IsEmptyString(szProduct))
            {
                szCondition = string.Format("{0} AND {1}='{2}'", szCondition
                                            , SystemData.HdpParameterTable.PRODUCT, szProduct);
            }

            string szOrder = string.Format("{0},{1}"
                                           , SystemData.HdpParameterTable.GROUP_NAME, SystemData.HdpParameterTable.CONFIG_NAME);

            string szSQL = null;

            if (string.IsNullOrEmpty(szCondition))
            {
                szSQL = string.Format(SystemData.SQL.SELECT_ORDER_ASC
                                      , szField, SystemData.DataTable.HDP_PARAMETER_T, szOrder);
            }
            else
            {
                szSQL = string.Format(SystemData.SQL.SELECT_WHERE_ORDER_ASC
                                      , szField, SystemData.DataTable.HDP_PARAMETER_T, szCondition, szOrder);
            }

            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 (lstHdpParameter == null)
                {
                    lstHdpParameter = new List <HdpParameter>();
                }
                do
                {
                    HdpParameter parameter = new HdpParameter();
                    parameter.GROUP_NAME   = dataReader.GetString(0);
                    parameter.CONFIG_NAME  = dataReader.GetString(1);
                    parameter.CONFIG_VALUE = dataReader.GetString(2);

                    if (!dataReader.IsDBNull(3))
                    {
                        parameter.CONFIG_DESC = dataReader.GetString(3);
                    }
                    if (!dataReader.IsDBNull(4))
                    {
                        parameter.PRODUCT = dataReader.GetString(4);
                    }
                    lstHdpParameter.Add(parameter);
                } while (dataReader.Read());
                return(SystemData.ReturnValue.OK);
            }
            catch (Exception ex)
            {
                LogManager.Instance.WriteLog("HDPDBAccess.GetHdpParameters", new string[] { "szGroupName", "szConfigName", "SQL" }
                                             , new object[] { szGroupName, szConfigName, szSQL }, "没有查询到记录!", ex);
                return(SystemData.ReturnValue.EXCEPTION);
            }
            finally { base.MedQCAccess.CloseConnnection(false); }
        }