Explorar el Código

拆解回流自动拆解箱号

callm hace 15 horas
padre
commit
629a201406
Se han modificado 1 ficheros con 18 adiciones y 9 borrados
  1. 18 9
      UAS_MES_YDCY/FunctionCode/OQC/OQC_PlanMaintain_NEW.cs

+ 18 - 9
UAS_MES_YDCY/FunctionCode/OQC/OQC_PlanMaintain_NEW.cs

@@ -1,4 +1,5 @@
 using DevExpress.Charts.Native;
+using NPOI.SS.Formula.Functions;
 using System;
 using System.Collections.Generic;
 using System.Data;
@@ -174,12 +175,13 @@ namespace UAS_MES_NEW.OQC
                         return;
                     }
                     sql.Clear();
-                    sql.Append("select ms_craftcode  from makeserial left join craft on cr_prodcode=ms_prodcode and cr_code=ms_craftcode " +
+                    sql.Append("select ms_craftcode,ms_outboxcode  from makeserial left join craft on cr_prodcode=ms_prodcode and cr_code=ms_craftcode " +
                         " left join craftdetail on cd_crid=cr_id where ms_id='" + oMSID + "' and cd_stepcode='" + pcd_okretuenstep + "'");
                     dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
                     if (dt.Rows.Count > 0)
                     {
                         string ms_craftcode = dt.Rows[0]["ms_craftcode"].ToString();
+                        string ms_outboxcode = dt.Rows[0]["ms_outboxcode"].ToString();
                         if (pcd_okretuenstep != "")
                         {
                             string stepno = dh.getFieldDataByCondition("craft left join craftdetail on cd_crid=cr_id", "cd_stepno", "cr_prodcode='" + ms_prodcode.Text + "' and cr_code='" + ms_craftcode + "' and cd_stepcode='" + pcd_okretuenstep + "'").ToString();
@@ -192,12 +194,15 @@ namespace UAS_MES_NEW.OQC
                             sql.Append("craftdetail on cd_crid = cr_id where cr_prodcode = '" + ms_prodcode.Text + "'  and cd_detno >= " + stepno + ") ");
                             sql.Append("and cm_sncode='" + ms_sncode.Text + "' and cm_makecode='" + oMakeCode + "'");
                             dh.ExecuteSql(sql.ToString(), "update");
-                            dh.ExecuteSql("update makeserial set MS_IFQCCHECK=0,ms_nextstepcode='" + pcd_okretuenstep + "' where ms_id='" + oMSID + "'", "select");
+                            dh.ExecuteSql("update makeserial set MS_IFQCCHECK=0,ms_outboxcode='',ms_nextstepcode='" + pcd_okretuenstep + "' where ms_id='" + oMSID + "'", "select");
                         }
                         else
                         {
-                            dh.ExecuteSql("update makeserial set MS_IFQCCHECK=0 where ms_id='" + oMSID + "'", "select");
+                            dh.ExecuteSql("update makeserial set MS_IFQCCHECK=0,ms_outboxcode='' where ms_id='" + oMSID + "'", "select");
                         }
+                        dh.ExecuteSql("delete from packagedetail where pd_outboxcode='" + ms_outboxcode + "' and pd_barcode='" + ms_sncode.Text + "'", "delete");
+                        //减少箱内容量
+                        dh.ExecuteSql("update package set pa_packageqty=pa_packageqty-1,pa_totalqty=pa_totalqty-1,pa_currentqty=pa_currentqty-1,pa_status=0 where pa_outboxcode='" + ms_outboxcode + "'", "update");
                     }
                     else
                     {
@@ -225,7 +230,6 @@ namespace UAS_MES_NEW.OQC
                             sql.Append("and cm_sncode='" + ms_sncode.Text + "' and cm_makecode='" + ms_makecode + "'");
                             dh.ExecuteSql(sql.ToString(), "update");
                         }
-
                     }
                 }
                 dh.ExecuteSql("update makeserial set MS_IFQCCHECK=0 where ms_id='" + oMSID + "'", "select");
@@ -262,12 +266,13 @@ namespace UAS_MES_NEW.OQC
                 if (ReturnStep.Checked)
                 {
                     sql.Clear();
-                    sql.Append("select ms_craftcode  from makeserial left join craft on cr_prodcode=ms_prodcode and cr_code=ms_craftcode " +
+                    sql.Append("select ms_craftcode,ms_outboxcode,ms_sncode  from makeserial left join craft on cr_prodcode=ms_prodcode and cr_code=ms_craftcode " +
                         " left join craftdetail on cd_crid=cr_id where ms_id='" + oMSID + "' and cd_stepcode='" + pcd_ngretuenstep + "'");
                     dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
                     if (dt.Rows.Count > 0)
                     {
-                        string ms_craftcode=dt.Rows[0]["ms_craftcode"].ToString();
+                        string ms_craftcode = dt.Rows[0]["ms_craftcode"].ToString();
+                        string ms_outboxcode = dt.Rows[0]["ms_outboxcode"].ToString();
                         if (pcd_ngretuenstep == "")
                         {
                             OperateResult.AppendText(">>回流工序为空,不允许回流\n", Color.Red, ms_sncode);
@@ -276,7 +281,8 @@ namespace UAS_MES_NEW.OQC
                         if (pcd_ngretuenstep != "")
                         {
                             string stepno = dh.getFieldDataByCondition("craft left join craftdetail on cd_crid=cr_id", "cd_stepno", "cr_prodcode='" + ms_prodcode.Text + "' and cr_code='" + ms_craftcode + "' and cd_stepcode='" + pcd_ngretuenstep + "'").ToString();
-                            if (stepno == "") {
+                            if (stepno == "")
+                            {
                                 stepno = "100";
                             }
                             StringBuilder sql = new StringBuilder();
@@ -284,12 +290,15 @@ namespace UAS_MES_NEW.OQC
                             sql.Append("craftdetail on cd_crid = cr_id where cr_prodcode = '" + ms_prodcode.Text + "'  and cd_detno >= " + stepno + ") ");
                             sql.Append("and cm_sncode='" + ms_sncode.Text + "' and cm_makecode='" + oMakeCode + "'");
                             dh.ExecuteSql(sql.ToString(), "update");
-                            dh.ExecuteSql("update makeserial set MS_IFQCCHECK=0,ms_nextstepcode='" + pcd_ngretuenstep + "' where ms_id='" + oMSID + "'", "select");
+                            dh.ExecuteSql("update makeserial set MS_IFQCCHECK=0,ms_outboxcode='',ms_nextstepcode='" + pcd_ngretuenstep + "' where ms_id='" + oMSID + "'", "select");
                         }
                         else
                         {
-                            dh.ExecuteSql("update makeserial set MS_IFQCCHECK=0 where ms_id='" + oMSID + "'", "select");
+                            dh.ExecuteSql("update makeserial set MS_IFQCCHECK=0,ms_outboxcode='' where ms_id='" + oMSID + "'", "select");
                         }
+                        dh.ExecuteSql("delete from packagedetail where pd_outboxcode='" + ms_outboxcode + "' and pd_barcode='" + ms_sncode.Text + "'", "delete");
+                        //减少箱内容量
+                        dh.ExecuteSql("update package set pa_packageqty=pa_packageqty-1,pa_totalqty=pa_totalqty-1,pa_currentqty=pa_currentqty-1,pa_status=0 where pa_outboxcode='" + ms_outboxcode + "'", "update");
                     }
                     else
                     {