using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BLL
{
    /// 
    /// 
    /// 
    public static class UrgeReportService
    {
        /// 
        /// 更新催报完成
        /// 
        /// 
        /// 
        /// 
        /// 
        public static void SetComplete(string unitId, string reportType, string year, string value)
        {
            Model.Information_UrgeReport urgeReport = new Model.Information_UrgeReport();
            if (reportType == Const.ReportType_1 || reportType == Const.ReportType_2 || reportType == Const.ReportType_8)
            {
                urgeReport = Funs.DB.Information_UrgeReport.FirstOrDefault(x => x.UnitId == unitId && x.ReprotType == reportType && x.YearId == year && x.MonthId == value);
            }
            else if (reportType == Const.ReportType_3 || reportType == Const.ReportType_4 || reportType == Const.ReportType_9)
            {
                urgeReport = Funs.DB.Information_UrgeReport.FirstOrDefault(x => x.UnitId == unitId && x.ReprotType == reportType && x.YearId == year && x.QuarterId == value);
            }
            else if (reportType == Const.ReportType_5)
            {
                urgeReport = Funs.DB.Information_UrgeReport.FirstOrDefault(x => x.UnitId == unitId && x.ReprotType == reportType && x.YearId == year && x.HalfYearId == value);
            }
            else if (reportType == Const.ReportType_6 || reportType == Const.ReportType_7 || reportType == Const.ReportType_10)
            {
                urgeReport = Funs.DB.Information_UrgeReport.FirstOrDefault(x => x.UnitId == unitId && x.ReprotType == reportType && x.YearId == year);
            }
            if (urgeReport != null)
            {
                urgeReport.IsComplete = true;
                Funs.DB.SubmitChanges();
            }
        }
    }
}