using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace BLL { public class IncentiveSortBService { public static Model.SGGLDB db = Funs.DB; public static Model.Manager_IncentiveSortB GetIncentiveSortByMonthReportIdAndIncentiveType(string monthReportId, string incentiveType) { return (from x in Funs.DB.Manager_IncentiveSortB where x.MonthReportId == monthReportId && x.IncentiveType == incentiveType select x).FirstOrDefault(); } /// /// 根据月报告主键获取所有月报告HSE奖惩情况信息 /// /// 月报告主键 /// public static List GetIncentiveSortsByMonthReportId(string monthReportId) { return (from x in Funs.DB.Manager_IncentiveSortB where x.MonthReportId == monthReportId select x).ToList(); } /// /// 根据月报告主键获取总奖惩金额 /// /// 奖惩类型 /// 月报告主键 /// public static decimal? GetSumIncentiveMoneyByMonthReportId(string monthReportId, string incentiveType) { return (from x in Funs.DB.Manager_IncentiveSortB where x.MonthReportId == monthReportId && x.IncentiveType == incentiveType select x.IncentiveMoney).Sum(); } /// /// 根据月报告主键获取总奖惩次数 /// /// 奖惩类型 /// 月报告主键 /// public static int? GetSumIncentiveNumberByMonthReportId(string monthReportId, string incentiveType) { return (from x in Funs.DB.Manager_IncentiveSortB where x.MonthReportId == monthReportId && x.IncentiveType == incentiveType select x.TotalIncentiveNumber).FirstOrDefault(); } /// /// 增加月报告HSE奖惩情况信息 /// /// 月报告HSE奖惩情况实体 public static void AddIncentiveSort(Model.Manager_IncentiveSortB incentiveSort) { Model.SGGLDB db = Funs.DB; string newKeyID = SQLHelper.GetNewID(typeof(Model.Manager_IncentiveSortB)); Model.Manager_IncentiveSortB newIncentiveSort = new Model.Manager_IncentiveSortB { IncentiveSortId = newKeyID, MonthReportId = incentiveSort.MonthReportId, IncentiveType = incentiveSort.IncentiveType, BigType = incentiveSort.BigType, TypeFlag = incentiveSort.TypeFlag, IncentiveMoney = incentiveSort.IncentiveMoney, TotalIncentiveMoney = incentiveSort.TotalIncentiveMoney, IncentiveNumber = incentiveSort.IncentiveNumber, TotalIncentiveNumber = incentiveSort.TotalIncentiveNumber }; db.Manager_IncentiveSortB.InsertOnSubmit(newIncentiveSort); db.SubmitChanges(); } /// /// 根据月报告主键删除对应的所有月报告HSE奖惩情况信息 /// /// 月报告主键 public static void DeleteIncentiveSortsByMonthReportId(string monthReportId) { var q = (from x in db.Manager_IncentiveSortB where x.MonthReportId == monthReportId select x).ToList(); db.Manager_IncentiveSortB.DeleteAllOnSubmit(q); db.SubmitChanges(); } } }