From 096f0a528fc003ad60d50155af11a40d14b9f0d9 Mon Sep 17 00:00:00 2001
From: yangle <admin@YINMOU>
Date: 星期二, 12 十二月 2023 13:34:14 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API

---
 WebAPI/Controllers/项目管理/工作任务/PM_WorkTaskBillController.cs |  722 +++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 517 insertions(+), 205 deletions(-)

diff --git "a/WebAPI/Controllers/\351\241\271\347\233\256\347\256\241\347\220\206/\345\267\245\344\275\234\344\273\273\345\212\241/PM_WorkTaskBillController.cs" "b/WebAPI/Controllers/\351\241\271\347\233\256\347\256\241\347\220\206/\345\267\245\344\275\234\344\273\273\345\212\241/PM_WorkTaskBillController.cs"
index 041f22e..ce78f4e 100644
--- "a/WebAPI/Controllers/\351\241\271\347\233\256\347\256\241\347\220\206/\345\267\245\344\275\234\344\273\273\345\212\241/PM_WorkTaskBillController.cs"
+++ "b/WebAPI/Controllers/\351\241\271\347\233\256\347\256\241\347\220\206/\345\267\245\344\275\234\344\273\273\345\212\241/PM_WorkTaskBillController.cs"
@@ -29,6 +29,7 @@
         {
             public int HInterID;
             public string HBillNo;
+            public int HProjectID;
             public string HProNumber;
             public string HProName;
             public int HProjectStageID;
@@ -58,6 +59,11 @@
             public string HDeleteManDate;
             public string HBackerDate;
             public string HBackRemark;
+
+            public int HMainSourceInterID;
+            public int HMainSourceEntryID;
+            public string HMainSourceBillNo;
+            public string HMainSourceBillType;
         }
         #endregion
 
@@ -141,6 +147,7 @@
                 string HBillSubType = "";
                 int HInterID = mainList[0].HInterID;
                 string HBillNo = mainList[0].HBillNo;
+                int HProjectID = mainList[0].HProjectID;
                 string HProNumber = mainList[0].HProNumber;
                 string HProName = mainList[0].HProName;
                 int HProjectStageID = mainList[0].HProjectStageID;
@@ -170,6 +177,10 @@
                 string HDeleteManDate = mainList[0].HDeleteManDate;
                 string HBackerDate = mainList[0].HBackerDate;
                 string HBackRemark = mainList[0].HBackRemark;
+                int HMainSourceInterID = mainList[0].HMainSourceInterID;
+                int HMainSourceEntryID = mainList[0].HMainSourceEntryID;
+                string HMainSourceBillNo = mainList[0].HMainSourceBillNo;
+                string HMainSourceBillType = mainList[0].HMainSourceBillType;
 
 
                 if (OperationType == 2)
@@ -190,8 +201,8 @@
                 if ((OperationType == 1 || OperationType == 2) && ds.Tables[0].Rows.Count == 0)//鏂板
                 {
                     string sql = "insert into PM_WorkTaskBillMain" +
-                        "(HYear,HPeriod,HBillType,HBillSubType,HInterID,HBillNo,HProNumber,HProjectStageID,HName,HDate,HTaskNote,HPlanTimes" +
-                        ",HSelfTimes,HLastDate,HSendEmp,HReceiveEmp,HType,HCopyEmp,HRemark,HOrgID,HMaker,HMakeDate)" +
+                        "(HYear,HPeriod,HBillType,HBillSubType,HInterID,HBillNo,HProjectID,HProNumber,HProjectStageID,HName,HDate,HTaskNote,HPlanTimes" +
+                        ",HSelfTimes,HLastDate,HSendEmp,HReceiveEmp,HType,HCopyEmp,HRemark,HOrgID,HMaker,HMakeDate,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo,HMainSourceBillType)" +
                         "values(" +
                         "" + HYear +
                         "," + HPeriod +
@@ -199,7 +210,8 @@
                         "','" + HBillSubType +
                         "'," + HInterID +
                         ",'" + HBillNo +
-                        "','" + HProNumber +
+                        "'," + HProjectID +
+                        ",'" + HProNumber +
                         "'," + HProjectStageID +
                         ",'" + HName +
                         "','" + HDate +
@@ -215,6 +227,10 @@
                         "'," + HOrgID +
                         ",'" + HMaker +
                         "','" + HMakerDate +
+                        "'," + HMainSourceInterID +
+                        "," + HMainSourceEntryID +
+                        ",'" + HMainSourceBillNo +
+                        "','" + HMainSourceBillType +
                         "')";
 
                     //涓昏〃
@@ -230,7 +246,8 @@
                         ",HBillType = '" + HBillType +
                         "',HBillSubType = '" + HBillSubType +
                         "',HBillNo = '" + HBillNo +
-                        "',HProNumber = '" + HProNumber +
+                        "',HProjectID = " + HProjectID +
+                        ",HProNumber = '" + HProNumber +
                         "',HProjectStageID = " + HProjectStageID +
                         ",HName = '" + HName +
                         "',HDate = '" + HDate +
@@ -246,6 +263,10 @@
                         "',HOrgID = " + HOrgID +
                         ",HUpdater = '" + HUpdater +
                         "',HUpdateDate = '" + HUpdaterDate +
+                        "',HMainSourceInterID = " + HMainSourceInterID +
+                        ",HMainSourceEntryID = " + HMainSourceEntryID +
+                        ",HMainSourceBillNo = '" + HMainSourceBillNo +
+                        "',HMainSourceBillType = '" + HMainSourceBillType +
                         "' where HInterID = " + HInterID;
 
                     oCN.RunProc(sql);
@@ -255,7 +276,46 @@
                     //璁板綍鏃ュ織
                     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_WorkTaskBillMain" +
+                        "(HYear,HPeriod,HBillType,HBillSubType,HInterID,HBillNo,HProjectID,HProNumber,HProjectStageID,HName,HDate,HTaskNote,HPlanTimes" +
+                        ",HSelfTimes,HLastDate,HSendEmp,HReceiveEmp,HType,HCopyEmp,HRemark,HOrgID,HMaker,HMakeDate,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo,HMainSourceBillType)" +
+                        "values(" +
+                        "" + HYear +
+                        "," + HPeriod +
+                        ",'" + HBillType +
+                        "','" + HBillSubType +
+                        "'," + HInterID +
+                        ",'" + HBillNo +
+                        "'," + HProjectID +
+                        ",'" + HProNumber +
+                        "'," + HProjectStageID +
+                        ",'" + HName +
+                        "','" + HDate +
+                        "','" + HTaskNote +
+                        "'," + HPlanTimes +
+                        "," + HSelfTimes +
+                        ",'" + HLastDate +
+                        "','" + HSendEmp +
+                        "','" + HReceiveEmp +
+                        "','" + HType +
+                        "','" + HCopyEmp +
+                        "','" + HRemark +
+                        "'," + HOrgID +
+                        ",'" + HMaker +
+                        "','" + HMakerDate +
+                        "'," + HMainSourceInterID +
+                        "," + HMainSourceEntryID +
+                        ",'" + HMainSourceBillNo +
+                        "','" + HMainSourceBillType +
+                        "')";
+                    //涓昏〃
+                    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(HInterID, HBillNo, OperationType);
 
@@ -333,12 +393,12 @@
 
                 if (sWhere == null || sWhere.Equals(""))
                 {
-                    ds = oCN.RunProcReturn("select * from h_v_PM_WorkTaskBillList order by 鍗曟嵁鍙� ", "h_v_PM_WorkTaskBillList");
+                    ds = oCN.RunProcReturn("select * from h_v_PM_WorkTaskBillList order by 鍗曟嵁鍙� desc", "h_v_PM_WorkTaskBillList");
                 }
                 else
                 {
                     string sql1 = "select * from h_v_PM_WorkTaskBillList where 1 = 1 ";
-                    string sql = sql1 + sWhere + " order by 鍗曟嵁鍙� ";
+                    string sql = sql1 + sWhere + " order by 鍗曟嵁鍙� desc";
                     ds = oCN.RunProcReturn(sql, "h_v_PM_WorkTaskBillList");
                 }
 
@@ -515,25 +575,49 @@
                     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]["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.Message = "鍗曟嵁宸插鏍�!涓嶈兘鍐嶆瀹℃牳锛�";
                             objJsonResult.data = null;
                             return objJsonResult;
                         }
-                    }
-                    //瀹℃牳鍗曟嵁
-                    if (!BillOld.CheckBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
-                    {
-                        objJsonResult.code = "0";
-                        objJsonResult.count = 1;
-                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
-                        objJsonResult.data = null;
-                        return objJsonResult;
+                        //瀹℃牳鍗曟嵁
+                        if (!BillOld.CheckBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
                     }
                 }
                 else
@@ -544,23 +628,39 @@
                     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.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;
+                        //鍙嶅鏍稿崟鎹�
+                        if (!BillOld.AbandonCheck(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
                     }
                 }
 
@@ -621,25 +721,50 @@
                     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;
+                        }
+
                         if (ds.Tables[0].Rows[0]["HCloseMan"] != null && ds.Tables[0].Rows[0]["HCloseMan"].ToString() != "")
                         {
                             objJsonResult.code = "0";
                             objJsonResult.count = 0;
-                            objJsonResult.Message = "鍗曟嵁宸插叧闂�!涓嶉渶瑕佸啀鍏抽棴!";
+                            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;
+                        //鍏抽棴鍗曟嵁
+                        if (!BillOld.CloseBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
                     }
                 }
                 else
@@ -650,23 +775,39 @@
                     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.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;
+                        //鍙嶅叧闂崟鎹�
+                        if (!BillOld.CancelClose(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
                     }
                 }
 
@@ -727,8 +868,24 @@
                     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";
@@ -737,15 +894,15 @@
                             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;
+                        //浣滃簾鍗曟嵁
+                        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
@@ -756,23 +913,31 @@
                     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.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;
+                        //鍙嶄綔搴熷崟鎹�
+                        if (!BillOld.AbandonCancelltion(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "鍙嶄綔搴熷け璐�!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
                     }
                 }
 
@@ -830,6 +995,7 @@
         public class PM_WorkTaskReportBill_Sub
         {
             public int RowID;
+            public int HProjectID;
             public string HProNumber;
             public int HProjectStageID;
             public string HProjectStageName;
@@ -840,9 +1006,14 @@
             public string HReportNote;
             public string HAdv;
             public string HRemarkSub;
+            public int HSourceInterID;
+            public int HSourceEntryID;
+            public string HSourceBillNo;
+            public string HSourceBillType;
+            public bool HFinishFlag;
         }
         #endregion
-        #region 椤圭洰闃舵娓呭崟 鏂板/缂栬緫-淇濆瓨
+        #region 浠诲姟姹囨姤 鏂板/缂栬緫-淇濆瓨
         /// <summary>
         /// 鏂板鍗曟嵁-淇濆瓨鎸夐挳
         ///鍙傛暟锛歴tring sql銆�
@@ -876,7 +1047,7 @@
             return objJsonResult;
         }
         #endregion
-        #region 娣诲姞 椤圭洰闃舵娓呭崟 涓昏〃
+        #region 娣诲姞 浠诲姟姹囨姤 涓昏〃
         public json AddBillMain_WorkTaskReportBill(string msg1)
         {
             string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
@@ -999,6 +1170,8 @@
 
                     oCN.RunProc(sql);
 
+                    //鍒犻櫎瀛愯〃鏃�  鍥炲~宸ヤ綔浠诲姟鍗曞叧鑱旀暟閲忋�佸崟鎹姸鎬�
+                    oCN.RunProc("exec h_p_PM_UpDateRelation_WorkTaskToWorkTaskReport_Delete " + HInterID.ToString());
                     //鍒犻櫎瀛愯〃
                     oCN.RunProc("delete from PM_WorkTaskReportBillSub where HInterID='" + HInterID + "'");
                     //璁板綍鏃ュ織
@@ -1034,7 +1207,7 @@
                     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_WorkTaskReportBill(msg3, HInterID, HBillNo, OperationType, HProID, HProjectStageID, HMainSourceBillType, HMainSourceBillNo);
+                objJsonResult = AddBillSub_WorkTaskReportBill(msg3, HInterID, HBillNo, OperationType);
 
                 if (objJsonResult.code == "0")
                 {
@@ -1061,89 +1234,60 @@
             }
         }
         #endregion
-        #region 娣诲姞椤圭洰闃舵娓呭崟 瀛愯〃
-        public json AddBillSub_WorkTaskReportBill(string msg3, long HInterID, string HBillNo, int OperationType, int HSourceInterID, int HSourceEntryID, string HSourceBillType, string HSourceBillNo)
+        #region 娣诲姞浠诲姟姹囨姤 瀛愯〃
+        public json AddBillSub_WorkTaskReportBill(string msg3, long HInterID, string HBillNo, int OperationType)
         {
             List<PM_WorkTaskReportBill_Sub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PM_WorkTaskReportBill_Sub>>(msg3);
             int i = 0;                                          //浣滀负瀛愯〃鍐呯爜
-            if(OperationType == 4) {
-                foreach (PM_WorkTaskReportBill_Sub oSub in DetailColl)
-                {
-                    i++;                                            //鍚屼竴涓富琛ㄤ笅鐨勫瓙琛ㄧ殑鍐呯爜鑷
-
-                    int HEntryID = i;
-                    string HProNumber = oSub.HProNumber;
-                    int HProjectStageID = oSub.HProjectStageID;
-                    string HName = oSub.HName;
-                    string HTaskNote = oSub.HTaskNote;
-                    string HType = oSub.HType;
-                    double HRelTimes = oSub.HRelTimes;
-                    string HReportNote = oSub.HReportNote;
-                    string HAdv = oSub.HAdv;
-                    string HRemark = oSub.HRemarkSub;
-
-                    string sql = "insert into PM_WorkTaskReportBillSub" +
-                        "(HInterID,HBillNo_bak,HEntryID,HRemark,HProNumber,HProjectStageID,HName,HTaskNote,HType,HRelTimes,HReportNote,HAdv,HSourceInterID,HSourceEntryID,HSourceBillType,HSourceBillNo) " +
-                        "values(" +
-                        "" + HInterID +
-                        ",'" + HBillNo +
-                        "'," + HEntryID +
-                        ",'" + HRemark +
-                        "','" + HProNumber +
-                        "'," + HProjectStageID +
-                        ",'" + HName +
-                        "','" + HTaskNote +
-                        "','" + HType +
-                        "'," + HRelTimes +
-                        ",'" + HReportNote +
-                        "','" + HAdv +
-                        "'," + HSourceInterID +
-                        "," + HSourceEntryID +
-                        ",'" + HSourceBillType +
-                        "','" + HSourceBillNo +
-                        "')";
-
-                    oCN.RunProc(sql);
-                }
-            }
-            else
+            foreach (PM_WorkTaskReportBill_Sub oSub in DetailColl)
             {
-                foreach (PM_WorkTaskReportBill_Sub oSub in DetailColl)
-                {
-                    i++;                                            //鍚屼竴涓富琛ㄤ笅鐨勫瓙琛ㄧ殑鍐呯爜鑷
+                i++;                                            //鍚屼竴涓富琛ㄤ笅鐨勫瓙琛ㄧ殑鍐呯爜鑷
 
-                    int HEntryID = i;
-                    string HProNumber = oSub.HProNumber;
-                    int HProjectStageID = oSub.HProjectStageID;
-                    string HName = oSub.HName;
-                    string HTaskNote = oSub.HTaskNote;
-                    string HType = oSub.HType;
-                    double HRelTimes = oSub.HRelTimes;
-                    string HReportNote = oSub.HReportNote;
-                    string HAdv = oSub.HAdv;
-                    string HRemark = oSub.HRemarkSub;
+                int HEntryID = i;
+                int HProjectID = oSub.HProjectID;
+                string HProNumber = oSub.HProNumber;
+                int HProjectStageID = oSub.HProjectStageID;
+                string HName = oSub.HName;
+                string HTaskNote = oSub.HTaskNote;
+                string HType = oSub.HType;
+                double HRelTimes = oSub.HRelTimes;
+                string HReportNote = oSub.HReportNote;
+                string HAdv = oSub.HAdv;
+                string HRemark = oSub.HRemarkSub;
+                int HSourceInterID = oSub.HSourceInterID;
+                int HSourceEntryID = oSub.HSourceEntryID;
+                string HSourceBillNo = oSub.HSourceBillNo;
+                string HSourceBillType = oSub.HSourceBillType;
+                bool HFinishFlag = oSub.HFinishFlag;
 
-                    string sql = "insert into PM_WorkTaskReportBillSub" +
-                        "(HInterID,HBillNo_bak,HEntryID,HRemark,HProNumber,HProjectStageID,HName,HTaskNote,HType,HRelTimes,HReportNote,HAdv) " +
-                        "values(" +
-                        "" + HInterID +
-                        ",'" + HBillNo +
-                        "'," + HEntryID +
-                        ",'" + HRemark +
-                        "','" + HProNumber +
-                        "'," + HProjectStageID +
-                        ",'" + HName +
-                        "','" + HTaskNote +
-                        "','" + HType +
-                        "'," + HRelTimes +
-                        ",'" + HReportNote +
-                        "','" + HAdv +
-                        "')";
+                string sql = "insert into PM_WorkTaskReportBillSub" +
+                    "(HInterID,HBillNo_bak,HEntryID,HRemark,HProjectID,HProNumber,HProjectStageID,HName,HTaskNote,HType,HRelTimes,HReportNote,HAdv,HSourceInterID,HSourceEntryID,HSourceBillType,HSourceBillNo,HFinishFlag) " +
+                    "values(" +
+                    "" + HInterID +
+                    ",'" + HBillNo +
+                    "'," + HEntryID +
+                    ",'" + HRemark +
+                    "'," + HProjectID +
+                    ",'" + HProNumber +
+                    "'," + HProjectStageID +
+                    ",'" + HName +
+                    "','" + HTaskNote +
+                    "','" + HType +
+                    "'," + HRelTimes +
+                    ",'" + HReportNote +
+                    "','" + HAdv +
+                    "'," + HSourceInterID +
+                    "," + HSourceEntryID +
+                    ",'" + HSourceBillType +
+                    "','" + HSourceBillNo +
+                    "'," + DBUtility.ClsPub.BoolToString(HFinishFlag) +
+                    ")";
 
-                    oCN.RunProc(sql);
-                }
+                oCN.RunProc(sql);
             }
-            
+
+            //鍥炲~宸ヤ綔浠诲姟鍗曞叧鑱旀暟閲忋�佸崟鎹姸鎬�
+            oCN.RunProc("exec h_p_PM_UpDateRelation_WorkTaskToWorkTaskReport_Add " + HInterID.ToString());
 
             objJsonResult.code = "1";
             objJsonResult.count = 1;
@@ -1179,12 +1323,12 @@
 
                 if (sWhere == null || sWhere.Equals(""))
                 {
-                    ds = oCN.RunProcReturn("select * from h_v_PM_WorkTaskReportBillList order by 鍗曟嵁鍙�", "h_v_PM_ProjectStageBillList");
+                    ds = oCN.RunProcReturn("select * from h_v_PM_WorkTaskReportBillList order by 鍗曟嵁鍙� desc", "h_v_PM_ProjectStageBillList");
                 }
                 else
                 {
                     string sql1 = "select * from h_v_PM_WorkTaskReportBillList where 1 = 1 ";
-                    string sql = sql1 + sWhere + " order by 鍗曟嵁鍙�";
+                    string sql = sql1 + sWhere + " order by 鍗曟嵁鍙� desc";
                     ds = oCN.RunProcReturn(sql, "h_v_PM_WorkTaskReportBillList");
                 }
 
@@ -1299,6 +1443,8 @@
 
                 oCN.BeginTran();
 
+                //鍒犻櫎瀛愯〃鏃�  鍥炲~宸ヤ綔浠诲姟鍗曞叧鑱旀暟閲忋�佸崟鎹姸鎬�
+                oCN.RunProc("exec h_p_PM_UpDateRelation_WorkTaskToWorkTaskReport_Delete " + HInterID.ToString());
                 oCN.RunProc("delete from PM_WorkTaskReportBillMain where HInterID = " + HInterID);
                 oCN.RunProc("delete from PM_WorkTaskReportBillSub where HInterID='" + HInterID + "'");
 
@@ -1306,7 +1452,7 @@
 
                 objJsonResult.code = "1";
                 objJsonResult.count = 1;
-                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.Message = "鍒犻櫎鎴愬姛锛�";
                 objJsonResult.data = null;
                 return objJsonResult;
             }
@@ -1365,25 +1511,49 @@
                     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]["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.Message = "鍗曟嵁宸插鏍�!涓嶈兘鍐嶆瀹℃牳锛�";
                             objJsonResult.data = null;
                             return objJsonResult;
                         }
-                    }
-                    //瀹℃牳鍗曟嵁
-                    if (!BillOld.CheckBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
-                    {
-                        objJsonResult.code = "0";
-                        objJsonResult.count = 1;
-                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
-                        objJsonResult.data = null;
-                        return objJsonResult;
+                        //瀹℃牳鍗曟嵁
+                        if (!BillOld.CheckBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
                     }
                 }
                 else
@@ -1394,23 +1564,39 @@
                     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.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;
+                        //鍙嶅鏍稿崟鎹�
+                        if (!BillOld.AbandonCheck(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
                     }
                 }
 
@@ -1471,25 +1657,50 @@
                     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;
+                        }
+
                         if (ds.Tables[0].Rows[0]["HCloseMan"] != null && ds.Tables[0].Rows[0]["HCloseMan"].ToString() != "")
                         {
                             objJsonResult.code = "0";
                             objJsonResult.count = 0;
-                            objJsonResult.Message = "鍗曟嵁宸插叧闂�!涓嶉渶瑕佸啀鍏抽棴!";
+                            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;
+                        //鍏抽棴鍗曟嵁
+                        if (!BillOld.CloseBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
                     }
                 }
                 else
@@ -1500,23 +1711,39 @@
                     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.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;
+                        //鍙嶅叧闂崟鎹�
+                        if (!BillOld.CancelClose(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
                     }
                 }
 
@@ -1577,8 +1804,24 @@
                     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";
@@ -1587,15 +1830,15 @@
                             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;
+                        //浣滃簾鍗曟嵁
+                        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
@@ -1606,23 +1849,31 @@
                     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.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;
+                        //鍙嶄綔搴熷崟鎹�
+                        if (!BillOld.AbandonCancelltion(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "鍙嶄綔搴熷け璐�!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
                     }
                 }
 
@@ -1645,5 +1896,66 @@
             }
         }
         #endregion
+
+        #region 鏍规嵁鐧诲綍璐︽埛鑾峰彇瀵逛簬鑱屽憳
+        [Route("PM_WorkTaskReportBill/getHEmpByHUserName")]
+        [HttpGet]
+        public object getHEmpByHUserName(string Czybm, string user)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                //鏌ョ湅鏉冮檺
+                //if (!DBUtility.ClsPub.Security_Log("Gy_ProjectStage_Query", 1, false, user))
+                //{
+                //    objJsonResult.code = "0";
+                //    objJsonResult.count = 0;
+                //    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                //    objJsonResult.data = null;
+                //    return objJsonResult;
+                //}
+
+                string sql = @"select a.HEmpID,b.HName HEmpName
+                            from Gy_Czygl AS a
+                            LEFT OUTER JOIN Gy_Employee AS b on a.HEmpID = b.HItemID
+                            where a.Czybm = '" + Czybm + "'";
+
+                ds = oCN.RunProcReturn(sql, "Gy_Czygl");
+
+                if (ds == null || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏈壘鍒扮浉鍏虫暟鎹紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+
+                //娣诲姞鍒楀悕
+                foreach (DataColumn col in ds.Tables[0].Columns)
+                {
+                    Type dataType = col.DataType;
+                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1