using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BLL
{
    /// 
    /// 本周主要工作内容
    /// 
    public static class ThisWeekOrMonthContentService
    {
        public static Model.SGGLDB db = Funs.DB;
        /// 
        /// 根据主键获取本周主要工作内容
        /// 
        /// 
        /// 
        public static Model.Report_ThisWeekOrMonthContent GetThisWeekOrMonthContentById(string thisWeekOrMonthContentId)
        {
            return Funs.DB.Report_ThisWeekOrMonthContent.FirstOrDefault(e => e.ContentId == thisWeekOrMonthContentId);
        }
        /// 
        /// 根据周(月)报表Id获取相关本周主要工作内容
        /// 
        /// 
        /// 
        public static List GetThisWeekOrMonthContentByReportId(string reportId)
        {
            return (from x in Funs.DB.Report_ThisWeekOrMonthContent where x.ReportId == reportId select x).ToList();
        }
        /// 
        /// 添加本周主要工作内容
        /// 
        /// 
        public static void AddThisWeekOrMonthContent(Model.Report_ThisWeekOrMonthContent thisWeekOrMonthContent)
        {
            Model.SGGLDB db = Funs.DB;
            Model.Report_ThisWeekOrMonthContent newThisWeekOrMonthContent = new Model.Report_ThisWeekOrMonthContent();
            newThisWeekOrMonthContent.ContentId = thisWeekOrMonthContent.ContentId;
            newThisWeekOrMonthContent.ReportId = thisWeekOrMonthContent.ReportId;
            newThisWeekOrMonthContent.Contents = thisWeekOrMonthContent.Contents;
            db.Report_ThisWeekOrMonthContent.InsertOnSubmit(newThisWeekOrMonthContent);
            db.SubmitChanges();
        }
        /// 
        /// 根据周(月)报Id删除所有相关本周主要工作内容
        /// 
        /// 
        public static void DeleteThisWeekOrMonthContentByReportId(string reportId)
        {
            Model.SGGLDB db = Funs.DB;
            var q = (from x in db.Report_ThisWeekOrMonthContent where x.ReportId == reportId select x).ToList();
            if (q.Count() > 0)
            {
                db.Report_ThisWeekOrMonthContent.DeleteAllOnSubmit(q);
                db.SubmitChanges();
            }
        }
    }
}