From d1b14d00d9ee4ff4a1b271e6b4fe094f5049a55f Mon Sep 17 00:00:00 2001
From: duhe <226547893@qq.com>
Date: 星期一, 17 三月 2025 09:23:16 +0800
Subject: [PATCH] 采购入库单:下推采购退料单

---
 WebAPI/Controllers/Xt_DefineBillMainSetController.cs |  105 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 104 insertions(+), 1 deletions(-)

diff --git a/WebAPI/Controllers/Xt_DefineBillMainSetController.cs b/WebAPI/Controllers/Xt_DefineBillMainSetController.cs
index c92cd5a..bf9bf71 100644
--- a/WebAPI/Controllers/Xt_DefineBillMainSetController.cs
+++ b/WebAPI/Controllers/Xt_DefineBillMainSetController.cs
@@ -21,7 +21,9 @@
         private json objJsonResult = new json();
         public DataSet ds = new DataSet();
         public SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
-      
+        public DAL.ClsXt_DefineBillMainSet BillOld = new DAL.ClsXt_DefineBillMainSet();
+        public DAL.ClsXt_DefineBillMainSet BillNew0 = new DAL.ClsXt_DefineBillMainSet();
+
         #region 鑷姩鍔犺浇椤甸潰琛ㄥご
         /// <summary>
         /// 杩斿洖椤圭洰闃舵鍒楄〃
@@ -99,5 +101,106 @@
         }
         #endregion
 
+        #region 琛ㄥご鑷姩鍔犺浇淇濆瓨 鏂板/缂栬緫
+        [Route("Xt_DefineBillMainSet/SaveXt_DefineBillMainSet")]
+        [HttpPost]
+        public object SaveXt_DefineBillMainSet([FromBody] JObject msg)
+        {
+            var _value = msg["msg"].ToString();
+            string msg1 = _value.ToString();
+            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+            string msg2 = sArray[0].ToString();                             //琛ㄥご鏁版嵁
+            string msg3 = sArray[1].ToString();                             //瀛愯〃1鏁版嵁
+            string msg4 = sArray[2].ToString();                             //鐢ㄦ埛
+
+            ListModels oListModels = new ListModels();
+            try
+            {
+                ////缂栬緫鏉冮檺
+                //if (!DBUtility.ClsPub.Security_Log_second("Xt_DefineBillMainSet_Edit", 1, false, msg4))
+                //{
+                //    objJsonResult.code = "0";
+                //    objJsonResult.count = 0;
+                //    objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒";
+                //    objJsonResult.data = null;
+                //    return objJsonResult;
+                //}
+
+                DAL.ClsXt_DefineBillMainSet oBill = new DAL.ClsXt_DefineBillMainSet();
+
+                //琛ㄥご鏁版嵁
+                List<Model.ClsXt_DefineBillMainSetMain> lsmain = new List<Model.ClsXt_DefineBillMainSetMain>();
+                msg2 = msg2.Replace("\\", "");
+                msg2 = msg2.Replace("\n", "");
+                lsmain = oListModels.getObjectByJson_Xt_DefineBillMainSetMain(msg2);
+                foreach (Model.ClsXt_DefineBillMainSetMain oItem in lsmain)
+                {
+                    oItem.HMaker = msg4;
+                    oItem.HUpDater = msg4;
+
+                    oBill.omodel = oItem;
+                }
+
+                //琛ㄤ綋鏁版嵁
+                msg3 = msg3.Substring(1, msg3.Length - 2);
+                msg3 = msg3.Replace("\\", "");
+                msg3 = msg3.Replace("\n", "");
+                List<Model.ClsXt_DefineBillMainSetSub> ls = new List<Model.ClsXt_DefineBillMainSetSub>();
+                ls = oListModels.getObjectByJson_Xt_DefineBillMainSetSub(msg3);
+                foreach (Model.ClsXt_DefineBillMainSetSub oItemSub in ls)
+                {
+                    if ((oItemSub.HElementID == null || oItemSub.HElementID == "")&&oItemSub.HElementIDAdditionalName!="")
+                    {
+                        oItemSub.HElementID = oItemSub.HElementIDAdditionalName;
+                    }
+                    oBill.DetailColl.Add(oItemSub);
+                }
+
+
+                //淇濆瓨
+                //淇濆瓨瀹屾瘯鍚庡鐞�
+                bool bResult;
+                if (oBill.omodel.HInterID == 0)
+                {
+                    bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+                }
+                else if (oBill.omodel.HInterID > 0)
+                {
+                    bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
+                }
+                else
+                {
+                    bResult = false;
+                }
+
+
+                //string message = "msg2:銆�" + msg2 + "銆�;msg3:銆�" + msg3 + "銆戯紱msg4:銆�" + msg4 + "銆�";
+                if (bResult)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
+                    objJsonResult.data = 1;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = 1;
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "淇濆瓨澶辫触锛�" + e.ToString();
+                objJsonResult.data = 1;
+                return objJsonResult;
+            }
+        }
+        #endregion
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1