# classRegister **Repository Path**: fswan/class-register ## Basic Information - **Project Name**: classRegister - **Description**: Class register - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2023-04-10 - **Last Updated**: 2023-05-05 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # classRegister ## 1. Introduce This is a class register system, designed by zhiwen and Xu. Zhiwen is responsible for the application structure and model, Xu responsible Views and Controllers. There are three role. Git address for this probject is: git@gitee.com:fswan/class-register.git. 1. admin Add user (teacher) only, reset password. 2. teacher Add user(student), and add class, reset password. 3. student Register class of a teacher and reset password. ## 2. System Architecture All data store with mysql database. Use javaFX do all view functions. ### 2.1 Structure of folder ``` ├─document -- save the files link in readme.md ├─src -- source code │ ├─main │ │ ├─java -- java file │ │ │ └─com │ │ │ └─swan │ │ │ ├─bean --- POJO bean folder │ │ │ ├─controllers -- controller folder │ │ │ ├─exception --- exception folder │ │ │ ├─models --- model folder │ │ │ ├─util -- some util tool │ │ │ └─views --- view folder │ │ └─resources --- save fxml files │ │ └─com │ │ └─swan │ └─test --- unit test case │ └─java │ └─com │ └─swan │ ├─util │ └─view ``` ### 2.2 E-R Diagram The DB connection information save into the file db.properties. The file db.sql in folder resources used to init database structure. ![ER diagram](document/ER.svg) ## 3. System Implementation ### 3.1 login page #### 3.1.1 GUI ![login page](document/login.png) Login: type the correct account and password , press login button , then login the system. ![login success](document/login_success.png) #### 3.1.2 Source code ##### 3.1.2.1 view ```java package com.swan.views; import java.io.IOException; import com.swan.App; import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.layout.Pane; import javafx.stage.Stage; import javafx.scene.Scene; /** * LoginApplication * @author xyh * @param * @date 20230426 * */ public class LoginApplication extends Application{ @Override public void start(Stage stage) throws IOException { Pane Login = FXMLLoader.load(App.class.getResource("Login.fxml")); Scene login = new Scene(Login); stage.setTitle("Please Login "); stage.setScene(login); stage.show(); } public static void main(String[] args) { launch(args); } public void changePwd() throws IOException { Pane Login = FXMLLoader.load(App.class.getResource("ChangePwd.fxml")); Scene login = new Scene(Login); Stage stage = new Stage(); stage.setTitle("Please Change Your Password "); stage.setScene(login); stage.show(); } public void login() throws IOException { Pane Login = FXMLLoader.load(App.class.getResource("Login.fxml")); Scene login = new Scene(Login); Stage stage = new Stage(); stage.setTitle("Please Login "); stage.setScene(login); stage.show(); } } ``` resources/com/swan/login.fxml ```xml ``` ##### 3.2.2.2 Controller com.swan.controllers.MainController ```java package com.swan.controllers; import java.io.IOException; import com.swan.beans.UserInfo; import com.swan.views.ClassMgtApplication; import com.swan.views.ClassRegistrationApplication; import com.swan.views.CourseSchedulingApplication; import com.swan.views.LoginApplication; import com.swan.views.SeasonMgtApplication; import com.swan.views.UserMgtApplication; import com.swan.views.StudentClassRegApplication; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.control.Hyperlink; import javafx.scene.control.Label; import javafx.stage.Stage; /** * MainController * * @author xyh * @date 20230426 * */ public class MainController { @FXML private Label UserInfoLabel; @FXML private Hyperlink logoutHyper; @FXML public void toUserMgt(ActionEvent event) throws IOException { UserMgtApplication app = new UserMgtApplication(); app.showStage(); } @FXML public void toSeasonMgt(ActionEvent event) throws IOException { SeasonMgtApplication app = new SeasonMgtApplication(); app.showStage(); } @FXML public void toClassMgt(ActionEvent event) throws IOException { ClassMgtApplication app = new ClassMgtApplication(); app.showStage(); } @FXML public void toCourseScheduling(ActionEvent event) throws IOException { CourseSchedulingApplication app = new CourseSchedulingApplication(); app.showStage(); } public void toStudentClassReg() throws IOException { StudentClassRegApplication app = new StudentClassRegApplication(); app.showStage(); } @FXML public void toClassRegistration(ActionEvent event) throws IOException { ClassRegistrationApplication app = new ClassRegistrationApplication(); app.showStage(); } @FXML public void toChangePwd(ActionEvent event) throws IOException { LoginApplication app = new LoginApplication(); app.changePwd(); } @FXML public void toLogout(ActionEvent event) throws IOException { UserInfo.cleanUserSession(); Stage primaryStage = (Stage) logoutHyper.getScene().getWindow(); primaryStage.close(); LoginApplication app = new LoginApplication(); app.login(); } @FXML private void initialize() { UserInfoLabel.setText("Hi , " + UserInfo.getLoginUser().getUserName()); } } ``` ##### 3.2.2.3 Model None ### 3.3 User management #### 3.3.1 GUI ![](document/user_management.png) ![](document/user_delete.png) #### 3.3.2 Source Code ##### 3.3.2.1 View com.swan.views.UserMgtApplication ```java package com.swan.views; import java.io.IOException; import com.swan.App; import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Scene; import javafx.scene.layout.Pane; import javafx.stage.Stage; /** * UserMgtApplication * @author xyh * @param * @date 20230426 * */ public class UserMgtApplication extends Application{ public void showStage() throws IOException { Pane root = FXMLLoader.load(App.class.getResource("UserMgt.fxml")); Scene scene = new Scene(root); Stage stage = new Stage(); // set title stage.setTitle("Class Management System"); stage.setScene(scene); stage.show(); } @Override public void start(Stage arg0) throws Exception { showStage(); } public static void main(String[] args) { launch(args); } } ``` resources/com/swan/userMgt.xml ```xml ``` ##### 3.5.2.2 Controller ```java package com.swan.controllers; import java.io.IOException; import com.swan.beans.UserInfo; import com.swan.views.ClassMgtApplication; import com.swan.views.ClassRegistrationApplication; import com.swan.views.CourseSchedulingApplication; import com.swan.views.LoginApplication; import com.swan.views.SeasonMgtApplication; import com.swan.views.UserMgtApplication; import com.swan.views.StudentClassRegApplication; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.control.Hyperlink; import javafx.scene.control.Label; import javafx.stage.Stage; /** * MainController * * @author xyh * @date 20230426 * */ public class MainController { @FXML private Label UserInfoLabel; @FXML private Hyperlink logoutHyper; @FXML public void toUserMgt(ActionEvent event) throws IOException { UserMgtApplication app = new UserMgtApplication(); app.showStage(); } @FXML public void toSeasonMgt(ActionEvent event) throws IOException { SeasonMgtApplication app = new SeasonMgtApplication(); app.showStage(); } @FXML public void toClassMgt(ActionEvent event) throws IOException { ClassMgtApplication app = new ClassMgtApplication(); app.showStage(); } @FXML public void toCourseScheduling(ActionEvent event) throws IOException { CourseSchedulingApplication app = new CourseSchedulingApplication(); app.showStage(); } public void toStudentClassReg() throws IOException { StudentClassRegApplication app = new StudentClassRegApplication(); app.showStage(); } @FXML public void toClassRegistration(ActionEvent event) throws IOException { ClassRegistrationApplication app = new ClassRegistrationApplication(); app.showStage(); } @FXML public void toChangePwd(ActionEvent event) throws IOException { LoginApplication app = new LoginApplication(); app.changePwd(); } @FXML public void toLogout(ActionEvent event) throws IOException { UserInfo.cleanUserSession(); Stage primaryStage = (Stage) logoutHyper.getScene().getWindow(); primaryStage.close(); LoginApplication app = new LoginApplication(); app.login(); } @FXML private void initialize() { UserInfoLabel.setText("Hi , " + UserInfo.getLoginUser().getUserName()); } } ``` ##### 3.5.2.3 Model ### 3.6 Class management #### 3.6.1 GUI ![3.6.1class_mange.jpg](document/3.6.1class_management.jpg) #### 3.6.2 Source Code ##### 3.6.2.1 View com.swan.views.ClassMgtApplication #### ```java package com.swan.views; import java.io.IOException; import com.swan.App; import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Scene; import javafx.scene.layout.Pane; import javafx.stage.Stage; /** * ClassMgtApplication * @author xyh * @param * @date 20230426 * */ public class ClassMgtApplication extends Application{ public void showStage() throws IOException { Pane root = FXMLLoader.load(App.class.getResource("ClassMgt.fxml")); Scene scene = new Scene(root); Stage stage = new Stage(); // set title stage.setTitle("Class Management System"); stage.setScene(scene); stage.show(); } @Override public void start(Stage arg0) throws Exception { showStage(); } public static void main(String[] args) { launch(args); } } ``` src/main/resources/com/swan/ClassMgt.fxml ```xml ``` ##### 3.9.2.2 Controller com/swan/controllers/MainController.java ##### 3.9.2.3 Model NONE ### 3.10 Class registation #### 3.10.1 GUI ![3.10.1Class_registation.jpg](document/3.10.1Class_registation.jpg) #### 3.10.2 Source Code ##### 3.10.2.1 View com.swan.views.ClassRegistrationApplication ```java package com.swan.views; import java.io.IOException; import com.swan.App; import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Scene; import javafx.scene.layout.Pane; import javafx.stage.Stage; /** * ClassRegistrationApplication * @author xyh * @param * @date 20230426 * */ public class ClassRegistrationApplication extends Application{ public void showStage() throws IOException { Pane root = FXMLLoader.load(App.class.getResource("ClassRegistration.fxml")); Scene scene = new Scene(root); Stage stage = new Stage(); // set title stage.setTitle("Class Management System"); stage.setScene(scene); stage.show(); } @Override public void start(Stage arg0) throws Exception { showStage(); } public static void main(String[] args) { launch(args); } } ``` com/swan/ClassRegistration.fxml ```xml