Special_BoxSplit.cs 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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.Entity;
  11. using UAS_MES.PublicMethod;
  12. namespace UAS_MES.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_makecode,v_barcode from mes_package_view where v_outboxcode='" + Pallate.Text + "'", "select");
  31. List<string> ms_sncode = new List<string>();
  32. List<string> v_makecode = new List<string>();
  33. for (int i = 0; i < dt.Rows.Count; i++)
  34. {
  35. ms_sncode.Add(dt.Rows[i]["v_barcode"].ToString());
  36. v_makecode.Add(dt.Rows[i]["v_makecode"].ToString());
  37. }
  38. sql.Clear();
  39. sql.Append("select distinct ms_outboxcode,ms_makecode from makeserial left join mes_package_view on v_makecode=ms_makecode and ");
  40. sql.Append("ms_sncode=v_barcode where v_outboxcode='" + Pallate.Text + "' and ms_outboxcode is not null");
  41. //获取所有的卡通箱号
  42. DataTable dt1 = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  43. if (dt1.Rows.Count > 0)
  44. {
  45. //获取卡通箱的外层箱号
  46. sql.Clear();
  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 dt2 = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  51. if (dt2.Rows.Count > 0)
  52. {
  53. //获取外层箱号的外箱号
  54. sql.Clear();
  55. sql.Append("select pa_mothercode from package where pa_outboxcode in(");
  56. sql.Append("select distinct pa_mothercode from package where pa_outboxcode in(select distinct ms_outboxcode ");
  57. sql.Append("from makeserial left join mes_package_view on v_makecode = ms_makecode and ms_sncode = v_barcode where ");
  58. sql.Append("v_outboxcode='" + Pallate.Text + "')) and pa_mothercode is not null");
  59. DataTable dt3 = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  60. if (dt3.Rows.Count > 0)
  61. {
  62. //删除最外层的箱号
  63. List<string> outboxcode2 = new List<string>();
  64. for (int i = 0; i < dt3.Rows.Count; i++)
  65. {
  66. outboxcode2.Add(dt3.Rows[i]["pa_mothercode"].ToString());
  67. }
  68. dh.BatchInsert("insert into PACKAGEBACKUP select * from package where pa_outboxcode=:outboxcode2", new string[] { "outboxcode2" }, outboxcode2.ToArray());
  69. dh.BatchInsert("insert into PACKAGEBACKUPDETAIL select * from packagedetail where pd_outboxcode=:outboxcode2", new string[] { "outboxcode2" }, outboxcode2.ToArray());
  70. dh.BatchInsert("delete from packagedetail where pd_outboxcode=:outboxcode2", new string[] { "outboxcode2" }, outboxcode2.ToArray());
  71. dh.BatchInsert("delete from package where pa_outboxcode=:outboxcode2", new string[] { "outboxcode2" }, outboxcode2.ToArray());
  72. }
  73. //删除内一层箱号
  74. List<string> outboxcode1 = new List<string>();
  75. for (int i = 0; i < dt2.Rows.Count; i++)
  76. {
  77. outboxcode1.Add(dt2.Rows[i]["pa_mothercode"].ToString());
  78. }
  79. dh.BatchInsert("insert into PACKAGEBACKUP select * from package where pa_outboxcode=:outboxcode1", new string[] { "outboxcode1" }, outboxcode1.ToArray());
  80. dh.BatchInsert("insert into PACKAGEBACKUPDETAIL select * from packagedetail where pd_outboxcode=:outboxcode1", new string[] { "outboxcode1" }, outboxcode1.ToArray());
  81. dh.BatchInsert("delete from packagedetail where pd_outboxcode=:outboxcode1", new string[] { "outboxcode1" }, outboxcode1.ToArray());
  82. dh.BatchInsert("delete from package where pa_outboxcode=:outboxcode1", new string[] { "outboxcode1" }, outboxcode1.ToArray());
  83. }
  84. //删除卡通箱号
  85. List<string> outboxcode = new List<string>();
  86. for (int i = 0; i < dt1.Rows.Count; i++)
  87. {
  88. outboxcode.Add(dt1.Rows[i]["ms_outboxcode"].ToString());
  89. }
  90. dh.BatchInsert("insert into PACKAGEBACKUP select * from package where pa_outboxcode=:outboxcode", new string[] { "outboxcode" }, outboxcode.ToArray());
  91. dh.BatchInsert("insert into PACKAGEBACKUPDETAIL select * from packagedetail where pd_outboxcode=:outboxcode", new string[] { "outboxcode" }, outboxcode.ToArray());
  92. dh.BatchInsert("delete from packagedetail where pd_outboxcode=:outboxcode", new string[] { "outboxcode" }, outboxcode.ToArray());
  93. dh.BatchInsert("delete from package where pa_outboxcode=:outboxcode", new string[] { "outboxcode" }, outboxcode.ToArray());
  94. dh.BatchInsert("update makeserial set ms_outboxcode='' where ms_sncode=:ms_sncode and ms_makecode=:ms_makecode", new string[] { "ms_sncode","ms_makecode" }, ms_sncode.ToArray(),v_makecode.ToArray());
  95. }
  96. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, "", User.UserLineCode, User.UserSourceCode, "返工栈板解除", "解除成功", Pallate.Text, "");
  97. OperatResult.AppendText(">>栈板" + Pallate.Text + "拆解成功\n", Color.Green, Pallate);
  98. }
  99. else OperatResult.AppendText(">>栈板号" + Pallate.Text + "不存在\n", Color.Red, Pallate);
  100. }
  101. }
  102. }