private void okActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okActionPerformed
//TODO:Métodos para ligar uma ou outra (factory)?
    //TODO: Falar com o prof sobre o singleton que está no eclipse
    //int[] type = new int[3];
    //type[0]=1;
    //Person p1 = new Person(-1,"lala@lala.com", "", "admin", "admin", "admin", "", "", "", type, "");
    //Admin a = new Admin(p1);
    //dat.storeAdmin(a);

    Person p = new Person();
    p.setLogin(login_field.getText());
    p.setPassword(password_field.getText());
    p = dat.checkLogin(p);
    if (p.getId() > 0) {
        int option = type_box.getSelectedIndex();
        //System.out.println(option);
        int[] type = dat.getPersonType(p);
        if (option == 0 && type[0] == 1) {
            new AdminForm().setVisible(true);
            dispose();
        } else if (option == 1 && type[2] == 1) {
            new LibrarianForm().setVisible(true);
            dispose();
        } else if (option == 2 && type[1] == 1) {
            new UserForm(p.getId()).setVisible(true);
            dispose();
        } else{
            error_msg.setText("Invalid type");
            error_msg.setVisible(true);
        }
    } else if (p.getId() == -1) {
        System.out.println("cenas");
        error_msg.setText("Username invalid");
        error_msg.setVisible(true);
    } else if (p.getId() == -2) {
        System.out.println("cenas");
        error_msg.setText("Password invalid");
        error_msg.setVisible(true);
    }//new AdminForm(dat).setVisible(true);
    //     dispose();

}