Make_ImeiCheck.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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. dt = (DataTable)dh.ExecuteSql("select ms_sncode from makeserial where ms_imei1='" + sncode.Text + "' order by ms_id desc", "select");
  62. if (dt.Rows.Count > 0)
  63. {
  64. sncode.Text = dt.Rows[0]["ms_sncode"].ToString();
  65. }
  66. else
  67. {
  68. dt = (DataTable)dh.ExecuteSql("select ms_sncode from makeserial where ms_imei2='" + sncode.Text + "' order by ms_id desc", "select");
  69. if (dt.Rows.Count > 0)
  70. {
  71. sncode.Text = dt.Rows[0]["ms_sncode"].ToString();
  72. }
  73. else
  74. {
  75. dt = (DataTable)dh.ExecuteSql("select mil_sncode from makeimeilist where mil_imei1='" + sncode.Text + "' order by mil_id desc", "select");
  76. if (dt.Rows.Count > 0)
  77. {
  78. sncode.Text = dt.Rows[0]["mil_sncode"].ToString();
  79. }
  80. else
  81. {
  82. dt = (DataTable)dh.ExecuteSql("select mil_sncode from makeimeilist where mil_imei2='" + sncode.Text + "' order by mil_id desc", "select");
  83. if (dt.Rows.Count > 0)
  84. {
  85. sncode.Text = dt.Rows[0]["mil_sncode"].ToString();
  86. }
  87. }
  88. }
  89. }
  90. //输入的是SN
  91. if (!isImei1)
  92. {
  93. OperateResult.AppendText("<<" + sncode.Text + "\n", Color.Black);
  94. //查询是否存在该ms_id
  95. sql.Clear();
  96. sql.Append("select max(ms_id) ms_id from makeserial where ms_sncode ='" + sncode.Text + "'");
  97. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  98. if (dt.Rows.Count == 0 || dt.Rows[0]["ms_id"].ToString() == "")
  99. {
  100. //SN错误,不存在
  101. //请输入SN
  102. OperateResult.AppendText("<<SN错误,序列号" + sncode.Text + "不存在\n", Color.Red, sncode);
  103. OperateResult.AppendText(">>请输入SN\n", Color.Black);
  104. }
  105. //存在该SN号
  106. else
  107. {
  108. //根据该ms_id查询ms_imei1,ms_makecode信息
  109. sql.Clear();
  110. sql.Append("select ms_sncode from makeserial where ms_id='" + dt.Rows[0]["ms_id"].ToString() + "'");
  111. info = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  112. if (info.Rows.Count > 0)
  113. {
  114. //用变量记录imei1和makecode
  115. imei1 = info.Rows[0]["ms_sncode"].ToString();
  116. SN = sncode.Text;
  117. //>>SN对应的SN号为:xxxxxxxxx
  118. //>> 请输入彩盒上的SN
  119. OperateResult.AppendText("<<序列号" + sncode.Text + "对应的SN号为:" + imei1 + "\n", Color.Green);
  120. OperateResult.AppendText(">>请输入彩盒上的SN\n", Color.Black, sncode);
  121. //设定要输入imei1
  122. isImei1 = true;
  123. ////不为null 并且不为””才继续
  124. //if (info.Rows[0]["ms_imei1"].ToString() == null || info.Rows[0]["ms_imei1"].ToString() == "")
  125. //{
  126. // // SN对应的SN不存在
  127. // //>> 请输入SN
  128. // OperateResult.AppendText("<<序列号" + sncode.Text + "对应的SN不存在\n", Color.Red, sncode);
  129. // OperateResult.AppendText(">>请输入SN\n", Color.Black);
  130. //}
  131. //else
  132. ////存在该imei信息
  133. //{
  134. //}
  135. }
  136. else
  137. {
  138. OperateResult.AppendText("<<SN:" + sncode.Text + "对应的SN不存在\n", Color.Red, sncode);
  139. OperateResult.AppendText(">>请输入SN\n", Color.Black);
  140. SetCheck set = new SetCheck("NG", Color.Red);
  141. BaseUtil.SetFormCenter(set);
  142. set.ShowDialog();
  143. }
  144. }
  145. }
  146. //输入的是imei1
  147. else
  148. {
  149. OperateResult.AppendText("<<" + sncode.Text + "\n", Color.Black);
  150. if (imei1 == sncode.Text)
  151. {
  152. //说明输入的imei1对比一致
  153. //判断工序属性attribute
  154. if (LogicHandler.CheckStepAttribute(Tag.ToString(), User.UserSourceCode, out oErrorMessage))
  155. {
  156. //判断序列号下一工序(CHECKSTEPSNANDMACODE)
  157. if (LogicHandler.CheckStepSNAndMacode("", User.UserSourceCode, SN, User.UserCode, out omakeCode, out oMsid, out oErrorMessage))
  158. {
  159. //调用 SETSTEPRESULT ,获取返回的工单号,
  160. if (LogicHandler.SetStepResult(omakeCode, User.UserSourceCode, SN, "标签核对", "OK", User.UserCode, out oErrorMessage))
  161. {
  162. //提示正确返回时传递的信息
  163. if (oErrorMessage.Contains("AFTERSUCCESS"))
  164. OperateResult.AppendText(">>" + oErrorMessage + "\n");
  165. //根据工单号查询makecraftdetail 表中的 mcd_okqty 计数,剩余数为ma_qty - nvl(mcd_inqty,0),刷新页面中工单信息的显示
  166. sql.Clear();
  167. sql.Append("select ma_code,nvl(mcd_okqty,0) mcd_okqty,ma_prodcode,pr_detail,");
  168. sql.Append("ma_qty - nvl(mcd_okqty, 0) remain_qty from make left join makecraftdetail on ");
  169. sql.Append("mcd_maid=ma_id left join product on pr_code=ma_prodcode where ma_code='" + omakeCode + "' and mcd_stepcode='" + User.CurrentStepCode + "'");
  170. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  171. BaseUtil.SetFormValue(Controls, dt);
  172. //将SN,时间,结果记录在页面
  173. recordResult(SN, DateTime.Now.ToString(), "成功");
  174. //记录日志
  175. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "标签核对", "标签核对成功", SN, "");
  176. //SN核对成功
  177. //>> 请输入SN
  178. OperateResult.AppendText("<<SN核对成功\n", Color.Green, sncode);
  179. OperateResult.AppendText(">>请输入SN\n", Color.Black);
  180. SetCheck set = new SetCheck("OK", Color.Green);
  181. BaseUtil.SetFormCenter(set);
  182. set.ShowDialog();
  183. }
  184. else
  185. {
  186. //setstepresult不通过
  187. OperateResult.AppendText(">>" + oErrorMessage + "\n", Color.Red, sncode);
  188. recordResult(SN, DateTime.Now.ToString(), "失败");
  189. SetCheck set = new SetCheck("NG", Color.Red);
  190. BaseUtil.SetFormCenter(set);
  191. set.ShowDialog();
  192. }
  193. }
  194. else
  195. {
  196. //判定序列号下一工序不通过
  197. OperateResult.AppendText(">>" + oErrorMessage + "\n", Color.Red, sncode);
  198. recordResult(SN, DateTime.Now.ToString(), "失败");
  199. SetCheck set = new SetCheck("NG", Color.Red);
  200. BaseUtil.SetFormCenter(set);
  201. set.ShowDialog();
  202. }
  203. }
  204. else
  205. {
  206. //判定工序属性不通过
  207. OperateResult.AppendText(">>" + oErrorMessage + "\n", Color.Red, sncode);
  208. recordResult(SN, DateTime.Now.ToString(), "失败");
  209. }
  210. }
  211. //说明比对不一致
  212. else
  213. {
  214. //清空imei1变量的值
  215. imei1 = "";
  216. //SN核对失败
  217. //>> 请输入SN
  218. OperateResult.AppendText(">>SN核对失败,不一致\n", Color.Red, sncode);
  219. OperateResult.AppendText(">>请输入SN\n", Color.Black);
  220. }
  221. //imei1校对结束,下次输入的是SN
  222. isImei1 = false;
  223. }
  224. }
  225. }
  226. private void recordResult(string SN, string time, string result)
  227. {
  228. //if (showResult.Items.Count >= 10)
  229. //{
  230. // //如果有10行的话,则删除最前一行
  231. // showResult.Items.RemoveAt(0);
  232. //}
  233. //创建一个item
  234. ListViewItem lvi = new ListViewItem();
  235. //分条赋值
  236. lvi.SubItems.Add(SN);
  237. lvi.SubItems.Add(time);
  238. lvi.SubItems.Add(result);
  239. //添加结果的信息进去
  240. showResult.Items.Add(lvi);
  241. }
  242. private void clear()
  243. {
  244. //清空变量的值
  245. omakeCode = "";
  246. oMsid = "";
  247. SN = "";
  248. imei1 = "";
  249. }
  250. }
  251. }