Make_EquiConnect.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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(LineVal.Text))
  36. {
  37. ShowMsg(0, "请选择线体");
  38. return;
  39. }
  40. if (string.IsNullOrEmpty(SNVal.Text))
  41. {
  42. ShowMsg(0, "请选择扫描序列号");
  43. return;
  44. }
  45. InsertLog("OK");
  46. }
  47. private void NG_Click(object sender, EventArgs e)
  48. {
  49. if (string.IsNullOrEmpty(LineVal.Text))
  50. {
  51. ShowMsg(0, "请选择线体");
  52. return;
  53. }
  54. if (string.IsNullOrEmpty(SNVal.Text))
  55. {
  56. ShowMsg(0, "请选择扫描序列号");
  57. return;
  58. }
  59. InsertLog("NG");
  60. }
  61. private void InsertLog(string resType)
  62. {
  63. UpdateSN("L", SNVal.Text.Trim());
  64. dh.ExecuteSql($@"INSERT INTO steptestdetail (std_id,std_sn,std_makecode,std_class,std_testresult,std_indate,std_rescode)
  65. VALUES (steptestdetail_seq.NEXTVAL, '{SNVal.Text.Trim()}','{workOrder.Text.Trim()}','Xray抽检','{resType}',sysdate, '{User.CurrentStepCode}')", "insert");
  66. ShowMsg(1, $"已记录 {SNVal.Text.Trim()},测试结果为 {resType}");
  67. SNVal.Focus();
  68. SNVal.SelectAll();
  69. }
  70. private void ShowMsg(int type, string msg)
  71. {
  72. msg = msg.Replace("\r", "").Replace("\n", "");
  73. string msgTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  74. string showMsg = $"{msgTime}: {msg}\n";
  75. if (type == 0)
  76. {
  77. OperatResult.AppendText(showMsg, Color.Red);
  78. }
  79. else if (type == 1)
  80. {
  81. OperatResult.AppendText(showMsg, Color.Green);
  82. }
  83. else if (type == 2)
  84. {
  85. OperatResult.AppendText(showMsg, Color.GreenYellow);
  86. }
  87. }
  88. private void UpdateSN(string type, string sn)
  89. {
  90. if (type == "C")
  91. {
  92. serialNumber.Text = "";
  93. workOrder.Text = "";
  94. productCode.Text = "";
  95. productName.Text = "";
  96. }
  97. else if (type == "L")
  98. {
  99. SQL.Clear();
  100. SQL.Append($@"SELECT ms_sncode,ma_code,pr_code,pr_spec FROM makeserial,make,product
  101. WHERE ms_sncode = '{sn}' AND ms_makecode = ma_code AND ms_prodcode = pr_code");
  102. dt = (DataTable)dh.ExecuteSql(SQL.ToString(), "select");
  103. if (dt.Rows.Count > 0)
  104. {
  105. serialNumber.Text = dt.Rows[0]["ms_sncode"].ToString();
  106. workOrder.Text = dt.Rows[0]["ma_code"].ToString();
  107. productCode.Text = dt.Rows[0]["pr_code"].ToString();
  108. productName.Text = dt.Rows[0]["pr_spec"].ToString();
  109. }
  110. else
  111. {
  112. UpdateSN("C", sn);
  113. }
  114. }
  115. }
  116. }
  117. }