496 lines
23 KiB
C#
496 lines
23 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using BLL;
|
||
using System.Linq;
|
||
using System.Data.SqlClient;
|
||
using System.Data;
|
||
using System.Web;
|
||
|
||
namespace FineUIPro.Web.HJGL.CheckManage
|
||
{
|
||
public partial class PTReportEdit : PageBase
|
||
{
|
||
#region 定义项
|
||
/// <summary>
|
||
/// 主键
|
||
/// </summary>
|
||
private string TestingReportPrintId
|
||
{
|
||
get
|
||
{
|
||
return (string)ViewState["TestingReportPrintId"];
|
||
}
|
||
set
|
||
{
|
||
ViewState["TestingReportPrintId"] = value;
|
||
}
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 检测报告Id
|
||
/// </summary>
|
||
private string ReportPrintId
|
||
{
|
||
get
|
||
{
|
||
return (string)ViewState["ReportPrintId"];
|
||
}
|
||
set
|
||
{
|
||
ViewState["ReportPrintId"] = value;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 管线ID
|
||
/// </summary>
|
||
private string ISO_ID
|
||
{
|
||
get
|
||
{
|
||
return (string)ViewState["ISO_ID"];
|
||
}
|
||
set
|
||
{
|
||
ViewState["ISO_ID"] = value;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 规格
|
||
/// </summary>
|
||
private string Specifications
|
||
{
|
||
get
|
||
{
|
||
return (string)ViewState["Specifications"];
|
||
}
|
||
set
|
||
{
|
||
ViewState["Specifications"] = value;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 检测类型主键
|
||
/// </summary>
|
||
private string NDT_ID
|
||
{
|
||
get
|
||
{
|
||
return (string)ViewState["NDT_ID"];
|
||
}
|
||
set
|
||
{
|
||
ViewState["NDT_ID"] = value;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 批主键
|
||
/// </summary>
|
||
private string BatchId
|
||
{
|
||
get
|
||
{
|
||
return (string)ViewState["BatchId"];
|
||
}
|
||
set
|
||
{
|
||
ViewState["BatchId"] = value;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 加载
|
||
/// <summary>
|
||
/// 加载页面
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Page_Load(object sender, EventArgs e)
|
||
{
|
||
if (!IsPostBack)
|
||
{
|
||
#region 加载下拉选择项
|
||
//检测时机
|
||
this.drpTestingTime.DataValueField = "ConstValue";
|
||
this.drpTestingTime.DataTextField = "ConstText";
|
||
this.drpTestingTime.DataSource = BLL.ConstValue.drpConstItemList(BLL.ConstValue.Group_TestingTime);
|
||
this.drpTestingTime.DataBind();
|
||
Funs.FineUIPleaseSelect(this.drpTestingTime);
|
||
|
||
//热处理状态
|
||
this.drpHotProessState.DataValueField = "ConstValue";
|
||
this.drpHotProessState.DataTextField = "ConstText";
|
||
this.drpHotProessState.DataSource = BLL.ConstValue.drpConstItemList(BLL.ConstValue.Group_HotProessState);
|
||
this.drpHotProessState.DataBind();
|
||
Funs.FineUIPleaseSelect(this.drpHotProessState);
|
||
#endregion
|
||
|
||
//this.ReportPrintId = Request.Params["reportPrintId"];
|
||
this.ReportPrintId = HttpUtility.UrlDecode(Request.Params["reportPrintId"]);
|
||
if (!string.IsNullOrEmpty(this.ReportPrintId))
|
||
{
|
||
ISO_ID = ReportPrintId.Split('|')[0];
|
||
Specifications = ReportPrintId.Split('|')[1];
|
||
NDT_ID = ReportPrintId.Split('|')[2];
|
||
BatchId = ReportPrintId.Split('|')[3];
|
||
string[] jointNos = (ReportPrintId.Split('|')[4]).Split(',');
|
||
|
||
//var report = BLL.HJGL_TestingReportPrintService.GetCheckReportInfo(ISO_ID, NDT_ID, BatchId);
|
||
Model.HJGL_PW_IsoInfo iso = BLL.HJGL_PW_IsoInfoService.GetIsoInfoByIsoInfoId(ISO_ID);
|
||
Model.HJGL_BO_Batch batch = BLL.HJGL_BO_BatchService.GetBatchById(BatchId);
|
||
var trust = from x in Funs.DB.HJGL_CH_Trust where x.BatchId == BatchId && x.CH_NDTMethod == NDT_ID select x;
|
||
var hardReport = from x in Funs.DB.HJGL_CH_HardTestReport where x.ISO_ID == ISO_ID select x;
|
||
var pro = BLL.Base_ProjectService.GetProjectByProjectId(iso.ProjectId);
|
||
|
||
this.txtCH_TrustUnit.Text = "镇海石化建安工程有限公司";
|
||
if (iso != null)
|
||
{
|
||
this.txtIsoNo.Text = iso.ISO_IsoNo;
|
||
Model.Base_Unit unit = BLL.Base_UnitService.GetUnit(iso.BSU_ID);
|
||
if (unit != null)
|
||
{
|
||
this.txtContractUnit.Text = unit.UnitName;
|
||
}
|
||
|
||
var jot = (from x in Funs.DB.HJGL_PW_JointInfo
|
||
join y in Funs.DB.HJGL_BO_BatchDetail
|
||
on x.JOT_ID equals y.JOT_ID
|
||
where x.ISO_ID == ISO_ID && x.JOT_JointDesc == Specifications && y.BatchId == BatchId && y.NDT.Contains(NDT_ID)
|
||
select x).FirstOrDefault();
|
||
if (jot != null)
|
||
{
|
||
var ste = BLL.HJGL_MaterialService.GetSteelBySteID(jot.STE_ID);
|
||
if (ste != null)
|
||
{
|
||
this.txtSteelCode.Text = ste.STE_Code;
|
||
}
|
||
}
|
||
|
||
var checkParm = from x in Funs.DB.HJGL_WeldingManage_TestingParameters where x.WeldSpecification == Specifications && x.STE_ID == iso.STE_ID select x;
|
||
if (checkParm.Count() > 0)
|
||
{
|
||
this.drpTestingTime.Text = checkParm.First().TestingTime;
|
||
|
||
}
|
||
}
|
||
if (batch != null)
|
||
{
|
||
var ndtr = BLL.HJGL_DetectionService.GetNDTRateByNDTRID(batch.NDTR_ID);
|
||
if (ndtr != null)
|
||
{
|
||
this.txtNDTR_Name.Text = ndtr.NDTR_Name;
|
||
}
|
||
}
|
||
|
||
if (trust.Count() > 0)
|
||
{
|
||
var wme = BLL.HJGL_WeldingMethodService.GetWeldMethodByWMEID(trust.First().CH_WeldMethod);
|
||
if (wme != null)
|
||
{
|
||
this.txtWME_Name.Text = wme.WME_Name;
|
||
}
|
||
this.txtCH_NDTCriteria.Text = trust.First().CH_NDTCriteria;
|
||
|
||
var jot = from x in Funs.DB.HJGL_PW_JointInfo
|
||
join y in Funs.DB.HJGL_CH_TrustItem on x.JOT_ID equals y.JOT_ID
|
||
where y.CH_TrustID == trust.First().CH_TrustID
|
||
select x;
|
||
if (jot.Count() > 0)
|
||
{
|
||
var ndtInfo = BLL.HJGL_TestingService.GetTestingByTestingId(NDT_ID);
|
||
var joty = BLL.HJGL_WeldService.GetJointTypeByID(jot.First().JOTY_ID);
|
||
if ((ndtInfo.NDT_Code == "MT" || ndtInfo.NDT_Code == "PT") && joty.JOTY_Group == "1")
|
||
{
|
||
this.txtCH_AcceptGrade.Text = "Ⅰ";
|
||
}
|
||
else
|
||
{
|
||
this.txtCH_AcceptGrade.Text = (from x in Funs.DB.HJGL_PW_JointInfo
|
||
join y in Funs.DB.HJGL_CH_TrustItem on x.JOT_ID equals y.JOT_ID
|
||
where y.CH_TrustID == trust.First().CH_TrustID
|
||
select x.JOT_QualifiedLevel).FirstOrDefault();
|
||
}
|
||
}
|
||
}
|
||
//var ndt = BLL.HJGL_TestingService.GetTestingByTestingId(NDT_ID);
|
||
//if (ndt != null)
|
||
//{
|
||
// this.txtTestMethod.Text = ndt.NDT_Code;
|
||
//}
|
||
this.txtTestMethod.Text = "ⅡC-d";//检测方法
|
||
this.txtSpecifications.Text = Specifications;//检件规格
|
||
|
||
this.drpHotProessState.Text = "消应力";//热处理状态
|
||
|
||
this.txtPenetrantGrade.Text = "DPT-5A";//渗透剂牌号
|
||
this.txtCleaningGrade.Text = "DPT-5A";//清洗剂牌号
|
||
this.txtImagingGrade.Text = "DPT-5A";//显像剂牌号
|
||
this.txtImposingMethod.Text = "喷洒";//施加方法
|
||
this.txtObservationMethod.Text = "目视";//观察方法
|
||
this.txtSensitivityTestBlock.Text = "C级";//检测灵敏度
|
||
this.txtTestBlock.Text = "B型";//检测试块
|
||
this.txtSurfaceState.Text = "机械打磨";//表面状态
|
||
this.drpTestingTime.Text = "焊后";
|
||
this.txtOsmoticTemperature.Text = " ℃";
|
||
this.txtPermeationTime.Text = " min";
|
||
this.txtImagingTime.Text = " min";
|
||
string jotyName = string.Empty;
|
||
foreach (var jointNo in jointNos)
|
||
{
|
||
var jointId = (from x in Funs.DB.HJGL_PW_JointInfo
|
||
where x.ISO_ID == ISO_ID && x.JOT_JointNo == jointNo
|
||
select x.JOT_ID).FirstOrDefault();
|
||
|
||
if (jointId != null)
|
||
{
|
||
if (string.IsNullOrEmpty(jotyName)) //获取检件名称
|
||
{
|
||
Model.HJGL_PW_JointInfo joint = BLL.HJGL_PW_JointInfoService.GetJointInfoByJotID(jointId);
|
||
if (joint != null)
|
||
{
|
||
Model.HJGL_BS_JointType jointType = BLL.HJGL_WeldService.GetJointTypeByID(joint.JOTY_ID);
|
||
if (jointType != null && !string.IsNullOrEmpty(jointType.JOTY_Name))
|
||
{
|
||
jotyName = jointType.JOTY_Name;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
this.txtIso_No.Text = jotyName;
|
||
var ptReport = BLL.HJGL_TestingReportPrintService.GetTestingReportPrint(ISO_ID, Specifications, NDT_ID, BatchId, Request.Params["STE_ID"], Request.Params["STE_ID2"], Request.Params["WME_ID"]);
|
||
if (ptReport != null)
|
||
{
|
||
this.TestingReportPrintId = ptReport.TestingReportPrintId;
|
||
if (!string.IsNullOrEmpty(ptReport.ReportCode) && ptReport.ReportCode.Length > 3)
|
||
{
|
||
this.txtPTReportCode.Text = ptReport.ReportCode.Substring(3);//报告编号
|
||
}
|
||
else
|
||
{
|
||
this.txtPTReportCode.Text = ptReport.ReportCode;
|
||
}
|
||
this.hdReportCode.Text = ptReport.ReportCode;
|
||
|
||
//this.txtContractUnit.Text = ptReport.ContractUnitId;//承包单位
|
||
this.txtSurfaceState.Text = ptReport.PT_SurfaceState;//表面状态
|
||
this.txtPenetrantGrade.Text = ptReport.PT_PenetrantGrade;//渗透剂牌号
|
||
this.txtCleaningGrade.Text = ptReport.PT_CleaningGrade;//清洗剂牌号
|
||
this.txtImagingGrade.Text = ptReport.PT_ImagingGrade;//显像剂牌号
|
||
this.txtOsmoticTemperature.Text = ptReport.PT_OsmoticTemperature;//渗透温度
|
||
this.txtImposingMethod.Text = ptReport.PT_ImposingMethod;//施加方法
|
||
this.txtObservationMethod.Text = ptReport.PT_ObservationMethod;//观察方法
|
||
this.txtSensitivityTestBlock.Text = ptReport.PT_SensitivityTestBlock;//灵敏度试块
|
||
this.txtPermeationTime.Text = ptReport.PT_PermeationTime;//渗透时间
|
||
this.txtImagingTime.Text = ptReport.PT_ImagingTime;//显像时间
|
||
this.drpTestingTime.Text = ptReport.TestingTime;
|
||
this.txtPrinter.Text = ptReport.Printer;//打印人
|
||
this.txtPrintTime.Text = string.Format("{0:yyyy-MM-dd}", ptReport.PrintTime);//打印时间
|
||
if (!string.IsNullOrEmpty(this.txtPrinter.Text.Trim()) && !string.IsNullOrEmpty(this.txtPrintTime.Text.Trim()))
|
||
{
|
||
this.cbIsPrint.Checked = true;
|
||
}
|
||
this.drpHotProessState.Text = ptReport.HotProessState;
|
||
}
|
||
else
|
||
{
|
||
this.hdReportCode.Text = BLL.SQLHelper.RunProcNewIdByProjectId("SpGetNewCodeByProjectId3", "HJGL_CH_TestingReportPrint", "ReportCode", iso.ProjectId, "PT-" + pro.TestEngineeringCode + "-");
|
||
this.txtPTReportCode.Text = this.hdReportCode.Text.Substring(3);
|
||
this.txtContractUnit.Text = "镇海石化建安工程有限公司";
|
||
}
|
||
BindGrid();
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 提交
|
||
/// <summary>
|
||
/// 提交按钮
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnSave_Click(object sender, EventArgs e)
|
||
{
|
||
var p = BLL.HJGL_BO_BatchService.GetBatchById(this.BatchId);
|
||
Model.HJGL_CH_TestingReportPrint newPTReport = new Model.HJGL_CH_TestingReportPrint();
|
||
newPTReport.ISO_ID = this.ISO_ID;
|
||
if (p != null)
|
||
{
|
||
newPTReport.ProjectId = p.ProjectId;
|
||
}
|
||
newPTReport.Specifications = this.Specifications;
|
||
newPTReport.JotyName = this.txtIso_No.Text;
|
||
newPTReport.NDT_ID = this.NDT_ID;
|
||
newPTReport.BatchId = this.BatchId;
|
||
newPTReport.ReportCode = this.hdReportCode.Text.Trim();
|
||
newPTReport.ContractUnitId = this.txtContractUnit.Text.Trim();
|
||
newPTReport.PT_SurfaceState = this.txtSurfaceState.Text.Trim();
|
||
newPTReport.PT_PenetrantGrade = this.txtPenetrantGrade.Text.Trim();
|
||
newPTReport.PT_CleaningGrade = this.txtCleaningGrade.Text.Trim();
|
||
newPTReport.PT_ImagingGrade = this.txtImagingGrade.Text.Trim();
|
||
newPTReport.PT_OsmoticTemperature = this.txtOsmoticTemperature.Text.Trim();
|
||
newPTReport.PT_ImposingMethod = this.txtImposingMethod.Text.Trim();
|
||
newPTReport.PT_ObservationMethod = this.txtObservationMethod.Text.Trim();
|
||
newPTReport.PT_SensitivityTestBlock = this.txtSensitivityTestBlock.Text.Trim();
|
||
newPTReport.TestBlock = this.txtTestBlock.Text.Trim();
|
||
newPTReport.PT_PermeationTime = this.txtPermeationTime.Text.Trim();
|
||
newPTReport.PT_ImagingTime = this.txtImagingTime.Text.Trim();
|
||
newPTReport.Printer = this.txtPrinter.Text.Trim();
|
||
newPTReport.PrintTime = Funs.GetNewDateTime(this.txtPrintTime.Text.Trim());
|
||
if (this.drpTestingTime.SelectedValue != BLL.Const._Null)
|
||
{
|
||
if (!string.IsNullOrEmpty(this.drpTestingTime.Text.Trim()))
|
||
{
|
||
newPTReport.TestingTime = this.drpTestingTime.Text.Trim();
|
||
}
|
||
else
|
||
{
|
||
newPTReport.TestingTime = this.drpTestingTime.SelectedValue;
|
||
}
|
||
}
|
||
if (this.drpHotProessState.SelectedValue != BLL.Const._Null)
|
||
{
|
||
if (!string.IsNullOrEmpty(this.drpHotProessState.Text.Trim()))
|
||
{
|
||
newPTReport.HotProessState = this.drpHotProessState.Text.Trim();
|
||
}
|
||
else
|
||
{
|
||
newPTReport.HotProessState = this.drpHotProessState.SelectedValue;
|
||
}
|
||
}
|
||
newPTReport.STE_ID = Request.Params["STE_ID"];
|
||
newPTReport.STE_ID2 = Request.Params["STE_ID2"];
|
||
newPTReport.WME_ID = Request.Params["WME_ID"];
|
||
if (string.IsNullOrEmpty(this.TestingReportPrintId))
|
||
{
|
||
newPTReport.Type = "PT";
|
||
this.TestingReportPrintId = SQLHelper.GetNewID(typeof(Model.HJGL_CH_TestingReportPrint));
|
||
newPTReport.TestingReportPrintId = this.TestingReportPrintId;
|
||
BLL.HJGL_TestingReportPrintService.AddTestingReportPrint(newPTReport);
|
||
BLL.Sys_LogService.AddLog(Const.System_3, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "添加渗透检测报告");
|
||
}
|
||
else
|
||
{
|
||
newPTReport.TestingReportPrintId = this.TestingReportPrintId;
|
||
BLL.HJGL_TestingReportPrintService.UpdateTestingReportPrint(newPTReport);
|
||
BLL.Sys_LogService.AddLog(Const.System_3, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "修改渗透检测报告");
|
||
}
|
||
ShowNotify("提交成功!", MessageBoxIcon.Success);
|
||
PageContext.RegisterStartupScript(ActiveWindow.GetHideReference());
|
||
}
|
||
#endregion
|
||
|
||
#region 绑定数据
|
||
/// <summary>
|
||
/// 绑定数据
|
||
/// </summary>
|
||
private void BindGrid()
|
||
{
|
||
string strSql = @"SELECT QualityRating.QualityRatingId,
|
||
QualityRating.CH_TrustItemID,
|
||
QualityRating.ISO_ID,
|
||
QualityRating.JOT_ID,
|
||
--BatchDetail.BatchDetailId,
|
||
trust.CH_NDTMethod AS NDT,
|
||
JointInfo.JOT_JointDesc,
|
||
JointInfo.JOT_JointNo+(case batchDetail.PointType when '2' then 'K' else '' end) as JOT_JointNo,
|
||
QualityRating.FilmNum,
|
||
Welder.WED_Code,
|
||
QualityRating.DefectNature,
|
||
QualityRating.DefectSize,
|
||
QualityRating.DefectResult,
|
||
QualityRating.Remark
|
||
FROM dbo.HJGL_BO_QualityRating AS QualityRating
|
||
LEFT JOIN DBO.HJGL_CH_TrustItem AS TrustItem ON TrustItem.CH_TrustItemID = QualityRating.CH_TrustItemID
|
||
LEFT JOIN dbo.HJGL_CH_Trust trust ON trust.CH_TrustID = TrustItem.CH_TrustID
|
||
--LEFT JOIN DBO.HJGL_BO_BatchDetail AS BatchDetail ON BatchDetail.BatchDetailId=TrustItem.BatchDetailId
|
||
LEFT JOIN DBO.HJGL_PW_JointInfo AS JointInfo ON JointInfo.JOT_ID=QualityRating.JOT_ID
|
||
LEFT JOIN dbo.HJGL_BO_BatchDetail batchDetail ON batchDetail.JOT_ID = QualityRating.JOT_ID
|
||
LEFT JOIN DBO.HJGL_BS_Welder AS Welder ON Welder.WED_ID =JointInfo.JOT_CellWelder
|
||
WHERE QualityRating.ISO_ID=@ISO_ID
|
||
AND JointInfo.JOT_JointDesc=@JOT_JointDesc AND JointInfo.STE_ID=@STE_ID AND (JointInfo.STE_ID2=@STE_ID2 or @STE_ID2='') AND JointInfo.WME_ID=@WME_ID
|
||
AND trust.CH_NDTMethod = @NDT
|
||
AND trust.BatchId=@BatchId";
|
||
List<SqlParameter> listStr = new List<SqlParameter>();
|
||
listStr.Add(new SqlParameter("@ISO_ID", this.ISO_ID));
|
||
listStr.Add(new SqlParameter("@JOT_JointDesc", this.Specifications));
|
||
listStr.Add(new SqlParameter("@NDT", this.NDT_ID));
|
||
listStr.Add(new SqlParameter("@BatchId", this.BatchId));
|
||
listStr.Add(new SqlParameter("@STE_ID", Request.Params["STE_ID"]));
|
||
listStr.Add(new SqlParameter("@STE_ID2", Request.Params["STE_ID2"]));
|
||
listStr.Add(new SqlParameter("@WME_ID", Request.Params["WME_ID"]));
|
||
SqlParameter[] parameter = listStr.ToArray();
|
||
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
||
// 2.获取当前分页数据
|
||
//var table = this.GetPagedDataTable(Grid1, tb1);
|
||
Grid1.RecordCount = tb.Rows.Count;
|
||
tb = GetFilteredTable(Grid1.FilteredData, tb);
|
||
var table = this.GetPagedDataTable(Grid1, tb);
|
||
Grid1.DataSource = table;
|
||
Grid1.DataBind();
|
||
}
|
||
#endregion
|
||
|
||
#region 分页排序
|
||
#region 页索引改变事件
|
||
/// <summary>
|
||
/// 页索引改变事件
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
||
{
|
||
BindGrid();
|
||
}
|
||
#endregion
|
||
|
||
#region 排序
|
||
/// <summary>
|
||
/// 排序
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Grid1_Sort(object sender, GridSortEventArgs e)
|
||
{
|
||
BindGrid();
|
||
}
|
||
#endregion
|
||
|
||
#region 分页选择下拉改变事件
|
||
/// <summary>
|
||
/// 分页选择下拉改变事件
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
||
{
|
||
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
|
||
BindGrid();
|
||
}
|
||
#endregion
|
||
#endregion
|
||
|
||
#region 是否打印点击事件
|
||
/// <summary>
|
||
/// 是否打印点击事件
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void cbIsPrint_CheckedChanged(object sender, CheckedEventArgs e)
|
||
{
|
||
if (this.cbIsPrint.Checked == false)
|
||
{
|
||
this.txtPrinter.Text = string.Empty;
|
||
this.txtPrintTime.Text = string.Empty;
|
||
}
|
||
}
|
||
#endregion
|
||
}
|
||
} |