Make_OutBoxSnCheck.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. object fugelcode = CheckSnDGV.Rows[RowIndex].Cells["pr_fugelcode"].Value;
  52. if ((fugelcode != null ? fugelcode.ToString() : "") + CheckSnDGV.Rows[RowIndex].Cells["pd_barcode"].Value.ToString() == sncode.Text)
  53. {
  54. CheckSnDGV.Rows[RowIndex].Cells["pd_checksn1"].Value = sncode.Text;
  55. FindFugeSN = true;
  56. }
  57. else
  58. {
  59. OperateResult.AppendText("<<" + sncode.Text + "机身校验失败\n", Color.Red, sncode);
  60. return;
  61. }
  62. }
  63. for (int i = 0; i < CheckSnDGV.Rows.Count; i++)
  64. {
  65. if (!FindColorSN)
  66. {
  67. object colorcode = CheckSnDGV.Rows[RowIndex].Cells["pr_colorcode"].Value;
  68. Console.WriteLine(CheckSnDGV.Rows[i].Cells["pd_barcode"].Value.ToString() + (colorcode != null ? colorcode.ToString() : ""));
  69. if ((colorcode != null ? colorcode.ToString() : "") + CheckSnDGV.Rows[i].Cells["pd_barcode"].Value.ToString() == sncode.Text)
  70. {
  71. CheckSnDGV.Rows[i].Cells["pd_checksn"].Value = sncode.Text;
  72. RowIndex = i;
  73. FindColorSN = true;
  74. }
  75. }
  76. if (CheckSnDGV.Rows[i].Cells["pd_checksn"].Value == null || CheckSnDGV.Rows[i].Cells["pd_checksn1"].Value == null)
  77. {
  78. AllCheck = false;
  79. }
  80. }
  81. if (!FindColorSN && !FindFugeSN)
  82. {
  83. OperateResult.AppendText("<<" + sncode.Text + "校验失败\n", Color.Red, sncode);
  84. }
  85. if (FindColorSN && !FindFugeSN)
  86. {
  87. OperateResult.AppendText("<<" + sncode.Text + "彩盒校验成功\n", Color.Green, sncode);
  88. }
  89. if (FindFugeSN)
  90. {
  91. FindColorSN = false;
  92. FindFugeSN = false;
  93. OperateResult.AppendText("<<" + sncode.Text + "机身校验成功\n", Color.Green, sncode);
  94. }
  95. if (AllCheck)
  96. {
  97. SetCheck set = new SetCheck("OK", Color.Green);
  98. BaseUtil.SetFormCenter(set);
  99. set.ShowDialog();
  100. pa_outboxcode.Focus();
  101. }
  102. }
  103. }
  104. private void pa_outboxcode_KeyDown(object sender, KeyEventArgs e)
  105. {
  106. if (e.KeyCode == Keys.Enter)
  107. {
  108. dt = (DataTable)dh.ExecuteSql("select pd_barcode,PR_COLORCODE, PR_FUGELCODE from packagedetail left join product on pr_code=PD_PRODCODE where pd_outboxcode='" + pa_outboxcode.Text + "'", "select");
  109. if (dt.Rows.Count > 0)
  110. {
  111. BaseUtil.FillDgvWithDataTable(CheckSnDGV, dt);
  112. sncode.Focus();
  113. }
  114. else
  115. {
  116. OperateResult.AppendText("<<箱号" + pa_outboxcode.Text + "不存在\n", Color.Red);
  117. }
  118. }
  119. }
  120. }
  121. }