Make_BurnInspection.cs 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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 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 + "' and mcd_stepcode='" + User.CurrentStepCode + "'");
  57. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  58. if (dt.Rows.Count > 0)
  59. {
  60. BaseUtil.SetFormValue(this.Controls, dt);
  61. }
  62. }
  63. private void ClearMsg_Click(object sender, EventArgs e)
  64. {
  65. OperatResult.Clear();
  66. }
  67. private void OK_Click(object sender, EventArgs e)
  68. {
  69. PassStation("OK");
  70. }
  71. private void NG_Click(object sender, EventArgs e)
  72. {
  73. PassStation("NG");
  74. }
  75. private void PassStation(string testResult)
  76. {
  77. BurnLotnoVal.Text = BurnLotnoVal.Text.Trim();
  78. if (DataBox.Rows.Count == 0)
  79. {
  80. ShowMsg(0, $"请先查询出烧录批号");
  81. return;
  82. }
  83. if (string.IsNullOrEmpty(BurnLotnoVal.Text))
  84. {
  85. ShowMsg(0, $"请扫描烧录批号");
  86. return;
  87. }
  88. foreach (DataGridViewRow item in DataBox.Rows)
  89. {
  90. string currLotNo = item.Cells["burn_lotno"].Value.ToString();
  91. if (currLotNo == BurnLotnoVal.Text.Trim())
  92. {
  93. burnId = item.Cells["BURN_ID"].Value.ToString();
  94. }
  95. }
  96. if (string.IsNullOrEmpty(burnId))
  97. {
  98. ShowMsg(0, $"请抽检所查询中烧录批号");
  99. return;
  100. }
  101. dt = (DataTable)dh.ExecuteSql($@"select * from burn_inspect where burn_lotno = '{BurnLotnoVal.Text}'", "select");
  102. if (dt.Rows.Count > 0)
  103. {
  104. ShowMsg(0, $"批号 {BurnLotnoVal.Text}已抽检");
  105. return;
  106. }
  107. SQL.Clear();
  108. SQL.Append($@"INSERT INTO burn_inspect (burn_inspect_id,burn_lotno,burn_id,
  109. inspect_res,inspect_time,inspect_name) VALUES (burn_inspect_seq.NEXTVAL, '{BurnLotnoVal.Text}',{burnId},
  110. '{testResult}',sysdate,'{User.UserName}')");
  111. dh.ExecuteSql(SQL.ToString(), "insert");
  112. ShowMsg(1, $"{BurnLotnoVal.Text} 记录抽检结果{testResult} 成功");
  113. BurnLotnoVal.Focus();
  114. BurnLotnoVal.SelectAll();
  115. }
  116. private void Query_Click(object sender, EventArgs e)
  117. {
  118. if(string.IsNullOrEmpty(ma_code.Text) && string.IsNullOrEmpty(LineVal.Text))
  119. {
  120. ShowMsg(0, $"请选择工单或者线体");
  121. return;
  122. }
  123. SQL.Clear();
  124. if (!string.IsNullOrEmpty(ma_code.Text))
  125. {
  126. SQL.Append($"AND a.work_order = '{ma_code.Text}'");
  127. }
  128. if (!string.IsNullOrEmpty(LineVal.Text))
  129. {
  130. SQL.Append($"AND a.line = '{LineVal.Text}'");
  131. }
  132. dt = (DataTable)dh.ExecuteSql($@"SELECT a.burn_id,a.burn_lotno,a.work_order,
  133. a.line,a.burn_software,a.check_code,
  134. a.dot_detail,b.inspect_time,b.inspect_name,b.inspect_res
  135. FROM burn_info a LEFT JOIN burn_inspect b ON a.burn_id = b.burn_id
  136. WHERE 1 = 1 {SQL.ToString()}", "select");
  137. if (dt.Rows.Count > 0)
  138. {
  139. DataBox.DataSource = dt;
  140. }
  141. }
  142. private void ShowMsg(int type, string msg)
  143. {
  144. string fullDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  145. if (type == 0)
  146. {
  147. OperatResult.AppendText($"{fullDateTime}: {msg}\n", Color.Red);
  148. }
  149. else if (type == 1)
  150. {
  151. OperatResult.AppendText($"{fullDateTime}: {msg}\n", Color.Green);
  152. }
  153. else if (type == 1)
  154. {
  155. OperatResult.AppendText($"{fullDateTime}: {msg}\n", Color.YellowGreen);
  156. }
  157. }
  158. }
  159. }