using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections; namespace BLL { public static class WeekAndMonthReportService { public static Model.SGGLDB db = Funs.DB; /// /// 记录数 /// public static int count { get; set; } /// /// 获取分页列表 /// /// /// /// /// /// public static IEnumerable GetListData(string projectId, string reportType, int startRowIndex, int maximumRows) { IQueryable q = from x in db.Report_WeekAndMonthReport where x.ProjectId == projectId && x.ReportType == reportType orderby x.StartDate descending select x; count = q.Count(); if (count == 0) { return new object[] { }; } return from x in q.Skip(startRowIndex).Take(maximumRows) select new { x.ReportId, Period = ("第 " + x.Period + " 期"), x.StartDate, x.EndDate, x.ProjectId, x.ReportType }; } /// /// 获取分页列表数 /// /// /// /// public static int GetListCount(string projectId, string reportType) { return count; } /// /// 根据主键获取周(月)报 /// /// /// public static Model.Report_WeekAndMonthReport GetWeekAndMonthReportById(string reportId) { return Funs.DB.Report_WeekAndMonthReport.FirstOrDefault(e => e.ReportId == reportId); } /// /// 添加周(月)报 /// /// public static void AddWeekAndMonthReport(Model.Report_WeekAndMonthReport report) { Model.SGGLDB db = Funs.DB; Model.Report_WeekAndMonthReport newReport = new Model.Report_WeekAndMonthReport(); newReport.ReportId = report.ReportId; newReport.Period = report.Period; newReport.StartDate = report.StartDate; newReport.EndDate = report.EndDate; newReport.ProjectId = report.ProjectId; newReport.ReportType = report.ReportType; db.Report_WeekAndMonthReport.InsertOnSubmit(newReport); db.SubmitChanges(); } /// /// 修改周(月)报 /// /// public static void UpdateWeekAndMonthReport(Model.Report_WeekAndMonthReport report) { Model.SGGLDB db = Funs.DB; Model.Report_WeekAndMonthReport newReport = db.Report_WeekAndMonthReport.FirstOrDefault(e => e.ReportId == report.ReportId); if (newReport != null) { newReport.Period = report.Period; newReport.StartDate = report.StartDate; newReport.EndDate = report.EndDate; newReport.ProjectId = report.ProjectId; newReport.ReportType = report.ReportType; db.SubmitChanges(); } } /// /// 根据主键删除周(月)报 /// /// public static void DeleteWeekAndMonthReportById(string reportId) { Model.SGGLDB db = Funs.DB; Model.Report_WeekAndMonthReport report = db.Report_WeekAndMonthReport.FirstOrDefault(e => e.ReportId == reportId); if (report != null) { db.Report_WeekAndMonthReport.DeleteOnSubmit(report); db.SubmitChanges(); } } } }