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_StepFoldinBillController.cs |  639 ++++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 449 insertions(+), 190 deletions(-)

diff --git "a/WebAPI/Controllers/\344\273\223\345\255\230\347\256\241\347\220\206/\351\252\214\346\224\266\345\205\245\345\272\223/Kf_StepFoldinBillController.cs" "b/WebAPI/Controllers/\344\273\223\345\255\230\347\256\241\347\220\206/\351\252\214\346\224\266\345\205\245\345\272\223/Kf_StepFoldinBillController.cs"
index f82e477..e8c9713 100644
--- "a/WebAPI/Controllers/\344\273\223\345\255\230\347\256\241\347\220\206/\351\252\214\346\224\266\345\205\245\345\272\223/Kf_StepFoldinBillController.cs"
+++ "b/WebAPI/Controllers/\344\273\223\345\255\230\347\256\241\347\220\206/\351\252\214\346\224\266\345\205\245\345\272\223/Kf_StepFoldinBillController.cs"
@@ -6,6 +6,8 @@
 using System.Web;
 using System.Web.Http;
 using WebAPI.Models;
+using Newtonsoft.Json.Linq;
+using Model;
 
 namespace WebAPI.Controllers.浠撳瓨绠$悊.楠屾敹鍏ュ簱
 {
@@ -13,37 +15,81 @@
     {
         public DBUtility.ClsPub.Enum_BillStatus BillStatus;//鍗曟嵁鐘舵�侊紙鏂板锛屼慨鏀癸紝娴忚锛屾洿鏂板崟浠凤紝鍙樻洿锛�
         private json objJsonResult = new json();
-        public DAL.ClsCg_POInStockBill BillOld = new DAL.ClsCg_POInStockBill();
+        //public DAL.ClsCg_POInStockBill BillOld = new DAL.ClsCg_POInStockBill();
         public DataSet ds = new DataSet();
         public SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+        public DAL.ClsKf_StepFoldInBill BillOld = new DAL.ClsKf_StepFoldInBill();
 
-        #region 鍒嗘寮忚皟鍏ュ崟 鏌ヨ
+        #region 鍒嗘寮忚皟鍏ュ崟 杩斿洖鍒楄〃
 
         [Route("Kf_StepFoldinBill/GetStepFoldinBillList")]
         [HttpGet]
-        public object GetStepFoldinBillList(string sWhere, string user, string Organization)
+        //public object GetStepFoldinBillList(string sWhere, string user, string Organization)
+        //{
+        //    try
+        //    {
+        //        //鍒ゆ柇鏌ヨ鏉冮檺
+        //        if (!DBUtility.ClsPub.Security_Log("Fb_StepFoldinBill_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_Kf_MoveStockStepInBillList where (璋冨叆缁勭粐='" + Organization + "')");
+        //        if (sWhere == null || sWhere.Equals(""))
+        //        {
+        //            ds = oCN.RunProcReturn(sql1 + " order by hmainid desc", "h_v_Kf_MoveStockStepInBillList");
+        //        }
+        //        else
+        //        {
+        //            string sql = sql1 + sWhere + " order by hmainid desc";
+        //            ds = oCN.RunProcReturn(sql, "h_v_Kf_MoveStockStepInBillList");
+        //        }
+
+        //        //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;
+        //    }
+        //}
+
+        //#endregion
+        public object list(string sWhere)
         {
             try
             {
-                //鍒ゆ柇鏌ヨ鏉冮檺
-                if (!DBUtility.ClsPub.Security_Log("Fb_StepFoldinBill_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_Kf_MoveStockStepInBillList where (璋冨叆缁勭粐='" + Organization + "')");
                 if (sWhere == null || sWhere.Equals(""))
                 {
-                    ds = oCN.RunProcReturn(sql1 + " order by hmainid desc", "h_v_Kf_MoveStockStepInBillList");
+                    ds = oCN.RunProcReturn("select * from h_v_IF_StepFoldInBillList order by hmainid desc", "h_v_IF_StepFoldInBillList");
                 }
                 else
                 {
+                    string sql1 = "select * from h_v_IF_StepFoldInBillList where 1 = 1 ";
                     string sql = sql1 + sWhere + " order by hmainid desc";
-                    ds = oCN.RunProcReturn(sql, "h_v_Kf_MoveStockStepInBillList");
+                    ds = oCN.RunProcReturn(sql, "h_v_IF_StepFoldInBillList");
                 }
 
                 //if (ds.Tables[0].Rows.Count != 0 || ds != null)
@@ -63,17 +109,292 @@
                 //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_StepFoldInBill/cx")]
+        [HttpGet]
+        public object cx(long HInterID)
+        {
+            try
+            {
+
+                ds = oCN.RunProcReturn("select * from h_v_IF_StepFoldInBillList where hmainid =" + HInterID, "h_v_IF_StepFoldInBillList");
+                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_StepFoldInBill/Kf_StepFoldInBillEdit")]
+        [HttpPost]
+        public object StepFoldInBillEdit([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_StepFoldInBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsKf_StepFoldInBillMain>>(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 HPSStyleID = mainList[0].HPSStyleID;//閲囪喘鏂瑰紡
+                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_StepFoldInBillList where hmainid=" + HInterID + " and 鍗曟嵁鍙�='" + HBillNo + "'", "h_v_IF_StepFoldInBillList");
+
+                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 + "','" + 1251 + "','" +
+                    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_StepFoldInBillSub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsKf_StepFoldInBillSub>>(msg3);
+
+            int i = 0;
+            foreach (ClsKf_StepFoldInBillSub 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_StepFoldInBill/DeltetFb_StepFoldInBill")]
+        [HttpGet]
+        public object DeltetFb_StepFoldInBill(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>
@@ -83,10 +404,12 @@
         /// <param name="IsAudit">瀹℃牳(0),鍙嶅鏍�(1)</param>
         /// <param name="CurUserName">瀹℃牳浜�</param>
         /// <returns></returns>
-        [Route("Fb_StepFoldinBill/AuditFb_StepFoldinBill")]
+        [Route("Kf_StepFoldInBill/AuditKf_StepFoldInBill")]
         [HttpGet]
-        public object AuditFb_StepFoldinBill(string HInterID, int Type, string user)
+        public object AuditKf_StepFoldInBill(string HInterID, int Type, string user)
         {
+            string sql = "";
+            //ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
             try
             {
                 //鍒ゆ柇鏄惁鏈夊鏍告潈闄�
@@ -110,113 +433,105 @@
 
                 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)
                 {
-                    //鍒ゆ柇鍗曟嵁鏄惁宸茬粡瀹℃牳
-                    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)
+                    //瀹℃牳鍓嶆帶鍒�
+                    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 = 0;
-                        objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦紒";
+                        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 (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
+
+                    if (!BillOld.CheckBill(int.Parse(HInterID), HBillNo, "h_p_Cg_POInStockBill_AfterCheckCtrl", user, ref ClsPub.sExeReturnInfo))
                     {
-                        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 (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 (!BillOld.CheckBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
-                        {
-                            objJsonResult.code = "0";
-                            objJsonResult.count = 1;
-                            objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
-                            objJsonResult.data = null;
-                            return objJsonResult;
-                        }
+                        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)
+                    //鍙嶅鏍稿墠鎺у埗
+                    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)
                     {
-                        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 (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 (!BillOld.AbandonCheck(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
-                        {
-                            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;
+
+                    }
+                    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;
                     }
                 }
-
-                oCN.Commit();//鎻愪氦浜嬪姟
 
                 objJsonResult.code = "0";
                 objJsonResult.count = 1;
                 objJsonResult.Message = "鎵ц鎴愬姛锛�";
                 objJsonResult.data = null;
-                return objJsonResult; ;
-
+                return objJsonResult;
             }
+
             catch (Exception e)
             {
                 objJsonResult.code = "0";
@@ -229,9 +544,9 @@
         #endregion
 
         #region 鍒嗘寮忚皟鍏ュ崟 鍏抽棴/鍙嶅叧闂姛鑳�
-        [Route("Fb_StepFoldinBill/CloseFb_StepFoldinBill")]
+        [Route("Kf_StepFoldInBill/CloseKf_StepFoldInBill")]
         [HttpGet]
-        public object CloseFb_StepFoldinBill(string HInterID, int Type, string user)
+        public object CloseKf_StepFoldInBill(string HInterID, int Type, string user)
         {
             try
             {
@@ -283,14 +598,14 @@
                             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]["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() != "")
                         {
@@ -327,14 +642,14 @@
                             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]["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";
@@ -377,13 +692,13 @@
 
 
         #region 鍒嗘寮忚皟鍏ュ崟 浣滃簾/鍙嶄綔搴熷姛鑳�
-        [Route("Fb_StepFoldinBill/DropFb_StepFoldinBill")]
+        [Route("Kf_StepFoldInBill/CancellKf_StepFoldInBill")]
         [HttpGet]
-        public object DropFb_StepFoldinBill(string HInterID, int Type, string user)
+        public object CancellKf_StepFoldInBill(string HInterID, int Type, string user)
         {
             try
             {
-                //鍒ゆ柇鏄惁鏈変綔搴熸潈闄�
+                //鍒ゆ柇鏄惁鏈夊垹闄ゆ潈闄�
                 if (!DBUtility.ClsPub.Security_Log("Fb_StepFoldinBill_Delete", 1, false, user))
                 {
                     objJsonResult.code = "0";
@@ -403,86 +718,30 @@
                 }
 
                 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)
+                    if (!BillOld.Cancelltion(int.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                     {
                         objJsonResult.code = "0";
-                        objJsonResult.count = 0;
-                        objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦紒";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "浣滃簾澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
                         objJsonResult.data = null;
                         return objJsonResult;
-                    }
-                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
-                    {
-                        if (ds.Tables[0].Rows[0]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].ToString() != "")
-                        {
-                            objJsonResult.code = "0";
-                            objJsonResult.count = 0;
-                            objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶈兘杩涜浣滃簾!";
-                            objJsonResult.data = null;
-                            return objJsonResult;
-                        }
-                        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 (!BillOld.Cancelltion(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 (!BillOld.AbandonCancelltion(int.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                     {
-                        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]["HDeleteMan"] == null || ds.Tables[0].Rows[0]["HDeleteMan"].ToString() == "")
-                        {
-                            objJsonResult.code = "0";
-                            objJsonResult.count = 0;
-                            objJsonResult.Message = "鍗曟嵁鏈綔搴�!涓嶉渶瑕佸啀鍙嶄綔搴�!";
-                            objJsonResult.data = null;
-                            return objJsonResult;
-                        }
-                        //鍙嶄綔搴熷崟鎹�
-                        if (!BillOld.AbandonCancelltion(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
-                        {
-                            objJsonResult.code = "0";
-                            objJsonResult.count = 1;
-                            objJsonResult.Message = "鍙嶄綔搴熷け璐�!鍘熷洜:" + ClsPub.sExeReturnInfo;
-                            objJsonResult.data = null;
-                            return objJsonResult;
-                        }
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶄綔搴熷け璐�!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
                     }
                 }
 

--
Gitblit v1.9.1