Make_OutBoxSnCheck.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. using System;
  2. using System.Data;
  3. using System.Drawing;
  4. using System.Windows.Forms;
  5. using UAS_MES_NEW.DataOperate;
  6. using UAS_MES_NEW.Entity;
  7. using UAS_MES_NEW.PublicForm;
  8. using UAS_MES_NEW.PublicMethod;
  9. namespace UAS_MES_NEW.Make
  10. {
  11. public partial class Make_OutBoxSnCheck : Form
  12. {
  13. AutoSizeFormClass asc = new AutoSizeFormClass();
  14. DataHelper dh;
  15. LogStringBuilder sql;
  16. DataTable dt;
  17. public Make_OutBoxSnCheck()
  18. {
  19. InitializeComponent();
  20. }
  21. private void Make_LabelCheck_Load(object sender, EventArgs e)
  22. {
  23. asc.controllInitializeSize(this);
  24. //聚焦SN号
  25. pa_outboxcode.Focus();
  26. //打开界面提示用户:请输入SN
  27. OperateResult.AppendText(">>请采集箱号\n", Color.Black);
  28. sql = new LogStringBuilder();
  29. dh = SystemInf.dh;
  30. }
  31. private void Make_LabelCheck_SizeChanged(object sender, EventArgs e)
  32. {
  33. asc.controlAutoSize(this);
  34. }
  35. bool FindColorSN = false;
  36. int RowIndex = 0;
  37. string ms_makecode = "";
  38. private void sncode_KeyDown(object sender, KeyEventArgs e)
  39. {
  40. //判断是enter事件
  41. if (e.KeyCode == Keys.Enter)
  42. {
  43. string ErrorMessage = "";
  44. if (sncode.Text == "")
  45. {
  46. OperateResult.AppendText("<<输入不能为空\n", Color.Red);
  47. return;
  48. }
  49. bool AllCheck = true;
  50. for (int i = 0; i < CheckSnDGV.Rows.Count; i++)
  51. {
  52. object colorcode = CheckSnDGV.Rows[RowIndex].Cells["pr_colorcode"].Value;
  53. if ((colorcode != null ? colorcode.ToString() : "") + CheckSnDGV.Rows[i].Cells["pd_barcode"].Value.ToString() == sncode.Text)
  54. {
  55. CheckSnDGV.Rows[i].Cells["pd_checksn"].Value = sncode.Text;
  56. RowIndex = i;
  57. FindColorSN = true;
  58. }
  59. if (CheckSnDGV.Rows[i].Cells["pd_checksn"].Value == null)
  60. {
  61. AllCheck = false;
  62. }
  63. }
  64. if (FindColorSN)
  65. {
  66. OperateResult.AppendText("<<" + sncode.Text + "彩盒校验成功\n", Color.Green, sncode);
  67. }
  68. if (AllCheck)
  69. {
  70. SetCheck set = new SetCheck("OK", Color.Green);
  71. BaseUtil.SetFormCenter(set);
  72. set.ShowDialog();
  73. if (LogicHandler.OutBoxStepPass(pa_outboxcode.Text, ms_makecode, User.UserSourceCode, User.UserCode, "卡通箱:" + pa_outboxcode.Text + "整箱过站", "卡通箱整箱过站", out ErrorMessage))
  74. {
  75. 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 + "'");
  76. OperateResult.AppendText("<<" + pa_outboxcode.Text + "整箱校验通过\n", Color.Green, pa_outboxcode);
  77. }
  78. else
  79. {
  80. OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
  81. }
  82. pa_outboxcode.Focus();
  83. }
  84. }
  85. }
  86. private void pa_outboxcode_KeyDown(object sender, KeyEventArgs e)
  87. {
  88. if (e.KeyCode == Keys.Enter)
  89. {
  90. dt = (DataTable)dh.ExecuteSql("select pd_barcode,PR_COLORCODE,pd_makecode from packagedetail left join product on pr_code=PD_PRODCODE where pd_outboxcode='" + pa_outboxcode.Text + "'", "select");
  91. if (dt.Rows.Count > 0)
  92. {
  93. ms_makecode = dt.Rows[0]["pd_makecode"].ToString();
  94. BaseUtil.FillDgvWithDataTable(CheckSnDGV, dt);
  95. sncode.Focus();
  96. }
  97. else
  98. {
  99. OperateResult.AppendText("<<箱号" + pa_outboxcode.Text + "不存在\n", Color.Red);
  100. }
  101. }
  102. }
  103. }
  104. }