Make_OutBoxSnCheck.cs 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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_OutBoxSnCheck : Form
  16. {
  17. AutoSizeFormClass asc = new AutoSizeFormClass();
  18. DataHelper dh;
  19. LogStringBuilder sql;
  20. DataTable dt;
  21. public Make_OutBoxSnCheck()
  22. {
  23. InitializeComponent();
  24. }
  25. private void Make_LabelCheck_Load(object sender, EventArgs e)
  26. {
  27. asc.controllInitializeSize(this);
  28. //聚焦SN号
  29. pa_outboxcode.Focus();
  30. //打开界面提示用户:请输入SN
  31. OperateResult.AppendText(">>请采集箱号\n", Color.Black);
  32. sql = new LogStringBuilder();
  33. dh = SystemInf.dh;
  34. }
  35. string pa_nextstep = "";
  36. private void Make_LabelCheck_SizeChanged(object sender, EventArgs e)
  37. {
  38. asc.controlAutoSize(this);
  39. }
  40. string ErrorMessage = "";
  41. private void sncode_KeyDown(object sender, KeyEventArgs e)
  42. {
  43. //判断是enter事件
  44. if (e.KeyCode == Keys.Enter)
  45. {
  46. if (sncode.Text == "")
  47. {
  48. OperateResult.AppendText("<<输入不能为空\n", Color.Red);
  49. return;
  50. }
  51. bool FindSN = false;
  52. bool AllCheck = true;
  53. dt = (DataTable)dh.ExecuteSql("select ms_sncode from makeserial where ms_imei1='" + sncode.Text + "' order by ms_id desc", "select");
  54. if (dt.Rows.Count > 0)
  55. {
  56. sncode.Text = dt.Rows[0]["ms_sncode"].ToString();
  57. }
  58. else
  59. {
  60. dt = (DataTable)dh.ExecuteSql("select ms_sncode from makeserial where ms_imei2='" + sncode.Text + "' order by ms_id desc", "select");
  61. if (dt.Rows.Count > 0)
  62. {
  63. sncode.Text = dt.Rows[0]["ms_sncode"].ToString();
  64. }
  65. else
  66. {
  67. dt = (DataTable)dh.ExecuteSql("select mil_sncode from makeimeilist where mil_imei1='" + sncode.Text + "' order by mil_id desc", "select");
  68. if (dt.Rows.Count > 0)
  69. {
  70. sncode.Text = dt.Rows[0]["mil_sncode"].ToString();
  71. }
  72. else
  73. {
  74. dt = (DataTable)dh.ExecuteSql("select mil_sncode from makeimeilist where mil_imei2='" + sncode.Text + "' order by mil_id desc", "select");
  75. if (dt.Rows.Count > 0)
  76. {
  77. sncode.Text = dt.Rows[0]["mil_sncode"].ToString();
  78. }
  79. }
  80. }
  81. }
  82. int CheckRow = 0;
  83. for (int i = 0; i < CheckSnDGV.Rows.Count; i++)
  84. {
  85. if (CheckSnDGV.Rows[i].Cells["pd_barcode"].Value.ToString() == sncode.Text)
  86. {
  87. if (CheckSnDGV.Rows[i].Cells["pd_checksn"].Value == null)
  88. {
  89. CheckSnDGV.Rows[i].Cells["pd_checksn"].Value = sncode.Text;
  90. FindSN = true;
  91. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, pa_makecode.Text, User.UserLineCode, User.UserSourceCode, "卡通箱装箱核对成功", "核对条码" + sncode.Text + "箱号" + pa_outboxcode.Text, "", "");
  92. }
  93. else
  94. {
  95. OperateResult.AppendText("<<SN" + sncode.Text + "已校验\n", Color.Red, sncode);
  96. return;
  97. }
  98. }
  99. if (CheckSnDGV.Rows[i].Cells["pd_checksn"].Value == null)
  100. {
  101. AllCheck = false;
  102. }
  103. else
  104. {
  105. CheckRow = CheckRow + 1;
  106. }
  107. }
  108. if (FindSN)
  109. {
  110. OperateResult.AppendText("<<SN" + sncode.Text + "校验成功\n", Color.Green, sncode);
  111. }
  112. else
  113. {
  114. OperateResult.AppendText("<<SN" + sncode.Text + "校验失败,不在箱中\n", Color.Red, sncode);
  115. }
  116. CheckNum.Text = CheckRow + "/" + CheckSnDGV.Rows.Count;
  117. if (AllCheck)
  118. {
  119. if (pa_nextstep != "" && pa_nextstep == User.CurrentStepCode)
  120. {
  121. if (LogicHandler.OutBoxStepPass(pa_outboxcode.Text, pa_makecode.Text, User.UserSourceCode, User.UserCode, "栈板采集成功,栈板号:" + pa_outboxcode.Text, "栈板采集", out ErrorMessage))
  122. {
  123. dh.UpdateByCondition("package", "pa_nextstep='" + dh.getFieldDataByCondition("packagedetail left join makeserial on ms_sncode=pd_barcode and ms_makecode=pd_makecode", "max(ms_nextstepcode)", "pd_outboxcode='" + pa_outboxcode.Text + "'").ToString() + "', PA_CURRENTSTEP = '' ", "pa_outboxcode='" + pa_outboxcode.Text + "'");
  124. }
  125. }
  126. OperateResult.AppendText("<<卡通箱核对成功\n", Color.DarkGreen, sncode);
  127. CheckRow = 0;
  128. SetCheck set = new SetCheck("OK", Color.Green);
  129. BaseUtil.SetFormCenter(set);
  130. set.ShowDialog();
  131. pa_outboxcode.Clear();
  132. pa_outboxcode.Focus();
  133. }
  134. }
  135. }
  136. private void pa_outboxcode_KeyDown(object sender, KeyEventArgs e)
  137. {
  138. if (e.KeyCode == Keys.Enter)
  139. {
  140. dt = (DataTable)dh.ExecuteSql("select pd_barcode,pd_makecode pa_makecode,pa_nextstep from packagedetail left join package on pa_id=pd_paid where pd_outboxcode='" + pa_outboxcode.Text + "'", "select");
  141. if (dt.Rows.Count > 0)
  142. {
  143. //CheckNum.Text = CheckRow + "/" + CheckSnDGV.Rows.Count;
  144. pa_nextstep = dt.Rows[0]["pa_nextstep"].ToString();
  145. if (pa_nextstep != User.CurrentStepCode && pa_nextstep != "")
  146. {
  147. OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "的下一工序" + pa_nextstep + "不是当前岗位资源对应工序\n", Color.Red);
  148. return;
  149. }
  150. BaseUtil.FillDgvWithDataTable(CheckSnDGV, dt);
  151. BaseUtil.SetFormValue(this.Controls, dt);
  152. sncode.Focus();
  153. }
  154. else
  155. {
  156. OperateResult.AppendText("<<箱号" + pa_outboxcode.Text + "不存在\n", Color.Red);
  157. }
  158. }
  159. }
  160. private void cancel_Click(object sender, EventArgs e)
  161. {
  162. }
  163. }
  164. }