123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409 |
- 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.PublicForm;
- using UAS_MES_NEW.PublicMethod;
- namespace UAS_MES_NEW.Make
- {
- public partial class Make_ImeiCheck_ThreeLabel : Form
- {
- AutoSizeFormClass asc = new AutoSizeFormClass();
- DataHelper dh;
- LogStringBuilder sql;
- DataTable dt;
- DataTable info;
- string imei1 = "";
- string imei2 = "";
- bool isImei1 = false;
- bool isImei2 = false;
- string oErrorMessage = "";
- string SN = "";
- string omakeCode = "";
- string oMsid = "";
- public Make_ImeiCheck_ThreeLabel()
- {
- 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();
- }
- string checksn = "";
- 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;
- }
- dt = (DataTable)dh.ExecuteSql("select ms_sncode from makeserial where ms_imei1='" + sncode.Text + "' order by ms_id desc", "select");
- if (dt.Rows.Count > 0)
- {
- sncode.Text = dt.Rows[0]["ms_sncode"].ToString();
- }
- else
- {
- dt = (DataTable)dh.ExecuteSql("select ms_sncode from makeserial where ms_imei2='" + sncode.Text + "' order by ms_id desc", "select");
- if (dt.Rows.Count > 0)
- {
- sncode.Text = dt.Rows[0]["ms_sncode"].ToString();
- }
- else
- {
- dt = (DataTable)dh.ExecuteSql("select mil_sncode from makeimeilist where mil_imei1='" + sncode.Text + "' order by mil_id desc", "select");
- if (dt.Rows.Count > 0)
- {
- sncode.Text = dt.Rows[0]["mil_sncode"].ToString();
- }
- else
- {
- dt = (DataTable)dh.ExecuteSql("select mil_sncode from makeimeilist where mil_imei2='" + sncode.Text + "' order by mil_id desc", "select");
- if (dt.Rows.Count > 0)
- {
- sncode.Text = dt.Rows[0]["mil_sncode"].ToString();
- }
- }
- }
- }
- if (LogicHandler.CheckStepSNAndMacode(ma_code.Text, User.UserSourceCode, sncode.Text, User.UserCode, out omakeCode, out oMsid, out oErrorMessage))
- {
- }
- //输入的是SN
- if (!isImei1 && !isImei2)
- {
- OperateResult.AppendText("<<" + sncode.Text + "\n", Color.Black);
- 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() == "")
- {
- sql.Clear();
- sql.Append("select max(ms_id) ms_id from makeserial where ms_imei1 ='" + sncode.Text + "'");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- if (dt.Rows.Count == 0 || dt.Rows[0]["ms_id"].ToString() == "")
- {
- sql.Clear();
- sql.Append("select max(ms_id) ms_id from makeserial where ms_imei2 ='" + sncode.Text + "'");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- if (dt.Rows.Count == 0 || dt.Rows[0]["ms_id"].ToString() == "")
- {
- sql.Clear();
- sql.Append("select max(ms_id) ms_id from makeimeilist left join makeserial on mil_makecode=ms_makecode and mil_sncode=ms_sncode where mil_imei1 ='" + sncode.Text + "'");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- if (dt.Rows.Count == 0 || dt.Rows[0]["ms_id"].ToString() == "")
- {
- sql.Clear();
- sql.Append("select max(ms_id) ms_id from makeimeilist left join makeserial on mil_makecode=ms_makecode and mil_sncode=ms_sncode where mil_imei2 ='" + sncode.Text + "'");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- if (dt.Rows.Count == 0 || dt.Rows[0]["ms_id"].ToString() == "")
- {
- OperateResult.AppendText("<<SN错误,序列号" + sncode.Text + "不存在\n", Color.Red, sncode);
- OperateResult.AppendText(">>请输入SN\n", Color.Black);
- }
- }
- }
- }
- }
- //存在该SN号
- //根据该ms_id查询ms_imei1,ms_makecode信息
- sql.Clear();
- sql.Append("select ms_sncode from makeserial where ms_id='" + dt.Rows[0]["ms_id"].ToString() + "'");
- info = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- if (info.Rows.Count > 0)
- {
- //用变量记录imei1和makecode
- checksn = info.Rows[0]["ms_sncode"].ToString();
- SN = sncode.Text;
- //>> 请输入彩盒上的SN
- OperateResult.AppendText("<<条码" + sncode.Text + "对应的SN号为:" + checksn + "\n", Color.Green);
- OperateResult.AppendText(">>请输入需要核对的条码1\n", Color.Black, sncode);
- //设定要输入imei1
- isImei1 = true;
- }
- else
- {
- OperateResult.AppendText("<<SN:" + sncode.Text + "对应的SN不存在\n", Color.Red, sncode);
- OperateResult.AppendText(">>请输入SN\n", Color.Black);
- SetCheck set = new SetCheck("NG", Color.Red);
- BaseUtil.SetFormCenter(set);
- set.ShowDialog();
- }
- }
- else if (isImei1)
- {
- OperateResult.AppendText("<<" + sncode.Text + "\n", Color.Black);
- 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() == "")
- {
- sql.Clear();
- sql.Append("select max(ms_id) ms_id from makeserial where ms_imei1 ='" + sncode.Text + "'");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- if (dt.Rows.Count == 0 || dt.Rows[0]["ms_id"].ToString() == "")
- {
- sql.Clear();
- sql.Append("select max(ms_id) ms_id from makeserial where ms_imei2 ='" + sncode.Text + "'");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- if (dt.Rows.Count == 0 || dt.Rows[0]["ms_id"].ToString() == "")
- {
- sql.Clear();
- sql.Append("select max(ms_id) ms_id from makeimeilist left join makeserial on mil_makecode=ms_makecode and mil_sncode=ms_sncode where mil_imei1 ='" + sncode.Text + "'");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- if (dt.Rows.Count == 0 || dt.Rows[0]["ms_id"].ToString() == "")
- {
- sql.Clear();
- sql.Append("select max(ms_id) ms_id from makeimeilist left join makeserial on mil_makecode=ms_makecode and mil_sncode=ms_sncode where mil_imei2 ='" + sncode.Text + "'");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- if (dt.Rows.Count == 0 || dt.Rows[0]["ms_id"].ToString() == "")
- {
- OperateResult.AppendText("<<SN错误,序列号" + sncode.Text + "不存在\n", Color.Red, sncode);
- OperateResult.AppendText(">>请输入SN\n", Color.Black);
- SetCheck set = new SetCheck("NG", Color.Red);
- BaseUtil.SetFormCenter(set);
- set.ShowDialog();
- }
- }
- }
- }
- }
- sql.Clear();
- sql.Append("select ms_sncode from makeserial where ms_id='" + dt.Rows[0]["ms_id"].ToString() + "'");
- info = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- if (info.Rows.Count > 0)
- {
- imei1 = info.Rows[0]["ms_sncode"].ToString();
- }
- if (imei1 == checksn)
- {
- OperateResult.AppendText("<<条码1核对成功\n", Color.Green, sncode);
- OperateResult.AppendText(">>请输入需要核对的条码2\n", Color.Black);
- isImei2 = true;
- isImei1 = false;
- }
- else
- {
- //清空imei1变量的值
- imei1 = "";
- imei2 = "";
- checksn = "";
- //SN核对失败
- //>> 请输入SN
- OperateResult.AppendText(">>SN核对失败,不一致\n", Color.Red, sncode);
- SetCheck set = new SetCheck("NG", Color.Red);
- BaseUtil.SetFormCenter(set);
- set.ShowDialog();
- OperateResult.AppendText(">>请输入SN\n", Color.Black);
- isImei1 = false;
- isImei2 = false;
- }
- }
- //输入的是imei1
- else
- {
- OperateResult.AppendText("<<" + sncode.Text + "\n", Color.Black);
- 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() == "")
- {
- sql.Clear();
- sql.Append("select max(ms_id) ms_id from makeserial where ms_imei1 ='" + sncode.Text + "'");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- if (dt.Rows.Count == 0 || dt.Rows[0]["ms_id"].ToString() == "")
- {
- sql.Clear();
- sql.Append("select max(ms_id) ms_id from makeserial where ms_imei2 ='" + sncode.Text + "'");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- if (dt.Rows.Count == 0 || dt.Rows[0]["ms_id"].ToString() == "")
- {
- sql.Clear();
- sql.Append("select max(ms_id) ms_id from makeimeilist left join makeserial on mil_makecode=ms_makecode and mil_sncode=ms_sncode where mil_imei1 ='" + sncode.Text + "'");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- if (dt.Rows.Count == 0 || dt.Rows[0]["ms_id"].ToString() == "")
- {
- sql.Clear();
- sql.Append("select max(ms_id) ms_id from makeimeilist left join makeserial on mil_makecode=ms_makecode and mil_sncode=ms_sncode where mil_imei2 ='" + sncode.Text + "'");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- if (dt.Rows.Count == 0 || dt.Rows[0]["ms_id"].ToString() == "")
- {
- OperateResult.AppendText("<<SN错误,序列号" + sncode.Text + "不存在\n", Color.Red, sncode);
- SetCheck set = new SetCheck("NG", Color.Red);
- BaseUtil.SetFormCenter(set);
- set.ShowDialog();
- OperateResult.AppendText(">>请输入SN\n", Color.Black);
- }
- }
- }
- }
- }
- sql.Clear();
- sql.Append("select ms_sncode from makeserial where ms_id='" + dt.Rows[0]["ms_id"].ToString() + "'");
- info = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- if (info.Rows.Count > 0)
- {
- imei2 = info.Rows[0]["ms_sncode"].ToString();
- }
- if (imei1 == checksn && imei2 == checksn)
- {
- //说明输入的imei1对比一致
- //判断工序属性attribute
- if (LogicHandler.CheckStepAttribute(Tag.ToString(), User.UserSourceCode, out oErrorMessage))
- {
- //判断序列号下一工序(CHECKSTEPSNANDMACODE)
- if (LogicHandler.CheckStepSNAndMacode("", User.UserSourceCode, checksn, User.UserCode, out omakeCode, out oMsid, out oErrorMessage))
- {
- string nextstepcode = dh.getFieldDataByCondition("makeserial", "ms_nextstepcode", "ms_id='" + oMsid + "'").ToString();
- if (nextstepcode != User.CurrentStepCode)
- {
- string stname = dh.getFieldDataByCondition("step", "st_name", "st_code='" + nextstepcode + "'").ToString();
- OperateResult.AppendText("<<序列号:" + sncode.Text + "下一工序是" + stname + ",不是当前岗位的工序\n", Color.Red, sncode);
- imei1 = "";
- imei2 = "";
- checksn = "";
- isImei1 = false;
- isImei2 = false;
- return;
- }
- //调用 SETSTEPRESULT ,获取返回的工单号,
- if (LogicHandler.SetStepResult(omakeCode, User.UserSourceCode, checksn, "标签核对", "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(checksn, DateTime.Now.ToString(), "成功");
- //记录日志
- LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "标签核对", "标签核对成功", SN, "");
- //SN核对成功
- //>> 请输入SN
- OperateResult.AppendText("<<条码2核对成功\n", Color.Green, sncode);
- OperateResult.AppendText(">>请输入SN\n", Color.Black);
- }
- else
- {
- //setstepresult不通过
- OperateResult.AppendText(">>" + oErrorMessage + "\n", Color.Red, sncode);
- recordResult(checksn, DateTime.Now.ToString(), "失败");
- SetCheck set = new SetCheck("NG", Color.Red);
- BaseUtil.SetFormCenter(set);
- set.ShowDialog();
- }
- }
- else
- {
- //判定序列号下一工序不通过
- OperateResult.AppendText(">>" + oErrorMessage + "\n", Color.Red, sncode);
- recordResult(checksn, DateTime.Now.ToString(), "失败");
- SetCheck set = new SetCheck("NG", Color.Red);
- BaseUtil.SetFormCenter(set);
- set.ShowDialog();
- }
- }
- else
- {
- //判定工序属性不通过
- OperateResult.AppendText(">>" + oErrorMessage + "\n", Color.Red, sncode);
- SetCheck set = new SetCheck("NG", Color.Red);
- BaseUtil.SetFormCenter(set);
- set.ShowDialog();
- recordResult(checksn, DateTime.Now.ToString(), "失败");
- }
- }
- //说明比对不一致
- else
- {
- //清空imei1变量的值
- imei1 = "";
- imei2 = "";
- checksn = "";
- //SN核对失败
- //>> 请输入SN
- OperateResult.AppendText(">>SN核对失败,不一致\n", Color.Red, sncode);
- SetCheck set = new SetCheck("NG", Color.Red);
- BaseUtil.SetFormCenter(set);
- set.ShowDialog();
- OperateResult.AppendText(">>请输入SN\n", Color.Black);
- }
- //imei1校对结束,下次输入的是SN
- isImei1 = false;
- isImei2 = false;
- }
- }
- }
- private void recordResult(string SN, string time, string result)
- {
- 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 = "";
- imei2 = "";
- checksn = "";
- }
- private void StepCount_Load(object sender, EventArgs e)
- {
- }
- }
- }
|