Make_ReadWriteInfo.cs 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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. }
  43. private void Make_LabelCheck_SizeChanged(object sender, EventArgs e)
  44. {
  45. asc.controlAutoSize(this);
  46. }
  47. string FullPath = "";
  48. private void Watcher_Created(object sender, FileSystemEventArgs e)
  49. {
  50. string BARCODE = "";
  51. string MAC = "";
  52. string BT = "";
  53. string IMEI0 = "";
  54. string IMEI1 = "";
  55. if (e.FullPath.Contains("MetaCore"))
  56. {
  57. return;
  58. }
  59. BaseUtil.GetWriteInfo(e.FullPath, out BARCODE, out MAC, out BT, out IMEI0, out IMEI1);
  60. FullPath = e.FullPath;
  61. sncode.Text = BARCODE;
  62. sncode_KeyDown(sender, new KeyEventArgs(Keys.Enter));
  63. }
  64. private void sncode_KeyDown(object sender, KeyEventArgs e)
  65. {
  66. //判断是enter事件
  67. if (e.KeyCode == Keys.Enter)
  68. {
  69. if (sncode.Text == "")
  70. {
  71. OperateResult.AppendText("<<输入不能为空\n", Color.Red);
  72. return;
  73. }
  74. if (LogicHandler.CheckStepAttribute(Tag.ToString(), User.UserSourceCode, out oErrorMessage))
  75. {
  76. //判断序列号下一工序(CHECKSTEPSNANDMACODE)
  77. if (LogicHandler.CheckStepSNAndMacode("", User.UserSourceCode, sncode.Text, User.UserCode, out omakeCode, out oMsid, out oErrorMessage))
  78. {
  79. string BARCODE = "";
  80. string MAC = "";
  81. string BT = "";
  82. string IMEI0 = "";
  83. string IMEI1 = "";
  84. BaseUtil.GetWriteInfo(FullPath, out BARCODE, out MAC, out BT, out IMEI0, out IMEI1);
  85. DataTable dt = new DataTable();
  86. dt.Columns.Add("ms_item");
  87. dt.Columns.Add("ms_info");
  88. if (BARCODE != "")
  89. {
  90. DataRow dr = dt.NewRow();
  91. dr["ms_item"] = "SN";
  92. dr["ms_info"] = BARCODE;
  93. dt.Rows.Add(dr);
  94. }
  95. if (MAC != "")
  96. {
  97. DataRow dr = dt.NewRow();
  98. dr["ms_item"] = "MAC";
  99. dr["ms_info"] = MAC;
  100. dt.Rows.Add(dr);
  101. }
  102. if (BT != "")
  103. {
  104. DataRow dr = dt.NewRow();
  105. dr["ms_item"] = "BT";
  106. dr["ms_info"] = BT;
  107. dt.Rows.Add(dr);
  108. }
  109. if (IMEI0 != "")
  110. {
  111. DataRow dr = dt.NewRow();
  112. dr["ms_item"] = "IMEI0";
  113. dr["ms_info"] = IMEI0;
  114. dt.Rows.Add(dr);
  115. }
  116. if (IMEI1 != "")
  117. {
  118. DataRow dr = dt.NewRow();
  119. dr["ms_item"] = "IMEI1";
  120. dr["ms_info"] = IMEI1;
  121. dt.Rows.Add(dr);
  122. }
  123. CheckItemDGV.DataSource = dt;
  124. //烧写信息
  125. if (LogicHandler.snBurn(sncode.Text, sncode.Text, User.UserSourceCode, User.UserCode, omakeCode, 0, IMEI0, IMEI1, "", "", "", "", "", "", "", MAC, BT, "", "", "", out oErrorMessage))
  126. {
  127. sql.Clear();
  128. sql.Append("select ma_code,nvl(mcd_okqty,0) mcd_okqty,ma_prodcode,pr_detail,");
  129. sql.Append("pr_spec,ma_qty - nvl(mcd_inqty, 0) remain_qty,nvl(ma_unlimitin,0) ma_unlimitin from make left join makecraftdetail on ");
  130. sql.Append("mcd_maid=ma_id left join product on pr_code=ma_prodcode where ma_code='" + omakeCode + "' and mcd_stepcode='" + User.CurrentStepCode + "'");
  131. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  132. if (dt.Rows.Count > 0)
  133. {
  134. BaseUtil.SetFormValue(this.Controls, dt);
  135. }
  136. OperateResult.AppendText(">>SN:" + sncode.Text + "烧写信息绑定成功\n", Color.Green, sncode);
  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. else
  149. {
  150. OperateResult.AppendText(">>" + oErrorMessage + "\n", Color.Red, sncode);
  151. }
  152. }
  153. }
  154. private void StepCount_Load(object sender, EventArgs e)
  155. {
  156. }
  157. private void CheckItemDGV_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
  158. {
  159. //系统值和
  160. if (e.ColumnIndex >= 0)
  161. {
  162. if (CheckItemDGV.Columns[e.ColumnIndex].Name == "psr_systemvalue" || CheckItemDGV.Columns[e.ColumnIndex].Name == "psr_localvalue")
  163. {
  164. if (e.RowIndex >= 0)
  165. {
  166. 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()))
  167. {
  168. e.Graphics.FillRectangle(Brushes.ForestGreen, e.CellBounds);
  169. Rectangle border = e.CellBounds;
  170. border.Width -= 1;
  171. e.Graphics.DrawRectangle(Pens.Black, border);
  172. e.PaintContent(e.CellBounds);
  173. e.Handled = true;
  174. }
  175. else
  176. {
  177. e.Graphics.FillRectangle(Brushes.OrangeRed, e.CellBounds);
  178. Rectangle border = e.CellBounds;
  179. border.Width -= 1;
  180. e.Graphics.DrawRectangle(Pens.Black, border);
  181. e.PaintContent(e.CellBounds);
  182. e.Handled = true;
  183. }
  184. }
  185. }
  186. }
  187. }
  188. private void Watch_Click(object sender, EventArgs e)
  189. {
  190. FileWatcher.Path = WatchPath.Text;
  191. FileWatcher.Filter = "*.log";
  192. FileWatcher.EnableRaisingEvents = true;
  193. FileWatcher.Created += new FileSystemEventHandler(Watcher_Created);
  194. }
  195. }
  196. }