129 lines
		
	
	
		
			4.5 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			129 lines
		
	
	
		
			4.5 KiB
		
	
	
	
		
			C#
		
	
	
	
| 
								 | 
							
								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;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 记录数
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        public static int count
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            get;
							 | 
						|||
| 
								 | 
							
								            set;
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 获取分页列表
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="projectId"></param>
							 | 
						|||
| 
								 | 
							
								        /// <param name="reportType"></param>
							 | 
						|||
| 
								 | 
							
								        /// <param name="startRowIndex"></param>
							 | 
						|||
| 
								 | 
							
								        /// <param name="maximumRows"></param>
							 | 
						|||
| 
								 | 
							
								        /// <returns></returns>
							 | 
						|||
| 
								 | 
							
								        public static IEnumerable GetListData(string projectId, string reportType, int startRowIndex, int maximumRows)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            IQueryable<Model.Report_WeekAndMonthReport> 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
							 | 
						|||
| 
								 | 
							
								                   };
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 获取分页列表数
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="projectId"></param>
							 | 
						|||
| 
								 | 
							
								        /// <param name="reportType"></param>
							 | 
						|||
| 
								 | 
							
								        /// <returns></returns>
							 | 
						|||
| 
								 | 
							
								        public static int GetListCount(string projectId, string reportType)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            return count;
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 根据主键获取周(月)报
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="reportId"></param>
							 | 
						|||
| 
								 | 
							
								        /// <returns></returns>
							 | 
						|||
| 
								 | 
							
								        public static Model.Report_WeekAndMonthReport GetWeekAndMonthReportById(string reportId)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            return Funs.DB.Report_WeekAndMonthReport.FirstOrDefault(e => e.ReportId == reportId);
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 添加周(月)报
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="report"></param>
							 | 
						|||
| 
								 | 
							
								        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();
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 修改周(月)报
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="report"></param>
							 | 
						|||
| 
								 | 
							
								        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();
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 根据主键删除周(月)报
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="reportId"></param>
							 | 
						|||
| 
								 | 
							
								        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();
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								}
							 |