From abf59bc386d65013b4782eb0b3af463457dbe968 Mon Sep 17 00:00:00 2001
From: yusijie <ysj@hz-kingdee.com>
Date: 星期二, 12 三月 2024 09:23:29 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API

---
 WebAPI/Controllers/项目管理/工程项目/PM_ProjectBillController.cs |  550 ++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 423 insertions(+), 127 deletions(-)

diff --git "a/WebAPI/Controllers/\351\241\271\347\233\256\347\256\241\347\220\206/\345\267\245\347\250\213\351\241\271\347\233\256/PM_ProjectBillController.cs" "b/WebAPI/Controllers/\351\241\271\347\233\256\347\256\241\347\220\206/\345\267\245\347\250\213\351\241\271\347\233\256/PM_ProjectBillController.cs"
index 8bc0e61..bceb379 100644
--- "a/WebAPI/Controllers/\351\241\271\347\233\256\347\256\241\347\220\206/\345\267\245\347\250\213\351\241\271\347\233\256/PM_ProjectBillController.cs"
+++ "b/WebAPI/Controllers/\351\241\271\347\233\256\347\256\241\347\220\206/\345\267\245\347\250\213\351\241\271\347\233\256/PM_ProjectBillController.cs"
@@ -25,6 +25,15 @@
         public DAL.ClsPM_WorkPlanMonthBillMain BillNew1 = new DAL.ClsPM_WorkPlanMonthBillMain();   //宸ヤ綔鍛ㄦ�荤粨瀵瑰簲鍗曟嵁绫�
         public DAL.ClsPM_WorkPlanMonthBillMain BillOld1 = new DAL.ClsPM_WorkPlanMonthBillMain();
 
+        public DAL.ClsPM_WorkPlanMonthBillMain BillNew2 = new DAL.ClsPM_WorkPlanMonthBillMain();   //鏈堝害闃舵璁″垝瀵瑰簲鍗曟嵁绫�
+        public DAL.ClsPM_WorkPlanMonthBillMain BillOld2 = new DAL.ClsPM_WorkPlanMonthBillMain();
+
+        public DAL.ClsPM_CustomerTaskBillMain BillNew3 = new DAL.ClsPM_CustomerTaskBillMain();   //椤圭洰闇�姹傚強闂娓呭崟瀵瑰簲鍗曟嵁绫�
+        public DAL.ClsPM_CustomerTaskBillMain BillOld3 = new DAL.ClsPM_CustomerTaskBillMain();
+
+        public DAL.ClsPM_ProjectMoneyBillMain BillNew4 = new DAL.ClsPM_ProjectMoneyBillMain();   //椤圭洰璐圭敤鍗曞搴斿崟鎹被
+        public DAL.ClsPM_ProjectMoneyBillMain BillOld4 = new DAL.ClsPM_ProjectMoneyBillMain();
+
         #region 宸ョ▼椤圭洰 鏂板/缂栬緫
         #region 宸ョ▼椤圭洰 琛ㄥご鏁版嵁
         public class PM_ProjectBill_Main
@@ -1244,7 +1253,7 @@
                     if (refSav == "Add")
                     {
                         //鍗曟嵁鍙锋槸鍚﹂噸澶�
-                        if (BillNew1.IsExistBillNo(ref ClsPub.sExeReturnInfo, oItem.HBillNo, BillStatus, BillOld.omodel.HInterID))
+                        if (BillNew2.IsExistBillNo(ref ClsPub.sExeReturnInfo, oItem.HBillNo, BillStatus, BillOld.omodel.HInterID))
                         {
                             objJsonResult.code = "0";
                             objJsonResult.count = 0;
@@ -1255,7 +1264,7 @@
                     }
                     if (refSav == "Update")
                     {
-                        if (BillOld1.ShowBill(oItem.HInterID, ref s) == false)
+                        if (BillOld2.ShowBill(oItem.HInterID, ref s) == false)
                         {
                             objJsonResult.code = "0";
                             objJsonResult.count = 0;
@@ -1264,7 +1273,7 @@
                             return objJsonResult;
                         }
                         //鍒ゆ柇鏄惁鍙紪杈�
-                        if (BillOld1.omodel.HChecker != "" && BillOld1.omodel.HChecker != null)
+                        if (BillOld2.omodel.HChecker != "" && BillOld2.omodel.HChecker != null)
                         {
                             objJsonResult.code = "0";
                             objJsonResult.count = 0;
@@ -1272,7 +1281,7 @@
                             objJsonResult.data = 1;
                             return objJsonResult;
                         }
-                        if (BillOld1.omodel.HBillStatus > 1)
+                        if (BillOld2.omodel.HBillStatus > 1)
                         {
                             objJsonResult.code = "0";
                             objJsonResult.count = 0;
@@ -1280,14 +1289,7 @@
                             objJsonResult.data = 1;
                             return objJsonResult;
                         }
-                        if (!DBUtility.Xt_BaseBillFun.Fun_AllowEditBill(BillOld, ref s))
-                        {
-                            objJsonResult.code = "0";
-                            objJsonResult.count = 0;
-                            objJsonResult.Message = s + "锛屼笉鍏佽淇敼";
-                            objJsonResult.data = 1;
-                            return objJsonResult;
-                        }
+                       
                     }
                     UserName = oItem.HMaker;  //鍒跺崟浜�
                     oItem.HBillType = "4758";
@@ -1382,12 +1384,13 @@
         #region 鏈堝害闃舵璁″垝 瀹℃牳/鍙嶅鏍稿姛鑳�
         [Route("PM_ProjectBill/CheckPM_WorkPlanMonthBillMain")]
         [HttpGet]
-        public object CheckPM_WorkPlanMonthBillMain(string HInterID, int IsAudit, string user)
+        public object CheckPM_WorkPlanMonthBillMain(int HInterID, int IsAudit, string CurUserName)
         {
+            DBUtility.ClsPub.CurUserName = CurUserName;
             try
             {
                 //瀹℃牳鏉冮檺
-                if (!DBUtility.ClsPub.Security_Log_second("PM_WorkPlanMonthBillMain_Check", 1, false, user))
+                if (!DBUtility.ClsPub.Security_Log_second("PM_WorkPlanMonthBillMain_Check", 1, false, CurUserName))
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
@@ -1396,12 +1399,43 @@
                     return objJsonResult;
                 }
 
-                var ds = oCN.RunProcReturn("select * from PM_WorkPlanMonthBillMain where HInterID=" + HInterID, "PM_WorkPlanMonthBillMain");
-                if (ds.Tables[0].Rows.Count > 0)
+                //HInterID鏁版嵁鍒ゆ柇
+                if (HInterID <= 0)
                 {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HInterID灏忎簬0锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+
+                Int64 lngBillKey = 0;
+                lngBillKey = DBUtility.ClsPub.isLong(HInterID);                                         //瀵笻InterID杩涜绫诲瀷鐨勮浆鎹�
+                DAL.ClsPM_WorkPlanMonthBillMain oBill = new DAL.ClsPM_WorkPlanMonthBillMain();                              //瀹炰緥鍖栧崟鎹搷浣滅被锛岀敤浜庤繘琛岀浉鍏虫搷浣�
+
+                //閽堝闇�瑕佽繘琛岀殑鎿嶄綔锛屾楠屽綋鍓嶅崟鎹殑鐘舵�佹槸鍚︽敮鎸侀渶瑕佽繘琛岀殑鎿嶄綔
+                if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))                    //鏍规嵁HInterID鑾峰彇璇ュ崟鎹殑鏁版嵁
+                {
+                    if (oBill.omodel.HCloseMan.Trim() != "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁宸插叧闂�!涓嶈兘鍐嶆瀹℃牳锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (oBill.omodel.HDeleteMan.Trim() != "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘鍐嶆瀹℃牳锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
                     if (IsAudit == 0)  //瀹℃牳鍒ゆ柇
                     {
-                        if (ds.Tables[0].Rows[0]["HChecker"].ToString() != "")
+                        if (oBill.omodel.HChecker.Trim() != "")
                         {
                             objJsonResult.code = "0";
                             objJsonResult.count = 0;
@@ -1412,7 +1446,7 @@
                     }
                     if (IsAudit == 1) //鍙嶅鏍稿垽鏂�
                     {
-                        if (ds.Tables[0].Rows[0]["HChecker"].ToString() == "")
+                        if (oBill.omodel.HChecker.Trim() == "")
                         {
                             objJsonResult.code = "0";
                             objJsonResult.count = 0;
@@ -1426,38 +1460,117 @@
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
-                    objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!";
+                    objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
 
-                oCN.BeginTran();
 
-                if (IsAudit == 0)  //瀹℃牳鍒ゆ柇
+                //杩涜闇�瑕佽繘琛岀殑瀹℃牳/鍙嶅鏍告搷浣�
+                if (IsAudit == 0) //瀹℃牳鎻愪氦
                 {
-                    oCN.RunProc("update PM_WorkPlanMonthBillMain set HChecker='" + user + "',HCheckDate=getdate() where HInterID=" + HInterID);
+                    oCN.BeginTran();
 
-                    objJsonResult.code = "1";
-                    objJsonResult.count = 1;
-                    objJsonResult.Message = "瀹℃牳鎴愬姛";
-                    objJsonResult.data = null;
+                    //璁板綍杩斿洖淇℃伅
+                    string msg = "";
+
+                    
+
+                    //瀹℃牳鍓嶆帶鍒�=========================================      
+                    string sql1 = "exec h_p_PM_WorkPlanMonthBill_BeforeCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_PM_WorkPlanMonthBill_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;
+                        oCN.RollBack();
+                        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;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+                    //==================================================================================      
+
+                    //瀹℃牳鎻愪氦
+                    if (oBill.CheckBill(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_PM_WorkPlanMonthBill_AfterCheckCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                    {
+                        oCN.Commit();
+
+                        objJsonResult.code = "1";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "瀹℃牳鎴愬姛锛�" + msg;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        oCN.RollBack();
+
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
                 }
-                if (IsAudit == 1) //鍙嶅鏍稿垽鏂�
+                if (IsAudit == 1) //鍙嶅鏍告彁浜�
                 {
-                    oCN.RunProc("update PM_WorkPlanMonthBillMain set HChecker='',HCheckDate=null where HInterID=" + HInterID);
 
-                    objJsonResult.code = "1";
-                    objJsonResult.count = 1;
-                    objJsonResult.Message = "鍙嶅鏍告垚鍔�";
-                    objJsonResult.data = null;
+                    //鍙嶅鏍稿墠鎺у埗=========================================        
+                    string sql1 = "exec h_p_PM_WorkPlanMonthBill_BeforeUnCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_PM_WorkPlanMonthBill_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;
+                    }
+                    //===========================================================          
+
+                    //鍙嶅鏍告彁浜bandonCheck
+                    if (oBill.AbandonCheck(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_PM_WorkPlanMonthBill_AfterUnCheckCtrl", 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;
+                    }
                 }
-                oCN.Commit();
-
                 return objJsonResult;
             }
             catch (Exception e)
             {
                 oCN.RollBack();
+
                 objJsonResult.code = "0";
                 objJsonResult.count = 0;
                 objJsonResult.Message = "瀹℃牳澶辫触鎴栬�呭弽瀹℃牳澶辫触锛�" + e.ToString();
@@ -1817,7 +1930,7 @@
                     if (refSav == "Add")
                     {
                         //鍗曟嵁鍙锋槸鍚﹂噸澶�
-                        if (BillNew1.IsExistBillNo(ref ClsPub.sExeReturnInfo, oItem.HBillNo, BillStatus, BillOld.omodel.HInterID))
+                        if (BillNew3.IsExistBillNo(ref ClsPub.sExeReturnInfo, oItem.HBillNo, BillStatus, BillOld.omodel.HInterID))
                         {
                             objJsonResult.code = "0";
                             objJsonResult.count = 0;
@@ -1828,7 +1941,7 @@
                     }
                     if (refSav == "Update")
                     {
-                        if (BillOld1.ShowBill(oItem.HInterID, ref s) == false)
+                        if (BillOld3.ShowBill(oItem.HInterID, ref s) == false)
                         {
                             objJsonResult.code = "0";
                             objJsonResult.count = 0;
@@ -1837,7 +1950,7 @@
                             return objJsonResult;
                         }
                         //鍒ゆ柇鏄惁鍙紪杈�
-                        if (BillOld1.omodel.HChecker != "" && BillOld1.omodel.HChecker != null)
+                        if (BillOld3.omodel.HChecker != "" && BillOld3.omodel.HChecker != null)
                         {
                             objJsonResult.code = "0";
                             objJsonResult.count = 0;
@@ -1845,7 +1958,7 @@
                             objJsonResult.data = 1;
                             return objJsonResult;
                         }
-                        if (BillOld1.omodel.HBillStatus > 1)
+                        if (BillOld3.omodel.HBillStatus > 1)
                         {
                             objJsonResult.code = "0";
                             objJsonResult.count = 0;
@@ -1853,14 +1966,7 @@
                             objJsonResult.data = 1;
                             return objJsonResult;
                         }
-                        if (!DBUtility.Xt_BaseBillFun.Fun_AllowEditBill(BillOld, ref s))
-                        {
-                            objJsonResult.code = "0";
-                            objJsonResult.count = 0;
-                            objJsonResult.Message = s + "锛屼笉鍏佽淇敼";
-                            objJsonResult.data = 1;
-                            return objJsonResult;
-                        }
+                       
                     }
                     UserName = oItem.HMaker;  //鍒跺崟浜�
                     oItem.HBillType = "4759";
@@ -2051,12 +2157,13 @@
         #region 椤圭洰闇�姹傚強闂娓呭崟鍒楄〃 瀹℃牳/鍙嶅鏍稿姛鑳�
         [Route("PM_ProjectBill/CheckPM_CustomerTaskBillMain")]
         [HttpGet]
-        public object CheckPM_CustomerTaskBillMain(string HInterID, int IsAudit, string user)
+        public object CheckPM_CustomerTaskBillMain(int HInterID, int IsAudit, string CurUserName)
         {
+            DBUtility.ClsPub.CurUserName = CurUserName;
             try
             {
                 //瀹℃牳鏉冮檺
-                if (!DBUtility.ClsPub.Security_Log_second("PM_CustomerTaskBillMain_Check", 1, false, user))
+                if (!DBUtility.ClsPub.Security_Log_second("PM_CustomerTaskBillMain_Check", 1, false, CurUserName))
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
@@ -2065,12 +2172,43 @@
                     return objJsonResult;
                 }
 
-                var ds = oCN.RunProcReturn("select * from PM_CustomerTaskBillMain  where HInterID=" + HInterID, "PM_CustomerTaskBillMain ");
-                if (ds.Tables[0].Rows.Count > 0)
+                //HInterID鏁版嵁鍒ゆ柇
+                if (HInterID <= 0)
                 {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HInterID灏忎簬0锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+
+                Int64 lngBillKey = 0;
+                lngBillKey = DBUtility.ClsPub.isLong(HInterID);                                         //瀵笻InterID杩涜绫诲瀷鐨勮浆鎹�
+                DAL.ClsPM_CustomerTaskBillMain oBill = new DAL.ClsPM_CustomerTaskBillMain();                              //瀹炰緥鍖栧崟鎹搷浣滅被锛岀敤浜庤繘琛岀浉鍏虫搷浣�
+
+                //閽堝闇�瑕佽繘琛岀殑鎿嶄綔锛屾楠屽綋鍓嶅崟鎹殑鐘舵�佹槸鍚︽敮鎸侀渶瑕佽繘琛岀殑鎿嶄綔
+                if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))                    //鏍规嵁HInterID鑾峰彇璇ュ崟鎹殑鏁版嵁
+                {
+                    if (oBill.omodel.HCloseMan.Trim() != "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁宸插叧闂�!涓嶈兘鍐嶆瀹℃牳锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (oBill.omodel.HDeleteMan.Trim() != "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘鍐嶆瀹℃牳锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
                     if (IsAudit == 0)  //瀹℃牳鍒ゆ柇
                     {
-                        if (ds.Tables[0].Rows[0]["HChecker"].ToString() != "")
+                        if (oBill.omodel.HChecker.Trim() != "")
                         {
                             objJsonResult.code = "0";
                             objJsonResult.count = 0;
@@ -2081,7 +2219,7 @@
                     }
                     if (IsAudit == 1) //鍙嶅鏍稿垽鏂�
                     {
-                        if (ds.Tables[0].Rows[0]["HChecker"].ToString() == "")
+                        if (oBill.omodel.HChecker.Trim() == "")
                         {
                             objJsonResult.code = "0";
                             objJsonResult.count = 0;
@@ -2095,38 +2233,117 @@
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
-                    objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!";
+                    objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
 
-                oCN.BeginTran();
 
-                if (IsAudit == 0)  //瀹℃牳鍒ゆ柇
+                //杩涜闇�瑕佽繘琛岀殑瀹℃牳/鍙嶅鏍告搷浣�
+                if (IsAudit == 0) //瀹℃牳鎻愪氦
                 {
-                    oCN.RunProc("update PM_CustomerTaskBillMain  set HChecker='" + user + "',HCheckDate=getdate() where HInterID=" + HInterID);
+                    oCN.BeginTran();
 
-                    objJsonResult.code = "1";
-                    objJsonResult.count = 1;
-                    objJsonResult.Message = "瀹℃牳鎴愬姛";
-                    objJsonResult.data = null;
+                    //璁板綍杩斿洖淇℃伅
+                    string msg = "";
+
+
+
+                    //瀹℃牳鍓嶆帶鍒�=========================================      
+                    string sql1 = "exec h_p_PM_CustomerTaskBill_BeforeCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_PM_CustomerTaskBill_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;
+                        oCN.RollBack();
+                        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;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+                    //==================================================================================      
+
+                    //瀹℃牳鎻愪氦
+                    if (oBill.CheckBill(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_PM_CustomerTaskBill_AfterCheckCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                    {
+                        oCN.Commit();
+
+                        objJsonResult.code = "1";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "瀹℃牳鎴愬姛锛�" + msg;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        oCN.RollBack();
+
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
                 }
-                if (IsAudit == 1) //鍙嶅鏍稿垽鏂�
+                if (IsAudit == 1) //鍙嶅鏍告彁浜�
                 {
-                    oCN.RunProc("update PM_CustomerTaskBillMain  set HChecker='',HCheckDate=null where HInterID=" + HInterID);
 
-                    objJsonResult.code = "1";
-                    objJsonResult.count = 1;
-                    objJsonResult.Message = "鍙嶅鏍告垚鍔�";
-                    objJsonResult.data = null;
+                    //鍙嶅鏍稿墠鎺у埗=========================================        
+                    string sql1 = "exec h_p_PM_CustomerTaskBill_BeforeUnCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_PM_CustomerTaskBill_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;
+                    }
+                    //===========================================================          
+
+                    //鍙嶅鏍告彁浜bandonCheck
+                    if (oBill.AbandonCheck(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_PM_CustomerTaskBill_AfterUnCheckCtrl", 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;
+                    }
                 }
-                oCN.Commit();
-
                 return objJsonResult;
             }
             catch (Exception e)
             {
                 oCN.RollBack();
+
                 objJsonResult.code = "0";
                 objJsonResult.count = 0;
                 objJsonResult.Message = "瀹℃牳澶辫触鎴栬�呭弽瀹℃牳澶辫触锛�" + e.ToString();
@@ -2381,7 +2598,7 @@
                     if (refSav == "Add")
                     {
                         //鍗曟嵁鍙锋槸鍚﹂噸澶�
-                        if (BillNew1.IsExistBillNo(ref ClsPub.sExeReturnInfo, oItem.HBillNo, BillStatus, BillOld.omodel.HInterID))
+                        if (BillNew4.IsExistBillNo(ref ClsPub.sExeReturnInfo, oItem.HBillNo, BillStatus, BillOld.omodel.HInterID))
                         {
                             objJsonResult.code = "0";
                             objJsonResult.count = 0;
@@ -2392,7 +2609,7 @@
                     }
                     if (refSav == "Update")
                     {
-                        if (BillOld1.ShowBill(oItem.HInterID, ref s) == false)
+                        if (BillOld4.ShowBill(oItem.HInterID, ref s) == false)
                         {
                             objJsonResult.code = "0";
                             objJsonResult.count = 0;
@@ -2401,7 +2618,7 @@
                             return objJsonResult;
                         }
                         //鍒ゆ柇鏄惁鍙紪杈�
-                        if (BillOld1.omodel.HChecker != "" && BillOld1.omodel.HChecker != null)
+                        if (BillOld4.omodel.HChecker != "" && BillOld4.omodel.HChecker != null)
                         {
                             objJsonResult.code = "0";
                             objJsonResult.count = 0;
@@ -2409,7 +2626,7 @@
                             objJsonResult.data = 1;
                             return objJsonResult;
                         }
-                        if (BillOld1.omodel.HBillStatus > 1)
+                        if (BillOld4.omodel.HBillStatus > 1)
                         {
                             objJsonResult.code = "0";
                             objJsonResult.count = 0;
@@ -2417,14 +2634,7 @@
                             objJsonResult.data = 1;
                             return objJsonResult;
                         }
-                        if (!DBUtility.Xt_BaseBillFun.Fun_AllowEditBill(BillOld, ref s))
-                        {
-                            objJsonResult.code = "0";
-                            objJsonResult.count = 0;
-                            objJsonResult.Message = s + "锛屼笉鍏佽淇敼";
-                            objJsonResult.data = 1;
-                            return objJsonResult;
-                        }
+                        
                     }
                     UserName = oItem.HMaker;  //鍒跺崟浜�
                     oItem.HBillType = "4762";
@@ -2631,12 +2841,13 @@
         #region 椤圭洰璐圭敤鍒楄〃 瀹℃牳/鍙嶅鏍稿姛鑳�
         [Route("PM_ProjectBill/CheckPM_ProjectMoneyBillMain")]
         [HttpGet]
-        public object CheckPM_ProjectMoneyBillMain(string HInterID, int IsAudit, string user)
+        public object CheckPM_ProjectMoneyBillMain(int HInterID, int IsAudit, string CurUserName)
         {
+            DBUtility.ClsPub.CurUserName = CurUserName;
             try
             {
                 //瀹℃牳鏉冮檺
-                if (!DBUtility.ClsPub.Security_Log_second("PM_ProjectMoneyBillMain_Check", 1, false, user))
+                if (!DBUtility.ClsPub.Security_Log_second("PM_ProjectMoneyBillMain_Check", 1, false, CurUserName))
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
@@ -2645,12 +2856,43 @@
                     return objJsonResult;
                 }
 
-                var ds = oCN.RunProcReturn("select * from PM_ProjectMoneyBillMain  where HInterID=" + HInterID, "PM_ProjectMoneyBillMain ");
-                if (ds.Tables[0].Rows.Count > 0)
+                //HInterID鏁版嵁鍒ゆ柇
+                if (HInterID <= 0)
                 {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HInterID灏忎簬0锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+
+                Int64 lngBillKey = 0;
+                lngBillKey = DBUtility.ClsPub.isLong(HInterID);                                         //瀵笻InterID杩涜绫诲瀷鐨勮浆鎹�
+                DAL.ClsPM_ProjectMoneyBillMain oBill = new DAL.ClsPM_ProjectMoneyBillMain();                              //瀹炰緥鍖栧崟鎹搷浣滅被锛岀敤浜庤繘琛岀浉鍏虫搷浣�
+
+                //閽堝闇�瑕佽繘琛岀殑鎿嶄綔锛屾楠屽綋鍓嶅崟鎹殑鐘舵�佹槸鍚︽敮鎸侀渶瑕佽繘琛岀殑鎿嶄綔
+                if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))                    //鏍规嵁HInterID鑾峰彇璇ュ崟鎹殑鏁版嵁
+                {
+                    if (oBill.omodel.HCloseMan.Trim() != "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁宸插叧闂�!涓嶈兘鍐嶆瀹℃牳锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (oBill.omodel.HDeleteMan.Trim() != "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘鍐嶆瀹℃牳锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
                     if (IsAudit == 0)  //瀹℃牳鍒ゆ柇
                     {
-                        if (ds.Tables[0].Rows[0]["HChecker"].ToString() != "")
+                        if (oBill.omodel.HChecker.Trim() != "")
                         {
                             objJsonResult.code = "0";
                             objJsonResult.count = 0;
@@ -2661,7 +2903,7 @@
                     }
                     if (IsAudit == 1) //鍙嶅鏍稿垽鏂�
                     {
-                        if (ds.Tables[0].Rows[0]["HChecker"].ToString() == "")
+                        if (oBill.omodel.HChecker.Trim() == "")
                         {
                             objJsonResult.code = "0";
                             objJsonResult.count = 0;
@@ -2675,38 +2917,117 @@
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
-                    objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!";
+                    objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
 
-                oCN.BeginTran();
 
-                if (IsAudit == 0)  //瀹℃牳鍒ゆ柇
+                //杩涜闇�瑕佽繘琛岀殑瀹℃牳/鍙嶅鏍告搷浣�
+                if (IsAudit == 0) //瀹℃牳鎻愪氦
                 {
-                    oCN.RunProc("update PM_ProjectMoneyBillMain  set HChecker='" + user + "',HCheckDate=getdate() where HInterID=" + HInterID);
+                    oCN.BeginTran();
 
-                    objJsonResult.code = "1";
-                    objJsonResult.count = 1;
-                    objJsonResult.Message = "瀹℃牳鎴愬姛";
-                    objJsonResult.data = null;
+                    //璁板綍杩斿洖淇℃伅
+                    string msg = "";
+
+
+
+                    //瀹℃牳鍓嶆帶鍒�=========================================      
+                    string sql1 = "exec h_p_PM_ProjectMoneyBill_BeforeCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_PM_ProjectMoneyBill_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;
+                        oCN.RollBack();
+                        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;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+                    //==================================================================================      
+
+                    //瀹℃牳鎻愪氦
+                    if (oBill.CheckBill(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_PM_ProjectMoneyBill_AfterCheckCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                    {
+                        oCN.Commit();
+
+                        objJsonResult.code = "1";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "瀹℃牳鎴愬姛锛�" + msg;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        oCN.RollBack();
+
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
                 }
-                if (IsAudit == 1) //鍙嶅鏍稿垽鏂�
+                if (IsAudit == 1) //鍙嶅鏍告彁浜�
                 {
-                    oCN.RunProc("update PM_ProjectMoneyBillMain  set HChecker='',HCheckDate=null where HInterID=" + HInterID);
 
-                    objJsonResult.code = "1";
-                    objJsonResult.count = 1;
-                    objJsonResult.Message = "鍙嶅鏍告垚鍔�";
-                    objJsonResult.data = null;
+                    //鍙嶅鏍稿墠鎺у埗=========================================        
+                    string sql1 = "exec h_p_PM_ProjectMoneyBill_BeforeUnCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_PM_ProjectMoneyBill_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;
+                    }
+                    //===========================================================          
+
+                    //鍙嶅鏍告彁浜bandonCheck
+                    if (oBill.AbandonCheck(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_PM_ProjectMoneyBill_AfterUnCheckCtrl", 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;
+                    }
                 }
-                oCN.Commit();
-
                 return objJsonResult;
             }
             catch (Exception e)
             {
                 oCN.RollBack();
+
                 objJsonResult.code = "0";
                 objJsonResult.count = 0;
                 objJsonResult.Message = "瀹℃牳澶辫触鎴栬�呭弽瀹℃牳澶辫触锛�" + e.ToString();
@@ -3864,31 +4185,6 @@
 
                     //璁板綍杩斿洖淇℃伅
                     string msg = "";
-
-                    if (oBill.omodel.HMainSourceInterID != 0)
-                    {
-                        //妫�楠屾簮鍗曟槸鍚﹀瓨鍦ㄥ強鍗曟嵁鐘舵��
-                        string sql = "select * from PM_ProjectEndBillMain where HInterID = " + oBill.omodel.HMainSourceInterID;
-                        ds = oCN.RunProcReturn(sql, "PM_ProjectEndBillMain");
-                        if (ds == null || ds.Tables[0].Rows.Count == 0)
-                        {
-                            objJsonResult.code = "0";
-                            objJsonResult.count = 0;
-                            objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:婧愬崟-鐗规壒鐢宠鍗曚笉瀛樺湪!";
-                            objJsonResult.data = null;
-                            return objJsonResult;
-                        }
-                        else if (ds.Tables[0].Rows[0]["HBillStatus"].ToString() != "2")
-                        {
-                            objJsonResult.code = "0";
-                            objJsonResult.count = 0;
-                            objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:婧愬崟-鐗规壒鐢宠鍗曟湭澶勪簬宸插鏍哥姸鎬�!";
-                            objJsonResult.data = null;
-                            return objJsonResult;
-                        }
-
-
-                    }
 
                     //瀹℃牳鍓嶆帶鍒�=========================================      
                     string sql1 = "exec h_p_PM_ProjectEndBill_BeforeCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";

--
Gitblit v1.9.1