123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- 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_ChecknoSpitBox : Form
- {
- DataHelper dh;
- LogStringBuilder sql = new LogStringBuilder();
- public Special_ChecknoSpitBox()
- {
- InitializeComponent();
- }
- private void Special_BoxSplit_Load(object sender, EventArgs e)
- {
- dh = SystemInf.dh;
- }
- private void Split_Click(object sender, EventArgs e)
- {
- if (dh.getFieldDataByCondition("step", "st_ifpack", "st_code = '" + User.CurrentStepCode + "'").ToString() != "-1")
- {
- OperatResult.AppendText(">>当前登陆资源非包装资源,不允许采集\n", Color.Red);
- return;
- }
- if (checkno.Text == "")
- {
- OperatResult.AppendText(">>抽检批不能为空\n", Color.Red);
- return;
- }
- string Delete = MessageBox.Show(this.ParentForm, "是否确认批量拆箱?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
- if (Delete == "Yes")
- {
- DataTable dt = (DataTable)dh.ExecuteSql("select pa_makecode,pa_outboxcode,nvl(pa_iostatus,0)pa_iostatus,pa_outno,pa_status,pa_checkno,ob_status,pa_mothercode,nvl(pa_downstatus,0)pa_downstatus from package join oqcbatch on pa_checkno=ob_checkno where ob_checkno='"+checkno.Text+"'", "select");
- if (dt.Rows.Count > 0)
- {
- for (int jk = 0; jk < dt.Rows.Count; jk++)
- {
- if (dt.Rows[jk]["pa_outno"].ToString() != "")
- {
- OperatResult.AppendText(">>卡通箱" + dt.Rows[jk]["pa_outboxcode"].ToString() + "已被出货单" + dt.Rows[jk]["pa_outno"].ToString() + "采集,不允许操作\n", Color.Red);
- return;
- }
- if (dt.Rows[0]["pa_iostatus"].ToString() != "0")
- {
- OperatResult.AppendText(">>卡通箱" + dt.Rows[jk]["pa_outboxcode"].ToString() + "处于入库状态,不允许操作\n", Color.Red);
- return;
- }
- if (dt.Rows[0]["pa_status"].ToString() != "1")
- {
- OperatResult.AppendText(">>卡通箱" + dt.Rows[jk]["pa_outboxcode"].ToString() + "未封箱,不允许操作\n", Color.Red);
- return;
- }
- if (dt.Rows[0]["pa_mothercode"].ToString() == "")
- {
- if (dt.Rows[0]["pa_downstatus"].ToString() == "0")
- {
- string ob_status = dt.Rows[0]["ob_status"].ToString();
- string pa_checkno = dt.Rows[0]["pa_checkno"].ToString();
- ////不存在抽检批次或者还未检验可以拆解
- //if (ob_status == "" || ob_status == "ENTERING" || ob_status == "UNCHECK")
- //{
- sql.Clear();
- sql.Append("select pd_makecode,count(1) num from packagedetail left join makeserial ");
- sql.Append("on ms_sncode=pd_barcode and ms_makecode=pd_makecode where pd_outboxcode='" + dt.Rows[jk]["pa_outboxcode"].ToString() + "' group by pd_makecode");
- DataTable dtB = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- List<string> SQLS1 = new List<string>();
- for (int i = 0; i < dtB.Rows.Count; i++)
- {
- string ma_code = dtB.Rows[i]["pd_makecode"].ToString();
- string num = dtB.Rows[i]["num"].ToString();
- // SQLS1.Add("delete from makeprocess where mp_sncode in (select ms_sncode from makeserial where ms_outboxcode='" + dt.Rows[jk]["pa_outboxcode"].ToString() + "' and ms_makecode='" + ma_code + "') and mp_makecode='" + ma_code + "' and mp_stepcode='" + User.CurrentStepCode + "'");
- // SQLS1.Add("delete from steppassed where sp_sncode in (select ms_sncode from makeserial where ms_outboxcode='" + dt.Rows[jk]["pa_outboxcode"].ToString() + "' and ms_makecode='" + ma_code + "') and sp_makecode='" + ma_code + "' and sp_stepcode='" + User.CurrentStepCode + "'");
- SQLS1.Add("update makecraftdetail set mcd_inqty=mcd_inqty-" + num + ",mcd_outqty=mcd_outqty-" + num + ",mcd_okqty=mcd_okqty-" + num + " where mcd_macode='" + ma_code + "' and mcd_stepcode='" + User.CurrentStepCode + "'");
- //扣减已完工数
- SQLS1.Add("update make set ma_madeqty=ma_madeqty-(select count(1) from makeserial where ms_outboxcode='" + dt.Rows[jk]["pa_outboxcode"].ToString() + "' and ms_makecode='" + ma_code + "' and ms_status=2) where ma_code='" + ma_code + "'");
- }
- if (pa_checkno != "")
- {
- SQLS1.Add("update makeserial set ms_checkno='' where ms_outboxcode='" + dt.Rows[jk]["pa_outboxcode"].ToString() + "'");
- SQLS1.Add("update oqcbatch set ob_nowcheckqty=ob_nowcheckqty-(select count(1) from oqcbatchdetail where obd_outboxcode='" + dt.Rows[jk]["pa_outboxcode"].ToString() + "') where ob_checkno='" + pa_checkno + "'");
- SQLS1.Add("delete from oqcbatchdetail where obd_outboxcode='" + dt.Rows[jk]["pa_outboxcode"].ToString() + "'");
- }
- //更新序列号状态
- SQLS1.Add("update makeserial set ms_status=1,ms_outboxcode='',ms_nextstepcode= (case when ms_nextstepcode='" + User.CurrentStepCode + "' then ms_nextstepcode else '" + User.CurrentStepCode + "' end ),ms_paststep=replace(ms_paststep,'," + User.CurrentStepCode + "','') where ms_outboxcode='" + dt.Rows[jk]["pa_outboxcode"].ToString() + "'");
- //抽检批次不为空的时候进行移除
- dh.ExecuteSQLTran(SQLS1.ToArray());
- string prcode = dh.getFieldDataByCondition("packagedetail", "pd_prodcode", "pd_outboxcode = '" + dt.Rows[jk]["pa_outboxcode"].ToString() + "'").ToString();
- string standqty = dh.getFieldDataByCondition("product", "pr_outboxinnerqty", "pr_code = '" + prcode + "'").ToString();
- //if (standqty != "")
- //{
- // //置空原箱
- // dh.ExecuteSql("update package set pa_checkno='',pa_prodcode='',pa_packtype='',pa_salecode='',pa_packageqty=0,pa_totalqty=0,pa_currentqty=0,pa_status=0,PA_STANDARDQTY = '" + standqty + "' where checkno='" + dt.Rows[jk]["pa_outboxcode"].ToString() + "'", "update");
- //}
- //else
- // //置空原箱
- // dh.ExecuteSql("update package set pa_checkno='',pa_prodcode='',pa_packtype='',pa_salecode='',pa_packageqty=0,pa_totalqty=0,pa_currentqty=0,pa_status=0 where checkno='" + dt.Rows[jk]["pa_outboxcode"].ToString() + "'", "update");
- dh.ExecuteSql("insert into PACKAGEBACKUP select * from package where pa_outboxcode='" + dt.Rows[jk]["pa_outboxcode"].ToString() + "'", "insert");
- dh.ExecuteSql("insert into PACKAGEBACKUPDETAIL select * from packagedetail where pd_outboxcode='" + dt.Rows[jk]["pa_outboxcode"].ToString() + "'", "insert");
- dh.ExecuteSql("delete from package where pa_outboxcode = '" + dt.Rows[jk]["pa_outboxcode"].ToString() + "'", "delete");
- //删除箱的明细
- dh.ExecuteSql("delete from packagedetail where pd_outboxcode='" + dt.Rows[jk]["pa_outboxcode"].ToString() + "'", "delete");
- LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, dt.Rows[jk]["pa_makecode"].ToString(), User.UserLineCode, User.UserSourceCode, "卡通箱拆解", "成功", dt.Rows[jk]["pa_outboxcode"].ToString(), checkno.Text);
- OperatResult.AppendText(">>箱号" + dt.Rows[jk]["pa_outboxcode"].ToString() + "成功拆解!\n", Color.Green);
- //}
- //else OperatResult.AppendText(">>箱号" + dt.Rows[jk]["pa_outboxcode"].ToString() + "已送检,不允许解除\n", Color.Red);
- }
- else OperatResult.AppendText(">>箱号" + dt.Rows[jk]["pa_outboxcode"].ToString() + "已下地,不允许解除\n", Color.Red);
- }
- else OperatResult.AppendText(">>箱号" + dt.Rows[jk]["pa_outboxcode"].ToString() + "已装箱" + dt.Rows[0]["pa_mothercode"].ToString() + ",不允许解除\n", Color.Red);
- }
- }
- else OperatResult.AppendText(">>抽检批" + checkno.Text + "不存在\n", Color.Red);
- }
- }
- }
- }
|