From 40049a1dc96cf68082171fdb72b07a5636b3bb79 Mon Sep 17 00:00:00 2001 From: duhe <226547893@qq.com> Date: 星期五, 28 七月 2023 18:06:37 +0800 Subject: [PATCH] 工资计算模块 --- WebAPI/Controllers/工资管理/Pay_SalaryCalculateController.cs | 916 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 916 insertions(+), 0 deletions(-) diff --git "a/WebAPI/Controllers/\345\267\245\350\265\204\347\256\241\347\220\206/Pay_SalaryCalculateController.cs" "b/WebAPI/Controllers/\345\267\245\350\265\204\347\256\241\347\220\206/Pay_SalaryCalculateController.cs" new file mode 100644 index 0000000..1a2a60f --- /dev/null +++ "b/WebAPI/Controllers/\345\267\245\350\265\204\347\256\241\347\220\206/Pay_SalaryCalculateController.cs" @@ -0,0 +1,916 @@ +锘縰sing DBUtility; +using Model; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Web; +using System.Web.Http; +using System.Windows.Forms; +using WebAPI.Models; +using static WebAPI.Controllers.Pay_SingleBalBillController; +using static WebAPI.Controllers.Pay_GroupBalBillController; + +namespace WebAPI.Controllers.宸ヨ祫绠$悊.宸ヨ祫璁$畻 +{ + public class Pay_SalaryCulateController : ApiController + { + public DBUtility.ClsPub.Enum_BillStatus BillStatus;//鍗曟嵁鐘舵�侊紙鏂板锛屼慨鏀癸紝娴忚锛屾洿鏂板崟浠凤紝鍙樻洿锛� + private json objJsonResult = new json(); + public DataSet ds = new DataSet(); + public SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); + public DAL.ClsSc_ICMOBill BillOld = new DAL.ClsSc_ICMOBill(); + string user_LongShan = ""; + string HName_LongShan = ""; + + #region 宸ヨ祫璁$畻-鏁版嵁鏌ヨ + /// <summary> + /// 杩斿洖椤圭洰闃舵鍒楄〃 + ///鍙傛暟锛歴tring sql銆� + ///杩斿洖鍊硷細object銆� + /// </summary> + [Route("Pay_SalaryCalculate/list")] + [HttpGet] + public object getSalaryCalculateData(string HBeginDate, string HEndDate, int HOperatorType,string HBillType,string user) + { + try + { + string sql = "exec h_p_Pay_SalaryCalculate_getData " + HOperatorType + ",'" + HBeginDate + "','" + HEndDate + "'"; + ds = oCN.RunProcReturn(sql, "h_p_Pay_SalaryCalculate_getData"); + + if (HOperatorType == 1) + { + oCN.BeginTran(); + objJsonResult = getSalaryCalculateData_SingleBalBill(HBeginDate, HEndDate, HOperatorType, HBillType, user); + if (objJsonResult.code == "0") + { + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = objJsonResult.Message; + objJsonResult.data = null; + return objJsonResult; + } + oCN.Commit(); + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "宸ヨ祫璁$畻瀹屾垚锛侊紒"; + objJsonResult.data = ds.Tables[0]; + return objJsonResult; + }else if(HOperatorType == 2) + { + oCN.BeginTran(); + objJsonResult = getSalaryCalculateData_GroupBalBill(HBeginDate, HEndDate, HOperatorType, HBillType, user); + if (objJsonResult.code == "0") + { + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = objJsonResult.Message; + objJsonResult.data = null; + return objJsonResult; + } + oCN.Commit(); + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "宸ヨ祫璁$畻瀹屾垚锛侊紒"; + objJsonResult.data = ds.Tables[0]; + return objJsonResult; + } + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "Sucess锛�"; + objJsonResult.data = ds.Tables[0]; + return objJsonResult; + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #region 宸ヨ祫璁$畻-涓汉宸ヨ祫缁撶畻鍗� + #region 宸ヨ祫璁$畻-鎵归噺璁$畻-涓汉宸ヨ祫缁撶畻鍗� + public json getSalaryCalculateData_SingleBalBill(string HBeginDate, string HEndDate, int HOperatorType, string HBillType, string user) + { + try + { + //鍒ゆ柇鏄惁鏈夌紪杈戞潈闄� + if (!DBUtility.ClsPub.Security_Log("Pay_SingleBalBill_Edit", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳柊澧炴潈闄�!"; + objJsonResult.data = null; + return objJsonResult; + } + + //鑾峰彇宸ュ簭鍑虹珯姹囨姤鍗曟暟鎹� + string sql = "exec h_p_Pay_SalaryCalculate_getData " + HOperatorType + ",'" + HBeginDate + "','" + HEndDate + "'"; + ds = oCN.RunProcReturn(sql, "h_p_Pay_SalaryCalculate_getData"); + DataTable data = ds.Tables[0]; + //鏁寸悊宸ュ簭鍑虹珯姹囨姤鍗曟暟鎹紝骞跺垎鍒敓鎴愪釜浜哄伐璧勭粨绠楀崟 + if (data.Rows.Count > 0) + { + int HEmpIDBar = -100; //褰撳墠涓汉宸ヨ祫缁撶畻鍗�-鑱屽憳ID鏍囪 + Pay_SingleBalBillMain mainTable = new Pay_SingleBalBillMain(); + List<Pay_SingleBalBillController.Pay_SingleBalBillSub> subTable = new List<Pay_SingleBalBillController.Pay_SingleBalBillSub>(); + for(int i = 0; i < data.Rows.Count; i++) + { + int HEmpID = data.Rows[i]["HEmpID"] == null ? 0 : (int)data.Rows[i]["HEmpID"]; + if (HEmpIDBar != HEmpID) + { + if (subTable.Count > 0) + { + //鏂板鍗曟嵁 + objJsonResult = AddBillMain_Pay_SingleBalBillMain(mainTable, user,subTable); + if (objJsonResult.code == "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = objJsonResult.Message; + objJsonResult.data = null; + return objJsonResult; + } + + //娓呯┖琛ㄥご淇℃伅鍜屽瓙琛ㄤ俊鎭紝鍔犺浇鏂板崟鎹殑鏁版嵁 + mainTable = new Pay_SingleBalBillMain(); + subTable.Clear(); + } + //鐢熸垚鍗曟嵁鍚庯紝鏇存柊褰撳墠涓汉宸ヨ祫缁撶畻鍗�-鑱屽憳ID鏍囪 + HEmpIDBar = HEmpID; + //濉厖琛ㄥご淇℃伅 + mainTable.HInterID = (int)DBUtility.ClsPub.CreateBillID(HBillType, ref DBUtility.ClsPub.sExeReturnInfo); + mainTable.HBillNo = DBUtility.ClsPub.CreateBillCode(HBillType, ref DBUtility.ClsPub.sExeReturnInfo, true); + mainTable.HDate = DateTime.Now.ToString("yyyy-MM-dd"); + mainTable.HInnerBillNo = mainTable.HBillNo; + mainTable.HDeptID = data.Rows[i]["HDeptID"] == null ? 0 : (int)data.Rows[i]["HDeptID"]; + mainTable.HGroupID = data.Rows[i]["HGroupID"] == null ? 0 :(int)data.Rows[i]["HGroupID"]; + mainTable.HEmpID = data.Rows[i]["HEmpID"] == null ? 0 : (int)data.Rows[i]["HEmpID"]; + mainTable.HPayTypeID = 0; + mainTable.HSourceBillID = 0; + mainTable.HSourceBillNo = ""; + mainTable.HSourceBillType = ""; + mainTable.HExplanation = ""; + mainTable.HRemark = ""; + mainTable.HMaker = user; + mainTable.HMakerDate = DateTime.Now.ToString("yyyy-MM-dd"); + } + //濉厖骞舵坊鍔犲瓙琛ㄨ褰曚俊鎭� + Pay_SingleBalBillController.Pay_SingleBalBillSub oSub = new Pay_SingleBalBillController.Pay_SingleBalBillSub(); + oSub.HMaterID = data.Rows[i]["HMaterID"] == null ? 0 : (int)data.Rows[i]["HMaterID"]; + oSub.HProcID = data.Rows[i]["HProcID"] == null ? 0 : (int)data.Rows[i]["HProcID"]; + oSub.HEmpID = data.Rows[i]["HEmpID"] == null ? 0 : (int)data.Rows[i]["HEmpID"]; + oSub.HTimes = data.Rows[i]["HTimes"] == null ? 0 : double.Parse(data.Rows[i]["HTimes"].ToString()); + oSub.HQty = data.Rows[i]["HQty"] == null ? 0 : double.Parse(data.Rows[i]["HQty"].ToString()); + oSub.HPrice = data.Rows[i]["HPrice"] == null ? 0 : double.Parse(data.Rows[i]["HPrice"].ToString()); + oSub.HPriceRate = 1; + oSub.HSubsidyQty = 0; + oSub.HSubsidyMoney = 0; + oSub.HSubsidyTotal = 0; + oSub.HDeuctTotal = 0; + oSub.HPackQty = 0; + oSub.HPackPrice = 0; + oSub.HPackMoney = 0; + oSub.HPackMaterID = 0; + oSub.HMoney = data.Rows[i]["HMoney"] == null ? 0 : double.Parse(data.Rows[i]["HMoney"].ToString()); + oSub.HRemark = ""; + oSub.HICMOInterID = data.Rows[i]["HICMOInterID"] == null ? 0 : (int)data.Rows[i]["HICMOInterID"]; + oSub.HICMOBillNo = data.Rows[i]["HICMOBillNo"] == null ? "" : data.Rows[i]["HICMOBillNo"].ToString(); + oSub.HProcReportInterID = 0; + oSub.HProcReportEntryID = 0; + oSub.HProcReportBillNo = ""; + oSub.HProcPlanInterID = data.Rows[i]["HProcPlanInterID"] == null ? 0 : (int)data.Rows[i]["HProcPlanInterID"]; + oSub.HProcPlanEntryID = data.Rows[i]["HProcPlanEntryID"] == null ? 0 : (int)data.Rows[i]["HProcPlanEntryID"]; + oSub.HProcPlanBillNo = data.Rows[i]["HProcPlanBillNo"] == null ? "" : data.Rows[i]["HProcPlanBillNo"].ToString(); + oSub.HSourceInterID = 0; //data.Rows[i]["HSourceInterID"] == null ? 0 : (int)data.Rows[i]["HSourceInterID"]; + oSub.HSourceEntryID = 0; //data.Rows[i]["HSourceEntryID "] == null ? 0 : (int)data.Rows[i]["HSourceEntryID "]; + oSub.HSourceBillNo = ""; //data.Rows[i]["HSourceBillNo"] == null ? "" : data.Rows[i]["HSourceBillNo"].ToString(); + oSub.HSourceBillType = ""; + oSub.HRelationQty = 0; + oSub.HRelationMoney = 0; + oSub.HCloseMan = ""; + oSub.HEntryCloseDate = ""; + subTable.Add(oSub); + } + //鐢熸垚鏈�鍚庝竴鏉¤褰曪細鏈�鍚庝竴鏉¤褰曞洜涓烘棤娉曞啀涓巇ata.Rows[data.Rows.Count]["HEmpID"]姣旇緝锛屾墍浠ヤ笉浼氭坊鍔狅紝闇�瑕佹渶鍚庡彟澶栨坊鍔� + objJsonResult = AddBillMain_Pay_SingleBalBillMain(mainTable, user, subTable); + 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 = "Sucess锛�"; + 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 = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + #region 宸ヨ祫璁$畻-宸ヨ祫缁撶畻鍗�(涓汉) 涓昏〃 + public json AddBillMain_Pay_SingleBalBillMain(Pay_SingleBalBillMain oMain,string user,List<Pay_SingleBalBillController.Pay_SingleBalBillSub> subTable) + { + int OperationType = 1;//鏁版嵁绫诲瀷 1娣诲姞 3淇敼 2 澶嶅埗 + string HComputerName = SystemInformation.ComputerName; //璁惧鍚嶇О + try + { + List<Pay_SingleBalBillMain> mainList = new List<Pay_SingleBalBillMain>(); + mainList.Add(oMain); + + int HYear = int.Parse(mainList[0].HDate.Split('-')[0]); + int HPeriod = int.Parse(mainList[0].HDate.Split('-')[1]); + string HBillType = "2205"; + string HBillSubType = ""; + int HBillStatus = 1; + + int HInterID = mainList[0].HInterID; + string HBillNo = mainList[0].HBillNo; + string HDate = mainList[0].HDate; + string HInnerBillNo = mainList[0].HInnerBillNo; + int HGroupID = mainList[0].HGroupID; + int HDeptID = mainList[0].HDeptID; + int HEmpID = mainList[0].HEmpID; + int HPayType = mainList[0].HPayTypeID; + int HMainSourceInterID = mainList[0].HSourceBillID; + string HMainSourceBillNo = mainList[0].HSourceBillNo; + string HMainSourceBillType = mainList[0].HSourceBillType; + string HExplanation = mainList[0].HExplanation; + string HRemark = mainList[0].HRemark; + + //鍒跺崟銆佷慨鏀� + string HMaker = mainList[0].HMaker; + string HMakerDate = mainList[0].HMakerDate; + + ds = oCN.RunProcReturn("select * from Pay_SingleBalBillMain where HInterID = " + HInterID + " and HBillNo = '" + HBillNo + "'", "Pay_SingleBalBillMain"); + + if (OperationType == 1 && ds.Tables[0].Rows.Count == 0)//鏂板 + { + string sql = "insert into Pay_SingleBalBillMain" + + "(HYear,HPeriod,HBillType,HBillSubType,HInterID,HDate,HBillNo,HBillStatus,HGroupID,HDeptID,HEmpID,HPayType,HExplanation,HInnerBillNo,HRemark,HMaker,HMakeDate,HMainSourceInterID,HMainSourceBillNo,HMainSourceBillType,HAutoCreate) " + + "values(" + + "" + HYear + + "," + HPeriod + + ",'" + HBillType + + "','" + HBillSubType + + "'," + HInterID + + ",'" + HDate + + "','" + HBillNo + + "'," + HBillStatus + + "," + HGroupID + + "," + HDeptID + + "," + HEmpID + + "," + HPayType + + ",'" + HExplanation + + "','" + HInnerBillNo + + "','" + HRemark + + "','" + HMaker + + "','" + HMakerDate + + "'," + HMainSourceInterID + + ",'" + HMainSourceBillNo + + "','" + HMainSourceBillType + + "'," + 1 + + ")"; + + //涓昏〃 + oCN.RunProc(sql); + LogService.Write("鐢ㄦ埛:" + user + ",鏃ユ湡:" + DateTime.Now + ",鏂板宸ヨ祫缁撶畻鍗�(涓汉):" + HBillNo); + oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','" + HComputerName + "','" + "鏂板宸ヨ祫缁撶畻鍗�(涓汉)锛�" + HBillNo + "','LMES-宸ヨ祫缁撶畻鍗�(涓汉)妯″潡','" + DBUtility.ClsPub.IPAddress + "','鏂板鍗曟嵁'", ref DBUtility.ClsPub.sExeReturnInfo); + } + + //淇濆瓨瀛愯〃 + objJsonResult = AddBillSub_Pay_SingleBalBillMain(subTable, HInterID, HBillNo, OperationType); + + 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 宸ヨ祫璁$畻-宸ヨ祫缁撶畻鍗�(涓汉) 瀛愯〃 + public json AddBillSub_Pay_SingleBalBillMain(List<Pay_SingleBalBillController.Pay_SingleBalBillSub> DetailColl, long HInterID, string HBillNo, int OperationType) + { + try + { + int i = 0; //浣滀负瀛愯〃鍐呯爜 + foreach (Pay_SingleBalBillController.Pay_SingleBalBillSub oSub in DetailColl) + { + i++; //鍚屼竴涓富琛ㄤ笅鐨勫瓙琛ㄧ殑鍐呯爜鑷 + + int HEntryID = i; + + int HMaterID = oSub.HMaterID; + int HProcID = oSub.HProcID; + int HEmpID = oSub.HEmpID; + + + double HTimes = oSub.HTimes; + double HQty = oSub.HQty; + double HPrice = oSub.HPrice; + double HPriceRate = oSub.HPriceRate; + double HSubsidyQty = oSub.HSubsidyQty; + double HSubsidyMoney = oSub.HSubsidyMoney; + double HSubsidyTotal = oSub.HSubsidyTotal; + double HDeuctTotal = oSub.HDeuctTotal; + double HPackQty = oSub.HPackQty; + double HPackPrice = oSub.HPackPrice; + double HPackMoney = oSub.HPackMoney; + int HPackMaterID = oSub.HPackMaterID; + double HMoney = oSub.HMoney; + + int HICMOInterID = oSub.HICMOInterID; + string HICMOBillNo = oSub.HICMOBillNo; + int HProcReportInterID = oSub.HProcReportInterID; + int HProcReportEntryID = oSub.HProcReportEntryID; + string HProcReportBillNo = oSub.HProcReportBillNo; + int HProcPlanInterID = oSub.HProcPlanInterID; + int HProcPlanEntryID = oSub.HProcPlanEntryID; + string HProcPlanBillNo = oSub.HProcPlanBillNo; + + string HRemark = oSub.HRemark; + + int HSourceInterID = oSub.HSourceInterID; + int HSourceEntryID = oSub.HSourceEntryID; + string HSourceBillNo = oSub.HSourceBillNo; + string HSourceBillType = oSub.HSourceBillType; + double HRelationQty = oSub.HRelationQty; + double HRelationMoney = oSub.HRelationMoney; + string HCloseMan = oSub.HCloseMan; + string HEntryCloseDate = oSub.HEntryCloseDate; + + string sql = "insert into Pay_SingleBalBillSub" + + "(HInterID,HEntryID,HMaterID,HProcID,HEmpID,HTimes,HQty,HPrice,HPriceRate,HSubsidyQty,HSubsidyMoney,HSubsidyTotal,HDeuctTotal" + + ",HPackQty,HPackPrice,HPackMoney,HPackMaterID,HMoney,HICMOInterID,HICMOBillNo,HProcReportInterID,HProcReportEntryID,HProcReportBillNo" + + ",HProcPlanInterID,HProcPlanEntryID,HProcPlanBillNo,HRemark,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" + + ",HCloseMan,HEntryCloseDate) " + + "values(" + + "" + HInterID + + "," + HEntryID + + "," + HMaterID + + "," + HProcID + + "," + HEmpID + + "," + HTimes + + "," + HQty + + "," + HPrice + + "," + HPriceRate + + "," + HSubsidyQty + + "," + HSubsidyMoney + + "," + HSubsidyTotal + + "," + HDeuctTotal + + "," + HPackQty + + "," + HPackPrice + + "," + HPackMoney + + "," + HPackMaterID + + "," + HMoney + + "," + HICMOInterID + + ",'" + HICMOBillNo + + "'," + HProcReportInterID + + "," + HProcReportEntryID + + ",'" + HProcReportBillNo + + "'," + HProcPlanInterID + + "," + HProcPlanEntryID + + ",'" + HProcPlanBillNo + + "','" + HRemark + + "'," + HSourceInterID + + "," + HSourceEntryID + + ",'" + HSourceBillNo + + "','" + HSourceBillType + + "'," + HRelationQty + + "," + HRelationMoney + + ",'" + HCloseMan + + "','" + HEntryCloseDate + + "')"; + + oCN.RunProc(sql); + } + + 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 + #endregion + + #region 宸ヨ祫璁$畻-闆嗕綋宸ヨ祫缁撶畻鍗� + #region 宸ヨ祫璁$畻-鎵归噺璁$畻-闆嗕綋宸ヨ祫缁撶畻鍗� + public json getSalaryCalculateData_GroupBalBill(string HBeginDate, string HEndDate, int HOperatorType, string HBillType, string user) + { + try + { + //鍒ゆ柇鏄惁鏈夌紪杈戞潈闄� + if (!DBUtility.ClsPub.Security_Log("Pay_GroupBalBill_Edit", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳柊澧炴潈闄�!"; + objJsonResult.data = null; + return objJsonResult; + } + + + //鑾峰彇宸ュ簭鍑虹珯姹囨姤鍗曟暟鎹� + string sql = "exec h_p_Pay_SalaryCalculate_getData " + HOperatorType + ",'" + HBeginDate + "','" + HEndDate + "'"; + ds = oCN.RunProcReturn(sql, "h_p_Pay_SalaryCalculate_getData"); + DataTable data = ds.Tables[0]; + //鏌ヨ瀛愯〃2鎵�闇�鍙橀噺 + DataSet ds1; + string sql1; + //鏁寸悊宸ュ簭鍑虹珯姹囨姤鍗曟暟鎹紝骞跺垎鍒敓鎴愪釜浜哄伐璧勭粨绠楀崟 + if (data.Rows.Count > 0) + { + int HDeptIDBar = -100; + int HGroupIDBar = -100; + + Pay_GroupBalBillMain mainTable = new Pay_GroupBalBillMain(); + List<Pay_GroupBalBillController.Pay_GroupBalBillSub> subTable = new List<Pay_GroupBalBillController.Pay_GroupBalBillSub>(); + List<Pay_GroupBalBillController.Pay_GroupBalBillEmp> subEmpTable = new List<Pay_GroupBalBillController.Pay_GroupBalBillEmp>(); + for (int i = 0; i < data.Rows.Count; i++) + { + int HDeptID = data.Rows[i]["HDeptID"] == null ? 0 : (int)data.Rows[i]["HDeptID"]; + int HGroupID = data.Rows[i]["HGroupID"] == null ? 0 : (int)data.Rows[i]["HGroupID"]; + if (HDeptIDBar != HDeptID || HGroupIDBar != HGroupID) + { + if (subTable.Count > 0) + { + //鑾峰彇瀛愯〃2鏁版嵁 + sql1 = "select * from h_v_Gy_Employee_ForWeb where HDeptID ='" + HDeptIDBar + "' and HGroupID = '" + HGroupIDBar + "'"; + ds1 = oCN.RunProcReturn(sql1, "h_v_Gy_Employee_ForWeb"); + if (ds1.Tables[0].Rows.Count > 0) + { + for(int j = 0; j < ds1.Tables[0].Rows.Count; j++) + { + Pay_GroupBalBillController.Pay_GroupBalBillEmp oSubEmp = new Pay_GroupBalBillController.Pay_GroupBalBillEmp(); + oSubEmp.HEmpID = ds1.Tables[0].Rows[j]["HItemID"] == null ? 0 : int.Parse(ds1.Tables[0].Rows[j]["HItemID"].ToString()); + oSubEmp.HEmpRate = ds1.Tables[0].Rows[j]["HEmpRate"] == null ? 0 : double.Parse(ds1.Tables[0].Rows[j]["HEmpRate"].ToString()); + oSubEmp.HBaseTimes = 0; + oSubEmp.HMoney = 0; + oSubEmp.HOtherSubsidy = 0; + oSubEmp.HOtherDeduct = 0; + oSubEmp.HYF = 0; + oSubEmp.HIsPay = false; + oSubEmp.HAvgFlag = false; + oSubEmp.HRemark = ""; + subEmpTable.Add(oSubEmp); + } + } + + //鏂板鍗曟嵁 + objJsonResult = AddBillMain_Pay_GroupBalBill(mainTable, user, subTable, subEmpTable); + if (objJsonResult.code == "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = objJsonResult.Message; + objJsonResult.data = null; + return objJsonResult; + } + + //娓呯┖琛ㄥご淇℃伅鍜屽瓙琛ㄤ俊鎭紝鍔犺浇鏂板崟鎹殑鏁版嵁 + mainTable = new Pay_GroupBalBillMain(); + subTable.Clear(); + subEmpTable.Clear(); + } + //鐢熸垚鍗曟嵁鍚庯紝鏇存柊褰撳墠闆嗕綋宸ヨ祫缁撶畻鍗�-閮ㄩ棬ID锛岀彮缁処D + HDeptIDBar = HDeptID; + HGroupIDBar = HGroupID; + + //濉厖琛ㄥご淇℃伅 + mainTable.HInterID = (int)DBUtility.ClsPub.CreateBillID(HBillType, ref DBUtility.ClsPub.sExeReturnInfo); + mainTable.HBillNo = DBUtility.ClsPub.CreateBillCode(HBillType, ref DBUtility.ClsPub.sExeReturnInfo, true); + mainTable.HDate = DateTime.Now.ToString("yyyy-MM-dd"); + mainTable.HInnerBillNo = mainTable.HBillNo; + mainTable.HDeptID = data.Rows[i]["HDeptID"] == null ? 0 : (int)data.Rows[i]["HDeptID"]; + mainTable.HGroupID = data.Rows[i]["HGroupID"] == null ? 0 : (int)data.Rows[i]["HGroupID"]; + mainTable.HSumMoney = 0; + mainTable.HOtherSubsidy = 0; + mainTable.HPayMoney = 0; + mainTable.HOtherDeduct = 0; + mainTable.HSourceBillID = 0; + mainTable.HSourceBillNo = ""; + mainTable.HSourceBillType = ""; + mainTable.HExplanation = ""; + mainTable.HRemark = ""; + mainTable.HMaker = user; + mainTable.HMakerDate = DateTime.Now.ToString("yyyy-MM-dd"); + } + + //濉厖骞舵坊鍔犲瓙琛ㄨ褰曚俊鎭� + Pay_GroupBalBillController.Pay_GroupBalBillSub oSub = new Pay_GroupBalBillController.Pay_GroupBalBillSub(); + + oSub.HMaterID = data.Rows[i]["HMaterID"] == null ? 0 : (int)data.Rows[i]["HMaterID"]; + oSub.HUnitID = data.Rows[i]["HUnitID"] == null ? 0 : (int)data.Rows[i]["HUnitID"]; + oSub.HProcID = data.Rows[i]["HProcID"] == null ? 0 : (int)data.Rows[i]["HProcID"]; + oSub.HSourceID = data.Rows[i]["HSourceID"] == null ? 0 : (int)data.Rows[i]["HSourceID"]; + oSub.HTimes = data.Rows[i]["HTimes"] == null ? 0 : double.Parse(data.Rows[i]["HTimes"].ToString()); + oSub.HQty = data.Rows[i]["HQty"] == null ? 0 : double.Parse(data.Rows[i]["HQty"].ToString()); + oSub.HPrice = data.Rows[i]["HPrice"] == null ? 0 : double.Parse(data.Rows[i]["HPrice"].ToString()); + oSub.HMoney = data.Rows[i]["HMoney"] == null ? 0 : double.Parse(data.Rows[i]["HMoney"].ToString()); + oSub.HRemark = ""; + oSub.HICMOInterID = 0; // data.Rows[i]["HICMOInterID"] == null ? 0 : (int)data.Rows[i]["HICMOInterID"]; + oSub.HICMOBillNo = ""; // data.Rows[i]["HICMOBillNo"] == null ? "" : data.Rows[i]["HICMOBillNo"].ToString(); + oSub.HProcReportInterID = 0; + oSub.HProcReportEntryID = 0; + oSub.HProcReportBillNo = ""; + oSub.HProcPlanInterID = 0; // data.Rows[i]["HProcPlanInterID"] == null ? 0 : (int)data.Rows[i]["HProcPlanInterID"]; + oSub.HProcPlanEntryID = 0; // data.Rows[i]["HProcPlanEntryID"] == null ? 0 : (int)data.Rows[i]["HProcPlanEntryID"]; + oSub.HProcPlanBillNo = ""; // data.Rows[i]["HProcPlanBillNo"] == null ? "" : data.Rows[i]["HProcPlanBillNo"].ToString(); + oSub.HSourceInterID = data.Rows[i]["HSourceInterID"] == null ? 0 : (int)data.Rows[i]["HSourceInterID"]; + oSub.HSourceEntryID = data.Rows[i]["HSourceEntryID"] == null ? 0 : (int)data.Rows[i]["HSourceEntryID"]; + oSub.HSourceBillNo = data.Rows[i]["HSourceBillNo"] == null ? "" : data.Rows[i]["HSourceBillNo"].ToString(); + oSub.HSourceBillType = data.Rows[i]["HSourceBillType"] == null ? "" : data.Rows[i]["HSourceBillType"].ToString(); + oSub.HRelationQty = data.Rows[i]["HQty"] == null ? 0 : double.Parse(data.Rows[i]["HQty"].ToString()); + oSub.HRelationMoney = data.Rows[i]["HMoney"] == null ? 0 : double.Parse(data.Rows[i]["HMoney"].ToString()); + subTable.Add(oSub); + } + + //鐢熸垚鏈�鍚庝竴鏉¤褰曪細鏈�鍚庝竴鏉¤褰曞洜涓烘棤娉曞啀涓巇ata.Rows[data.Rows.Count]["HEmpID"]姣旇緝锛屾墍浠ヤ笉浼氭坊鍔狅紝闇�瑕佹渶鍚庡彟澶栨坊鍔� + sql1 = "select * from h_v_Gy_Employee_ForWeb where HDeptID ='" + HDeptIDBar + "' and HGroupID = '" + HGroupIDBar + "'"; + ds1 = oCN.RunProcReturn(sql1, "h_v_Gy_Employee_ForWeb"); + if (ds1.Tables[0].Rows.Count > 0) + { + for (int j = 0; j < ds1.Tables[0].Rows.Count; j++) + { + Pay_GroupBalBillController.Pay_GroupBalBillEmp oSubEmp = new Pay_GroupBalBillController.Pay_GroupBalBillEmp(); + oSubEmp.HEmpID = ds1.Tables[0].Rows[j]["HItemID"] == null ? 0 : int.Parse(ds1.Tables[0].Rows[j]["HItemID"].ToString()); + oSubEmp.HEmpRate = ds1.Tables[0].Rows[j]["HEmpRate"] == null ? 0 : double.Parse(ds1.Tables[0].Rows[j]["HEmpRate"].ToString()); + oSubEmp.HBaseTimes = 0; + oSubEmp.HMoney = 0; + oSubEmp.HOtherSubsidy = 0; + oSubEmp.HOtherDeduct = 0; + oSubEmp.HYF = 0; + oSubEmp.HIsPay = false; + oSubEmp.HAvgFlag = false; + oSubEmp.HRemark = ""; + subEmpTable.Add(oSubEmp); + } + } + + objJsonResult = AddBillMain_Pay_GroupBalBill(mainTable, user, subTable,subEmpTable); + 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 = "Sucess锛�"; + 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 = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + #region 宸ヨ祫璁$畻-宸ヨ祫缁撶畻鍗�(闆嗕綋) 涓昏〃 + public json AddBillMain_Pay_GroupBalBill(Pay_GroupBalBillMain oMain, string user, List<Pay_GroupBalBillController.Pay_GroupBalBillSub> subTable, List<Pay_GroupBalBillController.Pay_GroupBalBillEmp> subEmpTable) + { + int OperationType = 1;//鏁版嵁绫诲瀷 1娣诲姞 3淇敼 2 澶嶅埗 + + string HComputerName = SystemInformation.ComputerName; //璁惧鍚嶇О + + try + { + List<Pay_GroupBalBillMain> mainList = new List<Pay_GroupBalBillMain>(); + mainList.Add(oMain); + + + int HYear = int.Parse(mainList[0].HDate.Split('-')[0]); + int HPeriod = int.Parse(mainList[0].HDate.Split('-')[1]); + string HBillType = "2201"; + string HBillSubType = ""; + int HBillStatus = 1; + + int HInterID = mainList[0].HInterID; + string HBillNo = mainList[0].HBillNo; + string HDate = mainList[0].HDate; + string HInnerBillNo = mainList[0].HInnerBillNo; + int HGroupID = mainList[0].HGroupID; + string HGroupName = mainList[0].HGroupName; + double HSumMoney = mainList[0].HSumMoney; + double HOtherSubsidy = mainList[0].HOtherSubsidy; + int HDeptID = mainList[0].HDeptID; + string HDeptName = mainList[0].HDeptName; + double HPayMoney = mainList[0].HPayMoney; + double HOtherDeduct = mainList[0].HOtherDeduct; + string HSourceBillType = mainList[0].HSourceBillType; + int HSourceBillID = mainList[0].HSourceBillID; + string HSourceBillNo = mainList[0].HSourceBillNo; + string HExplanation = mainList[0].HExplanation; + string HRemark = mainList[0].HRemark; + string HMaker = mainList[0].HMaker; + string HMakerDate = mainList[0].HMakerDate; + string HUpdater = mainList[0].HUpdater; + string HUpdaterDate = mainList[0].HUpdaterDate; + string HChecker = mainList[0].HChecker; + string HCheckerDate = mainList[0].HCheckerDate; + string HCloseMan = mainList[0].HCloseMan; + string HCloseManDate = mainList[0].HCloseManDate; + string HDeleteMan = mainList[0].HDeleteMan; + string HDeleteManDate = mainList[0].HDeleteManDate; + string HBacker = mainList[0].HBacker; + string HBackerDate = mainList[0].HBackerDate; + string HBackRemark = mainList[0].HBackRemark; + + ds = oCN.RunProcReturn("select * from Pay_GroupBalBillMain where HInterID = " + HInterID + " and HBillNo = '" + HBillNo + "'", "Pay_GroupBalBillMain"); + + if ((OperationType == 1 || OperationType == 2) && ds.Tables[0].Rows.Count == 0)//鏂板 + { + string sql = "insert into Pay_GroupBalBillMain" + + "(HYear,HPeriod,HBillType,HBillSubType,HBillStatus,HInterID,HBillNo,HDate,HInnerBillNo,HGroupID,HSumMoney,HOtherSubsidy,HDeptID" + + ",HPayMoney,HOtherDeduct,HMainSourceBillType,HMainSourceInterID,HMainSourceBillNo,HExplanation,HRemark,HMaker,HMakeDate) " + + "values(" + + "" + HYear + + "," + HPeriod + + ",'" + HBillType + + "','" + HBillSubType + + "','" + HBillStatus + + "'," + HInterID + + ",'" + HBillNo + + "','" + HDate + + "','" + HInnerBillNo + + "'," + HGroupID + + ",'" + HSumMoney + + "','" + HOtherSubsidy + + "'," + HDeptID + + "," + HPayMoney + + "," + HOtherDeduct + + ",'" + HSourceBillType + + "'," + HSourceBillID + + ",'" + HSourceBillNo + + "','" + HExplanation + + "','" + HRemark + + "','" + HMaker + + "','" + HMakerDate + + "')"; + + //涓昏〃 + oCN.RunProc(sql); + LogService.Write("鐢ㄦ埛:" + user + ",鏃ユ湡:" + DateTime.Now + ",鏂板宸ヨ祫缁撶畻鍗�(闆嗕綋):" + HBillNo); + oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','" + HComputerName + "','" + "鏂板宸ヨ祫缁撶畻鍗�(闆嗕綋)锛�" + HBillNo + "','LMES-宸ヨ祫缁撶畻鍗�(闆嗕綋)妯″潡','" + DBUtility.ClsPub.IPAddress + "','鏂板鍗曟嵁'", ref DBUtility.ClsPub.sExeReturnInfo); + } + + + //淇濆瓨瀛愯〃 + objJsonResult = AddBillSub1_Pay_GroupBalBill(subTable, HInterID, HBillNo, OperationType); + objJsonResult = AddBillSub2_Pay_GroupBalBill(subEmpTable, HInterID, HBillNo, OperationType); + + 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 娣诲姞 宸ヨ祫缁撶畻鍗�(闆嗕綋) 瀛愯〃1 + public json AddBillSub1_Pay_GroupBalBill(List<Pay_GroupBalBillController.Pay_GroupBalBillSub> DetailColl, long HInterID, string HBillNo, int OperationType) + { + try + { + int i = 0; //浣滀负瀛愯〃鍐呯爜 + foreach (Pay_GroupBalBillController.Pay_GroupBalBillSub oSub in DetailColl) + { + i++; //鍚屼竴涓富琛ㄤ笅鐨勫瓙琛ㄧ殑鍐呯爜鑷 + + int HEntryID = i; + + int HMaterID = oSub.HMaterID; + int HUnitID = oSub.HUnitID; + int HProcID = oSub.HProcID; + int HSourceID = oSub.HSourceID; + double HTimes = oSub.HTimes; + double HQty = oSub.HQty; + double HPrice = oSub.HPrice; + double HMoney = oSub.HMoney; + string HRemark = oSub.HRemark; + int HICMOInterID = oSub.HICMOInterID; + string HICMOBillNo = oSub.HICMOBillNo; + int HProcReportInterID = oSub.HProcReportInterID; + int HProcReportEntryID = oSub.HProcReportEntryID; + string HProcReportBillNo = oSub.HProcReportBillNo; + int HProcPlanInterID = oSub.HProcPlanInterID; + int HProcPlanEntryID = oSub.HProcPlanEntryID; + string HProcPlanBillNo = oSub.HProcPlanBillNo; + int HSourceInterID = oSub.HSourceInterID; + int HSourceEntryID = oSub.HSourceEntryID; + string HSourceBillNo = oSub.HSourceBillNo; + string HSourceBillType = oSub.HSourceBillType; + double HRelationQty = oSub.HRelationQty; + double HRelationMoney = oSub.HRelationMoney; + + + + string sql = "insert into Pay_GroupBalBillSub" + + "(HInterID,HEntryID,HMaterID,HUnitID,HProcID,HSourceID,HTimes,HQty,HPrice,HMoney,HRemark,HICMOInterID,HICMOBillNo,HProcReportInterID" + + ",HProcReportEntryID,HProcReportBillNo,HProcPlanInterID,HProcPlanEntryID,HProcPlanBillNo,HSourceInterID,HSourceEntryID,HSourceBillNo" + + ",HSourceBillType,HRelationQty,HRelationMoney) " + + "values(" + + "" + HInterID + + "," + HEntryID + + "," + HMaterID + + "," + HUnitID + + "," + HProcID + + "," + HSourceID + + "," + HTimes + + "," + HQty + + "," + HPrice + + "," + HMoney + + ",'" + HRemark + + "'," + HICMOInterID + + ",'" + HICMOBillNo + + "'," + HProcReportInterID + + "," + HProcReportEntryID + + ",'" + HProcReportBillNo + + "'," + HProcPlanInterID + + "," + HProcPlanEntryID + + ",'" + HProcPlanBillNo + + "'," + HSourceInterID + + "," + HSourceEntryID + + ",'" + HSourceBillNo + + "','" + HSourceBillType + + "'," + HRelationQty + + "," + HRelationMoney + + ")"; + + oCN.RunProc(sql); + } + + 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 娣诲姞 宸ヨ祫缁撶畻鍗�(闆嗕綋) 瀛愯〃2 + public json AddBillSub2_Pay_GroupBalBill(List<Pay_GroupBalBillController.Pay_GroupBalBillEmp> DetailColl, long HInterID, string HBillNo, int OperationType) + { + try + { + int i = 0; //浣滀负瀛愯〃鍐呯爜 + foreach (Pay_GroupBalBillEmp oSub in DetailColl) + { + i++; //鍚屼竴涓富琛ㄤ笅鐨勫瓙琛ㄧ殑鍐呯爜鑷 + + int HEntryID = i; + + int HEmpID = oSub.HEmpID; + string HEmpNumber = oSub.HEmpNumber; + string HEmpName = oSub.HEmpName; + double HEmpRate = oSub.HEmpRate; + double HBaseTimes = oSub.HBaseTimes; + double HMoney = oSub.HMoney; + double HOtherSubsidy = oSub.HOtherSubsidy; + double HOtherDeduct = oSub.HOtherDeduct; + double HYF = oSub.HYF; + int HIsPay = oSub.HIsPay ? 1 : 0; + int HAvgFlag = oSub.HAvgFlag ? 1 : 0; + string HRemark = oSub.HRemark; + + + + string sql = "insert into Pay_GroupBalBillEmp" + + "(HInterID,HEntryID,HEmpID,HEmpRate,HBaseTimes,HMoney,HOtherSubsidy,HOtherDeduct,HYF,HIsPay,HAvgFlag,HRemark) " + + "values(" + + "" + HInterID + + "," + HEntryID + + "," + HEmpID + + "," + HEmpRate + + "," + HBaseTimes + + "," + HMoney + + "," + HOtherSubsidy + + "," + HOtherDeduct + + "," + HYF + + "," + HIsPay + + "," + HAvgFlag + + ",'" + HRemark + + "')"; + + oCN.RunProc(sql); + } + + + 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 + #endregion + } +} \ No newline at end of file -- Gitblit v1.9.1