Make_EquiConnect.cs 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using UAS_MES_NEW.DataOperate;
  10. using UAS_MES_NEW.Entity;
  11. namespace UAS_MES_NEW.Make
  12. {
  13. public partial class Make_EquiConnect : Form
  14. {
  15. public Make_EquiConnect()
  16. {
  17. InitializeComponent();
  18. }
  19. StringBuilder SQL = new StringBuilder();
  20. DataHelper dh = SystemInf.dh;
  21. DataTable dt;
  22. private void Make_EquiConnect_Load(object sender, EventArgs e)
  23. {
  24. dt = (DataTable)dh.ExecuteSql("SELECT * FROM line WHERE li_wcname = 'SMT' ORDER BY li_auditdate", "select");
  25. if (dt.Rows.Count > 0)
  26. {
  27. foreach (DataRow item in dt.Rows)
  28. {
  29. LineVal.Items.Add(item["li_code"].ToString());
  30. }
  31. }
  32. }
  33. private void OK_Click(object sender, EventArgs e)
  34. {
  35. if (string.IsNullOrEmpty(EmployeeVal.Text))
  36. {
  37. ShowMsg(0, "请输入抽检人员姓名");
  38. return;
  39. }
  40. if (string.IsNullOrEmpty(LineVal.Text))
  41. {
  42. ShowMsg(0, "请选择线体");
  43. return;
  44. }
  45. if (string.IsNullOrEmpty(SNVal.Text))
  46. {
  47. ShowMsg(0, "请选择扫描序列号");
  48. return;
  49. }
  50. InsertLog("OK");
  51. }
  52. private void NG_Click(object sender, EventArgs e)
  53. {
  54. if (string.IsNullOrEmpty(EmployeeVal.Text))
  55. {
  56. ShowMsg(0, "请输入抽检人员姓名");
  57. return;
  58. }
  59. if (string.IsNullOrEmpty(LineVal.Text))
  60. {
  61. ShowMsg(0, "请选择线体");
  62. return;
  63. }
  64. if (string.IsNullOrEmpty(SNVal.Text))
  65. {
  66. ShowMsg(0, "请选择扫描序列号");
  67. return;
  68. }
  69. InsertLog("NG");
  70. }
  71. private void InsertLog(string resType)
  72. {
  73. UpdateSN("L", SNVal.Text.Trim());
  74. SQL.Clear();
  75. SQL.Append($@"INSERT INTO steptestdetail (std_id,std_sn,std_makecode,std_class,std_testresult,std_indate,STD_SUBCLASS1,STD_SUBCLASS2)
  76. VALUES (steptestdetail_seq.NEXTVAL, '{SNVal.Text.Trim()}','{workOrder.Text.Trim()}','Xray抽检','{resType}',sysdate, '{LineVal.Text}','{EmployeeVal.Text.Trim()}')");
  77. dh.ExecuteSql(SQL.ToString(), "insert");
  78. ShowMsg(1, $"已记录 {SNVal.Text.Trim()},测试结果为 {resType}");
  79. }
  80. private void ShowMsg(int type, string msg)
  81. {
  82. msg = msg.Replace("\r", "").Replace("\n", "");
  83. string msgTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  84. string showMsg = $"{msgTime}: {msg}\n";
  85. if (type == 0)
  86. {
  87. OperatResult.AppendText(showMsg, Color.Red);
  88. }
  89. else if (type == 1)
  90. {
  91. OperatResult.AppendText(showMsg, Color.Green);
  92. }
  93. else if (type == 2)
  94. {
  95. OperatResult.AppendText(showMsg, Color.GreenYellow);
  96. }
  97. }
  98. private void UpdateSN(string type, string sn)
  99. {
  100. if (type == "C")
  101. {
  102. serialNumber.Text = "";
  103. workOrder.Text = "";
  104. productCode.Text = "";
  105. productName.Text = "";
  106. TargetQty.Text = "";
  107. }
  108. else if (type == "L")
  109. {
  110. SQL.Clear();
  111. SQL.Append($@"SELECT ms_sncode,ma_code,pr_code,pr_spec,ma_qty FROM makeserial,make,product
  112. WHERE ms_sncode = '{sn}' AND ms_makecode = ma_code AND ms_prodcode = pr_code");
  113. dt = (DataTable)dh.ExecuteSql(SQL.ToString(), "select");
  114. if (dt.Rows.Count > 0)
  115. {
  116. serialNumber.Text = dt.Rows[0]["ms_sncode"].ToString();
  117. workOrder.Text = dt.Rows[0]["ma_code"].ToString();
  118. productCode.Text = dt.Rows[0]["pr_code"].ToString();
  119. productName.Text = dt.Rows[0]["pr_spec"].ToString();
  120. TargetQty.Text = dt.Rows[0]["ma_qty"].ToString();
  121. }
  122. else
  123. {
  124. UpdateSN("C", sn);
  125. }
  126. }
  127. }
  128. private void EmployeeVal_KeyDown_1(object sender, KeyEventArgs e)
  129. {
  130. if (e.KeyCode != Keys.Enter) return;
  131. if (string.IsNullOrEmpty(EmployeeVal.Text)) return;
  132. dt = (DataTable)dh.ExecuteSql($"select * from employee where em_name = '{EmployeeVal.Text.Trim()}'", "select");
  133. if (dt.Rows.Count == 0)
  134. {
  135. MessageBox.Show("请输入正确人员账号");
  136. EmployeeVal.Text = "";
  137. EmployeeVal.Focus();
  138. EmployeeVal.SelectAll();
  139. return;
  140. }
  141. }
  142. private void EmployeeVal_Leave_1(object sender, EventArgs e)
  143. {
  144. if (string.IsNullOrEmpty(EmployeeVal.Text)) return;
  145. dt = (DataTable)dh.ExecuteSql($"select * from employee where em_name = '{EmployeeVal.Text.Trim()}'", "select");
  146. if (dt.Rows.Count == 0)
  147. {
  148. MessageBox.Show("请输入正确人员账号");
  149. EmployeeVal.Text = "";
  150. EmployeeVal.Focus();
  151. EmployeeVal.SelectAll();
  152. return;
  153. }
  154. }
  155. private void NgBox_Click(object sender, EventArgs e)
  156. {
  157. OkBox.Checked = false;
  158. }
  159. private void OkBox_Click(object sender, EventArgs e)
  160. {
  161. NgBox.Checked = false;
  162. }
  163. private void SNVal_KeyDown(object sender, KeyEventArgs e)
  164. {
  165. if (e.KeyCode != Keys.Enter) return;
  166. SNVal.Text = SNVal.Text.Trim();
  167. if (string.IsNullOrEmpty(EmployeeVal.Text))
  168. {
  169. ShowMsg(0, "请输入抽检人员姓名");
  170. return;
  171. }
  172. dt = (DataTable)dh.ExecuteSql($@"SELECT ms_makecode,ms_prodcode,cd_stepcode,cd_stepname,cd_stepno FROM makeserial,craft,craftdetail
  173. WHERE ms_sncode = '{SNVal.Text}' AND ms_prodcode = cr_prodcode AND cr_id = cd_crid AND cd_stepno = 1 ORDER BY cd_stepno", "select");
  174. if (dt.Rows.Count == 0)
  175. {
  176. ShowMsg(0, $"序列号:{SNVal.Text} 无归属记录,请过投入站后再采集Xray信息");
  177. return;
  178. }
  179. dt = (DataTable)dh.ExecuteSql($@"SELECT mp_linecode FROM makeprocess WHERE mp_sncode = '{SNVal.Text}' AND mp_stepcode = '{dt.Rows[0]["cd_stepcode"]}'", "select");
  180. if (dt.Rows.Count == 0)
  181. {
  182. ShowMsg(0, $"序列号:{SNVal.Text} 无投入过站记录,请过投入站后再采集Xray信息");
  183. return;
  184. }
  185. for (int i = 0; i <= LineVal.Items.Count; i++)
  186. {
  187. string mplinecode = dt.Rows[0]["mp_linecode"].ToString();
  188. string allLine = LineVal.Items[i].ToString();
  189. if (mplinecode == allLine)
  190. {
  191. LineVal.SelectedIndex = i;
  192. break;
  193. }
  194. }
  195. if (string.IsNullOrEmpty(LineVal.Text))
  196. {
  197. ShowMsg(0, "请选择线体");
  198. return;
  199. }
  200. if(!OkBox.Checked && !NgBox.Checked)
  201. {
  202. ShowMsg(0, "请勾选判定结果");
  203. return;
  204. }
  205. if (string.IsNullOrEmpty(SNVal.Text))
  206. {
  207. ShowMsg(0, "请选择扫描序列号");
  208. return;
  209. }
  210. InsertLog(OkBox.Checked ? "OK" : "NG");
  211. SNVal.Focus();
  212. SNVal.SelectAll();
  213. }
  214. }
  215. }