/// <summary> /// validar usuarios /// </summary> /// <param name="obclsUsuarios">objeto usuario</param> /// <returns>confirmacion</returns> public bool getvalidarUsuario(Logica.MODELS.clsUsuarios obclsUsuarios) { try { DataSet dsConsulta = new DataSet(); _sqlConnection = new SqlConnection(stConexion); _sqlConnection.Open(); _sqlCommand = new SqlCommand("CONSULTARUSUARIO", _sqlConnection); _sqlCommand.CommandType = CommandType.StoredProcedure; _sqlCommand.Parameters.Add(new SqlParameter("@LOGIN", obclsUsuarios.stLogin)); _sqlCommand.Parameters.Add(new SqlParameter("@PASSWORD", obclsUsuarios.stPassword)); _sqlCommand.ExecuteNonQuery(); _SqlDataAdapter = new SqlDataAdapter(_sqlCommand); _SqlDataAdapter.Fill(dsConsulta); if (dsConsulta.Tables[0].Rows.Count > 0) { return(true); } else { return(false); } } catch (Exception ex) { throw ex; } finally { _sqlConnection.Close(); } }
/// <summary> /// valida usuario /// </summary> /// <param name="obclsUsuarios">objeto usuario</param> /// <returns>confirmacion</returns> public bool getvalidarUsuarioController(Logica.MODELS.clsUsuarios obclsUsuarios) { try { Logica.BL.clsUsuarios obclsUsuario = new Logica.BL.clsUsuarios(); return(obclsUsuario.getvalidarUsuario(obclsUsuarios)); } catch (Exception ex) { throw ex; } }
protected void BtnAceptar_Click1(object sender, EventArgs e) { try { string stMensaje = string.Empty; if (string.IsNullOrWhiteSpace(TxtEmail.Text)) { stMensaje += "ingrese email,"; } if (string.IsNullOrWhiteSpace(TxtPassword.Text)) { stMensaje += "ingrese password,"; } if (!string.IsNullOrEmpty(stMensaje)) { throw new Exception(stMensaje.TrimEnd(',')); } //defino objeto con propiedades Logica.MODELS.clsUsuarios obclsUsuarios = new Logica.MODELS.clsUsuarios { stLogin = TxtEmail.Text, stPassword = TxtPassword.Text }; //instancio controlador Controllers.LoginController obLoginController = new Controllers.LoginController(); bool blBandera = obLoginController.getvalidarUsuarioController(obclsUsuarios); if (blBandera) { Response.Redirect("../Index/Index.aspx");//redirecciono } else { throw new Exception("Usuario o Password incorrectos"); } } catch (Exception ex) { ClientScript.RegisterStartupScript(this.GetType(), "mensaje", "<script>swal('Error!','" + ex.Message + "!','error')</script>"); } }