版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、学生成绩管理系统课程设计实验报告题 目学生成绩管理系统学 院数学与信息工程学院专 业计算机科学与技术班 级同组成员编写日期一、课程设计目的做这个小的学生成绩管理系统来加深对 JAVA 所学知识的巩固,以及学习JAVA与数据库的连接和 JAVA的 GUI图形界面。二、需求分析此系统实现如下系统功能:(1)使得学生的成绩管理工作更加清晰、条理化、自动化。(2)通过用户名和密码登录系统,查询学生基本资料,学生所学课程成绩,等功能。容易地完成学生信息的查询操作。(3) 设计人机友好界面,功能安排合理,操作使用方便,并且进一步考虑系统在安全性,完整性,并发控制,备份和恢复等方面的功能要求。三、系统模块设
2、计此系统可分为 2 个模块,教师管理模块和学生操作模块,期中教师又包括学生信息输入与学生成绩录入等; 学生模块则包括学生成绩查询与学生信息录入查询操作等。系统流程图:用户登录教师学生学学学学生生生生成信成信绩息绩息录录查查入入询询四、数据库1、学生表:FieldTypeNullKeyCommentIDVarchar(10)PRI用户名 (学号 )PwdVarchar(10)密码NameChar(10)姓名SexChar(10)性别ClassChar(10)班级CollageChar(10)学院2、教师表FieldTypeNullKeyCommentIDVarchar(10)PRI用户名PwdV
3、archar(10)密码3、成绩表FieldTypeNullKeyCommentSidchar(10)PRI学号计算机网络char(10)课程Linux 操作系统char(10)课程计算机专业英语char(10)课程计算机信息技术char(10)课程Java 程序设计char(10)课程数据库应用实训char(10)课程高等数学char(10)课程XMLchar(10)课程五、 E-R 图ClassIDClocageIDPwd学生表TS教师表PwdSexSC计算机网络name计算机专业英Linux 操作系语统计算机系成绩计算机信息技数据库应用实术基础训教程Java 程序设计高等数学SID(ID
4、)XML六、心得体会通过本次课程设计,成功的完成了这个小型简单的系统的设计,在整个设计过程中我对 JAVA使用和它强大的作用有了一个更深刻的认识,尽管这个系统很简单,但是它让我综合运用了这个学期所学的 JAVA的很多内容,在此基础上,对 JAVA的基础知识得到了更好的巩固。在制作的过程中我也学到很多思想:首先,要学会统筹全局,合理规划,例如在制作整个框架的时候提前就要做全面考虑,要把整个结构图画出来, 并且要对数据库表里的东西做全面规划。 同时在编写程序的时候也要想好先实现什么功能,再实现什么功能, 这样做出来的东西才有条理性,更容易实现和理解。 其次,要细心仔细。 Java 程序虽然容易理解
5、,但在写的过程中一不留心就会出现错误。当然出错是在所难免的, 与性质有关的错误可以经过思考讨论后进行改正, 但如果粗心大意,出现输入上的错误就很难发现和修改,会耽误很多时间。我认为最大的收获是提高了自己的动手能力。 在平时的上机中大多数是根据书上的思想和布局来写程序的。 这次的课程设计要自己思考自己写, 考虑的东西比平时上机考虑的要多的多。 在整个设计过程中写代码不是最难的, 最难的是构思和布局。这次课程设计也是一次很好的实践活动,让我们体会到了 java 的神奇作用。附录:源代码1、用户登录界面import java.awt.*;import javax.swing.*;import jav
6、a.awt.event.*;import java.sql.*;public class Systems extends JFrame implements ActionListener static Systems ss;JPanel panel = new JPanel();JLabel label1 = new JLabel("输入姓名: ");JTextField name = new JTextField();JLabel label2 = new JLabel("密码: ");JPasswordField pwd = new JPasswor
7、dField();JButton Enter = new JButton("登录 ");JButton Exit = new JButton("退出 ");String url = "E:mysqlTM1.jpg"ButtonGroup bgp = new ButtonGroup();JRadioButton stu = new JRadioButton("学生 ");JRadioButton tch = new JRadioButton("教师 ");public Systems()super
8、(" 登录系统 ");this.setResizable(false);JLabel img = new JLabel(new ImageIcon(url);img.setBounds(0,0,500,125);panel.add(img);stu.setBounds(165,210,70,20);tch.setBounds(265,210,70,20);bgp.add(stu);bgp.add(tch);panel.add(stu);panel.add(tch);Enter.setBounds(150,250,80,20);Exit.setBounds(270,250,8
9、0,20);Enter.addActionListener(this);Exit.addActionListener(this);panel.add(Enter);panel.add(Exit);panel.setLayout(null);this.add(panel);label1.setBounds(135,130,100,25);panel.add(label1);name.setBounds(265,130,100,25);panel.add(name);label2.setBounds(135,165,100,25);panel.add(label2);pwd.setBounds(2
10、65,165,100,25);panel.add(pwd);this.setBounds(100,100,500,350);this.setVisible(true);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);public void actionPerformed(ActionEvent e)if(e.getSource()=Enter)String username , password;username = name.getText();password = new String(pwd.getPassword();tryCla
11、ss.forName("sun.jdbc.odbc.JdbcOdbcDriver");catch (ClassNotFoundException ce)JOptionPane.showMessageDialog(ss,ce.getMessage();if(stu.isSelected()tryConnectioncon=DriverManager.getConnection("jdbc:odbc:shujuku","sa",""); Statement stmt = con.createStatement(); R
12、esultSet rs = stmt.executeQuery("select * fromSTU");while(rs.next()if(rs.getString("ID").equals(username)if(rs.getString("Pwd").equals(password)JOptionPane.showMessageDialog(ss,"登陆成功 ");Students stu = new Students();elseJOptionPane.showMessageDialog(ss,"登
13、录失败 ");rs.close();stmt.close();catch (SQLException se)JOptionPane.showMessageDialog(ss,se.getMessage();else if(tch.isSelected()tryConnectioncon=DriverManager.getConnection("jdbc:odbc:shujuku","sa",""); Statement stmt = con.createStatement(); ResultSet rs = stmt.exe
14、cuteQuery("select * fromTCH");while(rs.next()if(rs.getString("ID").equals(username)if(rs.getString("Pwd").equals(password)JOptionPane.showMessageDialog(ss,"登陆成功 ");Teachers tch=new Teachers();elseJOptionPane.showMessageDialog(ss,"登录失败 ");catch (SQLEx
15、ception se)JOptionPane.showMessageDialog(ss,se.getMessage();elseSystem.exit(0);public static void main(String args)Systems sys = new Systems();2、学生登录界面:import java.awt.*;import javax.swing.*;import java.awt.event.*;public class Students extends JFrame implements ActionListener JMenuBar jmb = new JMe
16、nuBar();JMenu Message = new JMenu(" 信息 ");JMenu Score = new JMenu(" 成绩 ");JMenuItem Item1 = new JMenuItem("插入 ");JMenuItem Item2 = new JMenuItem("查询 ");JMenuItem Item3 = new JMenuItem("查询 ");public Students()super(" 学生界面 ");this.setSize(500
17、,400);this.setVisible(true);this.setResizable(false);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);this.setJMenuBar(jmb);jmb.add(Message);jmb.add(Score);Message.add(Item1);Message.add(Item2);Score.add(Item3);Item1.addActionListener(this);Item2.addActionListener(this);Item3.addActionListener(th
18、is);public void actionPerformed(ActionEvent e)if(e.getSource()=Item1)AddMsg ad = new AddMsg();else if(e.getSource()=Item2)Serch ser = new Serch();elseScore so = new Score();public static void main(String args)Students stu = new Students();3、教师登录界面:import java.awt.*;import javax.swing.*;import java.a
19、wt.event.*;public class Teachers extends JFrame implements ActionListener JMenuBar bar = new JMenuBar();JMenu menu1 = new JMenu(" 信息 ");JMenu menu2 = new JMenu(" 成绩 ");JMenuItem item1 = new JMenuItem("录入信息 ");JMenuItem item2 = new JMenuItem("录入成绩 ");JPanel jpl
20、 = new JPanel();public Teachers()super(" 教师界面 ");this.setSize(500,300);this.setResizable(false);this.setVisible(true);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);this.setJMenuBar(bar);this.add(jpl);jpl.setLayout(null);bar.add(menu1);bar.add(menu2);menu1.add(item1);menu2.add(item2);
21、item1.addActionListener(this);item2.addActionListener(this);public void actionPerformed(ActionEvent e)if(e.getSource()=item1)AddMsg msg = new AddMsg();elseAddscore as = new Addscore();public static void main(String args)Teachers tch = new Teachers();4、学生用户添加界面:import java.awt.*;import javax.swing.*;
22、import java.awt.event.*;import java.sql.*;public class AddMsg extends JFrame implements ActionListener static AddMsg s;/* 添加学生信息控件 */JPanel jpl = new JPanel();JLabel label1 = new JLabel("添加基本信息 ",JLabel.CENTER);JLabel label2 = new JLabel("学号: ",JLabel.CENTER);JLabel label3 = new
23、JLabel("姓名: ",JLabel.CENTER);JLabel label4 = new JLabel("性别: ",JLabel.CENTER);JLabel label5 = new JLabel("班级: ",JLabel.CENTER);JLabel label6 = new JLabel("学院: ",JLabel.CENTER);JTextField num = new JTextField(2);JTextField nam = new JTextField(4);ButtonGroup bg
24、p = new ButtonGroup();JRadioButton man = new JRadioButton("男");JRadioButton women = new JRadioButton("女");JTextField clas = new JTextField();JTextField scl = new JTextField();JButton reset = new JButton("重置 ");JButton addmsg = new JButton("添加 ");public AddMsg(
25、)super(" 添加学生信息 ");this.setResizable(false);this.setSize(500,400);this.setVisible(true);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);this.add(jpl);jpl.setLayout(null);addmsg.addActionListener(this);reset.addActionListener(this);/* 插入面板 */label1.setBounds(100,20,300,20);jpl.add(label
26、1);label2.setBounds(100,50,70,20);jpl.add(label2);num.setBounds(190,50,140,20);jpl.add(num);label3.setBounds(100,90,70,20);jpl.add(label3);nam.setBounds(190,90,140,20);jpl.add(nam);label4.setBounds(100,130,70,20);jpl.add(label4);man.setBounds(190,130,60,20);women.setBounds(270,130,60,20);jpl.add(man
27、);jpl.add(women);bgp.add(man);bgp.add(women);label5.setBounds(100,170,70,20);jpl.add(label5);clas.setBounds(190,170,140,20);jpl.add(clas);label6.setBounds(100,210,70,20);jpl.add(label6);scl.setBounds(190,210,140,20);jpl.add(scl);reset.setBounds(120,250,90,20);addmsg.setBounds(240,250,90,20);jpl.add(
28、reset);jpl.add(addmsg);public void actionPerformed(ActionEvent e)if(e.getSource()=addmsg)String sex;if(man.isSelected()sex="男"elsesex="女"tryClass.forName("sun.jdbc.odbc.JdbcOdbcDriver");catch (ClassNotFoundException ce)JOptionPane.showMessageDialog(s,ce.getMessage();try
29、Connection con = DriverManager.getConnection("jdbc:odbc:shujuku","sa","");Statement stmt = con.createStatement();Stringstr= "insertintoSTU(ID , Pwd, Name, Sex , Class ,Collage)values('"+num.getText()+"','"+"123','"+nam.g
30、etText()+"','"+sex+"','"+clas.getText()+"','"+scl.getText()+"')"/inta = stmt.executeUpdate("insertintoSTU(ID , Pwd, Name,Sex,Class,Collage)values('"+num.getText()+"','"+"12345678','"
31、+nam.getText()+"','"+sex+"','"+clas.getText()+"','"+scl.getText()+"')");System.out.println(str);int a = stmt.executeUpdate(str);if(a=1)JOptionPane.showMessageDialog(s,"已成功添加");elseJOptionPane.showMessageDialog(s,"添加失败
32、");stmt.close();catch (SQLException se)JOptionPane.showMessageDialog(s,se.getMessage();elsenum.setText("");nam.setText("");clas.setText("");scl.setText("");num.requestFocus();public static void main(String args)AddMsg amg = new AddMsg();5、学生成绩添加:import ja
33、va.awt.*;import javax.swing.*;import java.awt.event.*;import java.sql.*;public class Addscore extends JFrame implements ActionListener static Addscore ss;JLabel label = new JLabel("学号: ") , new JLabel("计算机网络:") , new JLabel("Linux操作系统: ") , new JLabel("计算机专业英语: &qu
34、ot;) ,new JLabel(" 计算机信息技术基础: ") , new JLabel("Java程序设计: "), newJLabel("数据库应用实训教程: "),new JLabel("高等 数学 : "),newJLabel("XML :");JTextFieldtxt=newJTextField(),new JTextField(),newJTextField() , new JTextField() , new JTextField() ,new JTextField() ,ne
35、w JTextField() ,new JTextField() ,new JTextField() ;JButton add = new JButton("添加 ");JButton reset = new JButton("重置 ");JPanel jpl = new JPanel();JLabel title = new JLabel(" 添加学生成绩 " , JLabel.CENTER); Font f = new Font(" 黑体 " , Font.BOLD , 16 );int s = 100;pub
36、lic Addscore()super(" 添加学生信息 ");this.setResizable(false);this.setSize(500,600);this.setDefaultCloseOperation(EXIT_ON_CLOSE);this.setVisible(true);this.add(jpl);add.addActionListener(this);reset.addActionListener(this);jpl.setLayout(null);title.setBounds(150,40,200,20);title.setFont(f);titl
37、e.setForeground(Color.red);jpl.setBackground(Color.LIGHT_GRAY);jpl.add(title);for(int i = 0 ; i <label.length ; i+)labeli.setBounds(100,s,140,20);jpl.add(labeli);txti.setBounds(260,s,140,20);jpl.add(txti);s=s+40;add.setBounds(150,s,80,20);reset.setBounds(250,s,80,20);jpl.add(add);jpl.add(reset);p
38、ublic void actionPerformed(ActionEvent e)if(e.getSource()=add)tryClass.forName("sun.jdbc.odbc.JdbcOdbcDriver");catch (ClassNotFoundException ce)JOptionPane.showMessageDialog(ss,ce.getMessage();tryConnectioncon=DriverManager.getConnection("jdbc:odbc:shujuku","sa","&
39、quot;);Statement stmt = con.createStatement();inta = stmt.executeUpdate("insertinto计算机系成绩 (SID ,计算机网络, Linux操作系统,计算机专业英语,计算机信息技术基础,Java程序设计,数据库应用实训教程,高等数学,Xml)values('"+txt0.getText()+"','"+txt1.getText()+"','"+txt2.ge tText()+"','"
40、+txt3.getText()+"','"+txt4.getText()+"','"+txt5.ge tText()+"','"+txt6.getText()+"','"+txt7.getText()+"','"+txt8.ge tText()+"')");if(a=1)JOptionPane.showMessageDialog(ss,"添加成功 ");elseJOpt
41、ionPane.showMessageDialog(ss,"添加失败 ");catch (SQLException se)JOptionPane.showMessageDialog(ss,se.getMessage();elsefor(int i = 0 ; i<txt.length ; i+)txti.setText("");txt0.requestFocus();public static void main(String args)Addscore as = new Addscore();6、学生信息查询:import java.awt.*;
42、import javax.swing.*;import java.awt.event.*;import java.sql.*;public class Serch extends JFrame implements ActionListener /* 查询学生信息控件 */static Serch s;JPanel jpl = new JPanel();JLabel SCH = new JLabel("查询学生信息 ",JLabel.CENTER);JLabel label1 = new JLabel("请输入学号: ",JLabel.CENTER);J
43、Button serch = new JButton("查询 ");JLabel label2 = new JLabel("姓名: ",JLabel.CENTER);JLabel label3 = new JLabel("班级: ",JLabel.CENTER);JLabel label4 = new JLabel("学校: ",JLabel.CENTER);JLabel label5 = new JLabel("性别: ",JLabel.CENTER);ButtonGroup bgp = ne
44、w ButtonGroup();JRadioButton man = new JRadioButton("男");JRadioButton women = new JRadioButton("女");JTextField num = new JTextField();JTextField nam = new JTextField();JTextField clas = new JTextField();JTextField scl = new JTextField();JButton reset = new JButton("重置 "
45、);public Serch()this.setSize(500,400);this.setVisible(true);this.setResizable(false);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);this.add(jpl);jpl.setLayout(null);serch.addActionListener(this);reset.addActionListener(this);/* 查询面板 */SCH.setBounds(100,20,300,20);jpl.add(SCH);label1.setBounds(
46、100,60,100,20);jpl.add(label1);num.setBounds(220,60,140,20);jpl.add(num);serch.setBounds(120,100,90,20);reset.setBounds(260,100,90,20);jpl.add(serch);jpl.add(reset);label2.setBounds(100,140,70,20);jpl.add(label2);nam.setBounds(190,140,140,20);jpl.add(nam);label5.setBounds(100,180,70,20);jpl.add(labe
47、l5);man.setBounds(205,180,60,20);women.setBounds(285,180,60,20);bgp.add(man);bgp.add(women);jpl.add(man);jpl.add(women);label3.setBounds(100,220,70,20);jpl.add(label3);clas.setBounds(190,220,140,20);jpl.add(clas);label4.setBounds(100,260,70,20);jpl.add(label4);scl.setBounds(190,260,140,20);jpl.add(s
48、cl);public void actionPerformed(ActionEvent e)String id = num.getText();if(e.getSource()=serch)tryClass.forName("sun.jdbc.odbc.JdbcOdbcDriver");catch (ClassNotFoundException ce)JOptionPane.showMessageDialog(s,ce.getMessage();tryConnectioncon=DriverManager.getConnection("jdbc:odbc:shuj
49、uku","sa","");Statement stmt = con.createStatement();ResultSetrs = stmt.executeQuery("select* from STUwhereID = '" + id + "'");while(rs.next()nam.setText(rs.getString("Name");if(rs.getString("Sex").equals("男")man.setS
50、elected(true);elsewomen.setSelected(true);clas.setText(rs.getString("Class");scl.setText(rs.getString("Collage");catch (SQLException se)JOptionPane.showMessageDialog(s,se.getMessage();public static void main(String args)Serch sch = new Serch();7、学生成绩查询import java.awt.*;import jav
51、ax.swing.*;import java.awt.event.*;import java.awt.font.*;import java.sql.*;public class Score extends JFrame implements ActionListenerstatic Score s;JLabel title = new JLabel("查询成绩 ",JLabel.CENTER);Font f = new Font("楷体 ",Font.BOLD+Font.ITALIC,16);JPanel jpl = new JPanel();JLabel label1 = new JLabel("请输入学号: ",JLabel.CENTER);JTextField num = new JTextField();JButton serch = new JButton("查询成绩 ");JButton reset = new JButton("重置 ");JLabel label2 = new JLabel("计算机网络: ",JLabel.LEFT);JLabel label3 = new JLabel("Linux操作系统: ",JLa
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 有机化学原料的工艺流程模拟与优化考核试卷
- 铁路隧道照明与通风设计考核试卷
- 化学实验室数据记录与分析考核试卷
- 蔬果罐头生产过程中的工艺参数调整与优化考核试卷
- 乡村旅游消费者行为分析
- 锑冶炼产品质量检测考核试卷
- 1.2 成长不仅仅是身体 (解析版)
- 非公开募集基金参与网络安全项目投资考核试卷
- 糕点店顾客关系管理与忠诚度计划考核试卷
- 中国城市群一体化报告
- 2023年企业安全生产双重预防机制建设规范
- 某大桥桥梁定期检查报告
- 新时代体育与健康课程改革下实现“教会、勤练、常赛”教学模式的策略 论文
- 公共政策视角下医疗服务价格改革政策效果及风险评估研究
- 中小学教师数据素养-专题四-教育数据可视化4.5-作业
- GB/T 9557-200840%辛硫磷乳油
- GB/T 32.1-2020六角头头部带孔螺栓
- 小学生成长档案记录手册
- 农村集体经济发展和提高农民收入课件
- 狭窄空间医学基础与救援课件
- 包袋设计与制作课件
评论
0/150
提交评论