using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BLL
{
    /// 
    /// 全厂地下管网完成情况
    /// 
    public class UndergroundPipeCompletionService
    {
        public static Model.SGGLDB db = Funs.DB;
        /// 
        /// 根据主键获取全厂地下管网完成情况
        /// 
        /// 
        /// 
        public static Model.JDGL_UndergroundPipeCompletion GetUndergroundPipeCompletionById(string pipelineCompletionId)
        {
            return Funs.DB.JDGL_UndergroundPipeCompletion.FirstOrDefault(e => e.UndergroundPipeCompletionId == pipelineCompletionId);
        }
        /// 
        /// 添加全厂地下管网完成情况
        /// 
        /// 
        public static void AddUndergroundPipeCompletion(Model.JDGL_UndergroundPipeCompletion pipelineCompletion)
        {
            Model.SGGLDB db = Funs.DB;
            Model.JDGL_UndergroundPipeCompletion newUndergroundPipeCompletion = new Model.JDGL_UndergroundPipeCompletion
            {
                UndergroundPipeCompletionId = pipelineCompletion.UndergroundPipeCompletionId,
                ProjectId = pipelineCompletion.ProjectId,
                UnitId = pipelineCompletion.UnitId,
                TotalNum = pipelineCompletion.TotalNum,
                ThisNum = pipelineCompletion.ThisNum,
                CompileMan = pipelineCompletion.CompileMan,
                CompileDate = pipelineCompletion.CompileDate,
                StartDate = pipelineCompletion.StartDate,
                EndDate = pipelineCompletion.EndDate
            };
            db.JDGL_UndergroundPipeCompletion.InsertOnSubmit(newUndergroundPipeCompletion);
            db.SubmitChanges();
        }
        /// 
        /// 修改全厂地下管网完成情况
        /// 
        /// 
        public static void UpdateUndergroundPipeCompletion(Model.JDGL_UndergroundPipeCompletion pipelineCompletion)
        {
            Model.SGGLDB db = Funs.DB;
            Model.JDGL_UndergroundPipeCompletion newUndergroundPipeCompletion = db.JDGL_UndergroundPipeCompletion.FirstOrDefault(e => e.UndergroundPipeCompletionId == pipelineCompletion.UndergroundPipeCompletionId);
            if (newUndergroundPipeCompletion != null)
            {
                newUndergroundPipeCompletion.TotalNum = pipelineCompletion.TotalNum;
                newUndergroundPipeCompletion.ThisNum = pipelineCompletion.ThisNum;
                newUndergroundPipeCompletion.CompileMan = pipelineCompletion.CompileMan;
                newUndergroundPipeCompletion.CompileDate = pipelineCompletion.CompileDate;
                db.SubmitChanges();
            }
        }
        /// 
        /// 根据主键删除全厂地下管网完成情况
        /// 
        /// 
        public static void DeleteUndergroundPipeCompletionById(string pipelineCompletionId)
        {
            Model.SGGLDB db = Funs.DB;
            var pipelineCompletion = (from x in db.JDGL_UndergroundPipeCompletion where x.UndergroundPipeCompletionId == pipelineCompletionId select x).FirstOrDefault();
            if (pipelineCompletion != null)
            {
                db.JDGL_UndergroundPipeCompletion.DeleteOnSubmit(pipelineCompletion);
                db.SubmitChanges();
            }
        }
    }
}