/// <summary> /// 保存信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { ProxyBllCOMMAND_INFO bllCommand_Info = new ProxyBllCOMMAND_INFO(); //置灰保存按钮 btnSave.Enabled = false; //判断该命令字编号在数据库中是否存在,如果存在进行修改处理,否则进行新增操作 string now_CommandCode = ""; now_CommandCode = txtCode.Text; DataSet dsCommandCodeCount = bllCommand_Info.GetCommandCount(now_CommandCode); int tempCommandCount = -1; if (dsCommandCodeCount != null) { if (dsCommandCodeCount.Tables[0].Rows.Count > 0) { tempCommandCount = Convert.ToInt16(dsCommandCodeCount.Tables[0].Rows[0][0].ToString()); } } if (tempCommandCount == 0) //新增操作 { try { //将产品标准数据写入Model类中 CreateOrUpdateCommandInfo(1); bllCommand_Info.Add(_mdlCommandInfo); } catch (Exception ex) { MessageBox.Show("系统处理异常,请联系管理员。", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else //修改操作 { //已经存在判断是否执行修改保存 DialogResult dialogResult = XtraMessageBox.Show("当前数据已存在,是否执行修改保存操作?", "选择", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.Yes) { try { //将产品数据写入Model类中 CreateOrUpdateCommandInfo(2); bllCommand_Info.Update(_mdlCommandInfo); } catch (Exception ex) { MessageBox.Show("系统处理异常,请联系管理员。", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } btnSave.Enabled = true; //读取未开始试验的试验任务 BindGridview(); }
/// <summary> /// 彻底删除一条记录,一旦删除无法恢复,建议不要使用此功能 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDelete_Click(object sender, EventArgs e) { string now_CommandCode = ""; string now_CommandId = ""; now_CommandId = txtId.Text; now_CommandCode = txtCode.Text; DialogResult dialogResult = XtraMessageBox.Show("确认执行试验命令字:" + now_CommandCode + "的删除操作吗?", "选择", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.Yes) { ProxyBllCOMMAND_INFO bllCommnadInfo = new ProxyBllCOMMAND_INFO(); bllCommnadInfo.Delete(Convert.ToInt16(now_CommandId), now_CommandCode); //读取试验命令字信息 BindGridview(); } }