From 178ef58efdb6e6fa1f3cc44c2b3b5a66d5200096 Mon Sep 17 00:00:00 2001
From: duhe <226547893@qq.com>
Date: 星期二, 23 一月 2024 09:36:46 +0800
Subject: [PATCH] 1

---
 WebAPI/Controllers/CGGL/Kf_POStockInBillController.cs |   88 ++++++++++++++++++++++++++++++++++++++------
 1 files changed, 76 insertions(+), 12 deletions(-)

diff --git a/WebAPI/Controllers/CGGL/Kf_POStockInBillController.cs b/WebAPI/Controllers/CGGL/Kf_POStockInBillController.cs
index e64393c..50b3852 100644
--- a/WebAPI/Controllers/CGGL/Kf_POStockInBillController.cs
+++ b/WebAPI/Controllers/CGGL/Kf_POStockInBillController.cs
@@ -1,4 +1,5 @@
 锘縰sing Newtonsoft.Json.Linq;
+using NPOI.SS.Formula.Functions;
 using Pub_Class;
 using System;
 using System.Collections;
@@ -202,7 +203,7 @@
                     oCN.RunProc("delete from Kf_ICStockBillSub where HInterID='" + HInterID + "'");
                 }
                 //淇濆瓨瀛愯〃
-                objJsonResult = AddBillSub(msg3, HInterID, OperationType);
+                objJsonResult = AddBillSub(msg3, HInterID, OperationType, user);
 
                 if (objJsonResult.code == "0")
                 {
@@ -229,7 +230,7 @@
             }
         }
 
-        public json AddBillSub(string msg3, long HInterID, int OperationType)
+        public json AddBillSub(string msg3, long HInterID, int OperationType,string user)
         {
             List<ClsKf_ICStockBillSub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsKf_ICStockBillSub>>(msg3);
 
@@ -312,6 +313,18 @@
                 ,{(oSub.HPropertyID == null ? 0 : oSub.HPropertyID)},{(oSub.HSecUnitID == null ? 0 : oSub.HSecUnitID)},{(oSub.HSecUnitRate == null ? 0 : oSub.HSecUnitRate)}
                 ,{(oSub.HPlanMode == null ? 0 : oSub.HPlanMode)},'{oSub.HRemark}',{oSub.HSeOrderInterID},{oSub.HSeOrderEntryID},'{oSub.HSeOrderBillNo}')";
 
+                string sReturn = "";
+                ds = oCN.RunProcReturn("exec h_p_Cg_POInStockBillMain " + oSub.HQty + ", '" +oSub.HSourceInterID + "', '" + oSub.HSourceEntryID + "','" + user+" '", "h_p_Cg_POInStockBillMain");
+                if (DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HBack"]) != 0)
+                {
+                    sReturn = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]).ToString();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = sReturn;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
                 oCN.RunProc(sql);
 
             }
@@ -330,30 +343,81 @@
         /// <returns></returns>
         [Route("Kf_POStockInBill/DeltetKf_POStockInBill")]
         [HttpGet]
-        public object DeltetKf_POStockInBill(string HInterID)
+        public object DeleteKf_POStockInBackBill(string Hmainid, string HsupId, string HQty, string HSourceInterID, string HSourceEntryID, string user)
         {
+            DataSet ds;
+            DataSet dss;
+            //string ModRightNameCheck = "Sc_ProcessReport_check";
             try
             {
-                oCN.BeginTran();
-                oCN.RunProc("Delete From Kf_ICStockBillMain  where HInterID = " + HInterID);
-                oCN.RunProc("Delete From Kf_ICStockBillSub where HInterID = " + HInterID);
-                oCN.Commit();
-                objJsonResult.code = "1";
+                //鍒犻櫎鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Kf_POStockInBackBill_Delete", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+                if (string.IsNullOrWhiteSpace(Hmainid))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "Hmainid涓虹┖锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                oCN.BeginTran();//寮�濮嬩簨鍔�
+                ds = oCN.RunProcReturn("select * from Kf_ICStockBillMain a inner join Kf_ICStockBillSub b on a.HInterID=b.HInterID where a.HInterID= '"+ Hmainid+"'", "Kf_ICStockBillMain");
+                dss = oCN.RunProcReturn("exec h_p_Cg_POInStockBillMain " + HQty + ", '" + HSourceInterID + "', '" + HSourceEntryID + "','" + user + " '", "h_p_Cg_POInStockBillMain");
+                var sReturn = "";
+                if (DBUtility.ClsPub.isLong(dss.Tables[0].Rows[0]["HBack"]) != 0)
+                {
+                    sReturn = DBUtility.ClsPub.isStrNull(dss.Tables[0].Rows[0]["HBackRemark"]).ToString();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = sReturn;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                if (ds == null || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "娌℃湁鏁版嵁锛屾棤娉曞垹闄わ紒";
+                    objJsonResult.data = null;
+                    return objJsonResult; ;
+                }
+                if (ds.Tables[0].Rows.Count  == 1)
+                {
+                    oCN.RunProc("delete Kf_ICStockBillSub where HInterID=" + Hmainid);
+                    oCN.RunProc("delete Kf_ICStockBillMain where HInterID=" + Hmainid);
+                }
+                else
+                {
+                    oCN.RunProc($"delete Kf_ICStockBillSub where HInterID={ Hmainid}and HEntryID={HsupId}");
+                }
+                oCN.Commit();//鎻愪氦浜嬪姟
+                objJsonResult.code = "0";
                 objJsonResult.count = 1;
-                objJsonResult.Message = "鍒犻櫎鎴愬姛锛�";
+                objJsonResult.Message = "鏁版嵁鍒犻櫎鎴愬姛锛�";
                 objJsonResult.data = null;
-                return objJsonResult;
+                return objJsonResult; ;
+
             }
             catch (Exception e)
             {
-                oCN.RollBack();
                 objJsonResult.code = "0";
                 objJsonResult.count = 0;
-                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.Message = "鍒犻櫎澶辫触锛�" + e.ToString();
                 objJsonResult.data = null;
                 return objJsonResult;
             }
         }
+        
 
         /// <summary>
         /// 鏍规嵁鍩虹璧勬枡ID 鏌ユ壘璁板綍

--
Gitblit v1.9.1