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