Make_SmtTestCollection.cs 57 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021
  1. using System;
  2. using System.Data;
  3. using System.Text;
  4. using System.Threading;
  5. using System.Drawing;
  6. using System.Windows.Forms;
  7. using UAS_MES_NEW.DataOperate;
  8. using UAS_MES_NEW.Entity;
  9. using UAS_MES_NEW.PublicMethod;
  10. using System.Collections.Generic;
  11. using UAS_MES_NEW.CustomControl.PowerControlForm;
  12. namespace UAS_MES_NEW.Make
  13. {
  14. public partial class Make_SmtTestCollection : Form
  15. {
  16. DataHelper dh = null;
  17. DataTable dt = null;
  18. //当前工序的名称
  19. string ErrorMessage = "";
  20. //用于保存是否之前输入的ms_sncode
  21. string LastSncode;
  22. string oMakeCode = "";
  23. string oMSID = "";
  24. string ifrework = "";
  25. string reworkstatus = "";
  26. LogStringBuilder sql = new LogStringBuilder();
  27. AutoSizeFormClass asc = new AutoSizeFormClass();
  28. /// <summary>
  29. /// 已选的不良
  30. /// </summary>
  31. List<string> ChoosedList = new List<string>();
  32. /// <summary>
  33. /// 待选的不良
  34. /// </summary>
  35. List<string> WaitList = new List<string>();
  36. //当前工序对应版面
  37. string st_table = "";
  38. bool AutoCut = false;
  39. bool LockSn = false;
  40. DataTable Dbfind;
  41. public Make_SmtTestCollection()
  42. {
  43. InitializeComponent();
  44. }
  45. private void TestCollection_Load(object sender, EventArgs e)
  46. {
  47. GoodProduct.Checked = true;
  48. asc.controllInitializeSize(this);
  49. ms_sncode.Focus();
  50. //设置锁定工单
  51. LockMakeCode.GetMakeCodeCtl(ma_code);
  52. ma_code.SetLockCheckBox(LockMakeCode);
  53. ControlLockTimer.Tick += ControlLockTimer_Tick;
  54. ControlLockTimer.Interval = 100;
  55. bd_soncode.FormName = Name;
  56. 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)";
  57. bd_soncode.SetValueField = new string[] { "bd_soncode" };
  58. bd_soncode.SelectField = "bd_fsoncode # 首选料号,bd_soncode # 子件编号,pr_detail # 物料名称,pr_spec # 物料规格,bd_location # 位号";
  59. bd_soncode.DBTitle = "不良零件";
  60. bd_soncode.DbChange += Prodcode_DbChange;
  61. //工单号放大镜配置
  62. ma_code.TableName = "make left join product on ma_prodcode=pr_code";
  63. ma_code.SelectField = "ma_code # 工单号,ma_prodcode # 产品编号,ma_qty # 工单数量,pr_detail # 产品名称,ma_softversion # 软件版本,ma_salecode # 销售单号,pr_sendchecktype # 产品送检方式";
  64. ma_code.FormName = Name;
  65. ma_code.SetValueField = new string[] { "ma_code", "ma_prodcode", "ma_qty", "pr_detail", "ma_softversion", "ma_salecode", "nvl(pr_sendchecktype,'LineCode')pr_sendchecktype" };
  66. ma_code.Condition = "ma_statuscode='STARTED' and ma_wccode = 'SMT'";
  67. ma_code.DbChange += Ma_code_DbChange;
  68. dh = SystemInf.dh;
  69. StepCount.StepCode = User.CurrentStepCode;
  70. StepCount.Source = User.UserSourceCode;
  71. StepCount.LineCode = User.UserLineCode;
  72. StepCount.Dh = dh;
  73. StepCount.Start();
  74. st_table = dh.getFieldDataByCondition("step", "st_table", "st_code = '" + User.CurrentStepCode + "'").ToString();
  75. }
  76. private void ControlLockTimer_Tick(object sender, EventArgs e)
  77. {
  78. this.Activate();
  79. ms_sncode.Focus();
  80. }
  81. private void Ma_code_DbChange(object sender, EventArgs e)
  82. {
  83. Dbfind = ma_code.ReturnData;
  84. BaseUtil.SetFormValue(this.Controls, Dbfind);
  85. LoadCollectedNum();
  86. LoadCheckQTY();
  87. }
  88. /// <summary>
  89. /// 将已选不良移动到待选不良
  90. /// </summary>
  91. /// <param name="sender"></param>
  92. /// <param name="e"></param>
  93. private void WaitReject_Click(object sender, EventArgs e)
  94. {
  95. Boolean HaveReject = false;
  96. for (int i = MakeBadView.Rows.Count - 1; i >= 0; i--)
  97. {
  98. if (MakeBadView.Rows[i].Cells["choose1"].Value != null)
  99. {
  100. if ((Boolean)MakeBadView.Rows[i].Cells["choose1"].Value == true)
  101. {
  102. HaveReject = true;
  103. break;
  104. }
  105. }
  106. }
  107. if (HaveReject)
  108. {
  109. string confirm = MessageBox.Show(this.ParentForm, "确认删除勾选的不良(已保存的不良代码也会删除)", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk).ToString();
  110. if (confirm == "Yes")
  111. {
  112. for (int i = MakeBadView.Rows.Count - 1; i >= 0; i--)
  113. {
  114. if (MakeBadView.Rows[i].Cells["choose1"].Value != null)
  115. {
  116. if ((Boolean)MakeBadView.Rows[i].Cells["choose1"].Value == true)
  117. {
  118. if (MakeBadView.Rows[i].Cells["mbr_id"].Value.ToString() != "")
  119. {
  120. List<string> SQLS = new List<string>();
  121. SQLS.Add("delete makebad where mb_id = '" + MakeBadView.Rows[i].Cells["mb_id"].Value.ToString() + "'");
  122. SQLS.Add("delete makebadreason where mbr_id = '" + MakeBadView.Rows[i].Cells["mbr_id"].Value.ToString() + "'");
  123. SQLS.Add("delete makebadrscom where mbc_mbrid = '" + MakeBadView.Rows[i].Cells["mbr_id"].Value.ToString() + "'");
  124. SQLS.Add("delete makebadrspart where mbp_mbrid = '" + MakeBadView.Rows[i].Cells["mbr_id"].Value.ToString() + "'");
  125. SQLS.Add("delete makebadrsloc where mbl_mbrid = '" + MakeBadView.Rows[i].Cells["mbr_id"].Value.ToString() + "'");
  126. dh.ExecuteSQLTran(SQLS.ToArray());
  127. }
  128. MakeBadView.Rows.RemoveAt(i);
  129. }
  130. }
  131. }
  132. (MakeBadView.DataSource as DataTable).AcceptChanges();
  133. }
  134. }
  135. HaveReject = false;
  136. }
  137. /// <summary>
  138. /// 将不良信息移动到已选不良
  139. /// </summary>
  140. /// <param name="sender"></param>
  141. /// <param name="e"></param>
  142. private void ChooseedReject_Click(object sender, EventArgs e)
  143. {
  144. if (ms_sncode.Text == "")
  145. {
  146. OperateResult.AppendText(">>序列号不能为空\n", Color.Red);
  147. ms_sncode.Focus();
  148. return;
  149. }
  150. LoadChoosedBadListView();
  151. DataTable choose = (MakeBadView.DataSource as DataTable);
  152. List<string> Chooseed = new List<string>();
  153. for (int i = 0; i < MakeBadView.Rows.Count; i++)
  154. {
  155. Chooseed.Add(MakeBadView.Rows[i].Cells["mb_badcode"].Value.ToString());
  156. }
  157. if (WaitChooseDGV.Rows.Count > 0)
  158. {
  159. for (int i = 0; i < WaitChooseDGV.Rows.Count; i++)
  160. {
  161. if (WaitChooseDGV.Rows[i].Cells["ChooseAll"].Value != null)
  162. {
  163. if ((Boolean)WaitChooseDGV.Rows[i].Cells["ChooseAll"].Value == true)
  164. {
  165. if (!Chooseed.Contains(WaitChooseDGV.Rows[i].Cells["bc_code"].Value.ToString()))
  166. {
  167. DataRow dr1 = choose.NewRow();
  168. dr1["mb_badcode"] = WaitChooseDGV.Rows[i].Cells["bc_code"].Value.ToString();
  169. dr1["mb_badname"] = WaitChooseDGV.Rows[i].Cells["bc_name"].Value.ToString();
  170. dr1["mb_bgname"] = WaitChooseDGV.Rows[i].Cells["bg_name"].Value.ToString();
  171. dr1["mb_bgcode"] = WaitChooseDGV.Rows[i].Cells["bg_code"].Value.ToString();
  172. choose.Rows.Add(dr1);
  173. }
  174. else
  175. {
  176. OperateResult.AppendText(">>不良代码" + WaitChooseDGV.Rows[i].Cells["bc_code"].Value.ToString() + "已存在\n", Color.Red);
  177. }
  178. }
  179. }
  180. }
  181. for (int i = 0; i < WaitChooseDGV.Rows.Count; i++)
  182. {
  183. WaitChooseDGV.Rows[i].Cells["ChooseAll"].Value = false;
  184. }
  185. }
  186. else OperateResult.AppendText(">>请勾选不良明细\n", Color.Red);
  187. }
  188. private void CleanInfo_Click(object sender, EventArgs e)
  189. {
  190. OperateResult.Clear();
  191. }
  192. private void ms_code_KeyDown(object sender, KeyEventArgs e)
  193. {
  194. if (e.KeyCode == Keys.Enter)
  195. {
  196. BaseUtil.CleanDGVData(MakeBadView);
  197. WaitList.Clear();
  198. ChoosedList.Clear();
  199. if (LogicHandler.CheckStepAttribute(Tag.ToString(), User.UserSourceCode, out ErrorMessage))
  200. {
  201. //是否提示过工单切换框,检测前执行
  202. bool NoteAlready = LogicHandler.CheckDiffMakeCodeBeforeStepCheck(ms_sncode.Text, ma_code.Text, NoteForChange.Checked, out oMakeCode, out ErrorMessage);
  203. if (!NoteAlready)
  204. {
  205. OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, ms_sncode);
  206. return;
  207. }
  208. if (LogicHandler.CheckStepSNAndMacode(oMakeCode, User.UserSourceCode, ms_sncode.Text, User.UserCode, out oMakeCode, out oMSID, out ErrorMessage))
  209. {
  210. //是否提示过工单切换框,检测前后执行
  211. if (!LogicHandler.CheckDiffMakeCodeAfterStepCheck(ms_sncode.Text, oMakeCode, NoteForChange.Checked, NoteAlready, ma_code, out ErrorMessage))
  212. {
  213. OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, ms_sncode);
  214. return;
  215. }
  216. if (ma_code.Text != oMakeCode && oMakeCode != null)
  217. {
  218. 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");
  219. if (dt.Rows.Count > 0)
  220. {
  221. BaseUtil.SetFormValue(this.Controls, dt);
  222. LockMakeCode.Checked = true;
  223. }
  224. }
  225. 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");
  226. string status = dt.Rows[0]["ms_status"].ToString();
  227. reworkstatus = dt.Rows[0]["ms_reworkstatus"].ToString();
  228. string stepcode = dt.Rows[0]["ms_stepcode"].ToString();
  229. string ifrepair = dt.Rows[0]["st_ifrepair"].ToString();
  230. string sncode = dt.Rows[0]["ms_sncode"].ToString();
  231. if (sncode != ms_sncode.Text)
  232. {
  233. OperateResult.AppendText(">>" + ms_sncode.Text + " 序列号已执行过转号,不允许使用TSN采集\n", Color.Red, ms_sncode);
  234. return;
  235. }
  236. ifrework = dt.Rows[0]["ms_ifrework"].ToString();
  237. if (GoodProduct.Checked)
  238. {
  239. if (ifrework != "0")
  240. {
  241. if (stepcode == User.CurrentStepCode && (reworkstatus == "1" || reworkstatus == "2") && ifrepair == "0")
  242. {
  243. OperateResult.AppendText(">>" + ms_sncode.Text + "序列号已执行过" + User.CurrentStepCode + "工序,采集结果为良品\n", Color.Red, ms_sncode);
  244. return;
  245. }
  246. }
  247. else
  248. {
  249. if (stepcode == User.CurrentStepCode && (status == "1" || status == "2") && ifrepair == "0")
  250. {
  251. OperateResult.AppendText(">>" + ms_sncode.Text + "序列号已执行过" + User.CurrentStepCode + "工序,采集结果为良品\n", Color.Red, ms_sncode);
  252. return;
  253. }
  254. }
  255. }
  256. SetCollectResult();
  257. }
  258. else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, ms_sncode);
  259. }
  260. else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, ms_sncode);
  261. }
  262. }
  263. /// <summary>
  264. /// 加载不良代码的ListView的信息
  265. /// </summary>
  266. private void LoadBadCodeListView()
  267. {
  268. sql.Clear();
  269. sql.Append("select bg_code,bg_name ,bc_code,bc_name,'' bc_remark from badgroupdetail ");
  270. sql.Append("left join badgroup on bg_id=bgd_bgid left join badcode on bgd_badcode=bc_code where ");
  271. sql.Append("bg_code='SMT' and bg_code is not null order by bgd_detno");
  272. DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  273. BadInfSource.DataSource = dt;
  274. BaseUtil.FillDgvWithDataTable(WaitChooseDGV, dt);
  275. }
  276. /// <summary>
  277. /// 加载已选不良的ListView
  278. /// </summary>
  279. private void LoadChoosedBadListView()
  280. {
  281. sql.Clear();
  282. 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 ");
  283. 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 ");
  284. 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");
  285. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  286. BaseUtil.FillDgvWithDataTable(MakeBadView, dt);
  287. }
  288. /// <summary>
  289. /// 设置良品或者不良品的采集结果
  290. /// </summary>
  291. private void SetCollectResult()
  292. {
  293. string ErrorMessage = "";
  294. //如果勾选的是不良品
  295. if (Reject.Checked)
  296. {
  297. LoadBadCodeListView();
  298. LoadChoosedBadListView();
  299. OperateResult.AppendText(">>请采集不良代码\n", Color.Green);
  300. //勾选了自动产生代码
  301. if (AutoBadCode.Checked)
  302. Save_Click(new object(), new EventArgs());
  303. }
  304. else if (GoodProduct.Checked)
  305. {
  306. //如果不是返修的
  307. if (ifrework == "0")
  308. {
  309. 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");
  310. for (int i = 0; i < dt.Rows.Count; i++)
  311. {
  312. if (dt.Rows[i]["mb_id"].ToString() != dt.Rows[i]["mbr_mbid"].ToString())
  313. ErrorMessage += "【" + dt.Rows[i]["bc_name"].ToString() + "】";
  314. }
  315. //存在不良记录
  316. if (ErrorMessage != "")
  317. {
  318. OperateResult.AppendText(">>序列号:" + ms_sncode.Text + " 已经判为不良品,不允许修改!\n", Color.Red);
  319. return;
  320. }
  321. else
  322. {
  323. //良品信息采集
  324. if (LogicHandler.SetStepResult(ma_code.Text, User.UserSourceCode, ms_sncode.Text, "良品采集", "检测合格", User.UserCode, out ErrorMessage))
  325. {
  326. //提示正确返回时传递的信息
  327. if (ErrorMessage.Contains("AFTERSUCCESS"))
  328. OperateResult.AppendText(">>" + ErrorMessage + "\n");
  329. LastSncode = ms_sncode.Text;
  330. OperateResult.AppendText(">>" + ms_sncode.Text + "良品采集成功\n", Color.Green, ms_sncode);
  331. //记录操作日志
  332. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "采集良品", "采集良品成功", LastSncode, ob_checkno.Text);
  333. }
  334. else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, ms_sncode);
  335. }
  336. }
  337. else
  338. {
  339. if (reworkstatus != "3")
  340. {
  341. if (LogicHandler.SetStepResult(ma_code.Text, User.UserSourceCode, ms_sncode.Text, "良品采集", "检测合格", User.UserCode, out ErrorMessage))
  342. {
  343. //提示正确返回时传递的信息
  344. if (ErrorMessage.Contains("AFTERSUCCESS"))
  345. OperateResult.AppendText(">>" + ErrorMessage + "\n");
  346. LastSncode = ms_sncode.Text;
  347. OperateResult.AppendText(">>" + ms_sncode.Text + "成功采集为良品\n", Color.Green, ms_sncode);
  348. //记录操作日志
  349. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "采集良品", "采集良品成功", LastSncode, ob_checkno.Text);
  350. }
  351. else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, ms_sncode);
  352. }
  353. else
  354. {
  355. OperateResult.AppendText(">>返修的不良序列号必须先进行维修\n", Color.Red);
  356. }
  357. }
  358. }
  359. //加载页面信息
  360. LoadCollectedNum();
  361. LoadCheckQTY();
  362. }
  363. private void 测试采集_SizeChanged(object sender, EventArgs e)
  364. {
  365. asc.controlAutoSize(this);
  366. }
  367. private void LoadCollectedNum()
  368. {
  369. 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");
  370. BaseUtil.SetFormValue(Controls, dt);
  371. }
  372. private void Save_Click(object sender, EventArgs e)
  373. {
  374. if (ms_sncode.Text == "")
  375. {
  376. OperateResult.AppendText(">>序列号不允许为空\n", Color.Red);
  377. return;
  378. }
  379. if (GoodProduct.Checked)
  380. ms_code_KeyDown(sender, new KeyEventArgs(Keys.Enter));
  381. else if (Reject.Checked)
  382. {
  383. if (LogicHandler.CheckStepAttribute(Tag.ToString(), User.UserSourceCode, out ErrorMessage))
  384. {
  385. //判断界面工单是否为空时的序列号是否自动归属工单
  386. string oStatus = "";
  387. if (!LogicHandler.GetMakeInfo(ms_sncode.Text, out oMakeCode, out oStatus, out ErrorMessage))
  388. {
  389. if (ma_code.Text == "")
  390. {
  391. OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, ms_sncode);
  392. return;
  393. }
  394. }
  395. if (LogicHandler.CheckStepSNAndMacode(ma_code.Text == "" ? oMakeCode : ma_code.Text, User.UserSourceCode, ms_sncode.Text, User.UserCode, out oMakeCode, out oMSID, out ErrorMessage))
  396. {
  397. 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");
  398. if (dt.Rows.Count > 0)
  399. {
  400. BaseUtil.SetFormValue(this.Controls, dt);
  401. LockMakeCode.Checked = true;
  402. }
  403. }
  404. else
  405. {
  406. OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, ms_sncode);
  407. return;
  408. }
  409. }
  410. else
  411. {
  412. OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, ms_sncode);
  413. return;
  414. }
  415. for (int i = 0; i < MakeBadView.Rows.Count; i++)
  416. {
  417. if (MakeBadView.Rows[i].Cells["mbl_loc"].Value.ToString() == "" || MakeBadView.Rows[i].Cells["mbp_part"].Value.ToString() == "")
  418. {
  419. OperateResult.AppendText(">>不良位置与不良零件均不可为空\n", Color.Red);
  420. return;
  421. }
  422. }
  423. List<string> bccode = new List<string>();
  424. List<string> bcremark = new List<string>();
  425. List<string> bgcode = new List<string>();
  426. List<string> bgname = new List<string>();
  427. List<string> bcname = new List<string>();
  428. bccode.Clear();
  429. bcremark.Clear();
  430. bgcode.Clear();
  431. bgname.Clear();
  432. bcname.Clear();
  433. if (MakeBadView.Rows.Count == 0)
  434. {
  435. OperateResult.AppendText(">>不良品必须选择不良原因和不良代码!\n", Color.Red);
  436. return;
  437. }
  438. else
  439. {
  440. for (int i = 0; i < MakeBadView.Rows.Count; i++)
  441. {
  442. if (MakeBadView.Rows[i].Cells["mb_id"].Value.ToString() == "")
  443. {
  444. //获取不良代码组
  445. bgcode.Add(MakeBadView.Rows[i].Cells["mb_bgcode"].Value.ToString());
  446. //获取不良代码组名称
  447. bgname.Add(MakeBadView.Rows[i].Cells["mb_bgname"].Value.ToString());
  448. //获取所有的不良代码
  449. bccode.Add(MakeBadView.Rows[i].Cells["mb_badcode"].Value.ToString());
  450. //获取不良名称
  451. bcname.Add(MakeBadView.Rows[i].Cells["mb_badname"].Value.ToString());
  452. //获取所有的不良备注
  453. bcremark.Add(bc_remark.Text);
  454. }
  455. }
  456. }
  457. //如果之前是良品的
  458. dt = dh.getFieldsDataByCondition("makeserial", new string[] { "ms_status", "ms_checkno" }, "ms_id='" + oMSID + "' and ms_stepcode='" + User.CurrentStepCode + "'");
  459. if (dt.Rows.Count > 0)
  460. {
  461. string status = dt.Rows[0]["ms_status"].ToString();
  462. if (status == "1" || status == "2")
  463. {
  464. 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 + "')");
  465. dh.UpdateByCondition("makecraftdetail", "mcd_okqty=mcd_okqty-1", "mcd_macode='" + ma_code.Text + "' and mcd_stepcode='" + User.CurrentStepCode + "'");
  466. dh.UpdateByCondition("makeserial", "ms_nextstepcode='',ms_badtimes=nvl(ms_badtimes,0)+1", "ms_id='" + oMSID + "'");
  467. LogicHandler.InsertMakeProcess(ms_sncode.Text, ma_code.Text, User.UserSourceCode, "良品采集成不良", "测试不良", User.UserCode);
  468. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "测试不良", "良品采集成不良", ms_sncode.Text, ob_checkno.Text);
  469. }
  470. string checkno = dt.Rows[0]["ms_checkno"].ToString();
  471. //存在抽检批次更新为空
  472. if (checkno != "")
  473. dh.UpdateByCondition("makeserial", "ms_checkno=''", "ms_id='" + oMSID + "'");
  474. }
  475. else
  476. {
  477. LogicHandler.InsertMakeProcess(ms_sncode.Text, ma_code.Text, User.UserSourceCode, "采集成不良", "测试不良", User.UserCode);
  478. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "采集成不良", "测试不良", ms_sncode.Text, ob_checkno.Text);
  479. }
  480. //不良信息采集,mb_status<>0的是之前维修保存的,不能删除
  481. dh.ExecuteSql("delete from makebad where mb_sncode='" + ms_sncode.Text + "' and mb_makecode='" + ma_code.Text + "' and nvl(mb_status,0)=0", "delete");
  482. 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))
  483. {
  484. OperateResult.AppendText(">>" + ms_sncode.Text + "成功采集为不良\n", Color.Green);
  485. for (int i = 0; i < MakeBadView.Rows.Count; i++)
  486. {
  487. //获取当前序列号对应的不良代码编号
  488. 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();
  489. //为空插入不良代码表与不良原因表
  490. if (MakeBadView.Rows[i].Cells["mbr_id"].Value.ToString() == "")
  491. {
  492. 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() + "'");
  493. string bgd_brgcode = temp.Rows[0]["bgd_brgcode"].ToString();
  494. string bgd_brcode = temp.Rows[0]["bgd_brcode"].ToString();
  495. string bgd_dutycode = temp.Rows[0]["bgd_dutycode"].ToString();
  496. string bgd_solutioncode = temp.Rows[0]["bgd_solutioncode"].ToString();
  497. string mbr_id = dh.GetSEQ("makebadreason_seq");
  498. string bgd_brgname = dh.getFieldDataByCondition("QUA_NGReasonGroup", "nrg_name", "nrg_code = '" + bgd_brgcode + "'").ToString();
  499. string bgd_brname = dh.getFieldDataByCondition("QUA_NGReason", "nr_name", "nr_code = '" + bgd_brcode + "'").ToString();
  500. string bgd_dutyname = dh.getFieldDataByCondition("NGDuty", "nd_name", "nd_code = '" + bgd_dutycode + "'").ToString();
  501. string bgd_solutionname = dh.getFieldDataByCondition("solution", "so_name", "so_code = '" + bgd_solutioncode + "'").ToString();
  502. sql.Clear();
  503. sql.Append("insert into makebadreason (mbr_mbid,mbr_id,mbr_brcode,mbr_solutioncode,");
  504. sql.Append("mbr_dutycode,mbr_brgcode,mbr_badcode,mbr_sncode,mbr_makecode,mbr_indate,");
  505. sql.Append("mbr_inman,mbr_brname,mbr_solutionname,mbr_badname,mbr_brgname,mbr_dutyname) select '" + makebadid + "','" + mbr_id + "','" + bgd_brcode + "',");
  506. sql.Append("'" + bgd_solutioncode + "','" + bgd_dutycode + "','" + bgd_brgcode + "','" + MakeBadView.Rows[i].Cells["mb_badcode"].Value.ToString() + "',");
  507. 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");
  508. dh.ExecuteSql(sql.GetString(), "insert");
  509. if (MakeBadView.Rows[i].Cells["mbc_component"].Value.ToString() != "")
  510. {
  511. sql.Clear();
  512. sql.Append("insert into makebadrscom (mbc_id,mbc_mbrid,mbc_component,mbc_badcode,");
  513. sql.Append("mbc_brcode,mbc_sncode,mbc_makecode,mbc_indate,mbc_inman ) values ");
  514. sql.Append("(makebadrscom_seq.nextval,'" + mbr_id + "' ,'" + MakeBadView.Rows[i].Cells["mbc_component"].Value.ToString() + "',");
  515. sql.Append("'" + MakeBadView.Rows[i].Cells["mb_badcode"].Value.ToString() + "','" + bgd_brcode + "','" + ms_sncode.Text + "','" + ma_code.Text + "',sysdate,'" + User.UserCode + "')");
  516. dh.ExecuteSql(sql.GetString(), "insert");
  517. }
  518. string[] mbp_part = MakeBadView.Rows[i].Cells["mbp_part"].Value.ToString().Split(',');
  519. string[] mbl_loc = MakeBadView.Rows[i].Cells["mbl_loc"].Value.ToString().Split(',');
  520. sql.Clear();
  521. sql.Append("insert into makebadrsloc(mbl_id,mbl_mbrid,mbl_loc,mbl_badcode,mbl_brcode,");
  522. sql.Append("mbl_sncode,mbl_makecode,mbl_indate ,mbl_inman) select makebadrsloc_seq.nextval," + mbr_id);
  523. sql.Append(",:mbl_loc,'" + MakeBadView.Rows[i].Cells["mb_badcode"].Value.ToString() + "','" + bgd_brcode + "','" + ms_sncode.Text + "','" + ma_code.Text + "',");
  524. sql.Append("sysdate,'" + User.UserCode + "' from dual");
  525. dh.BatchInsert(sql.GetString(), new string[] { "mbl_loc" }, mbl_loc);
  526. //sql.Clear();
  527. //sql.Append("with temp1 as (select bd_soncode,bd_location from bomdetail,bom where bo_id=bd_bomid ");
  528. //sql.Append(" start with bo_mothercode='" + ma_prodcode.Text + "' connect by bo_mothercode= prior bd_soncode) ");
  529. //sql.Append("select bd_soncode from temp1 where instr(','||bd_location||',','," + MakeBadView.Rows[i].Cells["mbl_loc"].Value.ToString().ToUpper() + ",')>0");
  530. //dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  531. //if (dt.Rows.Count > 0)
  532. //{
  533. // for (int j = 0; j < dt.Rows.Count; i++)
  534. // {
  535. // sql.Clear();
  536. // sql.Append("insert into makebadrspart(mbp_id,mbp_mbrid,mbp_part,mbp_badcode,");
  537. // sql.Append("mbp_brcode,mbp_sncode,mbp_makecode,mbp_indate,mbp_inman)");
  538. // sql.Append("select makebadrspart_seq.nextval," + mbr_id + ",'" + dt.Rows[0][j].ToString() + "',");
  539. // sql.Append("'" + MakeBadView.Rows[i].Cells["mb_badcode"].Value.ToString() + "','" + bgd_brcode + "','" + ms_sncode.Text + "','" + ma_code.Text + "',");
  540. // sql.Append("sysdate,'" + User.UserCode + "' from dual");
  541. // dh.ExecuteSql(sql.GetString(), "insert");
  542. // }
  543. //}
  544. sql.Clear();
  545. sql.Append("insert into makebadrspart(mbp_id,mbp_mbrid,mbp_part,mbp_badcode,");
  546. sql.Append("mbp_brcode,mbp_sncode,mbp_makecode,mbp_indate,mbp_inman)");
  547. sql.Append("select makebadrspart_seq.nextval," + mbr_id + ",:mbp_part,");
  548. sql.Append("'" + MakeBadView.Rows[i].Cells["mb_badcode"].Value.ToString() + "','" + bgd_brcode + "','" + ms_sncode.Text + "','" + ma_code.Text + "',");
  549. sql.Append("sysdate,'" + User.UserCode + "' from dual");
  550. dh.BatchInsert(sql.GetString(), new string[] { "mbp_part" }, mbp_part);
  551. }
  552. else
  553. {
  554. //已保存过不良信息的序列号
  555. 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() + "'");
  556. string bgd_brgcode = temp.Rows[0]["bgd_brgcode"].ToString();
  557. string bgd_brcode = temp.Rows[0]["bgd_brcode"].ToString();
  558. string bgd_dutycode = temp.Rows[0]["bgd_dutycode"].ToString();
  559. string bgd_solutioncode = temp.Rows[0]["bgd_solutioncode"].ToString();
  560. string mbr_id = MakeBadView.Rows[i].Cells["mbr_id"].Value.ToString();
  561. string bgd_brgname = dh.getFieldDataByCondition("QUA_NGReasonGroup", "nrg_name", "nrg_code = '" + bgd_brgcode + "'").ToString();
  562. string bgd_brname = dh.getFieldDataByCondition("QUA_NGReason", "nr_name", "nr_code = '" + bgd_brcode + "'").ToString();
  563. string bgd_dutyname = dh.getFieldDataByCondition("NGDuty", "nd_name", "nd_code = '" + bgd_dutycode + "'").ToString();
  564. string bgd_solutionname = dh.getFieldDataByCondition("solution", "so_name", "so_code = '" + bgd_solutioncode + "'").ToString();
  565. //删除不良组件,不良位置等信息重新插入
  566. dh.ExecuteSql("delete makebadrscom where mbc_mbrid = '" + mbr_id + "'", "delete");
  567. dh.ExecuteSql("delete makebadrsloc where mbl_mbrid = '" + mbr_id + "'", "delete");
  568. dh.ExecuteSql("delete makebadrspart where mbp_mbrid = '" + mbr_id + "'", "delete");
  569. if (MakeBadView.Rows[i].Cells["mbc_component"].Value.ToString() != "")
  570. {
  571. sql.Clear();
  572. sql.Append("insert into makebadrscom (mbc_id,mbc_mbrid,mbc_component,mbc_badcode,");
  573. sql.Append("mbc_brcode,mbc_sncode,mbc_makecode,mbc_indate,mbc_inman ) values ");
  574. sql.Append("(makebadrscom_seq.nextval,'" + mbr_id + "' ,'" + MakeBadView.Rows[i].Cells["mbc_component"].Value.ToString() + "',");
  575. sql.Append("'" + MakeBadView.Rows[i].Cells["mb_badcode"].Value.ToString() + "','" + bgd_brcode + "','" + ms_sncode.Text + "','" + ma_code.Text + "',sysdate,'" + User.UserCode + "')");
  576. dh.ExecuteSql(sql.GetString(), "insert");
  577. }
  578. string[] mbp_part = MakeBadView.Rows[i].Cells["mbp_part"].Value.ToString().Split(',');
  579. string[] mbl_loc = MakeBadView.Rows[i].Cells["mbl_loc"].Value.ToString().Split(',');
  580. sql.Clear();
  581. sql.Append("insert into makebadrsloc(mbl_id,mbl_mbrid,mbl_loc,mbl_badcode,mbl_brcode,");
  582. sql.Append("mbl_sncode,mbl_makecode,mbl_indate ,mbl_inman) select makebadrsloc_seq.nextval," + mbr_id);
  583. sql.Append(",:mbl_loc,'" + MakeBadView.Rows[i].Cells["mb_badcode"].Value.ToString() + "','" + bgd_brcode + "','" + ms_sncode.Text + "','" + ma_code.Text + "',");
  584. sql.Append("sysdate,'" + User.UserCode + "' from dual");
  585. dh.BatchInsert(sql.GetString(), new string[] { "mbl_loc" }, mbl_loc);
  586. sql.Clear();
  587. sql.Append("with temp1 as (select bd_soncode,bd_location from bomdetail,bom where bo_id=bd_bomid ");
  588. sql.Append(" start with bo_mothercode='" + ma_prodcode + "' connect by bo_mothercode= prior bd_soncode) ");
  589. sql.Append("select bd_soncode from temp1 where instr(','||bd_location||',','," + MakeBadView.Rows[i].Cells["mbl_loc"].Value.ToString().ToUpper() + ",')>0");
  590. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  591. if (dt.Rows.Count > 0)
  592. {
  593. for (int j = 0; j < dt.Rows.Count; i++)
  594. {
  595. sql.Clear();
  596. sql.Append("insert into makebadrspart(mbp_id,mbp_mbrid,mbp_part,mbp_badcode,");
  597. sql.Append("mbp_brcode,mbp_sncode,mbp_makecode,mbp_indate,mbp_inman)");
  598. sql.Append("select makebadrspart_seq.nextval," + mbr_id + ",'" + dt.Rows[0][j].ToString() + "',");
  599. sql.Append("'" + MakeBadView.Rows[i].Cells["mb_badcode"].Value.ToString() + "','" + bgd_brcode + "','" + ms_sncode.Text + "','" + ma_code.Text + "',");
  600. sql.Append("sysdate,'" + User.UserCode + "' from dual");
  601. dh.ExecuteSql(sql.GetString(), "insert");
  602. }
  603. }
  604. sql.Clear();
  605. sql.Append("insert into makebadrspart(mbp_id,mbp_mbrid,mbp_part,mbp_badcode,");
  606. sql.Append("mbp_brcode,mbp_sncode,mbp_makecode,mbp_indate,mbp_inman)");
  607. sql.Append("select makebadrspart_seq.nextval," + mbr_id + ",:mbp_part,");
  608. sql.Append("'" + MakeBadView.Rows[i].Cells["mb_badcode"].Value.ToString() + "','" + bgd_brcode + "','" + ms_sncode.Text + "','" + ma_code.Text + "',");
  609. sql.Append("sysdate,'" + User.UserCode + "' from dual");
  610. dh.BatchInsert(sql.GetString(), new string[] { "mbp_part" }, mbp_part);
  611. }
  612. }
  613. 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 + "' ");
  614. List<string> SQLS = new List<string>();
  615. if (dt.Rows.Count > 0)
  616. {
  617. string ms_id = dt.Rows[0]["ms_id"].ToString();
  618. string ms_ifrework = dt.Rows[0]["ms_ifrework"].ToString();
  619. if (ms_ifrework == "0")
  620. SQLS.Add("update makeserial set ms_checkno='', ms_nextstepcode ='" + User.CurrentStepCode + "',ms_status=1,ms_stepcode='SMT_REPAIR' where ms_id='" + ms_id + "'");
  621. else
  622. SQLS.Add("update makeserial set ms_checkno='', ms_nextstepcode ='" + User.CurrentStepCode + "',ms_reworkstatus=1,ms_stepcode='SMT_REPAIR' where ms_id='" + ms_id + "'");
  623. }
  624. 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 + "'");
  625. dh.ExecuteSQLTran(SQLS.ToArray());
  626. LogicHandler.InsertMakeProcess(ms_sncode.Text, ma_code.Text, User.UserSourceCode, "快速维修采集", "完成快速维修", User.UserCode);
  627. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "快速维修采集", "完成快速维修", ms_sncode.Text, ob_checkno.Text);
  628. //保存不良原因
  629. LastSncode = ms_sncode.Text;
  630. //采集完不良,聚焦序列号
  631. ms_sncode.Focus();
  632. //记录操作日志
  633. ms_sncode.Text = "";
  634. //清除不良信息
  635. BaseUtil.CleanDGVData(MakeBadView);
  636. //加载页面信息
  637. LoadCollectedNum();
  638. LoadCheckQTY();
  639. }
  640. else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
  641. }
  642. }
  643. private void bc_code_KeyDown(object sender, KeyEventArgs e)
  644. {
  645. }
  646. private void LoadCheckQTY()
  647. {
  648. sql.Clear();
  649. string condition = "";
  650. int nowcheckqty = int.Parse(ob_nowcheckqty.Text == "" ? "0" : ob_nowcheckqty.Text);
  651. int batchqty = int.Parse(ob_batchqty.Text == "" ? "0" : ob_batchqty.Text);
  652. if (nowcheckqty + 1 == batchqty && AutoCut)
  653. {
  654. condition = "and ob_status='UNCHECK' and ob_checkno='" + ob_checkno.Text + "'";
  655. }
  656. else
  657. {
  658. condition = "and ob_status='ENTERING' ";
  659. }
  660. if (pr_sendchecktype.Text == "SaleCode")
  661. {
  662. condition += " and ob_salecode='" + ma_salecode.Text + "'";
  663. }
  664. sql.Append("select ob_batchqty,ob_nowcheckqty,ob_checkno from oqcbatch where ");
  665. sql.Append("ob_linecode='" + User.UserLineCode + "' and ob_prodcode='" + ma_prodcode.Text + "' and ");
  666. sql.Append("ob_stepcode='" + User.CurrentStepCode + "' " + condition);
  667. DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  668. if (dt.Rows.Count > 0)
  669. {
  670. ob_sendqty.Text = dh.getFieldDataByCondition("oqcbatch", "sum(ob_nowcheckqty)", "ob_makecode='" + ma_code.Text + "' and ob_status<>'ENTERING'").ToString();
  671. ob_batchqty.Text = dt.Rows[0]["ob_batchqty"].ToString();
  672. ob_nowcheckqty.Text = dt.Rows[0]["ob_nowcheckqty"].ToString();
  673. ob_checkno.Text = dt.Rows[0]["ob_checkno"].ToString();
  674. nowcheckqty = int.Parse(ob_nowcheckqty.Text == "" ? "0" : ob_nowcheckqty.Text);
  675. batchqty = int.Parse(ob_batchqty.Text == "" ? "0" : ob_batchqty.Text);
  676. if (nowcheckqty == batchqty)
  677. {
  678. ob_nowcheckqty.ForeColor = Color.Red;
  679. OperateResult.AppendText(">>当前采集数量已达到送检数量\n", Color.Red);
  680. if (AutoCut)
  681. {
  682. OperateResult.AppendText(">>批次" + ob_checkno.Text + "自动断批\n", Color.Green);
  683. }
  684. }
  685. }
  686. else
  687. {
  688. ob_batchqty.Text = "";
  689. ob_nowcheckqty.Text = "";
  690. ob_checkno.Text = "";
  691. SendCheck.Enabled = false;
  692. }
  693. if (ob_batchqty.Text != "")
  694. {
  695. SendCheck.Enabled = true;
  696. }
  697. else
  698. {
  699. SendCheck.Enabled = false;
  700. }
  701. }
  702. private void GoodProduct_CheckedChanged(object sender, EventArgs e)
  703. {
  704. if (GoodProduct.Checked)
  705. {
  706. WaitReject.Enabled = false;
  707. ChooseedReject.Enabled = false;
  708. Save.Visible = false;
  709. }
  710. else
  711. {
  712. WaitReject.Enabled = true;
  713. ChooseedReject.Enabled = true;
  714. Save.Visible = true;
  715. }
  716. if (ms_sncode.Text == "")
  717. {
  718. ms_sncode.Focus();
  719. }
  720. }
  721. private void SendCheck_Click(object sender, EventArgs e)
  722. {
  723. sql.Clear();
  724. sql.Append("update oqcbatch set ob_status='UNCHECK',ob_breakingdate=sysdate where ob_checkno ='" + ob_checkno.Text + "'");
  725. dh.ExecuteSql(sql.GetString(), "select");
  726. ob_sendqty.Text = dh.getFieldDataByCondition("oqcbatch", "sum(ob_nowcheckqty)", "ob_makecode='" + ma_code.Text + "' and ob_status<>'ENTERING'").ToString();
  727. ob_nowcheckqty.Text = "";
  728. ob_batchqty.Text = "";
  729. ob_nowcheckqty.ForeColor = Color.Black;
  730. SendCheck.Enabled = false;
  731. OperateResult.AppendText(">>批次" + ob_checkno.Text + "送检成功\n", Color.Green);
  732. ms_sncode.Focus();
  733. LogicHandler.InsertMakeProcess(LastSncode, ma_code.Text, User.UserSourceCode, "手动送检", "手动送检成功", User.UserCode);
  734. //记录操作日志
  735. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "手动送检", "手动送检成功", "", ob_checkno.Text);
  736. ob_checkno.Text = "";
  737. }
  738. private void ob_checkno_TextChanged(object sender, EventArgs e)
  739. {
  740. if (ob_checkno.Text != "")
  741. {
  742. string Cut = dh.getFieldDataByCondition("product left join oqcbatch on ob_prodcode=pr_code", "pr_ifautocutcheckno", "ob_checkno='" + ob_checkno.Text + "'").ToString();
  743. if (Cut == "" || Cut == "0")
  744. AutoCut = false;
  745. else
  746. AutoCut = true;
  747. SendCheck.Enabled = true;
  748. }
  749. }
  750. /// <summary>
  751. /// 工单变化修改数量
  752. /// </summary>
  753. /// <param name="sender"></param>
  754. /// <param name="e"></param>
  755. private void ma_code_UserControlTextChanged(object sender, EventArgs e)
  756. {
  757. if (ma_code.Text.Length > 4)
  758. {
  759. mcd_inqty.Text = "";
  760. mcd_remainqty.Text = "";
  761. ob_batchqty.Text = "";
  762. ob_nowcheckqty.Text = "";
  763. ob_sendqty.Text = "";
  764. LoadCollectedNum();
  765. LoadCheckQTY();
  766. }
  767. }
  768. private void Make_TestCollection_FormClosing(object sender, FormClosingEventArgs e)
  769. {
  770. dh.Dispose();
  771. }
  772. private void ma_prodcode_TextChanged(object sender, EventArgs e)
  773. {
  774. 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)";
  775. bd_soncode.Condition = "1=1";
  776. }
  777. private void Filter_UserControlTextChanged(object sender, EventArgs e)
  778. {
  779. try
  780. {
  781. DataRow[] dr = (BadInfSource.DataSource as DataTable).Select("bc_code like '%" + Filter.Text + "%' or bc_name like '%" + Filter.Text + "%'");
  782. DataTable dt = (BadInfSource.DataSource as DataTable).Clone();
  783. for (int i = 0; i < dr.Length; i++)
  784. {
  785. dt.Rows.Add(dr[i].ItemArray);
  786. }
  787. BaseUtil.FillDgvWithDataTable(WaitChooseDGV, dt);
  788. }
  789. catch (Exception)
  790. {
  791. }
  792. }
  793. private void Make_TestCollection_KeyDown(object sender, KeyEventArgs e)
  794. {
  795. if (e.Modifiers == Keys.Control && e.KeyCode == Keys.Q)
  796. {
  797. if (!LockSn)
  798. {
  799. ControlLockTimer.Start();
  800. LockSn = true;
  801. Lock_label.Visible = true;
  802. }
  803. else
  804. {
  805. ControlLockTimer.Stop();
  806. LockSn = false;
  807. Lock_label.Visible = false;
  808. }
  809. }
  810. }
  811. private void Reject_CheckedChanged(object sender, EventArgs e)
  812. {
  813. if (Reject.Checked)
  814. {
  815. LoadBadCodeListView();
  816. }
  817. }
  818. private void Prodcode_DbChange(object sender, EventArgs e)
  819. {
  820. MakeBadView.EndEdit();
  821. if (bd_soncode.Text != "")
  822. {
  823. for (int i = 0; i < MakeBadView.Rows.Count; i++)
  824. {
  825. if (MakeBadView.Rows[i].Cells["choose1"].Value != null)
  826. {
  827. if ((Boolean)MakeBadView.Rows[i].Cells["choose1"].Value == true)
  828. {
  829. if (MakeBadView.Rows[i].Cells["mbp_part"].Value.ToString() == "")
  830. {
  831. MakeBadView.Rows[i].Cells["mbp_part"].Value = bd_soncode.Text;
  832. }
  833. else if (!MakeBadView.Rows[i].Cells["mbp_part"].Value.ToString().Contains(bd_soncode.Text))
  834. MakeBadView.Rows[i].Cells["mbp_part"].Value += "," + bd_soncode.Text;
  835. if (MakeBadView.Rows[i].Cells["mbl_loc"].Value.ToString() == "")
  836. {
  837. MakeBadView.Rows[i].Cells["mbl_loc"].Value = psl_location.Text.ToUpper();
  838. }
  839. else if (!MakeBadView.Rows[i].Cells["mbl_loc"].Value.ToString().Contains(psl_location.Text.ToUpper()))
  840. MakeBadView.Rows[i].Cells["mbl_loc"].Value += "," + psl_location.Text.ToUpper();
  841. }
  842. }
  843. }
  844. }
  845. else OperateResult.AppendText(">>不良零件不能为空\n", Color.Red);
  846. }
  847. private void bd_soncode_UserControlTextChanged(object sender, EventArgs e)
  848. {
  849. }
  850. private void bd_soncode_Load(object sender, EventArgs e)
  851. {
  852. }
  853. private void bad_loc_KeyDown(object sender, KeyEventArgs e)
  854. {
  855. if (e.KeyCode == Keys.Enter)
  856. {
  857. if (ma_prodcode.Text != "")
  858. {
  859. if (psl_location.Text != "")
  860. {
  861. 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 + "' 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");
  862. if (dt.Rows.Count > 0)
  863. {
  864. if (dt.Rows.Count == 1)
  865. {
  866. string psl_prodcode = dt.Rows[0]["bd_soncode"].ToString();
  867. for (int i = 0; i < MakeBadView.Rows.Count; i++)
  868. {
  869. if (MakeBadView.Rows[i].Cells["choose1"].Value != null)
  870. {
  871. if ((Boolean)MakeBadView.Rows[i].Cells["choose1"].Value == true)
  872. {
  873. if (MakeBadView.Rows[i].Cells["mbp_part"].Value.ToString() == "")
  874. {
  875. MakeBadView.Rows[i].Cells["mbp_part"].Value = psl_prodcode;
  876. }
  877. else if (!MakeBadView.Rows[i].Cells["mbp_part"].Value.ToString().Contains(psl_prodcode))
  878. MakeBadView.Rows[i].Cells["mbp_part"].Value += "," + psl_prodcode;
  879. if (MakeBadView.Rows[i].Cells["mbl_loc"].Value.ToString() == "")
  880. {
  881. MakeBadView.Rows[i].Cells["mbl_loc"].Value = psl_location.Text.ToUpper();
  882. }
  883. else if (!MakeBadView.Rows[i].Cells["mbl_loc"].Value.ToString().Contains(psl_location.Text.ToUpper()))
  884. MakeBadView.Rows[i].Cells["mbl_loc"].Value += "," + psl_location.Text.ToUpper();
  885. }
  886. }
  887. }
  888. }
  889. else if (dt.Rows.Count > 1)
  890. {
  891. Boolean ifgetloc = false;
  892. for (int j = 0; j < dt.Rows.Count; j++)
  893. {
  894. string psl_prodcode = dt.Rows[j]["bd_soncode"].ToString();
  895. for (int i = 0; i < MakeBadView.Rows.Count; i++)
  896. {
  897. if (MakeBadView.Rows[i].Cells["choose1"].Value != null)
  898. {
  899. if ((Boolean)MakeBadView.Rows[i].Cells["choose1"].Value == true)
  900. {
  901. if (MakeBadView.Rows[i].Cells["mbp_part"].Value.ToString() == "")
  902. {
  903. OperateResult.AppendText(">>站位" + psl_location.Text + "有替代料,需要提前采集不良零件,第" + (i + 1) + "行不良零件为空\n", Color.Red);
  904. }
  905. else if (MakeBadView.Rows[i].Cells["mbp_part"].Value.ToString().Contains(psl_prodcode))
  906. {
  907. ifgetloc = true;
  908. if (MakeBadView.Rows[i].Cells["mbl_loc"].Value.ToString() == "")
  909. {
  910. MakeBadView.Rows[i].Cells["mbl_loc"].Value = psl_location.Text.ToUpper();
  911. }
  912. else if (!MakeBadView.Rows[i].Cells["mbl_loc"].Value.ToString().Contains(psl_location.Text.ToUpper()))
  913. MakeBadView.Rows[i].Cells["mbl_loc"].Value += "," + psl_location.Text.ToUpper();
  914. }
  915. }
  916. }
  917. }
  918. }
  919. if (!ifgetloc)
  920. {
  921. OperateResult.AppendText(">>站位" + psl_location.Text + "有替代料,需要提前采集不良零件,当前所选行均未采集对应不良零件\n", Color.Red);
  922. }
  923. }
  924. }
  925. else
  926. {
  927. OperateResult.AppendText(">>站位" + psl_location.Text.ToUpper() + "无对应物料\n", Color.Red, psl_location);
  928. }
  929. }
  930. else
  931. {
  932. OperateResult.AppendText(">>不良位置录入不能为空\n", Color.Red);
  933. }
  934. }
  935. else
  936. {
  937. OperateResult.AppendText(">>产品编号不能为空\n", Color.Red);
  938. }
  939. }
  940. }
  941. private void psl_location_Leave(object sender, EventArgs e)
  942. {
  943. psl_location.Text = "";
  944. }
  945. }
  946. }