Make_OutBoxSnCheckPa.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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_OutBoxSnCheckPa : Form
  16. {
  17. AutoSizeFormClass asc = new AutoSizeFormClass();
  18. DataHelper dh;
  19. LogStringBuilder sql;
  20. DataTable dt;
  21. public Make_OutBoxSnCheckPa()
  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. private void Make_LabelCheck_SizeChanged(object sender, EventArgs e)
  36. {
  37. asc.controlAutoSize(this);
  38. }
  39. int CheckCount = 0;
  40. private void sncode_KeyDown(object sender, KeyEventArgs e)
  41. {
  42. //判断是enter事件
  43. if (e.KeyCode == Keys.Enter)
  44. {
  45. if (sncode.Text == "")
  46. {
  47. OperateResult.AppendText("<<输入不能为空\n", Color.Red);
  48. return;
  49. }
  50. bool FindSN = false;
  51. bool AllCheck = true;
  52. for (int i = 0; i < CheckSnDGV.Rows.Count; i++)
  53. {
  54. if (CheckSnDGV.Rows[i].Cells["pd_checksn"].Value != null && CheckSnDGV.Rows[i].Cells["pd_checksn"].Value.ToString() == sncode.Text)
  55. {
  56. OperateResult.AppendText("<<" + sncode.Text + "已校验\n", Color.Red);
  57. return;
  58. }
  59. if (CheckSnDGV.Rows[i].Cells["pd_barcode"].Value.ToString() == sncode.Text)
  60. {
  61. CheckSnDGV.Rows[i].Cells["pd_checksn"].Value = sncode.Text;
  62. FindSN = true;
  63. }
  64. if (CheckSnDGV.Rows[i].Cells["pd_checksn"].Value == null)
  65. {
  66. AllCheck = false;
  67. }
  68. }
  69. if (FindSN)
  70. {
  71. OperateResult.AppendText("<<SN" + sncode.Text + "校验成功\n", Color.Green, sncode);
  72. CheckCount = CheckCount + 1;
  73. CheckLabel.Text = CheckCount + "/" + dt.Rows.Count;
  74. }
  75. else
  76. {
  77. OperateResult.AppendText("<<SN" + sncode.Text + "校验失败\n", Color.Red, sncode);
  78. }
  79. if (AllCheck)
  80. {
  81. SetCheck set = new SetCheck("OK", Color.Green);
  82. BaseUtil.SetFormCenter(set);
  83. set.ShowDialog();
  84. pa_outboxcode.Focus();
  85. }
  86. }
  87. }
  88. private void pa_outboxcode_KeyDown(object sender, KeyEventArgs e)
  89. {
  90. if (e.KeyCode == Keys.Enter)
  91. {
  92. dt = (DataTable)dh.ExecuteSql("select pa_outboxcode from package where pa_mothercode='" + pa_outboxcode.Text + "'", "select");
  93. if (dt.Rows.Count > 0)
  94. {
  95. CheckLabel.Text = CheckCount + "/" + dt.Rows.Count;
  96. BaseUtil.FillDgvWithDataTable(CheckSnDGV, dt);
  97. sncode.Focus();
  98. }
  99. else
  100. {
  101. OperateResult.AppendText("<<箱号" + pa_outboxcode.Text + "不存在\n", Color.Red);
  102. }
  103. CheckCount = 0;
  104. }
  105. }
  106. private void cancel_Click(object sender, EventArgs e)
  107. {
  108. CheckCount = 0;
  109. dt = (DataTable)dh.ExecuteSql("select pa_outboxcode from package where pa_mothercode='" + pa_outboxcode.Text + "'", "select");
  110. if (dt.Rows.Count > 0)
  111. {
  112. CheckLabel.Text = CheckCount + "/" + dt.Rows.Count;
  113. BaseUtil.FillDgvWithDataTable(CheckSnDGV, dt);
  114. sncode.Focus();
  115. }
  116. else
  117. {
  118. OperateResult.AppendText("<<箱号" + pa_outboxcode.Text + "不存在\n", Color.Red);
  119. }
  120. CheckCount = 0;
  121. }
  122. }
  123. }