-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStaffDeleteWindowController.java
More file actions
135 lines (107 loc) · 4.42 KB
/
StaffDeleteWindowController.java
File metadata and controls
135 lines (107 loc) · 4.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package healthcareLook;
import java.net.URL;
import java.util.Optional;
import java.util.ResourceBundle;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonType;
import javafx.scene.control.TextField;
import javafx.scene.control.Tooltip;
import javafx.scene.image.ImageView;
/*
* The purpose of this window is to delete the staff member. This will delete
* them from the database but the id number will still be used.
* This is so the patient appointment information stays in case they wish to
* know when they came to the clinic.
*/
public class StaffDeleteWindowController implements Initializable {
@FXML
Button submit;
@FXML
TextField staffId;
@FXML
ImageView errorImage;
Tooltip errortip;
Alert dataAlert = new Alert(AlertType.CONFIRMATION);
Alert confirmAlert = new Alert(AlertType.CONFIRMATION);
Alert warnAlert = new Alert(AlertType.WARNING);
Employee employeeHolder;
Optional<ButtonType> result;
Optional<ButtonType> result2;
String adminId;
@Override
public void initialize(URL location, ResourceBundle resources) {
submit.setOnAction(e->{
//I set the image as invisible because I assume the person will enter the information correctly.
errorImage.setVisible(false);
//If the information is blank or empty it will set the error image to visible and the database
//is not accessed.
if(staffId.getText().trim().equals("")){
errorImage.setVisible(true);
errortip.install(errorImage, new Tooltip("Please enter your staff ID"));
}
else if(getLetterCount(staffId.getText().trim())){
errorImage.setVisible(true);
errortip.install(errorImage, new Tooltip("Please enter your staff ID"));
}//This checks if the employee is in the database.
else if(DatabaseWork.IDCheckStaff(staffId.getText().trim())){
//this will retrieve the information of the employee.
employeeHolder = DatabaseWork.IDStaffConfirmation(staffId.getText().trim());
dataAlert.setTitle("Confirmation");
dataAlert.setHeaderText("Are you sure you wish to delete this employee?");
//This displays the information of the employee. This is to make sure the admin knows who
//he is about to delete (fire).
dataAlert.setContentText("Name: " + employeeHolder.getfName() + " " + employeeHolder.getlName() +
"\nStaff Postion: " + employeeHolder.getPosition() + "\nSocial Security Number: " + employeeHolder.getSsn());
result = dataAlert.showAndWait();
if(result.get() == ButtonType.OK){
dataAlert.close();
//if the person wishes to delete the staff then they are removed.
DatabaseWork.RemoveStaff(staffId.getText().trim());
confirmAlert.setTitle("Successful Deletion");
confirmAlert.setHeaderText("The Deletion of the employee was successful.");
confirmAlert.setContentText("Do you wish to delete another employee?");
ButtonType yes = new ButtonType("YES");
ButtonType no = new ButtonType("NO");
confirmAlert.getButtonTypes().setAll(yes, no);
result2 = confirmAlert.showAndWait();
//if the person has another employee to delete then the messages box closes and they can
//enter in another id.
if(result2.get() == yes){
confirmAlert.close();
}
else{
//else they will be moved to the diagnosis window if they
//have a diagnosis to put, or moved to the interaction window
adminId = StaffDeleteWindow.getId();
StaffDeleteWindow.stageClose();
}
}
else{
staffId.clear();
dataAlert.close();
}
}
else{
warnAlert.setTitle("An Error Has Occurred");
warnAlert.setHeaderText("Staff ID not found.");
warnAlert.setContentText("Please Make sure you have the correct Staff ID");
warnAlert.showAndWait();
}
});
//If the admin has a change of heart and does not want to delete they can hit the skip
//button and this will take them to the next window.
}
//This check is for when I do not want letters or symbols.
public boolean getLetterCount(String s) {
Pattern p = Pattern.compile("[^0-9]");
Matcher m = p.matcher(s);
boolean b = m.find();
return b;
}
}