| 
									
										
										
										
											2021-08-13 11:15:59 +08:00
										 |  |  |  | using System; | 
					
						
							|  |  |  |  | using System.Collections.Generic; | 
					
						
							|  |  |  |  | using System.Linq; | 
					
						
							|  |  |  |  | using System.Text; | 
					
						
							|  |  |  |  | using System.Threading.Tasks; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | namespace BLL | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     public class CostControlService | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 根据费控项Id获取费控项信息 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="unitProjectId">费控项Id</param> | 
					
						
							|  |  |  |  |         /// <returns></returns> | 
					
						
							|  |  |  |  |         public static Model.WBS_CostControl GetCostControlByCostControlId(string costControlId) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             return Funs.DB.WBS_CostControl.FirstOrDefault(e => e.CostControlId.ToString() == costControlId); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 根据费控项编号集合获取费控项信息 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="costControlCodes">费控项编号集合</param> | 
					
						
							|  |  |  |  |         /// <returns></returns> | 
					
						
							|  |  |  |  |         public static List<Model.WBS_CostControl> GetCostControlsByCostControlCodes(List<string> costControlCodes, string wbsSetId) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             return (from x in Funs.DB.WBS_CostControl where costControlCodes.Contains(x.CostControlCode) && x.WbsSetId == wbsSetId select x).ToList(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 根据费控项编号集合获取费控项信息 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="costControlCodes">费控项编号集合</param> | 
					
						
							|  |  |  |  |         /// <returns></returns> | 
					
						
							|  |  |  |  |         public static List<Model.WBS_CostControl> GetCostControlsByWbsSetId(string wbsSetId) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             return (from x in Funs.DB.WBS_CostControl where x.WbsSetId == wbsSetId select x).ToList(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-21 16:10:02 +08:00
										 |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 根据费控项编号集合获取勾选的费控项信息 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="costControlCodes">费控项编号集合</param> | 
					
						
							|  |  |  |  |         /// <returns></returns> | 
					
						
							|  |  |  |  |         public static List<Model.WBS_CostControl> GetSelectedCostControlsByWbsSetId(string wbsSetId) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             return (from x in Funs.DB.WBS_CostControl where x.WbsSetId == wbsSetId && x.IsSelected == true orderby x.CostControlCode, x.CostControlName select x).ToList(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-13 11:15:59 +08:00
										 |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 增加费控项 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="user">费控项</param> | 
					
						
							|  |  |  |  |         public static void AddCostControl(Model.WBS_CostControl costControl) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             Model.SGGLDB db = Funs.DB; | 
					
						
							|  |  |  |  |             Model.WBS_CostControl newUP = new Model.WBS_CostControl(); | 
					
						
							|  |  |  |  |             newUP.CostControlId = SQLHelper.GetNewID(); | 
					
						
							|  |  |  |  |             newUP.ProjectId = costControl.ProjectId; | 
					
						
							|  |  |  |  |             newUP.WbsSetId = costControl.WbsSetId; | 
					
						
							|  |  |  |  |             newUP.CostControlCode = costControl.CostControlCode; | 
					
						
							|  |  |  |  |             newUP.CostControlName = costControl.CostControlName; | 
					
						
							|  |  |  |  |             newUP.Unit = costControl.Unit; | 
					
						
							| 
									
										
										
										
											2021-12-21 16:10:02 +08:00
										 |  |  |  |             newUP.IsSelected = costControl.IsSelected; | 
					
						
							| 
									
										
										
										
											2023-05-26 10:24:02 +08:00
										 |  |  |  |             newUP.EquipmentMaterialTypeId = costControl.EquipmentMaterialTypeId; | 
					
						
							| 
									
										
										
										
											2021-08-13 11:15:59 +08:00
										 |  |  |  |             newUP.TotalNum = costControl.TotalNum; | 
					
						
							|  |  |  |  |             newUP.RealPrice = costControl.RealPrice; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             db.WBS_CostControl.InsertOnSubmit(newUP); | 
					
						
							|  |  |  |  |             db.SubmitChanges(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 修改费控项信息 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="user">费控项信息</param> | 
					
						
							|  |  |  |  |         public static void UpdateCostControl(Model.WBS_CostControl costControl) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             Model.SGGLDB db = Funs.DB; | 
					
						
							|  |  |  |  |             Model.WBS_CostControl newUP = db.WBS_CostControl.First(e => e.CostControlId == costControl.CostControlId); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             newUP.CostControlCode = costControl.CostControlCode; | 
					
						
							|  |  |  |  |             newUP.CostControlName = costControl.CostControlName; | 
					
						
							|  |  |  |  |             newUP.Unit = costControl.Unit; | 
					
						
							|  |  |  |  |             newUP.TotalNum = costControl.TotalNum; | 
					
						
							| 
									
										
										
										
											2021-12-21 16:10:02 +08:00
										 |  |  |  |             newUP.IsSelected = costControl.IsSelected; | 
					
						
							| 
									
										
										
										
											2023-05-26 10:24:02 +08:00
										 |  |  |  |             newUP.EquipmentMaterialTypeId = costControl.EquipmentMaterialTypeId; | 
					
						
							| 
									
										
										
										
											2021-08-13 11:15:59 +08:00
										 |  |  |  |             newUP.RealPrice = costControl.RealPrice; | 
					
						
							|  |  |  |  |             newUP.PlanPrice = costControl.PlanPrice; | 
					
						
							| 
									
										
										
										
											2022-06-14 18:21:58 +08:00
										 |  |  |  |             newUP.PlanStartDate = costControl.PlanStartDate; | 
					
						
							|  |  |  |  |             newUP.PlanEndDate = costControl.PlanEndDate; | 
					
						
							|  |  |  |  |             newUP.RealStartDate = costControl.RealStartDate; | 
					
						
							|  |  |  |  |             newUP.RealEndDate = costControl.RealEndDate; | 
					
						
							| 
									
										
										
										
											2021-08-13 11:15:59 +08:00
										 |  |  |  |             db.SubmitChanges(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 根据Id删除费控项信息 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="userId"></param> | 
					
						
							|  |  |  |  |         public static void DeleteCostControl(string costControlId) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             Model.SGGLDB db = Funs.DB; | 
					
						
							|  |  |  |  |             Model.WBS_CostControl CnP = db.WBS_CostControl.First(e => e.CostControlId.ToString() == costControlId); | 
					
						
							|  |  |  |  |             db.WBS_CostControl.DeleteOnSubmit(CnP); | 
					
						
							|  |  |  |  |             db.SubmitChanges(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 根据Id删除费控项信息 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="userId"></param> | 
					
						
							|  |  |  |  |         public static void DeleteCostControlByWbsSetId(string wbsSetId) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             Model.SGGLDB db = Funs.DB; | 
					
						
							|  |  |  |  |             var costControls = from x in db.WBS_CostControl where x.WbsSetId == wbsSetId select x; | 
					
						
							|  |  |  |  |             if (costControls.Count() > 0) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 foreach (var costControl in costControls) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     BLL.CostControlDetailHistoryService.DeleteCostControlDetailHistoryByCostControlId(costControl.CostControlId); | 
					
						
							|  |  |  |  |                     BLL.CostControlDetailService.DeleteCostControlDetailByCostControlId(costControl.CostControlId); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 db.WBS_CostControl.DeleteAllOnSubmit(costControls); | 
					
						
							|  |  |  |  |                 db.SubmitChanges(); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | } |