From 8a6a87b93e0a25401b659c7940ca94646ff6dadf Mon Sep 17 00:00:00 2001
From: yusijie <ysj@hz-kingdee.com>
Date: 星期三, 21 一月 2026 16:50:10 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API

---
 WebAPI/Controllers/仓存管理/验收入库/Kf_ProductInBillController.cs |  821 +++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 772 insertions(+), 49 deletions(-)

diff --git "a/WebAPI/Controllers/\344\273\223\345\255\230\347\256\241\347\220\206/\351\252\214\346\224\266\345\205\245\345\272\223/Kf_ProductInBillController.cs" "b/WebAPI/Controllers/\344\273\223\345\255\230\347\256\241\347\220\206/\351\252\214\346\224\266\345\205\245\345\272\223/Kf_ProductInBillController.cs"
index e9d1972..121eaa5 100644
--- "a/WebAPI/Controllers/\344\273\223\345\255\230\347\256\241\347\220\206/\351\252\214\346\224\266\345\205\245\345\272\223/Kf_ProductInBillController.cs"
+++ "b/WebAPI/Controllers/\344\273\223\345\255\230\347\256\241\347\220\206/\351\252\214\346\224\266\345\205\245\345\272\223/Kf_ProductInBillController.cs"
@@ -12,18 +12,564 @@
 
 namespace WebAPI.Controllers
 {
-    //鐢熶骇鍏ュ簱鍗旵ontroller
     public class Kf_ProductInBillController : ApiController
     {
-        //鑾峰彇绯荤粺鍙傛暟
-        Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
-
         public DBUtility.ClsPub.Enum_BillStatus BillStatus;
-        public DAL.ClsKf_ProductInBill BillOld = new DAL.ClsKf_ProductInBill();
+        public const string ModName = "1202";                   //鍗曟嵁绫诲瀷
+        public const string ModCaption = "鐢熶骇鍏ュ簱鍗�";          //鍗曟嵁鍚嶇О
+        public const string ModRightName = "Kf_ProductInBill";
+        public const string ModRightNameList = ModRightName + "List";       //鍒楄〃
+        public const string ModRightNameEdit = ModRightName + "_Edit";      //缂栬緫
+        public const string ModRightNameCheck = ModRightName + "_Check";    //瀹℃牳
+        public const string ModRightNameClose = ModRightName + "_Close";    //鍏抽棴
+        public const string ModRightNameDelete = ModRightName + "_Delete";  //浣滃簾
+        public const string ModRightNameDrop = ModRightName + "_Drop";      //鍒犻櫎
+        public const string ModRightNameMoney = ModRightName + "_Money";    //閲戦
+        public const string ModRightNameQty = ModRightName + "_Qty";        //鏁伴噺
+        public DataSet ds = new DataSet();
         private json objJsonResult = new json();
-        SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
-        DataSet ds;
+        SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
+        public DAL.ClsKf_ProductInBill oBill = new DAL.ClsKf_ProductInBill();
+        public DAL.ClsKf_ProductInBill BillOld = new DAL.ClsKf_ProductInBill();
 
+
+        #region 鐢熶骇鍏ュ簱鍗曞垪琛�
+        /// <summary>
+        /// 鑾峰彇鐢熶骇鍏ュ簱鍗曞垪琛ㄤ俊鎭�
+        /// </summary>
+        /// <returns></returns>
+        [Route("Kf_ProductInBillController/GetKf_ProductInBillList_Json")]
+        [HttpGet]
+        public object GetKf_ProductInBillList_Json(string sWhere, string HMaker, string OperationType, string ViewName)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                //鍒ゆ柇鏉冮檺
+                if (OperationType == "1")
+                {
+                    //鍒ゆ柇鏉冮檺
+                    if (!DBUtility.ClsPub.Security_Log(ModRightNameList, 3, false, HMaker))
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鎮ㄦ病鏈夎妯″潡鏉冮檺,璇蜂笌绠$悊鍛樿仈绯伙紒";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+
+                //杩斿洖鍒楄〃淇℃伅
+                ds = oCn.RunProcReturn("select * from " + ViewName + " where 1=1 " + sWhere + " order by hmainid desc", ViewName);
+              
+                //娣诲姞鍒楀悕
+                foreach (DataColumn col in ds.Tables[0].Columns)
+                {
+                    Type dataType = col.DataType;
+                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));  //鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
+                }
+                objJsonResult.code = "0";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鎴愬姛锛�";
+                objJsonResult.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鏌ヨ鍒楄〃淇℃伅澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鐢熶骇鍏ュ簱鍗� 鍒犻櫎
+        /// <summary>
+        /// 鍒犻櫎鐢熶骇鍏ュ簱鍗�
+        /// </summary>
+        /// <returns></returns>
+        [Route("Kf_ProductInBillController/GetKf_ProductInBill_Delete_Json")]
+        [HttpGet]
+        public object GetKf_ProductInBill_Delete_Json(Int64 HInterID, string HMaker)
+        {
+            try
+            {
+                //鍒ゆ柇鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log(ModRightNameDrop, 3, false, HMaker))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鎮ㄦ病鏈夎妯″潡鍒犻櫎鍔熻兘鏉冮檺,璇蜂笌绠$悊鍛樿仈绯伙紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                //鍒ゆ柇瀛樺湪鎬�
+                if (oBill.ShowBill(HInterID, ref DBUtility.ClsPub.sExeReturnInfo))
+                {
+                    //鍒犻櫎鍓嶆帶鍒�
+                    DataSet BeforeDs = oCn.RunProcReturn("Exec h_p_Kf_ProductInBill_BeforeDelCtrl " + HInterID.ToString() + ",'" + HMaker + "'", "h_p_Kf_ProductInBill_BeforeDelCtrl");
+                    if (BeforeDs == null || BeforeDs.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍒犻櫎鍓嶅垽鏂け璐ワ紒";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        if (DBUtility.ClsPub.isLong(BeforeDs.Tables[0].Rows[0]["HBack"]) == 1)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍒犻櫎澶辫触锛�" + DBUtility.ClsPub.isStrNull(BeforeDs.Tables[0].Rows[0]["HRemark"]);
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+
+                    //杩涜 浼氳鏈熼棿 缁撹处 鐨勫垽鏂拰鎺у埗
+                    string s = "";
+                    int sYear = 0;
+                    int sPeriod = 0;
+                    DateTime HDate = DateTime.Now;
+                    if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false)
+                    {
+                        objJsonResult.Message = s;
+                        return objJsonResult;
+                    }
+
+                    //鍒犻櫎鍗曟嵁锛堝寘鍚垹闄ゅ悗鎺у埗銆佸啓鍏ユ棩蹇楋級
+                    if (!oBill.DeleteBill(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_Kf_ProductInBill_AfterDelCtrl", HMaker, ref ClsPub.sExeReturnInfo))
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍒犻櫎鐢熶骇鍏ュ簱鍗曟垚鍔燂紒";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏈煡璇㈠埌璇ョ敓浜у叆搴撳崟锛岃鍒锋柊鏁版嵁鍚庨噸鏂伴�夋嫨锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鍒犻櫎鐢熶骇鍏ュ簱鍗曞け璐ワ紒" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鐢熶骇鍏ュ簱鍗� 瀹℃牳/鍙嶅鏍�
+        /// <summary>
+        /// 瀹℃牳/鍙嶅鏍哥敓浜у叆搴撳崟
+        /// </summary>
+        /// <param name="HInterID">鍗曟嵁ID</param>
+        /// <param name="Type">瀹℃牳(1),鍙嶅鏍�(2)</param>
+        /// <param name="HMaker">瀹℃牳浜�</param>
+        /// <returns></returns>
+        [Route("Kf_ProductInBillController/GetKf_ProductInBill_Check_Json")]
+        [HttpGet]
+        public object GetKf_ProductInBill_Check_Json(Int64 HInterID, int Type, string HMaker)
+        {
+            try
+            {
+                //鍒ゆ柇鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 3, false, HMaker))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鎮ㄦ病鏈夎妯″潡瀹℃牳/鍙嶅鏍稿姛鑳芥潈闄�,璇蜂笌绠$悊鍛樿仈绯伙紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                //鍒ゆ柇瀛樺湪鎬�
+                if (oBill.ShowBill(HInterID, ref DBUtility.ClsPub.sExeReturnInfo))
+                {
+                    //杩涜 浼氳鏈熼棿 缁撹处 鐨勫垽鏂拰鎺у埗
+                    string s = "";
+                    int sYear = 0;
+                    int sPeriod = 0;
+                    DateTime HDate = DateTime.Now;
+                    if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false)
+                    {
+                        objJsonResult.Message = s;
+                        return objJsonResult;
+                    }
+                    //Type 1 瀹℃牳  2  鍙嶅鏍�
+                    if (Type == 1)
+                    {
+                        if (oBill.omodel.HChecker.Trim() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸插鏍革紝涓嶈兘鍐嶆瀹℃牳锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        if (oBill.omodel.HCloseMan.Trim() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸插叧闂紝涓嶈兘鍐嶆瀹℃牳锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        if (oBill.omodel.HDeleteMan.Trim() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸蹭綔搴燂紝涓嶈兘鍐嶆瀹℃牳锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        //瀹℃牳鍓嶆帶鍒�
+                        DataSet BeforeDs = oCn.RunProcReturn("Exec h_p_Kf_ProductInBill_BeforeCheckCtrl " + HInterID.ToString() + ",'" + HMaker + "'", "h_p_Kf_ProductInBill_BeforeCheckCtrl");
+                        if (BeforeDs == null || BeforeDs.Tables[0].Rows.Count == 0)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "瀹℃牳鍓嶅垽鏂け璐ワ紒";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        else
+                        {
+                            if (DBUtility.ClsPub.isLong(BeforeDs.Tables[0].Rows[0]["HBack"]) == 1)
+                            {
+                                objJsonResult.code = "0";
+                                objJsonResult.count = 0;
+                                objJsonResult.Message = "瀹℃牳澶辫触锛�" + DBUtility.ClsPub.isStrNull(BeforeDs.Tables[0].Rows[0]["HRemark"]);
+                                objJsonResult.data = null;
+                                return objJsonResult;
+                            }
+                        }                       
+                        //瀹℃牳鍗曟嵁
+                        if (!oBill.CheckBill(HInterID, oBill.omodel.HBillNo, "h_p_Kf_ProductInBill_AfterCheckCtrl", HMaker, ref ClsPub.sExeReturnInfo))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        else
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "鍗曟嵁鍙凤細" + oBill.omodel.HBillNo + " 瀹℃牳鎴愬姛锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult; ;
+                        }
+                    }
+                    else
+                    {
+                        if (oBill.omodel.HChecker.Trim() == "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁鏈鏍革紝涓嶉渶瑕佸弽瀹℃牳锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        //鍙嶅鏍稿墠鎺у埗
+                        DataSet BeforeDs = oCn.RunProcReturn("Exec h_p_Kf_ProductInBill_BeforeUnCheckCtrl " + HInterID.ToString() + ",'" + HMaker + "'", "h_p_Kf_ProductInBill_BeforeUnCheckCtrl");
+                        if (BeforeDs == null || BeforeDs.Tables[0].Rows.Count == 0)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍙嶅鏍稿墠鍒ゆ柇澶辫触锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        else
+                        {
+                            if (DBUtility.ClsPub.isLong(BeforeDs.Tables[0].Rows[0]["HBack"]) == 1)
+                            {
+                                objJsonResult.code = "0";
+                                objJsonResult.count = 0;
+                                objJsonResult.Message = "鍙嶅鏍稿け璐ワ紒" + DBUtility.ClsPub.isStrNull(BeforeDs.Tables[0].Rows[0]["HRemark"]);
+                                objJsonResult.data = null;
+                                return objJsonResult;
+                            }
+                        }
+
+                        //鍙嶅鏍稿崟鎹�
+                        if (!oBill.AbandonCheck(HInterID, oBill.omodel.HBillNo, "h_p_Kf_ProductInBill_AfterUnCheckCtrl", HMaker, ref ClsPub.sExeReturnInfo))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        else
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "鍗曟嵁鍙凤細" + oBill.omodel.HBillNo + " 鍙嶅鏍告垚鍔燂紒";
+                            objJsonResult.data = null;
+                            return objJsonResult; ;
+                        }
+                    }      
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏈煡璇㈠埌璇ョ敓浜у叆搴撳崟锛岃鍒锋柊鏁版嵁鍚庨噸鏂伴�夋嫨锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "瀹℃牳鎴栧弽瀹℃牳鐢熶骇鍏ュ簱鍗曞け璐ワ紒" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鐢熶骇鍏ュ簱鍗� 鍏抽棴/鍙嶅叧闂�
+        /// <summary>
+        /// 鍏抽棴/鍙嶅叧闂敓浜у叆搴撳崟
+        /// </summary>
+        /// <param name="HInterID">鍗曟嵁ID</param>
+        /// <param name="Type">鍏抽棴(1),鍙嶅叧闂�(2)</param>
+        /// <param name="HMaker">鍏抽棴浜�</param>
+        /// <returns></returns>
+        [Route("Kf_ProductInBillController/GetKf_ProductInBill_Close_Json")]
+        [HttpGet]
+        public object GetKf_ProductInBill_Close_Json(Int64 HInterID, int Type, string HMaker)
+        {
+            try
+            {
+                //鍒ゆ柇鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log(ModRightNameClose, 3, false, HMaker))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鎮ㄦ病鏈夎妯″潡鍏抽棴/鍙嶅叧闂姛鑳芥潈闄�,璇蜂笌绠$悊鍛樿仈绯伙紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                //鍒ゆ柇瀛樺湪鎬�
+                if (oBill.ShowBill(HInterID, ref DBUtility.ClsPub.sExeReturnInfo))
+                {
+                    //Type 1 鍏抽棴  2  鍙嶅叧闂�
+                    if (Type == 1)
+                    {
+                        if (oBill.omodel.HCloseMan.Trim() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸插叧闂紝涓嶈兘鍐嶆鍏抽棴锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        //鍏抽棴鍗曟嵁
+                        if (!oBill.CloseBill(HInterID, oBill.omodel.HBillNo, HMaker, ref ClsPub.sExeReturnInfo))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        else
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "鍗曟嵁鍙凤細" + oBill.omodel.HBillNo + " 鍏抽棴鎴愬姛锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult; ;
+                        }
+                    }
+                    else
+                    {
+                        if (oBill.omodel.HCloseMan.Trim() == "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁鏈叧闂紝涓嶉渶瑕佸弽鍏抽棴锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        //鍙嶅叧闂崟鎹�
+                        if (!oBill.CancelClose(HInterID, oBill.omodel.HBillNo, HMaker, ref ClsPub.sExeReturnInfo))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        else
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "鍗曟嵁鍙凤細" + oBill.omodel.HBillNo + " 鍙嶅叧闂垚鍔燂紒";
+                            objJsonResult.data = null;
+                            return objJsonResult; ;
+                        }
+                    }
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏈煡璇㈠埌璇ョ敓浜у叆搴撳崟锛岃鍒锋柊鏁版嵁鍚庨噸鏂伴�夋嫨锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鍏抽棴鎴栧弽鍏抽棴鐢熶骇鍏ュ簱鍗曞け璐ワ紒" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鐢熶骇鍏ュ簱鍗� 浣滃簾/鍙嶄綔搴�
+        /// <summary>
+        /// 浣滃簾/鍙嶄綔搴熺敓浜у叆搴撳崟
+        /// </summary>
+        /// <param name="HInterID">鍗曟嵁ID</param>
+        /// <param name="Type">浣滃簾(1),鍙嶄綔搴�(2)</param>
+        /// <param name="HMaker">浣滃簾浜�</param>
+        /// <returns></returns>
+        [Route("Kf_ProductInBillController/GetKf_ProductInBill_Cancelltion_Json")]
+        [HttpGet]
+        public object GetKf_ProductInBill_Cancelltion_Json(Int64 HInterID, int Type, string HMaker)
+        {
+            try
+            {
+                //鍒ゆ柇鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log(ModRightNameDelete, 3, false, HMaker))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鎮ㄦ病鏈夎妯″潡浣滃簾/鍙嶄綔搴熷姛鑳芥潈闄�,璇蜂笌绠$悊鍛樿仈绯伙紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                //鍒ゆ柇瀛樺湪鎬�
+                if (oBill.ShowBill(HInterID, ref DBUtility.ClsPub.sExeReturnInfo))
+                {
+                    //Type 1 浣滃簾  2  鍙嶄綔搴�
+                    if (Type == 1)
+                    {
+                        if (oBill.omodel.HDeleteMan.Trim() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸蹭綔搴燂紝涓嶈兘鍐嶆浣滃簾锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        //浣滃簾鍗曟嵁
+                        if (!oBill.Cancelltion(HInterID, oBill.omodel.HBillNo, HMaker, ref ClsPub.sExeReturnInfo))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "浣滃簾澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        else
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "鍗曟嵁鍙凤細" + oBill.omodel.HBillNo + " 浣滃簾鎴愬姛锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult; ;
+                        }
+                    }
+                    else
+                    {
+                        if (oBill.omodel.HDeleteMan.Trim() == "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁鏈綔搴燂紝涓嶉渶瑕佸弽浣滃簾锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        //鍙嶄綔搴熷崟鎹�
+                        if (!oBill.AbandonCancelltion(HInterID, oBill.omodel.HBillNo, HMaker, ref ClsPub.sExeReturnInfo))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍙嶄綔搴熷け璐�!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        else
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "鍗曟嵁鍙凤細" + oBill.omodel.HBillNo + " 鍙嶄綔搴熸垚鍔燂紒";
+                            objJsonResult.data = null;
+                            return objJsonResult; ;
+                        }
+                    }
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏈煡璇㈠埌璇ョ敓浜у叆搴撳崟锛岃鍒锋柊鏁版嵁鍚庨噸鏂伴�夋嫨锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "浣滃簾鎴栧弽浣滃簾鐢熶骇鍏ュ簱鍗曞け璐ワ紒" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+
+
+
+        //---------------------------------------------------------------------------------------------鏃ф柟娉�20240422鍓�
 
         #region 鐢熶骇鍏ュ簱鍗� 鏌ユ壘璁板綍鍔熻兘
         /// <summary>
@@ -38,7 +584,7 @@
             try
             {
 
-                ds = oCN.RunProcReturn("select * from h_v_IF_ProductInBillList where hmainid=" + HInterID, "h_v_IF_ProductInBillList");
+                ds = oCn.RunProcReturn("select * from h_v_IF_ProductInBillList where hmainid=" + HInterID, "h_v_IF_ProductInBillList");
                 if (ds == null || ds.Tables[0].Rows.Count == 0)
                 {
                     objJsonResult.code = "0";
@@ -91,12 +637,12 @@
 
                 if (sWhere == null || sWhere.Equals(""))
                 {
-                    ds = oCN.RunProcReturn("select * from h_v_IF_ProductInBillList where 1=1  order by hmainid desc", "h_v_IF_ProductInBillList");
+                    ds = oCn.RunProcReturn("select * from h_v_IF_ProductInBillList where 1=1  order by hmainid desc", "h_v_IF_ProductInBillList");
                 }
                 else
                 {
                     string sql = "select * from h_v_IF_ProductInBillList where 1 = 1 " + sWhere + " order by hmainid desc";
-                    ds = oCN.RunProcReturn(sql, "h_v_IF_ProductInBillList");
+                    ds = oCn.RunProcReturn(sql, "h_v_IF_ProductInBillList");
                 }
 
 
@@ -133,7 +679,7 @@
                 string HBillNo = "";
                 //鍒犻櫎鍓嶆帶鍒�=========================================      
                 string sql1 = "exec h_p_Kf_ProductInBill_BeforeDelCtrl " + HInterID + ",'" + HBillNo + "','" + user + "'";
-                ds = oCN.RunProcReturn(sql1, "h_p_Kf_ProductInBill_BeforeDelCtrl");
+                ds = oCn.RunProcReturn(sql1, "h_p_Kf_ProductInBill_BeforeDelCtrl");
                 if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                 {
                     objJsonResult.code = "0";
@@ -154,14 +700,14 @@
                 //==================================================================================      
 
                 string sReturn = "";
-                oCN.BeginTran();
-                oCN.RunProc("Delete From Kf_ICStockBillMain where HInterID = " + HInterID);
-                oCN.RunProc("Delete From Kf_ICStockBillSub where HInterID = " + HInterID);
-                oCN.Commit();
+                oCn.BeginTran();
+                oCn.RunProc("Delete From Kf_ICStockBillMain where HInterID = " + HInterID);
+                oCn.RunProc("Delete From Kf_ICStockBillSub where HInterID = " + HInterID);
+                oCn.Commit();
 
                 //鍒犻櫎鍚庢帶鍒�==================================================================================      
                 string sql2 = "exec h_p_Kf_ProductInBill_AfterDelCtrl " + HInterID + ",'" + HBillNo + "','" + user + "'";
-                ds = oCN.RunProcReturn(sql2, "h_p_Kf_ProductInBill_AfterDelCtrl");
+                ds = oCn.RunProcReturn(sql2, "h_p_Kf_ProductInBill_AfterDelCtrl");
                 if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                 {
                     sReturn = "鍒犻櫎鍚庡垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
@@ -169,7 +715,7 @@
                     objJsonResult.count = 1;
                     objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + sReturn;
                     objJsonResult.data = null;
-                    oCN.RollBack();
+                    oCn.RollBack();
                     return objJsonResult;
                 }
                 if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
@@ -179,7 +725,7 @@
                     objJsonResult.count = 1;
                     objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + sReturn;
                     objJsonResult.data = null;
-                    oCN.RollBack();
+                    oCn.RollBack();
                     return objJsonResult;
                 }
                 //==============================================================================================
@@ -192,7 +738,7 @@
             }
             catch (Exception e)
             {
-                oCN.RollBack();
+                oCn.RollBack();
                 objJsonResult.code = "0";
                 objJsonResult.count = 0;
                 objJsonResult.Message = "Exception锛�" + e.ToString();
@@ -211,19 +757,19 @@
             {
                 var _value = sMainSub["sMainSub"].ToString();
                 string msg1 = _value.ToString();
-                oCN.BeginTran();
+                oCn.BeginTran();
                 //淇濆瓨涓昏〃
                 objJsonResult = AddBillMain(msg1);
                 if (objJsonResult.code == "0")
                 {
-                    oCN.RollBack();
+                    oCn.RollBack();
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
                     objJsonResult.Message = objJsonResult.Message;
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
-                oCN.Commit();
+                oCn.Commit();
                 objJsonResult.code = "1";
                 objJsonResult.count = 1;
                 objJsonResult.Message = "鍗曟嵁淇濆瓨鎴愬姛锛�";
@@ -233,7 +779,7 @@
             }
             catch (Exception e)
             {
-                oCN.RollBack();
+                oCn.RollBack();
                 objJsonResult.code = "0";
                 objJsonResult.count = 0;
                 objJsonResult.Message = "淇濆瓨澶辫触锛�" + e.ToString();
@@ -304,12 +850,22 @@
                 string HSUPPLYADDRESS = mainList2[0].HSUPPLYADDRESS == null ? "''" : mainList2[0].HSUPPLYADDRESS;
                 long HPROVIDERCONTACTID = mainList2[0].HPROVIDERCONTACTID == null ? 0 : mainList2[0].HPROVIDERCONTACTID;
 
-                ds = oCN.RunProcReturn("select * from h_v_IF_ProductInBillList where hmainid=" + HInterID + " and 鍗曟嵁鍙�='" + HBillNo + "'", "h_v_IF_ProductInBillList");
+                //杩涜 浼氳鏈熼棿 缁撹处 鐨勫垽鏂拰鎺у埗
+                string s = "";
+                int sYear = 0;
+                int sPeriod = 0;
+                if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false)
+                {
+                    objJsonResult.Message = s;
+                    return objJsonResult;
+                }
+
+                ds = oCn.RunProcReturn("select * from h_v_IF_ProductInBillList where hmainid=" + HInterID + " and 鍗曟嵁鍙�='" + HBillNo + "'", "h_v_IF_ProductInBillList");
                 if ((OperationType == 1 || OperationType == 2 || OperationType == 4) && ds.Tables[0].Rows.Count == 0)//鏂板
                 {
 
                     //淇濆瓨鍓嶆帶鍒�=========================================
-                    ds = oCN.RunProcReturn("exec h_p_Kf_ProductInBill_BeforeSaveCtrl " + HInterID, "h_p_Kf_ProductInBill_BeforeSaveCtrl");
+                    ds = oCn.RunProcReturn("exec h_p_Kf_ProductInBill_BeforeSaveCtrl " + HInterID, "h_p_Kf_ProductInBill_BeforeSaveCtrl");
 
                     if (ds == null || ds.Tables[0].Rows.Count == 0)
                     {
@@ -337,7 +893,7 @@
                     "," + HManagerID + "," + HEmpID + "," + HDeptID + "," + HSecManagerID + "," + HKeeperID + ",'" + HRemark + "','" + HMaker +
                     "',getdate()" + "," + HCurID + "," + HExRate + "," + HWHID + ",'" + HInnerBillNo + "','" + HExplanation + "')";
 
-                    oCN.RunProc(sql);
+                    oCn.RunProc(sql);
 
                 }
                 else if (OperationType == 3 || ds.Tables[0].Rows.Count != 0)
@@ -348,20 +904,20 @@
                                  + ",HExRate=" + HExRate + ",HEmpID=" + HEmpID + ",HManagerID=" + HManagerID + ",HDeptID=" + HDeptID
                                  + ",HInnerBillNo='" + HInnerBillNo + "' where HInterID=" + HInterID;
 
-                    oCN.RunProc(sql);
+                    oCn.RunProc(sql);
 
                     
                     //鍒犻櫎瀛愯〃
-                    oCN.RunProc("delete from Kf_ICStockBillSub where HInterID='" + HInterID + "'");
+                    oCn.RunProc("delete from Kf_ICStockBillSub where HInterID='" + HInterID + "'");
                 }
                 //淇濆瓨瀛愯〃
                 objJsonResult = AddBillSub(msg3, HInterID, OperationType, user);
 
                 //鐢熶骇鍏ュ簱鍗曟柊澧炲洖濉敓浜ц鍗曞叧鑱旀暟閲�
-                oCN.RunProc("exec h_p_Kf_UpDateRelation_ProductInToICMO_Add " + HInterID);
+                oCn.RunProc("exec h_p_Kf_UpDateRelation_ProductInToICMO_Add " + HInterID);
 
                 //鐢熶骇鍏ュ簱鍗曟柊澧炲洖濉敓浜ф眹鎶ュ崟鍏宠仈鏁伴噺
-                oCN.RunProc("exec h_p_Kf_UpDateRelation_ProductInToICMOReport_Add " + HInterID);
+                oCn.RunProc("exec h_p_Kf_UpDateRelation_ProductInToICMOReport_Add " + HInterID);
 
                 if (objJsonResult.code == "0")
                 {
@@ -445,7 +1001,7 @@
 
                 DataSet Cs;
                 Int64 NewHEntryID = 1;
-                Cs = oCN.RunProcReturn("select MAX(HEntryID)HEntryID from Kf_ICStockBillSub", "Kf_ICStockBillSub");
+                Cs = oCn.RunProcReturn("select MAX(HEntryID)HEntryID from Kf_ICStockBillSub", "Kf_ICStockBillSub");
                 if (Cs.Tables[0].Rows.Count != 0 && ClsPub.isLong(Cs.Tables[0].Rows[0]["HEntryID"].ToString()) != 0)
                 {
                     NewHEntryID = ClsPub.isLong(Cs.Tables[0].Rows[0]["HEntryID"].ToString());
@@ -453,7 +1009,7 @@
                 }
                
 
-                oCN.RunProc($@"Insert into Kf_ICStockBillSub 
+                oCn.RunProc($@"Insert into Kf_ICStockBillSub 
                 (HInterID,HEntryID,HMaterID,HUnitID,HQtyMust,HQty,HPrice
 	            ,HMoney,HWHID,HSPID,HRemark,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HPOOrderInterID
                 ,HPOOrderEntryID,HPOORderBillNo,HSecUnitID,HSeOrderInterID,HSeOrderEntryID,HSeOrderBillNo,HRelationQty,HSecUnitRate,HPropertyID) 
@@ -463,7 +1019,7 @@
 
             }
             //淇濆瓨鍚庢帶鍒�=========================================              
-            ds = oCN.RunProcReturn("exec h_p_Kf_ProductInBill_AfterSaveCtrl " + HInterID, "h_p_Kf_ProductInBill_AfterSaveCtrl");
+            ds = oCn.RunProcReturn("exec h_p_Kf_ProductInBill_AfterSaveCtrl " + HInterID, "h_p_Kf_ProductInBill_AfterSaveCtrl");
 
             if (ds == null || ds.Tables[0].Rows.Count == 0)
             {
@@ -496,14 +1052,14 @@
         [HttpGet]
         public ApiResult<DataTable> getMaterialByMaterID(Int64 HMaterID)
         {
-            SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
 
             string sql = "select a.HItemID HMaterID,a.HNumber HMaterNumber,a.HName HMaterName,a.HMaterRuleType,a.HModel HMaterModel,a.HUnitID, b.HNumber HUnitNumber, b.HName HUnitName" +
                 " from Gy_Material AS a " +
                 " LEFT OUTER JOIN Gy_Unit AS b on a.HUnitID = b.HItemID " +
                 " where a.HItemID =" + HMaterID;
 
-            var dataSet = oCN.RunProcReturn(sql, "Gy_Material");
+            var dataSet = oCn.RunProcReturn(sql, "Gy_Material");
 
 
             if (dataSet == null || dataSet.Tables[0].Rows.Count == 0)
@@ -541,7 +1097,7 @@
 
                 ClsPub.CurUserName = user;
                 BillOld.MvarItemKey = "Kf_ICStockBillMain";
-                oCN.BeginTran();//寮�濮嬩簨鍔�
+                oCn.BeginTran();//寮�濮嬩簨鍔�
 
                 //Type 1 瀹℃牳  2  鍙嶅鏍�
                 if (Type == 1)
@@ -549,7 +1105,7 @@
                     //鍒ゆ柇鍗曟嵁鏄惁宸茬粡瀹℃牳
                     DataSet ds;
                     string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
-                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
+                    ds = oCn.RunProcReturn(sql, BillOld.MvarItemKey);
                     if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                     {
                         if (ds.Tables[0].Rows[0]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].ToString() != "")
@@ -576,7 +1132,7 @@
                     //鍒ゆ柇鍗曟嵁鏄惁宸茬粡鍙嶅鏍�
                     DataSet ds;
                     string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
-                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
+                    ds = oCn.RunProcReturn(sql, BillOld.MvarItemKey);
                     if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                     {
                         if (ds.Tables[0].Rows[0]["HChecker"] == null || ds.Tables[0].Rows[0]["HChecker"].ToString() == "")
@@ -612,7 +1168,7 @@
                     }
                 }
 
-                oCN.Commit();//鎻愪氦浜嬪姟
+                oCn.Commit();//鎻愪氦浜嬪姟
 
                 objJsonResult.code = "0";
                 objJsonResult.count = 1;
@@ -729,7 +1285,7 @@
 
                     //瀹℃牳鍓嶆帶鍒�=========================================      
                     string sql1 = "exec h_p_Kf_ProductInBill_BeforeCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
-                    ds = oCN.RunProcReturn(sql1, "h_p_Kf_ProductInBill_BeforeCheckCtrl");
+                    ds = oCn.RunProcReturn(sql1, "h_p_Kf_ProductInBill_BeforeCheckCtrl");
                     if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                     {
                         objJsonResult.code = "0";
@@ -770,7 +1326,7 @@
                 if (IsAudit == 1) //鍙嶅鏍告彁浜�
                 {
                     //鍙嶅鏍稿墠鎺у埗=========================================
-                    DataSet ds = oCN.RunProcReturn("Exec h_p_Kf_ProductInBill_BeforeUnCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'", "h_p_Kf_ProductInBill_BeforeUnCheckCtrl");
+                    DataSet ds = oCn.RunProcReturn("Exec h_p_Kf_ProductInBill_BeforeUnCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'", "h_p_Kf_ProductInBill_BeforeUnCheckCtrl");
                     if (ds == null)
                     {
                         objJsonResult.code = "0";
@@ -848,7 +1404,7 @@
 
                 ClsPub.CurUserName = user;
                 BillOld.MvarItemKey = "Kf_ICStockBillMain";
-                oCN.BeginTran();//寮�濮嬩簨鍔�
+                oCn.BeginTran();//寮�濮嬩簨鍔�
 
                 //Type 1 鍏抽棴  2  鍙嶅叧闂�
                 if (Type == 1)
@@ -856,7 +1412,7 @@
                     //鍒ゆ柇鍗曟嵁鏄惁宸茬粡鍏抽棴
                     DataSet ds;
                     string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
-                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
+                    ds = oCn.RunProcReturn(sql, BillOld.MvarItemKey);
                     if (ds == null || ds.Tables[0].Rows.Count == 0)
                     {
                         objJsonResult.code = "0";
@@ -908,7 +1464,7 @@
                     //鍒ゆ柇鍗曟嵁鏄惁宸茬粡鍙嶅叧闂�
                     DataSet ds;
                     string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
-                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
+                    ds = oCn.RunProcReturn(sql, BillOld.MvarItemKey);
                     if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                     {
                         if (ds.Tables[0].Rows[0]["HDeleteMan"] != null && ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "")
@@ -947,7 +1503,7 @@
                     }
                 }
 
-                oCN.Commit();//鎻愪氦浜嬪姟
+                oCn.Commit();//鎻愪氦浜嬪姟
 
                 objJsonResult.code = "0";
                 objJsonResult.count = 1;
@@ -995,7 +1551,7 @@
 
                 ClsPub.CurUserName = user;
                 BillOld.MvarItemKey = "Kf_ICStockBillMain";
-                oCN.BeginTran();//寮�濮嬩簨鍔�
+                oCn.BeginTran();//寮�濮嬩簨鍔�
 
                 //Type 1 浣滃簾  2  鍙嶄綔搴�
                 if (Type == 1)
@@ -1003,7 +1559,7 @@
                     //鍒ゆ柇鍗曟嵁鏄惁宸茬粡浣滃簾
                     DataSet ds;
                     string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
-                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
+                    ds = oCn.RunProcReturn(sql, BillOld.MvarItemKey);
                     if (ds == null || ds.Tables[0].Rows.Count == 0)
                     {
                         objJsonResult.code = "0";
@@ -1046,7 +1602,7 @@
                     //鍒ゆ柇鍗曟嵁鏄惁宸茬粡鍙嶄綔搴�
                     DataSet ds;
                     string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
-                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
+                    ds = oCn.RunProcReturn(sql, BillOld.MvarItemKey);
                     if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                     {
                         if (ds.Tables[0].Rows[0]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].ToString() != "")
@@ -1077,7 +1633,7 @@
                     }
                 }
 
-                oCN.Commit();//鎻愪氦浜嬪姟
+                oCn.Commit();//鎻愪氦浜嬪姟
 
                 objJsonResult.code = "0";
                 objJsonResult.count = 1;
@@ -1096,5 +1652,172 @@
             }
         }
         #endregion
+
+        #region 鐢熶骇鍏ュ簱鍗� 瀹℃牳鍚屾鎻掍欢 璋冪敤鎺ュ彛
+        [Route("Kf_ProductInBill/Kf_ProductInBillSaveApi")]
+        [HttpPost]
+        public object Kf_ProductInBillSaveApi([FromBody] JObject sMainSub)
+        {
+            try
+            {
+                oCn.BeginTran();
+                LogService.Write("鐢熶骇鍏ュ簱鍗曞悓姝�,淇濆瓨鏂规硶鎵ц锛�" + sMainSub.ToString());
+                sMainSub["model"]["hredblueflag"] = string.Equals(sMainSub["model"]["hredblueflag"].ToString(), "0") ? false : true;
+
+                var model = sMainSub["model"].ToString();
+                var entry = sMainSub["model"]["HENTRY"].ToString();
+                model = "[" + model.ToString() + "]";
+                List<ClsKf_ProductInBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsKf_ProductInBillMain>>(model);
+                List<ClsKf_ProductInBillSub> subList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsKf_ProductInBillSub>>(entry);
+
+
+                // 鍒ゆ柇 鏁版嵁搴撲腑鏄惁瀛樺湪id鍜屽崟鎹彿鐩哥瓑鐨勬墦鍗曟嵁锛屽瓨鍦紝鍒欓噸寤猴紝鍙湁id鍙风浉绛夛紝鍒欑敵璇锋柊鐨刬d鍙�
+                var ds1 = oCn.RunProcReturn($@"
+                select hmainid HInterID, 鍗曟嵁鍙� HBillNO from h_v_Kf_ProductInBillList where hmainid = {mainList[0].HInterID}
+                ", "h_v_Kf_ProductInBillList");
+                var HInterID_Old = mainList[0].HInterID;
+                if (ds1.Tables[0].Rows.Count > 0 && ds1.Tables[0].Rows[0]["HInterID"] != null)
+                {
+                    if (string.Equals(ds1.Tables[0].Rows[0]["HBillNo"].ToString(), mainList[0].HBillNo, StringComparison.OrdinalIgnoreCase))
+                    {
+                        string sql = string.Empty;
+                        sql = $"delete Kf_ICStockBillMain where HinterID = {mainList[0].HInterID}";
+                        oCn.RunProc(sql);
+                        sql = $"delete Kf_ICStockBillSub where HinterID = {mainList[0].HInterID}";
+                        oCn.RunProc(sql);
+                    }
+                    else
+                    {
+                        // 閲嶆柊鐢宠HInterID
+                        var HInterID_Exch = DBUtility.ClsPub.CreateBillID("1202", ref DBUtility.ClsPub.sExeReturnInfo);
+                        mainList[0].HInterID = HInterID_Exch;
+                
+                        foreach (var oSub in subList)
+                        {
+                            oSub.HInterID = HInterID_Exch;
+                        }
+                
+                    }
+                }
+
+                // string sql = string.Empty;
+                // sql = $"delete Kf_ICStockBillMain where HinterID = {mainList[0].HInterID}";
+                // oCn.RunProc(sql);
+                // sql = $"delete Kf_ICStockBillSub where HinterID = {mainList[0].HInterID}";
+                // oCn.RunProc(sql);
+                // 涓昏〃
+                oCn.RunProc($@"Insert Into Kf_ICStockBillMain 
+                (
+                    HInterID, HYear, HPeriod, HBillNo, HBillType, HBillSubType, HMainSourceBillType, HDate,
+                    HSupID, HWHID, HSCWHID, HEmpID, HManagerID, HSecManagerID, HKeeperID, HDeptID, HCurID,
+                    HSeOrderBillNo, HExplanation, HRemark, HInnerBillNo, HRedBlueFlag, HBillStatus,
+                    HMaker, HMakeDate, HChecker, HCheckDate,
+                    HUpDater, HUpDateDate, HDeleteMan, HDeleteDate,
+                    HOWNERID, HOWNERTYPEID, HERPInterID, HERPBillType, HERPBillNo,
+                    HPRDORGID, HSTOCKORGID, HSTOCKERGROUPID, HPURCHASERGROUPID, HDEMANDORGID, HCORRESPONDORGID,
+                    HPROVIDERCONTACTID, HSUPPLYID, HSETTLEID, HCHARGEID, HPURCHASEDEPTID, HBUSINESSTYPE,
+                    HSUPPLYADDRESS, HPAYORGID, HSETTLEORGID, HSETTLETYPEID, HPAYCONDITIONID, HSETTLECURRID,
+                    HEXCHANGETYPEID, HDISCOUNTLISTID, HEXCHANGERATE, HPRICETIMEPOINT, HLOCALCURRID, HISINCLUDEDTAX,
+                    HISPRICEEXCLUDETAX
+                )
+                values(
+                    '{mainList[0].HInterID}','{mainList[0].HYear}','{mainList[0].HPeriod}','{mainList[0].HBillNo}',                   
+                    '{mainList[0].HBillType}','{mainList[0].HBillSubType}','{mainList[0].HMainSourceBillType}','{mainList[0].HDate}',                     
+                    '{mainList[0].HSupID}','{mainList[0].HWHID}','{mainList[0].HSCWHID}','{mainList[0].HEmpID}','{mainList[0].HManagerID}',                
+                    '{mainList[0].HSecManagerID}','{mainList[0].HKeeperID}','{mainList[0].HDeptID}','{mainList[0].HCurID}',                    
+                    '{mainList[0].HSeOrderBillNo}','{mainList[0].HExplanation}','{mainList[0].HRemark}','{mainList[0].HInnerBillNo}',              
+                    '{mainList[0].HRedBlueFlag}',{mainList[0].HBillStatus},'{mainList[0].HMaker}','{mainList[0].HMakeDate}',                 
+                    '{mainList[0].HChecker}','{mainList[0].HCheckDate}','{mainList[0].HUpDater}','{mainList[0].HUpDateDate}',               
+                    '{mainList[0].HDeleteMan}','{mainList[0].HDeleteDate}','{mainList[0].HOWNERID}','{mainList[0].HOWNERTYPEID}',              
+                    '{mainList[0].HERPInterID}','{mainList[0].HERPBillType}','{mainList[0].HERPBillNo}','{mainList[0].HPRDORGID}',                 
+                    '{mainList[0].HSTOCKORGID}','{mainList[0].HSTOCKERGROUPID}','{mainList[0].HPURCHASERGROUPID}','{mainList[0].HDEMANDORGID}',              
+                    '{mainList[0].HCORRESPONDORGID}','{mainList[0].HPROVIDERCONTACTID}','{mainList[0].HSUPPLYID}','{mainList[0].HSETTLEID}',                 
+                    '{mainList[0].HCHARGEID}','{mainList[0].HPURCHASEDEPTID}','{mainList[0].HBUSINESSTYPE}','{mainList[0].HSUPPLYADDRESS}',            
+                    '{mainList[0].HPAYORGID}','{mainList[0].HSETTLEORGID}','{mainList[0].HSETTLETYPEID}','{mainList[0].HPAYCONDITIONID}',           
+                    '{mainList[0].HSETTLECURRID}','{mainList[0].HEXCHANGETYPEID}','{mainList[0].HDISCOUNTLISTID}','{mainList[0].HEXCHANGERATE}',             
+                    '{mainList[0].HPRICETIMEPOINT}','{mainList[0].HLOCALCURRID}','{mainList[0].HISINCLUDEDTAX}','{mainList[0].HISPRICEEXCLUDETAX}'         
+                )");
+
+                foreach (var osub in subList)
+                {
+                    // var syncSorceBillRes = oCN.RunProcReturn($@"
+                    //     exec h_p_IFCLD_ERPSourceBillToLocal_POStockInBill_GetSourceInfo 
+                    //     '{osub.HSourceBillType}', '{osub.HSourceBillNo}', {osub.HSourceSEQ} 
+                    // ", "h_p_IFCLD_ERPSourceBillToLocal_POStockInBill_GetSourceInfo");
+                    // ", "h_p_IFCLD_ERPSourceBillToLocal_POStockInBill_GetSourceInfo");
+                    // string HERPInterID = "0";
+                    // string HERPEntryID = "0";
+                    // if (syncSorceBillRes != null && syncSorceBillRes.Tables.Count > 0)
+                    // {
+                    //     osub.HSourceEntryID = (long)syncSorceBillRes.Tables[0].Rows[0]["HEntryID"];
+                    //     osub.HSourceInterID = (long)syncSorceBillRes.Tables[0].Rows[0]["HInterID"];
+                    //     HERPInterID = syncSorceBillRes.Tables[0].Rows[0]["HERPInterID"].ToString();
+                    //     HERPEntryID = syncSorceBillRes.Tables[0].Rows[0]["HERPInterID"].ToString();
+                    // }
+
+
+                   
+                    oCn.RunProc($@"Insert into Kf_ICStockBillSub 
+                    (
+                        HInterID, HEntryID, HMTONo, HPlanMode, HRemark, HExpressNumber,
+                        HMaterID, HUnitID, HBatchNo, HPropertyID, HWHID, HSPID, HSCWHID, HSCSPID,
+                        HQtyMust, HQty, HPrice, HMoney, HTaxPrice, HTaxRate, HTaxMoney, HRelationQty, HRelationMoney,
+                        HSourceInterID, HSourceEntryID, HSourceBillNo, HSourceBillType, HERPInterID, HERPEntryID, HERPBillNo_Sub,
+                        HPOOrderInterID, HPOOrderEntryID, HPOOrderBillNo, HSeOrderInterID, HSeOrderEntryID, HSeOrderBillNo,
+                        HICMOInterID, HICMOEntryID, HICMOBillNo, HWWOrderInterID, HWWOrderEntryID, HWWOrderBillNo,
+                        HProduceDate, HExpiryDate, HOWNERID, HOWNERTYPEID, HKEEPERID, HKEEPERTYPEID,
+                        HSUPPLIERLOT, HREQTRACENO, HPROJECTNO, HGIVEAWAY, HSYSPRICE, HPRICECOEFFICIENT,
+                        HDISCOUNTRATE, HBASEUNITPRICE, HTAXCOMBINATION, HPRICELISTENTRY, HCOSTPRICE, HSEQ,
+                        HROWTYPE, HPARENTMATID, HPRILSTENTRYID, HPURBASENUM, HSTOCKBASEDEN, HBFLOWID,
+                        HSTOCKSTATUSID, HPRICEUNITID, HBASEUNITID, HSNUNITID, HREMAININSTOCKUNITID, HEXTAUXUNITID,
+                        HTAXRATEID, HTAXRATE_TAX, HTAXAMOUNT, HCOSTPERCENT, HCOSTAMOUNT, HVAT,
+                        HSELLERWITHHOLDING, HBUYERWITHHOLDING
+                    ) 
+                    values (
+                        '{osub.HInterID}','{osub.HEntryID}','{osub.HMTONo}',{osub.HPlanMode},'{osub.HRemark}','{osub.HExpressNumber}',
+                        '{osub.HMaterID}','{osub.HUnitID}','{osub.HBatchNo}','{osub.HPropertyID}','{osub.HWHID}',                      
+                        '{osub.HSPID}','{osub.HSCWHID}','{osub.HSCSPID}', '{osub.HQtyMust}','{osub.HQty}','{osub.HPrice}',                     
+                        '{osub.HMoney}', '{osub.HTaxPrice}', '{osub.HTaxRate}', '{osub.HTaxMoney}', '{osub.HRelationQty}',               
+                        '{osub.HRelationMoney}','{osub.HSourceInterID}','{osub.HSourceEntryID}','{osub.HSourceBillNo}',              
+                        '{osub.HSourceBillType}','{osub.HERPInterID}','{osub.HERPEntryID}','{osub.HERPBillNo_Sub}',             
+                        '{osub.HPOOrderInterID}','{osub.HPOOrderEntryID}','{osub.HPOOrderBillNo}','{osub.HSeOrderInterID}',            
+                        '{osub.HSeOrderEntryID}','{osub.HSeOrderBillNo}','{osub.HICMOInterID}','{osub.HICMOEntryID}',               
+                        '{osub.HICMOBillNo}','{osub.HWWOrderInterID}','{osub.HWWOrderEntryID}', '{osub.HWWOrderBillNo}',             
+                        '{osub.HProduceDate}','{osub.HExpiryDate}', '{osub.HOWNERID}','{osub.HOWNERTYPEID}','{osub.HKEEPERID}',                  
+                        '{osub.HKEEPERTYPEID}', '{osub.HSUPPLIERLOT}', '{osub.HREQTRACENO}', '{osub.HPROJECTNO}','{osub.HGIVEAWAY}',                  
+                        '{osub.HSYSPRICE}', '{osub.HPRICECOEFFICIENT}','{osub.HDISCOUNTRATE}','{osub.HBASEUNITPRICE}', '{osub.HTAXCOMBINATION}',            
+                        '{osub.HPRICELISTENTRY}','{osub.HCOSTPRICE}', '{osub.HSEQ}','{osub.HROWTYPE}','{osub.HPARENTMATID}', '{osub.HPRILSTENTRYID}',             
+                        '{osub.HPURBASENUM}','{osub.HSTOCKBASEDEN}', '{osub.HBFLOWID}','{osub.HSTOCKSTATUSID}','{osub.HPRICEUNITID}', '{osub.HBASEUNITID}',                
+                        '{osub.HSNUNITID}', '{osub.HREMAININSTOCKUNITID}','{osub.HEXTAUXUNITID}','{osub.HTAXRATEID}','{osub.HTAXRATE_TAX}','{osub.HTAXAMOUNT}',                 
+                        '{osub.HCOSTPERCENT}','{osub.HCOSTAMOUNT}','{osub.HVAT}','{osub.HSELLERWITHHOLDING}','{osub.HBUYERWITHHOLDING}'           
+                    )");
+                }
+
+                //鐢熶骇鍏ュ簱鍗曟柊澧炲洖濉敓浜ц鍗曞叧鑱旀暟閲�
+                oCn.RunProc("exec h_p_Kf_UpDateRelation_ProductInToICMO_Add " + mainList[0].HInterID);
+                 
+                //鐢熶骇鍏ュ簱鍗曟柊澧炲洖濉敓浜ф眹鎶ュ崟鍏宠仈鏁伴噺
+                oCn.RunProc("exec h_p_Kf_UpDateRelation_ProductInToICMOReport_Add " + mainList[0].HInterID);
+
+                oCn.Commit();
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鍗曟嵁淇濆瓨鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                LogService.Write("鐢熶骇鍏ュ簱鍗曞悓姝ュ紓甯�,淇濆瓨鏂规硶鎵ц瀹屾垚寮傚父锛�" + e.Message.ToString());
+
+                oCn.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "淇濆瓨澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1