Special_BoxSplit.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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.DataOperate;
  10. using UAS_MES.PublicMethod;
  11. namespace UAS_MES.Special
  12. {
  13. public partial class Special_BoxSplit : Form
  14. {
  15. DataHelper dh;
  16. LogStringBuilder sql = new LogStringBuilder();
  17. public Special_BoxSplit()
  18. {
  19. InitializeComponent();
  20. }
  21. private void Special_BoxSplit_Load(object sender, EventArgs e)
  22. {
  23. dh = new DataHelper();
  24. }
  25. private void Split_Click(object sender, EventArgs e)
  26. {
  27. if (dh.CheckExist("package", "pa_outboxcode='" + Pallate.Text + "' and pa_type=3"))
  28. {
  29. sql.Clear();
  30. sql.Append("select distinct ms_outboxcode from makeserial left join mes_package_view on v_makecode=ms_makecode and ");
  31. sql.Append("ms_sncode=v_barcode where v_outboxcode='" + Pallate.Text + "' and ms_outboxcode is not null");
  32. //获取所有的卡通箱号
  33. DataTable dt1 = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  34. if (dt1.Rows.Count > 0)
  35. {
  36. //获取卡通箱的外层箱号
  37. sql.Clear();
  38. sql.Append("select distinct pa_mothercode from package where pa_outboxcode in(select distinct ms_outboxcode ");
  39. sql.Append("from makeserial left join mes_package_view on v_makecode = ms_makecode and ms_sncode = v_barcode where ");
  40. sql.Append("v_outboxcode='" + Pallate.Text + "') and pa_mothercode is not null");
  41. DataTable dt2 = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  42. if (dt2.Rows.Count > 0)
  43. {
  44. //获取外层箱号的外箱号
  45. sql.Clear();
  46. sql.Append("select pa_mothercode from package where pa_outboxcode in(");
  47. sql.Append("select distinct pa_mothercode from package where pa_outboxcode in(select distinct ms_outboxcode ");
  48. sql.Append("from makeserial left join mes_package_view on v_makecode = ms_makecode and ms_sncode = v_barcode where ");
  49. sql.Append("v_outboxcode='" + Pallate.Text + "')) and pa_mothercode is not null");
  50. DataTable dt3 = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  51. if (dt3.Rows.Count > 0)
  52. {
  53. //删除最外层的箱号
  54. List<string> outboxcode2 = new List<string>();
  55. for (int i = 0; i < dt3.Rows.Count; i++)
  56. {
  57. outboxcode2.Add(dt3.Rows[i]["pa_mothercode"].ToString());
  58. }
  59. dh.BatchInsert("delete from packagedetail where pd_outboxcode=:outboxcode2", new string[] { "outboxcode2" }, outboxcode2.ToArray());
  60. dh.BatchInsert("delete from package where pa_outboxcode=:outboxcode2", new string[] { "outboxcode2" }, outboxcode2.ToArray());
  61. }
  62. //删除内一层箱号
  63. List<string> outboxcode1 = new List<string>();
  64. for (int i = 0; i < dt2.Rows.Count; i++)
  65. {
  66. outboxcode1.Add(dt2.Rows[i]["pa_mothercode"].ToString());
  67. }
  68. dh.BatchInsert("delete from packagedetail where pd_outboxcode=:outboxcode1", new string[] { "outboxcode1" }, outboxcode1.ToArray());
  69. dh.BatchInsert("delete from package where pa_outboxcode=:outboxcode1", new string[] { "outboxcode1" }, outboxcode1.ToArray());
  70. }
  71. //删除卡通箱号
  72. List<string> outboxcode = new List<string>();
  73. for (int i = 0; i < dt1.Rows.Count; i++)
  74. {
  75. outboxcode.Add(dt1.Rows[i]["ms_outboxcode"].ToString());
  76. }
  77. dh.BatchInsert("delete from packagedetail where pd_outboxcode=:outboxcode", new string[] { "outboxcode" }, outboxcode.ToArray());
  78. dh.BatchInsert("delete from package where pa_outboxcode=:outboxcode", new string[] { "outboxcode" }, outboxcode.ToArray());
  79. }
  80. OperatResult.AppendText(">>栈板" + Pallate.Text + "拆解成功\n", Color.Green, Pallate);
  81. }
  82. else OperatResult.AppendText(">>栈板号" + Pallate.Text + "不存在\n", Color.Red, Pallate);
  83. }
  84. }
  85. }