/// <summary> /// Save all manhole to database (direct) /// </summary> /// <param name="countryId">countryId</param> /// <param name="provinceId">provinceId</param> /// <param name="countyId">countyId</param> /// <param name="cityId">cityId</param> /// <param name="companyId">companyId</param> public void Save(Int64? countryId, Int64? provinceId, Int64? countyId, Int64? cityId, int companyId, int projectId) { AddManholeTDS mrManholesAddChanges = (AddManholeTDS)Data.GetChanges(); if (mrManholesAddChanges.AddManholeNew.Rows.Count > 0) { AddManholeNewGateway addManholeNewGateway = new AddManholeNewGateway(mrManholesAddChanges); foreach (AddManholeTDS.AddManholeNewRow row in (AddManholeTDS.AddManholeNewDataTable)mrManholesAddChanges.AddManholeNew) { // Insert new manhole if ((!row.Deleted) && (!row.InDatabase)) { // ... Insert manhole int? manholeRugs = null; if (!row.IsManholeRugsNull()) manholeRugs = row.ManholeRugs; int? conditionRating = null; if (!row.IsConditionRatingNull()) conditionRating = row.ConditionRating; int? materialId = null; if (!row.IsMaterialIDNull()) materialId = row.MaterialID; LfsAssetSewerMH lfsAssetSewerMH = new LfsAssetSewerMH(); int assetId = lfsAssetSewerMH.InsertDirect(countryId, provinceId, countyId, cityId, row.MHID, row.Latitud, row.Longitude, row.Address, row.Deleted, companyId, row.ManholeShape, row.Location, materialId, row.TopDiameter, row.TopDepth, row.TopFloor, row.TopCeiling, row.TopBenching, row.DownDiameter, row.DownDepth, row.DownFloor, row.DownCeiling, row.DownBenching, row.Rectangle1LongSide, row.Rectangle1ShortSide, row.Rectangle2LongSide, row.Rectangle2ShortSide, row.TopSurfaceArea, row.DownSurfaceArea, manholeRugs, row.TotalDepth, row.TotalSurfaceArea, conditionRating); // insert in LFS tables (only if not exists) AssetSewerMHGateway assetSewerMHGateway = new AssetSewerMHGateway(); if (!assetSewerMHGateway.IsUsedInMHProject(projectId, assetId)) { AssetSewerMHGateway assetSewerMhGateway = new AssetSewerMHGateway(null); assetSewerMhGateway.InsertMHProject(assetId, projectId, DateTime.Now, false, companyId); } } } } }
protected void grdAddManholeNew_RowDataBound(object sender, GridViewRowEventArgs e) { // Edit controls if ((e.Row.RowType == DataControlRowType.DataRow) && ((e.Row.RowState == DataControlRowState.Edit) || (e.Row.RowState == (DataControlRowState.Edit | DataControlRowState.Alternate)))) { int companyId = Int32.Parse(hdfCompanyId.Value); int assetId = Int32.Parse(((Label)e.Row.FindControl("lblAssetID")).Text); AddManholeNewGateway addManholeNewGatewayForGrid = new AddManholeNewGateway(addManholeTDS); if (addManholeNewGatewayForGrid.Table.Rows.Count > 0) { ((DropDownList)e.Row.FindControl("ddlShapeEdit")).SelectedValue = addManholeNewGatewayForGrid.GetManholeShape(assetId); ((DropDownList)e.Row.FindControl("ddlLocationEdit")).SelectedValue = addManholeNewGatewayForGrid.GetLocation(assetId); ((DropDownList)e.Row.FindControl("ddlMaterialEdit")).SelectedValue = addManholeNewGatewayForGrid.GetMaterialID(assetId).ToString(); ((DropDownList)e.Row.FindControl("ddlRehabilitationDataRoundManholeRugsEdit")).SelectedValue = addManholeNewGatewayForGrid.GetManholeRugs(assetId).ToString(); ((DropDownList)e.Row.FindControl("ddlRehabilitationDataRectangularManholeRugsEdit")).SelectedValue = addManholeNewGatewayForGrid.GetManholeRugs(assetId).ToString(); ((DropDownList)e.Row.FindControl("ddlRehabilitationDataMixManholeRugsEdit")).SelectedValue = addManholeNewGatewayForGrid.GetManholeRugs(assetId).ToString(); if (addManholeNewGatewayForGrid.GetConditionRating(assetId).HasValue) { ((DropDownList)e.Row.FindControl("ddlConditioningRatingEdit")).SelectedValue = addManholeNewGatewayForGrid.GetConditionRating(assetId).ToString(); } else { ((DropDownList)e.Row.FindControl("ddlConditioningRatingEdit")).SelectedValue = "-1"; } } switch (addManholeNewGatewayForGrid.GetManholeShape(assetId)) { case "Round": ((Panel)e.Row.FindControl("pnlInformationRoundMHEdit")).Visible = true; ((Panel)e.Row.FindControl("pnlInformationRectangularMHEdit")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationMixedMHEdit")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationOtherMHEdit")).Visible = false; break; case "Rectangular": ((Panel)e.Row.FindControl("pnlInformationRoundMHEdit")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationRectangularMHEdit")).Visible = true; ((Panel)e.Row.FindControl("pnlInformationMixedMHEdit")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationOtherMHEdit")).Visible = false; break; case "Mixed": ((Panel)e.Row.FindControl("pnlInformationRoundMHEdit")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationRectangularMHEdit")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationMixedMHEdit")).Visible = true; ((Panel)e.Row.FindControl("pnlInformationOtherMHEdit")).Visible = false; break; case "Other": ((Panel)e.Row.FindControl("pnlInformationRoundMHEdit")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationRectangularMHEdit")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationMixedMHEdit")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationOtherMHEdit")).Visible = true; break; default: ((Panel)e.Row.FindControl("pnlInformationRoundMHEdit")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationRectangularMHEdit")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationMixedMHEdit")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationOtherMHEdit")).Visible = false; break; }; } // Normal rows if ((e.Row.RowType == DataControlRowType.DataRow) && ((e.Row.RowState == DataControlRowState.Normal) || (e.Row.RowState == (DataControlRowState.Normal | DataControlRowState.Alternate)))) { int companyId = Int32.Parse(hdfCompanyId.Value); int assetId = Int32.Parse(((Label)e.Row.FindControl("lblAssetID")).Text); AddManholeNewGateway addManholeNewGatewayForGrid = new AddManholeNewGateway(addManholeTDS); if (addManholeNewGatewayForGrid.Table.Rows.Count > 0) { ((TextBox)e.Row.FindControl("tbxShape")).Text = addManholeNewGatewayForGrid.GetManholeShape(assetId); ((TextBox)e.Row.FindControl("tbxLocation")).Text = addManholeNewGatewayForGrid.GetLocation(assetId); if (addManholeNewGatewayForGrid.GetConditionRating(assetId).HasValue) { ((TextBox)e.Row.FindControl("tbxConditionRating")).Text = addManholeNewGatewayForGrid.GetConditionRating(assetId).ToString(); } else { ((TextBox)e.Row.FindControl("tbxConditionRating")).Text = ""; } int? materialId = addManholeNewGatewayForGrid.GetMaterialID(assetId); ((TextBox)e.Row.FindControl("tbxMaterial")).Text = ""; if (materialId.HasValue) { AssetSewerMHMaterialTypeGateway assetSewerMHMaterialTypeGateway = new AssetSewerMHMaterialTypeGateway(); assetSewerMHMaterialTypeGateway.LoadByMaterialId((int)materialId, companyId); string materialDescription = assetSewerMHMaterialTypeGateway.GetMaterialType((int)materialId); ((TextBox)e.Row.FindControl("tbxMaterial")).Text = materialDescription; } } switch (((TextBox)e.Row.FindControl("tbxShape")).Text) { case "Round": ((Panel)e.Row.FindControl("pnlInformationRoundMH")).Visible = true; ((Panel)e.Row.FindControl("pnlInformationRectangularMH")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationMixedMH")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationOtherMH")).Visible = false; break; case "Rectangular": ((Panel)e.Row.FindControl("pnlInformationRoundMH")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationRectangularMH")).Visible = true; ((Panel)e.Row.FindControl("pnlInformationMixedMH")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationOtherMH")).Visible = false; break; case "Mixed": ((Panel)e.Row.FindControl("pnlInformationRoundMH")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationRectangularMH")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationMixedMH")).Visible = true; ((Panel)e.Row.FindControl("pnlInformationOtherMH")).Visible = false; break; case "Other": ((Panel)e.Row.FindControl("pnlInformationRoundMH")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationRectangularMH")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationMixedMH")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationOtherMH")).Visible = true; break; default: ((Panel)e.Row.FindControl("pnlInformationRoundMH")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationRectangularMH")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationMixedMH")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationOtherMH")).Visible = false; break; }; } // Footer rows if (e.Row.RowType == DataControlRowType.Footer) { switch (((DropDownList)e.Row.FindControl("ddlShapeAdd")).SelectedValue) { case "Round": ((Panel)e.Row.FindControl("pnlInformationRoundMHAdd")).Visible = true; ((Panel)e.Row.FindControl("pnlInformationRectangularMHAdd")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationMixedMHAdd")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationOtherMHAdd")).Visible = false; break; case "Rectangular": ((Panel)e.Row.FindControl("pnlInformationRoundMHAdd")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationRectangularMHAdd")).Visible = true; ((Panel)e.Row.FindControl("pnlInformationMixedMHAdd")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationOtherMHAdd")).Visible = false; break; case "Mixed": ((Panel)e.Row.FindControl("pnlInformationRoundMHAdd")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationRectangularMHAdd")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationMixedMHAdd")).Visible = true; ((Panel)e.Row.FindControl("pnlInformationOtherMHAdd")).Visible = false; break; case "Other": ((Panel)e.Row.FindControl("pnlInformationRoundMHAdd")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationRectangularMHAdd")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationMixedMHAdd")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationOtherMHAdd")).Visible = true; break; default: ((Panel)e.Row.FindControl("pnlInformationRoundMHAdd")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationRectangularMHAdd")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationMixedMHAdd")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationOtherMHAdd")).Visible = false; break; }; //int companyId = Int32.Parse(hdfCompanyId.Value); //string lastShape = ""; //// ... load last shape used at the grid //foreach (GridViewRow row in grdAddManholeNew.Rows) //{ // lastShape = ((TextBox)row.FindControl("tbxShape")).Text; //} //if (lastShape != "") //{ // ((DropDownList)e.Row.FindControl("ddlShapeAdd")).SelectedValue = lastShape; //} //else //{ // ((DropDownList)e.Row.FindControl("ddlShapeAdd")).SelectedIndex = 0; //} } }