├── student_management_system-er.png ├── Student management system ├── src │ ├── com │ │ └── YUbuntu │ │ │ ├── model │ │ │ ├── package-info.java │ │ │ ├── UserType.java │ │ │ ├── Table_Administrator.java │ │ │ ├── Table_Class.java │ │ │ ├── Table_Course.java │ │ │ ├── Table_Student.java │ │ │ ├── Table_Teacher.java │ │ │ └── Table_ChoosedCourse.java │ │ │ ├── util │ │ │ ├── package-info.java │ │ │ ├── StringUtil.java │ │ │ ├── DatabaseConfig.java │ │ │ └── JdbcUtil.java │ │ │ ├── dao │ │ │ ├── impl │ │ │ │ ├── package-info.java │ │ │ │ ├── Class_DaoImpl.java │ │ │ │ ├── Student_DaoImpl.java │ │ │ │ ├── Teacher_DaoImpl.java │ │ │ │ ├── Administrator_DaoImpl.java │ │ │ │ ├── Course_DaoImpl.java │ │ │ │ └── ChooseCourse_DaoImpl.java │ │ │ ├── package-info.java │ │ │ ├── Administrator_Dao.java │ │ │ ├── Class_Dao.java │ │ │ ├── Course_Dao.java │ │ │ ├── Teacher_Dao.java │ │ │ ├── Student_Dao.java │ │ │ └── ChooseCourse_Dao.java │ │ │ ├── view │ │ │ ├── package-info.java │ │ │ ├── Main_JFrame.java │ │ │ ├── AddClass_JFrame.java │ │ │ ├── ClassList_JFrame.java │ │ │ ├── ChangePassword_JFrame.java │ │ │ ├── function │ │ │ │ ├── package-info.java │ │ │ │ ├── AddClass_JFrame_function.java │ │ │ │ ├── Login_JFrame_function.java │ │ │ │ ├── AddStudent_JFrame_function.java │ │ │ │ ├── AddTeacher_JFrame_function.java │ │ │ │ ├── AddCourse_JFrame_function.java │ │ │ │ ├── ChangePassword_JFrame_function.java │ │ │ │ ├── ClassList_JFrame_function.java │ │ │ │ ├── CourseList_JInternalFrame_function.java │ │ │ │ ├── TeacherList_JFrame_function.java │ │ │ │ ├── StudentList_JFrame_function.java │ │ │ │ ├── ChooseCourse_JF_function.java │ │ │ │ └── Main_JFrame_function.java │ │ │ ├── DatabaseConfigInfo.java │ │ │ ├── AddCourse_JFrame.java │ │ │ ├── AddStudent_JFrame.java │ │ │ ├── Login_JFrame.java │ │ │ ├── AddTeacher_JInternalFrame.java │ │ │ └── CourseList_JInternalFrame.java │ │ │ └── basicDao │ │ │ ├── package-info.java │ │ │ └── BasicDao.java │ └── icon │ │ ├── Add.png │ │ ├── Age.png │ │ ├── Delete.png │ │ ├── Exit.png │ │ ├── Gender.png │ │ ├── Help.png │ │ ├── List.png │ │ ├── Reset.png │ │ ├── Search.png │ │ ├── Title.png │ │ ├── Confirm.png │ │ ├── Id card.png │ │ ├── Student.png │ │ ├── password.png │ │ ├── Class list.png │ │ ├── Class name.png │ │ ├── Teacher sex.png │ │ ├── User list.png │ │ ├── User name.png │ │ ├── User type.png │ │ ├── #YUbuntu logo.jpg │ │ ├── About author.png │ │ ├── System setup.png │ │ ├── Teacher name.png │ │ ├── Teacher title.png │ │ ├── AddTeacher_Reset.png │ │ ├── Class management.png │ │ ├── Confirm login in.png │ │ ├── Modify password.png │ │ ├── Teacher password.png │ │ ├── AddTeacher_Confirm.png │ │ ├── ChooseCourseJMenu.png │ │ ├── Class introduction.png │ │ ├── Course management.png │ │ ├── Studnet management.png │ │ ├── Teacher management.png │ │ └── Teacher telephone.png ├── lib │ ├── JTattoo-1.6.11.jar │ └── mysql-connector-java-8.0.11.jar ├── reference document.txt ├── databaseConfig.properties └── .gitignore ├── LICENSE ├── README.md └── student_management_system.sql /student_management_system-er.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/student_management_system-er.png -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/model/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * @author #YUbuntu 3 | * 4 | */ 5 | package com.YUbuntu.model; -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/util/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * @author #YUbuntu 3 | * 4 | */ 5 | package com.YUbuntu.util; -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/dao/impl/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * @author #YUbuntu 3 | * 4 | */ 5 | package com.YUbuntu.dao.impl; -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/dao/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * @author #YUbuntu 4 | * 5 | */ 6 | package com.YUbuntu.dao; -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/view/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * @author #YUbuntu 4 | * 5 | */ 6 | package com.YUbuntu.view; -------------------------------------------------------------------------------- /Student management system/src/icon/Add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/src/icon/Add.png -------------------------------------------------------------------------------- /Student management system/src/icon/Age.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/src/icon/Age.png -------------------------------------------------------------------------------- /Student management system/src/icon/Delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/src/icon/Delete.png -------------------------------------------------------------------------------- /Student management system/src/icon/Exit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/src/icon/Exit.png -------------------------------------------------------------------------------- /Student management system/src/icon/Gender.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/src/icon/Gender.png -------------------------------------------------------------------------------- /Student management system/src/icon/Help.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/src/icon/Help.png -------------------------------------------------------------------------------- /Student management system/src/icon/List.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/src/icon/List.png -------------------------------------------------------------------------------- /Student management system/src/icon/Reset.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/src/icon/Reset.png -------------------------------------------------------------------------------- /Student management system/src/icon/Search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/src/icon/Search.png -------------------------------------------------------------------------------- /Student management system/src/icon/Title.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/src/icon/Title.png -------------------------------------------------------------------------------- /Student management system/src/icon/Confirm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/src/icon/Confirm.png -------------------------------------------------------------------------------- /Student management system/src/icon/Id card.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/src/icon/Id card.png -------------------------------------------------------------------------------- /Student management system/src/icon/Student.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/src/icon/Student.png -------------------------------------------------------------------------------- /Student management system/src/icon/password.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/src/icon/password.png -------------------------------------------------------------------------------- /Student management system/lib/JTattoo-1.6.11.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/lib/JTattoo-1.6.11.jar -------------------------------------------------------------------------------- /Student management system/reference document.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/reference document.txt -------------------------------------------------------------------------------- /Student management system/src/icon/Class list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/src/icon/Class list.png -------------------------------------------------------------------------------- /Student management system/src/icon/Class name.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/src/icon/Class name.png -------------------------------------------------------------------------------- /Student management system/src/icon/Teacher sex.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/src/icon/Teacher sex.png -------------------------------------------------------------------------------- /Student management system/src/icon/User list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/src/icon/User list.png -------------------------------------------------------------------------------- /Student management system/src/icon/User name.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/src/icon/User name.png -------------------------------------------------------------------------------- /Student management system/src/icon/User type.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/src/icon/User type.png -------------------------------------------------------------------------------- /Student management system/src/icon/#YUbuntu logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/src/icon/#YUbuntu logo.jpg -------------------------------------------------------------------------------- /Student management system/src/icon/About author.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/src/icon/About author.png -------------------------------------------------------------------------------- /Student management system/src/icon/System setup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/src/icon/System setup.png -------------------------------------------------------------------------------- /Student management system/src/icon/Teacher name.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/src/icon/Teacher name.png -------------------------------------------------------------------------------- /Student management system/src/icon/Teacher title.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/src/icon/Teacher title.png -------------------------------------------------------------------------------- /Student management system/src/icon/AddTeacher_Reset.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/src/icon/AddTeacher_Reset.png -------------------------------------------------------------------------------- /Student management system/src/icon/Class management.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/src/icon/Class management.png -------------------------------------------------------------------------------- /Student management system/src/icon/Confirm login in.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/src/icon/Confirm login in.png -------------------------------------------------------------------------------- /Student management system/src/icon/Modify password.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/src/icon/Modify password.png -------------------------------------------------------------------------------- /Student management system/src/icon/Teacher password.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/src/icon/Teacher password.png -------------------------------------------------------------------------------- /Student management system/src/icon/AddTeacher_Confirm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/src/icon/AddTeacher_Confirm.png -------------------------------------------------------------------------------- /Student management system/src/icon/ChooseCourseJMenu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/src/icon/ChooseCourseJMenu.png -------------------------------------------------------------------------------- /Student management system/src/icon/Class introduction.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/src/icon/Class introduction.png -------------------------------------------------------------------------------- /Student management system/src/icon/Course management.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/src/icon/Course management.png -------------------------------------------------------------------------------- /Student management system/src/icon/Studnet management.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/src/icon/Studnet management.png -------------------------------------------------------------------------------- /Student management system/src/icon/Teacher management.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/src/icon/Teacher management.png -------------------------------------------------------------------------------- /Student management system/src/icon/Teacher telephone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/src/icon/Teacher telephone.png -------------------------------------------------------------------------------- /Student management system/lib/mysql-connector-java-8.0.11.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/lib/mysql-connector-java-8.0.11.jar -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/view/Main_JFrame.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/src/com/YUbuntu/view/Main_JFrame.java -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/view/AddClass_JFrame.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/src/com/YUbuntu/view/AddClass_JFrame.java -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/dao/impl/Class_DaoImpl.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/src/com/YUbuntu/dao/impl/Class_DaoImpl.java -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/view/ClassList_JFrame.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/src/com/YUbuntu/view/ClassList_JFrame.java -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/dao/impl/Student_DaoImpl.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/src/com/YUbuntu/dao/impl/Student_DaoImpl.java -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/dao/impl/Teacher_DaoImpl.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/src/com/YUbuntu/dao/impl/Teacher_DaoImpl.java -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/view/ChangePassword_JFrame.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/src/com/YUbuntu/view/ChangePassword_JFrame.java -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/dao/impl/Administrator_DaoImpl.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogTech/Student-management-system-CS/HEAD/Student management system/src/com/YUbuntu/dao/impl/Administrator_DaoImpl.java -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/basicDao/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * @Project Student management system 3 | * @Package com.YUbuntu.basicDao 4 | * @Description TODO 5 | * @Author #YUbuntu 6 | * @Date Dec 26, 2018-7:45:49 PM 7 | * @version 1.0 8 | */ 9 | package com.YUbuntu.basicDao; -------------------------------------------------------------------------------- /Student management system/databaseConfig.properties: -------------------------------------------------------------------------------- 1 | #Url 2 | Url=jdbc:mysql://localhost/student_management_system?useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true 3 | #User name 4 | UserName=xxxxxx 5 | #User password 6 | UserPassword=xxxxxx 7 | #Driver name 8 | DriverName=com.mysql.cj.jdbc.Driver -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/view/function/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * @Project Student management system 3 | * @Package com.YUbuntu.view.function 4 | * @Description 5 | * @Author #YUbuntu 6 | * @Date Dec 28, 2018-3:02:18 PM 7 | * @version 1.0 8 | */ 9 | package com.YUbuntu.view.function; 10 | -------------------------------------------------------------------------------- /Student management system/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | .sts4-cache 12 | 13 | ### IntelliJ IDEA ### 14 | .idea 15 | *.iws 16 | *.iml 17 | *.ipr 18 | 19 | ### NetBeans ### 20 | /nbproject/private/ 21 | /build/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/util/StringUtil.java: -------------------------------------------------------------------------------- 1 | package com.YUbuntu.util; 2 | 3 | /** 4 | * @Project Student management system 5 | * @Package com.YUbuntu.util 6 | * @Description The tool 7 | * @Author #YUbuntu 8 | * @Date Dec 27, 2018-11:40:28 AM 9 | * @version 1.0 10 | */ 11 | public class StringUtil 12 | { 13 | public static boolean IsEmpty(String string) 14 | { 15 | if("".equals(string)||string==null) //Be careful not to write: : string.equals("") 16 | return true; 17 | return false; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/view/function/AddClass_JFrame_function.java: -------------------------------------------------------------------------------- 1 | package com.YUbuntu.view.function; 2 | 3 | import java.awt.event.ActionEvent; 4 | 5 | /** 6 | * 7 | * @Project Student management system 8 | * @Package com.YUbuntu.view.function 9 | * @Description Extract panel functionality into the interface. 10 | * @Author #YUbuntu 11 | * @Date Dec 28, 2018-4:57:13 PM 12 | * @version 1.0 13 | */ 14 | public interface AddClass_JFrame_function 15 | { 16 | /** 17 | * 18 | * @Title Funciton 19 | * @Description Add a new class. 20 | * @param Performed action 21 | * @return void 22 | * @date Dec 28, 2018-5:01:14 PM 23 | * @throws .. 24 | * 25 | */ 26 | void Function_AddClass(ActionEvent e); 27 | 28 | /** 29 | * 30 | * @Title Function 31 | * @Description Reset the information entered by the user. 32 | * @param Performed action 33 | * @return void 34 | * @date Dec 28, 2018-5:02:30 PM 35 | * @throws .. 36 | * 37 | */ 38 | void Function_ResetInformation(ActionEvent e); 39 | } 40 | -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/view/function/Login_JFrame_function.java: -------------------------------------------------------------------------------- 1 | package com.YUbuntu.view.function; 2 | 3 | import java.awt.event.ActionEvent; 4 | 5 | /** 6 | * 7 | * @Project Student management system 8 | * @Package com.YUbuntu.view.function 9 | * @Description Extract panel functionality into the interface. 10 | * @Author #YUbuntu 11 | * @Date Dec 28, 2018-3:20:06 PM 12 | * @version 1.0 13 | */ 14 | public interface Login_JFrame_function 15 | { 16 | /** 17 | * 18 | * @Title Login 19 | * @Description Check user information from the database. 20 | * @param Performed action 21 | * @return void 22 | * @date Dec 28, 2018-3:20:35 PM 23 | * @throws 1.0 24 | * 25 | */ 26 | void LoginEvent(ActionEvent e); 27 | 28 | /** 29 | * 30 | * @Title Reset 31 | * @Description Reset the informaiton entered by the user. 32 | * @param Performed action 33 | * @return void 34 | * @date Dec 28, 2018-3:25:49 PM 35 | * @throws 1.0 36 | * 37 | */ 38 | void Function_ResetInformation(ActionEvent e); 39 | } 40 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 #YUbuntu 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/dao/Administrator_Dao.java: -------------------------------------------------------------------------------- 1 | package com.YUbuntu.dao; 2 | 3 | import com.YUbuntu.model.Table_Administrator; 4 | 5 | /** 6 | * 7 | * @Project Student management system 8 | * @Package com.YUbuntu.dao 9 | * @Description The ability of an administrator to manipulate a database. 10 | * @Author #YUbuntu 11 | * @Date Dec 26, 2018-7:22:51 PM 12 | * @version 1.0 13 | */ 14 | public interface Administrator_Dao 15 | { 16 | /** 17 | * 18 | * @Title Check 19 | * @Description Select information from MySQL database 20 | * @param The information of administrator 21 | * @return Table_Administrator 22 | * @date Dec 26, 2018-7:27:41 PM 23 | * @throws no 24 | * 25 | */ 26 | Table_Administrator Login_Administrator(Table_Administrator data); 27 | 28 | /** 29 | * 30 | * @Title Update 31 | * @Description Update user information from database. 32 | * @param The information of administrator 33 | * @return String 34 | * @date Dec 26, 2018-7:31:07 PM 35 | * @throws no 36 | * 37 | */ 38 | String ChangePassword(Table_Administrator table_Administrator, String newPassword); 39 | } 40 | -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/basicDao/BasicDao.java: -------------------------------------------------------------------------------- 1 | package com.YUbuntu.basicDao; 2 | 3 | import java.sql.Connection; 4 | 5 | import com.YUbuntu.util.JdbcUtil; 6 | 7 | /** 8 | * 9 | * @Project Student management system 10 | * @Package com.YUbuntu.dao 11 | * @Description Create a database connection object that is used by the entire project to interact with the database. 12 | * @Author #YUbuntu 13 | * @Date November 30,2018 14 | * @version 1.0 15 | */ 16 | public class BasicDao 17 | { 18 | public Connection connection = new JdbcUtil().getConnection(); 19 | 20 | /* 21 | * Every object that operates on the database is used : 22 | * JDBCUtil.freeResource(null, preparedStatement, connection); 23 | */ 24 | 25 | // Frees database connection resources 26 | // public void Close_BasicDao() 27 | // { 28 | // if(connection!=null) 29 | // { 30 | // try { 31 | // connection.close(); 32 | // } catch (SQLException e) { 33 | // System.err.println("ERROR : Failed to close database connection !\n"); 34 | // e.printStackTrace(); 35 | // } 36 | // connection = null; 37 | // } 38 | // } 39 | } 40 | -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/view/DatabaseConfigInfo.java: -------------------------------------------------------------------------------- 1 | package com.YUbuntu.view; 2 | 3 | 4 | /** 5 | * 6 | * @Project Student management system 7 | * @Package com.YUbuntu.view 8 | * @Description Stores configuration information about connecting to the database. 9 | * @Author HuangYuhui 10 | * @Date Feb 26, 2019-6:30:18 PM 11 | * @version 2.1 12 | */ 13 | public class DatabaseConfigInfo 14 | { 15 | private String Url; 16 | private String UserName; 17 | private String UserPassword; 18 | private String DriverName; 19 | 20 | public String getUrl() 21 | { 22 | return Url; 23 | } 24 | public void setUrl(String url) 25 | { 26 | Url = url; 27 | } 28 | public String getUserName() 29 | { 30 | return UserName; 31 | } 32 | public void setUserName(String userName) 33 | { 34 | UserName = userName; 35 | } 36 | public String getUserPassword() 37 | { 38 | return UserPassword; 39 | } 40 | public void setUserPassword(String userPassword) 41 | { 42 | UserPassword = userPassword; 43 | } 44 | public String getDriverName() 45 | { 46 | return DriverName; 47 | } 48 | public void setDriverName(String driverName) 49 | { 50 | DriverName = driverName; 51 | } 52 | 53 | 54 | } 55 | -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/model/UserType.java: -------------------------------------------------------------------------------- 1 | package com.YUbuntu.model; 2 | 3 | /** 4 | * 5 | * @Project Student management system 6 | * @Package com.YUbuntu.model 7 | * @Description Implementation of login-in logic. 8 | * @Author #YUbuntu 9 | * @Date November 30,2018 10 | * @version 1.0 11 | */ 12 | public enum UserType 13 | { 14 | Adminstrator("Administrator", 0), Teacher("Teacher", 1), Student("Student", 2); 15 | 16 | private String name; 17 | private int index; 18 | 19 | /*------------------------------------ 20 | * The structure of enumeration type | 21 | *------------------------------------ 22 | */ 23 | private UserType(String name, int index) 24 | { 25 | this.name = name; 26 | this.index = index; 27 | } 28 | 29 | 30 | public String getName() 31 | { 32 | return name; 33 | } 34 | 35 | public void setName(String name) 36 | { 37 | this.name = name; 38 | } 39 | 40 | public int getIndex() 41 | { 42 | return index; 43 | } 44 | 45 | public void setIndex(int index) 46 | { 47 | this.index = index; 48 | } 49 | 50 | @Override 51 | 52 | 53 | /** 54 | * Return the type name of the user,not the address value 55 | */ 56 | public String toString() 57 | { 58 | return this.name(); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/view/function/AddStudent_JFrame_function.java: -------------------------------------------------------------------------------- 1 | package com.YUbuntu.view.function; 2 | 3 | import java.awt.event.ActionEvent; 4 | 5 | /** 6 | * 7 | * @Project Student management system 8 | * @Package com.YUbuntu.view.function 9 | * @Description Extract panel functionality into the interface. 10 | * @Author #YUbuntu 11 | * @Date Dec 28, 2018-5:06:32 PM 12 | * @version 1.0 13 | */ 14 | public interface AddStudent_JFrame_function 15 | { 16 | /** 17 | * 18 | * @Title Function 19 | * @Description Add a new student. 20 | * @param performed action 21 | * @return void 22 | * @date Dec 28, 2018-5:07:27 PM 23 | * @throws .. 24 | * 25 | */ 26 | void Function_AddStudent(ActionEvent e); 27 | 28 | /** 29 | * 30 | * @Title Initialize 31 | * @Description Get class name. 32 | * @param Performed action 33 | * @return void 34 | * @date Dec 28, 2018-5:13:21 PM 35 | * @throws .. 36 | * 37 | */ 38 | void Initialize_InitializeClassName(); 39 | 40 | /** 41 | * 42 | * @Title Function 43 | * @Description Reset the information. 44 | * @param performed action 45 | * @return void 46 | * @date Dec 28, 2018-5:15:08 PM 47 | * @throws 48 | * 49 | */ 50 | void Function_ResetInformation(ActionEvent e); 51 | } 52 | -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/view/function/AddTeacher_JFrame_function.java: -------------------------------------------------------------------------------- 1 | package com.YUbuntu.view.function; 2 | 3 | import java.awt.event.ActionEvent; 4 | 5 | /** 6 | * 7 | * @Project Student management system 8 | * @Package com.YUbuntu.view.function 9 | * @Description Extract panel functionality into the interface. 10 | * @Author #YUbuntu 11 | * @Date Dec 28, 2018-5:28:24 PM 12 | * @version 1.0 13 | */ 14 | public interface AddTeacher_JFrame_function 15 | { 16 | /** 17 | * 18 | * @Title Function 19 | * @Description Add a new teacher. 20 | * @param Performed action 21 | * @return void 22 | * @date Dec 28, 2018-5:30:23 PM 23 | * @throws .. 24 | * 25 | */ 26 | void Function_AddTeacher(ActionEvent e); 27 | 28 | /** 29 | * 30 | * @Title Function 31 | * @Description Get the class name. 32 | * @param Performed action 33 | * @return void 34 | * @date Dec 28, 2018-5:31:44 PM 35 | * @throws .. 36 | * 37 | */ 38 | void Initialize_InitializeClassName(); 39 | 40 | /** 41 | * 42 | * @Title Function 43 | * @Description Reset the information. 44 | * @param Performed action 45 | * @return void 46 | * @date Dec 28, 2018-5:32:33 PM 47 | * @throws .. 48 | * 49 | */ 50 | void Function_ResetInformation(ActionEvent e); 51 | } 52 | -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/view/function/AddCourse_JFrame_function.java: -------------------------------------------------------------------------------- 1 | package com.YUbuntu.view.function; 2 | 3 | import java.awt.event.ActionEvent; 4 | 5 | /** 6 | * 7 | * @Project Student management system 8 | * @Package com.YUbuntu.view.function 9 | * @Description Extract panel functionality into the interface. 10 | * @Author #YUbuntu 11 | * @Date Dec 29, 2018-7:23:39 PM 12 | * @version 2.0 13 | */ 14 | public interface AddCourse_JFrame_function 15 | { 16 | 17 | /** 18 | * 19 | * @Title Initialize 20 | * @Description Initialize the teacher name 21 | * @param no 22 | * @return void 23 | * @date Dec 29, 2018-8:19:29 PM 24 | * @throws no 25 | * 26 | */ 27 | void Initialize_InitializeTeacherName(); 28 | 29 | /** 30 | * 31 | * @Title Function 32 | * @Description Add a new course. 33 | * @param Performed action 34 | * @return void 35 | * @date Dec 29, 2018-7:31:28 PM 36 | * @throws no 37 | * 38 | */ 39 | void Function_ConfirmAddCourse(ActionEvent e); 40 | 41 | /** 42 | * 43 | * @Title Function 44 | * @Description Reset the information. 45 | * @param Performed action 46 | * @return void 47 | * @date Dec 29, 2018-7:32:16 PM 48 | * @throws no 49 | * 50 | */ 51 | void Function_ResetInformation(ActionEvent e); 52 | } 53 | -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/view/function/ChangePassword_JFrame_function.java: -------------------------------------------------------------------------------- 1 | package com.YUbuntu.view.function; 2 | 3 | import java.awt.event.ActionEvent; 4 | 5 | /** 6 | * 7 | * @Project Student management system 8 | * @Package com.YUbuntu.view.function 9 | * @Description Extract panel functionality into the interface. 10 | * @Author #YUbuntu 11 | * @Date Dec 28, 2018-4:26:17 PM 12 | * @version 1.0 13 | */ 14 | public interface ChangePassword_JFrame_function 15 | { 16 | /** 17 | * 18 | * @Title Function 19 | * @Description Displays the user information of the current login. 20 | * @param Performed action 21 | * @return void 22 | * @date Dec 28, 2018-4:48:34 PM 23 | * @throws .. 24 | * 25 | */ 26 | void Function_DisplayUserInformation(); 27 | 28 | /** 29 | * 30 | * @Title Function 31 | * @Description Modify the user password. 32 | * @param Performed action 33 | * @return void 34 | * @date Dec 28, 2018-4:50:01 PM 35 | * @throws .. 36 | * 37 | */ 38 | void Confirm_ChangePassword(ActionEvent e); 39 | 40 | /** 41 | * 42 | * @Title Function 43 | * @Description Reset the information entered by the user. 44 | * @param Performed action 45 | * @return void 46 | * @date Dec 28, 2018-4:52:19 PM 47 | * @throws .. 48 | * 49 | */ 50 | void Reset_Information(ActionEvent e); 51 | } 52 | -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/util/DatabaseConfig.java: -------------------------------------------------------------------------------- 1 | package com.YUbuntu.util; 2 | 3 | import java.io.FileInputStream; 4 | import java.io.FileNotFoundException; 5 | import java.io.IOException; 6 | import java.util.Properties; 7 | 8 | import com.YUbuntu.view.DatabaseConfigInfo; 9 | 10 | /** 11 | * 12 | * @Project Student management system 13 | * @Package com.YUbuntu.util 14 | * @Description Configure about the information for connecting to the database. 15 | * @Author HuangYuhui 16 | * @Date Feb 26, 20196:26:59 PM 17 | * @version 2.1 18 | */ 19 | public class DatabaseConfig 20 | { 21 | public static DatabaseConfigInfo mailConfigInfo = new DatabaseConfigInfo(); 22 | static 23 | { 24 | try 25 | { 26 | Properties proper = new Properties(); 27 | proper.load(new FileInputStream("databaseConfig.properties")); 28 | 29 | mailConfigInfo.setUrl(proper.getProperty("Url")); 30 | mailConfigInfo.setUserName(proper.getProperty("UserName")); 31 | mailConfigInfo.setUserPassword(proper.getProperty("UserPassword")); 32 | mailConfigInfo.setDriverName(proper.getProperty("DriverName")); 33 | 34 | } catch (FileNotFoundException e) 35 | { 36 | System.err.println("error : not found the specified file: databaseConfig.properties"); 37 | e.printStackTrace(); 38 | } catch (IOException e) 39 | { 40 | e.printStackTrace(); 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/model/Table_Administrator.java: -------------------------------------------------------------------------------- 1 | package com.YUbuntu.model; 2 | 3 | /** 4 | * 5 | * @Project Student management system 6 | * @Package com.YUbuntu.model 7 | * @Description The information of user of administrator 8 | * @Author #YUbuntu 9 | * @Date December 30,2018 10 | * @version 1.0 11 | */ 12 | public class Table_Administrator 13 | { 14 | private int id; 15 | private String name; 16 | private String password; 17 | private String birthday; 18 | private String Telephone_number; 19 | 20 | public int getId() 21 | { 22 | return id; 23 | } 24 | 25 | public void setId(int id) 26 | { 27 | this.id = id; 28 | } 29 | 30 | public String getName() 31 | { 32 | return name; 33 | } 34 | 35 | public void setName(String name) 36 | { 37 | this.name = name; 38 | } 39 | 40 | public String getPassword() 41 | { 42 | return password; 43 | } 44 | 45 | public void setPassword(String password) 46 | { 47 | this.password = password; 48 | } 49 | 50 | public String getBirthday() 51 | { 52 | return birthday; 53 | } 54 | 55 | public void setBirthday(String birthday) 56 | { 57 | this.birthday = birthday; 58 | } 59 | 60 | public String getTelephone_number() 61 | { 62 | return Telephone_number; 63 | } 64 | 65 | public void setTelephone_number(String telephone_number) 66 | { 67 | Telephone_number = telephone_number; 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/dao/Class_Dao.java: -------------------------------------------------------------------------------- 1 | package com.YUbuntu.dao; 2 | 3 | import java.util.List; 4 | 5 | import com.YUbuntu.model.Table_Class; 6 | 7 | /** 8 | * 9 | * @Project Student management system 10 | * @Package com.YUbuntu.dao 11 | * @Description The function of the class operation database. 12 | * @Author #YUbuntu 13 | * @Date Dec 27, 2018-9:07:43 PM 14 | * @version 15 | */ 16 | public interface Class_Dao 17 | { 18 | /** 19 | * 20 | * @Title Insert 21 | * @Description Insert the class information into database. 22 | * @param The information of class. 23 | * @return boolean 24 | * @date Dec 27, 2018-9:11:24 PM 25 | * @throws no 26 | * 27 | */ 28 | boolean addClass(Table_Class table_Class); 29 | 30 | /** 31 | * 32 | * @Title Select 33 | * @Description Select the class information from database. 34 | * @param The information of class. 35 | * @return List 36 | * @date Dec 27, 2018-9:12:18 PM 37 | * @throws no 38 | * 39 | */ 40 | List getClassList(Table_Class table_Class); 41 | 42 | /** 43 | * 44 | * @Title Delete 45 | * @Description Deletes class information from database. 46 | * @param The information of class. 47 | * @return boolean 48 | * @date Dec 27, 2018-9:14:24 PM 49 | * @throws no 50 | * 51 | */ 52 | boolean Delete_ClassInformation(String clASS_ID); 53 | 54 | /** 55 | * 56 | * @Title Update 57 | * @Description Update class information from databases. 58 | * @param The specified class' ID. 59 | * @return boolean 60 | * @date Dec 27, 2018-9:15:45 PM 61 | * @throws no 62 | * 63 | */ 64 | boolean Update_ClassInformation(Table_Class table_Class); 65 | } 66 | -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/model/Table_Class.java: -------------------------------------------------------------------------------- 1 | package com.YUbuntu.model; 2 | 3 | /** 4 | * 5 | * @Project Student management system 6 | * @Package com.YUbuntu.model 7 | * @Description The class information 8 | * @Author #YUbuntu 9 | * @Date December 2,2018 10 | * @version 1.0 11 | * 12 | */ 13 | public class Table_Class 14 | { 15 | private String _CLASS_ID; 16 | private String _CLASS_NAME; 17 | private String _CLASS_Introduce; 18 | 19 | public String get_CLASS_ID() 20 | { 21 | return _CLASS_ID; 22 | } 23 | 24 | public void set_CLASS_ID(String classID) 25 | { 26 | this._CLASS_ID = classID; 27 | } 28 | 29 | public String get_CLASS_NAME() 30 | { 31 | return _CLASS_NAME; 32 | } 33 | 34 | public void set_CLASS_NAME(String _CLASS_NAME) 35 | { 36 | this._CLASS_NAME = _CLASS_NAME; 37 | } 38 | 39 | public String get_CLASS_Introduce() 40 | { 41 | return _CLASS_Introduce; 42 | } 43 | 44 | public void set_CLASS_Introduce(String _CLASS_Introduce) 45 | { 46 | this._CLASS_Introduce = _CLASS_Introduce; 47 | } 48 | 49 | /* 50 | * Position : com.YUbuntu.view.AddStudent_JFrame 51 | * 52 | * addItem(); 53 | * -------------------------------------------------------------------------------------------------------------------- 54 | * Warning:Focus and keyboard navigation problems may arise if you add duplicate String objects. | 55 | * A workaround is to add new objects instead of String objects and make sure that the toString() method is defined. | 56 | * -------------------------------------------------------------------------------------------------------------------- 57 | */ 58 | @Override 59 | public String toString() 60 | { 61 | return this._CLASS_NAME; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/dao/Course_Dao.java: -------------------------------------------------------------------------------- 1 | package com.YUbuntu.dao; 2 | 3 | import java.util.List; 4 | 5 | import com.YUbuntu.model.Table_Course; 6 | import com.YUbuntu.model.Table_ChoosedCourse; 7 | import com.YUbuntu.model.Table_Teacher; 8 | 9 | /** 10 | * 11 | * @Project Student management system 12 | * @Package com.YUbuntu.dao 13 | * @Description The function of the course operation database. 14 | * @Author #YUbuntu 15 | * @Date Dec 29, 2018-7:36:06 PM 16 | * @version 2.0 17 | */ 18 | public interface Course_Dao 19 | { 20 | 21 | /** 22 | * 23 | * @Title Delete 24 | * @Description Delete the specified course. 25 | * @param String(Course'ID) 26 | * @return boolean 27 | * @date Jan 17, 2019-12:22:46 PM 28 | * 29 | */ 30 | boolean Delete_CourseInformation(String string); 31 | 32 | /** 33 | * 34 | * @Title Update 35 | * @Description Update the course information. 36 | * @param Table_Course 37 | * @return boolean 38 | * @date Jan 16, 2019-9:44:59 PM 39 | * 40 | */ 41 | boolean Update_CourseInformation(Table_Course table_Course); 42 | 43 | /** 44 | * 45 | * @Title Select 46 | * @Description Get the course information from the database. 47 | * @param no 48 | * @return List 49 | * @date Jan 15, 2019-4:05:31 PM 50 | * 51 | */ 52 | List getCourseList(Table_Course table_Course); 53 | 54 | /** 55 | * 56 | * @Title Select 57 | * @Description Get the teacher name from the database. 58 | * @param no 59 | * @return List 60 | * @date Dec 29, 2018-9:44:38 PM 61 | * @throws no 62 | * 63 | */ 64 | List getTeacherName(); 65 | 66 | /** 67 | * 68 | * @Title Insert 69 | * @Description Inset a new course into the database. 70 | * @param The information of course. 71 | * @return boolean 72 | * @date Dec 29, 2018-9:46:17 PM 73 | * @throws no 74 | * 75 | */ 76 | boolean addCourse(Table_Course table_Course); 77 | 78 | } 79 | -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/view/function/ClassList_JFrame_function.java: -------------------------------------------------------------------------------- 1 | package com.YUbuntu.view.function; 2 | 3 | import java.awt.event.ActionEvent; 4 | import java.awt.event.MouseEvent; 5 | 6 | import com.YUbuntu.model.Table_Class; 7 | 8 | /** 9 | * 10 | * @Project Student management system 11 | * @Package com.YUbuntu.view.function 12 | * @Description Extract panel functionality into the interface. 13 | * @Author #YUbuntu 14 | * @Date Dec 28, 2018-6:33:09 PM 15 | * @version 1.0 16 | */ 17 | public interface ClassList_JFrame_function 18 | { 19 | /** 20 | * 21 | * @Title Function 22 | * @Description Delete the specified class. 23 | * @param Performed action 24 | * @return void 25 | * @date Dec 28, 2018-6:35:53 PM 26 | * @throws .. 27 | * 28 | */ 29 | void Function_ConfirmDelete(ActionEvent e); 30 | 31 | /** 32 | * 33 | * @Title Function 34 | * @Description Modify the specified class information. 35 | * @param Performed action 36 | * @return void 37 | * @date Dec 28, 2018-6:37:14 PM 38 | * @throws .. 39 | * 40 | */ 41 | void Function_ConfirmChange(ActionEvent e); 42 | 43 | /** 44 | * 45 | * @Title Initialize 46 | * @Description Adds the selected class information to the pointing location. 47 | * @param Mouse clicked 48 | * @return void 49 | * @date Dec 28, 2018-6:38:47 PM 50 | * @throws .. 51 | * 52 | */ 53 | void Initialize_SelectClassTableRow(MouseEvent e); 54 | 55 | /** 56 | * 57 | * @Title Function 58 | * @Description Initializes the informaiton in the class table. 59 | * @param Performed action 60 | * @return void 61 | * @date Dec 28, 2018-6:39:53 PM 62 | * @throws .. 63 | * 64 | */ 65 | void Function_InitializeClassTable(Table_Class table_Class); 66 | 67 | /** 68 | * 69 | * @Title Function 70 | * @Description Reset the information. 71 | * @param no 72 | * @return void 73 | * @date Dec 28, 2018-6:40:43 PM 74 | * @throws .. 75 | * 76 | */ 77 | void Function_ClearData(); 78 | 79 | } 80 | -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/dao/Teacher_Dao.java: -------------------------------------------------------------------------------- 1 | package com.YUbuntu.dao; 2 | 3 | import java.util.List; 4 | 5 | import com.YUbuntu.model.Table_Teacher; 6 | 7 | /** 8 | * 9 | * @Project Student management system 10 | * @Package com.YUbuntu.dao 11 | * @Description The function of teacher operation database. 12 | * @Author #YUbuntu 13 | * @Date Dec 27, 2018-9:18:12 PM 14 | * @version 1.0 15 | */ 16 | public interface Teacher_Dao 17 | { 18 | /** 19 | * 20 | * @Title Insert 21 | * @Description Insert new teacher information into database. 22 | * @param The information of teacher. 23 | * @return boolean 24 | * @date Dec 27, 2018-9:20:04 PM 25 | * @throws no 26 | * 27 | */ 28 | boolean addTeacher(Table_Teacher table_Teacher); 29 | 30 | /** 31 | * 32 | * @Title Select 33 | * @Description Search for information from database. 34 | * @param The information of teacher. 35 | * @return List 36 | * @date Dec 27, 2018-9:21:26 PM 37 | * @throws no 38 | * 39 | */ 40 | List getTeacherList(Table_Teacher table_Teacher); 41 | 42 | /** 43 | * 44 | * @Title Delete 45 | * @Description Delete the teacher information from databse. 46 | * @param The teacher' ID. 47 | * @return boolean 48 | * @date Dec 27, 2018-9:23:18 PM 49 | * @throws no 50 | * 51 | */ 52 | boolean Delete_TeacherInformation(String teacher_ID); 53 | 54 | /** 55 | * 56 | * @Title Update 57 | * @Description Update the teacher information from database. 58 | * @param The informaton of teacher. 59 | * @return boolean 60 | * @date Dec 27, 2018-9:26:43 PM 61 | * @throws no 62 | * 63 | */ 64 | boolean Update_TeacherInformation(Table_Teacher table_Teacher); 65 | 66 | /** 67 | * 68 | * @Title Select 69 | * @Description Select the student information from database. 70 | * @param The information of teacher. 71 | * @return Table_Teacher 72 | * @date Dec 27, 2018-9:30:26 PM 73 | * @throws no 74 | * 75 | */ 76 | Table_Teacher Login_Teacher(Table_Teacher Table_Teacher); 77 | } 78 | -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/view/function/CourseList_JInternalFrame_function.java: -------------------------------------------------------------------------------- 1 | package com.YUbuntu.view.function; 2 | 3 | import java.awt.event.ActionEvent; 4 | import java.awt.event.MouseEvent; 5 | 6 | import com.YUbuntu.model.Table_Course; 7 | 8 | /** 9 | * 10 | * @Project Student management system 11 | * @Package com.YUbuntu.view.function 12 | * @Description Extract panel functionality into the interface. 13 | * @Author HuangYuhui 14 | * @Date Jan 15, 2019-1:07:19 PM 15 | * @version 2.0 16 | */ 17 | public interface CourseList_JInternalFrame_function 18 | { 19 | 20 | /**s 21 | * @Title Delete 22 | * @Description Delete the specified course. 23 | * @param ActionEvent e 24 | * @return void 25 | * @date Jan 17, 2019-12:34:30 PM 26 | * 27 | */ 28 | void Function_ConfirmDeleteCourseInfo(ActionEvent e); 29 | 30 | /** 31 | * @Title Update 32 | * @Description Update the course information. 33 | * @param ActionEvent e 34 | * @return void 35 | * @date Jan 16, 2019-9:12:09 PM 36 | * 37 | */ 38 | void Function_ModifyCourseInfo(ActionEvent e); 39 | 40 | /** 41 | * @Title Select 42 | * @Description Select the specified course information. 43 | * @param Performed action 44 | * @return void 45 | * @date Jan 15, 2019-6:42:42 PM 46 | * 47 | */ 48 | void Function_SearchCourse(ActionEvent e); 49 | 50 | /** 51 | * @Title Initialize 52 | * @Description Add the selected course information to the pointing location. 53 | * @param Mouse clicked 54 | * @return void 55 | * @date Jan 15, 2019-6:30:49 PM 56 | * 57 | */ 58 | void Initialize_SelectCourseTableRow(MouseEvent e); 59 | 60 | /** 61 | * @Title Select 62 | * @Description Select the teacher information. 63 | * @param empty 64 | * @return void 65 | * @date Jan 15, 2019-5:47:13 PM 66 | * 67 | */ 68 | void Initialize_InitializeTeacherName(); 69 | 70 | /** 71 | * @Title Select 72 | * @Description Select the course information. 73 | * @param Table_Course 74 | * @return void 75 | * @date Jan 15, 2019-4:54:53 PM 76 | * 77 | */ 78 | void Initialize_CourseInfoTable(Table_Course table_Course); 79 | } 80 | -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/model/Table_Course.java: -------------------------------------------------------------------------------- 1 | package com.YUbuntu.model; 2 | 3 | /** 4 | * 5 | * @Project Student management system 6 | * @Package com.YUbuntu.model 7 | * @Description The information of course. 8 | * @Author #YUbuntu 9 | * @Date Dec 29, 2018-2:29:47 PM 10 | * @version 2.0 11 | */ 12 | public class Table_Course 13 | { 14 | private String Course_ID; 15 | private String Course_name; 16 | private String Teacher_ID; 17 | private String Teacher_name; 18 | private int Course_MaxStudentNumber; 19 | private int Selected_StudentNumber; 20 | private String Course_Introduction; 21 | 22 | public String getCourse_ID() 23 | { 24 | return Course_ID; 25 | } 26 | public void setCourse_ID(String course_ID) 27 | { 28 | Course_ID = course_ID; 29 | } 30 | public String getCourse_name() 31 | { 32 | return Course_name; 33 | } 34 | public void setCourse_name(String course_name) 35 | { 36 | Course_name = course_name; 37 | } 38 | public String getTeacher_ID() 39 | { 40 | return Teacher_ID; 41 | } 42 | public void setTeacher_ID(String teacher_ID) 43 | { 44 | Teacher_ID = teacher_ID; 45 | } 46 | public String getTeacher_name() 47 | { 48 | return Teacher_name; 49 | } 50 | public void setTeacher_name(String teacher_name) 51 | { 52 | Teacher_name = teacher_name; 53 | } 54 | public int getCourse_MaxStudentNumber() 55 | { 56 | return Course_MaxStudentNumber; 57 | } 58 | public void setCourse_MaxStudentNumber(int course_MaxStudentNumber) 59 | { 60 | Course_MaxStudentNumber = course_MaxStudentNumber; 61 | } 62 | public int getSelected_StudentNumber() 63 | { 64 | return Selected_StudentNumber; 65 | } 66 | public void setSelected_StudentNumber(int selected_StudentNumber) 67 | { 68 | Selected_StudentNumber = selected_StudentNumber; 69 | } 70 | public String getCourse_Introduction() 71 | { 72 | return Course_Introduction; 73 | } 74 | public void setCourse_Introduction(String course_Introduction) 75 | { 76 | Course_Introduction = course_Introduction; 77 | } 78 | 79 | /* 80 | * AddItem : A workaround is to add new objects instead of Stringobjects and make sure that the toString() method is defined ! 81 | */ 82 | @Override 83 | public String toString() 84 | { 85 | return Course_name.toString(); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/model/Table_Student.java: -------------------------------------------------------------------------------- 1 | package com.YUbuntu.model; 2 | 3 | /** 4 | * 5 | * @Project Student management system 6 | * @Package com.YUbuntu.model 7 | * @Description The student information 8 | * @Author #YUbuntu 9 | * @Date December 5,2018 10 | * @version 1.0 11 | */ 12 | public class Table_Student 13 | { 14 | String Student_id; 15 | String Student_sex; 16 | String Student_name; 17 | String Student_password; 18 | String Student_ClassId; 19 | String Student_ClassName; 20 | 21 | public String getStudent_id() 22 | { 23 | return Student_id; 24 | } 25 | 26 | public void setStudent_id(String studentID) 27 | { 28 | Student_id = studentID; 29 | } 30 | 31 | public String getStudent_sex() 32 | { 33 | return Student_sex; 34 | } 35 | 36 | public void setStudent_sex(String student_sex) 37 | { 38 | Student_sex = student_sex; 39 | } 40 | 41 | public String getStudent_name() 42 | { 43 | return Student_name; 44 | } 45 | 46 | public void setStudent_name(String student_name) 47 | { 48 | Student_name = student_name; 49 | } 50 | 51 | public String getStudent_password() 52 | { 53 | return Student_password; 54 | } 55 | 56 | public void setStudent_password(String student_password) 57 | { 58 | Student_password = student_password; 59 | } 60 | 61 | public String getStudent_ClassId() 62 | { 63 | return Student_ClassId; 64 | } 65 | 66 | public void setStudent_ClassId(String string) 67 | { 68 | Student_ClassId = string; 69 | } 70 | 71 | public String getStudent_ClassName() 72 | { 73 | return Student_ClassName; 74 | } 75 | 76 | public void setStudent_ClassName(String student_ClassName) 77 | { 78 | Student_ClassName = student_ClassName; 79 | } 80 | 81 | /* 82 | * Position : com.YUbuntu.view.StudentList_JInternalFrame 83 | * 84 | * addItem(); 85 | * -------------------------------------------------------------------------------------------------------------------- 86 | * Warning:Focus and keyboard navigation problems may arise if you add duplicate String objects. | 87 | * A workaround is to add new objects instead of String objects and make sure that the toString() method is defined. | 88 | * -------------------------------------------------------------------------------------------------------------------- 89 | */ 90 | @Override 91 | public String toString() 92 | { 93 | //return this.Student_ClassName 94 | 95 | return this.Student_name; 96 | } 97 | 98 | } 99 | -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/view/function/TeacherList_JFrame_function.java: -------------------------------------------------------------------------------- 1 | package com.YUbuntu.view.function; 2 | 3 | import java.awt.event.ActionEvent; 4 | import java.awt.event.MouseEvent; 5 | 6 | import com.YUbuntu.model.Table_Teacher; 7 | 8 | /** 9 | * 10 | * @Project Student management system 11 | * @Package com.YUbuntu.view.function 12 | * @Description Extract panel functionality into the interface. 13 | * @Author #YUbuntu 14 | * @Date Dec 28, 2018-6:42:55 PM 15 | * @version 1.0 16 | */ 17 | public interface TeacherList_JFrame_function 18 | { 19 | /** 20 | * 21 | * @Title Function 22 | * @Description Search the specified teacher information. 23 | * @param Performed action 24 | * @return void 25 | * @date Dec 28, 2018-6:46:01 PM 26 | * @throws .. 27 | * 28 | */ 29 | void Function_SearchTeacher(ActionEvent e); 30 | 31 | /** 32 | * 33 | * @Title Function 34 | * @Description Modify the specified teacher information. 35 | * @param Performed action 36 | * @return void 37 | * @date Dec 28, 2018-6:47:06 PM 38 | * @throws .. 39 | * 40 | */ 41 | void Function_ModifyTeacherInformation(ActionEvent e); 42 | 43 | /** 44 | * 45 | * @Title Function 46 | * @Description Delete the specified teacher. 47 | * @param Performed action 48 | * @return void 49 | * @date Dec 28, 2018-6:48:16 PM 50 | * @throws .. 51 | * 52 | */ 53 | void Function_DeleteTeacher(ActionEvent e); 54 | 55 | /** 56 | * 57 | * @Title Initialize 58 | * @Description Adds the selected student information to the pointing location. 59 | * @param Mouse clicked 60 | * @return void 61 | * @date Dec 28, 2018-6:49:21 PM 62 | * @throws .. 63 | * 64 | */ 65 | void Initialize_SelectTeacherTableRow(MouseEvent e); 66 | 67 | /** 68 | * 69 | * @Title Function 70 | * @Description Initializes the information in the teacher table. 71 | * @param no 72 | * @return void 73 | * @date Dec 28, 2018-6:50:21 PM 74 | * @throws .. 75 | * 76 | */ 77 | void Function_InitializedTeacherTable(Table_Teacher table_Teacher); 78 | 79 | /** 80 | * 81 | * @Title Initialize 82 | * @Description Get the class name. 83 | * @param no 84 | * @return void 85 | * @date Dec 28, 2018-6:51:09 PM 86 | * @throws .. 87 | * 88 | */ 89 | void Initialize_InitializeClassName(); 90 | 91 | /** 92 | * 93 | * @Title Initialize 94 | * @Description Set user permissions. 95 | * @param no 96 | * @return void 97 | * @date Dec 28, 2018-6:53:07 PM 98 | * @throws .. 99 | * 100 | */ 101 | void Initialize_SetUserPermissions(); 102 | } 103 | -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/dao/Student_Dao.java: -------------------------------------------------------------------------------- 1 | package com.YUbuntu.dao; 2 | 3 | import java.util.List; 4 | 5 | import com.YUbuntu.model.Table_Class; 6 | import com.YUbuntu.model.Table_Student; 7 | 8 | /** 9 | * 10 | * @Project Student management system 11 | * @Package com.YUbuntu.dao 12 | * @Description The function of the class operation database. 13 | * @Author #YUbuntu 14 | * @Date Dec 27, 2018-8:53:31 PM 15 | * @version 1.0 16 | */ 17 | public interface Student_Dao 18 | { 19 | 20 | /** 21 | * 22 | * @Title Select 23 | * @Description Get the student name by the class name. 24 | * @param Table_Class(Class ID) 25 | * @return List 26 | * @date Jan 18, 2019-s6:05:05 PM 27 | * 28 | */ 29 | List getStudentName(String className); 30 | 31 | /** 32 | * 33 | * @Title Insert 34 | * @Description Add the student information into database. 35 | * @param The information of student 36 | * @return boolean 37 | * @date Dec 27, 2018-8:56:08 PM 38 | * @throws no 39 | * 40 | */ 41 | boolean addStudent(Table_Student table_Student); 42 | 43 | /** 44 | * 45 | * @Title Select 46 | * @Description Select the student information from database. 47 | * @param The informaton student 48 | * @return List 49 | * @date Dec 27, 2018-8:57:39 PM 50 | * @throws no 51 | * 52 | */ 53 | List getStudentList(Table_Student table_Student); 54 | 55 | /** 56 | * 57 | * @Title Delete 58 | * @Description Deletes the student information from database. 59 | * @param The studnet' ID 60 | * @return boolean 61 | * @date Dec 27, 2018-8:59:19 PM 62 | * @throws no 63 | * 64 | */ 65 | boolean Delete_StudentInformation(String Student_ID); 66 | 67 | /** 68 | * 69 | * @Title Update 70 | * @Description Modify the student information from database. 71 | * @param The information of student 72 | * @return boolean 73 | * @date Dec 27, 2018-9:00:19 PM 74 | * @throws no 75 | * 76 | */ 77 | boolean Update_StudentInformation(Table_Student table_Student); 78 | 79 | /** 80 | * 81 | * @Title Select 82 | * @Description Check the formation of logining. 83 | * @param The information of student. 84 | * @return A Object that stores student information 85 | * @date Dec 27, 2018-9:01:49 PM 86 | * @throws no 87 | * 88 | */ 89 | Table_Student Login_Student(Table_Student table_Student); 90 | 91 | /** 92 | * 93 | * @Title Update 94 | * @Description Modify the student information from database. 95 | * @param The information of student. 96 | * @return String(The result of changing) 97 | * @date Dec 27, 2018-9:04:00 PM 98 | * @throws no 99 | * 100 | */ 101 | String ChangePassword(Table_Student table_Student, String newPassword); 102 | } 103 | -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/model/Table_Teacher.java: -------------------------------------------------------------------------------- 1 | package com.YUbuntu.model; 2 | 3 | /** 4 | * 5 | * @Project Student management system 6 | * @Package com.YUbuntu.model 7 | * @Description The teacher information. 8 | * @Author #YUbuntu 9 | * @Date December 15, 2018-7:37:47 PM 10 | * @version 1.0 11 | */ 12 | public class Table_Teacher 13 | { 14 | private String Teacher_id; 15 | private String Teacher_name; 16 | private String Teacher_password; 17 | private int Teacher_age; 18 | private String Teacher_sex; 19 | private String Teacher_title; 20 | private String Teacher_ClassID; 21 | private String Teacher_ClassName; 22 | private String Teacher_telephone; 23 | 24 | public String getTeacher_id() 25 | { 26 | return Teacher_id; 27 | } 28 | public void setTeacher_id(String teacher_id) 29 | { 30 | Teacher_id = teacher_id; 31 | } 32 | public String getTeacher_name() 33 | { 34 | return Teacher_name; 35 | } 36 | public void setTeacher_name(String teacher_name) 37 | { 38 | Teacher_name = teacher_name; 39 | } 40 | public String getTeacher_password() 41 | { 42 | return Teacher_password; 43 | } 44 | public void setTeacher_password(String teacher_password) 45 | { 46 | Teacher_password = teacher_password; 47 | } 48 | public int getTeacher_age() 49 | { 50 | return Teacher_age; 51 | } 52 | public void setTeacher_age(int teacher_age) 53 | { 54 | Teacher_age = teacher_age; 55 | } 56 | public String getTeacher_sex() 57 | { 58 | return Teacher_sex; 59 | } 60 | public void setTeacher_sex(String teacher_sex) 61 | { 62 | Teacher_sex = teacher_sex; 63 | } 64 | public String getTeacher_title() 65 | { 66 | return Teacher_title; 67 | } 68 | public void setTeacher_title(String teacher_title) 69 | { 70 | Teacher_title = teacher_title; 71 | } 72 | 73 | public String getTeacher_ClassID() 74 | { 75 | return Teacher_ClassID; 76 | } 77 | public void setTeacher_ClassID(String teacher_ClassID) 78 | { 79 | Teacher_ClassID = teacher_ClassID; 80 | } 81 | public String getTeacher_ClassName() 82 | { 83 | return Teacher_ClassName; 84 | } 85 | public void setTeacher_ClassName(String teacher_ClassName) 86 | { 87 | Teacher_ClassName = teacher_ClassName; 88 | } 89 | public String getTeacher_telephone() 90 | { 91 | return Teacher_telephone; 92 | } 93 | public void setTeacher_telephone(String teacher_telephone) 94 | { 95 | Teacher_telephone = teacher_telephone; 96 | } 97 | 98 | /* 99 | * (non-Javadoc) 100 | * @see java.lang.Object#toString() 101 | * 102 | * AddItem : A workaround is to add new objects instead of Stringobjects and make sure that the toString() method is defined ! 103 | */ 104 | @Override 105 | public String toString() 106 | { 107 | return this.Teacher_name; 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/view/function/StudentList_JFrame_function.java: -------------------------------------------------------------------------------- 1 | package com.YUbuntu.view.function; 2 | 3 | import java.awt.event.ActionEvent; 4 | import java.awt.event.MouseEvent; 5 | 6 | import com.YUbuntu.model.Table_Student; 7 | 8 | /** 9 | * 10 | * @Project Student management system 11 | * @Package com.YUbuntu.view.function 12 | * @Description Extract panel functionality into the interface. 13 | * @Author #YUbuntu 14 | * @Date Dec 28, 2018-6:16:21 PM 15 | * @version 1.0 16 | */ 17 | public interface StudentList_JFrame_function 18 | { 19 | /** 20 | * 21 | * @Title Function 22 | * @Description Modify the student information 23 | * @param Performed action 24 | * @return void 25 | * @date Dec 28, 2018-6:17:57 PM 26 | * @throws .. 27 | * 28 | */ 29 | void Function_ConfirmModify(ActionEvent e); 30 | 31 | /** 32 | * 33 | * @Title Function 34 | * @Description reset the information. 35 | * @param Performed action 36 | * @return void 37 | * @date Dec 28, 2018-6:19:39 PM 38 | * @throws .. 39 | * 40 | */ 41 | void Function_ClearData(); 42 | 43 | /** 44 | * 45 | * @Title Initialize 46 | * @Description Adds the selected student information to the pointing location. 47 | * @param Mouse click. 48 | * @return void 49 | * @date Dec 28, 2018-6:20:55 PM 50 | * @throws .. 51 | * 52 | */ 53 | void Initialize_SelectStudentTableRow(MouseEvent e); 54 | 55 | /** 56 | * 57 | * @Title Function 58 | * @Description Delete the specified student information. 59 | * @param Performed action 60 | * @return void 61 | * @date Dec 28, 2018-6:25:02 PM 62 | * @throws .. 63 | * 64 | */ 65 | void Function_DeleteStudent(ActionEvent e); 66 | 67 | /** 68 | * 69 | * @Title Function 70 | * @Description Search the specified student information. 71 | * @param Performed action 72 | * @return void 73 | * @date Dec 28, 2018-6:26:15 PM 74 | * @throws .. 75 | * 76 | */ 77 | void Function_SearchStudent(ActionEvent e); 78 | 79 | /** 80 | * 81 | * @Title Function 82 | * @Description Initializes the information in the student table. 83 | * @param Performed action 84 | * @return void 85 | * @date Dec 28, 2018-6:27:36 PM 86 | * @throws .. 87 | * 88 | */ 89 | void Function_InitializedStudentTable(Table_Student table_Student); 90 | 91 | /** 92 | * 93 | * @Title Initialize 94 | * @Description Get class name. 95 | * @param no 96 | * @return void 97 | * @date Dec 28, 2018-6:28:58 PM 98 | * @throws .. 99 | * 100 | */ 101 | void Initialize_InitializeClassName(); 102 | 103 | /** 104 | * 105 | * @Title Initialize 106 | * @Description Set user permissions. 107 | * @param no 108 | * @return void 109 | * @date Dec 28, 2018-6:29:45 PM 110 | * @throws .. 111 | * 112 | */ 113 | void Initialize_SetUserPermissions(); 114 | } 115 | -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/util/JdbcUtil.java: -------------------------------------------------------------------------------- 1 | package com.YUbuntu.util; 2 | 3 | import java.sql.Connection; 4 | import java.sql.DriverManager; 5 | import java.sql.PreparedStatement; 6 | import java.sql.ResultSet; 7 | import java.sql.SQLException; 8 | 9 | import javax.swing.JFrame; 10 | import javax.swing.JOptionPane; 11 | 12 | /** 13 | * 14 | * @Project Student management system 15 | * @Package com.YUbuntu.util 16 | * @Description Tools for connecting MySQL database. 17 | * @Author #YUbuntu 18 | * @Date Dec 28, 2018-3:49:03 PM 19 | * @version 2.1 20 | */ 21 | 22 | /* 23 | * Extends JFrame : In order to use the dialog box to prompt the user ! 24 | */ 25 | public class JdbcUtil extends JFrame 26 | { 27 | 28 | private static final long serialVersionUID = 7998300586272280215L; 29 | 30 | private static String URL = DatabaseConfig.mailConfigInfo.getUrl(); 31 | private static String USER = DatabaseConfig.mailConfigInfo.getUserName(); 32 | private static String PASSWORD = DatabaseConfig.mailConfigInfo.getUserPassword(); 33 | private static String DRIVER_NAME = DatabaseConfig.mailConfigInfo.getDriverName(); 34 | 35 | /* 36 | * Ensure that the registered driver code is only executed once. 37 | */ 38 | static 39 | { 40 | try 41 | { 42 | Class.forName(DRIVER_NAME); 43 | } catch (Exception e) 44 | { 45 | System.err.println("ERROR : Fail to Initialize the driver of MySQL ~\n"); 46 | throw new ExceptionInInitializerError(e); 47 | } 48 | } 49 | 50 | /* 51 | * Return a database connection object 52 | */ 53 | public Connection getConnection() 54 | { 55 | Connection connection = null; 56 | try 57 | { 58 | connection = DriverManager.getConnection(URL, USER, PASSWORD); 59 | } catch (SQLException e) 60 | { 61 | JOptionPane.showMessageDialog(this, "Not connect to Database server !", "Connection error", 62 | JOptionPane.WARNING_MESSAGE); 63 | // Terminates the currently running Java Virtual Machine. 64 | System.exit(0); 65 | } 66 | return connection; 67 | } 68 | 69 | /** 70 | * @Title release 71 | * @Description Frees database connection resources. 72 | * @return void 73 | * @date Feb 26, 2019-6:22:51 PM 74 | * 75 | */ 76 | public static void freeResource(ResultSet resultSet, PreparedStatement preparedStatement, Connection connection) 77 | { 78 | if (resultSet != null) 79 | { 80 | try 81 | { 82 | resultSet.close(); 83 | } catch (Exception e) 84 | { 85 | System.err.println("ERROR : Fail to close the resultSet of MySQL ~\n"); 86 | } 87 | resultSet = null; 88 | } 89 | if (preparedStatement != null) 90 | { 91 | try 92 | { 93 | preparedStatement.close(); 94 | } catch (Exception e2) 95 | { 96 | System.err.println("ERROR : Fail to close the statement of MySQL ~\n"); 97 | } 98 | preparedStatement = null; 99 | } 100 | if (connection != null) 101 | { 102 | try 103 | { 104 | connection.close(); 105 | } catch (SQLException e3) 106 | { 107 | System.err.println("ERROR : Fail to close the connection of MySQL ~\n"); 108 | } 109 | connection = null; 110 | } 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/model/Table_ChoosedCourse.java: -------------------------------------------------------------------------------- 1 | package com.YUbuntu.model; 2 | 3 | /** 4 | * 5 | * @Project Student management system 6 | * @Package com.YUbuntu.model 7 | * @Description Course selection information sheet. 8 | * @Author HuangYuhui 9 | * @Date Jan 17, 2019-2:33:44 PM 10 | * @version 2.0 11 | */ 12 | public class Table_ChoosedCourse 13 | { 14 | private int ChoosedCourse_ID; 15 | 16 | private String Class_ID; 17 | private String Class_name; 18 | 19 | private String Student_ID; 20 | private String Student_name; 21 | 22 | private String Teacher_ID; 23 | private String Teacher_name; 24 | 25 | private String Course_ID; 26 | private String Course_name; 27 | 28 | private int MaxStudentNumber; 29 | private int ChoosedStudentNumber; 30 | 31 | private String Course_Introduction; 32 | 33 | 34 | public int getChoosedCourse_ID() 35 | { 36 | return ChoosedCourse_ID; 37 | } 38 | 39 | public void setChoosedCourse_ID(int choosedCourse_ID) 40 | { 41 | ChoosedCourse_ID = choosedCourse_ID; 42 | } 43 | 44 | public String getClass_ID() 45 | { 46 | return Class_ID; 47 | } 48 | 49 | public void setClass_ID(String class_ID) 50 | { 51 | Class_ID = class_ID; 52 | } 53 | 54 | public String getClass_name() 55 | { 56 | return Class_name; 57 | } 58 | 59 | public void setClass_name(String class_name) 60 | { 61 | Class_name = class_name; 62 | } 63 | 64 | public String getStudent_ID() 65 | { 66 | return Student_ID; 67 | } 68 | 69 | public void setStudent_ID(String student_ID) 70 | { 71 | Student_ID = student_ID; 72 | } 73 | 74 | public String getStudent_name() 75 | { 76 | return Student_name; 77 | } 78 | 79 | public void setStudent_name(String student_name) 80 | { 81 | Student_name = student_name; 82 | } 83 | 84 | public String getTeacher_ID() 85 | { 86 | return Teacher_ID; 87 | } 88 | 89 | public void setTeacher_ID(String teacher_ID) 90 | { 91 | Teacher_ID = teacher_ID; 92 | } 93 | 94 | public String getTeacher_name() 95 | { 96 | return Teacher_name; 97 | } 98 | 99 | public void setTeacher_name(String teacher_name) 100 | { 101 | Teacher_name = teacher_name; 102 | } 103 | 104 | public String getCourse_ID() 105 | { 106 | return Course_ID; 107 | } 108 | 109 | public void setCourse_ID(String course_ID) 110 | { 111 | Course_ID = course_ID; 112 | } 113 | 114 | public String getCourse_name() 115 | { 116 | return Course_name; 117 | } 118 | 119 | public void setCourse_name(String course_name) 120 | { 121 | Course_name = course_name; 122 | } 123 | 124 | public int getMaxStudentNumber() 125 | { 126 | return MaxStudentNumber; 127 | } 128 | 129 | public void setMaxStudentNumber(int maxStudentNumber) 130 | { 131 | MaxStudentNumber = maxStudentNumber; 132 | } 133 | 134 | public int getChoosedStudentNumber() 135 | { 136 | return ChoosedStudentNumber; 137 | } 138 | 139 | public void setChoosedStudentNumber(int choosedStudentNumber) 140 | { 141 | ChoosedStudentNumber = choosedStudentNumber; 142 | } 143 | 144 | public String getCourse_Introduction() 145 | { 146 | return Course_Introduction; 147 | } 148 | 149 | public void setCourse_Introduction(String course_Introduction) 150 | { 151 | Course_Introduction = course_Introduction; 152 | } 153 | } 154 | -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/dao/ChooseCourse_Dao.java: -------------------------------------------------------------------------------- 1 | package com.YUbuntu.dao; 2 | 3 | import java.util.List; 4 | 5 | import com.YUbuntu.model.Table_ChoosedCourse; 6 | 7 | /** 8 | * 9 | * @Project Student management system 10 | * @Package com.YUbuntu.dao 11 | * @Description The function of course selection. 12 | * @Author HuangYuhui 13 | * @Date Jan 18, 201-93:49:58 PM 14 | * @version 2.0 15 | */ 16 | public interface ChooseCourse_Dao 17 | { 18 | 19 | /** 20 | * 21 | * @Title Update 22 | * @Description Update the number of student in the specified course. 23 | * @param Course ID and boolean(Increase or reduce). 24 | * @return boolean 25 | * @date Jan 24, 2019-7:52:37 PM 26 | * 27 | */ 28 | boolean updateCourseStudentNumber(String courseID,boolean increaseNumber); 29 | 30 | /** 31 | * 32 | * @Title Select 33 | * @Description Determine whether the specified course had been choosed. 34 | * @param Course ID and Student ID. 35 | * @return boolean 36 | * @date Jan 24, 2019-6:52:52 PM 37 | * 38 | */ 39 | boolean isChoosedCourse(String courseID, String studentID); 40 | 41 | 42 | /** 43 | * 44 | * @Title Select 45 | * @Description Determine whether the number of student is max. 46 | * @param Course ID 47 | * @return 48 | * @return void 49 | * @date Jan 24, 2019-6:51:22 PM 50 | * 51 | */ 52 | boolean isCourseNumberMax(String courseID); 53 | 54 | /** 55 | * 56 | * @Title Delete 57 | * @Description Delete the specified course. 58 | * @param ChoosedCourse_ID 59 | * @return boolean 60 | * @date Jan 21, 2019-4:26:08 PM 61 | * 62 | */ 63 | boolean Exit_Course(String ChoosedCourse_ID); 64 | 65 | 66 | /** 67 | * 68 | * @Title Update 69 | * @Description Modify the information about course selection. 70 | * @param Table_ChoosedCourse 71 | * @return boolean 72 | * @date Jan 26, 2019-6:45:30 PM 73 | * 74 | */ 75 | boolean Update_ChoosedCourseInfo(Table_ChoosedCourse table_ChoosedCourse); 76 | 77 | 78 | /** 79 | * 80 | * @Title Insert 81 | * @Description Add the information of course selection. 82 | * @param table_ChoosedCourse. 83 | * @return boolean 84 | * @date Jan 20, 2019-8:02:06 PM 85 | * 86 | */ 87 | boolean AddCourseSelectionInfo(Table_ChoosedCourse table_ChoosedCourse); 88 | 89 | 90 | /** 91 | * 92 | * @Title Select 93 | * @Description Get the specified ID by the teacher name. 94 | * @param Teacher name 95 | * @return Teacher ID 96 | * @date Jan 26, 2019-6:38:17 PM 97 | * 98 | */ 99 | String getTeacherID(String teacher_name); 100 | 101 | /** 102 | * 103 | * @Title Select 104 | * @Description Get the specified course ID by the course name. 105 | * @param Course name 106 | * @return String 107 | * @date Jan 24, 2019-8:23:31 PM 108 | * 109 | */ 110 | String getCourseID(String courseName); 111 | 112 | /** 113 | * 114 | * @Title Select 115 | * @Description Get the specified student ID by the student name. 116 | * @param student name. 117 | * @return String 118 | * @date Jan 20, 2019-8:00:58 PM 119 | * 120 | */ 121 | String getStudentID(String studentName); 122 | 123 | /** 124 | * 125 | * @Title Select 126 | * @Description Get the information about course selection. 127 | * @param Table_ChoosedCourse 128 | * @return List 129 | * @date Jan 18, 20194:01:17 PM 130 | * 131 | */ 132 | List getChoosedCourseList(Table_ChoosedCourse table_SelectCourse); 133 | } 134 | -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/view/function/ChooseCourse_JF_function.java: -------------------------------------------------------------------------------- 1 | package com.YUbuntu.view.function; 2 | 3 | import java.awt.event.ActionEvent; 4 | import java.awt.event.ItemEvent; 5 | import java.awt.event.MouseEvent; 6 | 7 | import com.YUbuntu.model.Table_ChoosedCourse; 8 | 9 | /** 10 | * 11 | * @Project Student management system 12 | * @Package com.YUbuntu.view.function 13 | * @Description Extract panel functionality into the interface. 14 | * @Author HuangYuhui 15 | * @Date Jan 17, 2019-3:54:16 PM 16 | * @version 2.0 17 | */ 18 | public interface ChooseCourse_JF_function 19 | { 20 | /** 21 | * 22 | * @Title Initialize 23 | * @Description Display the student name by the class name in the JComboBox. 24 | * @param ItemEvent e 25 | * @return void 26 | * @date Jan 24, 2019-8:54:57 PM 27 | * 28 | */ 29 | void Initialize_DisplayStudentName(ItemEvent e); 30 | 31 | 32 | /** 33 | * 34 | * @Title Initialize 35 | * @Description Get the data which click the specified row in the table. 36 | * @param MouseEvent e 37 | * @return void 38 | * @date Jan 21, 2019-5:49:44 PM 39 | * 40 | */ 41 | void Initialize_ClickCourseTableRow(MouseEvent e); 42 | 43 | 44 | /** 45 | * 46 | * @Title Initialize 47 | * @Description Initialize the data in the specified position. 48 | * @param empty 49 | * @return void 50 | * @date Jan 21, 2019-4:33:00 PM 51 | * 52 | */ 53 | void Function_ClearData(); 54 | 55 | 56 | /** 57 | * 58 | * @Title Function 59 | * @Description Exit the specified course which you don't like. 60 | * @param ActionEvent e 61 | * @return void 62 | * @date Jan 21, 2019-4:07:00 PM 63 | * 64 | */ 65 | void Function_ExitCourse(ActionEvent e); 66 | 67 | 68 | /** 69 | * 70 | * @Title Function 71 | * @Description Modify the information about the course selection. 72 | * @param ActionEvent e 73 | * @return void 74 | * @date Jan 21, 2019-4:03:33 PM 75 | * 76 | */ 77 | void Function_ModifyCourseSelectionInfo(ActionEvent e); 78 | 79 | 80 | /** 81 | * 82 | * @Title Function 83 | * @Description Choose the specified course. 84 | * @param ActionEvent e 85 | * @return void 86 | * @date Jan 21, 2019-4:05:47 PM 87 | * 88 | */ 89 | void Function_ChooseCourse(ActionEvent e); 90 | 91 | 92 | /** 93 | * 94 | * @Title Initialize 95 | * @Description Initialize the table of course selection. 96 | * @param Table_ChoosedCourse 97 | * @return void 98 | * @date Jan 17, 2019-4:55:32 PM 99 | * 100 | */ 101 | void Initialize_ChoosedCourseInfoTable(Table_ChoosedCourse table_SelectCourse); 102 | 103 | 104 | /** 105 | * @Title Initialize 106 | * @Description Display the course selection information of specified student into JTable. 107 | * @param ItemEvent e 108 | * @return void 109 | * @date Jan 28, 2019-3:58:18 PM 110 | * 111 | */ 112 | void Initialize_ChoosedCourseInfoTable(ItemEvent e); 113 | 114 | 115 | /** 116 | * 117 | * @Title Initialize 118 | * @Description Initialize the class name in the JComboBox. 119 | * @param empty 120 | * @return void 121 | * @date Jan 18, 2019-5:16:40 PM 122 | * 123 | */ 124 | void Initialize_InitializeClassName(); 125 | 126 | 127 | /** 128 | * 129 | * @Title Initialize 130 | * @Description Initialize the course name in the JComboBox. 131 | * @param empty 132 | * @return void 133 | * @date Jan 17, 2019-3:55:32 PM 134 | * 135 | */ 136 | void Initialize_InitializeCourseName(); 137 | 138 | 139 | /** 140 | * 141 | * @Title Initialize 142 | * @Description Initialize the teacher name in the JComboBox. 143 | * @param Empty 144 | * @return void 145 | * @date Jan 21, 2019-6:33:32 PM 146 | * 147 | */ 148 | void Initialize_InitializeTeacherName(); 149 | 150 | /** 151 | * 152 | * @Title Initialize 153 | * @Description Initialize the student name in the JComboBox. 154 | * @param empty 155 | * @return void 156 | * @date Jan 21, 2019-6:11:59 PM 157 | * 158 | */ 159 | void Initialize_InitializeStudentName(); 160 | 161 | } 162 | -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/view/function/Main_JFrame_function.java: -------------------------------------------------------------------------------- 1 | package com.YUbuntu.view.function; 2 | 3 | import java.awt.event.ActionEvent; 4 | import java.io.IOException; 5 | import java.net.URISyntaxException; 6 | 7 | /** 8 | * 9 | * @Project Student management system 10 | * @Package com.YUbuntu.view.function 11 | * @Description Extract the function panel into the interface. 12 | * @Author #YUbuntu 13 | * @Date Dec 28, 2018-3:52:22 PM 14 | * @version 1.0 15 | */ 16 | public interface Main_JFrame_function 17 | { 18 | 19 | /** 20 | * 21 | * @Title Interface 22 | * @Description Course selection management. 23 | * @param ActionEvent e 24 | * @return void 25 | * @date Jan 17, 2019-4:03:40 PM 26 | * 27 | */ 28 | void Interface_ChooseCourseManagement(ActionEvent e); 29 | 30 | /** 31 | * 32 | * @Title Interface 33 | * @Description Manage the course information. 34 | * @param Performed action 35 | * @return void 36 | * @date Jan 15, 2019-2:29:49 PM 37 | * 38 | */ 39 | void Interface_CourseListManagement(ActionEvent e); 40 | 41 | /** 42 | * 43 | * @Title Interface 44 | * @Description Add a new course. 45 | * @param Performed action 46 | * @return void 47 | * @date Dec 29, 2018-7:20:39 PM 48 | * @version 2.0 49 | * @throws no 50 | * 51 | */ 52 | void Interface_AddCourse(ActionEvent e); 53 | 54 | /** 55 | * 56 | * @Title Interface 57 | * @Description manage the teacher information. 58 | * @param Performed action 59 | * @return void 60 | * @date Dec 28, 2018-3:55:52 PM 61 | * @throws no 62 | * 63 | */ 64 | void Interface_TeacherListManagement(ActionEvent e); 65 | 66 | /** 67 | * 68 | * @Title Interface 69 | * @Description Add a new teacher. 70 | * @param Performed action 71 | * @return void 72 | * @date Dec 28, 2018-4:00:25 PM 73 | * @throws no 74 | * 75 | */ 76 | void Interface_AddTeacher(ActionEvent e); 77 | 78 | /** 79 | * 80 | * @Title Interface 81 | * @Description manage the student inforamtion. 82 | * @param Performed action 83 | * @return void 84 | * @date Dec 28, 2018-4:01:52 PM 85 | * @throws .. 86 | * 87 | */ 88 | void Interface_StudentListManagement(ActionEvent e); 89 | 90 | /** 91 | * 92 | * @Title Interface 93 | * @Description add a new student. 94 | * @param Performed action 95 | * @return void 96 | * @date Dec 28, 2018-4:04:12 PM 97 | * @throws .. 98 | * 99 | */ 100 | void Interface_AddStudent(ActionEvent e); 101 | 102 | /** 103 | * 104 | * @Title Interface 105 | * @Description manage the class information. 106 | * @param Performed action 107 | * @return void 108 | * @date Dec 28, 2018-4:05:42 PM 109 | * @throws .. 110 | * 111 | */ 112 | void Interface_ClassManagement(ActionEvent e); 113 | 114 | /** 115 | * 116 | * @Title Interface 117 | * @Description Add a new class. 118 | * @param Performed action 119 | * @return void 120 | * @date Dec 28, 2018-4:09:09 PM 121 | * @throws .. 122 | * 123 | */ 124 | void Interface_AddClass(ActionEvent e); 125 | 126 | /** 127 | * 128 | * @Title Interface 129 | * @Description Exit the system 130 | * @param Performed action 131 | * @return void 132 | * @date Dec 28, 2018-4:10:27 PM 133 | * @throws .. 134 | * 135 | */ 136 | void Interface_Login_Out(ActionEvent e); 137 | 138 | /** 139 | * 140 | * @Title Interface 141 | * @Description Modify the user password. 142 | * @param Performed action 143 | * @return void 144 | * @date Dec 28, 2018-4:11:23 PM 145 | * @throws .. 146 | * 147 | */ 148 | void Interface_ChangePassword(ActionEvent e); 149 | 150 | /** 151 | * 152 | * @Title Interface 153 | * @Description The information about me ~ 154 | * @param Performed action 155 | * @return void 156 | * @date Dec 28, 2018-4:12:27 PM 157 | * @throws URISyntaxException 158 | * @throws IOException 159 | * 160 | */ 161 | void About_YUbuntu(ActionEvent e) throws IOException, URISyntaxException; 162 | 163 | /** 164 | * 165 | * @Title Interface 166 | * @Description Set user permissions. 167 | * @param Performed action 168 | * @return void 169 | * @date Dec 28, 2018-4:14:54 PM 170 | * @throws .. 171 | * 172 | */ 173 | void Initialize_SetUserPermissions(); 174 | 175 | } 176 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## :mortar_board::book: Student management system 2 | `Desktop applications developed using the Java programming language and MySQL database ~` 3 | 4 | ### 项目概述 5 | 6 | #### 项目阶段介绍 (:speech_balloon: stop update) 7 | - *第一阶段:+学生信息管理功能 :white_check_mark:* 8 | - *第二阶段:+学生选课管理功能 :white_check_mark:* 9 | - *第三阶段:+学生考勤管理功能 :x:* 10 | - *第四阶段:+学生成绩管理功能 :x:* 11 | 12 | 13 | 14 | ### 系统截屏 15 | 16 | - *登录界面* 17 | 18 | ![](https://googtech.github.io/blog/2019/03/09/%E5%AD%A6%E7%94%9F%E7%AE%A1%E7%90%86%E7%B3%BB%E7%BB%9F-Java-swing/Login_Interface.PNG) 19 | 20 | - *选课界面* 21 | 22 | ![](https://googtech.github.io/blog/2019/03/09/%E5%AD%A6%E7%94%9F%E7%AE%A1%E7%90%86%E7%B3%BB%E7%BB%9F-Java-swing/Main_Interface.PNG) 23 | 24 | 25 | 26 | ### 项目结构 27 | ``` 28 | │ LICENSE 29 | │ README.md 30 | │ student_management_system-er.png 31 | │ student_management_system.sql 32 | │ 33 | └─Student management system 34 | │ databaseConfig.properties 35 | │ reference document.txt 36 | │ 37 | ├─lib 38 | │ JTattoo-1.6.11.jar 39 | │ mysql-connector-java-8.0.11.jar 40 | │ 41 | └─src 42 | ├─com 43 | │ └─YUbuntu 44 | │ ├─basicDao 45 | │ │ BasicDao.java 46 | │ │ package-info.java 47 | │ │ 48 | │ ├─dao 49 | │ │ │ Administrator_Dao.java 50 | │ │ │ ChooseCourse_Dao.java 51 | │ │ │ Class_Dao.java 52 | │ │ │ Course_Dao.java 53 | │ │ │ package-info.java 54 | │ │ │ Student_Dao.java 55 | │ │ │ Teacher_Dao.java 56 | │ │ │ 57 | │ │ └─impl 58 | │ │ Administrator_DaoImpl.java 59 | │ │ ChooseCourse_DaoImpl.java 60 | │ │ Class_DaoImpl.java 61 | │ │ Course_DaoImpl.java 62 | │ │ package-info.java 63 | │ │ Student_DaoImpl.java 64 | │ │ Teacher_DaoImpl.java 65 | │ │ 66 | │ ├─model 67 | │ │ package-info.java 68 | │ │ Table_Administrator.java 69 | │ │ Table_ChoosedCourse.java 70 | │ │ Table_Class.java 71 | │ │ Table_Course.java 72 | │ │ Table_Student.java 73 | │ │ Table_Teacher.java 74 | │ │ UserType.java 75 | │ │ 76 | │ ├─util 77 | │ │ DatabaseConfig.java 78 | │ │ JdbcUtil.java 79 | │ │ package-info.java 80 | │ │ StringUtil.java 81 | │ │ 82 | │ └─view 83 | │ │ AddClass_JFrame.java 84 | │ │ AddCourse_JFrame.java 85 | │ │ AddStudent_JFrame.java 86 | │ │ AddTeacher_JInternalFrame.java 87 | │ │ ChangePassword_JFrame.java 88 | │ │ ChooseCourse_JInternalFrame.java 89 | │ │ ClassList_JFrame.java 90 | │ │ CourseList_JInternalFrame.java 91 | │ │ DatabaseConfigInfo.java 92 | │ │ Login_JFrame.java 93 | │ │ Main_JFrame.java 94 | │ │ package-info.java 95 | │ │ StudentList_JInternalFrame.java 96 | │ │ TeacherList_JInternalFrame.java 97 | │ │ 98 | │ └─function 99 | │ AddClass_JFrame_function.java 100 | │ AddCourse_JFrame_function.java 101 | │ AddStudent_JFrame_function.java 102 | │ AddTeacher_JFrame_function.java 103 | │ ChangePassword_JFrame_function.java 104 | │ ChooseCourse_JF_function.java 105 | │ ClassList_JFrame_function.java 106 | │ CourseList_JInternalFrame_function.java 107 | │ Login_JFrame_function.java 108 | │ Main_JFrame_function.java 109 | │ package-info.java 110 | │ StudentList_JFrame_function.java 111 | │ TeacherList_JFrame_function.java 112 | │ 113 | └─icon(略..) 114 | ``` 115 | 116 | #### 项目文件说明-数据库文件 117 | ``` 118 | student_management_system.sql 119 | ``` 120 | 121 | #### 项目文件说明-数据库配置信息 122 | ``` 123 | databaseConfig.properties 124 | ``` 125 | 126 | 127 | 128 | ### 数据库ER图 129 | ![](https://raw.githubusercontent.com/YUbuntu0109/Student-management-system-CS/master/student_management_system-er.png) 130 | 131 | 132 | 133 | *:books:更多有趣项目及详细学习笔记请前往我的个人博客哟(づ ̄3 ̄)づ╭❤~ : https://yubuntu0109.github.io/* 134 | 135 | :coffee: Look forward to your contribution ! 136 | 137 | :man_student: If you need any help, please contact me ~ QQ : 3083968068 138 | -------------------------------------------------------------------------------- /student_management_system.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS `student_management_system` /*!40100 DEFAULT CHARACTER SET utf8 */; 2 | USE `student_management_system`; 3 | -- MySQL dump 10.13 Distrib 8.0.11, for Win64 (x86_64) 4 | -- 5 | -- Host: localhost Database: student_management_system 6 | -- ------------------------------------------------------ 7 | -- Server version 8.0.11 8 | 9 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 10 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 11 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 12 | SET NAMES utf8 ; 13 | /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; 14 | /*!40103 SET TIME_ZONE='+00:00' */; 15 | /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; 16 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 17 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 18 | /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; 19 | 20 | -- 21 | -- Table structure for table `table_administrator` 22 | -- 23 | 24 | DROP TABLE IF EXISTS `table_administrator`; 25 | /*!40101 SET @saved_cs_client = @@character_set_client */; 26 | SET character_set_client = utf8mb4 ; 27 | CREATE TABLE `table_administrator` ( 28 | `ID` int(20) NOT NULL, 29 | `NAME` varchar(45) NOT NULL, 30 | `PASSWORD` varchar(20) NOT NULL, 31 | `BIRTHDAY` date NOT NULL, 32 | `Telephone_number` varchar(12) NOT NULL, 33 | PRIMARY KEY (`ID`), 34 | UNIQUE KEY `ID_UNIQUE` (`ID`), 35 | UNIQUE KEY `NAME_UNIQUE` (`NAME`) 36 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Administrator data'; 37 | /*!40101 SET character_set_client = @saved_cs_client */; 38 | 39 | -- 40 | -- Table structure for table `table_choosedcourse` 41 | -- 42 | 43 | DROP TABLE IF EXISTS `table_choosedcourse`; 44 | /*!40101 SET @saved_cs_client = @@character_set_client */; 45 | SET character_set_client = utf8mb4 ; 46 | CREATE TABLE `table_choosedcourse` ( 47 | `ChoosedCourse_ID` int(10) NOT NULL, 48 | `Class_ID` varchar(20) NOT NULL, 49 | `Class_name` varchar(20) NOT NULL, 50 | `Student_ID` varchar(20) NOT NULL, 51 | `Student_name` varchar(10) NOT NULL, 52 | `Teacher_ID` varchar(20) NOT NULL, 53 | `Teacher_name` varchar(15) NOT NULL, 54 | `Course_ID` varchar(20) NOT NULL, 55 | `Course_name` varchar(30) NOT NULL, 56 | `MaxStudentNumber` int(3) NOT NULL, 57 | `ChoosedStudentNumber` int(3) NOT NULL DEFAULT '0', 58 | `Course_Introduction` varchar(200) NOT NULL, 59 | PRIMARY KEY (`ChoosedCourse_ID`), 60 | KEY `Student_foreginKey_idx` (`Student_ID`), 61 | KEY `Course_foreignKey_idx` (`Course_ID`), 62 | KEY `Teacher_foreignKey_idx` (`Teacher_ID`), 63 | KEY `Class_foreignKey_idx` (`Class_ID`), 64 | CONSTRAINT `Course_foreignKey` FOREIGN KEY (`Course_ID`) REFERENCES `table_course` (`course_id`), 65 | CONSTRAINT `Student_foreignKey` FOREIGN KEY (`Student_ID`) REFERENCES `table_student` (`student_id`), 66 | CONSTRAINT `Teacher_foreignKey` FOREIGN KEY (`Teacher_ID`) REFERENCES `table_teacher` (`teacher_id`) 67 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Course selection information sheet .'; 68 | /*!40101 SET character_set_client = @saved_cs_client */; 69 | 70 | -- 71 | -- Table structure for table `table_class` 72 | -- 73 | 74 | DROP TABLE IF EXISTS `table_class`; 75 | /*!40101 SET @saved_cs_client = @@character_set_client */; 76 | SET character_set_client = utf8mb4 ; 77 | CREATE TABLE `table_class` ( 78 | `CLASS_ID` varchar(20) NOT NULL, 79 | `CLASS_NAME` varchar(30) NOT NULL, 80 | `CLASS_INTRODUCE` varchar(200) NOT NULL, 81 | PRIMARY KEY (`CLASS_ID`) 82 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Class management'; 83 | /*!40101 SET character_set_client = @saved_cs_client */; 84 | 85 | -- 86 | -- Table structure for table `table_course` 87 | -- 88 | 89 | DROP TABLE IF EXISTS `table_course`; 90 | /*!40101 SET @saved_cs_client = @@character_set_client */; 91 | SET character_set_client = utf8mb4 ; 92 | CREATE TABLE `table_course` ( 93 | `Course_ID` varchar(20) NOT NULL, 94 | `Course_name` varchar(30) NOT NULL, 95 | `Teacher_ID` varchar(20) NOT NULL, 96 | `Teacher_name` varchar(20) NOT NULL, 97 | `Course_MaxStudentNumber` int(3) NOT NULL, 98 | `Selected_StudentNumber` int(3) DEFAULT '0', 99 | `Course_Introduction` varchar(200) NOT NULL, 100 | PRIMARY KEY (`Course_ID`), 101 | KEY `Course_Teacher_Key_idx` (`Teacher_ID`), 102 | CONSTRAINT `Course_Teacher_Key` FOREIGN KEY (`Teacher_ID`) REFERENCES `table_teacher` (`teacher_id`) 103 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='The information of course.'; 104 | /*!40101 SET character_set_client = @saved_cs_client */; 105 | 106 | -- 107 | -- Table structure for table `table_student` 108 | -- 109 | 110 | DROP TABLE IF EXISTS `table_student`; 111 | /*!40101 SET @saved_cs_client = @@character_set_client */; 112 | SET character_set_client = utf8mb4 ; 113 | CREATE TABLE `table_student` ( 114 | `Student_id` varchar(20) NOT NULL, 115 | `Student_name` varchar(15) NOT NULL, 116 | `Student_sex` varchar(10) NOT NULL, 117 | `Student_password` varchar(20) NOT NULL, 118 | `Student_ClassId` varchar(20) NOT NULL, 119 | `Student_ClassName` varchar(25) NOT NULL, 120 | PRIMARY KEY (`Student_id`), 121 | UNIQUE KEY `Student_id_UNIQUE` (`Student_id`), 122 | KEY `Class_Student_key_idx` (`Student_ClassId`), 123 | CONSTRAINT `Class_Student_key` FOREIGN KEY (`Student_ClassId`) REFERENCES `table_class` (`class_id`) 124 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='The student information'; 125 | /*!40101 SET character_set_client = @saved_cs_client */; 126 | 127 | -- 128 | -- Table structure for table `table_teacher` 129 | -- 130 | 131 | DROP TABLE IF EXISTS `table_teacher`; 132 | /*!40101 SET @saved_cs_client = @@character_set_client */; 133 | SET character_set_client = utf8mb4 ; 134 | CREATE TABLE `table_teacher` ( 135 | `Teacher_ID` varchar(20) NOT NULL, 136 | `Teacher_NAME` varchar(20) NOT NULL, 137 | `Teacher_PASSWORD` varchar(20) NOT NULL, 138 | `Teacher_SEX` varchar(6) NOT NULL, 139 | `Teacher_AGE` int(3) NOT NULL, 140 | `Teacher_TITLE` varchar(40) NOT NULL, 141 | `Teacher_CLASSID` varchar(20) NOT NULL, 142 | `Teacher_CLASSNAME` varchar(30) NOT NULL, 143 | `Teacher_TELEPHONE` varchar(12) NOT NULL, 144 | PRIMARY KEY (`Teacher_ID`), 145 | UNIQUE KEY `Teacher_ID_UNIQUE` (`Teacher_ID`), 146 | KEY `Teacher_ClassID_key_idx` (`Teacher_CLASSID`) 147 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='The Teacher information'; 148 | /*!40101 SET character_set_client = @saved_cs_client */; 149 | /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; 150 | 151 | /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; 152 | /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; 153 | /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; 154 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 155 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 156 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 157 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 158 | 159 | -- Dump completed on 2019-05-29 8:47:10 160 | -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/dao/impl/Course_DaoImpl.java: -------------------------------------------------------------------------------- 1 | package com.YUbuntu.dao.impl; 2 | 3 | import java.sql.PreparedStatement; 4 | import java.sql.ResultSet; 5 | import java.sql.SQLException; 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | import com.YUbuntu.basicDao.BasicDao; 10 | import com.YUbuntu.dao.Course_Dao; 11 | import com.YUbuntu.model.Table_Course; 12 | import com.YUbuntu.model.Table_Teacher; 13 | import com.YUbuntu.util.JdbcUtil; 14 | import com.YUbuntu.util.StringUtil; 15 | 16 | /** 17 | * 18 | * @Project Student management system 19 | * @Package com.YUbuntu.dao.impl 20 | * @Description Operation of course information in the database. 21 | * @Author #YUbuntu 22 | * @Date Dec 29, 2018-7:51:04 PM 23 | * @version 2.0 24 | */ 25 | public class Course_DaoImpl extends BasicDao implements Course_Dao 26 | { 27 | /** 28 | * 29 | * @Title Select 30 | * @Description Get teacher name from database. 31 | * @param Performed action 32 | * @return List 33 | * @date Dec 29, 2018-8:06:57 PM 34 | * @throws no 35 | * 36 | */ 37 | public List getTeacherName() 38 | { 39 | PreparedStatement preparedStatement = null; 40 | ResultSet resultSet = null; 41 | List list = new ArrayList(); 42 | String SQL_GetClassName = "SELECT TEACHER_ID,TEACHER_NAME FROM TABLE_TEACHER"; 43 | try 44 | { 45 | preparedStatement = connection.prepareStatement(SQL_GetClassName); 46 | resultSet = preparedStatement.executeQuery(); 47 | while (resultSet.next()) 48 | { 49 | Table_Teacher table_Teacher = new Table_Teacher(); 50 | table_Teacher.setTeacher_id(resultSet.getString("TEACHER_ID")); 51 | table_Teacher.setTeacher_name(resultSet.getString("TEACHER_NAME")); 52 | list.add(table_Teacher); 53 | } 54 | 55 | } catch (SQLException e) 56 | { 57 | System.err.println("ERROR : FAIL TO SELECT TEACHER NAME FROM TABLE_TEACHER ! \n"); 58 | e.printStackTrace(); 59 | }finally 60 | { 61 | JdbcUtil.freeResource(resultSet, preparedStatement, connection); 62 | } 63 | return list; 64 | } 65 | 66 | 67 | 68 | /** 69 | * 70 | * @Title Insert 71 | * @Description Insert a new course into the database. 72 | * @param The information of course. 73 | * @return boolean 74 | * @date Dec 29, 2018-9:38:35 PM 75 | * @throws no 76 | * 77 | */ 78 | public boolean addCourse(Table_Course table_Course) 79 | { 80 | PreparedStatement preparedStatement = null; 81 | /* 82 | * The selected number of student is zero in default case. 83 | */ 84 | String SQL_addCourse = "INSERT INTO TABLE_COURSE VALUES (?,?,?,?,?,0,?)"; 85 | try 86 | { 87 | preparedStatement = connection.prepareStatement(SQL_addCourse); 88 | 89 | preparedStatement.setString(1, table_Course.getCourse_ID()); 90 | preparedStatement.setString(2, table_Course.getCourse_name()); 91 | preparedStatement.setString(3, table_Course.getTeacher_ID()); 92 | preparedStatement.setString(4, table_Course.getTeacher_name()); 93 | preparedStatement.setInt(5, table_Course.getCourse_MaxStudentNumber()); 94 | preparedStatement.setString(6, table_Course.getCourse_Introduction()); 95 | 96 | if (preparedStatement.executeUpdate() > 0) 97 | { 98 | JdbcUtil.freeResource(null, preparedStatement, connection); 99 | return true; 100 | } 101 | } catch (SQLException e) 102 | { 103 | System.err.println("ERROR : FAIL TO INSERT A NEW COURSE INTO THE DATABASE ! \n"); 104 | e.printStackTrace(); 105 | } 106 | JdbcUtil.freeResource(null, preparedStatement, connection); 107 | return false; 108 | } 109 | 110 | 111 | 112 | /** 113 | * 114 | * @Title Initialize 115 | * @Description Initialize the information in the course table. 116 | * @param The object of course information. 117 | * @return boolean 118 | * @date Dec 29, 2018-9:38:35 PM 119 | * @throws no 120 | * 121 | */ 122 | public List getCourseList(Table_Course table_Course) 123 | { 124 | PreparedStatement preparedStatement = null; 125 | ResultSet resultSet = null; 126 | 127 | List list = new ArrayList(); 128 | 129 | /* 130 | * Default: displays all student information. 131 | */ 132 | StringBuffer SQL_GetCourseInformation = new StringBuffer("SELECT * FROM TABLE_COURSE"); 133 | 134 | /*---------------------------------------------- 135 | * For : Function_SearchTeacher(ActionEvent e) | 136 | *---------------------------------------------- 137 | */ 138 | if (!StringUtil.IsEmpty(table_Course.getCourse_name())) 139 | { 140 | SQL_GetCourseInformation.append(" AND Course_name LIKE '%" + table_Course.getCourse_name() + "%' "); 141 | } 142 | if (!StringUtil.IsEmpty(table_Course.getTeacher_name())) 143 | { 144 | SQL_GetCourseInformation.append(" AND Teacher_name = '" + table_Course.getTeacher_name() + "' "); 145 | } 146 | 147 | try 148 | { //Note the logical relationship. 149 | preparedStatement = connection.prepareStatement(SQL_GetCourseInformation.toString().replaceFirst("AND", "WHERE")); 150 | 151 | resultSet = preparedStatement.executeQuery(); 152 | while (resultSet.next()) 153 | { 154 | Table_Course table_Course_temp = new Table_Course(); 155 | table_Course_temp.setCourse_ID(resultSet.getString("Course_ID")); 156 | table_Course_temp.setCourse_name(resultSet.getString("Course_name")); 157 | table_Course_temp.setTeacher_ID(resultSet.getString("Teacher_ID")); 158 | table_Course_temp.setTeacher_name(resultSet.getString("Teacher_name")); 159 | table_Course_temp.setCourse_MaxStudentNumber(resultSet.getInt("Course_MaxStudentNumber")); 160 | table_Course_temp.setSelected_StudentNumber(resultSet.getInt("Selected_StudentNumber")); 161 | table_Course_temp.setCourse_Introduction(resultSet.getString("Course_Introduction")); 162 | 163 | list.add(table_Course_temp); 164 | } 165 | } catch (SQLException e) 166 | { 167 | System.err.println("ERROR : FAIL TO READ COURSE INFORMATION !\n"); 168 | e.printStackTrace(); 169 | } 170 | JdbcUtil.freeResource(resultSet, preparedStatement, connection); 171 | return list; 172 | 173 | } 174 | 175 | 176 | 177 | /** 178 | * @Title Update 179 | * @Description Update the course information. 180 | * @param Table_Course 181 | * @return boolean 182 | * @date Jan 16, 2019-9:43:22 PM 183 | * 184 | */ 185 | public boolean Update_CourseInformation(Table_Course table_Course) 186 | { 187 | PreparedStatement preparedStatement = null; 188 | String SQL_Update_TeacherInformation = "UPDATE TABLE_COURSE SET COURSE_NAME = ? , TEACHER_ID = ? , TEACHER_NAME = ? ," 189 | + "COURSE_MAXSTUDENTNUMBER = ?, COURSE_INTRODUCTION = ? WHERE COURSE_ID = ?"; 190 | try 191 | { 192 | preparedStatement = connection.prepareStatement(SQL_Update_TeacherInformation); 193 | preparedStatement.setString(1, table_Course.getCourse_name()); 194 | preparedStatement.setString(2, table_Course.getTeacher_ID()); 195 | preparedStatement.setString(3, table_Course.getTeacher_name()); 196 | preparedStatement.setInt(4, table_Course.getCourse_MaxStudentNumber()); 197 | preparedStatement.setString(5, table_Course.getCourse_Introduction()); 198 | preparedStatement.setString(6,table_Course.getCourse_ID()); 199 | if (preparedStatement.executeUpdate() > 0) 200 | { 201 | JdbcUtil.freeResource(null, preparedStatement, connection); 202 | return true; 203 | } 204 | } catch (SQLException e) 205 | { 206 | System.err.println("ERROR : FAIL TO UPDATE COURSE INFORMATION WITH THE SPECIFIED TEACHER' ID !\n"); 207 | e.printStackTrace(); 208 | } 209 | JdbcUtil.freeResource(null, preparedStatement, connection); 210 | return false; 211 | } 212 | 213 | 214 | 215 | /** 216 | * @Title Delete 217 | * @Description Delete the specified course information. 218 | * @param String(Course'ID) 219 | * @return boolean 220 | * @date Jan 17, 2019-12:20:23 PM 221 | * 222 | */ 223 | public boolean Delete_CourseInformation(String courseID) 224 | { 225 | PreparedStatement preparedStatement = null; 226 | String SQL_DeleteCourseInfo = "DELETE FROM TABLE_COURSE WHERE COURSE_ID = ?"; 227 | try 228 | { 229 | preparedStatement = connection.prepareStatement(SQL_DeleteCourseInfo); 230 | preparedStatement.setString(1, courseID); 231 | 232 | if (preparedStatement.executeUpdate() > 0) 233 | { 234 | JdbcUtil.freeResource(null, preparedStatement, connection); 235 | return true; 236 | } 237 | } catch (SQLException e) 238 | { 239 | System.err.println("ERROR :FAIL TO DELETE THE SPECIFIED COURSE WITH THE SPECIFIED COURSE' ID !\n"); 240 | e.printStackTrace(); 241 | } 242 | JdbcUtil.freeResource(null, preparedStatement, connection); 243 | return false; 244 | } 245 | 246 | 247 | /** 248 | * 249 | * @Title Select 250 | * @Description Get all of course information by the courser name. 251 | * @param Table_Course 252 | * @return Table_Course 253 | * @date Jan 18, 2019-9:08:49 PM 254 | * 255 | */ 256 | public Table_Course getCourseInfo(String courseName) 257 | { 258 | PreparedStatement preparedStatement = null; 259 | Table_Course table_Course_temp = null; 260 | ResultSet resultSet = null; 261 | try 262 | { 263 | preparedStatement = connection.prepareStatement("SELECT * FROM TABLE_COURSE WHERE COURSE_NAME = ?"); 264 | preparedStatement.setString(1, courseName); 265 | resultSet = preparedStatement.executeQuery(); 266 | while (resultSet.next()) 267 | { 268 | table_Course_temp = new Table_Course(); 269 | table_Course_temp.setCourse_ID(resultSet.getString("Course_ID")); 270 | table_Course_temp.setCourse_name(resultSet.getString("Course_name")); 271 | table_Course_temp.setTeacher_ID(resultSet.getString("Teacher_ID")); 272 | table_Course_temp.setTeacher_name(resultSet.getString("Teacher_name")); 273 | table_Course_temp.setCourse_MaxStudentNumber(resultSet.getInt("Course_MaxStudentNumber")); 274 | table_Course_temp.setSelected_StudentNumber(resultSet.getInt("Selected_StudentNumber")); 275 | table_Course_temp.setCourse_Introduction(resultSet.getString("Course_Introduction")); 276 | } 277 | } catch (SQLException e) 278 | { 279 | System.err.println("ERROR : FAIL TO READ COURSE INFORMATION !\n"); 280 | e.printStackTrace(); 281 | } 282 | JdbcUtil.freeResource(resultSet, preparedStatement, connection); 283 | return table_Course_temp; 284 | } 285 | } 286 | -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/view/AddCourse_JFrame.java: -------------------------------------------------------------------------------- 1 | package com.YUbuntu.view; 2 | 3 | import java.awt.Font; 4 | import java.awt.event.ActionEvent; 5 | import java.awt.event.ActionListener; 6 | import java.util.List; 7 | 8 | import javax.swing.GroupLayout; 9 | import javax.swing.GroupLayout.Alignment; 10 | import javax.swing.JButton; 11 | import javax.swing.JComboBox; 12 | import javax.swing.JInternalFrame; 13 | import javax.swing.JLabel; 14 | import javax.swing.JOptionPane; 15 | import javax.swing.JTextArea; 16 | import javax.swing.JTextField; 17 | import javax.swing.LayoutStyle.ComponentPlacement; 18 | import javax.swing.UIManager; 19 | 20 | import com.YUbuntu.dao.impl.Course_DaoImpl; 21 | import com.YUbuntu.model.Table_Course; 22 | import com.YUbuntu.model.Table_Teacher; 23 | import com.YUbuntu.util.StringUtil; 24 | import com.YUbuntu.view.function.AddCourse_JFrame_function; 25 | 26 | /** 27 | * 28 | * @Project Student management system 29 | * @Package com.YUbuntu.view 30 | * @Description The interface of adding new course information. 31 | * @Author #YUbuntu 32 | * @Date Dec 29, 2018-2:36:13 PM 33 | * @version 2.0 34 | */ 35 | public class AddCourse_JFrame extends JInternalFrame implements AddCourse_JFrame_function 36 | { 37 | private JComboBox TeacherNameList_ComboBox; 38 | private JTextArea CourseIntroduce_TextArea; 39 | 40 | private JTextField CourseID_TextField; 41 | private JTextField CourseName_TextField; 42 | private JTextField StudentMaxNumber_TextField; 43 | 44 | /** 45 | * Launch the application. 46 | */ 47 | /*public static void main(String[] args) 48 | { 49 | EventQueue.invokeLater(new Runnable() 50 | { 51 | public void run() 52 | { 53 | try 54 | { 55 | AddCourse_JFrame frame = new AddCourse_JFrame(); 56 | frame.setVisible(true); 57 | } catch (Exception e) 58 | { 59 | e.printStackTrace(); 60 | } 61 | } 62 | }); 63 | }*/ 64 | 65 | 66 | /** 67 | * Create the frame. 68 | */ 69 | public AddCourse_JFrame() 70 | { 71 | /* 72 | * Improve the function of the interface (You can close it, you can icon it) 73 | */ 74 | setClosable(true); 75 | setIconifiable(true); 76 | 77 | setBounds(100, 100, 412, 472); 78 | JLabel lblCourseId = new JLabel("Course ID"); 79 | lblCourseId.setFont(new Font("Consolas", Font.PLAIN, 13)); 80 | 81 | CourseID_TextField = new JTextField(); 82 | CourseID_TextField.setColumns(10); 83 | 84 | JLabel lblCourseName = new JLabel("Course name"); 85 | lblCourseName.setFont(new Font("Consolas", Font.PLAIN, 13)); 86 | 87 | CourseName_TextField = new JTextField(); 88 | CourseName_TextField.setColumns(10); 89 | 90 | JLabel lblTeacher = new JLabel("Teacher name"); 91 | lblTeacher.setFont(new Font("Consolas", Font.PLAIN, 13)); 92 | 93 | TeacherNameList_ComboBox = new JComboBox(); 94 | 95 | JLabel lblStudentCount = new JLabel("The number of students"); 96 | lblStudentCount.setFont(new Font("Consolas", Font.PLAIN, 13)); 97 | 98 | StudentMaxNumber_TextField = new JTextField(); 99 | StudentMaxNumber_TextField.setColumns(10); 100 | 101 | JLabel lblCourseInterview = new JLabel("Course introduction"); 102 | lblCourseInterview.setFont(new Font("Consolas", Font.PLAIN, 13)); 103 | 104 | CourseIntroduce_TextArea = new JTextArea(); 105 | CourseIntroduce_TextArea.setBackground(UIManager.getColor("ToolTip.background")); 106 | CourseIntroduce_TextArea.setLineWrap(true); 107 | 108 | JButton ConfirmAddCourse_JButton = new JButton("Confirm"); 109 | ConfirmAddCourse_JButton.addActionListener(new ActionListener() 110 | { 111 | public void actionPerformed(ActionEvent e) 112 | { 113 | Function_ConfirmAddCourse(e); 114 | } 115 | }); 116 | ConfirmAddCourse_JButton.setFont(new Font("Consolas", Font.PLAIN, 12)); 117 | 118 | JButton ResetInformation_JButton = new JButton("Reset"); 119 | ResetInformation_JButton.addActionListener(new ActionListener() 120 | { 121 | public void actionPerformed(ActionEvent e) 122 | { 123 | Function_ResetInformation(e); 124 | } 125 | }); 126 | ResetInformation_JButton.setFont(new Font("Consolas", Font.PLAIN, 12)); 127 | GroupLayout groupLayout = new GroupLayout(getContentPane()); 128 | groupLayout.setHorizontalGroup( 129 | groupLayout.createParallelGroup(Alignment.LEADING) 130 | .addGroup(groupLayout.createSequentialGroup() 131 | .addGap(135) 132 | .addComponent(StudentMaxNumber_TextField, GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE) 133 | .addGap(187)) 134 | .addGroup(groupLayout.createSequentialGroup() 135 | .addGap(114) 136 | .addComponent(lblCourseInterview) 137 | .addContainerGap(149, Short.MAX_VALUE)) 138 | .addGroup(groupLayout.createSequentialGroup() 139 | .addGap(102) 140 | .addComponent(lblStudentCount) 141 | .addContainerGap(139, Short.MAX_VALUE)) 142 | .addGroup(Alignment.TRAILING, groupLayout.createSequentialGroup() 143 | .addGap(69) 144 | .addGroup(groupLayout.createParallelGroup(Alignment.TRAILING) 145 | .addComponent(CourseIntroduce_TextArea, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 227, Short.MAX_VALUE) 146 | .addGroup(Alignment.LEADING, groupLayout.createSequentialGroup() 147 | .addComponent(ConfirmAddCourse_JButton) 148 | .addPreferredGap(ComponentPlacement.RELATED, 75, Short.MAX_VALUE) 149 | .addComponent(ResetInformation_JButton, GroupLayout.PREFERRED_SIZE, 73, GroupLayout.PREFERRED_SIZE)) 150 | .addGroup(Alignment.LEADING, groupLayout.createSequentialGroup() 151 | .addGroup(groupLayout.createParallelGroup(Alignment.LEADING) 152 | .addComponent(lblCourseName) 153 | .addComponent(lblCourseId) 154 | .addComponent(lblTeacher)) 155 | .addPreferredGap(ComponentPlacement.UNRELATED) 156 | .addGroup(groupLayout.createParallelGroup(Alignment.LEADING) 157 | .addComponent(TeacherNameList_ComboBox, 0, 129, Short.MAX_VALUE) 158 | .addComponent(CourseID_TextField, GroupLayout.DEFAULT_SIZE, 129, Short.MAX_VALUE) 159 | .addComponent(CourseName_TextField, GroupLayout.DEFAULT_SIZE, 129, Short.MAX_VALUE)))) 160 | .addGap(106)) 161 | ); 162 | groupLayout.setVerticalGroup( 163 | groupLayout.createParallelGroup(Alignment.LEADING) 164 | .addGroup(groupLayout.createSequentialGroup() 165 | .addGap(48) 166 | .addGroup(groupLayout.createParallelGroup(Alignment.BASELINE) 167 | .addComponent(lblCourseId) 168 | .addComponent(CourseID_TextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) 169 | .addGap(36) 170 | .addGroup(groupLayout.createParallelGroup(Alignment.BASELINE) 171 | .addComponent(lblCourseName) 172 | .addComponent(CourseName_TextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) 173 | .addGap(43) 174 | .addGroup(groupLayout.createParallelGroup(Alignment.BASELINE) 175 | .addComponent(lblTeacher) 176 | .addComponent(TeacherNameList_ComboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) 177 | .addGap(32) 178 | .addComponent(lblStudentCount) 179 | .addGap(18) 180 | .addComponent(StudentMaxNumber_TextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) 181 | .addGap(18) 182 | .addComponent(lblCourseInterview) 183 | .addPreferredGap(ComponentPlacement.RELATED) 184 | .addComponent(CourseIntroduce_TextArea, GroupLayout.PREFERRED_SIZE, 50, GroupLayout.PREFERRED_SIZE) 185 | .addGap(37) 186 | .addGroup(groupLayout.createParallelGroup(Alignment.BASELINE) 187 | .addComponent(ConfirmAddCourse_JButton) 188 | .addComponent(ResetInformation_JButton)) 189 | .addContainerGap(54, Short.MAX_VALUE)) 190 | ); 191 | getContentPane().setLayout(groupLayout); 192 | 193 | /* 194 | * Initializes the teacher name and displays it in the 'TeacherNameList_ComboBox' 195 | */ 196 | Initialize_InitializeTeacherName(); 197 | 198 | } 199 | 200 | /** 201 | * 202 | * @Title Function 203 | * @Description Add a new course into database. 204 | * @param Performed action. 205 | * @return void 206 | * @date Dec 29, 2018-4:05:21 PM 207 | * @throws no 208 | * 209 | */ 210 | public void Function_ConfirmAddCourse(ActionEvent e) 211 | { 212 | String courseID = CourseID_TextField.getText(); 213 | String courseName = CourseName_TextField.getText(); 214 | int studentMaxNumber = 0; 215 | String courseIntroduce = CourseIntroduce_TextArea.getText(); 216 | 217 | //Give the tip when error data inputed by the user. 218 | try 219 | { 220 | studentMaxNumber = Integer.parseInt(StudentMaxNumber_TextField.getText()); 221 | if(studentMaxNumber<0||studentMaxNumber>150) 222 | { 223 | JOptionPane.showMessageDialog(this, "The range is : 0 < student <= 150", "warning",JOptionPane.WARNING_MESSAGE ); 224 | } 225 | } catch (NumberFormatException e_) 226 | { 227 | JOptionPane.showMessageDialog(this, "Please enter the number !","warning",JOptionPane.WARNING_MESSAGE); 228 | return; 229 | } 230 | 231 | if(StringUtil.IsEmpty(courseID)) 232 | { 233 | JOptionPane.showMessageDialog(this, "Please enter the course ID !","warning",JOptionPane.WARNING_MESSAGE); 234 | return; 235 | } 236 | if(StringUtil.IsEmpty(courseName)) 237 | { 238 | JOptionPane.showMessageDialog(this, "Please enter the course name !","warning",JOptionPane.WARNING_MESSAGE); 239 | return; 240 | } 241 | if(StringUtil.IsEmpty(courseIntroduce)) 242 | { 243 | JOptionPane.showMessageDialog(this, "Please enter the introduction of student !","warning",JOptionPane.WARNING_MESSAGE); 244 | return; 245 | } 246 | 247 | /* 248 | * Stores the teacher information. Including : teacher ID and name. 249 | * For details, please refer to : List com.YUbuntu.dao.impl.Course_DaoImpl.getTeacherName() 250 | */ 251 | Table_Teacher table_Teacher = (Table_Teacher) TeacherNameList_ComboBox.getSelectedItem(); 252 | Table_Course table_Course = new Table_Course(); 253 | 254 | /*------------------------------------------------------------------------------ 255 | * Get the teacher ID and name based on the teacher name selected by the user. | 256 | *------------------------------------------------------------------------------ 257 | */ 258 | table_Course.setTeacher_ID(table_Teacher.getTeacher_id()); 259 | table_Course.setTeacher_name(table_Teacher.getTeacher_name()); 260 | 261 | table_Course.setCourse_ID(courseID); 262 | table_Course.setCourse_name(courseName); 263 | table_Course.setCourse_MaxStudentNumber(studentMaxNumber); 264 | table_Course.setCourse_Introduction(courseIntroduce); 265 | 266 | //Stores the student information. 267 | Course_DaoImpl course_DaoImpl = new Course_DaoImpl(); 268 | if(course_DaoImpl.addCourse(table_Course)) 269 | { 270 | JOptionPane.showMessageDialog(this,"Success to add course !","warning",JOptionPane.WARNING_MESSAGE); 271 | } 272 | else 273 | { 274 | JOptionPane.showMessageDialog(this,"Fail to add course !","warning",JOptionPane.WARNING_MESSAGE); 275 | } 276 | Function_ResetInformation(e); 277 | } 278 | 279 | 280 | 281 | /** 282 | * 283 | * @Title Function 284 | * @Description Reset the information entered by the user. 285 | * @param Performed action 286 | * @return void 287 | * @date Dec 29, 2018-3:59:58 PM 288 | * @throws .. 289 | * 290 | */ 291 | public void Function_ResetInformation(ActionEvent e) 292 | { 293 | CourseID_TextField.setText(""); 294 | CourseName_TextField.setText(""); 295 | TeacherNameList_ComboBox.setSelectedIndex(0); 296 | StudentMaxNumber_TextField.setText(""); 297 | CourseIntroduce_TextArea.setText(""); 298 | } 299 | 300 | /** 301 | * 302 | * @Title Initialze 303 | * @Description Get teacher name. 304 | * @param no 305 | * @return void 306 | * @date Dec 29, 2018-8:14:24 PM 307 | * @throws no 308 | * 309 | */ 310 | public void Initialize_InitializeTeacherName() 311 | { 312 | Course_DaoImpl course_DaoImpl = new Course_DaoImpl(); 313 | List list = course_DaoImpl.getTeacherName(); 314 | 315 | for (Table_Teacher table_Teacher : list) 316 | { 317 | TeacherNameList_ComboBox.addItem(table_Teacher); 318 | } 319 | } 320 | } 321 | -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/view/AddStudent_JFrame.java: -------------------------------------------------------------------------------- 1 | package com.YUbuntu.view; 2 | 3 | import java.awt.Font; 4 | import java.awt.event.ActionEvent; 5 | import java.awt.event.ActionListener; 6 | import java.util.List; 7 | 8 | import javax.swing.ButtonGroup; 9 | import javax.swing.GroupLayout; 10 | import javax.swing.GroupLayout.Alignment; 11 | import javax.swing.ImageIcon; 12 | import javax.swing.JButton; 13 | import javax.swing.JComboBox; 14 | import javax.swing.JInternalFrame; 15 | import javax.swing.JLabel; 16 | import javax.swing.JOptionPane; 17 | import javax.swing.JPanel; 18 | import javax.swing.JPasswordField; 19 | import javax.swing.JRadioButton; 20 | import javax.swing.JTextField; 21 | import javax.swing.LayoutStyle.ComponentPlacement; 22 | import javax.swing.border.EmptyBorder; 23 | 24 | import com.YUbuntu.dao.impl.Class_DaoImpl; 25 | import com.YUbuntu.dao.impl.Student_DaoImpl; 26 | import com.YUbuntu.model.Table_Class; 27 | import com.YUbuntu.model.Table_Student; 28 | import com.YUbuntu.util.StringUtil; 29 | import com.YUbuntu.view.function.AddStudent_JFrame_function; 30 | 31 | /** 32 | * @Project Student management system 33 | * @Package com.YUbuntu.view 34 | * @Description The interface of adding new student information 35 | * @Author #YUbuntu 36 | * @Date December 5,2018 37 | * @version 1.0 38 | * 39 | */ 40 | public class AddStudent_JFrame extends /*JFrame*/ JInternalFrame implements AddStudent_JFrame_function 41 | { 42 | 43 | //Extract objects for easy operation 44 | private JPanel contentPane; 45 | private JTextField StudentID_textField; 46 | private JTextField StudentName_textField; 47 | private JPasswordField Student_PasswordField; 48 | 49 | /* 50 | * Type safety: The method addItem(Object) belongs to the raw type JComboBox. 51 | * References to generic type JComboBox should be parameterized 52 | */ 53 | private JComboBox StudentClassName_ComboBox; 54 | 55 | //Button group creation feature: restricts the user to selecting only one of the buttons 56 | private ButtonGroup buttonGroup; 57 | private JRadioButton Male_JRadioButton; 58 | private JRadioButton Female_JRadioButton; 59 | 60 | 61 | /** 62 | * Launch the application.——>(Close program entry) 63 | */ 64 | // public static void main(String[] args) { 65 | // EventQueue.invokeLater(new Runnable() { 66 | // public void run() { 67 | // try { 68 | // AddStudent_JFrame frame = new AddStudent_JFrame(); 69 | // frame.setVisible(true); 70 | // } catch (Exception e) { 71 | // e.printStackTrace(); 72 | // } 73 | // } 74 | // }); 75 | // } 76 | 77 | 78 | /** 79 | * Create the frame. 80 | */ 81 | public AddStudent_JFrame() 82 | { 83 | /* --------------------------------------------------------------------------- 84 | * Improve the function of the interface (You can close it, you can icon it) | 85 | * --------------------------------------------------------------------------- 86 | */ 87 | setClosable(true); 88 | setIconifiable(true); 89 | 90 | setFont(new Font("Consolas", Font.PLAIN, 20)); 91 | setTitle("Add student"); 92 | 93 | //setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 94 | 95 | setBounds(100, 100, 399, 377); 96 | contentPane = new JPanel(); 97 | contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); 98 | setContentPane(contentPane); 99 | 100 | JLabel lblName = new JLabel("name"); 101 | lblName.setFont(new Font("Consolas", Font.PLAIN, 15)); 102 | 103 | StudentName_textField = new JTextField(); 104 | StudentName_textField.setFont(new Font("幼圆", Font.PLAIN, 15)); 105 | StudentName_textField.setColumns(10); 106 | 107 | JLabel lblClass = new JLabel("class"); 108 | lblClass.setFont(new Font("Consolas", Font.PLAIN, 15)); 109 | 110 | StudentClassName_ComboBox = new JComboBox(); 111 | //StudentClassName_ComboBox.setModel(new DefaultComboBoxModel()); 112 | StudentClassName_ComboBox.setFont(new Font("幼圆", Font.PLAIN, 15)); 113 | //StudentClassName_ComboBox.setMaximumRowCount(10); 114 | 115 | JLabel lblPassword = new JLabel("password"); 116 | lblPassword.setFont(new Font("Consolas", Font.PLAIN, 15)); 117 | 118 | Student_PasswordField = new JPasswordField(); 119 | Student_PasswordField.setFont(new Font("Consolas", Font.PLAIN, 15)); 120 | 121 | JLabel lblSex = new JLabel("sex"); 122 | lblSex.setFont(new Font("Consolas", Font.PLAIN, 15)); 123 | 124 | Male_JRadioButton = new JRadioButton("Male"); 125 | Male_JRadioButton.setFont(new Font("Consolas", Font.PLAIN, 15)); 126 | 127 | Female_JRadioButton = new JRadioButton("Female"); 128 | Female_JRadioButton.setFont(new Font("Consolas", Font.PLAIN, 15)); 129 | 130 | //Button group creation feature: restricts the user to selecting only one of the buttons 131 | buttonGroup = new ButtonGroup(); 132 | buttonGroup.add(Male_JRadioButton); 133 | buttonGroup.add(Female_JRadioButton); 134 | 135 | JButton btnConfirm = new JButton("confirm"); 136 | btnConfirm.addActionListener(new ActionListener() 137 | { 138 | public void actionPerformed(ActionEvent e) 139 | { 140 | Function_AddStudent(e); 141 | } 142 | }); 143 | btnConfirm.setFont(new Font("Consolas", Font.PLAIN, 12)); 144 | 145 | JButton btnReset = new JButton("reset"); 146 | btnReset.addActionListener(new ActionListener() 147 | { 148 | public void actionPerformed(ActionEvent e) 149 | { 150 | Function_ResetInformation(e); 151 | } 152 | }); 153 | btnReset.setFont(new Font("Consolas", Font.PLAIN, 12)); 154 | btnReset.setIcon(null); 155 | 156 | JLabel lblId = new JLabel("ID"); 157 | lblId.setFont(new Font("Consolas", Font.PLAIN, 15)); 158 | 159 | StudentID_textField = new JTextField(); 160 | StudentID_textField.setColumns(10); 161 | GroupLayout gl_contentPane = new GroupLayout(contentPane); 162 | gl_contentPane.setHorizontalGroup( 163 | gl_contentPane.createParallelGroup(Alignment.TRAILING) 164 | .addGroup(gl_contentPane.createSequentialGroup() 165 | .addGap(65) 166 | .addComponent(btnConfirm) 167 | .addGap(236)) 168 | .addGroup(Alignment.LEADING, gl_contentPane.createSequentialGroup() 169 | .addGap(28) 170 | .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING) 171 | .addComponent(lblPassword) 172 | .addComponent(lblClass) 173 | .addComponent(lblId) 174 | .addComponent(lblName) 175 | .addComponent(lblSex)) 176 | .addPreferredGap(ComponentPlacement.UNRELATED) 177 | .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING) 178 | .addGroup(gl_contentPane.createSequentialGroup() 179 | .addComponent(Male_JRadioButton) 180 | .addGap(37) 181 | .addComponent(Female_JRadioButton)) 182 | .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING, false) 183 | .addComponent(StudentClassName_ComboBox, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 184 | .addComponent(StudentID_textField, GroupLayout.DEFAULT_SIZE, 198, Short.MAX_VALUE) 185 | .addComponent(Student_PasswordField) 186 | .addComponent(StudentName_textField) 187 | .addComponent(btnReset, Alignment.TRAILING, GroupLayout.PREFERRED_SIZE, 77, GroupLayout.PREFERRED_SIZE))) 188 | .addContainerGap(87, Short.MAX_VALUE)) 189 | ); 190 | gl_contentPane.setVerticalGroup( 191 | gl_contentPane.createParallelGroup(Alignment.LEADING) 192 | .addGroup(gl_contentPane.createSequentialGroup() 193 | .addGap(25) 194 | .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE) 195 | .addComponent(lblName) 196 | .addComponent(StudentName_textField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) 197 | .addGap(26) 198 | .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE) 199 | .addComponent(lblId) 200 | .addComponent(StudentID_textField, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE)) 201 | .addPreferredGap(ComponentPlacement.RELATED, 28, Short.MAX_VALUE) 202 | .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE) 203 | .addComponent(lblClass) 204 | .addComponent(StudentClassName_ComboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) 205 | .addGap(31) 206 | .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE) 207 | .addComponent(lblPassword) 208 | .addComponent(Student_PasswordField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) 209 | .addPreferredGap(ComponentPlacement.RELATED, 28, Short.MAX_VALUE) 210 | .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE) 211 | .addComponent(lblSex) 212 | .addComponent(Male_JRadioButton) 213 | .addComponent(Female_JRadioButton)) 214 | .addPreferredGap(ComponentPlacement.RELATED, 29, Short.MAX_VALUE) 215 | .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE) 216 | .addComponent(btnConfirm) 217 | .addComponent(btnReset)) 218 | .addGap(22)) 219 | ); 220 | contentPane.setLayout(gl_contentPane); 221 | 222 | /* -------------------------------------------------------------------------------- 223 | * Initializes the class name and displays it in the 'StudentClassName_ComboBox' | 224 | * -------------------------------------------------------------------------------- 225 | */ 226 | Initialize_InitializeClassName(); 227 | } 228 | 229 | 230 | 231 | /** 232 | * 233 | * @Title Function 234 | * @Description Add new student to MySQL database 235 | * @param ActionEvent e 236 | * @return void 237 | * @date December 5,2018 238 | * 239 | */ 240 | public void Function_AddStudent(ActionEvent e) 241 | { 242 | String studentName = StudentName_textField.getText().toString(); 243 | String studentID = StudentID_textField.getText().toString(); 244 | String studentPassword = Student_PasswordField.getText(); 245 | 246 | if(StringUtil.IsEmpty(studentName)) 247 | { 248 | JOptionPane.showMessageDialog(this, "Please enter the student name !"); 249 | return; 250 | } 251 | if(StringUtil.IsEmpty(studentID)) 252 | { 253 | JOptionPane.showMessageDialog(this, "Please enter the student ID !"); 254 | return; 255 | } 256 | if(StringUtil.IsEmpty(studentPassword)) 257 | { 258 | JOptionPane.showMessageDialog(this,"Please enter the student password !"); 259 | return; 260 | } 261 | 262 | //The first step : Initializes the student information. 263 | Table_Class table_Class = (Table_Class) StudentClassName_ComboBox.getSelectedItem(); 264 | Table_Student table_Student = new Table_Student(); 265 | 266 | /*----------------------------------------------------------------------------------------------------------- 267 | * Initializes the user's class ID and class name information based on the class name selected by the user. | 268 | *----------------------------------------------------------------------------------------------------------- 269 | */ 270 | table_Student.setStudent_ClassId(table_Class.get_CLASS_ID()); 271 | table_Student.setStudent_ClassName(table_Class.get_CLASS_NAME()); 272 | table_Student.setStudent_name(studentName); 273 | table_Student.setStudent_id(studentID); 274 | table_Student.setStudent_password(studentPassword); 275 | //So simple ! (っ•̀ω•́)っ✎⁾⁾ ~ 276 | String sex = Male_JRadioButton.isSelected() ? Male_JRadioButton.getText() : Female_JRadioButton.getText(); 277 | table_Student.setStudent_sex(sex); 278 | 279 | //The second step : stores the student information into the MySQL database. 280 | Student_DaoImpl student_Dao = new Student_DaoImpl(); 281 | if(student_Dao.addStudent(table_Student)) 282 | { 283 | JOptionPane.showMessageDialog(this,"Success to add student !"); 284 | } 285 | else 286 | { 287 | JOptionPane.showMessageDialog(this,"Fail to add student !"); 288 | } 289 | 290 | //The last step : Reset the data entered by the user 291 | Function_ResetInformation(e); 292 | } 293 | 294 | 295 | /** 296 | * 297 | * @Title Initialize 298 | * @Description Get class information from MySQL database. 299 | * @param no 300 | * @return void 301 | * @date December 5,2018 302 | * 303 | */ 304 | public void Initialize_InitializeClassName() 305 | { 306 | Class_DaoImpl class_Dao = new Class_DaoImpl(); 307 | List list = class_Dao.getClassList(new Table_Class()); 308 | 309 | for (Table_Class table : list) 310 | { 311 | /* addItem(); 312 | * -------------------------------------------------------------------------------------------------------------------- 313 | * Warning:Focus and keyboard navigation problems may arise if you add duplicate String objects. | 314 | * A workaround is to add new objects instead of String objects and make sure that the toString() method is defined. | 315 | * -------------------------------------------------------------------------------------------------------------------- 316 | */ 317 | StudentClassName_ComboBox.addItem(table); 318 | 319 | /* System.err.println(table); 320 | * [ Before overwriting the toString method, the class name is shown as follows: ] 321 | * 322 | * com.YUbuntu.model.Table_Class@6d907fb3 eg:(@6d907fb3)<———— The address of object in memory 323 | * com.YUbuntu.model.Table_Class@328a3c2d 324 | * com.YUbuntu.model.Table_Class@760f2d0d 325 | * ... 326 | */ 327 | } 328 | Male_JRadioButton.setSelected(true);//Default:male 329 | } 330 | 331 | 332 | /** 333 | * 334 | * @Title Funciton 335 | * @Description Reset the data entered by the user 336 | * @param ActionEvent e 337 | * @return void 338 | * @date December 5,2018 339 | * 340 | */ 341 | public void Function_ResetInformation(ActionEvent e) 342 | { 343 | StudentName_textField.setText(""); 344 | StudentID_textField.setText(""); 345 | Student_PasswordField.setText(""); 346 | StudentClassName_ComboBox.setSelectedIndex(0); 347 | buttonGroup.clearSelection(); 348 | //Male_JRadioButton.setSelected(true);//Default:male 349 | } 350 | } 351 | -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/view/Login_JFrame.java: -------------------------------------------------------------------------------- 1 | package com.YUbuntu.view; 2 | 3 | import java.awt.Color; 4 | import java.awt.EventQueue; 5 | import java.awt.Font; 6 | import java.awt.Toolkit; 7 | import java.awt.event.ActionEvent; 8 | import java.awt.event.ActionListener; 9 | 10 | import javax.swing.DefaultComboBoxModel; 11 | import javax.swing.GroupLayout; 12 | import javax.swing.GroupLayout.Alignment; 13 | import javax.swing.ImageIcon; 14 | import javax.swing.JButton; 15 | import javax.swing.JComboBox; 16 | import javax.swing.JFrame; 17 | import javax.swing.JLabel; 18 | import javax.swing.JOptionPane; 19 | import javax.swing.JPanel; 20 | import javax.swing.JPasswordField; 21 | import javax.swing.JTextField; 22 | import javax.swing.LayoutStyle.ComponentPlacement; 23 | import javax.swing.UIManager; 24 | import javax.swing.UnsupportedLookAndFeelException; 25 | import javax.swing.border.EmptyBorder; 26 | 27 | import com.YUbuntu.dao.impl.Administrator_DaoImpl; 28 | import com.YUbuntu.dao.impl.Student_DaoImpl; 29 | import com.YUbuntu.dao.impl.Teacher_DaoImpl; 30 | import com.YUbuntu.model.Table_Administrator; 31 | import com.YUbuntu.model.Table_Student; 32 | import com.YUbuntu.model.Table_Teacher; 33 | import com.YUbuntu.model.UserType; 34 | import com.YUbuntu.util.StringUtil; 35 | import com.YUbuntu.view.function.Login_JFrame_function; 36 | 37 | /** 38 | * 39 | * @Project Student management system 40 | * @Package com.YUbuntu.view 41 | * @Description The login interface of user 42 | * @Author #YUbuntu 43 | * @Date November 29,2018 44 | * @version 1.0 45 | */ 46 | public class Login_JFrame extends JFrame implements Login_JFrame_function 47 | { 48 | 49 | private JPanel contentPane; 50 | private JComboBox UserType_ComboBox; 51 | private JTextField UserName_TextField; 52 | private JPasswordField User_PasswordField; 53 | private final JLabel lblNewLabel = new JLabel("New label"); 54 | 55 | /** 56 | * Launch the application. 57 | */ 58 | public static void main(String[] args) 59 | { 60 | /*------------------ 61 | * Design for UI | 62 | *------------------ 63 | */ 64 | try 65 | { 66 | UIManager.setLookAndFeel("com.jtattoo.plaf.mcwin.McWinLookAndFeel"); 67 | } catch (ClassNotFoundException e) 68 | { 69 | e.printStackTrace(); 70 | } catch (InstantiationException e) 71 | { 72 | e.printStackTrace(); 73 | } catch (IllegalAccessException e) 74 | { 75 | e.printStackTrace(); 76 | } catch (UnsupportedLookAndFeelException e) 77 | { 78 | e.printStackTrace(); 79 | } 80 | 81 | /* 82 | * The entry to the program. 83 | */ 84 | EventQueue.invokeLater(new Runnable() 85 | { 86 | public void run() 87 | { 88 | try 89 | { 90 | Login_JFrame frame = new Login_JFrame(); 91 | frame.setVisible(true); 92 | } catch (Exception e) 93 | { 94 | e.printStackTrace(); 95 | } 96 | } 97 | }); 98 | } 99 | 100 | 101 | /** 102 | * Create the frame. 103 | */ 104 | public Login_JFrame() 105 | { 106 | setIconImage(Toolkit.getDefaultToolkit().getImage(Login_JFrame.class.getResource("/icon/#YUbuntu logo.jpg"))); 107 | setTitle("Login interface \uFF08Progress : a quarter\uFF09"); 108 | setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 109 | setBounds(100, 100, 455, 337); 110 | contentPane = new JPanel(); 111 | contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); 112 | setContentPane(contentPane); 113 | 114 | // Center the login screen 115 | setLocationRelativeTo(null); 116 | 117 | JLabel lblNewLabel_1 = new JLabel("Student management system"); 118 | lblNewLabel_1.setForeground(Color.GREEN); 119 | lblNewLabel_1.setFont(new Font("Consolas", Font.BOLD, 20)); 120 | 121 | JLabel lblUserName = new JLabel("User name"); 122 | lblUserName.setIcon(new ImageIcon(Login_JFrame.class.getResource(""))); 123 | lblUserName.setFont(new Font("Consolas", Font.PLAIN, 13)); 124 | 125 | JLabel lblUserPassword = new JLabel("User password"); 126 | lblUserPassword.setIcon(new ImageIcon(Login_JFrame.class.getResource(""))); 127 | lblUserPassword.setFont(new Font("Consolas", Font.PLAIN, 13)); 128 | 129 | UserName_TextField = new JTextField(); 130 | UserName_TextField.setColumns(10); 131 | 132 | User_PasswordField = new JPasswordField(); 133 | 134 | JLabel lblTheUserTypes = new JLabel("The user types"); 135 | lblTheUserTypes.setIcon(new ImageIcon(Login_JFrame.class.getResource(""))); 136 | lblTheUserTypes.setFont(new Font("Consolas", Font.PLAIN, 13)); 137 | 138 | UserType_ComboBox = new JComboBox(); 139 | UserType_ComboBox.setFont(new Font("Consolas", Font.PLAIN, 12)); 140 | 141 | // ########## Receive the user type object ########## 142 | // UserType_ComboBox.setModel(new DefaultComboBoxModel(new String[] {"Administrator", "Teacher", "Student"})); 143 | UserType_ComboBox.setModel(new DefaultComboBoxModel(new UserType[] { UserType.Adminstrator, UserType.Teacher, UserType.Student })); 144 | 145 | JButton LoginIn_JButton = new JButton("Login"); 146 | LoginIn_JButton.addActionListener(new ActionListener() 147 | { 148 | public void actionPerformed(ActionEvent e) 149 | { 150 | LoginEvent(e); 151 | } 152 | }); 153 | LoginIn_JButton.setIcon(new ImageIcon(Login_JFrame.class.getResource(""))); 154 | LoginIn_JButton.setFont(new Font("Consolas", Font.PLAIN, 12)); 155 | 156 | JButton Reset_JButton = new JButton("Reset"); 157 | Reset_JButton.addActionListener(new ActionListener() 158 | { 159 | public void actionPerformed(ActionEvent e) 160 | { 161 | Function_ResetInformation(e); 162 | } 163 | }); 164 | Reset_JButton.setIcon(new ImageIcon(Login_JFrame.class.getResource(""))); 165 | Reset_JButton.setFont(new Font("Consolas", Font.PLAIN, 12)); 166 | GroupLayout gl_contentPane = new GroupLayout(contentPane); 167 | gl_contentPane.setHorizontalGroup( 168 | gl_contentPane.createParallelGroup(Alignment.LEADING) 169 | .addGroup(gl_contentPane.createSequentialGroup() 170 | .addContainerGap() 171 | .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING) 172 | .addGroup(gl_contentPane.createSequentialGroup() 173 | .addGap(36) 174 | .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING) 175 | .addComponent(lblNewLabel, GroupLayout.PREFERRED_SIZE, 0, GroupLayout.PREFERRED_SIZE) 176 | .addGroup(gl_contentPane.createSequentialGroup() 177 | .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING) 178 | .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING, false) 179 | .addComponent(lblTheUserTypes, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 180 | .addComponent(lblUserPassword, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 130, Short.MAX_VALUE)) 181 | .addComponent(lblUserName, GroupLayout.PREFERRED_SIZE, 96, GroupLayout.PREFERRED_SIZE)) 182 | .addPreferredGap(ComponentPlacement.UNRELATED) 183 | .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING) 184 | .addComponent(UserName_TextField, 181, 181, 181) 185 | .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING, false) 186 | .addComponent(User_PasswordField) 187 | .addComponent(UserType_ComboBox, 0, 181, Short.MAX_VALUE)))))) 188 | .addGroup(gl_contentPane.createSequentialGroup() 189 | .addGap(67) 190 | .addComponent(LoginIn_JButton, GroupLayout.PREFERRED_SIZE, 80, GroupLayout.PREFERRED_SIZE) 191 | .addGap(101) 192 | .addComponent(Reset_JButton, GroupLayout.PREFERRED_SIZE, 80, GroupLayout.PREFERRED_SIZE))) 193 | .addContainerGap(73, Short.MAX_VALUE)) 194 | .addGroup(Alignment.TRAILING, gl_contentPane.createSequentialGroup() 195 | .addContainerGap(74, Short.MAX_VALUE) 196 | .addComponent(lblNewLabel_1, GroupLayout.PREFERRED_SIZE, 293, GroupLayout.PREFERRED_SIZE) 197 | .addGap(63)) 198 | ); 199 | gl_contentPane.setVerticalGroup( 200 | gl_contentPane.createParallelGroup(Alignment.LEADING) 201 | .addGroup(gl_contentPane.createSequentialGroup() 202 | .addContainerGap() 203 | .addComponent(lblNewLabel, GroupLayout.PREFERRED_SIZE, 0, GroupLayout.PREFERRED_SIZE) 204 | .addPreferredGap(ComponentPlacement.UNRELATED) 205 | .addComponent(lblNewLabel_1) 206 | .addGap(28) 207 | .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE) 208 | .addComponent(lblUserName) 209 | .addComponent(UserName_TextField, GroupLayout.PREFERRED_SIZE, 28, GroupLayout.PREFERRED_SIZE)) 210 | .addGap(29) 211 | .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE) 212 | .addComponent(lblUserPassword) 213 | .addComponent(User_PasswordField, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)) 214 | .addGap(32) 215 | .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE) 216 | .addComponent(lblTheUserTypes) 217 | .addComponent(UserType_ComboBox, GroupLayout.PREFERRED_SIZE, 33, GroupLayout.PREFERRED_SIZE)) 218 | .addGap(23) 219 | .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE) 220 | .addComponent(LoginIn_JButton) 221 | .addComponent(Reset_JButton)) 222 | .addContainerGap()) 223 | ); 224 | contentPane.setLayout(gl_contentPane); 225 | } 226 | 227 | /** 228 | * 229 | * @Title Function 230 | * @Description Handing login events 231 | * @param event 232 | * @date November 29,2018 233 | * @exception no 234 | */ 235 | public void LoginEvent(ActionEvent e) 236 | { 237 | 238 | // Get the information entered by the user 239 | String userName = UserName_TextField.getText().toString(); 240 | // Be careful : getPassword(); 241 | String userPassword = User_PasswordField.getText().toString(); 242 | /*------------------------------------------------- 243 | * Return : The type of user selected by the user | 244 | *------------------------------------------------- 245 | */ 246 | UserType UserType_selectItem = (UserType) UserType_ComboBox.getSelectedItem(); 247 | 248 | if (StringUtil.IsEmpty(userName)) 249 | { 250 | JOptionPane.showMessageDialog(this, "Please enter the name of user !"); 251 | // return; //End program 252 | } 253 | if (StringUtil.IsEmpty(userPassword)) 254 | { 255 | JOptionPane.showMessageDialog(this, "Please enter the password of user !"); 256 | return; 257 | } 258 | 259 | /* 260 | * ------------------------------------------------------------------- 261 | * Determine the user type, different types of different permissions | 262 | * ------------------------------------------------------------------- 263 | */ 264 | if ("Administrator".equals(UserType_selectItem.getName())) 265 | { 266 | 267 | //Store personal information entered by users. 268 | Table_Administrator table_Administrator_temp = new Table_Administrator(); 269 | table_Administrator_temp.setName(userName); 270 | table_Administrator_temp.setPassword(userPassword); 271 | 272 | /* 273 | * ----------------------------------------------------------- 274 | * Verify that the login data entered by the user is correct | 275 | * ----------------------------------------------------------- 276 | */ 277 | Administrator_DaoImpl administrator_Dao = new Administrator_DaoImpl(); 278 | Table_Administrator table_Administrator = administrator_Dao.Login_Administrator(table_Administrator_temp); 279 | 280 | //Friendly tips 281 | if (table_Administrator == null) 282 | { 283 | JOptionPane.showMessageDialog(this, "The user name or password is error !"); 284 | return; 285 | } 286 | else 287 | { 288 | JOptionPane.showMessageDialog(this, "Welcome : " + UserType_selectItem + " : " 289 | + table_Administrator.getName()); 290 | // Close the interface of login 291 | this.dispose(); 292 | 293 | /*================================================================================== 294 | * Pararms : Initialize the main interface though the user's personal information. | 295 | *================================================================================== 296 | */ 297 | new Main_JFrame(UserType_selectItem, table_Administrator).setVisible(true); 298 | } 299 | 300 | } 301 | else if ("Student".equals(UserType_selectItem.getName())) 302 | { 303 | //Store personal information entered by users 304 | Table_Student table_Student_temp = new Table_Student(); 305 | table_Student_temp.setStudent_name(userName); 306 | table_Student_temp.setStudent_password(userPassword); 307 | 308 | //Verify that login data entered by the user is correct 309 | Student_DaoImpl student_Dao = new Student_DaoImpl(); 310 | Table_Student table_Student = student_Dao.Login_Student(table_Student_temp); 311 | 312 | //Friendly tip 313 | if(table_Student == null) 314 | { 315 | JOptionPane.showMessageDialog(this, "The user name or password is error !"); 316 | return; 317 | } 318 | else 319 | { 320 | JOptionPane.showMessageDialog(this, "Welcome : " + UserType_selectItem + " : " 321 | + table_Student.getStudent_name()); 322 | 323 | // Close the interface of login 324 | this.dispose(); 325 | 326 | /*================================================================================== 327 | * Pararms : Initialize the main interface though the user's personal information. | 328 | *================================================================================== 329 | */ 330 | new Main_JFrame(UserType_selectItem, table_Student).setVisible(true); 331 | } 332 | } 333 | 334 | else if("Teacher".equals(UserType_selectItem.getName())) 335 | { 336 | //Store personal information entered by users 337 | Table_Teacher table_Teacher_temp = new Table_Teacher(); 338 | table_Teacher_temp.setTeacher_name(userName); 339 | table_Teacher_temp.setTeacher_password(userPassword); 340 | 341 | //Verify that login data entered by the user is correct 342 | Teacher_DaoImpl teacher_Dao = new Teacher_DaoImpl(); 343 | Table_Teacher table_Teacher = teacher_Dao.Login_Teacher(table_Teacher_temp); 344 | 345 | //Friendly tip 346 | if(table_Teacher == null) 347 | { 348 | JOptionPane.showMessageDialog(this, "The user name or password is error !"); 349 | return; 350 | } 351 | else 352 | { 353 | JOptionPane.showMessageDialog(this, "Welcome : " + UserType_selectItem + " : " 354 | + table_Teacher.getTeacher_name()); 355 | 356 | // Close the interface of login 357 | this.dispose(); 358 | new Main_JFrame(UserType_selectItem, table_Teacher).setVisible(true); 359 | } 360 | } 361 | } 362 | 363 | 364 | /** 365 | * 366 | * @Title Function 367 | * @Description Reset the inforamtion entered by the user 368 | * @param event 369 | * @date November 29,2018 370 | */ 371 | public void Function_ResetInformation(ActionEvent e) 372 | { 373 | 374 | UserName_TextField.setText(""); 375 | User_PasswordField.setText(""); 376 | UserType_ComboBox.setSelectedIndex(0); 377 | } 378 | } 379 | -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/view/AddTeacher_JInternalFrame.java: -------------------------------------------------------------------------------- 1 | package com.YUbuntu.view; 2 | 3 | import java.awt.Font; 4 | import java.awt.event.ActionEvent; 5 | import java.awt.event.ActionListener; 6 | import java.util.List; 7 | 8 | import javax.swing.ButtonGroup; 9 | import javax.swing.GroupLayout; 10 | import javax.swing.GroupLayout.Alignment; 11 | import javax.swing.JButton; 12 | import javax.swing.JComboBox; 13 | import javax.swing.JInternalFrame; 14 | import javax.swing.JLabel; 15 | import javax.swing.JOptionPane; 16 | import javax.swing.JPasswordField; 17 | import javax.swing.JRadioButton; 18 | import javax.swing.JTextField; 19 | import javax.swing.LayoutStyle.ComponentPlacement; 20 | 21 | import com.YUbuntu.dao.impl.Class_DaoImpl; 22 | import com.YUbuntu.dao.impl.Teacher_DaoImpl; 23 | import com.YUbuntu.model.Table_Class; 24 | import com.YUbuntu.model.Table_Teacher; 25 | import com.YUbuntu.util.StringUtil; 26 | import com.YUbuntu.view.function.AddTeacher_JFrame_function; 27 | 28 | /** 29 | * 30 | * @Project Student management system 31 | * @Package com.YUbuntu.view 32 | * @Description The interface of adding new teacher information 33 | * @Author #YUbuntu 34 | * @Date Dec 29, 20182:36:57 PM 35 | * @version 36 | */ 37 | public class AddTeacher_JInternalFrame extends JInternalFrame implements AddTeacher_JFrame_function 38 | { 39 | private JTextField TeacherName_TextField; 40 | private JTextField TeacherID_TextField; 41 | private JTextField TeacherTitle_TextField; 42 | private JTextField TeacherTelephone_TextField; 43 | 44 | // Button group creation feature: restricts the user to selecting only one of the buttons 45 | private ButtonGroup buttonGroup; 46 | private JRadioButton TeacherSex_Male_JRadioButton; 47 | private JRadioButton TeacherSex_Female_JRadioButton; 48 | private JTextField TeacherAge_TextField; 49 | private JPasswordField TeacherPassword_PasswordField; 50 | 51 | // Extract objects for easy operation 52 | private JComboBox ChooseClassName_JComboBox; 53 | 54 | /** 55 | * Create the frame. 56 | */ 57 | public AddTeacher_JInternalFrame() 58 | { 59 | /* 60 | * --------------------------------------------------------------------------- 61 | * Improve the function of the interface (You can close it, you can icon it) | 62 | * --------------------------------------------------------------------------- 63 | */ 64 | setClosable(true); 65 | setIconifiable(true); 66 | 67 | setTitle("Add new teacher information"); 68 | setBounds(100, 100, 644, 582); 69 | 70 | JLabel lblName = new JLabel("Name"); 71 | lblName.setFont(new Font("Consolas", Font.PLAIN, 15)); 72 | 73 | TeacherName_TextField = new JTextField(); 74 | TeacherName_TextField.setColumns(10); 75 | 76 | JLabel lblAge = new JLabel("Sex"); 77 | lblAge.setFont(new Font("Consolas", Font.PLAIN, 15)); 78 | 79 | JLabel lblId = new JLabel("ID"); 80 | lblId.setFont(new Font("Consolas", Font.PLAIN, 15)); 81 | 82 | TeacherID_TextField = new JTextField(); 83 | TeacherID_TextField.setColumns(10); 84 | 85 | TeacherSex_Male_JRadioButton = new JRadioButton("Male"); 86 | TeacherSex_Male_JRadioButton.setFont(new Font("Consolas", Font.PLAIN, 15)); 87 | TeacherSex_Female_JRadioButton = new JRadioButton("Female"); 88 | TeacherSex_Female_JRadioButton.setFont(new Font("Consolas", Font.PLAIN, 15)); 89 | /* 90 | * Button group creation feature: restricts the user to selecting only one of the buttons 91 | */ 92 | buttonGroup = new ButtonGroup(); 93 | buttonGroup.add(TeacherSex_Male_JRadioButton); 94 | buttonGroup.add(TeacherSex_Female_JRadioButton); 95 | 96 | JLabel lblTitle = new JLabel("Title"); 97 | lblTitle.setFont(new Font("Consolas", Font.PLAIN, 15)); 98 | 99 | TeacherTitle_TextField = new JTextField(); 100 | TeacherTitle_TextField.setColumns(10); 101 | 102 | JLabel lblTelephone = new JLabel("Telephone"); 103 | lblTelephone.setFont(new Font("Consolas", Font.PLAIN, 15)); 104 | 105 | TeacherTelephone_TextField = new JTextField(); 106 | TeacherTelephone_TextField.setColumns(10); 107 | 108 | JButton Confirm_JButton = new JButton("Confirm"); 109 | Confirm_JButton.addActionListener(new ActionListener() 110 | { 111 | public void actionPerformed(ActionEvent e) 112 | { 113 | Function_AddTeacher(e); 114 | } 115 | }); 116 | Confirm_JButton.setFont(new Font("Consolas", Font.PLAIN, 12)); 117 | 118 | JButton Reset_JButton = new JButton("Reset"); 119 | Reset_JButton.addActionListener(new ActionListener() 120 | { 121 | public void actionPerformed(ActionEvent e) 122 | { 123 | Function_ResetInformation(e); 124 | } 125 | }); 126 | Reset_JButton.setFont(new Font("Consolas", Font.PLAIN, 12)); 127 | 128 | JLabel lblNewLabel = new JLabel("Age"); 129 | lblNewLabel.setFont(new Font("Consolas", Font.PLAIN, 15)); 130 | 131 | TeacherAge_TextField = new JTextField(); 132 | TeacherAge_TextField.setColumns(10); 133 | 134 | JLabel lblPassword = new JLabel("Password"); 135 | lblPassword.setFont(new Font("Consolas", Font.PLAIN, 15)); 136 | 137 | TeacherPassword_PasswordField = new JPasswordField(); 138 | 139 | ChooseClassName_JComboBox = new JComboBox(); 140 | 141 | JLabel lblClassName = new JLabel("Class name"); 142 | lblClassName.setFont(new Font("Consolas", Font.PLAIN, 14)); 143 | GroupLayout groupLayout = new GroupLayout(getContentPane()); 144 | groupLayout.setHorizontalGroup(groupLayout.createParallelGroup(Alignment.LEADING).addGroup(groupLayout 145 | .createSequentialGroup().addContainerGap(100, Short.MAX_VALUE) 146 | .addGroup(groupLayout.createParallelGroup(Alignment.TRAILING, false) 147 | .addComponent(lblName, Alignment.LEADING).addComponent(lblId, Alignment.LEADING) 148 | .addComponent(lblTelephone, Alignment.LEADING).addComponent(lblTitle, Alignment.LEADING) 149 | .addComponent(lblAge, Alignment.LEADING).addComponent(lblNewLabel, Alignment.LEADING) 150 | .addComponent(lblPassword, Alignment.LEADING) 151 | .addComponent(lblClassName, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, 152 | Short.MAX_VALUE) 153 | .addComponent(Confirm_JButton, GroupLayout.PREFERRED_SIZE, 99, GroupLayout.PREFERRED_SIZE)) 154 | .addGroup(groupLayout.createParallelGroup(Alignment.TRAILING).addGroup(groupLayout 155 | .createSequentialGroup().addGap(21) 156 | .addGroup(groupLayout.createParallelGroup(Alignment.LEADING, false) 157 | .addComponent(TeacherID_TextField, Alignment.TRAILING) 158 | .addGroup(groupLayout.createSequentialGroup().addComponent(TeacherSex_Male_JRadioButton) 159 | .addGap(38).addComponent(TeacherSex_Female_JRadioButton)) 160 | .addComponent(TeacherAge_TextField, 241, 241, Short.MAX_VALUE) 161 | .addComponent(ChooseClassName_JComboBox, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 162 | .addComponent(TeacherPassword_PasswordField).addComponent(TeacherName_TextField) 163 | .addComponent(TeacherTitle_TextField).addComponent(TeacherTelephone_TextField)) 164 | .addContainerGap(163, Short.MAX_VALUE)) 165 | .addGroup(groupLayout.createSequentialGroup().addPreferredGap(ComponentPlacement.RELATED) 166 | .addComponent(Reset_JButton, GroupLayout.PREFERRED_SIZE, 90, GroupLayout.PREFERRED_SIZE) 167 | .addGap(135))))); 168 | groupLayout.setVerticalGroup(groupLayout.createParallelGroup(Alignment.LEADING) 169 | .addGroup(groupLayout.createSequentialGroup().addGap(46) 170 | .addGroup(groupLayout.createParallelGroup(Alignment.BASELINE).addComponent(lblId).addComponent( 171 | TeacherID_TextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, 172 | GroupLayout.PREFERRED_SIZE)) 173 | .addGap(34) 174 | .addGroup(groupLayout.createParallelGroup(Alignment.BASELINE).addComponent(lblName) 175 | .addComponent(TeacherName_TextField, GroupLayout.PREFERRED_SIZE, 176 | GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) 177 | .addGap(41) 178 | .addGroup(groupLayout.createParallelGroup(Alignment.BASELINE).addComponent(lblPassword) 179 | .addComponent(TeacherPassword_PasswordField, GroupLayout.PREFERRED_SIZE, 180 | GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) 181 | .addGap(35) 182 | .addGroup(groupLayout.createParallelGroup(Alignment.BASELINE) 183 | .addComponent(ChooseClassName_JComboBox, GroupLayout.PREFERRED_SIZE, 184 | GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) 185 | .addComponent(lblClassName)) 186 | .addGap(35) 187 | .addGroup(groupLayout.createParallelGroup(Alignment.BASELINE).addComponent(lblNewLabel) 188 | .addComponent(TeacherAge_TextField, GroupLayout.PREFERRED_SIZE, 189 | GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) 190 | .addGap(34) 191 | .addGroup(groupLayout.createParallelGroup(Alignment.BASELINE).addComponent(lblAge) 192 | .addComponent(TeacherSex_Male_JRadioButton) 193 | .addComponent(TeacherSex_Female_JRadioButton)) 194 | .addGap(32) 195 | .addGroup(groupLayout.createParallelGroup(Alignment.BASELINE).addComponent(lblTitle) 196 | .addComponent(TeacherTitle_TextField, GroupLayout.PREFERRED_SIZE, 197 | GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) 198 | .addGap(38) 199 | .addGroup(groupLayout.createParallelGroup(Alignment.BASELINE).addComponent(lblTelephone) 200 | .addComponent(TeacherTelephone_TextField, GroupLayout.PREFERRED_SIZE, 201 | GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) 202 | .addPreferredGap(ComponentPlacement.RELATED, 37, Short.MAX_VALUE) 203 | .addGroup(groupLayout.createParallelGroup(Alignment.BASELINE).addComponent(Confirm_JButton) 204 | .addComponent(Reset_JButton)) 205 | .addGap(22))); 206 | getContentPane().setLayout(groupLayout); 207 | 208 | /* 209 | * -------------------------------------------------------------------------------- 210 | * Initializes the class name and displays it in the 'ChooseClassName_JComboBox' | 211 | * -------------------------------------------------------------------------------- 212 | */ 213 | Initialize_InitializeClassName(); 214 | } 215 | 216 | /** 217 | * 218 | * @Title Function 219 | * @Description Add new teacher information into MySQL database. 220 | * @param ActionEvent e 221 | * @return void 222 | * @date December 16, 2018-8:35:14 AM 223 | * @throws 224 | * 225 | */ 226 | public void Function_AddTeacher(ActionEvent e) 227 | { 228 | String teacherID = TeacherID_TextField.getText().toString(); 229 | String teacherName = TeacherName_TextField.getText().toString(); 230 | String teacherPassword = TeacherPassword_PasswordField.getText(); 231 | int teacherAge; 232 | // So simple ! (っ•̀ω•́)っ✎⁾⁾ ~ 233 | String teacherSex = TeacherSex_Male_JRadioButton.isSelected() ? TeacherSex_Male_JRadioButton.getText() 234 | : TeacherSex_Female_JRadioButton.getText(); 235 | String teacherTitle = TeacherTitle_TextField.getText().toString(); 236 | String teacherTelephone = TeacherTelephone_TextField.getText().toString(); 237 | 238 | // User friendly prompts. 239 | try 240 | { 241 | teacherAge = Integer.parseInt(TeacherAge_TextField.getText().toString()); 242 | } catch (Exception e2) 243 | { 244 | JOptionPane.showMessageDialog(this, "Please fill in the correct age format !"); 245 | TeacherAge_TextField.setText(""); 246 | return; 247 | } 248 | if (StringUtil.IsEmpty(teacherID) || StringUtil.IsEmpty(teacherName) || StringUtil.IsEmpty(teacherPassword) 249 | || StringUtil.IsEmpty(TeacherAge_TextField.getText().toString()) || StringUtil.IsEmpty(teacherTitle) 250 | || StringUtil.IsEmpty(teacherTelephone)) 251 | { 252 | JOptionPane.showMessageDialog(this, "Please add the information completely !"); 253 | return; 254 | } 255 | 256 | // The first step : Initializes the student information. 257 | Table_Class table_Class = (Table_Class) ChooseClassName_JComboBox.getSelectedItem(); 258 | Table_Teacher table_Teacher = new Table_Teacher(); 259 | 260 | /*----------------------------------------------------------------------------------------------------------- 261 | * Initializes the user's class ID and class name information based on the class name selected by the user. | 262 | *----------------------------------------------------------------------------------------------------------- 263 | */ 264 | table_Teacher.setTeacher_ClassID(table_Class.get_CLASS_ID()); 265 | table_Teacher.setTeacher_ClassName(table_Class.get_CLASS_NAME()); 266 | 267 | table_Teacher.setTeacher_id(teacherID); 268 | table_Teacher.setTeacher_name(teacherName); 269 | table_Teacher.setTeacher_password(teacherPassword); 270 | table_Teacher.setTeacher_age(teacherAge); 271 | table_Teacher.setTeacher_sex(teacherSex); 272 | table_Teacher.setTeacher_title(teacherTitle); 273 | table_Teacher.setTeacher_telephone(teacherTelephone); 274 | 275 | // The second step : stores the student information into the MySQL database. 276 | Teacher_DaoImpl teacher_Dao = new Teacher_DaoImpl(); 277 | if (teacher_Dao.addTeacher(table_Teacher)) 278 | { 279 | JOptionPane.showMessageDialog(this, "Success to add teacher !"); 280 | } else 281 | { 282 | JOptionPane.showMessageDialog(this, "Fail to add teacher !"); 283 | } 284 | 285 | // The last step : Reset the data entered by the user 286 | Function_ResetInformation(e); 287 | 288 | } 289 | 290 | /** 291 | * @Title Initialize 292 | * @Description Initialize the class name. 293 | * @param @return void 294 | * @date Dec 17, 2018-8:52:17 AM 295 | * @throws no 296 | * 297 | */ 298 | public void Initialize_InitializeClassName() 299 | { 300 | Class_DaoImpl class_Dao = new Class_DaoImpl(); 301 | List list = class_Dao.getClassList(new Table_Class()); 302 | 303 | for (Table_Class table : list) 304 | { 305 | /* 306 | * addItem(); 307 | * -------------------------------------------------------------------------------------------------------------------- 308 | * Warning:Focus and keyboard navigation problems may arise if you add duplicate String objects. | 309 | * A workaround is to add new objects instead of String objects and make sure that the toString() method is defined. | 310 | * -------------------------------------------------------------------------------------------------------------------- 311 | */ 312 | ChooseClassName_JComboBox.addItem(table); 313 | 314 | /* 315 | * System.err.println(table); [ Before overwriting the toString method, the class name is shown as follows: ] 316 | * 317 | * com.YUbuntu.model.Table_Class@6d907fb3 eg:(@6d907fb3) <———— The address of object in memory com.YUbuntu.model.Table_Class@328a3c2d 318 | * com.YUbuntu.model.Table_Class@760f2d0d ... 319 | */ 320 | } 321 | } 322 | 323 | /** 324 | * 325 | * @Title Function 326 | * @Description Reset the data entered by the user 327 | * @param ActionEvent e 328 | * @return void 329 | * @date Dec 15, 2018-9:30:29 PM 330 | * @throws no 331 | * 332 | */ 333 | public void Function_ResetInformation(ActionEvent e) 334 | { 335 | TeacherID_TextField.setText(""); 336 | TeacherName_TextField.setText(""); 337 | TeacherPassword_PasswordField.setText(""); 338 | TeacherAge_TextField.setText(""); 339 | buttonGroup.clearSelection(); 340 | TeacherTitle_TextField.setText(""); 341 | TeacherTelephone_TextField.setText(""); 342 | } 343 | } 344 | -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/dao/impl/ChooseCourse_DaoImpl.java: -------------------------------------------------------------------------------- 1 | package com.YUbuntu.dao.impl; 2 | 3 | import java.sql.PreparedStatement; 4 | import java.sql.ResultSet; 5 | import java.sql.SQLException; 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | import com.YUbuntu.basicDao.BasicDao; 10 | import com.YUbuntu.dao.ChooseCourse_Dao; 11 | import com.YUbuntu.model.Table_ChoosedCourse; 12 | import com.YUbuntu.util.JdbcUtil; 13 | 14 | /** 15 | * 16 | * @Project Student management system 17 | * @Package com.YUbuntu.dao.impl 18 | * @Description Operation of course selection information in the database. 19 | * @Author HuangYuhui 20 | * @Date Jan 18, 2019-3:50:42 PM 21 | * @version 2.0 22 | */ 23 | public class ChooseCourse_DaoImpl extends BasicDao implements ChooseCourse_Dao 24 | { 25 | @Override 26 | public List getChoosedCourseList(Table_ChoosedCourse table_SelectCourse) 27 | { 28 | PreparedStatement preparedStatement = null; 29 | ResultSet resultSet = null; 30 | 31 | List list = new ArrayList(); 32 | 33 | try 34 | { 35 | preparedStatement = connection.prepareStatement("SELECT * FROM TABLE_CHOOSEDCOURSE"); 36 | resultSet = preparedStatement.executeQuery(); 37 | while (resultSet.next()) 38 | { 39 | Table_ChoosedCourse table_ChooseCourse = new Table_ChoosedCourse(); 40 | table_ChooseCourse.setChoosedCourse_ID(resultSet.getInt("ChoosedCourse_ID")); 41 | table_ChooseCourse.setClass_name(resultSet.getString("Class_name")); 42 | table_ChooseCourse.setStudent_ID(resultSet.getString("Student_ID")); 43 | table_ChooseCourse.setStudent_name(resultSet.getString("Student_name")); 44 | table_ChooseCourse.setTeacher_ID(resultSet.getString("Teacher_ID")); 45 | table_ChooseCourse.setTeacher_name(resultSet.getString("Teacher_name")); 46 | table_ChooseCourse.setCourse_ID(resultSet.getString("Course_ID")); 47 | table_ChooseCourse.setCourse_name(resultSet.getString("Course_name")); 48 | table_ChooseCourse.setMaxStudentNumber(resultSet.getInt("MaxStudentNumber")); 49 | table_ChooseCourse.setChoosedStudentNumber(resultSet.getInt("ChoosedStudentNumber")); 50 | table_ChooseCourse.setCourse_Introduction(resultSet.getString("Course_Introduction")); 51 | 52 | list.add(table_ChooseCourse); 53 | } 54 | } catch (SQLException e) 55 | { 56 | System.err.println("ERROR : FAIL TO READ THE INFORMATION OF COURSE SELECTION !\n"); 57 | e.printStackTrace(); 58 | } 59 | JdbcUtil.freeResource(resultSet, preparedStatement, connection); 60 | return list; 61 | } 62 | 63 | 64 | /** 65 | * @Title Select 66 | * @Description Get the course selection information of the specified student. 67 | * @param Student name 68 | * @return List 69 | * @date Jan 28, 2019-4:17:31 PM 70 | * 71 | */ 72 | public List getChoosedCourseList(String student_name) 73 | { 74 | List list = new ArrayList(); 75 | PreparedStatement preparedStatement = null; 76 | ResultSet resultSet = null; 77 | 78 | try 79 | { 80 | preparedStatement = connection.prepareStatement("SELECT * FROM TABLE_CHOOSEDCOURSE WHERE STUDENT_NAME = ?"); 81 | preparedStatement.setString(1, student_name); 82 | resultSet = preparedStatement.executeQuery(); 83 | while (resultSet.next()) 84 | { 85 | Table_ChoosedCourse table_ChooseCourse = new Table_ChoosedCourse(); 86 | table_ChooseCourse.setChoosedCourse_ID(resultSet.getInt("ChoosedCourse_ID")); 87 | table_ChooseCourse.setClass_name(resultSet.getString("Class_name")); 88 | table_ChooseCourse.setStudent_ID(resultSet.getString("Student_ID")); 89 | table_ChooseCourse.setStudent_name(resultSet.getString("Student_name")); 90 | table_ChooseCourse.setTeacher_ID(resultSet.getString("Teacher_ID")); 91 | table_ChooseCourse.setTeacher_name(resultSet.getString("Teacher_name")); 92 | table_ChooseCourse.setCourse_ID(resultSet.getString("Course_ID")); 93 | table_ChooseCourse.setCourse_name(resultSet.getString("Course_name")); 94 | table_ChooseCourse.setMaxStudentNumber(resultSet.getInt("MaxStudentNumber")); 95 | table_ChooseCourse.setChoosedStudentNumber(resultSet.getInt("ChoosedStudentNumber")); 96 | table_ChooseCourse.setCourse_Introduction(resultSet.getString("Course_Introduction")); 97 | 98 | list.add(table_ChooseCourse); 99 | } 100 | } catch (SQLException e) 101 | { 102 | System.err.println("ERROR : FAIL TO READ THE INFORMATION OF COURSE SELECTION !\n"); 103 | e.printStackTrace(); 104 | } 105 | //JDBCUtil.freeResource(resultSet, preparedStatement, connection); 106 | return list; 107 | } 108 | 109 | 110 | 111 | /** 112 | * @Title Select 113 | * @Description Get the class ID by the specified class name. 114 | * @param Class name 115 | * @return String 116 | * @date Jan 24, 2019-11:04:30 AM 117 | * 118 | */ 119 | public String getClassID(String className) 120 | { 121 | String classID = null; 122 | PreparedStatement preparedStatement = null; 123 | ResultSet resultSet = null; 124 | 125 | try 126 | { 127 | preparedStatement = connection.prepareStatement("SELECT CLASS_ID FROM TABLE_CLASS WHERE CLASS_NAME = ?"); 128 | preparedStatement.setString(1,className); 129 | 130 | resultSet = preparedStatement.executeQuery(); 131 | if(resultSet.next()) 132 | { 133 | classID = resultSet.getString("Class_ID"); 134 | } 135 | } catch (SQLException e) 136 | { 137 | System.err.println("ERROR : FAIL TO GET THE CLASS ID FROM THE DATABASE !\n"); 138 | e.printStackTrace(); 139 | } 140 | 141 | /* 142 | * Not release the resource : java.sql.SQLNonTransientConnectionException: No operations allowed after connection closed. 143 | */ 144 | //JDBCUtil.freeResource(resultSet, preparedStatement, connection); 145 | return classID; 146 | } 147 | 148 | 149 | 150 | /** 151 | * @Title Select 152 | * @Description Get the student ID by the student name. 153 | * @param String(Student name) 154 | * @return String(Student ID) 155 | * @date Jan 18, 2019-8:27:10 PM 156 | * 157 | */ 158 | public String getStudentID(String studentName) 159 | { 160 | String studentID = null; 161 | PreparedStatement preparedStatement = null; 162 | ResultSet resultSet = null; 163 | 164 | try 165 | { 166 | preparedStatement = connection.prepareStatement("SELECT STUDENT_ID FROM TABLE_STUDENT WHERE STUDENT_NAME = ?"); 167 | preparedStatement.setString(1,studentName); 168 | 169 | resultSet = preparedStatement.executeQuery(); 170 | if(resultSet.next()) 171 | { 172 | studentID = resultSet.getString("STUDENT_ID"); 173 | } 174 | } catch (SQLException e) 175 | { 176 | System.err.println("ERROR : FAIL TO GET THE STUDENT ID FROM THE DATABASE !\n"); 177 | e.printStackTrace(); 178 | } 179 | 180 | /* 181 | * Not release the resource : java.sql.SQLNonTransientConnectionException: No operations allowed after connection closed. 182 | */ 183 | //JDBCUtil.freeResource(resultSet, preparedStatement, connection); 184 | return studentID; 185 | } 186 | 187 | 188 | /** 189 | * @Title Select 190 | * @Description Get the course ID by the specified course name. 191 | * @param Course name 192 | * @return Course ID 193 | * @date Jan 24, 2019-8:19:53 PM 194 | * 195 | */ 196 | public String getCourseID(String courseName) 197 | { 198 | String courseID = null; 199 | PreparedStatement preparedStatement = null; 200 | ResultSet resultSet = null; 201 | 202 | try 203 | { 204 | preparedStatement = connection.prepareStatement("SELECT COURSE_ID FROM TABLE_CHOOSEDCOURSE WHERE COURSE_NAME = ?"); 205 | preparedStatement.setString(1, courseName); 206 | 207 | resultSet = preparedStatement.executeQuery(); 208 | if (resultSet.next()) 209 | { 210 | courseID = resultSet.getString("COURSE_ID"); 211 | } 212 | } catch (SQLException e) 213 | { 214 | System.err.println("ERROR : FAIL TO GET THE COURSE ID FROM THE DATABASE !\n"); 215 | e.printStackTrace(); 216 | } 217 | 218 | /* 219 | * Not release the resource : java.sql.SQLNonTransientConnectionException: No operations allowed after connection closed. 220 | */ 221 | // JDBCUtil.freeResource(resultSet, preparedStatement, connection); 222 | return courseID; 223 | } 224 | 225 | /** 226 | * @Title Select 227 | * @Description Get the specified ID by the teacher name. 228 | * @param Empty 229 | * @return Teacher ID 230 | * @date Jan 26, 2019-6:33:25 PM 231 | * 232 | */ 233 | public String getTeacherID(String teacher_name) 234 | { 235 | String teacher_ID = null; 236 | PreparedStatement preparedStatement = null; 237 | ResultSet resultSet = null; 238 | 239 | try 240 | { 241 | preparedStatement = connection.prepareStatement("SELECT TEACHER_ID FROM TABLE_CHOOSEDCOURSE WHERE TEACHER_NAME = ?"); 242 | preparedStatement.setString(1, teacher_name); 243 | 244 | resultSet = preparedStatement.executeQuery(); 245 | if (resultSet.next()) 246 | { 247 | teacher_ID = resultSet.getString("TEACHER_ID"); 248 | } 249 | } catch (SQLException e) 250 | { 251 | System.err.println("ERROR : FAIL TO GET THE TEACHER ID FROM THE DATABASE !\n"); 252 | e.printStackTrace(); 253 | } 254 | 255 | /* 256 | * Not release the resource : java.sql.SQLNonTransientConnectionException: No operations allowed after connection closed. 257 | */ 258 | // JDBCUtil.freeResource(resultSet, preparedStatement, connection); 259 | return teacher_ID; 260 | } 261 | 262 | 263 | 264 | 265 | /** 266 | * @Title Insert 267 | * @Description Add the information of course selection into the database. 268 | * @param Table_ChoosedCourse 269 | * @return void 270 | * @date Jan 18, 2019-8:34:05 PM 271 | * 272 | */ 273 | public boolean AddCourseSelectionInfo(Table_ChoosedCourse table_ChoosedCourse) 274 | { 275 | PreparedStatement preparedStatement = null; 276 | String SQL_addCourseInfo = "INSERT INTO TABLE_CHOOSEDCOURSE " 277 | + "(Class_ID,Class_name,Student_ID,Student_name,Teacher_ID,Teacher_name,Course_ID,Course_name," 278 | + "MaxStudentNumber,ChoosedStudentNumber,Course_Introduction)" 279 | + "VALUES (?,?,?,?,?,?,?,?,?,?,?)"; 280 | try 281 | { 282 | /* 283 | * ERROR : java.sql.SQLNonTransientConnectionException: No operations allowed after connection closed. 284 | */ 285 | preparedStatement = connection.prepareStatement(SQL_addCourseInfo); 286 | 287 | preparedStatement.setString(1, table_ChoosedCourse.getClass_ID()); 288 | preparedStatement.setString(2, table_ChoosedCourse.getClass_name()); 289 | preparedStatement.setString(3, table_ChoosedCourse.getStudent_ID()); 290 | preparedStatement.setString(4, table_ChoosedCourse.getStudent_name()); 291 | preparedStatement.setString(5, table_ChoosedCourse.getTeacher_ID()); 292 | preparedStatement.setString(6, table_ChoosedCourse.getTeacher_name()); 293 | preparedStatement.setString(7, table_ChoosedCourse.getCourse_ID()); 294 | preparedStatement.setString(8, table_ChoosedCourse.getCourse_name()); 295 | preparedStatement.setInt(9, table_ChoosedCourse.getMaxStudentNumber()); 296 | preparedStatement.setInt(10,table_ChoosedCourse.getChoosedStudentNumber()); 297 | preparedStatement.setString(11, table_ChoosedCourse.getCourse_Introduction()); 298 | 299 | if (preparedStatement.executeUpdate() > 0) 300 | { 301 | //JDBCUtil.freeResource(null, preparedStatement, connection); 302 | return true; 303 | } 304 | } catch (SQLException e) 305 | { 306 | System.err.println("ERROR : FAIL TO ADD THE NEW COURSE INFORMATION INTO THE DATABASE !\n"); 307 | e.printStackTrace(); 308 | } 309 | //JDBCUtil.freeResource(null, preparedStatement, connection); 310 | return false; 311 | } 312 | 313 | 314 | /** 315 | * @Title Delete 316 | * @Description Delete the specified course information. 317 | * @param ChoosedCourse_ID 318 | * @return boolean 319 | * @date Jan 21, 2019-4:18:13 PM 320 | * 321 | */ 322 | public boolean Exit_Course(String ChoosedCourse_ID) 323 | { 324 | PreparedStatement preparedStatement = null; 325 | String SQL_ExitCourse = "DELETE FROM TABLE_CHOOSEDCOURSE WHERE CHOOSEDCOURSE_ID = ?"; 326 | try 327 | { 328 | preparedStatement = connection.prepareStatement(SQL_ExitCourse); 329 | preparedStatement.setString(1, ChoosedCourse_ID); 330 | 331 | if (preparedStatement.executeUpdate() > 0) 332 | { 333 | //JDBCUtil.freeResource(null, preparedStatement, connection); 334 | return true; 335 | } 336 | } catch (SQLException e) 337 | { 338 | System.err.println("ERROR :FAIL TO DELETE THE SPECIFIED COURSE WITH THE CHOOSEDCOURSE_ID !\n"); 339 | e.printStackTrace(); 340 | } 341 | //JDBCUtil.freeResource(null, preparedStatement, connection); 342 | return false; 343 | } 344 | 345 | 346 | 347 | /** 348 | * @Title Select 349 | * @Description Determine whether the number of student is max. 350 | * @param Empty 351 | * @return boolean 352 | * @date Jan 24, 2019-6:23:28 PM 353 | * 354 | */ 355 | public boolean isCourseNumberMax(String courseID) 356 | { 357 | int MaxStudentNumber; 358 | int ChoosedStudentNumber; 359 | PreparedStatement preparedStatement = null; 360 | ResultSet resultSet = null; 361 | 362 | try 363 | { 364 | preparedStatement = connection.prepareStatement("SELECT MaxStudentNumber,ChoosedStudentNumber FROM TABLE_CHOOSEDCOURSE WHERE COURSE_ID = ?"); 365 | preparedStatement.setString(1,courseID); 366 | 367 | resultSet = preparedStatement.executeQuery(); 368 | if (resultSet.next()) 369 | { 370 | MaxStudentNumber = resultSet.getInt("MaxStudentNumber"); 371 | ChoosedStudentNumber = resultSet.getInt("ChoosedStudentNumber"); 372 | if (MaxStudentNumber == ChoosedStudentNumber) 373 | { 374 | return false; 375 | } 376 | } 377 | } catch (SQLException e) 378 | { 379 | System.err.println("ERROR : FAIL TO GET THE MaxStudentNumber AND ChoosedStudentNumber FROM THE DATABASE !\n"); 380 | e.printStackTrace(); 381 | } 382 | 383 | /* 384 | * Not release the resource : java.sql.SQLNonTransientConnectionException: No operations allowed after connection closed. 385 | */ 386 | //JDBCUtil.freeResource(resultSet, preparedStatement, connection); 387 | return true; 388 | } 389 | 390 | 391 | /** 392 | * @Title Select 393 | * @Description Determine whether the course had been choosed. 394 | * @param Course ID and Student ID. 395 | * @return boolean 396 | * @date Jan 24, 2019-6:44:47 PM 397 | * 398 | */ 399 | public boolean isChoosedCourse(String courseID, String studentID) 400 | { 401 | PreparedStatement preparedStatement = null; 402 | ResultSet resultSet = null; 403 | 404 | try 405 | { 406 | preparedStatement = connection.prepareStatement("SELECT COURSE_ID,STUDENT_ID FROM TABLE_CHOOSEDCOURSE WHERE COURSE_ID = ? AND STUDENT_ID = ?"); 407 | preparedStatement.setString(1,courseID); 408 | preparedStatement.setString(2, studentID); 409 | 410 | resultSet = preparedStatement.executeQuery(); 411 | if(resultSet.next()) 412 | { 413 | return false; 414 | } 415 | } catch (SQLException e) 416 | { 417 | System.err.println("ERROR : FAIL TO GET COURSE_ID AND STUDENT_ID FROM THE DATABASE !\n"); 418 | e.printStackTrace(); 419 | } 420 | 421 | /* 422 | * Not release the resource : java.sql.SQLNonTransientConnectionException: No operations allowed after connection closed. 423 | */ 424 | //JDBCUtil.freeResource(resultSet, preparedStatement, connection); 425 | return true; 426 | } 427 | 428 | 429 | /** 430 | * @Title Update 431 | * @Description Update the number of student in the specified course. 432 | * @param Course ID and boolean(Increase or reduce). 433 | * @return boolean 434 | * @date Jan 24, 2019-7:37:40 PM 435 | * 436 | */ 437 | public boolean updateCourseStudentNumber(String courseID,boolean increase) 438 | { 439 | String studentNumber = "UPDATE TABLE_CHOOSEDCOURSE SET ChoosedStudentNumber = ChoosedStudentNumber - 1 WHERE COURSE_ID = ?"; 440 | if (increase) 441 | { 442 | studentNumber = "UPDATE TABLE_CHOOSEDCOURSE SET ChoosedStudentNumber = ChoosedStudentNumber + 1 WHERE COURSE_ID = ?"; 443 | try 444 | { 445 | PreparedStatement preparedStatement = connection.prepareStatement(studentNumber); 446 | preparedStatement.setString(1, courseID); 447 | if (preparedStatement.executeUpdate() > 0) 448 | { 449 | return true; 450 | } 451 | 452 | } catch (Exception e) 453 | { 454 | e.printStackTrace(); 455 | System.err.println("ERROR : FAIL TO UPDATE THE STUDENT NUMBER IN THE DATABASE !\n"); 456 | } 457 | } 458 | return false; 459 | } 460 | 461 | 462 | /** 463 | * @Title Update 464 | * @Description Modify the information about course selection. 465 | * @param Table_ChoosedCourse 466 | * @return boolean 467 | * @date Jan 26, 2019-6:43:48 PM 468 | * 469 | */ 470 | public boolean Update_ChoosedCourseInfo(Table_ChoosedCourse table_ChoosedCourse) 471 | { 472 | PreparedStatement preparedStatement = null; 473 | String SQL_Update_TeacherInformation = "UPDATE TABLE_CHOOSEDCOURSE SET " 474 | + "CLASS_NAME = ? , TEACHER_NAME = ? , STUDENT_NAME = ? ,COURSE_NAME = ? WHERE CHOOSEDCOURSE_ID = ?"; 475 | try 476 | { 477 | preparedStatement = connection.prepareStatement(SQL_Update_TeacherInformation); 478 | preparedStatement.setString(1, table_ChoosedCourse.getClass_name()); 479 | preparedStatement.setString(2, table_ChoosedCourse.getTeacher_name()); 480 | preparedStatement.setString(3, table_ChoosedCourse.getStudent_name()); 481 | preparedStatement.setString(4, table_ChoosedCourse.getCourse_name()); 482 | preparedStatement.setInt(5, table_ChoosedCourse.getChoosedCourse_ID()); 483 | if (preparedStatement.executeUpdate() > 0) 484 | { 485 | JdbcUtil.freeResource(null, preparedStatement, connection); 486 | return true; 487 | } 488 | } catch (SQLException e) 489 | { 490 | System.err.println("ERROR : FAIL TO UPDATE INFORMATION ABOUT COURSE SELECTION !\n"); 491 | e.printStackTrace(); 492 | } 493 | JdbcUtil.freeResource(null, preparedStatement, connection); 494 | return false; 495 | } 496 | } 497 | -------------------------------------------------------------------------------- /Student management system/src/com/YUbuntu/view/CourseList_JInternalFrame.java: -------------------------------------------------------------------------------- 1 | package com.YUbuntu.view; 2 | 3 | import java.awt.EventQueue; 4 | import java.awt.Font; 5 | import java.awt.event.ActionEvent; 6 | import java.awt.event.ActionListener; 7 | import java.awt.event.MouseAdapter; 8 | import java.awt.event.MouseEvent; 9 | import java.util.List; 10 | import java.util.Vector; 11 | 12 | import javax.swing.GroupLayout; 13 | import javax.swing.GroupLayout.Alignment; 14 | import javax.swing.JButton; 15 | import javax.swing.JComboBox; 16 | import javax.swing.JInternalFrame; 17 | import javax.swing.JLabel; 18 | import javax.swing.JOptionPane; 19 | import javax.swing.JPanel; 20 | import javax.swing.JScrollPane; 21 | import javax.swing.JTable; 22 | import javax.swing.JTextArea; 23 | import javax.swing.JTextField; 24 | import javax.swing.LayoutStyle.ComponentPlacement; 25 | import javax.swing.border.TitledBorder; 26 | import javax.swing.table.DefaultTableModel; 27 | 28 | import com.YUbuntu.dao.impl.Course_DaoImpl; 29 | import com.YUbuntu.dao.impl.Teacher_DaoImpl; 30 | import com.YUbuntu.model.Table_Course; 31 | import com.YUbuntu.model.Table_Teacher; 32 | import com.YUbuntu.util.StringUtil; 33 | import com.YUbuntu.view.function.CourseList_JInternalFrame_function; 34 | 35 | /** 36 | * @Project Student management system 37 | * @Package com.YUbuntu.view 38 | * @Description The interface of management course information. 39 | * @Author HuangYuhui 40 | * @Date Jan 15, 2019-1:05:11 PM 41 | * @version 2.0 42 | * 43 | */ 44 | public class CourseList_JInternalFrame extends JInternalFrame implements CourseList_JInternalFrame_function 45 | { 46 | private JTextField CourseName_TextField; 47 | private JComboBox TeacherName_JComboBox; 48 | private JButton Select_JButton; 49 | private JTable CourseList_JTable; 50 | private JTextField ModifyCourseName_TextField; 51 | private JTextField ModifyMaxNumber_TextField; 52 | private JComboBox ModifyTeacherName_JComboBox; 53 | private JTextArea ModifyCourseIntroduce_JTextArea; 54 | 55 | /** 56 | * Launch the application. 57 | */ 58 | public static void main(String[] args) 59 | { 60 | EventQueue.invokeLater(new Runnable() 61 | { 62 | public void run() 63 | { 64 | try 65 | { 66 | CourseList_JInternalFrame frame = new CourseList_JInternalFrame(); 67 | frame.setVisible(true); 68 | } catch (Exception e) 69 | { 70 | e.printStackTrace(); 71 | } 72 | } 73 | }); 74 | } 75 | 76 | /** 77 | * Create the frame. 78 | */ 79 | public CourseList_JInternalFrame() 80 | { 81 | /* 82 | * Improve the function of the interface (You can close it, you can icon it) ~ 83 | */ 84 | setClosable(true); 85 | setIconifiable(true); 86 | 87 | setTitle("Course information management"); 88 | setBounds(100, 100, 883, 520); 89 | 90 | JLabel lblCourseName = new JLabel("Course name"); 91 | lblCourseName.setFont(new Font("Consolas", Font.PLAIN, 14)); 92 | 93 | CourseName_TextField = new JTextField(); 94 | CourseName_TextField.setColumns(10); 95 | 96 | JLabel lblTeacherName = new JLabel("Teacher name"); 97 | lblTeacherName.setFont(new Font("Consolas", Font.PLAIN, 14)); 98 | 99 | TeacherName_JComboBox = new JComboBox(); 100 | 101 | Select_JButton = new JButton("Select"); 102 | Select_JButton.addActionListener(new ActionListener() 103 | { 104 | public void actionPerformed(ActionEvent e) 105 | { 106 | Function_SearchCourse(e); 107 | } 108 | }); 109 | Select_JButton.setFont(new Font("Consolas", Font.PLAIN, 12)); 110 | 111 | JScrollPane scrollPane = new JScrollPane(); 112 | 113 | JPanel panel = new JPanel(); 114 | panel.setBorder(new TitledBorder(null, "Modify the information", TitledBorder.LEADING, TitledBorder.TOP, null, null)); 115 | GroupLayout groupLayout = new GroupLayout(getContentPane()); 116 | groupLayout.setHorizontalGroup( 117 | groupLayout.createParallelGroup(Alignment.LEADING) 118 | .addGroup(groupLayout.createSequentialGroup() 119 | .addGap(26) 120 | .addGroup(groupLayout.createParallelGroup(Alignment.LEADING, false) 121 | .addGroup(groupLayout.createSequentialGroup() 122 | .addComponent(lblCourseName, GroupLayout.PREFERRED_SIZE, 89, GroupLayout.PREFERRED_SIZE) 123 | .addPreferredGap(ComponentPlacement.RELATED) 124 | .addComponent(CourseName_TextField, GroupLayout.PREFERRED_SIZE, 164, GroupLayout.PREFERRED_SIZE) 125 | .addGap(57) 126 | .addComponent(lblTeacherName) 127 | .addPreferredGap(ComponentPlacement.UNRELATED) 128 | .addComponent(TeacherName_JComboBox, GroupLayout.PREFERRED_SIZE, 170, GroupLayout.PREFERRED_SIZE) 129 | .addGap(26) 130 | .addComponent(Select_JButton)) 131 | .addComponent(scrollPane, GroupLayout.DEFAULT_SIZE, 816, Short.MAX_VALUE) 132 | .addComponent(panel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 133 | .addContainerGap(34, Short.MAX_VALUE)) 134 | ); 135 | groupLayout.setVerticalGroup( 136 | groupLayout.createParallelGroup(Alignment.LEADING) 137 | .addGroup(groupLayout.createSequentialGroup() 138 | .addGap(41) 139 | .addGroup(groupLayout.createParallelGroup(Alignment.BASELINE) 140 | .addComponent(lblCourseName) 141 | .addComponent(CourseName_TextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) 142 | .addComponent(TeacherName_JComboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) 143 | .addComponent(lblTeacherName) 144 | .addComponent(Select_JButton)) 145 | .addGap(36) 146 | .addComponent(scrollPane, GroupLayout.PREFERRED_SIZE, 223, GroupLayout.PREFERRED_SIZE) 147 | .addGap(18) 148 | .addComponent(panel, GroupLayout.PREFERRED_SIZE, 132, GroupLayout.PREFERRED_SIZE) 149 | .addContainerGap(16, Short.MAX_VALUE)) 150 | ); 151 | 152 | JLabel lblCourseName_1 = new JLabel("Course name"); 153 | lblCourseName_1.setFont(new Font("Consolas", Font.PLAIN, 12)); 154 | 155 | ModifyCourseName_TextField = new JTextField(); 156 | ModifyCourseName_TextField.setColumns(10); 157 | 158 | JLabel lblTeacherName_1 = new JLabel("Teacher name"); 159 | lblTeacherName_1.setFont(new Font("Consolas", Font.PLAIN, 12)); 160 | 161 | JLabel lblMaxNumber = new JLabel("Max number"); 162 | lblMaxNumber.setFont(new Font("Consolas", Font.PLAIN, 12)); 163 | 164 | ModifyMaxNumber_TextField = new JTextField(); 165 | ModifyMaxNumber_TextField.setColumns(10); 166 | 167 | JLabel lblCourseIntroduce = new JLabel("Course introduce"); 168 | lblCourseIntroduce.setFont(new Font("Consolas", Font.PLAIN, 12)); 169 | 170 | JButton ConfirmModify_JButton = new JButton("Modify"); 171 | ConfirmModify_JButton.addActionListener(new ActionListener() 172 | { 173 | public void actionPerformed(ActionEvent e) 174 | { 175 | Function_ModifyCourseInfo(e); 176 | } 177 | }); 178 | ConfirmModify_JButton.setFont(new Font("Consolas", Font.PLAIN, 12)); 179 | 180 | JButton ConfirmDelete_JButton = new JButton("Delete"); 181 | ConfirmDelete_JButton.addActionListener(new ActionListener() 182 | { 183 | public void actionPerformed(ActionEvent e) 184 | { 185 | Function_ConfirmDeleteCourseInfo(e); 186 | } 187 | }); 188 | ConfirmDelete_JButton.setFont(new Font("Consolas", Font.PLAIN, 12)); 189 | 190 | JScrollPane scrollPane_1 = new JScrollPane(); 191 | 192 | ModifyTeacherName_JComboBox = new JComboBox(); 193 | GroupLayout gl_panel = new GroupLayout(panel); 194 | gl_panel.setHorizontalGroup( 195 | gl_panel.createParallelGroup(Alignment.LEADING) 196 | .addGroup(gl_panel.createSequentialGroup() 197 | .addContainerGap() 198 | .addGroup(gl_panel.createParallelGroup(Alignment.LEADING) 199 | .addComponent(lblCourseName_1, GroupLayout.PREFERRED_SIZE, 85, GroupLayout.PREFERRED_SIZE) 200 | .addComponent(lblTeacherName_1, GroupLayout.PREFERRED_SIZE, 96, GroupLayout.PREFERRED_SIZE)) 201 | .addPreferredGap(ComponentPlacement.RELATED) 202 | .addGroup(gl_panel.createParallelGroup(Alignment.LEADING, false) 203 | .addComponent(ModifyTeacherName_JComboBox, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 204 | .addComponent(ModifyCourseName_TextField, GroupLayout.DEFAULT_SIZE, 133, Short.MAX_VALUE)) 205 | .addGap(27) 206 | .addGroup(gl_panel.createParallelGroup(Alignment.LEADING) 207 | .addComponent(lblMaxNumber, GroupLayout.PREFERRED_SIZE, 78, GroupLayout.PREFERRED_SIZE) 208 | .addComponent(lblCourseIntroduce, GroupLayout.PREFERRED_SIZE, 125, GroupLayout.PREFERRED_SIZE)) 209 | .addPreferredGap(ComponentPlacement.RELATED) 210 | .addGroup(gl_panel.createParallelGroup(Alignment.LEADING) 211 | .addGroup(gl_panel.createSequentialGroup() 212 | .addComponent(ModifyMaxNumber_TextField) 213 | .addGap(18) 214 | .addComponent(ConfirmModify_JButton) 215 | .addPreferredGap(ComponentPlacement.UNRELATED) 216 | .addComponent(ConfirmDelete_JButton)) 217 | .addComponent(scrollPane_1, GroupLayout.DEFAULT_SIZE, 240, Short.MAX_VALUE)) 218 | .addContainerGap()) 219 | ); 220 | gl_panel.setVerticalGroup( 221 | gl_panel.createParallelGroup(Alignment.LEADING) 222 | .addGroup(gl_panel.createSequentialGroup() 223 | .addContainerGap() 224 | .addGroup(gl_panel.createParallelGroup(Alignment.BASELINE) 225 | .addComponent(lblCourseName_1) 226 | .addComponent(ModifyCourseName_TextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) 227 | .addComponent(lblMaxNumber) 228 | .addComponent(ModifyMaxNumber_TextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) 229 | .addComponent(ConfirmDelete_JButton) 230 | .addComponent(ConfirmModify_JButton)) 231 | .addGap(26) 232 | .addGroup(gl_panel.createParallelGroup(Alignment.LEADING) 233 | .addGroup(gl_panel.createParallelGroup(Alignment.BASELINE) 234 | .addComponent(lblTeacherName_1) 235 | .addComponent(lblCourseIntroduce) 236 | .addComponent(ModifyTeacherName_JComboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) 237 | .addComponent(scrollPane_1, GroupLayout.PREFERRED_SIZE, 42, GroupLayout.PREFERRED_SIZE)) 238 | .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 239 | ); 240 | 241 | ModifyCourseIntroduce_JTextArea = new JTextArea(); 242 | ModifyCourseIntroduce_JTextArea.setLineWrap(true); 243 | scrollPane_1.setViewportView(ModifyCourseIntroduce_JTextArea); 244 | panel.setLayout(gl_panel); 245 | 246 | CourseList_JTable = new JTable(); 247 | CourseList_JTable.addMouseListener(new MouseAdapter() 248 | { 249 | @Override 250 | public void mouseClicked(MouseEvent e) 251 | { 252 | /* 253 | * 254 | */ 255 | Initialize_SelectCourseTableRow(e); 256 | } 257 | }); 258 | CourseList_JTable.setModel(new DefaultTableModel( 259 | new Object[][] { 260 | }, 261 | new String[] { 262 | "Course ID", "Course name", "Teacher ID", "Teacher name", "Max number", "Selected number", "Course introduce" 263 | } 264 | ) { 265 | boolean[] columnEditables = new boolean[] { 266 | false, false, false, false, false, false, false 267 | }; 268 | public boolean isCellEditable(int row, int column) { 269 | return columnEditables[column]; 270 | } 271 | }); 272 | CourseList_JTable.getColumnModel().getColumn(0).setPreferredWidth(68); 273 | CourseList_JTable.getColumnModel().getColumn(1).setPreferredWidth(96); 274 | CourseList_JTable.getColumnModel().getColumn(2).setPreferredWidth(71); 275 | CourseList_JTable.getColumnModel().getColumn(3).setPreferredWidth(97); 276 | CourseList_JTable.getColumnModel().getColumn(4).setPreferredWidth(71); 277 | CourseList_JTable.getColumnModel().getColumn(5).setPreferredWidth(105); 278 | CourseList_JTable.getColumnModel().getColumn(6).setPreferredWidth(146); 279 | scrollPane.setViewportView(CourseList_JTable); 280 | getContentPane().setLayout(groupLayout); 281 | 282 | 283 | /* 284 | * The initialized course information is added to the user interface table and displayed. 285 | */ 286 | Initialize_CourseInfoTable(new Table_Course()); 287 | 288 | /* 289 | * Initializes the teacher name and displays it in the specified place. 290 | */ 291 | Initialize_InitializeTeacherName(); 292 | } 293 | 294 | 295 | /** 296 | * @Title Function 297 | * @Description Confirm delete the specified course information. 298 | * @param ActionEvent e 299 | * @return void 300 | * @date Jan 17, 2019-12:13:32 PM 301 | * 302 | */ 303 | public void Function_ConfirmDeleteCourseInfo(ActionEvent e) 304 | { 305 | //First step : GetSelectRow : Returns the index of the first selected row, -1 if no row is selected. 306 | int Row_index = CourseList_JTable.getSelectedRow(); 307 | if(Row_index==-1) 308 | { 309 | JOptionPane.showMessageDialog(this, "Please click on the course information you want to delete !", "Warning",JOptionPane.WARNING_MESSAGE); 310 | return; 311 | } 312 | 313 | //Second step : Prompt the user to delete course information whether the operation is successful. 314 | /* 315 | * getValueAt : Returns the cell value at row and column. (0 == Course' ID) 316 | */ 317 | if(JOptionPane.showConfirmDialog(this, "Are you sure to delete it ?")==JOptionPane.YES_OPTION)//Sensitive operation prompt. 318 | { 319 | Course_DaoImpl course_DaoImpl = new Course_DaoImpl(); 320 | if(course_DaoImpl.Delete_CourseInformation(CourseList_JTable.getValueAt(Row_index, 0).toString())) 321 | { 322 | JOptionPane.showMessageDialog(this, "Delete successfully !"); 323 | } 324 | else 325 | { 326 | JOptionPane.showMessageDialog(this, "Deletion failed !"); 327 | return; 328 | } 329 | } 330 | else 331 | { 332 | return; 333 | } 334 | //The third step : Refresh the data in the course information table. 335 | Initialize_CourseInfoTable(new Table_Course()); 336 | 337 | //Clears the data in the specified location. 338 | Function_ClearData(); 339 | } 340 | 341 | 342 | 343 | /** 344 | * @Title Function 345 | * @Description Modify the course information. 346 | * @param ActionEvent e 347 | * @return void 348 | * @date Jan 16, 2019-9:11:04 PM 349 | * 350 | */ 351 | public void Function_ModifyCourseInfo(ActionEvent e) 352 | { 353 | //Determine whether the user has clicked on the course information they want to modify. 354 | int Row_index = CourseList_JTable.getSelectedRow(); 355 | if(Row_index==-1) 356 | { 357 | JOptionPane.showMessageDialog(this, "Please click on the course information you want to update !", "Warning",JOptionPane.WARNING_MESSAGE); 358 | return; 359 | } 360 | //Get the model object for the table 361 | DefaultTableModel defaultTableModel = (DefaultTableModel) CourseList_JTable.getModel(); 362 | //Get the data of the course information clicked by the user. 363 | String courseID = defaultTableModel.getValueAt(CourseList_JTable.getSelectedRow(), 0).toString(); 364 | String courseName = defaultTableModel.getValueAt(CourseList_JTable.getSelectedRow(), 1).toString(); 365 | String maxStudentNumber = defaultTableModel.getValueAt(CourseList_JTable.getSelectedRow(), 4).toString(); 366 | String courseIntroduce = defaultTableModel.getValueAt(CourseList_JTable.getSelectedRow(), 6).toString(); 367 | //Get the data of the course information that the user wants to modify. 368 | String Update_CourseName = ModifyCourseName_TextField.getText().toString(); 369 | int Update_MaxStudentNumber = Integer.parseInt(ModifyMaxNumber_TextField.getText().toString()); 370 | String Update_CourseIntroduce = ModifyCourseIntroduce_JTextArea.getText().toString(); 371 | 372 | //Give the friendly tips to user. 373 | if(StringUtil.IsEmpty(Update_CourseName)||StringUtil.IsEmpty(Update_CourseIntroduce)) 374 | { 375 | JOptionPane.showMessageDialog(this, "Please add the course information you need to modify completely !", "Warning",JOptionPane.WARNING_MESSAGE); 376 | return; 377 | } 378 | if(courseName.equals(Update_CourseName)&&maxStudentNumber.equals(Update_MaxStudentNumber)&&courseIntroduce.equals(Update_CourseIntroduce)) 379 | { 380 | JOptionPane.showMessageDialog(this, "You did not make any changes to the course information !", "Warning", JOptionPane.WARNING_MESSAGE); 381 | return; 382 | } 383 | 384 | //Prompt the user to update course information whether the operation is successful. 385 | if(JOptionPane.showConfirmDialog(this, "Are you sure to update it ?")==JOptionPane.YES_OPTION)//Sensitive operation prompt. 386 | { 387 | //Create an object to store course information. 388 | Table_Course table_Course = new Table_Course(); 389 | table_Course.setCourse_ID(courseID);//Attention : The where conditions in the SQL statement. 390 | table_Course.setCourse_name(Update_CourseName); 391 | table_Course.setCourse_MaxStudentNumber(Update_MaxStudentNumber); 392 | table_Course.setCourse_Introduction(Update_CourseIntroduce); 393 | 394 | /* 395 | * Store teacher information. 396 | */ 397 | Table_Teacher table_Teacher_ = (Table_Teacher) ModifyTeacherName_JComboBox.getSelectedItem(); 398 | table_Course.setTeacher_ID(table_Teacher_.getTeacher_id()); 399 | table_Course.setTeacher_name(table_Teacher_.getTeacher_name()); 400 | 401 | //Prompt the user: whether the course information has been modified successfully. 402 | Course_DaoImpl course_DaoImpl = new Course_DaoImpl(); 403 | if(course_DaoImpl.Update_CourseInformation(table_Course)) 404 | { 405 | JOptionPane.showMessageDialog(this, "Update the course information successfully !"); 406 | } 407 | else 408 | { 409 | JOptionPane.showMessageDialog(this, "Fail to update the course information !"); 410 | return; 411 | } 412 | } 413 | else 414 | { 415 | return; 416 | } 417 | 418 | //Refresh the data in the course information table. 419 | Initialize_CourseInfoTable(new Table_Course()); 420 | //Clears the data in the specified location. 421 | Function_ClearData(); 422 | } 423 | 424 | 425 | 426 | /** 427 | * @Title Function 428 | * @Description Clear the data of specified position. 429 | * @param empty 430 | * @return void 431 | * @date Jan 16, 2019-9:38:39 PM 432 | * 433 | */ 434 | private void Function_ClearData() 435 | { 436 | ModifyMaxNumber_TextField.setText(""); 437 | ModifyCourseName_TextField.setText(""); 438 | ModifyCourseIntroduce_JTextArea.setText(""); 439 | ModifyTeacherName_JComboBox.setSelectedIndex(0); 440 | } 441 | 442 | /** 443 | * @Title Function 444 | * @Description Search the specified course information. 445 | * @param ActionEvene e 446 | * @return void 447 | * @date Jan 15, 2019-6:40:49 PM 448 | * 449 | */ 450 | public void Function_SearchCourse(ActionEvent e) 451 | { 452 | //Create an object that stores course information. 453 | Table_Course table_Course = new Table_Course(); 454 | 455 | //Get the course information and deposit it in the course information object. 456 | table_Course.setCourse_name(CourseName_TextField.getText().toString()); 457 | table_Course.setTeacher_name(TeacherName_JComboBox.getSelectedItem().toString()); 458 | 459 | //Refresh the data of table. 460 | Initialize_CourseInfoTable(table_Course); 461 | } 462 | 463 | 464 | 465 | /** 466 | * @Title Initialize 467 | * @Description Adds the selected course information to the pointing location. 468 | * @param MouseEvent e 469 | * @return void 470 | * @date Jan 15, 2019-6:15:47 PM 471 | * 472 | */ 473 | public void Initialize_SelectCourseTableRow(MouseEvent e) 474 | { 475 | //Get the model object for the table. 476 | DefaultTableModel defaultTableModel = (DefaultTableModel) CourseList_JTable.getModel(); 477 | 478 | /* 479 | * Initialize the course information. 480 | * getValueAt() : Returns an attribute value for the cell at row and column. 481 | */ 482 | ModifyCourseName_TextField.setText(defaultTableModel.getValueAt(CourseList_JTable.getSelectedRow(), 1).toString()); 483 | ModifyMaxNumber_TextField.setText(defaultTableModel.getValueAt(CourseList_JTable.getSelectedRow(), 4).toString()); 484 | ModifyCourseIntroduce_JTextArea.setText(defaultTableModel.getValueAt(CourseList_JTable.getSelectedRow(), 6).toString()); 485 | 486 | /* 487 | * Initialize the teacher name. So simple ! 488 | */ 489 | String teacherName = (String) defaultTableModel.getValueAt(CourseList_JTable.getSelectedRow(), 3); 490 | for(int i=0;i list = course_DaoImpl.getCourseList(table_Course); 522 | 523 | //Write the obtained class information into the course table. 524 | for (Table_Course table_Course_ : list) 525 | { 526 | Vector vector = new Vector(); 527 | 528 | vector.add(table_Course_.getCourse_ID()); 529 | vector.add(table_Course_.getCourse_name()); 530 | vector.add(table_Course_.getTeacher_ID()); 531 | vector.add(table_Course_.getTeacher_name()); 532 | vector.add(table_Course_.getCourse_MaxStudentNumber()); 533 | vector.add(table_Course_.getSelected_StudentNumber()); 534 | vector.add(table_Course_.getCourse_Introduction()); 535 | 536 | /* 537 | * This is an implementation of TableModel thatuses a Vector of Vectors to store thecell value objects. 538 | */ 539 | defaultTableModel.addRow(vector); 540 | } 541 | } 542 | 543 | 544 | 545 | /** 546 | * @Title Initialize 547 | * @Description Initialize the teacher name. 548 | * @param empty 549 | * @return void 550 | * @date Jan 15, 2019-5:25:06 PM 551 | * 552 | */ 553 | public void Initialize_InitializeTeacherName() 554 | { 555 | Teacher_DaoImpl teacher_DaoImpl = new Teacher_DaoImpl(); 556 | List list = teacher_DaoImpl.getTeacherList(new Table_Teacher()); 557 | 558 | for (Table_Teacher table_Teacher : list) 559 | { 560 | TeacherName_JComboBox.addItem(table_Teacher); 561 | ModifyTeacherName_JComboBox.addItem(table_Teacher); 562 | } 563 | } 564 | 565 | } 566 | --------------------------------------------------------------------------------