/// <summary> /// 彻底删除一条记录,一旦删除无法恢复,建议不要使用此功能 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDelete_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_WORKSTATION_INFO modelWorkstationInfo = PreModelWorkstationInfo(); //判断是否有关系 bool hasRelation = _bllDevWorkstationInfo.HasRelation(modelWorkstationInfo.F_WORKSTATION_ID); if (hasRelation) { XtraMessageBox.Show("此设备有和其他设备的关系,不能删除。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } //更新数据 bool status = _bllDevWorkstationInfo.Drop(modelWorkstationInfo.F_WORKSTATION_ID); //获得当前rowhandle int rowhandle = gvList.FocusedRowHandle; //绑定数据 BindGridview(); //设置焦点行 gvList.FocusedRowHandle = rowhandle; if (status) { XtraMessageBox.Show("此数据已删除。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { XtraMessageBox.Show("没有数据被更新。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { Log.Error(GetType() + "->" + ApplicationCommon.GetMethodName() + "---FAILED", ex); throw ex; } }
/// <summary> /// 启动其中的一条记录 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnEnabled_Click(object sender, EventArgs e) { try { Log.Info(GetType() + "->" + ApplicationCommon.GetMethodName() + "---START"); //检查必填字段 bool isAllOk = CheckNotNullField(); if (!isAllOk) { return; } //准备要存储的数据 ModelDEV_WORKSTATION_INFO modelWorkstationInfo = PreModelWorkstationInfo(); //更新数据 bool status = _bllDevWorkstationInfo.Enabled(modelWorkstationInfo.F_WORKSTATION_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; } }
/// <summary> /// 准备要操作的ModelPARAMETER_MONITORCOMMON /// </summary> /// <returns></returns> private ModelDEV_WORKSTATION_INFO PreModelWorkstationInfo() { try { Log.Info(GetType() + "->" + ApplicationCommon.GetMethodName() + "---START"); ModelDEV_WORKSTATION_INFO modelWorkstationInfo = new ModelDEV_WORKSTATION_INFO(); //编号 modelWorkstationInfo.F_WORKSTATION_ID = txtF_WORKSTATION_ID.Text; //名称 modelWorkstationInfo.F_WORKSTATION_NAME = txtF_WORKSTATION_NAME.Text; //状态 modelWorkstationInfo.F_WORKSTATION_STATUS = decimal.Parse(lueF_WORKSTATION_STATUS.EditValue.ToString()); //校验编号 modelWorkstationInfo.F_WORKSTATION_CALIBRATION = txtF_WORKSTATION_CALIBRATION.Text; //备注 modelWorkstationInfo.F_WORKSTATION_MEMO = txtF_WORKSTATION_MEMO.Text; //创建时间 DateTime optDateTime = DateTime.Now; modelWorkstationInfo.F_CREATE_TIME = optDateTime; //操作员 modelWorkstationInfo.F_OPERATOR_ID = AppGlobal.GUserId; //操作时间 modelWorkstationInfo.F_OPERATIONTIME = optDateTime; //是否删除 modelWorkstationInfo.F_DEL = 0; return(modelWorkstationInfo); } catch (Exception ex) { Log.Error(GetType() + "->" + ApplicationCommon.GetMethodName() + "---FAILED", ex); throw ex; } }
/// <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_WORKSTATION_INFO modelWorkstationInfo = PreModelWorkstationInfo(); //判断此数据是否已经存在 bool isDataExist = _bllDevWorkstationInfo.Exists(modelWorkstationInfo.F_WORKSTATION_ID); if (isDataExist) { //已经存在判断是否更新 DialogResult dialogResult = XtraMessageBox.Show("当前数据已存在,是否更新?", "选择", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.No) { return; } //更新数据 bool status = _bllDevWorkstationInfo.Update(modelWorkstationInfo); //获得当前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 { _bllDevWorkstationInfo.Add(modelWorkstationInfo); //获得当前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; } }