protected void grdLaterals_RowDataBound(object sender, GridViewRowEventArgs e) { if ((e.Row.RowType == DataControlRowType.DataRow) && ((e.Row.RowState == DataControlRowState.Normal) || (e.Row.RowState == (DataControlRowState.Normal | DataControlRowState.Alternate)))) { int lateral = int.Parse(((Label)e.Row.FindControl("lblLateral")).Text); if (lateral > 0) { RehabAssessmentLateralDetailsGateway gateway = new RehabAssessmentLateralDetailsGateway(rehabAssessmentTDS); ((TextBox)e.Row.FindControl("tbxMaterial")).Text = gateway.GetMaterialType(lateral); } } // Control of footer controls if (e.Row.RowType == DataControlRowType.Footer) { // For Material ((DropDownList)e.Row.FindControl("ddlNewMaterial")).SelectedIndex = 0; } // Control of edit controls if ((e.Row.RowType == DataControlRowType.DataRow) && ((e.Row.RowState == DataControlRowState.Edit) || (e.Row.RowState == (DataControlRowState.Edit | DataControlRowState.Alternate)))) { int lateral = int.Parse(((Label)e.Row.FindControl("lblLateral")).Text); if (lateral > 0) { RehabAssessmentLateralDetailsGateway gateway = new RehabAssessmentLateralDetailsGateway(rehabAssessmentTDS); int companyId = Int32.Parse(hdfCompanyId.Value); // ... Control material and connection type dropdownlists ((DropDownList)e.Row.FindControl("ddlMaterialEdit")).SelectedValue = gateway.GetMaterialType(lateral); ((DropDownList)e.Row.FindControl("ddlConnectionTypeEdit")).SelectedValue = gateway.GetConnectionType(lateral); // .... If lateral us used in junction lining if (gateway.GetInJlDatabase(lateral)) { if (!LateralsCouldBeDeletedInJl(lateral)) { ((CheckBox)e.Row.FindControl("cbxJlEdit")).Enabled = false; } } // ... Control live value int currentProjectId = Int32.Parse(hdfCurrentProjectId.Value); WorkGateway workGateway = new WorkGateway(); workGateway.LoadByProjectIdAssetIdWorkType(currentProjectId, lateral, "Junction Lining Lateral", companyId); // ... If lateral is not used in junction lining if (!workGateway.ExistsProjectIdAssetIdWorkTypeCompanyId(lateral, currentProjectId, "Junction Lining Lateral", companyId)) { ((DropDownList)e.Row.FindControl("ddlLiveEdit")).Visible = true; ((DropDownList)e.Row.FindControl("ddlLiveEdit")).SelectedValue = gateway.GetLive(lateral); ((TextBox)e.Row.FindControl("tbxJlLive")).Visible = false; } else { ((DropDownList)e.Row.FindControl("ddlLiveEdit")).Visible = false; ((TextBox)e.Row.FindControl("tbxJlLive")).Visible = true; } } } }
/// <summary> /// Update Lateral /// </summary> /// <param name="row">row</param> /// <param name="projectId">projectId</param> /// <param name="sectionAssetId">sectionAssetId</param> /// <param name="countryId">countryId</param> /// <param name="provinceId">provinceId</param> /// <param name="countyId">countyId</param> /// <param name="cityId">cityId</param> /// <param name="videoLength">videoLength</param> /// <param name="companyId">companyId</param> private void UpdateLateral(RehabAssessmentTDS.LateralDetailsRow row, int projectId, int sectionAssetId, Int64 countryId, Int64? provinceId, Int64? countyId, Int64? cityId, string videoLength, int companyId) { // not modified variables RehabAssessmentTDS rehabAssessment = (RehabAssessmentTDS)Data; RehabAssessmentLateralDetailsGateway rehabAssessmentLateralDetailsGateway = new RehabAssessmentLateralDetailsGateway(rehabAssessment); int lateral = row.Lateral; AssetSewerLateralGateway assetSewerLateralGateway = new AssetSewerLateralGateway(); assetSewerLateralGateway.LoadByAssetId(lateral, companyId); int section_ = assetSewerLateralGateway.GetSection(lateral); string lateralId = assetSewerLateralGateway.GetLateralId(lateral); string latitudeAtSection = assetSewerLateralGateway.GetLatitudeAtSection(lateral); string longitudeAtSection = assetSewerLateralGateway.GetLongitudeAtSection(lateral); string latitudeAtPropertyLine = assetSewerLateralGateway.GetLatitudeAtPropertyLine(lateral); string longitudeAtPropertyLine = assetSewerLateralGateway.GetLongitudeAtPropertyLine(lateral); string mapSize = assetSewerLateralGateway.GetMapSize(lateral); // original values string originalState = rehabAssessmentLateralDetailsGateway.GetLiveOriginal(lateral); string originalSize = rehabAssessmentLateralDetailsGateway.GetSizeOriginal(lateral); string originalDistanceFromUsmh = rehabAssessmentLateralDetailsGateway.GetDistanceFromUSMHOriginal(lateral); string originalDistanceFromDsmh = rehabAssessmentLateralDetailsGateway.GetDistanceFromDSMHOriginal(lateral); string originalConnectionType = rehabAssessmentLateralDetailsGateway.GetConnectionTypeOriginal(lateral); string originalAddress = rehabAssessmentLateralDetailsGateway.GetMnOriginal(lateral); // new values string newState = rehabAssessmentLateralDetailsGateway.GetLive(lateral); string newSize = rehabAssessmentLateralDetailsGateway.GetSize(lateral); string newDistanceFromUsmh = rehabAssessmentLateralDetailsGateway.GetDistanceFromUSMH(lateral); string newDistanceFromDsmh = rehabAssessmentLateralDetailsGateway.GetDistanceFromDSMH(lateral); string newConnectionType = rehabAssessmentLateralDetailsGateway.GetConnectionType(lateral); string newAddress = rehabAssessmentLateralDetailsGateway.GetMn(lateral); // update asset laterals AssetSewerLateral assetSewerLateral = new AssetSewerLateral(null); assetSewerLateral.UpdateDirect(lateral, section_, originalAddress, lateralId, latitudeAtSection, longitudeAtSection, latitudeAtPropertyLine, longitudeAtPropertyLine, originalState, originalSize, originalDistanceFromUsmh, originalDistanceFromDsmh, mapSize, false, companyId, originalConnectionType, lateral, section_, newAddress, lateralId, latitudeAtSection, longitudeAtSection, latitudeAtPropertyLine, longitudeAtPropertyLine, newState, newSize, newDistanceFromUsmh, newDistanceFromDsmh, mapSize, false, companyId, newConnectionType); }