From aa92c97c1c87db25ba22fdaf0f6d398e2a2e67df Mon Sep 17 00:00:00 2001
From: wtt <1985833171@qq.com>
Date: 星期五, 18 十月 2024 15:02:39 +0800
Subject: [PATCH] 添加工艺路线系统参数,是否启用多级审批

---
 WebAPI/Controllers/项目管理/项目阶段/Gy_ProjectStageController.cs | 1095 +++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 983 insertions(+), 112 deletions(-)

diff --git "a/WebAPI/Controllers/\351\241\271\347\233\256\347\256\241\347\220\206/\351\241\271\347\233\256\351\230\266\346\256\265/Gy_ProjectStageController.cs" "b/WebAPI/Controllers/\351\241\271\347\233\256\347\256\241\347\220\206/\351\241\271\347\233\256\351\230\266\346\256\265/Gy_ProjectStageController.cs"
index 289d7de..9bf78e5 100644
--- "a/WebAPI/Controllers/\351\241\271\347\233\256\347\256\241\347\220\206/\351\241\271\347\233\256\351\230\266\346\256\265/Gy_ProjectStageController.cs"
+++ "b/WebAPI/Controllers/\351\241\271\347\233\256\347\256\241\347\220\206/\351\241\271\347\233\256\351\230\266\346\256\265/Gy_ProjectStageController.cs"
@@ -19,6 +19,7 @@
         private json objJsonResult = new json();
         public DataSet ds = new DataSet();
         public SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+        public DAL.ClsSc_ICMOBill BillOld = new DAL.ClsSc_ICMOBill();
         string user_LongShan = "";
         string HName_LongShan = "";
 
@@ -105,7 +106,7 @@
                 {
                     oCN.BeginTran();
                     string sql = "Insert into  Gy_ProjectStage" +
-                        " (HNumber,HName,HShortNumber,HParentID,HLevel,HEndFlag,HStopflag,HRemark,HHelpCode,HMakeEmp,HUSEORGID,HStageNote,HRelationGoods,HIsKey,HRate) " +
+                        " (HNumber,HName,HShortNumber,HParentID,HLevel,HEndFlag,HStopflag,HRemark,HHelpCode,HMakeEmp,HCREATEORGID,HStageNote,HRelationGoods,HIsKey,HRate) " +
                         " Values(" +
                         "'" + HNumber + "'" +
                         ",'" + HName + "'" +
@@ -145,8 +146,8 @@
                         ",HHelpCode='" + HHelpCode + "'" +
                         ",HMakeEmp='" + HMakeEmp + "'" +
                         ",HModifyEmp = '" + HModifyEmp + "'" +
-                        ",HModifyTime = getDate()" + 
-                        ",HUSEORGID=" + HUSEORGID + "" +
+                        ",HModifyTime = getDate()" +
+                        ",HCREATEORGID=" + HUSEORGID + "" +
                         ",HStageNote='" + HStageNote + "'" +
                         ",HRelationGoods='" + HRelationGoods + "'" +
                         ",HIsKey=" + Convert.ToString(HIsKey ? 1 : 0) + "" +
@@ -202,13 +203,13 @@
 
                 if (sWhere == null || sWhere.Equals(""))
                 {
-                    ds = oCN.RunProcReturn("select * from Gy_ProjectStage order by HNumber ", "Gy_ProjectStage");
+                    ds = oCN.RunProcReturn("select * from h_v_Gy_ProjectStage order by 闃舵缂栫爜 desc", "h_v_Gy_ProjectStage");
                 }
                 else
                 {
-                    string sql1 = "select * from Gy_ProjectStage where 1 = 1 ";
-                    string sql = sql1 + sWhere + " order by HNumber ";
-                    ds = oCN.RunProcReturn(sql, "Gy_ProjectStage");
+                    string sql1 = "select * from h_v_Gy_ProjectStage where 1 = 1 ";
+                    string sql = sql1 + sWhere + " order by 闃舵缂栫爜 desc";
+                    ds = oCN.RunProcReturn(sql, "h_v_Gy_ProjectStage");
                 }
 
                 //娣诲姞鍒楀悕
@@ -456,6 +457,102 @@
             }
         }
         #endregion
+
+        #region 椤圭洰闃舵 绂佺敤銆佸弽绂佺敤
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="HInterID">鍗曟嵁ID</param>
+        /// <param name="IsStop">绂佺敤(0),鍙嶇鐢�(1)</param>
+        /// <param name="CurUserName">瀹℃牳浜�</param>
+        /// <returns></returns>
+        [Route("Gy_ProjectStage/StopGy_ProjectStage")]
+        [HttpGet]
+        public object StopGy_ProjectStage(int HInterID, int IsStop, string CurUserName)
+        {
+            try
+            {
+                //瀹℃牳鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log_second("Pm_ProjectStage_Stop", 1, false, CurUserName))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "绂佺敤澶辫触锛佹棤鏉冮檺锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                var ds = oCN.RunProcReturn("select * from Gy_ProjectStage where HItemID=" + HInterID, "Gy_ProjectStage");
+                if (ds.Tables[0].Rows.Count > 0)
+                {
+                    if (IsStop == 0)  //绂佺敤鍒ゆ柇
+                    {
+                        if (ds.Tables[0].Rows[0]["HStopEmp"].ToString() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸茬鐢�!涓嶈兘鍐嶆绂佺敤锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                    if (IsStop == 1) //鍙嶇鐢ㄥ垽鏂�
+                    {
+                        if (ds.Tables[0].Rows[0]["HStopEmp"].ToString() == "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁鏈鐢�!涓嶉渶瑕佸弽绂佺敤!";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                oCN.BeginTran();
+
+                if (IsStop == 0)  //绂佺敤鍒ゆ柇
+                {
+                    oCN.RunProc("update Gy_ProjectStage set HStopEmp='" + CurUserName + "',HStopTime=getdate(),HStopflag=1 where HItemID=" + HInterID);
+
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "绂佺敤鎴愬姛";
+                    objJsonResult.data = null;
+                }
+                if (IsStop == 1) //鍙嶇鐢ㄥ垽鏂�
+                {
+                    oCN.RunProc("update Gy_ProjectStage set HStopEmp='',HStopTime=null,HStopflag=0 where HItemID=" + HInterID);
+
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍙嶇鐢ㄦ垚鍔�";
+                    objJsonResult.data = null;
+                }
+                oCN.Commit();
+
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                oCN.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "绂佺敤澶辫触鎴栬�呭弽绂佺敤澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
 
 
         #region 椤圭洰闃舵娓呭崟 鏂板/缂栬緫- 淇濆瓨
@@ -749,13 +846,13 @@
 
                 if (sWhere == null || sWhere.Equals(""))
                 {
-                    ds = oCN.RunProcReturn("select * from PM_ProjectStageBillMain order by HBillNo desc ", "PM_ProjectStageBillMain");
+                    ds = oCN.RunProcReturn("select * from h_v_PM_ProjectStageBill order by 鍗曟嵁鍙� desc", "h_v_PM_ProjectStageBill");
                 }
                 else
                 {
-                    string sql1 = "select * from PM_ProjectStageBillMain where 1 = 1 ";
-                    string sql = sql1 + sWhere + " order by HBillNo desc ";
-                    ds = oCN.RunProcReturn(sql, "PM_ProjectStageBillMain");
+                    string sql1 = "select * from h_v_PM_ProjectStageBill where 1 = 1 ";
+                    string sql = sql1 + sWhere + " order by 鍗曟嵁鍙� desc";
+                    ds = oCN.RunProcReturn(sql, "h_v_PM_ProjectStageBill");
                 }
 
                 //娣诲姞鍒楀悕
@@ -901,26 +998,67 @@
         /// <returns></returns>
         [Route("PM_ProjectStageBill/AuditPM_ProjectStageBill")]
         [HttpGet]
-        public object AuditPM_ProjectStageBill(int HInterID, int IsAudit, string CurUserName)
+        public object AuditPM_ProjectStageBill(string HInterID, int Type, string user)
         {
             try
             {
-                //瀹℃牳鏉冮檺
-                if (!DBUtility.ClsPub.Security_Log_second("Pm_ProjectStageBill_Check", 1, false, CurUserName))
+                //鍒ゆ柇鏄惁鏈夊鏍告潈闄�
+                if (!DBUtility.ClsPub.Security_Log("Pm_ProjectStageBill_Check", 1, false, user))
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
-                    objJsonResult.Message = "瀹℃牳澶辫触锛佹棤鏉冮檺锛�";
+                    objJsonResult.Message = "鏃犳潈闄愬鏍�!";
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
 
-                var ds = oCN.RunProcReturn("select * from PM_ProjectStageBillMain where HInterID=" + HInterID, "PM_ProjectStageBillMain");
-                if (ds.Tables[0].Rows.Count > 0)
+                if (string.IsNullOrWhiteSpace(HInterID))
                 {
-                    if (IsAudit == 0)  //瀹℃牳鍒ゆ柇
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HInterID涓虹┖锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                ClsPub.CurUserName = user;
+                BillOld.MvarItemKey = "PM_ProjectStageBillMain";
+                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 (ds.Tables[0].Rows[0]["HChecker"].ToString() != "")
+                        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]["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;
@@ -928,14 +1066,12 @@
                             objJsonResult.data = null;
                             return objJsonResult;
                         }
-                    }
-                    if (IsAudit == 1) //鍙嶅鏍稿垽鏂�
-                    {
-                        if (ds.Tables[0].Rows[0]["HChecker"].ToString() == "")
+                        //瀹℃牳鍗曟嵁
+                        if (!BillOld.CheckBill(Int64.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;
                         }
@@ -943,43 +1079,339 @@
                 }
                 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]["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;
+                        }
+                    }
+                }
+
+                oCN.Commit();//鎻愪氦浜嬪姟
+
+                objJsonResult.code = "0";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鎵ц鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult; ;
+
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鎵ц澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 椤圭洰闃舵娓呭崟 鍏抽棴/鍙嶅叧闂姛鑳�
+        [Route("PM_ProjectStageBill/ClosePM_ProjectStageBill")]
+        [HttpGet]
+        public object ClosePM_ProjectStageBill(string HInterID, int Type, string user)
+        {
+            try
+            {
+                //鍒ゆ柇鏄惁鏈夊垹闄ゆ潈闄�
+                if (!DBUtility.ClsPub.Security_Log("Pm_ProjectStageBill_Close", 1, false, user))
+                {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
-                    objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!";
+                    objJsonResult.Message = "鏃犳潈闄愬叧闂�!";
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
 
-                oCN.BeginTran();
-
-                if (IsAudit == 0)  //瀹℃牳鍒ゆ柇
+                if (string.IsNullOrWhiteSpace(HInterID))
                 {
-                    oCN.RunProc("update PM_ProjectStageBillMain set HChecker='" + CurUserName + "',HCheckDate=getdate() where HInterID=" + HInterID);
-
-                    objJsonResult.code = "1";
-                    objJsonResult.count = 1;
-                    objJsonResult.Message = "瀹℃牳鎴愬姛";
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HInterID涓虹┖锛�";
                     objJsonResult.data = null;
+                    return objJsonResult;
                 }
-                if (IsAudit == 1) //鍙嶅鏍稿垽鏂�
+
+                ClsPub.CurUserName = user;
+                BillOld.MvarItemKey = "PM_ProjectStageBillMain";
+                oCN.BeginTran();//寮�濮嬩簨鍔�
+
+                //Type 1 鍏抽棴  2  鍙嶅叧闂�
+                if (Type == 1)
                 {
-                    oCN.RunProc("update PM_ProjectStageBillMain set HChecker='',HCheckDate=null where HInterID=" + HInterID);
+                    //鍒ゆ柇鍗曟嵁鏄惁宸茬粡鍏抽棴
+                    DataSet ds;
+                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
+                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
+                    if (ds == null || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦紒";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
+                    {
+                        if (ds.Tables[0].Rows[0]["HDeleteMan"] != null && ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘杩涜鍏抽棴!";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        if (ds.Tables[0].Rows[0]["HChecker"] == null || ds.Tables[0].Rows[0]["HChecker"].ToString() == "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁鏈鏍�!涓嶈兘杩涜鍏抽棴!";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
 
-                    objJsonResult.code = "1";
-                    objJsonResult.count = 1;
-                    objJsonResult.Message = "鍙嶅鏍告垚鍔�";
-                    objJsonResult.data = null;
+                        if (ds.Tables[0].Rows[0]["HCloseMan"] != null && ds.Tables[0].Rows[0]["HCloseMan"].ToString() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸插叧闂�!涓嶈兘鍐嶆鍏抽棴!";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        //鍏抽棴鍗曟嵁
+                        if (!BillOld.CloseBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
                 }
-                oCN.Commit();
+                else
+                {
+                    //鍒ゆ柇鍗曟嵁鏄惁宸茬粡鍙嶅叧闂�
+                    DataSet ds;
+                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
+                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
+                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
+                    {
+                        if (ds.Tables[0].Rows[0]["HDeleteMan"] != null && ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘杩涜鍏抽棴!";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        if (ds.Tables[0].Rows[0]["HChecker"] == null || ds.Tables[0].Rows[0]["HChecker"].ToString() == "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁鏈鏍�!涓嶈兘杩涜鍏抽棴!";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        if (ds.Tables[0].Rows[0]["HCloseMan"] == null || ds.Tables[0].Rows[0]["HCloseMan"].ToString() == "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁鏈叧闂�!涓嶉渶瑕佸啀鍙嶅叧闂�!";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        //鍙嶅叧闂崟鎹�
+                        if (!BillOld.CancelClose(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                }
 
-                return objJsonResult;
+                oCN.Commit();//鎻愪氦浜嬪姟
+
+                objJsonResult.code = "0";
+                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.Message = "鎵ц澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 椤圭洰闃舵娓呭崟 浣滃簾/鍙嶄綔搴熷姛鑳�
+        [Route("PM_ProjectStageBill/DropPM_ProjectStageBill")]
+        [HttpGet]
+        public object DropPM_ProjectStageBill(string HInterID, int Type, string user)
+        {
+            try
+            {
+                //鍒ゆ柇鏄惁鏈変綔搴熸潈闄�
+                if (!DBUtility.ClsPub.Security_Log("Pm_ProjectStageBill_Drop", 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 = "PM_ProjectStageBillMain";
+                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;
             }
@@ -994,6 +1426,7 @@
             public int HInterID;
             public string HBillNo;
             public string HDate;
+            public int HProjectID;
             public string HProNumber;
             public int HProjectStageID;
             public string HProjectStageName;
@@ -1010,6 +1443,12 @@
             public int HOrgID;
             public string HRemark;
             public string HMaker;
+
+            public int HMainSourceInterID;
+            public int HMainSourceEntryID;
+            public string HMainSourceBillNo;
+            public string HMainSourceBillType;
+
             public string HUpdater;
             public string HChecker;
             public string HMakerDate;
@@ -1107,6 +1546,9 @@
                         objJsonResult.data = null;
                         return objJsonResult;
                     }
+                }else if (OperationType == 4)
+                {
+
                 }
 
                 msg2 = "[" + msg2.ToString() + "]";
@@ -1121,6 +1563,7 @@
                 int HInterID = mainList[0].HInterID;
                 string HBillNo = mainList[0].HBillNo;
                 string HDate = mainList[0].HDate;
+                int HProjectID = mainList[0].HProjectID;
                 string HProNumber = mainList[0].HProNumber;
                 int HProjectStageID = mainList[0].HProjectStageID;
                 string HStageNote = mainList[0].HStageNote;
@@ -1134,11 +1577,17 @@
                 double HRate = mainList[0].HRate;
                 int HOrgID = mainList[0].HOrgID;
                 string HRemark = mainList[0].HRemark;
+
+                int HMainSourceInterID = mainList[0].HMainSourceInterID;
+                int HMainSourceEntryID = mainList[0].HMainSourceEntryID;
+                string HMainSourceBillNo = mainList[0].HMainSourceBillNo;
+                string HMainSourceBillType = mainList[0].HMainSourceBillType;
+
                 string HMaker = mainList[0].HMaker;
                 string HMakerDate = mainList[0].HMakerDate;
                 string HUpdater = mainList[0].HUpdater;
                 string HUpdaterDate = mainList[0].HUpdaterDate;
-
+                
 
                 if (OperationType == 2)
                 {
@@ -1159,7 +1608,7 @@
                 {
                     string sql = "insert into PM_ProjectReportBillMain" +
                         "(HYear,HPeriod,HBillType,HBillSubType,HInterID,HDate,HBillNo,HBillStatus,HRemark,HMaker,HMakeDate" +
-                        ",HProNumber,HProjectStageID,HStageNote,HRelationGoods,HIsKey,HReportEmpID,HReportNote,HReportGoods,HReceiveEmp,HCopyEmp,HRate,HOrgID) " +
+                        ",HProjectID,HProNumber,HProjectStageID,HStageNote,HRelationGoods,HIsKey,HReportEmpID,HReportNote,HReportGoods,HReceiveEmp,HCopyEmp,HRate,HOrgID,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo,HMainSourceBillType) " +
                         "values(" +
                         "" + HYear +
                         "," + HPeriod +
@@ -1172,7 +1621,8 @@
                         ",'" + HRemark +
                         "','" + HMaker +
                         "','" + HMakerDate +
-                        "','" + HProNumber +
+                        "'," + HProjectID +
+                        ",'" + HProNumber +
                         "'," + HProjectStageID +
                         ",'" + HStageNote +
                         "','" + HRelationGoods +
@@ -1184,7 +1634,11 @@
                         "','" + HCopyEmp +
                         "'," + HRate +
                         "," + HOrgID +
-                        ")";
+                        "," + HMainSourceInterID +
+                        "," + HMainSourceEntryID +
+                        ",'" + HMainSourceBillNo +
+                        "','" + HMainSourceBillType +
+                        "')";
 
                     //涓昏〃
                     oCN.RunProc(sql);
@@ -1204,7 +1658,8 @@
                         ",HRemark = '" + HRemark +
                         "',HUpdater = '" + HUpdater +
                         "',HUpdateDate = '" + HUpdaterDate +
-                        "',HProNumber = '" + HProNumber +
+                        "',HProjectID = " + HProjectID +
+                        ",HProNumber = '" + HProNumber +
                         "',HProjectStageID = " + HProjectStageID +
                         ",HStageNote = '" + HStageNote +
                         "',HRelationGoods = '" + HRelationGoods +
@@ -1216,7 +1671,11 @@
                         "',HCopyEmp = '" + HCopyEmp +
                         "',HRate = " + HRate +
                         ",HOrgID = " + HOrgID +
-                        " where HInterID = " + HInterID;
+                        ",HMainSourceInterID = " + HMainSourceInterID +
+                        ",HMainSourceEntryID = " + HMainSourceEntryID +
+                        ",HMainSourceBillNo = '" + HMainSourceBillNo +
+                        "',HMainSourceBillType = '" + HMainSourceBillType +
+                        "' where HInterID = " + HInterID;
 
                     oCN.RunProc(sql);
 
@@ -1225,9 +1684,49 @@
                     //璁板綍鏃ュ織
                     LogService.Write("鐢ㄦ埛:" + user + ",鏃ユ湡:" + DateTime.Now + ",淇敼椤圭洰闃舵姹囨姤:" + HBillNo);
                     oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','" + HComputerName + "','" + "淇敼椤圭洰闃舵姹囨姤锛�" + HBillNo + "','LMES-椤圭洰闃舵姹囨姤妯″潡','" + DBUtility.ClsPub.IPAddress + "','淇敼鍗曟嵁'", ref DBUtility.ClsPub.sExeReturnInfo);
+                }else if(OperationType == 4 && ds.Tables[0].Rows.Count == 0 )           //涓嬫帹-鏂板
+                {
+                    string sql = "insert into PM_ProjectReportBillMain" +
+                        "(HYear,HPeriod,HBillType,HBillSubType,HInterID,HDate,HBillNo,HBillStatus,HRemark,HMaker,HMakeDate" +
+                        ",HProjectID,HProNumber,HProjectStageID,HStageNote,HRelationGoods,HIsKey,HReportEmpID,HReportNote,HReportGoods,HReceiveEmp,HCopyEmp,HRate,HOrgID,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillType,HMainSourceBillNo) " +
+                        "values(" +
+                        "" + HYear +
+                        "," + HPeriod +
+                        ",'" + HBillType +
+                        "','" + HBillSubType +
+                        "'," + HInterID +
+                        ",'" + HDate +
+                        "','" + HBillNo +
+                        "'," + HBillStatus +
+                        ",'" + HRemark +
+                        "','" + HMaker +
+                        "','" + HMakerDate +
+                        "'," + HProjectID +
+                        ",'" + HProNumber +
+                        "'," + HProjectStageID +
+                        ",'" + HStageNote +
+                        "','" + HRelationGoods +
+                        "'," + HIsKey +
+                        "," + HReportEmpID +
+                        ",'" + HReportNote +
+                        "','" + HReportGoods +
+                        "','" + HReceiveEmp +
+                        "','" + HCopyEmp +
+                        "'," + HRate +
+                        "," + HOrgID +
+                        "," + HMainSourceInterID +
+                        "," + HMainSourceEntryID +
+                        ",'" + HMainSourceBillType +
+                        "','" + HMainSourceBillNo +
+                        "')";
+
+                    //涓昏〃
+                    oCN.RunProc(sql);
+                    LogService.Write("鐢ㄦ埛:" + user + ",鏃ユ湡:" + DateTime.Now + ",鏂板椤圭洰闃舵姹囨姤:" + HBillNo);
+                    oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','" + HComputerName + "','" + "鏂板椤圭洰闃舵姹囨姤锛�" + HBillNo + "','LMES-椤圭洰闃舵姹囨姤妯″潡','" + DBUtility.ClsPub.IPAddress + "','鏂板鍗曟嵁'", ref DBUtility.ClsPub.sExeReturnInfo);
                 }
                 //淇濆瓨瀛愯〃
-                objJsonResult = AddBillSub_ProjectReportBill(msg3, HInterID, HBillNo, OperationType);
+                objJsonResult = AddBillSub_ProjectReportBill(msg3, HInterID, HBillNo, OperationType,HMainSourceInterID, HMainSourceEntryID, HMainSourceBillType, HMainSourceBillNo);
 
                 if (objJsonResult.code == "0")
                 {
@@ -1255,36 +1754,73 @@
         }
         #endregion
         #region 娣诲姞椤圭洰闃舵娓呭崟 瀛愯〃
-        public json AddBillSub_ProjectReportBill(string msg3, long HInterID, string HBillNo, int OperationType)
+        public json AddBillSub_ProjectReportBill(string msg3, long HInterID, string HBillNo, int OperationType, int HSourceInterID, int HSourceEntryID, string HSourceBillType, string HSourceBillNo)
         {
             List<PM_ProjectReportBill_Sub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PM_ProjectReportBill_Sub>>(msg3);
             int i = 0;                                          //浣滀负瀛愯〃鍐呯爜
-            foreach (PM_ProjectReportBill_Sub oSub in DetailColl)
+            if(OperationType == 4)
             {
-                i++;                                            //鍚屼竴涓富琛ㄤ笅鐨勫瓙琛ㄧ殑鍐呯爜鑷
+                foreach (PM_ProjectReportBill_Sub oSub in DetailColl)
+                {
+                    i++;                                            //鍚屼竴涓富琛ㄤ笅鐨勫瓙琛ㄧ殑鍐呯爜鑷
 
-                int HEntryID = i;
-                int HEmpID = oSub.HEmpID;
-                int HIsPM = oSub.HIsPM?1:0;
-                double HRate = oSub.HRate;
-                double HAvgMoney = oSub.HAvgMoney;
-                double HCountMoney = oSub.HCountMoney;
-                string HRemarkSub = oSub.HRemarkSub;
-                string sql = "insert into PM_ProjectReportBillSub" +
-                    "(HInterID,HBillNo_bak,HEntryID,HRemark,HEmpID,HIsPM,HRate,HAvgMoney,HCountMoney) " +
-                    "values(" +
-                    "" + HInterID +
-                    ",'" + HBillNo +
-                    "'," + HEntryID +
-                    ",'" + HRemarkSub +
-                    "'," + HEmpID +
-                    "," + HIsPM +
-                    "," + HRate +
-                    "," + HAvgMoney +
-                    "," + HCountMoney +
-                    ")";
-                oCN.RunProc(sql);
+                    int HEntryID = i;
+                    int HEmpID = oSub.HEmpID;
+                    int HIsPM = oSub.HIsPM ? 1 : 0;
+                    double HRate = oSub.HRate;
+                    double HAvgMoney = oSub.HAvgMoney;
+                    double HCountMoney = oSub.HCountMoney;
+                    string HRemarkSub = oSub.HRemarkSub;
+                    string sql = "insert into PM_ProjectReportBillSub" +
+                        "(HInterID,HBillNo_bak,HEntryID,HRemark,HEmpID,HIsPM,HRate,HAvgMoney,HCountMoney,HSourceInterID,HSourceEntryID,HSourceBillType,HSourceBillNo) " +
+                        "values(" +
+                        "" + HInterID +
+                        ",'" + HBillNo +
+                        "'," + HEntryID +
+                        ",'" + HRemarkSub +
+                        "'," + HEmpID +
+                        "," + HIsPM +
+                        "," + HRate +
+                        "," + HAvgMoney +
+                        "," + HCountMoney +
+                        "," + HSourceInterID + 
+                        "," + HSourceEntryID +
+                        ",'" + HSourceBillType + 
+                        "','" + HSourceBillNo +
+                        "')";
+                    oCN.RunProc(sql);
+                }
             }
+            else
+            {
+                foreach (PM_ProjectReportBill_Sub oSub in DetailColl)
+                {
+                    i++;                                            //鍚屼竴涓富琛ㄤ笅鐨勫瓙琛ㄧ殑鍐呯爜鑷
+
+                    int HEntryID = i;
+                    int HEmpID = oSub.HEmpID;
+                    int HIsPM = oSub.HIsPM ? 1 : 0;
+                    double HRate = oSub.HRate;
+                    double HAvgMoney = oSub.HAvgMoney;
+                    double HCountMoney = oSub.HCountMoney;
+                    string HRemarkSub = oSub.HRemarkSub;
+                    string sql = "insert into PM_ProjectReportBillSub" +
+                        "(HInterID,HBillNo_bak,HEntryID,HRemark,HEmpID,HIsPM,HRate,HAvgMoney,HCountMoney) " +
+                        "values(" +
+                        "" + HInterID +
+                        ",'" + HBillNo +
+                        "'," + HEntryID +
+                        ",'" + HRemarkSub +
+                        "'," + HEmpID +
+                        "," + HIsPM +
+                        "," + HRate +
+                        "," + HAvgMoney +
+                        "," + HCountMoney +
+                        ")";
+                    oCN.RunProc(sql);
+                }
+            }
+            
 
             objJsonResult.code = "1";
             objJsonResult.count = 1;
@@ -1320,13 +1856,13 @@
 
                 if (sWhere == null || sWhere.Equals(""))
                 {
-                    ds = oCN.RunProcReturn("select * from PM_ProjectReportBillMain order by HBillNo desc ", "PM_ProjectReportBillMain");
+                    ds = oCN.RunProcReturn("select * from h_v_PM_ProjectReportBillList order by 鍗曟嵁鍙� desc ", "h_v_PM_ProjectReportBillList");
                 }
                 else
                 {
-                    string sql1 = "select * from PM_ProjectReportBillMain where 1 = 1 ";
-                    string sql = sql1 + sWhere + " order by HBillNo desc ";
-                    ds = oCN.RunProcReturn(sql, "PM_ProjectReportBillMain");
+                    string sql1 = "select * from h_v_PM_ProjectReportBillList where 1 = 1 ";
+                    string sql = sql1 + sWhere + " order by 鍗曟嵁鍙� desc ";
+                    ds = oCN.RunProcReturn(sql, "h_v_PM_ProjectReportBillList");
                 }
 
                 //娣诲姞鍒楀悕
@@ -1472,26 +2008,67 @@
         /// <returns></returns>
         [Route("PM_ProjectReportBill/AuditPM_ProjectReportBill")]
         [HttpGet]
-        public object AuditPM_ProjectReportBill(int HInterID, int IsAudit, string CurUserName)
+        public object AuditPM_ProjectReportBill(string HInterID, int Type, string user)
         {
             try
             {
-                //瀹℃牳鏉冮檺
-                if (!DBUtility.ClsPub.Security_Log_second("Pm_ProjectReportBill_Check", 1, false, CurUserName))
+                //鍒ゆ柇鏄惁鏈夊鏍告潈闄�
+                if (!DBUtility.ClsPub.Security_Log("Pm_ProjectReportBill_Check", 1, false, user))
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
-                    objJsonResult.Message = "瀹℃牳澶辫触锛佹棤鏉冮檺锛�";
+                    objJsonResult.Message = "鏃犳潈闄愬鏍�!";
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
 
-                var ds = oCN.RunProcReturn("select * from PM_ProjectReportBillMain where HInterID=" + HInterID, "PM_ProjectReportBillMain");
-                if (ds.Tables[0].Rows.Count > 0)
+                if (string.IsNullOrWhiteSpace(HInterID))
                 {
-                    if (IsAudit == 0)  //瀹℃牳鍒ゆ柇
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HInterID涓虹┖锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                ClsPub.CurUserName = user;
+                BillOld.MvarItemKey = "PM_ProjectReportBillMain";
+                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 (ds.Tables[0].Rows[0]["HChecker"].ToString() != "")
+                        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]["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;
@@ -1499,14 +2076,12 @@
                             objJsonResult.data = null;
                             return objJsonResult;
                         }
-                    }
-                    if (IsAudit == 1) //鍙嶅鏍稿垽鏂�
-                    {
-                        if (ds.Tables[0].Rows[0]["HChecker"].ToString() == "")
+                        //瀹℃牳鍗曟嵁
+                        if (!BillOld.CheckBill(Int64.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;
                         }
@@ -1514,43 +2089,339 @@
                 }
                 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]["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;
+                        }
+                    }
+                }
+
+                oCN.Commit();//鎻愪氦浜嬪姟
+
+                objJsonResult.code = "0";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鎵ц鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult; ;
+
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鎵ц澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 椤圭洰闃舵姹囨姤 鍏抽棴/鍙嶅叧闂姛鑳�
+        [Route("PM_ProjectReportBill/ClosePM_ProjectReportBill")]
+        [HttpGet]
+        public object ClosePM_ProjectReportBill(string HInterID, int Type, string user)
+        {
+            try
+            {
+                //鍒ゆ柇鏄惁鏈夊垹闄ゆ潈闄�
+                if (!DBUtility.ClsPub.Security_Log("Pm_ProjectReportBill_Close", 1, false, user))
+                {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
-                    objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!";
+                    objJsonResult.Message = "鏃犳潈闄愬叧闂�!";
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
 
-                oCN.BeginTran();
-
-                if (IsAudit == 0)  //瀹℃牳鍒ゆ柇
+                if (string.IsNullOrWhiteSpace(HInterID))
                 {
-                    oCN.RunProc("update PM_ProjectReportBillMain set HChecker='" + CurUserName + "',HCheckDate=getdate() where HInterID=" + HInterID);
-
-                    objJsonResult.code = "1";
-                    objJsonResult.count = 1;
-                    objJsonResult.Message = "瀹℃牳鎴愬姛";
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HInterID涓虹┖锛�";
                     objJsonResult.data = null;
+                    return objJsonResult;
                 }
-                if (IsAudit == 1) //鍙嶅鏍稿垽鏂�
+
+                ClsPub.CurUserName = user;
+                BillOld.MvarItemKey = "PM_ProjectReportBillMain";
+                oCN.BeginTran();//寮�濮嬩簨鍔�
+
+                //Type 1 鍏抽棴  2  鍙嶅叧闂�
+                if (Type == 1)
                 {
-                    oCN.RunProc("update PM_ProjectReportBillMain set HChecker='',HCheckDate=null where HInterID=" + HInterID);
+                    //鍒ゆ柇鍗曟嵁鏄惁宸茬粡鍏抽棴
+                    DataSet ds;
+                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
+                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
+                    if (ds == null || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦紒";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
+                    {
+                        if (ds.Tables[0].Rows[0]["HDeleteMan"] != null && ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘杩涜鍏抽棴!";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        if (ds.Tables[0].Rows[0]["HChecker"] == null || ds.Tables[0].Rows[0]["HChecker"].ToString() == "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁鏈鏍�!涓嶈兘杩涜鍏抽棴!";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
 
-                    objJsonResult.code = "1";
-                    objJsonResult.count = 1;
-                    objJsonResult.Message = "鍙嶅鏍告垚鍔�";
-                    objJsonResult.data = null;
+                        if (ds.Tables[0].Rows[0]["HCloseMan"] != null && ds.Tables[0].Rows[0]["HCloseMan"].ToString() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸插叧闂�!涓嶈兘鍐嶆鍏抽棴!";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        //鍏抽棴鍗曟嵁
+                        if (!BillOld.CloseBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
                 }
-                oCN.Commit();
+                else
+                {
+                    //鍒ゆ柇鍗曟嵁鏄惁宸茬粡鍙嶅叧闂�
+                    DataSet ds;
+                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
+                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
+                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
+                    {
+                        if (ds.Tables[0].Rows[0]["HDeleteMan"] != null && ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘杩涜鍏抽棴!";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        if (ds.Tables[0].Rows[0]["HChecker"] == null || ds.Tables[0].Rows[0]["HChecker"].ToString() == "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁鏈鏍�!涓嶈兘杩涜鍏抽棴!";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        if (ds.Tables[0].Rows[0]["HCloseMan"] == null || ds.Tables[0].Rows[0]["HCloseMan"].ToString() == "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁鏈叧闂�!涓嶉渶瑕佸啀鍙嶅叧闂�!";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        //鍙嶅叧闂崟鎹�
+                        if (!BillOld.CancelClose(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                }
 
-                return objJsonResult;
+                oCN.Commit();//鎻愪氦浜嬪姟
+
+                objJsonResult.code = "0";
+                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.Message = "鎵ц澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 椤圭洰闃舵姹囨姤 浣滃簾/鍙嶄綔搴熷姛鑳�
+        [Route("PM_ProjectReportBill/DropPM_ProjectReportBill")]
+        [HttpGet]
+        public object DropPM_ProjectReportBill(string HInterID, int Type, string user)
+        {
+            try
+            {
+                //鍒ゆ柇鏄惁鏈変綔搴熸潈闄�
+                if (!DBUtility.ClsPub.Security_Log("Pm_ProjectReportBill_Drop", 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 = "PM_ProjectReportBillMain";
+                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;
             }

--
Gitblit v1.9.1