Пример #1
0
        /// <summary>
        ///     准备要操作Model
        /// </summary>
        /// <returns></returns>
        private ModelDEV_TESTBOX_INFO PrepareModelSubordinateInfo()
        {
            try
            {
                Log.Info(GetType() + "->" + ApplicationCommon.GetMethodName() + "---START");


                ModelDEV_TESTBOX_INFO modelDevTestboxInfo = new ModelDEV_TESTBOX_INFO();


                //	试验箱编号
                modelDevTestboxInfo.F_TESTBOX_ID = txtF_TESTBOX_ID.Text;
                //	试验箱名称
                modelDevTestboxInfo.F_TESTBOX_NAME = txtF_TESTBOX_NAME.Text;

                //校准编号
                modelDevTestboxInfo.F_TESTBOX_CALIBRATION = txtF_TESTBOX_CALIBRATION.Text;

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

                //通信地址
                decimal subordinateAddress;

                decimal.TryParse(txtF_TESTBOX_ADDRESS.Text, out subordinateAddress);

                //通信地址
                modelDevTestboxInfo.F_TESTBOX_ADDRESS = subordinateAddress;

                //	试验箱状态
                modelDevTestboxInfo.F_TESTBOX_STATUS = decimal.Parse(lueF_TESTBOX_STATUS.EditValue.ToString());

                //	备注
                modelDevTestboxInfo.F_TESTBOX_MEMO = txtF_TESTBOX_MEMO.Text;


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

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

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

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

                return(modelDevTestboxInfo);
            }
            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 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_TESTBOX_INFO modelDevTestboxInfo = PrepareModelSubordinateInfo();

                //更新数据
                bool status = _bllDevTestboxInfo.Disabled(modelDevTestboxInfo.F_TESTBOX_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;
            }
        }
Пример #3
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 testboxId = gvList.GetFocusedRowCellValue("F_TESTBOX_ID").ToString();

                ModelDEV_TESTBOX_INFO modelDevTestboxInfo = _bllDevTestboxInfo.GetModel(testboxId);


                //试验箱编号
                txtF_TESTBOX_ID.Text = modelDevTestboxInfo.F_TESTBOX_ID;

                //试验箱名称
                txtF_TESTBOX_NAME.Text = modelDevTestboxInfo.F_TESTBOX_NAME;

                //校准编号
                txtF_TESTBOX_CALIBRATION.Text = modelDevTestboxInfo.F_TESTBOX_CALIBRATION;

                //所在负载柜编号
                txtF_COM_ADDRESS.Text = modelDevTestboxInfo.F_COM_ADDRESS;

                //地址
                txtF_TESTBOX_ADDRESS.Text = modelDevTestboxInfo.F_TESTBOX_ADDRESS.ToString();

                //工作状态
                lueF_TESTBOX_STATUS.EditValue = modelDevTestboxInfo.F_TESTBOX_STATUS;

                //备注
                txtF_TESTBOX_MEMO.Text = modelDevTestboxInfo.F_TESTBOX_MEMO;

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

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

                if (!isAllOk)
                {
                    return;
                }

                //准备要存储的数据
                ModelDEV_TESTBOX_INFO modelDevTestboxInfo = PrepareModelSubordinateInfo();


                //判断此数据是否已经存在
                bool isDataExist = _bllDevTestboxInfo.Exists(modelDevTestboxInfo.F_TESTBOX_ID);

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

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

                    //获得当前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
                {
                    _bllDevTestboxInfo.Add(modelDevTestboxInfo);


                    //获得当前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;
            }
        }