From 243e86af1a7c74c8bfda3bb41f29a11fef13c065 Mon Sep 17 00:00:00 2001
From: zrg <z18737863051@163.com>
Date: 星期三, 09 十月 2024 16:32:52 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API

---
 WebAPI/DLL/ClsSc_MESBeginWorkBill.cs |   96 ++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 85 insertions(+), 11 deletions(-)

diff --git a/WebAPI/DLL/ClsSc_MESBeginWorkBill.cs b/WebAPI/DLL/ClsSc_MESBeginWorkBill.cs
index 0e38b1b..982f9d3 100644
--- a/WebAPI/DLL/ClsSc_MESBeginWorkBill.cs
+++ b/WebAPI/DLL/ClsSc_MESBeginWorkBill.cs
@@ -9,12 +9,13 @@
     {
         public Models.ClsSc_MESBeginWorkBillMain omodel = new Models.ClsSc_MESBeginWorkBillMain();
         public List<Models.ClsSc_MESBeginWorkBillSub> DetailColl = new List<Models.ClsSc_MESBeginWorkBillSub>();
+        public List<Models.ClsSc_MESBeginWorkBillSub_RelationBill> DetailCol2 = new List<Models.ClsSc_MESBeginWorkBillSub_RelationBill>();
         //public List<Model.ClsSc_MESBeginWorkBillSub_Item> DetailColl1 = new List<Model.ClsSc_MESBeginWorkBillSub_Item>();
 
         public ClsSc_MESBeginWorkBill()
         {
             base.MvarItemKeySub = "Sc_MESBeginWorkBillSub";
-            base.MvarItemKeySub2 = "";
+            base.MvarItemKeySub2 = "Sc_MESBeginWorkBillSub_RelationBill";
             base.MvarItemKeySub3 = "";
             base.MvarItemKeySub4 = "";
             base.MvarItemKey="Sc_MESBeginWorkBillMain";
@@ -152,8 +153,41 @@
                 DeleteRelation(ref sReturn, lngBillKey);
                 //鍒犻櫎瀛愯〃
                 DeleteBillSub(lngBillKey);
+                DeleteBillSub2(lngBillKey);
                 //鎻掑叆瀛愯〃
                 omodel.HInterID = lngBillKey;
+
+                //鎻掑叆瀛愯〃_鍓骇璁″垝
+                foreach (Models.ClsSc_MESBeginWorkBillSub_RelationBill oSub in DetailCol2)
+                {
+                    string subSql = "insert into Sc_MESBeginWorkBillSub_RelationBill " +
+                        "(HInterID, HEntryID,HBillNo_bak, HSourceInterID, HSourceEntryID, HSourceBillNo, HSourceBillType, HRemark, " +
+                        "HRelationBillInterID, HRelationBillEntryID, HRelationBillNo, HRelationBillType, HICMOInterID, HICMOEntryID, HICMOBillNo, " +
+                        "HProcExchInterID, HProcExchEntryID, HProcExchBillNo, HMaterID, HProcID) " +
+                        "values(" +
+                        "'" + omodel.HInterID.ToString() + "'," +
+                        "'" + oSub.HEntryID.ToString() + "'," +
+                        "'" + omodel.HBillNo + "'," +
+                        "'" + oSub.HSourceInterID + "'," +
+                        "'" + oSub.HSourceEntryID + "'," +
+                        "'" + oSub.HSourceBillNo + "'," +
+                        "'" + oSub.HSourceBillType + "'," +
+                        "'" + oSub.HRemark + "'," +
+                        "'" + oSub.HRelationBillInterID + "'," +
+                        "'" + oSub.HRelationBillEntryID + "'," +
+                        "'" + oSub.HRelationBillNo + "'," +
+                        "'" + oSub.HRelationBillType + "'," +
+                        "'" + oSub.HICMOInterID + "'," +
+                        "'" + oSub.HICMOEntryID + "'," +
+                        "'" + oSub.HICMOBillNo + "'," +
+                        "'" + oSub.HProcExchInterID + "'," +
+                        "'" + oSub.HProcExchEntryID + "'," +
+                        "'" + oSub.HProcExchBillNo + "'," +
+                        "'" + oSub.HMaterID + "'," +
+                        "'" + oSub.HProcID + "')";
+                    oCn.RunProc(subSql);
+                }
+
                 foreach (Models.ClsSc_MESBeginWorkBillSub oSub in DetailColl)
                 {
                     //oCn.RunProc("Insert into Sc_MESBeginWorkBillSub " +
@@ -249,6 +283,38 @@
                 "," + omodel.HGroupID.ToString() + "," + omodel.HDeptID.ToString() + "," + omodel.HEmpID.ToString() + ",'" + omodel.HBarCode + "','" + omodel.HAddr + "','" + omodel.HBarCodeMaker + "',getdate(),'"+ omodel.HRunStatus + "','"+ omodel.HSourceBeginQty.ToString() + "'" +
               ") ");
 
+                //鎻掑叆瀛愯〃
+                foreach (Models.ClsSc_MESBeginWorkBillSub_RelationBill oSub in DetailCol2)
+                {
+                    string subSql = "insert into Sc_MESBeginWorkBillSub_RelationBill " +
+                        "(HInterID, HEntryID,HBillNo_bak, HSourceInterID, HSourceEntryID, HSourceBillNo, HSourceBillType, HRemark, " +
+                        "HRelationBillInterID, HRelationBillEntryID, HRelationBillNo, HRelationBillType, HICMOInterID, HICMOEntryID, HICMOBillNo, " +
+                        "HProcExchInterID, HProcExchEntryID, HProcExchBillNo, HMaterID, HProcID) " +
+                        "values(" +
+                        "'" + omodel.HInterID.ToString() + "'," +
+                        "'" + oSub.HEntryID.ToString() + "'," +
+                        "'" + omodel.HBillNo + "'," +
+                        "'" + oSub.HSourceInterID + "'," +
+                        "'" + oSub.HSourceEntryID + "'," +
+                        "'" + oSub.HSourceBillNo + "'," +
+                        "'" + oSub.HSourceBillType + "'," +
+                        "'" + oSub.HRemark + "'," +
+                        "'" + oSub.HRelationBillInterID + "'," +
+                        "'" + oSub.HRelationBillEntryID + "'," +
+                        "'" + oSub.HRelationBillNo + "'," +
+                        "'" + oSub.HRelationBillType + "'," +
+                        "'" + oSub.HICMOInterID + "'," +
+                        "'" + oSub.HICMOEntryID + "'," +
+                        "'" + oSub.HICMOBillNo + "'," +
+                        "'" + oSub.HProcExchInterID + "'," +
+                        "'" + oSub.HProcExchEntryID + "'," +
+                        "'" + oSub.HProcExchBillNo + "'," +
+                        "'" + oSub.HMaterID + "'," +
+                        "'" + oSub.HProcID + "')";
+                    oCn.RunProc(subSql);
+                }
+
+
                 //鍐嶆楠岃瘉 淇濆瓨鏄惁 鍚堢悊
                 ds = oCn.RunProcReturn("exec h_p_JIT_MESBeginWorkBill_SaveCtrl @HInterId=" + omodel.HInterID + "", "h_p_JIT_MESBeginWorkBill_SaveCtrl");
                 if (ds == null || ds.Tables[0].Rows.Count <= 0) 
@@ -260,13 +326,6 @@
                 if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) == "2") 
                 {
                     sReturn = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
-                    oCn.RollBack();
-                    return false;
-                }
-
-                //淇濆瓨鍚庢帶鍒�
-                if (!AfterSave(omodel.HInterID, omodel.HICMOInterID, omodel.HICMOEntryID, omodel.HICMOBillNo, 1, ref sReturn))
-                {
                     oCn.RollBack();
                     return false;
                 }
@@ -283,14 +342,29 @@
                     string HSourceID = ds.Tables[0].Rows[0]["HSourceID"].ToString();
 
                     ds = oCn.RunProcReturn(@"select  HMouldID from Sc_MouldUpperBillMain a
-inner join Sc_MouldUpperBillSub b on a.HInterID = b.HInterID where HICMOInterID=" + HICMOInterID + " and HICMOEntryID=" + HICMOEntryID + " and HProcExchInterID=" + HSourceInterID + " and  HProcExchEntryID=" + HSourceEntryID + " and HSourceID=" + HSourceID + " order by HMakeDate desc", "Sc_MouldUpperBillMain");
+                        inner join Sc_MouldUpperBillSub b on a.HInterID = b.HInterID where HICMOInterID=" + HICMOInterID + " and HICMOEntryID=" + HICMOEntryID + " and HProcExchInterID=" + HSourceInterID + " and  HProcExchEntryID=" + HSourceEntryID + " and HSourceID=" + HSourceID + " order by HMakeDate desc", "Sc_MouldUpperBillMain");
                     if (ds.Tables[0].Rows.Count > 0)
                     {
                         oCn.RunProc("update Sc_ICMOBillStatus_Tmp set HMouldID= " + ds.Tables[0].Rows[0]["HMouldID"].ToString() + " where HInterID=" + omodel.HMainSourceInterID.ToString());
                     }
-
+                    else
+                    {
+                        ds = oCn.RunProcReturn(@"select  HMouldID from Sc_MouldUpperBillMain a
+                        inner join Sc_MouldUpperBillSub b on a.HInterID = b.HInterID where  HSourceID=" + HSourceID + " order by HMakeDate desc", "Sc_MouldUpperBillMain");
+                        if (ds.Tables[0].Rows.Count > 0)
+                        {
+                            oCn.RunProc("update Sc_ICMOBillStatus_Tmp set HMouldID= " + ds.Tables[0].Rows[0]["HMouldID"].ToString() + " where HInterID=" + omodel.HMainSourceInterID.ToString());
+                        }
+                    }
                 }
-               
+
+                //淇濆瓨鍚庢帶鍒�
+                if (!AfterSave(omodel.HInterID, omodel.HICMOInterID, omodel.HICMOEntryID, omodel.HICMOBillNo, 1, ref sReturn))
+                {
+                    oCn.RollBack();
+                    return false;
+                }
+
                 sReturn = omodel.HInterID.ToString();
                 oCn.Commit();
                 return true;

--
Gitblit v1.9.1