using BLL; using System; using System.Linq; namespace FineUIPro.Web.HJGL.PreWeld { public partial class FitupCheckEdit : PageBase { public string FitupCheckId { get { return (string)ViewState["FitupCheckId"]; } set { ViewState["FitupCheckId"] = value; } } protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { btnClose.OnClientClick = ActiveWindow.GetHideReference(); FitupCheckId = Request.Params["FitupCheckId"]; var weldJointId = Request.Params["WeldJointId"]; BindWeldJoint(); BindGrooveType(); BindCheckPerson(); ddlCheckResult.SelectedValue = "合格"; if (!string.IsNullOrEmpty(FitupCheckId)) { BindData(); } else if (!string.IsNullOrEmpty(weldJointId)) { drpWeldJoint.SelectedValue = weldJointId; drpWeldJoint.Enabled = false; drpCheckPerson.SelectedValue = CurrUser.PersonId; dpCheckTime.SelectedDate = DateTime.Now; } else { drpCheckPerson.SelectedValue = CurrUser.PersonId; dpCheckTime.SelectedDate = DateTime.Now; } } } private void BindWeldJoint() { using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { var data = (from x in db.HJGL_WeldJoint where x.ProjectId == CurrUser.LoginProjectId orderby x.PipelineCode, x.WeldJointCode select new { x.WeldJointId, WeldJointName = x.PipelineCode + " / " + x.WeldJointCode }).ToList(); drpWeldJoint.DataTextField = "WeldJointName"; drpWeldJoint.DataValueField = "WeldJointId"; drpWeldJoint.DataSource = data; drpWeldJoint.DataBind(); } } private void BindCheckPerson() { Person_PersonsService.InitUserProjectIdUnitIdRoleIdDropDownList(drpCheckPerson, CurrUser.LoginProjectId, null, null, true); } private void BindGrooveType() { drpGrooveType.DataTextField = "BaseInfoName"; drpGrooveType.DataValueField = "BaseInfoId"; drpGrooveType.DataSource = APIBaseInfoService.getGrooveType(); drpGrooveType.DataBind(); } private void BindData() { var model = PreWeldInspectionService.GetFitupCheckById(FitupCheckId); if (model == null) { return; } var weldJoint = APIPreWeldInspectionService.GetPreWeldJointByWeldJointId(model.WeldJointId); if (weldJoint != null) { drpWeldJoint.SelectedValue = weldJoint.WeldJointId; drpWeldJoint.Enabled = false; drpGrooveType.SelectedValue = weldJoint.GrooveTypeId; txtGrooveProcessType.Text = weldJoint.GrooveProcessType; if (weldJoint.GrooveAngle.HasValue) { numGrooveAngle.Text = weldJoint.GrooveAngle.Value.ToString(); } if (weldJoint.FitupGap.HasValue) { numFitupGap.Text = weldJoint.FitupGap.Value.ToString(); } if (weldJoint.Misalignment.HasValue) { numMisalignment.Text = weldJoint.Misalignment.Value.ToString(); } } if (model != null) { drpGrooveType.SelectedValue = model.GrooveTypeId; txtGrooveProcessType.Text = model.GrooveProcessType; if (model.GrooveAngle.HasValue) { numGrooveAngle.Text = model.GrooveAngle.Value.ToString(); } if (model.FitupGap.HasValue) { numFitupGap.Text = model.FitupGap.Value.ToString(); } if (model.Misalignment.HasValue) { numMisalignment.Text = model.Misalignment.Value.ToString(); } if (model.WeldReinforcement.HasValue) { numWeldReinforcement.Text = model.WeldReinforcement.Value.ToString(); } if (model.WeldHeight.HasValue) { numWeldHeight.Text = model.WeldHeight.Value.ToString(); } if (model.WeldWidth.HasValue) { numWeldWidth.Text = model.WeldWidth.Value.ToString(); } txtSurfaceDefect.Text = model.SurfaceDefect; if (!string.IsNullOrEmpty(model.CheckResult)) { ddlCheckResult.SelectedValue = model.CheckResult; } if (!string.IsNullOrEmpty(model.CheckPerson)) { drpCheckPerson.SelectedValue = model.CheckPerson; } dpCheckTime.SelectedDate = model.CheckTime; txtUnqualifiedReason.Text = model.UnqualifiedReason; txtRectifyRequirement.Text = model.RectifyRequirement; txtRemark.Text = model.Remark; } } protected void btnSave_Click(object sender, EventArgs e) { if (!CommonService.GetAllButtonPowerList(CurrUser.LoginProjectId, CurrUser.PersonId, Const.HJGL_PreWeldFitupCheckMenuId, Const.BtnSave)) { Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); return; } var item = new Model.PreWeldFitupCheckInput { FitupCheckId = FitupCheckId, ProjectId = CurrUser.LoginProjectId, WeldJointId = drpWeldJoint.SelectedValue, GrooveTypeId = drpGrooveType.SelectedValue, GrooveProcessType = txtGrooveProcessType.Text.Trim(), GrooveAngle = string.IsNullOrWhiteSpace(numGrooveAngle.Text) ? (decimal?)null : Convert.ToDecimal(numGrooveAngle.Text), FitupGap = string.IsNullOrWhiteSpace(numFitupGap.Text) ? (decimal?)null : Convert.ToDecimal(numFitupGap.Text), Misalignment = string.IsNullOrWhiteSpace(numMisalignment.Text) ? (decimal?)null : Convert.ToDecimal(numMisalignment.Text), WeldReinforcement = string.IsNullOrWhiteSpace(numWeldReinforcement.Text) ? (decimal?)null : Convert.ToDecimal(numWeldReinforcement.Text), WeldHeight = string.IsNullOrWhiteSpace(numWeldHeight.Text) ? (decimal?)null : Convert.ToDecimal(numWeldHeight.Text), WeldWidth = string.IsNullOrWhiteSpace(numWeldWidth.Text) ? (decimal?)null : Convert.ToDecimal(numWeldWidth.Text), SurfaceDefect = txtSurfaceDefect.Text.Trim(), CheckResult = ddlCheckResult.SelectedValue, CheckPerson = drpCheckPerson.SelectedValue, CheckTime = dpCheckTime.SelectedDate ?? DateTime.Now, CreateUser = CurrUser.PersonId, UnqualifiedReason = txtUnqualifiedReason.Text.Trim(), RectifyRequirement = txtRectifyRequirement.Text.Trim(), Remark = txtRemark.Text.Trim() }; FitupCheckId = APIPreWeldInspectionService.SaveFitupCheck(item); ShowNotify("保存成功!", MessageBoxIcon.Success); PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference()); } protected void btnAttachUrl_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(FitupCheckId)) { Alert.ShowInTop("请先保存组对抽检记录后再上传附件!", MessageBoxIcon.Warning); return; } PageContext.RegisterStartupScript(WindowAtt.GetShowReference( string.Format("../../AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/HJGL/PreWeld/FitupCheck&menuId={1}&edit=1&type=-1", FitupCheckId, Const.HJGL_PreWeldFitupCheckMenuId))); } } }