1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186 |
- using System;
- using System.Data;
- using System.Text;
- using System.Threading;
- using System.Drawing;
- using System.Windows.Forms;
- using UAS_MES_NEW.DataOperate;
- using UAS_MES_NEW.Entity;
- using UAS_MES_NEW.PublicMethod;
- using System.Collections.Generic;
- using UAS_MES_NEW.CustomControl.PowerControlForm;
- using UAS_MES_NEW.PublicForm;
- using LabelManager2;
- using System.IO;
- using System.Text.RegularExpressions;
- namespace UAS_MES_NEW.Make
- {
- public partial class Make_TestCollection : Form
- {
- DataHelper dh = null;
- DataTable dt = null;
- //当前工序的名称
- string ErrorMessage = "";
- //用于保存是否之前输入的ms_sncode
- string LastSncode;
- string oMakeCode = "";
- string oMSID = "";
- string ifrework = "";
- string reworkstatus = "";
- LogStringBuilder sql = new LogStringBuilder();
- AutoSizeFormClass asc = new AutoSizeFormClass();
- /// <summary>
- /// 已选的不良
- /// </summary>
- List<string> ChoosedList = new List<string>();
- /// <summary>
- /// 待选的不良
- /// </summary>
- List<string> WaitList = new List<string>();
- bool AutoCut = false;
- bool LockSn = false;
- string labelname;
- DataTable Dbfind;
- ApplicationClass lbl;
- Thread thread;
- // Document doc;
- public Make_TestCollection()
- {
- InitializeComponent();
- }
- private void TestCollection_Load(object sender, EventArgs e)
- {
- GoodProduct.Checked = true;
- asc.controllInitializeSize(this);
- ms_sncode.Focus();
- //设置锁定工单
- LockMakeCode.GetMakeCodeCtl(ma_code);
- ma_code.SetLockCheckBox(LockMakeCode);
- ControlLockTimer.Tick += ControlLockTimer_Tick;
- ControlLockTimer.Interval = 100;
- labelname = System.Windows.Forms.Application.StartupPath + @"\badsn.lab";
- //thread = new Thread(NewPrint);
- // SetLoadingWindow stw = new SetLoadingWindow(thread, "初始化打印程序");
- //BaseUtil.SetFormCenter(stw);
- // stw.ShowDialog();
- //工单号放大镜配置
- ma_code.TableName = "make left join product on ma_prodcode=pr_code";
- ma_code.SelectField = "ma_code # 工单号,ma_prodcode # 产品编号,ma_qty # 工单数量, pr_orispeccode # 型号, ma_wccode # 车间,ma_inqty # 投入数,pr_spec # 产品规格,ma_endremark # 客户代码";
- ma_code.FormName = Name;
- ma_code.SetValueField = new string[] { "ma_code", "ma_prodcode", "ma_qty", "pr_orispeccode pr_spec", "ma_endremark" };
- ma_code.Condition = "ma_statuscode='STARTED' order by ma_date desc";
- ma_code.DbChange += Ma_code_DbChange;
- dh = SystemInf.dh;
- StepCount.StepCode = User.CurrentStepCode;
- StepCount.Source = User.UserSourceCode;
- StepCount.LineCode = User.UserLineCode;
- StepCount.Dh = dh;
- StepCount.Start();
- }
- private void ControlLockTimer_Tick(object sender, EventArgs e)
- {
- this.Activate();
- ms_sncode.Focus();
- }
- private void Ma_code_DbChange(object sender, EventArgs e)
- {
- Dbfind = ma_code.ReturnData;
- BaseUtil.SetFormValue(this.Controls, Dbfind);
- LoadBadGroupData();
- LoadCollectedNum();
- LoadCheckQTY();
- }
- /// <summary>
- /// 将已选不良移动到待选不良
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void WaitReject_Click(object sender, EventArgs e)
- {
- int CheckedNum = 0;
- //已存在在ListView中的Item是不能添加到其他ListView中的,需要调用其克隆的方法
- for (int i = ChoosedRejectList.Items.Count - 1; i >= 0; i--)
- {
- if (ChoosedRejectList.Items[i].Checked)
- {
- ChoosedRejectList.Items[i].Checked = false;
- WaitRejectList.Items.Add((ListViewItem)ChoosedRejectList.Items[i].Clone());
- ChoosedRejectList.Items[i].Remove();
- CheckedNum++;
- }
- }
- if (CheckedNum == 0)
- {
- for (int i = ChoosedRejectList.Items.Count - 1; i >= 0; i--)
- {
- WaitRejectList.Items.Add((ListViewItem)ChoosedRejectList.Items[i].Clone());
- ChoosedRejectList.Items[i].Remove();
- }
- }
- }
- /// <summary>
- /// 将不良信息移动到已选不良
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ChooseedReject_Click(object sender, EventArgs e)
- {
- if (ms_sncode.Text == "")
- {
- OperateResult.AppendText(">>序列号不能为空\n", Color.Red);
- ms_sncode.Focus();
- return;
- }
- int CheckedNum = 0;
- //是否已经添加到不良
- bool AddToReject = false;
- if (ChoosedRejectList.Items.Count > 0)
- {
- OperateResult.AppendText(">>只可采集一个不良现象\n", Color.Red);
- return;
- }
- for (int i = WaitRejectList.Items.Count - 1; i >= 0; i--)
- {
- if (WaitRejectList.Items[i].Checked)
- {
- AddToReject = false;
- for (int j = 0; j < ChoosedRejectList.Items.Count; j++)
- {
- if ((ChoosedRejectList.Items[j].SubItems[2].Text == WaitRejectList.Items[i].SubItems[2].Text))
- {
- AddToReject = true;
- OperateResult.AppendText(">>已存在" + ChoosedRejectList.Items[j].SubItems[2].Text + "不良\n", Color.Red);
- break;
- }
- }
- //未添加则进行添加
- if (!AddToReject)
- {
- WaitRejectList.Items[i].Checked = false;
- ChoosedRejectList.Items.Add((ListViewItem)WaitRejectList.Items[i].Clone());
- WaitRejectList.Items[i].Remove();
- CheckedNum++;
- break;
- }
- }
- }
- if (CheckedNum == 0)
- {
- OperateResult.AppendText(">>请勾选不良代码\n", Color.Red);
- }
- }
- private void CleanInfo_Click(object sender, EventArgs e)
- {
- OperateResult.Clear();
- }
- private void ms_code_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- if (ms_sncode.Text.Contains("EMPLOYEE:"))
- {
- biduisn.Text = ms_sncode.Text.Split(':')[1];
- OperateResult.AppendText(">>采集人员编号"+ biduisn.Text+"\n", Color.Green, ms_sncode);
- return;
- }
- if (ms_sncode.Text.Contains("CHANGE:"))
- {
- GoodProduct.Checked = !GoodProduct.Checked;
- Reject.Checked = !GoodProduct.Checked;
- OperateResult.AppendText(">>切换良品不良采集\n", Color.Black, ms_sncode);
- return;
- }
- if (bidui.Checked && biduisn.Text =="")
- {
- OperateResult.AppendText(">>勾选人员采集需先采集人员\n", Color.Red, ms_sncode);
- return;
- }
- ChoosedRejectList.Items.Clear();
- WaitList.Clear();
- ChoosedList.Clear();
- if (LogicHandler.CheckStepAttribute(Tag.ToString(), User.UserSourceCode, out ErrorMessage))
- {
- bool NoteAlready = LogicHandler.CheckDiffMakeCodeBeforeStepCheck(ms_sncode.Text, ma_code.Text, NoteForChange.Checked, out oMakeCode, out ErrorMessage);
- if (!NoteAlready)
- {
- OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, ms_sncode);
- return;
- }
- if (LogicHandler.CheckStepSNAndMacode(oMakeCode, User.UserSourceCode, ms_sncode.Text, User.UserCode, out oMakeCode, out oMSID, out ErrorMessage))
- {
- //是否提示过工单切换框,检测前后执行
- if (!LogicHandler.CheckDiffMakeCodeAfterStepCheck(ms_sncode.Text, oMakeCode, NoteForChange.Checked, NoteAlready, ma_code, out ErrorMessage))
- {
- OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, ms_sncode);
- return;
- }
- if (ma_code.Text != oMakeCode && oMakeCode != null)
- {
- dt = (DataTable)dh.ExecuteSql("select ma_code,ma_prodcode,ma_softversion,ma_salecode,pr_orispeccode pr_spec,nvl(pr_sendchecktype,'LineCode')pr_sendchecktype,ma_qty,ma_endremark from make left join product on ma_prodcode=pr_code where ma_code='" + oMakeCode + "'", "select");
- if (dt.Rows.Count > 0)
- {
- BaseUtil.SetFormValue(this.Controls, dt);
- LockMakeCode.Checked = true;
- }
- }
- dt = (DataTable)dh.ExecuteSql("select ms_nextstepcode,ms_sncode,ms_reworkstatus,nvl(ms_ifrework,0)ms_ifrework,ms_stepcode,ms_status,nvl(st_ifrepair,0) st_ifrepair from makeserial left join step on ms_stepcode=st_code where ms_id='" + oMSID + "'", "select");
- string status = dt.Rows[0]["ms_status"].ToString();
- reworkstatus = dt.Rows[0]["ms_reworkstatus"].ToString();
- string stepcode = dt.Rows[0]["ms_stepcode"].ToString();
- string ifrepair = dt.Rows[0]["st_ifrepair"].ToString();
- string sncode = dt.Rows[0]["ms_sncode"].ToString();
- if (sncode != ms_sncode.Text)
- {
- OperateResult.AppendText(">>" + ms_sncode.Text + " 序列号已执行过转号,不允许使用TSN采集\n", Color.Red, ms_sncode);
- return;
- }
- ifrework = dt.Rows[0]["ms_ifrework"].ToString();
- if (GoodProduct.Checked)
- {
- if (ifrework != "0")
- {
- if (stepcode == User.CurrentStepCode && (reworkstatus == "1" || reworkstatus == "2") && ifrepair == "0")
- {
- OperateResult.AppendText(">>" + ms_sncode.Text + " 序列号已执行过" + User.CurrentStepName + "工序,采集结果为良品\n", Color.Red, ms_sncode);
- return;
- }
- }
- else
- {
- if (stepcode == User.CurrentStepCode && (status == "1" || status == "2") && ifrepair == "0")
- {
- OperateResult.AppendText(">>" + ms_sncode.Text + " 序列号已执行过" + User.CurrentStepName + "工序,采集结果为良品\n", Color.Red, ms_sncode);
- return;
- }
- }
- }
- SetCollectResult();
- }
- else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, ms_sncode, oth);
- }
- else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, ms_sncode, oth);
- }
- }
- private void bc_groupcode_SelectedIndexChanged(object sender, EventArgs e)
- {
- LoadBadCodeListView();
- }
- /// <summary>
- /// 填充不良组别信息
- /// </summary>
- private void LoadBadGroupData()
- {
- //如果ms_makecode的值修改过再去查询
- sql.Clear();
- sql.Append("select bg_code||':'||bg_name bg_name,bg_code from badgroup left join (select pb_badgroup,pr_kind ");
- sql.Append("from product left join productkind on pk_name=pr_kind ");
- sql.Append("left join productbadgroup on pk_code=PB_KINDCODE where pr_code='" + ma_prodcode.Text + "')");
- sql.Append("on pb_badgroup=bg_code where bg_statuscode='AUDITED' order by case when bg_code='" + User.DefaultBadGroup + "' then 0 else 1 end");
- DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- bc_groupcode.DisplayMember = "bg_name";
- bc_groupcode.ValueMember = "bg_code";
- bc_groupcode.DataSource = dt;
- }
- /// <summary>
- /// 加载不良代码的ListView的信息
- /// </summary>
- private void LoadBadCodeListView()
- {
- object bg_code = bc_groupcode.SelectedValue;
- sql.Clear();
- sql.Append("select bg_code||':'||bg_name bg_code,bc_code,bc_name,'' bc_remark from badgroupdetail ");
- sql.Append("left join badgroup on bg_id=bgd_bgid left join badcode on bgd_badcode=bc_code where ");
- sql.Append("bg_code='" + (bg_code != null ? bg_code.ToString() : "") + "' and bg_code is not null order by bgd_detno");
- DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- BadInfSource.DataSource = dt;
- //往listview中添加数据
- WaitRejectList.Items.Clear();
- WaitRejectList.BeginUpdate();
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- if (!ChoosedList.Contains(dt.Rows[i]["bc_code"].ToString()))
- {
- ListViewItem lvi = new ListViewItem();
- //第一列是勾选列,设置列头文本为空
- lvi.Text = "";
- WaitList.Add(dt.Rows[i]["bc_code"].ToString());
- for (int j = 0; j < dt.Columns.Count; j++)
- lvi.SubItems.Add(dt.Rows[i][j].ToString());
- WaitRejectList.Items.Add(lvi);
- }
- }
- WaitRejectList.EndUpdate();
- }
- /// <summary>
- /// 加载已选不良的ListView
- /// </summary>
- private void LoadChoosedBadListView()
- {
- sql.Clear();
- sql.Append("select nvl(bg_code,mb_bgcode)||':'||nvl(bg_name,mb_badcode) bg_code,nvl(mb_badcode,bc_code) bc_code,bc_name,mb_badremark from makebad ");
- sql.Append("left join badgroup on mb_bgcode=bg_code left join badcode on mb_badcode=bc_code ");
- sql.Append(" where mb_sncode='" + ms_sncode.Text + "' and mb_makecode='" + ma_code.Text + "' and mb_status=0");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- ChoosedRejectList.Items.Clear();
- ChoosedRejectList.BeginUpdate();
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- ListViewItem lvi = new ListViewItem();
- //第一列是勾选列,设置列头文本为空
- lvi.Text = "";
- ChoosedList.Add(dt.Rows[i]["bc_code"].ToString());
- for (int j = 0; j < dt.Columns.Count; j++)
- lvi.SubItems.Add(dt.Rows[i][j].ToString());
- ChoosedRejectList.Items.Add(lvi);
- }
- if (!dh.CheckExist("makebad", "mb_sncode='" + ms_sncode.Text + "' and mb_makecode='" + ma_code.Text + "'")&&(User.CurrentStepCode== "JIFMA"|| User.CurrentStepCode == "MOFMA"))
- {
- sql.Clear();
- sql.Append("select as_bgname||':'||as_bgcode bg_code,as_badcode bc_code,as_badname bc_name,'' mb_badremark from RETURNSNBD join AFSALES on rsb_oldsn = as_sn where rsb_newsn = '" + ms_sncode.Text + "' ");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- if (dt.Rows.Count > 0)
- {
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- ListViewItem lvi = new ListViewItem();
- //第一列是勾选列,设置列头文本为空
- lvi.Text = "";
- ChoosedList.Add(dt.Rows[i]["bc_code"].ToString());
- for (int j = 0; j < dt.Columns.Count; j++)
- lvi.SubItems.Add(dt.Rows[i][j].ToString());
- ChoosedRejectList.Items.Add(lvi);
- }
- }
- ChoosedRejectList.EndUpdate();
- }
- else
- {
- ChoosedRejectList.EndUpdate();
- }
-
- }
- /// <summary>
- /// 设置良品或者不良品的采集结果
- /// </summary>
- private void SetCollectResult()
- {
- string ErrorMessage = "";
- //如果勾选的是不良品
- if (Reject.Checked)
- {
- LoadBadCodeListView();
- LoadChoosedBadListView();
- OperateResult.AppendText(">>请采集不良代码\n", Color.Black);
- bc_code.Focus();
- }
- else if (GoodProduct.Checked)
- {
- //如果不是返修的
- if (ifrework == "0")
- {
- dt = (DataTable)dh.ExecuteSql("select mb_id,bc_name,mbr_mbid from makebad left join makebadreason on mbr_mbid=mb_id left join badcode on mb_badcode=bc_code where mb_sncode='" + ms_sncode.Text + "' and mb_makecode='" + ma_code.Text + "' and mb_status=0", "select");
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- if (dt.Rows[i]["mb_id"].ToString() != dt.Rows[i]["mbr_mbid"].ToString())
- ErrorMessage += "【" + dt.Rows[i]["bc_name"].ToString() + "】";
- }
- //存在不良记录
- if (ErrorMessage != "")
- {
- OperateResult.AppendText(">>序列号:" + ms_sncode.Text + " 已经判为不良品,不允许修改!\n", Color.Red);
- return;
- }
- else
- {
- //if (AutoBadCode.Checked)
- //{
- // string str = BaseUtil.GetDataFromDevice("DEVICES");
- // str = str.Replace("LIST OF DEVICES ATTACHED", "").Replace("\n", "");
- // if (!(str.Length == 0))
- // {
- // Console.WriteLine("有链接");
- // BaseUtil.GetDataFromDevice("RESET");
- // }
- // else
- // {
- // OperateResult.AppendText(">>无设备链接,无法恢复出厂设置,采集失败\n", Color.Red, ms_sncode);
- // return;
- // }
- //}
- if (khcheck.Checked)
- {
- String priex = dh.getFieldDataByCondition("product", "pr_usetype", "pr_code = '" + ma_prodcode.Text + "'").ToString();
- if (priex == "")
- {
- OperateResult.AppendText(">>产品编号" + ma_prodcode.Text + "未维护客户码防呆要求\n", Color.Red, ms_sncode);
- return;
- }
- string[] pres = priex.Split('|');
- bool f = false;
- for (int i = 0; i < pres.Length; i++)
- {
- if (pres[i] == "" ? true : oth.Text.Contains(pres[i]))
- {
- //满足其中一条即可
- f = true;
- break;
- }
- }
- if (!f)
- {
- OperateResult.AppendText(">>客户码" + oth.Text + "不符合防呆要求\n", Color.Red, oth);
- oth.Focus();
- oth.SelectAll();
- return;
- }
- }
- else
- {
- if (oth.Text != "")
- {
- OperateResult.AppendText(">>客户码" + oth.Text + "不需要采集\n", Color.Black, oth);
- }
- }
- //良品信息采集
- if (LogicHandler.SetStepResult(ma_code.Text, User.UserSourceCode, ms_sncode.Text, "良品采集", "检测合格", biduisn.Text==""?User.UserCode: biduisn.Text, out ErrorMessage))
- {
- //if (WriteSoftWare.Checked)
- //{
- // string Message = BaseUtil.GetDataFromDevice("INSTALL", SoftWarePath.Text);
- // OperateResult.AppendText(">>" + Message + "\n");
- //}
- //提示正确返回时传递的信息
- if (ErrorMessage.Contains("AFTERSUCCESS"))
- OperateResult.AppendText(">>" + ErrorMessage + "\n",Color.Red);
- ////恢复出厂设置
- //if (AutoBadCode.Checked)
- // BaseUtil.GetDataFromDevice("RESET");
- if (oth.Text != "")
- {
- dh.ExecuteSql(" update makeserial set MS_OTHCODE1 = '"+oth.Text+"' where ms_sncode = '"+ms_sncode.Text+"' ", "update");
- }
- LastSncode = ms_sncode.Text;
- LogicHandler.DoCommandLog(Tag.ToString(), biduisn.Text == "" ? User.UserCode : biduisn.Text, ma_code.Text, User.UserLineCode, User.UserSourceCode, "采集良品", "采集良品成功", LastSncode, ob_checkno.Text);
- lastsn.Text = ms_sncode.Text;
- lastresult.Text = "OK";
- lastresult.BackColor = Color.Green;
- OperateResult.AppendText(">>" + ms_sncode.Text + "良品采集成功\n", Color.Green, ms_sncode, oth);
- if (khcheck.Checked)
- {
- oth.Focus();
- }
- //记录操作日志
- }
- else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, ms_sncode, oth);
- }
- }
- else
- {
- if (reworkstatus != "3")
- {
- if (LogicHandler.SetStepResult(ma_code.Text, User.UserSourceCode, ms_sncode.Text, "良品采集", "检测合格", User.UserCode, out ErrorMessage))
- {
- //提示正确返回时传递的信息
- if (ErrorMessage.Contains("AFTERSUCCESS"))
- OperateResult.AppendText(">>" + ErrorMessage + "\n");
- LastSncode = ms_sncode.Text;
- OperateResult.AppendText(">>" + ms_sncode.Text + "成功采集为良品\n", Color.Green, ms_sncode, oth);
- //记录操作日志
- LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "采集良品", "采集良品成功", LastSncode, ob_checkno.Text);
- }
- else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, ms_sncode, oth);
- }
- else
- {
- OperateResult.AppendText(">>返修的不良序列号必须先进行维修\n", Color.Red);
- }
- }
- }
- //加载页面信息
- LoadCollectedNum();
- LoadCheckQTY();
- }
-
- private void 测试采集_SizeChanged(object sender, EventArgs e)
- {
- asc.controlAutoSize(this);
- }
- private void LoadCollectedNum()
- {
- dt = (DataTable)dh.ExecuteSql("select mcd_inqty,ma_qty-mcd_inqty mcd_remainqty,mcd_ngqty,mcd_okqty,mcd_totalng from make left join makecraftdetail_view on mcd_macode=ma_code where ma_code='" + ma_code.Text + "' and mcd_stepcode='" + User.CurrentStepCode + "'", "select");
- BaseUtil.SetFormValue(Controls, dt);
- }
- private void Save_Click(object sender, EventArgs e)
- {
- if (ms_sncode.Text == "")
- {
- OperateResult.AppendText(">>序列号不允许为空\n", Color.Red);
- return;
- }
- if (GoodProduct.Checked)
- ms_code_KeyDown(sender, new KeyEventArgs(Keys.Enter));
- else if (Reject.Checked)
- {
- if (LogicHandler.CheckStepAttribute(Tag.ToString(), User.UserSourceCode, out ErrorMessage))
- {
- //判断界面工单是否为空时的序列号是否自动归属工单
- string oStatus = "";
- if (!LogicHandler.GetMakeInfo(ms_sncode.Text, out oMakeCode, out oStatus, out ErrorMessage))
- {
- if (ma_code.Text == "")
- {
- OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, ms_sncode);
- return;
- }
- }
- if (LogicHandler.CheckStepSNAndMacode(ma_code.Text == "" ? oMakeCode : ma_code.Text, User.UserSourceCode, ms_sncode.Text, User.UserCode, out oMakeCode, out oMSID, out ErrorMessage))
- {
- dt = (DataTable)dh.ExecuteSql("select ma_code,ma_prodcode,ma_softversion,pr_orispeccode pr_spec,ma_qty from make left join product on ma_prodcode=pr_code where ma_code='" + oMakeCode + "'", "select");
- if (dt.Rows.Count > 0)
- {
- BaseUtil.SetFormValue(this.Controls, dt);
- LockMakeCode.Checked = true;
- }
- }
- else
- {
- OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, ms_sncode);
- return;
- }
- }
- else
- {
- OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, ms_sncode);
- return;
- }
- int RejectCount = ChoosedRejectList.Items.Count;
- string[] bccode = new string[RejectCount];
- string[] bcremark = new string[RejectCount];
- string[] bgcode = new string[RejectCount];
- string[] bgname = new string[RejectCount];
- string[] bcname = new string[RejectCount];
- if (ChoosedRejectList.Items.Count == 0)
- {
- OperateResult.AppendText(">>不良品必须选择不良原因和不良代码!\n", Color.Red);
- return;
- }
- else
- {
- for (int i = 0; i < RejectCount; i++)
- {
- //获取不良代码组
- bgcode[i] = ChoosedRejectList.Items[i].SubItems[1].Text.Split(':')[0];
- //获取不良代码组名称
- bgname[i] = ChoosedRejectList.Items[i].SubItems[1].Text.Split(':')[1];
- //获取所有的不良代码
- bccode[i] = ChoosedRejectList.Items[i].SubItems[2].Text;
- //获取不良名称
- bcname[i] = ChoosedRejectList.Items[i].SubItems[3].Text;
- //获取所有的不良备注
- bcremark[i] = bc_remark.Text;
- }
- }
-
- //如果之前是良品的
- dt = dh.getFieldsDataByCondition("makeserial", new string[] { "ms_status", "ms_checkno", "ms_outboxcode" }, "ms_id='" + oMSID + "' and ms_stepcode='" + User.CurrentStepCode + "'");
- if (dt.Rows.Count > 0)
- {
- string status = dt.Rows[0]["ms_status"].ToString();
- string outboxcode = dt.Rows[0]["ms_outboxcode"].ToString();
- if (outboxcode != "")
- {
- OperateResult.AppendText(">>序列号:" + ms_sncode.Text + "已装箱,请先进行拆箱\n", Color.Red);
- BaseUtil.CleanForm(this);
- return;
- }
- if (status == "1" || status == "2")
- {
- dh.UpdateByCondition("steppassed", "sp_result='不良品',sp_date = sysdate,sp_ifng=-1,sp_ymd=to_char(sysdate,'yyyymmdd'),sp_hm=to_char(sysdate,'hh24miss')", "sp_id=(select max(sp_id) from steppassed where sp_sncode='" + ms_sncode.Text + "')");
- dh.UpdateByCondition("makecraftdetail", "mcd_okqty=mcd_okqty-1", "mcd_macode='" + ma_code.Text + "' and mcd_stepcode='" + User.CurrentStepCode + "'");
- dh.UpdateByCondition("makeserial", "ms_nextstepcode='',ms_badtimes=nvl(ms_badtimes,0)+1", "ms_id='" + oMSID + "'");
- LogicHandler.InsertMakeProcess(ms_sncode.Text, ma_code.Text, User.UserSourceCode, "良品采集成不良", "测试不良", biduisn.Text == "" ? User.UserCode : biduisn.Text);
- LogicHandler.DoCommandLog(Tag.ToString(), biduisn.Text == "" ? User.UserCode : biduisn.Text, ma_code.Text, User.UserLineCode, User.UserSourceCode, "测试不良", "良品采集成不良", ms_sncode.Text, ob_checkno.Text);
- }
- string checkno = dt.Rows[0]["ms_checkno"].ToString();
- //存在抽检批次更新为空
- if (checkno != "")
- dh.UpdateByCondition("makeserial", "ms_checkno=''", "ms_id='" + oMSID + "'");
- }
- else
- {
- LogicHandler.InsertMakeProcess(ms_sncode.Text, ma_code.Text, User.UserSourceCode, "采集成不良", "测试不良", biduisn.Text == "" ? User.UserCode : biduisn.Text);
- LogicHandler.DoCommandLog(Tag.ToString(), biduisn.Text == "" ? User.UserCode : biduisn.Text, ma_code.Text, User.UserLineCode, User.UserSourceCode, "采集成不良", "测试不良", ms_sncode.Text, ob_checkno.Text);
- }
- //不良信息采集,mb_status<>0的是之前维修保存的,不能删除
- dh.ExecuteSql("delete from makebad where mb_sncode='" + ms_sncode.Text + "' and mb_makecode='" + ma_code.Text + "' and nvl(mb_status,0)=0", "delete");
- //normalButton1_Click(this, e);
- if (LogicHandler.SetTestNGDetail(ms_sncode.Text, ma_code.Text, biduisn.Text == "" ? User.UserCode : biduisn.Text, User.UserSourceCode, "检查未通过", bgcode, bccode, bgname, bcname, bcremark, out ErrorMessage))
- {
- for (int i = 0; i < bccode.Length; i++)
- {
- if (dh.CheckExist("badgroupdetail left join badgroup on bgd_bgid = bg_id", "bgd_badcode = '" + bccode[i] + "' and bg_code = '" + bgcode[i] + "' and bgd_brcode is not null and bgd_dutycode is not null and bgd_solutioncode is not null "))
- {
- string makebadid = dh.getFieldDataByCondition("makebad", "mb_id", "mb_sncode = '" + ms_sncode.Text + "' and mb_makecode = '" + ma_code.Text + "' and mb_badcode = '" + bccode[i] + "' order by mb_id desc").ToString();
- DataTable temp = dh.getFieldsDatasByCondition(" badgroupdetail left join badgroup on bgd_bgid = bg_id left join QUA_NGReason on nr_code = bgd_brcode left join QUA_NGReasonGroup on nrg_code = bgd_brgcode left join NGDuty on nd_code = bgd_dutycode left join solution on so_code = bgd_solutioncode", new string[] { "bgd_brgcode", "bgd_dutycode", "bgd_solutioncode", "bgd_brcode", "nrg_name", "nr_name", "nd_name", "so_name" }, "bgd_badcode= '" + bccode[i] + "' and bg_code = '" + bgcode[i] + "'");
- string bgd_brgcode = temp.Rows[0]["bgd_brgcode"].ToString();
- string bgd_brcode = temp.Rows[0]["bgd_brcode"].ToString();
- string bgd_dutycode = temp.Rows[0]["bgd_dutycode"].ToString();
- string bgd_solutioncode = temp.Rows[0]["bgd_solutioncode"].ToString();
- string mbr_id = dh.GetSEQ("makebadreason_seq");
- string bgd_brgname = temp.Rows[0]["nrg_name"].ToString();
- string bgd_brname = temp.Rows[0]["nr_name"].ToString();
- string bgd_dutyname = temp.Rows[0]["nd_name"].ToString();
- string bgd_solutionname = temp.Rows[0]["so_name"].ToString();
- sql.Clear();
- sql.Append("insert into makebadreason (mbr_mbid,mbr_id,mbr_brcode,mbr_solutioncode,");
- sql.Append("mbr_dutycode,mbr_brgcode,mbr_badcode,mbr_sncode,mbr_makecode,mbr_indate,");
- sql.Append("mbr_inman,mbr_brname,mbr_solutionname,mbr_badname,mbr_brgname,mbr_dutyname) select '" + makebadid + "','" + mbr_id + "','" + bgd_brcode + "',");
- sql.Append("'" + bgd_solutioncode + "','" + bgd_dutycode + "','" + bgd_brgcode + "','" + bccode[i] + "',");
- sql.Append("'" + ms_sncode.Text + "','" + ma_code.Text + "',sysdate,'" + User.UserCode + "','" + bgd_brname + "','" + bgd_solutionname + "','" + bcname[i] + "','" + bgd_brgname + "','" + bgd_dutyname + "' from dual");
- dh.ExecuteSql(sql.GetString(), "insert");
- }
- }
- OperateResult.AppendText(">>" + ms_sncode.Text + "成功采集为不良\n", Color.OrangeRed);
- lastsn.Text = ms_sncode.Text;
- lastresult.Text = "FAILED";
- lastresult.BackColor = Color.Red;
- LastSncode = ms_sncode.Text;
- //采集完不良,聚焦序列号
- ms_sncode.Focus();
- //记录操作日志
- ms_sncode.Text = "";
- //清除不良信息
- bc_code.Text = "";
- biduisn.Text = "";
- oth.Text = "";
- ChoosedRejectList.Items.Clear();
- LoadCollectedNum();
- WaitList.Clear();
- ChoosedList.Clear();
- }
- else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
- }
- }
- private void bc_code_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- sql.Clear();
- sql.Append("select bg_code||':'||bg_name bg_code,bc_code,bc_name,'' bc_remark from badgroupdetail left join ");
- sql.Append("badgroup on bg_id=bgd_bgid left join badcode on bgd_badcode = bc_code where bc_code='" + bc_code.Text + "' and rownum=1 ");
- DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- if (dt.Rows.Count > 0)
- {
- for (int i = 0; i < ChoosedRejectList.Items.Count; i++)
- {
- if (ChoosedRejectList.Items[i].ListView.Items[i].SubItems[2].Text == bc_code.Text)
- {
- OperateResult.AppendText(">>已添加过不良代码" + bc_code.Text + "\n", Color.Red, bc_code);
- return;
- }
- }
- ListViewItem lvi = new ListViewItem();
- lvi.Text = "";
- for (int j = 0; j < dt.Columns.Count; j++)
- lvi.SubItems.Add(dt.Rows[0][j].ToString());
- ChoosedRejectList.Items.Add(lvi);
- bc_code.Clear();
- }
- else OperateResult.AppendText(">>" + bc_code.Text + "不良代码不存在\n", Color.Red, bc_code);
- }
- }
- private void LoadCheckQTY()
- {
- sql.Clear();
- string condition = "";
- int nowcheckqty = int.Parse(ob_nowcheckqty.Text == "" ? "0" : ob_nowcheckqty.Text);
- int batchqty = int.Parse(ob_batchqty.Text == "" ? "0" : ob_batchqty.Text);
- if (nowcheckqty + 1 == batchqty && AutoCut)
- {
- condition = "and ob_status='UNCHECK' and ob_checkno='" + ob_checkno.Text + "'";
- }
- else
- {
- condition = "and ob_status='ENTERING' ";
- }
- if (pr_sendchecktype.Text == "SaleCode")
- {
- condition += " and ob_salecode='" + ma_salecode.Text + "'";
- }
- sql.Append("select ob_batchqty,ob_nowcheckqty,ob_checkno from oqcbatch where ");
- sql.Append("ob_linecode='" + User.UserLineCode + "' and ob_inman = '"+User.UserCode+"' and ob_prodcode='" + ma_prodcode.Text + "' and ");
- sql.Append("ob_stepcode='" + User.CurrentStepCode + "' " + condition);
- DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- if (dt.Rows.Count > 0)
- {
- ob_sendqty.Text = dh.getFieldDataByCondition("oqcbatchdetail left join oqcbatch on obd_checkno = ob_checkno", "count(obd_sncode)", "obd_makecode='" + ma_code.Text + "' and ob_status<>'ENTERING'").ToString();
- ob_batchqty.Text = dt.Rows[0]["ob_batchqty"].ToString();
- ob_nowcheckqty.Text = dt.Rows[0]["ob_nowcheckqty"].ToString();
- ob_checkno.Text = dt.Rows[0]["ob_checkno"].ToString();
- nowcheckqty = int.Parse(ob_nowcheckqty.Text == "" ? "0" : ob_nowcheckqty.Text);
- batchqty = int.Parse(ob_batchqty.Text == "" ? "0" : ob_batchqty.Text);
- if (nowcheckqty == batchqty)
- {
- //ob_nowcheckqty.ForeColor = Color.Red;
- OperateResult.AppendText(">>当前采集数量已达到送检数量\n", Color.Black);
- if (AutoCut)
- {
- OperateResult.AppendText(">>批次" + ob_checkno.Text + "自动送检成功\n", Color.Blue);
- }
- }
- }
- else
- {
- BaseUtil.CleanControlsText(ob_batchqty, ob_nowcheckqty, ob_checkno);
- SendCheck.Enabled = false;
- }
- if (ob_batchqty.Text != "")
- {
- SendCheck.Enabled = true;
- }
- else
- {
- SendCheck.Enabled = false;
- }
- }
- private void GoodProduct_CheckedChanged(object sender, EventArgs e)
- {
- if (GoodProduct.Checked)
- {
- bc_code.Enabled = false;
- WaitReject.Enabled = false;
- ChooseedReject.Enabled = false;
- Save.Visible = false;
- }
- else
- {
- bc_code.Enabled = true;
- WaitReject.Enabled = true;
- ChooseedReject.Enabled = true;
- Save.Visible = true;
- }
- if (ms_sncode.Text == "")
- {
- ms_sncode.Focus();
- }
- if (khcheck.Checked&& GoodProduct.Checked)
- {
- oth.Focus();
- }
- }
- private void SendCheck_Click(object sender, EventArgs e)
- {
- sql.Clear();
- sql.Append("update oqcbatch set ob_status='UNCHECK',ob_breakingdate=sysdate where ob_checkno ='" + ob_checkno.Text + "'");
- dh.ExecuteSql(sql.GetString(), "select");
- ob_sendqty.Text = dh.getFieldDataByCondition("oqcbatchdetail left join oqcbatch on obd_checkno = ob_checkno", "count(obd_sncode)", "obd_makecode='" + ma_code.Text + "' and ob_status<>'ENTERING'").ToString();
- ob_nowcheckqty.Text = "";
- ob_batchqty.Text = "";
- ob_nowcheckqty.ForeColor = Color.Black;
- SendCheck.Enabled = false;
- OperateResult.AppendText(">>批次" + ob_checkno.Text + "送检成功\n", Color.Blue);
- ms_sncode.Focus();
- LogicHandler.InsertMakeProcess(LastSncode, ma_code.Text, User.UserSourceCode, "手动送检", "手动送检成功", User.UserCode);
- //记录操作日志
- LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "手动送检", "手动送检成功", "", ob_checkno.Text);
- ob_checkno.Text = "";
- }
- private void ob_checkno_TextChanged(object sender, EventArgs e)
- {
- if (ob_checkno.Text != "")
- {
- string Cut = dh.getFieldDataByCondition("product left join oqcbatch on ob_prodcode=pr_code", "pr_ifautocutcheckno", "ob_checkno='" + ob_checkno.Text + "'").ToString();
- if (Cut == "" || Cut == "0")
- AutoCut = false;
- else
- AutoCut = true;
- SendCheck.Enabled = true;
- }
- }
- /// <summary>
- /// 工单变化修改数量
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ma_code_UserControlTextChanged(object sender, EventArgs e)
- {
- if (ma_code.Text.Length > 4)
- {
- BaseUtil.CleanControlsText(mcd_inqty, mcd_remainqty, ob_batchqty, ob_nowcheckqty, ob_sendqty);
- LoadCollectedNum();
- LoadCheckQTY();
- }
- }
- private void Make_TestCollection_FormClosing(object sender, FormClosingEventArgs e)
- {
- //BaseUtil.ClosePrint(lbl);
- //if (engine != null)
- // engine.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges);
- dh.Dispose();
- }
-
- private void ma_prodcode_TextChanged(object sender, EventArgs e)
- {
- LoadBadGroupData();
- if (dh.CheckExist("product", "pr_code = '" + ma_prodcode.Text + "' and pr_trydays = -1")&&dh.CheckExist("step","st_code = '"+User.CurrentStepCode+ "' and st_ifspc = -1"))
- {
- khcheck.Checked = true;
- }else
- {
- khcheck.Checked = false;
- }
- }
- private void Filter_UserControlTextChanged(object sender, EventArgs e)
- {
- try
- {
- DataRow[] dr = (BadInfSource.DataSource as DataTable).Select("bc_code like '%" + Filter.Text + "%' or bc_name like '%" + Filter.Text + "%'");
- DataTable dt = (BadInfSource.DataSource as DataTable).Clone();
- for (int i = 0; i < dr.Length; i++)
- {
- dt.Rows.Add(dr[i].ItemArray);
- }
- WaitRejectList.Items.Clear();
- WaitRejectList.BeginUpdate();
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- if (!ChoosedList.Contains(dt.Rows[i]["bc_code"].ToString()))
- {
- ListViewItem lvi = new ListViewItem();
- //第一列是勾选列,设置列头文本为空
- lvi.Text = "";
- WaitList.Add(dt.Rows[i]["bc_code"].ToString());
- for (int j = 0; j < dt.Columns.Count; j++)
- lvi.SubItems.Add(dt.Rows[i][j].ToString());
- WaitRejectList.Items.Add(lvi);
- }
- }
- WaitRejectList.EndUpdate();
- }
- catch (Exception)
- {
- }
- }
- private void WaitRejectList_DoubleClick(object sender, EventArgs e)
- {
- for (int i = WaitRejectList.Items.Count - 1; i >= 0; i--)
- {
- if (WaitRejectList.Items[i].Checked)
- {
- //双击右移
- ChooseedReject.PerformClick();
- }
- }
- }
- private void Make_TestCollection_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.Modifiers == Keys.Control && e.KeyCode == Keys.Q)
- {
- if (!LockSn)
- {
- ControlLockTimer.Start();
- LockSn = true;
- Lock_label.Visible = true;
- }
- else
- {
- ControlLockTimer.Stop();
- LockSn = false;
- Lock_label.Visible = false;
- }
- }
- }
- //创建打印进程
- private void NewPrint()
- {
- try
- {
- // engine = new BarTender.Application();
- lbl = new ApplicationClass();
- BaseUtil.WriteLbl();
- }
- catch (Exception ex)
- {
- OperateResult.AppendText("未正确安装CodeSoft软件\n" + ex.Message, Color.Red);
- }
- }
- private void normalButton1_Click(object sender, EventArgs e)
- {
- //if (ChoosedRejectList.Items.Count == 0 || ms_sncode.Text == "")
- //{
- // MessageBox.Show("未录入不良或SN为空");
- //}
- //string BADINFO = "";
- //for (int i = 0; i < ChoosedRejectList.Items.Count; i++)
- //{
- // BADINFO = BADINFO + ChoosedRejectList.Items[i].ListView.Items[i].SubItems[3].Text + " ";
- //}
- //BADINFO = BADINFO.Substring(0, BADINFO.Length - 1);
- //FileInfo PrintFile = new FileInfo(labelname);
- //if (!PrintFile.Exists)
- //{
- // MessageBox.Show("打印文件不存在");
- // return ;
- //}
- //doc = lbl.Documents.Open(labelname, true);
- //if (doc == null)
- //{
- // MessageBox.Show("标签文件打开失败");
- // return ;
- //}
- //for (int j = 1; j < doc.Variables.FormVariables.Count+1; j++)
- //{
- // switch (doc.Variables.FormVariables.Item(j).Name)
- // {
- // case "SN":
- // doc.Variables.FormVariables.Item(j).Value = ms_sncode.Text;
- // break;
- // case "BAD":
- // doc.Variables.FormVariables.Item(j).Value = BADINFO;
- // break;
- // }
- // // doc.Variables.FormVariables.Item(1).Value = (Prefix.Text + Date.Value.ToString("yyMMdd") + lpad(4, (i).ToString()));
- //}
- ////保存本次赋值进行打印
- //doc.Printer.SwitchTo(PrintList.Text);
- //doc.PrintDocument(1);
- }
- private void StartWatch_Click(object sender, EventArgs e)
- {
- if (FolderPath.Text == "")
- {
- OperateResult.AppendText("请选择监控文件夹\n");
- return;
- }
- else
- {
- if (!Directory.Exists(FolderPath.Text))
- {
- OperateResult.AppendText("监控文件夹不存在\n");
- return;
- }
- }
- XmlWatcher.Path = FolderPath.Text;
- XmlWatcher.Filter = "SN Writer.log";
- XmlWatcher.EnableRaisingEvents = true;
- //设置缓存数据
- BaseUtil.SetCacheData("FolderPath", FolderPath.Text);
- //设置按钮不可点击
- StartWatch.Enabled = false;
- ChooseFolder.Enabled = false;
- StopWatch.Enabled = true;
- OperateResult.AppendText("开始执行监控\n");
- }
- private void StopWatch_Click(object sender, EventArgs e)
- {
- XmlWatcher.EnableRaisingEvents = false;
- StartWatch.Enabled = true;
- ChooseFolder.Enabled = true;
- StopWatch.Enabled = false;
- OperateResult.AppendText("停止执行监控\n");
- }
- private void XmlWatcher_Created(object sender, FileSystemEventArgs e)
- {
- while (true)
- {
- try
- {
- using (Stream stream = File.Open(e.FullPath, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite))
- {
- if (stream != null)
- break;
- }
- }
- catch (Exception ex)
- {
- Console.WriteLine(ex.Message);
- }
- }
- StreamReader _Sr = new StreamReader(FolderPath.Text + @"\" + e.Name, Encoding.UTF8);
- String[] strData;
- string line;
- string ssn = "";
- string imei = "";
- string imei1 = "";
- string bt = "";
- string mac = "";
- try
- {
- while ((line = _Sr.ReadLine()) != null)
- {
- if (line.Contains("Barcode[0]"))
- {
- Regex regex = new Regex("\"[^\"]*\"");
- ssn = regex.Match(line).Value.Replace("\"", "");
- }
- else if (line.Contains("Prod_Info->IMEI[0]"))
- {
- strData = line.Replace("\r", "").Replace("\n", "").Replace("\t", "").Split('=');
- Regex regex = new Regex("\\[[^*]+\\]");
- imei = regex.Match(strData[1]).Value.Replace("[", "").Replace("]", "");
- }
- else if (line.Contains("Prod_Info->IMEI[1]"))
- {
- strData = line.Replace("\r", "").Replace("\n", "").Replace("\t", "").Split('=');
- Regex regex = new Regex("\\[[^*]+\\]");
- imei1 = regex.Match(strData[1]).Value.Replace("[", "").Replace("]", "");
- }
- else if (line.Contains("Prod_Info->BtAddress"))
- {
- strData = line.Replace("\r", "").Replace("\n", "").Replace("\t", "").Split('=');
- Regex regex = new Regex("\\[[^*]+\\]");
- bt = regex.Match(strData[1]).Value.Replace("[", "").Replace("]", "");
- }
- else if (line.Contains("Prod_Info->WiFiAddress"))
- {
- strData = line.Replace("\r", "").Replace("\n", "").Replace("\t", "").Split('=');
- Regex regex = new Regex("\\[[^*]+\\]");
- mac = regex.Match(strData[1]).Value.Replace("[", "").Replace("]", "");
- }
- }
- if (ssn != "")
- {
- ms_sncode.Text = ssn;
- ms_code_KeyDown(this, new KeyEventArgs(Keys.Enter));
- if (imei!="")
- {
- dh.ExecuteSql("update makeserial set ms_imei = '"+imei+"' where ms_sncode = '"+ ssn + "' and ms_makecode = '"+ma_code.Text+"'", "update");
- }
- if (imei1 != "")
- {
- dh.ExecuteSql("update makeserial set ms_imei1 = '" + imei1 + "' where ms_sncode = '" + ssn + "' and ms_makecode = '" + ma_code.Text + "'", "update");
- }
- if (bt != "")
- {
- dh.ExecuteSql("update makeserial set ms_bt = '" + bt + "' where ms_sncode = '" + ssn + "' and ms_makecode = '" + ma_code.Text + "'", "update");
- }
- if (mac != "")
- {
- dh.ExecuteSql("update makeserial set ms_mac = '" + mac + "' where ms_sncode = '" + ssn + "' and ms_makecode = '" + ma_code.Text + "'", "update");
- }
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- _Sr.Close();
- }
- _Sr.Close();
- }
- private void ChooseFolder_Click(object sender, EventArgs e)
- {
- FolderBrowserDialog folder = new FolderBrowserDialog();
- folder.Description = "选择监控文件夹";
- DialogResult result = folder.ShowDialog();
- if (result == DialogResult.OK)
- {
- FolderPath.Text = folder.SelectedPath;
- }
- }
- private void biduisn_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- if (bidui.Checked&&biduisn.Text!="")
- {
- ms_sncode.Focus();
- ms_sncode.SelectAll();
- }
- }
- }
- private void bc_code_KeyUp(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Add && Save.Visible)
- {
- Save_Click(sender, e);
- bc_code.Clear();
- }
- }
- private void oth_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- if (oth.Text != "")
- {
- ms_sncode.Focus();
- ms_sncode.SelectAll();
- }
- }
- }
- }
- }
|