//using PunchAndWeld.DataSouce; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace PunchingMistake { public partial class FrmProScreen3 : Form { OtherPart parts = new OtherPart(); private static string productID3 = "", productID4 = "", productID5 = "", productID6 = "", productID7 = "", productID8 = ""; int[] isCheck = new int[6] { 0, 0, 0, 0, 0, 0 }; private List _needScanRows = new List(); public FrmProScreen3(List needScanRows) { InitializeComponent(); this._needScanRows = needScanRows; } public FrmProScreen3(OtherPart part) { InitializeComponent(); parts = part; } private void FrmProScreen3_Load(object sender, EventArgs e) { textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = ""; textBox4.Text = ""; textBox5.Text = ""; textBox6.Text = ""; textBox1.Enabled = false; textBox2.Enabled = false; textBox3.Enabled = false; textBox4.Enabled = false; textBox5.Enabled = false; textBox6.Enabled = false; label4.Text = ""; label5.Text = ""; label6.Text = ""; label7.Text = ""; label9.Text = ""; label11.Text = ""; int[] isCheck = new int[6] { 0, 0, 0, 0, 0, 0 }; if (_needScanRows.Count > 0) { label4.Text = _needScanRows[0]["PartNo2"].ToString(); textBox1.Enabled = true; textBox1.Focus(); } if (_needScanRows.Count > 1) { label5.Text = _needScanRows[1]["PartNo2"].ToString(); textBox2.Enabled = true; textBox2.Focus(); } if (_needScanRows.Count > 2) { label6.Text = _needScanRows[2]["PartNo2"].ToString(); textBox3.Enabled = true; textBox3.Focus(); } if (_needScanRows.Count > 3) { label7.Text = _needScanRows[3]["PartNo2"].ToString(); textBox4.Enabled = true; textBox4.Focus(); } if (_needScanRows.Count > 4) { label9.Text = _needScanRows[4]["PartNo2"].ToString(); textBox5.Enabled = true; textBox5.Focus(); } if (_needScanRows.Count > 5) { label11.Text = _needScanRows[5]["PartNo2"].ToString(); textBox6.Enabled = true; textBox6.Focus(); } } private void textBox1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { string barcode = textBox1.Text.Trim(); productID3 = Function2.GetProductID(barcode); if (parts.productID3 == productID3) { isCheck[0] = 1; if (textBox2.Enabled) { textBox2.Text = ""; textBox2.Focus(); } else if (textBox3.Enabled) { textBox3.Text = ""; textBox3.Focus(); } else if (textBox4.Enabled) { textBox4.Text = ""; textBox4.Focus(); } else if (textBox5.Enabled) { textBox5.Text = ""; textBox5.Focus(); } else if (textBox6.Enabled) { textBox6.Text = ""; textBox6.Focus(); } else { isCheck[1] = 1; isCheck[2] = 1; isCheck[3] = 1; isCheck[4] = 1; isCheck[5] = 1; #region 判断关键零件是否都校验 if (isCheck[0] == 0) { MessageBox.Show("关键零件号1未校验!"); textBox1.SelectAll(); textBox1.Focus(); return; } if (isCheck[1] == 0) { MessageBox.Show("关键零件号2未校验!"); textBox2.SelectAll(); textBox2.Focus(); return; } if (isCheck[2] == 0) { MessageBox.Show("关键零件号3未校验!"); textBox3.SelectAll(); textBox3.Focus(); return; } if (isCheck[3] == 0) { MessageBox.Show("关键零件号4未校验!"); textBox4.SelectAll(); textBox4.Focus(); return; } if (isCheck[4] == 0) { MessageBox.Show("关键零件号5未校验!"); textBox5.SelectAll(); textBox5.Focus(); return; } if (isCheck[5] == 0) { MessageBox.Show("关键零件号6未校验!"); textBox6.SelectAll(); textBox6.Focus(); return; } #endregion ScanAll.ScanResult = true; ScanAll.barCode1 = textBox1.Text.Trim(); ScanAll.partNo1 = Function2.GetPartNoByID(productID3); ScanAll.barCode2 = textBox2.Text.Trim(); ScanAll.partNo2 = ""; ScanAll.barCode3 = textBox3.Text.Trim(); ScanAll.partNo3 = ""; ScanAll.barCode4 = textBox4.Text.Trim(); ScanAll.partNo4 = ""; ScanAll.barCode5 = textBox5.Text.Trim(); ScanAll.partNo5 = ""; ScanAll.barCode6 = textBox6.Text.Trim(); ScanAll.partNo6 = ""; this.Close(); } } else { MessageBox.Show("扫入条码与总成不匹配,请检查后再次扫描"); textBox1.Text = ""; } } } private void textBox2_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { string barcode = textBox2.Text.Trim(); productID4 = Function2.GetProductID(barcode); if (parts.productID4 == productID4) { isCheck[1] = 1; if (textBox3.Enabled) { textBox3.Text = ""; textBox3.Focus(); } else if (textBox4.Enabled) { textBox4.Text = ""; textBox4.Focus(); } else if (textBox5.Enabled) { textBox5.Text = ""; textBox5.Focus(); } else if (textBox6.Enabled) { textBox6.Text = ""; textBox6.Focus(); } else { isCheck[2] = 1; isCheck[3] = 1; isCheck[4] = 1; isCheck[5] = 1; #region 判断关键零件是否都校验 if (isCheck[0] == 0) { MessageBox.Show("关键零件号1未校验!"); textBox2.Text = ""; textBox1.SelectAll(); textBox1.Focus(); return; } if (isCheck[1] == 0) { MessageBox.Show("关键零件号2未校验!"); textBox2.SelectAll(); textBox2.Focus(); return; } if (isCheck[2] == 0) { MessageBox.Show("关键零件号3未校验!"); textBox3.SelectAll(); textBox3.Focus(); return; } if (isCheck[3] == 0) { MessageBox.Show("关键零件号4未校验!"); textBox4.SelectAll(); textBox4.Focus(); return; } if (isCheck[4] == 0) { MessageBox.Show("关键零件号54未校验!"); textBox5.SelectAll(); textBox5.Focus(); return; } if (isCheck[5] == 0) { MessageBox.Show("关键零件号6未校验!"); textBox6.SelectAll(); textBox6.Focus(); return; } #endregion ScanAll.ScanResult = true; ScanAll.barCode1 = textBox1.Text.Trim(); ScanAll.partNo1 = Function2.GetPartNoByID(productID3); ScanAll.barCode2 = textBox2.Text.Trim(); ScanAll.partNo2 = Function2.GetPartNoByID(productID4); ScanAll.barCode3 = textBox3.Text.Trim(); ScanAll.partNo3 = ""; ScanAll.barCode4 = textBox4.Text.Trim(); ScanAll.partNo4 = ""; ScanAll.barCode5 = textBox5.Text.Trim(); ScanAll.partNo5 = ""; ScanAll.barCode6 = textBox6.Text.Trim(); ScanAll.partNo6 = ""; this.Close(); } } else { MessageBox.Show("扫入条码与总成不匹配,请检查后再次扫描"); textBox2.Text = ""; } } } private void textBox3_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { string barcode = textBox3.Text.Trim(); productID5 = Function2.GetProductID(barcode); if (parts.productID5 == productID5) { isCheck[2] = 1; if (textBox4.Enabled) { textBox4.Text = ""; textBox4.Focus(); } else if (textBox5.Enabled) { textBox5.Text = ""; textBox5.Focus(); } else if (textBox6.Enabled) { textBox6.Text = ""; textBox6.Focus(); } else { isCheck[3] = 1; isCheck[4] = 1; isCheck[5] = 1; #region 判断关键零件是否都校验 if (isCheck[0] == 0) { MessageBox.Show("关键零件号1未校验!"); textBox3.Text = ""; textBox1.SelectAll(); textBox1.Focus(); return; } if (isCheck[1] == 0) { MessageBox.Show("关键零件号2未校验!"); textBox3.Text = ""; textBox2.SelectAll(); textBox2.Focus(); return; } if (isCheck[2] == 0) { MessageBox.Show("关键零件号3未校验!"); textBox3.SelectAll(); textBox3.Focus(); return; } if (isCheck[3] == 0) { MessageBox.Show("关键零件号4未校验!"); textBox4.SelectAll(); textBox4.Focus(); return; } if (isCheck[4] == 0) { MessageBox.Show("关键零件号5未校验!"); textBox5.SelectAll(); textBox5.Focus(); return; } if (isCheck[5] == 0) { MessageBox.Show("关键零件号5未校验!"); textBox6.SelectAll(); textBox6.Focus(); return; } #endregion ScanAll.ScanResult = true; ScanAll.barCode1 = textBox1.Text.Trim(); ScanAll.partNo1 = Function2.GetPartNoByID(productID3); ScanAll.barCode2 = textBox2.Text.Trim(); ScanAll.partNo2 = Function2.GetPartNoByID(productID4); ScanAll.barCode3 = textBox3.Text.Trim(); ScanAll.partNo3 = Function2.GetPartNoByID(productID5); ScanAll.barCode4 = textBox4.Text.Trim(); ScanAll.partNo4 = ""; ScanAll.barCode5 = textBox5.Text.Trim(); ScanAll.partNo5 = ""; ScanAll.barCode6 = textBox6.Text.Trim(); ScanAll.partNo6 = ""; this.Close(); } } else { MessageBox.Show("扫入条码与总成不匹配,请检查后再次扫描"); textBox3.Text = ""; } } } private void button1_Click(object sender, EventArgs e) { ScanAll.ScanResult = false; this.Close(); } private void textBox4_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { string barcode = textBox4.Text.Trim(); productID6 = Function2.GetProductID(barcode); if (parts.productID6 == productID6) { isCheck[3] = 1; if (textBox5.Enabled) { textBox5.Text = ""; textBox5.Focus(); } else if (textBox6.Enabled) { textBox6.Text = ""; textBox6.Focus(); } else { isCheck[4] = 1; isCheck[5] = 1; #region 判断关键零件是否都校验 if (isCheck[0] == 0) { MessageBox.Show("关键零件号1未校验!"); textBox4.Text = ""; textBox1.SelectAll(); textBox1.Focus(); return; } if (isCheck[1] == 0) { MessageBox.Show("关键零件号2未校验!"); textBox4.Text = ""; textBox2.SelectAll(); textBox2.Focus(); return; } if (isCheck[2] == 0) { MessageBox.Show("关键零件号3未校验!"); textBox4.Text = ""; textBox3.SelectAll(); textBox3.Focus(); return; } if (isCheck[3] == 0) { MessageBox.Show("关键零件号4未校验!"); textBox4.SelectAll(); textBox4.Focus(); return; } if (isCheck[4] == 0) { MessageBox.Show("关键零件号5未校验!"); textBox5.SelectAll(); textBox5.Focus(); return; } if (isCheck[5] == 0) { MessageBox.Show("关键零件号6未校验!"); textBox6.SelectAll(); textBox6.Focus(); return; } #endregion ScanAll.ScanResult = true; ScanAll.barCode1 = textBox1.Text.Trim(); ScanAll.partNo1 = Function2.GetPartNoByID(productID3); ScanAll.barCode2 = textBox2.Text.Trim(); ScanAll.partNo2 = Function2.GetPartNoByID(productID4); ScanAll.barCode3 = textBox3.Text.Trim(); ScanAll.partNo3 = Function2.GetPartNoByID(productID5); ScanAll.barCode4 = textBox4.Text.Trim(); ScanAll.partNo4 = Function2.GetPartNoByID(productID6); ScanAll.barCode5 = textBox5.Text.Trim(); ScanAll.partNo5 = ""; ScanAll.barCode6 = textBox6.Text.Trim(); ScanAll.partNo6 = ""; this.Close(); } } else { MessageBox.Show("扫入条码与总成不匹配,请检查后再次扫描"); textBox4.Text = ""; } } } private void textBox5_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { string barcode = textBox5.Text.Trim(); productID7 = Function2.GetProductID(barcode); if (parts.productID7 == productID7) { isCheck[4] = 1; if (textBox6.Enabled) { textBox6.Text = ""; textBox6.Focus(); } else { isCheck[5] = 1; #region 判断关键零件是否都校验 if (isCheck[0] == 0) { MessageBox.Show("关键零件号1未校验!"); textBox5.Text = ""; textBox1.SelectAll(); textBox1.Focus(); return; } if (isCheck[1] == 0) { MessageBox.Show("关键零件号2未校验!"); textBox5.Text = ""; textBox2.SelectAll(); textBox2.Focus(); return; } if (isCheck[2] == 0) { MessageBox.Show("关键零件号3未校验!"); textBox3.SelectAll(); textBox3.Focus(); return; } if (isCheck[3] == 0) { MessageBox.Show("关键零件号4未校验!"); textBox5.Text = ""; textBox4.SelectAll(); textBox4.Focus(); return; } if (isCheck[4] == 0) { MessageBox.Show("关键零件号5未校验!"); textBox5.SelectAll(); textBox5.Focus(); return; } if (isCheck[5] == 0) { MessageBox.Show("关键零件号6未校验!"); textBox6.SelectAll(); textBox6.Focus(); return; } #endregion ScanAll.ScanResult = true; ScanAll.barCode1 = textBox1.Text.Trim(); ScanAll.partNo1 = Function2.GetPartNoByID(productID3); ScanAll.barCode2 = textBox2.Text.Trim(); ScanAll.partNo2 = Function2.GetPartNoByID(productID4); ScanAll.barCode3 = textBox3.Text.Trim(); ScanAll.partNo3 = Function2.GetPartNoByID(productID5); ScanAll.barCode4 = textBox4.Text.Trim(); ScanAll.partNo4 = Function2.GetPartNoByID(productID6); ScanAll.barCode5 = textBox5.Text.Trim(); ScanAll.partNo5 = Function2.GetPartNoByID(productID7); ScanAll.barCode6 = textBox6.Text.Trim(); ScanAll.partNo6 = ""; this.Close(); } } else { MessageBox.Show("扫入条码与总成不匹配,请检查后再次扫描"); textBox4.Text = ""; } } } private void textBox6_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { string barcode = textBox6.Text.Trim(); productID8 = Function2.GetProductID(barcode); if (parts.productID8 == productID8) { isCheck[5] = 1; #region 判断关键零件是否都校验 if (isCheck[0] == 0) { MessageBox.Show("关键零件号1未校验!"); textBox6.Text = ""; textBox1.SelectAll(); textBox1.Focus(); return; } if (isCheck[1] == 0) { MessageBox.Show("关键零件号2未校验!"); textBox6.Text = ""; textBox2.SelectAll(); textBox2.Focus(); return; } if (isCheck[2] == 0) { MessageBox.Show("关键零件号3未校验!"); textBox6.Text = ""; textBox3.SelectAll(); textBox3.Focus(); return; } if (isCheck[3] == 0) { MessageBox.Show("关键零件号4未校验!"); textBox6.Text = ""; textBox4.SelectAll(); textBox4.Focus(); return; } if (isCheck[4] == 0) { MessageBox.Show("关键零件号5未校验!"); textBox6.Text = ""; textBox5.SelectAll(); textBox5.Focus(); return; } if (isCheck[5] == 0) { MessageBox.Show("关键零件号6未校验!"); textBox6.SelectAll(); textBox6.Focus(); return; } #endregion ScanAll.ScanResult = true; ScanAll.barCode1 = textBox1.Text.Trim(); ScanAll.partNo1 = Function2.GetPartNoByID(productID3); ScanAll.barCode2 = textBox2.Text.Trim(); ScanAll.partNo2 = Function2.GetPartNoByID(productID4); ScanAll.barCode3 = textBox3.Text.Trim(); ScanAll.partNo3 = Function2.GetPartNoByID(productID5); ScanAll.barCode4 = textBox4.Text.Trim(); ScanAll.partNo4 = Function2.GetPartNoByID(productID6); ScanAll.barCode5 = textBox5.Text.Trim(); ScanAll.partNo5 = Function2.GetPartNoByID(productID7); ScanAll.barCode6 = textBox6.Text.Trim(); ScanAll.partNo6 = Function2.GetPartNoByID(productID8); this.Close(); } else { MessageBox.Show("扫入条码与总成不匹配,请检查后再次扫描"); textBox4.Text = ""; } } } } }