From 6555f8f8bc4f7102a5e63303c30b151654ac712c Mon Sep 17 00:00:00 2001 From: Johannes Kantz <67144859+JohannesKantz@users.noreply.github.com> Date: Tue, 31 Jan 2023 06:01:53 +0100 Subject: [PATCH] add: Rechnung View --- .../InvoiceController.java | 67 +++++++++++++++++++ .../ParentMenuController.java | 6 +- .../StartViewApplication.java | 4 +- .../WorkerMenuController.java | 6 +- .../invoice-view.fxml | 66 +++++++++++++++--- 5 files changed, 138 insertions(+), 11 deletions(-) create mode 100644 src/main/java/com/bib/essensbestellungsverwaltung/InvoiceController.java diff --git a/src/main/java/com/bib/essensbestellungsverwaltung/InvoiceController.java b/src/main/java/com/bib/essensbestellungsverwaltung/InvoiceController.java new file mode 100644 index 0000000..aebd7ba --- /dev/null +++ b/src/main/java/com/bib/essensbestellungsverwaltung/InvoiceController.java @@ -0,0 +1,67 @@ +package com.bib.essensbestellungsverwaltung; + +import javafx.fxml.FXML; +import javafx.scene.control.ChoiceBox; +import javafx.scene.control.Spinner; +import javafx.scene.input.MouseEvent; +import javafx.scene.text.Text; + +import java.util.Calendar; + +public class InvoiceController { + @FXML + Text responseText; + @FXML + ChoiceBox monatChoiceBox; + + @FXML + Spinner jahrSpinner; + + @FXML + public void initialize() { + monatChoiceBox.setValue(intToMonth(Calendar.getInstance().get(Calendar.MONTH) + 1)); + jahrSpinner.getValueFactory().setValue(Calendar.getInstance().get(Calendar.YEAR)); + } + + @FXML + void onRechnungErstellenClick(MouseEvent mouseEvent) { + responseText.setText(monatChoiceBox.getValue().toString() + jahrSpinner.getValue()); + // hier rechnung erstellen + } + + private int monthToInt(String month) { + return switch (month) { + case "Januar" -> 1; + case "Februar" -> 2; + case "März" -> 3; + case "April" -> 4; + case "Mai" -> 5; + case "Juni" -> 6; + case "Juli" -> 7; + case "August" -> 8; + case "September" -> 9; + case "Oktober" -> 10; + case "November" -> 11; + case "Dezember" -> 12; + default -> -1; + }; + } + + private String intToMonth(int month) { + return switch (month) { + case 1 -> "Januar"; + case 2 -> "Februar"; + case 3 -> "März"; + case 4 -> "April"; + case 5 -> "Mai"; + case 6 -> "Juni"; + case 7 -> "Juli"; + case 8 -> "August"; + case 9 -> "September"; + case 10 -> "Oktober"; + case 11 -> "November"; + case 12 -> "Dezember"; + default -> ""; + }; + } +} diff --git a/src/main/java/com/bib/essensbestellungsverwaltung/ParentMenuController.java b/src/main/java/com/bib/essensbestellungsverwaltung/ParentMenuController.java index f42f378..a50d7ae 100644 --- a/src/main/java/com/bib/essensbestellungsverwaltung/ParentMenuController.java +++ b/src/main/java/com/bib/essensbestellungsverwaltung/ParentMenuController.java @@ -3,11 +3,13 @@ package com.bib.essensbestellungsverwaltung; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; +import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.input.ContextMenuEvent; import javafx.scene.input.MouseEvent; import javafx.scene.layout.Background; import javafx.scene.layout.BorderPane; +import javafx.stage.Stage; import java.io.IOException; import java.util.Arrays; @@ -57,7 +59,9 @@ public class ParentMenuController { } @FXML - public void onAusloggenClick(MouseEvent mouseEvent) { + public void onAusloggenClick(MouseEvent mouseEvent) throws IOException { + Parent p = FXMLLoader.load(StartViewApplication.class.getResource("workerMenu.fxml")); + StartViewApplication.primary.getScene().setRoot(p); } private void changePage(String page) { diff --git a/src/main/java/com/bib/essensbestellungsverwaltung/StartViewApplication.java b/src/main/java/com/bib/essensbestellungsverwaltung/StartViewApplication.java index 647b62a..fe03394 100644 --- a/src/main/java/com/bib/essensbestellungsverwaltung/StartViewApplication.java +++ b/src/main/java/com/bib/essensbestellungsverwaltung/StartViewApplication.java @@ -18,10 +18,12 @@ public class StartViewApplication extends Application { public void start(Stage stage) throws IOException { FXMLLoader fxmlLoader = new FXMLLoader(StartViewApplication.class.getResource("login-view.fxml")); Scene scene = new Scene(fxmlLoader.load(), 950,480); - primary = stage; + //stage = primary; stage.setTitle("Essen Bestellung im Kindergarten"); stage.setScene(scene); stage.show(); + + } public static void main(String[] args) { diff --git a/src/main/java/com/bib/essensbestellungsverwaltung/WorkerMenuController.java b/src/main/java/com/bib/essensbestellungsverwaltung/WorkerMenuController.java index 5d5ddcd..d552aea 100644 --- a/src/main/java/com/bib/essensbestellungsverwaltung/WorkerMenuController.java +++ b/src/main/java/com/bib/essensbestellungsverwaltung/WorkerMenuController.java @@ -3,10 +3,12 @@ package com.bib.essensbestellungsverwaltung; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; +import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.input.ContextMenuEvent; import javafx.scene.input.MouseEvent; import javafx.scene.layout.BorderPane; +import javafx.stage.Stage; import java.io.IOException; @@ -69,7 +71,9 @@ public class WorkerMenuController { } @FXML - public void onAusloggenClick(MouseEvent mouseEvent) { + public void onAusloggenClick(MouseEvent mouseEvent) throws IOException { + Parent p = FXMLLoader.load(StartViewApplication.class.getResource("parentMenu.fxml")); + StartViewApplication.primary.getScene().setRoot(p); } private void changePage(String page) { diff --git a/src/main/resources/com/bib/essensbestellungsverwaltung/invoice-view.fxml b/src/main/resources/com/bib/essensbestellungsverwaltung/invoice-view.fxml index 1087a44..399a6bd 100644 --- a/src/main/resources/com/bib/essensbestellungsverwaltung/invoice-view.fxml +++ b/src/main/resources/com/bib/essensbestellungsverwaltung/invoice-view.fxml @@ -1,14 +1,64 @@ - - + + + - - - + + + + + + + + + + + + + + + + + + + + +