Make_ImeiCheck.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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_ImeiCheck : Form
  16. {
  17. AutoSizeFormClass asc = new AutoSizeFormClass();
  18. DataHelper dh;
  19. LogStringBuilder sql;
  20. DataTable dt;
  21. DataTable info;
  22. string imei1 = "";
  23. bool isImei1 = false;
  24. string oErrorMessage = "";
  25. string SN = "";
  26. string omakeCode = "";
  27. string oMsid = "";
  28. public Make_ImeiCheck()
  29. {
  30. InitializeComponent();
  31. }
  32. private void Make_LabelCheck_Load(object sender, EventArgs e)
  33. {
  34. asc.controllInitializeSize(this);
  35. //聚焦SN号
  36. sncode.Focus();
  37. //打开界面提示用户:请输入SN
  38. OperateResult.AppendText(">>请输入SN\n", Color.Black);
  39. sql = new LogStringBuilder();
  40. dh = SystemInf.dh;
  41. StepCount.StepCode = User.CurrentStepCode;
  42. StepCount.Source = User.UserSourceCode;
  43. StepCount.LineCode = User.UserLineCode;
  44. StepCount.Dh = dh;
  45. StepCount.Start();
  46. }
  47. private void Make_LabelCheck_SizeChanged(object sender, EventArgs e)
  48. {
  49. asc.controlAutoSize(this);
  50. }
  51. private void sncode_KeyDown(object sender, KeyEventArgs e)
  52. {
  53. //判断是enter事件
  54. if (e.KeyCode == Keys.Enter)
  55. {
  56. if (sncode.Text == "")
  57. {
  58. OperateResult.AppendText("<<输入不能为空\n", Color.Red);
  59. return;
  60. }
  61. //输入的是SN
  62. if (!isImei1)
  63. {
  64. OperateResult.AppendText("<<" + sncode.Text + "\n", Color.Black);
  65. //查询是否存在该ms_id
  66. sql.Clear();
  67. sql.Append("select max(ms_id) ms_id from makeserial where ms_sncode ='" + sncode.Text + "'");
  68. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  69. if (dt.Rows.Count == 0 || dt.Rows[0]["ms_id"].ToString() == "")
  70. {
  71. //SN错误,不存在
  72. //请输入SN
  73. OperateResult.AppendText("<<SN错误,序列号" + sncode.Text + "不存在\n", Color.Red, sncode);
  74. OperateResult.AppendText(">>请输入SN\n", Color.Black);
  75. }
  76. //存在该SN号
  77. else
  78. {
  79. //根据该ms_id查询ms_imei1,ms_makecode信息
  80. sql.Clear();
  81. sql.Append("select ms_sncode from makeserial where ms_id='" + dt.Rows[0]["ms_id"].ToString() + "'");
  82. info = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  83. if (info.Rows.Count > 0)
  84. {
  85. //用变量记录imei1和makecode
  86. imei1 = info.Rows[0]["ms_sncode"].ToString();
  87. SN = sncode.Text;
  88. //>>SN对应的SN号为:xxxxxxxxx
  89. //>> 请输入彩盒上的SN
  90. OperateResult.AppendText("<<序列号" + sncode.Text + "对应的SN号为:" + imei1 + "\n", Color.Green);
  91. OperateResult.AppendText(">>请输入彩盒上的SN\n", Color.Black, sncode);
  92. //设定要输入imei1
  93. isImei1 = true;
  94. ////不为null 并且不为””才继续
  95. //if (info.Rows[0]["ms_imei1"].ToString() == null || info.Rows[0]["ms_imei1"].ToString() == "")
  96. //{
  97. // // SN对应的SN不存在
  98. // //>> 请输入SN
  99. // OperateResult.AppendText("<<序列号" + sncode.Text + "对应的SN不存在\n", Color.Red, sncode);
  100. // OperateResult.AppendText(">>请输入SN\n", Color.Black);
  101. //}
  102. //else
  103. ////存在该imei信息
  104. //{
  105. //}
  106. }
  107. else
  108. {
  109. OperateResult.AppendText("<<SN:" + sncode.Text + "对应的SN不存在\n", Color.Red, sncode);
  110. OperateResult.AppendText(">>请输入SN\n", Color.Black);
  111. SetCheck set = new SetCheck("NG", Color.Red);
  112. BaseUtil.SetFormCenter(set);
  113. set.ShowDialog();
  114. }
  115. }
  116. }
  117. //输入的是imei1
  118. else
  119. {
  120. OperateResult.AppendText("<<" + sncode.Text + "\n", Color.Black);
  121. if (imei1 == sncode.Text)
  122. {
  123. //说明输入的imei1对比一致
  124. //判断工序属性attribute
  125. if (LogicHandler.CheckStepAttribute(Tag.ToString(), User.UserSourceCode, out oErrorMessage))
  126. {
  127. //判断序列号下一工序(CHECKSTEPSNANDMACODE)
  128. if (LogicHandler.CheckStepSNAndMacode("", User.UserSourceCode, SN, User.UserCode, out omakeCode, out oMsid, out oErrorMessage))
  129. {
  130. //调用 SETSTEPRESULT ,获取返回的工单号,
  131. if (LogicHandler.SetStepResult(omakeCode, User.UserSourceCode, SN, "标签核对", "OK", User.UserCode, out oErrorMessage))
  132. {
  133. //提示正确返回时传递的信息
  134. if (oErrorMessage.Contains("AFTERSUCCESS"))
  135. OperateResult.AppendText(">>" + oErrorMessage + "\n");
  136. //根据工单号查询makecraftdetail 表中的 mcd_okqty 计数,剩余数为ma_qty - nvl(mcd_inqty,0),刷新页面中工单信息的显示
  137. sql.Clear();
  138. sql.Append("select ma_code,nvl(mcd_okqty,0) mcd_okqty,ma_prodcode,pr_detail,");
  139. sql.Append("ma_qty - nvl(mcd_okqty, 0) remain_qty from make left join makecraftdetail on ");
  140. sql.Append("mcd_maid=ma_id left join product on pr_code=ma_prodcode where ma_code='" + omakeCode + "' and mcd_stepcode='" + User.CurrentStepCode + "'");
  141. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  142. BaseUtil.SetFormValue(Controls, dt);
  143. //将SN,时间,结果记录在页面
  144. recordResult(SN, DateTime.Now.ToString(), "成功");
  145. //记录日志
  146. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "标签核对", "标签核对成功", SN, "");
  147. //SN核对成功
  148. //>> 请输入SN
  149. OperateResult.AppendText("<<SN核对成功\n", Color.Green, sncode);
  150. OperateResult.AppendText(">>请输入SN\n", Color.Black);
  151. SetCheck set = new SetCheck("OK", Color.Green);
  152. BaseUtil.SetFormCenter(set);
  153. set.ShowDialog();
  154. }
  155. else
  156. {
  157. //setstepresult不通过
  158. OperateResult.AppendText(">>" + oErrorMessage + "\n", Color.Red, sncode);
  159. recordResult(SN, DateTime.Now.ToString(), "失败");
  160. SetCheck set = new SetCheck("NG", Color.Red);
  161. BaseUtil.SetFormCenter(set);
  162. set.ShowDialog();
  163. }
  164. }
  165. else
  166. {
  167. //判定序列号下一工序不通过
  168. OperateResult.AppendText(">>" + oErrorMessage + "\n", Color.Red, sncode);
  169. recordResult(SN, DateTime.Now.ToString(), "失败");
  170. SetCheck set = new SetCheck("NG", Color.Red);
  171. BaseUtil.SetFormCenter(set);
  172. set.ShowDialog();
  173. }
  174. }
  175. else
  176. {
  177. //判定工序属性不通过
  178. OperateResult.AppendText(">>" + oErrorMessage + "\n", Color.Red, sncode);
  179. recordResult(SN, DateTime.Now.ToString(), "失败");
  180. }
  181. }
  182. //说明比对不一致
  183. else
  184. {
  185. //清空imei1变量的值
  186. imei1 = "";
  187. //SN核对失败
  188. //>> 请输入SN
  189. OperateResult.AppendText(">>SN核对失败,不一致\n", Color.Red, sncode);
  190. OperateResult.AppendText(">>请输入SN\n", Color.Black);
  191. }
  192. //imei1校对结束,下次输入的是SN
  193. isImei1 = false;
  194. }
  195. }
  196. }
  197. private void recordResult(string SN, string time, string result)
  198. {
  199. //if (showResult.Items.Count >= 10)
  200. //{
  201. // //如果有10行的话,则删除最前一行
  202. // showResult.Items.RemoveAt(0);
  203. //}
  204. //创建一个item
  205. ListViewItem lvi = new ListViewItem();
  206. //分条赋值
  207. lvi.SubItems.Add(SN);
  208. lvi.SubItems.Add(time);
  209. lvi.SubItems.Add(result);
  210. //添加结果的信息进去
  211. showResult.Items.Add(lvi);
  212. }
  213. private void clear()
  214. {
  215. //清空变量的值
  216. omakeCode = "";
  217. oMsid = "";
  218. SN = "";
  219. imei1 = "";
  220. }
  221. }
  222. }