using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BLL
{
    public class OtherWorkCService
    {
        private static Model.SGGLDB db = Funs.DB;
        /// 
        /// 根据月报ID获取其他工作情况列表
        /// 
        /// 
        /// 
        public static List GetOtherWorkByMonthReportId(string monthReportId)
        {
            return (from x in Funs.DB.Manager_Month_OtherWorkC where x.MonthReportId == monthReportId orderby x.SortIndex select x).ToList();
        }
        /// 
        /// 添加其他工作情况
        /// 
        /// 
        public static void AddOtherWork(Model.Manager_Month_OtherWorkC otherWork)
        {
            Model.SGGLDB db = Funs.DB;
            Model.Manager_Month_OtherWorkC newOtherWork = new Model.Manager_Month_OtherWorkC
            {
                OtherWorkId = SQLHelper.GetNewID(typeof(Model.Manager_Month_OtherWorkC)),
                MonthReportId = otherWork.MonthReportId,
                WorkContentDes = otherWork.WorkContentDes,
                SortIndex = otherWork.SortIndex
            };
            db.Manager_Month_OtherWorkC.InsertOnSubmit(newOtherWork);
            db.SubmitChanges();
        }
        /// 
        /// 根据月报Id删除所有相关的其他工作情况
        /// 
        /// 
        public static void DeleteOtherWorkByMonthReportId(string monthReportId)
        {
            Model.SGGLDB db = Funs.DB;
            var q = (from x in db.Manager_Month_OtherWorkC where x.MonthReportId == monthReportId select x).ToList();
            if (q != null)
            {
                db.Manager_Month_OtherWorkC.DeleteAllOnSubmit(q);
                db.SubmitChanges();
            }
        }
    }
}