瀏覽代碼

修改物料自动拆解

callm 2 天之前
父節點
當前提交
df51f66aee

+ 39 - 8
UAS_MES_YDCY/FunctionCode/OQC/OQC_PlanMaintain_Cust.cs

@@ -203,7 +203,7 @@ namespace UAS_MES_NEW.OQC
                             }
                             }
                             StringBuilder sql = new StringBuilder();
                             StringBuilder sql = new StringBuilder();
                             sql.Append("update craftmaterial set cm_status=-1,CM_DROPMAN='" + User.UserName + "' where  cm_stepcode in (select cd_stepcode from craft left join ");
                             sql.Append("update craftmaterial set cm_status=-1,CM_DROPMAN='" + User.UserName + "' where  cm_stepcode in (select cd_stepcode from craft left join ");
-                            sql.Append("craftdetail on cd_crid = cr_id where cr_prodcode = '" + ms_prodcode + "'  and cd_detno >= " + stepno + ") ");
+                            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 + "'");
                             sql.Append("and cm_sncode='" + ms_sncode.Text + "' and cm_makecode='" + oMakeCode + "'");
                             dh.ExecuteSql(sql.ToString(), "update");
                             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_nextstepcode='" + pcd_okretuenstep + "' where ms_id='" + oMSID + "'", "select");
@@ -217,8 +217,24 @@ namespace UAS_MES_NEW.OQC
                     {
                     {
                         dh.ExecuteSql("delete from makeserial where ms_id='" + oMSID + "'", "delete");
                         dh.ExecuteSql("delete from makeserial where ms_id='" + oMSID + "'", "delete");
                         dh.ExecuteSql("delete from steppassed where sp_sncode='" + ms_sncode.Text + "' and sp_makecode='" + oMakeCode + "'", "delete");
                         dh.ExecuteSql("delete from steppassed where sp_sncode='" + ms_sncode.Text + "' and sp_makecode='" + oMakeCode + "'", "delete");
-                        string ms_id = dh.getFieldDataByCondition("makeserial", "max(ms_id)", "ms_sncode='" + ms_sncode.Text + "'").ToString();
-                        dh.ExecuteSql("update makeserial set ms_nextmacode='',ms_nextstepcode='" + pcd_okretuenstep + "',ms_status=1 where ms_id='" + ms_id + "'", "update");
+                        dt = (DataTable)dh.ExecuteSql("select ms_id,ms_craftcode,ms_prodcode,ms_makecode from makeserial where ms_sncode='" + ms_sncode.Text + "' order by ms_id", "select");
+                        if (dt.Rows.Count > 0)
+                        {
+                            string ms_id = dt.Rows[0]["ms_id"].ToString();
+                            string ms_prodcode = dt.Rows[0]["ms_prodcode"].ToString();
+                            string ms_makecode = dt.Rows[0]["ms_makecode"].ToString();
+                            dh.ExecuteSql("update makeserial set ms_nextmacode='',ms_nextstepcode='" + pcd_okretuenstep + "',ms_status=1 where ms_id='" + ms_id + "'", "update");
+                            string stepno = dh.getFieldDataByCondition("makeserial left join craft on cr_code=ms_craftcode and ms_prodcode=cr_prodcode left join craftdetail on cd_crid=cr_id", "cd_stepno", "ms_id='" + ms_id + "' and cd_stepcode='" + pcd_okretuenstep + "'").ToString();
+                            if (stepno == "")
+                            {
+                                stepno = "100";
+                            }
+                            StringBuilder sql = new StringBuilder();
+                            sql.Append("update craftmaterial set cm_status=-1,CM_DROPMAN='" + User.UserName + "' where  cm_stepcode in (select cd_stepcode from craft left join ");
+                            sql.Append("craftdetail on cd_crid = cr_id where cr_prodcode = '" + ms_prodcode + "'  and cd_detno >= " + stepno + ") ");
+                            sql.Append("and cm_sncode='" + ms_sncode.Text + "' and cm_makecode='" + ms_makecode + "'");
+                            dh.ExecuteSql(sql.ToString(), "update");
+                        }
                     }
                     }
                 }
                 }
                 //if (LogicHandler.SetStepResult(oMakeCode, User.UserSourceCode, ms_sncode.Text, "良品采集", "OK", User.UserCode, out ErrorMessage))
                 //if (LogicHandler.SetStepResult(oMakeCode, User.UserSourceCode, ms_sncode.Text, "良品采集", "OK", User.UserCode, out ErrorMessage))
@@ -261,14 +277,14 @@ namespace UAS_MES_NEW.OQC
                         string ms_craftcode = dt.Rows[0]["ms_craftcode"].ToString();
                         string ms_craftcode = dt.Rows[0]["ms_craftcode"].ToString();
                         if (pcd_ngretuenstep != "")
                         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_okretuenstep + "'").ToString();
+                            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";
                                 stepno = "100";
                             }
                             }
                             StringBuilder sql = new StringBuilder();
                             StringBuilder sql = new StringBuilder();
                             sql.Append("update craftmaterial set cm_status=-1,CM_DROPMAN='" + User.UserName + "' where  cm_stepcode in (select cd_stepcode from craft left join ");
                             sql.Append("update craftmaterial set cm_status=-1,CM_DROPMAN='" + User.UserName + "' where  cm_stepcode in (select cd_stepcode from craft left join ");
-                            sql.Append("craftdetail on cd_crid = cr_id where cr_prodcode = '" + ms_prodcode + "'  and cd_detno >= " + stepno + ") ");
+                            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 + "'");
                             sql.Append("and cm_sncode='" + ms_sncode.Text + "' and cm_makecode='" + oMakeCode + "'");
                             dh.ExecuteSql(sql.ToString(), "update");
                             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_nextstepcode='" + pcd_ngretuenstep + "' where ms_id='" + oMSID + "'", "select");
@@ -285,9 +301,24 @@ namespace UAS_MES_NEW.OQC
                         dh.ExecuteSql("update craftmaterial set cm_status=-1 where cm_sncode='" + ms_sncode.Text + "' and cm_makecode='" + oMakeCode + "'", "update");
                         dh.ExecuteSql("update craftmaterial set cm_status=-1 where cm_sncode='" + ms_sncode.Text + "' and cm_makecode='" + oMakeCode + "'", "update");
                         dh.ExecuteSql("delete from steppassed where sp_sncode='" + ms_sncode.Text + "' and sp_makecode='" + oMakeCode + "'", "delete");
                         dh.ExecuteSql("delete from steppassed where sp_sncode='" + ms_sncode.Text + "' and sp_makecode='" + oMakeCode + "'", "delete");
                         dh.ExecuteSql("update makecraftdetail set mcd_inqty=mcd_inqty-1,mcd_outqty=mcd_outqty-1,mcd_okqty=mcd_okqty-1 where mcd_macode='" + oMakeCode + "' and instr((select ms_paststep from makeserial where ms_id='" + oMSID + "'),mcd_stepcode)>0 ", "update");
                         dh.ExecuteSql("update makecraftdetail set mcd_inqty=mcd_inqty-1,mcd_outqty=mcd_outqty-1,mcd_okqty=mcd_okqty-1 where mcd_macode='" + oMakeCode + "' and instr((select ms_paststep from makeserial where ms_id='" + oMSID + "'),mcd_stepcode)>0 ", "update");
-                        string ms_id = dh.getFieldDataByCondition("makeserial", "max(ms_id)", "ms_sncode='" + ms_sncode.Text + "'").ToString();
-                        // dh.ExecuteSql("update makeserial set ms_nextmacode='',ms_nextstepcode='" + pcd_ngretuenstep + "',ms_status=3 where ms_id='" + ms_id + "'", "update");
-                        dh.ExecuteSql("update makeserial set ms_nextmacode='',ms_nextstepcode='',ms_status=3 where ms_id='" + ms_id + "'", "update");
+                        dt = (DataTable)dh.ExecuteSql("select ms_id,ms_craftcode,ms_prodcode,ms_makecode from makeserial where ms_sncode='" + ms_sncode.Text + "' order by ms_id", "select");
+                        if (dt.Rows.Count > 0)
+                        {
+                            string ms_id = dt.Rows[0]["ms_id"].ToString();
+                            string ms_prodcode = dt.Rows[0]["ms_prodcode"].ToString();
+                            string ms_makecode = dt.Rows[0]["ms_makecode"].ToString();
+                            dh.ExecuteSql("update makeserial set ms_nextmacode='',ms_nextstepcode='',ms_status=3 where ms_id='" + ms_id + "'", "update");
+                            string stepno = dh.getFieldDataByCondition("makeserial left join craft on cr_code=ms_craftcode and ms_prodcode=cr_prodcode left join craftdetail on cd_crid=cr_id", "cd_stepno", "ms_id='" + ms_id + "' and cd_stepcode='" + pcd_okretuenstep + "'").ToString();
+                            if (stepno == "")
+                            {
+                                stepno = "100";
+                            }
+                            StringBuilder sql = new StringBuilder();
+                            sql.Append("update craftmaterial set cm_status=-1,CM_DROPMAN='" + User.UserName + "' where  cm_stepcode in (select cd_stepcode from craft left join ");
+                            sql.Append("craftdetail on cd_crid = cr_id where cr_prodcode = '" + ms_prodcode + "'  and cd_detno >= " + stepno + ") ");
+                            sql.Append("and cm_sncode='" + ms_sncode.Text + "' and cm_makecode='" + ms_makecode + "'");
+                            dh.ExecuteSql(sql.ToString(), "update");
+                        }
                     }
                     }
                 }
                 }
                 dh.ExecuteSql("insert into makebad(MB_ID, MB_MAKECODE, MB_MSCODE, MB_SNCODE, MB_INMAN, MB_INDATE, MB_STEPCODE, MB_SOURCECODE, MB_BADCODE, MB_BGCODE, " +
                 dh.ExecuteSql("insert into makebad(MB_ID, MB_MAKECODE, MB_MSCODE, MB_SNCODE, MB_INMAN, MB_INDATE, MB_STEPCODE, MB_SOURCECODE, MB_BADCODE, MB_BGCODE, " +

+ 42 - 8
UAS_MES_YDCY/FunctionCode/OQC/OQC_PlanMaintain_NEW.cs

@@ -189,7 +189,7 @@ namespace UAS_MES_NEW.OQC
                             }
                             }
                             StringBuilder sql = new StringBuilder();
                             StringBuilder sql = new StringBuilder();
                             sql.Append("update craftmaterial set cm_status=-1,CM_DROPMAN='" + User.UserName + "' where  cm_stepcode in (select cd_stepcode from craft left join ");
                             sql.Append("update craftmaterial set cm_status=-1,CM_DROPMAN='" + User.UserName + "' where  cm_stepcode in (select cd_stepcode from craft left join ");
-                            sql.Append("craftdetail on cd_crid = cr_id where cr_prodcode = '" + ms_prodcode + "'  and cd_detno >= " + stepno + ") ");
+                            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 + "'");
                             sql.Append("and cm_sncode='" + ms_sncode.Text + "' and cm_makecode='" + oMakeCode + "'");
                             dh.ExecuteSql(sql.ToString(), "update");
                             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_nextstepcode='" + pcd_okretuenstep + "' where ms_id='" + oMSID + "'", "select");
@@ -206,9 +206,26 @@ namespace UAS_MES_NEW.OQC
                         dh.ExecuteSql("delete from steppassed where sp_sncode='" + ms_sncode.Text + "' and sp_makecode='" + oMakeCode + "'", "delete");
                         dh.ExecuteSql("delete from steppassed where sp_sncode='" + ms_sncode.Text + "' and sp_makecode='" + oMakeCode + "'", "delete");
                         dh.ExecuteSql("update craftmaterial set cm_status=-1 where cm_sncode='" + ms_sncode.Text + "' and cm_makecode='" + oMakeCode + "'", "update");
                         dh.ExecuteSql("update craftmaterial set cm_status=-1 where cm_sncode='" + ms_sncode.Text + "' and cm_makecode='" + oMakeCode + "'", "update");
                         dh.ExecuteSql("update makecraftdetail set mcd_inqty=mcd_inqty-1,mcd_outqty=mcd_outqty-1,mcd_okqty=mcd_okqty-1 where mcd_macode='" + oMakeCode + "' and instr((select ms_paststep from makeserial where ms_id='" + oMSID + "'),mcd_stepcode)>0 ", "update");
                         dh.ExecuteSql("update makecraftdetail set mcd_inqty=mcd_inqty-1,mcd_outqty=mcd_outqty-1,mcd_okqty=mcd_okqty-1 where mcd_macode='" + oMakeCode + "' and instr((select ms_paststep from makeserial where ms_id='" + oMSID + "'),mcd_stepcode)>0 ", "update");
-                        string ms_id = dh.getFieldDataByCondition("makeserial", "max(ms_id)", "ms_sncode='" + ms_sncode.Text + "'").ToString();
                         //dh.ExecuteSql("update makeserial set ms_nextmacode='',ms_nextstepcode='" + pcd_ngretuenstep + "',ms_status=1 where ms_id='" + ms_id + "'", "update");
                         //dh.ExecuteSql("update makeserial set ms_nextmacode='',ms_nextstepcode='" + pcd_ngretuenstep + "',ms_status=1 where ms_id='" + ms_id + "'", "update");
-                        dh.ExecuteSql("update makeserial set ms_nextmacode='',ms_nextstepcode='"+ pcd_okretuenstep + "',ms_status=1 where ms_id='" + ms_id + "'", "update");
+                        dt = (DataTable)dh.ExecuteSql("select ms_id,ms_craftcode,ms_prodcode,ms_makecode from makeserial where ms_sncode='" + ms_sncode.Text + "' order by ms_id", "select");
+                        if (dt.Rows.Count > 0)
+                        {
+                            string ms_id = dt.Rows[0]["ms_id"].ToString();
+                            string ms_prodcode = dt.Rows[0]["ms_prodcode"].ToString();
+                            string ms_makecode = dt.Rows[0]["ms_makecode"].ToString();
+                            dh.ExecuteSql("update makeserial set ms_nextmacode='',ms_nextstepcode='" + pcd_okretuenstep + "',ms_status=1 where ms_id='" + ms_id + "'", "update");
+                            string stepno = dh.getFieldDataByCondition("makeserial left join craft on cr_code=ms_craftcode and ms_prodcode=cr_prodcode left join craftdetail on cd_crid=cr_id", "cd_stepno", "ms_id='" + ms_id + "' and cd_stepcode='" + pcd_okretuenstep + "'").ToString();
+                            if (stepno == "")
+                            {
+                                stepno = "100";
+                            }
+                            StringBuilder sql = new StringBuilder();
+                            sql.Append("update craftmaterial set cm_status=-1,CM_DROPMAN='" + User.UserName + "' where  cm_stepcode in (select cd_stepcode from craft left join ");
+                            sql.Append("craftdetail on cd_crid = cr_id where cr_prodcode = '" + ms_prodcode + "'  and cd_detno >= " + stepno + ") ");
+                            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");
                 dh.ExecuteSql("update makeserial set MS_IFQCCHECK=0 where ms_id='" + oMSID + "'", "select");
@@ -251,20 +268,20 @@ namespace UAS_MES_NEW.OQC
                     if (dt.Rows.Count > 0)
                     if (dt.Rows.Count > 0)
                     {
                     {
                         string ms_craftcode=dt.Rows[0]["ms_craftcode"].ToString();
                         string ms_craftcode=dt.Rows[0]["ms_craftcode"].ToString();
-                        if (pcd_okretuenstep == "")
+                        if (pcd_ngretuenstep == "")
                         {
                         {
                             OperateResult.AppendText(">>回流工序为空,不允许回流\n", Color.Red, ms_sncode);
                             OperateResult.AppendText(">>回流工序为空,不允许回流\n", Color.Red, ms_sncode);
                             return;
                             return;
                         }
                         }
                         if (pcd_ngretuenstep != "")
                         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_okretuenstep + "'").ToString();
+                            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";
                                 stepno = "100";
                             }
                             }
                             StringBuilder sql = new StringBuilder();
                             StringBuilder sql = new StringBuilder();
                             sql.Append("update craftmaterial set cm_status=-1,CM_DROPMAN='" + User.UserName + "' where  cm_stepcode in (select cd_stepcode from craft left join ");
                             sql.Append("update craftmaterial set cm_status=-1,CM_DROPMAN='" + User.UserName + "' where  cm_stepcode in (select cd_stepcode from craft left join ");
-                            sql.Append("craftdetail on cd_crid = cr_id where cr_prodcode = '" + ms_prodcode + "'  and cd_detno >= " + stepno + ") ");
+                            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 + "'");
                             sql.Append("and cm_sncode='" + ms_sncode.Text + "' and cm_makecode='" + oMakeCode + "'");
                             dh.ExecuteSql(sql.ToString(), "update");
                             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_nextstepcode='" + pcd_ngretuenstep + "' where ms_id='" + oMSID + "'", "select");
@@ -281,8 +298,25 @@ namespace UAS_MES_NEW.OQC
                         dh.ExecuteSql("delete from steppassed where sp_sncode='" + ms_sncode.Text + "' and sp_makecode='" + oMakeCode + "'", "delete");
                         dh.ExecuteSql("delete from steppassed where sp_sncode='" + ms_sncode.Text + "' and sp_makecode='" + oMakeCode + "'", "delete");
                         dh.ExecuteSql("update craftmaterial set cm_status=-1 where cm_sncode='" + ms_sncode.Text + "' and cm_makecode='" + oMakeCode + "'", "update");
                         dh.ExecuteSql("update craftmaterial set cm_status=-1 where cm_sncode='" + ms_sncode.Text + "' and cm_makecode='" + oMakeCode + "'", "update");
                         dh.ExecuteSql("update makecraftdetail set mcd_inqty=mcd_inqty-1,mcd_outqty=mcd_outqty-1,mcd_okqty=mcd_okqty-1 where mcd_macode='" + oMakeCode + "' and instr((select ms_paststep from makeserial where ms_id='" + oMSID + "'),mcd_stepcode)>0 ", "update");
                         dh.ExecuteSql("update makecraftdetail set mcd_inqty=mcd_inqty-1,mcd_outqty=mcd_outqty-1,mcd_okqty=mcd_okqty-1 where mcd_macode='" + oMakeCode + "' and instr((select ms_paststep from makeserial where ms_id='" + oMSID + "'),mcd_stepcode)>0 ", "update");
-                        string ms_id = dh.getFieldDataByCondition("makeserial", "max(ms_id)", "ms_sncode='" + ms_sncode.Text + "'").ToString();
-                        dh.ExecuteSql("update makeserial set ms_nextmacode='',ms_nextstepcode='',ms_status=3 where ms_id='" + ms_id + "'", "update");
+                        dt = (DataTable)dh.ExecuteSql("select ms_id,ms_craftcode,ms_prodcode,ms_makecode from makeserial where ms_sncode='" + ms_sncode.Text + "' order by ms_id", "select");
+                        if (dt.Rows.Count > 0)
+                        {
+                            string ms_id = dt.Rows[0]["ms_id"].ToString();
+                            string ms_prodcode = dt.Rows[0]["ms_prodcode"].ToString();
+                            string ms_makecode = dt.Rows[0]["ms_makecode"].ToString();
+                            dh.ExecuteSql("update makeserial set ms_nextmacode='',ms_nextstepcode='',ms_status=3 where ms_id='" + ms_id + "'", "update");
+                            string stepno = dh.getFieldDataByCondition("makeserial left join craft on cr_code=ms_craftcode and ms_prodcode=cr_prodcode left join craftdetail on cd_crid=cr_id", "cd_stepno", "ms_id='" + ms_id + "' and cd_stepcode='" + pcd_okretuenstep + "'").ToString();
+                            if (stepno == "")
+                            {
+                                stepno = "100";
+                            }
+                            StringBuilder sql = new StringBuilder();
+                            sql.Append("update craftmaterial set cm_status=-1,CM_DROPMAN='" + User.UserName + "' where  cm_stepcode in (select cd_stepcode from craft left join ");
+                            sql.Append("craftdetail on cd_crid = cr_id where cr_prodcode = '" + ms_prodcode + "'  and cd_detno >= " + stepno + ") ");
+                            sql.Append("and cm_sncode='" + ms_sncode.Text + "' and cm_makecode='" + ms_makecode + "'");
+                            dh.ExecuteSql(sql.ToString(), "update");
+                        }
+
                     }
                     }
                 }
                 }
                 LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, oMakeCode, User.UserLineCode, User.UserSourceCode, "采集不良品", "采集不良品成功", ms_sncode.Text, "");
                 LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, oMakeCode, User.UserLineCode, User.UserSourceCode, "采集不良品", "采集不良品成功", ms_sncode.Text, "");