using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using UAS_MES.DataOperate; using UAS_MES.PublicMethod; namespace UAS_MES.Special { public partial class Special_BoxSplit : Form { DataHelper dh; LogStringBuilder sql = new LogStringBuilder(); public Special_BoxSplit() { InitializeComponent(); } private void Special_BoxSplit_Load(object sender, EventArgs e) { dh = new DataHelper(); } private void Split_Click(object sender, EventArgs e) { if (dh.CheckExist("package", "pa_outboxcode='" + Pallate.Text + "' and pa_type=3")) { sql.Clear(); sql.Append("select distinct ms_outboxcode from makeserial left join mes_package_view on v_makecode=ms_makecode and "); sql.Append("ms_sncode=v_barcode where v_outboxcode='" + Pallate.Text + "' and ms_outboxcode is not null"); //获取所有的卡通箱号 DataTable dt1 = (DataTable)dh.ExecuteSql(sql.GetString(), "select"); if (dt1.Rows.Count > 0) { //获取卡通箱的外层箱号 sql.Clear(); sql.Append("select distinct pa_mothercode from package where pa_outboxcode in(select distinct ms_outboxcode "); sql.Append("from makeserial left join mes_package_view on v_makecode = ms_makecode and ms_sncode = v_barcode where "); sql.Append("v_outboxcode='" + Pallate.Text + "') and pa_mothercode is not null"); DataTable dt2 = (DataTable)dh.ExecuteSql(sql.GetString(), "select"); if (dt2.Rows.Count > 0) { //获取外层箱号的外箱号 sql.Clear(); sql.Append("select pa_mothercode from package where pa_outboxcode in("); sql.Append("select distinct pa_mothercode from package where pa_outboxcode in(select distinct ms_outboxcode "); sql.Append("from makeserial left join mes_package_view on v_makecode = ms_makecode and ms_sncode = v_barcode where "); sql.Append("v_outboxcode='" + Pallate.Text + "')) and pa_mothercode is not null"); DataTable dt3 = (DataTable)dh.ExecuteSql(sql.GetString(), "select"); if (dt3.Rows.Count > 0) { //删除最外层的箱号 List outboxcode2 = new List(); for (int i = 0; i < dt3.Rows.Count; i++) { outboxcode2.Add(dt3.Rows[i]["pa_mothercode"].ToString()); } dh.BatchInsert("delete from packagedetail where pd_outboxcode=:outboxcode2", new string[] { "outboxcode2" }, outboxcode2.ToArray()); dh.BatchInsert("delete from package where pa_outboxcode=:outboxcode2", new string[] { "outboxcode2" }, outboxcode2.ToArray()); } //删除内一层箱号 List outboxcode1 = new List(); for (int i = 0; i < dt2.Rows.Count; i++) { outboxcode1.Add(dt2.Rows[i]["pa_mothercode"].ToString()); } dh.BatchInsert("delete from packagedetail where pd_outboxcode=:outboxcode1", new string[] { "outboxcode1" }, outboxcode1.ToArray()); dh.BatchInsert("delete from package where pa_outboxcode=:outboxcode1", new string[] { "outboxcode1" }, outboxcode1.ToArray()); } //删除卡通箱号 List outboxcode = new List(); for (int i = 0; i < dt1.Rows.Count; i++) { outboxcode.Add(dt1.Rows[i]["ms_outboxcode"].ToString()); } dh.BatchInsert("delete from packagedetail where pd_outboxcode=:outboxcode", new string[] { "outboxcode" }, outboxcode.ToArray()); dh.BatchInsert("delete from package where pa_outboxcode=:outboxcode", new string[] { "outboxcode" }, outboxcode.ToArray()); } OperatResult.AppendText(">>栈板" + Pallate.Text + "拆解成功\n", Color.Green, Pallate); } else OperatResult.AppendText(">>栈板号" + Pallate.Text + "不存在\n", Color.Red, Pallate); } } }