Exemple #1
0
        private void BuscarCEP(object sender, EventArgs e)
        {
            //TODO: Lógica do Programa.
            String cep = CEP.Text.Trim();

            //TODO: Validações.
            if (isCEPValido(cep))
            {
                //TODO: Tratamento das exceções. Tratando cada uma delas individualmente tem maior controle das mensagens.
                try
                {
                    Endereco end = ViaCepServico.BuscarEnderecoViaCEP(cep);

                    if (end != null)
                    {
                        RESULTADO.Text = String.Format("Endereço: {0}, {1} - {2}/{3}", end.logradouro, end.bairro, end.localidade, end.uf);
                    }
                    else
                    {
                        DisplayAlert("ERRO", "O endereço não foi encontrado para o CEP informado: " + CEP.Text, "OK");
                    }
                }
                catch (Exception ex)
                {
                    DisplayAlert("ERRO CRÍTICO", ex.Message, "OK");
                }
            }
        }
Exemple #2
0
        private void BuscarCEP(object sender, EventArgs args)
        {
            string cep = CEP.Text.Trim();

            if (isValidCEP(cep))
            {
                try
                {
                    Endereco end = ViaCepServico.BuscarEnderecoViaCEP(cep);

                    if (end != null)
                    {
                        RESULTADO.Text = string.Format("Endereco: {0}-{1}, {2}, {3} = CEP {4}", end.localidade, end.bairro, end.uf, end.logradouro, end.cep);
                    }
                    else
                    {
                        DisplayAlert("ERRO CRÍTICO", "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 OnBuscarCep(object sender, EventArgs e)
        {
            string cep = Cep.Text;

            if (OnIsValidCep(cep))
            {
                try
                {
                    var end = ViaCepServico.BuscarEnderecoViaCEP(cep.Trim());

                    if (end != null)
                    {
                        Result.Text = $"Endereço: {end.Logradouro} de {end.bairro} {end.localidade},{end.uf} ";
                    }
                    else
                    {
                        DisplayAlert("ERRO", $"O endereço não foi encontrado para o CEP informado: {cep}", "OK");
                    }
                }
                catch (Exception ex)
                {
                    DisplayAlert("ERRO CRÍTICO", ex.Message, "OK");
                }
            }
        }
        /*Evento utilizado pelo evento de clicar do botao*/
        private void BuscarCEP(object sender, EventArgs args)
        {
            //TODO: Program Logic
            string cep = CEP.Text.Trim();

            if (isValidCEP(cep))
            {
                try {
                    Endereco end = ViaCepServico.BuscarEnderecoViaCEP(cep);

                    if (end != null)
                    {
                        RESULTADO.Text = string.Format("Endereco {2} de {3} {0},{1}", end.localidade, end.uf, end.logradouro, end.bairro);
                    }
                    else
                    {
                        DisplayAlert("ERRO 003", "Address did not find for the CEP", "Out");
                    }
                }
                catch (Exception e)
                {
                    DisplayAlert("CRITICAL ERROR 001", e.Message, "Out");
                }
            }
        }
Exemple #5
0
        private async void btBuscar_Click(object sender, EventArgs args)
        {
            try
            {
                // Logica do programa
                string cep = etCep.Text.Trim();

                // Validações
                if (EhCep(cep))
                {
                    Endereco end = await ViaCepServico.BuscarEnderecoViaCEP(cep);

                    if (end == null)
                    {
                        throw new Exception("O endereço não foi encontrado para o CEP informado.");
                    }

                    string resultado = string.Format("Endereço: {0}, {1}, {2}, {3}", end.logradouro, end.bairro, end.localidade, end.uf);

                    lblResultado.Text = resultado;
                }
            }
            catch (Exception erro)
            {
                await DisplayAlert("Erro", erro.Message, "OK");
            }
        }
Exemple #6
0
        private void BuscarCEP(object sender, EventArgs args)
        {
            //todo - Lógica do programa

            var xCep = CEP.Text.Trim();
            //todo - Validações

            if (CEPEhVAlido(xCep))
            {
                try
                {
                    var xEnd = ViaCepServico.BuscarEnderecoViaCEP(xCep);
                    if (xEnd != null)
                        RESULTADO.Text = $"Endereço: {xEnd.Logradouro} - {xEnd.Bairro} - {xEnd.Localidade}, {xEnd.UF}";
                    else
                        DisplayAlert("ERRO", $"O CEP não foi encontrado para o cep informado: {xCep} ", "OK")
                    
                }
                catch (Exception e)
                {
                    DisplayAlert("ERRO CRÍTICO", e.Message, "OK");
                }
                
            }
            
        }
Exemple #7
0
        private void BuscarCEP(object sender, EventArgs e)
        {
            string cep = CEP.Text.Trim();

            if (IsValidCep(cep))
            {
                try
                {
                    var end = ViaCepServico.BuscarEnderecoViaCEP(cep);

                    if (end != null)
                    {
                        RESULTADO.Text = String.Format("Endereço: {0}, {1}, {2}, {3}, {5}", end.logradouro, end.complemento, end.bairoo, end.localidade, end.uf, end.cep);
                    }
                    else
                    {
                        DisplayAlert("ERRO", "O endereço não foi encontrado para o CEP informado: " + cep, "OK");
                    }
                }
                catch (Exception ex)
                {
                    DisplayAlert("ERRO CRÍTICO", ex.Message, "OK");
                    throw;
                }
            }
        }
        private void BuscarCep(object sender, EventArgs args)
        {
            string cep = CEP.Text.Trim();

            if (isValidCep(cep))
            {
                try
                {
                    Endereco end = ViaCepServico.BuscarEnderecoViaCEP(cep);

                    if (end != null)
                    {
                        RESULTADO.Text = string.Format("Endereço:{0},{1},{2},{3},{4},{5}", end.complemento, end.logradouro, end.bairro, end.localidade, end.uf, end.cep);
                    }
                    else
                    {
                        DisplayAlert("ERRO Na Busca", "Não foi encontrado nenhum endereço para o CEP informado!", "OK");
                    }
                }
                catch (Exception e)
                {
                    DisplayAlert("ERRO CRITICO", e.Message, "OK");
                }
            }
        }
        private void BtnCep_Clicked(object sender, EventArgs e)
        {
            string cep = EtCep.Text.Trim();


            if (IsValidCep(cep))
            {
                try
                {
                    Endereco endereco = ViaCepServico.BuscarEnderecoViaCEP(cep);

                    if (endereco != null)
                    {
                        lblResultado.Text = string.Format("Endereco: {0} {1} {2} {3}", endereco.Localidade, endereco.Uf, endereco.Bairro, endereco.Logradouro);
                    }
                    else
                    {
                        DisplayAlert("Erro", "O endereco não foi encontrado para o CEP informado", "OK");
                    }
                }
                catch (Exception ex)
                {
                    DisplayAlert("Erro ", ex.Message, "OK");
                }
            }
        }
Exemple #10
0
        private void BuscarCep(object sender, EventArgs args)
        {
            string cepFormat = txtCep.Text.Trim();

            if (IsValid(cepFormat))
            {
                try
                {
                    Endereco end = ViaCepServico.BuscarEnderecoViaCEP(cepFormat);

                    if (end != null)
                    {
                        lblTexto.Text = string.Format("Endereço: {0},{1} {2}", end.Localidade, end.Logradouro, end.Uf);
                    }
                    else
                    {
                        DisplayAlert("ERRO", "O endereço não foi encontrado para este cep:" + cepFormat, "OK");
                    }
                }
                catch (Exception e)
                {
                    DisplayAlert("Erro Crítico", e.Message, "OK");
                    throw;
                }
            }
        }
        private void BuscarCEP(object sender, EventArgs args)
        {
            string cep = CEP.Text.Trim();

            if (isValid(cep))
            {
                try {
                    Endereco end = ViaCepServico.BuscarEnderecoViaCEP(cep);

                    RESULTADO.Text = string.Format("Endereço: {2}, {3}, {0}-{1}", end.localidade, end.uf, end.logradouro, end.bairro);
                }catch (Exception e)
                {
                    DisplayAlert("ERRO CRÍTICO", e.Message, "OK");
                }
            }
        }
        private void Cep_TextChanged(object sender, TextChangedEventArgs e)
        {
            if (campo_restaurante_cep.Text.Length == 8)
            {
                string CEP = campo_restaurante_cep.Text;

                //MostrarProgresso(true);

                Endereco endereco = ViaCepServico.BuscarEnderecoViaCEP(CEP);
                campo_restaurante_logradouro.Text = endereco.Logradouro;
                campo_restaurante_bairro.Text     = endereco.Bairro;
                campo_restaurante_cidade.Text     = endereco.Cidade;
                campo_restaurante_estado.Text     = endereco.Estado;

                // MostrarProgresso(false);
            }
        }
Exemple #13
0
        private void BuscarCEP(object sender, EventArgs args)
        {
            //TODO - Validações
            string cep = TxtCep.Text.Trim();

            if (isValidoCEP(cep))
            {
                try
                {
                    Endereco end = ViaCepServico.BuscarEnderecoViaCEP(cep);

                    TxtResultado.Text = string.Format("Endereço: {2} de {1},{0} ", end.localidade, end.logradouro, end.uf);
                }
                catch (Exception ex)
                {
                    DisplayAlert(ex.Source, ex.Message, "OK");
                }
            }
        }
        private void BuscarCEP(object sender, EventArgs args)//Metodo tem q receber estes dois parametros
        {
            string cep = CEP.Text.Trim();

            if (isValidCep(cep))
            {
                try
                {
                    Endereco end = ViaCepServico.BuscarEnderecoViaCEP(cep);
                    if (end != null)
                    {
                        RESULTADO.Text = string.Format("Endereco: {0}, {1}, {2}, {3}", end.localidade, end.uf, end.logradouro, end.bairro);
                    }
                    else
                    {
                        DisplayAlert("ERRO", "Endereço nao localizado para o CEP informado: " + CEP, "OK");
                    }
                }catch (Exception e)
                {
                    DisplayAlert("ERRO CRÍTICO", e.Message, "OK");
                }
            }
        }