From f331a2915eebc492e872206d9aa7e13fc7f0861f Mon Sep 17 00:00:00 2001
From: duhe <226547893@qq.com>
Date: 星期一, 12 八月 2024 09:04:51 +0800
Subject: [PATCH] 1

---
 WebAPI/Controllers/XSGL/Kf_ICStockBackBillController.cs |  128 ++++++++++++++++++++++++++++++++++++------
 1 files changed, 108 insertions(+), 20 deletions(-)

diff --git a/WebAPI/Controllers/XSGL/Kf_ICStockBackBillController.cs b/WebAPI/Controllers/XSGL/Kf_ICStockBackBillController.cs
index 84d34bc..c5cd285 100644
--- a/WebAPI/Controllers/XSGL/Kf_ICStockBackBillController.cs
+++ b/WebAPI/Controllers/XSGL/Kf_ICStockBackBillController.cs
@@ -8,6 +8,7 @@
 using System.Data.SqlClient;
 using System.Web.Http;
 using WebAPI.Models;
+using System.Windows.Forms;
 
 namespace WebAPI.Controllers
 {
@@ -160,6 +161,17 @@
                     oBill.DetailColl.Add(oItemSub);
                 }
 
+                //杩涜 浼氳鏈熼棿 缁撹处 鐨勫垽鏂拰鎺у埗
+                string s = "";
+                int sYear = 0;
+                int sPeriod = 0;
+                DateTime HDate = DateTime.Now;
+                if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false)
+                {
+                    objJsonResult.Message = s;
+                    return objJsonResult;
+                }
+
                 //淇濆瓨
                 //淇濆瓨瀹屾瘯鍚庡鐞�
                 bool bResult;
@@ -173,7 +185,6 @@
                 }
                 else                                                                    //缂栬緫淇濆瓨
                 {
-                    string s = "";
                     if (BillOld.ShowBill(lsmain[0].HInterID, ref s) == false)
                     {
                         objJsonResult.code = "0";
@@ -344,6 +355,16 @@
                 }
                 //==================================================================================  
 
+                //杩涜 浼氳鏈熼棿 缁撹处 鐨勫垽鏂拰鎺у埗
+                int sYear = 0;
+                int sPeriod = 0;
+                DateTime HDate = DateTime.Now;
+                if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false)
+                {
+                    objJsonResult.Message = s;
+                    return objJsonResult;
+                }
+
                 oCN.BeginTran();
 
                 //鍒犻櫎鍏宠仈
@@ -513,28 +534,80 @@
                     }
                     //==================================================================================      
 
-                    //oCN.BeginTran();
-                    ////澧炲姞鍏宠仈
-                    //oCN.RunProc("exec h_p_Xs_UpDateRelation_SeOrderToSellBack_Check " + HInterID + ",'" + CurUserName + "'");
-                    //瀹℃牳鎻愪氦
-                    if (oBill.CheckBill(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_Kf_SellOutBackBill_AfterCheckCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                    //杩涜 浼氳鏈熼棿 缁撹处 鐨勫垽鏂拰鎺у埗
+                    string s = "";
+                    int sYear = 0;
+                    int sPeriod = 0;
+                    DateTime HDate = DateTime.Now;
+                    if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false)
                     {
-                        //oCN.Commit();
-                        objJsonResult.code = "1";
-                        objJsonResult.count = 1;
-                        objJsonResult.Message = "瀹℃牳鎴愬姛";
-                        objJsonResult.data = null;
+                        objJsonResult.Message = s;
                         return objJsonResult;
                     }
-                    else
+
+                    //瀹℃牳鎻愪氦
+                    oCN.BeginTran();
+
+                    //瀹℃牳鏇存柊 鍙婃椂搴撳瓨琛� 澧炲姞搴撳瓨
+                    ds = oCN.RunProcReturn("exec h_KF_UPDateICinventory  '" + oBill.omodel.HInterID + "','" + oBill.omodel.HBillType + "','1'", "h_KF_UPDateICinventory");
+
+                    //澧炲姞鍏宠仈
+                    oCN.RunProc("exec h_p_Xs_UpDateRelation_SeOrderToSellBack_Check " + oBill.omodel.HInterID + ",'" + CurUserName + "'");
+                    //鍐欏叆鏃ュ織
+                    string WorkList = "瀹℃牳鍗曟嵁锛屽崟鎹彿锛�" + oBill.omodel.HBillNo;
+                    string SystemName = "LMES-閿�鍞��璐у崟妯″潡";
+                    oCN.RunProc("Insert into  System_Log(GeginDate,userid,WorkstationName,WorkList,SystemName,NetUserName,State) values " +
+                        "(getdate(),'" + CurUserName + "','" + SystemInformation.ComputerName + "','" + WorkList + "','" + SystemName + "','','瀹℃牳')"
+                        );
+
+
+                    //瀹℃牳鍚庢帶鍒�=========================================      
+                    string sql = "exec h_p_Kf_SellOutBackBill_AfterCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql, "h_p_Kf_SellOutBackBill_AfterCheckCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                     {
-                        //oCN.RollBack();
+                        oCN.RollBack();
                         objJsonResult.code = "0";
                         objJsonResult.count = 0;
-                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:瀹℃牳杩囩▼涓嚭閿欙紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
                         objJsonResult.data = null;
                         return objJsonResult;
                     }
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HBackRemark"].ToString();
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //=========================================      
+
+                    oCN.Commit();
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "瀹℃牳鎴愬姛";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+
+
+                    //if (oBill.CheckBill(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_Kf_SellOutBackBill_AfterCheckCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                    //{
+                    //    objJsonResult.code = "1";
+                    //    objJsonResult.count = 1;
+                    //    objJsonResult.Message = "瀹℃牳鎴愬姛";
+                    //    objJsonResult.data = null;
+                    //    return objJsonResult;
+                    //}
+                    //else
+                    //{
+                    //    objJsonResult.code = "0";
+                    //    objJsonResult.count = 0;
+                    //    objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                    //    objJsonResult.data = null;
+                    //    return objJsonResult;
+                    //}
                 }
                 if (IsAudit == 1) //鍙嶅鏍告彁浜�
                 {
@@ -560,13 +633,28 @@
                     }
                     //===========================================================   
 
+                    //杩涜 浼氳鏈熼棿 缁撹处 鐨勫垽鏂拰鎺у埗
+                    string s = "";
+                    int sYear = 0;
+                    int sPeriod = 0;
+                    DateTime HDate = DateTime.Now;
+                    if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false)
+                    {
+                        objJsonResult.Message = s;
+                        return objJsonResult;
+                    }
+
                     //鍙嶅鏍告彁浜bandonCheck
-                    //oCN.BeginTran();
-                    ////鍒犻櫎鍏宠仈
-                    //oCN.RunProc("exec h_p_Xs_UpDateRelation_SeOrderToSellBack_UnCheck " + HInterID + ",'" + CurUserName + "'");
+                    oCN.BeginTran();
+
+                    //瀹℃牳鏇存柊 鍙婃椂搴撳瓨琛� 鍑忓皯搴撳瓨
+                    ds = oCN.RunProcReturn("exec h_KF_UPDateICinventory  '" + oBill.omodel.HInterID + "','" + oBill.omodel.HBillType + "','2'", "h_KF_UPDateICinventory");
+
+                    //鍒犻櫎鍏宠仈
+                    oCN.RunProc("exec h_p_Xs_UpDateRelation_SeOrderToSellBack_UnCheck " + HInterID + ",'" + CurUserName + "'");
                     if (oBill.AbandonCheck(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_Kf_SellOutBackBill_AfterUnCheckCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                     {
-                        //oCN.Commit();
+                        oCN.Commit();
                         objJsonResult.code = "1";
                         objJsonResult.count = 1;
                         objJsonResult.Message = "鍙嶅鏍告垚鍔�";
@@ -575,7 +663,7 @@
                     }
                     else
                     {
-                        //oCN.RollBack();
+                        oCN.RollBack();
                         objJsonResult.code = "0";
                         objJsonResult.count = 0;
                         objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
@@ -587,7 +675,7 @@
             }
             catch (Exception e)
             {
-                //oCN.RollBack();
+                oCN.RollBack();
                 objJsonResult.code = "0";
                 objJsonResult.count = 0;
                 objJsonResult.Message = "瀹℃牳澶辫触鎴栬�呭弽瀹℃牳澶辫触锛�" + e.ToString();

--
Gitblit v1.9.1