From fcc99f2648369ea6aa20e59f59653ac872bba091 Mon Sep 17 00:00:00 2001
From: chenhaozhe <cgz@hz-kingdee.com>
Date: 星期日, 19 十月 2025 13:01:03 +0800
Subject: [PATCH] 分支合并

---
 WebAPI/Controllers/基础资料/基础资料/Gy_MateNumRelationController.cs |   66 +++++++++++++++++++++++++++++++++
 1 files changed, 66 insertions(+), 0 deletions(-)

diff --git "a/WebAPI/Controllers/\345\237\272\347\241\200\350\265\204\346\226\231/\345\237\272\347\241\200\350\265\204\346\226\231/Gy_MateNumRelationController.cs" "b/WebAPI/Controllers/\345\237\272\347\241\200\350\265\204\346\226\231/\345\237\272\347\241\200\350\265\204\346\226\231/Gy_MateNumRelationController.cs"
index b1932ff..0551520 100644
--- "a/WebAPI/Controllers/\345\237\272\347\241\200\350\265\204\346\226\231/\345\237\272\347\241\200\350\265\204\346\226\231/Gy_MateNumRelationController.cs"
+++ "b/WebAPI/Controllers/\345\237\272\347\241\200\350\265\204\346\226\231/\345\237\272\347\241\200\350\265\204\346\226\231/Gy_MateNumRelationController.cs"
@@ -457,5 +457,71 @@
             }
         }
         #endregion
+
+        #region 瀹㈡埛鐗╂枡瀵瑰簲琛ㄤ繚瀛�
+        [Route("Gy_MateNumRelation/SaveGy_MateNumRelationAPI")]
+        [HttpPost]
+        public object SaveGy_MateNumRelationAPI([FromBody] JObject oMain)
+        {
+            try
+            {
+                var model = oMain["model"].ToString();
+                LogService.Write("1" + model);
+                //鍙嶅簭鍒楀寲
+                model = "[" + model + "]";
+                List<Gy_MateNumRelation_Sec> lsmain = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Gy_MateNumRelation_Sec>>(model);
+                string sql = string.Empty;              
+                oCN.BeginTran();
+                foreach (var item in lsmain)
+                {
+                    // 浣跨敤褰撳墠item鐨凥ItemID鍒犻櫎
+                    sql = $"delete from  Gy_MateNumRelation_Sec where HItemID = {item.HItemID}";
+                    oCN.RunProc(sql);                  
+                    // 寮�鍚痠dentity_insert
+                    sql = "set identity_insert Gy_MateNumRelation_Sec on";
+                    oCN.RunProc(sql);                  
+
+                    LogService.Write("瀹㈡埛鐗╂枡瀵瑰簲琛�" + @"Insert Into Gy_MateNumRelation_Sec " +
+                          "(HItemID,HCusID,HCusRelationNumber,HCusRelationName,HMaterID" +
+                          ",HUsed,HCREATEORGID,HUSEORGID,HRemark,HMakeDate,HMaker" +
+                          ") " +
+                          " values('" + item.HItemID + "','" + item.HCusID + "','" + item.HCusRelationNumber + "','" + item.HCusRelationName + "','" + item.HMaterID + "'," +
+                          "'" + item.HUsed + "','" + item.HUSEORGID + "','" + item.HUSEORGID + "','" + item.HRemark + "',getdate(),'" + item.HMaker +
+                          "') ");
+
+                    // 鎻掑叆褰撳墠item鐨勮褰�
+                    sql = "Insert Into Gy_MateNumRelation_Sec " +
+                          "(HItemID,HCusID,HCusRelationNumber,HCusRelationName,HMaterID" +
+                          ",HUsed,HCREATEORGID,HUSEORGID,HRemark,HMakeDate,HMaker" +
+                          ") " +
+                          " values('" + item.HItemID + "','" + item.HCusID + "','" + item.HCusRelationNumber + "','" + item.HCusRelationName + "','" + item.HMaterID + "'," +
+                          "'" + item.HUsed + "','" + item.HUSEORGID + "','" + item.HUSEORGID + "','" + item.HRemark + "',getdate(),'" + item.HMaker +
+                         "') ";
+                    oCN.RunProc(sql);                   
+                    // 鍏抽棴identity_insert
+                    sql = "set identity_insert Gy_MateNumRelation_Sec off";
+                    oCN.RunProc(sql);
+
+                    // 鎻愪氦褰撳墠浜嬪姟
+                    oCN.Commit();
+                }
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鏂板鍗曟嵁鎴愬姛锛�";
+                //objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                oCN.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.Message;
+                objJsonResult.data = null;               
+                return objJsonResult;
+               
+            }
+        }
+        #endregion
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1