Compare commits
3 commits
0c3c1ec9df
...
280ef132b3
Author | SHA1 | Date | |
---|---|---|---|
280ef132b3 | |||
4b13bf6fe3 | |||
fcebe01f1e |
4 changed files with 55 additions and 5 deletions
|
@ -1,18 +1,30 @@
|
|||
package de.hitec.nhplus.nurse;
|
||||
|
||||
import static de.hitec.nhplus.utils.Validator.*;
|
||||
|
||||
import de.hitec.nhplus.datastorage.DaoFactory;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.control.cell.PropertyValueFactory;
|
||||
import javafx.scene.control.cell.TextFieldTableCell;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class AllNurseController {
|
||||
|
||||
@FXML
|
||||
public TextField textFieldSurname;
|
||||
@FXML
|
||||
public TextField textFieldFirstname;
|
||||
@FXML
|
||||
public TextField textFieldPhoneNumber;
|
||||
@FXML
|
||||
public Button buttonAdd;
|
||||
@FXML
|
||||
private TableView<Nurse> tableView;
|
||||
@FXML
|
||||
|
@ -43,6 +55,20 @@ public class AllNurseController {
|
|||
this.columnPhoneNumber.setCellFactory(TextFieldTableCell.forTableColumn());
|
||||
|
||||
this.tableView.setItems(this.nurses);
|
||||
|
||||
this.buttonAdd.setDisable(true);
|
||||
ChangeListener<String> inputNewNurseValidationListener = (observableValue, oldText, newText)->
|
||||
{
|
||||
boolean isValid = isValidFirstName(this.textFieldFirstname.getText())
|
||||
&& isValidSurName(this.textFieldSurname.getText())
|
||||
&& isValidPhoneNumber(this.textFieldPhoneNumber.getText());
|
||||
|
||||
AllNurseController.this.buttonAdd.setDisable(!isValid);
|
||||
};
|
||||
|
||||
this.textFieldFirstname.textProperty().addListener(inputNewNurseValidationListener);
|
||||
this.textFieldSurname.textProperty().addListener(inputNewNurseValidationListener);
|
||||
this.textFieldPhoneNumber.textProperty().addListener(inputNewNurseValidationListener);
|
||||
}
|
||||
|
||||
private void readAllAndShowInTableView(){
|
||||
|
@ -54,4 +80,25 @@ public class AllNurseController {
|
|||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
@FXML
|
||||
public void handleAdd(){
|
||||
String surname=this.textFieldSurname.getText();
|
||||
String firstName=this.textFieldFirstname.getText();
|
||||
String phoneNumber=this.textFieldPhoneNumber.getText();
|
||||
try {
|
||||
this.dao.create(new Nurse(firstName, surname, phoneNumber));
|
||||
}
|
||||
catch (SQLException exception){
|
||||
exception.printStackTrace();
|
||||
}
|
||||
readAllAndShowInTableView();
|
||||
clearTextfields();
|
||||
}
|
||||
|
||||
private void clearTextfields() {
|
||||
this.textFieldFirstname.clear();
|
||||
this.textFieldSurname.clear();
|
||||
this.textFieldPhoneNumber.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -77,11 +77,10 @@ public class AllTreatmentController {
|
|||
}
|
||||
|
||||
public void readAllAndShowInTableView() {
|
||||
this.treatments.clear();
|
||||
comboBoxPatientSelection.getSelectionModel().select(0);
|
||||
this.dao = DaoFactory.getDaoFactory().createTreatmentDao();
|
||||
try {
|
||||
this.treatments.addAll(dao.readAll());
|
||||
this.treatments.setAll(dao.readAll());
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
@ -109,7 +108,7 @@ public class AllTreatmentController {
|
|||
|
||||
if (selectedPatient.equals("alle")) {
|
||||
try {
|
||||
this.treatments.addAll(this.dao.readAll());
|
||||
this.treatments.setAll(this.dao.readAll());
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
@ -118,7 +117,7 @@ public class AllTreatmentController {
|
|||
Patient patient = searchInList(selectedPatient);
|
||||
if (patient != null) {
|
||||
try {
|
||||
this.treatments.addAll(this.dao.readTreatmentsByPid(patient.getId()));
|
||||
this.treatments.setAll(this.dao.readTreatmentsByPid(patient.getId()));
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
|
|
@ -68,6 +68,9 @@ public class Validator
|
|||
public static boolean isValidSurName(String text){
|
||||
return !text.isBlank();
|
||||
}
|
||||
public static boolean isValidPhoneNumber(String text){
|
||||
return !text.isBlank();
|
||||
}
|
||||
public static boolean isValidCareLevel(String text){
|
||||
return !text.isBlank();
|
||||
}
|
||||
|
|
|
@ -72,6 +72,7 @@
|
|||
<Button
|
||||
fx:id="buttonAdd"
|
||||
mnemonicParsing="false"
|
||||
onAction="#handleAdd"
|
||||
prefWidth="90.0"
|
||||
text="Hinzufügen"
|
||||
/>
|
||||
|
|
Loading…
Reference in a new issue