|
|
@@ -749,38 +749,32 @@ namespace UAS_MES.Make
|
|
|
if (ob_status == "" || ob_status == "ENTERING" || ob_status == "UNCHECK")
|
|
|
{
|
|
|
sql.Clear();
|
|
|
- sql.Append("select pd_makecode,pd_barcode,pd_prodcode,ms_status,ms_stepcode from packagedetail left join makeserial ");
|
|
|
- sql.Append("on ms_sncode=pd_barcode and ms_makecode=pd_makecode where pd_outboxcode='" + pa_outboxcode.Text + "'");
|
|
|
+ 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='" + pa_outboxcode.Text + "' group by pd_makecode");
|
|
|
dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
|
|
|
+ List<string> SQLS1 = new List<string>();
|
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
|
{
|
|
|
string ma_code = dt.Rows[i]["pd_makecode"].ToString();
|
|
|
- string ms_sncode = dt.Rows[i]["pd_barcode"].ToString();
|
|
|
- string pr_code = dt.Rows[i]["pd_prodcode"].ToString();
|
|
|
- string ms_status = dt.Rows[i]["ms_status"].ToString();
|
|
|
- string ms_stepcode = dt.Rows[i]["ms_stepcode"].ToString();
|
|
|
- List<string> SQLS1 = new List<string>();
|
|
|
- if (ms_status == "2")
|
|
|
- {
|
|
|
- //已完工数-1
|
|
|
- SQLS1.Add("update make set ma_madeqty=ma_madeqty-1 where ma_code='" + ma_code + "'");
|
|
|
- }
|
|
|
- //更新序列号状态
|
|
|
- SQLS1.Add("update makecraftdetail set mcd_inqty=mcd_inqty-1,mcd_okqty=mcd_okqty-1 where mcd_macode='" + ma_code + "' and mcd_stepcode='" + ms_stepcode + "'");
|
|
|
- SQLS1.Add("update makeserial set ms_status=1,ms_outboxcode='',ms_nextstepcode= (case when ms_nextstepcode='" + User.CurrentStepCode + "' then ms_nextstepcode else ms_stepcode end ) where ms_sncode='" + ms_sncode + "' and ms_makecode='" + ma_code + "'");
|
|
|
- SQLS1.Add("delete from makeprocess where mp_sncode='" + ms_sncode + "' and mp_makecode='" + ma_code + "' and mp_stepcode='" + ms_stepcode + "'");
|
|
|
- SQLS1.Add("delete from steppassed where sp_sncode='" + ms_sncode + "' and sp_makecode='" + ma_code + "' and sp_stepcode='" + ms_stepcode + "'");
|
|
|
- //抽检批次不为空的时候进行移除
|
|
|
- if (pa_checkno != "")
|
|
|
- {
|
|
|
- SQLS1.Add("update makeserial set ms_checkno='' where ms_sncode='" + ms_sncode + "' and ms_makecode='" + ma_code + "'");
|
|
|
- SQLS1.Add("update oqcbatch set ob_nowcheckqty=ob_nowcheckqty-(select count(1) from oqcbatchdetail where obd_outboxcode='" + pa_outboxcode.Text + "') where ob_checkno='" + pa_checkno + "'");
|
|
|
- SQLS1.Add("delete from oqcbatchdetail where obd_outboxcode='" + pa_outboxcode.Text + "'");
|
|
|
- }
|
|
|
- dh.ExecuteSQLTran(SQLS1.ToArray());
|
|
|
+ string num = dt.Rows[i]["num"].ToString();
|
|
|
+ SQLS1.Add("delete from makeprocess where mp_sncode in (select ms_sncode from makeserial where ms_outboxcode='" + pa_outboxcode.Text + "' 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='" + pa_outboxcode.Text + "' 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='" + pa_outboxcode.Text + "' 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='" + pa_outboxcode.Text + "'");
|
|
|
+ SQLS1.Add("update oqcbatch set ob_nowcheckqty=ob_nowcheckqty-(select count(1) from oqcbatchdetail where obd_outboxcode='" + pa_outboxcode.Text + "') where ob_checkno='" + pa_checkno + "'");
|
|
|
+ SQLS1.Add("delete from oqcbatchdetail where obd_outboxcode='" + pa_outboxcode.Text + "'");
|
|
|
+ }
|
|
|
+ //更新序列号状态
|
|
|
+ SQLS1.Add("update makeserial set ms_status=1,ms_outboxcode='',ms_nextstepcode= (case when ms_nextstepcode='" + User.CurrentStepCode + "' then ms_nextstepcode else ms_stepcode end ),ms_paststep=replace(ms_paststep,'," + User.CurrentStepCode + "','') where ms_outboxcode='" + pa_outboxcode.Text + "'");
|
|
|
+ //抽检批次不为空的时候进行移除
|
|
|
+ dh.ExecuteSQLTran(SQLS1.ToArray());
|
|
|
List<string> SQLS2 = new List<string>();
|
|
|
- ////置空原箱
|
|
|
+ //置空原箱
|
|
|
SQLS2.Add("update package set pa_checkno='',pa_prodcode='',pa_packtype='',pa_salecode='',pa_packageqty=0,pa_totalqty=0,pa_currentqty=0,pa_status=0 where pa_outboxcode='" + pa_outboxcode.Text + "'");
|
|
|
pa_status.Text = "0";
|
|
|
//删除箱的明细
|
|
|
@@ -935,7 +929,6 @@ namespace UAS_MES.Make
|
|
|
}
|
|
|
else
|
|
|
OperateResult.AppendText(">>服务已经开启\n");
|
|
|
-
|
|
|
}
|
|
|
|
|
|
private void CloseServer_Click(object sender, EventArgs e)
|