From ebfc03efdf0a0a2d5b60c259dd4f2eacbdc312ec Mon Sep 17 00:00:00 2001 From: Tergel TSAGAAN Date: Thu, 7 Jan 2021 15:25:14 +0100 Subject: [PATCH] edit projection --- src/main/java/GUI/ProjectionHandler.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/main/java/GUI/ProjectionHandler.java b/src/main/java/GUI/ProjectionHandler.java index 30e26a8..93b6568 100644 --- a/src/main/java/GUI/ProjectionHandler.java +++ b/src/main/java/GUI/ProjectionHandler.java @@ -119,18 +119,13 @@ public class ProjectionHandler extends JDialog { slotComboBox.removeAllItems(); roomComboBox.removeAllItems(); if (dayComboBox.getSelectedItem() != null) { - ArrayList slots = null; + ArrayList slots; Competition competition = (Competition) competitionComboBox.getSelectedItem(); Date date = Date.valueOf((LocalDate) dayComboBox.getSelectedItem()); - switch (projectionType) { - case ADD: + if (projectionType == ProjectionType.ADD) slots = Slot.getAvailable(competition, date); - break; - case EDIT: - break; - case REMOVE: + else slots = Slot.getAll(competition, date); - } if (slots != null) for (Slot s : slots) slotComboBox.addItem(s); @@ -146,9 +141,8 @@ public class ProjectionHandler extends JDialog { Date date = Date.valueOf((LocalDate) dayComboBox.getSelectedItem()); switch (projectionType) { case ADD: - rooms = Room.getAvailable(movie, slot, date); - break; case EDIT: + rooms = Room.getAvailable(movie, slot, date); break; case REMOVE: rooms = Room.getAll(movie, slot, date); @@ -173,6 +167,11 @@ public class ProjectionHandler extends JDialog { new Projection(date, competition, room, movie, slot); break; case EDIT: + if (projection != null) + projection.delete(); + else + (Projection.find(date, competition, room, movie, slot)).delete(); + new Projection(date, competition, room, movie, slot); break; case REMOVE: if (projection != null)