Make_OutBoxSnCheck.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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.PublicMethod;
  12. namespace UAS_MES_NEW.Make
  13. {
  14. public partial class Make_OutBoxSnCheck : Form
  15. {
  16. AutoSizeFormClass asc = new AutoSizeFormClass();
  17. DataHelper dh;
  18. LogStringBuilder sql;
  19. DataTable dt;
  20. public Make_OutBoxSnCheck()
  21. {
  22. InitializeComponent();
  23. }
  24. private void Make_LabelCheck_Load(object sender, EventArgs e)
  25. {
  26. asc.controllInitializeSize(this);
  27. //聚焦SN号
  28. pa_outboxcode.Focus();
  29. //打开界面提示用户:请输入SN
  30. OperateResult.AppendText(">>请采集箱号\n", Color.Black);
  31. sql = new LogStringBuilder();
  32. dh = SystemInf.dh;
  33. }
  34. private void Make_LabelCheck_SizeChanged(object sender, EventArgs e)
  35. {
  36. asc.controlAutoSize(this);
  37. }
  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 FindSN = false;
  49. bool AllCheck = true;
  50. for (int i = 0; i < CheckSnDGV.Rows.Count; i++)
  51. {
  52. if (CheckSnDGV.Rows[i].Cells["pd_barcode"].Value.ToString() == sncode.Text)
  53. {
  54. CheckSnDGV.Rows[i].Cells["pd_checksn"].Value = sncode.Text;
  55. FindSN = true;
  56. }
  57. if (CheckSnDGV.Rows[i].Cells["pd_checksn"].Value == null)
  58. {
  59. AllCheck = false;
  60. }
  61. }
  62. if (FindSN)
  63. {
  64. OperateResult.AppendText("<<SN" + sncode.Text + "校验成功\n", Color.Green, sncode);
  65. }
  66. else
  67. {
  68. OperateResult.AppendText("<<SN" + sncode.Text + "校验失败\n", Color.Red, sncode);
  69. }
  70. if (AllCheck)
  71. {
  72. pa_outboxcode.Focus();
  73. }
  74. }
  75. }
  76. private void pa_outboxcode_KeyDown(object sender, KeyEventArgs e)
  77. {
  78. if (e.KeyCode == Keys.Enter)
  79. {
  80. dt = (DataTable)dh.ExecuteSql("select pd_barcode from packagedetail where pd_outboxcode='" + pa_outboxcode.Text + "'", "select");
  81. if (dt.Rows.Count > 0)
  82. {
  83. BaseUtil.FillDgvWithDataTable(CheckSnDGV, dt);
  84. sncode.Focus();
  85. }
  86. else
  87. {
  88. OperateResult.AppendText("<<箱号" + pa_outboxcode.Text + "不存在\n", Color.Red);
  89. }
  90. }
  91. }
  92. }
  93. }