From 4bfab3d9173fcced07cea4afb71227b83b47c469 Mon Sep 17 00:00:00 2001
From: zrg <z18737863051@163.com>
Date: 星期二, 25 六月 2024 12:32:22 +0800
Subject: [PATCH] 1

---
 WebAPI/Controllers/工资管理/Pay_SingleBalBillController.cs | 1378 +++++++++++++++++++++++++++++++++++++----------------------
 1 files changed, 862 insertions(+), 516 deletions(-)

diff --git "a/WebAPI/Controllers/\345\267\245\350\265\204\347\256\241\347\220\206/Pay_SingleBalBillController.cs" "b/WebAPI/Controllers/\345\267\245\350\265\204\347\256\241\347\220\206/Pay_SingleBalBillController.cs"
index 413dab1..fafa6d8 100644
--- "a/WebAPI/Controllers/\345\267\245\350\265\204\347\256\241\347\220\206/Pay_SingleBalBillController.cs"
+++ "b/WebAPI/Controllers/\345\267\245\350\265\204\347\256\241\347\220\206/Pay_SingleBalBillController.cs"
@@ -1,4 +1,5 @@
-锘縰sing Newtonsoft.Json.Linq;
+锘縰sing Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
 using Pub_Class;
 using System;
 using System.Collections;
@@ -6,9 +7,8 @@
 using System.Data;
 using System.Data.SqlClient;
 using System.Web.Http;
-using System.Windows.Forms;
 using WebAPI.Models;
-using Newtonsoft.Json;
+using System.Windows.Forms;
 
 namespace WebAPI.Controllers
 {
@@ -16,14 +16,807 @@
     public class Pay_SingleBalBillController : ApiController
     {
         public DBUtility.ClsPub.Enum_BillStatus BillStatus;
-
-        private json objJsonResult = new json();
+        public const string ModName = "2205";                   //鍗曟嵁绫诲瀷
+        public const string ModCaption = "宸ヨ祫缁撶畻鍗曪紙涓汉锛�";          //鍗曟嵁鍚嶇О
+        public const string ModRightName = "Pay_SingleBalBill";
+        public const string ModRightNameList = ModRightName + "List";       //鍒楄〃
+        public const string ModRightNameEdit = ModRightName + "_Edit";      //缂栬緫
+        public const string ModRightNameCheck = ModRightName + "_Check";    //瀹℃牳
+        public const string ModRightNameClose = ModRightName + "_Close";    //鍏抽棴
+        public const string ModRightNameDelete = ModRightName + "_Delete";  //浣滃簾
+        public const string ModRightNameDrop = ModRightName + "_Drop";      //鍒犻櫎
+        public const string ModRightNameMoney = ModRightName + "_Money";    //閲戦
+        public const string ModRightNameQty = ModRightName + "_Qty";        //鏁伴噺
         public DataSet ds = new DataSet();
-        public WebServer webserver = new WebServer();
-        SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
-        public DAL.ClsSc_ICMOBill BillOld = new DAL.ClsSc_ICMOBill();
+        private json objJsonResult = new json();
+        SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
+        public DAL.ClsPay_SingleBalBill oBill = new DAL.ClsPay_SingleBalBill();
         public DLL.ClsPay_SingleBalBill BillNew0 = new DLL.ClsPay_SingleBalBill();   // 
         public DLL.ClsPay_SingleBalBill BillOld0 = new DLL.ClsPay_SingleBalBill();   //                                                                                         
+
+
+        #region 宸ヨ祫缁撶畻鍗�(涓汉)鍒楄〃
+        /// <summary>
+        /// 鑾峰彇宸ヨ祫缁撶畻鍗�(涓汉)鍒楄〃淇℃伅
+        /// </summary>
+        /// <returns></returns>
+        [Route("Pay_SingleBalBillController/GetPay_SingleBalBillList_Json")]
+        [HttpGet]
+        public object GetPay_SingleBalBillList_Json(string sWhere, string HMaker)
+        {
+            try
+            {
+                //鍒ゆ柇鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log(ModRightNameList, 3, false, HMaker))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鎮ㄦ病鏈夎妯″潡鏉冮檺,璇蜂笌绠$悊鍛樿仈绯伙紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                //杩斿洖鍒楄〃淇℃伅
+                ds = oCn.RunProcReturn("select * from h_v_Pay_SingleBalBillList where 1=1 " + sWhere + " order by hmainid desc", "h_v_Pay_SingleBalBillList");
+                List<object> columnNameList = new List<object>();
+                //娣诲姞鍒楀悕
+                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 = "0";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鎴愬姛锛�";
+                objJsonResult.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鏌ヨ鍒楄〃淇℃伅澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 宸ヨ祫缁撶畻鍗�(涓汉) 鍒犻櫎
+        /// <summary>
+        /// 鍒犻櫎宸ヨ祫缁撶畻鍗�(涓汉)
+        /// </summary>
+        /// <returns></returns>
+        [Route("Pay_SingleBalBillController/GetPay_SingleBalBill_Delete_Json")]
+        [HttpGet]
+        public object GetPay_SingleBalBill_Delete_Json(Int64 HInterID, string HMaker)
+        {
+            try
+            {
+                //鍒ゆ柇鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log(ModRightNameDrop, 3, false, HMaker))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鎮ㄦ病鏈夎妯″潡鍒犻櫎鍔熻兘鏉冮檺,璇蜂笌绠$悊鍛樿仈绯伙紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                //鍒ゆ柇瀛樺湪鎬�
+                if (oBill.ShowBill(HInterID, ref DBUtility.ClsPub.sExeReturnInfo))
+                {
+                    //鍒ゆ柇浼氳鏈熸槸鍚﹀悎鐞�
+                    string s = "";
+                    int sYear = 0;
+                    int sPeriod = 0;
+                    if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod_Pay(oBill.omodel.HDate, ref sYear, ref sPeriod, ref s) == false)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = s;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //鍒犻櫎鍓嶆帶鍒�
+                    DataSet BeforeDs = oCn.RunProcReturn("Exec h_p_Pay_SingleBalBill_BeforeDelCtrl " + HInterID.ToString() + ",'" + HMaker + "'", "h_p_Pay_SingleBalBill_BeforeDelCtrl");
+                    if (BeforeDs == null || BeforeDs.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍒犻櫎鍓嶅垽鏂け璐ワ紒";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        if (DBUtility.ClsPub.isLong(BeforeDs.Tables[0].Rows[0]["HBack"]) == 1)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍒犻櫎澶辫触锛�" + DBUtility.ClsPub.isStrNull(BeforeDs.Tables[0].Rows[0]["HRemark"]);
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                    //鍒犻櫎鍗曟嵁锛堝寘鍚垹闄ゅ悗鎺у埗銆佸啓鍏ユ棩蹇楋級
+                    if (!oBill.DeleteBill(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_Pay_SingleBalBill_AfterDelCtrl", HMaker, ref ClsPub.sExeReturnInfo))
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍒犻櫎宸ヨ祫缁撶畻鍗�(涓汉)鎴愬姛锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    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 宸ヨ祫缁撶畻鍗�(涓汉) 瀹℃牳/鍙嶅鏍�
+        /// <summary>
+        /// 瀹℃牳/鍙嶅鏍稿伐璧勭粨绠楀崟(涓汉)
+        /// </summary>
+        /// <param name="HInterID">鍗曟嵁ID</param>
+        /// <param name="Type">瀹℃牳(1),鍙嶅鏍�(2)</param>
+        /// <param name="HMaker">瀹℃牳浜�</param>
+        /// <returns></returns>
+        [Route("Pay_SingleBalBillController/GetPay_SingleBalBill_Check_Json")]
+        [HttpGet]
+        public object GetPay_SingleBalBill_Check_Json(Int64 HInterID, int Type, string HMaker)
+        {
+            try
+            {
+                //鍒ゆ柇鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 3, false, HMaker))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鎮ㄦ病鏈夎妯″潡瀹℃牳/鍙嶅鏍稿姛鑳芥潈闄�,璇蜂笌绠$悊鍛樿仈绯伙紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                //鍒ゆ柇瀛樺湪鎬�
+                if (oBill.ShowBill(HInterID, ref DBUtility.ClsPub.sExeReturnInfo))
+                {
+                    //鍒ゆ柇浼氳鏈熸槸鍚﹀悎鐞�
+                    string s = "";
+                    int sYear = 0;
+                    int sPeriod = 0;
+                    if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod_Pay(oBill.omodel.HDate, ref sYear, ref sPeriod, ref s) == false)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = s;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+
+                    //Type 1 瀹℃牳  2  鍙嶅鏍�
+                    if (Type == 1)
+                    {
+                        if (oBill.omodel.HChecker.Trim() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸插鏍革紝涓嶈兘鍐嶆瀹℃牳锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        if (oBill.omodel.HCloseMan.Trim() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸插叧闂紝涓嶈兘鍐嶆瀹℃牳锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        if (oBill.omodel.HDeleteMan.Trim() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸蹭綔搴燂紝涓嶈兘鍐嶆瀹℃牳锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        //瀹℃牳鍓嶆帶鍒�
+                        DataSet BeforeDs = oCn.RunProcReturn("Exec h_p_Pay_SingleBalBill_BeforeCheckCtrl " + HInterID.ToString() + ",'" + HMaker + "'", "h_p_Pay_SingleBalBill_BeforeCheckCtrl");
+                        if (BeforeDs == null || BeforeDs.Tables[0].Rows.Count == 0)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "瀹℃牳鍓嶅垽鏂け璐ワ紒";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        else
+                        {
+                            if (DBUtility.ClsPub.isLong(BeforeDs.Tables[0].Rows[0]["HBack"]) == 1)
+                            {
+                                objJsonResult.code = "0";
+                                objJsonResult.count = 0;
+                                objJsonResult.Message = "瀹℃牳澶辫触锛�" + DBUtility.ClsPub.isStrNull(BeforeDs.Tables[0].Rows[0]["HRemark"]);
+                                objJsonResult.data = null;
+                                return objJsonResult;
+                            }
+                        }
+                        //瀹℃牳鍗曟嵁
+                        if (!oBill.CheckBill(HInterID, oBill.omodel.HBillNo, "h_p_Pay_SingleBalBill_AfterCheckCtrl", HMaker, ref ClsPub.sExeReturnInfo))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        else
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "鍗曟嵁鍙凤細" + oBill.omodel.HBillNo + " 瀹℃牳鎴愬姛锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult; ;
+                        }
+                    }
+                    else
+                    {
+                        if (oBill.omodel.HChecker.Trim() == "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁鏈鏍革紝涓嶉渶瑕佸弽瀹℃牳锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        //鍙嶅鏍稿墠鎺у埗
+                        DataSet BeforeDs = oCn.RunProcReturn("Exec h_p_Pay_SingleBalBill_BeforeUnCheckCtrl " + HInterID.ToString() + ",'" + HMaker + "'", "h_p_Pay_SingleBalBill_BeforeUnCheckCtrl");
+                        if (BeforeDs == null || BeforeDs.Tables[0].Rows.Count == 0)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍙嶅鏍稿墠鍒ゆ柇澶辫触锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        else
+                        {
+                            if (DBUtility.ClsPub.isLong(BeforeDs.Tables[0].Rows[0]["HBack"]) == 1)
+                            {
+                                objJsonResult.code = "0";
+                                objJsonResult.count = 0;
+                                objJsonResult.Message = "鍙嶅鏍稿け璐ワ紒" + DBUtility.ClsPub.isStrNull(BeforeDs.Tables[0].Rows[0]["HRemark"]);
+                                objJsonResult.data = null;
+                                return objJsonResult;
+                            }
+                        }
+
+                        //鍙嶅鏍稿崟鎹�
+                        if (!oBill.AbandonCheck(HInterID, oBill.omodel.HBillNo, "h_p_Pay_SingleBalBill_AfterUnCheckCtrl", HMaker, ref ClsPub.sExeReturnInfo))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        else
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "鍗曟嵁鍙凤細" + oBill.omodel.HBillNo + " 鍙嶅鏍告垚鍔燂紒";
+                            objJsonResult.data = null;
+                            return objJsonResult; ;
+                        }
+                    }
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    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 宸ヨ祫缁撶畻鍗�(涓汉) 鍏抽棴/鍙嶅叧闂�
+        /// <summary>
+        /// 鍏抽棴/鍙嶅叧闂伐璧勭粨绠楀崟(涓汉)
+        /// </summary>
+        /// <param name="HInterID">鍗曟嵁ID</param>
+        /// <param name="Type">鍏抽棴(1),鍙嶅叧闂�(2)</param>
+        /// <param name="HMaker">鍏抽棴浜�</param>
+        /// <returns></returns>
+        [Route("Pay_SingleBalBillController/GetPay_SingleBalBill_Close_Json")]
+        [HttpGet]
+        public object GetPay_SingleBalBill_Close_Json(Int64 HInterID, int Type, string HMaker)
+        {
+            try
+            {
+                //鍒ゆ柇鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log(ModRightNameClose, 3, false, HMaker))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鎮ㄦ病鏈夎妯″潡鍏抽棴/鍙嶅叧闂姛鑳芥潈闄�,璇蜂笌绠$悊鍛樿仈绯伙紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                //鍒ゆ柇瀛樺湪鎬�
+                if (oBill.ShowBill(HInterID, ref DBUtility.ClsPub.sExeReturnInfo))
+                {
+                    //鍒ゆ柇浼氳鏈熸槸鍚﹀悎鐞�
+                    string s = "";
+                    int sYear = 0;
+                    int sPeriod = 0;
+                    if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod_Pay(oBill.omodel.HDate, ref sYear, ref sPeriod, ref s) == false)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = s;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+
+                    //Type 1 鍏抽棴  2  鍙嶅叧闂�
+                    if (Type == 1)
+                    {
+                        if (oBill.omodel.HCloseMan.Trim() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸插叧闂紝涓嶈兘鍐嶆鍏抽棴锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        //鍏抽棴鍗曟嵁
+                        if (!oBill.CloseBill(HInterID, oBill.omodel.HBillNo, HMaker, ref ClsPub.sExeReturnInfo))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        else
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "鍗曟嵁鍙凤細" + oBill.omodel.HBillNo + " 鍏抽棴鎴愬姛锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult; ;
+                        }
+                    }
+                    else
+                    {
+                        if (oBill.omodel.HCloseMan.Trim() == "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁鏈叧闂紝涓嶉渶瑕佸弽鍏抽棴锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        //鍙嶅叧闂崟鎹�
+                        if (!oBill.CancelClose(HInterID, oBill.omodel.HBillNo, HMaker, ref ClsPub.sExeReturnInfo))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        else
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "鍗曟嵁鍙凤細" + oBill.omodel.HBillNo + " 鍙嶅叧闂垚鍔燂紒";
+                            objJsonResult.data = null;
+                            return objJsonResult; ;
+                        }
+                    }
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    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 宸ヨ祫缁撶畻鍗�(涓汉) 浣滃簾/鍙嶄綔搴�
+        /// <summary>
+        /// 浣滃簾/鍙嶄綔搴熷伐璧勭粨绠楀崟(涓汉)
+        /// </summary>
+        /// <param name="HInterID">鍗曟嵁ID</param>
+        /// <param name="Type">浣滃簾(1),鍙嶄綔搴�(2)</param>
+        /// <param name="HMaker">浣滃簾浜�</param>
+        /// <returns></returns>
+        [Route("Pay_SingleBalBillController/GetPay_SingleBalBill_Cancelltion_Json")]
+        [HttpGet]
+        public object GetPay_SingleBalBill_Cancelltion_Json(Int64 HInterID, int Type, string HMaker)
+        {
+            try
+            {
+                //鍒ゆ柇鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log(ModRightNameDelete, 3, false, HMaker))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鎮ㄦ病鏈夎妯″潡浣滃簾/鍙嶄綔搴熷姛鑳芥潈闄�,璇蜂笌绠$悊鍛樿仈绯伙紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                //鍒ゆ柇瀛樺湪鎬�
+                if (oBill.ShowBill(HInterID, ref DBUtility.ClsPub.sExeReturnInfo))
+                {
+                    //鍒ゆ柇浼氳鏈熸槸鍚﹀悎鐞�
+                    string s = "";
+                    int sYear = 0;
+                    int sPeriod = 0;
+                    if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod_Pay(oBill.omodel.HDate, ref sYear, ref sPeriod, ref s) == false)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = s;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+
+                    //Type 1 浣滃簾  2  鍙嶄綔搴�
+                    if (Type == 1)
+                    {
+                        if (oBill.omodel.HDeleteMan.Trim() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸蹭綔搴燂紝涓嶈兘鍐嶆浣滃簾锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        //浣滃簾鍗曟嵁
+                        if (!oBill.Cancelltion(HInterID, oBill.omodel.HBillNo, HMaker, ref ClsPub.sExeReturnInfo))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "浣滃簾澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        else
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "鍗曟嵁鍙凤細" + oBill.omodel.HBillNo + " 浣滃簾鎴愬姛锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult; ;
+                        }
+                    }
+                    else
+                    {
+                        if (oBill.omodel.HDeleteMan.Trim() == "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁鏈綔搴燂紝涓嶉渶瑕佸弽浣滃簾锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        //鍙嶄綔搴熷崟鎹�
+                        if (!oBill.AbandonCancelltion(HInterID, oBill.omodel.HBillNo, HMaker, ref ClsPub.sExeReturnInfo))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍙嶄綔搴熷け璐�!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        else
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "鍗曟嵁鍙凤細" + oBill.omodel.HBillNo + " 鍙嶄綔搴熸垚鍔燂紒";
+                            objJsonResult.data = null;
+                            return objJsonResult; ;
+                        }
+                    }
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    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 宸ヨ祫缁撶畻鍗�(涓汉)妯″潡   浠庡垪琛ㄩ�変腑鎵撳紑鍗曟嵁锛岃繑鍥炲崟鎹俊鎭椂璋冪敤
+        /// <summary>
+        /// 宸ヨ祫缁撶畻鍗�(涓汉)缂栬緫鏃讹紝鏍规嵁鍗曟嵁ID鑾峰彇鍗曟嵁淇℃伅
+        /// </summary>
+        /// <returns></returns>
+        [Route("Pay_SingleBalBillController/GetPay_SingleBalBill_Json")]
+        [HttpGet]
+        public object GetPay_SingleBalBill_Json(Int64 HInterID, string HMaker)
+        {
+            try
+            {
+                //鍒ゆ柇鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log(ModRightNameEdit, 3, false, HMaker))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鎮ㄦ病鏈夎妯″潡缂栬緫鏉冮檺,璇蜂笌绠$悊鍛樿仈绯伙紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                //杩斿洖鍒楄〃淇℃伅
+                ds = oCn.RunProcReturn("exec h_p_Pay_SingleBalBill_EditInit " + HInterID, "h_p_Pay_SingleBalBill_EditInit");
+                if (ds == null || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏈煡璇㈠埌璇ュ伐璧勭粨绠楀崟(涓汉)锛岃鍒锋柊鏁版嵁鍚庨噸鏂伴�夋嫨锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鎴愬姛锛�";
+                    objJsonResult.data = ds.Tables[0];
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "杩斿洖宸ヨ祫缁撶畻鍗�(涓汉)淇℃伅澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 宸ヨ祫缁撶畻鍗�(涓汉)淇濆瓨
+        /// <summary>
+        /// 宸ヨ祫缁撶畻鍗�(涓汉)淇濆瓨
+        /// </summary>
+        [Route("Pay_SingleBalBillController/GetPay_SingleBalBill_Save_Json")]
+        [HttpPost]
+        public object GetPay_SingleBalBill_Save_Json([FromBody] JObject sMainSub)
+        {
+            var _value = sMainSub["sMainSub"].ToString();
+            string msg1 = _value.ToString();
+            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+            string sMainStr = sArray[0].ToString();         //涓昏〃鏁版嵁
+            string sSubStr = sArray[1].ToString();          //瀛愯〃鏁版嵁
+            string OperationType = sArray[2].ToString();    //鎿嶄綔绫诲瀷锛�1鏂板銆�2缂栬緫锛�
+            string HMaker = sArray[3].ToString();           //鍒跺崟浜�
+            try
+            {
+                //鍒ゆ柇鏉冮檺
+                if (OperationType == "1")
+                {
+                    BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew;
+                    //鍒ゆ柇鏂板鏉冮檺
+                    if (!DBUtility.ClsPub.Security_Log(ModRightName, 1, false, HMaker))
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鎮ㄦ病鏈夎妯″潡鏂板鏉冮檺,璇蜂笌绠$悊鍛樿仈绯伙紒";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                else
+                {
+                    BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify;
+                    //鍒ゆ柇缂栬緫鏉冮檺
+                    if (!DBUtility.ClsPub.Security_Log(ModRightNameEdit, 1, false, HMaker))
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鎮ㄦ病鏈夎妯″潡缂栬緫鏉冮檺,璇蜂笌绠$悊鍛樿仈绯伙紒";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                //琛ㄥご璧嬪��
+                sMainStr = sMainStr.Replace("\\", "");
+                sMainStr = sMainStr.Replace("\n", "");
+                sMainStr = "[" + sMainStr.ToString() + "]";
+                List<Model.ClsPay_SingleBalBillMain> lsmain = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsPay_SingleBalBillMain>>(sMainStr);
+                foreach (Model.ClsPay_SingleBalBillMain oItem in lsmain)
+                {
+                    //鍗曟嵁鍙锋槸鍚﹂噸澶�
+                    if (oBill.IsExistBillNo(ref ClsPub.sExeReturnInfo, oItem.HBillNo, BillStatus, oItem.HInterID))
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁鍙烽噸澶嶏紒涓嶅厑璁镐繚瀛橈紒";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //鍒ゆ柇浼氳鏈熸槸鍚﹀悎鐞�
+                    string s = "";
+                    int sYear = 0;
+                    int sPeriod = 0;
+                    if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod_Pay(oItem.HDate, ref sYear, ref sPeriod, ref s) == false)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = s;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+
+                    oItem.HYear = sYear;
+                    oItem.HPeriod = sPeriod;
+                    DBUtility.ClsPub.CurUserName = oItem.HMaker;
+                    oBill.omodel = oItem;
+                }
+                //琛ㄤ綋璧嬪��
+                //鎸� },{鏉ユ媶鍒嗘暟缁� //鍘绘帀銆愬拰銆�
+                sSubStr = sSubStr.Substring(1, sSubStr.Length - 2);
+                sSubStr = sSubStr.Replace("\\", "");
+                sSubStr = sSubStr.Replace("\n", "");
+                sSubStr = "[" + sSubStr.ToString() + "]";
+                List<Model.ClsPay_SingleBalBillSub> ls = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsPay_SingleBalBillSub>>(sSubStr);
+                int i = 0;
+                foreach (Model.ClsPay_SingleBalBillSub oItemSub in ls)
+                {
+                    i++;
+                    oItemSub.HEntryID = i;
+                    oBill.DetailColl.Add(oItemSub);
+                }
+
+                //淇濆瓨
+                bool bResult;
+                if (OperationType == "1")   //鏂板淇濆瓨
+                {
+                    bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+                }
+                else                        //缂栬緫淇濆瓨
+                {
+                    bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
+                }
+
+                if (bResult)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo;  //鎴愬姛锛�
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "淇濆瓨澶辫触锛�" + e.Message;
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+        #endregion
+
+        #region 鏍规嵁鐗╂枡ID銆佸伐搴廔D銆佽祫婧怚D鑾峰彇宸ヤ环
+        [Route("Pay_SingleBalBill/get_HPrice_BaseMaterHProcHSource")]
+        [HttpGet]
+        public object get_HPrice_BaseMaterHProcHSource(Int64 HMaterID, Int64 HProcID, Int64 HSourceID)
+        {
+            try
+            {
+                DAL.ClsGy_ProcPrice_Ctl oProcPrice = new DAL.ClsGy_ProcPrice_Ctl();
+                double HPrice = oProcPrice.LoadProcPrice(HMaterID, HProcID, HSourceID, true);
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = HPrice;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+        //---------------------------------------------------------------------------------------------鏃ф柟娉�
 
         #region 宸ヨ祫缁撶畻鍗曚釜浜�-鏌ヨ
         /// <summary>
@@ -326,54 +1119,13 @@
         }
         #endregion
 
-        #region 宸ヨ祫缁撶畻鍗曚釜浜哄垹闄�
-        /// <summary>
-        ///宸ヨ祫缁撶畻涓汉鍗曞垹闄ゅ姛鑳�
-        /// </summary>
-        /// <returns></returns>
-        [Route("Pay_SingleBalBill/DeltetSingleBalBill")]
-        [HttpGet]
-        public object Pay_SingleBalBill(string HInterID,string user)
-        {
-            try
-            {
-                if (!DBUtility.ClsPub.Security_Log("Pay_SingleBalBill_Drop", 1, false, user))
-                {
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
-                    objJsonResult.data = null;
-                    return objJsonResult;
-                }
-                oCN.BeginTran();
-                oCN.RunProc("Delete From Pay_SingleBalBillMain where HInterID = " + HInterID);
-                oCN.RunProc("Delete From Pay_SingleBalBillSub where HInterID = " + HInterID);
-                oCN.Commit();
-                objJsonResult.code = "1";
-                objJsonResult.count = 1;
-                objJsonResult.Message = "鍒犻櫎鎴愬姛锛�";
-                objJsonResult.data = null;
-                return objJsonResult;
-            }
-            catch (Exception e)
-            {
-                oCN.RollBack();
-                objJsonResult.code = "0";
-                objJsonResult.count = 0;
-                objJsonResult.Message = "Exception锛�" + e.ToString();
-                objJsonResult.data = null;
-                return objJsonResult;
-            }
-        }
-        #endregion
-
         [Route("Pay_SingleBalBill/getSingleBalBillPrice")]
         [HttpGet]
         public object getSingleBalBillPrice(string HMaterID,string HProcID)
         {
             try
             {
-                DataSet ds = oCN.RunProcReturn("select 鍗曚环 from h_v_Gy_ProcPriceList where HMaterID='" + HMaterID + "' and HProcID='" + HProcID + "'", "h_v_Gy_ProcPriceList");
+                DataSet ds = oCn.RunProcReturn("select 鍗曚环 from h_v_Gy_ProcPriceList where HMaterID='" + HMaterID + "' and HProcID='" + HProcID + "'", "h_v_Gy_ProcPriceList");
                 objJsonResult.code = "1";
                 objJsonResult.count = 1;
                 objJsonResult.Message = "鏌ヨ鎴愬姛锛�";
@@ -404,7 +1156,7 @@
             try
             {
                 string sql = $"exec h_p_Gy_GenerateSalary '{HBeginDate}','{HEndDate}','{HDeptID}' ";
-                oCN.RunProc(sql); 
+                oCn.RunProc(sql); 
                 objJsonResult.code = "1";
                 objJsonResult.count = 1;
                 objJsonResult.Message = "鐢熸垚鎴愬姛";
@@ -523,19 +1275,19 @@
             var _value = sMainSub["sMainSub"].ToString();
             string msg1 = _value.ToString();
             //寮�濮嬩簨鍔�
-            oCN.BeginTran();
+            oCn.BeginTran();
             //淇濆瓨涓昏〃
             objJsonResult = AddBillMain_Pay_SingleBalBillMain(msg1);
             if (objJsonResult.code == "0")
             {
-                oCN.RollBack();
+                oCn.RollBack();
                 objJsonResult.code = "0";
                 objJsonResult.count = 0;
                 objJsonResult.Message = objJsonResult.Message;
                 objJsonResult.data = null;
                 return objJsonResult;
             }
-            oCN.Commit();
+            oCn.Commit();
             objJsonResult.code = "1";
             objJsonResult.count = 1;
             objJsonResult.Message = "鏂板鍗曟嵁鎴愬姛锛�";
@@ -604,25 +1356,33 @@
                 
                 //鍒跺崟銆佷慨鏀�
                 string HMaker = mainList[0].HMaker;
-                string HMakerDate = mainList[0].HMakerDate;
+                DateTime HMakerDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString());
                 string HUpdater = mainList[0].HUpdater;
-                string HUpdaterDate = mainList[0].HUpdaterDate;
-                
+                DateTime HUpdaterDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString());
 
-                //if (OperationType == 2)
-                //{
-                //    ds = oCN.RunProcReturn("select * from PM_ProjectStageBillMain where HBillNo ='" + HBillNo + "'", "PM_ProjectStageBill");
-                //    if (ds.Tables[0].Rows.Count > 0)
-                //    {
-                //        objJsonResult.code = "0";
-                //        objJsonResult.count = 0;
-                //        objJsonResult.Message = "鍗曟嵁鍙烽噸澶�,璇烽噸鏂拌緭鍏�!";
-                //        objJsonResult.data = null;
-                //        return objJsonResult;
-                //    }
-                //}
+                //淇濆瓨鍓嶆帶鍒�
+                DataSet BeforeDs = oCn.RunProcReturn("Exec h_p_Pay_SingleBalBill_BeforeSaveCtrl " + HInterID.ToString() + ",'" + HBillNo + "'," + OperationType.ToString(), "h_p_Pay_SingleBalBill_BeforeSaveCtrl");
+                if (BeforeDs == null || BeforeDs.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "淇濆瓨鍓嶅垽鏂け璐ワ紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    if (DBUtility.ClsPub.isLong(BeforeDs.Tables[0].Rows[0]["HBack"]) == 1)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.isStrNull(BeforeDs.Tables[0].Rows[0]["HRemark"]);
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
 
-                ds = oCN.RunProcReturn("select * from Pay_SingleBalBillMain where HInterID = " + HInterID + " and HBillNo = '" + HBillNo + "'", "Pay_SingleBalBillMain");
+                ds = oCn.RunProcReturn("select * from Pay_SingleBalBillMain where HInterID = " + HInterID + " and HBillNo = '" + HBillNo + "'", "Pay_SingleBalBillMain");
 
                 if ((OperationType == 1 || OperationType == 2) && ds.Tables[0].Rows.Count == 0)//鏂板
                 {
@@ -652,9 +1412,9 @@
                         "')";
 
                     //涓昏〃
-                    oCN.RunProc(sql);
+                    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);
+                    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 == 3 || ds.Tables[0].Rows.Count != 0)                    //缂栬緫
                 {
@@ -679,13 +1439,13 @@
                         "',HMainSourceBillType = '" + HMainSourceBillType +
                         "' where HInterID = " + HInterID;
 
-                    oCN.RunProc(sql);
+                    oCn.RunProc(sql);
 
                     //鍒犻櫎瀛愯〃
-                    oCN.RunProc("delete from Pay_SingleBalBillSub where HInterID=" + HInterID + "");
+                    oCn.RunProc("delete from Pay_SingleBalBillSub where HInterID=" + HInterID + "");
                     //璁板綍鏃ュ織
                     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);
+                    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_Pay_SingleBalBillMain(msg3, HInterID, HBillNo, OperationType);
@@ -808,77 +1568,43 @@
                     "','" + HEntryCloseDate +
                     "')";
 
-                oCN.RunProc(sql);
+                oCn.RunProc(sql);
             }
 
-            objJsonResult.code = "1";
-            objJsonResult.count = 1;
-            objJsonResult.Message = null;
-            objJsonResult.data = null;
-            return objJsonResult;
-        }
-        #endregion
-        #endregion
-
-        #region 宸ヨ祫缁撶畻鍗�(涓汉)-鏌ヨ
-        /// <summary>
-        /// 杩斿洖椤圭洰闃舵鍒楄〃
-        ///鍙傛暟锛歴tring sql銆�
-        ///杩斿洖鍊硷細object銆�
-        /// </summary>
-        [Route("Pay_SingleBalBill/list")]
-        [HttpGet]
-        public object getSingleBalBill(string sWhere, string user)
-        {
-            try
-            {
-                List<object> columnNameList = new List<object>();
-                if (!DBUtility.ClsPub.Security_Log("Pay_SingleBalBillList", 1, false, user))
-                {
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
-                    objJsonResult.data = null;
-                    return objJsonResult;
-                }
-
-                if (sWhere == null || sWhere.Equals(""))
-                {
-                    ds = oCN.RunProcReturn("select * from h_v_Pay_SingleBalBillList order by hmainid desc", "h_v_Pay_SingleBalBillList");
-                }
-                else
-                {
-                    string sql1 = "select * from h_v_Pay_SingleBalBillList where 1 = 1 ";
-                    string sql = sql1 + sWhere + " order by hmainid desc";
-                    ds = oCN.RunProcReturn(sql, "h_v_Pay_SingleBalBillList");
-                }
-
-                //娣诲姞鍒楀悕
-                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)
+            //淇濆瓨鍚庢帶鍒�
+            DataSet AfterDs = oCn.RunProcReturn("Exec h_p_Pay_SingleBalBill_AfterSaveCtrl " + HInterID.ToString() + ",'" + HBillNo + "'," + OperationType.ToString(), "h_p_Pay_SingleBalBill_AfterSaveCtrl");
+            if (AfterDs == null || AfterDs.Tables[0].Rows.Count == 0)
             {
                 objJsonResult.code = "0";
                 objJsonResult.count = 0;
-                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.Message = "淇濆瓨鍚庡垽鏂け璐ワ紒";
                 objJsonResult.data = null;
                 return objJsonResult;
             }
+            else
+            {
+                if (DBUtility.ClsPub.isLong(AfterDs.Tables[0].Rows[0]["HBack"]) == 1)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.isStrNull(AfterDs.Tables[0].Rows[0]["HRemark"]);
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = null;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+            }
         }
         #endregion
+        #endregion
 
+        
         #region 宸ヨ祫缁撶畻鍗� 缂栬緫-椤甸潰璧嬪��
         /// <summary>
         ///鍙傛暟锛歴tring HInterID銆�
@@ -911,7 +1637,7 @@
                     return objJsonResult;
                 }
 
-                ds = oCN.RunProcReturn("exec h_p_Pay_SingleBalBill_EditInit " + HInterID, "h_p_Pay_SingleBalBill_EditInit");
+                ds = oCn.RunProcReturn("exec h_p_Pay_SingleBalBill_EditInit " + HInterID, "h_p_Pay_SingleBalBill_EditInit");
                 tableList.Add(ds.Tables[0]);
                 tableList.Add(ds.Tables[1]);
 
@@ -926,386 +1652,6 @@
                 objJsonResult.code = "0";
                 objJsonResult.count = 0;
                 objJsonResult.Message = "Exception锛�" + e.ToString();
-                objJsonResult.data = null;
-                return objJsonResult;
-            }
-        }
-        #endregion
-
-        #region 宸ヨ祫缁撶畻鍗�(涓汉) 鍒犻櫎
-        /// <summary>
-        ///鍙傛暟锛歴tring HInterID銆�
-        ///杩斿洖鍊硷細object銆�
-        /// </summary>
-        [Route("Pay_SingleBalBill/delete")]
-        [HttpGet]
-        public object deleteSingleBalBill(string HInterID, string user)
-        {
-            try
-            {
-                //鏌ョ湅鏉冮檺
-                if (!DBUtility.ClsPub.Security_Log("Pay_SingleBalBill_Drop", 1, false, user))
-                {
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
-                    objJsonResult.data = null;
-                    return objJsonResult;
-                }
-
-                if (HInterID == null || HInterID.Equals(""))
-                {
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = "HInterID涓嶈兘涓虹┖锛�";
-                    objJsonResult.data = null;
-                    return objJsonResult;
-                }
-
-                oCN.BeginTran();
-
-                oCN.RunProc("delete from Pay_SingleBalBillMain where HInterID = " + HInterID);
-                oCN.RunProc("delete from Pay_SingleBalBillSub where HInterID='" + HInterID + "'");
-
-                oCN.Commit();
-
-                objJsonResult.code = "1";
-                objJsonResult.count = 1;
-                objJsonResult.Message = "Sucess锛�";
-                objJsonResult.data = null;
-                return objJsonResult;
-            }
-            catch (Exception e)
-            {
-                objJsonResult.code = "0";
-                objJsonResult.count = 0;
-                objJsonResult.Message = "Exception锛�" + e.ToString();
-                objJsonResult.data = null;
-                return objJsonResult;
-            }
-        }
-        #endregion
-
-        #region 宸ヨ祫缁撶畻鍗�(涓汉) 瀹℃牳/鍙嶅鏍�
-        /// <summary>
-        /// 
-        /// </summary>
-        /// <param name="HInterID">鍗曟嵁ID</param>
-        /// <param name="IsAudit">瀹℃牳(0),鍙嶅鏍�(1)</param>
-        /// <param name="CurUserName">瀹℃牳浜�</param>
-        /// <returns></returns>
-        [Route("Pay_SingleBalBill/AuditPay_SingleBalBill")]
-        [HttpGet]
-        public object AuditPM_ProjectReportBill(string HInterID, int Type, string user)
-        {
-            try
-            {
-                //鍒ゆ柇鏄惁鏈夊鏍告潈闄�
-                if (!DBUtility.ClsPub.Security_Log("Pay_SingleBalBill_Check", 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 = "Pay_SingleBalBillMain";
-                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.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 (!BillOld.CheckBill(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 (!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("Pay_SingleBalBill/ClosePay_SingleBalBill")]
-        [HttpGet]
-        public object ClosePay_SingleBalBill(string HInterID, int Type, string user)
-        {
-            try
-            {
-                //鍒ゆ柇鏄惁鏈夊垹闄ゆ潈闄�
-                if (!DBUtility.ClsPub.Security_Log("Pay_SingleBalBill_Close", 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 = "Pay_SingleBalBillMain";
-                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.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 (!BillOld.CloseBill(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]["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;
-                    }
-                }
-
-                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("Pay_SingleBalBill/DropPay_SingleBalBill")]
-        [HttpGet]
-        public object DropPay_SingleBalBill(string HInterID, int Type, string user)
-        {
-            try
-            {
-                //鍒ゆ柇鏄惁鏈変綔搴熸潈闄�
-                if (!DBUtility.ClsPub.Security_Log("Pay_SingleBalBill_Delete", 1, false, user))
-                {
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = "鏃犳潈闄愪綔搴�!";
-                    objJsonResult.data = null;
-                    return objJsonResult;
-                }
-
-                if (string.IsNullOrWhiteSpace(HInterID))
-                {
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = "HInterID涓虹┖锛�";
-                    objJsonResult.data = null;
-                    return objJsonResult;
-                }
-
-                ClsPub.CurUserName = user;
-                BillOld.MvarItemKey = "Pay_SingleBalBillMain";
-                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.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 (!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]["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