Compare commits
2 commits
c303e45af3
...
2bd06fab41
Author | SHA1 | Date | |
---|---|---|---|
2bd06fab41 | |||
4a9dace345 |
9 changed files with 157 additions and 66 deletions
Binary file not shown.
|
@ -0,0 +1,59 @@
|
|||
package de.hitec.nhplus.controller;
|
||||
|
||||
import de.hitec.nhplus.datastorage.DaoFactory;
|
||||
import de.hitec.nhplus.datastorage.NurseDao;
|
||||
import de.hitec.nhplus.model.Nurse;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.control.cell.PropertyValueFactory;
|
||||
import javafx.scene.control.cell.TextFieldTableCell;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class AllNurseController {
|
||||
|
||||
@FXML
|
||||
private TableView<Nurse> tableView;
|
||||
@FXML
|
||||
private TableColumn<Nurse, Long> columnId;
|
||||
@FXML
|
||||
private TableColumn<Nurse, String> columnFirstName;
|
||||
@FXML
|
||||
private TableColumn<Nurse, String> columnSurname;
|
||||
@FXML
|
||||
private TableColumn<Nurse, String> columnPhoneNumber;
|
||||
|
||||
private final ObservableList<Nurse> nurses = FXCollections.observableArrayList();
|
||||
private NurseDao dao;
|
||||
|
||||
public void initialize() {
|
||||
this.readAllAndSHowInTableView();
|
||||
|
||||
this.columnId.setCellValueFactory(new PropertyValueFactory<>("nid"));
|
||||
|
||||
this.columnFirstName.setCellValueFactory(new PropertyValueFactory<>("firstName"));
|
||||
this.columnFirstName.setCellFactory(TextFieldTableCell.forTableColumn());
|
||||
|
||||
this.columnSurname.setCellValueFactory(new PropertyValueFactory<>("surname"));
|
||||
this.columnSurname.setCellFactory(TextFieldTableCell.forTableColumn());
|
||||
|
||||
|
||||
this.columnPhoneNumber.setCellValueFactory(new PropertyValueFactory<>("phoneNumber"));
|
||||
this.columnPhoneNumber.setCellFactory(TextFieldTableCell.forTableColumn());
|
||||
|
||||
this.tableView.setItems(this.nurses);
|
||||
}
|
||||
|
||||
private void readAllAndSHowInTableView(){
|
||||
this.nurses.clear();
|
||||
this.dao = DaoFactory.getDaoFactory().createNurseDAO();
|
||||
try {
|
||||
this.nurses.addAll(this.dao.readAll());
|
||||
}catch (SQLException exception){
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -36,4 +36,14 @@ public class MainWindowController {
|
|||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
private void handleShowAllNurses(ActionEvent event){
|
||||
FXMLLoader loader = new FXMLLoader(Main.class.getResource("/de/hitec/nhplus/AllNurseView.fxml"));
|
||||
try {
|
||||
mainBorderPane.setCenter(loader.load());
|
||||
}catch (IOException exception){
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ public class NurseDao extends DaoImp<Nurse> {
|
|||
protected PreparedStatement getCreateStatement(Nurse nurse) {
|
||||
PreparedStatement preparedStatement = null;
|
||||
try {
|
||||
final String SQL = "INSERT INTO patient (firstname, surname, phoneNumber)" +
|
||||
final String SQL = "INSERT INTO nurse (firstname, surname, phoneNumber)" +
|
||||
"VALUES (?, ?, ?)";
|
||||
preparedStatement = this.connection.prepareStatement(SQL);
|
||||
preparedStatement.setString(1, nurse.getFirstName());
|
||||
|
|
|
@ -23,6 +23,12 @@ public class Fixtures
|
|||
treatmentFixture.dropTable(connection);
|
||||
treatmentFixture.setupTable(connection);
|
||||
treatmentFixture.load();
|
||||
|
||||
NurseFixture nurseFixture = new NurseFixture();
|
||||
nurseFixture.dropTable(connection);
|
||||
nurseFixture.setupTable(connection);
|
||||
nurseFixture.load();
|
||||
|
||||
} catch (Exception exception){
|
||||
System.out.println(exception.getMessage());
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ public class NurseFixture implements Fixture<Nurse> {
|
|||
@Override
|
||||
public void setupTable(Connection connection) {
|
||||
final String SQL = "CREATE TABLE IF NOT EXISTS nurse (" +
|
||||
"nid BIGINT PRIMARY KEY AUTOINCREMENT, " +
|
||||
"tid INTEGER PRIMARY KEY AUTOINCREMENT, " +
|
||||
"firstname TEXT NOT NULL, " +
|
||||
"surname TEXT NOT NULL, " +
|
||||
"phoneNumber TEXT NOT NULL" +
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.text.*?>
|
||||
|
||||
<AnchorPane prefHeight="500.0" prefWidth="855.0" xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1">
|
||||
<children>
|
||||
<TableView fx:id="tableView" editable="true" layoutX="31.0" layoutY="40.0" AnchorPane.bottomAnchor="70.0" AnchorPane.leftAnchor="15.0" AnchorPane.rightAnchor="15.0" AnchorPane.topAnchor="80.0">
|
||||
<columns>
|
||||
<TableColumn fx:id="colID" maxWidth="1200.0" minWidth="5.0" prefWidth="5.0" text="ID" />
|
||||
<TableColumn fx:id="colSurname" maxWidth="7500.0" minWidth="20.0" prefWidth="100.0" text="Nachname" />
|
||||
<TableColumn fx:id="colFirstName" maxWidth="7500.0" prefWidth="75.0" text="Vorname" />
|
||||
<TableColumn fx:id="colTelephone" maxWidth="7500.0" prefWidth="75.0" text="Telefon" />
|
||||
</columns>
|
||||
<columnResizePolicy>
|
||||
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
|
||||
</columnResizePolicy>
|
||||
</TableView>
|
||||
<HBox layoutX="420.0" layoutY="450.0" spacing="10.0" AnchorPane.bottomAnchor="15.0" AnchorPane.leftAnchor="15.0" AnchorPane.rightAnchor="15.0">
|
||||
<children>
|
||||
<TextField fx:id="txfSurname" prefHeight="26.0" prefWidth="220.0" promptText="Nachname" />
|
||||
<TextField fx:id="txfFirstname" prefHeight="26.0" prefWidth="220.0" promptText="Vorname" />
|
||||
<TextField fx:id="txfTelephone" prefWidth="160.0" promptText="Telefonnummer" />
|
||||
<Button fx:id="btnAdd" mnemonicParsing="false" prefWidth="90.0" text="Hinzufügen" />
|
||||
<Button fx:id="btnDelete" mnemonicParsing="false" prefWidth="90.0" text="Löschen" />
|
||||
</children>
|
||||
</HBox>
|
||||
<HBox alignment="TOP_CENTER" layoutX="10.0" layoutY="10.0" prefWidth="200.0" spacing="25.0" AnchorPane.leftAnchor="5.0" AnchorPane.rightAnchor="5.0" AnchorPane.topAnchor="5.0">
|
||||
<children>
|
||||
<Label alignment="CENTER" contentDisplay="CENTER" minWidth="400.0" text="Pfleger/innen" textAlignment="CENTER">
|
||||
<font>
|
||||
<Font size="36.0" />
|
||||
</font>
|
||||
</Label>
|
||||
</children>
|
||||
</HBox>
|
||||
</children>
|
||||
<padding>
|
||||
<Insets top="10.0" />
|
||||
</padding>
|
||||
</AnchorPane>
|
47
src/main/resources/de/hitec/nhplus/AllNurseView.fxml
Normal file
47
src/main/resources/de/hitec/nhplus/AllNurseView.fxml
Normal file
|
@ -0,0 +1,47 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
<AnchorPane prefHeight="500.0" prefWidth="855.0" xmlns="http://javafx.com/javafx/10.0.2-internal"
|
||||
xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hitec.nhplus.controller.AllNurseController">
|
||||
<children>
|
||||
<TableView fx:id="tableView" editable="true" layoutX="31.0" layoutY="40.0" AnchorPane.bottomAnchor="70.0"
|
||||
AnchorPane.leftAnchor="15.0" AnchorPane.rightAnchor="15.0" AnchorPane.topAnchor="80.0">
|
||||
<columns>
|
||||
<TableColumn fx:id="columnId" maxWidth="1200.0" minWidth="5.0" prefWidth="5.0" text="ID"/>
|
||||
<TableColumn fx:id="columnSurname" maxWidth="7500.0" minWidth="20.0" prefWidth="100.0" text="Nachname"/>
|
||||
<TableColumn fx:id="columnFirstName" maxWidth="7500.0" prefWidth="75.0" text="Vorname"/>
|
||||
<TableColumn fx:id="columnPhoneNumber" maxWidth="7500.0" prefWidth="75.0" text="Telefonnummer"/>
|
||||
</columns>
|
||||
<columnResizePolicy>
|
||||
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY"/>
|
||||
</columnResizePolicy>
|
||||
</TableView>
|
||||
<HBox layoutX="420.0" layoutY="450.0" spacing="10.0" AnchorPane.bottomAnchor="15.0" AnchorPane.leftAnchor="15.0"
|
||||
AnchorPane.rightAnchor="15.0">
|
||||
<children>
|
||||
<TextField fx:id="txfSurname" prefHeight="26.0" prefWidth="220.0" promptText="Nachname"/>
|
||||
<TextField fx:id="txfFirstname" prefHeight="26.0" prefWidth="220.0" promptText="Vorname"/>
|
||||
<TextField fx:id="txfPhoneNumber" prefWidth="160.0" promptText="Telefonnummer"/>
|
||||
<Button fx:id="btnAdd" mnemonicParsing="false" prefWidth="90.0" text="Hinzufügen"/>
|
||||
<Button fx:id="btnDelete" mnemonicParsing="false" prefWidth="90.0" text="Löschen"/>
|
||||
</children>
|
||||
</HBox>
|
||||
<HBox alignment="TOP_CENTER" layoutX="10.0" layoutY="10.0" prefWidth="200.0" spacing="25.0"
|
||||
AnchorPane.leftAnchor="5.0" AnchorPane.rightAnchor="5.0" AnchorPane.topAnchor="5.0">
|
||||
<children>
|
||||
<Label alignment="CENTER" contentDisplay="CENTER" minWidth="400.0" text="Pfleger/innen"
|
||||
textAlignment="CENTER">
|
||||
<font>
|
||||
<Font size="36.0"/>
|
||||
</font>
|
||||
</Label>
|
||||
</children>
|
||||
</HBox>
|
||||
</children>
|
||||
<padding>
|
||||
<Insets top="10.0"/>
|
||||
</padding>
|
||||
</AnchorPane>
|
|
@ -1,24 +1,36 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
|
||||
<BorderPane fx:id="mainBorderPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="688.0" prefWidth="926.0" xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hitec.nhplus.controller.MainWindowController">
|
||||
<BorderPane fx:id="mainBorderPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity"
|
||||
prefHeight="688.0" prefWidth="926.0" xmlns="http://javafx.com/javafx/10.0.2-internal"
|
||||
xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hitec.nhplus.controller.MainWindowController">
|
||||
<left>
|
||||
<VBox id="vBox" alignment="CENTER" spacing="50.0" styleClass="vBox" stylesheets="@Application.css" BorderPane.alignment="CENTER">
|
||||
<VBox id="vBox" alignment="CENTER" spacing="50.0" styleClass="vBox" stylesheets="@Application.css"
|
||||
BorderPane.alignment="CENTER">
|
||||
<children>
|
||||
<Button alignment="CENTER" contentDisplay="CENTER" mnemonicParsing="false" onAction="#handleShowAllPatient" prefWidth="105.0" text="Patienten/innen">
|
||||
<Button alignment="CENTER" contentDisplay="CENTER" mnemonicParsing="false"
|
||||
onAction="#handleShowAllPatient" prefWidth="105.0" text="Patienten/innen">
|
||||
<VBox.margin>
|
||||
<Insets bottom="50.0" left="10.0" right="10.0" top="50.0" />
|
||||
<Insets bottom="50.0" left="10.0" right="10.0" top="50.0"/>
|
||||
</VBox.margin>
|
||||
<opaqueInsets>
|
||||
<Insets />
|
||||
</opaqueInsets></Button>
|
||||
<Button alignment="CENTER" contentDisplay="CENTER" mnemonicParsing="false" onAction="#handleShowAllTreatments" prefWidth="105.0" text="Behandlungen">
|
||||
<Insets/>
|
||||
</opaqueInsets>
|
||||
</Button>
|
||||
<Button alignment="CENTER" contentDisplay="CENTER" mnemonicParsing="false"
|
||||
onAction="#handleShowAllTreatments" prefWidth="105.0" text="Behandlungen">
|
||||
<VBox.margin>
|
||||
<Insets bottom="50.0" left="10.0" right="10.0" top="50.0" />
|
||||
</VBox.margin></Button>
|
||||
<Insets bottom="50.0" left="10.0" right="10.0" top="50.0"/>
|
||||
</VBox.margin>
|
||||
</Button>
|
||||
<Button alignment="CENTER" contentDisplay="CENTER" mnemonicParsing="false"
|
||||
onAction="#handleShowAllNurses" prefWidth="105.0" text="Pfleger/innen">
|
||||
<VBox.margin>
|
||||
<Insets bottom="50.0" left="10.0" right="10.0" top="50.0"/>
|
||||
</VBox.margin>
|
||||
</Button>
|
||||
</children>
|
||||
</VBox>
|
||||
</left>
|
||||
|
|
Loading…
Reference in a new issue