Example #1
0
        public async void BuscarCEP(object sender, EventArgs args)
        {
            //Endereco end = new Endereco();
            //string teste = cep.Text;
            if (cep.Text != null)
            {
                string CEP = cep.Text.Trim();
                if (isValidCEP(CEP))
                {
                    try
                    {
                        Endereco end = await 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 não encontrato para o cep: " + cep, "OK");
                        }
                    }
                    catch (Exception e)
                    {
                        DisplayAlert("Erro Critico", e.Message, "OK");
                    }
                }
            }
            else
            {
                DisplayAlert("ERRO", "CEP Inválido, CEP deve conter 8 caracteres", "Voltar");
            }
        }
        //Rotina que identifica a ocorrência de evento de apertar o botão
        //Para isso os argumentos informados são OBRIGATÓRIOS para a linguagem C#
        private void BuscarCEP(object sender, EventArgs args)
        {
            //Atribuição do valor de texto da variável CEP (tela) para variável cep local
            //Trim() remove espaço em branco do teto passado
            string cep = CEP.Text.Trim();

            if (IsValidCEP(cep))
            {
                //try -> tenta executar, caso contrário, captura o texto de exception
                try
                {
                    Endereco end = ViaCEPServico.BuscarEnderecoViaCep(cep);

                    if (end != null)
                    {
                        RESULTADO.Text = string.Format("Endereço: {1} de {2}, {3} / {0}", end.cep, end.logradouro, end.localidade, end.uf);
                    }
                    else
                    {
                        DisplayAlert("ERRO", "O endereço não foi encontrado para este CEP informado" + cep, "OK");
                    }
                }
                catch (Exception e)
                {
                    DisplayAlert("EERRO CRÍTICO", e.Message, "OK");
                }
            }
        }
        private void BuscarCEP(object sender, EventArgs args)
        {
            //  Lógica do Programa.

            //  Validações.

            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.logradouro, end.bairro, end.localidade, end.uf);
                    }
                    else
                    {
                        DisplayAlert("ERRO", "O CEP NÃO EXISTE", "OK");
                    };
                }
                catch (Exception)
                {
                    DisplayAlert("ERRO CRÍTICO", "Sem Acesso ao Servidor", "OK");
                }
            }
        }
Example #4
0
        private void BuscarCEP(object sender, EventArgs args)
        {
            //TODO - Validações
            string cep = CEP.Text.Trim();

            if (isValidCEP(cep))
            {
                try
                {
                    Endereco end = ViaCEPServico.BuscarEnderecoViaCep(cep);
                    if (end != null)
                    {
                        RESULTADO.Text = $"Endereço: {end.uf}-{end.localidade}, {end.bairro} - {end.logradouro} ";
                    }
                    else
                    {
                        DisplayAlert("ERRO", $"Endereço não encontrado para o cep {cep}", "Ok");
                    }
                }
                catch (Exception ex)
                {
                    DisplayAlert("ERRO CRÍTICO", ex.Message, "Ok");
                }
            }
        }
Example #5
0
        private void BuscarCEP(object send, EventArgs args)
        {
            string cep = CEP.Text.Trim(); //Trim remove todos espaços vazios

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

                    if (end == null)
                    {
                        DisplayAlert("ERRO", "O CEP " + cep + " não existe!", "OK");
                    }
                    else
                    {
                        RESULTADO.Text  = string.Format("Endereço: {0}", end.logradouro);
                        RESULTADO.Text += string.Format("\nBairro: {0}", end.bairro);
                        RESULTADO.Text += string.Format("\nCidade: {0}", end.localidade);
                        RESULTADO.Text += string.Format("\nUF: {0}", end.uf);
                    }
                }
                catch (Exception e)
                {
                    DisplayAlert("ERRO CRÍTICO", e.Message, "OK");
                }
            }
        }
Example #6
0
        private void BuscarCEP(object sender, EventArgs args)
        {
            string cep = EntryCEP.Text.Trim();

            if (ValidarCep(cep))
            {
                try
                {
                    Endereco end = ViaCEPServico.BuscarEnderecoViaCep(cep);

                    if (end != null)
                    {
                        LblResultado.Text = string.Format("Endereço: {2}, {3}, {0}, {1}", end.Localidade, end.Uf, end.Logradouro, end.Bairro);
                    }
                    else
                    {
                        DisplayAlert("ERRO", "Endereço não encontrado para o CEP informado: " + cep, "OK");
                    }
                }
                catch (Exception ex)
                {
                    DisplayAlert("ERRO CRÍTICO: ", ex.Message, "OK");
                }
            }
        }
Example #7
0
        private void BuscarCep(object sender, EventArgs args)
        {
            string cep = CEP.Text.Trim();

            if (isValidCep(cep))
            {
                Endereco end = ViaCEPServico.BuscarEnderecoViaCep(cep);

                RESULTADO.Text = string.Format("Endereço: {0}, {1}, {2}", end.localidade, end.uf, end.logradouro);
            }
        }
        private void BuscarCep(object sender, EventArgs args)
        {
            string cep = txtCep.Text?.Trim();

            lblResultado.Text = "";

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

                    lblResultado.Text = end.ToString();
                }
                catch (Exception ex)
                {
                    DisplayAlert("ERRO CRITICO", ex.Message, "OK");
                }
            }
        }
Example #9
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 = $"Endereço: {end.logradouro} {end.bairro}, {end.localidade},{end.uf}";
                    }
                    else
                    {
                        DisplayAlert("ERRO", "O endereço não foi encontrado para o Cep informado", "OK");
                    }
                }catch (Exception ex)
                {
                    DisplayAlert("Erro Crítico", ex.Message, "OK");
                }
            }
        }
        private void BuscarCEP(object sender, EventArgs args)
        {
            //TODO - Validações


            //Logica do Programa.
            string cep = CEP.Text.Trim();

            if (isValidCEP(cep))
            {
                try
                {
                    Endereco end = ViaCEPServico.BuscarEnderecoViaCep(cep);
                    if (end != null)
                    {
                        RESULTADO.Text = String.Format("Endereço: Cep: {0}" +
                                                       "\n Logradouro: {1}" +
                                                       "\n Complemento: {2}" +
                                                       "\n Bairro: {3}" +
                                                       "\n Localidade: {4}" +
                                                       "\n UF: {5}" +
                                                       "\n Unidade: {6}" +
                                                       "\n IBGE: {7}" +
                                                       "\n Gia: {8}", end.cep, end.logadouro, end.completo, end.bairro, end.localidade, end.uf, end.unidade, end.ibge, end.gia);
                    }
                    else
                    {
                        DisplayAlert("Error", "Endereço nao encontrado para o CEP: " + cep, "OK", "CANCEL");
                    }
                }
                catch (Exception e)
                {
                    DisplayAlert("Error", e.Message, "OK", "Cancel");
                }
            }
        }
Example #11
0
 private void BuscarCEP(object sender, EventArgs args)
 {
     //Validações
     try
     {
         string cep = CEP.Text.Trim();
         if (IsValidCEP(cep))
         {
             Endereco end = ViaCEPServico.BuscarEnderecoViaCep(cep);
             if (end != null)
             {
                 RESULT.Text = string.Format("Endereço: {3}, {0}, {1}, {2}", end.Localidade, end.Uf, end.Logradouro, end.Bairro);
             }
             else
             {
                 DisplayAlert("ERRO: ", "CEP não encontrado! ", "OK");
             }
         }
     }
     catch (Exception ex)
     {
         DisplayAlert("Erro:", ex.Message, "OK");
     }
 }