protected void grdProjectAddSectionsNew_RowDeleting(object sender, GridViewDeleteEventArgs e) { // ProjectAddSectionsNew Gridview, if the gridview is edition mode if (grdProjectAddSectionsNew.EditIndex >= 0) { grdProjectAddSectionsNew.UpdateRow(grdProjectAddSectionsNew.EditIndex, true); } // Delete section int id = (int)e.Keys["ID"]; ProjectAddSectionsTDS dataSet = new ProjectAddSectionsTDS(); dataSet.ProjectAddSectionsNew.Merge(projectAddSectionsNew, true); ProjectAddSectionsNew model = new ProjectAddSectionsNew(dataSet); model.Delete(id); Session["projectAddSectionsNew"] = dataSet.ProjectAddSectionsNew; }
protected void grdProjectAddSectionsNew_RowUpdating(object sender, GridViewUpdateEventArgs e) { // Update section Page.Validate("AddSectionsUpdate"); if (Page.IsValid) { int id = (int)e.Keys["ID"]; int companyId = Int32.Parse(hdfCompanyId.Value); string sectionId = ((Label)grdProjectAddSectionsNew.Rows[e.RowIndex].Cells[0].FindControl("lblSectionIdEdit")).Text; string street = ((TextBox)grdProjectAddSectionsNew.Rows[e.RowIndex].Cells[1].FindControl("tbxStreetEdit")).Text; string usmh = ((TextBox)grdProjectAddSectionsNew.Rows[e.RowIndex].Cells[1].FindControl("tbxUsmhEdit")).Text; string dsmh = ((TextBox)grdProjectAddSectionsNew.Rows[e.RowIndex].Cells[1].FindControl("tbxDsmhEdit")).Text; string mapSize = ((TextBox)grdProjectAddSectionsNew.Rows[e.RowIndex].Cells[1].FindControl("tbxMapSizeEdit")).Text; string mapLength = ((TextBox)grdProjectAddSectionsNew.Rows[e.RowIndex].Cells[1].FindControl("tbxMapLengthEdit")).Text; string clientId = ""; if (((TextBox)grdProjectAddSectionsNew.Rows[e.RowIndex].Cells[1].FindControl("tbxClientIdEdit")).Text.Trim() != "") { clientId = ((TextBox)grdProjectAddSectionsNew.Rows[e.RowIndex].Cells[1].FindControl("tbxClientIdEdit")).Text; } string sectionMaterial = ""; if (((DropDownList)grdProjectAddSectionsNew.Rows[e.RowIndex].FindControl("ddlSectionMaterialEdit")).SelectedValue != "-1") { sectionMaterial = ((DropDownList)grdProjectAddSectionsNew.Rows[e.RowIndex].FindControl("ddlSectionMaterialEdit")).SelectedValue; } bool cbxRA = ((CheckBox)grdProjectAddSectionsNew.Rows[e.RowIndex].FindControl("cbxRehabAssessmentWorkEdit")).Checked; bool cbxFLL = ((CheckBox)grdProjectAddSectionsNew.Rows[e.RowIndex].FindControl("cbxFullLengthLiningWorkEdit")).Checked; bool cbxPR = ((CheckBox)grdProjectAddSectionsNew.Rows[e.RowIndex].FindControl("cbxPointRepairsWorkEdit")).Checked; bool cbxJL = ((CheckBox)grdProjectAddSectionsNew.Rows[e.RowIndex].FindControl("cbxJunctionLiningWorkEdit")).Checked; bool cbxMHRehabUsmh = ((CheckBox)grdProjectAddSectionsNew.Rows[e.RowIndex].FindControl("cbxMHRehabUsmhEdit")).Checked; bool cbxMHRehabDsmh = ((CheckBox)grdProjectAddSectionsNew.Rows[e.RowIndex].FindControl("cbxMHRehabDsmhEdit")).Checked; string usmhStreet = ((TextBox)grdProjectAddSectionsNew.Rows[e.RowIndex].Cells[1].FindControl("tbxUsmhStreetEdit")).Text.Trim(); string usmhLatitude = ((TextBox)grdProjectAddSectionsNew.Rows[e.RowIndex].Cells[1].FindControl("tbxUsmhLatitudeEdit")).Text.Trim(); string usmhLongitude = ((TextBox)grdProjectAddSectionsNew.Rows[e.RowIndex].Cells[1].FindControl("tbxUsmhLongitudeEdit")).Text.Trim(); string usmhShape = ((DropDownList)grdProjectAddSectionsNew.Rows[e.RowIndex].Cells[1].FindControl("ddlUsmhShapeEdit")).SelectedValue; string usmhLocation = ((DropDownList)grdProjectAddSectionsNew.Rows[e.RowIndex].Cells[1].FindControl("ddlUsmhLocationEdit")).SelectedValue; int? usmhConditionRating = null; if (((DropDownList)grdProjectAddSectionsNew.Rows[e.RowIndex].Cells[1].FindControl("ddlUsmhConditionRatingEdit")).SelectedValue != "-1") { usmhConditionRating = Int32.Parse(((DropDownList)grdProjectAddSectionsNew.Rows[e.RowIndex].Cells[1].FindControl("ddlUsmhConditionRatingEdit")).SelectedValue); } int? usmhMaterialId = null; string usmhMaterial = ""; if (((DropDownList)grdProjectAddSectionsNew.Rows[e.RowIndex].Cells[1].FindControl("ddlUsmhMaterialEdit")).SelectedValue != "-1") { usmhMaterialId = Int32.Parse(((DropDownList)grdProjectAddSectionsNew.Rows[e.RowIndex].Cells[1].FindControl("ddlUsmhMaterialEdit")).SelectedValue); AssetSewerMHMaterialTypeGateway assetSewerMHMaterialTypeGatewayForUsmh = new AssetSewerMHMaterialTypeGateway(); assetSewerMHMaterialTypeGatewayForUsmh.LoadByMaterialId((int)usmhMaterialId, companyId); usmhMaterial = assetSewerMHMaterialTypeGatewayForUsmh.GetMaterialType((int)usmhMaterialId); } string dsmhStreet = ((TextBox)grdProjectAddSectionsNew.Rows[e.RowIndex].Cells[1].FindControl("tbxDsmhStreetEdit")).Text.Trim(); string dsmhLatitude = ((TextBox)grdProjectAddSectionsNew.Rows[e.RowIndex].Cells[1].FindControl("tbxDsmhLatitudeEdit")).Text.Trim(); string dsmhLongitude = ((TextBox)grdProjectAddSectionsNew.Rows[e.RowIndex].Cells[1].FindControl("tbxDsmhLongitudeEdit")).Text.Trim(); string dsmhShape = ((DropDownList)grdProjectAddSectionsNew.Rows[e.RowIndex].Cells[1].FindControl("ddlDsmhShapeEdit")).SelectedValue; string dsmhLocation = ((DropDownList)grdProjectAddSectionsNew.Rows[e.RowIndex].Cells[1].FindControl("ddlDsmhLocationEdit")).SelectedValue; int? dsmhConditionRating = null; if (((DropDownList)grdProjectAddSectionsNew.Rows[e.RowIndex].Cells[1].FindControl("ddlDsmhConditionRatingEdit")).SelectedValue != "-1") { dsmhConditionRating = Int32.Parse(((DropDownList)grdProjectAddSectionsNew.Rows[e.RowIndex].Cells[1].FindControl("ddlDsmhConditionRatingEdit")).SelectedValue); } int? dsmhMaterialId = null; string dsmhMaterial = ""; if (((DropDownList)grdProjectAddSectionsNew.Rows[e.RowIndex].Cells[1].FindControl("ddlDsmhMaterialEdit")).SelectedValue != "-1") { dsmhMaterialId = Int32.Parse(((DropDownList)grdProjectAddSectionsNew.Rows[e.RowIndex].Cells[1].FindControl("ddlDsmhMaterialEdit")).SelectedValue); AssetSewerMHMaterialTypeGateway assetSewerMHMaterialTypeGatewayForDsmh = new AssetSewerMHMaterialTypeGateway(); assetSewerMHMaterialTypeGatewayForDsmh.LoadByMaterialId((int)dsmhMaterialId, companyId); dsmhMaterial = assetSewerMHMaterialTypeGatewayForDsmh.GetMaterialType((int)dsmhMaterialId); } // ... get structure data string usmhTopDiameter = ""; string usmhTopDepth = ""; string usmhDownDiameter = ""; string usmhDownDepth = ""; int? usmhManholeRugs = null; string usmhRectangle1LongSide = ""; string usmhRectangle1ShortSide = ""; string usmhRectangle2LongSide = ""; string usmhRectangle2ShortSide = ""; string usmhTotalSurfaceArea = ""; string dsmhTopDiameter = ""; string dsmhTopDepth = ""; string dsmhDownDiameter = ""; string dsmhDownDepth = ""; int? dsmhManholeRugs = null; string dsmhRectangle1LongSide = ""; string dsmhRectangle1ShortSide = ""; string dsmhRectangle2LongSide = ""; string dsmhRectangle2ShortSide = ""; string dsmhTotalSurfaceArea = ""; // Update datasets ProjectAddSectionsTDS dataSet = new ProjectAddSectionsTDS(); dataSet.ProjectAddSectionsNew.Merge(projectAddSectionsNew, true); ProjectAddSectionsNew model = new ProjectAddSectionsNew(dataSet); // Update model.Update(id, sectionId, street, usmh, dsmh, cbxJL, cbxRA, cbxFLL, cbxPR, false, sectionId, mapSize, mapLength, usmhStreet, usmhLatitude, usmhLongitude, usmhShape, usmhLocation, usmhConditionRating, usmhMaterialId, usmhMaterial, usmhTopDiameter, usmhTopDepth, usmhDownDiameter, usmhDownDepth, usmhManholeRugs, usmhRectangle1LongSide, usmhRectangle1ShortSide, usmhRectangle2LongSide, usmhRectangle2ShortSide, usmhTotalSurfaceArea, dsmhStreet, dsmhLatitude, dsmhLongitude, dsmhShape, dsmhLocation, dsmhConditionRating, dsmhMaterialId, dsmhMaterial, dsmhTopDiameter, dsmhTopDepth, dsmhDownDiameter, dsmhDownDepth, dsmhManholeRugs, dsmhRectangle1LongSide, dsmhRectangle1ShortSide, dsmhRectangle2LongSide, dsmhRectangle2ShortSide, dsmhTotalSurfaceArea, sectionMaterial, clientId, cbxMHRehabUsmh, cbxMHRehabDsmh); Session["projectAddSectionsNew"] = dataSet.ProjectAddSectionsNew; projectAddSectionsNew = dataSet.ProjectAddSectionsNew; } else { e.Cancel = true; } }
protected void grdProjectAddSectionsNew_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 id = Int32.Parse(((Label)e.Row.FindControl("lblID")).Text); ProjectAddSectionsTDS dataSet = new ProjectAddSectionsTDS(); dataSet.ProjectAddSectionsNew.Merge(projectAddSectionsNew, true); ProjectAddSectionsNew model = new ProjectAddSectionsNew(dataSet); projectAddSectionsNew = dataSet.ProjectAddSectionsNew; ProjectAddSectionsNewGateway projectAddSectionsNewGatewayForGrid = new ProjectAddSectionsNewGateway(dataSet); if (projectAddSectionsNewGatewayForGrid.Table.Rows.Count > 0) { ((DropDownList)e.Row.FindControl("ddlSectionMaterialEdit")).SelectedValue = projectAddSectionsNewGatewayForGrid.GetSectionMaterial(id).ToString(); ((DropDownList)e.Row.FindControl("ddlUsmhShapeEdit")).SelectedValue = projectAddSectionsNewGatewayForGrid.GetUsmhShape(id); ((DropDownList)e.Row.FindControl("ddlUsmhLocationEdit")).SelectedValue = projectAddSectionsNewGatewayForGrid.GetUsmhLocation(id); ((DropDownList)e.Row.FindControl("ddlUsmhConditionRatingEdit")).SelectedValue = projectAddSectionsNewGatewayForGrid.GetUsmhConditionRating(id).ToString(); ((DropDownList)e.Row.FindControl("ddlUsmhMaterialEdit")).SelectedValue = projectAddSectionsNewGatewayForGrid.GetUsmhMaterialId(id).ToString(); ((DropDownList)e.Row.FindControl("ddlDsmhShapeEdit")).SelectedValue = projectAddSectionsNewGatewayForGrid.GetDsmhShape(id); ((DropDownList)e.Row.FindControl("ddlDsmhLocationEdit")).SelectedValue = projectAddSectionsNewGatewayForGrid.GetDsmhLocation(id); ((DropDownList)e.Row.FindControl("ddlDsmhConditionRatingEdit")).SelectedValue = projectAddSectionsNewGatewayForGrid.GetDsmhConditionRating(id).ToString(); ((DropDownList)e.Row.FindControl("ddlDsmhMaterialEdit")).SelectedValue = projectAddSectionsNewGatewayForGrid.GetDsmhMaterialId(id).ToString(); } } // Footer Item if (e.Row.RowType == DataControlRowType.Footer) { switch (hdfWorkType.Value) { case "All": ((CheckBox)e.Row.FindControl("cbxRehabAssessmentWorkAdd")).Checked = true; ((CheckBox)e.Row.FindControl("cbxFullLengthLiningWorkAdd")).Checked = true; ((CheckBox)e.Row.FindControl("cbxPointRepairsWorkAdd")).Checked = true; ((CheckBox)e.Row.FindControl("cbxJunctionLiningWorkAdd")).Checked = true; ((CheckBox)e.Row.FindControl("cbxMHRehabUsmhAdd")).Checked = true; ((CheckBox)e.Row.FindControl("cbxMHRehabDsmhAdd")).Checked = true; break; case "Rehab Assessment": ((CheckBox)e.Row.FindControl("cbxRehabAssessmentWorkAdd")).Checked = true; ((CheckBox)e.Row.FindControl("cbxFullLengthLiningWorkAdd")).Checked = false; ((CheckBox)e.Row.FindControl("cbxPointRepairsWorkAdd")).Checked = false; ((CheckBox)e.Row.FindControl("cbxJunctionLiningWorkAdd")).Checked = false; ((CheckBox)e.Row.FindControl("cbxMHRehabUsmhAdd")).Checked = false; ((CheckBox)e.Row.FindControl("cbxMHRehabDsmhAdd")).Checked = false; break; case "Full Length Lining": ((CheckBox)e.Row.FindControl("cbxRehabAssessmentWorkAdd")).Checked = false; ((CheckBox)e.Row.FindControl("cbxFullLengthLiningWorkAdd")).Checked = true; ((CheckBox)e.Row.FindControl("cbxPointRepairsWorkAdd")).Checked = false; ((CheckBox)e.Row.FindControl("cbxJunctionLiningWorkAdd")).Checked = false; ((CheckBox)e.Row.FindControl("cbxMHRehabUsmhAdd")).Checked = false; ((CheckBox)e.Row.FindControl("cbxMHRehabDsmhAdd")).Checked = false; break; case "Point Repairs": ((CheckBox)e.Row.FindControl("cbxRehabAssessmentWorkAdd")).Checked = false; ((CheckBox)e.Row.FindControl("cbxFullLengthLiningWorkAdd")).Checked = false; ((CheckBox)e.Row.FindControl("cbxPointRepairsWorkAdd")).Checked = true; ((CheckBox)e.Row.FindControl("cbxJunctionLiningWorkAdd")).Checked = false; ((CheckBox)e.Row.FindControl("cbxMHRehabUsmhAdd")).Checked = false; ((CheckBox)e.Row.FindControl("cbxMHRehabDsmhAdd")).Checked = false; break; case "Junction Lining": ((CheckBox)e.Row.FindControl("cbxRehabAssessmentWorkAdd")).Checked = false; ((CheckBox)e.Row.FindControl("cbxFullLengthLiningWorkAdd")).Checked = false; ((CheckBox)e.Row.FindControl("cbxPointRepairsWorkAdd")).Checked = false; ((CheckBox)e.Row.FindControl("cbxJunctionLiningWorkAdd")).Checked = true; ((CheckBox)e.Row.FindControl("cbxMHRehabUsmhAdd")).Checked = false; ((CheckBox)e.Row.FindControl("cbxMHRehabDsmhAdd")).Checked = false; break; case "Manhole Rehabilitation": ((CheckBox)e.Row.FindControl("cbxRehabAssessmentWorkAdd")).Checked = false; ((CheckBox)e.Row.FindControl("cbxFullLengthLiningWorkAdd")).Checked = false; ((CheckBox)e.Row.FindControl("cbxPointRepairsWorkAdd")).Checked = false; ((CheckBox)e.Row.FindControl("cbxJunctionLiningWorkAdd")).Checked = false; ((CheckBox)e.Row.FindControl("cbxMHRehabUsmhAdd")).Checked = true; ((CheckBox)e.Row.FindControl("cbxMHRehabDsmhAdd")).Checked = true; break; } } }
// //////////////////////////////////////////////////////////////////////// // STEP5 - NEW INTERMEDIATE SECTIONS - AUXILIARY EVENTS // protected void cvSectionId_ServerValidate(object source, ServerValidateEventArgs args) { ProjectAddSectionsTDS dataSet = new ProjectAddSectionsTDS(); dataSet.ProjectAddSectionsNew.Merge(projectAddSectionsNew, true); dataSet.ProjectAddSectionsTemp.Merge(projectAddSectionsTemp, true); ProjectAddSectionsNew projectAddSectionsNewModel = new ProjectAddSectionsNew(dataSet); ProjectAddSectionsTemp projectAddSectionsTempModel = new ProjectAddSectionsTemp(dataSet); // Initialize CustomValidator cvSectionId = (CustomValidator)source; args.IsValid = true; // verify in this step if (projectAddSectionsNewModel.ExistsBySectionId(args.Value)) { cvSectionId.Text = "Duplicated section. (you already have this section here)"; args.IsValid = false; } // verify before added or selected if (args.IsValid) { if (projectAddSectionsTempModel.ExistsBySectionId(args.Value)) { cvSectionId.Text = "Duplicated section. (this section was already created or added previously)"; args.IsValid = false; } } // verify in project with specific work if (args.IsValid) { string workType; switch (hdfWorkType.Value) { case "All": workType = "%"; break; case "Rehab Assessment": workType = "Rehab Assessment"; break; case "Full Length Lining": workType = "Full Length Lining"; break; case "Point Repairs": workType = "Point Repairs"; break; case "Junction Lining": workType = "Junction Lining Section"; break; case "Manhole Rehabilitation": workType = "%"; break; default: throw new Exception("Erroneus work type in Add Section query string."); } WorkGateway workGateway = new WorkGateway(null); if (workGateway.ExistsSectionByProjectIdSectionIdWorkType(int.Parse(hdfProjectId.Value), args.Value, workType, int.Parse(hdfCompanyId.Value))) { cvSectionId.Text = "This section is already associated with this project. (if you would like to see it go to the Sections data of this project)"; args.IsValid = false; } } // verify in project general if (args.IsValid) { Int64? countryId = int.Parse(hdfCountryId.Value); Int64? provinceId = null; if (hdfProvinceId.Value != "") provinceId = Int64.Parse(hdfProvinceId.Value); Int64? countyId = null; if (hdfCountyId.Value != "") countyId = Int64.Parse(hdfCountyId.Value); Int64? cityId = null; if (hdfCityId.Value != "") cityId = Int64.Parse(hdfCityId.Value); int companyId = int.Parse(hdfCompanyId.Value); AssetSewerSectionGateway assetSewerSectionGateway = new AssetSewerSectionGateway(null); if (assetSewerSectionGateway.ExistsByCountryIdProvinceIdCountyIdCityIdSectionId(countryId, provinceId, countyId, cityId, args.Value, companyId)) { cvSectionId.Text = "This section is already in the database. (you can try adding it using the Add Existing Sections option)"; args.IsValid = false; } } }
private bool StepNewSectionsNext() { // Update dataset ProjectAddSectionsTDS dataSet = new ProjectAddSectionsTDS(); dataSet.ProjectAddSectionsNew.Merge(projectAddSectionsNew, true); ProjectAddSectionsNew model = new ProjectAddSectionsNew(dataSet); // Conditions Gridview, if the gridview is edition mode if (grdProjectAddSectionsNew.EditIndex >= 0) { grdProjectAddSectionsNew.UpdateRow(grdProjectAddSectionsNew.EditIndex, false); } if (ValidateProjectAddSectionsFooter()) { Page.Validate("AddSectionsAdd"); if (!Page.IsValid) { return false; } else { bool cbxRA = ((CheckBox)grdProjectAddSectionsNew.FooterRow.FindControl("cbxRehabAssessmentWorkAdd")).Checked; bool cbxFLL = ((CheckBox)grdProjectAddSectionsNew.FooterRow.FindControl("cbxFullLengthLiningWorkAdd")).Checked; bool cbxPR = ((CheckBox)grdProjectAddSectionsNew.FooterRow.FindControl("cbxPointRepairsWorkAdd")).Checked; bool cbxJL = ((CheckBox)grdProjectAddSectionsNew.FooterRow.FindControl("cbxJunctionLiningWorkAdd")).Checked; bool cbxMHRehabUsmh = ((CheckBox)grdProjectAddSectionsNew.FooterRow.FindControl("cbxMHRehabUsmhAdd")).Checked; bool cbxMHRehabDsmh = ((CheckBox)grdProjectAddSectionsNew.FooterRow.FindControl("cbxMHRehabDsmhAdd")).Checked; if (cbxRA || cbxFLL || cbxJL || cbxPR) { // Get values int companyId = Int32.Parse(hdfCompanyId.Value); string street = ((TextBox)grdProjectAddSectionsNew.FooterRow.FindControl("tbxStreetAdd")).Text; string usmh = ((TextBox)grdProjectAddSectionsNew.FooterRow.FindControl("tbxUsmhAdd")).Text; string dsmh = ((TextBox)grdProjectAddSectionsNew.FooterRow.FindControl("tbxDsmhAdd")).Text; string mapSize = ((TextBox)grdProjectAddSectionsNew.FooterRow.FindControl("tbxMapSizeAdd")).Text; string mapLength = ((TextBox)grdProjectAddSectionsNew.FooterRow.FindControl("tbxMapLengthAdd")).Text; string clientId = ""; if (((TextBox)grdProjectAddSectionsNew.FooterRow.FindControl("tbxClientIdAdd")).Text.Trim() != "") { clientId = ((TextBox)grdProjectAddSectionsNew.FooterRow.FindControl("tbxClientIdAdd")).Text; } string sectionMaterial = ""; if (((DropDownList)grdProjectAddSectionsNew.FooterRow.FindControl("ddlSectionMaterialAdd")).SelectedValue != "-1") { sectionMaterial = ((DropDownList)grdProjectAddSectionsNew.FooterRow.FindControl("ddlSectionMaterialAdd")).SelectedValue; } string usmhStreet = ((TextBox)grdProjectAddSectionsNew.FooterRow.FindControl("tbxUsmhStreetAdd")).Text.Trim(); string usmhLatitude = ((TextBox)grdProjectAddSectionsNew.FooterRow.FindControl("tbxUsmhLatitudeAdd")).Text.Trim(); string usmhLongitude = ((TextBox)grdProjectAddSectionsNew.FooterRow.FindControl("tbxUsmhLongitudeAdd")).Text.Trim(); string usmhShape = ((DropDownList)grdProjectAddSectionsNew.FooterRow.FindControl("ddlUsmhShapeAdd")).SelectedValue; string usmhLocation = ((DropDownList)grdProjectAddSectionsNew.FooterRow.FindControl("ddlUsmhLocationAdd")).SelectedValue; int? usmhConditionRating = null; if (((DropDownList)grdProjectAddSectionsNew.FooterRow.FindControl("ddlUsmhConditionRatingAdd")).SelectedValue != "-1") { usmhConditionRating = Int32.Parse(((DropDownList)grdProjectAddSectionsNew.FooterRow.FindControl("ddlUsmhConditionRatingAdd")).SelectedValue); } int? usmhMaterialId = null; string usmhMaterial = ""; if (((DropDownList)grdProjectAddSectionsNew.FooterRow.FindControl("ddlUsmhMaterialAdd")).SelectedValue != "-1") { usmhMaterialId = Int32.Parse(((DropDownList)grdProjectAddSectionsNew.FooterRow.FindControl("ddlUsmhMaterialAdd")).SelectedValue); AssetSewerMHMaterialTypeGateway assetSewerMHMaterialTypeGatewayForUsmh = new AssetSewerMHMaterialTypeGateway(); assetSewerMHMaterialTypeGatewayForUsmh.LoadByMaterialId((int)usmhMaterialId, companyId); usmhMaterial = assetSewerMHMaterialTypeGatewayForUsmh.GetMaterialType((int)usmhMaterialId); } string dsmhStreet = ((TextBox)grdProjectAddSectionsNew.FooterRow.FindControl("tbxDsmhStreetAdd")).Text.Trim(); string dsmhLatitude = ((TextBox)grdProjectAddSectionsNew.FooterRow.FindControl("tbxDsmhLatitudeAdd")).Text.Trim(); string dsmhLongitude = ((TextBox)grdProjectAddSectionsNew.FooterRow.FindControl("tbxDsmhLongitudeAdd")).Text.Trim(); string dsmhShape = ((DropDownList)grdProjectAddSectionsNew.FooterRow.FindControl("ddlDsmhShapeAdd")).SelectedValue; string dsmhLocation = ((DropDownList)grdProjectAddSectionsNew.FooterRow.FindControl("ddlDsmhLocationAdd")).SelectedValue; int? dsmhConditionRating = null; if (((DropDownList)grdProjectAddSectionsNew.FooterRow.FindControl("ddlDsmhConditionRatingAdd")).SelectedValue != "-1") { dsmhConditionRating = Int32.Parse(((DropDownList)grdProjectAddSectionsNew.FooterRow.FindControl("ddlDsmhConditionRatingAdd")).SelectedValue); } int? dsmhMaterialId = null; string dsmhMaterial = ""; if (((DropDownList)grdProjectAddSectionsNew.FooterRow.FindControl("ddlDsmhMaterialAdd")).SelectedValue != "-1") { dsmhMaterialId = Int32.Parse(((DropDownList)grdProjectAddSectionsNew.FooterRow.FindControl("ddlDsmhMaterialAdd")).SelectedValue); AssetSewerMHMaterialTypeGateway assetSewerMHMaterialTypeGatewayForDsmh = new AssetSewerMHMaterialTypeGateway(); assetSewerMHMaterialTypeGatewayForDsmh.LoadByMaterialId((int)dsmhMaterialId, companyId); dsmhMaterial = assetSewerMHMaterialTypeGatewayForDsmh.GetMaterialType((int)dsmhMaterialId); } // ... get structure data string usmhTopDiameter = ""; string usmhTopDepth = ""; string usmhDownDiameter = ""; string usmhDownDepth = ""; int? usmhManholeRugs = null; string usmhRectangle1LongSide = ""; string usmhRectangle1ShortSide = ""; string usmhRectangle2LongSide = ""; string usmhRectangle2ShortSide = ""; string usmhTotalSurfaceArea = ""; string dsmhTopDiameter = ""; string dsmhTopDepth = ""; string dsmhDownDiameter = ""; string dsmhDownDepth = ""; int? dsmhManholeRugs = null; string dsmhRectangle1LongSide = ""; string dsmhRectangle1ShortSide = ""; string dsmhRectangle2LongSide = ""; string dsmhRectangle2ShortSide = ""; string dsmhTotalSurfaceArea = ""; int sectionId = model.Table.Rows.Count + 1; // Insert section if ((street != "") || (usmh != "") || (dsmh != "") || (mapSize != "") || (mapLength != "")) { model.Insert(sectionId.ToString(), street, usmh, dsmh, cbxRA, cbxFLL, cbxPR, cbxJL, false, sectionId.ToString(), mapSize, mapLength, usmhStreet, usmhLatitude, usmhLongitude, usmhShape, usmhLocation, usmhConditionRating, usmhMaterialId, usmhMaterial, usmhTopDiameter, usmhTopDepth, usmhDownDiameter, usmhDownDepth, usmhManholeRugs, usmhRectangle1LongSide, usmhRectangle1ShortSide, usmhRectangle2LongSide, usmhRectangle2ShortSide, usmhTotalSurfaceArea, dsmhStreet, dsmhLatitude, dsmhLongitude, dsmhShape, dsmhLocation, dsmhConditionRating, dsmhMaterialId, dsmhMaterial, dsmhTopDiameter, dsmhTopDepth, dsmhDownDiameter, dsmhDownDepth, dsmhManholeRugs, dsmhRectangle1LongSide, dsmhRectangle1ShortSide, dsmhRectangle2LongSide, dsmhRectangle2ShortSide, dsmhTotalSurfaceArea, sectionMaterial, clientId, cbxMHRehabUsmh, cbxMHRehabDsmh); } } else { return false; } } } // create dataset for temp dataSet.ProjectAddSectionsTemp.Merge(projectAddSectionsTemp, true); // process new sections ProjectAddSectionsTemp modelTemp = new ProjectAddSectionsTemp(dataSet); modelTemp.ProcessNew(); // get changes projectAddSectionsNew.Rows.Clear(); projectAddSectionsTemp.Rows.Clear(); projectAddSectionsTemp.Merge(modelTemp.Table); // store tables Session.Remove("projectAddSectionsNewDummy"); Session["projectAddSectionsNew"] = projectAddSectionsNew; Session["projectAddSectionsTemp"] = projectAddSectionsTemp; return true; }
private bool StepNewIntermediateSectionsNext() { Page.Validate("intermediateData"); if (Page.IsValid) { // Saving new data string secuentialPart = ddlNewIntermediateSectionId.SelectedValue.ToString(); string street = tbxNewIntermediateStreet.Text.Trim(); string usmh = tbxNewIntermediateUsmh.Text.Trim(); string dsmh = tbxNewIntermediateDsmh.Text.Trim(); string mapSize = tbxNewIntermediateMapSize.Text.Trim(); string mapLength = tbxNewIntermediateMapLength.Text.Trim(); ProjectAddSectionsTDS dataSet = new ProjectAddSectionsTDS(); dataSet.ProjectAddSectionsNew.Merge(projectAddSectionsNew, true); ProjectAddSectionsNew intermediateData = new ProjectAddSectionsNew(dataSet); // ... Insert section string countryId = "0"; if (hdfCountryId.Value != "") countryId = hdfCountryId.Value; string provinceId = "0"; if (hdfProvinceId.Value != "") provinceId = hdfProvinceId.Value; string countyId = "0"; if (hdfCountyId.Value != "") countyId = hdfCountyId.Value; string cityId = "0"; if (hdfCityId.Value != "") cityId = hdfCityId.Value; string sectionId = countryId + "." + provinceId + "." + countyId + "." + cityId; sectionId = sectionId + "-" + secuentialPart; string flowOrderId = sectionId.Substring(sectionId.Length - 6, 6); bool rehabAssesswork = false; if (hdfWorkType.Value == "Rehab Assessment") rehabAssesswork = true; bool fullLengthLiningWork = false; if (hdfWorkType.Value == "Full Length Lining") fullLengthLiningWork = true; bool pointRepairsWork = false; if (hdfWorkType.Value == "Point Repairs") pointRepairsWork = true; bool junctionLiningWork = false; if (hdfWorkType.Value == "Junction Lining") junctionLiningWork = true; intermediateData.Insert(sectionId, street, usmh, dsmh, rehabAssesswork, fullLengthLiningWork, pointRepairsWork, junctionLiningWork, false, flowOrderId, mapSize, mapLength, "", "", "", "", "", null, null, "", "", "", "", "", null, "", "", "", "", "", "", "", "", "", "", null, null, "", "", "", "", "", null, "", "", "", "", "", "", "", false, false); // create temp dataset dataSet.ProjectAddSectionsTemp.Merge(projectAddSectionsTemp, true); // process new sections ProjectAddSectionsTemp model = new ProjectAddSectionsTemp(dataSet); model.ProcessNew(); // get changes projectAddSectionsNew.Rows.Clear(); projectAddSectionsTemp.Rows.Clear(); projectAddSectionsTemp.Merge(model.Table); // store tables Session.Remove("projectAddSectionsNewDummy"); Session["projectAddSectionsNew"] = projectAddSectionsNew; Session["projectAddSectionsTemp"] = projectAddSectionsTemp; return true; } return false; }
private void GrdProjectAddSectionsNewAdd() { if (ValidateProjectAddSectionsFooter()) { Page.Validate("AddSectionsAdd"); if (Page.IsValid) { // Get values int companyId = Int32.Parse(hdfCompanyId.Value); string street = ((TextBox)grdProjectAddSectionsNew.FooterRow.FindControl("tbxStreetAdd")).Text; string usmh = ((TextBox)grdProjectAddSectionsNew.FooterRow.FindControl("tbxUsmhAdd")).Text; string dsmh = ((TextBox)grdProjectAddSectionsNew.FooterRow.FindControl("tbxDsmhAdd")).Text; string mapSize = ((TextBox)grdProjectAddSectionsNew.FooterRow.FindControl("tbxMapSizeAdd")).Text; string mapLength = ((TextBox)grdProjectAddSectionsNew.FooterRow.FindControl("tbxMapLengthAdd")).Text; string clientId = ""; if (((TextBox)grdProjectAddSectionsNew.FooterRow.FindControl("tbxClientIdAdd")).Text.Trim() != "") { clientId = ((TextBox)grdProjectAddSectionsNew.FooterRow.FindControl("tbxClientIdAdd")).Text; } string sectionMaterial = ""; if (((DropDownList)grdProjectAddSectionsNew.FooterRow.FindControl("ddlSectionMaterialAdd")).SelectedValue != "-1") { sectionMaterial = ((DropDownList)grdProjectAddSectionsNew.FooterRow.FindControl("ddlSectionMaterialAdd")).SelectedValue; } bool cbxRA = ((CheckBox)grdProjectAddSectionsNew.FooterRow.FindControl("cbxRehabAssessmentWorkAdd")).Checked; bool cbxFLL = ((CheckBox)grdProjectAddSectionsNew.FooterRow.FindControl("cbxFullLengthLiningWorkAdd")).Checked; bool cbxPR = ((CheckBox)grdProjectAddSectionsNew.FooterRow.FindControl("cbxPointRepairsWorkAdd")).Checked; bool cbxJL = ((CheckBox)grdProjectAddSectionsNew.FooterRow.FindControl("cbxJunctionLiningWorkAdd")).Checked; bool cbxMHRehabUsmh = ((CheckBox)grdProjectAddSectionsNew.FooterRow.FindControl("cbxMHRehabUsmhAdd")).Checked; bool cbxMHRehabDsmh = ((CheckBox)grdProjectAddSectionsNew.FooterRow.FindControl("cbxMHRehabDsmhAdd")).Checked; string usmhStreet = ((TextBox)grdProjectAddSectionsNew.FooterRow.FindControl("tbxUsmhStreetAdd")).Text.Trim(); string usmhLatitude = ((TextBox)grdProjectAddSectionsNew.FooterRow.FindControl("tbxUsmhLatitudeAdd")).Text.Trim(); string usmhLongitude = ((TextBox)grdProjectAddSectionsNew.FooterRow.FindControl("tbxUsmhLongitudeAdd")).Text.Trim(); string usmhShape = ((DropDownList)grdProjectAddSectionsNew.FooterRow.FindControl("ddlUsmhShapeAdd")).SelectedValue; string usmhLocation = ((DropDownList)grdProjectAddSectionsNew.FooterRow.FindControl("ddlUsmhLocationAdd")).SelectedValue; int? usmhConditionRating = null; if (((DropDownList)grdProjectAddSectionsNew.FooterRow.FindControl("ddlUsmhConditionRatingAdd")).SelectedValue != "-1") { usmhConditionRating = Int32.Parse(((DropDownList)grdProjectAddSectionsNew.FooterRow.FindControl("ddlUsmhConditionRatingAdd")).SelectedValue); } int? usmhMaterialId = null; string usmhMaterial = ""; if (((DropDownList)grdProjectAddSectionsNew.FooterRow.FindControl("ddlUsmhMaterialAdd")).SelectedValue != "-1") { usmhMaterialId = Int32.Parse(((DropDownList)grdProjectAddSectionsNew.FooterRow.FindControl("ddlUsmhMaterialAdd")).SelectedValue); AssetSewerMHMaterialTypeGateway assetSewerMHMaterialTypeGatewayForUsmh = new AssetSewerMHMaterialTypeGateway(); assetSewerMHMaterialTypeGatewayForUsmh.LoadByMaterialId((int)usmhMaterialId, companyId); usmhMaterial = assetSewerMHMaterialTypeGatewayForUsmh.GetMaterialType((int)usmhMaterialId); } string dsmhStreet = ((TextBox)grdProjectAddSectionsNew.FooterRow.FindControl("tbxDsmhStreetAdd")).Text.Trim(); string dsmhLatitude = ((TextBox)grdProjectAddSectionsNew.FooterRow.FindControl("tbxDsmhLatitudeAdd")).Text.Trim(); string dsmhLongitude = ((TextBox)grdProjectAddSectionsNew.FooterRow.FindControl("tbxDsmhLongitudeAdd")).Text.Trim(); string dsmhShape = ((DropDownList)grdProjectAddSectionsNew.FooterRow.FindControl("ddlDsmhShapeAdd")).SelectedValue; string dsmhLocation = ((DropDownList)grdProjectAddSectionsNew.FooterRow.FindControl("ddlDsmhLocationAdd")).SelectedValue; int? dsmhConditionRating = null; if (((DropDownList)grdProjectAddSectionsNew.FooterRow.FindControl("ddlDsmhConditionRatingAdd")).SelectedValue != "-1") { dsmhConditionRating = Int32.Parse(((DropDownList)grdProjectAddSectionsNew.FooterRow.FindControl("ddlDsmhConditionRatingAdd")).SelectedValue); } int? dsmhMaterialId = null; string dsmhMaterial = ""; if (((DropDownList)grdProjectAddSectionsNew.FooterRow.FindControl("ddlDsmhMaterialAdd")).SelectedValue != "-1") { dsmhMaterialId = Int32.Parse(((DropDownList)grdProjectAddSectionsNew.FooterRow.FindControl("ddlDsmhMaterialAdd")).SelectedValue); AssetSewerMHMaterialTypeGateway assetSewerMHMaterialTypeGatewayForDsmh = new AssetSewerMHMaterialTypeGateway(); assetSewerMHMaterialTypeGatewayForDsmh.LoadByMaterialId((int)dsmhMaterialId, companyId); dsmhMaterial = assetSewerMHMaterialTypeGatewayForDsmh.GetMaterialType((int)dsmhMaterialId); } // ... get structure data string usmhTopDiameter = ""; string usmhTopDepth = ""; string usmhDownDiameter = ""; string usmhDownDepth = ""; int? usmhManholeRugs = null; string usmhRectangle1LongSide = ""; string usmhRectangle1ShortSide = ""; string usmhRectangle2LongSide = ""; string usmhRectangle2ShortSide = ""; string usmhTotalSurfaceArea = ""; string dsmhTopDiameter = ""; string dsmhTopDepth = ""; string dsmhDownDiameter = ""; string dsmhDownDepth = ""; int? dsmhManholeRugs = null; string dsmhRectangle1LongSide = ""; string dsmhRectangle1ShortSide = ""; string dsmhRectangle2LongSide = ""; string dsmhRectangle2ShortSide = ""; string dsmhTotalSurfaceArea = ""; // Update datasets ProjectAddSectionsTDS dataSet = new ProjectAddSectionsTDS(); dataSet.ProjectAddSectionsNew.Merge(projectAddSectionsNew, true); ProjectAddSectionsNew model = new ProjectAddSectionsNew(dataSet); int sectionId = model.Table.Rows.Count + 1; // Insert section model.Insert(sectionId.ToString(), street, usmh, dsmh, cbxRA, cbxFLL, cbxPR, cbxJL, false, sectionId.ToString(), mapSize, mapLength, usmhStreet, usmhLatitude, usmhLongitude, usmhShape, usmhLocation, usmhConditionRating, usmhMaterialId, usmhMaterial, usmhTopDiameter, usmhTopDepth, usmhDownDiameter, usmhDownDepth, usmhManholeRugs, usmhRectangle1LongSide, usmhRectangle1ShortSide, usmhRectangle2LongSide, usmhRectangle2ShortSide, usmhTotalSurfaceArea, dsmhStreet, dsmhLatitude, dsmhLongitude, dsmhShape, dsmhLocation, dsmhConditionRating, dsmhMaterialId, dsmhMaterial, dsmhTopDiameter, dsmhTopDepth, dsmhDownDiameter, dsmhDownDepth, dsmhManholeRugs, dsmhRectangle1LongSide, dsmhRectangle1ShortSide, dsmhRectangle2LongSide, dsmhRectangle2ShortSide, dsmhTotalSurfaceArea, sectionMaterial, clientId, cbxMHRehabUsmh, cbxMHRehabDsmh); // Store data Session.Remove("projectAddSectionsNewDummy"); Session["projectAddSectionsNew"] = dataSet.ProjectAddSectionsNew; grdProjectAddSectionsNew.DataBind(); grdProjectAddSectionsNew.PageIndex = grdProjectAddSectionsNew.PageCount - 1; } } }