1、 JAVA 程序设计 课程设计报告课 题: 学生信息管理系统 姓 名: 学 号: 201117030234 同组姓名: 专业班级: 网络工程 11102 班 指导教师: 设计时间: 2013-6-24 评阅意见:评定成绩:指导老师签名:年 月 日目录1. 系统描述 11.1 设计目的 11.2 需求分析 .11.21 设计任务要求 .11.2 2 系统功能需求分析 21.23 界面构建 22.分析与设计 .22.1 功能模块分析 22.11 图形用户界面的设计 42.12 个人信息管理模块 102.13 选课信息管理模块 .142.14 奖励信息管理模块 172.4 测试数据和数据结果 .19
2、3.系统测试 .20运行截图 203.1 用户界面 203. 2 个人信息管理 .203. 3 选课信息管理 213. 4 奖励信息管理 214.心得体会 .225.参考文献 .236.附录 .231.系统描述1.1 设计目的本程序用于用户对少量学生信息进行简单的管理,本程序针对于对安全系数要求不高,操作不是很复杂的小型客户开发。本程序可以实现对学生信息的录入、查询、修改、删除等操作,同时支持查看所有学生信息,功能完善,界面简洁美观,布局合理,操作简便,简单易用,任何人可轻松操作。同时,本程序对系统要求配置较低,运行速度快,而却对数据库管理要求较低。本程序数据库采用 SQL server200
3、5 进行数据存储,该数据库可实现关系较为简单的数据管理。 1.2 需求分析利用计算机进行学生信息管理,不仅能够保证准确、无误、快速输出,而且还可以利用计算机对有关信息进行查询,检索迅速、查找方便、可靠性高、存储量大、保密性好。要科学地实现信息化管理,开发一个适合学校的,能够进行信息存储、查询、修改等功能的信息管理系统是十分重要的。我这次的课题就是设计与实现一个学生信息管理系统。1.21 设计任务要求该学生信息管理系统的设计要求主要有以下几点:(1)使用图形用户界面;(2)用数据库建立几个学生信息表; (3)能连接数据库并实现对学生信息查询、增、删、改等功能。1.2 2 系统功能需求分析系统主要
4、分为以下几个模块:(1) 个人信息管理(2) 选课信息管理(3) 奖励信息管理系统主要包括以下几项功能:(1)添加学生信息;(2)查询学生信息;(3)删除学生信息;(4)修改学生信息。1.23 界面构建 1、为了便于各种操作,软件采用多窗口的模式。用户可在不同窗口进行相应操作(录入、查询、修改、删除、显示所有学生信息) 。 2、主窗口是用户进行各种操作的平台,具体操作在各个独立功能窗口中完成。 3、主窗口的主要功能位于菜单中,菜单为进入各个功能窗口的唯一通道。4、当用户在进行个别录入、删除或错误输入操作时,会弹出相应对话框提示用户。5、界面布局尽量合理,各组件位置分布均匀美观。2.分析与设计2
5、.1 功能模块分析以下是学生信息管理系统功能模块关系图,主要包含查询、添加、修改、删除学生信息等功能。学生信息管理系统个人信息管理选课信息管理奖励信息管理查询,删除,修改,插入操作查询,删除,修改,插入操作查询,删除,修改,插入操作各模块分析如下:2.11 图形用户界面的设计功能:用户进入时的页面,丰富了整个系统的结构主界面窗口设计函数代码程序如下:package stumanage;import javax.swing.*;import java.awt.*;import sun.awt.image.*;import java.awt.event.*;/* Title: * Descript
6、ion: * Copyright: Copyright (c) 2003* Company: * author not attributable* version 1.0*/public class WelcomeFrameextends JFrame JPanel jPanel1 = new MyPanel();ImageIcon imageIcon1 = new ImageIcon(“beautiful.jpg“);BorderLayout borderLayout1 = new BorderLayout();JPanel jPanel2 = new JPanel();GridBagLay
7、out gridBagLayout1 = new GridBagLayout();JButton jButton1 = new JButton();JButton jButton2 = new JButton();JButton jButton3 = new JButton();JButton jButton4 = new JButton();JButton jButton5 = new JButton();public WelcomeFrame() try jbInit();catch (Exception e) e.printStackTrace();public static void
8、main(String args) WelcomeFrame welcomeFrame = new WelcomeFrame();welcomeFrame.pack();welcomeFrame.show();private void jbInit() throws Exception imageIcon1.setDescription(“beautiful.jpg“);imageIcon1.setImageObserver(this);jPanel1.setLayout(borderLayout1);jPanel1.setMinimumSize(new Dimension(600, 400)
9、;jPanel1.setPreferredSize(new Dimension(600, 420);this.setLocale(java.util.Locale.getDefault();this.setResizable(true);this.setSize(new Dimension(747, 396);this.setState(Frame.NORMAL);jPanel2.setBackground(UIManager.getColor(“RadioButtonMenuItem.selectionBackground“);jPanel2.setForeground(Color.blac
10、k);jPanel2.setMinimumSize(new Dimension(100, 30);jPanel2.setPreferredSize(new Dimension(100, 400);jPanel2.setLayout(gridBagLayout1);jButton1.setToolTipText(“ 个人信息管理“);jButton1.setText(“ 个人信息管理 “);jButton1.addActionListener(new WelcomeFrame_jButton1_actionAdapter(this);jButton2.setToolTipText(“ 选课信息管
11、理“);jButton2.setText(“ 选课信息管理 “);jButton2.addActionListener(new WelcomeFrame_jButton2_actionAdapter(this);jButton3.setToolTipText(“奖励信息管理“);jButton3.setText(“奖励信息管理 “);jButton3.addActionListener(new WelcomeFrame_jButton3_actionAdapter(this);jButton4.addActionListener(new WelcomeFrame_jButton4_action
12、Adapter(this);jButton5.setToolTipText(“退出系统“);jButton5.setText(“退出系统 “);jButton5.addActionListener(new WelcomeFrame_jButton5_actionAdapter(this);this.getContentPane().add(jPanel1, BorderLayout.CENTER);jPanel1.add(jPanel2, BorderLayout.EAST);jPanel2.add(jButton1, new GridBagConstraints(0, 0, 1, 1, 0.
13、0, 0.0,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);jPanel2.add(jButton2, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(9, 0, 0, 21), 0, 0);jPanel2.add(jButton3, new GridBagConstraints(0, 2, 1, 1, 0.0,
14、0.0,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 0, 0, 10), 0, 0);jPanel2.add(jButton5, new GridBagConstraints(0, 4, 2, 1, 0.0, 0.0,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 11), 21, 0);jPanel2.add(jButton4, new GridBagConstraints(0, 3, 1, 1, 0.0,
15、0.0,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(9, 0, 13, 0), 12, 0);class MyPanelextends JPanel public void paintComponent(Graphics g) super.paintComponent(g);imageIcon1.paintIcon(this, g, 0, 0);void jButton4_actionPerformed(ActionEvent e) MainFrame.main( null );this.hide();MainF
16、rame.jTabbedPane1.setSelectedComponent( MainFrame.jPanel4);void jButton1_actionPerformed(ActionEvent e) MainFrame.main( null );this.hide();void jButton3_actionPerformed(ActionEvent e) MainFrame.main( null );this.hide();MainFrame.jTabbedPane1.setSelectedComponent( MainFrame.jPanel3);void jButton2_act
17、ionPerformed(ActionEvent e) MainFrame.main( null );this.hide();MainFrame.jTabbedPane1.setSelectedComponent( MainFrame.jPanel2);void jButton5_actionPerformed(ActionEvent e) System.exit(0);class WelcomeFrame_jButton4_actionAdapter implements java.awt.event.ActionListener WelcomeFrame adaptee;WelcomeFr
18、ame_jButton4_actionAdapter(WelcomeFrame adaptee) this.adaptee = adaptee;public void actionPerformed(ActionEvent e) adaptee.jButton4_actionPerformed(e);class WelcomeFrame_jButton1_actionAdapter implements java.awt.event.ActionListener WelcomeFrame adaptee;WelcomeFrame_jButton1_actionAdapter(WelcomeFr
19、ame adaptee) this.adaptee = adaptee;public void actionPerformed(ActionEvent e) adaptee.jButton1_actionPerformed(e);class WelcomeFrame_jButton3_actionAdapter implements java.awt.event.ActionListener WelcomeFrame adaptee;WelcomeFrame_jButton3_actionAdapter(WelcomeFrame adaptee) this.adaptee = adaptee;
20、public void actionPerformed(ActionEvent e) adaptee.jButton3_actionPerformed(e);class WelcomeFrame_jButton2_actionAdapter implements java.awt.event.ActionListener WelcomeFrame adaptee;WelcomeFrame_jButton2_actionAdapter(WelcomeFrame adaptee) this.adaptee = adaptee;public void actionPerformed(ActionEv
21、ent e) adaptee.jButton2_actionPerformed(e);class WelcomeFrame_jButton5_actionAdapter implements java.awt.event.ActionListener WelcomeFrame adaptee;WelcomeFrame_jButton5_actionAdapter(WelcomeFrame adaptee) this.adaptee = adaptee;public void actionPerformed(ActionEvent e) adaptee.jButton5_actionPerfor
22、med(e);2.12 个人信息管理模块功能:对学生个人信息进行管理,并且具有查询,删除,修改,插入等功能。代码如下:Font f = new java.awt.Font(“SansSerif“, 0, 12);UIManager.put(“Label.font“,f);UIManager.put(“Label.foreground“,Color.black);UIManager.put(“Button.font“,f);UIManager.put(“Menu.font“,f);UIManager.put(“MenuItem.font“,f);UIManager.put(“List.font“
23、,f);UIManager.put(“CheckBox.font“,f);UIManager.put(“RadioButton.font“,f);UIManager.put(“ComboBox.font“,f);UIManager.put(“TextArea.font“,f);UIManager.put(“dbTextArea.font“,f);UIManager.put(“font“,f);MainFrame mainFrame = new MainFrame();mainFrame.setFont(new java.awt.Font(“SansSerif“, 0, 12);mainFram
24、e.pack();mainFrame.setSize(600,450);mainFrame.show();private void jbInit() throws Exception font1 = new java.awt.Font(“SansSerif“, 0, 12);this.getContentPane().setLayout(paneLayout1);jPanel1.setLayout(borderLayout1);jdbNavToolBar1.setDebugGraphicsOptions(0);jdbNavToolBar1.setAlignment(FlowLayout.CEN
25、TER);jPanel5.setLayout(borderLayout2);database1.setConnection(new com.borland.dx.sql.dataset.ConnectionDescriptor(“jdbc:microsoft:sqlserver:/localhost:1433;databaseName=student“, “sa“, “sa“, false, “com.microsoft.jdbc.sqlserver.SQLServerDriver“);database1.setDatabaseName(“);jPanel6.setFont(new java.
26、awt.Font(“SansSerif“, 0, 12);jPanel6.setMinimumSize(new Dimension(50, 100);jPanel6.setPreferredSize(new Dimension(50, 110);jPanel6.setLayout(borderLayout3);jPanel7.setFont(new java.awt.Font(“SansSerif“, 0, 12);jPanel7.setMinimumSize(new Dimension(100, 30);jPanel7.setPreferredSize(new Dimension(100,
27、40);jPanel7.setLayout(flowLayout1);jPanel8.setFont(new java.awt.Font(“SansSerif“, 0, 12);jPanel8.setMinimumSize(new Dimension(10, 10);jPanel8.setLayout(gridBagLayout2);jLabel1.setText(“学号: “);flowLayout1.setAlignment(FlowLayout.LEFT);jLabel2.setHorizontalAlignment(SwingConstants.RIGHT);jLabel2.setTe
28、xt(“姓名: “);jLabel3.setHorizontalAlignment(SwingConstants.RIGHT);jLabel3.setText(“性别: “);jLabel4.setHorizontalAlignment(SwingConstants.RIGHT);jLabel4.setText(“班级: “);jLabel5.setHorizontalAlignment(SwingConstants.RIGHT);jLabel5.setText(“生日: “);jLabel6.setHorizontalAlignment(SwingConstants.RIGHT);jLabe
29、l6.setText(“电话: “);jLabel7.setHorizontalAlignment(SwingConstants.RIGHT);jLabel7.setText(“地址: “);jButton1.setText(“修改 “);jButton1.addActionListener(new MainFrame_jButton1_actionAdapter(this);jButton2.setText(“取消 “);jdbTable1.setFont(new java.awt.Font(“SansSerif“, 0, 12);jdbTable1.setDataSet(queryData
30、Set2);jTabbedPane1.setFont(new java.awt.Font(“SansSerif“, 0, 12);jTabbedPane1.setMinimumSize(new Dimension(500, 194);jTabbedPane1.setPreferredSize(new Dimension(500, 607);queryDataSet2.setProvider(null);queryDataSet2.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, “SELECT student_
31、info.student_id,student_info.student_name,student_info.student_class,student_info.stud“ +“ent_sex,student_info.student_birthday,student_info.student_tel,student_info.student_address “ +“FROM student.dbo.student_info“, null, true, Load.ALL);column8.setCaption(“生日“);column8.setColumnName(“student_birt
32、hday“);column8.setDataType(com.borland.dx.dataset.Variant.TIMESTAMP);column8.setDisplayMask(“yyyy-MM-dd“);column8.setEditMask(“yyyy-MM-dd“);column8.setSchemaName(“dbo“);column8.setTableName(“student_info“);column8.setWidth(10);column8.setServerColumnName(“student_birthday“);column8.setSqlType(93);co
33、lumn9.setCaption(“学号“);column9.setColumnName(“student_id“);column9.setDataType(com.borland.dx.dataset.Variant.INT);column9.setEditMask(“#“);column9.setFont(new java.awt.Font(“SansSerif“, 0, 12);column9.setRowId(true);column9.setSchemaName(“dbo“);column9.setTableName(“student_info“);column9.setWidth(
34、10);column9.setServerColumnName(“student_id“);column9.setSqlType(4);column10.setCaption(“姓名“);column10.setColumnName(“student_name“);column10.setDataType(com.borland.dx.dataset.Variant.STRING);column10.setPrecision(50);column10.setSchemaName(“dbo“);column10.setTableName(“student_info“);column10.setW
35、idth(10);column10.setServerColumnName(“student_name“);column10.setSqlType(12);column11.setCaption(“班级“);column11.setColumnName(“student_class“);column11.setDataType(com.borland.dx.dataset.Variant.INT);column11.setSchemaName(“dbo“);column11.setTableName(“student_info“);column11.setWidth(10);column11.
36、setServerColumnName(“student_class“);column11.setSqlType(4);column12.setCaption(“性别“);column12.setColumnName(“student_sex“);column12.setDataType(com.borland.dx.dataset.Variant.STRING);column12.setPrecision(50);column12.setSchemaName(“dbo“);column12.setTableName(“student_info“);column12.setWidth(10);
37、column12.setServerColumnName(“student_sex“);column12.setSqlType(12);column13.setCaption(“联系电话“);column13.setColumnName(“student_tel“);column13.setDataType(com.borland.dx.dataset.Variant.STRING);column13.setPrecision(50);column13.setSchemaName(“dbo“);column13.setTableName(“student_info“);column13.set
38、Width(10);column13.setServerColumnName(“student_tel“);column13.setSqlType(12);column14.setCaption(“联系地址“);column14.setColumnName(“student_address“);column14.setDataType(com.borland.dx.dataset.Variant.STRING);column14.setPrecision(150);column14.setSchemaName(“dbo“);column14.setTableName(“student_info
39、“);column14.setWidth(14);column14.setServerColumnName(“student_address“);column14.setSqlType(12);queryDataSet2.setColumns(new Column column9, column10, column11, column12, column8, column13, column14);queryDataSet2.addNavigationListener(new MainFrame_queryDataSet2_navigationAdapter(this);jPanel1.set
40、Font(new java.awt.Font(“SansSerif“, 0, 12);jPanel1.setPreferredSize(new Dimension(472, 580);jPanel5.setFont(new java.awt.Font(“SansSerif“, 0, 12);tableScrollPane1.setFont(new java.awt.Font(“SansSerif“, 0, 12);tableScrollPane1.getViewport().setFont(new java.awt.Font(“SansSerif“, 0, 12);this.setFont(n
41、ew java.awt.Font(“SansSerif“, 0, 12);jPanel2.setFont(new java.awt.Font(“SansSerif“, 0, 12);jPanel2.setLayout(borderLayout4);jLabel8.setText(“学号: “);jLabel9.setRequestFocusEnabled(true);jLabel9.setText(“姓名 : “);jLabel10.setText(“班级: “);jLabel11.setText(“性别: “);jdbNavToolBar2.setEnabled(false);jdbNavT
42、oolBar2.setAlignment(FlowLayout.CENTER);jPanel10.setMinimumSize(new Dimension(300, 10);jPanel10.setPreferredSize(new Dimension(300, 10);jPanel10.setLayout(borderLayout5);2.13 选课信息管理模块功能:对学生选课信息进行管理,方便学生查询,具有查询,修改,删除,插入功能模块代码如下:jLabel12.setText(“学校设置可选课程信息“);jPanel11.setMinimumSize(new Dimension(200,
43、 10);jPanel11.setPreferredSize(new Dimension(200, 10);jPanel11.setLayout(borderLayout6);jLabel13.setText(“个人已选课程信息“);jButton3.setText(“选课 “);jButton3.addActionListener(new MainFrame_jButton3_actionAdapter(this);jButton4.setText(“退课 “);jButton4.addActionListener(new MainFrame_jButton4_actionAdapter(t
44、his);jPanel12.setLayout(xYLayout1);queryDataSet1.setReadOnly(false);queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, “SELECT student_coursecode.course_code,student_coursecode.course_name,student_coursecode.course_period“ +“,student_coursecode.course_credit,student_cou
45、rsecode.course_teacher,student_coursecode.course_address“ +“ FROM student.dbo.student_coursecode“, null, true, Load.ALL);column1.setCaption(“课程代号“);column1.setColumnName(“course_code“);column1.setDataType(com.borland.dx.dataset.Variant.INT);column1.setRowId(true);column1.setSchemaName(“dbo“);column1
46、.setTableName(“student_coursecode“);column1.setWidth(10);column1.setServerColumnName(“course_code“);column1.setSqlType(4);column2.setCaption(“课程名称“);column2.setColumnName(“course_name“);column2.setDataType(com.borland.dx.dataset.Variant.STRING);column2.setPrecision(50);column2.setSchemaName(“dbo“);c
47、olumn2.setTableName(“student_coursecode“);column2.setWidth(10);column2.setServerColumnName(“course_name“);column2.setSqlType(12);column3.setCaption(“课程学时“);column3.setColumnName(“course_period“);column3.setDataType(com.borland.dx.dataset.Variant.INT);column3.setSchemaName(“dbo“);column3.setTableName
48、(“student_coursecode“);column3.setWidth(10);column3.setServerColumnName(“course_period“);column3.setSqlType(4);column4.setCaption(“课程学分“);column4.setColumnName(“course_credit“);column4.setDataType(com.borland.dx.dataset.Variant.DOUBLE);column4.setSchemaName(“dbo“);column4.setTableName(“student_cours
49、ecode“);column4.setWidth(10);column4.setServerColumnName(“course_credit“);column4.setSqlType(6);column5.setCaption(“任课老师“);column5.setColumnName(“course_teacher“);column5.setDataType(com.borland.dx.dataset.Variant.STRING);column5.setPrecision(50);column5.setSchemaName(“dbo“);column5.setTableName(“student_coursecode“);column5.setWidth(10);column5.setServ