资源描述
《JAVA编程技术》课程设计汇报
( / 年 第 学期)
学生姓名:
学生专业:
学生班级:
学生学号:
指导老师:
年 月 日
目录
一、需求分析................................................1
1.1本系统需要实现功效.....................................1
1.2用例.....................................................1
1.3用例图...................................................2
二、系统总体设计............................................3
2.1系统模块图................................................3
2.2类 图.....................................................4
2.3次序图....................................................5
2.4状态图....................................................6
三、 具体设计.................................................7
四、 实现......................................................7
4.1主函数....................................................7
4.2登录......................................................8
4.3管理员界面...............................................10
4.4学生信息管理模块.........................................10
4.5课程信息管理模块.........................................15
4.6选课信息管理模块.........................................19
4.7成绩信息管理模块.........................................23
4.8用户信息管理模块.........................................26
五、测试....................................................29
5.1学生信息管理系统登录...................................29
5.2实现管理员和学生操作功效界面 ..........................31
六、体会.....................................................36
一、 需求分析
1.1本系统需要实现功效:
(1)、管理员对学生信息和课程信息进行增加、删除、修改、查找等操作,对选课信息进行管理,对成绩信息和用户信息进行修改、查找等操作。
(2)、学生对学生信息和成绩信息进行查看,对个人密码信息进行修改等。
1.2 用例
该管理系统用例关键有:
管理员登录,
学生登录,
学生信息管理,
课程信息管理,
选课信息管理,
成绩信息管理,
用户信息管理,
学生信息查看,
成绩信息查看,
个人信息查看,
退出系统。
1.3 用例图
图1.1 用例图
二、 系统总体设计:
学生信息管理系统关键包含管理员和学生两大模块。管理员模块包含:学生信息管理、课程信息管理、选课信息管理、成绩信息管理、用户信息管理等。用户模块包含:学生信息查看、成绩信息查看、个人信息管理等。系统总体结构图所表示。
2.1系统模块图
图2.1 系统模块图
2.2类图
图2.2 系统类图
2.3 次序图
图2.3 系统次序图
2.4 状态图
图2.4 状态图
三、 具体设计:
图3.1 学生信息增、删、改、查询、显示功效步骤图
注:成绩信息管理,课程信息管理,选课信息管理及用户信息管理功效实现和学生信息管理功效实现一样。
四、 实现:
4.1主函数
public class SimpleStudentManager {
public static void main(String[] args) {
new DLFrame();}
}
4.2登录
class DLFrame extends JFrame implements ActionListener, ItemListener {// 登录界面
JPanel p1 = null;
JPanel p2 = null;
JPanel p3 = null;
JLabel userName = new JLabel("用户:");
JTextField txtUser = new JTextField();//文本框控件
JLabel password = new JLabel("密码:");
JPasswordField txtPwd = new JPasswordField(6);//密码框控件
JLabel role = new JLabel("角色:");
JComboBox cbrole = new JComboBox();
JButton btnLogin = new JButton("登录");
JButton btncz = new JButton("重置");
JButton btnCancel = new JButton("取消");
JLabel imageLabel;
Icon image;
static int OK = 1;
static int CANCEL = 0;
int actionCode = 0;
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
int qxian = 0;
public DLFrame() {// 结构方法
super("登录界面");
p1 = new JPanel();
p2 = new JPanel();
p3 = new JPanel();
cbrole.addItem("管理员");
cbrole.addItem("学生");
image = new ImageIcon("picture\\st.jpg");
imageLabel = new JLabel(image);
p1.add(imageLabel);
this.setLayout(new FlowLayout());
this.setBounds(50, 50, 500, 400);
this.setVisible(true);
p2.setLayout(new GridLayout(4,3));
p2.add(userName);
p2.add(txtUser);
p2.add(password);
p2.add(txtPwd);
p2.add(role);
p2.add(cbrole);
p3.add(btnLogin);
p3.add(btncz);
p3.add(btnCancel);
this.add(p1);
this.add(p2);
this.add(p3);
this.setResizable(false);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.show();
btnLogin.addActionListener(this);
cbrole.addItemListener(this);
btncz.addActionListener(this);
btnCancel.addActionListener(this);
}
4.3管理员界面
class ManagerFrame extends JFrame implements ActionListener {// 管理员界面
JPanel p1 = new JPanel();
JPanel p2 = new JPanel();
JButton btns = new JButton("学生信息管理");
JButton btnc = new JButton("课程信息管理");
JButton btnsc = new JButton("选课信息管理");
JButton btng = new JButton("成绩信息管理");
JButton btnu = new JButton("用户信息管理");
JButton btnClose = new JButton("退出管理系统");
JLabel l = new JLabel("管理员");
ManagerFrame() {// 结构方法
super("学生信息管理系统");
setSize(350, 200);
add("North", p1);
add("Center", p2);
p1.add(l);
p2.add(btns);
p2.add(btnc);
p2.add(btnsc);
p2.add(btng);
p2.add(btnu);
p2.add(btnClose);
btns.addActionListener(this);
btnc.addActionListener(this);
btnsc.addActionListener(this);
btng.addActionListener(this);
btnu.addActionListener(this);
btnClose.addActionListener(this);
this.setResizable(false);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
show();
}
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand() == "学生信息管理")
new StudentManage().display();
if (e.getActionCommand() == "课程信息管理") {
new CourseManage("课程信息管理").display();
}
if (e.getActionCommand() == "选课信息管理") {
new SCManage("选课信息管理").display();
}
if (e.getActionCommand() == "成绩信息管理") {
new GradeManage("成绩信息管理").display();
}
if (e.getActionCommand() == "用户信息管理") {
new PM("用户信息管理").display();
}
if (e.getActionCommand() == "退出管理系统") {
System.exit(0);
}
}
}
4.4学生信息管理模块
学生信息管理模块包含增加、删除、修改、查询、显示全部等。
class StudentManage extends JFrame implements ActionListener {// 学生信息管理
JPanel p = new JPanel();
JButton btnAdd = new JButton("增加");
JButton btnDelete = new JButton("删除");
JButton btnAlter = new JButton("修改");
JButton btnSearch = new JButton("查询");
JButton btnDisplay = new JButton("显示");
JMenuBar mb = new JMenuBar();
JPanel p1 = new JPanel();;
JTable sTable;
JScrollPane scroll;
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
Object[][] playerInfo;
SSelect sst;
String mxh = null;
boolean bstd = false;
StudentManage() {// 结构方法
super("学生信息管理");
add("South", p);
this.add("Center", p1);
mb.add(btnAdd);
mb.add(btnDelete);
mb.add(btnAlter);
mb.add(btnSearch);
mb.add(btnDisplay);
this.connDB(); // 连接数据库
// this.display();
this.setBounds(200, 200, 400, 260);
btnAdd.addActionListener(this);
btnDelete.addActionListener(this);
btnAlter.addActionListener(this);
btnSearch.addActionListener(this);
btnDisplay.addActionListener(this);
this.setJMenuBar(mb);
// this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setResizable(false);
show();
}
StudentManage(SSelect sst) {// 结构方法
super("学生信息管理");
this.sst = sst;
bstd = true;
add("South", p);
this.add("Center", p1);
mb.add(btnAdd);
mb.add(btnDelete);
mb.add(btnAlter);
mb.add(btnSearch);
mb.add(btnDisplay);
this.connDB();
this.setBounds(200, 200, 400, 260);
btnAdd.addActionListener(this);
btnDelete.addActionListener(this);
btnAlter.addActionListener(this);
btnSearch.addActionListener(this);
btnDisplay.addActionListener(this);
this.setJMenuBar(mb);
// this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setResizable(false);
show();
}
public void display() {// 显示全部学生基础信息
int i = 0;
int j = 0;
int k = 0;
List al = new ArrayList();
try {
rs = stmt.executeQuery("select * from student");
while (rs.next()) { // 找出表中统计数赋给i
al.add(rs.getString("sno"));
al.add(rs.getString("sn"));
al.add(rs.getString("ss"));
al.add(rs.getInt("sa"));
al.add(rs.getString("sc"));
i++;
}
} catch (SQLException e) {
e.printStackTrace();
}
playerInfo = new Object[i][5];
String[] columnNames = { "学号", "姓名", "年纪", "性别", "班级" };
try {
rs = stmt.executeQuery("select * from student order by sno");
while (rs.next()) {
playerInfo[j][0] = rs.getString("sno");
playerInfo[j][1] = rs.getString("sn");
playerInfo[j][2] = rs.getInt("sa");
playerInfo[j][3] = rs.getString("ss");
playerInfo[j][4] = rs.getString("sc");
j++;
}
} catch (SQLException e) {
e.printStackTrace();
}
sTable = new JTable(playerInfo, columnNames);// 创建网格
p1.add(sTable);
scroll = new JScrollPane(sTable);
this.add(scroll);
}
4.5课程信息管理模块
课程信息管理模块包含增加、删除、修改、查询、显示全部等。
class CourseManage extends JFrame implements ActionListener {// 课程信息管理
JPanel p = new JPanel();
JButton btnAdd = new JButton("增加");
JButton btnDelete = new JButton("删除");
JButton btnAlter = new JButton("修改");
JButton btnSearch = new JButton("查询");
JButton btnDisplay = new JButton("显示");
JMenuBar mb = new JMenuBar();
JPanel p1 = new JPanel();;
JTable sTable;
JScrollPane scroll;
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
Object[][] playerInfo;
CourseSelect cst;
String mkch = null;
boolean bstd = false;
CourseManage(String title) {// 结构方法
super(title);
add("South", p);
this.add("Center", p1);
mb.add(btnAdd);
mb.add(btnDelete);
mb.add(btnAlter);
mb.add(btnSearch);
mb.add(btnDisplay);
this.connDB();// 连接数据库
this.setBounds(200, 200, 400, 260);
btnAdd.addActionListener(this);
btnDelete.addActionListener(this);
btnAlter.addActionListener(this);
btnSearch.addActionListener(this);
btnDisplay.addActionListener(this);
this.setJMenuBar(mb);
// this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setResizable(false);
show();
}
CourseManage(CourseSelect cst, String title) {// 结构方法
super(title);
this.cst = cst;
bstd = true;
add("South", p);
this.add("Center", p1);
mb.add(btnAdd);
mb.add(btnDelete);
mb.add(btnAlter);
mb.add(btnSearch);
mb.add(btnDisplay);
this.connDB();
this.setBounds(200, 200, 400, 260);
btnAdd.addActionListener(this);
btnDelete.addActionListener(this);
btnAlter.addActionListener(this);
btnSearch.addActionListener(this);
btnDisplay.addActionListener(this);
this.setJMenuBar(mb);
// this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setResizable(false);
show();
setVisible(false);
setVisible(true);
}
public void display() {// 显示全部课程信息
int i = 0;
int j = 0;
int k = 0;
List al = new ArrayList();
try {
rs = stmt.executeQuery("select * from course");
while (rs.next()) {// 找出表中统计数赋给i
al.add(rs.getString("cno"));
al.add(rs.getString("cn"));
al.add(rs.getString("pcno"));
i++;
}
} catch (SQLException e) {
e.printStackTrace();
}
playerInfo = new Object[i][5];
String[] columnNames = { "课程号", "课程名", "先行课程号" };
try {
rs = stmt.executeQuery("select * from course order by cno");
//rs = stmt.executeQuery("select * from course where cno=");
while (rs.next()) {
playerInfo[j][0] = rs.getString("cno");
playerInfo[j][1] = rs.getString("cn");
playerInfo[j][2] = rs.getString("pcno");
j++;
}
} catch (SQLException e) {
e.printStackTrace();
}
sTable = new JTable(playerInfo, columnNames);// 创建网格
p1.add(sTable);
scroll = new JScrollPane(sTable);
this.add(scroll);
}
4.6选课信息管理模块
选课信息管理模块包含增加、删除、修改、查询、显示全部等。
class SCManageFrame extends JFrame implements ActionListener {// 选课信息管理界面显示
JPanel p = new JPanel();
JButton btnAdd = new JButton("增加");
JButton btnDelete = new JButton("删除");
JButton btnAlter = new JButton("修改");
JButton btnSearch = new JButton("查询");
JButton btnDisplay = new JButton("显示");
JMenuBar mb = new JMenuBar();
JPanel p1 = new JPanel();;
JTable sTable;
JScrollPane scroll;
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
Object[][] playerInfo;
SCSelect cst;
String mkch = null;
boolean bstd = false;
SCManageFrame(String title) {// 结构方法
super(title);
add("South", p);
this.add("Center", p1);
mb.add(btnAdd);
mb.add(btnDelete);
mb.add(btnAlter);
mb.add(btnSearch);
mb.add(btnDisplay);
this.connDB();// 连接数据库
this.setBounds(200, 200, 400, 260);
btnAdd.addActionListener(this);
btnDelete.addActionListener(this);
btnAlter.addActionListener(this);
btnSearch.addActionListener(this);
btnDisplay.addActionListener(this);
this.setJMenuBar(mb);
// this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setResizable(false);
show();
}
SCManageFrame(SCSelect cst, String title) {// 结构方法
super(title);
this.cst = cst;
bstd = true;
add("South", p);
this.add("Center", p1);
mb.add(btnAdd);
mb.add(btnDelete);
mb.add(btnAlter);
mb.add(btnSearch);
mb.add(btnDisplay);
this.connDB();
this.setBounds(200, 200, 400, 260);
btnAdd.addActionListener(this);
btnDelete.addActionListener(this);
btnAlter.addActionListener(this);
btnSearch.addActionListener(this);
btnDisplay.addActionListener(this);
this.setJMenuBar(mb);
// this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setResizable(false);
show();
setVisible(false);
setVisible(true);
}
public void display() {// 显示全部课程信息
int i = 0;
int j = 0;
int k = 0;
List al = new ArrayList();
try {
rs = stmt.executeQuery("select * from class");
while (rs.next()) {// 找出表中统计数赋给i
al.add(rs.getString("classNum"));
al.add(rs.getString("cno"));
al.add(rs.getString("pcno"));
i++;
}
} catch (SQLException e) {
e.printStackTrace();
}
playerInfo = new Object[i][3];
String[] columnNames = { "班级号", "课程名", "先行课程号" };
try {
rs = stmt.executeQuery("select * from class order by classNum");
while (rs.next()) {
playerInfo[j][0] = rs.getString("classNum");
playerInfo[j][1] = rs.getString("cno");
playerInfo[j][2] = rs.getString("pcno");
j++;
}
} catch (SQLException e) {
e.printStackTrace();
}
sTable = new JTable(playerInfo, columnNames);// 创建网格
p1.add(sTable);
scroll = new JScrollPane(sTable);
this.add(scroll);
}
public void connDB() { // 连接数据库
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
try {
con = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/test",
"root", "renjie");
stmt = con.createStatement();
} catch (SQLException e) {
e.printStackTrace();
}
}
4.7成绩信息管理模块
成绩信息管理模块包含修改成绩、查询、显示全部等。
class GradeManage extends JFrame implements ActionListener {// 成绩信息管理
JPanel p = new JPanel();
JButton btnAlter = new JButton("修改成绩");
JButton btnSearch = new JButton("查询");
JButton btnDisplay = new JButton("显示");
JMenuBar mb = new JMenuBar();
JPanel p1 = new JPanel();;
JTable sTable;
JScrollPane scroll;
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
Object[][] playerInfo;
GradeSelectFrame gst;
int ii = 0;
展开阅读全文