346 lines
15 KiB
C#
346 lines
15 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_HotProessManageEditService
|
|
{
|
|
/// <summary>
|
|
/// 根据热处理Id获取用于热处理信息
|
|
/// </summary>
|
|
/// <param name="jot_id"></param>
|
|
/// <returns></returns>
|
|
public static Model.HJGL_HotProess GetHotProessByID(string HotProessId)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
var view = db.HJGL_HotProess.FirstOrDefault(e => e.HotProessId == HotProessId);
|
|
return view;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据热处理委托Id获取用于热处理信息
|
|
/// </summary>
|
|
/// <param name="jot_id"></param>
|
|
/// <returns></returns>
|
|
public static Model.HJGL_HotProess GetHotProessByHotProessTrustId(string HotProessTrustId)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
var view = db.HJGL_HotProess.FirstOrDefault(e => e.HotProessTrustId == HotProessTrustId);
|
|
return view;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据热处理委托Id及焊口和热处理类型获取增加记录对应的索引值
|
|
/// </summary>
|
|
/// <param name="jot_id"></param>
|
|
/// <returns></returns>
|
|
public static int GetSortIndex(string HotProessTrustId, string jot_id, string proessTypes)
|
|
{
|
|
int i = 1;
|
|
Model.SGGLDB db = Funs.DB;
|
|
var view = from x in db.HJGL_HotProessItem where x.HotProessTrustId == HotProessTrustId && x.JOT_ID == jot_id && x.ProessTypes == proessTypes orderby x.SortIndex descending select x;
|
|
if (view.Count() > 0)
|
|
{
|
|
i = Funs.GetNewIntOrZero(view.First().SortIndex.ToString()) + 1;
|
|
}
|
|
return i;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据热处理Id获取用于热处理信息明细
|
|
/// </summary>
|
|
/// <param name="jot_id"></param>
|
|
/// <returns></returns>
|
|
public static List<Model.View_HotProessItem> GetViewHotProessItemListByID(string hotProessId)
|
|
{
|
|
var view = (from x in Funs.DB.View_HotProessItem where x.HotProessId == hotProessId select x).ToList();
|
|
return view;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据焊口Id获取用于热处理信息明细
|
|
/// </summary>
|
|
/// <param name="jot_id"></param>
|
|
/// <returns></returns>
|
|
public static Model.View_HotProessItem GetViewHotProessItemByJOT_ID(string jot_ID)
|
|
{
|
|
return Funs.DB.View_HotProessItem.FirstOrDefault(x => x.JOT_ID == jot_ID);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据主键获取用于热处理信息明细
|
|
/// </summary>
|
|
/// <param name="jot_id"></param>
|
|
/// <returns></returns>
|
|
public static Model.HJGL_HotProessItem GetHotProessItemByHotProessItemId(string hotProessItemId)
|
|
{
|
|
return Funs.DB.HJGL_HotProessItem.FirstOrDefault(x => x.HotProessItemId == hotProessItemId);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 增加热处理信息
|
|
/// </summary>
|
|
/// <param name="hotProess">热处理实体</param>
|
|
public static void AddHotProess(Model.HJGL_HotProess hotProess)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
Model.HJGL_HotProess newTestPackage = new Model.HJGL_HotProess();
|
|
newTestPackage.HotProessId = hotProess.HotProessId;
|
|
newTestPackage.HotProessNo = hotProess.HotProessNo;
|
|
newTestPackage.ProessDate = hotProess.ProessDate;
|
|
newTestPackage.ProjectId = hotProess.ProjectId;
|
|
newTestPackage.InstallationId = hotProess.InstallationId;
|
|
newTestPackage.UnitId = hotProess.UnitId;
|
|
newTestPackage.Tabler = hotProess.Tabler;
|
|
newTestPackage.Remark = hotProess.Remark;
|
|
newTestPackage.ProessMethod = hotProess.ProessMethod;
|
|
newTestPackage.ProessEquipment = hotProess.ProessEquipment;
|
|
newTestPackage.NDTMethod = hotProess.NDTMethod;
|
|
newTestPackage.NDTRate = hotProess.NDTRate;
|
|
newTestPackage.Standards = hotProess.Standards;
|
|
newTestPackage.InspectionNum = hotProess.InspectionNum;
|
|
newTestPackage.CheckNum = hotProess.CheckNum;
|
|
newTestPackage.TestWeldNum = hotProess.TestWeldNum;
|
|
newTestPackage.Sendee = hotProess.Sendee;
|
|
newTestPackage.CheckUnitId = hotProess.CheckUnitId;
|
|
newTestPackage.HotProessTrustId = hotProess.HotProessTrustId;
|
|
db.HJGL_HotProess.InsertOnSubmit(newTestPackage);
|
|
db.SubmitChanges();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改热处理信息
|
|
/// </summary>
|
|
/// <param name="weldReport">热处理实体</param>
|
|
public static void UpdateHotProess(Model.HJGL_HotProess hotProess)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
Model.HJGL_HotProess newTestPackage = db.HJGL_HotProess.FirstOrDefault(e => e.HotProessId == hotProess.HotProessId);
|
|
if (newTestPackage != null)
|
|
{
|
|
newTestPackage.HotProessId = hotProess.HotProessId;
|
|
newTestPackage.HotProessNo = hotProess.HotProessNo;
|
|
newTestPackage.ProessDate = hotProess.ProessDate;
|
|
newTestPackage.ProjectId = hotProess.ProjectId;
|
|
newTestPackage.InstallationId = hotProess.InstallationId;
|
|
newTestPackage.UnitId = hotProess.UnitId;
|
|
newTestPackage.Tabler = hotProess.Tabler;
|
|
newTestPackage.Remark = hotProess.Remark;
|
|
newTestPackage.ProessMethod = hotProess.ProessMethod;
|
|
newTestPackage.ProessEquipment = hotProess.ProessEquipment;
|
|
newTestPackage.NDTMethod = hotProess.NDTMethod;
|
|
newTestPackage.NDTRate = hotProess.NDTRate;
|
|
newTestPackage.Standards = hotProess.Standards;
|
|
newTestPackage.InspectionNum = hotProess.InspectionNum;
|
|
newTestPackage.CheckNum = hotProess.CheckNum;
|
|
newTestPackage.TestWeldNum = hotProess.TestWeldNum;
|
|
newTestPackage.Sendee = hotProess.Sendee;
|
|
newTestPackage.CheckUnitId = hotProess.CheckUnitId;
|
|
newTestPackage.HotProessTrustId = hotProess.HotProessTrustId;
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据主键删除热处理信息
|
|
/// </summary>
|
|
/// <param name="hotProessID">热处理主键</param>
|
|
public static void DeleteHotProessByHotProessID(string hotProessID)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
Model.HJGL_HotProess hotProess = db.HJGL_HotProess.FirstOrDefault(e => e.HotProessId == hotProessID);
|
|
if (hotProess != null)
|
|
{
|
|
db.HJGL_HotProess.DeleteOnSubmit(hotProess);
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据主键删除热处理信息明细
|
|
/// </summary>
|
|
/// <param name="hotProessID">热处理主键</param>
|
|
public static void DeleteHotProessItemByHotProessId(string HotProessId)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
var items = from x in db.HJGL_HotProessItem where x.HotProessId == HotProessId select x;
|
|
if (items != null)
|
|
{
|
|
foreach (var item in items)
|
|
{
|
|
Model.HJGL_PW_JointInfo info = new Model.HJGL_PW_JointInfo();
|
|
info.JOT_ID = item.JOT_ID;
|
|
|
|
info.IS_Proess = "0";
|
|
UpdateJointInfo(info);
|
|
}
|
|
|
|
db.HJGL_HotProessItem.DeleteAllOnSubmit(items);
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据委托主键删除热处理信息明细
|
|
/// </summary>
|
|
/// <param name="hotProessID">热处理委托主键</param>
|
|
public static void DeleteHotProessItemByHotProessTrustId(string HotProessTrustId)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
var items = from x in db.HJGL_HotProessItem where x.HotProessTrustId == HotProessTrustId select x;
|
|
if (items != null)
|
|
{
|
|
//foreach (var item in items)
|
|
//{
|
|
// Model.HJGL_PW_JointInfo info = new Model.HJGL_PW_JointInfo();
|
|
// info.JOT_ID = item.JOT_ID;
|
|
// info.JOT_ProessDate = null;
|
|
// info.JOT_HotRpt = null;
|
|
// info.IS_Proess = "0";
|
|
// UpdateJointInfo(info);
|
|
//}
|
|
|
|
db.HJGL_HotProessItem.DeleteAllOnSubmit(items);
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据委托主键删除热处理信息明细
|
|
/// </summary>
|
|
/// <param name="hotProessID">热处理委托主键</param>
|
|
public static void DeleteHotProessItemByHotProessItemId(string HotProessItemId)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
var items = (from x in db.HJGL_HotProessItem where x.HotProessItemId == HotProessItemId select x).FirstOrDefault();
|
|
if (items != null)
|
|
{
|
|
//foreach (var item in items)
|
|
//{
|
|
// Model.HJGL_PW_JointInfo info = new Model.HJGL_PW_JointInfo();
|
|
// info.JOT_ID = item.JOT_ID;
|
|
// info.JOT_ProessDate = null;
|
|
// info.JOT_HotRpt = null;
|
|
// info.IS_Proess = "0";
|
|
// UpdateJointInfo(info);
|
|
//}
|
|
|
|
db.HJGL_HotProessItem.DeleteOnSubmit(items);
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 增加热处理信息明细
|
|
/// </summary>
|
|
/// <param name="HJGL_HotProessItem">热处理明细实体</param>
|
|
public static void AddHotProessItem(Model.HJGL_HotProessItem HJGL_HotProessItem, string HotProessNo, string date)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
Model.HJGL_HotProessItem newHotProessItem = new Model.HJGL_HotProessItem();
|
|
if (!string.IsNullOrEmpty(HJGL_HotProessItem.HotProessItemId))
|
|
{
|
|
newHotProessItem.HotProessItemId = HJGL_HotProessItem.HotProessItemId;
|
|
}
|
|
else
|
|
{
|
|
newHotProessItem.HotProessItemId = SQLHelper.GetNewID(typeof(Model.HJGL_HotProessItem));
|
|
}
|
|
newHotProessItem.HotProessId = HJGL_HotProessItem.HotProessId;
|
|
newHotProessItem.JOT_ID = HJGL_HotProessItem.JOT_ID;
|
|
newHotProessItem.PointCount = HJGL_HotProessItem.PointCount;
|
|
newHotProessItem.RequiredT = HJGL_HotProessItem.RequiredT;
|
|
newHotProessItem.ActualT = HJGL_HotProessItem.ActualT;
|
|
newHotProessItem.ProessTypes = HJGL_HotProessItem.ProessTypes;
|
|
newHotProessItem.RequestTime = HJGL_HotProessItem.RequestTime;
|
|
newHotProessItem.ActualTime = HJGL_HotProessItem.ActualTime;
|
|
newHotProessItem.RecordChartNo = HJGL_HotProessItem.RecordChartNo;
|
|
newHotProessItem.HardnessReportNo = HJGL_HotProessItem.HardnessReportNo;
|
|
newHotProessItem.HotProessTrustId = HJGL_HotProessItem.HotProessTrustId;
|
|
newHotProessItem.HotProessDate = HJGL_HotProessItem.HotProessDate;
|
|
newHotProessItem.SortIndex = HJGL_HotProessItem.SortIndex;
|
|
newHotProessItem.Remark = HJGL_HotProessItem.Remark;
|
|
Model.HJGL_CH_HotProessTrustItem hotProessTrustItem = BLL.HJGL_CH_HotProessTrustService.GetCH_HotProessTrustItemByHotProessTrustIdAndJotId(HJGL_HotProessItem.HotProessTrustId, HJGL_HotProessItem.JOT_ID);
|
|
if (hotProessTrustItem != null) //如果热处理委托明细存在,则插入并更新数据
|
|
{
|
|
db.HJGL_HotProessItem.InsertOnSubmit(newHotProessItem);
|
|
db.SubmitChanges();
|
|
////更新焊口信息
|
|
Model.HJGL_PW_JointInfo info = new Model.HJGL_PW_JointInfo();
|
|
info.JOT_ID = HJGL_HotProessItem.JOT_ID;
|
|
|
|
info.IS_Proess = "1";
|
|
UpdateJointInfo(info);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改
|
|
/// </summary>
|
|
/// <param name="jointInfo"></param>
|
|
public static void UpdateJointInfo(Model.HJGL_PW_JointInfo jointInfo)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
Model.HJGL_PW_JointInfo newJointInfo = db.HJGL_PW_JointInfo.FirstOrDefault(e => e.JOT_ID == jointInfo.JOT_ID);
|
|
if (newJointInfo != null)
|
|
{
|
|
newJointInfo.IS_Proess = jointInfo.IS_Proess;
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据单位Id获取热处理数
|
|
/// </summary>
|
|
/// <param name="unitId"></param>
|
|
/// <returns></returns>
|
|
public static int GetHotProessByUnitId(string unitId)
|
|
{
|
|
var q = (from x in Funs.DB.HJGL_HotProess where x.UnitId == unitId select x).ToList();
|
|
return q.Count();
|
|
}
|
|
/// <summary>
|
|
/// 根据装置Id获取热处理数
|
|
/// </summary>
|
|
/// <param name="installationId"></param>
|
|
/// <returns></returns>
|
|
public static int GetHotProessByInstallationId(string installationId)
|
|
{
|
|
var q = (from x in Funs.DB.HJGL_HotProess where x.InstallationId == installationId select x).ToList();
|
|
return q.Count();
|
|
}
|
|
/// <summary>
|
|
/// 根据焊口获取热处理
|
|
/// </summary>
|
|
/// <param name="jotno"></param>
|
|
/// <returns></returns>
|
|
public static int GetHotProessByJotId(string jotno)
|
|
{
|
|
var q = (from x in Funs.DB.HJGL_HotProessItem join y in Funs.DB.HJGL_PW_JointInfo on x.JOT_ID equals y.JOT_ID where y.JOT_JointNo == jotno select x).ToList();
|
|
return q.Count();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据热处理主键获取热处理编号是否存在
|
|
/// </summary>
|
|
/// <param name="weldReportNo">焊接日报编号</param>
|
|
/// <returns>焊接日报信息</returns>
|
|
public static bool IsExistHotProessNO(string hotProessNo, string hotProessId, string projectId)
|
|
{
|
|
var q = Funs.DB.HJGL_HotProess.FirstOrDefault(x => x.HotProessNo == hotProessNo && x.ProjectId == projectId && x.HotProessId != hotProessId);
|
|
if (q != null)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|