Java综合性实验学生成绩管理(整理)_第1页
Java综合性实验学生成绩管理(整理)_第2页
免费预览已结束,剩余12页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、综合性实验学生成绩管理系统班级:数学 092 学号: 200912010210 姓名:同艳云实验仪器设备:多媒体计算机。实验目的:在掌握相关基础知识的基础上,学会自己设计实验,熟练掌握 JDBC 技术访问数 据库(或数据文件)的方法、在 Java 中进行数据库应用程序开发的方法和步骤,熟悉 Swing 组件特性和 Action 接口并能够恰当运用实现特定功能,会开发多窗体应用程 序。实验要求:在 8 学时以内,制作出能够实现基本功能的学生成绩管理系统。写出技术工作报 告并附源程序。实验内容及任务:1进行数据库(或数据文件)设计,数据分为学生信息、成绩管理、信息查询等 三部分;使用学生信息表、课

2、程表两个数据表来存放数据。2选择适当组件进行界面设计:界面要美观大方,具有主菜单和相应工具栏及按 钮;3编写事件代码:能够实现学生信息维护(录入、修改和删除);学生信息浏览;按“学号”查 询学生信息; 按“姓名”和“所在班级”查询学生信息; 按“学院名称”查询学生信 息;按课程查询学生成绩等功能。4分析总结:1 数据库、数据表(或数据文件)设计;1.1 学生基本信息表包含的信息是学生编号、学生姓名、学生性别、学生年龄、家庭住址、联系电话等信息,设计时注意ID 字段设为主键,设为 Int 类型,如表 4.1所示:表 4.1 学生基本信息表字段名数据类型说明IDInt学生编号NameVarchar

3、(10)学生姓名SexChar(10)性别AgeInt年龄AddressVarchar(50)家庭住址PhoneChar(15)联系电话1.2 班级基本信息表包括学生编号、科目类型、任课教师、所得分数,ID 设为主键,如表 4.2 所示:表 4.2 班级基本信息信息表字段名数据类型说明IDInt学生编号OTypeVarchar(10)科目类型ONameVarchar(10)任课教师Gradeint所得分数2.主控模块设计;2.1 系统登录界面,如图 4.3-4.6 所示。图 4.3图 4.4图 4.52.2 系统主界面,如图 4.6 所示。图 4.63.学生信息维护模块设计;3.1 增加学生信

4、息界面,如图 4.7 所示。图 4.73.2 修改学生信息界面,如图 4.8 所示。图 4.83.3.删除学生信息界面,如图 4.9 所示。图 4.94.学生信息查询模块设计;4.1 按学号查找学生信息界面,如图4.10 所示。图 4.104.2 按姓名,学号查找学生信息界面,如图4.11 所示。图 4.11实验总结:通过本次实验设计,我对 JAVA 的知识又有了更深的了解,而且对 Swing 界面设计 有了更深的领悟,而且更熟练使用JAVA 和数据库的连接,以及对简单的数据库查询语言有了些许了解,然后在编程设计阶段还是遇到了许多问题,但是通过网上查询资料,以及和同学讨论这些问题都迎刃而解了,

5、必须要有团结合作精神,而且要吃苦耐 劳,耐心严谨,这次设计实验对我的知识技能和思维都是一个很好的锻炼。附录1系统登录界面程序代码import java.awt.* 。import java.awt.event.*。import javax.swing.* 。class WyFrame extends Frame implements ActionListenerLabel l1,l2。TextField t1,t2。Button b1,b2。public static int k 。public WyFrame()super(学生管理系统”)。setBackground(Color.light

6、Gray)。 setLayout(null)。setSize(240,160)。 this.setLocationRelativeTo(null)。11= new Label用户名丄 abel.CENTER)。12=new Label密 码丄 abel.CENTER)。t1=new TextField()。t2=new TextField()。b1= new Butto n(登入)。b2=new Butto n(退 出)。11.setBounds(40,45,40,30。)12.setBounds(40,80,40,30。)t1.setBounds(90,45,100,25。)t2.setBo

7、unds(90,80,100,25。)b1.setBounds(50,115,60,30。) b2.setBounds(125,115,60,30。)b1.addActionListener(this)。 b2.addActionListener(this)。add(l1)。 add(l2)。 add(t1)。 add(t2)。 add(b1)。 add(b2)。this.addWindowListener(new WindowAdapter()publicvoid windowClosing(WindowEvent e)dispose()。System.exit(0)。)。setVisibl

8、e(true)。public void actionPerformed(ActionEvent e)if(e.getSource()=b1)k=1。if(e.getSource()=b2)k=2。repaint()。if(k=1)if(t1.getText().toString().trim().equals(09321104)&t2.getText().toString().trim().equals(880902)MyMenu hyf=new MyMenu() 。 this.setVisible(false)。elseif(t1.getText().toString().trim(

9、).equals(09321104)JOptio nPan e.showMessageDialog(this,密码与用户名不匹配! ) 。elseJOptio nPan e.showMessageDialog(this,用户名错误!)。if(k=2)dispose()。 System.exit(0)。public class Loginpublic static void main(String args)WyFrame hyf=new WyFrame()。2. 系统主界面程序代码(含有菜单)import java.awt.* 。import java.awt.event.*。import j

10、ava.util.* 。public class MyMenu extends Frame implements ActionListenerpublic MyMenu()super(学生管理系统)。setSize(400,300)。setBackground(Color.lightGray)。setVisible(true)。setLocationRelativeTo(null)。this.addWindowListener(new WindowAdapter()public void windowClosing(WindowEvent e)dispose()。System.exit(0)。

11、)。Menu file=new Menu( 文件 )。Menultem exit=new Menultem(”退出)。file.add(exit) 。Menu student=new Menu(学生信息管理)。Menultem ins=new Menultem(增加学生信息)。Me nultem del=new Men ultem(删除学生信息)。Me nultem upd=new Men ultem(修改学生信息)。Me nultem sel=new Men ultem(查找学生信息)。student.add(ins)。 student.add(del)。 student.add(upd)。

12、 student.add(sel。)MenuBar hyf=new MenuBar()。hyf.add(file)。 hyf.add(student)。setMenuBar(hyf)。exit.addActionListener(this)。ins.addActionListener(this)。del.addActionListener(this)。upd.addActionListener(this)。 sel.addActionListener(this)。public void actionPerformed(ActionEvent e)String strCmd=e.getActio

13、nCommand()。 if(strCmd.equals(退出)System.exit(0)。if(strCmd.equals(增加学生信息) Insert ins=new Insert()。if(strCmd.equals(删除学生信息)Insert del=null。if(strCmd.equals(修改学生信息)Update upd=new Update()。if(strCmd.equals(查询学生信息)Select sel=new Select(。)repaint()。3. 添加学生信息界面程序代码import java.awt.*。import java.awt.event.*。i

14、mport javax.swing.* 。import java.util.* 。public class Insert extends Frame implements ActionListener ,ItemListenerCheckboxGroup cg=new CheckboxGroup()。 Label l1,l2,l3,l4,l5,l6,l7 。TextField t1,t2,t3,t4,t5,t6,t7。Button b1,b2。Checkbox c1,c2。public static Student hyf。public static String a1,a2,a3,a4,a5

15、,a6,a7public Insert()super(添加学生信息界面)。setBackground(Color.lightGray)。 setLayout(null)。11= new Label(姓名丄 abel.CENTER)。12=new Label(性别丄 abel.CENTER)。l3=new Label(出生日期丄 abel.CENTER)。l4=new Label(学号丄 abel.CENTER)。 l5=new La be l (计算机成绩,Label.CENTER)。l6=new Label(英语成绩丄 abel.CENTER)。l7=new Label(数学成绩丄 abel

16、.CENTER)。c1= new Checkbox(男 ”,cg,true)。c2=new Checkbox( 女 ”,cg,false)。c1.addItemListener(this)。 c2.addItemListener(this)。 t1=new TextField()。t2=new TextField()。 t3=new TextField()。 t4=new TextField()。 t5=newTextField()。 t6=new TextField()。 t7=new TextField()。 b1=new Button( 确定)。 b2=new Button(退出)。b1

17、.addActionListener(this)。b2.addActionListener(this)。add(l1)。add(t1)。add(l2)。add(t2)。add(l3)。add(t3)。add(l4)。add(t4)。add(l5)。add(t5)。add(l6)。add(t6)。add(l7)。 add(t7)。 add(b1)。 add(b2)。add(c1)。 add(c2)。11.setBounds(40,60,70,30)。12.setBounds(40,90,70,30)。13.setBounds(40,120,70,30。)14.setBounds(40,150,7

18、0,30。)15.setBounds(40,180,70,30。)16.setBounds(40,210,70,30。)17.setBounds(40,240,70,30。) t1.setBounds(120,60,100,30。)c1.setBounds(120,90,50,30。) c2.setBounds(170,90,50,30。)t3.setBounds(120,120,100,30。) t4.setBounds(120,150,100,30。)t5.setBounds(120,180,100,30。) t6.setBounds(120,210,100,30。)t7.setBound

19、s(120,240,100,30。) b1.setBounds(100,280,80,30。)b2.setBounds(200,280,80,30。)c1.setState(true。)a2=男。addWindowListener(new WindowAdapter()public void windowClosing(WindowEvent e) dispose()。System.exit(0)。) 。/关闭窗口 setSize(400,350)。 setLocationRelativeTo(null)。setVisible(true)。public void itemStateChange

20、d(ItemEvent e)if(e.getItemSelectable()=c1)a2=男。if(e.getItemSelectable()=c2)a2=女。public void actionPerformed(ActionEvent e)String strCmd=e.getActionCommand()。if(strCmd.equals(”退出) this.hide()。if(strCmd.equals(” 确定)a1=t1.getText()。char c1=a2.toCharArray()。a3=t3.getText()。a4=t4.getText()。a5=t5.getText(

21、)。a6=t6.getText()。a7=t7.getText()。hyf.setcompScore( Integer.parseInt(a5.trim()。)hyf.setengScore(Integer.parseInt(a6.trim()。)hyf.setmathScore(Integer.parseInt(a7.trim()。) repaint()。4. 修改学生记录界面程序代码import java.awt.* 。import java.awt.event.*。import javax.swing.* 。import java.util.* 。public class Update

22、extends Frame implements ActionListenerLabel l1,l2,l3,l4,l5,l6,l7 。 TextField t1,t2,t3,t4,t5,t6,t7。 Button b1,b2。public static String a1,a2,a3,a4,a5,a6,a7public Update()super(学生管理增加学生界面)。setBackground(Color.lightGray)。setLayout(null)。11= new Label姓名丄 abel.CENTER)。12=new Label性别丄 abel.CENTER)。l3=new

23、Label出生日期丄 abel.CENTER)。l4=new Label学号丄 abel.CENTER)。l5=new Label计算机成绩丄 abel.CENTER)。 l6=new Label英语成绩丄abel.CENTER)。 l7=new Label数学成绩丄 abel.CENTER)。 t1=newTextField()。 t2=new TextField()。 t3=new TextField()。 t4=new TextField()。t5=new TextField()。 t6=new TextField()。 t7=new TextField()。 b1=new Button

24、(确定)。 b2=new Button(退出)。b1.addActionListener(this)。b2.addActionListener(this)。add(l1)。add(t1)。add(l2)。add(t2)。add(l3)。add(t3)。add(l4)。add(t4)。add(l5)。add(t5)。add(l6)。add(t6)。add(l7)。 add(t7)。 add(b1)。 add(b2)。11.setBounds(40,60,70,30)。12.setBounds(40,90,70,30)。13.setBounds(40,120,70,30。)14.setBounds

25、(40,150,70,30。)15.setBounds(40,180,70,30。)16.setBounds(40,210,70,30。)17.setBounds(40,240,70,30。) t1.setBounds(120,60,100,30。)t2.setBounds(120,90,100,30。) t3.setBounds(120,120,100,30。)t4.setBounds(120,150,100,30。) t5.setBounds(120,180,100,30。)t6.setBounds(120,210,100,30。) t7.setBounds(120,240,100,30。

26、)b1.setBounds(100,280,80,30。) b2.setBounds(200,280,80,30。)addWindowListener(new WindowAdapter() public void windowClosing(WindowEvent e) dispose()。 System.exit(0)。) 。/关闭窗口 setSize(400,350)。 setLocationRelativeTo(null)。setVisible(true)。public void actionPerformed(ActionEvent e)String strCmd=e.getActi

27、onCommand()。if(strCmd.equals(”退出) this.hide()。 if(strCmd.equals(” 确定) a1=t1.getText()。String a2=t2.getText()。 char c1=a2.toCharArray()。a3=t3.getText()。 a4=t4.getText()。 a5=t5.getText()。 a6=t6.getText()。a7=t7.getText()。I=a1。Insert.hyf.sex=c10。Insert.hyf.birthday=a3。 Insert.hyf.number=a4

28、。Insert.hyf.setcompScore( Integer.parseInt(a5.trim()。)Insert.hyf.setengScore(Integer.parseInt(a6.trim()。)Insert.hyf.setmathScore(Integer.parseInt(a7.trim()。) repaint()。5. 查找学生记录界面程序设计import java.awt.* 。import java.awt.event.*。import javax.swing.* 。import java.util.* 。public class Select extends Fram

29、e implements ActionListenerLabel l1,l2,l3,l4,l5,l6,l7,l8,l9,l10 。TextField t1,t2,t3,t4,t5,t6,t7,t8,t9,t10。Button b1,b2。public Select()super(学生管理查询学生界面”)。setBackground(Color.lightGray)。 setLayout(null)。11= new Label姓名丄 abel.CENTER)。12=new Label性别丄 abel.CENTER)。13=new Label出生日期丄 abel.CENTER)。14=new La

30、bel学号丄 abel.CENTER)。15=new Label计算机成绩丄 abel.CENTER)。16=new Label英语成绩丄 abel.CENTER)。17=new Label数学成绩丄 abel.CENTER)。18=new Label最大值丄 abel.CENTER)。19=new Label最小值丄 abel.CENTER)。110=new Label平均值丄 abel.CENTER)。t1=new TextField()。t2=new TextField()。t3=new TextField()。t4=new TextField()。t5=new TextField()。

31、t6=new TextField()。t7=new TextField()。t8=new TextField()。t9=new TextField()。t10=new TextField()。b1=new Button( 查询)。b2=new Button(退出)。b1.addActionListener(this)。 b2.addActionListener(this)。 add(l1)。 add(t1)。add(l2)。add(t2)。add(l3)。 add(t3)。add(l4)。add(t4)。add(l5)。add(t5)。add(l6)。add(t6)。add(l7)。add(t

32、7)。add(b1)。add(b2)。 add(t8)。 add(t9)。 add(t10)。 add(l8)。 add(l9)。 add(l10)。11.setBounds(40,60,70,30)。12.setBounds(40,90,70,30)。13.setBounds(40,120,70,30。)14.setBounds(40,150,70,30。)15.setBounds(40,180,70,30。)16.setBounds(40,210,70,30。)17.setBounds(40,240,70,30。)18.setBounds(40,270,70,30。)19.setBounds(40,300,70,30。) l10.setBounds(40,330,70,30。)t1.setBounds(120,60,100,30。) t2.setBounds(120,90,100,30。)t3.setBound

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论