Exemplo n.º 1
0
  public ArrayList<Object> getAppointments(AdminUser user) {
    ArrayList<Object> appointments = new ArrayList<Object>();
    try {
      Connection conn = this.connectDB();
      PreparedStatement statement;
      String command =
          "SELECT advisor_settings.pname,advisor_settings.email,advising_date,advising_starttime,advising_endtime,appointment_type,id FROM appointments INNER JOIN advisor_settings "
              + "WHERE advisor_settings.userid = appointments.advisor_userid";
      statement = conn.prepareStatement(command);
      ResultSet rs = statement.executeQuery();
      while (rs.next()) {
        Appointment set = new Appointment();
        set.setPname(rs.getString(1));
        set.setAdvisorEmail(rs.getString(2));
        set.setAdvisingDate(rs.getString(3));
        set.setAdvisingStartTime(rs.getString(4));
        set.setAdvisingEndTime(rs.getString(5));
        set.setAppointmentType(rs.getString(6));
        set.setAppointmentId(rs.getInt(7));
        appointments.add(set);
      }
      conn.close();
    } catch (Exception e) {
      System.out.printf(e.toString());
    }

    return appointments;
  }
Exemplo n.º 2
0
  public ArrayList<Object> getAppointments(StudentUser user) {
    ArrayList<Object> appointments = new ArrayList<Object>();
    try {
      Connection conn = this.connectDB();
      PreparedStatement statement;
      String command =
          "SELECT advisor_settings.pname,advisor_settings.email,advising_date,advising_starttime,advising_endtime,appointment_type,id,description,user.email  FROM USER,APPOINTMENTS,ADVISOR_SETTINGS "
              + "WHERE USER.email=? AND user.userid=appointments.student_userid AND advisor_settings.userid=appointments.advisor_userid";
      statement = conn.prepareStatement(command);
      statement.setString(1, user.getEmail());
      ResultSet rs = statement.executeQuery();
      while (rs.next()) {
        Appointment set = new Appointment();
        set.setPname(rs.getString(1));
        set.setAdvisorEmail(rs.getString(2));
        set.setAdvisingDate(rs.getString(3));
        set.setAdvisingStartTime(rs.getString(4));
        set.setAdvisingEndTime(rs.getString(5));
        set.setAppointmentType(rs.getString(6));
        set.setAppointmentId(rs.getInt(7));
        set.setDescription(rs.getString(8));
        set.setStudentid("Advisor only");
        set.setStudentEmail(rs.getString(9));
        appointments.add(set);
      }
      conn.close();
    } catch (Exception e) {
      System.out.printf(e.toString());
    }

    return appointments;
  }