Exemplo n.º 1
0
        private void MaskedTextBoxCpf_Leave(object sender, EventArgs e)
        {
            if (infoPessoa == null || string.IsNullOrEmpty(infoPessoa.Ident))
            {
                cpf = maskedTextBoxCpf.Text;

                //preencher o formulário com os meus dados para testes
                if (cpf == "71992776512")
                {
                    PreencherFormClienteTeste();
                    return;
                }

                if (cpf.Length >= 11)
                {
                    ValidarCpfCnpj validarCpfCnpj = new ValidarCpfCnpj(cpf);

                    if (validarCpfCnpj.CpfCpnjValido())
                    {
                        ConsultarCpf();
                    }
                    else
                    {
                        if (!infoPessoa.booPF)
                        {
                            FormMessage.ShowMessegeWarning("CNPJ inválido! Tente novamente...");
                        }
                        else
                        {
                            FormMessage.ShowMessegeWarning("CPF inválido! Tente novamente...");
                        }

                        maskedTextBoxCpf.Clear();
                        maskedTextBoxCpf.Focus();
                    }
                }
                else
                {
                    maskedTextBoxCpf.Clear();
                }
            }
        }
Exemplo n.º 2
0
        private void maskedTextBoxCpf_Leave(object sender, EventArgs e)
        {
            cpf = maskedTextBoxCpf.Text;


            //preencher o formulário com os meus dados para testes
            if (cpf == "71992776512")
            {
                PreencherFormClienteTeste();
                return;
            }

            ValidarCpfCnpj validarCpfCnpj = new ValidarCpfCnpj(cpf);

            if (cpf != "00000000000")
            {
                if (validarCpfCnpj.CpfCpnjValido())
                {
                    ConsultarCpf();
                }
                else
                {
                    if (radioButtonCnpj.Checked)
                    {
                        FormMessage.ShowMessegeWarning("CNPJ inválido! Tente novamente...");
                    }
                    else
                    {
                        FormMessage.ShowMessegeWarning("CPF inválido! Tente novamente...");
                    }

                    maskedTextBoxCpf.Clear();
                    maskedTextBoxCpf.Focus();
                }
            }
        }