protected void grdLaterals_RowUpdating(object sender, GridViewUpdateEventArgs e) { Page.Validate("AddLateralsEdit"); if (Page.IsValid) { if (((DropDownList)grdLaterals.Rows[e.RowIndex].Cells[2].FindControl("ddlLiveEdit")).Visible == true) { Page.Validate("AddLateralsEditSpecial"); } if (Page.IsValid) { int lateral = int.Parse(((Label)grdLaterals.Rows[e.RowIndex].Cells[1].FindControl("lblLateral")).Text.Trim()); string lateralId = ((TextBox)grdLaterals.Rows[e.RowIndex].Cells[2].FindControl("tbxLateralIdEdit")).Text.Trim(); string clientLateralId = ((TextBox)grdLaterals.Rows[e.RowIndex].Cells[2].FindControl("tbxClientLateralIdEdit")).Text.Trim(); string size = ((TextBox)grdLaterals.Rows[e.RowIndex].Cells[2].FindControl("tbxSizeEdit")).Text.Trim(); // Load material string material = ""; material = ((DropDownList)grdLaterals.Rows[e.RowIndex].Cells[2].FindControl("ddlMaterialEdit")).SelectedValue; // Load lateral state string live = ""; if (((TextBox)grdLaterals.Rows[e.RowIndex].Cells[2].FindControl("tbxJlLive")).Visible == true) { live = "Live"; } else { if (((DropDownList)grdLaterals.Rows[e.RowIndex].Cells[2].FindControl("ddlLiveEdit")).Visible == true) { live = ((DropDownList)grdLaterals.Rows[e.RowIndex].Cells[2].FindControl("ddlLiveEdit")).SelectedValue.Trim(); } } string videoDistance = ((TextBox)grdLaterals.Rows[e.RowIndex].Cells[2].FindControl("tbxVideoDistanceEdit")).Text.Trim(); string clockPosition = ((TextBox)grdLaterals.Rows[e.RowIndex].Cells[2].FindControl("tbxClockPositionEdit")).Text.Trim(); string distanceToCentre = ((TextBox)grdLaterals.Rows[e.RowIndex].Cells[2].FindControl("tbxDistanceToCentreEdit")).Text.Trim(); string timeOpened = ((TextBox)grdLaterals.Rows[e.RowIndex].Cells[2].FindControl("tbxTimeOpenedEdit")).Text.Trim(); // Reverse Setup calculation string reverseSetup = ""; if (videoDistance != "") { Distance videoLength = new Distance(tbxVideoLength.Text.Trim()); Distance videoDistanceD = new Distance(videoDistance); Distance reverseSetupD = videoLength - videoDistanceD; switch (videoDistanceD.DistanceType) { case 1: reverseSetup = reverseSetupD.ToStringInEng1(); break; case 2: reverseSetup = reverseSetupD.ToStringInEng2(); break; case 3: reverseSetup = reverseSetupD.ToStringInEng3(); break; case 4: reverseSetup = reverseSetupD.ToStringInMet1(); break; case 5: reverseSetup = reverseSetupD.ToStringInMil1(); break; } } DateTime? reinstate = null; if (((RadDatePicker)grdLaterals.Rows[e.RowIndex].Cells[2].FindControl("tkrdpReinstateEdit")).SelectedDate.HasValue) { reinstate = ((RadDatePicker)grdLaterals.Rows[e.RowIndex].Cells[2].FindControl("tkrdpReinstateEdit")).SelectedDate.Value; } string comments = ((TextBox)grdLaterals.Rows[e.RowIndex].Cells[2].FindControl("tbxCommentsEdit")).Text.Trim(); bool inProject = ((CheckBox)grdLaterals.Rows[e.RowIndex].Cells[3].FindControl("cbxInProject")).Checked; string connectionType = ""; connectionType = ((DropDownList)grdLaterals.Rows[e.RowIndex].Cells[2].FindControl("ddlConnectionTypeEdit")).SelectedValue; string mn = ""; mn = ((TextBox)grdLaterals.Rows[e.RowIndex].Cells[2].FindControl("tbxMnEdit")).Text.Trim(); string clientInspectionNo = ((TextBox)grdLaterals.Rows[e.RowIndex].Cells[2].FindControl("tbxclientInspectionNoEdit")).Text.Trim(); bool requiredRoboticPrep = ((CheckBox)grdLaterals.Rows[e.RowIndex].Cells[2].FindControl("ckbxRequiresRoboticPrepEdit")).Checked; DateTime? requiredRoboticPrepDate = null; if (((RadDatePicker)grdLaterals.Rows[e.RowIndex].Cells[2].FindControl("tkrdpRequiresRoboticPrepDateEdit")).SelectedDate.HasValue) { requiredRoboticPrepDate = ((RadDatePicker)grdLaterals.Rows[e.RowIndex].Cells[2].FindControl("tkrdpRequiresRoboticPrepDateEdit")).SelectedDate.Value; } bool holdClientIssue = ((CheckBox)grdLaterals.Rows[e.RowIndex].Cells[2].FindControl("ckbxHoldClientIssueEdit")).Checked; bool holdLFSIssue = ((CheckBox)grdLaterals.Rows[e.RowIndex].Cells[2].FindControl("ckbxHoldLFSIssueEdit")).Checked; string flange = ((DropDownList)grdLaterals.Rows[e.RowIndex].Cells[2].FindControl("ddlFlangeEdit")).SelectedValue; bool lineLateral = ((CheckBox)grdLaterals.Rows[e.RowIndex].Cells[2].FindControl("cbxJlEdit")).Checked; ; bool dyeTestReq = ((CheckBox)grdLaterals.Rows[e.RowIndex].Cells[2].FindControl("ckbxDyeTestReqEdit")).Checked; DateTime? dyeTestComplete = null; if (((RadDatePicker)grdLaterals.Rows[e.RowIndex].Cells[2].FindControl("tkrdpDyeTestCompleteEdit")).SelectedDate.HasValue) { dyeTestComplete = ((RadDatePicker)grdLaterals.Rows[e.RowIndex].Cells[2].FindControl("tkrdpDyeTestCompleteEdit")).SelectedDate.Value; } // Update FullLengthLiningLateralDetails lateralModel = new FullLengthLiningLateralDetails(fullLengthLiningTDS); lateralModel.Update(lateral, lateralId, size, material, live, videoDistance, clockPosition, distanceToCentre, timeOpened, reverseSetup, reinstate, comments, inProject, clientLateralId, connectionType, mn, clientInspectionNo, requiredRoboticPrep, requiredRoboticPrepDate, holdClientIssue, holdLFSIssue, lineLateral, flange, lineLateral, dyeTestReq, dyeTestComplete); tbxLaterals.Text = lateralModel.GetTotalLaterals().ToString(); tbxLiveLaterals.Text = lateralModel.GetLiveLaterals().ToString(); // Store dataset Session["fullLengthLiningTDS"] = fullLengthLiningTDS; // Update JL lateral issues FLLateralsSave(lateralId, requiredRoboticPrep, requiredRoboticPrepDate, holdClientIssue, holdLFSIssue, dyeTestReq, dyeTestComplete); } else { e.Cancel = true; } } else { e.Cancel = true; } }