From 7cea3d81578e44569d1dfd250172dee5f2b64a21 Mon Sep 17 00:00:00 2001
From: 王 垚 <1402714037@qq.com>
Date: 星期三, 17 十一月 2021 16:45:27 +0800
Subject: [PATCH] 生产领料单

---
 WebAPI/ListModels.cs                                        |   26 
 WebAPI/Models/ClsKf_MateOutBillMain.cs                      |   21 
 WebAPI/DLL/ClsKf_MateOutBill.cs                             |  498 +++++++++++++++
 WebAPI/Models/ClsKf_MateOutBillScheme.cs                    |   29 
 WebAPI/Models/ClsKf_ICStockBillMain.cs                      |   53 +
 WebAPI/DLL/ClsKf_MateOutBackBill.cs                         |  386 ++++++++++++
 WebAPI/Models/ClsKf_ICStockBillScheme.cs                    |   23 
 WebAPI/Models/ClsKf_MateOutBillSub.cs                       |   34 +
 WebAPI/Models/ClsKf_ICStockBillSub.cs                       |   71 ++
 WebAPI/Controllers/Sc_MouldRepairInBillListController - .cs |   38 -
 WebAPI/Controllers/仓存管理/Kf_MateOutBillController.cs         |  701 +++++++++++++++++++++
 11 files changed, 1,842 insertions(+), 38 deletions(-)

diff --git a/WebAPI/Controllers/Sc_MouldRepairInBillListController - .cs b/WebAPI/Controllers/Sc_MouldRepairInBillListController - .cs
index 15d78f7..9eae8a3 100644
--- a/WebAPI/Controllers/Sc_MouldRepairInBillListController - .cs
+++ b/WebAPI/Controllers/Sc_MouldRepairInBillListController - .cs
@@ -791,44 +791,6 @@
             return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_IF_MoveStockBillList order by 鏃ユ湡 desc", "h_v_IF_MoveStockBillList");
         }
         #endregion
-
-        /// <summary>
-        /// 鐢熶骇棰嗘枡鍗曞垪琛�
-        /// </summary>
-        /// <returns></returns>
-        [Route("Kf_MateOutBill/GetMateOutBillList")]
-        [HttpGet]
-        public object GetMateOutBillList(string sWhere)
-        {
-            try
-            {
-                ds = Sc_GetMateOutBillList(sWhere);
-                objJsonResult.code = "1";
-                objJsonResult.count = 1;
-                objJsonResult.Message = "杩斿洖璁板綍鎴愬姛锛�";
-                objJsonResult.data = ds.Tables[0];
-                return objJsonResult;
-            }
-            catch (Exception ex)
-            {
-                objJsonResult.code = "0";
-                objJsonResult.count = 0;
-                objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + ex.ToString();
-                objJsonResult.data = null;
-                return objJsonResult;
-            }
-        }
-
-        #region sql璇彞
-
-
-        public static DataSet Sc_GetMateOutBillList(string sWhere)
-        {
-            return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_IF_MateOutBillList order by 鏃ユ湡 desc", "h_v_IF_MateOutBillList");
-        }
-        #endregion
-
-
         /// <summary>
         /// 閿�鍞嚭搴撳崟鍒楄〃
         /// </summary>
diff --git "a/WebAPI/Controllers/\344\273\223\345\255\230\347\256\241\347\220\206/Kf_MateOutBillController.cs" "b/WebAPI/Controllers/\344\273\223\345\255\230\347\256\241\347\220\206/Kf_MateOutBillController.cs"
new file mode 100644
index 0000000..851281a
--- /dev/null
+++ "b/WebAPI/Controllers/\344\273\223\345\255\230\347\256\241\347\220\206/Kf_MateOutBillController.cs"
@@ -0,0 +1,701 @@
+锘縰sing DBUtility;
+using Newtonsoft.Json.Linq;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Net;
+using System.Net.Http;
+using System.Web.Http;
+using WebAPI.Models;
+
+namespace WebAPI.Controllers
+{
+    public class Kf_MateOutBillController : ApiController
+    {
+        public DBUtility.ClsPub.Enum_BillStatus BillStatus;//鍗曟嵁鐘舵�侊紙鏂板锛屼慨鏀癸紝娴忚锛屾洿鏂板崟浠凤紝鍙樻洿锛�
+        private json objJsonResult = new json();
+        public DataSet ds = new DataSet();
+        public SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
+        public DLL.ClsKf_MateOutBill BillNew0 = new DLL.ClsKf_MateOutBill();   //妯″叿鎶ュ簾鍏ュ簱瀵瑰簲鍗曟嵁绫�
+        public DLL.ClsKf_MateOutBill BillOld0 = new DLL.ClsKf_MateOutBill();   //妯″叿鎶ュ簾鍏ュ簱瀵瑰簲鍗曟嵁绫�
+
+        #region 鐢熶骇棰嗘枡鍗曞垪琛�
+
+        [Route("Kf_MateOutBill/GetMateOutBillList")]
+        [HttpGet]
+        public object GetMateOutBillList(string sWhere)
+        {
+            try
+            {
+                ds = oCn.RunProcReturn("select * from h_v_IF_MateOutBillList order by 鏃ユ湡 desc", "h_v_IF_MateOutBillList");
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "杩斿洖璁板綍鎴愬姛锛�";
+                objJsonResult.data = ds.Tables[0];
+                return objJsonResult;
+            }
+            catch (Exception ex)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + ex.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+        #endregion
+
+        #region [鐢熶骇棰嗘枡鍗曞垹闄ゅ姛鑳絔
+        /// <summary>
+        /// 鐢熶骇棰嗘枡鍗曞垹闄ゅ姛鑳�
+        /// </summary>
+        /// <returns></returns>
+        [Route("Sc_MouldProdInBill/set_DeleteBill")]
+        [HttpGet]
+        public object set_DeleteBill(string HInterID,string user)
+        {
+            //缂栬緫鏉冮檺
+            if (!DBUtility.ClsPub.Security_Log_second("Sc_MouldProdInBill_Delete", 1, true, user))
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+
+            string s = "";
+            Int64 lngBillKey = 0;
+            lngBillKey = DBUtility.ClsPub.isLong(HInterID);
+            if (lngBillKey == 0)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鍗曟嵁ID涓虹┖锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            DLL.ClsSc_MouldProdInBill oBill = new DLL.ClsSc_MouldProdInBill();
+            if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))
+            {
+                if (oBill.omodel.HBillStatus > 1)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁褰撳墠澶勪簬涓嶈兘鍒犻櫎鐘舵��,涓嶈兘鍒犻櫎锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                if (oBill.omodel.HChecker != ""&& oBill.omodel.HChecker !=null)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁宸茬粡瀹℃牳,涓嶈兘鍒犻櫎锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                if (!DBUtility.Xt_BaseBillFun.Fun_AllowDeleteBill(oBill, ref s))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = s + "锛屼笉鍏佽鍒犻櫎";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                bool IsDete = oBill.DeleteBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo);
+                if (IsDete)
+                {
+                    objJsonResult.code = "1";
+                    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;
+                }
+            }
+            else
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鍗曟嵁鏈壘鍒�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+        #endregion
+
+        #region [鐢熶骇棰嗘枡鍗曞鏍搞�佸弽瀹℃牳]
+        /// <summary>
+        /// 瀹℃牳
+        /// </summary>
+        /// <param name="HInterID">鍗曟嵁ID</param>
+        /// <param name="CurUserName">瀹℃牳浜�</param>
+        /// <returns></returns>
+        [Route("Sc_MouldProdInBill/set_CheckBill")]
+        [HttpGet]
+        public object set_CheckBill(int HInterID, string CurUserName)
+        {
+            string ModRightNameCheck = "Sc_MouldProdInBill_Check";
+            DBUtility.ClsPub.CurUserName = CurUserName;
+            DLL.ClsSc_MouldProdInBill oBill = new DLL.ClsSc_MouldProdInBill();
+            try
+            {
+                //瀹℃牳鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, true, CurUserName))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "瀹℃牳澶辫触锛佹棤鏉冮檺锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //瀹℃牳鍓嶅垽鏂槸鍚﹀厑璁�
+                string s = "";
+                if (!DBUtility.Xt_BaseBillFun.Fun_AllowCheckBill(oBill, ref s))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = s + "锛屼笉鍏佽瀹℃牳";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                if (HInterID <= 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HInterID灏忎簬0锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                Int64 lngBillKey = 0;
+                lngBillKey = DBUtility.ClsPub.isLong(HInterID);
+                //鏌ョ湅鏄惁宸插鏍�,鍏抽棴,浣滃簾
+                if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))
+                {
+                    if (oBill.omodel.HCloseMan.Trim() != "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁宸插叧闂�!涓嶈兘鍐嶆瀹℃牳锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (oBill.omodel.HDeleteMan.Trim() != "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘鍐嶆瀹℃牳锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (oBill.omodel.HChecker.Trim() != "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶈兘鍐嶆瀹℃牳锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //瀹℃牳鎻愪氦
+                if (oBill.CheckBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                {
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "瀹℃牳鎴愬姛";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "瀹℃牳澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        /// <summary>
+        /// 鍙嶅鏍�
+        /// </summary>
+        /// <param name="HInterID">鍗曟嵁ID</param>
+        /// <param name="CurUserName">瀹℃牳浜�</param>
+        /// <returns></returns>
+        [Route("Sc_MouldProdInBill/set_AbandonCheck")]
+        [HttpGet]
+        public object set_AbandonCheck(int HInterID, string CurUserName)
+        {
+            string ModRightNameCheck = "Sc_MouldProdInBill_Check";
+            DBUtility.ClsPub.CurUserName = CurUserName;
+            DLL.ClsSc_MouldProdInBill oBill = new DLL.ClsSc_MouldProdInBill();
+            try
+            {
+                //瀹℃牳鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, true, CurUserName))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍙嶅鏍稿け璐ワ紒鏃犳潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //鍙嶅鏍稿墠鍒ゆ柇
+                string s = "";
+                if (!DBUtility.Xt_BaseBillFun.Fun_AllowCheckBill(oBill, ref s))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = s + "锛屼笉鍏佽鍙嶅鏍�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                if (HInterID <= 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HInterID灏忎簬0锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                Int64 lngBillKey = 0;
+                lngBillKey = DBUtility.ClsPub.isLong(HInterID);
+                //鏌ョ湅鏄惁宸插鏍�,鍏抽棴,浣滃簾
+                if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))
+                {
+                    if (oBill.omodel.HCloseMan.Trim() != "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁宸插叧闂�!涓嶈兘鍐嶆鍙嶅鏍革紒";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (oBill.omodel.HDeleteMan.Trim() != "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘鍐嶆鍙嶅鏍革紒";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (oBill.omodel.HChecker.Trim() == "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁鏈鏍�!涓嶉渶瑕佸弽瀹℃牳!";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //鍙嶅鏍告彁浜bandonCheck
+                if (oBill.AbandonCheck(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                {
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍙嶅鏍告垚鍔�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                    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[鐢熶骇棰嗘枡鍗曠紪杈戞椂鑾峰彇琛ㄥご鏁版嵁]
+        [Route("Kf_MateOutBill/Kf_MateOutBillListCheckDetai")]
+        [HttpGet]
+        public ApiResult<DataSet> Kf_MateOutBillListCheckDetai(string HID)
+        {
+            if (string.IsNullOrEmpty(HID))
+                return new ApiResult<DataSet> { code = -1, msg = "ID涓嶈兘涓虹┖" };
+            SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+
+            var dataSet = oCN.RunProcReturn("select top 1 * from h_v_IF_MateOutBillList  where hmainid= " + HID + " ", "h_v_Sc_MouldProdInHouseBillList");
+            if (dataSet == null || dataSet.Tables[0].Rows.Count == 0)
+                return new ApiResult<DataSet> { code = -1, msg = "涓嶅瓨鍦ㄥ崟鍙�" };
+
+            return new ApiResult<DataSet> { code = 1, msg = "鏌ヨ鎴愬姛", data = dataSet };
+        }
+        #endregion
+
+        #region[鐢熶骇棰嗘枡鍗曠紪杈戞椂鑾峰彇琛ㄤ綋鏁版嵁]
+        [Route("Kf_MateOutBill/Kf_MateOutBillListProjectDetai")]
+        [HttpGet]
+        public object Kf_MateOutBillListProjectDetai(string sqlWhere)
+        {
+            DataSet ds;
+            DataSet ds1;
+            List<object> list = new List<object>();
+            try
+            {
+                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+                if (sqlWhere == null || sqlWhere.Equals(""))
+                {
+                    ds = oCN.RunProcReturn(string.Format(@"select HMaterID ,鐗╂枡浠g爜 HMaterCode ,鐗╂枡鍚嶇О HMaterName,瑙勬牸鍨嬪彿 HMaterSpec,HUnitID,璁¢噺鍗曚綅浠g爜 HUnitCode,璁¢噺鍗曚綅 HUnitName,搴旀敹鏁伴噺 HQtyMust,瀹炴敹鏁伴噺 HQty,鍗曚环 HPrice,閲戦 HMoney,HWHID,棰嗘枡浠撳簱浠g爜 HWHCode,棰嗘枡浠撳簱 HWHName,琛ㄤ綋澶囨敞 HRemark
+from h_v_IF_MateOutBillList"), "H_V_IF_MATEOUTBILLLIST");
+                    
+                }
+                else
+                {
+
+                    //string sql1 = "select HRepairCheckID,HRepairCheckContent,HManagerID,HRemark  from Sc_MouldRepairCheckBillSub where 1 = 1 ";
+                    string sql1 = string.Format(@"select HMaterID ,鐗╂枡浠g爜 HMaterCode ,鐗╂枡鍚嶇О HMaterName,瑙勬牸鍨嬪彿 HMaterSpec,HUnitID,璁¢噺鍗曚綅浠g爜 HUnitCode,璁¢噺鍗曚綅 HUnitName,搴旀敹鏁伴噺 HQtyMust,瀹炴敹鏁伴噺 HQty,鍗曚环 HPrice,閲戦 HMoney,HWHID,棰嗘枡浠撳簱浠g爜 HWHCode,棰嗘枡浠撳簱 HWHName,琛ㄤ綋澶囨敞 HRemark
+from h_v_IF_MateOutBillList WHERE 1=1");
+                    string sql = sql1 + sqlWhere;
+                    ds = oCN.RunProcReturn(sql, "H_V_IF_MATEOUTBILLLIST");
+                }
+                //鏌ユ眹鎬�
+                ds1 = oCN.RunProcReturn(string.Format(@"select  鐗╂枡浠g爜,max(鐗╂枡鍚嶇О)鐗╂枡鍚嶇О,瑙勬牸鍨嬪彿,max(鍗曟嵁鍙�)鍗曟嵁鍙�,鎵规,sum(瀹炴敹鏁伴噺)瀹炴敹鏁伴噺,
+                                            hwhid1,max(鏀舵枡浠撳簱浠g爜)鏀舵枡浠撳簱浠g爜,max(鏀舵枡浠撳簱)鏀舵枡浠撳簱,琛ㄤ綋澶囨敞 from h_v_Sc_MouldProdInHouseBillList 
+                                            where 1=1 " + sqlWhere + " group by 鐗╂枡浠g爜,瑙勬牸鍨嬪彿,hwhid1,鎵规,琛ㄤ綋澶囨敞"), "h_v_Sc_MouldProdInHouseBillList");
+
+                list.Add(ds.Tables[0]);
+                list.Add(ds1.Tables[0]);
+                objJsonResult.code = "0";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鑾峰彇淇℃伅鎴愬姛锛�";
+                objJsonResult.list = list;
+
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + e.ToString();
+                objJsonResult.data = null;
+            }
+            return objJsonResult;
+        }
+        #endregion
+
+        #region 鐢熶骇棰嗘枡鍗曚繚瀛�/缂栬緫
+        /// <summary>
+        /// 淇濆瓨鐢熶骇棰嗘枡鍗�
+        /// </summary>
+        /// <param name="msg"></param>
+        /// <returns></returns>
+        [Route("Kf_MateOutBill/SaveGetMateOutBillList")]
+        [HttpPost]
+        public object SaveGetMateOutBillList([FromBody] JObject msg)
+        {
+            var _value = msg["msg"].ToString();
+            string msg1 = _value.ToString();
+            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+            string msg2 = sArray[0].ToString();
+            string msg3 = sArray[1].ToString();
+            string refSav = sArray[2].ToString();
+            string msg4 = sArray[3].ToString();
+
+            string UserName = "";
+            string s = "";
+            ListModels oListModels = new ListModels();
+            try
+            {
+                //缂栬緫鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log_second("Sc_MouldProdInBill_Edit", 1, true, msg4))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                DLL.ClsKf_MateOutBill oBill = new DLL.ClsKf_MateOutBill();
+                List<Models.ClsKf_MateOutBillMain> lsmain = new List<Models.ClsKf_MateOutBillMain>();
+                msg2 = msg2.Replace("\\", "");
+                msg2 = msg2.Replace("\n", "");  //\n
+                lsmain = oListModels.getObjectByJson_Kf_ICStockBillMain(msg2);
+                foreach (Models.ClsKf_MateOutBillMain oItem in lsmain)
+                {
+                    if (refSav == "Add")
+                    {
+                        //鍗曟嵁鍙锋槸鍚﹂噸澶�
+                        if (BillNew0.IsExistBillNo(ref ClsPub.sExeReturnInfo, oItem.HBillNo, BillStatus, BillOld0.omodel.HInterID))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁鍙烽噸澶嶏紒涓嶅厑璁镐繚瀛橈紒";
+                            objJsonResult.data = 1;
+                            return objJsonResult;
+                        }
+                    }
+                    if (refSav == "Update")
+                    {
+                        if (BillOld0.ShowBill(oItem.HInterID, ref s) == false)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "姝ゅ崟鎹湁璇紒";
+                            objJsonResult.data = 1;
+                            return objJsonResult;
+                        }
+                        //鍒ゆ柇鏄惁鍙紪杈�
+                        if (BillOld0.omodel.HChecker != "" && BillOld0.omodel.HChecker != null)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "姝ゅ崟鎹凡缁忚瀹℃牳锛屼笉鍏佽淇敼锛�";
+                            objJsonResult.data = 1;
+                            return objJsonResult;
+                        }
+                        if (BillOld0.omodel.HBillStatus > 1)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "姝ゅ崟鎹浜庝笉鍙紪杈戠姸鎬侊紝涓嶅厑璁镐慨鏀癸紒";
+                            objJsonResult.data = 1;
+                            return objJsonResult;
+                        }
+                        if (!DBUtility.Xt_BaseBillFun.Fun_AllowEditBill(BillOld0, ref s))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = s + "锛屼笉鍏佽淇敼";
+                            objJsonResult.data = 1;
+                            return objJsonResult;
+                        }
+                    }
+                    //oItem.HMaker = "";
+                    UserName = oItem.HMaker;  //鍒跺崟浜�
+                    oItem.HBillType = "3801";
+                    oItem.HBillSubType = "3801";
+                    //oItem.HBillNo = "";    //鍗曟嵁鍙�
+                    //oItem.HDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd"));//  --鏃ユ湡
+                    //oItem.HInnerBillNo = "";  //  --鍐呴儴鍗曟嵁鍙�
+                    oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year);
+                    oItem.HPeriod = DBUtility.ClsPub.isLong(DateTime.Now.Month);
+                    oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd"));
+                    //oItem.HEquipID = 0;    //璁惧ID(Gy_EquipMent)
+                    //oItem.HPeriod = 0;
+                    //oItem.HCheckBeginDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd"));  //  --缁翠慨鏃ユ湡
+                    //oItem.HCheckResult = "";     //楠屾敹缁撹--(姝e父锛屽紓甯�)
+                    //oItem.HEmpID = 0;           //楠屾敹浜�(Gy_Employee)
+                    //oItem.HManagerID = 0;      //璐熻矗浜�(Gy_Employee)
+                    //oItem.HDeptID = 0;        //楠屾敹閮ㄩ棬(Gy_Department)
+                    //oItem.HExplanation = "";  //鎽樿(鏁呴殰鎻忚堪)  
+                    //oItem.HRemark = "";       //澶囨敞
+
+                    //oItem.HMainSourceInterID = oItem.HInterID;
+
+                    //oItem.HInterID = DBUtility.ClsPub.CreateBillID_SRMProd("1103", ref DBUtility.ClsPub.sExeReturnInfo);
+                    if (DBUtility.ClsPub.isStrNull(oItem.HDate) == "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "淇濆瓨澶辫触锛佹病鏈夊崟鎹棩鏈燂紝鏃犳硶淇濆瓨锛�";
+                        objJsonResult.data = 1;
+                        return objJsonResult;
+                    }
+                    oBill.omodel = oItem;
+                }
+                //琛ㄤ綋鏁版嵁
+                //鎸� },{鏉ユ媶鍒嗘暟缁� //鍘绘帀銆愬拰銆�
+                msg3 = msg3.Substring(1, msg3.Length - 2);
+                msg3 = msg3.Replace("\\", "");
+                msg3 = msg3.Replace("\n", "");  //\n
+                //msg2 = msg2.Replace("'", "鈥�");
+                List<Models.ClsKf_MateOutBillSub> ls = new List<Models.ClsKf_MateOutBillSub>();
+                ls = oListModels.getObjectByJson_Kf_MateOutBillSub(msg3);
+                int i = 0;
+                foreach (Models.ClsKf_MateOutBillSub oItemSub in ls)
+                {
+
+                    i++;
+                    oItemSub.HEntryID = i;
+
+                    //oItemSub.HRepairCheckID = 0;   //楠屾敹椤圭洰ID
+                    //oItemSub.HRepairCheckContent = ""; //楠屾敹鍐呭
+                    //oItemSub.HManagerID = 0;   //璐熻矗浜篒D
+                    //oItemSub.HCloseMan = "";       //琛屽叧闂�
+                    oItemSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now);
+                    oItemSub.HCloseType = false;   //鍏抽棴绫诲瀷
+                    //oItemSub.HRemark = "";         //澶囨敞
+                    oItemSub.HSourceInterID = 0;     // 婧愬崟涓诲唴鐮�
+                    oItemSub.HSourceEntryID = 0;   //婧愬崟瀛愬唴鐮�
+                    //oItemSub.HSourceBillNo = "";  //婧愬崟鍗曞彿
+                    //oItemSub.HSourceBillType = ""; //婧愬崟绫诲瀷
+                    //oItemSub.HRelationQty = 0;     //鍏宠仈鏁伴噺
+                    //oItemSub.HRelationMoney = 0;   //鍏宠仈閲戦 
+                    //oItemSub.HRepairID = 0;       //缁翠慨椤圭洰
+                    //oItemSub.HRepairExplanation ="";   //缁翠慨瑕佹眰
+                    //oItemSub.HMoney = 0;        //缁翠慨璐圭敤
+                    oBill.DetailColl.Add(oItemSub);
+
+                }
+                //淇濆瓨
+                //淇濆瓨瀹屾瘯鍚庡鐞�
+                bool bResult;
+                if (oBill.omodel.HInterID == 0)
+                {
+                    // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+                    bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+                }
+                else
+                {
+                    bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
+                }
+                if (bResult)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
+                    //WebAPIController.Add_Log("閫佽揣鍗曚笅鎺�", UserName, "鐢熸垚閫佽揣鍗�");
+                    objJsonResult.data = 1;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = 1;
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "淇濆瓨澶辫触锛�" + e.ToString();
+                objJsonResult.data = 1;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鍣ㄥ叿閲囪喘鍏ュ簱鍗曞鏍�/鍙嶅鏍�
+        [Route("Sc_MouldProdInHouseBill/AuditMouldProdInHouseBill")]
+        [HttpGet]
+        public object AuditMouldProdInHouseBill(string HInterID, string user, int flag)
+        {
+            //flag=1 瀹℃牳锛�  flag=2 鍙嶅鏍�
+            //缂栬緫鏉冮檺
+            if (!DBUtility.ClsPub.Security_Log_second("Sc_MouldProdInBill_Check", 1, true, user))
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鏃犲鏍告潈闄愶紒";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+
+            Int64 lngBillKey = 0;
+            lngBillKey = DBUtility.ClsPub.isLong(HInterID);
+            if (lngBillKey == 0)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鍗曟嵁ID涓虹┖锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            DLL.ClsSc_MouldProdOutBill oBill = new DLL.ClsSc_MouldProdOutBill();
+            if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))
+            {
+                if (flag == 1)
+                {
+                    if (oBill.omodel.HBillStatus == 2)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "褰撳墠鍗曟嵁宸插鏍革紝鏃犻渶鍐嶆瀹℃牳";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        string HCheckDate = DateTime.Now.Date.ToString();
+                        oCn.RunProc(" Update Sc_MouldStockBillMain set HChecker='" + user + "',HCheckDate='" + HCheckDate + "',HBillStatus=2 Where HBillType='3801' and HInterID=" + HInterID);
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "瀹℃牳鎴愬姛锛�";
+                        objJsonResult.data = 1;
+                        return objJsonResult;
+                    }
+                }
+                else
+                {
+                    if (oBill.omodel.HBillStatus == 1)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "褰撳墠鍗曟嵁鏈鏍革紝鏃犻渶鍙嶅鏍�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        string HCheckDate = DateTime.Now.Date.ToString();
+                        oCn.RunProc(" Update Sc_MouldStockBillMain set HChecker=' ',HCheckDate=' ',HBillStatus=1 Where HBillType='3801' and HInterID=" + HInterID);
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅鏍告垚鍔燂紒";
+                        objJsonResult.data = 1;
+                        return objJsonResult;
+                    }
+                }
+
+            }
+            else
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鍗曟嵁鏈壘鍒�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+    }
+}
diff --git a/WebAPI/DLL/ClsKf_MateOutBackBill.cs b/WebAPI/DLL/ClsKf_MateOutBackBill.cs
new file mode 100644
index 0000000..c4f803e
--- /dev/null
+++ b/WebAPI/DLL/ClsKf_MateOutBackBill.cs
@@ -0,0 +1,386 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Text;
+using System.Data;
+
+namespace WebAPI.DLL
+{
+    public class ClsKf_MateOutBackBill:DBUtility.ClsXt_BaseBill
+    {
+        public Model.ClsKf_ICStockBillMain omodel = new Model.ClsKf_ICStockBillMain();
+        public List<Model.ClsKf_ICStockBillSub> DetailColl = new List<Model.ClsKf_ICStockBillSub>();
+        public List<Model.ClsKf_ICStockBillScheme> DetailSubColl = new List<Model.ClsKf_ICStockBillScheme>();
+
+        public ClsKf_MateOutBackBill()
+        {
+            base.MvarItemKeySub = "Kf_ICStockBillSub";
+            base.MvarItemKeySub2 = "";
+            base.MvarItemKeySub3 = "";
+            base.MvarItemKeySub4 = "";
+            base.MvarItemKey="Kf_ICStockBillMain";
+            base.MvarReportTitle="鐢熶骇閫�鏂欏崟";
+            base.BillType="1244";
+            base.HBillSubType = "1244";
+        }
+
+        #region 鍥哄畾浠g爜
+
+        ~ClsKf_MateOutBackBill()
+        {
+            DetailColl = null;
+        }
+
+
+        #endregion   鑷畾涔夋柟娉�
+
+        //淇敼鍗曟嵁
+        public override bool ModifyBill(Int64 lngBillKey, ref string sReturn)
+        {
+            try
+            {
+                oCn.BeginTran();
+                //鏇存柊涓昏〃
+                oCn.RunProc("UpDate Kf_ICStockBillMain set  " +
+                //鍥哄畾璧嬪��===============
+                " HBillNo='" + omodel.HBillNo + "'" +  
+                ",HDate='" + omodel.HDate + "'" +
+                ",HYear='" + omodel.HYear.ToString() + "'" +
+                ",HPeriod='" + omodel.HPeriod.ToString() + "'" +
+                ",HRemark='" + omodel.HRemark + "'" +
+                ",HUpDater='" + DBUtility.ClsPub.CurUserName + "'" +
+                ",HUpDateDate=getdate()" +
+                //========================================
+                ",HSupID=" + omodel.HSupID.ToString() +
+                ",HWHID=" + omodel.HWHID.ToString() +
+                ",HSCWHID=" + omodel.HSCWHID.ToString() +
+                ",HEmpID=" + omodel.HEmpID.ToString() +
+                ",HManagerID=" + omodel.HManagerID.ToString() +
+                ",HSecManagerID=" + omodel.HSecManagerID.ToString() +
+                ",HKeeperID=" + omodel.HKeeperID.ToString() +
+                ",HDeptID=" + omodel.HDeptID.ToString() +
+                ",HExplanation='" + omodel.HExplanation + "'" +
+                ",HInnerBillNo='" + omodel.HInnerBillNo + "'" +
+                ",HRedBlueFlag=" + DBUtility.ClsPub.BoolToString(omodel.HRedBlueFlag) +
+                " where HInterID=" + lngBillKey.ToString());
+                //鍒犻櫎鍏宠仈
+                DeleteRelation(ref sReturn, lngBillKey);
+                //鍒犻櫎瀛愯〃
+                DeleteBillSub(lngBillKey);
+                //鎻掑叆瀛愯〃
+                omodel.HInterID = lngBillKey;
+                foreach (Model.ClsKf_ICStockBillSub oSub in DetailColl)
+                {
+                    oCn.RunProc("Insert into Kf_ICStockBillSub " +
+                      " (HInterID,HEntryID,HCloseMan,HEntryCloseDate,HCloseType,HRemark" +
+                      ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" +
+                      ",HMaterID,HPropertyID,HSecUnitID,HSecUnitRate,HUnitID,HQtyMust" +
+                      ",HQty,HPrice,HMoney,HWHID,HSCWHID,HSPID" +
+                      ",HSCSPID,HSPGroupID,HBatchNo,HPOOrderInterID,HPOOrderEntryID,HPOOrderBillNo" +
+                      ",HSeOrderInterID,HSeOrderEntryID,HSeOrderBillNo" +
+                      ") values("
+                      + omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + ",'" + oSub.HCloseMan + "','" + oSub.HEntryCloseDate.ToShortDateString() + "'," + Convert.ToString(oSub.HCloseType ? 1 : 0) + ",'" + oSub.HRemark + "'" +
+                      "," + oSub.HSourceInterID.ToString() + "," + oSub.HSourceEntryID.ToString() + ",'" + oSub.HSourceBillNo + "','" + oSub.HSourceBillType + "'," + oSub.HRelationQty.ToString() + "," + oSub.HRelationMoney.ToString() +
+                      "," + oSub.HMaterID.ToString() + "," + oSub.HPropertyID.ToString() + "," + oSub.HSecUnitID.ToString() + "," + oSub.HSecUnitRate.ToString() + "," + oSub.HUnitID.ToString() + "," + oSub.HQtyMust.ToString() +
+                      "," + oSub.HQty.ToString() + "," + oSub.HPrice.ToString() + "," + oSub.HMoney.ToString() + "," + oSub.HWHID.ToString() + "," + oSub.HSCWHID.ToString() + "," + oSub.HSPID.ToString() +
+                      "," + oSub.HSCSPID.ToString() + "," + oSub.HSPGroupID.ToString() + ",'" + oSub.HBatchNo + "'," + oSub.HPOOrderInterID.ToString() + "," + oSub.HPOOrderEntryID.ToString() + ",'" + oSub.HPOOrderBillNo + "'" +
+                      "," + oSub.HSeOrderInterID.ToString() + "," + oSub.HSeOrderEntryID.ToString() + ",'" + oSub.HSeOrderBillNo + "'" +
+                      ") ");
+                }
+                sReturn = "淇敼鍗曟嵁鎴愬姛锛�";
+                oCn.Commit();
+                return true;
+            }
+            catch (Exception e)
+            {
+                sReturn = e.Message;
+                oCn.RollBack();
+                throw (e);
+            }
+        }
+
+        //鏂板鍗曟嵁
+        public override bool AddBill(ref string sReturn)
+        {
+            try
+            {
+                //寰楀埌mainid
+                omodel.HInterID = DBUtility.ClsPub.CreateBillID(BillType, ref DBUtility.ClsPub.sExeReturnInfo);
+                omodel.HBillNo = DBUtility.ClsPub.CreateBillCode(BillType, ref DBUtility.ClsPub.sExeReturnInfo, true);
+                //鑻AINDI閲嶅鍒欓噸鏂拌幏鍙�
+                if (IsExistBillNo(ref DBUtility.ClsPub.sExeReturnInfo, omodel.HBillNo, Pub_Class.ClsPub.Enum_BillStatus.BillStatus_AddNew, omodel.HInterID))
+                {
+                    omodel.HBillNo = DBUtility.ClsPub.CreateBillCode(BillType, ref DBUtility.ClsPub.sExeReturnInfo, true);
+                }
+                if (IsExistMainID(ref DBUtility.ClsPub.sExeReturnInfo, omodel.HInterID, Pub_Class.ClsPub.Enum_BillStatus.BillStatus_AddNew))
+                {
+                    omodel.HInterID = DBUtility.ClsPub.CreateBillID(BillType, ref DBUtility.ClsPub.sExeReturnInfo);
+                }
+                //
+                oCn.BeginTran();
+                //涓昏〃
+                oCn.RunProc("Insert Into Kf_ICStockBillMain   " +
+                "(HBillType,HBillSubType,HInterID,HBillNo,HDate" +
+                ",HYear,HPeriod,HRemark,HMaker,HMakeDate" +
+                ",HSupID,HWHID,HSCWHID,HEmpID,HManagerID,HSecManagerID" +
+                ",HKeeperID,HDeptID,HExplanation,HInnerBillNo,HRedBlueFlag" +
+                ") " +
+                " values('" + this.BillType + "','" + this.HBillSubType + "'," + omodel.HInterID.ToString() + ",'" + omodel.HBillNo + "','" + omodel.HDate + "'" +
+                ", " + omodel.HYear.ToString() + "," + omodel.HPeriod.ToString() + ",'" + omodel.HRemark + "','" + DBUtility.ClsPub.CurUserName + "',getdate()" +
+                ", " + omodel.HSupID.ToString() + "," + omodel.HWHID.ToString() + "," + omodel.HSCWHID.ToString() + "," + omodel.HEmpID.ToString() + "," + omodel.HManagerID.ToString() + "," + omodel.HSecManagerID.ToString() +
+                ", " + omodel.HKeeperID.ToString() + "," + omodel.HDeptID.ToString() + ",'" + omodel.HExplanation + "','" + omodel.HInnerBillNo + "'," + DBUtility.ClsPub.BoolToString(omodel.HRedBlueFlag) +
+                ") ");
+                //鎻掑叆瀛愯〃
+                foreach (Model.ClsKf_ICStockBillSub oSub in DetailColl)
+                {
+                    oCn.RunProc("Insert into Kf_ICStockBillSub " +
+                      " (HInterID,HEntryID,HCloseMan,HEntryCloseDate,HCloseType,HRemark" +
+                      ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" +
+                      ",HMaterID,HPropertyID,HSecUnitID,HSecUnitRate,HUnitID,HQtyMust" +
+                      ",HQty,HPrice,HMoney,HWHID,HSCWHID,HSPID" +
+                      ",HSCSPID,HSPGroupID,HBatchNo,HPOOrderInterID,HPOOrderEntryID,HPOOrderBillNo" +
+                      ",HSeOrderInterID,HSeOrderEntryID,HSeOrderBillNo" +
+                      ") values("
+                      + omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + ",'" + oSub.HCloseMan + "','" + oSub.HEntryCloseDate.ToShortDateString() + "'," + Convert.ToString(oSub.HCloseType ? 1 : 0) + ",'" + oSub.HRemark + "'" +
+                      "," + oSub.HSourceInterID.ToString() + "," + oSub.HSourceEntryID.ToString() + ",'" + oSub.HSourceBillNo + "','" + oSub.HSourceBillType + "'," + oSub.HRelationQty.ToString() + "," + oSub.HRelationMoney.ToString() +
+                      "," + oSub.HMaterID.ToString() + "," + oSub.HPropertyID.ToString() + "," + oSub.HSecUnitID.ToString() + "," + oSub.HSecUnitRate.ToString() + "," + oSub.HUnitID.ToString() + "," + oSub.HQtyMust.ToString() +
+                      "," + oSub.HQty.ToString() + "," + oSub.HPrice.ToString() + "," + oSub.HMoney.ToString() + "," + oSub.HWHID.ToString() + "," + oSub.HSCWHID.ToString() + "," + oSub.HSPID.ToString() +
+                      "," + oSub.HSCSPID.ToString() + "," + oSub.HSPGroupID.ToString() + ",'" + oSub.HBatchNo + "'," + oSub.HPOOrderInterID.ToString() + "," + oSub.HPOOrderEntryID.ToString() + ",'" + oSub.HPOOrderBillNo + "'" +
+                      "," + oSub.HSeOrderInterID.ToString() + "," + oSub.HSeOrderEntryID.ToString() + ",'" + oSub.HSeOrderBillNo + "'" +
+                      ") ");
+                }
+                sReturn = "鏂板鍗曟嵁鎴愬姛锛�";
+                oCn.Commit();
+                return true;
+            }
+            catch (Exception e)
+            {
+                sReturn = e.Message;
+                oCn.RollBack();
+                throw (e);
+            }
+        }
+
+        //鏄剧ず鍗曟嵁
+        public override bool ShowBill(Int64 lngBillKey, ref string sReturn)
+        {
+            try
+            {
+                //鏌ヨ涓昏〃
+                DataSet Ds;
+                Ds = oCn.RunProcReturn("Select * from Kf_ICStockBillMain Where HInterID=" + lngBillKey.ToString(), "Kf_ICStockBillMain");
+                if (Ds.Tables[0].Rows.Count == 0)
+                {
+                    sReturn = "鍗曟嵁鏈壘鍒帮紒";
+                    return false;
+                }
+                //鍥哄畾璧嬪��===========================================
+                omodel.HYear = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HYear"]);
+                omodel.HPeriod = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HPeriod"]);
+                omodel.HBillType = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBillType"]);
+                omodel.HBillSubType = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBillSubType"]);
+                omodel.HInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"]);
+                omodel.HDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["HDate"]);
+                omodel.HBillNo = Ds.Tables[0].Rows[0]["HBillNo"].ToString().Trim();
+                omodel.HBillStatus = DBUtility.ClsPub.isInt(Ds.Tables[0].Rows[0]["HBillStatus"]);
+                omodel.HCheckItemNowID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HCheckItemNowID"]);
+                omodel.HCheckItemNextID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HCheckItemNextID"]);
+                omodel.HCheckFlowID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HCheckFlowID"]);
+                omodel.HRemark = Ds.Tables[0].Rows[0]["HRemark"].ToString().Trim();
+                omodel.HBackDate = Ds.Tables[0].Rows[0]["HBackDate"].ToString().Trim();
+                omodel.HBacker = Ds.Tables[0].Rows[0]["HBacker"].ToString().Trim();
+                omodel.HCheckDate = Ds.Tables[0].Rows[0]["HCheckDate"].ToString().Trim();
+                omodel.HChecker = Ds.Tables[0].Rows[0]["HChecker"].ToString().Trim();
+                omodel.HMaker = Ds.Tables[0].Rows[0]["HMaker"].ToString().Trim();
+                omodel.HMakeDate = Ds.Tables[0].Rows[0]["HMakeDate"].ToString().Trim();
+                omodel.HUpDateDate = Ds.Tables[0].Rows[0]["HUpDateDate"].ToString().Trim();
+                omodel.HUpDater = Ds.Tables[0].Rows[0]["HUpDater"].ToString().Trim();
+                omodel.HCloseDate = Ds.Tables[0].Rows[0]["HCloseDate"].ToString().Trim();
+                omodel.HCloseMan = Ds.Tables[0].Rows[0]["HCloseMan"].ToString().Trim();
+                omodel.HCloseType = DBUtility.ClsPub.isBool(Ds.Tables[0].Rows[0]["HCloseType"]);
+                omodel.HDeleteDate = Ds.Tables[0].Rows[0]["HDeleteDate"].ToString().Trim();
+                omodel.HDeleteMan = Ds.Tables[0].Rows[0]["HDeleteMan"].ToString().Trim();
+                //========================================================
+                omodel.HSupID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSupID"]);
+                omodel.HWHID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HWHID"]);
+                omodel.HSCWHID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSCWHID"]);
+                omodel.HEmpID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HEmpID"]);
+                omodel.HManagerID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HManagerID"]);
+                omodel.HSecManagerID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSecManagerID"]);
+                omodel.HKeeperID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HKeeperID"]);
+                omodel.HDeptID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HDeptID"]);
+                omodel.HExplanation = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HExplanation"]);
+                omodel.HInnerBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HInnerBillNo"]);
+                omodel.HRedBlueFlag = DBUtility.ClsPub.isBool(Ds.Tables[0].Rows[0]["HRedBlueFlag"]);
+
+                //寰幆
+                DataSet DsSub;
+                DsSub = oCn.RunProcReturn("Select * from Kf_ICStockBillSub Where HInterID=" + lngBillKey.ToString(), "Kf_ICStockBillSub");
+                DetailColl.Clear();//娓呯┖
+                for (int i = 0; i < DsSub.Tables[0].Rows.Count; i++)
+                {
+                    Model.ClsKf_ICStockBillSub oSub = new Model.ClsKf_ICStockBillSub();
+                    // 鍥哄畾璧嬪��===============================================
+                    oSub.HInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HInterID"]);
+                    oSub.HEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HEntryID"]);
+                    oSub.HSourceInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSourceInterID"]);
+                    oSub.HSourceEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSourceEntryID"]);
+                    oSub.HSourceBillType = DsSub.Tables[0].Rows[i]["HSourceBillType"].ToString().Trim();
+                    oSub.HSourceBillNo = DsSub.Tables[0].Rows[i]["HSourceBillNo"].ToString().Trim();
+                    oSub.HRelationQty = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HRelationQty"]);
+                    oSub.HRelationMoney = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HRelationMoney"]);
+                    oSub.HCloseMan = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HCloseMan"]);
+                    oSub.HCloseType = DBUtility.ClsPub.isBool(DsSub.Tables[0].Rows[i]["HCloseType"]);
+                    oSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DsSub.Tables[0].Rows[i]["HEntryCloseDate"]);
+                    oSub.HRemark = DsSub.Tables[0].Rows[i]["HRemark"].ToString().Trim();
+                    //===================================================
+                    oSub.HMaterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HMaterID"]);
+                    oSub.HPropertyID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HPropertyID"]);
+                    oSub.HSecUnitID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSecUnitID"]);
+                    oSub.HSecUnitRate = DBUtility.ClsPub.isSingle(DsSub.Tables[0].Rows[i]["HSecUnitRate"]);
+                    oSub.HUnitID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HUnitID"]);
+                    oSub.HQtyMust = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HQtyMust"]);
+                    oSub.HQty = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HQty"]);
+                    oSub.HPrice = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HPrice"]);
+                    oSub.HMoney = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HMoney"]);
+                    oSub.HWHID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HWHID"]);
+                    oSub.HSCWHID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSCWHID"]);
+                    oSub.HSPID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSPID"]);
+                    oSub.HSCSPID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSCSPID"]);
+                    oSub.HSPGroupID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSPGroupID"]);
+                    oSub.HBatchNo = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HBatchNo"]);
+                    oSub.HPOOrderInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HPOOrderInterID"]);
+                    oSub.HPOOrderEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HPOOrderEntryID"]);
+                    oSub.HPOOrderBillNo = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HPOOrderBillNo"]);
+                    oSub.HSeOrderInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSeOrderInterID"]);
+                    oSub.HSeOrderEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSeOrderEntryID"]);
+                    oSub.HSeOrderBillNo = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HSeOrderBillNo"]);
+                    DetailColl.Add(oSub);
+                }
+                sReturn = "鏄剧ず鍗曟嵁鎴愬姛锛�";
+                return true;
+            }
+            catch (Exception e)
+            {
+                sReturn = e.Message;
+                throw (e);
+            }
+        }
+
+        //鏄剧ず鍗曟嵁鏉$爜淇℃伅
+        public bool ShowBill_Scheme(Int64 lngBillKey, ref string sReturn)
+        {
+            try
+            {
+                //寰幆瀛愯〃2
+                DataSet DsSubSec;
+                DsSubSec = oCn.RunProcReturn("Select * from Kf_ICStockBillSub_WMS   with (nolock) Where HInterID=" + lngBillKey.ToString() + " and HBillType='" + this.BillType + "'", "Kf_ICStockBillSub_WMS");
+                DetailSubColl.Clear();//娓呯┖
+                for (int i = 0; i < DsSubSec.Tables[0].Rows.Count; i++)
+                {
+                    Model.ClsKf_ICStockBillScheme oSubSec = new Model.ClsKf_ICStockBillScheme();
+                    oSubSec.HInterID = DBUtility.ClsPub.isLong(DsSubSec.Tables[0].Rows[i]["HInterID"].ToString());
+                    oSubSec.HEntryID = DBUtility.ClsPub.isLong(DsSubSec.Tables[0].Rows[i]["HEntryID"].ToString());
+                    oSubSec.HItemID = DBUtility.ClsPub.isLong(DsSubSec.Tables[0].Rows[i]["HItemID"].ToString());
+                    oSubSec.HBillType = DsSubSec.Tables[0].Rows[i]["HBillType"].ToString();
+                    oSubSec.HMaterID = DBUtility.ClsPub.isLong(DsSubSec.Tables[0].Rows[i]["HMaterID"].ToString());
+                    oSubSec.HProcID = DBUtility.ClsPub.isLong(DsSubSec.Tables[0].Rows[i]["HProcID"].ToString());
+                    oSubSec.HWhID = DBUtility.ClsPub.isLong(DsSubSec.Tables[0].Rows[i]["HWhID"].ToString());
+                    oSubSec.HGroupID = DBUtility.ClsPub.isLong(DsSubSec.Tables[0].Rows[i]["HGroupID"].ToString());
+                    oSubSec.HQty = DBUtility.ClsPub.isDoule(DsSubSec.Tables[0].Rows[i]["HQty"].ToString());
+                    oSubSec.HBarCode = DsSubSec.Tables[0].Rows[i]["HBarCode"].ToString();
+                    oSubSec.HAddr = DsSubSec.Tables[0].Rows[i]["HAddr"].ToString();
+                    oSubSec.HMaker = DsSubSec.Tables[0].Rows[i]["HMaker"].ToString();
+                    oSubSec.HMakeDate = DBUtility.ClsPub.isDate(DsSubSec.Tables[0].Rows[i]["HMakeDate"].ToString());
+                    oSubSec.HSourceInterID = DBUtility.ClsPub.isLong(DsSubSec.Tables[0].Rows[i]["HSourceInterID"].ToString());
+                    oSubSec.HSourceEntryID = DBUtility.ClsPub.isLong(DsSubSec.Tables[0].Rows[i]["HSourceEntryID"].ToString());
+                    oSubSec.HSourceBillType = DsSubSec.Tables[0].Rows[i]["HSourceBillType"].ToString();
+                    oSubSec.HSourceBillNo = DsSubSec.Tables[0].Rows[i]["HSourceBillNo"].ToString();
+                    oSubSec.HSourceItemID = DBUtility.ClsPub.isLong(DsSubSec.Tables[0].Rows[i]["HSourceItemID"].ToString());
+                    //
+                    DetailSubColl.Add(oSubSec);
+                }
+                sReturn = "鏄剧ず鍗曟嵁鎴愬姛锛�";
+                return true;
+            }
+            catch (Exception e)
+            {
+                sReturn = e.Message;
+                throw (e);
+            }
+        }
+
+
+        #region  WMS鏉$爜绋嬪簭
+
+        //鏉$爜鎵弿璁板綍锛屾柊澧炲埌鐢熶骇閫�鏂欏崟    鏃犳簮鍗�
+        public bool AddBill_PDA_NoSource(ref string sReturn)
+        {
+            try
+            {
+                //鍒ゆ柇浼氳鏈熸槸鍚﹀悎鐞�
+                string s = "";
+                int sYear = 0;
+                int sPeriod = 0;
+                if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(omodel.HDate, ref sYear, ref sPeriod, ref s) == false)
+                {
+                    sReturn = s;
+                    return false;
+                }
+                omodel.HYear = sYear;
+                omodel.HPeriod = sPeriod;
+
+                DataSet Ds;
+                oCn.BeginTran();
+                //鍒犻櫎涓昏〃
+                oCn.RunProc("Delete From Kf_ICStockBillMain where HInterID=" + omodel.HInterID.ToString());
+                //鎻掑叆瀛愯〃
+                oCn.RunProc("EXEC h_p_Kf_MateOutBackBillSub_Insert_NoSource " + omodel.HInterID.ToString() + ",'" + omodel.HBillNo + "'");
+                //鎻掑叆涓昏〃
+                oCn.RunProc("Insert Into Kf_ICStockBillMain   " +
+                "(HBillType,HBillSubType,HInterID,HBillNo,HDate,HMainSourceBillType" +
+                ",HYear,HPeriod,HRemark,HMaker,HMakeDate" +
+                ",HSupID,HWHID,HSCWHID,HEmpID,HManagerID,HSecManagerID" +
+                ",HKeeperID,HDeptID,HExplanation,HInnerBillNo,HRedBlueFlag" +
+                ") " +
+                " values('" + this.BillType + "','" + this.HBillSubType + "'," + omodel.HInterID.ToString() + ",'" + omodel.HBillNo + "',convert(varchar(10),getdate(),120),'" + omodel.HMainSourceBillType + "'" +
+                ", " + omodel.HYear.ToString() + "," + omodel.HPeriod.ToString() + ",'" + omodel.HRemark + "','" + omodel.HMaker + "',convert(varchar(10),getdate(),120)" +
+                ", " + omodel.HSupID.ToString() + "," + omodel.HWHID.ToString() + "," + omodel.HSCWHID.ToString() + "," + omodel.HEmpID.ToString() + "," + omodel.HManagerID.ToString() + "," + omodel.HSecManagerID.ToString() +
+                ", " + omodel.HKeeperID.ToString() + "," + omodel.HDeptID.ToString() + ",'" + omodel.HExplanation + "','" + omodel.HInnerBillNo + "'," + DBUtility.ClsPub.BoolToString(omodel.HRedBlueFlag) +
+                ") ");
+                //鏇存柊鍏宠仈鏁伴噺
+
+                //瀹℃牳鍗曟嵁
+                oCn.RunProc("Update Kf_ICStockBillMain Set HChecker='" + omodel.HMaker + "',HCheckDate=convert(varchar(10),getdate(),120),HBillStatus=2 where HInterID= " + omodel.HInterID.ToString());
+                
+                //鐢熸垚K3鍗曟嵁
+                //鏂板瀛愯〃銆佷富琛�
+                oCn.RunProc("exec h_p_IFK3_ToERP_MateOutBackBill_Insert " + omodel.HInterID.ToString() + ",'" + omodel.HBillNo + "'," + omodel.HBillerID.ToString());
+                //鍥炲~鍏宠仈鏁伴噺
+                oCn.RunProc("exec h_p_IFK3_ToERP_MateOutBackBill_UpdateBillRelateData " + omodel.HInterID.ToString());
+                //瀹℃牳鍗曟嵁
+                oCn.RunProc("exec h_p_IFK3_ToERP_MateOutBackBill_Check " + omodel.HInterID.ToString() + "," + omodel.HBillerID.ToString());
+                ////鏇存柊搴撳瓨
+                oCn.RunProc("exec h_p_IFK3_ToERP_MateOutBackBill_UpdateStock " + omodel.HInterID.ToString());
+                oCn.RunProc("exec h_p_IFK3_ToERP_MateOutBackBill_UpdateOrderStock " + omodel.HInterID.ToString());
+
+                sReturn = "鏂板鍗曟嵁鎴愬姛锛�";
+                oCn.Commit();
+                return true;
+            }
+            catch (Exception e)
+            {
+                sReturn = e.Message;
+                oCn.RollBack();
+                throw (e);
+            }
+        }
+
+
+
+        #endregion
+
+
+
+
+    }
+}
diff --git a/WebAPI/DLL/ClsKf_MateOutBill.cs b/WebAPI/DLL/ClsKf_MateOutBill.cs
new file mode 100644
index 0000000..8deba8f
--- /dev/null
+++ b/WebAPI/DLL/ClsKf_MateOutBill.cs
@@ -0,0 +1,498 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Text;
+using System.Data;
+
+namespace WebAPI.DLL
+{
+    public  class ClsKf_MateOutBill:DBUtility.ClsXt_BaseBill
+    {
+        public Models.ClsKf_MateOutBillMain omodel = new Models.ClsKf_MateOutBillMain();
+        public List<Models.ClsKf_MateOutBillSub> DetailColl = new List<Models.ClsKf_MateOutBillSub>();
+        public List<Models.ClsKf_MateOutBillScheme> DetailSubColl = new List<Models.ClsKf_MateOutBillScheme>();
+
+        public ClsKf_MateOutBill()
+        {
+            base.MvarItemKeySub = "Kf_ICStockBillSub";
+            base.MvarItemKeySub2 = "";
+            base.MvarItemKeySub3 = "";
+            base.MvarItemKeySub4 = "";
+            base.MvarItemKey="Kf_ICStockBillMain";
+            base.MvarReportTitle="鐢熶骇棰嗘枡鍗�";
+            base.BillType="1204";
+            base.HBillSubType = "1204";
+
+        }
+
+        #region 鍥哄畾浠g爜
+
+        ~ClsKf_MateOutBill()
+        {
+            DetailColl = null;
+        }
+       
+        #endregion   鑷畾涔夋柟娉�
+        //淇敼鍗曟嵁
+        public override bool ModifyBill(Int64 lngBillKey, ref string sReturn)
+        {
+            try
+            {
+                //
+                oCn.BeginTran();
+                //鏇存柊涓昏〃
+                oCn.RunProc("UpDate Kf_ICStockBillMain set  " +
+                " HBillNo='" + omodel.HBillNo + "'" +  //鍥哄畾璧嬪��===============
+                ",HDate='" + omodel.HDate + "'" +
+                ",HYear='" + omodel.HYear.ToString() + "'" +
+                ",HPeriod='" + omodel.HPeriod.ToString() + "'" +
+                ",HRemark='" + omodel.HRemark + "'" +
+                ",HUpDater='" + DBUtility.ClsPub.CurUserName + "'" +
+                ",HUpDateDate=getdate()" +
+                //========================================
+                ",HSupID=" + omodel.HSupID.ToString() +
+                ",HWHID=" + omodel.HWHID.ToString() +
+                ",HSCWHID=" + omodel.HSCWHID.ToString() +
+                ",HEmpID=" + omodel.HEmpID.ToString() +
+                ",HManagerID=" + omodel.HManagerID.ToString() +
+                ",HSecManagerID=" + omodel.HSecManagerID.ToString() +
+                ",HKeeperID=" + omodel.HKeeperID.ToString() +
+                ",HDeptID=" + omodel.HDeptID.ToString() +
+                ",HExplanation='" + omodel.HExplanation + "'" +
+                ",HInnerBillNo='" + omodel.HInnerBillNo + "'" +
+                ",HRedBlueFlag=" + DBUtility.ClsPub.BoolToString(omodel.HRedBlueFlag) +
+                " where HInterID=" + lngBillKey.ToString());
+                //鍒犻櫎鍏宠仈
+                DeleteRelation(ref sReturn, lngBillKey);
+                //鍒犻櫎瀛愯〃
+                DeleteBillSub(lngBillKey);
+                //鎻掑叆瀛愯〃
+                omodel.HInterID = lngBillKey;
+                foreach (Models.ClsKf_MateOutBillSub oSub in DetailColl)
+                {
+                    oCn.RunProc("Insert into Kf_ICStockBillSub " +
+                      " (HInterID,HEntryID,HCloseMan,HEntryCloseDate,HCloseType,HRemark" +
+                      ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" +
+                      ",HMaterID,HPropertyID,HSecUnitID,HSecUnitRate,HUnitID,HQtyMust" +
+                      ",HQty,HPrice,HMoney,HWHID,HSCWHID,HSPID" +
+                      ",HSCSPID,HSPGroupID,HBatchNo,HPOOrderInterID,HPOOrderEntryID,HPOOrderBillNo" +
+                      ",HSeOrderInterID,HSeOrderEntryID,HSeOrderBillNo" +
+                      ") values("
+                      + omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + ",'" + oSub.HCloseMan + "','" + oSub.HEntryCloseDate.ToShortDateString() + "'," + Convert.ToString(oSub.HCloseType ? 1 : 0) + ",'" + oSub.HRemark + "'" +
+                      "," + oSub.HSourceInterID.ToString() + "," + oSub.HSourceEntryID.ToString() + ",'" + oSub.HSourceBillNo + "','" + oSub.HSourceBillType + "'," + oSub.HRelationQty.ToString() + "," + oSub.HRelationMoney.ToString() +
+                      "," + oSub.HMaterID.ToString() + "," + oSub.HPropertyID.ToString() + "," + oSub.HSecUnitID.ToString() + "," + oSub.HSecUnitRate.ToString() + "," + oSub.HUnitID.ToString() + "," + oSub.HQtyMust.ToString() +
+                      "," + oSub.HQty.ToString() + "," + oSub.HPrice.ToString() + "," + oSub.HMoney.ToString() + "," + oSub.HWHID.ToString() + "," + oSub.HSCWHID.ToString() + "," + oSub.HSPID.ToString() +
+                      "," + oSub.HSCSPID.ToString() + "," + oSub.HSPGroupID.ToString() + ",'" + oSub.HBatchNo + "'," + oSub.HPOOrderInterID.ToString() + "," + oSub.HPOOrderEntryID.ToString() + ",'" + oSub.HPOOrderBillNo + "'" +
+                      "," + oSub.HSeOrderInterID.ToString() + "," + oSub.HSeOrderEntryID.ToString() + ",'" + oSub.HSeOrderBillNo + "'" +
+                      ") ");
+                }
+                //
+                //foreach (Model.ClsKf_MateOutBillSub oSub in DetailColl)
+                //{
+                //    Ds = oCn.RunProcReturn("exec h_p_Kf_MateOutBill_Qty " + oSub.HICMOInterID, "");
+                //    if (Ds.Tables[0].Rows.Count == 0)
+                //        return;
+                //    if (DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBool"]) == "Y")
+                //    {
+                //        sReturn = "姹囨姤鏁伴噺瓒呰繃璁″垝鏁伴噺锛佷笉鍏佽淇濆瓨";
+                //        return false;
+                //    }
+                //}
+                sReturn = "淇敼鍗曟嵁鎴愬姛锛�";
+                oCn.Commit();
+                return true;
+            }
+            catch (Exception e)
+            {
+                sReturn = e.Message;
+                oCn.RollBack();
+                throw (e);
+            }
+        }
+        //鏂板鍗曟嵁
+        public override bool AddBill(ref string sReturn)
+        {
+            try
+            {
+                //寰楀埌mainid
+                omodel.HInterID = DBUtility.ClsPub.CreateBillID(BillType, ref DBUtility.ClsPub.sExeReturnInfo);
+                omodel.HBillNo = DBUtility.ClsPub.CreateBillCode(BillType, ref DBUtility.ClsPub.sExeReturnInfo, true);
+                //鑻AINDI閲嶅鍒欓噸鏂拌幏鍙�
+                if (IsExistBillNo(ref DBUtility.ClsPub.sExeReturnInfo, omodel.HBillNo, Pub_Class.ClsPub.Enum_BillStatus.BillStatus_AddNew, omodel.HInterID))
+                {
+                    omodel.HBillNo = DBUtility.ClsPub.CreateBillCode(BillType, ref DBUtility.ClsPub.sExeReturnInfo, true);
+                }
+                if (IsExistMainID(ref DBUtility.ClsPub.sExeReturnInfo, omodel.HInterID, Pub_Class.ClsPub.Enum_BillStatus.BillStatus_AddNew))
+                {
+                    omodel.HInterID = DBUtility.ClsPub.CreateBillID(BillType, ref DBUtility.ClsPub.sExeReturnInfo);
+                }
+                //
+                oCn.BeginTran();
+                //涓昏〃
+                oCn.RunProc("Insert Into Kf_ICStockBillMain   " +
+                "(HBillType,HBillSubType,HInterID,HBillNo,HDate" +
+                ",HYear,HPeriod,HRemark,HMaker,HMakeDate" +
+                ",HSupID,HWHID,HSCWHID,HEmpID,HManagerID,HSecManagerID" +
+                ",HKeeperID,HDeptID,HExplanation,HInnerBillNo,HRedBlueFlag" +
+                ") " +
+                " values('" + this.BillType + "','"  + this.HBillSubType + "'," +omodel.HInterID.ToString() + ",'" + omodel.HBillNo + "','" + omodel.HDate + "'" +
+                ", " + omodel.HYear.ToString() + "," + omodel.HPeriod.ToString() + ",'" + omodel.HRemark + "','" + DBUtility.ClsPub.CurUserName + "',getdate()" +
+                ", " + omodel.HSupID.ToString() + "," + omodel.HWHID.ToString() + "," + omodel.HSCWHID.ToString() + "," + omodel.HEmpID.ToString() + "," + omodel.HManagerID.ToString() + "," + omodel.HSecManagerID.ToString() +
+                ", " + omodel.HKeeperID.ToString() + "," + omodel.HDeptID.ToString() + ",'" + omodel.HExplanation + "','" + omodel.HInnerBillNo + "'," + DBUtility.ClsPub.BoolToString(omodel.HRedBlueFlag) +
+                ") ");
+                //鎻掑叆瀛愯〃
+                foreach (Models.ClsKf_MateOutBillSub oSub in DetailColl)
+                {
+                    oCn.RunProc("Insert into Kf_ICStockBillSub " +
+                      " (HInterID,HEntryID,HCloseMan,HEntryCloseDate,HCloseType,HRemark" +
+                      ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" +
+                      ",HMaterID,HPropertyID,HSecUnitID,HSecUnitRate,HUnitID,HQtyMust" +
+                      ",HQty,HPrice,HMoney,HWHID,HSCWHID,HSPID" +
+                      ",HSCSPID,HSPGroupID,HBatchNo,HPOOrderInterID,HPOOrderEntryID,HPOOrderBillNo" +
+                      ",HSeOrderInterID,HSeOrderEntryID,HSeOrderBillNo" +
+                      ") values("
+                      + omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + ",'" + oSub.HCloseMan + "','" + oSub.HEntryCloseDate.ToShortDateString() + "'," + Convert.ToString(oSub.HCloseType ? 1 : 0) + ",'" + oSub.HRemark + "'" +
+                      "," + oSub.HSourceInterID.ToString() + "," + oSub.HSourceEntryID.ToString() + ",'" + oSub.HSourceBillNo + "','" + oSub.HSourceBillType + "'," + oSub.HRelationQty.ToString() + "," + oSub.HRelationMoney.ToString() +
+                      "," + oSub.HMaterID.ToString() + "," + oSub.HPropertyID.ToString() + "," + oSub.HSecUnitID.ToString() + "," + oSub.HSecUnitRate.ToString() + "," + oSub.HUnitID.ToString() + "," + oSub.HQtyMust.ToString() +
+                      "," + oSub.HQty.ToString() + "," + oSub.HPrice.ToString() + "," + oSub.HMoney.ToString() + "," + oSub.HWHID.ToString() + "," + oSub.HSCWHID.ToString() + "," + oSub.HSPID.ToString() +
+                      "," + oSub.HSCSPID.ToString() + "," + oSub.HSPGroupID.ToString() + ",'" + oSub.HBatchNo + "'," + oSub.HPOOrderInterID.ToString() + "," + oSub.HPOOrderEntryID.ToString() + ",'" + oSub.HPOOrderBillNo + "'" +
+                      "," + oSub.HSeOrderInterID.ToString() + "," + oSub.HSeOrderEntryID.ToString() + ",'" + oSub.HSeOrderBillNo + "'" +
+                      ") ");
+                }
+                //
+                //foreach (Model.ClsKf_MateOutBillSub oSub in DetailColl)
+                //{
+                //    Ds = oCn.RunProcReturn("exec h_p_Kf_MateOutBill_Qty " + oSub.HICMOInterID, "");
+                //    if (Ds.Tables[0].Rows.Count == 0)
+                //        return;
+                //    if (DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBool"]) == "Y")
+                //    {
+                //        sReturn = "姹囨姤鏁伴噺瓒呰繃璁″垝鏁伴噺锛佷笉鍏佽淇濆瓨";
+                //        return false;
+                //    }
+                //}
+                //
+                sReturn = "鏂板鍗曟嵁鎴愬姛锛�";
+                oCn.Commit();
+                return true;
+            }
+            catch (Exception e)
+            {
+                sReturn = e.Message;
+                oCn.RollBack();
+                throw (e);
+            }
+        }
+        //鏄剧ず鍗曟嵁
+        public override bool ShowBill(Int64 lngBillKey, ref string sReturn)
+        {
+            try
+            {
+                //鏌ヨ涓昏〃
+                DataSet Ds ;
+                Ds = oCn.RunProcReturn("Select * from Kf_ICStockBillMain Where HInterID=" + lngBillKey.ToString(), "Kf_ICStockBillMain");
+                if(Ds.Tables[0].Rows.Count==0)
+                {
+                    sReturn = "鍗曟嵁鏈壘鍒帮紒";
+                    return false;
+                }
+                //鍥哄畾璧嬪��===========================================
+                omodel.HYear = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HYear"]);
+                omodel.HPeriod = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HPeriod"]);
+                omodel.HBillType = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBillType"]);
+                omodel.HBillSubType = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBillSubType"]);
+                omodel.HInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"]);
+                omodel.HDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["HDate"]);
+                omodel.HBillNo = Ds.Tables[0].Rows[0]["HBillNo"].ToString().Trim();
+                omodel.HBillStatus = DBUtility.ClsPub.isInt(Ds.Tables[0].Rows[0]["HBillStatus"]);
+                omodel.HCheckItemNowID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HCheckItemNowID"]);
+                omodel.HCheckItemNextID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HCheckItemNextID"]);
+                omodel.HCheckFlowID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HCheckFlowID"]);
+                omodel.HRemark = Ds.Tables[0].Rows[0]["HRemark"].ToString().Trim();
+                omodel.HBackDate = Ds.Tables[0].Rows[0]["HBackDate"].ToString().Trim();
+                omodel.HBacker = Ds.Tables[0].Rows[0]["HBacker"].ToString().Trim();
+                omodel.HCheckDate = Ds.Tables[0].Rows[0]["HCheckDate"].ToString().Trim();
+                omodel.HChecker = Ds.Tables[0].Rows[0]["HChecker"].ToString().Trim();
+                omodel.HMaker = Ds.Tables[0].Rows[0]["HMaker"].ToString().Trim();
+                omodel.HMakeDate = Ds.Tables[0].Rows[0]["HMakeDate"].ToString().Trim();
+                omodel.HUpDateDate = Ds.Tables[0].Rows[0]["HUpDateDate"].ToString().Trim();
+                omodel.HUpDater = Ds.Tables[0].Rows[0]["HUpDater"].ToString().Trim();
+                omodel.HCloseDate = Ds.Tables[0].Rows[0]["HCloseDate"].ToString().Trim();
+                omodel.HCloseMan = Ds.Tables[0].Rows[0]["HCloseMan"].ToString().Trim();
+                omodel.HCloseType = DBUtility.ClsPub.isBool(Ds.Tables[0].Rows[0]["HCloseType"]);
+                omodel.HDeleteDate = Ds.Tables[0].Rows[0]["HDeleteDate"].ToString().Trim();
+                omodel.HDeleteMan = Ds.Tables[0].Rows[0]["HDeleteMan"].ToString().Trim();
+                //========================================================
+                omodel.HSupID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSupID"]);
+                omodel.HWHID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HWHID"]);
+                omodel.HSCWHID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSCWHID"]);
+                omodel.HEmpID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HEmpID"]);
+                omodel.HManagerID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HManagerID"]);
+                omodel.HSecManagerID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSecManagerID"]);
+                omodel.HKeeperID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HKeeperID"]);
+                omodel.HDeptID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HDeptID"]);
+                omodel.HExplanation = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HExplanation"]);
+                omodel.HInnerBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HInnerBillNo"]);
+                omodel.HRedBlueFlag = DBUtility.ClsPub.isBool(Ds.Tables[0].Rows[0]["HRedBlueFlag"]);
+                //
+                
+                //寰幆
+                DataSet DsSub ;
+                DsSub = oCn.RunProcReturn("Select * from Kf_ICStockBillSub Where HInterID=" + lngBillKey.ToString(), "Kf_ICStockBillSub");
+                DetailColl.Clear();//娓呯┖
+                for (int i = 0; i < DsSub.Tables[0].Rows.Count; i++)
+                {
+                    Models.ClsKf_MateOutBillSub oSub = new Models.ClsKf_MateOutBillSub();
+                    // 鍥哄畾璧嬪��===============================================
+                    oSub.HInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HInterID"]);
+                    oSub.HEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HEntryID"]);
+                    oSub.HSourceInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSourceInterID"]);
+                    oSub.HSourceEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSourceEntryID"]);
+                    oSub.HSourceBillType = DsSub.Tables[0].Rows[i]["HSourceBillType"].ToString().Trim();
+                    oSub.HSourceBillNo = DsSub.Tables[0].Rows[i]["HSourceBillNo"].ToString().Trim();
+                    oSub.HRelationQty = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HRelationQty"]);
+                    oSub.HRelationMoney = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HRelationMoney"]); 
+                    oSub.HCloseMan =  DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HCloseMan"]);
+                    oSub.HCloseType = DBUtility.ClsPub.isBool(DsSub.Tables[0].Rows[i]["HCloseType"]);
+                    oSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DsSub.Tables[0].Rows[i]["HEntryCloseDate"]);
+                    oSub.HRemark = DsSub.Tables[0].Rows[i]["HRemark"].ToString().Trim();
+                    //===================================================
+                    oSub.HMaterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HMaterID"]);
+                    oSub.HPropertyID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HPropertyID"]);
+                    oSub.HSecUnitID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSecUnitID"]);
+                    oSub.HSecUnitRate = DBUtility.ClsPub.isSingle(DsSub.Tables[0].Rows[i]["HSecUnitRate"]);
+                    oSub.HUnitID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HUnitID"]);
+                    oSub.HQtyMust = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HQtyMust"]);
+                    oSub.HQty = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HQty"]);
+                    oSub.HPrice = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HPrice"]);
+                    oSub.HMoney = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HMoney"]);
+                    oSub.HWHID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HWHID"]);
+                    oSub.HSCWHID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSCWHID"]);
+                    oSub.HSPID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSPID"]);
+                    oSub.HSCSPID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSCSPID"]);
+                    oSub.HSPGroupID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSPGroupID"]);
+                    oSub.HBatchNo = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HBatchNo"]);
+                    oSub.HPOOrderInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HPOOrderInterID"]);
+                    oSub.HPOOrderEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HPOOrderEntryID"]);
+                    oSub.HPOOrderBillNo = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HPOOrderBillNo"]);
+                    oSub.HSeOrderInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSeOrderInterID"]);
+                    oSub.HSeOrderEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSeOrderEntryID"]);
+                    oSub.HSeOrderBillNo = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HSeOrderBillNo"]);
+                    DetailColl.Add(oSub);
+                }
+                sReturn = "鏄剧ず鍗曟嵁鎴愬姛锛�";
+                return true;
+            }
+            catch (Exception e)
+            {
+                sReturn = e.Message;
+                throw (e);
+            }
+        }
+
+        //鏄剧ず鍗曟嵁鏉$爜淇℃伅
+        public bool ShowBill_Scheme(Int64 lngBillKey, ref string sReturn)
+        {
+            try
+            {
+                //寰幆瀛愯〃2
+                DataSet DsSubSec;
+                DsSubSec = oCn.RunProcReturn("Select * from Kf_ICStockBillSub_WMS   with (nolock) Where HInterID=" + lngBillKey.ToString() + " and HBillType='" + this.BillType + "'", "Kf_ICStockBillSub_WMS");
+                DetailSubColl.Clear();//娓呯┖
+                for (int i = 0; i < DsSubSec.Tables[0].Rows.Count; i++)
+                {
+                    Models.ClsKf_MateOutBillScheme oSubSec = new Models.ClsKf_MateOutBillScheme();
+                    oSubSec.HInterID = DBUtility.ClsPub.isLong(DsSubSec.Tables[0].Rows[i]["HInterID"].ToString());
+                    oSubSec.HEntryID = DBUtility.ClsPub.isLong(DsSubSec.Tables[0].Rows[i]["HEntryID"].ToString());
+                    oSubSec.HItemID = DBUtility.ClsPub.isLong(DsSubSec.Tables[0].Rows[i]["HItemID"].ToString());
+                    oSubSec.HBillType = DsSubSec.Tables[0].Rows[i]["HBillType"].ToString();
+                    oSubSec.HMaterID = DBUtility.ClsPub.isLong(DsSubSec.Tables[0].Rows[i]["HMaterID"].ToString());
+                    oSubSec.HProcID = DBUtility.ClsPub.isLong(DsSubSec.Tables[0].Rows[i]["HProcID"].ToString());
+                    oSubSec.HWhID = DBUtility.ClsPub.isLong(DsSubSec.Tables[0].Rows[i]["HWhID"].ToString());
+                    oSubSec.HGroupID = DBUtility.ClsPub.isLong(DsSubSec.Tables[0].Rows[i]["HGroupID"].ToString());
+                    oSubSec.HQty = DBUtility.ClsPub.isDoule(DsSubSec.Tables[0].Rows[i]["HQty"].ToString());
+                    oSubSec.HBarCode = DsSubSec.Tables[0].Rows[i]["HBarCode"].ToString();
+                    oSubSec.HAddr = DsSubSec.Tables[0].Rows[i]["HAddr"].ToString();
+                    oSubSec.HMaker = DsSubSec.Tables[0].Rows[i]["HMaker"].ToString();
+                    oSubSec.HMakeDate = DBUtility.ClsPub.isDate(DsSubSec.Tables[0].Rows[i]["HMakeDate"].ToString());
+                    oSubSec.HSourceInterID = DBUtility.ClsPub.isLong(DsSubSec.Tables[0].Rows[i]["HSourceInterID"].ToString());
+                    oSubSec.HSourceEntryID = DBUtility.ClsPub.isLong(DsSubSec.Tables[0].Rows[i]["HSourceEntryID"].ToString());
+                    oSubSec.HSourceBillType = DsSubSec.Tables[0].Rows[i]["HSourceBillType"].ToString();
+                    oSubSec.HSourceBillNo = DsSubSec.Tables[0].Rows[i]["HSourceBillNo"].ToString();
+                    oSubSec.HSourceItemID = DBUtility.ClsPub.isLong(DsSubSec.Tables[0].Rows[i]["HSourceItemID"].ToString());
+                    //
+                    DetailSubColl.Add(oSubSec);
+                }
+                sReturn = "鏄剧ず鍗曟嵁鎴愬姛锛�";
+                return true;
+            }
+            catch (Exception e)
+            {
+                sReturn = e.Message;
+                throw (e);
+            }
+        }
+
+        //鍒ゆ柇 璐熷簱瀛�
+        public bool CheckKF(Int64 lngBillKey, int iType, ref string sReturn)
+        {
+
+            //try
+            //{
+                //DataSet oDs = new DataSet();
+                //oDs = oCn.RunProcReturn("exec  h_p_Kf_ICStockBill_CheckKF  " + lngBillKey.ToString() + "," + iType.ToString(), "gy_czygl");
+                //if (oDs == null || oDs.Tables[0].Rows.Count == 0)
+                //{
+                //    return false;
+                //}
+                //if (DBUtility.ClsPub.isStrNull(oDs.Tables[0].Rows[0][0]) == "N")
+                //{
+                //    sReturn = DBUtility.ClsPub.isStrNull(oDs.Tables[0].Rows[0][1]);
+                //    return false;
+                //}
+                //else
+                //{
+                //    sReturn = DBUtility.ClsPub.isStrNull(oDs.Tables[0].Rows[0][1]);
+                    return true;
+            //    }
+            //}
+            //catch (Exception e)
+            //{
+            //    sReturn = e.Message;
+            //    throw (e);
+            //}
+        }
+
+        //鏉$爜鎵弿璁板綍,鏂板鍒伴鏂欏嚭搴�
+        public bool AddBill_PDA(ref string sReturn)
+        {
+            try
+            {
+                //鍒ゆ柇浼氳鏈熸槸鍚﹀悎鐞�
+                string s = "";
+                int sYear = 0;
+                int sPeriod = 0;
+                if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(omodel.HDate, ref sYear, ref sPeriod, ref s) == false)
+                {
+                    sReturn = s;
+                    return false;
+                }
+                omodel.HYear = sYear;
+                omodel.HPeriod = sPeriod;
+
+                DataSet Ds;
+                oCn.BeginTran();
+                //鍒犻櫎涓昏〃
+                oCn.RunProc("Delete From Kf_ICStockBillMain  where HInterID=" + omodel.HInterID.ToString());
+                //鎻掑叆瀛愯〃
+                oCn.RunProc("EXEC h_p_Kf_MateOutBillSub_Insert " + omodel.HInterID.ToString() + ",'" + omodel.HBillNo + "'");
+                //鎻掑叆涓昏〃
+                oCn.RunProc("Insert Into Kf_ICStockBillMain   " +
+                "(HBillType,HBillSubType,HInterID,HBillNo,HDate,HMainSourceBillType" +
+                ",HYear,HPeriod,HRemark,HMaker,HMakeDate" +
+                ",HSupID,HWHID,HSCWHID,HEmpID,HManagerID,HSecManagerID" +
+                ",HKeeperID,HDeptID,HExplanation,HInnerBillNo,HRedBlueFlag" +
+                ") " +
+                " values('" + this.BillType + "','" + this.HBillSubType + "'," + omodel.HInterID.ToString() + ",'" + omodel.HBillNo + "',convert(varchar(10),getdate(),120),'" + omodel.HMainSourceBillType + "'" +
+                ", " + omodel.HYear.ToString() + "," + omodel.HPeriod.ToString() + ",'" + omodel.HRemark + "','" + omodel.HMaker + "',convert(varchar(10),getdate(),120)" +
+                ", " + omodel.HSupID.ToString() + "," + omodel.HWHID.ToString() + "," + omodel.HSCWHID.ToString() + "," + omodel.HEmpID.ToString() + "," + omodel.HManagerID.ToString() + "," + omodel.HSecManagerID.ToString() +
+                ", " + omodel.HKeeperID.ToString() + "," + omodel.HDeptID.ToString() + ",'" + omodel.HExplanation + "','" + omodel.HInnerBillNo + "'," + DBUtility.ClsPub.BoolToString(omodel.HRedBlueFlag) +
+                ") ");
+                //鏇存柊鍏宠仈鏁伴噺
+                oCn.RunProc("exec h_p_Sc_UpDatePPBomRelation_Add " + omodel.HInterID.ToString());
+                //瀹℃牳鍗曟嵁
+                oCn.RunProc("Update Kf_ICStockBillMain Set HChecker='" + omodel.HMaker + "',HCheckDate=convert(varchar(10),getdate(),120),HBillStatus=2 where HInterID= " + omodel.HInterID.ToString());
+
+                //鐢熸垚K3鍗曟嵁
+                //鏂板瀛愯〃銆佷富琛�
+                oCn.RunProc("exec h_p_IFK3_ToERP_MateOutBill_Insert " + omodel.HInterID.ToString() + ",'" + omodel.HBillNo + "'," + omodel.HBillerID.ToString());
+                //鍥炲~鍏宠仈鏁伴噺
+                oCn.RunProc("exec h_p_IFK3_ToERP_MateOutBill_UpdateBillRelateData " + omodel.HInterID.ToString());
+                //瀹℃牳鍗曟嵁
+                oCn.RunProc("exec h_p_IFK3_ToERP_MateOutBill_Check " + omodel.HInterID.ToString() + "," + omodel.HBillerID.ToString());
+                //鏇存柊搴撳瓨
+                oCn.RunProc("exec h_p_IFK3_ToERP_MateOutBill_UpdateStock " + omodel.HInterID.ToString());
+                oCn.RunProc("exec h_p_IFK3_ToERP_MateOutBill_UpdateOrderStock " + omodel.HInterID.ToString());
+
+                //鍒ゆ柇鏉$爜搴撳瓨鏄惁寮傚父锛堣礋搴撳瓨銆佸簱瀛樺ぇ浜庢潯鐮佸垵濮嬪寲锛�
+                Ds = oCn.RunProcReturn("EXEC h_p_KF_ICInventoryBarCodeQtyCtrl  " + omodel.HInterID.ToString(), "h_p_KF_ICInventoryBarCodeQtyCtrl");
+
+                if (DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0][0]) == 1)
+                {
+
+                }
+                else
+                {
+                    sReturn = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0][1]);
+                    oCn.RollBack();
+                    return false;
+                }
+                sReturn = "鏂板鍗曟嵁鎴愬姛锛�";
+                oCn.Commit();
+                return true;
+            }
+            catch (Exception e)
+            {
+                sReturn = e.Message;
+                oCn.RollBack();
+                throw (e);
+            }
+        }
+
+        //鏉$爜鎵弿璁板綍,鏂板鍒伴鏂欏嚭搴� (绾㈠瓧)
+        public bool AddBill_PDA_Red(ref string sReturn)
+        {
+            try
+            {
+                //鍒ゆ柇浼氳鏈熸槸鍚﹀悎鐞�
+                string s = "";
+                int sYear = 0;
+                int sPeriod = 0;
+                if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(omodel.HDate, ref sYear, ref sPeriod, ref s) == false)
+                {
+                    sReturn = s;
+                    return false;
+                }
+                omodel.HYear = sYear;
+                omodel.HPeriod = sPeriod;
+
+                DataSet Ds;
+                oCn.BeginTran();
+                //鍒犻櫎涓昏〃
+                oCn.RunProc("Delete From Kf_ICStockBillMain  where HInterID=" + omodel.HInterID.ToString());
+                //鎻掑叆瀛愯〃
+                oCn.RunProc("EXEC h_p_Kf_MateOutBillSub_Red_Insert " + omodel.HInterID.ToString() + ",'" + omodel.HBillNo + "'");
+                //鎻掑叆涓昏〃
+                oCn.RunProc("Insert Into Kf_ICStockBillMain   " +
+                "(HBillType,HBillSubType,HInterID,HBillNo,HDate,HMainSourceBillType" +
+                ",HYear,HPeriod,HRemark,HMaker,HMakeDate" +
+                ",HSupID,HWHID,HSCWHID,HEmpID,HManagerID,HSecManagerID" +
+                ",HKeeperID,HDeptID,HExplanation,HInnerBillNo,HRedBlueFlag" +
+                ") " +
+                " values('" + this.BillType + "','" + this.HBillSubType + "'," + omodel.HInterID.ToString() + ",'" + omodel.HBillNo + "',convert(varchar(10),getdate(),120),'" + omodel.HMainSourceBillType + "'" +
+                ", " + omodel.HYear.ToString() + "," + omodel.HPeriod.ToString() + ",'" + omodel.HRemark + "','" + omodel.HMaker + "',convert(varchar(10),getdate(),120)" +
+                ", " + omodel.HSupID.ToString() + "," + omodel.HWHID.ToString() + "," + omodel.HSCWHID.ToString() + "," + omodel.HEmpID.ToString() + "," + omodel.HManagerID.ToString() + "," + omodel.HSecManagerID.ToString() +
+                ", " + omodel.HKeeperID.ToString() + "," + omodel.HDeptID.ToString() + ",'" + omodel.HExplanation + "','" + omodel.HInnerBillNo + "'," + DBUtility.ClsPub.BoolToString(omodel.HRedBlueFlag) +
+                ") ");
+                //鏇存柊鍏宠仈鏁伴噺
+                oCn.RunProc("exec h_p_Sc_UpDatePPBomRelation_Add " + omodel.HInterID.ToString());
+                //瀹℃牳鍗曟嵁
+                oCn.RunProc("Update Kf_ICStockBillMain Set HChecker='" + omodel.HMaker + "',HCheckDate=convert(varchar(10),getdate(),120),HBillStatus=2 where HInterID= " + omodel.HInterID.ToString());
+                sReturn = "鏂板鍗曟嵁鎴愬姛锛�";
+                oCn.Commit();
+                return true;
+            }
+            catch (Exception e)
+            {
+                sReturn = e.Message;
+                oCn.RollBack();
+                throw (e);
+            }
+        }
+
+
+
+
+
+
+    }
+}
diff --git a/WebAPI/ListModels.cs b/WebAPI/ListModels.cs
index c8796ba..4a63f3d 100644
--- a/WebAPI/ListModels.cs
+++ b/WebAPI/ListModels.cs
@@ -1673,5 +1673,31 @@
             List<Models.UserPower> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Models.UserPower>>(jsonString);
             return list;
         }
+
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="jsonString"></param>
+        /// <returns></returns>
+        public List<Models.ClsKf_MateOutBillMain> getObjectByJson_Kf_ICStockBillMain(string jsonString)
+        {
+            jsonString = "[" + jsonString.ToString() + "]";
+            List<Models.ClsKf_MateOutBillMain> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Models.ClsKf_MateOutBillMain>>(jsonString);
+            return list;
+        }
+
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="jsonString"></param>
+        /// <returns></returns>
+        public List<Models.ClsKf_MateOutBillSub> getObjectByJson_Kf_MateOutBillSub(string jsonString)
+        {
+            jsonString = "[" + jsonString.ToString() + "]";
+            List<Models.ClsKf_MateOutBillSub> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Models.ClsKf_MateOutBillSub>>(jsonString);
+            return list;
+        }
     }
 } 
\ No newline at end of file
diff --git a/WebAPI/Models/ClsKf_ICStockBillMain.cs b/WebAPI/Models/ClsKf_ICStockBillMain.cs
new file mode 100644
index 0000000..5af248d
--- /dev/null
+++ b/WebAPI/Models/ClsKf_ICStockBillMain.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace WebAPI.Models
+{
+    public class ClsKf_ICStockBillMain:DBUtility.ClsXt_BaseBillMain
+    {
+        public Int64 HSupID;            //			int	            --往来单位(界面上不需要显示,存0进去)
+        public Int64 HWHID;             //			int         	--仓库
+        public Int64 HSCWHID;           //			int         	--调出仓库( 界面上不需要显示,存0进去)
+        public Int64 HEmpID;            //			int         	--业务员
+        public Int64 HManagerID;        //          int    	        --负责人(主管)
+        public Int64 HSecManagerID;     //  		int   	        --验收
+        public Int64 HKeeperID;         //  		int	            --保管员
+        public Int64 HDeptID;           //			int         	--部门
+        public Int64 HCurID;            //			int	            --币别( 界面上不需要显示,存0进去)
+        public string HExplanation;     //		    varchar(200)	--摘要
+        public string HInnerBillNo;     //		    varchar(50) 	--内部单据号
+        public bool HRedBlueFlag;       //		    bit    		    --红蓝单
+        public Int64 HSellSID;          //		    int	            --销售方式 (Gy_SellStyle)	addnew
+        public Int64 HConveyCompID;     //		    int		        --运输公司		addnew
+        public Int64 HConveyTypeID;     //		    int		        --运输方式		addnew
+        public Single HCarriage;        //		    money		    --运费			addnew
+        public string HSeOrderBillNo_M; //	        varchar(100)	--销售订单		addnew
+        public string HSeOrderBillNo;   //		    varchar(100)	--销售订单		addnew
+        public double HConveyMoney;     //		    dec(18,8)	    --送货费用(无用)
+        public double HCheckMoney;      //	        dec(18,8)	    --检测费用(无用)
+        public double HCheckMoneyFor;   //		    dec(18,8)	    --检测费用本位币(无用)
+        public double HRemainMoney;     //		    dec(18,8)	    --核销剩余数量(无用)
+        public Int64 HCheckStatus;      //		    int		        --核销状态(无用)
+        public string HHookType;        //		    varchar(50) 	--勾稽类型(无用)
+        public double HHookQty;         //		    dec(18,8)	    --勾稽数量(无用)
+        public string HCarNo;           //			varchar(100)	--车牌号	
+        public string HMainSourceBillType;//	    varchar(50)	    --源单类型
+        public string HLinkMan;         //		    varchar(50) 	--联系人
+        public string HLinkPhone;       //		    varchar(50)	    --联系电话
+        public string HAddress;         //		    varchar(500)	--送货地址
+        public Int64 HProcID;           //			int		        --工序(gy_process)
+        public Int64 HSALEORGID;        //		    int		        --销售组织
+        public Int64 HPRDORGID;         //		    int		        --生产组织
+        public Int64 HSTOCKORGID;       //		    int		        --库存组织
+        public Int64 HOWNERID;          //		    int		        --货主
+        public Int64 HSETTLEORGID;      //		    int		        --结算组织
+        public Int64 HOWNERSUPPLIERID;  //	        int		        --供应货主
+        public Int64 HDEMANDORGID;      //		    int		        --需求组织
+        public Int64 HPURCHASEORGID;    //		    int		        --采购组织
+        public Int64 HPAYORGID;         //		    int		        --付款结算组织
+        public string HOWNERTYPEID;     //		    varchar(100)	--货主类型
+        public string HStockStyle;      //		    varchar(100)	--库存类型
+
+    }
+}
diff --git a/WebAPI/Models/ClsKf_ICStockBillScheme.cs b/WebAPI/Models/ClsKf_ICStockBillScheme.cs
new file mode 100644
index 0000000..c6d8a47
--- /dev/null
+++ b/WebAPI/Models/ClsKf_ICStockBillScheme.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace WebAPI.Models
+{
+    public class ClsKf_ICStockBillScheme : DBUtility.ClsXt_BaseBillSub
+    {
+        public Int64 HItemID;
+        public string HBillType;
+        public Int64 HMaterID;
+        public Int64 HProcID;
+        public Int64 HWhID;
+        public Int64 HGroupID;
+        public double HQty;
+        public string HBarCode;
+        public string HAddr;
+        public string HMaker;
+        public DateTime HMakeDate;
+        public Int64 HSourceItemID;
+
+    }
+}
diff --git a/WebAPI/Models/ClsKf_ICStockBillSub.cs b/WebAPI/Models/ClsKf_ICStockBillSub.cs
new file mode 100644
index 0000000..36d61a4
--- /dev/null
+++ b/WebAPI/Models/ClsKf_ICStockBillSub.cs
@@ -0,0 +1,71 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace WebAPI.Models
+{
+    public class ClsKf_ICStockBillSub:DBUtility.ClsXt_BaseBillSub
+    { 
+        public Int64 HMaterID;              //		int		        --物料ID
+        public Int64 HPropertyID;           //		int		        --辅助属性
+        public Int64 HSecUnitID;            //		int		        --辅助计量单位
+        public Single HSecUnitRate;         //		money		    --换算率 
+        public Int64 HUnitID;               //		int		        --计量单位
+        public double HQtyMust;             //		dec(18,8)	    --应收数量
+        public double HQty;                 //		dec(18,8)	    --实收数量	
+        public double HPrice;               //		dec(18,8)	    --单价
+        public double HMoney;               //		dec(18,8)	    --金额
+        public double HOrderPrice;          //		dec(18,8)	    --采购金额	--addnew
+        public Int64 HWHID;                 //		int		        --收料仓库
+        public Int64 HSCWHID;               //		int         	--调出仓库ID(界面上不需要显示,存0进去)
+        public Int64 HSPID;                 //		int		        --仓位ID
+        public Int64 HSCSPID;               //		int	            --调出仓位ID(界面上不需要显示,存0进去)
+        public Int64 HSPGroupID;            //		int		        --仓位组ID(仓库选择完自动带出)
+        public string HBatchNo;             //		varchar(50)	    --批次
+        public Int64 HPOOrderInterID;       //		int		        --采购订单主内码
+        public Int64 HPOOrderEntryID;       //		int		        --采购订单子内码
+        public string HPOOrderBillNo;       //		varchar(50)	    --采购订单号
+        public Int64 HSeOrderInterID;       //		int		        --销售订单主内码
+        public Int64 HSeOrderEntryID;       //		int		        --销售订单子内码
+        public string HSeOrderBillNo;       //		varchar(50)	    --销售订单号
+        public Int64 HICMOInterID;          //		int		        --生产订单主内码
+        public Int64 HICMOEntryID;          //		int		        --生产订单子内码
+        public string HICMOBillNo;          //		varchar(50)	    --生产订单号
+        public Int64 HWWOrderInterID;       //		int 		    --委外订单主内码
+        public Int64 HWWOrderEntryID;       //		int 		    --委外订单子内码
+        public string HWWOrderBillNo;       //		varchar(50) 	--委外订单号
+        public string HEngineNum;           //		varchar(100)	--发动机号(隐藏)
+        public string HUnderPanNum;         //		varchar(100)	--地盘号(隐藏)
+        public string HLeaveFactCard;       //		varchar(100)	--出厂证(隐藏)	
+        public double HSalePrice;           //		dec(18,8)	    --销售单价	--addnew
+        public Single HCostPrice;           //		money		    --成本单价	--addnew
+        public Single HCostMoney;           //		money		    --成本金额	--addnew
+        public double HQtyRel;              //		dec(18,8)	    --实际数量
+        public DateTime HEndDate;           //		datetime	    --结束日期
+        public bool HOldMaterBackFlag;      //	    bit		        --旧件返回标记
+        public Int64 HProcID;               //      int             --工序(Gy_Process)
+        public double HHookQty;             //		dec(18,8)	    --勾稽数量
+        public string HHookType;            //		varchar(50)	    --勾稽类型
+        public double HTaxPrice;            //		dec(18,8)	    --含税单价
+        public double HTaxMoney;            //		dec(18,8)	    --含税金额
+        public Int64 HPackMaterID;          //		int		        --包装材料
+        public double HPackQty;             //		dec(18,8)	    --包装数量
+        public Int64 HBottleMaterID;        //		int		        --无用
+        public double HBottleLackQty;       //		dec(18,8)	    --无用
+        public double HBottleQty;           //		dec(18,8)	    --无用
+        public string HMTONo;               //		varchar(50)	    --计划跟踪号
+        public Int64 HPlanMode;             //		int		        --计划模式
+        public Int64 HEOWNERSUPPLIERID;     //      int		        --供应组织货主
+        public Int64 HOWNERID;              //		int		        --货主
+        public Int64 HKEEPERID;             //		int		        --保管者
+        public Int64 HPARENTOWNERID;        //		int		        --产品货主
+        public Int64 HRECEIVEOWNERID;       //		int		        --收料组织
+        public string HOWNERTYPEID;         //		varchar(100)	--货主类型
+        public string HKEEPERTYPEID;        //		varchar(100)	--保管类型
+        public string HPARENTOWNERTYPEID;   //	    varchar(100)	--产品货主类型
+        public string HRECEIVEOWNERTYPEID;  //	    varchar(100)	--收料货主类型
+        public Single HTaxRate;             //		money   		--税率
+        public Int64 HSTOCKORGID;           //		int     		--库存组织
+
+    }
+}
diff --git a/WebAPI/Models/ClsKf_MateOutBillMain.cs b/WebAPI/Models/ClsKf_MateOutBillMain.cs
new file mode 100644
index 0000000..f5b43d1
--- /dev/null
+++ b/WebAPI/Models/ClsKf_MateOutBillMain.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace WebAPI.Models
+{
+    public class ClsKf_MateOutBillMain:DBUtility.ClsXt_BaseBillMain
+    {
+        public Int64 HSupID;//   int        		--供应商
+        public Int64 HWHID;//    int         		--仓库
+        public Int64 HSCWHID;//  int           		--调出仓库   
+        public Int64 HEmpID;//    int        		--业务员
+        public Int64 HManagerID;//   int    		--负责人
+        public Int64 HSecManagerID;//  int   		--验收
+        public Int64 HKeeperID;//   int     		--保管员
+        public Int64 HDeptID;//     int     		--部门
+        public string HExplanation;//   varchar(200)    	--摘要
+        public string HInnerBillNo;//  varchar(50)     	--内部单据号
+        public bool HRedBlueFlag;//  bit    		--红蓝单
+    }
+}
diff --git a/WebAPI/Models/ClsKf_MateOutBillScheme.cs b/WebAPI/Models/ClsKf_MateOutBillScheme.cs
new file mode 100644
index 0000000..22989ef
--- /dev/null
+++ b/WebAPI/Models/ClsKf_MateOutBillScheme.cs
@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace WebAPI.Models
+{
+    public class ClsKf_MateOutBillScheme : DBUtility.ClsXt_BaseBillSub
+    {
+        public Int64 HInterID;
+        public Int64 HEntryID;
+        public Int64 HItemID;
+        public string HBillType;
+        public Int64 HMaterID;
+        public Int64 HProcID;
+        public Int64 HWhID;
+        public Int64 HGroupID;
+        public double HQty;
+        public string HBarCode;
+        public string HAddr;
+        public string HMaker;
+        public DateTime HMakeDate;
+        public Int64 HSourceInterID;
+        public Int64 HSourceEntryID;
+        public string HSourceBillType;
+        public string HSourceBillNo;
+        public Int64 HSourceItemID;
+
+    }
+}
diff --git a/WebAPI/Models/ClsKf_MateOutBillSub.cs b/WebAPI/Models/ClsKf_MateOutBillSub.cs
new file mode 100644
index 0000000..6799a63
--- /dev/null
+++ b/WebAPI/Models/ClsKf_MateOutBillSub.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace WebAPI.Models
+{
+    public class ClsKf_MateOutBillSub:DBUtility.ClsXt_BaseBillSub
+    { 
+        public DateTime HEntryCloseDate;//   datetime      --行关闭 (默认为'')		new
+        public string HRemark;//         varchar(200)        --备注 
+        public Int64 HMaterID;//     int   			--物料ID
+        public Int64 HPropertyID;//  int    			--辅助属性
+        public Int64 HSecUnitID;//   int    			--辅助计量单位
+        public Single HSecUnitRate;//   	money			--换算率 	
+        public Int64 HUnitID;//    int      			--计量单位
+        public double HQtyMust;//   dec(18,8)       		--应收数量
+        public double HQty;//        dec(18,8)      		--实收数量
+        public double HPrice;//     dec(18,8)       		--单价
+        public double HMoney;//     dec(18,8)      		--金额
+        public Int64 HWHID;//      int      			--收料仓库
+        public Int64 HSCWHID;//    int         			--调出仓库ID 
+        public Int64 HSPID;//		int			--仓位ID		 
+        public Int64 HSCSPID;//		int 			--调出仓位ID	
+        public Int64 HSPGroupID;//	int			--仓位组ID(仓库选择完自动带出)		 
+        public string HBatchNo;//	varchar(50)		--批次		 
+        public Int64 HPOOrderInterID;//  int      		--采购订单主内码
+        public Int64 HPOOrderEntryID;//    int    		--采购订单子内码
+        public string HPOOrderBillNo;//    varchar(50)     	--采购订单号
+        public Int64 HSeOrderInterID;//   int     		--销售订单主内码
+        public Int64 HSeOrderEntryID;//	  int			--销售订单子内码
+        public string HSeOrderBillNo;//	varchar(50)		--销售订单号
+
+    }
+}

--
Gitblit v1.9.1