Make_EquiConnect.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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. SNVal.Focus();
  80. SNVal.SelectAll();
  81. }
  82. private void ShowMsg(int type, string msg)
  83. {
  84. msg = msg.Replace("\r", "").Replace("\n", "");
  85. string msgTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  86. string showMsg = $"{msgTime}: {msg}\n";
  87. if (type == 0)
  88. {
  89. OperatResult.AppendText(showMsg, Color.Red);
  90. }
  91. else if (type == 1)
  92. {
  93. OperatResult.AppendText(showMsg, Color.Green);
  94. }
  95. else if (type == 2)
  96. {
  97. OperatResult.AppendText(showMsg, Color.GreenYellow);
  98. }
  99. }
  100. private void UpdateSN(string type, string sn)
  101. {
  102. if (type == "C")
  103. {
  104. serialNumber.Text = "";
  105. workOrder.Text = "";
  106. productCode.Text = "";
  107. productName.Text = "";
  108. TargetQty.Text = "";
  109. }
  110. else if (type == "L")
  111. {
  112. SQL.Clear();
  113. SQL.Append($@"SELECT ms_sncode,ma_code,pr_code,pr_spec,ma_qty FROM makeserial,make,product
  114. WHERE ms_sncode = '{sn}' AND ms_makecode = ma_code AND ms_prodcode = pr_code");
  115. dt = (DataTable)dh.ExecuteSql(SQL.ToString(), "select");
  116. if (dt.Rows.Count > 0)
  117. {
  118. serialNumber.Text = dt.Rows[0]["ms_sncode"].ToString();
  119. workOrder.Text = dt.Rows[0]["ma_code"].ToString();
  120. productCode.Text = dt.Rows[0]["pr_code"].ToString();
  121. productName.Text = dt.Rows[0]["pr_spec"].ToString();
  122. TargetQty.Text = dt.Rows[0]["ma_qty"].ToString();
  123. }
  124. else
  125. {
  126. UpdateSN("C", sn);
  127. }
  128. }
  129. }
  130. private void EmployeeVal_KeyDown_1(object sender, KeyEventArgs e)
  131. {
  132. if (e.KeyCode != Keys.Enter) return;
  133. if (string.IsNullOrEmpty(EmployeeVal.Text)) return;
  134. dt = (DataTable)dh.ExecuteSql($"select * from employee where em_name = '{EmployeeVal.Text.Trim()}'", "select");
  135. if (dt.Rows.Count == 0)
  136. {
  137. MessageBox.Show("请输入正确人员账号");
  138. EmployeeVal.Text = "";
  139. EmployeeVal.Focus();
  140. EmployeeVal.SelectAll();
  141. return;
  142. }
  143. }
  144. private void EmployeeVal_Leave_1(object sender, EventArgs e)
  145. {
  146. if (string.IsNullOrEmpty(EmployeeVal.Text)) return;
  147. dt = (DataTable)dh.ExecuteSql($"select * from employee where em_name = '{EmployeeVal.Text.Trim()}'", "select");
  148. if (dt.Rows.Count == 0)
  149. {
  150. MessageBox.Show("请输入正确人员账号");
  151. EmployeeVal.Text = "";
  152. EmployeeVal.Focus();
  153. EmployeeVal.SelectAll();
  154. return;
  155. }
  156. }
  157. }
  158. }