Make_ReadWriteInfo.cs 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.IO;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Windows.Forms;
  10. using UAS_MES_NEW.DataOperate;
  11. using UAS_MES_NEW.Entity;
  12. using UAS_MES_NEW.PublicForm;
  13. using UAS_MES_NEW.PublicMethod;
  14. namespace UAS_MES_NEW.Make
  15. {
  16. public partial class Make_ReadWriteInfo : Form
  17. {
  18. AutoSizeFormClass asc = new AutoSizeFormClass();
  19. DataHelper dh;
  20. LogStringBuilder sql;
  21. string oErrorMessage = "";
  22. string omakeCode = "";
  23. string oMsid = "";
  24. public Make_ReadWriteInfo()
  25. {
  26. InitializeComponent();
  27. }
  28. private void Make_LabelCheck_Load(object sender, EventArgs e)
  29. {
  30. asc.controllInitializeSize(this);
  31. //聚焦SN号
  32. sncode.Focus();
  33. //打开界面提示用户:请输入SN
  34. OperateResult.AppendText(">>请输入SN\n", Color.Black);
  35. sql = new LogStringBuilder();
  36. dh = SystemInf.dh;
  37. StepCount.StepCode = User.CurrentStepCode;
  38. StepCount.Source = User.UserSourceCode;
  39. StepCount.LineCode = User.UserLineCode;
  40. StepCount.Dh = dh;
  41. StepCount.Start();
  42. FileWatcher.Path = WatchPath.Text;
  43. FileWatcher.Filter = "*.log";
  44. FileWatcher.EnableRaisingEvents = true;
  45. FileWatcher.Created += new FileSystemEventHandler(Watcher_Created);
  46. }
  47. private void Make_LabelCheck_SizeChanged(object sender, EventArgs e)
  48. {
  49. asc.controlAutoSize(this);
  50. }
  51. string FullPath = "";
  52. private void Watcher_Created(object sender, FileSystemEventArgs e)
  53. {
  54. string BARCODE = "";
  55. string MAC = "";
  56. string BT = "";
  57. string IMEI0 = "";
  58. string IMEI1 = "";
  59. if (e.FullPath.Contains("MetaCore"))
  60. {
  61. return;
  62. }
  63. BaseUtil.GetWriteInfo(e.FullPath, out BARCODE, out MAC, out BT, out IMEI0, out IMEI1);
  64. FullPath = e.FullPath;
  65. sncode.Text = BARCODE;
  66. sncode_KeyDown(sender, new KeyEventArgs(Keys.Enter));
  67. }
  68. private void sncode_KeyDown(object sender, KeyEventArgs e)
  69. {
  70. //判断是enter事件
  71. if (e.KeyCode == Keys.Enter)
  72. {
  73. if (sncode.Text == "")
  74. {
  75. OperateResult.AppendText("<<输入不能为空\n", Color.Red);
  76. return;
  77. }
  78. if (LogicHandler.CheckStepAttribute(Tag.ToString(), User.UserSourceCode, out oErrorMessage))
  79. {
  80. //判断序列号下一工序(CHECKSTEPSNANDMACODE)
  81. if (LogicHandler.CheckStepSNAndMacode("", User.UserSourceCode, sncode.Text, User.UserCode, out omakeCode, out oMsid, out oErrorMessage))
  82. {
  83. string BARCODE = "";
  84. string MAC = "";
  85. string BT = "";
  86. string IMEI0 = "";
  87. string IMEI1 = "";
  88. BaseUtil.GetWriteInfo(FullPath, out BARCODE, out MAC, out BT, out IMEI0, out IMEI1);
  89. DataTable dt = new DataTable();
  90. dt.Columns.Add("ms_item");
  91. dt.Columns.Add("ms_info");
  92. if (BARCODE != "")
  93. {
  94. DataRow dr = dt.NewRow();
  95. dr["ms_item"] = "SN";
  96. dr["ms_info"] = BARCODE;
  97. dt.Rows.Add(dr);
  98. }
  99. if (MAC != "")
  100. {
  101. DataRow dr = dt.NewRow();
  102. dr["ms_item"] = "MAC";
  103. dr["ms_info"] = MAC;
  104. dt.Rows.Add(dr);
  105. }
  106. if (BT != "")
  107. {
  108. DataRow dr = dt.NewRow();
  109. dr["ms_item"] = "BT";
  110. dr["ms_info"] = BT;
  111. dt.Rows.Add(dr);
  112. }
  113. if (IMEI0 != "")
  114. {
  115. DataRow dr = dt.NewRow();
  116. dr["ms_item"] = "IMEI0";
  117. dr["ms_info"] = IMEI0;
  118. dt.Rows.Add(dr);
  119. }
  120. if (IMEI1 != "")
  121. {
  122. DataRow dr = dt.NewRow();
  123. dr["ms_item"] = "IMEI1";
  124. dr["ms_info"] = IMEI1;
  125. dt.Rows.Add(dr);
  126. }
  127. CheckItemDGV.DataSource = dt;
  128. //烧写信息
  129. if (LogicHandler.snBurn(sncode.Text, sncode.Text, User.UserSourceCode, User.UserCode, omakeCode, 0, IMEI0, IMEI1, "", "", "", "", "", "", "", MAC, BT, "", "", "", out oErrorMessage))
  130. {
  131. OperateResult.AppendText(">>SN:" + sncode.Text + "烧写信息绑定成功\n", Color.Green, sncode);
  132. }
  133. else
  134. {
  135. OperateResult.AppendText(">>" + oErrorMessage + "\n", Color.Red, sncode);
  136. }
  137. }
  138. else
  139. {
  140. OperateResult.AppendText(">>" + oErrorMessage + "\n", Color.Red, sncode);
  141. }
  142. }
  143. else
  144. {
  145. OperateResult.AppendText(">>" + oErrorMessage + "\n", Color.Red, sncode);
  146. }
  147. }
  148. }
  149. private void StepCount_Load(object sender, EventArgs e)
  150. {
  151. }
  152. private void CheckItemDGV_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
  153. {
  154. //系统值和
  155. if (e.ColumnIndex >= 0)
  156. {
  157. if (CheckItemDGV.Columns[e.ColumnIndex].Name == "psr_systemvalue" || CheckItemDGV.Columns[e.ColumnIndex].Name == "psr_localvalue")
  158. {
  159. if (e.RowIndex >= 0)
  160. {
  161. if (CheckItemDGV.Rows[e.RowIndex].Cells["psr_systemvalue"].Value != null && (CheckItemDGV.Rows[e.RowIndex].Cells["psr_systemvalue"].Value.ToString() == CheckItemDGV.Rows[e.RowIndex].Cells["psr_localvalue"].Value.ToString()))
  162. {
  163. e.Graphics.FillRectangle(Brushes.ForestGreen, e.CellBounds);
  164. Rectangle border = e.CellBounds;
  165. border.Width -= 1;
  166. e.Graphics.DrawRectangle(Pens.Black, border);
  167. e.PaintContent(e.CellBounds);
  168. e.Handled = true;
  169. }
  170. else
  171. {
  172. e.Graphics.FillRectangle(Brushes.OrangeRed, e.CellBounds);
  173. Rectangle border = e.CellBounds;
  174. border.Width -= 1;
  175. e.Graphics.DrawRectangle(Pens.Black, border);
  176. e.PaintContent(e.CellBounds);
  177. e.Handled = true;
  178. }
  179. }
  180. }
  181. }
  182. }
  183. }
  184. }