singup mit Datebase verbunden und new Adresse
This commit is contained in:
parent
dbe98686bd
commit
6ca54aa026
@ -0,0 +1,140 @@
|
||||
/*Schulte*/
|
||||
|
||||
package com.bib.essensbestellungsverwaltung;
|
||||
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.*;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Formattable;
|
||||
import java.util.List;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
public class ChildViewController implements Initializable {
|
||||
|
||||
@FXML
|
||||
public TextField name;
|
||||
@FXML
|
||||
public TextField lastname;
|
||||
@FXML
|
||||
public TextField street;
|
||||
@FXML
|
||||
public TextField number;
|
||||
@FXML
|
||||
public TextField plz;
|
||||
@FXML
|
||||
public TextField city;
|
||||
//@FXML
|
||||
//public ComboBox group;
|
||||
//@FXML
|
||||
//public TextField age;
|
||||
//@FXML
|
||||
//public TextField allergies;
|
||||
@FXML
|
||||
public ListView allergiesList;
|
||||
@FXML
|
||||
public ComboBox selectAllergy;
|
||||
@FXML
|
||||
public ComboBox selectAllergySeverity;
|
||||
|
||||
|
||||
|
||||
@FXML
|
||||
protected void onBtClick(){
|
||||
|
||||
boolean childData = false;
|
||||
|
||||
String childName = name.getText();
|
||||
String childLastname = lastname.getText();
|
||||
|
||||
String streetString = street.getText();
|
||||
String numberString = number.getText();
|
||||
String plzString = plz.getText();
|
||||
String cityString = city.getText();
|
||||
|
||||
|
||||
|
||||
if(childName.isEmpty() || childLastname.isEmpty() || streetString.isEmpty() || numberString.isEmpty() ||plzString.isEmpty() || cityString.isEmpty()){
|
||||
Alert alert = new Alert(Alert.AlertType.ERROR);
|
||||
alert.setTitle("Felder");
|
||||
alert.setHeaderText("Eingabe unvollständig");
|
||||
alert.setContentText("Bitte füllen sie alle Felder aus");
|
||||
alert.showAndWait();
|
||||
}
|
||||
else childData = true;
|
||||
|
||||
|
||||
|
||||
if(childData) {
|
||||
|
||||
|
||||
Address adress = new Address(streetString, numberString, plzString, cityString);
|
||||
|
||||
List<Allergy> childAllergyList = allergiesList.getItems();
|
||||
ArrayList<AllergySeverity> allergySeverityArrayList = new ArrayList<>();
|
||||
|
||||
/*for (Allergy a : childAllergyList) {
|
||||
AllergySeverity aS = new AllergySeverity(a, )
|
||||
}*/ //Allergy Severity doesn't work in my case so the List will be left empty for now
|
||||
|
||||
|
||||
Child child = new Child(childLastname, childName, adress, allergySeverityArrayList);
|
||||
|
||||
System.out.println(AccountMgr.createChild(child));
|
||||
|
||||
Alert alert = new Alert(Alert.AlertType.INFORMATION);
|
||||
alert.setTitle("Bestätigung");
|
||||
alert.setHeaderText("Bestätigung");
|
||||
alert.setContentText("Ihr Kind " + childName + " " + childLastname + " wurde Erfolgreich angelegt");
|
||||
alert.showAndWait();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public ArrayList<Allergy> allergyComboBox(){
|
||||
ArrayList<Allergy> allergyArrayList = new ArrayList<>();
|
||||
for (int i = 1; i < 23; i++){
|
||||
Allergy a = FoodMgr.getAllergyById(i);
|
||||
allergyArrayList.add(a);
|
||||
}
|
||||
return allergyArrayList;
|
||||
}
|
||||
|
||||
|
||||
@FXML
|
||||
public void addAllergy() {
|
||||
|
||||
boolean allergyEmpty = (selectAllergy.getValue() == "Allergie Wählen");
|
||||
boolean severityEmpty = (selectAllergySeverity.getValue() == "Schwere");
|
||||
|
||||
if(allergyEmpty || severityEmpty) {
|
||||
Alert alert = new Alert(Alert.AlertType.ERROR);
|
||||
alert.setTitle("Fehler");
|
||||
alert.setHeaderText("Ungültige Auswahl");
|
||||
alert.setContentText("Bitte Wählen Sie Allergie und schwere aus");
|
||||
alert.showAndWait();
|
||||
}
|
||||
|
||||
|
||||
|
||||
String addedAllergy = selectAllergy.getValue().toString();
|
||||
String addedSeverity = selectAllergySeverity.getValue().toString().split(":")[0];
|
||||
allergiesList.getItems().add(addedAllergy + ":" + addedSeverity);
|
||||
|
||||
|
||||
selectAllergy.setValue("Allergie Wählen");
|
||||
selectAllergySeverity.setValue("Schwere");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(URL url, ResourceBundle resourceBundle) {
|
||||
selectAllergy.getItems().addAll(allergyComboBox());
|
||||
|
||||
selectAllergySeverity.getItems().addAll("1:Harmlos","2:Warnung","3:Kritisch");
|
||||
}
|
||||
}
|
@ -3,7 +3,6 @@
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.control.ComboBox?>
|
||||
<?import javafx.scene.control.DatePicker?>
|
||||
<?import javafx.scene.control.ListView?>
|
||||
<?import javafx.scene.control.TextField?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
@ -12,7 +11,7 @@
|
||||
<?import javafx.scene.text.Font?>
|
||||
<?import javafx.scene.text.Text?>
|
||||
|
||||
<AnchorPane prefHeight="700.0" prefWidth="950.0" stylesheets="@child.css" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.bib.essensbestellungsverwaltung.ParentController">
|
||||
<AnchorPane prefHeight="700.0" prefWidth="950.0" stylesheets="@child.css" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.bib.essensbestellungsverwaltung.ChildViewController">
|
||||
<children>
|
||||
<Text layoutX="51.0" layoutY="90.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Kinder">
|
||||
<font>
|
||||
@ -28,21 +27,21 @@
|
||||
<Insets bottom="15.0" top="15.0" />
|
||||
</VBox.margin>
|
||||
</Text>
|
||||
<TextField prefWidth="97.0">
|
||||
<TextField fx:id="name" prefWidth="97.0">
|
||||
<VBox.margin>
|
||||
<Insets bottom="15.0" top="15.0" />
|
||||
</VBox.margin>
|
||||
</TextField>
|
||||
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Geburtsdatum">
|
||||
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Nachname">
|
||||
<VBox.margin>
|
||||
<Insets bottom="15.0" top="15.0" />
|
||||
</VBox.margin>
|
||||
</Text>
|
||||
<DatePicker prefHeight="26.0" prefWidth="226.0">
|
||||
<TextField fx:id="lastname" prefWidth="97.0">
|
||||
<VBox.margin>
|
||||
<Insets top="13.0" />
|
||||
<Insets bottom="15.0" top="15.0" />
|
||||
</VBox.margin>
|
||||
</DatePicker>
|
||||
</TextField>
|
||||
</children>
|
||||
<HBox.margin>
|
||||
<Insets left="15.0" right="15.0" />
|
||||
@ -50,26 +49,46 @@
|
||||
</VBox>
|
||||
<VBox id="contentContainer" prefHeight="250.0" prefWidth="256.0">
|
||||
<children>
|
||||
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Alter">
|
||||
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Straße">
|
||||
<VBox.margin>
|
||||
<Insets bottom="15.0" top="15.0" />
|
||||
</VBox.margin>
|
||||
</Text>
|
||||
<TextField prefWidth="97.0">
|
||||
<TextField fx:id="street" prefWidth="97.0">
|
||||
<VBox.margin>
|
||||
<Insets bottom="15.0" top="15.0" />
|
||||
</VBox.margin>
|
||||
</TextField>
|
||||
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Gruppe">
|
||||
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Hausnummer">
|
||||
<VBox.margin>
|
||||
<Insets bottom="15.0" top="15.0" />
|
||||
</VBox.margin>
|
||||
</Text>
|
||||
<ComboBox prefHeight="26.0" prefWidth="230.0">
|
||||
<TextField fx:id="number" prefWidth="97.0">
|
||||
<VBox.margin>
|
||||
<Insets top="13.0" />
|
||||
<Insets bottom="15.0" top="15.0" />
|
||||
</VBox.margin>
|
||||
</ComboBox>
|
||||
</TextField>
|
||||
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="PLZ">
|
||||
<VBox.margin>
|
||||
<Insets bottom="15.0" top="15.0" />
|
||||
</VBox.margin>
|
||||
</Text>
|
||||
<TextField fx:id="plz" prefWidth="97.0">
|
||||
<VBox.margin>
|
||||
<Insets bottom="15.0" top="15.0" />
|
||||
</VBox.margin>
|
||||
</TextField>
|
||||
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Stadt">
|
||||
<VBox.margin>
|
||||
<Insets bottom="15.0" top="15.0" />
|
||||
</VBox.margin>
|
||||
</Text>
|
||||
<TextField fx:id="city" prefWidth="97.0">
|
||||
<VBox.margin>
|
||||
<Insets bottom="15.0" top="15.0" />
|
||||
</VBox.margin>
|
||||
</TextField>
|
||||
</children>
|
||||
<HBox.margin>
|
||||
<Insets left="15.0" right="15.0" />
|
||||
@ -83,11 +102,13 @@
|
||||
</VBox.margin>
|
||||
</Text>
|
||||
<ListView prefHeight="101.0" prefWidth="227.0" />
|
||||
<TextField id="tfAddAllergy" promptText="Allergie hinzufügen">
|
||||
<VBox.margin>
|
||||
<Insets top="15.0" />
|
||||
</VBox.margin>
|
||||
</TextField>
|
||||
<HBox prefHeight="26.0" prefWidth="256.0">
|
||||
<children>
|
||||
<ComboBox fx:id="selectAllergy" prefWidth="150.0" promptText="Allergie wählen" />
|
||||
<ComboBox fx:id="selectAllergySeverity" prefWidth="150.0" promptText="Schwere" />
|
||||
</children>
|
||||
</HBox>
|
||||
<Button fx:id="addAllergy" mnemonicParsing="false" onAction="#addAllergy" prefHeight="25.0" prefWidth="171.0" text="Allergie hinzufügen" />
|
||||
</children>
|
||||
<HBox.margin>
|
||||
<Insets left="15.0" right="15.0" />
|
||||
@ -95,6 +116,6 @@
|
||||
</VBox>
|
||||
</children>
|
||||
</HBox>
|
||||
<Button id="btAddChild" layoutX="419.0" layoutY="502.0" mnemonicParsing="false" prefHeight="26.0" prefWidth="125.0" text="Kind hinzufügen" />
|
||||
<Button id="btAddChild" layoutX="421.0" layoutY="587.0" mnemonicParsing="false" onAction="#onBtClick" prefHeight="26.0" prefWidth="125.0" text="Kind hinzufügen" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
|
Loading…
Reference in New Issue
Block a user