//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 }; public event Action ScanCompleted = null; private List _needScanRows = new List(); public FrmProScreen3(List needScanRows) { InitializeComponent(); this._needScanRows = needScanRows; this.StartPosition = FormStartPosition.CenterParent; foreach(DataRow dr in needScanRows) { } for(int i =0;i< needScanRows.Count; i++) { if(i == 0) { parts.productID3 = needScanRows[i]["PartNo2"].ToString(); } if (i == 1) { parts.productID4 = needScanRows[i]["PartNo2"].ToString(); } if (i == 2) { parts.productID5 = needScanRows[i]["PartNo2"].ToString(); } if (i == 3) { parts.productID6 = needScanRows[i]["PartNo2"].ToString(); } if (i == 4) { parts.productID7 = needScanRows[i]["PartNo2"].ToString(); } if (i == 5) { parts.productID8 = needScanRows[i]["PartNo2"].ToString(); } } } 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(); } } void ScanBarCode(int lbIndex) { //string barcode = textBox1.Text.Trim(); string partProductID = string.Empty; string productID = string.Empty; if(lbIndex == 0) { productID = productID3 = Function2.GetProductNo(textBox1.Text.Trim()); partProductID = parts.productID3; } else if (lbIndex == 1) { productID = productID4 = Function2.GetProductNo(textBox2.Text.Trim()); partProductID = parts.productID4; } else if (lbIndex == 2) { productID = productID5 = Function2.GetProductNo(textBox3.Text.Trim()); partProductID = parts.productID5; } else if (lbIndex == 3) { productID = productID6 = Function2.GetProductNo(textBox4.Text.Trim()); partProductID = parts.productID6; } else if (lbIndex == 4) { productID = productID7 = Function2.GetProductNo(textBox5.Text.Trim()); partProductID = parts.productID7; } else if (lbIndex == 5) { productID = productID8 = Function2.GetProductNo(textBox6.Text.Trim()); partProductID = parts.productID8; } if (partProductID == productID) { isCheck[lbIndex] = 1; if (textBox2.Enabled && lbIndex ==0) { textBox2.Text = ""; textBox2.Focus(); } else if (textBox3.Enabled && lbIndex == 1) { textBox3.Text = ""; textBox3.Focus(); } else if (textBox4.Enabled && lbIndex == 2) { textBox4.Text = ""; textBox4.Focus(); } else if (textBox5.Enabled && lbIndex == 3) { textBox5.Text = ""; textBox5.Focus(); } else if (textBox6.Enabled && lbIndex == 4) { textBox6.Text = ""; textBox6.Focus(); } else { if(lbIndex >0) isCheck[1] = 1; if (lbIndex > 1) isCheck[2] = 1; if (lbIndex > 2) isCheck[3] = 1; if (lbIndex > 3) isCheck[4] = 1; if (lbIndex > 4) isCheck[5] = 1; #region 判断关键零件是否都校验 if (isCheck[0] == 0 && lbIndex >= 0) { MessageBox.Show("关键零件号1未校验!"); textBox1.SelectAll(); textBox1.Focus(); return; } if (isCheck[1] == 0 && lbIndex >= 1) { MessageBox.Show("关键零件号2未校验!"); textBox2.SelectAll(); textBox2.Focus(); return; } if (isCheck[2] == 0 && lbIndex >= 2) { MessageBox.Show("关键零件号3未校验!"); textBox3.SelectAll(); textBox3.Focus(); return; } if (isCheck[3] == 0 && lbIndex >= 3) { MessageBox.Show("关键零件号4未校验!"); textBox4.SelectAll(); textBox4.Focus(); return; } if (isCheck[4] == 0 && lbIndex >= 4) { MessageBox.Show("关键零件号5未校验!"); textBox5.SelectAll(); textBox5.Focus(); return; } if (isCheck[5] == 0 && lbIndex >= 5) { MessageBox.Show("关键零件号6未校验!"); textBox6.SelectAll(); textBox6.Focus(); return; } #endregion ScanAll.ScanResult = true; ScanAll.barCode1 = textBox1.Text.Trim(); if (lbIndex >= 0) ScanAll.partNo1 = productID3; // Function2.GetPartNoByID(productID3); ScanAll.barCode2 = textBox2.Text.Trim(); if (lbIndex >= 1) ScanAll.partNo2 = productID4; // Function2.GetPartNoByID(productID4); else ScanAll.partNo2 = ""; ScanAll.barCode3 = textBox3.Text.Trim(); if (lbIndex >= 2) ScanAll.partNo3 = productID5;// Function2.GetPartNoByID(productID5); else ScanAll.partNo3 = ""; ScanAll.barCode4 = textBox4.Text.Trim(); if (lbIndex >= 3) ScanAll.partNo4 = productID6; // Function2.GetPartNoByID(productID6); else ScanAll.partNo4 = ""; ScanAll.barCode5 = textBox5.Text.Trim(); if (lbIndex >= 4) ScanAll.partNo5 = productID7;// Function2.GetPartNoByID(productID7); else ScanAll.partNo5 = ""; ScanAll.barCode6 = textBox6.Text.Trim(); if (lbIndex >= 5) ScanAll.partNo6 = productID8; // Function2.GetPartNoByID(productID8); else ScanAll.partNo6 = ""; this.Close(); ScanCompleted?.Invoke(true); } } else { MessageBox.Show("扫入条码与总成不匹配,请检查后再次扫描"); textBox1.Text = ""; } } private void textBox1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { ScanBarCode(0); //string barcode = textBox1.Text.Trim(); //productID3 = Function2.GetProductNo(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) { ScanBarCode(1); //string barcode = textBox2.Text.Trim(); //productID4 = Function2.GetProductNo(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) { ScanBarCode(2); //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(); ScanCompleted?.Invoke(false); } private void textBox4_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { ScanBarCode(3); //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) { ScanBarCode(4); //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) { ScanBarCode(5); //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 = ""; //} } } } }