using System.Collections.Generic; using System.Linq; namespace BLL { public class CostReportService { /// /// 根据主键获取成本信息 /// /// /// public static Model.Editor_CostReport GetCostReportById(string costReportId) { return Funs.DB.Editor_CostReport.FirstOrDefault(e => e.CostReportId == costReportId); } /// /// 根据项目号和月份获取成本信息 /// /// /// /// public static Model.Editor_CostReport GetCostReportByEProjectIdAndMonth(string eProjectId, string month) { return Funs.DB.Editor_CostReport.FirstOrDefault(e => e.EProjectId == eProjectId && e.Monthly == month); } /// /// 根据项目Id获取成本信息 /// /// /// public static List GetCostReportByEProjectId(string eProjectId) { return (from x in Funs.DB.Editor_CostReport where x.EProjectId == eProjectId select x).ToList(); } /// /// 批量增加 /// /// public static void AddCostReport(Model.Editor_CostReport costReport) { Model.Editor_CostReport newCostReport = new Model.Editor_CostReport(); newCostReport.CostReportId = costReport.CostReportId; newCostReport.EProjectId = costReport.EProjectId; newCostReport.Monthly = costReport.Monthly; newCostReport.OrginalBudget = costReport.OrginalBudget; newCostReport.ChangedBudget = costReport.ChangedBudget; newCostReport.ActualCost = costReport.ActualCost; newCostReport.CommittedPRPO = costReport.CommittedPRPO; newCostReport.CommittedSSRs = costReport.CommittedSSRs; newCostReport.CostToComplete = costReport.CostToComplete; Funs.DB.Editor_CostReport.InsertOnSubmit(costReport); Funs.DB.SubmitChanges(); } /// /// 修改 /// /// public static void UpdateCostReport(Model.Editor_CostReport costReport) { Model.Editor_CostReport newCostReport = Funs.DB.Editor_CostReport.FirstOrDefault(e => e.CostReportId == costReport.CostReportId); if (newCostReport != null) { newCostReport.Monthly = costReport.Monthly; newCostReport.OrginalBudget = costReport.OrginalBudget; newCostReport.ChangedBudget = costReport.ChangedBudget; newCostReport.ActualCost = costReport.ActualCost; newCostReport.CommittedPRPO = costReport.CommittedPRPO; newCostReport.CommittedSSRs = costReport.CommittedSSRs; newCostReport.CostToComplete = costReport.CostToComplete; Funs.DB.SubmitChanges(); } } /// /// 根据主键删除成本信息 /// /// public static void DeleteCostReportById(string costReportId) { Model.Editor_CostReport costReport = Funs.DB.Editor_CostReport.FirstOrDefault(e => e.CostReportId == costReportId); if (costReport != null) { Funs.DB.Editor_CostReport.DeleteOnSubmit(costReport); Funs.DB.SubmitChanges(); } } /// /// 根据项目Id删除成本信息 /// /// public static void DeleteCostReportByEProjectId(string eProjectId) { var q = (from x in Funs.DB.Editor_CostReport where x.EProjectId == eProjectId select x).ToList(); if (q != null) { Funs.DB.Editor_CostReport.DeleteAllOnSubmit(q); Funs.DB.SubmitChanges(); } } /// /// 根据项目Id获取最新的成本 /// /// /// public static Model.Editor_CostReport GetMaxMonthCostReportByEprojectId(string eprojectId) { return (from x in Funs.DB.Editor_CostReport where x.EProjectId == eprojectId orderby x.Monthly descending select x).FirstOrDefault(); } } }