ZHJA_HJGL/HJGL_ZH/FineUIPro.Web/YLRQ/TestDataManagement/MTReportEdit.aspx.cs

513 lines
23 KiB
C#

using BLL;
using FineUIPro.Web.HJGL.CheckManage;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace FineUIPro.Web.YLRQ.TestDataManagement
{
public partial class MTReportEdit : 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>
/// 规格
/// </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 EntrustId
{
get
{
return (string)ViewState["EntrustId"];
}
set
{
ViewState["EntrustId"] = value;
}
}
/// <summary>
/// 焊缝主键
/// </summary>
private string WeldingId
{
get
{
return (string)ViewState["WeldingId"];
}
set
{
ViewState["WeldingId"] = 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);
//磁化方法
this.drpTestMethod.DataValueField = "ConstValue";
this.drpTestMethod.DataTextField = "ConstText";
this.drpTestMethod.DataSource = BLL.ConstValue.drpConstItemList(BLL.ConstValue.Group_TestMethod);
this.drpTestMethod.DataBind();
Funs.FineUIPleaseSelect(this.drpTestMethod);
//设备名称
this.drpEquipmentName.DataValueField = "ConstValue";
this.drpEquipmentName.DataTextField = "ConstText";
this.drpEquipmentName.DataSource = BLL.ConstValue.drpConstItemList(BLL.ConstValue.Group_EquipmentName);
this.drpEquipmentName.DataBind();
Funs.FineUIPleaseSelect(this.drpEquipmentName);
//设备型号
this.drpEquipmentModel.DataValueField = "ConstValue";
this.drpEquipmentModel.DataTextField = "ConstText";
this.drpEquipmentModel.DataSource = BLL.ConstValue.drpConstItemList(BLL.ConstValue.Group_EquipmentModel);
this.drpEquipmentModel.DataBind();
Funs.FineUIPleaseSelect(this.drpEquipmentModel);
//灵敏度试片
this.drpSensitivityTestBlock.DataValueField = "ConstValue";
this.drpSensitivityTestBlock.DataTextField = "ConstText";
this.drpSensitivityTestBlock.DataSource = BLL.ConstValue.drpConstItemList(BLL.ConstValue.Group_SensitivityTestBlock);
this.drpSensitivityTestBlock.DataBind();
Funs.FineUIPleaseSelect(this.drpSensitivityTestBlock);
//磁粉种类
this.drpMagneticPowderType.DataValueField = "ConstValue";
this.drpMagneticPowderType.DataTextField = "ConstText";
this.drpMagneticPowderType.DataSource = BLL.ConstValue.drpConstItemList(BLL.ConstValue.Group_MagneticPowderType);
this.drpMagneticPowderType.DataBind();
Funs.FineUIPleaseSelect(this.drpMagneticPowderType);
//磁悬液浓度
this.drpConcentration.DataValueField = "ConstValue";
this.drpConcentration.DataTextField = "ConstText";
this.drpConcentration.DataSource = BLL.ConstValue.drpConstItemList(BLL.ConstValue.Group_Concentration);
this.drpConcentration.DataBind();
Funs.FineUIPleaseSelect(this.drpConcentration);
#endregion
this.ReportPrintId = HttpUtility.UrlDecode(Request.Params["reportPrintId"]);
if (!string.IsNullOrEmpty(this.ReportPrintId))
{
WeldingId = ReportPrintId.Split('|')[0];
Specifications = ReportPrintId.Split('|')[1];
NDT_ID = ReportPrintId.Split('|')[2];
EntrustId = ReportPrintId.Split('|')[3];
string WeldingCode = ReportPrintId.Split('|')[4];
var trust = Funs.DB.PV_EntrustRecord.FirstOrDefault(p => p.Id == EntrustId);
var pro = Funs.DB.Base_Project.FirstOrDefault(s => s.ProjectId == trust.ProjectId);
var weld = Funs.DB.PV_WeldInformation.FirstOrDefault(p => p.WeldingId == WeldingId);
this.txtCH_TrustUnit.Text = "舟山分公司";
this.txtContractUnit.Text = "镇海石化建安工程有限公司";
if (weld != null)
{
this.txtWeldingCode.Text = weld.WeldingCode;
this.txtIso_No.Text = weld.WeldingCode;//焊缝名称(添加的时候没有用到此字段,暂时赋这个值)
var ste = Funs.DB.HJGL_BS_Steel.FirstOrDefault(s => s.STE_ID == weld.TextureMaterial1);
if (ste != null)
{
this.txtSteelCode.Text = ste.STE_Code;
}
var ndt = Funs.DB.PV_TestMethod.FirstOrDefault(p => p.Ndt_Id == this.NDT_ID);
if (ndt != null)
{
this.txtNDTR_Name.Text = ndt.Ndt_NdtName;
this.txtCH_NDTCriteria.Text = ndt.Ndt_TestStandardCode;
this.txtCH_AcceptGrade.Text = ndt.Ndt_Level;
}
var wme = Funs.DB.HJGL_BS_WeldMethod.FirstOrDefault(p => p.WME_ID == Request.Params["WME_ID"]);
if (wme != null)
{
this.txtWME_Name.Text = wme.WME_Name;
}
}
this.txtSpecifications.Text = Specifications;//检件规格
this.drpHotProessState.Text = "消应力";//热处理状态
this.drpTestMethod.Text = "连续磁轭法";//磁化方法
this.txtSurfaceState.Text = "机械打磨";
this.drpSensitivityTestBlock.Text = "A1:30/100";
this.txtCurrentType.Text = "交流电";
this.txtLiftingPower.Text = "≥45N";
this.txtMagnetizationTime.Text = "1-3s";
this.drpMagneticPowderType.Text = "黑磁膏";
this.drpConcentration.Text = "1.2-2.4mL/100mL";
this.txtImposingMethod.Text = "喷洒";
this.drpTestingTime.Text = "焊后";
var mtReport = Funs.DB.PV_CH_TestingReportPrint.FirstOrDefault(s => s.Specifications == Specifications && s.NdtId == NDT_ID && s.EntrustId == EntrustId && s.STE_ID == Request.Params["STE_ID"] && s.STE_ID2 == Request.Params["STE_ID2"] && s.WME_ID == Request.Params["WME_ID"]);
if (mtReport != null)
{
this.txtContractUnit.Text = mtReport.ContractUnitId;
this.TestingReportPrintId = mtReport.TestingReportPrintId;
this.hdReportCode.Text = mtReport.ReportCode;
if (!string.IsNullOrEmpty(mtReport.ReportCode) && mtReport.ReportCode.Length > 3)
{
this.txtMTReportCode.Text = mtReport.ReportCode.Substring(3);//报告编号
}
else
{
this.txtMTReportCode.Text = mtReport.ReportCode;
}
this.hdReportCode.Text = mtReport.ReportCode;
this.txtSurfaceState.Text = mtReport.MT_SurfaceState;//表面状态
this.drpSensitivityTestBlock.Text = mtReport.MT_SensitivityTestBlock;//灵敏度试片
this.txtCurrentType.Text = mtReport.MT_CurrentType;//电流类型
this.txtLiftingPower.Text = mtReport.MT_LiftingPower;//提升力/电流
this.txtMagnetizationTime.Text = mtReport.MT_MagnetizationTime;//磁化时间
this.drpMagneticPowderType.Text = mtReport.MT_MagneticPowderType;//磁粉种类
this.drpConcentration.Text = mtReport.MT_Concentration;//磁悬液浓度
this.txtImposingMethod.Text = mtReport.MT_ImposingMethod;//施加方法
this.drpEquipmentName.Text = mtReport.EquipmentName;
this.drpEquipmentModel.Text = mtReport.EquipmentCode;
this.drpTestingTime.Text = mtReport.TestingTime;
this.txtPrinter.Text = mtReport.Printer;//打印人
this.txtPrintTime.Text = string.Format("{0:yyyy-MM-dd}", mtReport.PrintTime);//打印时间
if (!string.IsNullOrEmpty(this.txtPrinter.Text.Trim()) && !string.IsNullOrEmpty(this.txtPrintTime.Text.Trim()))
{
this.cbIsPrint.Checked = true;
}
this.drpHotProessState.Text = mtReport.HotProessState;
this.txtPoleSpacing.Text = mtReport.PoleSpacing;
}
else
{
this.hdReportCode.Text = BLL.SQLHelper.RunProcNewIdByProjectId("SpGetNewCodeByProjectId3", "PV_CH_TestingReportPrint", "ReportCode", pro.ProjectId, "MT-" + pro.TestEngineeringCode + "-");
this.txtMTReportCode.Text = this.hdReportCode.Text.Substring(3);
}
BindGrid();
}
}
}
#endregion
#region
/// <summary>
/// 提交按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
var p = Funs.DB.PV_EntrustRecord.FirstOrDefault(s => s.Id == EntrustId);
Model.PV_CH_TestingReportPrint newMTReport = new Model.PV_CH_TestingReportPrint();
newMTReport.WeldingId = this.WeldingId;
if (!string.IsNullOrEmpty(this.TestingReportPrintId))
{
newMTReport = Funs.DB.PV_CH_TestingReportPrint.FirstOrDefault(s => s.TestingReportPrintId == this.TestingReportPrintId);
}
if (p != null)
{
newMTReport.ProjectId = p.ProjectId;
}
newMTReport.Specifications = this.Specifications;
newMTReport.JotyName = this.txtIso_No.Text;
newMTReport.NdtId = this.NDT_ID;
newMTReport.EntrustId = this.EntrustId;
newMTReport.JotyName = this.txtIso_No.Text;
newMTReport.ReportCode = this.hdReportCode.Text.Trim();
newMTReport.ContractUnitId = this.txtContractUnit.Text.Trim();
newMTReport.MT_SurfaceState = this.txtSurfaceState.Text.Trim();
if (this.drpSensitivityTestBlock.SelectedValue != BLL.Const._Null)
{
if (!string.IsNullOrEmpty(this.drpSensitivityTestBlock.Text.Trim()))
{
newMTReport.MT_SensitivityTestBlock = this.drpSensitivityTestBlock.Text.Trim();
}
else
{
newMTReport.MT_SensitivityTestBlock = this.drpSensitivityTestBlock.SelectedValue;
}
}
newMTReport.MT_CurrentType = this.txtCurrentType.Text.Trim();
newMTReport.MT_LiftingPower = this.txtLiftingPower.Text.Trim();
newMTReport.MT_MagnetizationTime = this.txtMagnetizationTime.Text.Trim();
if (this.drpMagneticPowderType.SelectedValue != BLL.Const._Null)
{
if (!string.IsNullOrEmpty(this.drpMagneticPowderType.Text.Trim()))
{
newMTReport.MT_MagneticPowderType = this.drpMagneticPowderType.Text.Trim();
}
else
{
newMTReport.MT_MagneticPowderType = this.drpMagneticPowderType.SelectedValue;
}
}
if (this.drpConcentration.SelectedValue != BLL.Const._Null)
{
if (!string.IsNullOrEmpty(this.drpConcentration.Text.Trim()))
{
newMTReport.MT_Concentration = this.drpConcentration.Text.Trim();
}
else
{
newMTReport.MT_Concentration = this.drpConcentration.SelectedValue;
}
}
newMTReport.MT_ImposingMethod = this.txtImposingMethod.Text.Trim();
if (this.drpTestMethod.SelectedValue != BLL.Const._Null)
{
if (!string.IsNullOrEmpty(this.drpTestMethod.Text.Trim()))
{
newMTReport.MT_TestMethod = this.drpTestMethod.Text.Trim();
}
else
{
newMTReport.MT_TestMethod = this.drpTestMethod.SelectedValue;
}
}
if (this.drpTestingTime.SelectedValue != BLL.Const._Null)
{
if (!string.IsNullOrEmpty(this.drpTestingTime.Text.Trim()))
{
newMTReport.TestingTime = this.drpTestingTime.Text.Trim();
}
else
{
newMTReport.TestingTime = this.drpTestingTime.SelectedValue;
}
}
if (this.drpEquipmentName.SelectedValue != BLL.Const._Null)
{
if (!string.IsNullOrEmpty(this.drpEquipmentName.Text.Trim()))
{
newMTReport.EquipmentName = this.drpEquipmentName.Text.Trim();
}
else
{
newMTReport.EquipmentName = this.drpEquipmentName.SelectedValue;
}
}
if (this.drpEquipmentModel.SelectedValue != BLL.Const._Null)
{
if (!string.IsNullOrEmpty(this.drpEquipmentModel.Text.Trim()))
{
newMTReport.EquipmentCode = this.drpEquipmentModel.Text.Trim();
}
else
{
newMTReport.EquipmentCode = this.drpEquipmentModel.SelectedValue;
}
}
newMTReport.Printer = this.txtPrinter.Text.Trim();
newMTReport.PrintTime = Funs.GetNewDateTime(this.txtPrintTime.Text.Trim());
if (this.drpHotProessState.SelectedValue != BLL.Const._Null)
{
if (!string.IsNullOrEmpty(this.drpHotProessState.Text.Trim()))
{
newMTReport.HotProessState = this.drpHotProessState.Text.Trim();
}
else
{
newMTReport.HotProessState = this.drpHotProessState.SelectedValue;
}
}
newMTReport.PoleSpacing = this.txtPoleSpacing.Text.Trim();
newMTReport.STE_ID = Request.Params["STE_ID"];
newMTReport.STE_ID2 = Request.Params["STE_ID2"];
newMTReport.WME_ID = Request.Params["WME_ID"];
if (string.IsNullOrEmpty(this.TestingReportPrintId))
{
newMTReport.Type = "MT";
this.TestingReportPrintId = SQLHelper.GetNewID(typeof(Model.PV_CH_TestingReportPrint));
newMTReport.TestingReportPrintId = this.TestingReportPrintId;
Funs.DB.PV_CH_TestingReportPrint.InsertOnSubmit(newMTReport);
}
Funs.DB.SubmitChanges();
ShowNotify("提交成功!", MessageBoxIcon.Success);
PageContext.RegisterStartupScript(ActiveWindow.GetHideReference());
}
#endregion
#region
/// <summary>
/// 绑定数据
/// </summary>
private void BindGrid()
{
string strSql = @"SELECT QualityRating.QualityRatingId,
QualityRating.MethodId,
QualityRating.WeldingId,
test.Ndt_NdtCode,
JointInfo.JointDesc,
JointInfo.WeldingCode,
QualityRating.FilmNum,
(select a.pkidStr from (SELECT STUFF(( SELECT ',' +convert(VARCHAR, WED_Code) FROM (select Welder.WED_Code from HJGL_BS_Welder as Welder where Welder.WED_ID in (select Id from StrToTable(JointInfo.BackingWelderId)))t FOR XML PATH('')), 1, 1, '') AS pkidStr) a)+','+(select a.pkidStr from (SELECT STUFF(( SELECT ',' +convert(VARCHAR, WED_Code) FROM (select Welder.WED_Code from HJGL_BS_Welder as Welder where Welder.WED_ID in (select Id from StrToTable(JointInfo.CoverWelderId)))t FOR XML PATH('')), 1, 1, '') AS pkidStr) a) as WED_Code,
QualityRating.DefectNature,
QualityRating.DefectSize,
QualityRating.DefectResult,
QualityRating.Remark
FROM dbo.PV_BO_QualityRating AS QualityRating
left join PV_ManagementMethod as record on record.MethodId=QualityRating.MethodId
LEFT JOIN dbo.PV_EntrustRecord trust ON trust.Id = record.EntrustId
LEFT JOIN DBO.PV_WeldInformation AS JointInfo ON JointInfo.WeldingId=QualityRating.WeldingId
left join PV_TestMethod as test on test.Ndt_Id=trust.NdtId
WHERE QualityRating.WeldingId=@WeldingId
AND JointInfo.JointDesc=@JointDesc
AND JointInfo.TextureMaterial1=@STE_ID AND (JointInfo.TextureMaterial2=@STE_ID2 or @STE_ID2='')
AND JointInfo.WmeId=@WME_ID
AND trust.NdtId = @NDT
AND trust.Id=@EntrustId";
List<SqlParameter> listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@WeldingId", this.WeldingId));
listStr.Add(new SqlParameter("@JointDesc", this.Specifications));
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"]));
listStr.Add(new SqlParameter("@NDT", this.NDT_ID));
listStr.Add(new SqlParameter("@EntrustId", this.EntrustId));
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
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
}
}