Make_BurnInspection.cs 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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. ShowMsg(1, $"工单: {ma_code.Text} 已找到{dt.Rows.Count}条烧录记录");
  77. }
  78. private void ClearMsg_Click(object sender, EventArgs e)
  79. {
  80. OperatResult.Clear();
  81. }
  82. private void OK_Click(object sender, EventArgs e)
  83. {
  84. PassStation("OK");
  85. }
  86. private void NG_Click(object sender, EventArgs e)
  87. {
  88. PassStation("NG");
  89. }
  90. private void PassStation(string testResult)
  91. {
  92. BurnLotnoVal.Text = BurnLotnoVal.Text.Trim();
  93. if (string.IsNullOrEmpty(EmployeeVal.Text))
  94. {
  95. ShowMsg(0, $"请填写抽检人员");
  96. return;
  97. }
  98. if (DataBox.Rows.Count == 0)
  99. {
  100. ShowMsg(0, $"请选择工单筛选出烧录信息");
  101. return;
  102. }
  103. if (string.IsNullOrEmpty(BurnLotnoVal.Text))
  104. {
  105. ShowMsg(0, $"请扫描烧录批号");
  106. return;
  107. }
  108. foreach (DataGridViewRow item in DataBox.Rows)
  109. {
  110. string currLotNo = item.Cells["burn_lotno"].Value.ToString();
  111. if (currLotNo == BurnLotnoVal.Text.Trim())
  112. {
  113. burnId = item.Cells["BURN_ID"].Value.ToString();
  114. }
  115. }
  116. if (string.IsNullOrEmpty(burnId))
  117. {
  118. ShowMsg(0, $"请抽检所查询中烧录批号");
  119. return;
  120. }
  121. dt = (DataTable)dh.ExecuteSql($@"select * from burn_inspect where burn_lotno = '{BurnLotnoVal.Text}'", "select");
  122. if (dt.Rows.Count > 0)
  123. {
  124. ShowMsg(0, $"批号 {BurnLotnoVal.Text}已抽检");
  125. return;
  126. }
  127. SQL.Clear();
  128. SQL.Append($@"INSERT INTO burn_inspect (burn_inspect_id,BURNLOTNO,BURNID,
  129. inspect_res,inspect_time,inspect_name) VALUES (burn_inspect_seq.NEXTVAL, '{BurnLotnoVal.Text}',{burnId},
  130. '{testResult}',sysdate,'{User.UserName}')");
  131. dh.ExecuteSql(SQL.ToString(), "insert");
  132. ShowMsg(1, $"{BurnLotnoVal.Text} 记录抽检结果{testResult} 成功");
  133. BurnLotnoVal.Focus();
  134. BurnLotnoVal.SelectAll();
  135. }
  136. private void BurnLotnoVal_KeyDown(object sender, KeyEventArgs e)
  137. {
  138. if (e.KeyCode != Keys.Enter) return;
  139. if (OkBox.Checked)
  140. {
  141. PassStation("OK");
  142. }
  143. else
  144. {
  145. PassStation("NG");
  146. }
  147. }
  148. private void OkBox_Click(object sender, EventArgs e)
  149. {
  150. NgBox.Checked = false;
  151. }
  152. private void NgBox_Click(object sender, EventArgs e)
  153. {
  154. OkBox.Checked = false;
  155. }
  156. private void ShowMsg(int type, string msg)
  157. {
  158. string fullDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  159. if (type == 0)
  160. {
  161. OperatResult.AppendText($"{fullDateTime}: {msg}\n", Color.Red);
  162. }
  163. else if (type == 1)
  164. {
  165. OperatResult.AppendText($"{fullDateTime}: {msg}\n", Color.Green);
  166. }
  167. else if (type == 1)
  168. {
  169. OperatResult.AppendText($"{fullDateTime}: {msg}\n", Color.YellowGreen);
  170. }
  171. }
  172. }
  173. }