拨开荷叶行,寻梦已然成。仙女莲花里,翩翩白鹭情。
IMG-LOGO
主页 文章列表 Java+Eclipse+MySQL+Swing实作学生会考成绩管理系统(免费完整项目)

Java+Eclipse+MySQL+Swing实作学生会考成绩管理系统(免费完整项目)

白鹭 - 2022-03-01 1978 0 0

 

目录

一、需求开发档案

二、数据库设计档案

三、功能模块部分代码及效果展示

四、完整原始码下载

五、作者Info

 

一、需求开发档案

项目完整档案串列:

 

需求开发档案部分截图:

 

 

 

 

 

 

 

 

 


 

二、数据库设计档案

数据库设计档案部分截图:

 

 

 

 


 

三、功能模块部分代码及效果展示

数据库类:

 1 package system_of_database;
 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 public class DBUtil {
10 
11     Connection con = null;
12     PreparedStatement ps = null;
13     ResultSet rs = null;
14 
15     public Connection getConnection() throws ClassNotFoundException,
16             SQLException,InstantiationException,IllegalAccessException {
17         String driver = "com.mysql.jdbc.Driver";
18         String url = "jdbc:mysql://localhost:3306/exam_of_students?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8&useSSL=false";
19         String user = "root";
20         String password = "root";
21         try {
22             Class.forName(driver);
23             con = DriverManager.getConnection(url,user,password);
24             return con;
25         } catch(Exception e) {
26             throw new SQLException("驱动错误或连接失败!");
27         }
28     }

 

考生登录部分代码如下:

 1 public class LoginListener implements ActionListener{
 2         public void actionPerformed(ActionEvent e) {
 3             lblMsg1.setText("");
 4             lblMsg2.setText("");
 5             user = userService.findUserByName(txtName.getText().trim());
 6             if(user != null) {
 7                 if(user.getPassword().equals(new String(txtPwd.getPassword()))) {
 8                     LoginFrame_Of_Students.this.setVisible(false);
 9                     new MainFrame_Of_Students();
10                 } else {
11                     lblMsg2.setText("密码错误!");
12                     txtPwd.setText("");
13                 }
14             } else {
15                 lblMsg1.setText("该考生不存在 !");
16             }
17         }
18     }

 

考生登录效果如下:

 

管理员登录部分代码如下:

 1 public class LoginListener implements ActionListener{
 2         public void actionPerformed(ActionEvent e) {
 3             lblMsg1.setText("");
 4             lblMsg2.setText("");
 5             user = userService.findUserByName(txtName.getText().trim());
 6             if(user != null) {
 7                 if(user.getPassword().equals(new String(txtPwd.getPassword()))) {
 8                     LoginFrame_Of_Administration.this.setVisible(false);
 9                     new MainFrame_Of_Administration();
10                 } else {
11                     lblMsg2.setText("密码错误!");
12                     txtPwd.setText("");
13                 }
14             } else {
15                 lblMsg1.setText("该管理员不存在 !");
16             }
17         }
18     }
19 
20     public class ResetListener implements ActionListener{
21         public void actionPerformed(ActionEvent e) {
22             txtName.setText("");
23             txtPwd.setText("");
24         }
25     }

 

管理员登录效果如下:

 

考生查询成绩部分代码如下:

 1 private void showData() {
 2         String id = txtId.getText();
 3         String sql = "select id as 考生号,geography as 地理,chemistry as 化学,IT as 信息技术,History as 历史 ,Biology as 生物,mathematics as 数学,general_technique as 通用技术,physics as 物理,english as 英语,chinese as 语文,politics as 政治  from information_of_grade where id = '"+id+"'";
 4         DBUtil db = new DBUtil();
 5         try {
 6             db.getConnection();
 7             ResultSet rs = db.executeQuery(sql, null);
 8             ResultSetMetaData rsmd = rs.getMetaData();
 9             int colCount = rsmd.getColumnCount();
10             Vector<String> title = new Vector<String>();  //存放标题
11             for(int i = 1;i<=colCount;i++) {
12                 title.add(rsmd.getColumnLabel(i));
13             }
14             Vector<Vector<String>> data = https://www.cnblogs.com/makerchen/archive/2022/01/02/new Vector<Vector<String>>();    //存放表格资料
15             int rowCount = 0;
16             while(rs.next()) {
17                 rowCount++;
18                 Vector<String> rowdata = https://www.cnblogs.com/makerchen/archive/2022/01/02/new Vector<String>();         //存放行资料
19                 for(int i = 1;i<=colCount;i++) {
20                     rowdata.add(rs.getString(i));
21                 }
22                 data.add(rowdata);
23             }
24             if(rowCount == 0) {
25                 model.setDataVector(null, title);
26             } else {
27                 model.setDataVector(data,title);
28             }
29         } catch(Exception ee) {
30             System.out.println(ee.toString());
31             JOptionPane.showMessageDialog(this, "系统出现例外错误,请检查数据库,系统即将推出!!!","错误",0);
32         } finally {
33             db.closeAll();
34         }
35         JOptionPane.showMessageDialog(null, "查询到该考生信息");
36     }

 

考生查询成绩效果如下:

 

考生成绩汇出部分代码如下:

 1 public void saveFile() {
 2         JFileChooser fc = new JFileChooser();
 3         int rVal = fc.showSaveDialog(this);
 4         if(rVal == JFileChooser.APPROVE_OPTION) {
 5             String fileName = fc.getSelectedFile().getName();
 6             String path = fc.getCurrentDirectory().toString();
 7             try {
 8                 TableModel model = table.getModel(); 
 9                 FileWriter fw = new FileWriter(path + "/" + fileName);
10                 for(int i=0; i < model.getColumnCount(); i++) { 
11                     fw.write(model.getColumnName(i) + "\t"); 
12                 } 
13                 fw.write("\n"); 
14                 for(int i=0; i< model.getRowCount(); i++) { 
15                     for(int j=0; j < model.getColumnCount(); j++) { 
16                         fw.write(model.getValueAt(i,j).toString()+"\t"); 
17                     } 
18                     fw.write("\n");
19                 } 
20                 fw.close();
21             } catch(Exception e) {
22                 e.printStackTrace();
23             }
24             JOptionPane.showMessageDialog(null, "汇出成功");
25         }
26     }

 

考生成绩汇出效果如下:

 

考生修改密码部分代码如下:

 1 public class listener_of_delete implements ActionListener{
 2            public void actionPerformed(ActionEvent e){
 3                String id = jtId.getText();
 4                String code = new String(jpCode.getPassword());
 5                String code1 = new String(jpCode1.getPassword());
 6                DBUtil db = new DBUtil();
 7                String sql = "update information_of_students set pwd = '"+code+"' where id = '"+id+"
								
							
标签:

0 评论

发表评论

您的电子邮件地址不会被公开。 必填的字段已做标记 *