From cc0b389122a9ebddb52541df11f54be99dab5f36 Mon Sep 17 00:00:00 2001
From: wtt <1985833171@qq.com>
Date: 星期三, 21 五月 2025 20:03:43 +0800
Subject: [PATCH] 排产删除excel导入功能优化

---
 WebAPI/Controllers/工资管理/Pay_DuSubsidyItemBillController.cs | 1418 +++++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 1,087 insertions(+), 331 deletions(-)

diff --git "a/WebAPI/Controllers/\345\267\245\350\265\204\347\256\241\347\220\206/Pay_DuSubsidyItemBillController.cs" "b/WebAPI/Controllers/\345\267\245\350\265\204\347\256\241\347\220\206/Pay_DuSubsidyItemBillController.cs"
index 9f45657..631f096 100644
--- "a/WebAPI/Controllers/\345\267\245\350\265\204\347\256\241\347\220\206/Pay_DuSubsidyItemBillController.cs"
+++ "b/WebAPI/Controllers/\345\267\245\350\265\204\347\256\241\347\220\206/Pay_DuSubsidyItemBillController.cs"
@@ -6,22 +6,601 @@
 using System.Collections.Generic;
 using System.Data;
 using System.Linq;
+using System.IO;
 using System.Web;
 using System.Web.Http;
 using System.Windows.Forms;
 using WebAPI.Models;
+using WebAPI.Controllers.SCGL.鏃ヨ鍒掔鐞�;
+using System.Text.RegularExpressions;
 
-namespace WebAPI.Controllers.椤圭洰绠$悊.宸ヤ綔浠诲姟
+namespace WebAPI.Controllers.宸ヨ祫绠$悊.鎵hˉ椤圭洰璐圭敤鍗�
 {
     public class Pay_DuSubsidyItemBillController : ApiController
     {
-        public DBUtility.ClsPub.Enum_BillStatus BillStatus;//鍗曟嵁鐘舵�侊紙鏂板锛屼慨鏀癸紝娴忚锛屾洿鏂板崟浠凤紝鍙樻洿锛�
-        private json objJsonResult = new json();
+        public DBUtility.ClsPub.Enum_BillStatus BillStatus;
+        public const string ModName = "2233";                   //鍗曟嵁绫诲瀷
+        public const string ModCaption = "鎵hˉ椤圭洰璐圭敤鍗�";          //鍗曟嵁鍚嶇О
+        public const string ModRightName = "Pay_DuSubsidyItemBill";
+        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 SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
-        public DAL.ClsSc_ICMOBill BillOld = new DAL.ClsSc_ICMOBill();
-        string user_LongShan = "";
-        string HName_LongShan = "";
+        private json objJsonResult = new json();
+        SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
+        public DAL.ClsPay_DuSubsidyItemBill oBill = new DAL.ClsPay_DuSubsidyItemBill();
+        public DAL.ClsPay_DuSubsidyItemBill BillOld = new DAL.ClsPay_DuSubsidyItemBill();
+        DAL.ClsGy_Employee_View oEmp = new DAL.ClsGy_Employee_View();
+        DAL.ClsGy_Department_View oDept = new DAL.ClsGy_Department_View();
+        DAL.ClsGy_Group_View oGroup = new DAL.ClsGy_Group_View();
+        DAL.ClsGy_ORGANIZATIONS_View oOrg = new DAL.ClsGy_ORGANIZATIONS_View();
+        DAL.ClsGy_DuSubsidyItem_View oDuSItem = new DAL.ClsGy_DuSubsidyItem_View();
+
+
+        #region 鎵hˉ椤圭洰璐圭敤鍗曞垪琛�
+        /// <summary>
+        /// 鑾峰彇鎵hˉ椤圭洰璐圭敤鍗曞垪琛ㄤ俊鎭�
+        /// </summary>
+        /// <returns></returns>
+        [Route("Pay_DuSubsidyItemBillController/GetPay_DuSubsidyItemBillList_Json")]
+        [HttpGet]
+        public object GetPay_DuSubsidyItemBillList_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_DuSubsidyItemBillList where 1=1 " + sWhere + " order by hmainid desc", "h_v_Pay_DuSubsidyItemBillList");
+                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 鎵hˉ椤圭洰璐圭敤鍗曞垹闄�
+        /// <summary>
+        /// 鍒犻櫎鎵hˉ椤圭洰璐圭敤鍗�
+        /// </summary>
+        /// <returns></returns>
+        [Route("Pay_DuSubsidyItemBillController/GetPay_DuSubsidyItemBill_Delete_Json")]
+        [HttpGet]
+        public object GetPay_DuSubsidyItemBill_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_DuSubsidyItemBill_BeforeDelCtrl " + HInterID.ToString() + ",'" + HMaker + "'", "h_p_Pay_DuSubsidyItemBill_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_DuSubsidyItemBill_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 = "鍒犻櫎鎵hˉ椤圭洰璐圭敤鍗曟垚鍔燂紒";
+                        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 = "鍒犻櫎鎵hˉ椤圭洰璐圭敤鍗曞け璐ワ紒" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鎵hˉ椤圭洰璐圭敤鍗曞鏍�/鍙嶅鏍�
+        /// <summary>
+        /// 瀹℃牳/鍙嶅鏍告墸琛ラ」鐩垂鐢ㄥ崟
+        /// </summary>
+        /// <param name="HInterID">鍗曟嵁ID</param>
+        /// <param name="Type">瀹℃牳(1),鍙嶅鏍�(2)</param>
+        /// <param name="HMaker">瀹℃牳浜�</param>
+        /// <returns></returns>
+        [Route("Pay_DuSubsidyItemBillController/GetPay_DuSubsidyItemBill_Check_Json")]
+        [HttpGet]
+        public object GetPay_DuSubsidyItemBill_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_DuSubsidyItemBill_BeforeCheckCtrl " + HInterID.ToString() + ",'" + HMaker + "'", "h_p_Pay_DuSubsidyItemBill_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_DuSubsidyItemBill_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_DuSubsidyItemBill_BeforeUnCheckCtrl " + HInterID.ToString() + ",'" + HMaker + "'", "h_p_Pay_DuSubsidyItemBill_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_DuSubsidyItemBill_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 = "瀹℃牳鎴栧弽瀹℃牳鎵hˉ椤圭洰璐圭敤鍗曞け璐ワ紒" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鎵hˉ椤圭洰璐圭敤鍗曞叧闂�/鍙嶅叧闂�
+        /// <summary>
+        /// 鍏抽棴/鍙嶅叧闂墸琛ラ」鐩垂鐢ㄥ崟
+        /// </summary>
+        /// <param name="HInterID">鍗曟嵁ID</param>
+        /// <param name="Type">鍏抽棴(1),鍙嶅叧闂�(2)</param>
+        /// <param name="HMaker">鍏抽棴浜�</param>
+        /// <returns></returns>
+        [Route("Pay_DuSubsidyItemBillController/GetPay_DuSubsidyItemBill_Close_Json")]
+        [HttpGet]
+        public object GetPay_DuSubsidyItemBill_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 = "鍏抽棴鎴栧弽鍏抽棴鎵hˉ椤圭洰璐圭敤鍗曞け璐ワ紒" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鎵hˉ椤圭洰璐圭敤鍗曚綔搴�/鍙嶄綔搴�
+        /// <summary>
+        /// 浣滃簾/鍙嶄綔搴熸墸琛ラ」鐩垂鐢ㄥ崟
+        /// </summary>
+        /// <param name="HInterID">鍗曟嵁ID</param>
+        /// <param name="Type">浣滃簾(1),鍙嶄綔搴�(2)</param>
+        /// <param name="HMaker">浣滃簾浜�</param>
+        /// <returns></returns>
+        [Route("Pay_DuSubsidyItemBillController/GetPay_DuSubsidyItemBill_Cancelltion_Json")]
+        [HttpGet]
+        public object GetPay_DuSubsidyItemBill_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 = "浣滃簾鎴栧弽浣滃簾鎵hˉ椤圭洰璐圭敤鍗曞け璐ワ紒" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+
+
 
         #region 鎵hˉ椤圭洰璐圭敤鍗� 鏂板/缂栬緫
         #region 鎵hˉ椤圭洰璐圭敤鍗� 琛ㄥご鏁版嵁
@@ -83,19 +662,19 @@
             var _value = sMainSub["sMainSub"].ToString();
             string msg1 = _value.ToString();
             //寮�濮嬩簨鍔�
-            oCN.BeginTran();
+            oCn.BeginTran();
             //淇濆瓨涓昏〃
             objJsonResult = AddBillMain_Pay_DuSubsidyItemBill(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 = "鏂板鍗曟嵁鎴愬姛锛�";
@@ -180,7 +759,7 @@
 
                 //if (OperationType == 2)
                 //{
-                //    ds = oCN.RunProcReturn("select * from PM_ProjectBillMain where HBillNo ='" + HBillNo + "'", "PM_ProjectBillMain");
+                //    ds = oCn.RunProcReturn("select * from PM_ProjectBillMain where HBillNo ='" + HBillNo + "'", "PM_ProjectBillMain");
                 //    if (ds.Tables[0].Rows.Count > 0)
                 //    {
                 //        objJsonResult.code = "0";
@@ -191,7 +770,7 @@
                 //    }
                 //}
 
-                ds = oCN.RunProcReturn("select * from Pay_DuSubsidyItemBillMain where HInterID = " + HInterID + " and HBillNo = '" + HBillNo + "'", "Pay_DuSubsidyItemBillMain");
+                ds = oCn.RunProcReturn("select * from Pay_DuSubsidyItemBillMain where HInterID = " + HInterID + " and HBillNo = '" + HBillNo + "'", "Pay_DuSubsidyItemBillMain");
 
                 if ((OperationType == 1 || OperationType == 2) && ds.Tables[0].Rows.Count == 0)//鏂板
                 {
@@ -217,9 +796,9 @@
                         "')";
 
                     //涓昏〃
-                    oCN.RunProc(sql);
+                    oCn.RunProc(sql);
                     LogService.Write("鐢ㄦ埛:" + user + ",鏃ユ湡:" + DateTime.Now + ",鏂板鎵hˉ椤圭洰璐圭敤鍗�:" + HBillNo);
-                    oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','" + HComputerName + "','" + "鏂板鎵hˉ椤圭洰璐圭敤鍗曪細" + HBillNo + "','LMES-鎵hˉ椤圭洰璐圭敤鍗曟ā鍧�','" + DBUtility.ClsPub.IPAddress + "','鏂板鍗曟嵁'", ref DBUtility.ClsPub.sExeReturnInfo);
+                    oCn.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','" + HComputerName + "','" + "鏂板鎵hˉ椤圭洰璐圭敤鍗曪細" + HBillNo + "','LMES-鎵hˉ椤圭洰璐圭敤鍗曟ā鍧�','" + DBUtility.ClsPub.IPAddress + "','鏂板鍗曟嵁'", ref DBUtility.ClsPub.sExeReturnInfo);
                 }
                 else if (OperationType == 3 || ds.Tables[0].Rows.Count != 0)                    //缂栬緫
                 {
@@ -237,13 +816,13 @@
                         "', HUpdateDate = '" + HUpdaterDate +
                         "' where HInterID = " + HInterID;
 
-                    oCN.RunProc(sql);
+                    oCn.RunProc(sql);
 
                     //鍒犻櫎瀛愯〃
-                    oCN.RunProc("delete from Pay_DuSubsidyItemBillSub where HInterID= " + HInterID);
+                    oCn.RunProc("delete from Pay_DuSubsidyItemBillSub where HInterID= " + HInterID);
                     //璁板綍鏃ュ織
                     LogService.Write("鐢ㄦ埛:" + user + ",鏃ユ湡:" + DateTime.Now + ",淇敼鎵hˉ椤圭洰璐圭敤鍗�:" + HBillNo);
-                    oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','" + HComputerName + "','" + "淇敼鎵hˉ椤圭洰璐圭敤鍗曪細" + HBillNo + "','LMES-鎵hˉ椤圭洰璐圭敤鍗曟ā鍧�','" + DBUtility.ClsPub.IPAddress + "','淇敼鍗曟嵁'", ref DBUtility.ClsPub.sExeReturnInfo);
+                    oCn.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','" + HComputerName + "','" + "淇敼鎵hˉ椤圭洰璐圭敤鍗曪細" + HBillNo + "','LMES-鎵hˉ椤圭洰璐圭敤鍗曟ā鍧�','" + DBUtility.ClsPub.IPAddress + "','淇敼鍗曟嵁'", ref DBUtility.ClsPub.sExeReturnInfo);
                 }
                 //淇濆瓨瀛愯〃
                 objJsonResult = AddBillSub1_Pay_DuSubsidyItemBill(msg3, HInterID, HBillNo, OperationType);
@@ -304,7 +883,7 @@
                     ",'" + HRemark +
                     "')";
 
-                oCN.RunProc(sql);
+                oCn.RunProc(sql);
             }
 
             objJsonResult.code = "1";
@@ -315,6 +894,7 @@
         }
         #endregion
         #endregion
+
         #region 鎵hˉ椤圭洰璐圭敤鍗� 缂栬緫-椤甸潰璧嬪��
         /// <summary>
         ///鍙傛暟锛歴tring HInterID銆�
@@ -347,7 +927,7 @@
                     return objJsonResult;
                 }
 
-                ds = oCN.RunProcReturn("exec h_p_Pay_DuSubsidyItemBill_EditInit " + HInterID, "h_p_Pay_DuSubsidyItemBill_EditInit");
+                ds = oCn.RunProcReturn("exec h_p_Pay_DuSubsidyItemBill_EditInit " + HInterID, "h_p_Pay_DuSubsidyItemBill_EditInit");
                 tableList.Add(ds.Tables[0]);
                 tableList.Add(ds.Tables[1]);
 
@@ -368,46 +948,179 @@
         }
         #endregion
 
-        #region 鎵hˉ椤圭洰璐圭敤鍗� 鏌ヨ
-        [Route("Pay_DuSubsidyItemBill/list")]
-        [HttpGet]
-        public object getDuSubsidyItemBillList(string sWhere, string user)
+        #region 鎵hˉ椤圭洰璐圭敤鍗� 鏁版嵁瀵煎叆
+        #region 鑾峰彇瀵煎叆鏂囦欢鐨勬暟鎹�
+        [Route("Pay_DuSubsidyItemBill/Pay_DuSubsidyItemBillimport")]
+        [HttpPost]
+        public object Pay_DuSubsidyItemBillimport()
         {
             try
             {
-                List<object> columnNameList = new List<object>();
-                if (!DBUtility.ClsPub.Security_Log("Pay_DuSubsidyItemBillList", 1, false, user))
-                {
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
-                    objJsonResult.data = null;
-                    return objJsonResult;
-                }
+                var WorkBookName = HttpContext.Current.Request["WorkBookName"];
+                DBUtility.ClsPub.HOrgID = long.Parse(HttpContext.Current.Request["HOrgID"]);
+                //鑾峰彇鏂囦欢鍚嶇О
+                var file = HttpContext.Current.Request.Files[0];
+                //鑾峰彇鏂囦欢鐗╃悊璺緞
+                string ExcelPath = HttpContext.Current.Server.MapPath("~/" + file.FileName);
+                //淇濆瓨鏂囦欢
+                file.SaveAs(ExcelPath);
 
-                if (sWhere == null || sWhere.Equals(""))
-                {
-                    ds = oCN.RunProcReturn("select * from h_v_Pay_DuSubsidyItemBillList order by hmainid desc", "h_v_Pay_DuSubsidyItemBillList");
-                }
-                else
-                {
-                    string sql1 = "select * from h_v_Pay_DuSubsidyItemBillList where 1 = 1 ";
-                    string sql = sql1 + sWhere + " order by hmainid desc";
-                    ds = oCN.RunProcReturn(sql, "h_v_Pay_DuSubsidyItemBillList");
-                }
+                NpoiHelper np = new NpoiHelper();
+                DataSet ExcelDs = np.ReadExcel(ExcelPath, 1, 2, WorkBookName);
+
+                //鍒犻櫎鏂囦欢
+                File.Delete(ExcelPath);
+
+                //鍒涘缓涓存椂琛�
+                DataTable tb2 = new DataTable("dt2");
+                DataTable tb3 = new DataTable("dt3");
 
                 //娣诲姞鍒楀悕
-                foreach (DataColumn col in ds.Tables[0].Columns)
+                for (int i = 0; i < ExcelDs.Tables[0].Columns.Count; i++)
+                {
+                    tb2.Columns.Add(ExcelDs.Tables[0].Rows[0][i].ToString());
+                }
+
+                //娣诲姞鏁版嵁
+                for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++)
+                {
+                    DataRow row = tb2.NewRow();
+                    for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++)
+                    {
+                        row[j] = ExcelDs.Tables[0].Rows[i][j].ToString();
+                    }
+                    tb2.Rows.Add(row);
+                }
+                //鑾峰彇瀵煎叆鏂囦欢鍒楀悕闆嗗悎锛岀敤浜庡墠绔姩鎬佸垪
+                List<object> columnNameList = new List<object>();
+                //娣诲姞鍒楀悕
+                foreach (DataColumn col in tb2.Columns)
                 {
                     Type dataType = col.DataType;
                     string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                     columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
                 }
 
+                var error = "";
+
+                //鏌ヨ鎵hˉ椤圭洰璐圭敤鍗曟病鏈夌殑鍒�
+                if (!tb2.Columns.Contains("鏃ユ湡"))
+                    error += "娌℃湁鎵惧埌銆愭棩鏈熴�戠殑鏍囬,";
+                if (!tb2.Columns.Contains("骞�"))
+                    error += "娌℃湁鎵惧埌銆愬勾銆戠殑鏍囬,";
+                if (!tb2.Columns.Contains("鏈�"))
+                    error += "娌℃湁鎵惧埌銆愭湀銆戠殑鏍囬,";
+                if (!tb2.Columns.Contains("缁勭粐浠g爜"))
+                    error += "娌℃湁鎵惧埌銆愮粍缁囦唬鐮併�戠殑鏍囬,";
+                if (!tb2.Columns.Contains("缁勭粐"))
+                    error += "娌℃湁鎵惧埌銆愮粍缁囥�戠殑鏍囬,";
+                if (!tb2.Columns.Contains("閮ㄩ棬浠g爜"))
+                    error += "娌℃湁鎵惧埌銆愰儴闂ㄤ唬鐮併�戠殑鏍囬,";
+                if (!tb2.Columns.Contains("閮ㄩ棬鍚嶇О"))
+                    error += "娌℃湁鎵惧埌銆愰儴闂ㄥ悕绉般�戠殑鏍囬,";
+                if (!tb2.Columns.Contains("鐝粍浠g爜"))
+                    error += "娌℃湁鎵惧埌銆愮彮缁勪唬鐮併�戠殑鏍囬,";
+                if (!tb2.Columns.Contains("鐝粍"))
+                    error += "娌℃湁鎵惧埌銆愮彮缁勩�戠殑鏍囬,";
+                if (!tb2.Columns.Contains("琛ㄥご澶囨敞"))
+                    error += "娌℃湁鎵惧埌銆愯〃澶村娉ㄣ�戠殑鏍囬,";
+                if (!tb2.Columns.Contains("鑱屽憳浠g爜"))
+                    error += "娌℃湁鎵惧埌銆愯亴鍛樹唬鐮併�戠殑鏍囬,";
+                if (!tb2.Columns.Contains("鑱屽憳鍚嶇О"))
+                    error += "娌℃湁鎵惧埌銆愯亴鍛樺悕绉般�戠殑鏍囬,";
+                ////鑾峰彇鎵�鏈夌殑鎵hˉ椤圭洰锛屽垽瀹氬鍏ユ枃浠朵腑鏈寘鍚殑鎵hˉ椤圭洰
+                //DataSet ds_DuSubsidyItem;
+                //ds_DuSubsidyItem = oCn.RunProcReturn("select * from Gy_DuSubsidyItem", "Gy_DuSubsidyItem");
+                //if (ds_DuSubsidyItem.Tables[0] != null)
+                //{
+                //    for (int i = 0; i < ds_DuSubsidyItem.Tables[0].Rows.Count; i++)
+                //    {
+                //        string DuSubsidyItem = ds_DuSubsidyItem.Tables[0].Rows[i]["HName"] == null ? "" : ds_DuSubsidyItem.Tables[0].Rows[i]["HName"].ToString();
+                //        if (!tb2.Columns.Contains(DuSubsidyItem))
+                //            error += "娌℃湁鎵惧埌銆�" + DuSubsidyItem + "銆戠殑鏍囬,";
+                //    }
+                //}
+
+                if (error.Length > 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = $"Excel妯℃澘瀛樺湪閿欒,{error}\r\n";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                objJsonResult = (json)Checkdata(tb2);
+                if (objJsonResult.code == "0")
+                {
+                    return objJsonResult;
+                }
+
+                oCn.BeginTran();
+                //鍒犻櫎涓存椂琛ㄦ暟鎹�
+                oCn.RunProc("delete from diyipi_Pay_DuSubsidyItemBill");
+
+                //涓存椂琛ㄦ坊鍔犳暟鎹�
+                for (int i = 0; i < tb2.Rows.Count; i++)
+                {
+                    if (tb2.Rows[i]["鑱屽憳浠g爜"].ToString() != "")
+                    {
+                        //鏍规嵁浠g爜鑾峰彇琛ㄦ暟鎹�
+                        oOrg.GetInfoByNumber(tb2.Rows[i]["缁勭粐浠g爜"].ToString());
+                        oDept.GetInfoByNumber(tb2.Rows[i]["閮ㄩ棬浠g爜"].ToString());
+                        oGroup.GetInfoByNumber(tb2.Rows[i]["鐝粍浠g爜"].ToString());
+                        oEmp.GetInfoByNumber(tb2.Rows[i]["鑱屽憳浠g爜"].ToString());
+
+                        //鑾峰彇鍐呯爜
+                        Int64 HOrgID = oOrg.omodel.HItemID;
+                        Int64 HDeptID = oDept.omodel.HItemID;
+                        Int64 HGroupID = oGroup.omodel.HItemID;
+                        Int64 HEmpID = oEmp.omodel.HItemID;
+
+                        for (int j = 12; j < tb2.Columns.Count - 1; j++)
+                        {
+                            oDuSItem.GetInfoByName(tb2.Columns[j].ColumnName);
+                            Int64 HDuSID = oDuSItem.omodel.HItemID;
+                            string HDuSNumber = oDuSItem.omodel.HNumber;
+                            string HDuSName = oDuSItem.omodel.HName;
+                            double HMoney = double.Parse(tb2.Rows[i][tb2.Columns[j].ColumnName].ToString());
+
+                            string sql = "insert into diyipi_Pay_DuSubsidyItemBill(HDate,HYear,HPeriod,HOrgID,HOrgNumber,HOrgName,HDeptID,HDeptNumber,HDeptName" +
+                                ",HGroupID,HGroupNumber,HGroupName,HRemarkMain,HEmpID,HEmpNumber,HEmpName,HDuSubsidyItemID,HDuSubsidyItemNumber,HDuSubsidyItemName,HMoney,HRemarkSub) " +
+                                "values(" +
+                                "'" + tb2.Rows[i]["鏃ユ湡"].ToString() +
+                                "'," + int.Parse(tb2.Rows[i]["骞�"].ToString()) +
+                                "," + int.Parse(tb2.Rows[i]["鏈�"].ToString()) +
+                                "," + HOrgID +
+                                ",'" + tb2.Rows[i]["缁勭粐浠g爜"].ToString() +
+                                "','" + tb2.Rows[i]["缁勭粐"].ToString() +
+                                "'," + HDeptID +
+                                ",'" + tb2.Rows[i]["閮ㄩ棬浠g爜"].ToString() +
+                                "','" + tb2.Rows[i]["閮ㄩ棬鍚嶇О"].ToString() +
+                                "'," + HGroupID +
+                                ",'" + tb2.Rows[i]["鐝粍浠g爜"].ToString() +
+                                "','" + tb2.Rows[i]["鐝粍"].ToString() +
+                                "','" + tb2.Rows[i]["琛ㄥご澶囨敞"].ToString() +
+                                "'," + HEmpID +
+                                ",'" + tb2.Rows[i]["鑱屽憳浠g爜"].ToString() +
+                                "','" + tb2.Rows[i]["鑱屽憳鍚嶇О"].ToString() +
+                                "'," + HDuSID +
+                                ",'" + HDuSNumber +
+                                "','" + HDuSName +
+                                "'," + HMoney +
+                                ",'" + tb2.Rows[i]["琛ㄤ綋澶囨敞"] +
+                                "')";
+                            oCn.RunProc(sql);
+                        }
+                    }
+                    
+                }
+                oCn.Commit();
+
                 objJsonResult.code = "1";
                 objJsonResult.count = 1;
-                objJsonResult.Message = "Sucess锛�";
-                objJsonResult.data = ds.Tables[0];
+                objJsonResult.Message = error;
+                objJsonResult.data = tb2;
                 objJsonResult.list = columnNameList;
                 return objJsonResult;
             }
@@ -421,47 +1134,235 @@
             }
         }
         #endregion
-        #region 鎵hˉ椤圭洰璐圭敤鍗� 鍒犻櫎
-        /// <summary>
-        ///鍙傛暟锛歴tring HInterID銆�
-        ///杩斿洖鍊硷細object銆�
-        /// </summary>
-        [Route("Pay_DuSubsidyItemBill/delete")]
+
+        #region 妫�鏌ュ鍏ユ枃浠剁殑鏁版嵁
+        private object Checkdata(DataTable dt)
+        {
+            bool b = false;
+            string sErrMsg = "";
+            string sMsg = "";
+            for (int i = 0; i <= dt.Rows.Count - 1; i++)
+            {
+                string HDeptNumber = "";
+                string HGroupNumber = "";
+                string HEmpNumber = "";
+                double HMoney = 0;
+
+                HDeptNumber = DBUtility.ClsPub.isStrNull(dt.Rows[i]["閮ㄩ棬浠g爜"].ToString());
+                HGroupNumber = DBUtility.ClsPub.isStrNull(dt.Rows[i]["鐝粍浠g爜"].ToString());
+                HEmpNumber = DBUtility.ClsPub.isStrNull(dt.Rows[i]["鑱屽憳浠g爜"].ToString());
+                if (HEmpNumber != "")
+                {
+                    int index = i + 1;                                                                  //璁板綍褰撳墠妫�楠屾暟鎹綅浜庡鍏ユ枃浠剁殑绗嚑琛�
+
+                    //瀹℃牳浠g爜鏄惁鍚堢悊
+                    if (!DBUtility.ClsPub.AllowNumber(HDeptNumber))
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "閮ㄩ棬浠g爜涓笉鑳藉嚭鐜拌繛缁��.鈥欏苟涓旈浣嶆湯浣嶄笉鑳戒负鈥�.鈥欙紒";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (!DBUtility.ClsPub.AllowNumber(HGroupNumber))
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鐝粍浠g爜涓笉鑳藉嚭鐜拌繛缁��.鈥欏苟涓旈浣嶆湯浣嶄笉鑳戒负鈥�.鈥欙紒";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (!DBUtility.ClsPub.AllowNumber(HEmpNumber))
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鑱屽憳浠g爜涓笉鑳藉嚭鐜拌繛缁��.鈥欏苟涓旈浣嶆湯浣嶄笉鑳戒负鈥�.鈥欙紒";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+
+                    //寰楀埌閮ㄩ棬鍐呯爜
+                    if (!oDept.GetInfoByNumber(HDeptNumber))
+                    {
+                        sMsg = "[" + HDeptNumber + "]閮ㄩ棬涓嶅瓨鍦�";
+                        if (sErrMsg.Contains(sMsg) == false)
+                        {
+                            sErrMsg = sErrMsg + "[" + HDeptNumber + "]閮ㄩ棬涓嶅瓨鍦╘r\n";
+                        }
+                        b = true;
+                    }
+                    //寰楀埌鐝粍鍐呯爜
+                    if (!oGroup.GetInfoByNumber(HGroupNumber))
+                    {
+                        sMsg = "[" + HGroupNumber + "]鐝粍涓嶅瓨鍦�";
+                        if (sErrMsg.Contains(sMsg) == false)
+                        {
+                            sErrMsg = sErrMsg + "[" + HGroupNumber + "]鐝粍涓嶅瓨鍦╘r\n";
+                        }
+                        b = true;
+                    }
+
+                    //寰楀埌鑱屽憳鍐呯爜
+                    if (!oEmp.GetInfoByNumber(HEmpNumber))
+                    {
+                        sMsg = "[" + HEmpNumber + "]鑱屽憳涓嶅瓨鍦�";
+                        if (sErrMsg.Contains(sMsg) == false)
+                        {
+                            sErrMsg = sErrMsg + "[" + HEmpNumber + "]鑱屽憳涓嶅瓨鍦╘r\n";
+                        }
+                        b = true;
+                    }
+                    //妫�楠屽鍏ユ枃浠朵腑鐨勬墸琛ラ」鐩槸鍚﹀瓨鍦ㄣ�佸�兼槸鍚﹀悎娉�
+                    for(int j=12; j < dt.Columns.Count-1; j++)
+                    {
+                        //妫�楠屽鍏ユ枃浠朵腑鐨勬墸琛ラ」鐩槸鍚﹀瓨鍦�
+                        if (!oDuSItem.GetInfoByName(dt.Columns[j].ColumnName))
+                        {
+                            sMsg = "[" + dt.Columns[j].ColumnName + "]鎵hˉ椤圭洰涓嶅瓨鍦�";
+                            if (sErrMsg.Contains(sMsg) == false)
+                            {
+                                sErrMsg = sErrMsg + "[" + dt.Columns[j].ColumnName + "]鎵hˉ椤圭洰涓嶅瓨鍦╘r\n";
+                            }
+                            b = true;
+                        }
+                        //妫�楠屽鍏ユ枃浠朵腑鐨勬墸琛ラ」鐩�兼槸鍚﹀悎娉�
+                        if ( !Regex.IsMatch( dt.Rows[i][dt.Columns[j].ColumnName].ToString(), @"^\d+(\.\d+)?$"))
+                        {
+                            sMsg = "[" + dt.Columns[j].ColumnName + "]鏁版嵁鏍煎紡閿欒锛岃杈撳叆闈炶礋鏁�";
+                            if (sErrMsg.Contains(sMsg) == false)
+                            {
+                                sErrMsg = sErrMsg + "[" + dt.Columns[j].ColumnName + "]鏁版嵁鏍煎紡閿欒锛岃杈撳叆闈炶礋鏁癨r\n";
+                            }
+                            b = true;
+                        }
+                    }
+                }
+            }
+            if (b == true)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = sErrMsg;
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            else
+            {
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = sErrMsg;
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鎵hˉ椤圭洰璐圭敤鍗� 淇濆瓨瀵煎叆鏁版嵁
+        [Route("Pay_DuSubsidyItemBill/Pay_DuSubsidyItemBillSaveImport")]
         [HttpGet]
-        public object deleteDuSubsidyItemBill(string HInterID, string user)
+        public object Pay_DuSubsidyItemBillSaveImport(string user)
         {
             try
             {
                 //鏌ョ湅鏉冮檺
-                if (!DBUtility.ClsPub.Security_Log("Pay_DuSubsidyItemBill_Delete", 1, false, user))
+                if (!DBUtility.ClsPub.Security_Log("Pay_DuSubsidyItemBill_Edit", 1, false, user))
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
-                    objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
+                    objJsonResult.Message = "鏃犳柊澧炴潈闄愶紒";
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
-
-                if (HInterID == null || HInterID.Equals(""))
+                //鑾峰彇涓存椂琛ㄦ暟鎹�
+                ds = oCn.RunProcReturn("select * from diyipi_Pay_DuSubsidyItemBill order by HDate desc,HYear desc,HPeriod desc,HOrgID desc,HDeptID desc,HGroupID desc,HRemarkMain desc,HEmpID desc", "diyipi_Pay_DuSubsidyItemBill");
+                if (ds==null || ds.Tables[0].Rows.Count == 0)
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
-                    objJsonResult.Message = "HInterID涓嶈兘涓虹┖锛�";
+                    objJsonResult.Message = "淇濆瓨澶辫触锛氭暟鎹湭瀵煎叆鎴愬姛锛岃閲嶆柊瀵煎叆鏁版嵁锛侊紒";
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
+                //淇濆瓨鏁版嵁
+                oCn.BeginTran();
+                DataTable dt = ds.Tables[0];
+                Pay_DuSubsidyItemBillMain mainTable = new Pay_DuSubsidyItemBillMain();
+                List<Pay_DuSubsidyItemBillSub> subTable = new List<Pay_DuSubsidyItemBillSub>();
+                int HOrgID = 0;
+                int HYear = 0;
+                int HPeriod = 0;
+                string compareText = "";
 
-                oCN.BeginTran();
+                for (int i = 0; i < dt.Rows.Count; i++)
+                {
+                    string compareText1 = dt.Rows[i]["HDate"].ToString() +
+                        "" + dt.Rows[i]["HYear"].ToString() +
+                        "" + dt.Rows[i]["HPeriod"].ToString() +
+                        "" + dt.Rows[i]["HOrgID"].ToString() +
+                        "" + dt.Rows[i]["HDeptID"].ToString() +
+                        "" + dt.Rows[i]["HGroupID"].ToString() +
+                        "" + dt.Rows[i]["HRemarkMain"].ToString() +
+                        "" + dt.Rows[i]["HEmpID"].ToString();
+                    if(compareText != compareText1)
+                    {
+                        if (subTable.Count>0)
+                        {
+                            objJsonResult = SaveImport_AddBillMain(mainTable, subTable, HOrgID, HYear, HPeriod, user);
+                            if (objJsonResult.code == "0")
+                            {
+                                objJsonResult.code = "0";
+                                objJsonResult.count = 0;
+                                objJsonResult.Message = objJsonResult.Message;
+                                objJsonResult.data = null;
+                                return objJsonResult;
+                            }
+                            mainTable = new Pay_DuSubsidyItemBillMain();
+                            subTable.Clear();
+                        }
+                        compareText = compareText1;
+                        mainTable.HDate = dt.Rows[i]["HDate"].ToString();
+                        mainTable.HDeptID = int.Parse(dt.Rows[i]["HDeptID"].ToString());
+                        mainTable.HGroupID = int.Parse(dt.Rows[i]["HGroupID"].ToString());
+                        mainTable.HRemark = dt.Rows[i]["HRemarkMain"].ToString();
+                        mainTable.HMaker = user;
+                        mainTable.HMakerDate = DateTime.Now.ToString("yyyy-MM-dd");
+                        HOrgID = int.Parse(dt.Rows[i]["HOrgID"].ToString());
+                        HYear = int.Parse(dt.Rows[i]["HYear"].ToString());
+                        HPeriod = int.Parse(dt.Rows[i]["HPeriod"].ToString());
+                    }
 
-                oCN.RunProc("delete from Pay_DuSubsidyItemBillMain where HInterID = " + HInterID);
-                oCN.RunProc("delete from Pay_DuSubsidyItemBillSub where HInterID= " + HInterID);
+                    Pay_DuSubsidyItemBillSub oSub = new Pay_DuSubsidyItemBillSub();
+                    oSub.HEmpID = int.Parse(dt.Rows[i]["HEmpID"].ToString());
+                    oSub.HDuSubsidyItemID = int.Parse(dt.Rows[i]["HDuSubsidyItemID"].ToString());
+                    oSub.HQty = 0;
+                    oSub.HPrice = 0;
+                    oSub.HMoney = double.Parse(dt.Rows[i]["HMoney"].ToString());
+                    oSub.HRemark = dt.Rows[i]["HRemarkSub"].ToString();
+                    subTable.Add(oSub);
+                }
 
-                oCN.Commit();
+                //娣诲姞鏈�鍚庝竴娆¤褰�
+                if (subTable.Count > 0)
+                {
+                    objJsonResult = SaveImport_AddBillMain(mainTable, subTable, HOrgID, HYear, HPeriod, user);
+                    if (objJsonResult.code == "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = objJsonResult.Message;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    mainTable = new Pay_DuSubsidyItemBillMain();
+                    subTable.Clear();
+                }
+
+
+                oCn.Commit();
 
                 objJsonResult.code = "1";
                 objJsonResult.count = 1;
                 objJsonResult.Message = "Sucess锛�";
-                objJsonResult.data = null;
                 return objJsonResult;
             }
             catch (Exception e)
@@ -475,324 +1376,179 @@
         }
         #endregion
 
-        #region 鎵hˉ椤圭洰璐圭敤鍗� 瀹℃牳/鍙嶅鏍�
-        /// <summary>
-        /// 
-        /// </summary>
-        /// <param name="HInterID">鍗曟嵁ID</param>
-        /// <param name="IsAudit">瀹℃牳(0),鍙嶅鏍�(1)</param>
-        /// <param name="CurUserName">瀹℃牳浜�</param>
-        /// <returns></returns>
-        [Route("Pay_DuSubsidyItemBill/AuditPay_DuSubsidyItemBill")]
-        [HttpGet]
-        public object AuditPay_DuSubsidyItemBill(string HInterID, int Type, string user)
+        #region 娣诲姞 鎵hˉ椤圭洰璐圭敤鍗� 涓昏〃
+        public json SaveImport_AddBillMain(Pay_DuSubsidyItemBillMain mainTable, List<Pay_DuSubsidyItemBillSub> subTable, int HOrgID, int Year, int Period, string user)
         {
+            string HComputerName = SystemInformation.ComputerName; //璁惧鍚嶇О
+
             try
             {
-                //鍒ゆ柇鏄惁鏈夊鏍告潈闄�
-                if (!DBUtility.ClsPub.Security_Log("Pay_DuSubsidyItemBill_Check", 1, false, user))
+                List<Pay_DuSubsidyItemBillMain> mainList = new List<Pay_DuSubsidyItemBillMain>();
+                mainList.Add(mainTable);
+
+
+                int HYear = Year;
+                int HPeriod = Period;
+                string HBillType = "2233";
+                string HBillSubType = "";
+                int HBillStatus = 1;
+
+                int HAutoSaveFlag = 0;
+
+
+                Int64 HInterID = DBUtility.ClsPub.CreateBillID_Prod(HBillType, ref DBUtility.ClsPub.sExeReturnInfo);
+                string HBillNo = DBUtility.ClsPub.CreateBillCode(HBillType, ref DBUtility.ClsPub.sExeReturnInfo, true);
+                string HDate = mainList[0].HDate;
+                string HInnerBillNo = "";
+                int HGroupID = mainList[0].HGroupID;
+                int HDeptID = mainList[0].HDeptID;
+                string HExplanation = "";
+                string HRemark = mainList[0].HRemark;
+
+
+                string HMaker = mainList[0].HMaker;
+                string HMakerDate = mainList[0].HMakerDate;
+               
+                ds = oCn.RunProcReturn("select * from Pay_DuSubsidyItemBillMain where HInterID = " + HInterID + " and HBillNo = '" + HBillNo + "'", "Pay_DuSubsidyItemBillMain");
+
+                //涓昏〃娣诲姞鏁版嵁
+                string sql = "insert into Pay_DuSubsidyItemBillMain" +
+                    "(HYear,HPeriod,HBillType,HBillSubType,HBillStatus,HInterID,HBillNo,HDate,HInnerBillNo,HGroupID,HDeptID,HExplanation,HAutoSaveFlag,HRemark,HMaker,HMakeDate) " +
+                    "values(" +
+                    "" + HYear +
+                    "," + HPeriod +
+                    ",'" + HBillType +
+                    "','" + HBillSubType +
+                    "'," + HBillStatus +
+                    "," + HInterID +
+                    ",'" + HBillNo +
+                    "','" + HDate +
+                    "','" + HInnerBillNo +
+                    "'," + HGroupID +
+                    "," + HDeptID +
+                    ",'" + HExplanation +
+                    "'," + HAutoSaveFlag +
+                    ",'" + HRemark +
+                    "','" + HMaker +
+                    "','" + HMakerDate +
+                    "')";
+
+                //涓昏〃
+                oCn.RunProc(sql);
+                LogService.Write("鐢ㄦ埛:" + user + ",鏃ユ湡:" + DateTime.Now + ",鏂板鎵hˉ椤圭洰璐圭敤鍗�:" + HBillNo);
+                oCn.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','" + HComputerName + "','" + "鏂板鎵hˉ椤圭洰璐圭敤鍗曪細" + HBillNo + "','LMES-鎵hˉ椤圭洰璐圭敤鍗曟ā鍧�','" + DBUtility.ClsPub.IPAddress + "','鏂板鍗曟嵁'", ref DBUtility.ClsPub.sExeReturnInfo);
+                
+               
+                //淇濆瓨瀛愯〃
+                objJsonResult = SaveImport_AddBillSub(subTable, HInterID,HBillNo);
+
+                if (objJsonResult.code == "0")
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
-                    objJsonResult.Message = "鏃犳潈闄愬鏍�!";
+                    objJsonResult.Message = 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_DuSubsidyItemBillMain";
-                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.code = "1";
                 objJsonResult.count = 1;
-                objJsonResult.Message = "鎵ц鎴愬姛锛�";
+                objJsonResult.Message = null;
                 objJsonResult.data = null;
-                return objJsonResult; ;
-
+                return objJsonResult;
             }
             catch (Exception e)
             {
                 objJsonResult.code = "0";
                 objJsonResult.count = 0;
-                objJsonResult.Message = "鎵ц澶辫触锛�" + e.ToString();
+                objJsonResult.Message = "Exception锛�" + e.ToString();
                 objJsonResult.data = null;
                 return objJsonResult;
             }
         }
         #endregion
-        #region 鎵hˉ椤圭洰璐圭敤鍗� 鍏抽棴/鍙嶅叧闂姛鑳�
-        [Route("Pay_DuSubsidyItemBill/ClosePay_DuSubsidyItemBill")]
-        [HttpGet]
-        public object ClosePay_DuSubsidyItemBill(string HInterID, int Type, string user)
+        #region 娣诲姞 鎵hˉ椤圭洰璐圭敤鍗� 瀛愯〃
+        public json SaveImport_AddBillSub(List<Pay_DuSubsidyItemBillSub> DetailColl, Int64 HInterID, string HBillNo)
         {
-            try
+            int i = 0;                                          //浣滀负瀛愯〃鍐呯爜
+            foreach (Pay_DuSubsidyItemBillSub oSub in DetailColl)
             {
-                //鍒ゆ柇鏄惁鏈夊垹闄ゆ潈闄�
-                if (!DBUtility.ClsPub.Security_Log("Pay_DuSubsidyItemBill_Close", 1, false, user))
-                {
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = "鏃犳潈闄愬叧闂�!";
-                    objJsonResult.data = null;
-                    return objJsonResult;
-                }
+                i++;                                            //鍚屼竴涓富琛ㄤ笅鐨勫瓙琛ㄧ殑鍐呯爜鑷
 
-                if (string.IsNullOrWhiteSpace(HInterID))
-                {
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = "HInterID涓虹┖锛�";
-                    objJsonResult.data = null;
-                    return objJsonResult;
-                }
+                int HEntryID = i;
 
-                ClsPub.CurUserName = user;
-                BillOld.MvarItemKey = "Pay_DuSubsidyItemBillMain";
-                oCN.BeginTran();//寮�濮嬩簨鍔�
+                int HEmpID = oSub.HEmpID;
+                int HDuSubsidyItemID = oSub.HDuSubsidyItemID;
+                double HQty = oSub.HQty;
+                double HPrice = oSub.HPrice;
+                double HMoney = oSub.HMoney;
+                string HRemark = oSub.HRemark;
 
-                //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;
-                    }
-                }
+                string sql = "insert into Pay_DuSubsidyItemBillSub" +
+                    "(HInterID,HEntryID,HEmpID,HDuSubsidyItemID,HQty,HPrice,HMoney,HRemark) " +
+                    "values(" +
+                    "" + HInterID +
+                    "," + HEntryID +
+                    "," + HEmpID +
+                    "," + HDuSubsidyItemID +
+                    "," + HQty +
+                    "," + HPrice +
+                    "," + HMoney +
+                    ",'" + HRemark +
+                    "')";
 
-                oCN.Commit();//鎻愪氦浜嬪姟
-
-                objJsonResult.code = "0";
-                objJsonResult.count = 1;
-                objJsonResult.Message = "鎵ц鎴愬姛锛�";
-                objJsonResult.data = null;
-                return objJsonResult; ;
-
+                oCn.RunProc(sql);
             }
-            catch (Exception e)
-            {
-                objJsonResult.code = "0";
-                objJsonResult.count = 0;
-                objJsonResult.Message = "鎵ц澶辫触锛�" + e.ToString();
-                objJsonResult.data = null;
-                return objJsonResult;
-            }
+
+            objJsonResult.code = "1";
+            objJsonResult.count = 1;
+            objJsonResult.Message = null;
+            objJsonResult.data = null;
+            return objJsonResult;
         }
         #endregion
-        #region 鎵hˉ椤圭洰璐圭敤鍗� 浣滃簾/鍙嶄綔搴熷姛鑳�
-        [Route("Pay_DuSubsidyItemBill/DropPay_DuSubsidyItemBill")]
+        #endregion
+
+        #region 鎵hˉ椤圭洰璐圭敤鍗昣璐圭敤妯悜鏄剧ず 鑾峰彇鎵hˉ椤圭洰
+        [Route("Pay_DuSubsidyItemBill_KS/getInitGrid_KS")]
         [HttpGet]
-        public object DropPay_DuSubsidyItemBill(string HInterID, int Type, string user)
+        public object getInitGrid_KS()
         {
             try
             {
-                //鍒ゆ柇鏄惁鏈変綔搴熸潈闄�
-                if (!DBUtility.ClsPub.Security_Log("Pay_DuSubsidyItemBill_Drop", 1, false, user))
+                //鑾峰彇鏈鐢ㄧ殑鎵hˉ椤圭洰
+                string sql = "select * from Gy_DuSubsidyItem where HStopFlag = 0";
+                ds = oCn.RunProcReturn(sql, "Gy_DuSubsidyItem");
+                if (ds == null || ds.Tables[0].Rows.Count == 0)
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
-                    objJsonResult.Message = "鏃犳潈闄愪綔搴�!";
+                    objJsonResult.Message = "鏈壘鍒扮浉鍏虫墸琛ラ」鐩紒";
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
-
-                if (string.IsNullOrWhiteSpace(HInterID))
+                //澶勭悊鎵hˉ椤圭洰
+                List<object> columnNameList = new List<object>();
+                for(int i = 0; i < ds.Tables[0].Rows.Count; i++)
                 {
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = "HInterID涓虹┖锛�";
-                    objJsonResult.data = null;
-                    return objJsonResult;
+                    string field = ds.Tables[0].Rows[i]["HItemID"].ToString();
+                    string title = ds.Tables[0].Rows[i]["HName"].ToString();
+                    string dataType = "decimal(18,2)";
+                    string ColmString = "{\"field\":\"" + field + "\",\"title\":\"" + title + "\",\"dataType\":\"" + dataType + "\"}";
+                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));
                 }
-
-                ClsPub.CurUserName = user;
-                BillOld.MvarItemKey = "Pay_DuSubsidyItemBillMain";
-                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.code = "1";
                 objJsonResult.count = 1;
-                objJsonResult.Message = "鎵ц鎴愬姛锛�";
-                objJsonResult.data = null;
-                return objJsonResult; ;
-
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.list = columnNameList;
+                return objJsonResult;
             }
             catch (Exception e)
             {
                 objJsonResult.code = "0";
                 objJsonResult.count = 0;
-                objJsonResult.Message = "鎵ц澶辫触锛�" + e.ToString();
+                objJsonResult.Message = "Exception锛�" + e.ToString();
                 objJsonResult.data = null;
                 return objJsonResult;
             }

--
Gitblit v1.9.1