1
0
Fork 0

edit projection

This commit is contained in:
Tergel TSAGAAN 2021-01-07 15:25:14 +01:00 committed by flifloo
parent 28d2b300f1
commit ebfc03efdf

View file

@ -119,18 +119,13 @@ public class ProjectionHandler extends JDialog {
slotComboBox.removeAllItems(); slotComboBox.removeAllItems();
roomComboBox.removeAllItems(); roomComboBox.removeAllItems();
if (dayComboBox.getSelectedItem() != null) { if (dayComboBox.getSelectedItem() != null) {
ArrayList<Slot> slots = null; ArrayList<Slot> slots;
Competition competition = (Competition) competitionComboBox.getSelectedItem(); Competition competition = (Competition) competitionComboBox.getSelectedItem();
Date date = Date.valueOf((LocalDate) dayComboBox.getSelectedItem()); Date date = Date.valueOf((LocalDate) dayComboBox.getSelectedItem());
switch (projectionType) { if (projectionType == ProjectionType.ADD)
case ADD:
slots = Slot.getAvailable(competition, date); slots = Slot.getAvailable(competition, date);
break; else
case EDIT:
break;
case REMOVE:
slots = Slot.getAll(competition, date); slots = Slot.getAll(competition, date);
}
if (slots != null) if (slots != null)
for (Slot s : slots) for (Slot s : slots)
slotComboBox.addItem(s); slotComboBox.addItem(s);
@ -146,9 +141,8 @@ public class ProjectionHandler extends JDialog {
Date date = Date.valueOf((LocalDate) dayComboBox.getSelectedItem()); Date date = Date.valueOf((LocalDate) dayComboBox.getSelectedItem());
switch (projectionType) { switch (projectionType) {
case ADD: case ADD:
rooms = Room.getAvailable(movie, slot, date);
break;
case EDIT: case EDIT:
rooms = Room.getAvailable(movie, slot, date);
break; break;
case REMOVE: case REMOVE:
rooms = Room.getAll(movie, slot, date); rooms = Room.getAll(movie, slot, date);
@ -173,6 +167,11 @@ public class ProjectionHandler extends JDialog {
new Projection(date, competition, room, movie, slot); new Projection(date, competition, room, movie, slot);
break; break;
case EDIT: case EDIT:
if (projection != null)
projection.delete();
else
(Projection.find(date, competition, room, movie, slot)).delete();
new Projection(date, competition, room, movie, slot);
break; break;
case REMOVE: case REMOVE:
if (projection != null) if (projection != null)