Make_InfoCheck.cs 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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. using UAS_MES_NEW.PublicForm;
  12. using UAS_MES_NEW.PublicMethod;
  13. namespace UAS_MES_NEW.Make
  14. {
  15. public partial class Make_InfoCheck : Form
  16. {
  17. AutoSizeFormClass asc = new AutoSizeFormClass();
  18. DataHelper dh;
  19. LogStringBuilder sql;
  20. DataTable dt;
  21. DataTable info;
  22. string oErrorMessage = "";
  23. string omakeCode = "";
  24. string oMsid = "";
  25. public Make_InfoCheck()
  26. {
  27. InitializeComponent();
  28. }
  29. private void Make_LabelCheck_Load(object sender, EventArgs e)
  30. {
  31. asc.controllInitializeSize(this);
  32. //聚焦SN号
  33. sncode.Focus();
  34. //打开界面提示用户:请输入SN
  35. OperateResult.AppendText(">>请输入SN\n", Color.Black);
  36. sql = new LogStringBuilder();
  37. dh = SystemInf.dh;
  38. StepCount.StepCode = User.CurrentStepCode;
  39. StepCount.Source = User.UserSourceCode;
  40. StepCount.LineCode = User.UserLineCode;
  41. StepCount.Dh = dh;
  42. StepCount.Start();
  43. }
  44. private void Make_LabelCheck_SizeChanged(object sender, EventArgs e)
  45. {
  46. asc.controlAutoSize(this);
  47. }
  48. private void sncode_KeyDown(object sender, KeyEventArgs e)
  49. {
  50. //判断是enter事件
  51. if (e.KeyCode == Keys.Enter)
  52. {
  53. if (sncode.Text == "")
  54. {
  55. OperateResult.AppendText("<<输入不能为空\n", Color.Red);
  56. return;
  57. }
  58. if (LogicHandler.CheckStepAttribute(Tag.ToString(), User.UserSourceCode, out oErrorMessage))
  59. {
  60. //判断序列号下一工序(CHECKSTEPSNANDMACODE)
  61. if (LogicHandler.CheckStepSNAndMacode("", User.UserSourceCode, sncode.Text, User.UserCode, out omakeCode, out oMsid, out oErrorMessage))
  62. {
  63. dt = (DataTable)dh.ExecuteSql("select psr_type from makeserial left join ProductSNRelation on ms_prodcode=psr_prodcode where ms_id='" + oMsid + "' order by psr_detno", "select");
  64. CheckItemDGV.DataSource = dt;
  65. string ErrMsg = "";
  66. Dictionary<string, string> dic;
  67. LogicHandler.GetMobileAllInfo(sncode.Text, out dic, out ErrMsg);
  68. bool AllMatched = true;
  69. for (int i = 0; i < CheckItemDGV.Rows.Count; i++)
  70. {
  71. foreach (var item in dic)
  72. {
  73. if (CheckItemDGV.Rows[i].Cells["psr_type"].Value.ToString() == item.Key)
  74. {
  75. CheckItemDGV.Rows[i].Cells["psr_systemvalue"].Value = item.Value;
  76. }
  77. }
  78. if (CheckItemDGV.Rows[i].Cells["psr_systemvalue"].Value == null)
  79. {
  80. CheckItemDGV.Rows[i].Cells["psr_systemvalue"].Value = "";
  81. }
  82. CheckItemDGV.Rows[i].Cells["psr_localvalue"].Value = BaseUtil.GetDataFromDevice(CheckItemDGV.Rows[i].Cells["psr_type"].Value.ToString());
  83. if (CheckItemDGV.Rows[i].Cells["psr_localvalue"].Value.ToString() != CheckItemDGV.Rows[i].Cells["psr_systemvalue"].Value.ToString())
  84. {
  85. AllMatched = false;
  86. }
  87. }
  88. if (AllMatched)
  89. {
  90. if (LogicHandler.SetStepResult(omakeCode, User.UserSourceCode, sncode.Text, "标签核对", "OK", User.UserCode, out oErrorMessage))
  91. {
  92. //提示正确返回时传递的信息
  93. if (oErrorMessage.Contains("AFTERSUCCESS"))
  94. OperateResult.AppendText(">>" + oErrorMessage + "\n");
  95. //根据工单号查询makecraftdetail 表中的 mcd_okqty 计数,剩余数为ma_qty - nvl(mcd_inqty,0),刷新页面中工单信息的显示
  96. sql.Clear();
  97. sql.Append("select ma_code,nvl(mcd_okqty,0) mcd_okqty,ma_prodcode,pr_detail,");
  98. sql.Append("ma_qty - nvl(mcd_okqty, 0) remain_qty from make left join makecraftdetail on ");
  99. sql.Append("mcd_maid=ma_id left join product on pr_code=ma_prodcode where ma_code='" + omakeCode + "' and mcd_stepcode='" + User.CurrentStepCode + "'");
  100. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  101. BaseUtil.SetFormValue(Controls, dt);
  102. //将SN,时间,结果记录在页面
  103. //记录日志
  104. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "标签核对", "参数核对成功", sncode.Text, "");
  105. //SN核对成功
  106. //>> 请输入SN
  107. OperateResult.AppendText("<<信息核对成功\n", Color.Green, sncode);
  108. OperateResult.AppendText(">>请输入SN\n", Color.Black);
  109. SetCheck set = new SetCheck("OK", Color.Green);
  110. BaseUtil.SetFormCenter(set);
  111. set.ShowDialog();
  112. }
  113. else
  114. {
  115. OperateResult.AppendText(">>" + oErrorMessage + "\n", Color.Red, sncode);
  116. }
  117. }
  118. }
  119. else
  120. {
  121. OperateResult.AppendText(">>" + oErrorMessage + "\n", Color.Red, sncode);
  122. }
  123. }
  124. else
  125. {
  126. OperateResult.AppendText(">>" + oErrorMessage + "\n", Color.Red, sncode);
  127. }
  128. }
  129. }
  130. private void StepCount_Load(object sender, EventArgs e)
  131. {
  132. }
  133. private void CheckItemDGV_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
  134. {
  135. //系统值和
  136. if (e.ColumnIndex >= 0)
  137. {
  138. if (CheckItemDGV.Columns[e.ColumnIndex].Name == "psr_systemvalue" || CheckItemDGV.Columns[e.ColumnIndex].Name == "psr_localvalue")
  139. {
  140. if (e.RowIndex >= 0)
  141. {
  142. 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()))
  143. {
  144. e.Graphics.FillRectangle(Brushes.ForestGreen, e.CellBounds);
  145. Rectangle border = e.CellBounds;
  146. border.Width -= 1;
  147. e.Graphics.DrawRectangle(Pens.Black, border);
  148. e.PaintContent(e.CellBounds);
  149. e.Handled = true;
  150. }
  151. else
  152. {
  153. e.Graphics.FillRectangle(Brushes.OrangeRed, e.CellBounds);
  154. Rectangle border = e.CellBounds;
  155. border.Width -= 1;
  156. e.Graphics.DrawRectangle(Pens.Black, border);
  157. e.PaintContent(e.CellBounds);
  158. e.Handled = true;
  159. }
  160. }
  161. }
  162. }
  163. }
  164. }
  165. }