private void DisplayGeocodeResult(EZGeoSaaS.AddressLocation addressLocation) { // Geocoded Address group txtScore.Text = String.Format("{0:0.0}", addressLocation.Score); String[] address = addressLocation.StandardizedAddress; try { txtGeocodedStreet.Text = address[0]; } catch (Exception) { //Ignore } txtGeocodedCity.Text = addressLocation.CityName; txtGeocodedCounty.Text = addressLocation.County; txtGeocodedState.Text = addressLocation.StateName; txtGeocodedPostalCode.Text = addressLocation.PostalCode; if (!String.IsNullOrEmpty(addressLocation.PostalCodeExtension)) { txtGeocodedPostalCode.Text += "-"; txtGeocodedPostalCode.Text += addressLocation.PostalCodeExtension; } // Cass Address group if (addressLocation.CassAddress != null) { var cassAddress = addressLocation.CassAddress; txtCassStreet.Text = cassAddress.AddressLine; txtCassCity.Text = cassAddress.City; txtCassState.Text = cassAddress.State; txtCassPostalCode.Text = cassAddress.Zip; if (!String.IsNullOrEmpty(cassAddress.Zip4)) { txtCassPostalCode.Text += "-"; txtCassPostalCode.Text += cassAddress.Zip4; } } // Tax Jurisdiction Information group txtJurisdictionCode.Text = addressLocation.PCode.ToString(); txtJurisdictionName.Text = addressLocation.TaxJurisdictionName; txtFIPSCode.Text = addressLocation.FipsCode.ToString("0000000000"); txtFeatureID.Text = addressLocation.FeatureID.ToString(); chkUnincorporated.Checked = !addressLocation.Incorporated && addressLocation.Country .Equals("USA", StringComparison.CurrentCultureIgnoreCase); chkGeocodedSTD.Checked = !String .IsNullOrEmpty(addressLocation.SpecialTaxDistrictName); }
private void btnVerifyAddress_Click(object sender, EventArgs e) { ClearResultFields(); var restoreCursor = Cursor.Current; Cursor.Current = Cursors.WaitCursor; if (String.IsNullOrEmpty(txtStreet.Text) || String.IsNullOrEmpty(txtCityStateZip.Text)) { MessageBox.Show("Street and CityStateZip input required.", "Invalid input data", MessageBoxButtons.OK); return; } if (updateServiceCredentials) { SetServiceCredentials(txtUserName.Text, txtPassword.Text); } EZGeoSaaS.AddressLocation addressLocation = null; EZGeoSaaS.InputAddress inputAddress = GetInputAddress(); try { addressLocation = ezgeoServiceClient.GeocodeAddress(inputAddress); } catch (Exception ex) { MessageBox.Show(ex.Message, "Service Request Failed", MessageBoxButtons.OK); ClearFaultedState(); } if (addressLocation != null) { DisplayGeocodeResult(addressLocation); } else { txtScore.Text = "0.0"; txtGeocodedStreet.Text = "Address not found"; } Cursor.Current = restoreCursor; }