using System; using System.Data; using System.Drawing; using System.Windows.Forms; using UAS_MES_NEW.DataOperate; using UAS_MES_NEW.Entity; using UAS_MES_NEW.PublicForm; using UAS_MES_NEW.PublicMethod; namespace UAS_MES_NEW.Make { public partial class Make_OutBoxSnCheck : Form { AutoSizeFormClass asc = new AutoSizeFormClass(); DataHelper dh; LogStringBuilder sql; DataTable dt; public Make_OutBoxSnCheck() { InitializeComponent(); } private void Make_LabelCheck_Load(object sender, EventArgs e) { asc.controllInitializeSize(this); //聚焦SN号 pa_outboxcode.Focus(); //打开界面提示用户:请输入SN OperateResult.AppendText(">>请采集箱号\n", Color.Black); sql = new LogStringBuilder(); dh = SystemInf.dh; } private void Make_LabelCheck_SizeChanged(object sender, EventArgs e) { asc.controlAutoSize(this); } bool FindColorSN = false; bool FindFugeSN = false; int RowIndex = 0; private void sncode_KeyDown(object sender, KeyEventArgs e) { //判断是enter事件 if (e.KeyCode == Keys.Enter) { if (sncode.Text == "") { OperateResult.AppendText("<<输入不能为空\n", Color.Red); return; } bool AllCheck = true; if (FindColorSN) { object fugelcode = CheckSnDGV.Rows[RowIndex].Cells["pr_fugelcode"].Value; if ((fugelcode != null ? fugelcode.ToString() : "") + CheckSnDGV.Rows[RowIndex].Cells["pd_barcode"].Value.ToString() == sncode.Text) { CheckSnDGV.Rows[RowIndex].Cells["pd_checksn1"].Value = sncode.Text; FindFugeSN = true; } else { OperateResult.AppendText("<<" + sncode.Text + "机身校验失败\n", Color.Red, sncode); return; } } for (int i = 0; i < CheckSnDGV.Rows.Count; i++) { if (!FindColorSN) { object colorcode = CheckSnDGV.Rows[RowIndex].Cells["pr_colorcode"].Value; Console.WriteLine(CheckSnDGV.Rows[i].Cells["pd_barcode"].Value.ToString() + (colorcode != null ? colorcode.ToString() : "")); if ((colorcode != null ? colorcode.ToString() : "") + CheckSnDGV.Rows[i].Cells["pd_barcode"].Value.ToString() == sncode.Text) { CheckSnDGV.Rows[i].Cells["pd_checksn"].Value = sncode.Text; RowIndex = i; FindColorSN = true; } } if (CheckSnDGV.Rows[i].Cells["pd_checksn"].Value == null || CheckSnDGV.Rows[i].Cells["pd_checksn1"].Value == null) { AllCheck = false; } } if (!FindColorSN && !FindFugeSN) { OperateResult.AppendText("<<" + sncode.Text + "校验失败\n", Color.Red, sncode); } if (FindColorSN && !FindFugeSN) { OperateResult.AppendText("<<" + sncode.Text + "彩盒校验成功\n", Color.Green, sncode); } if (FindFugeSN) { FindColorSN = false; FindFugeSN = false; OperateResult.AppendText("<<" + sncode.Text + "机身校验成功\n", Color.Green, sncode); } if (AllCheck) { SetCheck set = new SetCheck("OK", Color.Green); BaseUtil.SetFormCenter(set); set.ShowDialog(); pa_outboxcode.Focus(); } } } private void pa_outboxcode_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { dt = (DataTable)dh.ExecuteSql("select pd_barcode,PR_COLORCODE, PR_FUGELCODE from packagedetail left join product on pr_code=PD_PRODCODE where pd_outboxcode='" + pa_outboxcode.Text + "'", "select"); if (dt.Rows.Count > 0) { BaseUtil.FillDgvWithDataTable(CheckSnDGV, dt); sncode.Focus(); } else { OperateResult.AppendText("<<箱号" + pa_outboxcode.Text + "不存在\n", Color.Red); } } } } }