Exemplo n.º 1
0
  private void jTableUsersMouseClicked(
      java.awt.event.MouseEvent evt) { // GEN-FIRST:event_jTableUsersMouseClicked
    if (evt.getClickCount() >= 2) {
      // Double clicked!

      int response =
          JOptionPane.showConfirmDialog(
              null,
              "Weet je zeker dat je deze deelnemer wilt uitschrijven?",
              "Deelnemer uitschrijven",
              JOptionPane.YES_NO_OPTION);

      if (response == 0) {
        // Get the currently selected subscription
        int rowNumber = jTableUsers.getSelectedRow();
        int user_id = (Integer) model.getValueAt(rowNumber, 0);

        Enrollment enrollment = new Enrollment();
        enrollment.unsubscribe(this.subscription.getId(), user_id);

        this.model.removeRow(rowNumber);

        Application.getInstance()
            .showPopup(new SuccessPopup("De deelnemer is succesvol uitgeschreven."));
      }
    }
  } // GEN-LAST:event_jTableUsersMouseClicked
Exemplo n.º 2
0
  /** This method is used to retrieve data and show it on the screen */
  public void render() {
    jLabelName.setText(this.subscription.getTitle());
    jLabelGender.setText("Man");
    jLabelAge.setText(String.valueOf(this.subscription.getMinimumAge()));
    jLabelDays.setText(CourseInfo.implode(this.subscription.getDays(), ", "));
    jLabelDuration.setText(
        String.valueOf(this.subscription.getStartTime())
            + " - "
            + String.valueOf(this.subscription.getEndTime()));
    jLabelDescription.setText(this.subscription.getDescription());
    jLabelBranch.setText(this.subscription.getBranch().getCity());

    // Empty results
    jLabelUser.setText("");
    jBtnSubmit.setVisible(false);

    // Age range
    if (this.subscription.getMaximumAge() <= 16) jLabelAge.setText("< 16");
    else if (this.subscription.getMaximumAge() <= 18) jLabelAge.setText("16 - 18");
    else if (this.subscription.getMaximumAge() <= 65) jLabelAge.setText("18 - 65");
    else if (this.subscription.getMaximumAge() <= 150) jLabelAge.setText("65+");

    // Enrollments
    ArrayList<User> users = Enrollment.readBySubscriptionId(this.subscription.getId());

    for (User user : users) {
      if (user.getFullName() != "" && user.getFirstname() != null) {
        this.model.insertRow(0, new Object[] {user.getId(), user.getFullName()});
      }
    }

    // Make a selection listener
    this.row = jTableUsers.getSelectionModel();
    this.row.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
  }
Exemplo n.º 3
0
  private void jBtnSubmitActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jBtnSubmitActionPerformed
    Enrollment enrollment = new Enrollment();

    enrollment.readEnrollmentBySubscriptionIdAndUserId(this.subscription.getId(), this.userId);

    if (enrollment.isEnrolled() == false) {
      enrollment.subscribe(this.subscription.getId(), this.userId);

      User user = new User();
      user.readUser(this.userId);

      this.model.insertRow(0, new Object[] {user.getId(), user.getFullName()});

      Application.getInstance()
          .showPopup(new SuccessPopup("Deelnemer " + user.getFullName() + " is ingeschreven."));
    } else {
      Application.getInstance().showPopup(new ErrorPopup("De deelnemer is al ingeschreven."));
    }
  } // GEN-LAST:event_jBtnSubmitActionPerformed