From f9c66dcfca26da4eeba5c87df4ca3916461e37f8 Mon Sep 17 00:00:00 2001
From: yangle <admin@YINMOU>
Date: 星期四, 28 十一月 2024 14:27:32 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API

---
 WebAPI/Controllers/CGGL/Cg_PORequestBillController.cs |  339 +++++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 272 insertions(+), 67 deletions(-)

diff --git a/WebAPI/Controllers/CGGL/Cg_PORequestBillController.cs b/WebAPI/Controllers/CGGL/Cg_PORequestBillController.cs
index 35d7f02..08033d0 100644
--- a/WebAPI/Controllers/CGGL/Cg_PORequestBillController.cs
+++ b/WebAPI/Controllers/CGGL/Cg_PORequestBillController.cs
@@ -63,7 +63,7 @@
                 objJsonResult.count = 1;
                 objJsonResult.Message = "Sucess锛�";
                 objJsonResult.data = ds.Tables[0];
-                objJsonResult.list = columnNameList;
+                objJsonResult.list = columnNameList;//灏哻olumnNameList璧嬪�肩粰objJsonResult鐨刲ist灞炴��
                 return objJsonResult;
             }
             catch (Exception e)
@@ -167,13 +167,41 @@
                 string HCloseMan = mainList2[0].HCloseMan == null ? "''" : mainList2[0].HCloseMan;
                 string HCloseDate = mainList2[0].HCloseDate == null ? "''" : mainList2[0].HCloseDate;
 
-
+                //杩涜 浼氳鏈熼棿 缁撹处 鐨勫垽鏂拰鎺у埗
+                string s = "";
+                int sYear = 0;
+                int sPeriod = 0;
+                if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false)
+                {
+                    objJsonResult.Message = s;
+                    return objJsonResult;
+                }
 
 
                 ds = oCN.RunProcReturn("select * from h_v_Cg_PORequestBillList where hmainid=" + HInterID + " and 鍗曟嵁鍙�='" + HBillNo + "'", "h_v_Cg_PORequestBillList");
 
                 if ((OperationType == 1 || OperationType == 2) && ds.Tables[0].Rows.Count == 0)//鏂板
                 {
+                    //淇濆瓨鍓嶆帶鍒�=========================================              
+                    ds = oCN.RunProcReturn("exec h_p_Cg_PORequestBill_BeforeSaveCtrl " + HInterID, "h_p_Cg_PORequestBill_BeforeSaveCtrl");
+
+                    if (ds == null || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "淇濆瓨鍓嶅垽鏂け璐ワ紒";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //=========================================================
                     DataSet Ds;
                     Int64 NewHInterID = 1;
                     Ds = oCN.RunProcReturn("select MAX(HInterID)HInterID from Cg_PORequestBillMain", "Cg_PORequestBillMain");
@@ -303,13 +331,33 @@
                 
                 oCN.RunProc(sql);
             }
+            //淇濆瓨鍚庢帶鍒�=========================================              
+            ds = oCN.RunProcReturn("exec h_p_Cg_PORequestBill_AfterSaveCtrl " + HInterID, "h_p_Cg_PORequestBill_AfterSaveCtrl");
 
+            if (ds == null || ds.Tables[0].Rows.Count == 0)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "淇濆瓨鍚庡垽鏂け璐ワ紒";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0")
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            //=========================================================
             objJsonResult.code = "1";
             objJsonResult.count = 1;
             objJsonResult.Message = null;
             objJsonResult.data = null;
             return objJsonResult;
         }
+
         [Route("Cg_PORequestBill/Cg_PORequestBillSaveApi")]
         [HttpPost]
         public object Cg_PORequestBillSaveApi([FromBody] JObject sMainSub)
@@ -386,6 +434,17 @@
         {
             try
             {
+                //杩涜 浼氳鏈熼棿 缁撹处 鐨勫垽鏂拰鎺у埗
+                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;
+                }
+
                 oCN.BeginTran();
                 oCN.RunProc("Delete From Cg_PORequestBillMain where HInterID = " + HInterID);
                 oCN.RunProc("Delete From Cg_PORequestBillSub where HInterID = " + HInterID);
@@ -481,6 +540,7 @@
         [HttpGet]
         public object AuditCg_PORequestBill(string HInterID, int Type, string user)
         {
+            string sql = "";
             try
             {
                 //鍒ゆ柇鏄惁鏈夊鏍告潈闄�
@@ -503,90 +563,107 @@
                 }
 
                 ClsPub.CurUserName = user;
+                ds = oCN.RunProcReturn("select * from Cg_PORequestBillMain where HInterID = " + int.Parse(HInterID), "Cg_PORequestBillMain");
+                string HBillNo = "";
+                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();
+                }
                 BillOld.MvarItemKey = "Cg_PORequestBillMain";
+
+                //杩涜 浼氳鏈熼棿 缁撹处 鐨勫垽鏂拰鎺у埗
+                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;
+                }
+
                 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)
+                    //瀹℃牳鍓嶆帶鍒�
+                    sql = "exec h_p_Cg_PORequestBill_BeforeCheckCtrl " + int.Parse(HInterID) + ",'" + HBillNo + "','" + user + "'";
+                    ds = oCN.RunProcReturn(sql, "h_p_Cg_PORequestBill_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_PORequestBill_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]["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_PORequestBill_BeforeUnCheckCtrl " + int.Parse(HInterID) + ",'" + HBillNo + "','" + user + "'";
+                    ds = oCN.RunProcReturn(sql, "h_p_Cg_PORequestBill_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]["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_PORequestBill_AfterUnCheckCtrl", user, ref ClsPub.sExeReturnInfo))
+                    {
+                        SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
+                        //DataSet DSet = oCn.RunProcReturn("exec h_p_Sc_ICMOBill_AbandonCheckCtrl " + int.Parse(HInterID), "h_p_Sc_ICMOBill_AbandonCheckCtrl");
+                 
+                    }
+                    else
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
                     }
                 }
-
-                oCN.Commit();//鎻愪氦浜嬪姟
 
                 objJsonResult.code = "0";
                 objJsonResult.count = 1;
@@ -737,7 +814,135 @@
         }
         #endregion
 
+        #region 閲囪喘鐢宠鍗� 浣滃簾/鍙嶄綔搴熷姛鑳�
+        [Route("Cg_PORequestBill/DropCg_PORequestBill")]
+        [HttpGet]
+        public object DropCg_PORequestBill(string HInterID, int Type, string user)
+        {
+            try
+            {
+                //鍒ゆ柇鏄惁鏈変綔搴熸潈闄�
+                if (!DBUtility.ClsPub.Security_Log("Cg_PORequestBill_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;
+                BillOld.MvarItemKey = "Cg_PORequestBillMain";
+                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]["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 (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;
+                        }
+                    }
+                }
+
+                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
     }
 
 }

--
Gitblit v1.9.1