From ed65f00c01e31f2ba9ad7f681fea08a332120c06 Mon Sep 17 00:00:00 2001
From: yusijie <ysj@hz-kingdee.com>
Date: 星期三, 07 十二月 2022 11:08:20 +0800
Subject: [PATCH] 单据(调拨申请单,发货通知单,出库申请单);报表(奥邦/车间报表)

---
 WebAPI/Controllers/仓存管理/调拨盘点/Kf_MoveStockRequestBillController.cs |  264 ++++++++++++++++
 WorkM/报表分析/Sc_WorkShopReport.cs                                   |   40 -
 Model/仓库管理/ClsKf_StockOutRequestBillSub.cs                        |   23 +
 WebAPI/Controllers/仓存管理/领料发货/Kf_StockOutRequestBillController.cs  |  322 ++++++++++++++++++++
 Model/仓库管理/ClsKf_MoveStockRequestBillMain.cs                      |   10 
 Model/销售管理/ClsXs_SeOutStockBillMain.cs                            |   17 
 Model/仓库管理/ClsKf_StockOutRequestBillMain.cs                       |    7 
 Model/仓库管理/ClsKf_MoveStockRequestBillSub.cs                       |   20 +
 Model/销售管理/ClsXs_SeOutStockBillSub.cs                             |   11 
 WebAPI/Controllers/XSGL/Xs_SeOutStockBillController.cs            |  223 +++++++++++++
 WebAPI/WebAPI.csproj                                              |    2 
 11 files changed, 906 insertions(+), 33 deletions(-)

diff --git "a/Model/\344\273\223\345\272\223\347\256\241\347\220\206/ClsKf_MoveStockRequestBillMain.cs" "b/Model/\344\273\223\345\272\223\347\256\241\347\220\206/ClsKf_MoveStockRequestBillMain.cs"
index d48ace6..1f8a818 100644
--- "a/Model/\344\273\223\345\272\223\347\256\241\347\220\206/ClsKf_MoveStockRequestBillMain.cs"
+++ "b/Model/\344\273\223\345\272\223\347\256\241\347\220\206/ClsKf_MoveStockRequestBillMain.cs"
@@ -20,5 +20,15 @@
         public Int64 HDeptID;       //     	int     		--部门              
         public string HExplanation; //    	varchar(200)    --摘要 
         public string HInnerBillNo; //   	varchar(50)    	--内部单据号
+
+        public Int64 HERPInterID;
+        public string HERPBillType;
+        public Int64 HSTOCKINORGID;
+        public Int64 HSTOCKOUTORGID;
+        public string HStockStyle;
+        public string HOWNERTYPEHEADID;
+        public string HTRANSTYPE;
+        public string HOWNERTYPEINID;
+        public string HBUSINESSTYPE;
     }
 }
diff --git "a/Model/\344\273\223\345\272\223\347\256\241\347\220\206/ClsKf_MoveStockRequestBillSub.cs" "b/Model/\344\273\223\345\272\223\347\256\241\347\220\206/ClsKf_MoveStockRequestBillSub.cs"
index 8d836e6..5195f2b 100644
--- "a/Model/\344\273\223\345\272\223\347\256\241\347\220\206/ClsKf_MoveStockRequestBillSub.cs"
+++ "b/Model/\344\273\223\345\272\223\347\256\241\347\220\206/ClsKf_MoveStockRequestBillSub.cs"
@@ -33,5 +33,25 @@
         public Int64 HICMOInterID;      //      int         --生产订单ID
         public Int64 HICMOEntryID;      //      int         --生产订单子内码
         public string HICMOBillNo;      //      varchar(100)--生产订单号
+
+        public string HMTONo;
+        public Int64 HPlanMode;
+        public Int64 HERPInterID;
+        public Int64 HERPEntryID;
+        public Int64 HAuxPropID;
+        public string HBatchNO;
+        public Int64 HSPID;
+        public Int64 HSCSPID;
+        public Int64 HSTOCKORGID;
+        public Int64 HOWNERID;
+        public string HOWNERTYPEID;
+        public Int64 HSTOCKORGINID;
+        public Int64 HOWNERINID;
+        public string HOWNERTYPEINID;
+        public string HPRODUCEDATE;
+        public string HExpiryDate;
+        public Int64 HBASEUNITID;
+        public Int64 HEXTAUXUNITID;
+        public double HSECQTY;
     }
 }
diff --git "a/Model/\344\273\223\345\272\223\347\256\241\347\220\206/ClsKf_StockOutRequestBillMain.cs" "b/Model/\344\273\223\345\272\223\347\256\241\347\220\206/ClsKf_StockOutRequestBillMain.cs"
index 53828ab..196e63e 100644
--- "a/Model/\344\273\223\345\272\223\347\256\241\347\220\206/ClsKf_StockOutRequestBillMain.cs"
+++ "b/Model/\344\273\223\345\272\223\347\256\241\347\220\206/ClsKf_StockOutRequestBillMain.cs"
@@ -19,5 +19,12 @@
         public Int64 HDeptID;       //     	int     		--部门              
         public string HExplanation; //    	varchar(200)    --摘要 
         public string HInnerBillNo; //   	varchar(50)    	--内部单据号
+
+        public Int64 HERPInterID;//--ERP主内码
+        public string HERPBillType;//--ERP单据类型
+        public Int64 HSTOCKORGID;//--申请组织
+        public string HAPPLYTYPE;
+        public Int64 HOWNERTYPEIDHEAD;//--货主类型
+        public string HBIZTYPE;//--业务类型
     }
 }
diff --git "a/Model/\344\273\223\345\272\223\347\256\241\347\220\206/ClsKf_StockOutRequestBillSub.cs" "b/Model/\344\273\223\345\272\223\347\256\241\347\220\206/ClsKf_StockOutRequestBillSub.cs"
index 5effe7b..99e9051 100644
--- "a/Model/\344\273\223\345\272\223\347\256\241\347\220\206/ClsKf_StockOutRequestBillSub.cs"
+++ "b/Model/\344\273\223\345\272\223\347\256\241\347\220\206/ClsKf_StockOutRequestBillSub.cs"
@@ -30,5 +30,28 @@
         public Int64 HICMOInterID;      //      int         --生产订单ID
         public Int64 HICMOEntryID;      //      int         --生产订单子内码
         public string HICMOBillNo;      //      varchar(100)--生产订单号
+
+        public string HMTONo;
+        public Int64 HPlanMode;
+        public Int64 HERPInterID;
+        public Int64 HERPEntryID;
+        public Int64 HAuxPropID;
+        public string HBatchNO;
+        public Int64 HSPID;
+        public Int64 HSCSPID;
+        public Int64 HSTOCKORGID;
+        public Int64 HOWNERID;
+        public string HOWNERTYPEID;
+        public Int64 HSTOCKORGINID;
+        public Int64 HOWNERINID;
+        public string HOWNERTYPEINID;
+        public string HPRODUCEDATE;
+        public string HEXPIRYDATE;
+        public Int64 HBASEUNITID;
+        public Int64 HEXTAUXUNITID;
+        public double HSECQTY;
+        public Int64 HSEQ;
+        public Int64 HSTOCKSTATUSID;
+        public Int64 HBOMID;
     }
 }
diff --git "a/Model/\351\224\200\345\224\256\347\256\241\347\220\206/ClsXs_SeOutStockBillMain.cs" "b/Model/\351\224\200\345\224\256\347\256\241\347\220\206/ClsXs_SeOutStockBillMain.cs"
index 6e0f860..28018b5 100644
--- "a/Model/\351\224\200\345\224\256\347\256\241\347\220\206/ClsXs_SeOutStockBillMain.cs"
+++ "b/Model/\351\224\200\345\224\256\347\256\241\347\220\206/ClsXs_SeOutStockBillMain.cs"
@@ -11,19 +11,26 @@
         public Int64 HManagerID;//  int     			--主管	(Gy_Employee)
         public string HAddress;//     varchar(200)            	--交货地点 
         public Int64 HSSID;//	 int				--结算方式 (Gy_SettleStyle)
-        public Int64 HCusID;//	
+        public Int64 HCusID;//	客户
         public Int64 HCurID;//    int      			--币别 (Gy_Currency)
         public Single HExRate;//    money      			--汇率  (选择完币别带出)
-        public Int64 HWHID;//   
+        public Int64 HWHID;//  仓库
         public string HExplanation;//  varchar(200)     		--摘要 
         public string HInnerBillNo;//  varchar(50)     		--内部单据号
-        public Int64 HConveyTypeID;//	
-        public Int64 HConveyCompID;//	
-        public double HConveyMoney;//	
+        public Int64 HConveyTypeID;//	运输方式
+        public Int64 HConveyCompID;//	运输公司
+        public double HConveyMoney;//	运费
 
         public bool HDFflag; //是否垫付
         public string HLinkMan;//    varchar(50)      //联系人     new
         public string HLinkPhone;//   varchar(100)     //联系电话   new
 
+        public Int64 HSALEORGID;
+        public Int64 HDELIVERYORGID;
+        public Int64 HOWNERID;
+        public string HOWNERTYPEID;
+        public Int64 HERPInterID;
+        public string HERPBillType;
+
     }
 }
diff --git "a/Model/\351\224\200\345\224\256\347\256\241\347\220\206/ClsXs_SeOutStockBillSub.cs" "b/Model/\351\224\200\345\224\256\347\256\241\347\220\206/ClsXs_SeOutStockBillSub.cs"
index 11e67b9..378a743 100644
--- "a/Model/\351\224\200\345\224\256\347\256\241\347\220\206/ClsXs_SeOutStockBillSub.cs"
+++ "b/Model/\351\224\200\345\224\256\347\256\241\347\220\206/ClsXs_SeOutStockBillSub.cs"
@@ -18,5 +18,16 @@
         public Int64 HSeOrderEntryID;//	int		--销售订单子内码
         public string HSeOrderBillNo;//	varchar(50)	--销售订单号
 
+        public Int64 HSPID;
+        public Int64 HOWNERID;
+        public string HOWNERTYPEID;
+        public Int64 HSETTLEORGID;
+        public double HMoveStockQty;
+        public Int64 HAuxPropID;
+        public string HBatchNO;
+        public string HMTONo;
+        public Int64 HERPInterID;
+        public Int64 HERPEntryID;
+        public string HSeORderBillNo;
     }
 }
diff --git a/WebAPI/Controllers/XSGL/Xs_SeOutStockBillController.cs b/WebAPI/Controllers/XSGL/Xs_SeOutStockBillController.cs
index bd3e253..d45f65f 100644
--- a/WebAPI/Controllers/XSGL/Xs_SeOutStockBillController.cs
+++ b/WebAPI/Controllers/XSGL/Xs_SeOutStockBillController.cs
@@ -1,4 +1,5 @@
-锘縰sing Newtonsoft.Json.Linq;
+锘縰sing Model;
+using Newtonsoft.Json.Linq;
 using Pub_Class;
 using System;
 using System.Collections;
@@ -158,6 +159,226 @@
             }
         }
 
+        #region 鍙戣揣閫氱煡鍗� 淇濆瓨/缂栬緫鍔熻兘
+        [Route("Xs_SeOutStockBill/SeOutStockBillEdit")]
+        [HttpPost]
+        public object SeOutStockBillEdit([FromBody] JObject sMainSub)
+        {
+            try
+            {
+                var _value = sMainSub["sMainSub"].ToString();
+                string msg1 = _value.ToString();
+                oCN.BeginTran();
+                //淇濆瓨涓昏〃
+                objJsonResult = AddBillMain(msg1);
+                if (objJsonResult.code == "0")
+                {
+                    oCN.RollBack();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = objJsonResult.Message;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                oCN.Commit();
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鍗曟嵁淇濆瓨鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+
+            }
+            catch (Exception e)
+            {
+                oCN.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "淇濆瓨澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+        public json AddBillMain(string msg1)
+        {
+            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+            string msg2 = sArray[0].ToString(); //涓昏〃鏁版嵁
+            string msg3 = sArray[1].ToString(); //瀛愯〃鏁版嵁
+            int OperationType = int.Parse(sArray[2].ToString()); // 鏁版嵁绫诲瀷 1娣诲姞 3淇敼
+            string user = sArray[3].ToString();
+            string msg_allVal = sArray[4].ToString(); //涓昏〃+瀛愯〃鎵�鏈夋暟鎹�
+
+            try
+            {
+                msg2 = "[" + msg2.ToString() + "]";
+                List<ClsXs_SeOutStockBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsXs_SeOutStockBillMain>>(msg2);
+
+                long HInterID = mainList[0].HInterID;//閫掑叆type寰楀埌鐨勫崟鎹甀D
+                string HBillNo = mainList[0].HBillNo;//閫掑叆type寰楀埌鐨勫崟鎹彿
+                long HPRDORGID = mainList[0].HPRDORGID;//缁勭粐
+                DateTime HDate = mainList[0].HDate;//鏃ユ湡
+                string HRemark = mainList[0].HRemark;//澶囨敞
+                long HEmpID = mainList[0].HEmpID;//涓氬姟鍛�
+                long HDeptID = mainList[0].HDeptID;//閮ㄩ棬
+                long HWHID = mainList[0].HWHID;//浠撳簱
+                long HManagerID = mainList[0].HManagerID;//涓荤
+                long HCurID = mainList[0].HCurID;//甯佸埆
+                Single HExRate = mainList[0].HExRate;//姹囩巼
+                string HMaker = user;//鍒跺崟浜�
+                string HExplanation = mainList[0].HExplanation;//鎽樿
+                string HInnerBillNo = mainList[0].HInnerBillNo;//鍐呴儴鍗曟嵁鍙� 
+                long HCusID = mainList[0].HCusID; //瀹㈡埛
+                string HAddress = mainList[0].HAddress;//鍦板潃
+                long HSSID = mainList[0].HSSID;//缁撶畻鏂瑰紡
+
+                long HDFflag = Convert.ToInt32(mainList[0].HDFflag); //鏄惁鍨粯
+
+
+                string HBillType = mainList[0].HBillType;
+                string HBillSubType = mainList[0].HBillSubType;
+                long HBillStatus = mainList[0].HBillStatus;
+                string HMakeDate = mainList[0].HMakeDate;
+                string HChecker = mainList[0].HChecker;
+                string HCheckDate = mainList[0].HCheckDate;
+                string HUpDater = mainList[0].HUpDater;
+                string HUpDateDate = mainList[0].HUpDateDate;
+                string HDeleteMan = mainList[0].HDeleteMan;
+                string HDeleteDate = mainList[0].HDeleteDate;
+                string HCloseMan = mainList[0].HCloseMan;
+                string HCloseDate = mainList[0].HCloseDate;
+                long HERPInterID = mainList[0].HERPInterID;
+                string HERPBillType = mainList[0].HERPBillType;
+                long HSALEORGID = mainList[0].HSALEORGID;
+                long HDELIVERYORGID = mainList[0].HDELIVERYORGID;
+                long HOWNERID = mainList[0].HOWNERID;
+                string HOWNERTYPEID = mainList[0].HOWNERTYPEID;
+
+                ds = oCN.RunProcReturn("select * from h_v_IF_SeOutStockBillList where hmainid=" + HInterID + " and 鍗曟嵁鍙�='" + HBillNo + "'", "h_v_IF_SeOutStockBillList");
+
+                if ((OperationType == 1 || OperationType == 2) && ds.Tables[0].Rows.Count == 0)//鏂板
+                {
+                    //涓昏〃
+                    oCN.RunProc(@"Insert Into Xs_SeOutStockBillMain   
+                        (HInterID,HYear,HPeriod,HBillType,HBillSubType,HDate,HBillNo,HBillStatus
+	                    ,HCusID,HManagerID,HDeptID,HRemark,HMaker,HMakeDate
+	                    ,HAddress,HSSID,HCurID,HWHID,HExRate,HEmpID,HExplanation,HInnerBillNo
+	                    ,HSALEORGID,HDELIVERYORGID,HOWNERID,HOWNERTYPEID
+	                    ,HChecker,HCheckDate,HCloseMan,HCloseDate,HERPInterID,HERPBillType,HDFflag)
+                        values(" + HInterID + "," + DateTime.Now.Year + "," + DateTime.Now.Month + ",'" + 1402 + "','" +
+                    1402 + "','" + HDate + "','" + HBillNo + "'," + HBillStatus + "," + HCusID +
+                    "," + HManagerID + "," + HDeptID + ",'" + HRemark + "','" + HMaker + "','" + HMakeDate +
+                    "','" + HAddress + "'," + HSSID + "," + HCurID + "," + HWHID + "," + HExRate + "," + HEmpID + ",'" +
+                    HExplanation + "','" + HInnerBillNo + "'," + HSALEORGID + "," + HDELIVERYORGID + "," + HOWNERID + ",'"
+                    + HOWNERTYPEID + "','" + HChecker + "','" + HCheckDate + "','" + HCloseMan + "','" + HCloseDate + "'," + HERPInterID +
+                    ",'" + HERPBillType + "'," + HDFflag + ")");
+                }
+                else if (OperationType == 3 || ds.Tables[0].Rows.Count != 0)
+                { //淇敼
+                    oCN.RunProc("update Xs_SeOutStockBillMain  set " +
+                                "HRemark='" + HRemark + "', HChecker='" + HMaker + "', HCheckDate=getdate()" + "' where HInterID=" + HInterID);
+
+                    //鍒犻櫎瀛愯〃
+                    oCN.RunProc("delete from Xs_SeOutStockBillSub where HInterID='" + HInterID + "'");
+                }
+                //淇濆瓨瀛愯〃
+                objJsonResult = AddBillSub(msg3, HInterID, OperationType);
+
+                if (objJsonResult.code == "0")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = objJsonResult.Message;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = null;
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+        public json AddBillSub(string msg3, long HInterID, int OperationType)
+        {
+            List<ClsXs_SeOutStockBillSub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsXs_SeOutStockBillSub>>(msg3);
+
+            int i = 0;
+            foreach (ClsXs_SeOutStockBillSub oSub in DetailColl)
+            {
+                i++;
+                if (oSub.HQty <= 0 || oSub.HQty == null)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "绗�" + i + "琛岋紝鏁伴噺涓嶈兘涓�0鎴栬�呭皬浜�0";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                if (oSub.HMaterID == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "绗�" + i + "琛岋紝鐗╂枡涓嶈兘涓虹┖";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                //if (oSub.HSourceID == 0)
+                //{
+                //    objJsonResult.code = "0";
+                //    objJsonResult.count = 0;
+                //    objJsonResult.Message = "绗�" + i + "琛岋紝鐢熶骇璧勬簮涓嶈兘涓虹┖";
+                //    objJsonResult.data = null;
+                //    return objJsonResult;
+                //}
+
+                if (oSub.HUnitID == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "绗�" + i + "琛岋紝璁¢噺鍗曚綅涓嶈兘涓虹┖";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                DataSet Cs;
+                Int64 NewHEntryID = 1;
+                Cs = oCN.RunProcReturn("select MAX(HEntryID)HEntryID from Xs_SeOutStockBillSub", "Xs_SeOutStockBillSub");
+                if (Cs.Tables[0].Rows.Count != 0 && ClsPub.isLong(Cs.Tables[0].Rows[0]["HEntryID"].ToString()) != 0)
+                {
+                    NewHEntryID = ClsPub.isLong(Cs.Tables[0].Rows[0]["HEntryID"].ToString());
+                    NewHEntryID += 1;
+                }
+
+                oCN.RunProc($@"Insert into Xs_SeOutStockBillSub 
+                (HInterID,HEntryID,HMaterID,HUnitID,HQty,HPrice,HMoney,HWHID,HSPID,HRemark
+	            ,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HSeOrderInterID,HSeOrderEntryID,HSeORderBillNo
+	            ,HOWNERID,HOWNERTYPEID,HSETTLEORGID,HMoveStockQty
+	            ,HRelationQty,HAuxPropID,HBatchNO,HMTONo,HERPInterID,HERPEntryID) 
+                 values({HInterID},{NewHEntryID},{oSub.HMaterID},{oSub.HUnitID},{oSub.HQty}
+                ,{oSub.HPrice},{oSub.HMoney},{oSub.HWHID},{oSub.HSPID},'{oSub.HRemark}',{oSub.HSourceInterID},{oSub.HSourceEntryID},'{oSub.HSourceBillNo}','{oSub.HSourceBillType}',{oSub.HSeOrderInterID},{oSub.HSeOrderEntryID},'{oSub.HSeORderBillNo}',{oSub.HOWNERID},'{oSub.HOWNERTYPEID}',{oSub.HSETTLEORGID},{oSub.HMoveStockQty},{oSub.HRelationQty}
+                ,{oSub.HAuxPropID},'{oSub.HBatchNO}','{oSub.HMTONo}',{oSub.HERPInterID},{oSub.HERPEntryID})");
+            }
+
+            objJsonResult.code = "1";
+            objJsonResult.count = 1;
+            objJsonResult.Message = null;
+            objJsonResult.data = null;
+            return objJsonResult;
+        }
+
+        #endregion
 
         //
     }
diff --git "a/WebAPI/Controllers/\344\273\223\345\255\230\347\256\241\347\220\206/\350\260\203\346\213\250\347\233\230\347\202\271/Kf_MoveStockRequestBillController.cs" "b/WebAPI/Controllers/\344\273\223\345\255\230\347\256\241\347\220\206/\350\260\203\346\213\250\347\233\230\347\202\271/Kf_MoveStockRequestBillController.cs"
index f4c442a..d4c6f2c 100644
--- "a/WebAPI/Controllers/\344\273\223\345\255\230\347\256\241\347\220\206/\350\260\203\346\213\250\347\233\230\347\202\271/Kf_MoveStockRequestBillController.cs"
+++ "b/WebAPI/Controllers/\344\273\223\345\255\230\347\256\241\347\220\206/\350\260\203\346\213\250\347\233\230\347\202\271/Kf_MoveStockRequestBillController.cs"
@@ -1,4 +1,7 @@
-锘縰sing System;
+锘縰sing DBUtility;
+using Model;
+using Newtonsoft.Json.Linq;
+using System;
 using System.Collections.Generic;
 using System.Data;
 using System.Linq;
@@ -59,5 +62,264 @@
             }
         }
         #endregion
+
+        #region 璋冩嫧鍗� 淇濆瓨/缂栬緫鍔熻兘
+        [Route("Kf_MoveStockRequestBill/Kf_MoveStockRequestBillEdit")]
+        [HttpPost]
+        public object MoveStockRequestBillEdit([FromBody] JObject sMainSub)
+        {
+            try
+            {
+                var _value = sMainSub["sMainSub"].ToString();
+                string msg1 = _value.ToString();
+                oCn.BeginTran();
+                //淇濆瓨涓昏〃
+                objJsonResult = AddBillMain(msg1);
+                if (objJsonResult.code == "0")
+                {
+                    oCn.RollBack();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = objJsonResult.Message;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                oCn.Commit();
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鍗曟嵁淇濆瓨鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+
+            }
+            catch (Exception e)
+            {
+                oCn.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "淇濆瓨澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+        public json AddBillMain(string msg1)
+        {
+            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+            string msg2 = sArray[0].ToString(); //涓昏〃鏁版嵁
+            string msg3 = sArray[1].ToString(); //瀛愯〃鏁版嵁
+            int OperationType = int.Parse(sArray[2].ToString()); // 鏁版嵁绫诲瀷 1娣诲姞 3淇敼
+            string user = sArray[3].ToString();
+            string msg_allVal = sArray[4].ToString(); //涓昏〃+瀛愯〃鎵�鏈夋暟鎹�
+
+            try
+            {
+                msg2 = "[" + msg2.ToString() + "]";
+                List<ClsKf_MoveStockRequestBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsKf_MoveStockRequestBillMain>>(msg2);
+
+                long HInterID = mainList[0].HInterID;//閫掑叆type寰楀埌鐨勫崟鎹甀D
+                string HBillNo = mainList[0].HBillNo;//閫掑叆type寰楀埌鐨勫崟鎹彿
+                long HPRDORGID = mainList[0].HPRDORGID;//缁勭粐
+                DateTime HDate = mainList[0].HDate;//鏃ユ湡
+                string HRemark = mainList[0].HRemark;//澶囨敞
+                long HSupID = mainList[0].HSupID;//寰�鏉ュ崟浣�
+                long HEmpID = mainList[0].HEmpID;//涓氬姟鍛�
+                long HDeptID = mainList[0].HDeptID;//閮ㄩ棬
+                long HWHID = mainList[0].HWHID;//璋冨叆浠撳簱
+                long HSCWHID = mainList[0].HSCWHID;//璋冨嚭浠撳簱
+                long HMangerID = mainList[0].HMangerID;//涓荤
+                long HSecManagerID = mainList[0].HSecManagerID;//楠屾敹鍛�
+                long HKeeperID = mainList[0].HKeeperID;//淇濈鍛�
+                string HMaker = user;//鍒跺崟浜�
+                string HExplanation = mainList[0].HExplanation;//鎽樿
+                string HInnerBillNo = mainList[0].HInnerBillNo;//鍐呴儴鍗曟嵁鍙� 
+
+                string HBillType = mainList[0].HBillType;
+                string HBillSubType = mainList[0].HBillSubType;
+                long HBillStatus = mainList[0].HBillStatus;
+                string HMakeDate = mainList[0].HMakeDate;
+                string HChecker = mainList[0].HChecker;
+                string HCheckDate = mainList[0].HCheckDate;
+                string HUpDater = mainList[0].HUpDater;
+                string HUpDateDate = mainList[0].HUpDateDate;
+                string HDeleteMan = mainList[0].HDeleteMan;
+                string HDeleteDate = mainList[0].HDeleteDate;
+                string HCloseMan = mainList[0].HCloseMan;
+                string HCloseDate = mainList[0].HCloseDate;
+                long HERPInterID = mainList[0].HERPInterID;
+                string HERPBillType = mainList[0].HERPBillType;
+                long HSTOCKINORGID = mainList[0].HSTOCKINORGID;
+                long HSTOCKOUTORGID = mainList[0].HSTOCKOUTORGID;
+                string HStockStyle = mainList[0].HStockStyle;
+                string HOWNERTYPEHEADID = mainList[0].HOWNERTYPEHEADID;
+                string HTRANSTYPE = mainList[0].HTRANSTYPE;
+                string HOWNERTYPEINID = mainList[0].HOWNERTYPEINID;
+                string HBUSINESSTYPE = mainList[0].HBUSINESSTYPE;
+
+                ds = oCn.RunProcReturn("select * from h_v_IF_MoveStockRequestBillList where hmainid=" + HInterID + " and 鍗曟嵁鍙�='" + HBillNo + "'", "h_v_IF_MoveStockRequestBillList");
+
+                if ((OperationType == 1 || OperationType == 2) && ds.Tables[0].Rows.Count == 0)//鏂板
+                {
+                    //涓昏〃
+                    oCn.RunProc(@"Insert Into Kf_MoveStockRequestBillMain   
+                        (HInterID,HBillNo,HDate,HBillType,HBillSubType,HBillStatus,HYear,HPeriod
+	                    ,HSupID,HWHID,HSCWHID,HEmpID,HMangerID,HSecManagerID,HKeeperID,HDeptID
+	                    ,HMaker,HMakeDate,HChecker,HCheckDate,HUpDater,HUpDateDate
+	                    ,HDeleteMan,HDeleteDate,HCloseMan,HCloseDate
+	                    ,HRemark,HExplanation,HInnerBillNo,HERPInterID,HERPBillType
+	                    ,HSTOCKINORGID,HSTOCKOUTORGID,HStockStyle
+	                    ,HOWNERTYPEHEADID,HTRANSTYPE,HOWNERTYPEINID,HBUSINESSTYPE)
+                        values(" + HInterID + ",'" + HBillNo + "','" + HDate + "','" + 1243 + "','" +
+                    HBillSubType + "'," + HBillStatus + "," + DateTime.Now.Year + "," + DateTime.Now.Month + "," + HSupID +
+                    "," + HWHID + "," + HSCWHID + "," + HEmpID + "," + HMangerID + "," + HSecManagerID +
+                    "," + HKeeperID + "," + HDeptID + ",'" + HMaker + "','" + HMakeDate + "','" + HChecker + "','" + HCheckDate + "','" +  HUpDater + "','" +
+                    HUpDateDate + "','" + HDeleteMan + "','" + HDeleteDate + "','" + HCloseMan + "','" + HCloseDate + "','"
+                    + HRemark + "','" + HExplanation + "','" + HInnerBillNo + "'," + HERPInterID + ",'" + HERPBillType + "',"
+                    + HSTOCKINORGID + "," + HSTOCKOUTORGID + ",'" + HStockStyle + "','" + HOWNERTYPEHEADID + "','" + HTRANSTYPE + "','"
+                    + HOWNERTYPEINID + "','" + HBUSINESSTYPE + "'" + ")");
+                }
+                else if (OperationType == 3 || ds.Tables[0].Rows.Count != 0)
+                { //淇敼
+                    oCn.RunProc("update Kf_MoveStockRequestBillMain  set " +
+                                "HRemark='" + HRemark + "', HChecker='" + HMaker + "', HCheckDate=getdate()" + "' where HInterID=" + HInterID);
+
+                    //鍒犻櫎瀛愯〃
+                    oCn.RunProc("delete from Kf_MoveStockRequestBillSub where HInterID='" + HInterID + "'");
+                }
+                //淇濆瓨瀛愯〃
+                objJsonResult = AddBillSub(msg3, HInterID, OperationType);
+
+                if (objJsonResult.code == "0")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = objJsonResult.Message;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = null;
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+        public json AddBillSub(string msg3, long HInterID, int OperationType)
+        {
+            List<ClsKf_MoveStockRequestBillSub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsKf_MoveStockRequestBillSub>>(msg3);
+
+            int i = 0;
+            foreach (ClsKf_MoveStockRequestBillSub oSub in DetailColl)
+            {
+                i++;
+                if (oSub.HQty <= 0 || oSub.HQty == null)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "绗�" + i + "琛岋紝鏁伴噺涓嶈兘涓�0鎴栬�呭皬浜�0";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                if (oSub.HMaterID == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "绗�" + i + "琛岋紝鐗╂枡涓嶈兘涓虹┖";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                //if (oSub.HSourceID == 0)
+                //{
+                //    objJsonResult.code = "0";
+                //    objJsonResult.count = 0;
+                //    objJsonResult.Message = "绗�" + i + "琛岋紝鐢熶骇璧勬簮涓嶈兘涓虹┖";
+                //    objJsonResult.data = null;
+                //    return objJsonResult;
+                //}
+
+                if (oSub.HUnitID == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "绗�" + i + "琛岋紝璁¢噺鍗曚綅涓嶈兘涓虹┖";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                DataSet Cs;
+                Int64 NewHEntryID = 1;
+                Cs = oCn.RunProcReturn("select MAX(HEntryID)HEntryID from Kf_MoveStockRequestBillSub", "Kf_MoveStockRequestBillSub");
+                if (Cs.Tables[0].Rows.Count != 0 && ClsPub.isLong(Cs.Tables[0].Rows[0]["HEntryID"].ToString()) != 0)
+                {
+                    NewHEntryID = ClsPub.isLong(Cs.Tables[0].Rows[0]["HEntryID"].ToString());
+                    NewHEntryID += 1;
+                }
+
+                oCn.RunProc($@"Insert into Kf_MoveStockRequestBillSub 
+                (HInterID,HEntryID,HBillNo_bak,HRemark,HMTONo,HPlanMode,HERPInterID,HERPEntryID
+	            ,HMaterID,HUnitID,HSecUnitID,HPropertyID,HAuxPropID,HBatchNO
+	            ,HWHID,HSCWHID,HSPID,HSCSPID
+	            ,HQtyMust,HQty,HRelationQty,HRelationMoney,HSecUnitRate,HPrice,HMoney,HOutPrice,HOutMoney
+	            ,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType
+	            ,HICMOInterID,HICMOEntryID,HICMOBillNo,HPOOrderInterID,HPOOrderEntryID,HPOOrderBillNo,HSeOrderInterID,HSeOrderEntryID,HSeOrderBillNo
+	            ,HSTOCKORGID,HOWNERID,HOWNERTYPEID,HSTOCKORGINID,HOWNERINID,HOWNERTYPEINID,HPRODUCEDATE,HExpiryDate,HBASEUNITID,HEXTAUXUNITID,HSECQTY) 
+                 values({HInterID},{NewHEntryID},'{oSub.HBillNo_bak}','{oSub.HRemark}','{oSub.HMTONo}'
+                ,'{oSub.HPlanMode}',{oSub.HERPInterID},{oSub.HERPEntryID},{oSub.HMaterID},{oSub.HUnitID},{oSub.HSecUnitID},{oSub.HPropertyID},{oSub.HAuxPropID},'{oSub.HBatchNO}',{oSub.HWHID},{oSub.HSCWHID},{oSub.HSPID},{oSub.HSCSPID},{oSub.HQtyMust},{(oSub.HQty == null ? 0 : oSub.HQty)},{oSub.HRelationQty},{oSub.HRelationMoney},{oSub.HSecUnitRate},{oSub.HPrice},{oSub.HMoney},{oSub.HOutPrice},{oSub.HOutMoney}
+                ,{oSub.HSourceInterID},{oSub.HSourceEntryID},'{oSub.HSourceBillNo}','{oSub.HSourceBillType}',{oSub.HICMOInterID},{oSub.HICMOEntryID},'{oSub.HICMOBillNo}',{oSub.HPOOrderInterID},{oSub.HPOOrderEntryID}
+                ,'{oSub.HPOOrderBillNo}',{oSub.HSeOrderInterID},{oSub.HSeOrderEntryID},'{oSub.HSeOrderBillNo}',{oSub.HSTOCKORGID},{oSub.HOWNERID},'{oSub.HOWNERTYPEID}',{oSub.HSTOCKORGINID},{oSub.HOWNERINID}
+                ,'{oSub.HOWNERTYPEINID}','{oSub.HPRODUCEDATE}','{oSub.HExpiryDate}',{oSub.HBASEUNITID},{oSub.HEXTAUXUNITID},{oSub.HSECQTY})");
+            }
+
+            objJsonResult.code = "1";
+            objJsonResult.count = 1;
+            objJsonResult.Message = null;
+            objJsonResult.data = null;
+            return objJsonResult;
+        }
+
+        #endregion
+
+        /// <summary>
+        ///鍒犻櫎鍔熻兘
+        /// </summary>
+        /// <returns></returns>
+        [Route("Kf_MoveStockRequestBill/DeltetKf_MoveStockRequestBill")]
+        [HttpGet]
+        public object DeltetKf_MoveStockRequestBill(string HInterID)
+        {
+            try
+            {
+                oCn.BeginTran();
+                oCn.RunProc("Delete From Kf_MoveStockRequestBillMain where HInterID = " + HInterID);
+                oCn.RunProc("Delete From Kf_MoveStockRequestBillSub where HInterID = " + HInterID);
+                oCn.Commit();
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鍒犻櫎鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                oCn.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
     }
 }
\ No newline at end of file
diff --git "a/WebAPI/Controllers/\344\273\223\345\255\230\347\256\241\347\220\206/\351\242\206\346\226\231\345\217\221\350\264\247/Kf_StockOutRequestBillController.cs" "b/WebAPI/Controllers/\344\273\223\345\255\230\347\256\241\347\220\206/\351\242\206\346\226\231\345\217\221\350\264\247/Kf_StockOutRequestBillController.cs"
new file mode 100644
index 0000000..28a3b9c
--- /dev/null
+++ "b/WebAPI/Controllers/\344\273\223\345\255\230\347\256\241\347\220\206/\351\242\206\346\226\231\345\217\221\350\264\247/Kf_StockOutRequestBillController.cs"
@@ -0,0 +1,322 @@
+锘縰sing DBUtility;
+using Model;
+using Newtonsoft.Json.Linq;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Web;
+using System.Web.Http;
+using WebAPI.Models;
+
+
+namespace WebAPI.Controllers.浠撳瓨绠$悊.棰嗘枡鍙戣揣
+{
+    public class Kf_StockOutRequestBillController : ApiController
+    {
+        public DBUtility.ClsPub.Enum_BillStatus BillStatus;//鍗曟嵁鐘舵�侊紙鏂板锛屼慨鏀癸紝娴忚锛屾洿鏂板崟浠凤紝鍙樻洿锛�
+        private json objJsonResult = new json();
+        public DataSet ds = new DataSet();
+        public SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
+
+        #region 鍑哄簱鐢宠鍗曞垪琛�
+        [Route("Kf_StockOutRequestBill/GetStockOutRequestBillList")]
+        [HttpGet]
+        public object GetMoveStockRequestBillList(string sWhere, string user)
+        {
+            try
+            {
+                ////鍒ゆ柇鏄惁鏈夋煡璇㈡潈闄�
+                //if (!DBUtility.ClsPub.Security_Log("Kf_MoveStockRequestBill_Query", 1, false, user))
+                //{
+                //    objJsonResult.code = "0";
+                //    objJsonResult.count = 0;
+                //    objJsonResult.Message = "鏃犳潈闄愭煡璇�!";
+                //    objJsonResult.data = null;
+                //    return objJsonResult;
+                //}
+
+                string sql1 = string.Format("select * from h_v_IF_StockOutRequestBillList where 1=1 ");
+                if (sWhere == null || sWhere.Equals(""))
+                {
+                    ds = oCn.RunProcReturn(sql1 + " order by hmainid desc", "h_v_IF_StockOutRequestBillList");
+                }
+                else
+                {
+                    string sql = sql1 + sWhere + " order by hmainid desc";
+                    ds = oCn.RunProcReturn(sql, "h_v_IF_StockOutRequestBillList");
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                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 鍑哄簱鐢宠鍗� 淇濆瓨/缂栬緫鍔熻兘
+        [Route("Kf_StockOutRequestBill/StockOutRequestBillEdit")]
+        [HttpPost]
+        public object StockOutRequestBillEdit([FromBody] JObject sMainSub)
+        {
+            try
+            {
+                var _value = sMainSub["sMainSub"].ToString();
+                string msg1 = _value.ToString();
+                oCn.BeginTran();
+                //淇濆瓨涓昏〃
+                objJsonResult = AddBillMain(msg1);
+                if (objJsonResult.code == "0")
+                {
+                    oCn.RollBack();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = objJsonResult.Message;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                oCn.Commit();
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鍗曟嵁淇濆瓨鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+
+            }
+            catch (Exception e)
+            {
+                oCn.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "淇濆瓨澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+        public json AddBillMain(string msg1)
+        {
+            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+            string msg2 = sArray[0].ToString(); //涓昏〃鏁版嵁
+            string msg3 = sArray[1].ToString(); //瀛愯〃鏁版嵁
+            int OperationType = int.Parse(sArray[2].ToString()); // 鏁版嵁绫诲瀷 1娣诲姞 3淇敼
+            string user = sArray[3].ToString();
+            string msg_allVal = sArray[4].ToString(); //涓昏〃+瀛愯〃鎵�鏈夋暟鎹�
+
+            try
+            {
+                msg2 = "[" + msg2.ToString() + "]";
+                List<ClsKf_StockOutRequestBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsKf_StockOutRequestBillMain>>(msg2);
+
+                long HInterID = mainList[0].HInterID;//閫掑叆type寰楀埌鐨勫崟鎹甀D
+                string HBillNo = mainList[0].HBillNo;//閫掑叆type寰楀埌鐨勫崟鎹彿
+                long HPRDORGID = mainList[0].HPRDORGID;//缁勭粐
+                DateTime HDate = mainList[0].HDate;//鏃ユ湡
+                string HRemark = mainList[0].HRemark;//澶囨敞
+                long HSupID = mainList[0].HSupID;//寰�鏉ュ崟浣�
+                long HEmpID = mainList[0].HEmpID;//涓氬姟鍛�
+                long HDeptID = mainList[0].HDeptID;//閮ㄩ棬
+                long HWHID = mainList[0].HWHID;//浠撳簱
+                long HMangerID = mainList[0].HMangerID;//涓荤
+                long HSecManagerID = mainList[0].HSecManagerID;//楠屾敹
+                long HKeeperID = mainList[0].HKeeperID;//淇濈鍛�
+                string HMaker = user;//鍒跺崟浜�
+                string HExplanation = mainList[0].HExplanation;//鎽樿
+                string HInnerBillNo = mainList[0].HInnerBillNo;//鍐呴儴鍗曟嵁鍙� 
+
+                string HBillType = mainList[0].HBillType;
+                string HBillSubType = mainList[0].HBillSubType;
+                long HBillStatus = mainList[0].HBillStatus;
+                string HMakeDate = mainList[0].HMakeDate;
+                string HChecker = mainList[0].HChecker;
+                string HCheckDate = mainList[0].HCheckDate;
+                string HUpDater = mainList[0].HUpDater;
+                string HUpDateDate = mainList[0].HUpDateDate;
+                string HDeleteMan = mainList[0].HDeleteMan;
+                string HDeleteDate = mainList[0].HDeleteDate;
+                string HCloseMan = mainList[0].HCloseMan;
+                string HCloseDate = mainList[0].HCloseDate;
+                long HERPInterID = mainList[0].HERPInterID;
+                string HERPBillType = mainList[0].HERPBillType;
+                long HSTOCKORGID = mainList[0].HSTOCKORGID;
+                string HAPPLYTYPE = mainList[0].HAPPLYTYPE;
+                long HOWNERTYPEIDHEAD = mainList[0].HOWNERTYPEIDHEAD;
+                string HBIZTYPE = mainList[0].HBIZTYPE;
+
+                ds = oCn.RunProcReturn("select * from h_v_IF_StockOutRequestBillList where hmainid=" + HInterID + " and 鍗曟嵁鍙�='" + HBillNo + "'", "h_v_IF_StockOutRequestBillList");
+
+                if ((OperationType == 1 || OperationType == 2) && ds.Tables[0].Rows.Count == 0)//鏂板
+                {
+                    //涓昏〃
+                    oCn.RunProc(@"Insert Into Kf_StockOutRequestBillMain   
+                        (HInterID,HBillNo,HDate,HBillType,HBillSubType,HBillStatus,HYear,HPeriod
+	                    ,HSupID,HWHID,HEmpID,HMangerID,HSecManagerID,HKeeperID,HDeptID
+	                    ,HMaker,HMakeDate,HChecker,HCheckDate,HUpDater,HUpDateDate
+	                    ,HDeleteMan,HDeleteDate,HCloseMan,HCloseDate
+	                    ,HRemark,HExplanation,HInnerBillNo,HERPInterID,HERPBillType
+	                    ,HSTOCKORGID,HAPPLYTYPE,HOWNERTYPEIDHEAD,HBIZTYPE)
+                        values(" + HInterID + ",'" + HBillNo + "','" + HDate + "','" + 1242 + "','" +
+                    1242 + "'," + HBillStatus + "," + DateTime.Now.Year + "," + DateTime.Now.Month + "," + HSupID +
+                    "," + HWHID + "," + HEmpID + "," + HMangerID + "," + HSecManagerID + "," + HKeeperID +
+                    "," + HDeptID + ",'" + HMaker + "','" + HMakeDate + "','" + HChecker + "','" + HCheckDate + "','" + HUpDater + "','" +
+                    HUpDateDate + "','" + HDeleteMan + "','" + HDeleteDate + "','" + HCloseMan + "','" + HCloseDate + "','"
+                    + HRemark + "','" + HExplanation + "','" + HInnerBillNo + "'," + HERPInterID + ",'" + HERPBillType + "',"
+                    + HSTOCKORGID + ",'" + HAPPLYTYPE + "'," + HOWNERTYPEIDHEAD + ",'" + HBIZTYPE + "'" + ")");
+                }
+                else if (OperationType == 3 || ds.Tables[0].Rows.Count != 0)
+                { //淇敼
+                    oCn.RunProc("update Kf_StockOutRequestBillMain  set " +
+                                "HRemark='" + HRemark + "', HChecker='" + HMaker + "', HCheckDate=getdate()" + "' where HInterID=" + HInterID);
+
+                    //鍒犻櫎瀛愯〃
+                    oCn.RunProc("delete from Kf_StockOutRequestBillSub where HInterID='" + HInterID + "'");
+                }
+                //淇濆瓨瀛愯〃
+                objJsonResult = AddBillSub(msg3, HInterID, OperationType);
+
+                if (objJsonResult.code == "0")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = objJsonResult.Message;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = null;
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+        public json AddBillSub(string msg3, long HInterID, int OperationType)
+        {
+            List<ClsKf_StockOutRequestBillSub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsKf_StockOutRequestBillSub>>(msg3);
+
+            int i = 0;
+            foreach (ClsKf_StockOutRequestBillSub oSub in DetailColl)
+            {
+                i++;
+                if (oSub.HQty <= 0 || oSub.HQty == null)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "绗�" + i + "琛岋紝鏁伴噺涓嶈兘涓�0鎴栬�呭皬浜�0";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                if (oSub.HMaterID == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "绗�" + i + "琛岋紝鐗╂枡涓嶈兘涓虹┖";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                //if (oSub.HSourceID == 0)
+                //{
+                //    objJsonResult.code = "0";
+                //    objJsonResult.count = 0;
+                //    objJsonResult.Message = "绗�" + i + "琛岋紝鐢熶骇璧勬簮涓嶈兘涓虹┖";
+                //    objJsonResult.data = null;
+                //    return objJsonResult;
+                //}
+
+                if (oSub.HUnitID == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "绗�" + i + "琛岋紝璁¢噺鍗曚綅涓嶈兘涓虹┖";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                DataSet Cs;
+                Int64 NewHEntryID = 1;
+                Cs = oCn.RunProcReturn("select MAX(HEntryID)HEntryID from Kf_StockOutRequestBillSub", "Kf_StockOutRequestBillSub");
+                if (Cs.Tables[0].Rows.Count != 0 && ClsPub.isLong(Cs.Tables[0].Rows[0]["HEntryID"].ToString()) != 0)
+                {
+                    NewHEntryID = ClsPub.isLong(Cs.Tables[0].Rows[0]["HEntryID"].ToString());
+                    NewHEntryID += 1;
+                }
+
+                oCn.RunProc($@"Insert into Kf_StockOutRequestBillSub 
+                (HInterID,HEntryID,HBillNo_bak,HRemark,HMTONo,HPlanMode,HERPInterID,HERPEntryID
+	            ,HMaterID,HUnitID,HSecUnitID,HPropertyID,HAuxPropID,HBatchNO,HWHID,HSPID
+	            ,HQtyMust,HQty,HRelationQty,HRelationMoney,HSecUnitRate,HPrice,HMoney
+	            ,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType
+	            ,HICMOInterID,HICMOEntryID,HICMOBillNo,HPOOrderInterID,HPOOrderEntryID,HPOOrderBillNo
+	            ,HSeOrderInterID,HSeOrderEntryID,HSeOrderBillNo
+	            ,HSEQ,HSTOCKORGID,HSTOCKSTATUSID,HOWNERTYPEID,HEXTAUXUNITID
+	            ,HOWNERID,HBOMID,HBASEUNITID,HPRODUCEDATE,HEXPIRYDATE) 
+                 values({HInterID},{NewHEntryID},'{oSub.HBillNo_bak}','{oSub.HRemark}','{oSub.HMTONo}'
+                ,'{oSub.HPlanMode}',{oSub.HERPInterID},{oSub.HERPEntryID},{oSub.HMaterID},{oSub.HUnitID},{oSub.HSecUnitID},{oSub.HPropertyID},{oSub.HAuxPropID},'{oSub.HBatchNO}',{oSub.HWHID},{oSub.HSPID},{oSub.HQtyMust},{(oSub.HQty == null ? 0 : oSub.HQty)},{oSub.HRelationQty},{oSub.HRelationMoney},{oSub.HSecUnitRate},{oSub.HPrice},{oSub.HMoney}
+                ,{oSub.HSourceInterID},{oSub.HSourceEntryID},'{oSub.HSourceBillNo}','{oSub.HSourceBillType}',{oSub.HICMOInterID},{oSub.HICMOEntryID},'{oSub.HICMOBillNo}',{oSub.HPOOrderInterID},{oSub.HPOOrderEntryID}
+                ,'{oSub.HPOOrderBillNo}',{oSub.HSeOrderInterID},{oSub.HSeOrderEntryID},'{oSub.HSeOrderBillNo}',{oSub.HSEQ},{oSub.HSTOCKORGID},{oSub.HSTOCKSTATUSID},'{oSub.HOWNERTYPEID}',{oSub.HEXTAUXUNITID},{oSub.HOWNERID}
+                ,{oSub.HBOMID},{oSub.HBASEUNITID},'{oSub.HPRODUCEDATE}','{oSub.HEXPIRYDATE}')");
+            }
+
+            objJsonResult.code = "1";
+            objJsonResult.count = 1;
+            objJsonResult.Message = null;
+            objJsonResult.data = null;
+            return objJsonResult;
+        }
+
+        #endregion
+
+        /// <summary>
+        ///鍒犻櫎鍔熻兘
+        /// </summary>
+        /// <returns></returns>
+        [Route("Kf_StockOutRequestBill/DeltetKf_StockOutRequestBill")]
+        [HttpGet]
+        public object DeltetKf_StockOutRequestBill(string HInterID)
+        {
+            try
+            {
+                oCn.BeginTran();
+                oCn.RunProc("Delete From Kf_StockOutRequestBillMain where HInterID = " + HInterID);
+                oCn.RunProc("Delete From Kf_StockOutRequestBillSub where HInterID = " + HInterID);
+                oCn.Commit();
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鍒犻櫎鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                oCn.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+    }
+}
\ No newline at end of file
diff --git a/WebAPI/WebAPI.csproj b/WebAPI/WebAPI.csproj
index 79619d3..e8bc19a 100644
--- a/WebAPI/WebAPI.csproj
+++ b/WebAPI/WebAPI.csproj
@@ -441,6 +441,7 @@
     <Compile Include="Controllers\浠撳瓨绠$悊\璋冩嫧鐩樼偣\Kf_MoveStockRequestBillController.cs" />
     <Compile Include="Controllers\浠撳瓨绠$悊\棰嗘枡鍙戣揣\apiController.cs" />
     <Compile Include="Controllers\浠撳瓨绠$悊\棰嗘枡鍙戣揣\Kf_StepFoldOutBillController.cs" />
+    <Compile Include="Controllers\浠撳瓨绠$悊\棰嗘枡鍙戣揣\Kf_StockOutRequestBillController.cs" />
     <Compile Include="Controllers\浠撳瓨绠$悊\楠屾敹鍏ュ簱\Kf_StepFoldinBillController.cs" />
     <Compile Include="Controllers\鍗氭棩鑷姩鎵爜绾縗ScanlineAPIController.cs" />
     <Compile Include="Controllers\鍩虹璧勬枡\鍩虹璧勬枡\Gy_COMMONCONTACTBillController.cs" />
@@ -911,6 +912,7 @@
     <Folder Include="Views\KF_PonderationBill\" />
     <Folder Include="Views\kf_StepFoldinBill\" />
     <Folder Include="Views\Kf_StepFoldOutBill\" />
+    <Folder Include="Views\Kf_StockOutRequestBill\" />
     <Folder Include="Views\Mes_OrderProcFlowAllReport\" />
     <Folder Include="Views\MoveStockBill\" />
     <Folder Include="Views\Pay_Report\" />
diff --git "a/WorkM/\346\212\245\350\241\250\345\210\206\346\236\220/Sc_WorkShopReport.cs" "b/WorkM/\346\212\245\350\241\250\345\210\206\346\236\220/Sc_WorkShopReport.cs"
index 2ddd55c..8d13608 100644
--- "a/WorkM/\346\212\245\350\241\250\345\210\206\346\236\220/Sc_WorkShopReport.cs"
+++ "b/WorkM/\346\212\245\350\241\250\345\210\206\346\236\220/Sc_WorkShopReport.cs"
@@ -166,8 +166,8 @@
             {
                 sDlgWhere = sDlgWhere.Substring(1, sDlgWhere.Length - 1);
             }
-            //
-            DSet = SubCn.RunProcReturn("exec h_p_CJKB" + sDlgWhere, "Gy_Czygl");
+
+            DSet = SubCn.RunProcReturn("exec h_p_CJKB " + sDlgWhere, "h_p_CJKB");
             //鐢熸垚棣栬鏍囬
             if (DSet == null)
             {
@@ -176,33 +176,21 @@
             }
             //
             grdMain.DataSource = DSet.Tables[0].DefaultView;
-            //鑾峰彇鍔ㄦ�佸垪 锛堢墿鏂欎俊鎭級
 
-            //DsHead = SubCn.RunProcReturn("exec h_p_Sc_GetProcExchReportHead " + sDlgWhere, "Gy_Czygl");
-
-            //for (int a = 0; a < DsHead.Tables[0].Rows.Count; a++)
-            //{
-            //    if (ClsPub.isLong(DsHead.Tables[0].Rows[a]["HMaterID"]) != 0)
-            //    {
-            //        grdMain.Columns.Add(ClsPub.isStrNull(DsHead.Tables[0].Rows[a]["HMaterID"]), ClsPub.isStrNull(DsHead.Tables[0].Rows[a]["HName"]));
-            //        grdMain.Columns[BCol].Tag = ClsPub.isLong(DsHead.Tables[0].Rows[a]["HMaterID"]);
-            //        BCol = BCol + 1;
-            //    }
-            //}
             BCol = 7;
             //鑾峰彇鍔ㄦ�佸唴瀹�  锛堟暟閲忎俊鎭級
-            for (int row = 0; row <= grdMain.RowCount - 1; row++)
-            {
-                for (int col = BCol; col <= grdMain.ColumnCount - 1; col++)
-                {
-                    HDeptID = DBUtility.ClsPub.isLong(grdMain.Rows[row].Cells[Fun_GetCol("HDeptID")].Value);
-                    DsQty = SubCn.RunProcReturn("exec h_p_CJKB '" +  HDeptID.ToString(), "Gy_Czygl");
-                    if (DsQty != null && DsQty.Tables[0].Rows.Count > 0)
-                    {
-                        grdMain.Rows[row].Cells[col].Value = DBUtility.ClsPub.isDoule(DsQty.Tables[0].Rows[0]["HQty"], 2);
-                    }
-                }
-            }
+            //for (int row = 0; row <= grdMain.RowCount - 1; row++)
+            //{
+            //    for (int col = BCol; col <= grdMain.ColumnCount - 1; col++)
+            //    {
+            //        //HDeptID = DBUtility.ClsPub.isLong(grdMain.Rows[row].Cells[Fun_GetCol("HDeptID")].Value);
+            //        DsQty = SubCn.RunProcReturn("exec h_p_CJKB " + 0, "h_p_CJKB");
+            //        if (DsQty != null && DsQty.Tables[0].Rows.Count > 0)
+            //        {
+            //            grdMain.Rows[row].Cells[col].Value = DBUtility.ClsPub.isDoule(DsQty.Tables[0].Rows[0]["HQty"], 2);
+            //        }
+            //    }
+            //}
 
             //璁剧疆鍚堣鍒�
             string sTotalCol = "";

--
Gitblit v1.9.1