using System; using BLL; using System.Linq; namespace FineUIPro.Web.WeldingProcess.WeldingManage { public partial class JointInfoEdit : PageBase { #region 定义项 /// /// 管线主键 /// private string PipelineId { get { return (string)ViewState["PipelineId"]; } set { ViewState["PipelineId"] = value; } } /// /// 焊口主键 /// public string WeldJointId { get { return (string)ViewState["WeldJointId"]; } set { ViewState["WeldJointId"] = value; } } /// /// 项目主键 /// public string ProjectId { get { return (string)ViewState["ProjectId"]; } set { ViewState["ProjectId"] = value; } } #endregion #region 加载页面 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.WeldJointId = Request.Params["WeldJointId"]; this.PipelineId = Request.Params["PipelineId"]; Model.Pipeline_Pipeline pipeline = BLL.Pipeline_PipelineService.GetPipelineByPipelineId(this.PipelineId); if (pipeline != null) { this.ProjectId = pipeline.ProjectId; } var jointInfo = BLL.Pipeline_WeldJointService.GetViewWeldJointById(this.WeldJointId); if (jointInfo != null) { this.PipelineId = jointInfo.PipelineId; this.ProjectId = jointInfo.ProjectId; } ///初始化下拉框 this.LoadDropDownList(); ///初始化显示信息 this.LoadShowInfo(jointInfo); ////初始化页面信息 this.LoadPageInfo(jointInfo); } } #endregion #region 初始化页面信息 #region 加载下拉框 /// /// 加载下拉框 /// private void LoadDropDownList() { //管道等级 Base_PipingClassService.InitPipingClassDropDownList(this.drpPipingClass, true,Resources.Lan.PleaseSelect); ///焊接区域 //this.drpJointArea.DataTextField = "Text"; //this.drpJointArea.DataValueField = "Value"; //this.drpJointArea.DataSource = BLL.DropListService.HJGL_WLO_CODEItem(); //this.drpJointArea.DataBind(); //Funs.FineUIPleaseSelect(this.drpJointArea,Resources.Lan.PleaseSelect); ///材质1 Base_MaterialService.InitMaterialDropDownList(this.drpMaterial1, true,Resources.Lan.PleaseSelect); ///材质2 Base_MaterialService.InitMaterialDropDownList(this.drpMaterial2, true, Resources.Lan.PleaseSelect); ///焊缝类型 Base_WeldTypeService.InitWeldTypeDropDownList(this.drpWeldType, Resources.Lan.PleaseSelect, false); ///焊接方法 Base_WeldingMethodService.InitWeldingMethodDropDownList(this.drpWeldingMethod, true, Resources.Lan.PleaseSelect); ///坡口类型 Base_GrooveTypeService.InitGrooveTypeDropDownList(this.drpGrooveType, true,Resources.Lan.PleaseSelect); ///焊口属性 this.drpJointAttribute.DataTextField = "Text"; this.drpJointAttribute.DataValueField = "Value"; this.drpJointAttribute.DataSource = BLL.DropListService.HJGL_JointAttributeItem(); this.drpJointAttribute.DataBind(); Funs.FineUIPleaseSelect(this.drpJointAttribute,Resources.Lan.PleaseSelect); ///组件1号 Base_ComponentsService.InitComponentsDropDownList(this.drpPipeAssembly1, true,Resources.Lan.PleaseSelect); ///组件2号 Base_ComponentsService.InitComponentsDropDownList(this.drpPipeAssembly2, true, Resources.Lan.PleaseSelect); ///焊丝 Base_ConsumablesService.InitConsumablesDropDownList(this.drpWeldSilk, true, "1",Resources.Lan.PleaseSelect); ///焊条 Base_ConsumablesService.InitConsumablesDropDownList(this.drpWeldMat, true, "2", Resources.Lan.PleaseSelect); ///焊接位置 this.drpWeldingLocation.DataTextField = "WeldingLocationCode"; this.drpWeldingLocation.DataValueField = "WeldingLocationId"; this.drpWeldingLocation.DataSource = from x in Funs.DB.Base_WeldingLocation orderby x.WeldingLocationCode select x; this.drpWeldingLocation.DataBind(); ///是否热处理 this.drpIsHotProess.DataValueField = "Value"; this.drpIsHotProess.DataTextField = "Text"; this.drpIsHotProess.DataSource = DropListService.IsTrueOrFalseDrpList(); this.drpIsHotProess.DataBind(); Funs.FineUIPleaseSelect(this.drpIsHotProess,Resources.Lan.PleaseSelect); } #endregion #region 加载页面显示信息 /// /// 加载页面显示信息 /// private void LoadShowInfo(Model.View_Pipeline_WeldJoint jointInfo) { this.txtReport.Text = Resources.Lan.WeldingWorkNotDone; this.txtPoint.Text = Resources.Lan.NDTJointNotSelected; this.ddlTrustFlag.Text = Resources.Lan.NotRequested; this.ddlCheckFlag.Text = Resources.Lan.NDTIsNotDone; if (jointInfo != null) { if (!string.IsNullOrEmpty(jointInfo.WeldingDailyId)) { this.txtReport.Text = Resources.Lan.WeldingAlready; this.TextIsReadOnly(true); var dReport = BLL.Pipeline_WeldingDailyService.GetPipeline_WeldingDailyByWeldingDailyId(jointInfo.WeldingDailyId); if (dReport != null) { this.ddlReportCode.Text = dReport.WeldingDailyCode; this.txtReportDate.Text = string.Format("{0:yyyy-MM-dd}", dReport.WeldingDate); this.txtBackingWelder.Text = jointInfo.BackingWelderCode; this.txtBackingWelderName.Text = jointInfo.BackingWelderName; this.txtCoverWelder.Text = jointInfo.CoverWelderCode; this.txtCoverWelderName.Text = jointInfo.CoverWelderName; if (jointInfo.DoneDin != null) { this.txtDoneDia.Text = Convert.ToString(jointInfo.DoneDin); } } } // 焊口状态 var pointStatus = from x in Funs.DB.Batch_PointBatchItem where x.WeldJointId == jointInfo.WeldJointId select x; if (pointStatus.Count() > 0) { this.txtPoint.Text = "已点口"; } // 委托状态 var trustFlag = from x in Funs.DB.Batch_BatchTrustItem where x.WeldJointId == jointInfo.WeldJointId select x; if (trustFlag.Count() > 0) { this.ddlTrustFlag.Text = "已委托"; } // 探伤标志 var checkFlag = from x in Funs.DB.Batch_NDEItem join y in Funs.DB.Batch_BatchTrustItem on x.TrustBatchItemId equals y.TrustBatchItemId join z in Funs.DB.Base_DetectionType on x.DetectionTypeId equals z.DetectionTypeId where y.WeldJointId == jointInfo.WeldJointId select z.DetectionTypeCode ; if (checkFlag.Count() > 0) { string nde = string.Empty; foreach (string n in checkFlag) { nde = nde + n + ","; } if (nde.Length > 0) { this.ddlCheckFlag.Text = nde.Substring(0, nde.Length - 1); } } } ///加载管线、区域、装置、单位 var pipeline = BLL.Pipeline_PipelineService.GetPipelineByPipelineId(this.PipelineId); if (pipeline != null) { this.txtPipelineCode.Text = pipeline.PipelineCode; drpPipingClass.SelectedValue = pipeline.PipingClassId; var workArea = BLL.Project_WorkAreaService.GetProject_WorkAreaByWorkAreaId(pipeline.WorkAreaId); if (workArea != null) { this.txtWorkAreaId.Text = workArea.WorkAreaCode; var installation = BLL.Project_InstallationService.GetProject_InstallationByInstallationId(workArea.InstallationId); if (installation != null) { this.lbInstallationName.Text = installation.InstallationName; } var unit = BLL.Base_UnitService.GetUnit(workArea.UnitId); if (unit != null) { this.lbUnitName.Text = unit.UnitName; } } } } #endregion #region 初始化页面信息 /// /// 初始化页面信息 /// protected void LoadPageInfo(Model.View_Pipeline_WeldJoint jointInfo) { if (jointInfo != null) { this.txtWeldJointCode.Text = jointInfo.WeldJointCode; if (!string.IsNullOrEmpty(jointInfo.PipingClassId)) { this.drpPipingClass.SelectedValue = jointInfo.PipingClassId; } //if (!string.IsNullOrEmpty(jointInfo.JointArea)) //{ // this.drpJointArea.SelectedValue = jointInfo.JointArea; //} this.txtPipeSegment.Text = jointInfo.PipeSegment; if (!string.IsNullOrEmpty(jointInfo.Material1Id)) { this.drpMaterial1.SelectedValue = jointInfo.Material1Id; } if (!string.IsNullOrEmpty(jointInfo.Material2Id)) { this.drpMaterial2.SelectedValue = jointInfo.Material2Id; } if (!string.IsNullOrEmpty(jointInfo.WeldTypeId)) { this.drpWeldType.SelectedValue = jointInfo.WeldTypeId; } this.txtSpecification.Text = jointInfo.Specification; if (jointInfo.Size != null) { this.txtSize.Text = jointInfo.Size.ToString(); } if (jointInfo.Dia != null) { this.txtDia.Text = jointInfo.Dia.ToString(); } if (jointInfo.Thickness != null) { this.txtThickness.Text = jointInfo.Thickness.ToString(); } if (!string.IsNullOrEmpty(jointInfo.WeldingMethodId)) { this.drpWeldingMethod.SelectedValue = jointInfo.WeldingMethodId; } this.txtHeartNo1.Text = jointInfo.HeartNo1; this.txtHeartNo2.Text = jointInfo.HeartNo2; if (!string.IsNullOrEmpty(jointInfo.GrooveTypeId)) { this.drpGrooveType.SelectedValue = jointInfo.GrooveTypeId; } if (!string.IsNullOrEmpty(jointInfo.JointAttribute)) { this.drpJointAttribute.SelectedValue = jointInfo.JointAttribute; } if (!string.IsNullOrEmpty(jointInfo.PipeAssembly1Id)) { this.drpPipeAssembly1.SelectedValue = jointInfo.PipeAssembly1Id; } if (!string.IsNullOrEmpty(jointInfo.PipeAssembly2Id)) { this.drpPipeAssembly2.SelectedValue = jointInfo.PipeAssembly2Id; } if (!string.IsNullOrEmpty(jointInfo.WeldSilkId)) { this.drpWeldSilk.SelectedValue = jointInfo.WeldSilkId; } if (!string.IsNullOrEmpty(jointInfo.WeldMatId)) { this.drpWeldMat.SelectedValue = jointInfo.WeldMatId; } if (!string.IsNullOrEmpty(jointInfo.WeldingLocationId)) { this.drpWeldingLocation.SelectedValue = jointInfo.WeldingLocationId; } if (jointInfo.IsHotProess == true) { this.drpIsHotProess.SelectedValue = BLL.Const._True; } else if (jointInfo.IsHotProess == false) { this.drpIsHotProess.SelectedValue = BLL.Const._False; } if (jointInfo.IsCancel == true) { ckbIsCancel.Checked = true; } this.txtSystemNumber.Text = jointInfo.SystemNumber; this.txtTestPackageNo.Text = jointInfo.TestPackageNo; this.txtRemark.Text = jointInfo.Remark; } } #endregion #region 文本框是否可编辑 /// /// 文本框是否可编辑 /// /// private void TextIsReadOnly(bool readOnly) { //this.btnSave.Hidden = readOnly; this.txtWeldJointCode.Readonly = readOnly; this.drpJointAttribute.Enabled = !readOnly; this.drpPipingClass.Enabled = !readOnly; //this.drpJointArea.Enabled = !readOnly; this.txtPipeSegment.Readonly = readOnly; this.drpPipeAssembly1.Enabled = !readOnly; this.drpPipeAssembly2.Enabled = !readOnly; this.txtHeartNo1.Readonly = readOnly; this.txtHeartNo2.Readonly = readOnly; this.drpMaterial1.Enabled = !readOnly; this.txtSize.Readonly = readOnly; this.txtDia.Readonly = readOnly; this.drpMaterial2.Enabled = !readOnly; this.txtThickness.Readonly = readOnly; //this.txtFactSch.Readonly = readOnly; //this.txtLastTemp.Readonly = readOnly; //this.txtCellTemp.Readonly = readOnly; //this.txtPrepareTemp.Readonly = readOnly; this.drpWeldType.Enabled = !readOnly; this.drpWeldingMethod.Enabled = !readOnly; this.drpWeldSilk.Enabled = !readOnly; this.drpWeldMat.Enabled = !readOnly; this.txtSystemNumber.Readonly = readOnly; //this.txtVoltage.Readonly = readOnly; //this.txtComponentNum.Readonly = readOnly; this.txtTestPackageNo.Readonly = readOnly; //this.txtRemark.Readonly = readOnly; //this.txtPressurePipingGrade.Readonly = readOnly; } #endregion #endregion #region 保存按钮 /// /// 保存按钮 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_JointInfoMenuId, Const.BtnSave)) { if (string.IsNullOrEmpty(this.txtWeldJointCode.Text.Trim()) || this.drpPipingClass.SelectedValue == BLL.Const._Null || this.drpMaterial1.SelectedValue == BLL.Const._Null || this.drpWeldType.SelectedValue == BLL.Const._Null || this.drpJointAttribute.SelectedValue == BLL.Const._Null || string.IsNullOrEmpty(this.txtSize.Text.Trim()) || string.IsNullOrEmpty(this.txtDia.Text.Trim()) || string.IsNullOrEmpty(this.txtThickness.Text.Trim())) { Alert.ShowInTop(Resources.Lan.RequestPages, MessageBoxIcon.Warning); return; } var weldType = BLL.Base_WeldTypeService.GetWeldTypeByWeldTypeId(this.drpWeldType.SelectedValue); if (weldType != null && weldType.WeldTypeCode != "SOB") { if (this.drpWeldingMethod.SelectedValue == BLL.Const._Null) { Alert.ShowInTop("焊接方法不能为空", MessageBoxIcon.Warning); return; } } if (BLL.Pipeline_WeldJointService.IsExistWeldJointCode(this.txtWeldJointCode.Text.Trim(), this.PipelineId, this.WeldJointId)) { Alert.ShowInTop(Resources.Lan.WeldingJointCodeExists, MessageBoxIcon.Warning); return; } Model.Pipeline_WeldJoint newJointInfo = new Model.Pipeline_WeldJoint(); newJointInfo.ProjectId = this.ProjectId; newJointInfo.PipelineId = this.PipelineId; newJointInfo.WeldJointCode = this.txtWeldJointCode.Text.Trim(); if (this.drpPipingClass.SelectedValue != BLL.Const._Null) { newJointInfo.PipingClassId = this.drpPipingClass.SelectedValue; } if (this.drpJointAttribute.SelectedValue != BLL.Const._Null) { newJointInfo.JointAttribute = this.drpJointAttribute.SelectedValue; if (this.drpJointAttribute.SelectedValue == "活动S") { newJointInfo.JointArea = "S"; } else { newJointInfo.JointArea = "F"; } } //if (this.drpJointArea.SelectedValue != BLL.Const._Null) //{ // newJointInfo.JointArea = this.drpJointArea.SelectedValue; //} newJointInfo.PipeSegment = this.txtPipeSegment.Text.Trim(); if (this.drpMaterial1.SelectedValue != BLL.Const._Null) { newJointInfo.Material1Id = this.drpMaterial1.SelectedValue; } if (this.drpMaterial2.SelectedValue != BLL.Const._Null) { newJointInfo.Material2Id = this.drpMaterial2.SelectedValue; } if (this.drpWeldType.SelectedValue != BLL.Const._Null) { newJointInfo.WeldTypeId = this.drpWeldType.SelectedValue; } newJointInfo.Specification = this.txtSpecification.Text.Trim(); newJointInfo.Size = Funs.GetNewDecimal(this.txtSize.Text.Trim()); newJointInfo.Dia = Funs.GetNewDecimal(this.txtDia.Text.Trim()); newJointInfo.Thickness = Funs.GetNewDecimal(this.txtThickness.Text.Trim()); if (this.drpWeldingMethod.SelectedValue != BLL.Const._Null) { newJointInfo.WeldingMethodId = this.drpWeldingMethod.SelectedValue; } newJointInfo.HeartNo1 = this.txtHeartNo1.Text.Trim(); newJointInfo.HeartNo2 = this.txtHeartNo2.Text.Trim(); if (this.drpGrooveType.SelectedValue != BLL.Const._Null) { newJointInfo.GrooveTypeId = this.drpGrooveType.SelectedValue; } if (this.drpPipeAssembly1.SelectedValue != BLL.Const._Null) { newJointInfo.PipeAssembly1Id = this.drpPipeAssembly1.SelectedValue; } if (this.drpPipeAssembly2.SelectedValue != BLL.Const._Null) { newJointInfo.PipeAssembly2Id = this.drpPipeAssembly2.SelectedValue; } if (this.drpWeldSilk.SelectedValue != BLL.Const._Null) { newJointInfo.WeldSilkId = this.drpWeldSilk.SelectedValue; } if (this.drpWeldMat.SelectedValue != BLL.Const._Null) { newJointInfo.WeldMatId = this.drpWeldMat.SelectedValue; } if (this.drpIsHotProess.SelectedValue != BLL.Const._Null) { newJointInfo.IsHotProess = Convert.ToBoolean(this.drpIsHotProess.SelectedValue); } if (this.drpWeldingLocation.SelectedValue != BLL.Const._Null) { newJointInfo.WeldingLocationId = this.drpWeldingLocation.SelectedValue; } newJointInfo.SystemNumber = this.txtSystemNumber.Text.Trim(); newJointInfo.TestPackageNo = this.txtTestPackageNo.Text.Trim(); newJointInfo.Remark = this.txtRemark.Text.Trim(); if (ckbIsCancel.Checked == true) { newJointInfo.IsCancel = true; } if (string.IsNullOrEmpty(this.WeldJointId)) { BLL.Pipeline_WeldJointService.AddWeldJoint(newJointInfo); BLL.Sys_LogService.AddLog(BLL.Const.System_3, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_JointInfoMenuId, Const.BtnAdd, string.Empty); } else { var jointInfo = BLL.Pipeline_WeldJointService.GetWeldJointByWeldJointId(this.WeldJointId); if (!string.IsNullOrEmpty(jointInfo.WeldingDailyId)) { if (txtRemark.Text != "") jointInfo.Remark = txtRemark.Text.Trim(); Funs.DB.SubmitChanges(); } else { newJointInfo.WeldJointId = this.WeldJointId; BLL.Pipeline_WeldJointService.UpdateWeldJoint(newJointInfo); BLL.Sys_LogService.AddLog(BLL.Const.System_3, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_JointInfoMenuId, Const.BtnModify, newJointInfo.WeldJointId); } } PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); ShowNotify(Resources.Lan.SaveSuccessfully, MessageBoxIcon.Success); } else { Alert.ShowInTop(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning); return; } } #endregion protected void ckbIsCancel_OnCheckedChanged(object sender, EventArgs e) { if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_JointInfoMenuId, Const.BtnSave)) { Model.HJGLDB db = Funs.DB; Model.Pipeline_WeldJoint cancel = db.Pipeline_WeldJoint.FirstOrDefault(x => x.WeldJointId == WeldJointId); if (cancel != null) { cancel.IsCancel = ckbIsCancel.Checked; db.SubmitChanges(); PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); ShowNotify(Resources.Lan.SaveSuccessfully, MessageBoxIcon.Success); } } else { Alert.ShowInTop(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning); return; } } #region 外径、壁厚输入框事件 /// /// 选择外径和壁厚自动获取规格 /// /// /// protected void txtText_TextChanged(object sender, EventArgs e) { string dn = string.Empty; string s = string.Empty; if (!string.IsNullOrEmpty(this.txtDia.Text.Trim())) { dn = this.txtDia.Text.Trim(); if (!string.IsNullOrEmpty(this.txtThickness.Text.Trim())) { this.txtSpecification.Text = "Φ" + dn + "*" + this.txtThickness.Text.Trim(); } } } #endregion } }