コード例 #1
0
        private bool ValidarCampos()
        {
            bool formatoCorreto = true;

            if (EMAIL.Text != string.Empty)
            {
                if (!isValidEmail(EMAIL.Text))
                {
                    formatoCorreto = false;
                    DisplayAlert("ATENÇÃO", "O E-mail informado é inválido. Por favor verifique.", "OK");
                    EMAIL.Focus();
                    return(formatoCorreto);
                }
                if (CEP.Text != string.Empty)

                {
                    if (!isValidCEP(CEP.Text))

                    {
                        formatoCorreto = false;

                        DisplayAlert("ATENÇÃO", "O CEP Informado é inválido. Por favor verifique.", "OK");

                        CEP.Focus();
                        return(formatoCorreto);
                    }
                }
            }
            return(formatoCorreto);
        }
コード例 #2
0
        private bool isValidCEP(String cep)
        {
            if (cep.Length != 8)
            {
                CEP.Focus();
                DisplayAlert("ERRO", "CEP inválido, deve conter 8 caracteres !", "OK");
                return(false);
            }

            int NovoCEP = 0;

            if (!int.TryParse(cep, out NovoCEP))
            {
                CEP.Focus();
                DisplayAlert("ERRO", "CEP inválido, deve conter 8 caracteres numéricos !", "OK");
                return(false);
            }


            return(true);
        }
コード例 #3
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:\r\n\r\n{0}, {1} \r\n{2} - {3}", end.logradouro, end.bairro, end.localidade, end.uf);
                    }
                    else
                    {
                        DisplayAlert("ERRO", "O endereço não foi localizado para o CEP: " + cep, "OK");
                    }
                    CEP.Focus();
                }
                catch (Exception e) {
                    DisplayAlert("ERRO CRÍTICO", e.Message, "OK");
                }
            }
        }
コード例 #4
0
 protected override void OnAppearing()
 {
     base.OnAppearing();
     CEP.Focus();
 }
コード例 #5
0
 private void BOTAONOVO_Clicked(object sender, EventArgs e)
 {
     CEP.Text = "";
     CEP.Focus();
     RESULTADO.Text = "";
 }