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");
                }
            }
        }
        /*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 #3
0
        private void BuscarCep(object sender, EventArgs args)
        {
            string   cep      = CEP.Text.Trim();
            Endereco endereco = ViaCepServico.BuscarEnderecoViaCep(cep);

            RESULTADO.Text = string.Format("Endereço: {0} , {1} , {2}/{3}", endereco.logradouro, endereco.bairro, endereco.localidade, endereco.uf);
        }
Exemple #4
0
        private void BuscarCEP(object sender, EventArgs args)
        {
            string cep = cCep.Text.Trim();

            if (isValidaCEP(cep))
            {
                try
                {
                    Endereco end = ViaCepServico.BuscarEnderecoViaCep(cep);

                    if (end != null)
                    {
                        cResultado.Text = string.Format("Endereço:" + "{2} de {3} {0},{1}", end.localidade, end.uf, end.bairro);
                    }
                    else
                    {
                        DisplayAlert("Erro", "O endereço não foi encontrad" + "para o CEP informado" + cep, "Ok");
                    }
                }
                catch (Exception e)
                {
                    DisplayAlert("Erro Crítico", e.Message, "Ok");
                }
            }
        }
Exemple #5
0
        private void BuscarCEP(object sender, EventArgs args)
        {
            //Logica 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("Logradouro: {0} " + Environment.NewLine
                                                       + "Complemento: {1} " + Environment.NewLine
                                                       + "Bairro : {2} " + Environment.NewLine
                                                       + "Localidade : {3} " + Environment.NewLine
                                                       + "UF : {4} " + Environment.NewLine,
                                                       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 ex)
                {
                    DisplayAlert("ERRO CRÍTICO", ex.Message, "OK");
                }
            }
        }
Exemple #6
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 #7
0
        private void BuscarCep(object sendert, 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}", end.logradouro, end.bairro, end.localidade, end.uf);
                    }
                    else
                    {
                        DisplayAlert("ATENÇÃO", "Endereço não encontrado", "OK");
                    }
                }
                catch (Exception e)
                {
                    DisplayAlert("ERRO CRÍTICO", e.Message, "OK");
                }
            }
        }
        private void BuscarCEP(object sender, EventArgs args)
        {
            //todo lógica do programa


            //todo Validações

            string cep = CEP.Text.Trim();

            if (IsValidaCEP(cep))
            {
                try
                {
                    Endereco end = ViaCepServico.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 CEP informado não foi localizado :" + cep, "OK");
                    }
                }
                catch (Exception e)
                {
                    DisplayAlert("ERRO CRÍTICO", e.Message, "OK");
                }
            }
        }
Exemple #9
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;
                }
            }
        }
Exemple #10
0
        private void BuscarCEP(object sender, EventArgs args)
        {
            string cep = "";

            //cep recebe o texto da caixa de texto (Entry), retirando espaços iniciais e finais (trim)
            if (CEP.Text != null)
            {
                cep = CEP.Text.Trim();
            }

            //Validações
            if (isValidCEP(cep))
            {
                try {
                    //Passado o cep para o serviço ViaCEP, será retornado o obj Endereço.
                    Endereco end = ViaCepServico.BuscarEnderecoViaCep(cep);

                    if (end != null)
                    {
                        //Inserindo texto na label
                        RESULTADO.Text = string.Format("Endereço: {0}, {1} - {2}, {3}",
                                                       end.logradouro, end.bairro, end.localidade, end.uf);
                    }
                    else
                    {
                        DisplayAlert("CEP inexistente", "Não foi econtrado endereço correspondente ao CEP informado: " + cep, "OK");
                        RESULTADO.Text = "CEP " + cep + " não localizado.";
                    }
                } catch (Exception e) {
                    DisplayAlert("ERRO CRÍTICO", e.Message, "OK");
                }
            }
        }//fim BuscarCEP()
        private void BuscarCep(object sender, EventArgs args)
        {
            //TODO - Lógica do Programa

            //TODO  - validações

            string cep = Cep.Text.Trim();

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

                    if (end != null)
                    {
                        Result.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.Text, "OK");
                    }
                }catch (Exception e)
                {
                    DisplayAlert("ERRO CRITICO", e.Message, "OK");
                }
            }
        }
Exemple #12
0
        public 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: {2} de {3},{0},{1}", end.Localidade, end.Uf, end.Logradouro, end.Bairro);
                    }
                    else
                    {
                        DisplayAlert("ERRO ", "Endereço não foi encontrado", "OK");
                    }
                }
                catch (Exception e)
                {
                    DisplayAlert("ERRO CRÌTICO", e.Message, "OK");
                }
            }
        }
        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");
                }
            }
        }
Exemple #14
0
        private void BuscarCep(object sender, EventArgs args)
        {
            //validate

            //logica

            //search
            string cep = InputCep.Text.Trim();

            cep = cep.Replace("-", "");

            if (IsValidCep(cep))
            {
                try
                {
                    Endereco end = ViaCepServico.BuscarCep(cep);
                    if (end != null)
                    {
                        lbl_result.Text = string.Format("Endereço: {2}, {3}, {0} , {1}, {2}", end.localidade, end.uf, end.logradouro, end.bairro);
                    }
                    else
                    {
                        DisplayAlert("ERRO", "CEP não encontrado, verifique o CEP e tente novamente", "OK");
                    }
                }
                catch (Exception ex)
                {
                    DisplayAlert("ERRO", "O serviço de busca está indisponível./nCódigo do Erro:" + ex.Message, "OK");
                }
            }
            else
            {
                lbl_result.Text = "O CEP digitado é inválido.";
            }
        }
Exemple #15
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(@"Endereço: {0}, {3} {1}-{2}",
                                                       end.Logradouro, end.Localidade, end.Uf, end.Bairro);
                    }
                    else
                    {
                        DisplayAlert("Alerta!", "cep não encontrado", "OK");
                    }
                }
                catch (Exception e)
                {
                    DisplayAlert("ERRO crítipo - Verifique sua rede", e.Message, "OK");
                }
            }
        }
Exemple #16
0
        private void BuscarCep(object sender, EventArgs args)
        {
            string cepDigitado = txtCep.Text.Trim();

            if (isValidCEP(cepDigitado))
            {
                try
                {
                    Endereco e = ViaCepServico.BuscarEnderecoViaCep(cepDigitado);
                    if (e == null)
                    {
                        lblResultado.Text = string.Format("Endereco: {3} {0}, {1} {2}", e.localidade, e.uf, e.logradouro, e.bairro);
                    }
                    else
                    {
                        DisplayAlert("Erro", "Cep não foi encontrado", "OK");
                    }
                } catch (Exception e)
                {
                    DisplayAlert("Erro", "Ocorreram falhas na consulta do CEP", "OK");
                }
            }
            else
            {
                DisplayAlert("Erro", "Cep digitado é inválido!", "OK");
            }
        }
        private void BtnBusca_Clicked(object sender, EventArgs e)
        {
            try
            {
                var cep = etrCep.Text.Trim();

                if (CepValido(cep))
                {
                    var endereco = ViaCepServico.ObtemEnderecoPor(cep);

                    if (endereco != null)
                    {
                        lblResultado.Text = string.Format("Endereço: {0}, {1} - {2}, {3}", endereco.Localidade, endereco.Uf, endereco.Logradouro, endereco.Bairro);
                    }
                    else
                    {
                        DisplayAlert("INFO", string.Format("Nenhum endereço foi encontrato para o CEP {0}.", cep), "OK");
                    }
                }
            }
            catch (Exception ex)
            {
                DisplayAlert("ERRO", ex.Message, "OK");
            }
        }
 private void BuscarCep(object sender, EventArgs args)
 {
     try {
         string cep = CEP.Text.Trim();
         validacao.Text = "";
         if (isValid(cep))
         {
             try {
                 Endereco end = ViaCepServico.BuscarEnderecoViaCep(cep);
                 if (end != null)
                 {
                     Resultado.IsVisible = true;
                     Resultado.Text      = string.Format($"CEP {cep}\n\n{end.logradouro} - {end.bairro} - {end.localidade}/{end.uf}");
                 }
                 else
                 {
                     Resultado.Text = "Não foi encontrado nenhum endereço correspondente ao CEP digitado";
                 }
             }
             catch (Exception e) {
                 Resultado.Text = "Verifique sua conexão com a internet";
             }
         }
         else
         {
             CEP.Text = "";
         }
     }
     catch (Exception i) {
         validacao.Text = "Digite um CEP";
     }
 }
Exemple #19
0
        private void BuscarCep(object sender, EventArgs args)
        {
            var cep = EntCep.Text.Trim();

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

                    if (end != null)
                    {
                        lblResultado.Text = string.Format("Endereço: {2} de {3} {0},{1}", end.localidade, end.uf, end.logradouro, end.bairro);
                    }
                    else
                    {
                        DisplayAlert("ERRO", "O enderço não foi encontrado para o CEP informado " + cep, "OK");
                    }
                }
                catch (Exception ex)
                {
                    DisplayAlert("ERRO EXCEPTION", ex.Message, "OK");
                }
            }
        }
Exemple #20
0
        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)
                    {
                        RESULTADO.Text = string.Format("Endereço: {2} de {3} {0},{1}  ",
                                                       end.Localidade,
                                                       end.Uf,
                                                       end.Logradouro,
                                                       end.Bairro);
                        CEP.Text = "";
                    }
                    else
                    {
                        DisplayAlert("ERRO", "Endereço não Encontrado para o CEP Digitado: " + cep, "Ok");
                        CEP.Text = "";
                    }
                }
                catch (Exception e)
                {
                    DisplayAlert("ERRO CRÍTICO", e.Message, "OK");
                }
            }
        }
        private void BuscarCep(object obj, EventArgs args)
        {
            //a fazer 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 : {0}, {1}, {2}", end.logradouro, end.bairro, end.localidade);
                    }
                    else
                    {
                        DisplayAlert("Erro", "o endereço nao foi encontrado para o cep informado: " + cep, "Ok");
                    }
                }

                catch (Exception e)
                {
                    DisplayAlert("ERRO CRITICO", 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");
                }
            }
        }
Exemple #23
0
        private void CepButton_Clicked(object sender, EventArgs e)
        {
            string        cepFormatado  = Util.Mascara.RemoverMascara(cepTextBox.Text);
            Processamento processamento = ValidarCep(cepFormatado);

            if (!processamento.Sucesso)
            {
                DisplayAlert("CEP Inválido", processamento.MensagemFormata, "OK");
                return;
            }

            Endereco endereco = new Endereco();

            processamento = ViaCepServico.BuscarEnderecoViaCep(cepFormatado, out endereco);
            if (!processamento.Sucesso)
            {
                DisplayAlert("CEP Inválido", processamento.MensagemFormata, "OK");
                return;
            }

            if (endereco == null)
            {
                DisplayAlert("CEP Não Encontrado", string.Format("O endereço não foi encontrado para o CEP informado: {0}", Util.Mascara.RenderizarMascara(cepFormatado, "##.###-###")), "OK");
                return;
            }

            cepLabel.Text = string.Format("Logradouro: {0}\nBairro: {1}\nCidade: {2}\nUF: {3}\nCEP: {4}\nIBGE: {5}", endereco.Logradouro, endereco.Bairro, endereco.Localidade, endereco.Uf, endereco.Cep, endereco.Ibge);
        }
Exemple #24
0
        //========================================================================================================

        private void BuscarCEP(object sender, EventArgs args)
        {
            //TODO - Validações.
            string cep = CEP.Text.Trim();  //Trim remove espaços em branco no final e no começo do campo

            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", "O endereço não foi encontrado para o CEP informado:" + cep, "OK");
                    }
                }
                catch (Exception e)
                {
                    //ERRO
                    DisplayAlert("ERRO CRÍTICO.", e.Message, "OK");
                }
            }
        }
Exemple #25
0
        private void BuscarCep(object sender, EventArgs args)
        {
            string cep = CEP.Text.Trim();

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

                    if (end != null)
                    {
                        Resultado.Text = string.Format("Endereço: {0},{1},{2}", end.logradouro, end.localidade, end.uf);
                    }
                    else
                    {
                        DisplayAlert("Erro", "O endereço não foi encontrado para o cep: " + cep, "OK");
                    }
                }
                catch (Exception e)
                {
                    DisplayAlert("Erro Crítico", e.Message, "OK");
                }
            }
        }
Exemple #26
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 #27
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");
                }
            }
        }
Exemple #28
0
        private void BuscarCEP(object sender, EventArgs args)
        {
            string cep = entCEP.Text.Trim();

            if (ValidarCEP(cep))
            {
                try
                {
                    Endereco end = ViaCepServico.BuscarEnderecoCEP(cep);

                    if (end != null)
                    {
                        lblResultado.Text = string.Format("Endereço: {0}, {1}, {2} \r\n{3} ", end.localidade, end.uf, end.logradouro, end.bairro);
                    }
                    else
                    {
                        DisplayAlert("ERRO", "CEP Inexistete", "OK");
                    }
                }
                catch (Exception e)
                {
                    DisplayAlert("ERRO CRÍTICO", e.Message, "OK");
                }
            }
        }
Exemple #29
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");
                }
            }
        }
        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}",
                                             end.localidade, end.uf, end.logradouro, end.complemento, end.bairro);
                    }
                    else
                    {
                        DisplayAlert("Erro!", "O Endereço não foi localizado para o Cep" +
                                     " Informado: " + cep, "OK");
                    }
                }
                catch (Exception e)
                {
                    DisplayAlert("Erro Crítico!", e.Message, "OK");
                }
            }
        }