예제 #1
0
 private bool ValidarCampos()
 {
     try
     {
         ValidacionExpRegulares validator = new ValidacionExpRegulares();
         if (User == null)
         {
             msgError = "Escriba un correo electrónico";
             return(false);
         }
         if (Password == null)
         {
             msgError = "Escriba su contraseña";
             return(false);
         }
         return(true);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        private bool ValidarCampos()
        {
            ValidacionExpRegulares validator = new ValidacionExpRegulares();

            msgError = "";
            try
            {
                if (txtNombre.Text == null || txtNombre.Text == string.Empty || txtNombre.Text == "")
                {
                    msgError = "Escriba su nombre";
                    return(false);
                }
                if (txtCorreo.Text == null || txtCorreo.Text == string.Empty || txtCorreo.Text == "")
                {
                    msgError = "Escriba su correo electrónico";
                    return(false);
                }
                if (!validator.IsValidEmail(txtCorreo.Text.Trim()))
                {
                    msgError = "Escriba un correo electrónico válido";
                    return(false);
                }
                if (dtpFecNac.Date.Date >= DateTime.Now.Date)
                {
                    msgError = "Eliga una fecha de nacimiento válida";
                    return(false);
                }
                int var = Convert.ToInt32(txtExperiencia.Text);
                if (var == 0)
                {
                    msgError = "Ingrese los anños de experiencia en numero";
                    return(false);
                }
                if (txtUsuario.Text == null || txtUsuario.Text == string.Empty || txtUsuario.Text == "")
                {
                    msgError = "Escriba su usuario";
                    return(false);
                }

                /*
                 * if (await ValidarUsuario())
                 * {
                 *  msgError = "El nombre de usuario ya se encuentra en uso.";
                 *  return false;
                 * }*/
                if (txtPass1.Text != null && txtPass2.Text != null)
                {
                    if (txtPass2.Text.Trim() != txtPass1.Text.Trim())
                    {
                        msgError = "Las Contraseñas no coinciden.";
                        return(false);
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                msgError = ex.Message.ToString();
                return(false);
            }
        }