From d19fcd70a3b11339eb0c50b5c734eeca855a9a95 Mon Sep 17 00:00:00 2001
From: yusijie <ysj@hz-kingdee.com>
Date: 星期三, 12 二月 2025 14:05:50 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API

---
 WebAPI/Controllers/条码管理/MouldController.cs | 1513 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 1,510 insertions(+), 3 deletions(-)

diff --git "a/WebAPI/Controllers/\346\235\241\347\240\201\347\256\241\347\220\206/MouldController.cs" "b/WebAPI/Controllers/\346\235\241\347\240\201\347\256\241\347\220\206/MouldController.cs"
index 663c5fc..366aa5c 100644
--- "a/WebAPI/Controllers/\346\235\241\347\240\201\347\256\241\347\220\206/MouldController.cs"
+++ "b/WebAPI/Controllers/\346\235\241\347\240\201\347\256\241\347\220\206/MouldController.cs"
@@ -25,6 +25,8 @@
         public DataSet ds = new DataSet();
         private json objJsonResult = new json();
         SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
+        Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
+        string ComputerName = SystemInformation.ComputerName;   //璁惧鍚嶇О
 
 
         #region 鍣ㄥ叿鎵爜妯″潡璋冪敤鏂规硶
@@ -36,11 +38,99 @@
         /// <returns></returns>
         [Route("MouldController/Get_CheckTypeByMouldBarCode_Json")]
         [HttpGet]
-        public object Get_CheckTypeByMouldBarCode_Json(string sBarCode, Int64 HInterID, string HBillType, string HBillNo, string HMaker, Int64 HWhID, Int64 HSPID, Int64 HSCWhID, Int64 HSCSPID, bool HRedBlueFlag, string HSourceBillNo, string HSourceBillType, Int64 HStockOrgID)
+        public object Get_CheckTypeByMouldBarCode_Json(string sBarCode, Int64 HInterID, string HBillType, string HBillNo, string HMaker, Int64 HWhID, Int64 HSPID, Int64 HSCWhID, Int64 HSCSPID, bool HRedBlueFlag, string HSourceBillNo, string HSourceBillType, Int64 HStockOrgID, Int64 HStockOutOrgID)
         {
+            Int64 HBarCodeQty = 0;   //鍏佽鎵弿鏉$爜涓暟锛�0銆�1銆�2銆�3.....锛屽叾涓�0涓轰笉鎺у埗锛�
+
+            #region 鑾峰彇绯荤粺鍙傛暟
+            string sErrMsg = "";
+            if (oSystemParameter.ShowBillByOrgID(HStockOrgID, ref sErrMsg) == true)
+            {
+                //鍣ㄥ叿閲囪喘鍏ュ簱鍗�
+                if (HBillType == "3801")
+                {
+                    HBarCodeQty = DBUtility.ClsPub.isLong(oSystemParameter.omodel.Sc_MouldProdInBill_BarCodeQty);
+                }
+                //鍣ㄥ叿棰嗙敤鍑哄簱鍗�
+                else if (HBillType == "3802")
+                {
+                    HBarCodeQty = DBUtility.ClsPub.isLong(oSystemParameter.omodel.Sc_MouldProdOutBill_BarCodeQty);
+                }
+                //鍣ㄥ叿棰嗙敤閫�搴撳崟
+                else if (HBillType == "3803")
+                {
+                    HBarCodeQty = DBUtility.ClsPub.isLong(oSystemParameter.omodel.Sc_MouldProdBackBill_BarCodeQty);
+                }
+                //鍣ㄥ叿鏀瑰埗鍑哄簱鍗�
+                else if (HBillType == "3825")
+                {
+                    HBarCodeQty = DBUtility.ClsPub.isLong(oSystemParameter.omodel.Sc_MouldRepairOutBill_BarCodeQty);
+                }
+                //鍣ㄥ叿鏀瑰埗鍏ュ簱鍗�
+                else if (HBillType == "3826")
+                {
+                    HBarCodeQty = DBUtility.ClsPub.isLong(oSystemParameter.omodel.Sc_MouldRepairInBill_BarCodeQty);
+                }
+                //鍣ㄥ叿鍏朵粬鍏ュ簱鍗�
+                else if (HBillType == "3827")
+                {
+                    HBarCodeQty = DBUtility.ClsPub.isLong(oSystemParameter.omodel.Sc_MouldOtherInBill_BarCodeQty);
+                }
+                //鍣ㄥ叿鍏朵粬鍑哄簱鍗�
+                else if (HBillType == "3828")
+                {
+                    HBarCodeQty = DBUtility.ClsPub.isLong(oSystemParameter.omodel.Sc_MouldOtherOutBill_BarCodeQty);
+                }
+                //鍣ㄥ叿鏆傚�熷叆搴撳崟
+                else if (HBillType == "3829")
+                {
+                    HBarCodeQty = DBUtility.ClsPub.isLong(oSystemParameter.omodel.Sc_MouldBorrowInBill_BarCodeQty);
+                }
+                //鍣ㄥ叿鏆傚�熷嚭搴撳崟
+                else if (HBillType == "3830")
+                {
+                    HBarCodeQty = DBUtility.ClsPub.isLong(oSystemParameter.omodel.Sc_MouldBorrowOutBill_BarCodeQty);
+                }
+                //鍣ㄥ叿鎶ュ簾鍏ュ簱鍗�
+                else if (HBillType == "3831")
+                {
+                    HBarCodeQty = DBUtility.ClsPub.isLong(oSystemParameter.omodel.Sc_MouldScrapInBill_BarCodeQty);
+                }
+                //鍣ㄥ叿鎶ュ簾鍑哄簱鍗�
+                else if (HBillType == "3832")
+                {
+                    HBarCodeQty = DBUtility.ClsPub.isLong(oSystemParameter.omodel.Sc_MouldScrapOutBill_BarCodeQty);
+                }
+                //鍣ㄥ叿鐩存帴璋冩嫧鍗�
+                else if (HBillType == "3814")
+                {
+                    HBarCodeQty = DBUtility.ClsPub.isLong(oSystemParameter.omodel.Sc_MouldProdMoveBill_BarCodeQty);
+                }
+                //鍣ㄥ叿鍒嗘璋冨嚭鍗�
+                else if (HBillType == "3840")
+                {
+                    HBarCodeQty = DBUtility.ClsPub.isLong(oSystemParameter.omodel.Sc_MouldMoveStockStepOutBill_BarCodeQty);
+                }
+                //鍣ㄥ叿鍒嗘璋冨叆鍗�
+                else if (HBillType == "3841")
+                {
+                    HBarCodeQty = DBUtility.ClsPub.isLong(oSystemParameter.omodel.Sc_MouldMoveStockStepInBill_BarCodeQty);
+                }
+            }
+            else
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鑾峰彇绯荤粺鍙傛暟澶辫触锛� " + sErrMsg;
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+
+            #endregion
+
             try
             {
-                ds = oCn.RunProcReturn("exec h_p_WMS_AddMouldBarCode_New '" + sBarCode + "'," + HInterID.ToString() + ",'" + HBillNo + "','" + HBillType + "'," + HWhID.ToString() + "," + HSPID.ToString() + "," + HSCWhID.ToString() + "," + HSCSPID.ToString() + ",'" + HSourceBillNo + "','" + HSourceBillType + "','" + HRedBlueFlag + "','" + HMaker + "'," + HStockOrgID.ToString(), "h_p_WMS_AddMouldBarCode_New");
+                ds = oCn.RunProcReturn("exec h_p_WMS_CheckMouldBarCode_Add '" + sBarCode + "'," + HInterID.ToString() + ",'" + HBillNo + "','" + HBillType + "'," + HWhID.ToString() + "," + HSPID.ToString() + "," + HSCWhID.ToString() + "," + HSCSPID.ToString() + ",'" + HSourceBillNo + "','" + HSourceBillType + "','" + HRedBlueFlag + "','" + HMaker + "'," + HStockOrgID.ToString() + "," + HStockOutOrgID.ToString() + "," + HBarCodeQty.ToString(), "h_p_WMS_CheckMouldBarCode_Add");
                 if (ds == null || ds.Tables[0].Rows.Count == 0)
                 {
                     objJsonResult.code = "0";
@@ -136,7 +226,7 @@
         /// <returns></returns>
         [Route("MouldController/set_DelMouldStockBillMain_Temp_Json")]
         [HttpGet]
-        public object set_DelPonderationBillMain_Temp_BarCode_Json(Int64 HInterID, string HBillType, string HBarCode)
+        public object set_DelMouldStockBillMain_Temp_Json(Int64 HInterID, string HBillType, string HBarCode)
         {
             try
             {
@@ -161,8 +251,309 @@
 
         #endregion
 
+        #region 鍣ㄥ叿缂撳瓨鍒楄〃妯″潡璋冪敤鏂规硶
+
+        #region 鍣ㄥ叿缂撳瓨鍒楄〃鐣岄潰锛岃繑鍥炵紦瀛樺垪琛ㄤ俊鎭�
+
+        /// <summary>
+        /// 鍣ㄥ叿缂撳瓨鍒楄〃鐣岄潰锛岃繑鍥炵紦瀛樺垪琛ㄤ俊鎭�
+        /// </summary>
+        /// <returns></returns>
+        [Route("MouldController/GetSc_MouldStockBillMain_TempList_Json")]
+        [HttpGet]
+        public object GetSc_MouldStockBillMain_TempList_Json(string HBillType, string HMaker, Int64 HStockOrgID)
+        {
+            try
+            {
+                ds = oCn.RunProcReturn("exec h_p_Sc_GetMouldStockBillMain_TempList '" + HBillType + "','" + HMaker + "'," + HStockOrgID.ToString(), "h_p_Sc_GetMouldStockBillMain_TempList");
+                if (ds == null || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    List<object> columnNameList = new List<object>();
+                    //娣诲姞鍒楀悕
+                    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("MouldController/MouldTempList_Modify_Json")]
+        [HttpGet]
+        public object MouldTempList_Modify_Json(long HInterID, string HBillNo, string HBillType)
+        {
+            try
+            {
+                ds = oCn.RunProcReturn("exec h_p_WMS_MouldTempList_Modify " + HInterID + ",'" + HBillNo + "','" + HBillType + "'", "h_p_WMS_MouldTempList_Modify");
+                if (ds == null || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "妯″叿缂撳瓨鍒楄〃缂栬緫鍓嶅垽鏂け璐ワ紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else if (DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HBack"]) == 1)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HRemark"]);
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                objJsonResult.code = "0";
+                objJsonResult.count = 1;
+                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>
+        /// <returns></returns>
+        [Route("MouldController/set_DeleteMouldBillList_Json")]
+        [HttpGet]
+        public object set_DeleteMouldBillList_Json(long HInterID, string HBillNo, string HBillType, string HMaker, string MvarReportTitle)
+        {
+            try
+            {
+                string WorkList = "鍒犻櫎缂撳瓨鍗曟嵁锛屽崟鎹彿锛�" + HBillNo;
+                string SystemName = "WMS-" + MvarReportTitle + "妯″潡";
+                oCn.BeginTran();
+                oCn.RunProc("Delete from Sc_MouldStockBillMain_Temp where HInterID=" + HInterID.ToString() + " and HBillType='" + HBillType + "'", ref DBUtility.ClsPub.sExeReturnInfo);
+                //鍐欏叆鏃ュ織
+                oCn.RunProc("Insert into  System_Log(GeginDate,userid,WorkstationName,WorkList,SystemName,NetUserName,State) values " +
+                    "(getdate(),'" + HMaker + "','" + ComputerName + "','" + WorkList + "','" + SystemName + "','','鍒犻櫎')"
+                    );
+                oCn.Commit();
+                objJsonResult.code = "0";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鍗曟嵁鍙凤細" + HBillNo + " 鍒犻櫎鎴愬姛";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                oCn.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鍒犻櫎鍣ㄥ叿缂撳瓨鍒楄〃鍗曟嵁澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+        #endregion
+
+        #endregion
+
 
         #region 鍣ㄥ叿鎻愪氦鐢熷崟澶勭悊鏂规硶
+
+        #region 妯″叿閲囪喘鍏ュ簱鍗�     涓婁紶鐢熷崟
+
+        /// <summary>
+        /// 妯″叿閲囪喘鍏ュ簱鍗曟柊澧炰笂浼�
+        /// </summary>
+        /// <returns></returns>
+        [Route("MouldController/set_SaveMouldProdInBill_Json")]
+        [HttpPost]
+        public object set_SaveMouldProdInBill_Json([FromBody] JObject oMain)
+        {
+            BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew;
+            DAL.ClsSc_MouldProdInBill BillNew = new DAL.ClsSc_MouldProdInBill();
+            var _value = oMain["oMain"].ToString();
+            string msg1 = _value.ToString();
+            try
+            {
+                string sMainStr = "[" + msg1.ToString() + "]";
+                List<Model.ClsSc_MouldProdInBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsSc_MouldProdInBillMain>>(sMainStr);
+
+                //鍗曟嵁鍙锋槸鍚﹂噸澶�
+                if (BillNew.IsExistBillNo(ref ClsPub.sExeReturnInfo, mainList[0].HBillNo, BillStatus, mainList[0].HInterID))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁鍙烽噸澶嶏紒涓嶅厑璁镐繚瀛橈紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //鍒ゆ柇浼氳鏈熸槸鍚﹀悎鐞�
+                string s = "";
+                int sYear = 0;
+                int sPeriod = 0;
+                if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(mainList[0].HDate, ref sYear, ref sPeriod, ref s) == false)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = s;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //鍥哄畾璧嬪��=================================
+                BillNew.omodel.HYear = sYear;
+                BillNew.omodel.HPeriod = sPeriod;
+                BillNew.omodel.HBillType = "3801";
+                BillNew.omodel.HInterID = mainList[0].HInterID;
+                BillNew.omodel.HBillNo = mainList[0].HBillNo;
+                BillNew.omodel.HDate = mainList[0].HDate;
+                BillNew.omodel.HRemark = mainList[0].HRemark;
+                BillNew.omodel.HMaker = mainList[0].HMaker;
+                BillNew.omodel.HSTOCKORGID = mainList[0].HSTOCKORGID;
+                DBUtility.ClsPub.CurUserName = mainList[0].HMaker;
+                //====================================================
+                BillNew.omodel.HSupID = mainList[0].HSupID;
+                BillNew.omodel.HSupTypeID = 1; //锛�1 渚涘簲鍟嗐��2 瀹㈡埛銆� 3 杞﹂棿閮ㄩ棬锛�
+                BillNew.omodel.HEmpID = mainList[0].HEmpID;
+                BillNew.omodel.HManagerID = mainList[0].HManagerID;
+                BillNew.omodel.HSecManagerID = mainList[0].HSecManagerID;
+                BillNew.omodel.HKeeperID = mainList[0].HKeeperID;
+                BillNew.omodel.HDeptID = mainList[0].HDeptID;
+                BillNew.omodel.HWHID = mainList[0].HWHID;
+                BillNew.omodel.HSCWHID = mainList[0].HSCWHID;
+                BillNew.omodel.HExplanation = mainList[0].HExplanation;
+                BillNew.omodel.HInnerBillNo = mainList[0].HInnerBillNo;
+                BillNew.omodel.HRedBlueFlag = mainList[0].HRedBlueFlag;
+                //瀛愯〃璧嬪��
+                ds = oCn.RunProcReturn("exec h_p_Sc_GetMouldStockBill_Temp " + BillNew.omodel.HInterID.ToString() + ",'" + BillNew.omodel.HBillType + "'", "h_p_Sc_GetMouldStockBill_Temp");
+                if (ds == null || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "娌℃湁鎵爜淇℃伅锛岃鍏堟壂鎻忔潯鐮侊紝纭鏃犺鍚庡啀鎻愪氦锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
+                    {
+                        Model.ClsSc_MouldStockBillSub oSub = new Model.ClsSc_MouldStockBillSub();
+                        //鍥哄畾璧嬪��========================================
+                        oSub.HEntryID = i + 1;
+                        oSub.HRemark = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HRemark"]);
+                        oSub.HSourceInterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSourceInterID"]);
+                        oSub.HSourceEntryID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSourceEntryID"]);
+                        oSub.HSourceBillType = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HSourceBillType"]);
+                        oSub.HSourceBillNo = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HSourceBillNo"]);
+                        oSub.HRelationQty = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HRelationQty"]);
+                        oSub.HRelationMoney = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HRelationMoney"]);
+                        //=============================
+                        oSub.HMaterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HMaterID"]);
+                        oSub.HPropertyID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HAuxPropID"]);
+                        oSub.HSecUnitID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSecUnitID"]);
+                        oSub.HSecUnitRate = DBUtility.ClsPub.isSingle(ds.Tables[0].Rows[i]["HSecUnitRate"]);
+                        oSub.HUnitID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HUnitID"]);
+                        oSub.HBatchNo = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HBatchNo"]);
+                        oSub.HQtyMust = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HQtyMust"]);
+                        oSub.HQtyRel = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HQtyRel"]);
+                        oSub.HQty = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HQty"]);
+                        oSub.HPrice = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HPrice"]);
+                        oSub.HMoney = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HMoney"]);
+                        oSub.HDesignLife = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HDesignLife"]);
+                        oSub.HLeaveLife = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HLeaveLife"]);
+                        oSub.HUseLife = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HUseLife"]);
+                        oSub.HUseLifeQty = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HUseLifeQty"]);
+                        oSub.HNewLifeQty = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HNewLifeQty"]);
+                        oSub.HWHID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HWHID"]);
+                        oSub.HSCWHID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSCWHID"]);
+                        oSub.HSPID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSPID"]);
+                        oSub.HSCSPID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSCSPID"]);
+                        oSub.HSPGroupID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSPGroupID"]);
+                        oSub.HBarCode = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HBarCode"]);
+                        oSub.HCorrespondentTypeID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HCorrespondentTypeID"]);
+                        oSub.HCorrespondentID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HCorrespondentID"]);
+                        oSub.HPOOrderInterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HPOOrderInterID"]);
+                        oSub.HPOOrderEntryID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HPOOrderEntryID"]);
+                        oSub.HPOOrderBillNo = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HPOOrderBillNo"]);
+                        oSub.HSeOrderInterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSeOrderInterID"]);
+                        oSub.HSeOrderEntryID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSeOrderEntryID"]);
+                        oSub.HSeOrderBillNo = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HSeOrderBillNo"]);
+                        oSub.HStockOrgID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HStockOrgID"]);
+                        oSub.HOWNERID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HOWNERID"]);
+                        oSub.HOtherOrgID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HOtherOrgID"]);
+                        oSub.HOWNERTYPEID = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HOWNERTYPEID"]);
+                        BillNew.DetailColl.Add(oSub);
+                    }
+                }
+                //淇濆瓨
+                bool bResult;
+                bResult = BillNew.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+
+                if (bResult)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo;  //鎴愬姛锛�
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "妯″叿閲囪喘鍏ュ簱鍗曚笂浼犲け璐ワ紒" + e.Message;
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+        #endregion
 
         #region 妯″叿棰嗙敤鍑哄簱鍗�     涓婁紶鐢熷崟
 
@@ -482,6 +873,1122 @@
 
         #endregion
 
+        #region 妯″叿鏀瑰埗鍏ュ簱鍗�     涓婁紶鐢熷崟
+
+        /// <summary>
+        /// 妯″叿鏀瑰埗鍏ュ簱鍗曟柊澧炰笂浼�
+        /// </summary>
+        /// <returns></returns>
+        [Route("MouldController/set_SaveMouldRepairInBill_Json")]
+        [HttpPost]
+        public object set_SaveMouldRepairInBill_Json([FromBody] JObject oMain)
+        {
+            BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew;
+            DAL.ClsSc_MouldRepairInBill BillNew = new DAL.ClsSc_MouldRepairInBill();
+            var _value = oMain["oMain"].ToString();
+            string msg1 = _value.ToString();
+            try
+            {
+                string sMainStr = "[" + msg1.ToString() + "]";
+                List<Model.ClsSc_MouldRepairInBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsSc_MouldRepairInBillMain>>(sMainStr);
+
+                //鍗曟嵁鍙锋槸鍚﹂噸澶�
+                if (BillNew.IsExistBillNo(ref ClsPub.sExeReturnInfo, mainList[0].HBillNo, BillStatus, mainList[0].HInterID))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁鍙烽噸澶嶏紒涓嶅厑璁镐繚瀛橈紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //鍒ゆ柇浼氳鏈熸槸鍚﹀悎鐞�
+                string s = "";
+                int sYear = 0;
+                int sPeriod = 0;
+                if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(mainList[0].HDate, ref sYear, ref sPeriod, ref s) == false)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = s;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //鍥哄畾璧嬪��=================================
+                BillNew.omodel.HYear = sYear;
+                BillNew.omodel.HPeriod = sPeriod;
+                BillNew.omodel.HBillType = "3826";
+                BillNew.omodel.HInterID = mainList[0].HInterID;
+                BillNew.omodel.HBillNo = mainList[0].HBillNo;
+                BillNew.omodel.HDate = mainList[0].HDate;
+                BillNew.omodel.HRemark = mainList[0].HRemark;
+                BillNew.omodel.HMaker = mainList[0].HMaker;
+                BillNew.omodel.HSTOCKORGID = mainList[0].HSTOCKORGID;
+                DBUtility.ClsPub.CurUserName = mainList[0].HMaker;
+                //====================================================
+                BillNew.omodel.HSupID = mainList[0].HSupID;
+                BillNew.omodel.HSupTypeID = 1; //锛�1 渚涘簲鍟嗐��2 瀹㈡埛銆� 3 杞﹂棿閮ㄩ棬锛�
+                BillNew.omodel.HEmpID = mainList[0].HEmpID;
+                BillNew.omodel.HManagerID = mainList[0].HManagerID;
+                BillNew.omodel.HSecManagerID = mainList[0].HSecManagerID;
+                BillNew.omodel.HKeeperID = mainList[0].HKeeperID;
+                BillNew.omodel.HDeptID = mainList[0].HDeptID;
+                BillNew.omodel.HWHID = mainList[0].HWHID;
+                BillNew.omodel.HSCWHID = mainList[0].HSCWHID;
+                BillNew.omodel.HExplanation = mainList[0].HExplanation;
+                BillNew.omodel.HInnerBillNo = mainList[0].HInnerBillNo;
+                BillNew.omodel.HRedBlueFlag = mainList[0].HRedBlueFlag;
+                //瀛愯〃璧嬪��
+                ds = oCn.RunProcReturn("exec h_p_Sc_GetMouldStockBill_Temp " + BillNew.omodel.HInterID.ToString() + ",'" + BillNew.omodel.HBillType + "'", "h_p_Sc_GetMouldStockBill_Temp");
+                if (ds == null || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "娌℃湁鎵爜淇℃伅锛岃鍏堟壂鎻忔潯鐮侊紝纭鏃犺鍚庡啀鎻愪氦锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
+                    {
+                        Model.ClsSc_MouldStockBillSub oSub = new Model.ClsSc_MouldStockBillSub();
+                        //鍥哄畾璧嬪��========================================
+                        oSub.HEntryID = i + 1;
+                        oSub.HRemark = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HRemark"]);
+                        oSub.HSourceInterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSourceInterID"]);
+                        oSub.HSourceEntryID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSourceEntryID"]);
+                        oSub.HSourceBillType = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HSourceBillType"]);
+                        oSub.HSourceBillNo = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HSourceBillNo"]);
+                        oSub.HRelationQty = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HRelationQty"]);
+                        oSub.HRelationMoney = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HRelationMoney"]);
+                        //=============================
+                        oSub.HMaterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HMaterID"]);
+                        oSub.HPropertyID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HAuxPropID"]);
+                        oSub.HSecUnitID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSecUnitID"]);
+                        oSub.HSecUnitRate = DBUtility.ClsPub.isSingle(ds.Tables[0].Rows[i]["HSecUnitRate"]);
+                        oSub.HUnitID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HUnitID"]);
+                        oSub.HBatchNo = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HBatchNo"]);
+                        oSub.HQtyMust = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HQtyMust"]);
+                        oSub.HQtyRel = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HQtyRel"]);
+                        oSub.HQty = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HQty"]);
+                        oSub.HPrice = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HPrice"]);
+                        oSub.HMoney = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HMoney"]);
+                        oSub.HDesignLife = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HDesignLife"]);
+                        oSub.HLeaveLife = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HLeaveLife"]);
+                        oSub.HUseLife = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HUseLife"]);
+                        oSub.HUseLifeQty = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HUseLifeQty"]);
+                        oSub.HNewLifeQty = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HNewLifeQty"]);
+                        oSub.HWHID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HWHID"]);
+                        oSub.HSCWHID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSCWHID"]);
+                        oSub.HSPID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSPID"]);
+                        oSub.HSCSPID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSCSPID"]);
+                        oSub.HSPGroupID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSPGroupID"]);
+                        oSub.HBarCode = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HBarCode"]);
+                        oSub.HCorrespondentTypeID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HCorrespondentTypeID"]);
+                        oSub.HCorrespondentID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HCorrespondentID"]);
+                        oSub.HPOOrderInterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HPOOrderInterID"]);
+                        oSub.HPOOrderEntryID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HPOOrderEntryID"]);
+                        oSub.HPOOrderBillNo = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HPOOrderBillNo"]);
+                        oSub.HSeOrderInterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSeOrderInterID"]);
+                        oSub.HSeOrderEntryID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSeOrderEntryID"]);
+                        oSub.HSeOrderBillNo = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HSeOrderBillNo"]);
+                        oSub.HStockOrgID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HStockOrgID"]);
+                        oSub.HOWNERID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HOWNERID"]);
+                        oSub.HOtherOrgID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HOtherOrgID"]);
+                        oSub.HOWNERTYPEID = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HOWNERTYPEID"]);
+                        BillNew.DetailColl.Add(oSub);
+                    }
+                }
+                //淇濆瓨
+                bool bResult;
+                bResult = BillNew.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+
+                if (bResult)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo;  //鎴愬姛锛�
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "妯″叿鏀瑰埗鍏ュ簱鍗曚笂浼犲け璐ワ紒" + e.Message;
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+        #endregion
+
+        #region 妯″叿鏀瑰埗鍑哄簱鍗�     涓婁紶鐢熷崟
+
+        /// <summary>
+        /// 妯″叿鏀瑰埗鍑哄簱鍗曟柊澧炰笂浼�
+        /// </summary>
+        /// <returns></returns>
+        [Route("MouldController/set_SaveMouldRepairOutBill_Json")]
+        [HttpPost]
+        public object set_SaveMouldRepairOutBill_Json([FromBody] JObject oMain)
+        {
+            BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew;
+            DAL.ClsSc_MouldRepairOutBill BillNew = new DAL.ClsSc_MouldRepairOutBill();
+            var _value = oMain["oMain"].ToString();
+            string msg1 = _value.ToString();
+            try
+            {
+                string sMainStr = "[" + msg1.ToString() + "]";
+                List<Model.ClsSc_MouldRepairOutBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsSc_MouldRepairOutBillMain>>(sMainStr);
+
+                //鍗曟嵁鍙锋槸鍚﹂噸澶�
+                if (BillNew.IsExistBillNo(ref ClsPub.sExeReturnInfo, mainList[0].HBillNo, BillStatus, mainList[0].HInterID))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁鍙烽噸澶嶏紒涓嶅厑璁镐繚瀛橈紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //鍒ゆ柇浼氳鏈熸槸鍚﹀悎鐞�
+                string s = "";
+                int sYear = 0;
+                int sPeriod = 0;
+                if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(mainList[0].HDate, ref sYear, ref sPeriod, ref s) == false)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = s;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //鍥哄畾璧嬪��=================================
+                BillNew.omodel.HYear = sYear;
+                BillNew.omodel.HPeriod = sPeriod;
+                BillNew.omodel.HBillType = "3825";
+                BillNew.omodel.HInterID = mainList[0].HInterID;
+                BillNew.omodel.HBillNo = mainList[0].HBillNo;
+                BillNew.omodel.HDate = mainList[0].HDate;
+                BillNew.omodel.HRemark = mainList[0].HRemark;
+                BillNew.omodel.HMaker = mainList[0].HMaker;
+                BillNew.omodel.HSTOCKORGID = mainList[0].HSTOCKORGID;
+                DBUtility.ClsPub.CurUserName = mainList[0].HMaker;
+                //====================================================
+                BillNew.omodel.HSupID = mainList[0].HSupID;
+                BillNew.omodel.HSupTypeID = 1; //锛�1 渚涘簲鍟嗐��2 瀹㈡埛銆� 3 杞﹂棿閮ㄩ棬锛�
+                BillNew.omodel.HEmpID = mainList[0].HEmpID;
+                BillNew.omodel.HManagerID = mainList[0].HManagerID;
+                BillNew.omodel.HSecManagerID = mainList[0].HSecManagerID;
+                BillNew.omodel.HKeeperID = mainList[0].HKeeperID;
+                BillNew.omodel.HDeptID = mainList[0].HDeptID;
+                BillNew.omodel.HWHID = mainList[0].HWHID;
+                BillNew.omodel.HSCWHID = mainList[0].HSCWHID;
+                BillNew.omodel.HExplanation = mainList[0].HExplanation;
+                BillNew.omodel.HInnerBillNo = mainList[0].HInnerBillNo;
+                BillNew.omodel.HRedBlueFlag = mainList[0].HRedBlueFlag;
+                //瀛愯〃璧嬪��
+                ds = oCn.RunProcReturn("exec h_p_Sc_GetMouldStockBill_Temp " + BillNew.omodel.HInterID.ToString() + ",'" + BillNew.omodel.HBillType + "'", "h_p_Sc_GetMouldStockBill_Temp");
+                if (ds == null || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "娌℃湁鎵爜淇℃伅锛岃鍏堟壂鎻忔潯鐮侊紝纭鏃犺鍚庡啀鎻愪氦锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
+                    {
+                        Model.ClsSc_MouldStockBillSub oSub = new Model.ClsSc_MouldStockBillSub();
+                        //鍥哄畾璧嬪��========================================
+                        oSub.HEntryID = i + 1;
+                        oSub.HRemark = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HRemark"]);
+                        oSub.HSourceInterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSourceInterID"]);
+                        oSub.HSourceEntryID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSourceEntryID"]);
+                        oSub.HSourceBillType = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HSourceBillType"]);
+                        oSub.HSourceBillNo = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HSourceBillNo"]);
+                        oSub.HRelationQty = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HRelationQty"]);
+                        oSub.HRelationMoney = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HRelationMoney"]);
+                        //=============================
+                        oSub.HMaterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HMaterID"]);
+                        oSub.HPropertyID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HAuxPropID"]);
+                        oSub.HSecUnitID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSecUnitID"]);
+                        oSub.HSecUnitRate = DBUtility.ClsPub.isSingle(ds.Tables[0].Rows[i]["HSecUnitRate"]);
+                        oSub.HUnitID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HUnitID"]);
+                        oSub.HBatchNo = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HBatchNo"]);
+                        oSub.HQtyMust = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HQtyMust"]);
+                        oSub.HQtyRel = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HQtyRel"]);
+                        oSub.HQty = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HQty"]);
+                        oSub.HPrice = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HPrice"]);
+                        oSub.HMoney = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HMoney"]);
+                        oSub.HDesignLife = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HDesignLife"]);
+                        oSub.HLeaveLife = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HLeaveLife"]);
+                        oSub.HUseLife = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HUseLife"]);
+                        oSub.HUseLifeQty = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HUseLifeQty"]);
+                        oSub.HNewLifeQty = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HNewLifeQty"]);
+                        oSub.HWHID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HWHID"]);
+                        oSub.HSCWHID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSCWHID"]);
+                        oSub.HSPID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSPID"]);
+                        oSub.HSCSPID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSCSPID"]);
+                        oSub.HSPGroupID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSPGroupID"]);
+                        oSub.HBarCode = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HBarCode"]);
+                        oSub.HCorrespondentTypeID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HCorrespondentTypeID"]);
+                        oSub.HCorrespondentID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HCorrespondentID"]);
+                        oSub.HPOOrderInterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HPOOrderInterID"]);
+                        oSub.HPOOrderEntryID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HPOOrderEntryID"]);
+                        oSub.HPOOrderBillNo = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HPOOrderBillNo"]);
+                        oSub.HSeOrderInterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSeOrderInterID"]);
+                        oSub.HSeOrderEntryID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSeOrderEntryID"]);
+                        oSub.HSeOrderBillNo = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HSeOrderBillNo"]);
+                        oSub.HStockOrgID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HStockOrgID"]);
+                        oSub.HOWNERID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HOWNERID"]);
+                        oSub.HOtherOrgID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HOtherOrgID"]);
+                        oSub.HOWNERTYPEID = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HOWNERTYPEID"]);
+                        BillNew.DetailColl.Add(oSub);
+                    }
+                }
+                //淇濆瓨
+                bool bResult;
+                bResult = BillNew.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+
+                if (bResult)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo;  //鎴愬姛锛�
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "妯″叿鏀瑰埗鍑哄簱鍗曚笂浼犲け璐ワ紒" + e.Message;
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+        #endregion
+
+        #region 妯″叿鍏朵粬鍏ュ簱鍗�     涓婁紶鐢熷崟
+
+        /// <summary>
+        /// 妯″叿鍏朵粬鍏ュ簱鍗曟柊澧炰笂浼�
+        /// </summary>
+        /// <returns></returns>
+        [Route("MouldController/set_SaveMouldOtherInBill_Json")]
+        [HttpPost]
+        public object set_SaveMouldOtherInBill_Json([FromBody] JObject oMain)
+        {
+            BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew;
+            DAL.ClsSc_MouldOtherInBill BillNew = new DAL.ClsSc_MouldOtherInBill();
+            var _value = oMain["oMain"].ToString();
+            string msg1 = _value.ToString();
+            try
+            {
+                string sMainStr = "[" + msg1.ToString() + "]";
+                List<Model.ClsSc_MouldOtherInBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsSc_MouldOtherInBillMain>>(sMainStr);
+
+                //鍗曟嵁鍙锋槸鍚﹂噸澶�
+                if (BillNew.IsExistBillNo(ref ClsPub.sExeReturnInfo, mainList[0].HBillNo, BillStatus, mainList[0].HInterID))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁鍙烽噸澶嶏紒涓嶅厑璁镐繚瀛橈紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //鍒ゆ柇浼氳鏈熸槸鍚﹀悎鐞�
+                string s = "";
+                int sYear = 0;
+                int sPeriod = 0;
+                if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(mainList[0].HDate, ref sYear, ref sPeriod, ref s) == false)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = s;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //鍥哄畾璧嬪��=================================
+                BillNew.omodel.HYear = sYear;
+                BillNew.omodel.HPeriod = sPeriod;
+                BillNew.omodel.HBillType = "3827";
+                BillNew.omodel.HInterID = mainList[0].HInterID;
+                BillNew.omodel.HBillNo = mainList[0].HBillNo;
+                BillNew.omodel.HDate = mainList[0].HDate;
+                BillNew.omodel.HRemark = mainList[0].HRemark;
+                BillNew.omodel.HMaker = mainList[0].HMaker;
+                BillNew.omodel.HSTOCKORGID = mainList[0].HSTOCKORGID;
+                DBUtility.ClsPub.CurUserName = mainList[0].HMaker;
+                //====================================================
+                BillNew.omodel.HSupID = mainList[0].HSupID;
+                BillNew.omodel.HSupTypeID = 1; //锛�1 渚涘簲鍟嗐��2 瀹㈡埛銆� 3 杞﹂棿閮ㄩ棬锛�
+                BillNew.omodel.HEmpID = mainList[0].HEmpID;
+                BillNew.omodel.HManagerID = mainList[0].HManagerID;
+                BillNew.omodel.HSecManagerID = mainList[0].HSecManagerID;
+                BillNew.omodel.HKeeperID = mainList[0].HKeeperID;
+                BillNew.omodel.HDeptID = mainList[0].HDeptID;
+                BillNew.omodel.HWHID = mainList[0].HWHID;
+                BillNew.omodel.HSCWHID = mainList[0].HSCWHID;
+                BillNew.omodel.HExplanation = mainList[0].HExplanation;
+                BillNew.omodel.HInnerBillNo = mainList[0].HInnerBillNo;
+                BillNew.omodel.HRedBlueFlag = mainList[0].HRedBlueFlag;
+                //瀛愯〃璧嬪��
+                ds = oCn.RunProcReturn("exec h_p_Sc_GetMouldStockBill_Temp " + BillNew.omodel.HInterID.ToString() + ",'" + BillNew.omodel.HBillType + "'", "h_p_Sc_GetMouldStockBill_Temp");
+                if (ds == null || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "娌℃湁鎵爜淇℃伅锛岃鍏堟壂鎻忔潯鐮侊紝纭鏃犺鍚庡啀鎻愪氦锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
+                    {
+                        Model.ClsSc_MouldStockBillSub oSub = new Model.ClsSc_MouldStockBillSub();
+                        //鍥哄畾璧嬪��========================================
+                        oSub.HEntryID = i + 1;
+                        oSub.HRemark = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HRemark"]);
+                        oSub.HSourceInterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSourceInterID"]);
+                        oSub.HSourceEntryID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSourceEntryID"]);
+                        oSub.HSourceBillType = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HSourceBillType"]);
+                        oSub.HSourceBillNo = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HSourceBillNo"]);
+                        oSub.HRelationQty = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HRelationQty"]);
+                        oSub.HRelationMoney = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HRelationMoney"]);
+                        //=============================
+                        oSub.HMaterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HMaterID"]);
+                        oSub.HPropertyID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HAuxPropID"]);
+                        oSub.HSecUnitID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSecUnitID"]);
+                        oSub.HSecUnitRate = DBUtility.ClsPub.isSingle(ds.Tables[0].Rows[i]["HSecUnitRate"]);
+                        oSub.HUnitID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HUnitID"]);
+                        oSub.HBatchNo = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HBatchNo"]);
+                        oSub.HQtyMust = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HQtyMust"]);
+                        oSub.HQtyRel = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HQtyRel"]);
+                        oSub.HQty = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HQty"]);
+                        oSub.HPrice = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HPrice"]);
+                        oSub.HMoney = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HMoney"]);
+                        oSub.HDesignLife = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HDesignLife"]);
+                        oSub.HLeaveLife = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HLeaveLife"]);
+                        oSub.HUseLife = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HUseLife"]);
+                        oSub.HUseLifeQty = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HUseLifeQty"]);
+                        oSub.HNewLifeQty = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HNewLifeQty"]);
+                        oSub.HWHID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HWHID"]);
+                        oSub.HSCWHID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSCWHID"]);
+                        oSub.HSPID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSPID"]);
+                        oSub.HSCSPID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSCSPID"]);
+                        oSub.HSPGroupID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSPGroupID"]);
+                        oSub.HBarCode = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HBarCode"]);
+                        oSub.HCorrespondentTypeID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HCorrespondentTypeID"]);
+                        oSub.HCorrespondentID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HCorrespondentID"]);
+                        oSub.HPOOrderInterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HPOOrderInterID"]);
+                        oSub.HPOOrderEntryID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HPOOrderEntryID"]);
+                        oSub.HPOOrderBillNo = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HPOOrderBillNo"]);
+                        oSub.HSeOrderInterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSeOrderInterID"]);
+                        oSub.HSeOrderEntryID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSeOrderEntryID"]);
+                        oSub.HSeOrderBillNo = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HSeOrderBillNo"]);
+                        oSub.HStockOrgID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HStockOrgID"]);
+                        oSub.HOWNERID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HOWNERID"]);
+                        oSub.HOtherOrgID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HOtherOrgID"]);
+                        oSub.HOWNERTYPEID = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HOWNERTYPEID"]);
+                        BillNew.DetailColl.Add(oSub);
+                    }
+                }
+                //淇濆瓨
+                bool bResult;
+                bResult = BillNew.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+
+                if (bResult)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo;  //鎴愬姛锛�
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "妯″叿鍏朵粬鍏ュ簱鍗曚笂浼犲け璐ワ紒" + e.Message;
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+        #endregion
+
+        #region 妯″叿鍏朵粬鍑哄簱鍗�     涓婁紶鐢熷崟
+
+        /// <summary>
+        /// 妯″叿鍏朵粬鍑哄簱鍗曟柊澧炰笂浼�
+        /// </summary>
+        /// <returns></returns>
+        [Route("MouldController/set_SaveMouldOtherOutBill_Json")]
+        [HttpPost]
+        public object set_SaveMouldOtherOutBill_Json([FromBody] JObject oMain)
+        {
+            BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew;
+            DAL.ClsSc_MouldOtherOutBill BillNew = new DAL.ClsSc_MouldOtherOutBill();
+            var _value = oMain["oMain"].ToString();
+            string msg1 = _value.ToString();
+            try
+            {
+                string sMainStr = "[" + msg1.ToString() + "]";
+                List<Model.ClsSc_MouldOtherOutBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsSc_MouldOtherOutBillMain>>(sMainStr);
+
+                //鍗曟嵁鍙锋槸鍚﹂噸澶�
+                if (BillNew.IsExistBillNo(ref ClsPub.sExeReturnInfo, mainList[0].HBillNo, BillStatus, mainList[0].HInterID))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁鍙烽噸澶嶏紒涓嶅厑璁镐繚瀛橈紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //鍒ゆ柇浼氳鏈熸槸鍚﹀悎鐞�
+                string s = "";
+                int sYear = 0;
+                int sPeriod = 0;
+                if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(mainList[0].HDate, ref sYear, ref sPeriod, ref s) == false)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = s;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //鍥哄畾璧嬪��=================================
+                BillNew.omodel.HYear = sYear;
+                BillNew.omodel.HPeriod = sPeriod;
+                BillNew.omodel.HBillType = "3828";
+                BillNew.omodel.HInterID = mainList[0].HInterID;
+                BillNew.omodel.HBillNo = mainList[0].HBillNo;
+                BillNew.omodel.HDate = mainList[0].HDate;
+                BillNew.omodel.HRemark = mainList[0].HRemark;
+                BillNew.omodel.HMaker = mainList[0].HMaker;
+                BillNew.omodel.HSTOCKORGID = mainList[0].HSTOCKORGID;
+                DBUtility.ClsPub.CurUserName = mainList[0].HMaker;
+                //====================================================
+                BillNew.omodel.HSupID = mainList[0].HSupID;
+                BillNew.omodel.HSupTypeID = 1; //锛�1 渚涘簲鍟嗐��2 瀹㈡埛銆� 3 杞﹂棿閮ㄩ棬锛�
+                BillNew.omodel.HEmpID = mainList[0].HEmpID;
+                BillNew.omodel.HManagerID = mainList[0].HManagerID;
+                BillNew.omodel.HSecManagerID = mainList[0].HSecManagerID;
+                BillNew.omodel.HKeeperID = mainList[0].HKeeperID;
+                BillNew.omodel.HDeptID = mainList[0].HDeptID;
+                BillNew.omodel.HWHID = mainList[0].HWHID;
+                BillNew.omodel.HSCWHID = mainList[0].HSCWHID;
+                BillNew.omodel.HExplanation = mainList[0].HExplanation;
+                BillNew.omodel.HInnerBillNo = mainList[0].HInnerBillNo;
+                BillNew.omodel.HRedBlueFlag = mainList[0].HRedBlueFlag;
+                //瀛愯〃璧嬪��
+                ds = oCn.RunProcReturn("exec h_p_Sc_GetMouldStockBill_Temp " + BillNew.omodel.HInterID.ToString() + ",'" + BillNew.omodel.HBillType + "'", "h_p_Sc_GetMouldStockBill_Temp");
+                if (ds == null || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "娌℃湁鎵爜淇℃伅锛岃鍏堟壂鎻忔潯鐮侊紝纭鏃犺鍚庡啀鎻愪氦锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
+                    {
+                        Model.ClsSc_MouldStockBillSub oSub = new Model.ClsSc_MouldStockBillSub();
+                        //鍥哄畾璧嬪��========================================
+                        oSub.HEntryID = i + 1;
+                        oSub.HRemark = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HRemark"]);
+                        oSub.HSourceInterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSourceInterID"]);
+                        oSub.HSourceEntryID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSourceEntryID"]);
+                        oSub.HSourceBillType = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HSourceBillType"]);
+                        oSub.HSourceBillNo = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HSourceBillNo"]);
+                        oSub.HRelationQty = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HRelationQty"]);
+                        oSub.HRelationMoney = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HRelationMoney"]);
+                        //=============================
+                        oSub.HMaterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HMaterID"]);
+                        oSub.HPropertyID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HAuxPropID"]);
+                        oSub.HSecUnitID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSecUnitID"]);
+                        oSub.HSecUnitRate = DBUtility.ClsPub.isSingle(ds.Tables[0].Rows[i]["HSecUnitRate"]);
+                        oSub.HUnitID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HUnitID"]);
+                        oSub.HBatchNo = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HBatchNo"]);
+                        oSub.HQtyMust = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HQtyMust"]);
+                        oSub.HQtyRel = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HQtyRel"]);
+                        oSub.HQty = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HQty"]);
+                        oSub.HPrice = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HPrice"]);
+                        oSub.HMoney = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HMoney"]);
+                        oSub.HDesignLife = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HDesignLife"]);
+                        oSub.HLeaveLife = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HLeaveLife"]);
+                        oSub.HUseLife = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HUseLife"]);
+                        oSub.HUseLifeQty = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HUseLifeQty"]);
+                        oSub.HNewLifeQty = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HNewLifeQty"]);
+                        oSub.HWHID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HWHID"]);
+                        oSub.HSCWHID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSCWHID"]);
+                        oSub.HSPID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSPID"]);
+                        oSub.HSCSPID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSCSPID"]);
+                        oSub.HSPGroupID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSPGroupID"]);
+                        oSub.HBarCode = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HBarCode"]);
+                        oSub.HCorrespondentTypeID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HCorrespondentTypeID"]);
+                        oSub.HCorrespondentID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HCorrespondentID"]);
+                        oSub.HPOOrderInterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HPOOrderInterID"]);
+                        oSub.HPOOrderEntryID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HPOOrderEntryID"]);
+                        oSub.HPOOrderBillNo = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HPOOrderBillNo"]);
+                        oSub.HSeOrderInterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSeOrderInterID"]);
+                        oSub.HSeOrderEntryID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSeOrderEntryID"]);
+                        oSub.HSeOrderBillNo = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HSeOrderBillNo"]);
+                        oSub.HStockOrgID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HStockOrgID"]);
+                        oSub.HOWNERID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HOWNERID"]);
+                        oSub.HOtherOrgID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HOtherOrgID"]);
+                        oSub.HOWNERTYPEID = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HOWNERTYPEID"]);
+                        BillNew.DetailColl.Add(oSub);
+                    }
+                }
+                //淇濆瓨
+                bool bResult;
+                bResult = BillNew.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+
+                if (bResult)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo;  //鎴愬姛锛�
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "妯″叿鍏朵粬鍑哄簱鍗曚笂浼犲け璐ワ紒" + e.Message;
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+        #endregion
+
+        #region 妯″叿鎶ュ簾鍏ュ簱鍗�     涓婁紶鐢熷崟
+
+        /// <summary>
+        /// 妯″叿鎶ュ簾鍏ュ簱鍗曟柊澧炰笂浼�
+        /// </summary>
+        /// <returns></returns>
+        [Route("MouldController/set_SaveMouldScrapInBill_Json")]
+        [HttpPost]
+        public object set_SaveMouldScrapInBill_Json([FromBody] JObject oMain)
+        {
+            BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew;
+            DAL.ClsSc_MouldScrapInBill BillNew = new DAL.ClsSc_MouldScrapInBill();
+            var _value = oMain["oMain"].ToString();
+            string msg1 = _value.ToString();
+            try
+            {
+                string sMainStr = "[" + msg1.ToString() + "]";
+                List<Model.ClsSc_MouldScrapInBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsSc_MouldScrapInBillMain>>(sMainStr);
+
+                //鍗曟嵁鍙锋槸鍚﹂噸澶�
+                if (BillNew.IsExistBillNo(ref ClsPub.sExeReturnInfo, mainList[0].HBillNo, BillStatus, mainList[0].HInterID))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁鍙烽噸澶嶏紒涓嶅厑璁镐繚瀛橈紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //鍒ゆ柇浼氳鏈熸槸鍚﹀悎鐞�
+                string s = "";
+                int sYear = 0;
+                int sPeriod = 0;
+                if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(mainList[0].HDate, ref sYear, ref sPeriod, ref s) == false)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = s;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //鍥哄畾璧嬪��=================================
+                BillNew.omodel.HYear = sYear;
+                BillNew.omodel.HPeriod = sPeriod;
+                BillNew.omodel.HBillType = "3831";
+                BillNew.omodel.HInterID = mainList[0].HInterID;
+                BillNew.omodel.HBillNo = mainList[0].HBillNo;
+                BillNew.omodel.HDate = mainList[0].HDate;
+                BillNew.omodel.HRemark = mainList[0].HRemark;
+                BillNew.omodel.HMaker = mainList[0].HMaker;
+                BillNew.omodel.HSTOCKORGID = mainList[0].HSTOCKORGID;
+                DBUtility.ClsPub.CurUserName = mainList[0].HMaker;
+                //====================================================
+                BillNew.omodel.HSupID = mainList[0].HSupID;
+                BillNew.omodel.HSupTypeID = 1; //锛�1 渚涘簲鍟嗐��2 瀹㈡埛銆� 3 杞﹂棿閮ㄩ棬锛�
+                BillNew.omodel.HEmpID = mainList[0].HEmpID;
+                BillNew.omodel.HManagerID = mainList[0].HManagerID;
+                BillNew.omodel.HSecManagerID = mainList[0].HSecManagerID;
+                BillNew.omodel.HKeeperID = mainList[0].HKeeperID;
+                BillNew.omodel.HDeptID = mainList[0].HDeptID;
+                BillNew.omodel.HWHID = mainList[0].HWHID;
+                BillNew.omodel.HSCWHID = mainList[0].HSCWHID;
+                BillNew.omodel.HExplanation = mainList[0].HExplanation;
+                BillNew.omodel.HInnerBillNo = mainList[0].HInnerBillNo;
+                BillNew.omodel.HRedBlueFlag = mainList[0].HRedBlueFlag;
+                //瀛愯〃璧嬪��
+                ds = oCn.RunProcReturn("exec h_p_Sc_GetMouldStockBill_Temp " + BillNew.omodel.HInterID.ToString() + ",'" + BillNew.omodel.HBillType + "'", "h_p_Sc_GetMouldStockBill_Temp");
+                if (ds == null || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "娌℃湁鎵爜淇℃伅锛岃鍏堟壂鎻忔潯鐮侊紝纭鏃犺鍚庡啀鎻愪氦锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
+                    {
+                        Model.ClsSc_MouldStockBillSub oSub = new Model.ClsSc_MouldStockBillSub();
+                        //鍥哄畾璧嬪��========================================
+                        oSub.HEntryID = i + 1;
+                        oSub.HRemark = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HRemark"]);
+                        oSub.HSourceInterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSourceInterID"]);
+                        oSub.HSourceEntryID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSourceEntryID"]);
+                        oSub.HSourceBillType = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HSourceBillType"]);
+                        oSub.HSourceBillNo = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HSourceBillNo"]);
+                        oSub.HRelationQty = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HRelationQty"]);
+                        oSub.HRelationMoney = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HRelationMoney"]);
+                        //=============================
+                        oSub.HMaterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HMaterID"]);
+                        oSub.HPropertyID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HAuxPropID"]);
+                        oSub.HSecUnitID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSecUnitID"]);
+                        oSub.HSecUnitRate = DBUtility.ClsPub.isSingle(ds.Tables[0].Rows[i]["HSecUnitRate"]);
+                        oSub.HUnitID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HUnitID"]);
+                        oSub.HBatchNo = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HBatchNo"]);
+                        oSub.HQtyMust = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HQtyMust"]);
+                        oSub.HQtyRel = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HQtyRel"]);
+                        oSub.HQty = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HQty"]);
+                        oSub.HPrice = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HPrice"]);
+                        oSub.HMoney = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HMoney"]);
+                        oSub.HDesignLife = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HDesignLife"]);
+                        oSub.HLeaveLife = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HLeaveLife"]);
+                        oSub.HUseLife = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HUseLife"]);
+                        oSub.HUseLifeQty = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HUseLifeQty"]);
+                        oSub.HNewLifeQty = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HNewLifeQty"]);
+                        oSub.HWHID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HWHID"]);
+                        oSub.HSCWHID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSCWHID"]);
+                        oSub.HSPID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSPID"]);
+                        oSub.HSCSPID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSCSPID"]);
+                        oSub.HSPGroupID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSPGroupID"]);
+                        oSub.HBarCode = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HBarCode"]);
+                        oSub.HCorrespondentTypeID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HCorrespondentTypeID"]);
+                        oSub.HCorrespondentID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HCorrespondentID"]);
+                        oSub.HPOOrderInterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HPOOrderInterID"]);
+                        oSub.HPOOrderEntryID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HPOOrderEntryID"]);
+                        oSub.HPOOrderBillNo = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HPOOrderBillNo"]);
+                        oSub.HSeOrderInterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSeOrderInterID"]);
+                        oSub.HSeOrderEntryID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSeOrderEntryID"]);
+                        oSub.HSeOrderBillNo = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HSeOrderBillNo"]);
+                        oSub.HStockOrgID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HStockOrgID"]);
+                        oSub.HOWNERID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HOWNERID"]);
+                        oSub.HOtherOrgID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HOtherOrgID"]);
+                        oSub.HOWNERTYPEID = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HOWNERTYPEID"]);
+                        BillNew.DetailColl.Add(oSub);
+                    }
+                }
+                //淇濆瓨
+                bool bResult;
+                bResult = BillNew.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+
+                if (bResult)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo;  //鎴愬姛锛�
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "妯″叿鎶ュ簾鍏ュ簱鍗曚笂浼犲け璐ワ紒" + e.Message;
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+        #endregion
+
+        #region 妯″叿鎶ュ簾鍑哄簱鍗�     涓婁紶鐢熷崟
+
+        /// <summary>
+        /// 妯″叿鎶ュ簾鍑哄簱鍗曟柊澧炰笂浼�
+        /// </summary>
+        /// <returns></returns>
+        [Route("MouldController/set_SaveMouldScrapOutBill_Json")]
+        [HttpPost]
+        public object set_SaveMouldScrapOutBill_Json([FromBody] JObject oMain)
+        {
+            BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew;
+            DAL.ClsSc_MouldScrapOutBill BillNew = new DAL.ClsSc_MouldScrapOutBill();
+            var _value = oMain["oMain"].ToString();
+            string msg1 = _value.ToString();
+            try
+            {
+                string sMainStr = "[" + msg1.ToString() + "]";
+                List<Model.ClsSc_MouldStockBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsSc_MouldStockBillMain>>(sMainStr);
+
+                //鍗曟嵁鍙锋槸鍚﹂噸澶�
+                if (BillNew.IsExistBillNo(ref ClsPub.sExeReturnInfo, mainList[0].HBillNo, BillStatus, mainList[0].HInterID))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁鍙烽噸澶嶏紒涓嶅厑璁镐繚瀛橈紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //鍒ゆ柇浼氳鏈熸槸鍚﹀悎鐞�
+                string s = "";
+                int sYear = 0;
+                int sPeriod = 0;
+                if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(mainList[0].HDate, ref sYear, ref sPeriod, ref s) == false)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = s;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //鍥哄畾璧嬪��=================================
+                BillNew.omodel.HYear = sYear;
+                BillNew.omodel.HPeriod = sPeriod;
+                BillNew.omodel.HBillType = "3832";
+                BillNew.omodel.HInterID = mainList[0].HInterID;
+                BillNew.omodel.HBillNo = mainList[0].HBillNo;
+                BillNew.omodel.HDate = mainList[0].HDate;
+                BillNew.omodel.HRemark = mainList[0].HRemark;
+                BillNew.omodel.HMaker = mainList[0].HMaker;
+                BillNew.omodel.HSTOCKORGID = mainList[0].HSTOCKORGID;
+                DBUtility.ClsPub.CurUserName = mainList[0].HMaker;
+                //====================================================
+                BillNew.omodel.HSupID = mainList[0].HSupID;
+                BillNew.omodel.HSupTypeID = 1; //锛�1 渚涘簲鍟嗐��2 瀹㈡埛銆� 3 杞﹂棿閮ㄩ棬锛�
+                BillNew.omodel.HEmpID = mainList[0].HEmpID;
+                BillNew.omodel.HManagerID = mainList[0].HManagerID;
+                BillNew.omodel.HSecManagerID = mainList[0].HSecManagerID;
+                BillNew.omodel.HKeeperID = mainList[0].HKeeperID;
+                BillNew.omodel.HDeptID = mainList[0].HDeptID;
+                BillNew.omodel.HWHID = mainList[0].HWHID;
+                BillNew.omodel.HSCWHID = mainList[0].HSCWHID;
+                BillNew.omodel.HExplanation = mainList[0].HExplanation;
+                BillNew.omodel.HInnerBillNo = mainList[0].HInnerBillNo;
+                BillNew.omodel.HRedBlueFlag = mainList[0].HRedBlueFlag;
+                //瀛愯〃璧嬪��
+                ds = oCn.RunProcReturn("exec h_p_Sc_GetMouldStockBill_Temp " + BillNew.omodel.HInterID.ToString() + ",'" + BillNew.omodel.HBillType + "'", "h_p_Sc_GetMouldStockBill_Temp");
+                if (ds == null || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "娌℃湁鎵爜淇℃伅锛岃鍏堟壂鎻忔潯鐮侊紝纭鏃犺鍚庡啀鎻愪氦锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
+                    {
+                        Model.ClsSc_MouldStockBillSub oSub = new Model.ClsSc_MouldStockBillSub();
+                        //鍥哄畾璧嬪��========================================
+                        oSub.HEntryID = i + 1;
+                        oSub.HRemark = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HRemark"]);
+                        oSub.HSourceInterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSourceInterID"]);
+                        oSub.HSourceEntryID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSourceEntryID"]);
+                        oSub.HSourceBillType = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HSourceBillType"]);
+                        oSub.HSourceBillNo = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HSourceBillNo"]);
+                        oSub.HRelationQty = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HRelationQty"]);
+                        oSub.HRelationMoney = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HRelationMoney"]);
+                        //=============================
+                        oSub.HMaterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HMaterID"]);
+                        oSub.HPropertyID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HAuxPropID"]);
+                        oSub.HSecUnitID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSecUnitID"]);
+                        oSub.HSecUnitRate = DBUtility.ClsPub.isSingle(ds.Tables[0].Rows[i]["HSecUnitRate"]);
+                        oSub.HUnitID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HUnitID"]);
+                        oSub.HBatchNo = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HBatchNo"]);
+                        oSub.HQtyMust = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HQtyMust"]);
+                        oSub.HQtyRel = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HQtyRel"]);
+                        oSub.HQty = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HQty"]);
+                        oSub.HPrice = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HPrice"]);
+                        oSub.HMoney = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HMoney"]);
+                        oSub.HDesignLife = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HDesignLife"]);
+                        oSub.HLeaveLife = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HLeaveLife"]);
+                        oSub.HUseLife = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HUseLife"]);
+                        oSub.HUseLifeQty = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HUseLifeQty"]);
+                        oSub.HNewLifeQty = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HNewLifeQty"]);
+                        oSub.HWHID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HWHID"]);
+                        oSub.HSCWHID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSCWHID"]);
+                        oSub.HSPID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSPID"]);
+                        oSub.HSCSPID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSCSPID"]);
+                        oSub.HSPGroupID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSPGroupID"]);
+                        oSub.HBarCode = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HBarCode"]);
+                        oSub.HCorrespondentTypeID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HCorrespondentTypeID"]);
+                        oSub.HCorrespondentID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HCorrespondentID"]);
+                        oSub.HPOOrderInterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HPOOrderInterID"]);
+                        oSub.HPOOrderEntryID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HPOOrderEntryID"]);
+                        oSub.HPOOrderBillNo = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HPOOrderBillNo"]);
+                        oSub.HSeOrderInterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSeOrderInterID"]);
+                        oSub.HSeOrderEntryID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSeOrderEntryID"]);
+                        oSub.HSeOrderBillNo = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HSeOrderBillNo"]);
+                        oSub.HStockOrgID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HStockOrgID"]);
+                        oSub.HOWNERID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HOWNERID"]);
+                        oSub.HOtherOrgID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HOtherOrgID"]);
+                        oSub.HOWNERTYPEID = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HOWNERTYPEID"]);
+                        BillNew.DetailColl.Add(oSub);
+                    }
+                }
+                //淇濆瓨
+                bool bResult;
+                bResult = BillNew.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+
+                if (bResult)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo;  //鎴愬姛锛�
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "妯″叿鎶ュ簾鍑哄簱鍗曚笂浼犲け璐ワ紒" + e.Message;
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+        #endregion
+
+        #region 妯″叿璋冩嫧鍗�     涓婁紶鐢熷崟
+
+        /// <summary>
+        /// 妯″叿璋冩嫧鍗曟柊澧炰笂浼�
+        /// </summary>
+        /// <returns></returns>
+        [Route("MouldController/set_SaveMouldProdMoveBill_Json")]
+        [HttpPost]
+        public object set_SaveMouldProdMoveBill_Json([FromBody] JObject oMain)
+        {
+            BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew;
+            DAL.ClsSc_MouldProdMoveBill BillNew = new DAL.ClsSc_MouldProdMoveBill();
+            var _value = oMain["oMain"].ToString();
+            string msg1 = _value.ToString();
+            try
+            {
+                string sMainStr = "[" + msg1.ToString() + "]";
+                List<Model.ClsSc_MouldProdMoveBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsSc_MouldProdMoveBillMain>>(sMainStr);
+
+                //鍗曟嵁鍙锋槸鍚﹂噸澶�
+                if (BillNew.IsExistBillNo(ref ClsPub.sExeReturnInfo, mainList[0].HBillNo, BillStatus, mainList[0].HInterID))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁鍙烽噸澶嶏紒涓嶅厑璁镐繚瀛橈紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //鍒ゆ柇浼氳鏈熸槸鍚﹀悎鐞�
+                string s = "";
+                int sYear = 0;
+                int sPeriod = 0;
+                if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(mainList[0].HDate, ref sYear, ref sPeriod, ref s) == false)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = s;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //鍥哄畾璧嬪��=================================
+                BillNew.omodel.HYear = sYear;
+                BillNew.omodel.HPeriod = sPeriod;
+                BillNew.omodel.HBillType = "3814";
+                BillNew.omodel.HInterID = mainList[0].HInterID;
+                BillNew.omodel.HBillNo = mainList[0].HBillNo;
+                BillNew.omodel.HDate = mainList[0].HDate;
+                BillNew.omodel.HRemark = mainList[0].HRemark;
+                BillNew.omodel.HMaker = mainList[0].HMaker;
+                BillNew.omodel.HSTOCKORGID = mainList[0].HStockInOrgID;
+                DBUtility.ClsPub.CurUserName = mainList[0].HMaker;
+                //====================================================
+                BillNew.omodel.HSupID = mainList[0].HSupID;
+                BillNew.omodel.HSupTypeID = mainList[0].HSupTypeID;
+                BillNew.omodel.HEmpID = mainList[0].HEmpID;
+                BillNew.omodel.HManagerID = mainList[0].HManagerID;
+                BillNew.omodel.HSecManagerID = mainList[0].HSecManagerID;
+                BillNew.omodel.HKeeperID = mainList[0].HKeeperID;
+                BillNew.omodel.HDeptID = mainList[0].HDeptID;
+                BillNew.omodel.HWHID = mainList[0].HWHID;
+                BillNew.omodel.HSCWHID = mainList[0].HSCWHID;
+                BillNew.omodel.HExplanation = mainList[0].HExplanation;
+                BillNew.omodel.HInnerBillNo = mainList[0].HInnerBillNo;
+                BillNew.omodel.HRedBlueFlag = mainList[0].HRedBlueFlag;
+                BillNew.omodel.HStockStyle = mainList[0].HStockStyle;
+                BillNew.omodel.HStockInOrgID = mainList[0].HStockInOrgID;
+                BillNew.omodel.HStockOutOrgID = mainList[0].HStockOutOrgID;
+                //瀛愯〃璧嬪��
+                ds = oCn.RunProcReturn("exec h_p_Sc_GetMouldStockBill_Temp " + BillNew.omodel.HInterID.ToString() + ",'" + BillNew.omodel.HBillType + "'", "h_p_Sc_GetMouldStockBill_Temp");
+                if (ds == null || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "娌℃湁鎵爜淇℃伅锛岃鍏堟壂鎻忔潯鐮侊紝纭鏃犺鍚庡啀鎻愪氦锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
+                    {
+                        Model.ClsSc_MouldProdMoveBillSub oSub = new Model.ClsSc_MouldProdMoveBillSub();
+                        //鍥哄畾璧嬪��========================================
+                        oSub.HEntryID = i + 1;
+                        oSub.HRemark = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HRemark"]);
+                        oSub.HSourceInterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSourceInterID"]);
+                        oSub.HSourceEntryID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSourceEntryID"]);
+                        oSub.HSourceBillType = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HSourceBillType"]);
+                        oSub.HSourceBillNo = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HSourceBillNo"]);
+                        oSub.HRelationQty = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HRelationQty"]);
+                        oSub.HRelationMoney = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HRelationMoney"]);
+                        //=============================
+                        oSub.HMaterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HMaterID"]);
+                        oSub.HPropertyID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HAuxPropID"]);
+                        oSub.HSecUnitID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSecUnitID"]);
+                        oSub.HSecUnitRate = DBUtility.ClsPub.isSingle(ds.Tables[0].Rows[i]["HSecUnitRate"]);
+                        oSub.HUnitID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HUnitID"]);
+                        oSub.HBatchNo = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HBatchNo"]);
+                        oSub.HQtyMust = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HQtyMust"]);
+                        oSub.HQtyRel = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HQtyRel"]);
+                        oSub.HQty = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HQty"]);
+                        oSub.HPrice = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HPrice"]);
+                        oSub.HMoney = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HMoney"]);
+                        oSub.HDesignLife = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HDesignLife"]);
+                        oSub.HLeaveLife = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HLeaveLife"]);
+                        oSub.HUseLife = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HUseLife"]);
+                        oSub.HUseLifeQty = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HUseLifeQty"]);
+                        oSub.HNewLifeQty = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[i]["HNewLifeQty"]);
+                        oSub.HWHID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HWHID"]);
+                        oSub.HSCWHID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSCWHID"]);
+                        oSub.HSPID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSPID"]);
+                        oSub.HSCSPID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSCSPID"]);
+                        oSub.HSPGroupID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSPGroupID"]);
+                        oSub.HBarCode = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HBarCode"]);
+                        oSub.HCorrespondentTypeID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HCorrespondentTypeID"]);
+                        oSub.HCorrespondentID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HCorrespondentID"]);
+                        oSub.HPOOrderInterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HPOOrderInterID"]);
+                        oSub.HPOOrderEntryID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HPOOrderEntryID"]);
+                        oSub.HPOOrderBillNo = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HPOOrderBillNo"]);
+                        oSub.HSeOrderInterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSeOrderInterID"]);
+                        oSub.HSeOrderEntryID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HSeOrderEntryID"]);
+                        oSub.HSeOrderBillNo = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HSeOrderBillNo"]);
+                        oSub.HStockOrgID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HStockOrgID"]);
+                        oSub.HOWNERID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HOWNERID"]);
+                        oSub.HOtherOrgID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HOtherOrgID"]);
+                        oSub.HOWNERTYPEID = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HOWNERTYPEID"]);
+                        BillNew.DetailColl.Add(oSub);
+                    }
+                }
+                //淇濆瓨
+                bool bResult;
+                bResult = BillNew.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+
+                if (bResult)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo;  //鎴愬姛锛�
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "妯″叿璋冩嫧鍗曚笂浼犲け璐ワ紒" + e.Message;
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+        #endregion
+
 
 
         #endregion

--
Gitblit v1.9.1