private void checkCredentials(){
		view.setEnabled(false);
		LoginDao dao = new LoginDaoSQL();
		
		try {
			int type = view.getType();
			String username = view.getUsername();
			String password = view.getPassword();
			
			if(username == null || username.trim().length() < 3)
				throw new LoginException(1);
			
			if(password == null || password.trim().length() < 6 || password.trim().length() > 16)
				throw new LoginException(2);
			
			Usuario usuario = dao.tryLogin(type, username, password);
			
			
			
			if(Config.DEBUG)
				System.out.println("Login success: " + usuario + " (id: " + usuario.getId() + ")");
			
			switch(usuario.getTipo()){
				case Usuario.CLIENTE : loadDashboardCliente(view.getApplication(), dao.getClienteByUser(usuario)); break;
				case Usuario.FUNCIONARIO : loadDashboardFunctionario(view.getApplication(), dao.getFuncionarioByUser(usuario)); break;
				default: throw new LoginException(0);
			}
			
		} catch(LoginException ex){
			view.loginError(ex.getCode());
		}
		
		view.setEnabled(true);
	}