88import GUI .utilities .ModuleRegisterTableGUI ;
99import database .bean .ModuleRegister ;
1010import database .managers .ModuleRegisterManager ;
11+ import exception .InvalidAdminException ;
1112import javafx .collections .FXCollections ;
1213import javafx .collections .ObservableList ;
1314import javafx .event .ActionEvent ;
1415import javafx .fxml .FXML ;
1516import javafx .fxml .Initializable ;
17+ import javafx .geometry .Insets ;
18+ import javafx .scene .Scene ;
1619import javafx .scene .control .Button ;
1720import javafx .scene .control .ComboBox ;
1821import javafx .scene .control .Label ;
2427import javafx .scene .image .ImageView ;
2528import javafx .scene .input .KeyEvent ;
2629import javafx .scene .input .MouseEvent ;
30+ import javafx .scene .layout .GridPane ;
31+ import javafx .stage .Modality ;
32+ import javafx .stage .Stage ;
2733import utils .ModuleRegisterFilter ;
2834
2935public 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 ) {
0 commit comments