Пример #1
0
        /// <summary>
        /// 禁用其中的一条记录
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDisabled_Click(object sender, EventArgs e)
        {
            try
            {
                Log.Info(GetType() + "->" + ApplicationCommon.GetMethodName() + "---START");
                //禁用前判断
                DialogResult dialogResult = XtraMessageBox.Show("此操作可能导致其他关联数据出错,是否继续?", "选择", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dialogResult == DialogResult.No)
                {
                    return;
                }

                //检查必填字段
                bool isAllOk = CheckNotNullField();

                if (!isAllOk)
                {
                    return;
                }

                //准备要存储的数据
                ModelDEV_SENSOR_INFO modelSensorInfo = PrepareSensorInfo();

                //更新数据
                bool status = _bllSensorInfo.Disabled(modelSensorInfo.F_SENSOR_ID);

                //获得当前rowhandle
                int rowhandle = gvList.FocusedRowHandle;

                //绑定数据
                BindGridview();

                //设置焦点行
                gvList.FocusedRowHandle = rowhandle;

                if (status)
                {
                    XtraMessageBox.Show("此数据已禁用。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    //刷新数据
                    gvList_RowClick(this, null);
                }
                else
                {
                    XtraMessageBox.Show("没有数据被更新。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception ex)
            {
                Log.Error(GetType() + "->" + ApplicationCommon.GetMethodName() + "---FAILED", ex);
                throw ex;
            }
        }
Пример #2
0
        /// <summary>
        /// 表格点击,将其中数据显示在下面
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void gvList_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
        {
            try
            {
                Log.Info(GetType() + "->" + ApplicationCommon.GetMethodName() + "---START");
                if (gvList.FocusedRowHandle < 0)
                {
                    return;
                }


                string sensorId = gvList.GetFocusedRowCellValue("F_SENSOR_ID").ToString();

                ModelDEV_SENSOR_INFO modelSensorInfo = _bllSensorInfo.GetModel(sensorId);


                //温度传感器编号
                txtCode.Text = modelSensorInfo.F_SENSOR_ID;

                //温度传感器型号
                txtF_SENSOR_TYPE.Text = modelSensorInfo.F_SENSOR_TYPE;

                //设备类型
                lueF_DEV_TYPE.EditValue = modelSensorInfo.F_DEV_TYPE;

                //设备编码
                lueF_DEV_ID.EditValue = modelSensorInfo.F_DEV_ID;

                //端口
                txtF_COM_ADDRESS.Text = modelSensorInfo.F_COM_ADDRESS;

                //通信地址
                txtF_SENSOR_ADDRESS.Text = modelSensorInfo.F_SENSOR_ADDRESS.ToString();


                //热敏电阻安装端口
                txtF_SENSER_NO.Text = modelSensorInfo.F_SENSER_NO.ToString();

                //温度传感器位置
                txtF_SENSOR_POSTION.Text = modelSensorInfo.F_SENSOR_POSTION;

                //温度传感器安装时间
                if (modelSensorInfo.F_SENDOR_INSTALL_DATE != null)
                {
                    dateF_SENDOR_INSTALL_DATE.DateTime = (DateTime)modelSensorInfo.F_SENDOR_INSTALL_DATE;
                }

                //温度报警下限值
                txtF_SENSOR_VALUE_FLOOR.Text = modelSensorInfo.F_SENSOR_ALARMVALUE_FLOOR.ToString();

                //温度报警上限值
                txtF_SENSOR_VALUE_CEILING.Text = modelSensorInfo.F_SENSOR_ALARMVALUE_CEILING.ToString();

                //温度动作上限
                txtF_SENSOR_ACTIONVALUE_CEILING.Text = modelSensorInfo.F_SENSOR_ACTIONVALUE_CEILING.ToString();

                //温度动作下限
                txtF_SENSOR_ACTIONVALUE_FLOOR.Text = modelSensorInfo.F_SENSOR_ACTIONVALUE_FLOOR.ToString();

                //当前温度值
                txtF_SENSOR_NOW_VALUE.Text = modelSensorInfo.F_SENSOR_NOW_VALUE.ToString();

                //采集时间
                if (modelSensorInfo.F_SENSOR_VALUE_TIME != null)
                {
                    txtF_SENSOR_VALUE_TIME.Text = ((DateTime)modelSensorInfo.F_SENSOR_VALUE_TIME).ToString("yyyy/mm/dd hh:MM:ss");
                }

                //工作状态
                lueF_SENSOR_STATUS.EditValue = modelSensorInfo.F_SENSOR_STATUS;

                //温度校正系数
                txtF_TEMPERATURE_ADJUST_COFF.Text = modelSensorInfo.F_TEMPERATURE_ADJUST_COFF.ToString();

                //备注
                txtF_MEMO.Text = modelSensorInfo.F_MEMO;

                //禁用状态
                rdoF_DEL.EditValue = modelSensorInfo.F_DEL;
            }
            catch (Exception ex)
            {
                Log.Error(GetType() + "->" + ApplicationCommon.GetMethodName() + "---FAILED", ex);
                throw ex;
            }
        }
Пример #3
0
        /// <summary>
        /// 更新信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                Log.Info(GetType() + "->" + ApplicationCommon.GetMethodName() + "---START");

                //检查必填字段
                bool isAllOk = CheckNotNullField();

                if (!isAllOk)
                {
                    return;
                }

                //准备要存储的数据
                ModelDEV_SENSOR_INFO modelSensorInfo = PrepareSensorInfo();


                //判断此数据是否已经存在
                bool isDataExist = _bllSensorInfo.Exists(modelSensorInfo.F_SENSOR_ID);

                if (isDataExist)
                {
                    //已经存在判断是否更新
                    DialogResult dialogResult = XtraMessageBox.Show("当前数据已存在,是否更新?", "选择", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                    if (dialogResult == DialogResult.No)
                    {
                        return;
                    }
                    //更新数据
                    bool status = _bllSensorInfo.Update(modelSensorInfo);

                    //获得当前rowhandle
                    int rowhandle = gvList.FocusedRowHandle;

                    //绑定数据
                    BindGridview();

                    //设置焦点行
                    gvList.FocusedRowHandle = rowhandle;


                    if (status)
                    {
                        XtraMessageBox.Show("此数据已更新。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        XtraMessageBox.Show("没有数据被更新,操作中断。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                else
                {
                    _bllSensorInfo.Add(modelSensorInfo);


                    //获得当前rowhandle
                    int rowhandle = gvList.FocusedRowHandle;

                    //绑定数据
                    BindGridview();

                    //设置焦点行
                    gvList.FocusedRowHandle = rowhandle + 1;


                    XtraMessageBox.Show("此数据已增加。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                Log.Error(GetType() + "->" + ApplicationCommon.GetMethodName() + "---FAILED", ex);
                throw ex;
            }
        }
Пример #4
0
        /// <summary>
        ///     准备要操作的ModelPARAMETER_MONITORCOMMON
        /// </summary>
        /// <returns></returns>
        private ModelDEV_SENSOR_INFO PrepareSensorInfo()
        {
            try
            {
                Log.Info(GetType() + "->" + ApplicationCommon.GetMethodName() + "---START");


                ModelDEV_SENSOR_INFO modelSensorInfo = new ModelDEV_SENSOR_INFO();


                //温度传感器编号
                modelSensorInfo.F_SENSOR_ID = txtCode.Text;

                //温度传感器型号
                modelSensorInfo.F_SENSOR_TYPE = txtF_SENSOR_TYPE.Text;

                //设备类型
                decimal devType;
                decimal.TryParse(lueF_DEV_TYPE.EditValue.ToString(), out devType);
                modelSensorInfo.F_DEV_TYPE = devType;

                //设备编码
                if (lueF_DEV_ID.EditValue != null)
                {
                    modelSensorInfo.F_DEV_ID = lueF_DEV_ID.EditValue.ToString();
                }

                //温度传感器位置
                modelSensorInfo.F_SENSOR_POSTION = txtF_SENSOR_POSTION.Text;

                //端口
                modelSensorInfo.F_COM_ADDRESS = txtF_COM_ADDRESS.Text.ToUpper();

                //通信地址
                modelSensorInfo.F_SENSOR_ADDRESS = decimal.Parse(txtF_SENSOR_ADDRESS.Text);

                //热敏电阻安装端口
                modelSensorInfo.F_SENSER_NO = decimal.Parse(txtF_SENSER_NO.Text);

                //温度传感器安装时间
                modelSensorInfo.F_SENDOR_INSTALL_DATE = dateF_SENDOR_INSTALL_DATE.DateTime;

                decimal tempDecimal;
                //温度报警下限值
                decimal.TryParse(txtF_SENSOR_VALUE_FLOOR.Text, out tempDecimal);
                modelSensorInfo.F_SENSOR_ALARMVALUE_FLOOR = tempDecimal;

                //温度报警上限值
                decimal.TryParse(txtF_SENSOR_VALUE_CEILING.Text, out tempDecimal);
                modelSensorInfo.F_SENSOR_ALARMVALUE_CEILING = tempDecimal;


                //温度动作下限值
                decimal.TryParse(txtF_SENSOR_ACTIONVALUE_FLOOR.Text, out tempDecimal);
                modelSensorInfo.F_SENSOR_ACTIONVALUE_FLOOR = tempDecimal;

                //温度动作上限值
                decimal.TryParse(txtF_SENSOR_ACTIONVALUE_CEILING.Text, out tempDecimal);
                modelSensorInfo.F_SENSOR_ACTIONVALUE_CEILING = tempDecimal;

                //当前温度值
                //modelSensorInfo.F_SENSOR_NOW_VALUE = decimal.Parse(txtF_SENSOR_NOW_VALUE.Text);

                //采集时间
                //modelSensorInfo.F_SENSOR_VALUE_TIME = dateF_SENSOR_VALUE_TIME.DateTime;

                //温度校正系数
                decimal.TryParse(txtF_TEMPERATURE_ADJUST_COFF.Text, out tempDecimal);
                modelSensorInfo.F_TEMPERATURE_ADJUST_COFF = tempDecimal;

                //备注
                modelSensorInfo.F_MEMO = txtF_MEMO.Text;


                //创建时间
                DateTime optDateTime = DateTime.Now;
                modelSensorInfo.F_CREATE_TIME = optDateTime;

                //操作员
                modelSensorInfo.F_OPERATOR_ID = AppGlobal.GUserId;

                //操作时间
                modelSensorInfo.F_OPERATIONTIME = optDateTime;

                //是否删除
                modelSensorInfo.F_DEL = 0;

                return(modelSensorInfo);
            }
            catch (Exception ex)
            {
                Log.Error(GetType() + "->" + ApplicationCommon.GetMethodName() + "---FAILED", ex);
                throw ex;
            }
        }