protected void grdLaterals_RowDeleting(object sender, GridViewDeleteEventArgs e) { // Laterals Gridview, if the gridview is edition mode if (grdLaterals.EditIndex >= 0) { grdLaterals.UpdateRow(grdLaterals.EditIndex, true); } // Delete laterals int lateral = int.Parse(((Label)grdLaterals.Rows[e.RowIndex].Cells[1].FindControl("lblLateral")).Text); RehabAssessmentLateralDetails model = new RehabAssessmentLateralDetails(rehabAssessmentTDS); // Delete lateral model.Delete(lateral); tbxLaterals.Text = model.GetTotalLaterals().ToString(); tbxLiveLaterals.Text = model.GetLiveLaterals().ToString(); // Store dataset Session["rehabAssessmentTDS"] = rehabAssessmentTDS; }
protected void grdLaterals_RowUpdating(object sender, GridViewUpdateEventArgs e) { Page.Validate("AddLateralsUpdate"); if (Page.IsValid) { if (((DropDownList)grdLaterals.Rows[e.RowIndex].Cells[2].FindControl("ddlLiveEdit")).Visible == true) { Page.Validate("AddLateralsUpdateSpecial"); } 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.ToString().Trim(); // 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 = true; bool inFll = true; bool inJl = ((CheckBox)grdLaterals.Rows[e.RowIndex].Cells[2].FindControl("cbxJlEdit")).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(); DateTime? v1Inspection = null; if (((RadDatePicker)grdLaterals.Rows[e.RowIndex].Cells[2].FindControl("tkrdpV1InspectionEdit")).SelectedDate.HasValue) { v1Inspection = ((RadDatePicker)grdLaterals.Rows[e.RowIndex].Cells[2].FindControl("tkrdpV1InspectionEdit")).SelectedDate.Value; } 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; bool lineLateral = inJl; string flange = ((DropDownList)grdLaterals.Rows[e.RowIndex].Cells[2].FindControl("ddlFlangeEdit")).SelectedValue; 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; } string contractYear = ((TextBox)grdLaterals.Rows[e.RowIndex].Cells[2].FindControl("tbxContractYearEdit")).Text.Trim(); // Update RehabAssessmentLateralDetails lateralModel = new RehabAssessmentLateralDetails(rehabAssessmentTDS); lateralModel.Update(lateral, lateralId, size, material, live, videoDistance, clockPosition, distanceToCentre, timeOpened, reverseSetup, reinstate, comments, inProject, clientLateralId, inFll, inJl, connectionType, mn, clientInspectionNo, v1Inspection, requiredRoboticPrep, requiredRoboticPrepDate, holdClientIssue, holdLFSIssue, lineLateral, flange, dyeTestReq, dyeTestComplete, contractYear); tbxLaterals.Text = lateralModel.GetTotalLaterals().ToString(); tbxLiveLaterals.Text = lateralModel.GetLiveLaterals().ToString(); // Store dataset Session["rehabAssessmentTDS"] = rehabAssessmentTDS; // Update JL lateral issues FLLateralsSave(lateralId, requiredRoboticPrep, requiredRoboticPrepDate, holdClientIssue, holdLFSIssue, dyeTestReq, dyeTestComplete, contractYear); } else { e.Cancel = true; } } else { e.Cancel = true; } }
private void GrdRaAddLateralsNewAdd() { if (ValidateLateralFooter()) { Page.Validate("AddLateralsAdd"); if (Page.IsValid) { string size = ((TextBox)grdLaterals.FooterRow.FindControl("tbxNewSize")).Text.Trim(); string material = ((DropDownList)grdLaterals.FooterRow.FindControl("ddlNewMaterial")).SelectedValue.ToString().Trim(); string live = ((DropDownList)grdLaterals.FooterRow.FindControl("ddlNewLive")).SelectedValue.Trim(); string videoDistance = ((TextBox)grdLaterals.FooterRow.FindControl("tbxNewVideoDistance")).Text.Trim(); string clockPosition = ((TextBox)grdLaterals.FooterRow.FindControl("tbxNewClockPosition")).Text.Trim(); string distanceToCentre = ((TextBox)grdLaterals.FooterRow.FindControl("tbxNewDistanceToCentre")).Text.Trim(); string timeOpened = ""; DateTime? reinstate = null; string comments = ((TextBox)grdLaterals.FooterRow.FindControl("tbxNewComments")).Text.Trim(); // Reverse Setup calculation string reverseSetup = ""; if (videoDistance != "") { Distance videoDistanceD = new Distance(videoDistance); Distance videoLength = new Distance(tbxVideoLength.Text.Trim()); 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; } } bool inProject = true; bool inFll = true; bool inJl = ((CheckBox)grdLaterals.FooterRow.FindControl("cbxNewJl")).Checked; int companyId = Int32.Parse(hdfCompanyId.Value); string lateralId = GetLateralIdIncrement(); string clientLateralId = ((TextBox)grdLaterals.FooterRow.FindControl("tbxNewClientLateralId")).Text.Trim(); string connectionType = ""; connectionType = ((DropDownList)grdLaterals.FooterRow.FindControl("ddlNewConnectionType")).SelectedValue; string mn = ((TextBox)grdLaterals.FooterRow.FindControl("tbxNewMn")).Text.Trim(); string clientInspectionNo = ((TextBox)grdLaterals.FooterRow.FindControl("tbxNewClientInspectionNo")).Text.Trim(); DateTime? v1Inspection = null; if (((RadDatePicker)grdLaterals.FooterRow.FindControl("tkrdpNewV1Inspection")).SelectedDate.HasValue) v1Inspection = ((RadDatePicker)grdLaterals.FooterRow.FindControl("tkrdpNewV1Inspection")).SelectedDate.Value; bool requiresRoboticPrep = ((CheckBox)grdLaterals.FooterRow.FindControl("ckbxRequiresRoboticPrepNew")).Checked; DateTime? requiresRoboticPrepDate = null; if (((RadDatePicker)grdLaterals.FooterRow.FindControl("tkrdpRequiresRoboticPrepDateNew")).SelectedDate.HasValue) { requiresRoboticPrepDate = ((RadDatePicker)grdLaterals.FooterRow.FindControl("tkrdpRequiresRoboticPrepDateNew")).SelectedDate.Value; } bool holdClientIssue = ((CheckBox)grdLaterals.FooterRow.FindControl("ckbxHoldClientIssueNew")).Checked; bool holdLFSIssue = ((CheckBox)grdLaterals.FooterRow.FindControl("ckbxHoldLFSIssueNew")).Checked; bool lineLateral = inJl; string flange = ((DropDownList)grdLaterals.FooterRow.FindControl("ddlFlangeNew")).SelectedValue; bool dyeTestReq = ((CheckBox)grdLaterals.FooterRow.FindControl("ckbxDyeTestReqNew")).Checked; DateTime? dyeTestComplete = null; if (((RadDatePicker)grdLaterals.FooterRow.FindControl("tkrdpDyeTestCompleteNew")).SelectedDate.HasValue) dyeTestComplete = ((RadDatePicker)grdLaterals.FooterRow.FindControl("tkrdpDyeTestCompleteNew")).SelectedDate.Value; string contractYear =((TextBox)grdLaterals.FooterRow.FindControl("tbxNewContractYear")).Text.Trim(); // Insert RehabAssessmentLateralDetails model = new RehabAssessmentLateralDetails(rehabAssessmentTDS); model.Insert(videoDistance, clockPosition, distanceToCentre, timeOpened, reverseSetup, reinstate, comments, lateralId, size, material, false, companyId, inProject, live, clientLateralId, inFll, inJl, connectionType, mn, clientInspectionNo, v1Inspection, requiresRoboticPrep, requiresRoboticPrepDate, holdClientIssue, holdLFSIssue, lineLateral, flange, dyeTestReq, dyeTestComplete, contractYear); // Store datasets Session.Remove("raAddLateralsNewDummy"); Session["rehabAssessmentTDS"] = rehabAssessmentTDS; grdLaterals.DataBind(); grdLaterals.PageIndex = grdLaterals.PageCount - 1; tbxLaterals.Text = model.GetTotalLaterals().ToString(); tbxLiveLaterals.Text = model.GetLiveLaterals().ToString(); } } }