Basf_EProject/EProject/BLL/EditorManage/CostReportService.cs

118 lines
4.6 KiB
C#

using System.Collections.Generic;
using System.Linq;
namespace BLL
{
public class CostReportService
{
/// <summary>
/// 根据主键获取成本信息
/// </summary>
/// <param name="costReportId"></param>
/// <returns></returns>
public static Model.Editor_CostReport GetCostReportById(string costReportId)
{
return Funs.DB.Editor_CostReport.FirstOrDefault(e => e.CostReportId == costReportId);
}
/// <summary>
/// 根据项目号和月份获取成本信息
/// </summary>
/// <param name="eProjectId"></param>
/// <param name="month"></param>
/// <returns></returns>
public static Model.Editor_CostReport GetCostReportByEProjectIdAndMonth(string eProjectId, string month)
{
return Funs.DB.Editor_CostReport.FirstOrDefault(e => e.EProjectId == eProjectId && e.Monthly == month);
}
/// <summary>
/// 根据项目Id获取成本信息
/// </summary>
/// <param name="eProjectId"></param>
/// <returns></returns>
public static List<Model.Editor_CostReport> GetCostReportByEProjectId(string eProjectId)
{
return (from x in Funs.DB.Editor_CostReport where x.EProjectId == eProjectId select x).ToList();
}
/// <summary>
/// 批量增加
/// </summary>
/// <param name="model"></param>
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();
}
/// <summary>
/// 修改
/// </summary>
/// <param name="costReport"></param>
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();
}
}
/// <summary>
/// 根据主键删除成本信息
/// </summary>
/// <param name="costReportId"></param>
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();
}
}
/// <summary>
/// 根据项目Id删除成本信息
/// </summary>
/// <param name="eProjectId"></param>
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();
}
}
/// <summary>
/// 根据项目Id获取最新的成本
/// </summary>
/// <param name="eprojectId"></param>
/// <returns></returns>
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();
}
}
}