123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334 |
- 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 : 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();
- ma_code.TableName = "make left join product on ma_prodcode=pr_code";
- ma_code.SelectField = "ma_code # 工单号,ma_pocode # 内部订单号,ma_prodcode # 产品编号,ma_qty # 工单数量,pr_spec # 产品规格,ma_softversion # 软件版本,ma_salecode # 销售单号,pr_sendchecktype # 产品送检方式";
- ma_code.FormName = Name;
- ma_code.SetValueField = new string[] { "ma_code", "ma_pocode", "ma_prodcode", "ma_qty", "substr(pr_spec,0,50)pr_spec", "ma_softversion", "ma_salecode", "nvl(pr_sendchecktype,'LineCode')pr_sendchecktype" };
- ma_code.Condition = "ma_statuscode='STARTED'";
- ma_code.DbChange += Ma_code_DbChange;
- //打开界面提示用户:请输入SN
- OperateResult.AppendText(">>请输入SN\n", Color.Black);
- sql = new LogStringBuilder();
- dh = SystemInf.dh;
- LockMakeCode.GetMakeCodeCtl(ma_code);
- ma_code.SetLockCheckBox(LockMakeCode);
- StepCount.StepCode = User.CurrentStepCode;
- StepCount.Source = User.UserSourceCode;
- StepCount.LineCode = User.UserLineCode;
- StepCount.Dh = dh;
- StepCount.Start();
- }
- DataTable Dbfind;
- private void Ma_code_DbChange(object sender, EventArgs e)
- {
- Dbfind = ma_code.ReturnData;
- BaseUtil.SetFormValue(this.Controls, Dbfind);
- }
- 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.DarkRed);
- return;
- }
- dt = (DataTable)dh.ExecuteSql("select ms_sncode from makeserial where ms_code='" + sncode.Text + "' or 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)
- {
- OperateResult.AppendText("<<" + sncode.Text + "\n", Color.Black);
- sql.Clear();
- sql.Append("select max(ms_id) ms_id from makeserial where ms_sncode ='" + sncode.Text + "' or ms_code='" + 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.DarkRed, 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
- imei1 = info.Rows[0]["ms_sncode"].ToString();
- SN = sncode.Text;
- //>> 请输入彩盒上的SN
- OperateResult.AppendText("<<条码" + sncode.Text + "对应的SN号为:" + imei1 + "\n", Color.Green);
- OperateResult.AppendText(">>请输入需要核对的条码\n", Color.Black, sncode);
- //设定要输入imei1
- isImei1 = true;
- }
- else
- {
- OperateResult.AppendText("<<SN:" + sncode.Text + "对应的SN不存在\n", Color.DarkRed, sncode);
- OperateResult.AppendText(">>请输入SN\n", Color.Black);
- SetCheck set = new SetCheck("NG", Color.DarkRed);
- BaseUtil.SetFormCenter(set);
- set.ShowDialog();
- }
- }
- //输入的是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 + "' or ms_code='" + 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.DarkRed, sncode);
- 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");
- string checksn = "";
- if (info.Rows.Count > 0)
- {
- checksn = info.Rows[0]["ms_sncode"].ToString();
- }
- if (imei1 == checksn)
- {
- //说明输入的imei1对比一致
- //判断工序属性attribute
- if (LogicHandler.CheckStepAttribute(Tag.ToString(), User.UserSourceCode, out oErrorMessage))
- {
- //判断序列号下一工序(CHECKSTEPSNANDMACODE)
- if (LogicHandler.CheckStepSNAndMacode(ma_code.Text, 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.DarkRed, sncode);
- imei1 = "";
- isImei1 = 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("<<SN核对成功\n", Color.LightGreen, sncode);
- OperateResult.AppendText(">>请输入SN\n", Color.Black);
- }
- else
- {
- //setstepresult不通过
- OperateResult.AppendText(">>" + oErrorMessage + "\n", Color.DarkRed, sncode);
- recordResult(checksn, DateTime.Now.ToString(), "失败");
- SetCheck set = new SetCheck("NG", Color.DarkRed);
- BaseUtil.SetFormCenter(set);
- set.ShowDialog();
- }
- }
- else
- {
- //判定序列号下一工序不通过
- OperateResult.AppendText(">>" + oErrorMessage + "\n", Color.DarkRed, sncode);
- recordResult(checksn, DateTime.Now.ToString(), "失败");
- SetCheck set = new SetCheck("NG", Color.DarkRed);
- BaseUtil.SetFormCenter(set);
- set.ShowDialog();
- }
- }
- else
- {
- //判定工序属性不通过
- OperateResult.AppendText(">>" + oErrorMessage + "\n", Color.DarkRed, sncode);
- recordResult(checksn, DateTime.Now.ToString(), "失败");
- }
- }
- //说明比对不一致
- else
- {
- //清空imei1变量的值
- imei1 = "";
- //SN核对失败
- //>> 请输入SN
- OperateResult.AppendText(">>SN核对失败,不一致\n", Color.DarkRed, sncode);
- OperateResult.AppendText(">>请输入SN\n", Color.Black);
- }
- //imei1校对结束,下次输入的是SN
- isImei1 = 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 = "";
- }
- private void StepCount_Load(object sender, EventArgs e)
- {
- }
- }
- }
|