Make_OutBoxSnCheck.cs 4.3 KB

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