From 99bd816e3c11999b7dea0571e1041508d761834b Mon Sep 17 00:00:00 2001 From: yusijie <ysj@hz-kingdee.com> Date: 星期三, 30 八月 2023 09:03:03 +0800 Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API --- WebAPI/Controllers/工资管理/Pay_DuSubsidyItemBillController.cs | 621 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 619 insertions(+), 2 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..c4b7cf1 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,12 +6,15 @@ 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 { @@ -19,7 +22,13 @@ private json objJsonResult = new json(); public DataSet ds = new DataSet(); public SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); - public DAL.ClsSc_ICMOBill BillOld = new DAL.ClsSc_ICMOBill(); + 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(); + public DAL.ClsPay_DuSubsidyItemBill BillOld = new DAL.ClsPay_DuSubsidyItemBill(); + Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter(); string user_LongShan = ""; string HName_LongShan = ""; @@ -798,5 +807,613 @@ } } #endregion + + + #region 鎵hˉ椤圭洰璐圭敤鍗� 鏁版嵁瀵煎叆 + #region 鑾峰彇瀵煎叆鏂囦欢鐨勬暟鎹� + [Route("Pay_DuSubsidyItemBill/Pay_DuSubsidyItemBillimport")] + [HttpPost] + public object Pay_DuSubsidyItemBillimport() + { + try + { + 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); + + 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"); + + //娣诲姞鍒楀悕 + 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 = error; + objJsonResult.data = tb2; + objJsonResult.list = columnNameList; + return objJsonResult; + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #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 Pay_DuSubsidyItemBillSaveImport(string user) + { + try + { + //鏌ョ湅鏉冮檺 + if (!DBUtility.ClsPub.Security_Log("Pay_DuSubsidyItemBill_Edit", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳柊澧炴潈闄愶紒"; + objJsonResult.data = null; + return objJsonResult; + } + //鑾峰彇涓存椂琛ㄦ暟鎹� + 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 = "淇濆瓨澶辫触锛氭暟鎹湭瀵煎叆鎴愬姛锛岃閲嶆柊瀵煎叆鏁版嵁锛侊紒"; + 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 = ""; + + 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()); + } + + 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); + } + + //娣诲姞鏈�鍚庝竴娆¤褰� + 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锛�"; + return objJsonResult; + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #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 + { + 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.data = null; + return objJsonResult; + } + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = null; + 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 娣诲姞 鎵hˉ椤圭洰璐圭敤鍗� 瀛愯〃 + public json SaveImport_AddBillSub(List<Pay_DuSubsidyItemBillSub> DetailColl, Int64 HInterID, string HBillNo) + { + int i = 0; //浣滀负瀛愯〃鍐呯爜 + foreach (Pay_DuSubsidyItemBillSub oSub in DetailColl) + { + i++; //鍚屼竴涓富琛ㄤ笅鐨勫瓙琛ㄧ殑鍐呯爜鑷 + + int HEntryID = i; + + int HEmpID = oSub.HEmpID; + int HDuSubsidyItemID = oSub.HDuSubsidyItemID; + double HQty = oSub.HQty; + double HPrice = oSub.HPrice; + double HMoney = oSub.HMoney; + string HRemark = oSub.HRemark; + + string sql = "insert into Pay_DuSubsidyItemBillSub" + + "(HInterID,HEntryID,HEmpID,HDuSubsidyItemID,HQty,HPrice,HMoney,HRemark) " + + "values(" + + "" + HInterID + + "," + HEntryID + + "," + HEmpID + + "," + HDuSubsidyItemID + + "," + HQty + + "," + HPrice + + "," + HMoney + + ",'" + HRemark + + "')"; + + oCN.RunProc(sql); + } + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = null; + objJsonResult.data = null; + return objJsonResult; + } + #endregion + #endregion + + #region 鎵hˉ椤圭洰璐圭敤鍗昣璐圭敤妯悜鏄剧ず 鑾峰彇鎵hˉ椤圭洰 + [Route("Pay_DuSubsidyItemBill_KS/getInitGrid_KS")] + [HttpGet] + public object getInitGrid_KS() + { + try + { + //鑾峰彇鏈鐢ㄧ殑鎵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.data = null; + return objJsonResult; + } + //澶勭悊鎵hˉ椤圭洰 + List<object> columnNameList = new List<object>(); + for(int i = 0; i < ds.Tables[0].Rows.Count; i++) + { + 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)); + } + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "Sucess锛�"; + objJsonResult.list = columnNameList; + return objJsonResult; + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion } } \ No newline at end of file -- Gitblit v1.9.1