Skip to content

Commit ea7be32

Browse files
committed
GUI UPdated
Verify student button added Add student to module added
1 parent debca67 commit ea7be32

8 files changed

Lines changed: 439 additions & 9 deletions

File tree

‎ModualrProject/src/GUI/controller/AspiringStudentsController.java‎

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
11
package GUI.controller;
22

3+
import java.io.IOException;
34
import java.net.URL;
45
import java.sql.SQLException;
56
import java.util.ResourceBundle;
67

78
import GUI.utilities.AspStudentTableGUI;
9+
import GUI.utilities.Paths;
810
import database.bean.Admin;
11+
import database.bean.ModuleRegister;
912
import database.bean.student.Student;
1013
import database.managers.ConnectionManager;
1114
import database.managers.DatabaseManager;
15+
import database.managers.ModuleRegisterManager;
1216
import database.managers.StudentManager;
1317
import exception.InvalidAdminException;
1418
import javafx.collections.FXCollections;
1519
import javafx.collections.ObservableList;
1620
import javafx.event.ActionEvent;
1721
import javafx.fxml.FXML;
22+
import javafx.fxml.FXMLLoader;
1823
import javafx.fxml.Initializable;
24+
import javafx.geometry.Insets;
25+
import javafx.scene.Parent;
26+
import javafx.scene.Scene;
1927
import javafx.scene.control.Button;
2028
import javafx.scene.control.ComboBox;
2129
import javafx.scene.control.Label;
@@ -25,13 +33,16 @@
2533
import javafx.scene.control.cell.PropertyValueFactory;
2634
import javafx.scene.image.ImageView;
2735
import javafx.scene.input.MouseEvent;
36+
import javafx.scene.layout.GridPane;
37+
import javafx.stage.Modality;
38+
import javafx.stage.Stage;
2839

2940
public class AspiringStudentsController implements Initializable{
3041
@FXML private TextField txtSearchBar;
3142
@FXML private Button btnGo;
3243
@FXML private Button btnRegisterStudent;
3344

34-
@FXML private ComboBox cmbCategory;
45+
@FXML private ComboBox<?> cmbCategory;
3546
@FXML private TableView<AspStudentTableGUI> aspStudentTable;
3647
@FXML private TableColumn<AspStudentTableGUI,String> sn;
3748
@FXML private TableColumn<AspStudentTableGUI,String> firstName;
@@ -47,8 +58,17 @@ public void getuser(MouseEvent event) {
4758

4859

4960

50-
@FXML private void studentDetails(ActionEvent event) {
51-
61+
@FXML private void studentDetails(ActionEvent event) throws IOException {
62+
Stage regInfo = new Stage();
63+
regInfo.initModality(Modality.APPLICATION_MODAL);
64+
Parent root = FXMLLoader.load(getClass().getResource(Paths.viewpath + "VerifyStudent.fxml"));
65+
Scene scene = new Scene(root);
66+
//helpStage.getIcons().add(new Image(logoURL));
67+
regInfo.setResizable(false);
68+
regInfo.setScene(scene);
69+
regInfo.sizeToScene();
70+
regInfo.setTitle("Aspiring Students info");
71+
regInfo.show();
5272
}
5373

5474

@@ -62,6 +82,8 @@ public void initialize(URL location, ResourceBundle resources)
6282
aspStudentTable.setItems(getstudents());
6383
}
6484

85+
86+
6587
private ObservableList<AspStudentTableGUI> getstudents(){
6688

6789
ObservableList<AspStudentTableGUI> aspStudentList = FXCollections.observableArrayList();

‎ModualrProject/src/GUI/controller/ModuleRegisterController.java‎

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@
88
import GUI.utilities.ModuleRegisterTableGUI;
99
import database.bean.ModuleRegister;
1010
import database.managers.ModuleRegisterManager;
11+
import exception.InvalidAdminException;
1112
import javafx.collections.FXCollections;
1213
import javafx.collections.ObservableList;
1314
import javafx.event.ActionEvent;
1415
import javafx.fxml.FXML;
1516
import javafx.fxml.Initializable;
17+
import javafx.geometry.Insets;
18+
import javafx.scene.Scene;
1619
import javafx.scene.control.Button;
1720
import javafx.scene.control.ComboBox;
1821
import javafx.scene.control.Label;
@@ -24,6 +27,9 @@
2427
import javafx.scene.image.ImageView;
2528
import javafx.scene.input.KeyEvent;
2629
import javafx.scene.input.MouseEvent;
30+
import javafx.scene.layout.GridPane;
31+
import javafx.stage.Modality;
32+
import javafx.stage.Stage;
2733
import utils.ModuleRegisterFilter;
2834

2935
public class ModuleRegisterController implements Initializable
@@ -46,6 +52,7 @@ public class ModuleRegisterController implements Initializable
4652

4753
@FXML private TextField txtSearch;
4854
@FXML private Button btnGO;
55+
@FXML private Button btnRegisterStudent;
4956

5057

5158
private ModuleRegister[] modRegs;
@@ -155,7 +162,59 @@ private void getFilter(ActionEvent event)
155162
moduleRegisterTable.setItems(list);
156163
}
157164

158-
165+
@FXML
166+
private void registerStudent(ActionEvent event) {
167+
Stage window = new Stage();
168+
window.initModality(Modality.WINDOW_MODAL);
169+
window.setTitle("thenewboston - JavaFX");
170+
171+
//GridPane with 10px padding around edge
172+
GridPane grid = new GridPane();
173+
grid.setPadding(new Insets(10, 10, 10, 10));
174+
grid.setVgap(8);
175+
grid.setHgap(10);
176+
177+
//Name Label - constrains use (child, column, row)
178+
Label nameLabel = new Label("StudentID:");
179+
GridPane.setConstraints(nameLabel, 0, 0);
180+
181+
//Name Input
182+
TextField txtstudentID = new TextField();
183+
GridPane.setConstraints(txtstudentID, 1, 0);
184+
185+
//Password Label
186+
Label moduleLabel = new Label("Module:");
187+
GridPane.setConstraints(moduleLabel, 0, 1);
188+
189+
//Password Input
190+
TextField txtModuleName = new TextField();
191+
// passInput.setPromptText("password");
192+
GridPane.setConstraints(txtModuleName, 1, 1);
193+
194+
//Login
195+
Button registerButton = new Button("Register");
196+
GridPane.setConstraints(registerButton, 1, 2);
197+
198+
registerButton.setOnMouseClicked(e->{
199+
try
200+
{
201+
ModuleRegisterManager.registerForModule(new ModuleRegister(txtstudentID.getText(),txtModuleName.getText()));
202+
}
203+
catch (SQLException | InvalidAdminException e1)
204+
{
205+
e1.printStackTrace();
206+
}
207+
208+
System.out.println(txtstudentID.getText() + "was successfully registered for " + txtModuleName.getText());
209+
});
210+
//Add everything to grid
211+
grid.getChildren().addAll(nameLabel, txtstudentID, moduleLabel, txtModuleName, registerButton);
212+
213+
Scene scene = new Scene(grid, 300, 200);
214+
window.setScene(scene);
215+
window.show();
216+
217+
}
159218

160219
@FXML
161220
private void keyPressed(KeyEvent event) {
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
package GUI.controller;
2+
3+
import javafx.fxml.FXML;
4+
import javafx.geometry.Insets;
5+
import javafx.scene.Scene;
6+
import javafx.scene.control.Button;
7+
import javafx.scene.control.Label;
8+
import javafx.scene.control.TextField;
9+
import javafx.scene.layout.GridPane;
10+
import javafx.stage.Modality;
11+
import javafx.stage.Stage;
12+
13+
import java.sql.SQLException;
14+
15+
import database.bean.ModuleRegister;
16+
import database.managers.ModuleRegisterManager;
17+
import exception.InvalidAdminException;
18+
import javafx.event.ActionEvent;
19+
20+
public class VerifyStudentController {
21+
@FXML
22+
private Button btnRegister;
23+
24+
// Event Listener on Button[#btnRegister].onAction
25+
@FXML
26+
private void registerStudent(ActionEvent event) {
27+
Stage window = new Stage();
28+
window.initModality(Modality.WINDOW_MODAL);
29+
window.setTitle("Student Info");
30+
31+
//GridPane with 10px padding around edge
32+
GridPane grid = new GridPane();
33+
grid.setPadding(new Insets(10, 10, 10, 10));
34+
grid.setVgap(8);
35+
grid.setHgap(10);
36+
37+
//Name Label - constrains use (child, column, row)
38+
Label nameLabel = new Label("StudentID:");
39+
GridPane.setConstraints(nameLabel, 0, 0);
40+
41+
//Name Input
42+
TextField txtstudentID = new TextField();
43+
GridPane.setConstraints(txtstudentID, 1, 0);
44+
45+
//Password Label
46+
Label moduleLabel = new Label("Class:");
47+
GridPane.setConstraints(moduleLabel, 0, 1);
48+
49+
//Password Input
50+
TextField txtClass = new TextField();
51+
// passInput.setPromptText("password");
52+
GridPane.setConstraints(txtClass, 1, 1);
53+
54+
//Password Label
55+
Label lblPhoneno = new Label("Phone no:");
56+
GridPane.setConstraints(lblPhoneno, 0, 2);
57+
58+
//Phone
59+
TextField txtPhoneno = new TextField();
60+
// passInput.setPromptText("password");
61+
GridPane.setConstraints(txtClass, 1, 2);
62+
63+
//Login
64+
Button registerButton = new Button("Register");
65+
GridPane.setConstraints(registerButton, 1, 4);
66+
67+
registerButton.setOnMouseClicked(e->{
68+
try
69+
{
70+
ModuleRegisterManager.registerForModule(new ModuleRegister(txtstudentID.getText(),txtClass.getText()));
71+
}
72+
catch (SQLException | InvalidAdminException e1)
73+
{
74+
e1.printStackTrace();
75+
}
76+
77+
System.out.println(txtstudentID.getText() + "was successfully registered for " + txtClass.getText());
78+
});
79+
//Add everything to grid
80+
grid.getChildren().addAll(nameLabel, txtstudentID, moduleLabel, txtClass, txtPhoneno,lblPhoneno,registerButton);
81+
82+
Scene scene = new Scene(grid, 300, 200);
83+
window.setScene(scene);
84+
window.show();
85+
}
86+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
*
3+
*/
4+
package GUI.utilities;
5+
6+
/**
7+
* @author ChineduKnight
8+
*
9+
*/
10+
public class Paths {
11+
public static final String viewpath = "/GUI/views/";
12+
// public static final String controllerpath = "/com/solutioninventors/tournament/GUI/controller/";
13+
// public static final String GUIpath = "/com/solutioninventors/tournament/GUI/";
14+
// public static final String fonts = "/com/solutioninventors/tournament/GUI/resource/font/";
15+
// public static final String images = "/com/solutioninventors/tournament/GUI/resource/images/";
16+
// public static final String css = "/com/solutioninventors/tournament/GUI/css/";
17+
}

‎ModualrProject/src/GUI/views/AspiringStudents.fxml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,6 @@
6161
</ImageView>
6262
</children>
6363
</GridPane>
64-
<Button fx:id="btnRegisterStudent" layoutX="57.0" layoutY="441.0" mnemonicParsing="false" prefHeight="47.0" prefWidth="122.0" text="Register Student" />
64+
<Button fx:id="btnRegisterStudent" layoutX="57.0" layoutY="441.0" mnemonicParsing="false" onAction="#studentDetails" prefHeight="47.0" prefWidth="122.0" text="Register Student" />
6565
</children>
6666
</AnchorPane>

‎ModualrProject/src/GUI/views/Module Register.fxml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,6 @@
7070
<image>
7171
<Image url="@../../../../../../Pictures/Customer.jpg" />
7272
</image></ImageView>
73-
<Label text="Label" />
73+
<Button fx:id="btnRegisterStudent" layoutX="52.0" layoutY="433.0" mnemonicParsing="false" onAction="#registerStudent" prefHeight="32.0" prefWidth="111.0" text="Register student" />
7474
</children>
7575
</AnchorPane>

‎ModualrProject/src/GUI/views/Registration.fxml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
<content>
7979
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
8080
<children>
81-
<GridPane layoutX="37.0" layoutY="34.0" prefHeight="330.0" prefWidth="337.0">
81+
<GridPane layoutX="27.0" layoutY="33.0" prefHeight="330.0" prefWidth="337.0">
8282
<columnConstraints>
8383
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
8484
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
@@ -201,11 +201,11 @@
201201
</AnchorPane>
202202
</content>
203203
</Tab>
204-
<Tab text="Untitled Tab">
204+
<Tab text="Sponsor">
205205
<content>
206206
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
207207
<children>
208-
<GridPane prefHeight="330.0" prefWidth="337.0">
208+
<GridPane layoutX="37.0" prefHeight="330.0" prefWidth="337.0">
209209
<columnConstraints>
210210
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
211211
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />

0 commit comments

Comments
 (0)