-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPatientEnrollController.java
149 lines (124 loc) · 5.36 KB
/
PatientEnrollController.java
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
package com.example.hopeitworks;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.stage.Stage;
import java.io.IOException;
import java.net.URL;
import java.sql.*;
import java.time.LocalDate;
import java.util.ResourceBundle;
public class PatientEnrollController implements Initializable {
@FXML
public TextField usernameTextField10;
@FXML
public TextField usernameTextField11;
@FXML
public TextField usernameTextField12;
@FXML
private ChoiceBox<String> usernameTextField13;
@FXML
public TextField usernameTextField14;
@FXML
public TextField usernameTextField15;
@FXML
public DatePicker usernameTextField16;
@FXML
public TextField usernameTextField17;
@FXML
public TextField usernameTextField18;
@FXML
private Label gender;
@FXML
private ChoiceBox<String> roomcategory;
private String[] g = {"Male", "Female"};
@Override
public void initialize (URL url, ResourceBundle resourceBundle){
usernameTextField13.getItems().addAll(g);
try {
roomcategory.setItems(DatabaseConnection.getRoomCategory());
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
public void getGender(ActionEvent event){
String mygender = usernameTextField13.getValue();
gender.setText(mygender);
}
public void Enroll(ActionEvent event) {
try {
Connection connect = DatabaseConnection.connectDb();
//Creating Connection Object
String Sql = "INSERT INTO `hbms_db`.`patient`(p_name,p_phone,p_age,p_gender,p_relative_name,p_relative_no,p_admission,b_id,p_lastname) VALUES(?,?,?,?,?,?,?,?,?)";
//Preapared Statement
PreparedStatement Pstatement = connect.prepareStatement(Sql);
//Specifying the values of it's parameter
Pstatement.setString(1, usernameTextField10.getText());
Pstatement.setString(2, usernameTextField11.getText());
Pstatement.setString(3, usernameTextField12.getText());
Pstatement.setString(4, usernameTextField13.getValue());
Pstatement.setString(5, usernameTextField14.getText());
Pstatement.setString(6, usernameTextField15.getText());
Pstatement.setString(7, String.valueOf(usernameTextField16.getValue()));
Pstatement.setString(8, usernameTextField17.getText());
Pstatement.setString(9, usernameTextField18.getText());
int result = Pstatement.executeUpdate();
Alert alert;
alert = new Alert(Alert.AlertType.INFORMATION);
alert.setTitle("enrolled succesfully!");
alert.setContentText("Successfully");
alert.showAndWait();
Parent NextParent = FXMLLoader.load(getClass().getResource("patients_infotable.fxml"));
Scene NextScene = new Scene(NextParent);
Stage window = (Stage)((Node)event.getSource()).getScene().getWindow();
window.setScene(NextScene);
window.show();
} catch (SQLException e1) {
e1.printStackTrace();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public void onCancelButtonClick(ActionEvent event) throws IOException {
Parent NextParent = FXMLLoader.load(getClass().getResource("patients_info.fxml"));
Scene NextScene = new Scene(NextParent);
Stage window = (Stage)((Node)event.getSource()).getScene().getWindow();
window.setScene(NextScene);
window.show();
}
public void onPatientInfoButtonClick(ActionEvent event) throws IOException {
Parent NextParent = FXMLLoader.load(getClass().getResource("patients_infotable.fxml"));
Scene NextScene = new Scene(NextParent);
Stage window = (Stage)((Node)event.getSource()).getScene().getWindow();
window.setScene(NextScene);
window.show();
}
public void onDashboardButtonClick(ActionEvent event) throws IOException {
Parent NextParent = FXMLLoader.load(getClass().getResource("dashboard.fxml"));
Scene NextScene = new Scene(NextParent);
Stage window = (Stage)((Node)event.getSource()).getScene().getWindow();
window.setScene(NextScene);
window.show();
}
public void onBedInfoButtonClick(ActionEvent event) throws IOException {
Parent NextParent = FXMLLoader.load(getClass().getResource("bed_ui.fxml"));
Scene NextScene = new Scene(NextParent);
Stage window = (Stage)((Node)event.getSource()).getScene().getWindow();
window.setScene(NextScene);
window.show();
}
public void Logout(ActionEvent event) throws IOException {
Parent NextParent = FXMLLoader.load(getClass().getResource("loginform.fxml"));
Scene NextScene = new Scene(NextParent);
Stage window = (Stage)((Node)event.getSource()).getScene().getWindow();
window.setScene(NextScene);
window.show();
}
}