Make_EquiConnect.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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. dh.ExecuteSql($@"INSERT INTO steptestdetail (std_id,std_sn,std_makecode,std_class,std_testresult,std_indate,std_rescode)
  75. VALUES (steptestdetail_seq.NEXTVAL, '{SNVal.Text.Trim()}','{workOrder.Text.Trim()}','Xray抽检','{resType}',sysdate, '{User.CurrentStepCode}')", "insert");
  76. ShowMsg(1, $"已记录 {SNVal.Text.Trim()},测试结果为 {resType}");
  77. SNVal.Focus();
  78. SNVal.SelectAll();
  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_code = '{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_code = '{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. }
  156. }