#25: Implement Editing of Nurses
This commit is contained in:
parent
e4793780fd
commit
47354a4bd9
3 changed files with 54 additions and 5 deletions
|
@ -106,6 +106,17 @@ public class AllNurseController {
|
|||
this.textFieldPhoneNumber.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal method that stores the changes in the database.
|
||||
*/
|
||||
private void doUpdate(TableColumn.CellEditEvent<Nurse, String> event) {
|
||||
try {
|
||||
this.dao.update(event.getRowValue());
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void handleAdd(){
|
||||
String surname=this.textFieldSurName.getText();
|
||||
|
@ -137,4 +148,39 @@ public class AllNurseController {
|
|||
readAllAndShowInTableView();
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void handleOnEditSurname(TableColumn.CellEditEvent<Nurse, String> event) {
|
||||
String newSurName = event.getNewValue();
|
||||
if (!isValidSurName(newSurName)) {
|
||||
showValidationError("Nachname");
|
||||
event.getTableView().refresh();
|
||||
return;
|
||||
}
|
||||
event.getRowValue().setSurName(newSurName);
|
||||
this.doUpdate(event);
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void handleOnEditFirstname(TableColumn.CellEditEvent<Nurse, String> event) {
|
||||
String newFirstName = event.getNewValue();
|
||||
if (!isValidFirstName(newFirstName)) {
|
||||
showValidationError("Vorname");
|
||||
event.getTableView().refresh();
|
||||
return;
|
||||
}
|
||||
event.getRowValue().setFirstName(newFirstName);
|
||||
this.doUpdate(event);
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void handleOnEditPhoneNumber(TableColumn.CellEditEvent<Nurse, String> event) {
|
||||
String newPhoneNumber = event.getNewValue();
|
||||
if (!isValidPhoneNumber(newPhoneNumber)) {
|
||||
showValidationError("Telefonnummer");
|
||||
event.getTableView().refresh();
|
||||
return;
|
||||
}
|
||||
event.getRowValue().setPhoneNumber(newPhoneNumber);
|
||||
this.doUpdate(event);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -154,7 +154,7 @@ public class AllPatientController {
|
|||
public void handleOnEditFirstname(TableColumn.CellEditEvent<Patient, String> event) {
|
||||
String newFirstName = event.getNewValue();
|
||||
if (!isValidFirstName(newFirstName)) {
|
||||
showValidationError("First Name");
|
||||
showValidationError("Vorname");
|
||||
event.getTableView().refresh();
|
||||
return;
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ public class AllPatientController {
|
|||
public void handleOnEditSurname(TableColumn.CellEditEvent<Patient, String> event) {
|
||||
String newSurName = event.getNewValue();
|
||||
if (!isValidSurName(newSurName)) {
|
||||
showValidationError("Sur Name");
|
||||
showValidationError("Nachname");
|
||||
event.getTableView().refresh();
|
||||
return;
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ public class AllPatientController {
|
|||
public void handleOnEditDateOfBirth(TableColumn.CellEditEvent<Patient, String> event) {
|
||||
String newDateString = event.getNewValue();
|
||||
if (!isValidDate(newDateString)) {
|
||||
showValidationError("Date");
|
||||
showValidationError("Geburtstag");
|
||||
event.getTableView().refresh();
|
||||
return;
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ public class AllPatientController {
|
|||
public void handleOnEditCareLevel(TableColumn.CellEditEvent<Patient, String> event) {
|
||||
String newCareLevel = event.getNewValue();
|
||||
if (!isValidCareLevel(newCareLevel)) {
|
||||
showValidationError("Care Level");
|
||||
showValidationError("Pflegegrad");
|
||||
event.getTableView().refresh();
|
||||
return;
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ public class AllPatientController {
|
|||
public void handleOnEditRoomNumber(TableColumn.CellEditEvent<Patient, String> event) {
|
||||
String newRoomNumber = event.getNewValue();
|
||||
if (!isValidRoomNumber(newRoomNumber)) {
|
||||
showValidationError("Room Number");
|
||||
showValidationError("Raum");
|
||||
event.getTableView().refresh();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -22,16 +22,19 @@
|
|||
<TableColumn
|
||||
fx:id="columnSurName"
|
||||
minWidth="140.0"
|
||||
onEditCommit="#handleOnEditSurname"
|
||||
text="Nachname"
|
||||
/>
|
||||
<TableColumn
|
||||
fx:id="columnFirstName"
|
||||
minWidth="140.0"
|
||||
onEditCommit="#handleOnEditFirstname"
|
||||
text="Vorname"
|
||||
/>
|
||||
<TableColumn
|
||||
fx:id="columnPhoneNumber"
|
||||
minWidth="140.0"
|
||||
onEditCommit="#handleOnEditPhoneNumber"
|
||||
text="Telefonnummer"
|
||||
/>
|
||||
</columns>
|
||||
|
|
Loading…
Reference in a new issue