using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BLL
{
    public class DriverPrepareDutyService
    {
        /// 
        /// 增加--开车资料收集
        /// 
        public static void AddDriverPrepareDriverPlan(Model.DriverPrepare_Duty DriverPrepareDriverPlan)
        {
            using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
            {
                Model.DriverPrepare_Duty newDriverData = new Model.DriverPrepare_Duty();
                newDriverData.DutyId = DriverPrepareDriverPlan.DutyId;
                newDriverData.ProjectId = DriverPrepareDriverPlan.ProjectId;
                newDriverData.DutyName = DriverPrepareDriverPlan.DutyName;
                newDriverData.DutyCode = DriverPrepareDriverPlan.DutyCode;
                newDriverData.CompileMan = DriverPrepareDriverPlan.CompileMan;
                newDriverData.CompileDate = DriverPrepareDriverPlan.CompileDate;
                newDriverData.AttchUrl = DriverPrepareDriverPlan.AttchUrl;
                newDriverData.Remark = DriverPrepareDriverPlan.Remark;
                db.DriverPrepare_Duty.InsertOnSubmit(newDriverData);
                db.SubmitChanges();
            }
        }
        /// 
        /// 修改--开车资料收集
        /// 
        public static void UpdateDriverPrepareDriverPlan(Model.DriverPrepare_Duty DriverPrepareDriverPlan)
        {
            using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
            {
                Model.DriverPrepare_Duty newDriverData = db.DriverPrepare_Duty.FirstOrDefault(e => e.DutyId == DriverPrepareDriverPlan.DutyId);
                if (newDriverData != null)
                {
                    newDriverData.ProjectId = DriverPrepareDriverPlan.ProjectId;
                    newDriverData.DutyName = DriverPrepareDriverPlan.DutyName;
                    newDriverData.DutyCode = DriverPrepareDriverPlan.DutyCode;
                    newDriverData.CompileMan = DriverPrepareDriverPlan.CompileMan;
                    newDriverData.CompileDate = DriverPrepareDriverPlan.CompileDate;
                    newDriverData.AttchUrl = DriverPrepareDriverPlan.AttchUrl;
                    newDriverData.Remark = DriverPrepareDriverPlan.Remark;
                }
                db.SubmitChanges();
            }
        }
        /// 
        /// 根据主键删除 开车资料收集
        /// 
        /// 
        public static void DeleteDriverPrepareDuty(string DutyId)
        {
            using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
            {
                Model.DriverPrepare_Duty newDriverData = db.DriverPrepare_Duty.FirstOrDefault(e => e.DutyId == DutyId);
                if (newDriverData != null)
                {
                    db.DriverPrepare_Duty.DeleteOnSubmit(newDriverData);
                    db.SubmitChanges();
                }
            }
        }
        /// 
        /// 详情--开车资料收集
        /// 
        public static Model.DriverPrepare_Duty GetDriverPlanById(string DutyId)
        {
            return Funs.DB.DriverPrepare_Duty.FirstOrDefault(e => e.DutyId == DutyId);
        }
    }
    
}