private void BuscarCEP(object sender, EventArgs args) { string cep = txtCEP.Text.Trim(); if (IsValidCEP(cep)) { try { Endereco end = ViaCEPServico.BuscaEnderecoViaCEP(cep); if (end != null) { lblResultado.Text = string.Format("Endereço: {0}\nBairro: {1}\nCidade: {2}\nEstado: {3} ", end.Logradouro, end.Bairro, end.Localidade, end.Uf); } else { DisplayAlert("ERRO", "O endereço não foi encontrado para o CEP informado: " + cep, "OK"); } } catch (Exception e) { DisplayAlert("ERRO CRÍTICO", e.Message, "OK"); } } }
private void BuscarCEP(object sender, EventArgs args) { //TODO - Validações string cep = CEP.Text.Trim(); if (isValidCEP(cep)) { try { Endereco end = ViaCEPServico.BuscaEnderecoViaCEP(cep); if (end != null) { //Exibir RESULTADO.Text = string.Format("Endereço: {2} de {3} {0},{1} ", end.localidade, end.uf, end.logradouro, end.bairro); } else { DisplayAlert("ERRO", "CEP nao encontrado: " + cep, "OK"); } } catch (Exception e) { DisplayAlert("ERRO CRITICO", e.Message, "OK"); } } }