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; using UAS_MES_NEW.DataOperate; using UAS_MES_NEW.Entity; using UAS_MES_NEW.PublicMethod; namespace UAS_MES_NEW.Make { public partial class Make_ImeiCheck : Form { AutoSizeFormClass asc = new AutoSizeFormClass(); DataHelper dh; LogStringBuilder sql; DataTable dt; DataTable info; string imei1 = ""; bool isImei1 = false; string oErrorMessage = ""; string SN = ""; string omakeCode = ""; string oMsid = ""; public Make_ImeiCheck() { InitializeComponent(); } private void Make_LabelCheck_Load(object sender, EventArgs e) { asc.controllInitializeSize(this); //聚焦SN号 sncode.Focus(); //打开界面提示用户:请输入SN OperateResult.AppendText(">>请输入SN\n", Color.Black); sql = new LogStringBuilder(); dh = SystemInf.dh; StepCount.StepCode = User.CurrentStepCode; StepCount.Source = User.UserSourceCode; StepCount.LineCode = User.UserLineCode; StepCount.Dh = dh; StepCount.Start(); } private void Make_LabelCheck_SizeChanged(object sender, EventArgs e) { asc.controlAutoSize(this); } private void sncode_KeyDown(object sender, KeyEventArgs e) { //判断是enter事件 if (e.KeyCode == Keys.Enter) { if (sncode.Text == "") { OperateResult.AppendText("<<输入不能为空\n", Color.Red); return; } //输入的是SN if (!isImei1) { OperateResult.AppendText("<<" + sncode.Text + "\n", Color.Black); //查询是否存在该ms_id sql.Clear(); sql.Append("select max(ms_id) ms_id from makeserial where ms_sncode ='"+sncode.Text+"'"); dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select"); if (dt.Rows.Count == 0 || dt.Rows[0]["ms_id"].ToString() == "") { //SN错误,不存在 //请输入SN OperateResult.AppendText("<>请输入SN\n", Color.Black); } //存在该SN号 else { //根据该ms_id查询ms_imei1,ms_makecode信息 sql.Clear(); sql.Append("select ms_imei1 from makeserial where ms_id='" + dt.Rows[0]["ms_id"].ToString() + "'"); info = (DataTable)dh.ExecuteSql(sql.GetString(), "select"); if (info.Rows.Count > 0) { //不为null 并且不为””才继续 if (info.Rows[0]["ms_imei1"].ToString() == null || info.Rows[0]["ms_imei1"].ToString() == "") { // SN对应的IMEI不存在 //>> 请输入SN OperateResult.AppendText("<<序列号" + sncode.Text + "对应的IMEI不存在\n", Color.Red, sncode); OperateResult.AppendText(">>请输入SN\n", Color.Black); } else //存在该imei信息 { //用变量记录imei1和makecode imei1 = info.Rows[0]["ms_imei1"].ToString(); SN = sncode.Text; //>>SN对应的IMEI号为:xxxxxxxxx //>> 请输入彩盒上的IMEI OperateResult.AppendText("<<序列号" + sncode.Text + "对应的IMEI号为:" + imei1 + "\n", Color.Green); OperateResult.AppendText(">>请输入彩盒上的IMEI\n", Color.Black, sncode); //设定要输入imei1 isImei1 = true; } } else { OperateResult.AppendText("<>请输入SN\n", Color.Black); } } } //输入的是imei1 else { OperateResult.AppendText("<<" + sncode.Text + "\n", Color.Black); if (imei1 == sncode.Text) { //说明输入的imei1对比一致 //判断工序属性attribute if (LogicHandler.CheckStepAttribute(Tag.ToString(), User.UserSourceCode, out oErrorMessage)) { //判断序列号下一工序(CHECKSTEPSNANDMACODE) if (LogicHandler.CheckStepSNAndMacode("", User.UserSourceCode, SN, User.UserCode, out omakeCode, out oMsid, out oErrorMessage)) { //调用 SETSTEPRESULT ,获取返回的工单号, if (LogicHandler.SetStepResult(omakeCode, User.UserSourceCode, SN, "标签核对", "OK", User.UserCode, out oErrorMessage)) { //提示正确返回时传递的信息 if (oErrorMessage.Contains("AFTERSUCCESS")) OperateResult.AppendText(">>" + oErrorMessage + "\n"); //根据工单号查询makecraftdetail 表中的 mcd_okqty 计数,剩余数为ma_qty - nvl(mcd_inqty,0),刷新页面中工单信息的显示 sql.Clear(); sql.Append("select ma_code,nvl(mcd_okqty,0) mcd_okqty,ma_prodcode,pr_detail,"); sql.Append("ma_qty - nvl(mcd_okqty, 0) remain_qty from make left join makecraftdetail on "); sql.Append("mcd_maid=ma_id left join product on pr_code=ma_prodcode where ma_code='" + omakeCode + "' and mcd_stepcode='" + User.CurrentStepCode + "'"); dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select"); BaseUtil.SetFormValue(Controls, dt); //将SN,时间,结果记录在页面 recordResult(SN, DateTime.Now.ToString(), "成功"); //记录日志 LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "标签核对", "标签核对成功", SN, ""); //IMEI核对成功 //>> 请输入SN OperateResult.AppendText("<>请输入SN\n", Color.Black); } else { //setstepresult不通过 OperateResult.AppendText(">>" + oErrorMessage + "\n", Color.Red, sncode); recordResult(SN, DateTime.Now.ToString(), "失败"); } } else { //判定序列号下一工序不通过 OperateResult.AppendText(">>" + oErrorMessage + "\n", Color.Red, sncode); recordResult(SN, DateTime.Now.ToString(), "失败"); } } else { //判定工序属性不通过 OperateResult.AppendText(">>" + oErrorMessage + "\n", Color.Red, sncode); recordResult(SN, DateTime.Now.ToString(), "失败"); } } //说明比对不一致 else { //清空imei1变量的值 imei1 = ""; //IMEI核对失败 //>> 请输入SN OperateResult.AppendText(">>IMEI核对失败,不一致\n", Color.Red, sncode); OperateResult.AppendText(">>请输入SN\n", Color.Black); } //imei1校对结束,下次输入的是SN isImei1 = false; } } } private void recordResult(string SN, string time, string result) { //if (showResult.Items.Count >= 10) //{ // //如果有10行的话,则删除最前一行 // showResult.Items.RemoveAt(0); //} //创建一个item ListViewItem lvi = new ListViewItem(); //分条赋值 lvi.SubItems.Add(SN); lvi.SubItems.Add(time); lvi.SubItems.Add(result); //添加结果的信息进去 showResult.Items.Add(lvi); } private void clear() { //清空变量的值 omakeCode = ""; oMsid = ""; SN = ""; imei1 = ""; } } }