123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125 |
- using System;
- using System.Data;
- using System.Text;
- using System.Threading;
- using System.Drawing;
- using System.Windows.Forms;
- using UAS_MES.DataOperate;
- using UAS_MES.Entity;
- using UAS_MES.PublicMethod;
- using System.Collections.Generic;
- using UAS_MES.CustomControl.PowerControlForm;
- namespace UAS_MES.Make
- {
- public partial class Make_SmtbdTestCollection : Form
- {
- DataHelper dh = null;
- DataTable dt = null;
- //当前工序的名称
- string ErrorMessage = "";
- //用于保存是否之前输入的ms_sncode
- string LastSncode;
- string oMakeCode = "";
- string oMSID = "";
- string ifrework = "";
- string reworkstatus = "";
- string status = "";
- LogStringBuilder sql = new LogStringBuilder();
- AutoSizeFormClass asc = new AutoSizeFormClass();
- /// <summary>
- /// 已选的不良
- /// </summary>
- List<string> ChoosedList = new List<string>();
- /// <summary>
- /// 待选的不良
- /// </summary>
- List<string> WaitList = new List<string>();
- //当前工序对应版面
- string st_table = "";
- bool AutoCut = false;
- bool LockSn = false;
- string ms_nextstepcode;
- string UserSourceCode = "";
- DataTable Dbfind;
- public Make_SmtbdTestCollection()
- {
- InitializeComponent();
- }
- private void TestCollection_Load(object sender, EventArgs e)
- {
- dh = SystemInf.dh;
- Reject.Checked = true;
- asc.controllInitializeSize(this);
- ms_sncode.Focus();
- //设置锁定工单
- LockMakeCode.GetMakeCodeCtl(ma_code);
- ma_code.SetLockCheckBox(LockMakeCode);
- ControlLockTimer.Tick += ControlLockTimer_Tick;
- ControlLockTimer.Interval = 100;
- bd_soncode.FormName = Name;
- bd_soncode.TableName = "(with temp1 as (select bd_fsoncode,bd_soncode,bd_location,pr_spec,pr_detail from bomdetail innner join bom on bo_id=bd_bomid left join product on bd_soncode = pr_code start with bo_mothercode = '" + ma_prodcode.Text + "' connect by bo_mothercode = prior bd_soncode)select* from temp1)";
- bd_soncode.SetValueField = new string[] { "bd_soncode" };
- bd_soncode.SelectField = "bd_fsoncode # 首选料号,bd_soncode # 子件编号,pr_detail # 物料名称,pr_spec # 物料规格,bd_location # 位号";
- bd_soncode.DBTitle = "不良零件";
- bd_soncode.DbChange += Prodcode_DbChange;
- //工单号放大镜配置
- ma_code.TableName = "make left join product on ma_prodcode=pr_code";
- ma_code.SelectField = "ma_code # 工单号,ma_prodcode # 产品编号,ma_qty # 工单数量,pr_detail # 产品名称,ma_softversion # 软件版本,ma_salecode # 销售单号,pr_sendchecktype # 产品送检方式";
- ma_code.FormName = Name;
- ma_code.SetValueField = new string[] { "ma_code", "ma_prodcode", "ma_qty", "pr_detail", "ma_softversion", "ma_salecode", "nvl(pr_sendchecktype,'LineCode')pr_sendchecktype" };
- ma_code.Condition = "ma_statuscode='STARTED' and ma_wccode = 'SMT'";
- ma_code.DbChange += Ma_code_DbChange;
-
-
- }
- 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);
- LoadCollectedNum();
- LoadCheckQTY();
- }
- /// <summary>
- /// 将已选不良移动到待选不良
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void WaitReject_Click(object sender, EventArgs e)
- {
- Boolean HaveReject = false;
- for (int i = MakeBadView.Rows.Count - 1; i >= 0; i--)
- {
- if (MakeBadView.Rows[i].Cells["choose1"].Value != null)
- {
- if ((Boolean)MakeBadView.Rows[i].Cells["choose1"].Value == true)
- {
- HaveReject = true;
- break;
- }
- }
- }
- if (HaveReject)
- {
- string confirm = MessageBox.Show(this.ParentForm, "确认删除勾选的不良(已保存的不良代码也会删除)", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk).ToString();
- if (confirm == "Yes")
- {
- for (int i = MakeBadView.Rows.Count - 1; i >= 0; i--)
- {
- if (MakeBadView.Rows[i].Cells["choose1"].Value != null)
- {
- if ((Boolean)MakeBadView.Rows[i].Cells["choose1"].Value == true)
- {
- if (MakeBadView.Rows[i].Cells["mbr_id"].Value.ToString() != "")
- {
- List<string> SQLS = new List<string>();
- SQLS.Add("delete makebad where mb_id = '" + MakeBadView.Rows[i].Cells["mb_id"].Value.ToString() + "'");
- SQLS.Add("delete makebadreason where mbr_id = '" + MakeBadView.Rows[i].Cells["mbr_id"].Value.ToString() + "'");
- SQLS.Add("delete makebadrscom where mbc_mbrid = '" + MakeBadView.Rows[i].Cells["mbr_id"].Value.ToString() + "'");
- SQLS.Add("delete makebadrspart where mbp_mbrid = '" + MakeBadView.Rows[i].Cells["mbr_id"].Value.ToString() + "'");
- SQLS.Add("delete makebadrsloc where mbl_mbrid = '" + MakeBadView.Rows[i].Cells["mbr_id"].Value.ToString() + "'");
- dh.ExecuteSQLTran(SQLS.ToArray());
- }
- MakeBadView.Rows.RemoveAt(i);
- }
- }
- }
- (MakeBadView.DataSource as DataTable).AcceptChanges();
- }
- }
- HaveReject = false;
- }
- /// <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;
- }
- LoadChoosedBadListView();
- DataTable choose = (MakeBadView.DataSource as DataTable);
- List<string> Chooseed = new List<string>();
- for (int i = 0; i < MakeBadView.Rows.Count; i++)
- {
- Chooseed.Add(MakeBadView.Rows[i].Cells["mb_badcode"].Value.ToString());
- }
- if (WaitChooseDGV.Rows.Count > 0)
- {
- for (int i = 0; i < WaitChooseDGV.Rows.Count; i++)
- {
- if (WaitChooseDGV.Rows[i].Cells["ChooseAll"].Value != null)
- {
- if ((Boolean)WaitChooseDGV.Rows[i].Cells["ChooseAll"].Value == true)
- {
- if (!Chooseed.Contains(WaitChooseDGV.Rows[i].Cells["bc_code"].Value.ToString()))
- {
- DataRow dr1 = choose.NewRow();
- dr1["mb_badcode"] = WaitChooseDGV.Rows[i].Cells["bc_code"].Value.ToString();
- dr1["mb_badname"] = WaitChooseDGV.Rows[i].Cells["bc_name"].Value.ToString();
- dr1["mb_bgname"] = WaitChooseDGV.Rows[i].Cells["bg_name"].Value.ToString();
- dr1["mb_bgcode"] = WaitChooseDGV.Rows[i].Cells["bg_code"].Value.ToString();
- choose.Rows.Add(dr1);
- }
- else
- {
- OperateResult.AppendText(">>不良代码" + WaitChooseDGV.Rows[i].Cells["bc_code"].Value.ToString() + "已存在\n", Color.Red);
- }
- }
- }
- }
- for (int i = 0; i < WaitChooseDGV.Rows.Count; i++)
- {
- WaitChooseDGV.Rows[i].Cells["ChooseAll"].Value = false;
- }
- for (int i = 0; i < MakeBadView.Rows.Count; i++)
- {
- if (MakeBadView.Rows[i].Cells["mb_id"].Value.ToString() == "")
- {
- MakeBadView.Rows[i].Cells["choose1"].Value = true;
- }
- }
- }
- else 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)
- {
- BaseUtil.CleanDGVData(MakeBadView);
- 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, 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_detail,nvl(pr_sendchecktype,'LineCode')pr_sendchecktype,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;
- }
- }
- dt = (DataTable)dh.ExecuteSql("select nvl(ms_spi,0)ms_spi,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");
- ms_nextstepcode = dt.Rows[0]["ms_nextstepcode"].ToString();
- 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();
- int ms_spi = int.Parse(dt.Rows[0]["ms_spi"].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 (ms_spi != 0)
- {
- OperateResult.AppendText(">>" + ms_sncode.Text + "已采集过XRAY良品,无法重复采集\n", Color.Red, ms_sncode);
- return;
- }
- if (ifrework != "0")
- {
- if (stepcode == User.CurrentStepCode && (reworkstatus == "1" || reworkstatus == "2") && ifrepair == "0")
- {
- OperateResult.AppendText(">>" + ms_sncode.Text + "序列号已执行过" + User.CurrentStepCode + "工序,采集结果为良品\n", Color.Red, ms_sncode);
- return;
- }
- }
- else
- {
- if (stepcode == User.CurrentStepCode && (status == "1" || status == "2") && ifrepair == "0")
- {
- OperateResult.AppendText(">>" + ms_sncode.Text + "序列号已执行过" + User.CurrentStepCode + "工序,采集结果为良品\n", Color.Red, ms_sncode);
- return;
- }
- }
- }
- SetCollectResult();
- }
- else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, ms_sncode);
- }
- else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, ms_sncode);
- }
- }
- /// <summary>
- /// 加载不良代码的ListView的信息
- /// </summary>
- private void LoadBadCodeListView()
- {
- sql.Clear();
- sql.Append("select bg_code,bg_name ,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='" + User.DefaultBadGroup + "' and bg_code is not null order by bgd_detno");
- DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- BadInfSource.DataSource = dt;
- BaseUtil.FillDgvWithDataTable(WaitChooseDGV, dt);
- }
- /// <summary>
- /// 加载已选不良的ListView
- /// </summary>
- private void LoadChoosedBadListView()
- {
- sql.Clear();
- sql.Append("select mb_id,mbr_id,mb_badcode,mb_badname,mbc_component,mb_bgcode,mb_bgname,WM_CONCAT(distinct mbp_part) mbp_part,WM_CONCAT(distinct mbl_loc) mbl_loc ");
- sql.Append("from makebad left join makebadreason on mb_id = mbr_mbid left join makebadrscom on mbc_mbrid = mbr_id left join makebadrspart on MBP_MBRID =mbr_id left join makebadrsloc ");
- sql.Append(" on mbl_mbrid = mbr_id where mb_sncode ='" + ms_sncode.Text + "'AND MB_MAKECODE = '" + ma_code.Text + "' AND MB_STEPCODE = '" + User.CurrentStepCode + "' group by mb_id,mbr_id,mb_sncode,mb_badcode,mb_badname,mbc_component,mb_bgcode,mb_bgname");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- BaseUtil.FillDgvWithDataTable(MakeBadView, dt);
- }
- /// <summary>
- /// 设置良品或者不良品的采集结果
- /// </summary>
- private void SetCollectResult()
- {
- string ErrorMessage = "";
- //如果勾选的是不良品
- if (Reject.Checked)
- {
- LoadBadCodeListView();
- LoadChoosedBadListView();
- OperateResult.AppendText(">>请采集不良代码\n", Color.Green);
- //勾选了自动产生代码
- if (AutoBadCode.Checked)
- Save_Click(new object(), new EventArgs());
- }
- 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 (LogicHandler.SetStepResult(ma_code.Text, UserSourceCode, ms_sncode.Text, "良品采集", "检测合格", User.UserCode, out ErrorMessage))
- {
- //提示正确返回时传递的信息
- if (ErrorMessage.Contains("AFTERSUCCESS"))
- OperateResult.AppendText(">>" + ErrorMessage + "\n");
- LastSncode = ms_sncode.Text;
- dh.ExecuteSql("update makeserial set ms_spi = 1 where ms_sncode = '" + ms_sncode.Text + "' and ms_makecode = '" + ma_code.Text + "'", "update");
- OperateResult.AppendText(">>" + ms_sncode.Text + "良品采集成功\n", Color.Green, ms_sncode);
- //记录操作日志
- LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, UserSourceCode, "采集良品", "采集良品成功", LastSncode, ob_checkno.Text);
- }
- else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, ms_sncode);
- }
- }
- else
- {
- if (reworkstatus != "3")
- {
- if (LogicHandler.SetStepResult(ma_code.Text, 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);
- //记录操作日志
- LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, UserSourceCode, "采集良品", "采集良品成功", LastSncode, ob_checkno.Text);
- }
- else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, ms_sncode);
- }
- 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 from make left join makecraftdetail 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, UserSourceCode, ms_sncode.Text, User.UserCode, out oMakeCode, out oMSID, out ErrorMessage))
- {
- dt = (DataTable)dh.ExecuteSql("select ma_code,ma_prodcode,ma_softversion,pr_detail,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;
- }
- 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");
- ms_nextstepcode = dt.Rows[0]["ms_nextstepcode"].ToString();
- 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();
- }
- else
- {
- OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, ms_sncode);
- return;
- }
- dt = (DataTable)dh.ExecuteSql("SELECT * FROM BOMDetail LEFT JOIN Product ON bd_soncode=pr_code WHERE bd_mothercode = '" + ma_prodcode.Text + "'", "select");
- if (dt.Rows.Count > 0)
- {
- for (int i = 0; i < MakeBadView.Rows.Count; i++)
- {
- if (MakeBadView.Rows[i].Cells["mbl_loc"].Value.ToString() == "" || MakeBadView.Rows[i].Cells["mbp_part"].Value.ToString() == "")
- {
- OperateResult.AppendText(">>不良位置与不良零件均不可为空\n", Color.Red);
- return;
- }
- }
- }
- else
- {
- for (int i = 0; i < MakeBadView.Rows.Count; i++)
- {
- if (MakeBadView.Rows[i].Cells["mbl_loc"].Value.ToString() == "")
- {
- OperateResult.AppendText(">>不良位置不可为空\n", Color.Red);
- return;
- }
- }
- }
- List<string> bccode = new List<string>();
- List<string> bcremark = new List<string>();
- List<string> bgcode = new List<string>();
- List<string> bgname = new List<string>();
- List<string> bcname = new List<string>();
- bccode.Clear();
- bcremark.Clear();
- bgcode.Clear();
- bgname.Clear();
- bcname.Clear();
- if (MakeBadView.Rows.Count == 0)
- {
- OperateResult.AppendText(">>不良品必须选择不良原因和不良代码!\n", Color.Red);
- return;
- }
- else
- {
- for (int i = 0; i < MakeBadView.Rows.Count; i++)
- {
- if (MakeBadView.Rows[i].Cells["mb_id"].Value.ToString() == "")
- {
- //获取不良代码组
- bgcode.Add(MakeBadView.Rows[i].Cells["mb_bgcode"].Value.ToString());
- //获取不良代码组名称
- bgname.Add(MakeBadView.Rows[i].Cells["mb_bgname"].Value.ToString());
- //获取所有的不良代码
- bccode.Add(MakeBadView.Rows[i].Cells["mb_badcode"].Value.ToString());
- //获取不良名称
- bcname.Add(MakeBadView.Rows[i].Cells["mb_badname"].Value.ToString());
- //获取所有的不良备注
- bcremark.Add(bc_remark.Text);
- }
- }
- }
- //如果之前是良品的
- dt = dh.getFieldsDataByCondition("makeserial", new string[] { "ms_status", "ms_checkno" }, "ms_id='" + oMSID + "' and ms_stepcode='" + User.CurrentStepCode + "'");
- if (dt.Rows.Count > 0)
- {
- status = dt.Rows[0]["ms_status"].ToString();
- if (status == "1" || status == "2")
- {
- dh.UpdateByCondition("steppassed", "sp_result='不良品',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, "良品采集成不良", "测试不良", User.UserCode);
- LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, 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, "采集成不良", "测试不良", User.UserCode);
- LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode,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");
- if (LogicHandler.SetTestNGDetail(ms_sncode.Text, ma_code.Text, User.UserCode, User.UserSourceCode, "检查未通过", bgcode.ToArray(), bccode.ToArray(), bgname.ToArray(), bcname.ToArray(), bcremark.ToArray(), out ErrorMessage))
- {
- OperateResult.AppendText(">>" + ms_sncode.Text + "成功采集为不良\n", Color.Green);
- for (int i = 0; i < MakeBadView.Rows.Count; i++)
- {
- //获取当前序列号对应的不良代码编号
- string makebadid = dh.getFieldDataByCondition("makebad", "mb_id", "mb_sncode = '" + ms_sncode.Text + "' and mb_makecode = '" + ma_code.Text + "' and mb_badcode = '" + MakeBadView.Rows[i].Cells["mb_badcode"].Value.ToString() + "'").ToString();
- //为空插入不良代码表与不良原因表
- if (MakeBadView.Rows[i].Cells["mbr_id"].Value.ToString() == "")
- {
- DataTable temp = dh.getFieldsDatasByCondition(" BADGROUPDETAIL left join badgroup on bgd_bgid = bg_id", new string[] { "bgd_brgcode", "bgd_dutycode", "bgd_solutioncode", "bgd_brcode" }, "bgd_badcode= '" + MakeBadView.Rows[i].Cells["mb_badcode"].Value.ToString() + "' and bg_code = '" + MakeBadView.Rows[i].Cells["mb_bgcode"].Value.ToString() + "'");
- 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 = dh.getFieldDataByCondition("QUA_NGReasonGroup", "nrg_name", "nrg_code = '" + bgd_brgcode + "'").ToString();
- string bgd_brname = dh.getFieldDataByCondition("QUA_NGReason", "nr_name", "nr_code = '" + bgd_brcode + "'").ToString();
- string bgd_dutyname = dh.getFieldDataByCondition("NGDuty", "nd_name", "nd_code = '" + bgd_dutycode + "'").ToString();
- string bgd_solutionname = dh.getFieldDataByCondition("solution", "so_name", "so_code = '" + bgd_solutioncode + "'").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 + "','" + MakeBadView.Rows[i].Cells["mb_badcode"].Value.ToString() + "',");
- sql.Append("'" + ms_sncode.Text + "','" + ma_code.Text + "',sysdate,'" + User.UserCode + "','" + bgd_brname + "','" + bgd_solutionname + "','" + MakeBadView.Rows[i].Cells["mb_badname"].Value.ToString() + "','" + bgd_brgname + "','" + bgd_dutyname + "' from dual");
- dh.ExecuteSql(sql.GetString(), "insert");
- if (MakeBadView.Rows[i].Cells["mbc_component"].Value.ToString() != "")
- {
- sql.Clear();
- sql.Append("insert into makebadrscom (mbc_id,mbc_mbrid,mbc_component,mbc_badcode,");
- sql.Append("mbc_brcode,mbc_sncode,mbc_makecode,mbc_indate,mbc_inman ) values ");
- sql.Append("(makebadrscom_seq.nextval,'" + mbr_id + "' ,'" + MakeBadView.Rows[i].Cells["mbc_component"].Value.ToString() + "',");
- sql.Append("'" + MakeBadView.Rows[i].Cells["mb_badcode"].Value.ToString() + "','" + bgd_brcode + "','" + ms_sncode.Text + "','" + ma_code.Text + "',sysdate,'" + User.UserCode + "')");
- dh.ExecuteSql(sql.GetString(), "insert");
- }
-
- string[] mbl_loc = MakeBadView.Rows[i].Cells["mbl_loc"].Value.ToString().ToUpper().Split(',');
- sql.Clear();
- sql.Append("insert into makebadrsloc(mbl_id,mbl_mbrid,mbl_loc,mbl_badcode,mbl_brcode,");
- sql.Append("mbl_sncode,mbl_makecode,mbl_indate ,mbl_inman) select makebadrsloc_seq.nextval," + mbr_id);
- sql.Append(",:mbl_loc,'" + MakeBadView.Rows[i].Cells["mb_badcode"].Value.ToString() + "','" + bgd_brcode + "','" + ms_sncode.Text + "','" + ma_code.Text + "',");
- sql.Append("sysdate,'" + User.UserCode + "' from dual");
- dh.BatchInsert(sql.GetString(), new string[] { "mbl_loc" }, mbl_loc);
- //sql.Clear();
- //sql.Append("with temp1 as (select bd_soncode,bd_location from bomdetail,bom where bo_id=bd_bomid ");
- //sql.Append(" start with bo_mothercode='" + ma_prodcode.Text + "' connect by bo_mothercode= prior bd_soncode) ");
- //sql.Append("select bd_soncode from temp1 where instr(','||bd_location||',','," + MakeBadView.Rows[i].Cells["mbl_loc"].Value.ToString().ToUpper() + ",')>0");
- //dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- //if (dt.Rows.Count > 0)
- //{
- // for (int j = 0; j < dt.Rows.Count; i++)
- // {
- // sql.Clear();
- // sql.Append("insert into makebadrspart(mbp_id,mbp_mbrid,mbp_part,mbp_badcode,");
- // sql.Append("mbp_brcode,mbp_sncode,mbp_makecode,mbp_indate,mbp_inman)");
- // sql.Append("select makebadrspart_seq.nextval," + mbr_id + ",'" + dt.Rows[0][j].ToString() + "',");
- // sql.Append("'" + MakeBadView.Rows[i].Cells["mb_badcode"].Value.ToString() + "','" + bgd_brcode + "','" + ms_sncode.Text + "','" + ma_code.Text + "',");
- // sql.Append("sysdate,'" + User.UserCode + "' from dual");
- // dh.ExecuteSql(sql.GetString(), "insert");
- // }
- //}
- if (MakeBadView.Rows[i].Cells["mbp_part"].Value.ToString() != "")
- {
- string[] mbp_part = MakeBadView.Rows[i].Cells["mbp_part"].Value.ToString().ToUpper().Split(',');
- sql.Clear();
- sql.Append("insert into makebadrspart(mbp_id,mbp_mbrid,mbp_part,mbp_badcode,");
- sql.Append("mbp_brcode,mbp_sncode,mbp_makecode,mbp_indate,mbp_inman)");
- sql.Append("select makebadrspart_seq.nextval," + mbr_id + ",:mbp_part,");
- sql.Append("'" + MakeBadView.Rows[i].Cells["mb_badcode"].Value.ToString() + "','" + bgd_brcode + "','" + ms_sncode.Text + "','" + ma_code.Text + "',");
- sql.Append("sysdate,'" + User.UserCode + "' from dual");
- dh.BatchInsert(sql.GetString(), new string[] { "mbp_part" }, mbp_part);
- }
- }
- else
- {
- //已保存过不良信息的序列号
- DataTable temp = dh.getFieldsDatasByCondition(" BADGROUPDETAIL left join badgroup on bgd_bgid = bg_id", new string[] { "bgd_brgcode", "bgd_dutycode", "bgd_solutioncode", "bgd_brcode" }, "bgd_badcode= '" + MakeBadView.Rows[i].Cells["mb_badcode"].Value.ToString() + "' and bg_code = '" + MakeBadView.Rows[i].Cells["mb_bgcode"].Value.ToString() + "'");
- 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 = MakeBadView.Rows[i].Cells["mbr_id"].Value.ToString();
- string bgd_brgname = dh.getFieldDataByCondition("QUA_NGReasonGroup", "nrg_name", "nrg_code = '" + bgd_brgcode + "'").ToString();
- string bgd_brname = dh.getFieldDataByCondition("QUA_NGReason", "nr_name", "nr_code = '" + bgd_brcode + "'").ToString();
- string bgd_dutyname = dh.getFieldDataByCondition("NGDuty", "nd_name", "nd_code = '" + bgd_dutycode + "'").ToString();
- string bgd_solutionname = dh.getFieldDataByCondition("solution", "so_name", "so_code = '" + bgd_solutioncode + "'").ToString();
- //删除不良组件,不良位置等信息重新插入
- dh.ExecuteSql("delete makebadrscom where mbc_mbrid = '" + mbr_id + "'", "delete");
- dh.ExecuteSql("delete makebadrsloc where mbl_mbrid = '" + mbr_id + "'", "delete");
- dh.ExecuteSql("delete makebadrspart where mbp_mbrid = '" + mbr_id + "'", "delete");
- if (MakeBadView.Rows[i].Cells["mbc_component"].Value.ToString() != "")
- {
- sql.Clear();
- sql.Append("insert into makebadrscom (mbc_id,mbc_mbrid,mbc_component,mbc_badcode,");
- sql.Append("mbc_brcode,mbc_sncode,mbc_makecode,mbc_indate,mbc_inman ) values ");
- sql.Append("(makebadrscom_seq.nextval,'" + mbr_id + "' ,'" + MakeBadView.Rows[i].Cells["mbc_component"].Value.ToString() + "',");
- sql.Append("'" + MakeBadView.Rows[i].Cells["mb_badcode"].Value.ToString() + "','" + bgd_brcode + "','" + ms_sncode.Text + "','" + ma_code.Text + "',sysdate,'" + User.UserCode + "')");
- dh.ExecuteSql(sql.GetString(), "insert");
- }
-
- string[] mbl_loc = MakeBadView.Rows[i].Cells["mbl_loc"].Value.ToString().ToUpper().Split(',');
- sql.Clear();
- sql.Append("insert into makebadrsloc(mbl_id,mbl_mbrid,mbl_loc,mbl_badcode,mbl_brcode,");
- sql.Append("mbl_sncode,mbl_makecode,mbl_indate ,mbl_inman) select makebadrsloc_seq.nextval," + mbr_id);
- sql.Append(",:mbl_loc,'" + MakeBadView.Rows[i].Cells["mb_badcode"].Value.ToString() + "','" + bgd_brcode + "','" + ms_sncode.Text + "','" + ma_code.Text + "',");
- sql.Append("sysdate,'" + User.UserCode + "' from dual");
- dh.BatchInsert(sql.GetString(), new string[] { "mbl_loc" }, mbl_loc);
- sql.Clear();
- sql.Append("with temp1 as (select bd_soncode,bd_location from bomdetail,bom where bo_id=bd_bomid ");
- sql.Append(" start with bo_mothercode='" + ma_prodcode + "' connect by bo_mothercode= prior bd_soncode) ");
- sql.Append("select bd_soncode from temp1 where instr(','||bd_location||',','," + MakeBadView.Rows[i].Cells["mbl_loc"].Value.ToString().ToUpper() + ",')>0");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- if (dt.Rows.Count > 0)
- {
- for (int j = 0; j < dt.Rows.Count; i++)
- {
- sql.Clear();
- sql.Append("insert into makebadrspart(mbp_id,mbp_mbrid,mbp_part,mbp_badcode,");
- sql.Append("mbp_brcode,mbp_sncode,mbp_makecode,mbp_indate,mbp_inman)");
- sql.Append("select makebadrspart_seq.nextval," + mbr_id + ",'" + dt.Rows[0][j].ToString() + "',");
- sql.Append("'" + MakeBadView.Rows[i].Cells["mb_badcode"].Value.ToString() + "','" + bgd_brcode + "','" + ms_sncode.Text + "','" + ma_code.Text + "',");
- sql.Append("sysdate,'" + User.UserCode + "' from dual");
- dh.ExecuteSql(sql.GetString(), "insert");
- }
- }
- if (MakeBadView.Rows[i].Cells["mbp_part"].Value.ToString() != "")
- {
- string[] mbp_part = MakeBadView.Rows[i].Cells["mbp_part"].Value.ToString().ToUpper().Split(',');
- sql.Clear();
- sql.Append("insert into makebadrspart(mbp_id,mbp_mbrid,mbp_part,mbp_badcode,");
- sql.Append("mbp_brcode,mbp_sncode,mbp_makecode,mbp_indate,mbp_inman)");
- sql.Append("select makebadrspart_seq.nextval," + mbr_id + ",:mbp_part,");
- sql.Append("'" + MakeBadView.Rows[i].Cells["mb_badcode"].Value.ToString() + "','" + bgd_brcode + "','" + ms_sncode.Text + "','" + ma_code.Text + "',");
- sql.Append("sysdate,'" + User.UserCode + "' from dual");
- dh.BatchInsert(sql.GetString(), new string[] { "mbp_part" }, mbp_part);
- }
- }
- }
- //dt = dh.getFieldsDataByCondition("makeserial", new string[] { "ms_id", "nvl(ms_ifrework,0) ms_ifrework", "ms_paststep" }, "ms_sncode='" + ms_sncode.Text + "' and ms_makecode='" + ma_code.Text + "' ");
- //string St_ifqccheck = dh.getFieldDataByCondition("source LEFT JOIN STEP on st_code=sc_stepcode", "nvl(St_ifqccheck,0)", "sc_code='" + User.UserSourceCode + "'").ToString();
- //List<string> SQLS = new List<string>();
- //LogicHandler.InsertMakeProcess(ms_sncode.Text, ma_code.Text, User.UserSourceCode, "快速维修采集", "完成快速维修", User.UserCode);
- //LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "快速维修采集", "完成快速维修", ms_sncode.Text, ob_checkno.Text);
- //if (dt.Rows.Count > 0)
- //{
- // string ms_id = dt.Rows[0]["ms_id"].ToString();
- // string ms_ifrework = dt.Rows[0]["ms_ifrework"].ToString();
- // if (St_ifqccheck != "-1")
- // {
- // if (ms_ifrework == "0")
- // SQLS.Add("update makeserial set ms_checkno='', ms_nextstepcode ='" + User.CurrentStepCode + "',ms_status=1,ms_stepcode='SMT_REPAIR' where ms_id='" + ms_id + "'");
- // else
- // SQLS.Add("update makeserial set ms_checkno='', ms_nextstepcode ='" + User.CurrentStepCode + "',ms_reworkstatus=1,ms_stepcode='SMT_REPAIR' where ms_id='" + ms_id + "'");
- // }
- // else
- // {
- // if (ms_ifrework == "0")
- // SQLS.Add("update makeserial set ms_checkno='', ms_nextstepcode ='" + ms_nextstepcode + "',ms_status=1,ms_stepcode='SMT_REPAIR',ms_paststep = REPLACE(ms_paststep,','||'" + ms_nextstepcode + "') where ms_id='" + ms_id + "'");
- // else
- // SQLS.Add("update makeserial set ms_checkno='', ms_nextstepcode ='" + ms_nextstepcode + "',ms_reworkstatus=1,ms_stepcode='SMT_REPAIR',ms_paststep = REPLACE(ms_paststep,','||'" + ms_nextstepcode + "') where ms_id='" + ms_id + "'");
- // if (status == "2")
- // SQLS.Add("update makeserial set ms_status='2' where ms_id='" + ms_id + "'");
- // }
- //}
- //SQLS.Add("update makebad set mb_status=-1 where mb_sncode='" + ms_sncode.Text + "' and mb_makecode='" + ma_code.Text + "' and MB_STEPCODE = '" + User.CurrentStepCode + "'");
- //dh.ExecuteSQLTran(SQLS.ToArray());
- //保存不良原因
- LastSncode = ms_sncode.Text;
- //采集完不良,聚焦序列号
- ms_sncode.Focus();
- //记录操作日志
- ms_sncode.Text = "";
- //清除不良信息
- BaseUtil.CleanDGVData(MakeBadView);
- //加载页面信息
- LoadCollectedNum();
- LoadCheckQTY();
- }
- else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
- }
- }
- private void bc_code_KeyDown(object sender, KeyEventArgs e)
- {
- }
- 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 + "'";
- }
- else if (pr_sendchecktype.Text == "MakeCode")
- {
- condition += " and ob_makecode='" + ma_code.Text + "'";
- }
- sql.Append("select ob_batchqty,ob_nowcheckqty,ob_checkno from oqcbatch where ");
- sql.Append("ob_linecode='" + User.UserLineCode + "' 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("oqcbatch", "sum(ob_nowcheckqty)", "ob_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.Red);
- if (AutoCut)
- {
- OperateResult.AppendText(">>批次" + ob_checkno.Text + "自动断批\n", Color.Green);
- }
- }
- }
- else
- {
- ob_batchqty.Text = "";
- ob_nowcheckqty.Text = "";
- ob_checkno.Text = "";
- 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)
- {
- WaitReject.Enabled = false;
- ChooseedReject.Enabled = false;
- Save.Visible = false;
- }
- else
- {
- WaitReject.Enabled = true;
- ChooseedReject.Enabled = true;
- Save.Visible = true;
- }
- if (ms_sncode.Text == "")
- {
- ms_sncode.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("oqcbatch", "sum(ob_nowcheckqty)", "ob_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.Green);
- 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)
- {
- mcd_inqty.Text = "";
- mcd_remainqty.Text = "";
- ob_batchqty.Text = "";
- ob_nowcheckqty.Text = "";
- ob_sendqty.Text = "";
- LoadCollectedNum();
- LoadCheckQTY();
- }
- }
- private void Make_TestCollection_FormClosing(object sender, FormClosingEventArgs e)
- {
- dh.Dispose();
- }
- private void ma_prodcode_TextChanged(object sender, EventArgs e)
- {
- bd_soncode.TableName = "(with temp1 as (select bd_fsoncode,bd_soncode,bd_location,pr_spec,pr_detail from bomdetail innner join bom on bo_id=bd_bomid left join product on bd_soncode = pr_code start with bo_mothercode = '" + ma_prodcode.Text + "' connect by bo_mothercode = prior bd_soncode)select* from temp1)";
- bd_soncode.Condition = "1=1";
- }
- 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);
- }
- BaseUtil.FillDgvWithDataTable(WaitChooseDGV, dt);
- }
- catch (Exception)
- {
- }
- }
- 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 Reject_CheckedChanged(object sender, EventArgs e)
- {
- if (Reject.Checked)
- {
- LoadBadCodeListView();
- }
- }
- private void Prodcode_DbChange(object sender, EventArgs e)
- {
- MakeBadView.EndEdit();
- if (bd_soncode.Text != "")
- {
- for (int i = 0; i < MakeBadView.Rows.Count; i++)
- {
- if (MakeBadView.Rows[i].Cells["choose1"].Value != null)
- {
- if ((Boolean)MakeBadView.Rows[i].Cells["choose1"].Value == true)
- {
- if (MakeBadView.Rows[i].Cells["mbp_part"].Value.ToString() == "")
- {
- MakeBadView.Rows[i].Cells["mbp_part"].Value = bd_soncode.Text;
- }
- else if (!MakeBadView.Rows[i].Cells["mbp_part"].Value.ToString().Contains(bd_soncode.Text))
- MakeBadView.Rows[i].Cells["mbp_part"].Value += "," + bd_soncode.Text;
- if (MakeBadView.Rows[i].Cells["mbl_loc"].Value.ToString() == "")
- {
- MakeBadView.Rows[i].Cells["mbl_loc"].Value = psl_location.Text.ToUpper();
- }
- else if (!MakeBadView.Rows[i].Cells["mbl_loc"].Value.ToString().Contains(psl_location.Text.ToUpper()))
- MakeBadView.Rows[i].Cells["mbl_loc"].Value += "," + psl_location.Text.ToUpper();
- }
- }
- }
- }
- else OperateResult.AppendText(">>不良零件不能为空\n", Color.Red);
- }
- private void bd_soncode_UserControlTextChanged(object sender, EventArgs e)
- {
- }
- private void bd_soncode_Load(object sender, EventArgs e)
- {
- }
- private void bad_loc_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- if (ma_prodcode.Text != "")
- {
- if (psl_location.Text != "" && psl_location.Text.Length <= 6)
- {
- DataTable dt = (DataTable)dh.ExecuteSql("select bd_soncode,bd_location,pr_spec,pr_detail from (with temp1 as (select bd_soncode,bd_location,pr_spec,pr_detail from bomdetail innner join bom on bo_id=bd_bomid left join product on bd_soncode = pr_code start with bo_mothercode= '" + ma_prodcode.Text + "'and nvl(bd_usestatus,' ') <> 'DISABLE' connect by bo_mothercode= prior bd_soncode)select * from temp1) where bd_location = '" + psl_location.Text.ToUpper() + "' OR bd_location LIKE '" + psl_location.Text.ToUpper() + ",%' OR bd_location LIKE '%," + psl_location.Text.ToUpper() + "' OR bd_location LIKE '%," + psl_location.Text.ToUpper() + ",%'", "select");
- if (dt.Rows.Count > 0)
- {
- if (dt.Rows.Count == 1)
- {
- string psl_prodcode = dt.Rows[0]["bd_soncode"].ToString();
- for (int i = 0; i < MakeBadView.Rows.Count; i++)
- {
- if (MakeBadView.Rows[i].Cells["choose1"].Value != null)
- {
- if ((Boolean)MakeBadView.Rows[i].Cells["choose1"].Value == true)
- {
- if (MakeBadView.Rows[i].Cells["mbp_part"].Value.ToString() == "")
- {
- MakeBadView.Rows[i].Cells["mbp_part"].Value = psl_prodcode;
- }
- else if (!MakeBadView.Rows[i].Cells["mbp_part"].Value.ToString().Contains(psl_prodcode))
- MakeBadView.Rows[i].Cells["mbp_part"].Value += "," + psl_prodcode;
- if (MakeBadView.Rows[i].Cells["mbl_loc"].Value.ToString() == "")
- {
- MakeBadView.Rows[i].Cells["mbl_loc"].Value = psl_location.Text.ToUpper();
- }
- else if (!MakeBadView.Rows[i].Cells["mbl_loc"].Value.ToString().Contains(psl_location.Text.ToUpper()))
- MakeBadView.Rows[i].Cells["mbl_loc"].Value += "," + psl_location.Text.ToUpper();
- }
- }
- }
- }
- else if (dt.Rows.Count > 1)
- {
- Boolean ifgetloc = false;
- for (int j = 0; j < dt.Rows.Count; j++)
- {
- string psl_prodcode = dt.Rows[j]["bd_soncode"].ToString();
- for (int i = 0; i < MakeBadView.Rows.Count; i++)
- {
- if (MakeBadView.Rows[i].Cells["choose1"].Value != null)
- {
- if ((Boolean)MakeBadView.Rows[i].Cells["choose1"].Value == true)
- {
- if (MakeBadView.Rows[i].Cells["mbp_part"].Value.ToString() == "")
- {
- OperateResult.AppendText(">>站位" + psl_location.Text + "有替代料,需要提前采集不良零件,第" + (i + 1) + "行不良零件为空\n", Color.Red);
- }
- else if (MakeBadView.Rows[i].Cells["mbp_part"].Value.ToString().Contains(psl_prodcode))
- {
- ifgetloc = true;
- if (MakeBadView.Rows[i].Cells["mbl_loc"].Value.ToString() == "")
- {
- MakeBadView.Rows[i].Cells["mbl_loc"].Value = psl_location.Text.ToUpper();
- }
- else if (!MakeBadView.Rows[i].Cells["mbl_loc"].Value.ToString().Contains(psl_location.Text.ToUpper()))
- MakeBadView.Rows[i].Cells["mbl_loc"].Value += "," + psl_location.Text.ToUpper();
- }
- }
- }
- }
- }
- if (!ifgetloc)
- {
- OperateResult.AppendText(">>站位" + psl_location.Text + "有替代料,需要提前采集不良零件,当前所选行均未采集对应不良零件\n", Color.Red);
- }
- }
- }
- else
- {
- OperateResult.AppendText(">>站位" + psl_location.Text.ToUpper() + "无对应物料\n", Color.Red, psl_location);
- }
- }
- else
- {
- OperateResult.AppendText(">>不良位置录入不能为空或长度不能大于6\n", Color.Red);
- }
- }
- else
- {
- OperateResult.AppendText(">>产品编号不能为空\n", Color.Red);
- }
- }
- }
- private void psl_location_Leave(object sender, EventArgs e)
- {
- psl_location.Text = "";
- }
- private void Make_SmtbdTestCollection_Shown(object sender, EventArgs e)
- {
- st_table = dh.getFieldDataByCondition("step", "st_table", "st_code = '" + User.CurrentStepCode + "'").ToString();
- if (st_table == "A")
- {
- UserSourceCode = dh.getFieldDataByCondition("SOURCE", "nvl(sc_code,'')", "sc_linecode = '" + User.UserLineCode + "' and sc_stepcode = 'BDA'").ToString() ;
- }
- else if (st_table == "B")
- {
- UserSourceCode = dh.getFieldDataByCondition("SOURCE", "nvl(sc_code,'')", "sc_linecode = '" + User.UserLineCode + "' and sc_stepcode = 'BDB'").ToString();
- }
- else
- {
- MessageBox.Show("此工序没有维护版面,无法操作");
- System.Environment.Exit(0);
- }
- if (UserSourceCode == "")
- {
- MessageBox.Show("线别"+User.UserLineCode+",版面"+st_table+"没有维护对应岗位资源,无法操作");
- System.Environment.Exit(0);
- }
- StepCount.StepCode = User.CurrentStepCode;
- StepCount.Source = UserSourceCode;
- StepCount.LineCode = User.UserLineCode;
- StepCount.Dh = dh;
- StepCount.Start();
- }
- }
- }
|