Make_WirelessTest.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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_WirelessTest : Form
  22. {
  23. StringBuilder sql = new StringBuilder();
  24. DataHelper dh = new DataHelper();
  25. DataTable dt = new DataTable();
  26. string SN,WO = "";
  27. public Make_WirelessTest()
  28. {
  29. InitializeComponent();
  30. }
  31. private void Make_WirelessTest_Load(object sender, EventArgs e)
  32. {
  33. }
  34. private void GetSNCode_KeyDown(object sender, KeyEventArgs e)
  35. {
  36. if (e.KeyCode == Keys.Enter)
  37. {
  38. if (GetSNCode.Text == "")
  39. {
  40. ShowMsg(0, "序列号不允许为空");
  41. ClearSnDetail();
  42. return;
  43. }
  44. string oStatus, ErrorMessage = "";
  45. if (LogicHandler.GetMakeInfo(GetSNCode.Text.Trim(), out WO, out oStatus, out ErrorMessage))
  46. {
  47. sql.Clear();
  48. sql.Append($@"SELECT ms_sncode,ma_code,ms_prodcode,pr_detail
  49. FROM makeserial,make,product WHERE ms_sncode = '{GetSNCode.Text.Trim()}'
  50. AND ms_makecode = ma_code AND ma_prodcode = pr_code");
  51. dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
  52. if (dt.Rows.Count > 0)
  53. {
  54. SetSnDetail(dt);
  55. }
  56. }
  57. else
  58. {
  59. ShowMsg(0, "序列号不存在");
  60. ClearSnDetail();
  61. return;
  62. }
  63. SN = GetSNCode.Text.Trim();
  64. GetSNCode.Focus();
  65. GetSNCode.SelectAll();
  66. }
  67. }
  68. private void Clean_Click(object sender, EventArgs e)
  69. {
  70. OperatResult.Clear();
  71. }
  72. private void SetSnDetail(DataTable dt)
  73. {
  74. snVal.Text = dt.Rows[0]["ms_sncode"].ToString();
  75. woVal.Text = dt.Rows[0]["ma_code"].ToString();
  76. prodVal.Text = dt.Rows[0]["ms_prodcode"].ToString();
  77. prodNameVal.Text = dt.Rows[0]["pr_detail"].ToString();
  78. }
  79. private void ClearSnDetail()
  80. {
  81. snVal.Text = "";
  82. woVal.Text = "";
  83. prodVal.Text = "";
  84. prodNameVal.Text = "";
  85. }
  86. private void OK_Click(object sender, EventArgs e)
  87. {
  88. PassStation("OK");
  89. }
  90. private void NG_Click(object sender, EventArgs e)
  91. {
  92. PassStation("NG");
  93. }
  94. private void PassStation(string testResult)
  95. {
  96. if (GetSNCode.Text.Trim() == "" || string.IsNullOrEmpty(SN))
  97. {
  98. ShowMsg(0, "序列号不允许为空,请Enter");
  99. ClearSnDetail();
  100. return;
  101. }
  102. string omakeCode, oMsid, oErrorMessage;
  103. if (LogicHandler.CheckStepSNAndMacode(WO, User.UserSourceCode, SN, User.UserCode, out omakeCode, out oMsid, out oErrorMessage))
  104. {
  105. if (LogicHandler.SetStepResult(omakeCode, User.UserSourceCode, SN, "无线吞吐量测试", testResult, User.UserCode, out oErrorMessage))
  106. {
  107. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, WO, User.UserLineCode, User.UserSourceCode, "无线吞吐量测试", "", SN, "");
  108. sql.Clear();
  109. sql.Append($@"INSERT INTO steptestdetail (std_id,std_sn,std_makecode,
  110. std_rescode,std_date,std_indate,std_class,std_value1,std_stepcode) VALUES
  111. (steptestdetail_seq.NEXTVAL,'{SN}','{WO}',
  112. '{User.UserSourceCode}',sysdate,sysdate,'无线吞吐量测试','{testResult}', '{User.CurrentStepCode}' )");
  113. dh.ExecuteSql(sql.ToString(), "insert");
  114. ShowMsg(1, $"{SN}: 过站记录成功,结果为{testResult}");
  115. GetSNCode.Text = "";
  116. ClearSnDetail();
  117. }
  118. else
  119. {
  120. ShowMsg(0, $"过站处理记录NG: {oErrorMessage}");
  121. }
  122. }
  123. else
  124. {
  125. ShowMsg(0, $"过站核对NG: {oErrorMessage}");
  126. }
  127. }
  128. private void ShowMsg(int type, string msg)
  129. {
  130. string fullDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  131. if (type == 0)
  132. {
  133. OperatResult.AppendText($"{fullDateTime}: {msg}\n", Color.Red);
  134. }
  135. else if (type == 1)
  136. {
  137. OperatResult.AppendText($"{fullDateTime}: {msg}\n", Color.Black);
  138. }
  139. }
  140. }
  141. }