Пример #1
0
        private void BuscarCep(object sender, EventArgs args)
        {
            //TODO - Validações
            string cep = CEP.Text.Trim();

            if (IsValidCEP(cep))
            {
                try
                {
                    Endereco end = ViaCepService.BuscarEnderecoViaCep(cep);

                    if (end != null)
                    {
                        Resultado.Text = string.Format("Endereço: {2}, de {3} {0}, {1}", end.Localidade, end.Uf, end.Logradouro, end.Bairro);
                    }
                    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)
        {
            var cep = Cep.Text.Trim();

            if (CepValido(cep))
            {
                try
                {
                    var endereco = ViaCepService.BuscarEnderecoViaCep(cep);


                    if (endereco != null)
                    {
                        Resultado.Text = $"Endereço: {endereco.Logradouro}, Bairro {endereco.Bairro}, Cidade {endereco.Localidade} - {endereco.Uf},";
                    }
                    else
                    {
                        DisplayAlert("ERRO", $"O endereço não foi encontrado para o CEP informado: {cep}", "OK");
                    }
                }
                catch (Exception e)
                {
                    DisplayAlert("ERRO CRITICO", e.Message, "OK");
                }
            }
        }
Пример #3
0
        private void BuscarCEP(object sender, EventArgs args)
        {
            //todo logica do programa

            //todo validacoes
            string cep = CEP.Text.Trim();

            if (isValidCep(cep))
            {
                try
                {
                    Endereco end = ViaCepService.BuscarEnderecoViaCep(cep);
                    if (end != null)
                    {
                        RESULTADO.Text = string.Format("Endereço: {0}, {1} {2} {3}  ", end.localidade, end.uf, end.logradouro, end.bairro);
                    }
                    else
                    {
                        DisplayAlert("ERRO", "O Endereço não foi encontrado para o CEP informado" + cep, "OK");
                    }
                }
                catch (Exception e)
                {
                    DisplayAlert("ERRO CRITICO", e.Message, "OK");
                }
            }
        }
Пример #4
0
        private void BuscarCEP(object sender, TextChangedEventArgs args)
        {
            string cep = cep_entry.Text.Trim();

            if (cep.Length == 9)
            {
                try
                {
                    Endereco end = ViaCepService.BuscarEnderecoViaCep(cep);
                    if (end != null)
                    {
                        resultado.Text = string.Format("Endereço: {0}, {1}, {2}", end.UF, end.Logradouro, end.Bairro);
                    }
                    else
                    {
                        DisplayAlert("ERRO", "O endereço não foi encontrado para o CEP informado: " + cep, "OK");
                    }
                    pais_entry.Text       = "Brasil";
                    uf_entry.Text         = end.UF;
                    logradouro_entry.Text = end.Logradouro;
                    bairro_entry.Text     = end.Bairro;
                }
                catch (Exception e)
                {
                    DisplayAlert("ERRO CRÍTICO", e.Message, "OK");
                }
            }
        }
Пример #5
0
        private void BuscarCep(object sender, EventArgs args)
        {
            //TODO - Validações.
            string cep = CEP.Text.Trim();

            if (isValidCEP(cep))
            {
                try {
                    Endereco end = ViaCepService.BuscarEnderecoViaCep(cep);

                    if (end != null)
                    {
                        RESULTADO.Text = $"Endereço: {end.Localidade},{end.Uf}, {end.Logradouro}, {end.Bairro} ";
                    }
                    else
                    {
                        DisplayAlert("ERRO", "o endereço não foi encontrado para o CEP Informado: " + end.Cep, "OK");
                    }
                }
                catch (Exception e)
                {
                    DisplayAlert("ERRO CRIticon", e.Message, "OK");
                }
            }
        }
Пример #6
0
        private void BuscarCEP(object sender, EventArgs args)
        {
            string cep = CEP.Text.Trim();

            if (isValid(cep))
            {
                try {
                    Endereco end = ViaCepService.BuscarEnderecoViaCep(cep);

                    if (end != null)
                    {
                        RESULTADO.Text = "Endereço para o CEP " + cep + ": "
                                         + end.logradouro + ", "
                                         + end.complemento + ", "
                                         + 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", e.Message, "OK");
                }
            }
        }
Пример #7
0
        private async void BuscarCep(object sender, EventArgs args)
        {
            try
            {
                string cep = CEP.Text.Trim();

                ValidaCep(cep);

                Endereco end = await ViaCepService.BuscarEnderecoViaCep(cep);

                RESULTADO.Text = $"Cidade: {end.Localidade}   |   Estado: {end.Uf}   |   Logradouro: {end.Logradouro}   |   Bairro: {end.Bairro}";
            }
            catch (Exception ex)
            {
                await DisplayAlert("Atenção", ex.Message, "OK");
            }
        }
Пример #8
0
        private void BuscarCep(object sender, EventArgs e)
        {
            var cep = txtCep.Text.Trim();

            if (EhCepValido(cep))
            {
                Endereco endereco = ViaCepService.BuscarEnderecoViaCep(cep);

                if (EhEnderecoValido(endereco))
                {
                    lblResultado.Text = $"Endereço: {endereco.Localidade} \n" +
                                        $"UF: {endereco.Uf} \n" +
                                        $"Bairro: {endereco.Bairro} ";
                }
                ;

                txtCep.Text = string.Empty;
            }
        }
Пример #9
0
        private void BuscarCep(object sender, EventArgs args)
        {
            var cep = txtCep.Text.Trim();

            try
            {
                if (IsValidCep(cep))
                {
                    var resultado = ViaCepService.BuscarEnderecoViaCep(cep);
                    lbResultado.Text = $"Endereço: {resultado.Localidade}, {resultado.Uf}, {resultado.Logradouro}";
                }
                else
                {
                    DisplayAlert("Atenção", "Cép inválido!", "Ok");
                    txtCep.Text = "";
                    txtCep.Focus();
                }
            }
            catch (Exception e)
            {
                DisplayAlert("Erro", "Não foi possível encontrar o cep", "Ok");
            }
        }