【课程设计报告】基于JAVA和MySql数据库的CS架构学生成绩管理系统的设计与实现

上传人:仙*** 文档编号:29871459 上传时间:2021-10-08 格式:DOC 页数:26 大小:297KB
返回 下载 相关 举报
【课程设计报告】基于JAVA和MySql数据库的CS架构学生成绩管理系统的设计与实现_第1页
第1页 / 共26页
【课程设计报告】基于JAVA和MySql数据库的CS架构学生成绩管理系统的设计与实现_第2页
第2页 / 共26页
【课程设计报告】基于JAVA和MySql数据库的CS架构学生成绩管理系统的设计与实现_第3页
第3页 / 共26页
点击查看更多>>
资源描述
更多计算机类课程设计、毕业设计、论文请访问:上海理工大学计算机学院可视化程序设计报告(2010 2011 年度第2学期)题 目 学生成绩管理系统 院 系 专 业 电子商务 年 级 2009级 学 号 姓 名 指 导 教 师 成 绩 _2011 年 03月 09日 目 录一、课程设计的目的与要求2二、 设计的正文 21.系统分析21.1系统开发背景等 21.2业务流程分析 21.3数据流程图 32.系统设计 3 2.1功能设计 3 2.2系统运行环境与数据库设计 4 2.3输入/输出设计43.系统实施4 3.1登录与退出界面 4 3.2 修改密码10 3.3成绩查询153.4 相关数据库表24三、课程设计总结25四、参考文献26 学生成绩查询系统一、课程设计的目的与要求通过面向对象程序设计课程设计,进一步掌握面向对象程序设计的理论和方法。培养和锻炼开发小型学生成绩查询系统的能力。为今后相关系统开发打下良好的基础。要求了学生成绩查询系统开发的全过程,理解面向对象程序设计课程相关的概念,掌握面向对象程序设计的开发方法,巩固对Java相关方法和概论的理解。主要包括:系统调研方法;业务分析、数据分析、系统逻辑模型设计方法;数据库设计、功能设计、物理模型设计方法;系统的实现等方法。完成一个小型系统的设计与开发。二、设计正文1 系统分析1.1系统开发背景、开发范围、建设目标与必要性随着国家对于教育的重视逐渐加大,学校正向着大型化、规模化发展,而对于大中型学校,跟学生信息管理有关的信息随之急剧增加。在这种情况下单靠人工来处理员工的工资不但显得力不从心,而且极容易出错。该系统就是设计一个学生信息数据库管理系统,由计算机代替人工执行一系列诸如增加新学生,删除旧学生,学生信息修改,查询,维护及打印等操作。这样就使学生部门管理人员可以轻松快捷地完成学生信息管理的任务。1本课题的研究意义当今时代是飞速发展的信息时代。在各行各业中离不开信息处理,这正是计算机被广泛应用于信息管理系统的环境。计算机的最大好处在于利用它能够进行信息管理。使用计算机进行信息控制,不仅提高了工作效率,而且大大的提高了其安全性。尤其对于复杂的信息管理,计算机能够充分发挥它的优越性。2本课题的研究现状管理查询信息系统是进行信息的采集、存储、查询、加工、维护和使用的系统。它是随着管理科学和技术科学的发展而形成的。学生成绩管理查询系统是一个教育单位不可缺少的部分,它的内容对于学校的决策者和管理者和学生来说都至关重要,所以学生成绩管理查询系统应该能够为用户提供充足的信息和快捷的查询手段,但一直以来人们使用传统人工的方式管理文件档案,这种管理方式存在着许多缺点,如:效率低、保密性差;另外时间一长,将产生大量的文件和数据,这对于查找、更新和维护都带来了不少的困难。1.2业务流程分析主要业务流程图,如下图所示 1.3数据流程图 2 系统设计2.1功能设计学生信息管理系统主要提供方便高效的查询功能,学生可以通过该系统查询相关信息。对于本系统,我们需要实现以下一些基本功能:1)密码管理功能该模块实现对用户密码进行管理的功能,主要是进行密码的修改。为了防止个人的名片信息被泄露,不知道用户密码的人员不能进入本系统。出于安全的考虑,用户可以定期修改自己的密码,以防止密码被盗用。2)成绩管理功能该模块实现成绩查询功能。用户在查询学生成绩时,有时需要了解学生的基本信息,因此希望在查询出的内容中包括学生基本情况和成绩信息。有时用户需要查询学生的某些课程成绩,因此应该具有查询课程成绩的功能。有时需要查询学生的学期总成绩,因此也应该具有该功能。3)退出系统完成了对学生成绩的查询的操作后,应该可以安全地离开该系统。通过该模块实现安全退出大学生成绩查询系统。2.2系统运行环境与数据库设计鉴于本系统的业务性质,必须选择具有较高的可靠性、稳定性和必要的容错能力的计算机硬件和软件系统,以保证任何情况下都不至于丢失、损坏数据;必须具有较高的响应速度,以保证各项具体业务的顺利进行;应考虑具有良好的可维护性,可操作性和可扩充性,以保证将来系统规模的扩展和升级的需要。开发与运行环境的使用开发前台工具:JAVA开发后台工具:MySQL本系统采用Microsoft Windows 2000Server作为操作系统。本系统准备采用客户机/服务器(C/S)结构模式。2.3输入/输出设计格式说明:学生成绩输入界面格式为对话框格式,可是选项为:学生学号、姓名、班级、各科目成绩。输出单个学生成绩也是对话框形式,全部学生成绩输出为表格形式。安全性设计:设置了用户名和密码验证方式,防止用户非法登录。3 系统实施3.1登录与退出界面登录界面:退出界面关键代码如下,public class Login extends JFrame implements ActionListener, FocusListener,KeyListener, ItemListener /* * */private static final long serialVersionUID = 1L;JLabel top, bott;JPanel panelMain, panelInfo;JTextField userName;JPasswordField password;JButton login, cancel;String culeString = 提 示 : ;public Login() super(重庆大学城市科技学院2008级电子商务-学生成绩管理系统);top = new JLabel(new ImageIcon(picture/login_top.gif);bott = new JLabel();panelMain = new JPanel(new BorderLayout(10, 10);bott.setBorder(new LineBorder(new Color(184, 173, 151);buildCenter();panelMain.add(North, top);panelMain.add(South, bott);panelMain.add(panelInfo);/ 加监听事件login.addActionListener(this);cancel.addActionListener(this);login.addFocusListener(this);cancel.addFocusListener(this);login.addKeyListener(this);cancel.addKeyListener(this);userName.addFocusListener(this);userName.addKeyListener(this);password.addFocusListener(this);password.addKeyListener(this);/ 加窗口监听,new WindowAdapter适配器this.addWindowListener(new WindowAdapter() public void windowClosing(WindowEvent we) quit();/ End windowClosing);this.setContentPane(panelMain); / 设置窗口面板this.setLocation(400, 335);this.setSize(350, 250);this.setResizable(false); / 设置窗口大小不可变this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);/ /*/this.setVisible(true);password.requestFocus(true); / 设置焦点给密码框private void buildCenter() / TODO Auto-generated method stubJLabel lb1, lb2;lb1 = new JLabel(用户名:);lb2 = new JLabel(密 码:);userName = new JTextField(15);password = new JPasswordField(15);login = new TJButton(picture/key.gif, 登 录, 登录系统);cancel = new TJButton(picture/exit.gif, 退 出, 关闭系统);/ */ 定义面板为无布局panelInfo = new JPanel(null);/ 加入组建panelInfo.add(lb1);panelInfo.add(lb2);panelInfo.add(userName);panelInfo.add(password);panelInfo.add(login);panelInfo.add(cancel);lb1.setBounds(70, 14, 60, 25);lb2.setBounds(70, 48, 60, 25);userName.setBounds(150, 14, 150, 25);password.setBounds(150, 48, 150, 25);login.setBounds(80, 100, 80, 23);cancel.setBounds(195, 100, 80, 23);/ 设置边框线panelInfo.setBorder(BorderFactory.createTitledBorder();private void quit() int flag = 0;String msg = 您 现 在 要 关 闭 系 统 吗?;flag = JOptionPane.showConfirmDialog(null, msg, 提示,JOptionPane.YES_NO_OPTION);if (flag = JOptionPane.YES_OPTION) this.setVisible(false);System.exit(0);return;private void dengLu() String username = userName.getText().trim();/ System.out.println(user);String pwd = String.valueOf(password.getPassword();String sql = select password from userinfo where username=+ username + ;ResultSet rs = ConnectionDB.verification(sql); / 从数据库获取匹配user的密码结果集int flag = 0; / 用户登录错误次数的标记try while (rs.next() / 用户名存在if (pwd.equals(rs.getString(1) bott.setText(culeString + 登录成功,正在进入系统.);SaveUserInfo user = new SaveUserInfo();/ 保存用户名user.setUsername(username);user.setPassword(pwd);new RegisterUI();this.setVisible(false); else bott.setText(culeString + 用户名/密码不正确,请重新输入.);int m = JOptionPane.showConfirmDialog(null,用户名/密码错误,请重新输入!, 错误信息, JOptionPane.YES_OPTION);if (m = JOptionPane.NO_OPTION) System.exit(1); else flag+;if (flag = 3) JOptionPane.showMessageDialog(null,您不是本系统的用户,系统关闭 ., 警告,JOptionPane.ERROR_MESSAGE);System.exit(0);/在Login.java这个页面里面点击鼠标右键,run as -Java Application就OK了明白了/还有一种方法,上面哟uge绿的圆形图标,那个下拉菜单有需要运行的类名称,需要运行哪个就点一下哦/程序要改一下 =return; catch (HeadlessException e) / TODO Auto-generated catch blocke.printStackTrace(); catch (SQLException e) / TODO Auto-generated catch blocke.printStackTrace();public void actionPerformed(ActionEvent ae) / 动作按键if (ae.getSource() = login) dengLu(); / 登录 else quit(); / 退出public void itemStateChanged(ItemEvent ie) password.requestFocus(true);public void keyListener(KeyEvent ke) / 键盘按下监听int key = ke.getKeyCode();if (key = ke.VK_ENTER) if (ke.getSource() = userName) password.requestFocus(true); / 按下Enter键后,焦点从用户名框转到密码框 else if (password.getPassword().length 0) dengLu(); / 按Enter键登录系统 else if (key = ke.VK_ESCAPE) quit(); / 按ESC键退出系统public void keyReleased(KeyEvent ke) / 键盘释放监听public void keyTyped(KeyEvent ke) / 按键类型监听public void focusGained(FocusEvent fe) if (fe.getSource() = userName) / 窗口下面的功能提示bott.setText(culeString + 请输入用户名.); else if (fe.getSource() = password) bott.setText(culeString + 请输入登录密码.); else if (fe.getSource() = login) bott.setText(culeString + 登录系统.); else if (fe.getSource() = cancel) bott.setText(culeString + 退出系统.);public void focusLost(FocusEvent fe) / 失去焦点监听 */public static void main(String args) new FStartWindow(picture/Login.gif, new JFrame(), 1200);new Login();public void keyPressed(KeyEvent e) / TODO Auto-generated method stub3.2修改密码修改密码:学生输入正确的用户名和密码后可以对自己的密码进行修改。管理员也可以登录系统后,进入用户管理模块,点击修改用户密码,输入原始密码,新密码和确认密码,如果原始密码输入错误系统将提示密码错误,新密码和确认密码必须是一样的这样才能修改成功。private static final long serialVersionUID = 1L;String username = SaveUserInfo.getUsername();String password = SaveUserInfo.getPassword();JButton bt1, bt2;JTextField tf1, tf2, tf3, tf;JPanel panelMain;public RePassword (JFrame frame) super(frame, 修改密码, true);panelMain = new JPanel(new BorderLayout();BuildPanel();Addlistener();this.setContentPane(panelMain);this.setSize(350, 200);this.setMaximumSize(new Dimension(500, 500);this.setResizable(false);this.setLocation(450, 350);this.setVisible(true);private void Addlistener() / TODO Auto-generated method stubbt1.addActionListener(this);bt2.addActionListener(this);bt1.addMouseListener(this);bt2.addMouseListener(this);tf1.addActionListener(this);tf2.addActionListener(this);private void BuildPanel() / TODO Auto-generated method stubJLabel pass1, pass2, pass3;pass1 = new JLabel(原密码:);pass2 = new JLabel(新密码:);pass3 = new JLabel(重复新密码:);/文本框tf1 = new JTextField(15);tf2 = new JTextField(15);tf3 = new JTextField(15);tf = new JTextField(密码信息);tf.setHorizontalAlignment (JTextField.CENTER);tf.setBackground(new Color(199, 183, 143);tf.setBorder(new LineBorder(new Color(87, 87, 47);tf.setEditable(false);/按钮bt1 = new TJButton(picture/modi3.gif, 确定, 修改密码);bt2 = new TJButton(picture/cancel.gif, 取消, 取消操作);JPanel ps, pc, pcc, pcc1, pcc11, pcc12;/JLabel line0 = new JLabel(new ImageIcon(pic/line5.gif);/分隔线/JLabel line1 = new JLabel(new ImageIcon(pic/line4.gif);/分隔线ps = new JPanel(new FlowLayout(FlowLayout.CENTER,50,10); /放置确定和取消按钮pc = new JPanel(new BorderLayout(0,5); /放置按钮以上的部分pcc = new JPanel(new FlowLayout(FlowLayout.CENTER,0,0); /添加新用户文本框为不可编辑,放在North,其他放在流布局的面板中pcc1 = new JPanel(new FlowLayout(FlowLayout.LEFT,0,3); /放置密码信息三行pcc11 = new JPanel(new GridLayout(3,1,0,6);/放置密码信息三行pcc12 = new JPanel(new GridLayout(3,1,0,6);/放置密码信息三行文本框/构造密码信息三行pcc11.add(pass1);pcc11.add(pass2);pcc11.add(pass3);pcc12.add(tf1);pcc12.add(tf2);pcc12.add(tf3);pcc1.add(pcc11);pcc1.add(pcc12);/将用户信息加入面板pcc.add(pcc1);pc.add(North,tf);pc.add(pcc);pc.setBorder(BorderFactory.createTitledBorder();ps.add(bt1);ps.add(bt2);panelMain.add(South,ps);panelMain.add(pc);/*=* *# private boolean isValidity() : 测试用户输入的数据是否合法 *参数 :无 *返回值 :boolean *修饰符 :private *功能 :测试用户输入的数据是否合法 *=* */private boolean isValidity() if(tf1.getText().length() = 0) JOptionPane.showMessageDialog(null, 原密码不能为空, 提示, JOptionPane.INFORMATION_MESSAGE);tf1.requestFocus(true);return false; else if(tf2.getText().length() = 0) JOptionPane.showMessageDialog(null, 新密码不能为空, 提示, JOptionPane.INFORMATION_MESSAGE);tf1.requestFocus(true);return false; else if(tf3.getText().length() = 0) JOptionPane.showMessageDialog(null, 重复密码不能为空, 提示, JOptionPane.INFORMATION_MESSAGE);tf1.requestFocus(true);return false; else if(tf2.getText().length() != tf3.getText().length() JOptionPane.showMessageDialog(null, 新密码和重复密码不一致不能为空, 提示, JOptionPane.INFORMATION_MESSAGE);tf1.requestFocus(true);return false; else if(tf1.getText().toString() != password) JOptionPane.showMessageDialog(null, 您输入的原密码不正确, 提示, JOptionPane.INFORMATION_MESSAGE);tf1.requestFocus(true);return false; else if(tf2.getText().length() 16) JOptionPane.showMessageDialog(null, 密码长度不能超过16位, 提示, JOptionPane.INFORMATION_MESSAGE);tf1.requestFocus(true);return false; else password = tf2.getText();return true;/*=* *# private void saveLiveIn() : *参数 :无 *返回值 :无 *修饰符 :private *功能 :保存用户信息 *=* * throws SQLException */private boolean rePassword() throws SQLException boolean flag = ConnectionDB.rePassword(username, password);return flag;/*=* *ActionListener 监听 *=* */public void actionPerformed (ActionEvent e) String msg = 密码修改成功!请返回.;if (e.getSource() = bt1) if (isValidity() try boolean flag = rePassword(); catch (SQLException e1) / TODO Auto-generated catch blocke1.printStackTrace();JOptionPane.showMessageDialog(null, msg, 提示, JOptionPane.YES_OPTION);else if(e.getSource() = bt2) this.setVisible(false);public void mouseClicked(MouseEvent e) / TODO Auto-generated method stubpublic void mouseEntered(MouseEvent e) / TODO Auto-generated method stubpublic void mouseExited(MouseEvent e) / TODO Auto-generated method stubpublic void mousePressed(MouseEvent e) / TODO Auto-generated method stubpublic void mouseReleased(MouseEvent e) / TODO Auto-generated method stub3.3成绩查询public class ConnectionDB private static Connection conn = null;private static Statement stmt = null;private static ResultSet rs = null;static try Class.forName(com.mysql.jdbc.Driver).newInstance();conn = DriverManager.getConnection(jdbc:mysql:/localhost:3306/stu, root, root); catch (Exception e) JOptionPane.showMessageDialog(null, 数据库连接失败., 错误,JOptionPane.ERROR_MESSAGE);System.exit(0);private ConnectionDB() / 防止实例化public static ResultSet verification(String sql) try stmt = conn.createStatement();rs = stmt.executeQuery(sql);/ stmt.close();/ conn.close(); catch (SQLException e) / TODO Auto-generated catch blocke.printStackTrace();return rs;/根据用户名获取密码信息public String getPassword(String username) String password = null;try stmt = conn.createStatement();rs = stmt.executeQuery(select password from userinfo where username = + username + );while (rs.next() password = rs.getString(password);rs.close();stmt.close();conn.close(); catch (SQLException e) / TODO Auto-generated catch blockSystem.out.println(ConnectionDB.insertAmount(): false);return password;/更新数据库中的密码信息public static boolean rePassword(String username, String password) boolean flag = false; / 作为是否成功插入记录的标记int rsBefore = 0;try stmt = conn.createStatement();rsBefore = stmt.executeUpdate(UPDATE userinfo SET password = + password + where username = + username + );stmt.close();conn.close(); catch (SQLException e) / TODO Auto-generated catch blockSystem.out.println(ConnectionDB.insertAmount(): false);if (rsBefore 0)flag = true;return flag;/根据学号获取此学生的各科成绩,返回值为String数组,保存形式为课程名+分数public static String getGrade(String stuid) String sql = select b.coursename, a.grade FROM gradeinfo a,courseinfo b where a.stuid=+ stuid + and a.courseid=b.courseid;String str = null;int count = 0;try stmt = conn.createStatement();rs = stmt.executeQuery(sql);while (rs.next() / GradeInfo info = new GradeInfo();/ info.setCourseName(rs.getString(coursename);/ info.setScore(rs.getString(grade);/ list.add(info);count+;str = new Stringcount;rs.beforeFirst();int i = 0;while (rs.next() stri+ = rs.getString(coursename) + .+ rs.getString(grade);rs.close();stmt.close(); catch (SQLException e) / TODO Auto-generated catch blocke.printStackTrace();if (str != null & str.length 0)return str;return null;/根据学号获取学生姓名(写重复了 。见getName方法)public static String getName(String stuid) String sql = select name from stuinfo where stuid= + stuid + ;String str = null;try stmt = conn.createStatement();rs = stmt.executeQuery(sql);while (rs.next() str = rs.getString(name);rs.close();stmt.close(); catch (SQLException e) / TODO Auto-generated catch blocke.printStackTrace();if (str != null)return str;return null;/根据学号获取此学号的平均成绩public static String getAvg(String stuid) String sql = select avg(grade) as avg from gradeinfo where stuid=+ stuid + ;/cast(avg(colname) as decimal(9,1) endString str = null;try stmt = conn.createStatement();rs = stmt.executeQuery(sql);while (rs.next() str = rs.getString(avg);rs.close();stmt.close(); catch (SQLException e) / TODO Auto-generated catch blocke.printStackTrace();if (str != null)return str;return null;/获取所有学生的平均成绩public static String getAllAvg() String sql = select a.stuid, name, avg(grade) avg + from gradeinfo a, courseinfo b, stuinfo c + where a.stuid=c.stuid and a.courseid=b.courseid + GROUP by stuid;String str = null;int count = 0;try stmt = conn.createStatement();rs = stmt.executeQuery(sql);while (rs.next() count+;rs.beforeFirst();str = new Stringcount;int i = 0;while (rs.next() stri+ = rs.getString(stuid) + . + rs.getString(name)+ . + rs.getString(avg);rs.close();stmt.close(); catch (SQLException e) / TODO Auto-generated catch blocke.printStackTrace();if (str != null & str.length 0)return str;return null;/获取所有课程信息(课程名)public static String getCourseName() String sql = select coursename from courseinfo;String str = ;try stmt = conn.createStatement();rs = stmt.executeQuery(sql);while (rs.next() if (!rs.isLast() str += rs.getString(coursename) + .; else str += rs.getString(coursename); catch (SQLException e) / TODO Auto-generated catch blocke.printStackTrace();if (str != null)return str;return null;/根据学号获取学生姓名public static String getNameByStuid(String stuid) String sql = select name from stuinfo where stuid= + stuid + ;String str = null;try stmt = conn.createStatement();rs = stmt.executeQuery(sql);while (rs.next() str = rs.getString(name); catch (SQLException e) / TODO Auto-generated catch blocke.printStackTrace();if (str != nu
展开阅读全文
相关资源
相关搜索

最新文档


当前位置:首页 > 办公文档


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!