185 lines
		
	
	
		
			8.6 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			185 lines
		
	
	
		
			8.6 KiB
		
	
	
	
		
			C#
		
	
	
	
| using System;
 | |
| using System.Collections.Generic;
 | |
| using System.Linq;
 | |
| using System.Text;
 | |
| using System.Threading.Tasks;
 | |
| 
 | |
| namespace BLL
 | |
| {
 | |
|     public class CostControlDetailHistoryService
 | |
|     {
 | |
|         /// <summary>
 | |
|         /// 根据Id获取一个费控项明细历史记录信息
 | |
|         /// </summary>
 | |
|         /// <param name="costControlDetailHistoryId">费控项明细历史记录Id</param>
 | |
|         public static Model.WBS_CostControlDetailHistory GetCostControlDetailHistoryByCostControlDetailHistoryId(string costControlDetailHistoryId)
 | |
|         {
 | |
|             return Funs.DB.WBS_CostControlDetailHistory.FirstOrDefault(e => e.CostControlDetailHistoryId == costControlDetailHistoryId);
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据CostControlId判断是否存在费控项明细历史记录信息
 | |
|         /// </summary>
 | |
|         /// <param name="costControlId">costControlId</param>
 | |
|         public static bool IsExitCostControlDetailHistoryByCostControlId(string costControlId)
 | |
|         {
 | |
|             return (from x in Funs.DB.WBS_CostControlDetailHistory where x.CostControlId == costControlId select x).Count() > 0;
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据Id获取对应费控项月明细历史记录信息
 | |
|         /// </summary>
 | |
|         /// <param name="toWbs">对应wbsId</param>
 | |
|         public static List<Model.WBS_CostControlDetailHistory> GetMonthCostControlDetailHistorysByCostControlId(string costControlId)
 | |
|         {
 | |
|             return (from x in Funs.DB.WBS_CostControlDetailHistory where x.CostControlId == costControlId && x.StartDate == null orderby x.VersionNum, x.Months select x).ToList();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据Id获取对应费控项周明细历史记录信息
 | |
|         /// </summary>
 | |
|         /// <param name="toWbs">对应wbsId</param>
 | |
|         public static List<Model.WBS_CostControlDetailHistory> GetWeekCostControlDetailHistorysByCostControlId(string costControlId, DateTime months)
 | |
|         {
 | |
|             return (from x in Funs.DB.WBS_CostControlDetailHistory where x.CostControlId == costControlId && x.Months == months && x.StartDate != null orderby x.VersionNum, x.StartDate select x).ToList();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据costControlId和年及月获取对应费控项明细历史记录信息
 | |
|         /// </summary>
 | |
|         /// <param name="costControlId">对应wbsId</param>
 | |
|         /// <param name="toFlag">对应标志</param>
 | |
|         /// <param name="years">年</param>
 | |
|         /// <param name="months">月</param>
 | |
|         public static Model.WBS_CostControlDetailHistory GetCostControlDetailHistoryByCostControlIdAndMonths(string costControlId, DateTime months)
 | |
|         {
 | |
|             return (from x in Funs.DB.WBS_CostControlDetailHistory where x.CostControlId == costControlId && x.Months == months select x).FirstOrDefault();
 | |
|         }
 | |
| 
 | |
|         public static Model.WBS_CostControlDetailHistory GetWBS_CostControlDetailHistoryByCostControlId(string costControlId)
 | |
|         {
 | |
|             return (from x in Funs.DB.WBS_CostControlDetailHistory where x.CostControlId == costControlId select x).FirstOrDefault();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 
 | |
|         /// </summary>
 | |
|         /// <param name="costControlId"></param>
 | |
|         /// <param name="toFlag"></param>
 | |
|         /// <param name="months"></param>
 | |
|         /// <returns></returns>
 | |
|         public static bool IsExitWBS_CostControlDetailHistoryByCostControlIdOrMonth(string costControlId, DateTime months)
 | |
|         {
 | |
|             bool result = false;
 | |
|             var q = Funs.DB.WBS_CostControlDetailHistory.FirstOrDefault(e => e.CostControlId == costControlId && e.Months == months);
 | |
|             if (q != null)
 | |
|             {
 | |
|                 result = true;
 | |
|             }
 | |
|             return result;
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据年及月获取之前月份的对应费控项明细历史记录信息集合(含当月)
 | |
|         /// </summary>
 | |
|         /// <param name="years">年</param>
 | |
|         /// <param name="months">月</param>
 | |
|         public static List<Model.WBS_CostControlDetailHistory> GetTotalWBS_CostControlDetailHistorysByYearMonth2(string costControlId, DateTime months)
 | |
|         {
 | |
|             return (from x in Funs.DB.WBS_CostControlDetailHistory where x.CostControlId == costControlId && x.Months <= months select x).ToList();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据CostControlId月获取当前月计划最大版本
 | |
|         /// </summary>
 | |
|         /// <param name="costControlId">costControlId</param>
 | |
|         public static int GetMonthMaxVersionNumByCostControlId(string costControlId)
 | |
|         {
 | |
|             int i = 0;
 | |
|             var q = (from x in Funs.DB.WBS_CostControlDetailHistory where x.CostControlId == costControlId && x.StartDate == null orderby x.VersionNum descending select x.VersionNum ?? 0).ToList();
 | |
|             if (q.Count > 0)
 | |
|             {
 | |
|                 i = q[0];
 | |
|             }
 | |
|             return i;
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据CostControlId月获取当前周计划最大版本
 | |
|         /// </summary>
 | |
|         /// <param name="costControlId">costControlId</param>
 | |
|         public static int GetWeekMaxVersionNumByCostControlId(string costControlId, DateTime months)
 | |
|         {
 | |
|             int i = 0;
 | |
|             var q = (from x in Funs.DB.WBS_CostControlDetailHistory where x.CostControlId == costControlId && x.Months == months && x.StartDate != null orderby x.VersionNum descending select x.VersionNum ?? 0).ToList();
 | |
|             if (q.Count > 0)
 | |
|             {
 | |
|                 i = q[0];
 | |
|             }
 | |
|             return i;
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 增加费控项明细历史记录
 | |
|         /// </summary>
 | |
|         /// <param name="user">费控项明细历史记录</param>
 | |
|         public static void AddCostControlDetailHistory(Model.WBS_CostControlDetailHistory costControlDetailHistory)
 | |
|         {
 | |
|             Model.SGGLDB db = Funs.DB;
 | |
|             Model.WBS_CostControlDetailHistory newWBS_CostControlDetailHistory = new Model.WBS_CostControlDetailHistory();
 | |
|             newWBS_CostControlDetailHistory.CostControlDetailHistoryId = costControlDetailHistory.CostControlDetailHistoryId;
 | |
|             newWBS_CostControlDetailHistory.CostControlId = costControlDetailHistory.CostControlId;
 | |
|             newWBS_CostControlDetailHistory.Months = costControlDetailHistory.Months;
 | |
|             newWBS_CostControlDetailHistory.StartDate = costControlDetailHistory.StartDate;
 | |
|             newWBS_CostControlDetailHistory.EndDate = costControlDetailHistory.EndDate;
 | |
|             newWBS_CostControlDetailHistory.PlanNum = costControlDetailHistory.PlanNum;
 | |
|             newWBS_CostControlDetailHistory.VersionNum = costControlDetailHistory.VersionNum;
 | |
| 
 | |
|             db.WBS_CostControlDetailHistory.InsertOnSubmit(newWBS_CostControlDetailHistory);
 | |
|             db.SubmitChanges();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 修改费控项明细历史记录
 | |
|         /// </summary>
 | |
|         /// <param name="user">费控项明细历史记录</param>
 | |
|         public static void UpdateCostControlDetailHistory(Model.WBS_CostControlDetailHistory costControlDetailHistory)
 | |
|         {
 | |
|             Model.SGGLDB db = Funs.DB;
 | |
|             Model.WBS_CostControlDetailHistory newWBS_CostControlDetailHistory = db.WBS_CostControlDetailHistory.First(e => e.CostControlDetailHistoryId == costControlDetailHistory.CostControlDetailHistoryId);
 | |
|             newWBS_CostControlDetailHistory.StartDate = costControlDetailHistory.StartDate;
 | |
|             newWBS_CostControlDetailHistory.EndDate = costControlDetailHistory.EndDate;
 | |
|             newWBS_CostControlDetailHistory.PlanNum = costControlDetailHistory.PlanNum;
 | |
| 
 | |
|             db.SubmitChanges();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据Id删除费控项明细历史记录信息
 | |
|         /// </summary>
 | |
|         /// <param name="userId"></param>
 | |
|         public static void DeleteCostControlDetailHistory(string costControlDetailHistoryId)
 | |
|         {
 | |
|             Model.SGGLDB db = Funs.DB;
 | |
|             Model.WBS_CostControlDetailHistory ins = db.WBS_CostControlDetailHistory.First(e => e.CostControlDetailHistoryId == costControlDetailHistoryId);
 | |
|             db.WBS_CostControlDetailHistory.DeleteOnSubmit(ins);
 | |
|             db.SubmitChanges();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据costControlId删除费控项明细历史记录信息
 | |
|         /// </summary>
 | |
|         /// <param name="userId"></param>
 | |
|         public static void DeleteCostControlDetailHistoryByCostControlId(string costControlId)
 | |
|         {
 | |
|             Model.SGGLDB db = Funs.DB;
 | |
|             var details = from x in db.WBS_CostControlDetailHistory where x.CostControlId == costControlId select x;
 | |
|             if (details.Count() > 0)
 | |
|             {
 | |
|                 db.WBS_CostControlDetailHistory.DeleteAllOnSubmit(details);
 | |
|                 db.SubmitChanges();
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| }
 |