From 2d1dd7ea14fdf01d08ea52889037681dfb1a19cc Mon Sep 17 00:00:00 2001
From: duhe <226547893@qq.com>
Date: 星期日, 03 三月 2024 16:50:03 +0800
Subject: [PATCH] 1

---
 WebAPI/Controllers/仓存管理/领料发货/Kf_StepFoldOutBillController.cs |  722 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 705 insertions(+), 17 deletions(-)

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_StepFoldOutBillController.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_StepFoldOutBillController.cs"
index 9779566..e71f4bc 100644
--- "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_StepFoldOutBillController.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_StepFoldOutBillController.cs"
@@ -5,6 +5,9 @@
 using System.Web;
 using System.Web.Http;
 using WebAPI.Models;
+using Newtonsoft.Json.Linq;
+using Model;
+using DBUtility;
 
 namespace WebAPI.Controllers.浠撳瓨绠$悊.棰嗘枡鍙戣揣
 {
@@ -14,34 +17,76 @@
         private json objJsonResult = new json();
         public DataSet ds = new DataSet();
         public SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
+        public DAL.ClsKf_StepFoldOutBill BillOld = new DAL.ClsKf_StepFoldOutBill();
 
-        #region 鍒嗘寮忚皟鍑哄崟 鏌ヨ
+        #region 鍒嗘寮忚皟鍑哄崟 杩斿洖鍒楄〃
 
         [Route("Kf_StepFoldOutBill/GetStepFoldOutBillList")]
         [HttpGet]
-        public object GetStepFoldOutBillList(string sWhere, string user, string Organization)
+        //public object GetStepFoldOutBillList(string sWhere, string user, string Organization)
+        //{
+        //    try
+        //    {
+        //        //鍒ゆ柇鏄惁鏈夋煡璇㈡潈闄�
+        //        if (!DBUtility.ClsPub.Security_Log("Kf_MoveStockStepOutBillQuery", 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_StepFoldOutBillList where (璋冨叆缁勭粐='" + Organization + "')");
+        //        if (sWhere == null || sWhere.Equals(""))
+        //        {
+        //            ds = oCn.RunProcReturn(sql1 + " order by hmainid desc", "h_v_IF_StepFoldOutBillList");
+        //        }
+        //        else
+        //        {
+        //            string sql = sql1 + sWhere + " order by hmainid desc";
+        //            ds = oCn.RunProcReturn(sql, "h_v_IF_StepFoldOutBillList");
+        //        }
+
+        //        //if (ds.Tables[0].Rows.Count != 0 || ds != null)
+        //        //{
+        //        objJsonResult.code = "1";
+        //        objJsonResult.count = 1;
+        //        objJsonResult.Message = "Sucess锛�";
+        //        objJsonResult.data = ds.Tables[0];
+        //        return objJsonResult;
+        //        //}
+        //        //else
+        //        //{
+        //        //objJsonResult.code = "0";
+        //        //objJsonResult.count = 0;
+        //        //objJsonResult.Message = "鏃犳暟鎹�";
+        //        //objJsonResult.data = null;
+        //        //return objJsonResult;
+        //        //}
+        //    }
+        //    catch (Exception ex)
+        //    {
+        //        objJsonResult.code = "0";
+        //        objJsonResult.count = 0;
+        //        objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + ex.ToString();
+        //        objJsonResult.data = null;
+        //        return objJsonResult;
+        //    }
+        //}
+        public object list(string sWhere)
         {
             try
             {
-                //鍒ゆ柇鏄惁鏈夋煡璇㈡潈闄�
-                if (!DBUtility.ClsPub.Security_Log("Kf_MoveStockStepOutBillQuery", 1, false, user))
-                {
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = "鏃犳煡璇㈡潈闄�!";
-                    objJsonResult.data = null;
-                    return objJsonResult;
-                }
-
-                string sql1 = string.Format("select * from h_v_Kf_MoveStockStepOutBillList where (璋冨叆缁勭粐='" + Organization + "')");
                 if (sWhere == null || sWhere.Equals(""))
                 {
-                    ds = oCn.RunProcReturn(sql1 + " order by hmainid desc", "h_v_Kf_MoveStockStepOutBillList");
+                    ds = oCn.RunProcReturn("select * from h_v_IF_StepFoldOutBillList order by hmainid desc", "h_v_IF_StepFoldOutBillList");
                 }
                 else
                 {
+                    string sql1 = "select * from h_v_IF_StepFoldOutBillList where 1 = 1 ";
                     string sql = sql1 + sWhere + " order by hmainid desc";
-                    ds = oCn.RunProcReturn(sql, "h_v_Kf_MoveStockStepOutBillList");
+                    ds = oCn.RunProcReturn(sql, "h_v_IF_StepFoldOutBillList");
                 }
 
                 //if (ds.Tables[0].Rows.Count != 0 || ds != null)
@@ -61,16 +106,659 @@
                 //return objJsonResult;
                 //}
             }
-            catch (Exception ex)
+            catch (Exception e)
             {
                 objJsonResult.code = "0";
                 objJsonResult.count = 0;
-                objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + ex.ToString();
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鍒嗘寮忚皟鍑哄崟 鏌ヨ
+        [Route("Kf_StepFoldOutBill/cx")]
+        [HttpGet]
+        public object cx(long HInterID)
+        {
+            try
+            {
+
+                ds = oCn.RunProcReturn("select * from h_v_IF_StepFoldOutBillList where hmainid =" + HInterID, "h_v_IF_StepFoldOutBillList");
+                if (ds == null || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "false锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "Sucess锛�";
+                    objJsonResult.data = ds.Tables[0];
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鍒嗘寮忚皟鍑哄崟 淇濆瓨/缂栬緫鍔熻兘
+        [Route("Kf_StepFoldOutBill/Kf_StepFoldOutBillEdit")]
+        [HttpPost]
+        public object StepFoldOutBillEdit([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_StepFoldOutBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsKf_StepFoldOutBillMain>>(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 HManagerID = mainList[0].HManagerID;//璐熻矗浜�
+                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 HCurID = mainList[0].HCurID;
+
+                ds = oCn.RunProcReturn("select * from h_v_IF_StepFoldOutBillList where hmainid=" + HInterID + " and 鍗曟嵁鍙�='" + HBillNo + "'", "h_v_IF_StepFoldOutBillList");
+
+                if ((OperationType == 1 || OperationType == 2) && ds.Tables[0].Rows.Count == 0)//鏂板
+                {
+                    //涓昏〃
+                    oCn.RunProc(@"Insert Into Kf_ICStockBillMain   
+                        (HInterID,HBillNo,HDate,HBillType,HBillSubType,HBillStatus,HYear,HPeriod
+	                    ,HSupID,HWHID,HSCWHID,HEmpID,HManagerID,HSecManagerID,HKeeperID,HDeptID
+	                    ,HMaker,HMakeDate,HChecker,HUpDater
+	                    ,HDeleteMan,HCloseMan
+	                    ,HRemark,HExplanation,HInnerBillNo,HCurID)
+                        values(" + HInterID + ",'" + HBillNo + "','" + HDate + "','" + 1250 + "','" +
+                    HBillSubType + "'," + HBillStatus + "," + DateTime.Now.Year + "," + DateTime.Now.Month + "," + HSupID +
+                    "," + HWHID + "," + HSCWHID + "," + HEmpID + "," + HManagerID + "," + HSecManagerID +
+                    "," + HKeeperID + "," + HDeptID + ",'" + HMaker + "','" + HMakeDate + "','" + HChecker + "','" + HUpDater + "','" + HDeleteMan + "','" + HCloseMan + "','"
+                    + HRemark + "','" + HExplanation + "','" + HInnerBillNo + "'," + HCurID + "" + ")");
+                }
+                else if (OperationType == 3 || ds.Tables[0].Rows.Count != 0)
+                { //淇敼
+                    String sql="update Kf_ICStockBillMain   set " +
+                                "HRemark='" + HRemark + "', HUpDater='" + HMaker + "', HUpDateDate=getdate()" + " where HInterID=" + "HInterID";
+
+                    oCn.RunProc(sql);
+                    //鍒犻櫎瀛愯〃
+                    oCn.RunProc("delete from Kf_ICStockBillSub 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_StepFoldOutBillSub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsKf_StepFoldOutBillSub>>(msg3);
+
+            int i = 0;
+            foreach (ClsKf_StepFoldOutBillSub 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.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_ICStockBillSub", "Kf_ICStockBillSub");
+                if (Cs.Tables[0].Rows.Count != 0 && ClsPub.isLong(Cs.Tables[0].Rows[0]["HEntryID"].ToString()) != 0)
+                {
+                    NewHEntryID = ClsPub.isLong(Cs.Tables[0].Rows[0]["HEntryID"].ToString());
+                    NewHEntryID += 1;
+                }
+
+                oCn.RunProc($@"Insert into Kf_ICStockBillSub 
+                (HInterID,HEntryID,HRemark
+	            ,HMaterID,HUnitID,HSecUnitID,HPropertyID,HBatchNo
+	            ,HWHID,HSCWHID,HSPID,HSCSPID
+	            ,HQtyMust,HQty,HRelationQty,HRelationMoney,HSecUnitRate,HPrice,HMoney,HOrderPrice
+	            ,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType
+	            ,HPOOrderInterID,HPOOrderEntryID,HPOOrderBillNo,HSeOrderInterID,HSeOrderEntryID,HSeOrderBillNo) 
+                 values({HInterID},{NewHEntryID},'{oSub.HRemark}'
+                ,{oSub.HMaterID},{oSub.HUnitID},{oSub.HSecUnitID},{oSub.HPropertyID},'{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.HOrderPrice}
+                ,{oSub.HSourceInterID},{oSub.HSourceEntryID},'{oSub.HSourceBillNo}','{oSub.HSourceBillType}',{oSub.HPOOrderInterID},{oSub.HPOOrderEntryID}
+                ,'{oSub.HPOOrderBillNo}',{oSub.HSeOrderInterID},{oSub.HSeOrderEntryID},'{oSub.HSeOrderBillNo}')");
+            }
+
+            objJsonResult.code = "1";
+            objJsonResult.count = 1;
+            objJsonResult.Message = null;
+            objJsonResult.data = null;
+            return objJsonResult;
+        }
+
         #endregion
+
+        #region 鍒嗘寮忚皟鍑哄崟 鍒犻櫎鍔熻兘
+        [Route("Fb_StepFoldOutBill/DeltetFb_StepFoldOutBill")]
+        [HttpGet]
+        public object DeltetFb_StepFoldOutBill(string HInterID)
+        {
+            try
+            {
+                oCn.BeginTran();
+                oCn.RunProc("Delete From Kf_ICStockBillMain where HInterID = " + HInterID);
+                oCn.RunProc("Delete From Kf_ICStockBillSub where HInterID = " + HInterID);
+                oCn.Commit();
+                objJsonResult.code = "1";
+                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;
+            }
+        }
+        #endregion
+
+
+        #region 鍒嗘寮忚皟鍑哄崟 瀹℃牳/鍙嶅鏍�
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="HInterID">鍗曟嵁ID</param>
+        /// <param name="IsAudit">瀹℃牳(0),鍙嶅鏍�(1)</param>
+        /// <param name="CurUserName">瀹℃牳浜�</param>
+        /// <returns></returns>
+        [Route("Kf_StepFoldOutBill/AuditKf_StepFoldOutBill")]
+        [HttpGet]
+        public object AuditKf_StepFoldOutBill(string HInterID, int Type, string user)
+        {
+            string sql = "";
+            //ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
+            try
+            {
+                //鍒ゆ柇鏄惁鏈夊鏍告潈闄�
+                if (!DBUtility.ClsPub.Security_Log("Kf_MoveStockStepOutBill_Check", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳潈闄愬鏍�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                if (string.IsNullOrWhiteSpace(HInterID))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HInterID涓虹┖锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                ClsPub.CurUserName = user;
+                BillOld.MvarItemKey = "Kf_ICStockBillMain";
+
+
+                ds = oCn.RunProcReturn("select * from Kf_ICStockBillMain where HInterID = " + int.Parse(HInterID), "Kf_ICStockBillMain");
+                string HBillNo = "";
+                oCn.BeginTran();//寮�濮嬩簨鍔�
+
+                if (ds == null || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    HBillNo = ds.Tables[0].Rows[0]["HBillNo"].ToString();
+                }
+
+
+
+
+                //Type 1 瀹℃牳  2  鍙嶅鏍�
+                if (Type == 1)
+                {
+                    //瀹℃牳鍓嶆帶鍒�
+                    sql = "exec h_p_Cg_POInStockBill_BeforeCheckCtrl " + int.Parse(HInterID) + ",'" + HBillNo + "','" + user + "'";
+                    ds = oCn.RunProcReturn(sql, "h_p_Cg_POInStockBill_BeforeCheckCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:瀹℃牳鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+
+                    }
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+
+                    if (!BillOld.CheckBill(int.Parse(HInterID), HBillNo, "h_p_Cg_POInStockBill_AfterCheckCtrl", user, ref ClsPub.sExeReturnInfo))
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                else
+                {
+                    //鍙嶅鏍稿墠鎺у埗
+                    sql = "exec h_p_Cg_POInStockBill_BeforeUnCheckCtrl " + int.Parse(HInterID) + ",'" + HBillNo + "','" + user + "'";
+                    ds = oCn.RunProcReturn(sql, "h_p_Cg_POInStockBill_BeforeUnCheckCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:鍙嶅鏍稿墠鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+
+                    }
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (BillOld.AbandonCheck(int.Parse(HInterID), HBillNo, "h_p_Cg_POInStockBill_AfterUnCheckCtrl", user, ref ClsPub.sExeReturnInfo))
+                    {
+                        SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
+
+                    }
+                    else
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+
+                objJsonResult.code = "0";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鎵ц鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鎵ц澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鍒嗘寮忚皟鍑哄崟 鍏抽棴/鍙嶅叧闂姛鑳�
+        [Route("Kf_StepFoldOutBill/CloseKf_StepFoldOutBill")]
+        [HttpGet]
+        public object CloseKf_StepFoldOutBill(string HInterID, int Type, string user)
+        {
+            try
+            {
+                //鍒ゆ柇鏄惁鏈夊垹闄ゆ潈闄�
+                if (!DBUtility.ClsPub.Security_Log("Kf_MoveStockStepOutBill_Close", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳潈闄愬叧闂�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                if (string.IsNullOrWhiteSpace(HInterID))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HInterID涓虹┖锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                ClsPub.CurUserName = user;
+                BillOld.MvarItemKey = "Kf_ICStockBillMain";
+                oCn.BeginTran();//寮�濮嬩簨鍔�
+
+                //Type 1 鍏抽棴  2  鍙嶅叧闂�
+                if (Type == 1)
+                {
+                    //鍒ゆ柇鍗曟嵁鏄惁宸茬粡鍏抽棴
+                    DataSet ds;
+                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
+                    ds = oCn.RunProcReturn(sql, BillOld.MvarItemKey);
+                    if (ds == null || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦紒";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
+                    {
+                        if (ds.Tables[0].Rows[0]["HDeleteMan"] != null && ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘杩涜鍏抽棴!";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        //if (ds.Tables[0].Rows[0]["HChecker"] == null || ds.Tables[0].Rows[0]["HChecker"].ToString() == "")
+                        //{
+                        //    objJsonResult.code = "0";
+                        //    objJsonResult.count = 0;
+                        //    objJsonResult.Message = "鍗曟嵁鏈鏍�!涓嶈兘杩涜鍏抽棴!";
+                        //    objJsonResult.data = null;
+                        //    return objJsonResult;
+                        //}
+
+                        if (ds.Tables[0].Rows[0]["HCloseMan"] != null && ds.Tables[0].Rows[0]["HCloseMan"].ToString() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸插叧闂�!涓嶈兘鍐嶆鍏抽棴!";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        //鍏抽棴鍗曟嵁
+                        if (!BillOld.CloseBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                }
+                else
+                {
+                    //鍒ゆ柇鍗曟嵁鏄惁宸茬粡鍙嶅叧闂�
+                    DataSet ds;
+                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
+                    ds = oCn.RunProcReturn(sql, BillOld.MvarItemKey);
+                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
+                    {
+                        if (ds.Tables[0].Rows[0]["HDeleteMan"] != null && ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘杩涜鍏抽棴!";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        //if (ds.Tables[0].Rows[0]["HChecker"] == null || ds.Tables[0].Rows[0]["HChecker"].ToString() == "")
+                        //{
+                        //    objJsonResult.code = "0";
+                        //    objJsonResult.count = 0;
+                        //    objJsonResult.Message = "鍗曟嵁鏈鏍�!涓嶈兘杩涜鍏抽棴!";
+                        //    objJsonResult.data = null;
+                        //    return objJsonResult;
+                        //}
+                        if (ds.Tables[0].Rows[0]["HCloseMan"] == null || ds.Tables[0].Rows[0]["HCloseMan"].ToString() == "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁鏈叧闂�!涓嶉渶瑕佸啀鍙嶅叧闂�!";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        //鍙嶅叧闂崟鎹�
+                        if (!BillOld.CancelClose(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                }
+
+                oCn.Commit();//鎻愪氦浜嬪姟
+
+                objJsonResult.code = "0";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鎵ц鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult; ;
+
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鎵ц澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鍒嗘寮忚皟鍑哄崟 浣滃簾/鍙嶄綔搴熷姛鑳�
+        [Route("Kf_StepFoldOutBill/CancellKf_StepFoldOutBill")]
+        [HttpGet]
+        public object CancellKf_StepFoldOutBill(string HInterID, int Type, string user)
+        {
+            try
+            {
+                //鍒ゆ柇鏄惁鏈夊垹闄ゆ潈闄�
+                if (!DBUtility.ClsPub.Security_Log("Kf_MoveStockStepOutBill_Delete", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳潈闄愪綔搴�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                if (string.IsNullOrWhiteSpace(HInterID))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HInterID涓虹┖锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                ClsPub.CurUserName = user;
+
+                oCn.BeginTran();//寮�濮嬩簨鍔�
+
+                //Type 1 浣滃簾  2  鍙嶄綔搴�
+                if (Type == 1)
+                {
+                    if (!BillOld.Cancelltion(int.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "浣滃簾澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                else
+                {
+                    if (!BillOld.AbandonCancelltion(int.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶄綔搴熷け璐�!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+
+                oCn.Commit();//鎻愪氦浜嬪姟
+
+                objJsonResult.code = "0";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鎵ц鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult; ;
+
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鎵ц澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1