Make_SmtbdTestCollection.cs 63 KB

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