123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408 |
- 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_CollectElec : Form
- {
- DataHelper dh;
- AutoSizeFormClass asc = new AutoSizeFormClass();
- LogStringBuilder sql = new LogStringBuilder();
- DataTable dt;
- //当前序列号记录
- string sn_code;
- //制造单号
- string macode;
- //采集网标号
- float net_code;
- //网标查询条件ms_id
- string oMsID;
- //判断是否输入网标
- Boolean isnetcode = false;
- //打印计数
- int printcount = 0;
- int ma_unlimitin;
- public Make_CollectElec()
- {
- InitializeComponent();
- }
- private void Make_CollectNetCode_Load(object sender, EventArgs e)
- {
- asc.controllInitializeSize(this);
- sncode.Focus();
- dh = SystemInf.dh;
- StepCount.StepCode = User.CurrentStepCode;
- StepCount.Source = User.UserSourceCode;
- StepCount.LineCode = User.UserLineCode;
- StepCount.Dh = dh;
- StepCount.Start();
- }
- private void sncode_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- string ErrorMessage2;
- string oMakeCode;
- //采集序列号
- if (!isnetcode)
- {
- string[] arr = sncode.Text.Split(',');
- if (arr.Length != 6)
- {
- OperateResult.AppendText(">>数据长度错误,无法解析\n", Color.Red);
- return;
- }
- TSN.Text = arr[0];
- PSN.Text = arr[1];
- PKID.Text = arr[2];
- KEY.Text = arr[3];
- MAC.Text = arr[4];
- IMEI.Text = arr[5];
- if (CheckPSN.Checked&& dh.CheckExist("wincheck", "WC_SNCODE<>'" + TSN.Text + "' and (WC_PSN='" + PSN.Text + "')"))
- {
- OperateResult.AppendText(">>PSN重复信息\n", Color.Red);
- return;
- }
- if (CheckMac.Checked&& dh.CheckExist("wincheck", "WC_SNCODE<>'" + TSN.Text + "' and (WC_MAC='" + MAC.Text + "' )"))
- {
- OperateResult.AppendText(">>MAC重复信息\n", Color.Red);
- return;
- }
- if (CheckPKID.Checked&& dh.CheckExist("wincheck", "WC_SNCODE<>'" + TSN.Text + "' and (WC_PKID='" + PKID.Text + "')") && PKID.Text != "NONE")
- {
- OperateResult.AppendText(">>PKID重复信息\n", Color.Red);
- return;
- }
- if (CheckKey.Checked&& dh.CheckExist("wincheck", "WC_SNCODE<>'" + TSN.Text + "' and (WC_KEY='" + KEY.Text + "')") && KEY.Text != "NONE")
- {
- OperateResult.AppendText(">>KEY重复信息\n", Color.Red);
- return;
- }
- if (CheckImei.Checked&&dh.CheckExist("wincheck", "WC_SNCODE<>'" + TSN.Text + "' and (WC_IMEI='" + IMEI.Text + "')"))
- {
- OperateResult.AppendText(">>IMEI重复信息\n", Color.Red);
- return;
- }
- sncode.Text = TSN.Text;
- if (sncode.Text == "")
- {
- OperateResult.AppendText(">>序列号不能为空\n", Color.Red);
- return;
- }
- if (LogicHandler.CheckStepAttribute(Tag.ToString(), User.UserSourceCode, out ErrorMessage2))
- {
- //判断界面工单是否为空时的序列号是否自动归属工单
- string oStatus = "";
- string sn_code = "";
- dt = (DataTable)dh.ExecuteSql("select ms_sncode from makeserial where ms_sncode ='" + TSN.Text + "' or ms_firstsn='" + TSN.Text + "' order by ms_id desc", "select");
- if (dt.Rows.Count > 0)
- {
- sn_code = dt.Rows[0]["ms_sncode"].ToString();
- }
- if (!LogicHandler.GetMakeInfo(sn_code, out oMakeCode, out oStatus, out ErrorMessage2))
- {
- if (ms_makecode.Text == "")
- {
- OperateResult.AppendText(">>" + ErrorMessage2 + "\n", Color.Red, sncode);
- return;
- }
- }
- OperateResult.AppendText("<<" + sn_code + "\n", Color.Black);
- // 获取工单归属工单下一工序是否正确
- if (LogicHandler.CheckStepSNAndMacode(ms_makecode.Text == "" ? oMakeCode : ms_makecode.Text, User.UserSourceCode, sn_code, User.UserCode, out oMakeCode, out oMsID, out ErrorMessage2))
- {
- sql.Clear();
- sql.Append("select ms_makecode,ms_prodcode,pr_detail,nvl(pr_electricmax,0)pr_electricmax,nvl(pr_electricmin,0)pr_electricmin from makeserial left join product on ");
- sql.Append(" ms_prodcode = pr_code where ms_id = '" + oMsID + "'");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- BaseUtil.SetFormValue(this.Controls, dt);
- OperateResult.AppendText(">>请输入核对参数\n", Color.Black);
- sn_code = sncode.Text;
- sncode.Text = "";
- isnetcode = true;
- return;
- }
- else OperateResult.AppendText(">>" + ErrorMessage2 + "\n", Color.Red, sncode);
- }
- else OperateResult.AppendText(">>" + ErrorMessage2 + "\n", Color.Red, sncode);
- }
- //采集netcode
- else
- {
- if (CheckTSN.Checked)
- {
- if (TSN_CHECK.Text == "")
- {
- if (TSN.Text == sncode.Text)
- {
- TSN_CHECK.Text = sncode.Text;
- {
- OperateResult.AppendText(">>TSN核对成功\n", Color.Green);
- if (CheckInfoPass())
- {
- dh.ExecuteSql("insert into wincheck(WC_ID, WC_SNCODE, WC_PSN, WC_PKID, WC_KEY, WC_MAC, WC_IMEI) values(wincheck_seq.nextval,'" + TSN.Text + "','" + PSN.Text + "','" + PKID.Text + "','" + KEY.Text + "','" + MAC.Text + "','" + IMEI.Text + "')", "insert");
- isnetcode = false;
- sncode.Text = "";
- sncode.Focus();
- CleanData();
- return;
- }
- return;
- }
- }
- else
- {
- OperateResult.AppendText(">>TSN核对错误,请重新输入\n", Color.Red);
- return;
- }
- }
- }
- if (CheckPSN.Checked)
- {
- if ((!CheckTSN.Checked || TSN_CHECK.Text != "") && PSN_CHECK.Text == "")
- {
- if (PSN.Text == sncode.Text)
- {
- PSN_CHECK.Text = sncode.Text;
- {
- OperateResult.AppendText(">>PSN核对成功\n", Color.Green);
- if (CheckInfoPass())
- {
- dh.ExecuteSql("insert into wincheck(WC_ID, WC_SNCODE, WC_PSN, WC_PKID, WC_KEY, WC_MAC, WC_IMEI) values(wincheck_seq.nextval,'" + TSN.Text + "','" + PSN.Text + "','" + PKID.Text + "','" + KEY.Text + "','" + MAC.Text + "','" + IMEI.Text + "')", "insert");
- isnetcode = false;
- sncode.Text = "";
- sncode.Focus();
- CleanData();
- return;
- }
- return;
- }
- }
- else
- {
- OperateResult.AppendText(">>PSN核对错误,请重新输入\n", Color.Red);
- return;
- }
- }
- }
- if (CheckPKID.Checked)
- {
- if ((!CheckTSN.Checked || TSN_CHECK.Text != "" || !CheckPSN.Checked || PSN_CHECK.Text != "") && PKID_CHECK.Text == "")
- {
- if (PKID.Text == sncode.Text)
- {
- PKID_CHECK.Text = sncode.Text;
- {
- OperateResult.AppendText(">>PKID核对成功\n", Color.Green);
- if (CheckInfoPass())
- {
- dh.ExecuteSql("insert into wincheck(WC_ID, WC_SNCODE, WC_PSN, WC_PKID, WC_KEY, WC_MAC, WC_IMEI) values(wincheck_seq.nextval,'" + TSN.Text + "','" + PSN.Text + "','" + PKID.Text + "','" + KEY.Text + "','" + MAC.Text + "','" + IMEI.Text + "')", "insert");
- isnetcode = false;
- sncode.Text = "";
- sncode.Focus();
- CleanData();
- return;
- }
- return;
- }
- }
- else
- {
- OperateResult.AppendText(">>PKID核对错误,请重新输入\n", Color.Red);
- return;
- }
- }
- }
- if (CheckKey.Checked)
- {
- if ((!CheckTSN.Checked || TSN_CHECK.Text != "" || !CheckPSN.Checked || PSN_CHECK.Text != "" || !CheckPKID.Checked || PKID_CHECK.Text != "") && KEY_CHECK.Text == "")
- {
- if (KEY.Text == sncode.Text)
- {
- KEY_CHECK.Text = sncode.Text;
- {
- OperateResult.AppendText(">>KEY核对成功\n", Color.Green);
- if (CheckInfoPass())
- {
- dh.ExecuteSql("insert into wincheck(WC_ID, WC_SNCODE, WC_PSN, WC_PKID, WC_KEY, WC_MAC, WC_IMEI) values(wincheck_seq.nextval,'" + TSN.Text + "','" + PSN.Text + "','" + PKID.Text + "','" + KEY.Text + "','" + MAC.Text + "','" + IMEI.Text + "')", "insert");
- isnetcode = false;
- sncode.Text = "";
- sncode.Focus();
- CleanData();
- return;
- }
- return;
- }
- }
- else
- {
- OperateResult.AppendText(">>KEY核对错误,请重新输入\n", Color.Red);
- return;
- }
- }
- }
- if (CheckMac.Checked)
- {
- if ((!CheckTSN.Checked || TSN_CHECK.Text != "" || !CheckPSN.Checked || PSN_CHECK.Text != "" || !CheckPKID.Checked || PKID_CHECK.Text != "" || !CheckKey.Checked || KEY_CHECK.Text != "") && MAC_CHECK.Text == "")
- {
- if (MAC.Text == sncode.Text)
- {
- MAC_CHECK.Text = sncode.Text;
- {
- OperateResult.AppendText(">>MAC核对成功\n", Color.Green);
- if (CheckInfoPass())
- {
- dh.ExecuteSql("insert into wincheck(WC_ID, WC_SNCODE, WC_PSN, WC_PKID, WC_KEY, WC_MAC, WC_IMEI) values(wincheck_seq.nextval,'" + TSN.Text + "','" + PSN.Text + "','" + PKID.Text + "','" + KEY.Text + "','" + MAC.Text + "','" + IMEI.Text + "')", "insert");
- isnetcode = false;
- sncode.Text = "";
- sncode.Focus();
- CleanData();
- return;
- }
- return;
- }
- }
- else
- {
- OperateResult.AppendText(">>MAC核对错误,请重新输入\n", Color.Red);
- return;
- }
- }
- }
- if (CheckImei.Checked)
- {
- if ((!CheckTSN.Checked || TSN_CHECK.Text != "" || !CheckPSN.Checked || PSN_CHECK.Text != "" || !CheckPKID.Checked || PKID_CHECK.Text != "" || !CheckKey.Checked || KEY_CHECK.Text != "" || !CheckMac.Checked || MAC_CHECK.Text != "") && IMEI_CHECK.Text == "")
- {
- if (IMEI.Text == sncode.Text)
- {
- IMEI_CHECK.Text = sncode.Text;
- {
- OperateResult.AppendText(">>IMEI核对成功\n", Color.Green);
- if (CheckInfoPass())
- {
- dh.ExecuteSql("insert into wincheck(WC_ID, WC_SNCODE, WC_PSN, WC_PKID, WC_KEY, WC_MAC, WC_IMEI) values(wincheck_seq.nextval,'" + TSN.Text + "','" + PSN.Text + "','" + PKID.Text + "','" + KEY.Text + "','" + MAC.Text + "','" + IMEI.Text + "')", "insert");
- isnetcode = false;
- sncode.Text = "";
- sncode.Focus();
- CleanData();
- return;
- }
- return;
- }
- }
- else
- {
- OperateResult.AppendText(">>IMEI核对错误,请重新输入\n", Color.Red);
- return;
- }
- }
- }
- }
- }
- }
- private void CleanData()
- {
- TSN.Clear();
- PSN.Clear();
- PKID.Clear();
- IMEI.Clear();
- MAC.Clear();
- KEY.Clear();
- TSN_CHECK.Clear();
- PSN_CHECK.Clear();
- PKID.Clear();
- IMEI.Clear();
- MAC.Clear();
- KEY.Clear();
- OperateResult.AppendText(">>核对完成,请重新输入SN号\n", Color.Green);
- }
- private bool CheckInfoPass()
- {
- if (CheckTSN.Checked)
- {
- if (TSN.Text != TSN_CHECK.Text)
- {
- return false;
- }
- }
- if (CheckPSN.Checked)
- {
- if (PSN.Text != PSN_CHECK.Text)
- return false;
- }
- if (CheckPKID.Checked)
- {
- if (PKID.Text != PKID_CHECK.Text)
- return false;
- }
- if (CheckKey.Checked)
- {
- if (KEY.Text != KEY_CHECK.Text)
- return false;
- }
- if (CheckMac.Checked)
- {
- if (MAC.Text != MAC_CHECK.Text)
- return false;
- }
- if (CheckImei.Checked)
- {
- if (IMEI.Text != IMEI_CHECK.Text)
- return false;
- }
- string ErrorMessage2;
- string sn_code = "";
- dt = (DataTable)dh.ExecuteSql("select ms_sncode from makeserial where ms_sncode ='" + TSN.Text + "' or ms_firstsn='" + TSN.Text + "' order by ms_id desc", "select");
- if (dt.Rows.Count > 0)
- {
- sn_code = dt.Rows[0]["ms_sncode"].ToString();
- }
- if (!LogicHandler.SetStepResult(ms_makecode.Text, User.UserSourceCode, sn_code, "核对标签信息", "核对成功", User.UserCode, out ErrorMessage2))
- {
- OperateResult.AppendText(">>" + ErrorMessage2 + "\n", Color.Red);
- }
- else
- {
- }
- return true;
- }
- private void Make_CollectNetCode_SizeChanged(object sender, EventArgs e)
- {
- asc.controlAutoSize(this);
- }
- private void Make_CollectNetCode_Activated(object sender, EventArgs e)
- {
- sncode.Focus();
- }
- private void deleteButton1_Click(object sender, EventArgs e)
- {
- CleanData();
- }
- private void StepCount_Load(object sender, EventArgs e)
- {
- }
- }
- }
|