using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BLL
{
    public class RotatingEquipmentService
    {
        /// 
        /// 根据主键获取设备材料报验信息
        /// 
        /// 
        /// 
        public static Model.Transfer_RotatingEquipment GetRotatingEquipmentById(string Id)
        {
            return Funs.DB.Transfer_RotatingEquipment.FirstOrDefault(e => e.Id == Id);
        }
        /// 
        /// 添加设备材料报验
        /// 
        /// 
        public static void AddRotatingEquipment(Model.Transfer_RotatingEquipment RotatingEquipment)
        {
            Model.SGGLDB db = Funs.DB;
            Model.Transfer_RotatingEquipment newRotatingEquipment = new Model.Transfer_RotatingEquipment();
            newRotatingEquipment.Id = RotatingEquipment.Id;
            newRotatingEquipment.ProjectId = RotatingEquipment.ProjectId;
            newRotatingEquipment.RotatingEquipment = RotatingEquipment.RotatingEquipment;
            newRotatingEquipment.SYSTEM = RotatingEquipment.SYSTEM;
            newRotatingEquipment.Subsystem = RotatingEquipment.Subsystem;
            newRotatingEquipment.TestPackage = RotatingEquipment.TestPackage;
            newRotatingEquipment.TestPackageSTART = RotatingEquipment.TestPackageSTART;
            newRotatingEquipment.TestPackageFINISH = RotatingEquipment.TestPackageFINISH;
            newRotatingEquipment.MechanicalFINALStatus = RotatingEquipment.MechanicalFINALStatus;
            db.Transfer_RotatingEquipment.InsertOnSubmit(newRotatingEquipment);
            db.SubmitChanges();
        }
        /// 
        /// 修改设备材料报验
        /// 
        /// 
        public static void UpdateRotatingEquipment(Model.Transfer_RotatingEquipment RotatingEquipment)
        {
            Model.SGGLDB db = Funs.DB;
            Model.Transfer_RotatingEquipment newRotatingEquipment = db.Transfer_RotatingEquipment.FirstOrDefault(e => e.Id == RotatingEquipment.Id);
            if (newRotatingEquipment != null)
            {
                newRotatingEquipment.ProjectId = RotatingEquipment.ProjectId;
                newRotatingEquipment.RotatingEquipment = RotatingEquipment.RotatingEquipment;
                newRotatingEquipment.SYSTEM = RotatingEquipment.SYSTEM;
                newRotatingEquipment.Subsystem = RotatingEquipment.Subsystem;
                newRotatingEquipment.TestPackage = RotatingEquipment.TestPackage;
                newRotatingEquipment.TestPackageSTART = RotatingEquipment.TestPackageSTART;
                newRotatingEquipment.TestPackageFINISH = RotatingEquipment.TestPackageFINISH;
                newRotatingEquipment.MechanicalFINALStatus = RotatingEquipment.MechanicalFINALStatus;
                db.SubmitChanges();
            }
        }
        /// 
        /// 根据主键删除设备材料报验
        /// 
        /// 
        public static void DeleteRotatingEquipment(string Id)
        {
            Model.SGGLDB db = Funs.DB;
            Model.Transfer_RotatingEquipment RotatingEquipment = db.Transfer_RotatingEquipment.FirstOrDefault(e => e.Id == Id);
            if (RotatingEquipment != null)
            {
                db.Transfer_RotatingEquipment.DeleteOnSubmit(RotatingEquipment);
                db.SubmitChanges();
            }
        }
    }
}