using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BLL
{
    /// <summary>
    /// 安全管理工作总结报告
    /// </summary>
    public static class ProjectWorkSummaryReportService
    {
        /// <summary>
        /// 根据主键获取安全管理工作总结报告
        /// </summary>
        /// <param name="workSummaryReportId"></param>
        /// <returns></returns>
        public static Model.InformationProject_WorkSummaryReport GetWorkSummaryReportById(string workSummaryReportId)
        {
            return Funs.DB.InformationProject_WorkSummaryReport.FirstOrDefault(e => e.WorkSummaryReportId == workSummaryReportId);
        }

        /// <summary>
        /// 添加安全管理工作总结报告
        /// </summary>
        /// <param name="workSummaryReport"></param>
        public static void AddWorkSummaryReport(Model.InformationProject_WorkSummaryReport workSummaryReport)
        {
            Model.InformationProject_WorkSummaryReport newWorkSummaryReport = new Model.InformationProject_WorkSummaryReport
            {
                WorkSummaryReportId = workSummaryReport.WorkSummaryReportId,
                ProjectId=workSummaryReport.ProjectId,
                YearId = workSummaryReport.YearId,
                UnitId = workSummaryReport.UnitId,
                ResponsiblePerson = workSummaryReport.ResponsiblePerson,
                ResponsiblePersonTel = workSummaryReport.ResponsiblePersonTel,
                ContactPerson = workSummaryReport.ContactPerson,
                ContactPersonTel = workSummaryReport.ContactPersonTel,
                ReportDate = workSummaryReport.ReportDate,
                SafeLaborTime = workSummaryReport.SafeLaborTime,
                SafetyObjectives = workSummaryReport.SafetyObjectives,
                AccidentSituation = workSummaryReport.AccidentSituation,
                Awards = workSummaryReport.Awards,
                WorkDevelopment = workSummaryReport.WorkDevelopment,
                PersonnelTraining = workSummaryReport.PersonnelTraining,
                GovernanceSituation = workSummaryReport.GovernanceSituation,
                ManagementActivity = workSummaryReport.ManagementActivity,
                WorkExperience = workSummaryReport.WorkExperience,
                Countermeasures = workSummaryReport.Countermeasures,
                NextYearWorkPlan = workSummaryReport.NextYearWorkPlan,
                JobSuggestion = workSummaryReport.JobSuggestion,
                CompileMan=workSummaryReport.CompileMan,
                CompileDate=workSummaryReport.CompileDate
            };
            Funs.DB.InformationProject_WorkSummaryReport.InsertOnSubmit(newWorkSummaryReport);
            Funs.DB.SubmitChanges();
        }

        /// <summary>
        /// 修改安全管理工作总结报告
        /// </summary>
        /// <param name="workSummaryReport"></param>
        public static void UpdateWorkSummaryReport(Model.InformationProject_WorkSummaryReport workSummaryReport)
        {
            Model.InformationProject_WorkSummaryReport newWorkSummaryReport = Funs.DB.InformationProject_WorkSummaryReport.FirstOrDefault(e => e.WorkSummaryReportId == workSummaryReport.WorkSummaryReportId);
            if (newWorkSummaryReport != null)
            {
                newWorkSummaryReport.UnitId = workSummaryReport.UnitId;
                newWorkSummaryReport.YearId = workSummaryReport.YearId;
                newWorkSummaryReport.ResponsiblePerson = workSummaryReport.ResponsiblePerson;
                newWorkSummaryReport.ResponsiblePersonTel = workSummaryReport.ResponsiblePersonTel;
                newWorkSummaryReport.ContactPerson = workSummaryReport.ContactPerson;
                newWorkSummaryReport.ContactPersonTel = workSummaryReport.ContactPersonTel;
                newWorkSummaryReport.ReportDate = workSummaryReport.ReportDate;
                newWorkSummaryReport.SafeLaborTime = workSummaryReport.SafeLaborTime;
                newWorkSummaryReport.SafetyObjectives = workSummaryReport.SafetyObjectives;
                newWorkSummaryReport.AccidentSituation = workSummaryReport.AccidentSituation;
                newWorkSummaryReport.Awards = workSummaryReport.Awards;
                newWorkSummaryReport.WorkDevelopment = workSummaryReport.WorkDevelopment;
                newWorkSummaryReport.PersonnelTraining = workSummaryReport.PersonnelTraining;
                newWorkSummaryReport.GovernanceSituation = workSummaryReport.GovernanceSituation;
                newWorkSummaryReport.ManagementActivity = workSummaryReport.ManagementActivity;
                newWorkSummaryReport.WorkExperience = workSummaryReport.WorkExperience;
                newWorkSummaryReport.Countermeasures = workSummaryReport.Countermeasures;
                newWorkSummaryReport.NextYearWorkPlan = workSummaryReport.NextYearWorkPlan;
                newWorkSummaryReport.JobSuggestion = workSummaryReport.JobSuggestion;
                newWorkSummaryReport.CompileMan = workSummaryReport.CompileMan;
                newWorkSummaryReport.CompileDate = workSummaryReport.CompileDate;

                Funs.DB.SubmitChanges();
            }
        }

        /// <summary>
        /// 根据主键删除安全管理工作总结报告
        /// </summary>
        /// <param name="workSummaryReportId"></param>
        public static void DeleteWorkSummaryReportById(string workSummaryReportId)
        {
            Model.InformationProject_WorkSummaryReport workSummaryReport = Funs.DB.InformationProject_WorkSummaryReport.FirstOrDefault(e => e.WorkSummaryReportId == workSummaryReportId);
            if (workSummaryReport != null)
            {
                Funs.DB.InformationProject_WorkSummaryReport.DeleteOnSubmit(workSummaryReport);
                Funs.DB.SubmitChanges();
            }
        }
    }
}