/// <summary> /// 手动验证物资 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnManually_Click(object sender, EventArgs e) { try { //获取当前选中行 if (dtSource == null || dtSource.Rows.Count == 0) { return; } int index = dataGrid.CurrentRowIndex; if (index < 0) { MessageBox.Show("请选择要验证的物资!"); return; } DataRow row = dtSource.Rows[index]; //判断当前行是否已经上车 bool flag = row["ikey1"].Equals("已出门"); string ID = row["ID"].ToString(); if (flag) { MessageBox.Show("该物资已出门!"); return; } string errMsg; try { Cursor.Current = Cursors.WaitCursor; flag = new BLL.OutVerify().Verify(ID, out errMsg); if (!flag) { throw new Exception(errMsg); } //手动验证 dtSource.Rows[index]["ikey1"] = "已出门"; } catch (Exception ex) { MessageBox.Show(ex.Message); return; } finally { Cursor.Current = Cursors.Default; } dataGrid.DataSource = dtSource; JudgeScanComplete(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnConfirm_Click(object sender, EventArgs e) { //判断类型 if (panelConfirm.Tag == null) { return; } //判断确认人是否为空 string confirmName = txtConfirm.Text.Trim(); if (string.IsNullOrEmpty(confirmName)) { MessageBox.Show("请输入确认人!"); txtConfirm.Focus(); return; } bool flag = false; string errMsg; //判断是保卫部出门 还是物资部出门 if (panelConfirm.Tag.Equals("Security")) { flag = new BLL.OutVerify().SecurityVerify(mainID.ToString(), confirmName, out errMsg); if (flag) { btnSecurity.Enabled = false; btnDepartment.Enabled = true; btnCancel_Click(null, null);//隐藏panel } else { MessageBox.Show("保卫部出门确认失败!" + errMsg); } } else if (panelConfirm.Tag.Equals("Department")) { flag = new BLL.OutVerify().DepartmentVerify(mainID.ToString(), confirmName, out errMsg); if (flag) { MessageBox.Show("出门验证完成!"); btnDepartment.Enabled = false; btnCancel_Click(null, null);//隐藏panel } else { MessageBox.Show("物资部出门确认失败!" + errMsg); } } }
/// <summary> /// 扫描物资条码 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void txtBarCode_KeyPress(object sender, KeyPressEventArgs e) { string barCode = txtBarCode.Text.Trim(); if (!string.IsNullOrEmpty(barCode) && e.KeyChar == (char)Keys.Enter) { string errMsg; DataRow temprow = null;//行对象 //第一步:判断该条码是否在该单据中 bool flag = false; foreach (DataRow row in dtSource.Rows) { if (row["cNO"].Equals(barCode)) { temprow = row; flag = true; break; } } //如果不存在 if (!flag) { MessageBox.Show("对不起,此物资不在该单据中!"); txtBarCode.Focus(); txtBarCode.SelectAll(); return; } //第二步:判断该条码是否已经上车 if (temprow["ikey1"].Equals("已出门")) { MessageBox.Show("该物资已出门!"); txtBarCode.Focus(); txtBarCode.SelectAll(); return; } //第三步:验证该条码 try { Cursor.Current = Cursors.WaitCursor; flag = new BLL.OutVerify().Verify(temprow["ID"].ToString(), out errMsg); if (!flag) { throw new Exception(errMsg); } //修改当前行的状态 temprow["ikey1"] = "已出门"; } catch (Exception ex) { MessageBox.Show(ex.Message); return; } finally { Cursor.Current = Cursors.Default; } dataGrid.DataSource = dtSource; JudgeScanComplete(); //成功后 txtBarCode.Focus(); txtBarCode.SelectAll(); } }