123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- 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_NEW.DataOperate;
- using UAS_MES_NEW.Entity;
- using UAS_MES_NEW.PublicMethod;
- namespace UAS_MES_NEW.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 = SystemInf.dh;
- }
- private void Split_Click(object sender, EventArgs e)
- {
- if (dh.CheckExist("package", "pa_outboxcode='" + Pallate.Text + "' and pa_type=3"))
- {
- DataTable dt = (DataTable)dh.ExecuteSql("select v_barcode from mes_package_view where v_outboxcode='" + Pallate.Text + "'", "select");
- List<string> ms_sncode = new List<string>();
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- ms_sncode.Add(dt.Rows[i]["v_barcode"].ToString());
- }
- sql.Clear();
- sql.Append("select distinct ms_outboxcode,ms_makecode 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)
- {
- string ms_makecode = dt1.Rows[0]["ms_makecode"].ToString();
- //获取卡通箱的外层箱号
- 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<string> outboxcode2 = new List<string>();
- for (int i = 0; i < dt3.Rows.Count; i++)
- {
- outboxcode2.Add(dt3.Rows[i]["pa_mothercode"].ToString());
- }
- dh.BatchInsert("insert into PACKAGEBACKUP select * from package where pa_outboxcode=:outboxcode2", new string[] { "outboxcode2" }, outboxcode2.ToArray());
- dh.BatchInsert("insert into PACKAGEBACKUPDETAIL select * from packagedetail where pd_outboxcode=:outboxcode2", new string[] { "outboxcode2" }, outboxcode2.ToArray());
- 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<string> outboxcode1 = new List<string>();
- for (int i = 0; i < dt2.Rows.Count; i++)
- {
- outboxcode1.Add(dt2.Rows[i]["pa_mothercode"].ToString());
- }
- dh.BatchInsert("insert into PACKAGEBACKUP select * from package where pa_outboxcode=:outboxcode1", new string[] { "outboxcode1" }, outboxcode1.ToArray());
- dh.BatchInsert("insert into PACKAGEBACKUPDETAIL select * from packagedetail where pd_outboxcode=:outboxcode1", new string[] { "outboxcode1" }, outboxcode1.ToArray());
- 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<string> outboxcode = new List<string>();
- for (int i = 0; i < dt1.Rows.Count; i++)
- {
- outboxcode.Add(dt1.Rows[i]["ms_outboxcode"].ToString());
- }
- dh.BatchInsert("insert into PACKAGEBACKUP select * from package where pa_outboxcode=:outboxcode", new string[] { "outboxcode" }, outboxcode.ToArray());
- dh.BatchInsert("insert into PACKAGEBACKUPDETAIL select * from packagedetail where pd_outboxcode=:outboxcode", new string[] { "outboxcode" }, outboxcode.ToArray());
- 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());
- dh.BatchInsert("update makeserial set ms_outboxcode='' where ms_sncode=:ms_sncode and ms_makecode='" + ms_makecode + "' ", new string[] { "ms_sncode" }, ms_sncode.ToArray());
- }
- LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, "", User.UserLineCode, User.UserSourceCode, "返工栈板解除", "解除成功", Pallate.Text, "");
- OperatResult.AppendText(">>栈板" + Pallate.Text + "拆解成功\n", Color.Green, Pallate);
- }
- else OperatResult.AppendText(">>栈板号" + Pallate.Text + "不存在\n", Color.Red, Pallate);
- }
- }
- }
|