/// <summary> /// 销售交货 - 物料编码文本框 发生改变 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void txtTraceNo_TextChanged(object sender, EventArgs e) { string val = txtTraceNo.Text.Trim(); if (val == "") { return; } DataTable dt = ((DataTable)DGsale.DataSource); if (dt != null) { for (int i = 0; i < dt.Rows.Count; i++) { if (val == dt.Rows[i]["物料编码"].ToString()) { DGsale.Select(i); rowXS = i; this.btnSave.Enabled = true; break; } } } }
/// <summary> /// 条码信息 - 回车事件 /// </summary> private void textBox1KeyPress() { try { if (DGsale.IsSelected(rowXS)) { DGsale.UnSelect(rowXS); txtTraceNo.Text = ""; int docEntry = int.Parse(cmbSaleNo.Text.ToString().Trim()); //LoadItemPage(docEntry);//忘记为什么添加这行代码了 } string qrCodeStr = textBox1.Text.Trim(); if (qrCodeStr != "") { string[] array = qrCodeStr.Split(','); if (array.Length == 5 && !qrCodeStr.EndsWith(",")) { string itemCode = qrCodeStr.Split(',')[0].Trim(); string qty = qrCodeStr.Split(',')[4].Trim(); pc = qrCodeStr.Split(',')[2].Trim(); DataTable dt = (DataTable)DG2.DataSource; if (dt != null && dt.Rows.Count > 0) { //判断当前扫描的物料批次是否为第一个 for (int i = 0; i < dt.Rows.Count; i++) { if (dt.Rows[i][1].ToString() == itemCode) //物料编码 { double kcQty = double.Parse(dt.Rows[i][6].ToString()); //库存数量 double syQty = double.Parse(dt.Rows[i][7].ToString()); //出库数量 if (kcQty - syQty > 0) { string currPc = dt.Rows[i][3].ToString();//批次 if (currPc == pc) { txtTraceNo.Text = itemCode; tb_Quantity.Text = qty; rowNum = i; //行号 rowNumQty = kcQty - syQty; tb_Quantity.Focus(); //数量文本框获得焦点 return; } else { MessageBox.Show(string.Format("本次扫描批次不匹配\r\n扫描批次【{0}】\r\n应扫描批次【{1}】", pc, currPc)); textBox1.Text = ""; textBox1.Focus(); return; } } } } MessageBox.Show(string.Format("物料明细页签不存在本次扫描\r\n物料编码【{0}】", itemCode)); textBox1.Text = ""; textBox1.Focus(); } else { MessageBox.Show("当前物料明细页签数据为空...."); textBox1.Text = ""; textBox1.Focus(); } } } } catch (Exception ex) { MessageBox.Show(ex.Message); textBox1.Text = ""; textBox1.Focus(); } }