Make_ImeiCheck.cs 10 KB

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