diff --git a/src/main/java/DB/Slot.java b/src/main/java/DB/Slot.java index 2235cfd..8310cb4 100644 --- a/src/main/java/DB/Slot.java +++ b/src/main/java/DB/Slot.java @@ -69,7 +69,7 @@ public class Slot extends Table { static public ArrayList getAll(Competition competition) { ArrayList list = new ArrayList<>(); try { - PreparedStatement ps = DB.getConnection().prepareStatement("SELECT id FROM Slot WHERE CompetitionName = ?"); + PreparedStatement ps = DB.getConnection().prepareStatement("SELECT id FROM Slot WHERE CompetitionName = ? ORDER BY startTime"); ps.setString(1, competition.getName()); for (ResultSet rs = ps.executeQuery(); rs.next(); ) list.add(new Slot(rs.getInt("id"))); @@ -83,7 +83,7 @@ public class Slot extends Table { static public ArrayList getAll(Competition competition, Date date) { ArrayList list = new ArrayList<>(); try { - PreparedStatement ps = DB.getConnection().prepareStatement("SELECT S.id FROM Slot S INNER JOIN Projection P on S.id = P.SlotId WHERE S.CompetitionName = ? AND P.startDate = ? GROUP BY S.id"); + PreparedStatement ps = DB.getConnection().prepareStatement("SELECT S.id FROM Slot S INNER JOIN Projection P on S.id = P.SlotId WHERE S.CompetitionName = ? AND P.startDate = ? GROUP BY S.id, S.startTime ORDER BY S.startTime"); ps.setString(1, competition.getName()); ps.setDate(2, date); for (ResultSet rs = ps.executeQuery(); rs.next(); ) @@ -98,7 +98,7 @@ public class Slot extends Table { static public ArrayList getAvailable(Competition competition, Date date) { ArrayList list = new ArrayList<>(); try { - PreparedStatement ps = DB.getConnection().prepareStatement("SELECT S.id FROM Slot S LEFT JOIN Projection P ON S.id = P.SlotId WHERE S.CompetitionName = ? AND P.id IS NULL OR P.startDate != ?"); + PreparedStatement ps = DB.getConnection().prepareStatement("SELECT S.id FROM Slot S LEFT JOIN Projection P ON S.id = P.SlotId WHERE S.CompetitionName = ? AND (P.id IS NULL OR P.startDate != ?) GROUP BY S.id, S.startTime ORDER BY S.startTime"); ps.setString(1, competition.getName()); ps.setDate(2, date); for (ResultSet rs = ps.executeQuery(); rs.next();) diff --git a/src/main/java/GUI/ProjectionHandler.java b/src/main/java/GUI/ProjectionHandler.java index 60313c1..5ada2de 100644 --- a/src/main/java/GUI/ProjectionHandler.java +++ b/src/main/java/GUI/ProjectionHandler.java @@ -48,6 +48,7 @@ public class ProjectionHandler extends JDialog { this.projectionType = projectionType; this.agenda = agenda; competitionComboBox.getModel().setSelectedItem(agenda.getCompetition()); + createUI(); if (agenda.getDate() != null || agenda.getSlot() != null) { updateMovies(); updateDates(); @@ -56,7 +57,6 @@ public class ProjectionHandler extends JDialog { slotComboBox.getModel().setSelectedItem(agenda.getSlot()); updateRooms(); } - createUI(); } public ProjectionHandler(ProjectionType projectionType, Agenda agenda, Projection projection) {