1、 《JAVA编程技术》课程设计汇报 ( / 年 第 学期) 学生姓名: 学生专业: 学生班级: 学生学号: 指导老师: 年 月 日 目录 一、需求分析................................................1 1.1本系统需要实现功效.....................................1
2、 1.2用例.....................................................1 1.3用例图...................................................2 二、系统总体设计............................................3 2.1系统模块图................................................3 2.2类 图....................................
3、4 2.3次序图....................................................5 2.4状态图....................................................6 三、 具体设计.................................................7 四、 实现......................................................7 4.1主函数.............
4、7 4.2登录......................................................8 4.3管理员界面...............................................10 4.4学生信息管理模块.........................................10 4.5课程信息管理模块.........................................15
5、 4.6选课信息管理模块.........................................19 4.7成绩信息管理模块.........................................23 4.8用户信息管理模块.........................................26 五、测试....................................................29 5.1学生信息管理系统登录.................................
6、29 5.2实现管理员和学生操作功效界面 ..........................31 六、体会.....................................................36 一、 需求分析 1.1本系统需要实现功效: (1)、管理员对学生信息和课程信息进行增加、删除、修改、查找等操作,对选课信息进行管理,对成绩信息和用户信息进行修改、查找等操作。 (2)、学生对学生信息和成绩信息进行查看,对个人密码信息进行修改等。 1.2 用例 该管理系统用例关键有: 管理员登录, 学生登录, 学
7、生信息管理, 课程信息管理, 选课信息管理, 成绩信息管理, 用户信息管理, 学生信息查看, 成绩信息查看, 个人信息查看, 退出系统。 1.3 用例图 图1.1 用例图 二、 系统总体设计: 学生信息管理系统关键包含管理员和学生两大模块。管理员模块包含:学生信息管理、课程信息管理、选课信息管理、成绩信息管理、用户信息管理等。用户模块包含:学生信息查看、成绩信息查看、个人信息管理等。系统总体结构图所表示。 2.1系统模块图 图2.1 系统模块图 2.2类图
8、 图2.2 系统类图 2.3 次序图 图2.3 系统次序图 2.4 状态图 图2.4 状态图 三、 具体设计: 图3.1 学生信息增、删、改、查询、显示功效步骤图 注:成绩信息管理,课程信息管理,选课信息管理及用户信息管理功效实现和学生信息管理功效实现一样。 四、 实现: 4.1主函数 public class SimpleStudentManager { public static void main(String[] args) { new DLFr
9、ame();} } 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("密码:"); JPasswordFiel
10、d 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
11、 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 =
12、 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.a
13、dd(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);
14、 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
15、 = 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); ad
16、d("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.
17、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.getA
18、ctionCommand() == "课程信息管理") { new CourseManage("课程信息管理").display(); } if (e.getActionCommand() == "选课信息管理") { new SCManage("选课信息管理").display(); } if (e.getActionCommand() == "成绩信息管理") { new GradeManage("成绩信息管理").display(); } if (e.getActionCommand() == "用户信息管理") { n
19、ew 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
20、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 = nu
21、ll; 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.ad
22、d(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.se
23、tJMenuBar(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);
24、 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.addActionListe
25、ner(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 * fr
26、om 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(); } player
27、Info = 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] = r
28、s.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.
29、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 =
30、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;
31、 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);
32、 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);
33、 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();
34、 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_O
35、N_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()) {// 找出表
36、中统计数赋给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 = st
37、mt.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++; }
38、 } 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 ActionListene
39、r {// 选课信息管理界面显示 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 JPan
40、el();; 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("Cen
41、ter", 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); btnS
42、earch.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 =
43、 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); btnAlt
44、er.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 displa
45、y() {// 显示全部课程信息 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"));
46、 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.ge
47、tString("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(sTa
48、ble); 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", "renji
49、e"); 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 btnSearc
50、h = 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;






