Special_BoxSplit.cs 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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;
  31. sql.Clear();
  32. sql.Append("select nvl(pa_iostatus,0) pa_iostatus,pa_outno from package where pa_outboxcode='" + Pallate.Text + "'");
  33. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  34. if (dt.Rows.Count > 0)
  35. {
  36. if (dt.Rows[0]["pa_outno"].ToString() != "")
  37. {
  38. OperatResult.AppendText(">>栈板" + Pallate.Text + "已被出货单" + dt.Rows[0]["pa_outno"].ToString() + "采集,不允许操作\n", Color.Red);
  39. return;
  40. }
  41. if (dt.Rows[0]["pa_iostatus"].ToString() != "0")
  42. {
  43. OperatResult.AppendText(">>栈板" + Pallate.Text + "处于入库状态,不允许操作\n", Color.Red);
  44. return;
  45. }
  46. }
  47. dt = (DataTable)dh.ExecuteSql("select v_makecode,v_barcode from mes_package_view where v_outboxcode='" + Pallate.Text + "'", "select");
  48. List<string> ms_sncode = new List<string>();
  49. List<string> v_makecode = new List<string>();
  50. for (int i = 0; i < dt.Rows.Count; i++)
  51. {
  52. ms_sncode.Add(dt.Rows[i]["v_barcode"].ToString());
  53. v_makecode.Add(dt.Rows[i]["v_makecode"].ToString());
  54. }
  55. sql.Clear();
  56. sql.Append("select distinct ms_outboxcode,ms_makecode from makeserial left join mes_package_view on v_makecode=ms_makecode and ");
  57. sql.Append("ms_sncode=v_barcode where v_outboxcode='" + Pallate.Text + "' and ms_outboxcode is not null");
  58. //获取所有的卡通箱号
  59. DataTable dt1 = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  60. if (dt1.Rows.Count > 0)
  61. {
  62. //获取卡通箱的外层箱号
  63. sql.Clear();
  64. sql.Append("select distinct pa_mothercode from package where pa_outboxcode in(select distinct ms_outboxcode ");
  65. sql.Append("from makeserial left join mes_package_view on v_makecode = ms_makecode and ms_sncode = v_barcode where ");
  66. sql.Append("v_outboxcode='" + Pallate.Text + "') and pa_mothercode is not null");
  67. DataTable dt2 = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  68. if (dt2.Rows.Count > 0)
  69. {
  70. //获取外层箱号的外箱号
  71. sql.Clear();
  72. sql.Append("select pa_mothercode from package where pa_outboxcode in(");
  73. sql.Append("select distinct pa_mothercode from package where pa_outboxcode in(select distinct ms_outboxcode ");
  74. sql.Append("from makeserial left join mes_package_view on v_makecode = ms_makecode and ms_sncode = v_barcode where ");
  75. sql.Append("v_outboxcode='" + Pallate.Text + "')) and pa_mothercode is not null");
  76. DataTable dt3 = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  77. if (dt3.Rows.Count > 0)
  78. {
  79. //删除最外层的箱号
  80. List<string> outboxcode2 = new List<string>();
  81. for (int i = 0; i < dt3.Rows.Count; i++)
  82. {
  83. outboxcode2.Add(dt3.Rows[i]["pa_mothercode"].ToString());
  84. }
  85. dh.BatchInsert("insert into PACKAGEBACKUP select * from package where pa_outboxcode=:outboxcode2", new string[] { "outboxcode2" }, outboxcode2.ToArray());
  86. dh.BatchInsert("insert into PACKAGEBACKUPDETAIL select * from packagedetail where pd_outboxcode=:outboxcode2", new string[] { "outboxcode2" }, outboxcode2.ToArray());
  87. dh.BatchInsert("delete from packagedetail where pd_outboxcode=:outboxcode2", new string[] { "outboxcode2" }, outboxcode2.ToArray());
  88. dh.BatchInsert("delete from package where pa_outboxcode=:outboxcode2", new string[] { "outboxcode2" }, outboxcode2.ToArray());
  89. dh.BatchInsert("delete from labelprintlog where lpl_value=:outboxcode2", new string[] { "outboxcode2" }, outboxcode2.ToArray());
  90. }
  91. //删除内一层箱号
  92. List<string> outboxcode1 = new List<string>();
  93. for (int i = 0; i < dt2.Rows.Count; i++)
  94. {
  95. outboxcode1.Add(dt2.Rows[i]["pa_mothercode"].ToString());
  96. }
  97. dh.BatchInsert("insert into PACKAGEBACKUP select * from package where pa_outboxcode=:outboxcode1", new string[] { "outboxcode1" }, outboxcode1.ToArray());
  98. dh.BatchInsert("insert into PACKAGEBACKUPDETAIL select * from packagedetail where pd_outboxcode=:outboxcode1", new string[] { "outboxcode1" }, outboxcode1.ToArray());
  99. dh.BatchInsert("delete from packagedetail where pd_outboxcode=:outboxcode1", new string[] { "outboxcode1" }, outboxcode1.ToArray());
  100. dh.BatchInsert("delete from package where pa_outboxcode=:outboxcode1", new string[] { "outboxcode1" }, outboxcode1.ToArray());
  101. dh.BatchInsert("delete from labelprintlog where lpl_value=:outboxcode1", new string[] { "outboxcode1" }, outboxcode1.ToArray());
  102. }
  103. //删除卡通箱号
  104. List<string> outboxcode = new List<string>();
  105. for (int i = 0; i < dt1.Rows.Count; i++)
  106. {
  107. outboxcode.Add(dt1.Rows[i]["ms_outboxcode"].ToString());
  108. }
  109. dh.BatchInsert("insert into PACKAGEBACKUP select * from package where pa_outboxcode=:outboxcode", new string[] { "outboxcode" }, outboxcode.ToArray());
  110. dh.BatchInsert("insert into PACKAGEBACKUPDETAIL select * from packagedetail where pd_outboxcode=:outboxcode", new string[] { "outboxcode" }, outboxcode.ToArray());
  111. dh.BatchInsert("delete from packagedetail where pd_outboxcode=:outboxcode", new string[] { "outboxcode" }, outboxcode.ToArray());
  112. dh.BatchInsert("delete from package where pa_outboxcode=:outboxcode", new string[] { "outboxcode" }, outboxcode.ToArray());
  113. 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());
  114. dh.BatchInsert("delete from labelprintlog where lpl_value=:outboxcode", new string[] { "outboxcode" }, outboxcode.ToArray());
  115. }
  116. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, "", User.UserLineCode, User.UserSourceCode, "返工栈板解除", "解除成功", Pallate.Text, "");
  117. OperatResult.AppendText(">>栈板" + Pallate.Text + "拆解成功\n", Color.Green, Pallate);
  118. }
  119. else OperatResult.AppendText(">>栈板号" + Pallate.Text + "不存在\n", Color.Red, Pallate);
  120. }
  121. }
  122. }