/// <summary> /// 确定修改 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void labelRepair_Click(object sender, EventArgs e) { clsUpdateData updata = new clsUpdateData(); clsSetSqlData sql = new clsSetSqlData(); string err = string.Empty; try { for (int i = 0; i < CheckDatas.Rows.Count; i++) { //updata.bianhao = CheckDatas.Rows[i].Cells[0].Value.ToString(); //Global.bianhao = CheckDatas.Rows[i].Cells[0].Value.ToString(); ////updata.Chkxiangmu = CheckDatas.Rows[i].Cells[1].Value.ToString(); //Global.Chkxiangmu = CheckDatas.Rows[i].Cells[1].Value.ToString(); ////updata.ChkTime = CheckDatas.Rows[i].Cells[2].Value.ToString(); //Global.ChkTime =DateTime.Parse( CheckDatas.Rows[i].Cells[2].Value.ToString()); ////updata.ChkSample = CheckDatas.Rows[i].Cells[3].Value.ToString(); //Global.ChkSample = CheckDatas.Rows[i].Cells[3].Value.ToString(); //updata.result = CheckDatas.Rows[i].Cells[14].Value.ToString(); //updata.unit = CheckDatas.Rows[i].Cells[5].Value.ToString(); //updata.GetSampTime = CheckDatas.Rows[i].Cells[6].Value.ToString(); //updata.GetSampPlace = CheckDatas.Rows[i].Cells[7].Value.ToString(); //updata.intrument = CheckDatas.Rows[i].Cells[8].Value.ToString(); //updata.Chktestbase = CheckDatas.Rows[i].Cells[9].Value.ToString(); ////updata.ChklimitData = CheckDatas.Rows[i].Cells[8].Value.ToString(); //updata.ChkPeople = CheckDatas.Rows[i].Cells[10].Value.ToString(); //updata.ChkUnit = CheckDatas.Rows[i].Cells[11].Value.ToString(); //updata.quantityin = CheckDatas.Rows[i].Cells[12].Value.ToString(); //updata.sampleNum = CheckDatas.Rows[i].Cells[13].Value.ToString(); //sql.UpdateResult(updata, out err); updata.ChkSample = CheckDatas.Rows[i].Cells[0].Value.ToString();; updata.Chkxiangmu = CheckDatas.Rows[i].Cells[1].Value.ToString(); updata.result = CheckDatas.Rows[i].Cells[2].Value.ToString(); updata.unit = CheckDatas.Rows[i].Cells[3].Value.ToString(); updata.Chktestbase = CheckDatas.Rows[i].Cells[4].Value.ToString(); updata.ChklimitData = CheckDatas.Rows[i].Cells[5].Value.ToString(); updata.intrument = CheckDatas.Rows[i].Cells[6].Value.ToString(); updata.conclusion = CheckDatas.Rows[i].Cells[7].Value.ToString(); updata.detectunit = CheckDatas.Rows[i].Cells[8].Value.ToString(); updata.GetSampTime = CheckDatas.Rows[i].Cells[9].Value.ToString(); updata.GetSampPlace = CheckDatas.Rows[i].Cells[10].Value.ToString(); updata.ChkUnit = CheckDatas.Rows[i].Cells[11].Value.ToString(); updata.ChkPeople = CheckDatas.Rows[i].Cells[12].Value.ToString(); updata.ChkTime = CheckDatas.Rows[i].Cells[13].Value.ToString(); sql.RepairResult(updata, ssid[i], out err); } MessageBox.Show("修改成功", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); this.DialogResult = DialogResult.OK; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error"); } this.Close(); }
/// <summary> /// 根据样品名称判定检测结果 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void cmbSample_SelectedIndexChanged(object sender, EventArgs e) { //LZ2000读回数据有结果无需判断 if (Global.ChkManchine == "LZ-2000农药残留快检仪") { if (cmbSample.Text == "以下相同") { for (int k = CheckDatas.CurrentCell.RowIndex; k < CheckDatas.Rows.Count; k++) { CheckDatas.Rows[k].Cells[8].Value = CheckDatas.CurrentCell.Value.ToString(); } cmbSample.Visible = false; } else if (cmbSample.Text == "删除") { CheckDatas.CurrentCell.Value = ""; cmbSample.Visible = false; } else { CheckDatas.CurrentCell.Value = cmbSample.Text; cmbSample.Visible = false; } } else //非LZ2000 { if (cmbSample.Text == "以下相同") { for (int k = CheckDatas.CurrentCell.RowIndex; k < CheckDatas.Rows.Count; k++) { CheckDatas.Rows[k].Cells[8].Value = CheckDatas.CurrentCell.Value.ToString(); //查找检测项目编号 for (int d = 0; d < clsDY3000DY.CheckItemsArray.GetLength(1); d++) { if (clsDY3000DY.CheckItemsArray[d, 0] == CheckDatas.Rows[k].Cells[2].Value.ToString()) { chkitecode = clsDY3000DY.CheckItemsArray[d, 1]; } } try { string[] rtn = new string[3]; rtn[0] = ""; rtn[1] = "0"; rtn[2] = ""; bool IsExist = false; string foodCode = string.Empty; for (int j = 0; j < Sarr.GetLength(0); j++) { if (CheckDatas.Rows[k].Cells[8].Value.ToString() == Sarr[j, 0]) { foodCode = Sarr[j, 1]; } } string errMsg = string.Empty; string sql = "SELECT CheckItemCodes FROM CheckSample WHERE syscode='" + foodCode + "'"; Object o = DataBase.GetOneValue(sql, out errMsg); if (o == null) { return; } else { string[,] result = clsStringUtil.GetFoodAry(o.ToString()); if (result.GetLength(0) >= 1) { for (int j = 0; j < result.GetLength(0); j++) { int d = result.GetLength(0); if (result[j, 0].Equals(chkitecode)) { IsExist = true; if (result[j, 1].Equals("-1")) { sql = "SELECT DemarcateInfo FROM tCheckItem WHERE SysCode='" + chkitecode + "'"; o = DataBase.GetOneValue(sql, out errMsg); if (o == null) { rtn[0] = ""; } else { rtn[0] = o.ToString(); } sql = "SELECT StandardValue FROM tCheckItem WHERE SysCode='" + chkitecode + "'"; o = DataBase.GetOneValue(sql, out errMsg); if (o == null) { rtn[1] = ""; } else { rtn[1] = o.ToString(); } sql = "SELECT Unit FROM tCheckItem WHERE SysCode='" + chkitecode + "'"; o = DataBase.GetOneValue(sql, out errMsg); if (o == null) { rtn[2] = ""; } else { rtn[2] = o.ToString(); } } else { rtn[0] = result[j, 1]; rtn[1] = result[j, 2]; rtn[2] = result[j, 3]; } break; } if (!IsExist) { rtn[0] = "-1"; rtn[1] = "0"; rtn[2] = "-1"; } } } } _dTestValue = Convert.ToDecimal(rtn[1]); _sign = rtn[0]; if (CheckDatas.Rows[k].Cells[2].Value.ToString() != string.Empty) { checkValueState(_dTestValue, k);//自动关联合格或不合格 } cmbSample.Visible = false; //查询检测依据 string Ssql = "SELECT ItemDes FROM tStandSample WHERE FtypeNmae='" + CheckDatas.Rows[CheckDatas.CurrentCell.RowIndex].Cells[8].Value.ToString() + "'"; Object os = DataBase.GetOneValue(Ssql, out errMsg); if (os != null) { CheckDatas.Rows[k].Cells[11].Value = os.ToString(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error"); } } } else if (cmbSample.Text == "删除") { CheckDatas.CurrentCell.Value = ""; cmbSample.Visible = false; } else { try { CheckDatas.CurrentCell.Value = cmbSample.Text; string[] rtn = new string[3]; rtn[0] = ""; rtn[1] = "0"; rtn[2] = ""; bool IsExist = false; string foodCode = string.Empty; for (int i = 0; i < Sarr.GetLength(0); i++) { if (CheckDatas.CurrentCell.Value.ToString() == Sarr[i, 0]) { foodCode = Sarr[i, 1]; } } string errMsg = string.Empty; string sql = "SELECT CheckItemCodes FROM CheckSample WHERE syscode='" + foodCode + "'"; Object o = DataBase.GetOneValue(sql, out errMsg); if (o == null) { return; } else { string[,] result = clsStringUtil.GetFoodAry(o.ToString()); if (result.GetLength(0) >= 1) { for (int i = 0; i < result.GetLength(0); i++) { int d = result.GetLength(0); if (result[i, 0].Equals(chkitecode)) { IsExist = true; if (result[i, 1].Equals("-1")) { sql = "SELECT DemarcateInfo FROM tCheckItem WHERE SysCode='" + chkitecode + "'"; o = DataBase.GetOneValue(sql, out errMsg); if (o == null) { rtn[0] = ""; } else { rtn[0] = o.ToString(); } sql = "SELECT StandardValue FROM tCheckItem WHERE SysCode='" + chkitecode + "'"; o = DataBase.GetOneValue(sql, out errMsg); if (o == null) { rtn[1] = ""; } else { rtn[1] = o.ToString(); } sql = "SELECT Unit FROM tCheckItem WHERE SysCode='" + chkitecode + "'"; o = DataBase.GetOneValue(sql, out errMsg); if (o == null) { rtn[2] = ""; } else { rtn[2] = o.ToString(); } } else { rtn[0] = result[i, 1]; rtn[1] = result[i, 2]; rtn[2] = result[i, 3]; } break; } if (!IsExist) { rtn[0] = "-1"; rtn[1] = "0"; rtn[2] = "-1"; } } } } _dTestValue = Convert.ToDecimal(rtn[1]); _sign = rtn[0]; if (CheckDatas.Rows[CheckDatas.CurrentCell.RowIndex].Cells[2].Value.ToString() != string.Empty) { checkValueState(_dTestValue, CheckDatas.CurrentCell.RowIndex);//自动关联合格或不合格 } cmbSample.Visible = false; //查询检测依据 string Ssql = "SELECT ItemDes FROM tStandSample WHERE FtypeNmae='" + CheckDatas.Rows[CheckDatas.CurrentCell.RowIndex].Cells[8].Value.ToString() + "'"; Object os = DataBase.GetOneValue(Ssql, out errMsg); if (os != null) { CheckDatas.Rows[CheckDatas.CurrentCell.RowIndex].Cells[11].Value = os.ToString(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error"); } } } }