コード例 #1
0
        private void TbCedula_TextChanged(object sender, EventArgs e)
        {
            if (tbCedula.Text.Trim() == "")
            {
                errorProvider1.SetError(tbCedula, null);
                flagCedula = false;
            }

            else
            {
                flagCedula = true;

                if (rbPersona.Checked)
                {
                    if (Validaciones.VerificaCedula(tbCedula.Text))
                    {
                        int r = Validaciones.verificarCedulaRepetida(tbCedula, conexion);

                        if (r != 0)
                        {
                            tbCedula.ForeColor = Color.Red;
                            errorProvider1.SetError(tbCedula, "Cédula de ciudadanía ya registrada");
                            errorCedula = 1;
                        }
                        else
                        {
                            errorProvider1.SetError(tbCedula, null);
                            tbCedula.ForeColor = Color.Green;
                            errorCedula        = 0;
                        }
                    }
                    else
                    {
                        errorProvider1.SetError(tbCedula, "Cédula de ciudadanía incorrecta");
                        tbCedula.ForeColor = Color.Red;
                        errorCedula        = 2;
                    }
                }
                else
                {
                    if (Validaciones.RucPersonaNatural(tbCedula.Text))
                    {
                        int r = Validaciones.verificarCedulaRepetida(tbCedula, conexion);

                        if (r != 0)
                        {
                            tbCedula.ForeColor = Color.Red;
                            errorProvider1.SetError(tbCedula, "RUC ya registrado");
                            errorCedula = 1;
                        }
                        else
                        {
                            errorProvider1.SetError(tbCedula, null);
                            tbCedula.ForeColor = Color.Green;
                            errorCedula        = 0;
                        }
                    }
                    else
                    {
                        errorProvider1.SetError(tbCedula, "RUC incorrecto");
                        tbCedula.ForeColor = Color.Red;
                        errorCedula        = 2;
                    }
                }
            }
        }