Make_OutBoxSnCheck.cs 3.3 KB

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