using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BLL
{
    public static class ReportRemindService
    {
        /// 
        /// 根据月份获取报告信息
        /// 
        /// 
        /// 
        public static Model.ManagementReport_ReportRemind GetReportRemindByReportRemindId(string reportRemindId)
        {
            return (from x in Funs.DB.ManagementReport_ReportRemind where x.ReportRemindId == reportRemindId select x).FirstOrDefault();
        }
        /// 
        /// 添加报表上报情况
        /// 
        /// 
        public static void AddReportRemind(Model.ManagementReport_ReportRemind reportRemind)
        {
            Model.ManagementReport_ReportRemind newReportRemind = new Model.ManagementReport_ReportRemind
            {
                ReportRemindId = SQLHelper.GetNewID(typeof(Model.ManagementReport_ReportRemind)),
                ProjectId = reportRemind.ProjectId,
                Months = reportRemind.Months,
                Year = reportRemind.Year,
                Month = reportRemind.Month,
                Quarterly = reportRemind.Quarterly,
                HalfYear = reportRemind.HalfYear,
                ReportName = reportRemind.ReportName,
                CompileDate = reportRemind.CompileDate
            };
            Funs.DB.ManagementReport_ReportRemind.InsertOnSubmit(newReportRemind);
            Funs.DB.SubmitChanges();
        }
        /// 
        /// 根据月报Id删除报表上报情况
        /// 
        /// 
        public static void DeleteReportRemindByReportRemind(Model.ManagementReport_ReportRemind reportRemind)
        {
            if (reportRemind != null)
            {
                Funs.DB.ManagementReport_ReportRemind.DeleteOnSubmit(reportRemind);
                Funs.DB.SubmitChanges();
            }
        }
        /// 
        /// 根据项目Id删除报表上报情况
        /// 
        /// 
        public static void DeleteReportRemindByProjectId(string projectId)
        {
            var report = from x in Funs.DB.ManagementReport_ReportRemind where x.ProjectId == projectId select x;
            if (report.Count() > 0)
            {
                Funs.DB.ManagementReport_ReportRemind.DeleteAllOnSubmit(report);
                Funs.DB.SubmitChanges();
            }
        }
    }
}