资源描述
学
生
信
息
管
理
系
统
23
《Java程序设计》结课报告
目录
第1章学生信息管理系统简介3
1。1 系统功能3
1.2 系统引用例子3
第2章表的设计4
2。1 系统数据库表结构:4
第3章连接数据库的实现5
第4章系统详细设计6
4。1系统登录模块设计6
4.2系统主界面详细设计10
4.2.1管理员操作模块10
4。2。2 教师操作模块12
4。2.3 学生操作模块14
第5章系统运行与测试16
5.1管理员登录16
5.2 教师登录17
5。3学生登录22
答辩记录31
成绩考核表31
《Java程序设计》结课报告
学生信息管理系统
第1章 学生信息管理系统简介
1.1 系统功能
本系统主要功能:
1. 用户登陆界面。该界面可以选择使用者的身份,“管理员,教师,学生”。不同的身份有不同的操作界面和功能权限.ID号和密码输入正确即可登录。学生管理界面.提供了学生学籍信息的查询,相关科目的成绩查询和排名,修改登录密码等功能.
2. 教师管理界面。提供了对学生学籍信息的查询,添加,修改,删除;学生成绩的录入,修改,删除,查询班级排名.修改密码等功能。
3. 管理员管理界面。拥有最高的权限。允许添加教师信息和课程信息等.
4. 登录的用户信息分别存储在SQL数据库的“管理员信息表”, “教师信息表”, “学籍信息表"中,如果用户信息不存在则三张表中,将会无权利登录本管理系统.
保证了本学生管理系统的安全性.
1。2 系统引用例子
课本P228页 13。03
课本P231页 13.05
课本P247页 13。17
课本P249页 13.22
课本P370页 20.11
第2章 表的设计
2。1 系统数据库表结构:
教师信息表:
字段名
类型
空值
约束条件
教师ID
varchar(8)
not null
主键
教师姓名
varchar(8)
not null
登录密码
varchar(8)
not null
课程信息表:
字段名
类型
空值
约束条件
课程号
varchar(8)
not null
主键
课程名称
varchar(12)
not null
教师ID
varchar(8)
not null
外键
班级信息表:
字段名
类型
空值
约束条件
班级号
varchar(8)
not null
主键
班级名称
varchar(8)
not null
班级人数
nchar(4)
管理员信息表:
字段名
类型
空值
约束条件
管理员ID
varchar(10)
not null
主键
登录密码
varchar(10)
not null
成绩信息表:
字段名
类型
空值
约束条件
学号
varchar(15)
not null
主键,外键
课程号
varchar(8)
not null
主键,外键
成绩
smallint
not null
学籍信息表:
字段名
类型
空值
约束条件
学号
int
not null
主键
姓名
varchar(30)
not null
性别
char(2)
班级号
varchar(30)
not null
外键
籍贯
char(10)
登录密码
money
not null
第3章 连接数据库的实现
Mysql连接数据库的关键代码:
publicclass DbOperation {
//打开连接
publicstatic Connection getConnection() {
Connection con = null;
try {
Class。forName("com。mysql。jdbc。Driver”);
String url = ”jdbc:mysql://127。0。0。1:3306/member”;
String user = "root"; // 定义连接数据库的用户名
String passWord = ”raoyang”; // 定义连接数据库的密码
con = DriverManager。getConnection(url, user, passWord);
} catch (Exception e) {
e.printStackTrace();
}
return con;
}
//关闭连接
publicstaticvoid closeConnection(Connection con) {
if (con != null)
try {
con.close();
} catch (SQLException e) {
e。printStackTrace();
}
}}
第4章 系统详细设计
4。1系统登录模块设计
1)运行结果:
2)实验代码:
//登录界面
import java。awt.Container;
import java。awt.event.*;
import java。sql。*;
import javax.swing.*;
publicclass Login extends JFrame implements ActionListener{
privatestaticfinallongserialVersionUID = 1L;
JFrame mm=new JFrame(”您好!请您先登录!");
JTextField t2=new JTextField(null,15);
JTextField t4=new JPasswordField(null,15);
public String zh=null;
JRadioButton b=new JRadioButton("教师");
JRadioButton b1=new JRadioButton(”学生");
JRadioButton b2=new JRadioButton("管理员”);
static Connection con;
static PreparedStatement sql;
static ResultSet res;
publicvoid jiemian(){
mm.setSize(300,340);
mm。setVisible(true);
mm。setLocation(200,300);
JLabel t1=new JLabel(”ID号:”);
JLabel t3=new JLabel(”密码:”);
JButton denglu2=new JButton(”登录");
denglu2。setContentAreaFilled(false);
Container n=mm。getContentPane();
n.setLayout(null);
t1。setBounds(40,100,75,35);
t2。setBounds(80,100,150,35);
t3.setBounds(40,150,75,35);
t4.setBounds(80,150,150,35);
denglu2。setBounds(120,210,70,30);
n。add(t1);n。add(t2); n.add(t3); n。add(t4); n。add(denglu2);
b。setBounds(120,50,60,30);
b1。setBounds(60,50,80,30);
b2。setBounds(180,50,80,30);
ButtonGroup rg=new ButtonGroup();
b.setSelected(false);
b1.setSelected(false);
b1。setSelected(false);
n。add(b);n。add(b1); n。add(b2); rg.add(b); rg.add(b1);rg。add(b2);
b。setContentAreaFilled(false);
b1.setContentAreaFilled(false);
b2.setContentAreaFilled(false);
denglu2。addActionListener(this);
denglu2.addActionListener(new ActionListener() {
publicvoid actionPerformed(ActionEvent arg0) {
JButton denglu2=(JButton)arg0。getSource();
boolean flag = true;
if(arg0。getSource()==denglu2)
{
if(b1。isSelected()) {
Login app=new Login();
app.Login();
con=app.getConnection();
try {
Class.forName(”com。mysql.jdbc.Driver”); String url = ”jdbc:mysql://127.0。0。1:3306/课设"; String user = ”root”; String passWord = ”raoyang”; con = DriverManager。getConnection(url, user, passWord); // 连接连接
} catch (Exception e) {
e。printStackTrace();
}
String id = t2.getText().toString();
String mm = t4。getText()。toString();
try { Statement sql = con。createStatement();
ResultSet res = sql。executeQuery("select * from 学籍”);
while(res.next())
{if((res.getString(”学号”)。equals(id))&&(res。getString(”登入密码”).equals(mm)))
{ JOptionPane。showMessageDialog(null,"登陆成功”);
flag = false;
new xscaozuo();
}}
if(flag)
{JOptionPane.showMessageDialog(null,”登录失败”);}
res.close();
}catch (SQLException e) {
e。printStackTrace();
}}
elseif (b。isSelected()) {
try {
Class。forName(”com。mysql.jdbc.Driver”); String url = "jdbc:mysql://127.0。0.1:3306/课设”;
String user = "root”; String passWord = ”raoyang”; con = DriverManager。getConnection(url, user, passWord); // 连接连接
} catch (Exception e) {
e.printStackTrace();
}
String id = t2.getText().toString();
String mm = t4。getText().toString();
try {
Statement sql = con.createStatement();
ResultSet res = sql.executeQuery("select * from 教师”);
while(res.next())
{
if((res。getString("教师ID”)。equals(id))&&(res.getString(”登入密码”).equals(mm)))
{ JOptionPane。showMessageDialog(null,”登陆成功");
flag = false;
new jscaozuo();
} }
if(flag)
{JOptionPane。showMessageDialog(null,”登录失败");}
res。close();
}catch (SQLException e) {
e。printStackTrace();
}
}elseif (b2.isSelected()) {
con = null;
try {
Class。forName(”com。mysql。jdbc。Driver”); String url = ”jdbc:mysql://127。0.0.1:3306/课设";
String user = ”root”; String passWord = ”raoyang"; con = DriverManager.getConnection(url, user, passWord); // 连接连接
} catch (Exception e) {
e。printStackTrace();
}
String id = t2.getText().toString();
String mm = t4。getText()。toString();
try {
Statement sql = con。createStatement();
ResultSet res = sql.executeQuery(”select * from 管理员");
while(res.next())
{
if((res。getString(”管理员ID”)。equals(id))&&(res。getString("登入密码”)。equals(mm)))
{
JOptionPane。showMessageDialog(null,”登陆成功”);
flag = false;
new guanliyuancaozuo();
}
}
if(flag)
{
JOptionPane。showMessageDialog(null,”登录失败");
}
res.close();
}catch (SQLException e) {
e。printStackTrace();
}
}}}});
}
public Connection getConnection() {
returnnull;
}
publicvoid actionPerformed(ActionEvent e) {
t2.setText(null);
t4.setText(null);
}
publicstaticvoid main(String args[]){
Login app=new Login();
app.jiemian();
}
4.2 系统主界面详细设计
4.2.1 管理员操作模块
1) 运行结果:
2)实验代码:
//学生操作界面
import java.awt.*;
import java。awt。event.*;
import javax。swing.*;
publicclassguanliyuancaozuoextends JFrame implements ActionListener{
public guanliyuancaozuo(){
setTitle(”管理员操作");
setLayout(null);
JButton b1=new JButton(”添加教师信息");b1。setBounds(30,20,140,30);
JButton b2=new JButton(”修改教师信息”);b2。setBounds(30,70,140,30);
JButton b3=new JButton(”删除教师信息");b3.setBounds(30,120,140,30);
JButton b4=new JButton("查询教师信息");b4.setBounds(30,170,140,30);
JButton b5=new JButton(”教师管理界面”);b5。setBounds(30,220,140,30);
JButton b6=new JButton(”重新登录");b6。setBounds(30,270,140,30);
Container c=getContentPane();
c.add(b1); c.add(b2); c.add(b3); c。add(b4); c。add(b5); c.add(b6);
setSize(220,360);
setLocation(100,300);
setVisible(true);
b1.addActionListener(this);
b1。addActionListener(new ActionListener(){
publicvoid actionPerformed(ActionEvent arg0) {
new tianjiajiaoshi();
}
});
b2。addActionListener(this);
b2。addActionListener(new ActionListener(){
publicvoid actionPerformed(ActionEvent arg0) {
new xiugaijiaoshi();
}
});
b3。addActionListener(this);
b3。addActionListener(new ActionListener(){
publicvoid actionPerformed(ActionEvent arg0) {
new shanchujiaoshi();
}
});
b4。addActionListener(this);
b4。addActionListener(new ActionListener(){
publicvoid actionPerformed(ActionEvent arg0) {
new chaxunjiaoshi();
}
});
b5。addActionListener(this);
b5。addActionListener(new ActionListener(){
publicvoid actionPerformed(ActionEvent arg0) {
new jscaozuo();
}
});
b6.addActionListener(this);
b6。addActionListener(new ActionListener(){
publicvoid actionPerformed(ActionEvent arg0) {
Login app=new Login();
app。jiemian();
}
});
}
4。2。2教师操作模块
1) 运行结果:
2)实验代码:
//教师操作界面
import java。awt.*;
import java。awt。event.*;
import javax.swing。*;
publicclass jscaozuo extends JFrame implements ActionListener{
privatestaticfinallongserialVersionUID = 5328938865248326479L;
public jscaozuo(){
setTitle("教师操作");
setLayout(null);
JLabel aaa=new JLabel(”学生信息管理:”);
JLabel aaa1=new JLabel(”学生成绩管理:”);
JButton b1=new JButton(”显示学生信息");b1。setBounds(40,45,140,30);
JButton b2=new JButton(”添加学生信息”);b2.setBounds(200,45,140,30);
JButton b3=new JButton(”修改学生信息");b3。setBounds(40,90,140,30);
JButton b4=new JButton(”删除学生信息");b4.setBounds(200,90,140,30);
JButton b5=new JButton(”录入学生成绩”);b5。setBounds(40,170,140,30);
JButton b6=new JButton("修改学生成绩”);b6.setBounds(200,170,140,30);
JButton b7=new JButton(”删除学生成绩”);b7。setBounds(40,215,140,30);
JButton b8=new JButton("查询学生成绩");b8。setBounds(200,215,140,30);
JButton b10=new JButton("退出系统”);b10。setBounds(40,285,90,30);
JButton b11=new JButton(”修改密码”);b11。setBounds(150,285,90,30);
JButton back=new JButton("重新登录”);back.setBounds(260,285,90,30);
aaa。setBounds(15,15,90,30); aaa1。setBounds(15,140,90,30);
Container c=getContentPane();
c。add(b1); c。add(b2); c.add(b3); c。add(b4); c。add(b5); c。add(b6);
c。add(b7); c。add(b8); c。add(b10); c。add(b11); c。add(back);
c。add(aaa);c。add(aaa1);
setSize(400,420);
setLocation(200,300);
setVisible(true);
back.addActionListener(this);
back。addActionListener(new ActionListener(){
publicvoid actionPerformed(ActionEvent arg0) {
Login app=new Login();
app.jiemian();
}});
b1.addActionListener(this);
b1.addActionListener(new ActionListener(){
publicvoid actionPerformed(ActionEvent arg0) {
new chaxunxs();
} });
b2。addActionListener(this);
b2。addActionListener(new ActionListener(){
publicvoid actionPerformed(ActionEvent arg0) {
new tianjiaxuesheng();
} });
b3。addActionListener(this);
b3。addActionListener(new ActionListener(){
publicvoid actionPerformed(ActionEvent arg0) {
new xiugaixuesheng();
}});
b4。addActionListener(this);
b4.addActionListener(new ActionListener(){
publicvoid actionPerformed(ActionEvent arg0) {
new shanchuxuesheng();
} });
b5。addActionListener(this);
b5。addActionListener(new ActionListener(){
publicvoid actionPerformed(ActionEvent arg0) {
new dengruxschengji();
} });
b6。addActionListener(this);
b6。addActionListener(new ActionListener(){
publicvoid actionPerformed(ActionEvent arg0) {
new xiugaixschengji();
} });
b7。addActionListener(this);
b7。addActionListener(new ActionListener(){
publicvoid actionPerformed(ActionEvent arg0) {
new shanchuxschengji();
} });
b8.addActionListener(this);
b8。addActionListener(new ActionListener(){
publicvoid actionPerformed(ActionEvent arg0) {
new chaxunxschengji();
} });
b11。addActionListener(this);
b11.addActionListener(new ActionListener(){
publicvoid actionPerformed(ActionEvent arg0) {
new xiugaijiaoshimima();
} });
b10。addActionListener(this);
b10.addActionListener(new ActionListener(){
publicvoid actionPerformed(ActionEvent arg0) {
System.exit(0);
}});
}
4。2。3学生操作模块
1)运行结果:
2)实验代码:
//学生操作界面
import java。awt.*;
import java。awt.event。*;
import javax.swing.*;
publicclassxscaozuoextends JFrame implements ActionListener{
public xscaozuo(){
setTitle(”学生操作”);
setLayout(null);
JButton b1=new JButton("显示学生信息");b1.setBounds(30,20,140,30);
JButton b2=new JButton(”查询学生成”);b2.setBounds(30,70,140,30);
JButton b3=new JButton("修改密码”);b3。setBounds(30,120,140,30);
JButton b4=new JButton("重新登录");b4。setBounds(30,170,140,30);
Container c=getContentPane();
c.add(b1); c.add(b2); c。add(b3); c。add(b4);
setSize(220,260);
setLocation(100,300);
setVisible(true);
b1。addActionListener(this);
b1.addActionListener(new ActionListener(){
publicvoid actionPerformed(ActionEvent arg0) {
new chaxunxs();
}});
b2.addActionListener(this);
b2。addActionListener(new ActionListener(){
publicvoid actionPerformed(ActionEvent arg0) {
new chaxunxschengji();
}});
b3.addActionListener(this);
b3.addActionListener(new ActionListener(){
publicvoid actionPerformed(ActionEvent arg0) {
new xiugaixueshengmima();
}});
b4.addActionListener(this);
b4。addActionListener(new ActionListener(){
publicvoid actionPerformed(ActionEvent arg0) {
Login app=new Login();
app.jiemian();
}});
}
第5章 系统运行与测试
5.1管理员登录
点击“管理员”按钮.输入正确的ID和密码。验证成功则可进入管理员管理界面.管理员ID号和登录密码存在数据库中的管理员信息表。表中存在的管理员才允许登录。
(1)添加教师信息。在弹出的输入栏中输入正确的数据.
(2)修改教师信息
(3)删除信息修改
(4)查询教师信息
(5)教师管理界面
同下面的教师操作界面
5.2 教师登录
在登录界面选择“教师”按钮,并输入正确的ID号和密码,即可登录成功!
输入错误则会弹出提示!
ID号输入正确,登录成功!进入教师管理的操作界面:
(1)显示学生信息
(2)添加学生信息
(3)修改学生信息,输入正确则显示!
(4) 删除学生信息
(5) 录入学生成绩
(6) 修改学生成绩
(7) 删除学生成绩
(8)查询学生成绩
(9)更改登录密码
5。3 学生登录
(1)查询个人成绩
(2)查询学生成绩
(3)修改密码
部分实验代码:
//添加老师信息:
publicclass tianjiajiaoshi extends JFrame implements ActionListener{
privatestaticfinallongserialVersionUID = 1L;
JFrame mm=new JFrame(”添加教师信息”);
JTextField t2=new JTextField(null,30);
JTextField t4=new JTextField(null,30);
JTextField t6=new JTextField(null,30);
JTextField t8=new JTextField(null,30);
JTextField t10=new JTextField(null,30);
static Connection con;
static PreparedStatement sql;
static ResultSet res;
public Connection getConnection(){
/********省略数据库连接的代码************/
return con;
}
privatevoidtianjiajiaoshi(){
mm。setSize(250,300);
mm.setVisible(true);
mm。setLocation(200,300);
JLabel t1=new JLabel(”请输入教师ID:”);
JLabel t3=new JLabel("请输入教师姓名:”);
JLabel t5=new JLabel(”请输入教师的登录密码:”);
JButton querenxiugai=new JButton(”确认添加”);
querenxiugai。setContentAreaFilled(false);
Container n=mm。getContentPane();
n.setLayout(null);
t1.setBounds(50,10,150,30);
t2。setBounds(50,40,150,30);
t3。setBounds(50,70,150,30);
t4.setBounds(50,100,150,30);
t5。setBounds(50,130,150,30);
t6。setBounds(50,160,150,30);
querenxiugai.setBounds(8
展开阅读全文