/// <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); } } } } }
/// <summary> /// Save a section /// </summary> /// <param name="row">row</param> /// <param name="projectId">projectId</param> /// <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> /// <returns>section_assetId</returns> private int SaveSection(ProjectAddSectionsTDS.ProjectAddSectionsTempRow row, int projectId, Int64? countryId, Int64? provinceId, Int64? countyId, Int64? cityId, int companyId) { string street = ""; if (!row.IsStreetNull()) street = row.Street; string usmh = ""; if (!row.IsUSMHNull()) usmh = row.USMH; string dsmh = ""; if (!row.IsDSMHNull()) dsmh = row.DSMH; string usmhStreet = ""; if (!row.IsUsmhStreetNull()) usmhStreet = row.UsmhStreet; string usmhLatitude = ""; if (!row.IsUsmhLatitudeNull()) usmhLatitude = row.UsmhLatitude; string usmhLongitude = ""; if (!row.IsUsmhLongitudeNull()) usmhLongitude = row.UsmhLongitude; string usmhShape = ""; if (!row.IsUsmhShapeNull()) usmhShape = row.UsmhShape; string usmhLocation = ""; if (!row.IsUsmhLocationNull()) usmhLocation = row.UsmhLocation; int? usmhConditionRating = null; if (!row.IsUsmhConditionRatingNull()) usmhConditionRating = row.UsmhConditionRating; int? usmhMaterialId = null; if (!row.IsUsmhMaterialIdNull()) usmhMaterialId = row.UsmhMaterialId; string usmhTopDiameter = ""; if (!row.IsUsmhTopDiameterNull()) usmhTopDiameter = row.UsmhTopDiameter; string usmhTopDepth = ""; if (!row.IsUsmhTopDepthNull()) usmhTopDepth = row.UsmhTopDepth; string usmhDownDiameter = ""; if (!row.IsUsmhDownDiameterNull()) usmhDownDiameter = row.UsmhDownDiameter; string usmhDownDepth = ""; if (!row.IsUsmhDownDepthNull()) usmhDownDepth = row.UsmhDownDepth; int? usmhManholeRugs = null; if (!row.IsUsmhManholeRugsNull()) usmhManholeRugs = row.UsmhManholeRugs; string usmhRectangle1LongSide = ""; if (!row.IsUsmhRectangle1LongSideNull()) usmhRectangle1LongSide = row.UsmhRectangle1LongSide; string usmhRectangle1ShortSide = ""; if (!row.IsUsmhRectangle1ShortSideNull()) usmhRectangle1ShortSide = row.UsmhRectangle1ShortSide; string usmhRectangle2LongSide = ""; if (!row.IsUsmhRectangle2LongSideNull()) usmhRectangle2LongSide = row.UsmhRectangle2LongSide; string usmhRectangle2ShortSide = ""; if (!row.IsUsmhRectangle2ShortSideNull()) usmhRectangle2ShortSide = row.UsmhRectangle2ShortSide; string usmhTotalSurfaceArea = ""; if (!row.IsUsmhTotalSurfaceAreaNull()) usmhTotalSurfaceArea = row.UsmhTotalSurfaceArea; string dsmhStreet = ""; if (!row.IsDsmhStreetNull()) dsmhStreet = row.DsmhStreet; string dsmhLatitude = ""; if (!row.IsDsmhLatitudeNull()) dsmhLatitude = row.DsmhLatitude; string dsmhLongitude = ""; if (!row.IsDsmhLongitudeNull()) dsmhLongitude = row.DsmhLongitude; string dsmhShape = ""; if (!row.IsDsmhShapeNull()) dsmhShape = row.DsmhShape; string dsmhLocation = ""; if (!row.IsDsmhLocationNull()) dsmhLocation = row.DsmhLocation; int? dsmhConditionRating = null; if (!row.IsDsmhConditionRatingNull()) dsmhConditionRating = row.DsmhConditionRating; int? dsmhMaterialId = null; if (!row.IsDsmhMaterialIdNull()) dsmhMaterialId = row.DsmhMaterialId; string dsmhTopDiameter = ""; if (!row.IsDsmhTopDiameterNull()) dsmhTopDiameter = row.DsmhTopDiameter; string dsmhTopDepth = ""; if (!row.IsDsmhTopDepthNull()) dsmhTopDepth = row.DsmhTopDepth; string dsmhDownDiameter = ""; if (!row.IsDsmhDownDiameterNull()) dsmhDownDiameter = row.DsmhDownDiameter; string dsmhDownDepth = ""; if (!row.IsDsmhDownDepthNull()) dsmhDownDepth = row.DsmhDownDepth; int? dsmhManholeRugs = null; if (!row.IsDsmhManholeRugsNull()) dsmhManholeRugs = row.DsmhManholeRugs; string dsmhRectangle1LongSide = ""; if (!row.IsDsmhRectangle1LongSideNull()) dsmhRectangle1LongSide = row.DsmhRectangle1LongSide; string dsmhRectangle1ShortSide = ""; if (!row.IsDsmhRectangle1ShortSideNull()) dsmhRectangle1ShortSide = row.DsmhRectangle1ShortSide; string dsmhRectangle2LongSide = ""; if (!row.IsDsmhRectangle2LongSideNull()) dsmhRectangle2LongSide = row.DsmhRectangle2LongSide; string dsmhRectangle2ShortSide = ""; if (!row.IsDsmhRectangle2ShortSideNull()) dsmhRectangle2ShortSide = row.DsmhRectangle2ShortSide; string dsmhTotalSurfaceArea = ""; if (!row.IsDsmhTotalSurfaceAreaNull()) dsmhTotalSurfaceArea = row.DsmhTotalSurfaceArea; // insert usmh (if not exists) int? usmh_assetId = null; if (usmh != "") { LfsAssetSewerMH lfsAssetSewerUsmh = new LfsAssetSewerMH(null); usmh_assetId = lfsAssetSewerUsmh.InsertDirect(countryId, provinceId, countyId, cityId, usmh, usmhLatitude, usmhLongitude, usmhStreet, false, companyId, usmhShape, usmhLocation, usmhMaterialId, usmhTopDiameter, usmhTopDepth, "", "", "", usmhDownDiameter, usmhDownDepth, "", "", "", usmhRectangle1LongSide, usmhRectangle1ShortSide, usmhRectangle2LongSide, usmhRectangle2ShortSide, "", "", usmhManholeRugs, "", usmhTotalSurfaceArea, usmhConditionRating); // insert in LFS tables (only if not exists) AssetSewerMHGateway assetSewerMHGateway = new AssetSewerMHGateway(); if (!assetSewerMHGateway.IsUsedInMHProject(projectId, usmh_assetId.Value)) { AssetSewerMHGateway assetSewerMhGatewayForUSMH = new AssetSewerMHGateway(null); assetSewerMhGatewayForUSMH.InsertMHProject(usmh_assetId.Value, projectId, DateTime.Now, false, companyId); } if (row.MHRehabUsmh) { //TODO MH SaveMHRehabWork(projectId, usmh_assetId.Value, companyId); } } // insert dsmh (if not exists) int? dsmh_assetId = null; if (dsmh != "") { LfsAssetSewerMH lfsAssetSewerDsmh = new LfsAssetSewerMH(null); dsmh_assetId = lfsAssetSewerDsmh.InsertDirect(countryId, provinceId, countyId, cityId, dsmh, dsmhLatitude, dsmhLongitude, dsmhStreet, false, companyId, dsmhShape, dsmhLocation, dsmhMaterialId, dsmhTopDiameter, dsmhTopDepth, "", "", "", dsmhDownDiameter, dsmhDownDepth, "", "", "", dsmhRectangle1LongSide, dsmhRectangle1ShortSide, dsmhRectangle2LongSide, dsmhRectangle2ShortSide, "", "", dsmhManholeRugs, "", dsmhTotalSurfaceArea, dsmhConditionRating); // insert in LFS tables (only if not exists) AssetSewerMHGateway assetSewerMHGateway = new AssetSewerMHGateway(); if (!assetSewerMHGateway.IsUsedInMHProject(projectId, dsmh_assetId.Value)) { AssetSewerMHGateway assetSewerMhGatewayForDSMH = new AssetSewerMHGateway(null); assetSewerMhGatewayForDSMH.InsertMHProject(dsmh_assetId.Value, projectId, DateTime.Now, false, companyId); } if (row.MHRehabDsmh) { //TODO MH SaveMHRehabWork(projectId, dsmh_assetId.Value, companyId); } } // insert section LfsAssetSewerSection lfsAssetSewerSection = new LfsAssetSewerSection(null); string mapSize = ""; if (!row.IsMapSizeNull()) mapSize = row.MapSize; string mapLength = ""; if (!row.IsMapLengthNull()) mapLength = row.MapLength; int sectionMaterialRefId = 1; // first material when adding new section string sectionMaterial = ""; if (!row.IsSectionMaterialNull()) sectionMaterial = row.SectionMaterial; DateTime sectionMaterialDate = DateTime.Now; int section_assetId = lfsAssetSewerSection.InsertDirect(countryId, provinceId, countyId, cityId, row.SectionID, street, usmh_assetId, dsmh_assetId, mapSize, "", mapLength, "", null, null, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", false, companyId, "", "", sectionMaterialRefId, sectionMaterial, sectionMaterialDate); return section_assetId; }
protected void cvMhIdFooter_ServerValidate(object source, ServerValidateEventArgs args) { // Validate if mh already exists int companyId = Int32.Parse(hdfCompanyId.Value); string mhId = ((TextBox)grdAddManholeNew.FooterRow.FindControl("tbxMhIdAdd")).Text; Int64? countryId = null; if (hdfCountryId.Value != "0") countryId = Int64.Parse(hdfCountryId.Value); Int64? provinceId = null; if (hdfProvinceId.Value != "0") provinceId = Int64.Parse(hdfProvinceId.Value); Int64? countyId = null; if (hdfCountyId.Value != "0") countyId = Int64.Parse(hdfCountyId.Value); Int64? cityId = null; if (hdfCityId.Value != "0") cityId = Int64.Parse(hdfCityId.Value); int projectId = Convert.ToInt32(ddlProject.SelectedValue); string latitud = ((TextBox)grdAddManholeNew.FooterRow.FindControl("tbxLatitudeAdd")).Text; string longitude = ((TextBox)grdAddManholeNew.FooterRow.FindControl("tbxLongitudeAdd")).Text; string address = ((TextBox)grdAddManholeNew.FooterRow.FindControl("tbxStreetAdd")).Text; AssetSewerMHGateway assetSewerMhGateway = new AssetSewerMHGateway(); assetSewerMhGateway.LoadByCountryIdProvinceIdCountyIdCityIdMhId(countryId, provinceId, countyId, cityId, mhId, companyId, latitud, longitude, address); if (assetSewerMhGateway.Table.Rows.Count > 0) { int assetIdMh = assetSewerMhGateway.GetAssetID(mhId); if (assetSewerMhGateway.IsUsedInMHProject(projectId, assetIdMh)) { args.IsValid = false; } else { assetSewerMhGateway.LoadTop1ByMhIdProjectId(mhId, Convert.ToInt32(ddlProject.SelectedValue), companyId); if (assetSewerMhGateway.Table.Rows.Count > 0) { args.IsValid = false; } else { args.IsValid = true; } } } else { args.IsValid = true; } //AssetSewerMHGateway assetSewerMHGateway = new AssetSewerMHGateway(); //if (ddlProject.SelectedIndex != 0) //{ // assetSewerMHGateway.LoadTop1ByMhIdProjectId(mhId, Convert.ToInt32(ddlProject.SelectedValue), companyId); //} //else //{ // assetSewerMHGateway.LoadTop1ByMhId(mhId, companyId); //} //if (assetSewerMHGateway.Table.Rows.Count > 0) //{ // args.IsValid = false; //} //else //{ // args.IsValid = true; //} }