ZHJA_HJGL/HJGL_ZH/BLL/HJGL/HotHardManage/HJGL_CH_HardTestResultServi...

114 lines
4.6 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Web.UI.WebControls;
namespace BLL
{
public class HJGL_CH_HardTestResultService
{
/// <summary>
/// 根据硬度检验Id获取用于硬度检验结果反馈
/// </summary>
/// <param name="jot_id"></param>
/// <returns></returns>
public static Model.HJGL_CH_HardTestResult GetHardTestResultByID(string HardTestResultId)
{
Model.SGGLDB db = Funs.DB;
var view = db.HJGL_CH_HardTestResult.FirstOrDefault(e => e.HardTestResultId == HardTestResultId);
return view;
}
/// <summary>
/// 根据硬度检验委托Id和焊口id获取用于硬度检验结果反馈
/// </summary>
/// <param name="jot_id"></param>
/// <returns></returns>
public static Model.HJGL_CH_HardTestResult GetHardTestResultByHardTestReportIdAndJotID(string hardTestReportId, string jot_id)
{
Model.SGGLDB db = Funs.DB;
var view = db.HJGL_CH_HardTestResult.FirstOrDefault(e => e.HardTestReportId == hardTestReportId && e.JOT_ID == jot_id);
return view;
}
/// <summary>
/// 增加硬度检验结果反馈
/// </summary>
/// <param name="hotProess">硬度检验实体</param>
public static void AddHardTestResult(Model.HJGL_CH_HardTestResult hotProess)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_CH_HardTestResult newTestPackage = new Model.HJGL_CH_HardTestResult();
newTestPackage.HardTestResultId = SQLHelper.GetNewID(typeof(Model.HJGL_CH_HardTestResult));
newTestPackage.HardTestReportId = hotProess.HardTestReportId;
newTestPackage.JOT_ID = hotProess.JOT_ID;
newTestPackage.IsOK = hotProess.IsOK;
newTestPackage.ResultDate = hotProess.ResultDate;
newTestPackage.CannotCheck = hotProess.CannotCheck;
newTestPackage.Remark = hotProess.Remark;
db.HJGL_CH_HardTestResult.InsertOnSubmit(newTestPackage);
db.SubmitChanges();
}
/// <summary>
/// 修改硬度检验结果反馈
/// </summary>
/// <param name="weldReport">硬度检验实体</param>
public static void UpdateHardTestResult(Model.HJGL_CH_HardTestResult hotProess)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_CH_HardTestResult newTestPackage = db.HJGL_CH_HardTestResult.FirstOrDefault(e => e.HardTestResultId == hotProess.HardTestResultId);
if (newTestPackage != null)
{
newTestPackage.JOT_ID = hotProess.JOT_ID;
newTestPackage.IsOK = hotProess.IsOK;
newTestPackage.ResultDate = hotProess.ResultDate;
newTestPackage.CannotCheck = hotProess.CannotCheck;
newTestPackage.Remark = hotProess.Remark;
db.SubmitChanges();
}
}
/// <summary>
/// 根据主键删除硬度检验结果反馈
/// </summary>
/// <param name="hotProessID">硬度检验主键</param>
public static void DeleteHardTestResultByHardTestResultID(string hotProessResultId)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_CH_HardTestResult hotProess = db.HJGL_CH_HardTestResult.FirstOrDefault(e => e.HardTestResultId == hotProessResultId);
if (hotProess != null)
{
db.HJGL_CH_HardTestResult.DeleteOnSubmit(hotProess);
db.SubmitChanges();
}
}
/// <summary>
/// 根据主键删除硬度检验结果反馈明细
/// </summary>
/// <param name="hotProessID">硬度检验主键</param>
public static void DeleteHardTestResultsyHardTestReportId(string HardTestReportId)
{
Model.SGGLDB db = Funs.DB;
var items = from x in db.HJGL_CH_HardTestResult where x.HardTestReportId == HardTestReportId select x;
if (items != null)
{
foreach (var item in items)
{
//回写硬度合格及反馈时间
BLL.HJGL_PW_JointInfoService.WriteBackHardTestResultOKAndDate(item.JOT_ID, null);
if (item.IsOK == null && item.CannotCheck == null && string.IsNullOrEmpty(item.Remark) && item.ResultDate == null)
{
db.HJGL_CH_HardTestResult.DeleteOnSubmit(item);
db.SubmitChanges();
}
}
}
}
}
}