using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections; namespace BLL { public class HeadMonthReportBService { public static Model.SGGLDB db = Funs.DB; /// /// 根据安全统计主键获取安全统计信息 /// /// 安全统计主键 /// 安全统计信息 public static Model.Manager_HeadMonthReportB GetHeadMonthReportByHeadMonthReportId(string headMonthReportId) { return Funs.DB.Manager_HeadMonthReportB.FirstOrDefault(x => x.HeadMonthReportId == headMonthReportId); } /// /// 根据安全统计编号获取安全统计信息 /// /// 安全统计编号 /// 安全统计信息 public static Model.Manager_HeadMonthReportB GetHeadMonthReportByMonthReportCode(string monthReportCode) { return Funs.DB.Manager_HeadMonthReportB.FirstOrDefault(x => x.MonthReportCode == monthReportCode); } public static int GetHeadMonthReportCount() { return (from x in Funs.DB.Manager_HeadMonthReportB orderby x.MonthReportCode select x).Count(); } /// /// 根据日期获取安全统计信息 /// /// 日期 /// public static Model.Manager_HeadMonthReportB GetHeadMonthReportByMonths(DateTime months) { return Funs.DB.Manager_HeadMonthReportB.FirstOrDefault(x => x.Months == months); } /// /// 获取最近时间的一条安全统计信息 /// /// public static Model.Manager_HeadMonthReportB GetLastHeadMonthReport() { return (from x in Funs.DB.Manager_HeadMonthReportB orderby x.Months descending select x).FirstOrDefault(); } /// /// 获取早于当前时间的最近时间的一条安全统计信息 /// /// public static Model.Manager_HeadMonthReportB GetLastHeadMonthReportByMonths(DateTime months) { return (from x in Funs.DB.Manager_HeadMonthReportB where x.Months < months orderby x.Months descending select x).FirstOrDefault(); } /// /// 增加安全统计信息 /// /// 安全统计实体 public static void AddHeadMonthReport(Model.Manager_HeadMonthReportB headMonthReport) { Model.SGGLDB db = Funs.DB; string newKeyID = SQLHelper.GetNewID(typeof(Model.Manager_HeadMonthReportB)); Model.Manager_HeadMonthReportB newHeadMonthReport = new Model.Manager_HeadMonthReportB { HeadMonthReportId = headMonthReport.HeadMonthReportId, MonthReportCode = headMonthReport.MonthReportCode, Months = headMonthReport.Months, ReportUnitName = headMonthReport.ReportUnitName, ReportDate = headMonthReport.ReportDate, ReportMan = headMonthReport.ReportMan, CheckMan = headMonthReport.CheckMan, AllSumHseManhours = headMonthReport.AllSumHseManhours, AllSumTotalHseManhours = headMonthReport.AllSumTotalHseManhours }; db.Manager_HeadMonthReportB.InsertOnSubmit(newHeadMonthReport); db.SubmitChanges(); } /// /// 修改安全统计信息 /// /// 安全统计实体 public static void UpdateHeadMonthReport(Model.Manager_HeadMonthReportB headMonthReport) { Model.SGGLDB db = Funs.DB; Model.Manager_HeadMonthReportB newHeadMonthReport = db.Manager_HeadMonthReportB.First(e => e.HeadMonthReportId == headMonthReport.HeadMonthReportId); newHeadMonthReport.MonthReportCode = headMonthReport.MonthReportCode; newHeadMonthReport.Months = headMonthReport.Months; newHeadMonthReport.ReportUnitName = headMonthReport.ReportUnitName; newHeadMonthReport.ReportDate = headMonthReport.ReportDate; newHeadMonthReport.ReportMan = headMonthReport.ReportMan; newHeadMonthReport.CheckMan = headMonthReport.CheckMan; newHeadMonthReport.AllSumHseManhours = headMonthReport.AllSumHseManhours; newHeadMonthReport.AllSumTotalHseManhours = headMonthReport.AllSumTotalHseManhours; db.SubmitChanges(); } /// /// 根据安全统计主键删除一个安全统计信息 /// /// 安全统计主键 public static void DeleteHeadMonthReportByHeadMonthReportId(string headMonthReportId) { Model.SGGLDB db = Funs.DB; Model.Manager_HeadMonthReportB headMonthReport = db.Manager_HeadMonthReportB.First(e => e.HeadMonthReportId == headMonthReportId); db.Manager_HeadMonthReportB.DeleteOnSubmit(headMonthReport); db.SubmitChanges(); } } }