Make_BurnInspection.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. using DevExpress.Printing.Core.PdfExport.Metafile;
  2. using NPOI.SS.Formula.Eval;
  3. using System;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. using System.ComponentModel;
  7. using System.Configuration.Assemblies;
  8. using System.Data;
  9. using System.Diagnostics;
  10. using System.Drawing;
  11. using System.IO;
  12. using System.Linq;
  13. using System.Text;
  14. using System.Windows.Forms;
  15. using System.Xml;
  16. using UAS_MES_NEW.DataOperate;
  17. using UAS_MES_NEW.Entity;
  18. using UAS_MES_NEW.PublicMethod;
  19. namespace UAS_MES_NEW.Make
  20. {
  21. public partial class Make_BurnInspection : Form
  22. {
  23. StringBuilder SQL = new StringBuilder();
  24. LogStringBuilder sql = new LogStringBuilder();
  25. DataHelper dh = new DataHelper();
  26. DataTable Dbfind;
  27. DataTable dt = new DataTable();
  28. string SN,WO = "";
  29. string burnId;
  30. public Make_BurnInspection()
  31. {
  32. InitializeComponent();
  33. }
  34. private void Make_WirelessTest_Load(object sender, EventArgs e)
  35. {
  36. //设置锁定工单
  37. LockMakeCode.GetMakeCodeCtl(ma_code);
  38. ma_code.SetLockCheckBox(LockMakeCode);
  39. //工单号放大镜配置
  40. ma_code.TableName = "make left join product on ma_prodcode=pr_code";
  41. ma_code.SelectField = "ma_code # 工单号,pr_code # 产品编号,pr_detail # 产品名称";
  42. ma_code.FormName = Name;
  43. ma_code.SetValueField = new string[] { "ma_code", "pr_code", "pr_detail" };
  44. ma_code.Condition = "ma_statuscode='STARTED'";
  45. ma_code.DbChange += Ma_code_DbChange;
  46. dh = SystemInf.dh;
  47. }
  48. private void Ma_code_DbChange(object sender, EventArgs e)
  49. {
  50. Dbfind = ma_code.ReturnData;
  51. BaseUtil.SetFormValue(this.Controls, Dbfind);
  52. //获取工单的其他信息
  53. sql.Clear();
  54. sql.Append("select ma_code,nvl(mcd_okqty,0) mcd_okqty,ma_prodcode as pr_code ,pr_detail,");
  55. sql.Append("pr_spec,ma_qty - nvl(mcd_inqty, 0) mcd_remainqty,ma_qty from make left join makecraftdetail on ");
  56. sql.Append("mcd_maid=ma_id left join product on pr_code=ma_prodcode where ma_code='" + ma_code.Text + "'");
  57. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  58. if (dt.Rows.Count > 0)
  59. {
  60. BaseUtil.SetFormValue(this.Controls, dt);
  61. }
  62. SQL.Clear();
  63. if (!string.IsNullOrEmpty(ma_code.Text))
  64. {
  65. SQL.Append($"AND a.work_order = '{ma_code.Text}'");
  66. }
  67. dt = (DataTable)dh.ExecuteSql($@"SELECT a.burn_id,a.burn_lotno,a.work_order,
  68. a.line,a.burn_software,a.check_code,
  69. a.dot_detail,b.inspect_time,b.inspect_name,b.inspect_res
  70. FROM burn_info a LEFT JOIN burn_inspect b ON a.burn_id = b.burn_id
  71. WHERE 1 = 1 {SQL.ToString()}", "select");
  72. if (dt.Rows.Count > 0)
  73. {
  74. DataBox.DataSource = dt;
  75. }
  76. }
  77. private void ClearMsg_Click(object sender, EventArgs e)
  78. {
  79. OperatResult.Clear();
  80. }
  81. private void OK_Click(object sender, EventArgs e)
  82. {
  83. PassStation("OK");
  84. }
  85. private void NG_Click(object sender, EventArgs e)
  86. {
  87. PassStation("NG");
  88. }
  89. private void PassStation(string testResult)
  90. {
  91. BurnLotnoVal.Text = BurnLotnoVal.Text.Trim();
  92. if (DataBox.Rows.Count == 0)
  93. {
  94. ShowMsg(0, $"请先查询出烧录批号");
  95. return;
  96. }
  97. if (string.IsNullOrEmpty(BurnLotnoVal.Text))
  98. {
  99. ShowMsg(0, $"请扫描烧录批号");
  100. return;
  101. }
  102. foreach (DataGridViewRow item in DataBox.Rows)
  103. {
  104. string currLotNo = item.Cells["burn_lotno"].Value.ToString();
  105. if (currLotNo == BurnLotnoVal.Text.Trim())
  106. {
  107. burnId = item.Cells["BURN_ID"].Value.ToString();
  108. }
  109. }
  110. if (string.IsNullOrEmpty(burnId))
  111. {
  112. ShowMsg(0, $"请抽检所查询中烧录批号");
  113. return;
  114. }
  115. dt = (DataTable)dh.ExecuteSql($@"select * from burn_inspect where burn_lotno = '{BurnLotnoVal.Text}'", "select");
  116. if (dt.Rows.Count > 0)
  117. {
  118. ShowMsg(0, $"批号 {BurnLotnoVal.Text}已抽检");
  119. return;
  120. }
  121. SQL.Clear();
  122. SQL.Append($@"INSERT INTO burn_inspect (burn_inspect_id,burn_lotno,burn_id,
  123. inspect_res,inspect_time,inspect_name) VALUES (burn_inspect_seq.NEXTVAL, '{BurnLotnoVal.Text}',{burnId},
  124. '{testResult}',sysdate,'{User.UserName}')");
  125. dh.ExecuteSql(SQL.ToString(), "insert");
  126. ShowMsg(1, $"{BurnLotnoVal.Text} 记录抽检结果{testResult} 成功");
  127. BurnLotnoVal.Focus();
  128. BurnLotnoVal.SelectAll();
  129. }
  130. private void ShowMsg(int type, string msg)
  131. {
  132. string fullDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  133. if (type == 0)
  134. {
  135. OperatResult.AppendText($"{fullDateTime}: {msg}\n", Color.Red);
  136. }
  137. else if (type == 1)
  138. {
  139. OperatResult.AppendText($"{fullDateTime}: {msg}\n", Color.Green);
  140. }
  141. else if (type == 1)
  142. {
  143. OperatResult.AppendText($"{fullDateTime}: {msg}\n", Color.YellowGreen);
  144. }
  145. }
  146. }
  147. }