123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941 |
- 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;
- using DevExpress.XtraSpellChecker;
- namespace UAS_MES_NEW.Make
- {
- public partial class Make_TestCollectionCL : 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_TestCollectionCL()
- {
- 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_code.FormName = Name;
- ma_code.SetValueField = new string[] { "ma_code", "ma_prodcode", "ma_qty", "pr_orispeccode pr_spec"};
- ma_code.Condition = "ma_statuscode='STARTED' order by ma_date desc";
- ma_code.DbChange += Ma_code_DbChange;
- dh = SystemInf.dh;
- mm_prodcode.TableName = "MakeMaterial left join make on mm_maid=ma_id left join Product on mm_prodcode=pr_code";
- mm_prodcode.SelectField = "mm_prodcode # 材料编号,pr_detail # 材料名称,pr_orispeccode # 材料型号";
- mm_prodcode.FormName = Name;
- mm_prodcode.Condition = " 1= 2";
- mm_prodcode.SetValueField = new string[] { "mm_prodcode", "pr_detail mmpr_detail", "pr_orispeccode mm_prorispeccode" };
- mm_prodcode.DbChange += Ma_code_DbChange1;
- }
- 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();
- }
- private void Ma_code_DbChange1(object sender, EventArgs e)
- {
- Dbfind = mm_prodcode.ReturnData;
- BaseUtil.SetFormValue(this.Controls, Dbfind);
- //LoadBadGroupData();
- LoadCollectedNum();
- }
- /// <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;
- //}
- if (ma_code.Text == "" || mm_prodcode.Text == "")
- {
- OperateResult.AppendText(">>工单号材料号不可为空\n", Color.Red, ms_sncode);
- return;
- }
- String priex = dh.getFieldDataByCondition("product", "pr_oriname", "pr_code = '"+mm_prodcode.Text+"'").ToString();
- if (priex == "")
- {
- OperateResult.AppendText(">>材料编号" + mm_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 : ms_sncode.Text.Contains(pres[i]))
- {
- //满足其中一条即可
- f = true;
- break;
- }
- }
- if (!f)
- {
- OperateResult.AppendText(">>原材料号"+ms_sncode.Text+"不符合防呆要求\n", Color.Red, ms_sncode);
- return;
- }
- ChoosedRejectList.Items.Clear();
- WaitList.Clear();
- ChoosedList.Clear();
- if (dh.CheckExist("lcdcheck", "lc_sncode = '" + ms_sncode.Text + "' and LC_VALI = 0"))
- {
- string lcstatus = dh.getFieldDataByCondition("lcdcheck", "lc_status", "lc_sncode = '" + ms_sncode.Text + "' and LC_VALI = 0").ToString();
- if (lcstatus.Equals("0") != GoodProduct.Checked)
- {
- string ChangeMakeCode = System.Windows.Forms.MessageBox.Show("原材料" + ms_sncode.Text + "已存在不同采集记录,是否更新?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
- //如果选择不切换赋值当前界面工单
- if (ChangeMakeCode != "Yes")
- {
- ms_sncode.Clear();
- return;
- }
- }
- else
- {
- OperateResult.AppendText(">>原材料号" + ms_sncode.Text + "已存在相同采集记录\n", Color.Red, ms_sncode);
- return;
- }
- }
- 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 from make left join product on ma_prodcode=pr_code where ma_code='" + ma_code.Text + "'", "select");
- if (dt.Rows.Count > 0)
- {
- BaseUtil.SetFormValue(this.Controls, dt);
- LockMakeCode.Checked = true;
- }
- SetCollectResult();
- }
- }
- 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)
- {
- LastSncode = ms_sncode.Text;
- lastsn.Text = ms_sncode.Text;
- lastresult.Text = "OK";
- lastresult.BackColor = Color.Green;
- dh.ExecuteSql(" update lcdcheck set LC_VALI = -1 where lc_sncode = '" + ms_sncode.Text + "' ", "update");
- dh.ExecuteSql(" insert into lcdcheck (lc_id,lc_sncode,lc_status,lc_indate,lc_inman,lc_makecode,lc_prodcode,LC_SOURCECODE) " +
- " values (lcdcheck_seq.nextval,'"+ms_sncode.Text+"',0,sysdate,'"+User.UserCode+"','"+ma_code.Text+"','"+ mm_prodcode.Text + "','"+User.UserSourceCode+"') ", "insert");
- LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "原材料检验", "原材料检验良品", ms_sncode.Text, "");
- OperateResult.AppendText(">>SN:" + ms_sncode.Text + "原材料检验良品\n", Color.Green, ms_sncode);
- }
- //加载页面信息
- LoadCollectedNum();
- }
-
- 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");
- dt = (DataTable)dh.ExecuteSql(" select count(1) mcd_inqty,sum(case when lc_status = 0 then 1 else 0 end) mcd_okqty,sum(case when lc_status = -1 then 1 else 0 end) mcd_ngqty from lcdcheck " +
- "where lc_makecode = '"+ma_code.Text+"' and lc_prodcode = '"+mm_prodcode.Text+ "' and LC_VALI = 0 ", "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)
- {
- //判断界面工单是否为空时的序列号是否自动归属工单
- string oStatus = "";
- 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='" + ma_code.Text + "'", "select");
- if (dt.Rows.Count > 0)
- {
- BaseUtil.SetFormValue(this.Controls, dt);
- LockMakeCode.Checked = true;
- }
- 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;
- }
- }
- dh.ExecuteSql(" update lcdcheck set LC_VALI = -1 where lc_sncode = '" + ms_sncode.Text + "' ", "update");
- dh.ExecuteSql(" insert into lcdcheck (lc_id,lc_sncode,lc_status,lc_indate,lc_inman,lc_makecode,lc_prodcode,lc_badcode,lc_badname,lc_bgcode,lc_bgname,LC_SOURCECODE) " +
- " values (lcdcheck_seq.nextval,'" + ms_sncode.Text + "',-1,sysdate,'" + User.UserCode + "','" + ma_code.Text + "','" + mm_prodcode.Text + "','" + bccode[0] + "','" + bcname[0] + "','" + bgcode[0] + "','" + bgname[0] +"','"+User.UserSourceCode+"') ", "insert");
- LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "原材料检验", "原材料检验不良", ms_sncode.Text, "");
- lastsn.Text = ms_sncode.Text;
- lastresult.Text = "FAILED";
- lastresult.BackColor = Color.Red;
- LastSncode = ms_sncode.Text;
- OperateResult.AppendText(">>SN:" + ms_sncode.Text + "原材料检验不良\n", Color.OrangeRed, ms_sncode);
- //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);
- //采集完不良,聚焦序列号
- ms_sncode.Focus();
- //记录操作日志
- ms_sncode.Text = "";
- //清除不良信息
- bc_code.Text = "";
- biduisn.Text = "";
- if (bidui.Checked)
- {
- biduisn.Focus();
- }
- 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 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();
- }
- }
-
- private void ob_checkno_TextChanged(object sender, EventArgs e)
- {
- }
- /// <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_ngqty,mcd_okqty, mm_prodcode,mmpr_detail,mm_prorispeccode);
- mm_prodcode.Condition = "mm_code = '" + ma_code.Text + "' order by mm_prodcode desc";
- LoadCollectedNum();
- }
- }
- 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();
- }
- 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 mm_prodcode_UserControlTextChanged(object sender, EventArgs e)
- {
- }
- }
- }
|