/// <summary> /// 禁用一条数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDisabled_Click(object sender, EventArgs e) { try { Log.Info(this.GetType() + "->" + ApplicationCommon.GetMethodName() + "---START"); //禁用前判断 DialogResult dialogResult = XtraMessageBox.Show("此操作可能导致其他关联数据出错,是否继续?", "选择", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.No) { return; } //检查必填字段 bool isAllOk = CheckNotNullField(); if (!isAllOk) { return; } //准备要存储的数据 ModelTESTTASK_PARTYPE modelParameterMonitortype = PreapairModelParameterMonitortype(); //更新数据 bool status = _bllTesttaskPartype.Disabled(modelParameterMonitortype.F_TYPE_CODE); //获得当前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(this.GetType() + "->" + ApplicationCommon.GetMethodName() + "---FAILED", ex); throw ex; } }
/// <summary> /// 永久删除一条数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDelete_Click(object sender, EventArgs e) { try { Log.Info(this.GetType() + "->" + ApplicationCommon.GetMethodName() + "---START"); //删除前判断 DialogResult dialogResult = XtraMessageBox.Show("此操作将永久删除数据并有可能导致其他关联数据出错,是否继续?", "选择", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.No) { return; } //检查必填字段 bool isAllOk = CheckNotNullField(); if (!isAllOk) { return; } //准备要存储的数据 ModelTESTTASK_PARTYPE modelParameterMonitortype = PreapairModelParameterMonitortype(); //更新数据 bool status = _bllTesttaskPartype.Drop(modelParameterMonitortype.F_TYPE_CODE); //绑定数据 BindGridview(); //重新刷新数据 lueParameterType_EditValueChanged(this, null); if (status) { XtraMessageBox.Show("此数据已删除。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); //刷新数据 gvList_RowClick(this, null); } else { XtraMessageBox.Show("没有数据被删除。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { Log.Error(this.GetType() + "->" + ApplicationCommon.GetMethodName() + "---FAILED", ex); throw ex; } }
/// <summary> /// 准备要操作的ModelPARAMETER_MONITORCOMMON /// </summary> /// <returns></returns> private ModelTESTTASK_PARTYPE PreapairModelParameterMonitortype() { try { Log.Info(this.GetType() + "->" + ApplicationCommon.GetMethodName() + "---START"); ModelTESTTASK_PARTYPE modelParameterMonitortype = new ModelTESTTASK_PARTYPE(); //参数编号 modelParameterMonitortype.F_TYPE_CODE = txtTypeCode.Text; //参数名称 modelParameterMonitortype.F_TYPE_NAME = txtTypeName.Text; //创建时间 DateTime optTime = DateTime.Now; modelParameterMonitortype.F_CREATE_TIME = optTime; //操作员 modelParameterMonitortype.F_OPERATOR_ID = AppGlobal.GUserId; //操作时间 modelParameterMonitortype.F_OPERATIONTIME = optTime; //是否删除 modelParameterMonitortype.F_DEL = 0; return(modelParameterMonitortype); } catch (Exception ex) { Log.Error(this.GetType() + "->" + ApplicationCommon.GetMethodName() + "---FAILED", ex); throw ex; } }
/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { try { Log.Info(this.GetType() + "->" + ApplicationCommon.GetMethodName() + "---START"); //检查必填字段 bool isAllOk = CheckNotNullField(); if (!isAllOk) { return; } //准备要存储的数据 ModelTESTTASK_PARTYPE modelParameterMonitortype = PreapairModelParameterMonitortype(); //判断此数据是否已经存在 bool isDataExist = _bllTesttaskPartype.Exists(modelParameterMonitortype.F_TYPE_CODE); //如果存在数据则更新 if (isDataExist) { //已经存在判断是否更新 DialogResult dialogResult = DevExpress.XtraEditors.XtraMessageBox.Show("当前数据已存在,是否更新?", "选择", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.No) { return; } //更新数据 bool status = _bllTesttaskPartype.Update(modelParameterMonitortype); //获得当前rowhandle int rowhandle = gvList.FocusedRowHandle; //绑定数据 BindGridview(); //设置焦点行 gvList.FocusedRowHandle = rowhandle; if (status) { XtraMessageBox.Show("此数据已更新。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { XtraMessageBox.Show("没有数据被更新,执行中断。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } //如果不存在就增加数据 else { //插入数据 _bllTesttaskPartype.Add(modelParameterMonitortype); //获得当前rowhandle int rowhandle = gvList.FocusedRowHandle; //绑定数据 BindGridview(); //设置焦点行 gvList.FocusedRowHandle = rowhandle + 1; XtraMessageBox.Show("此数据已增加。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { Log.Error(this.GetType() + "->" + ApplicationCommon.GetMethodName() + "---FAILED", ex); throw ex; } }