using System.Linq;
namespace BLL
{
    /// 
    /// 热处理报告
    /// 
    public static class HotProessReportService
    {
        /// 
        /// 根据主键获取热处理报告
        /// 
        /// 
        /// 
        public static Model.HotProess_Report GetHotProessReportById(string hotProessReportId)
        {
            return Funs.DB.HotProess_Report.FirstOrDefault(e => e.HotProessReportId == hotProessReportId);
        }
        /// 
        /// 添加热处理报告
        /// 
        /// 
        public static void AddHotProessReport(Model.HotProess_Report hotProessReport)
        {
            Model.HJGLDB db = Funs.DB;
            Model.HotProess_Report newHotProessReport = new Model.HotProess_Report();
            newHotProessReport.HotProessReportId = hotProessReport.HotProessReportId;
            newHotProessReport.HotProessTrustItemId = hotProessReport.HotProessTrustItemId;
            newHotProessReport.WeldJointId = hotProessReport.WeldJointId;
            newHotProessReport.PointCount = hotProessReport.PointCount;
            newHotProessReport.RequiredT = hotProessReport.RequiredT;
            newHotProessReport.ActualT = hotProessReport.ActualT;
            newHotProessReport.RequestTime = hotProessReport.RequestTime;
            newHotProessReport.ActualTime = hotProessReport.ActualTime;
            newHotProessReport.RecordChartNo = hotProessReport.RecordChartNo;
            db.HotProess_Report.InsertOnSubmit(newHotProessReport);
            db.SubmitChanges();
        }
        /// 
        /// 修改热处理报告
        /// 
        /// 
        public static void UpdateHotProessReport(Model.HotProess_Report hotProessReport)
        {
            Model.HJGLDB db = Funs.DB;
            Model.HotProess_Report newHotProessReport = db.HotProess_Report.FirstOrDefault(e => e.HotProessReportId == hotProessReport.HotProessReportId);
            if (newHotProessReport != null)
            {
                newHotProessReport.PointCount = hotProessReport.PointCount;
                newHotProessReport.RequiredT = hotProessReport.RequiredT;
                newHotProessReport.ActualT = hotProessReport.ActualT;
                newHotProessReport.RequestTime = hotProessReport.RequestTime;
                newHotProessReport.ActualTime = hotProessReport.ActualTime;
                newHotProessReport.RecordChartNo = hotProessReport.RecordChartNo;
                db.SubmitChanges();
            }
        }
        /// 
        /// 根据主键删除热处理报告
        /// 
        /// 
        public static void DeleteHotProessReportById(string hotProessReportId)
        {
            Model.HJGLDB db = Funs.DB;
            Model.HotProess_Report hotProessReport = db.HotProess_Report.FirstOrDefault(e => e.HotProessReportId == hotProessReportId);
            if (hotProessReport != null)
            {
                db.HotProess_Report.DeleteOnSubmit(hotProessReport);
                db.SubmitChanges();
            }
        }
    }
}