Java综合性实验学生成绩管理系统.docx
《Java综合性实验学生成绩管理系统.docx》由会员分享,可在线阅读,更多相关《Java综合性实验学生成绩管理系统.docx(24页珍藏版)》请在冰豆网上搜索。
Java综合性实验学生成绩管理系统
Java综合性实验_学生成绩管理系统
沈阳理工大学应用技术学院综合实验报告
综合性实验—学生成绩管理系统
班级:
数学092学号:
200912010210姓名:
同艳云实验仪器设备:
多媒体计算机。
实验目的:
在掌握相关基础知识的基础上,学会自己设计实验,熟练掌握JDBC技术访问数据库(或数据文件)的方法、在Java中进行数据库应用程序开发的方法和步骤,熟悉Swing组件特性和Action接口并能够恰当运用实现特定功能,会开发多窗体应用程序。
实验要求:
在8学时以内,制作出能够实现基本功能的学生成绩管理系统。
写出技术工作报告并附源程序。
实验内容及任务:
1(进行数据库(或数据文件)设计,数据分为学生信息、成绩管理、信息查询等三部分;使用学生信息表、课程表两个数据表来存放数据。
2(选择适当组件进行界面设计:
界面要美观大方,具有主菜单和相应工具栏及按钮;
3(编写事件代码:
能够实现学生信息维护(录入、修改和删除);学生信息浏览;按“学号”查询学生信息;按“姓名”和“所在班级”查询学生信息;按“学院名称”查询学生信息;按课程查询学生成绩等功能。
4(分析总结:
学生成绩管理系统
登录查询编辑存储管理
学学
生生系
登基统
录本管添删修信理加除改息
沈阳理工大学应用技术学院综合实验报告
1(数据库、数据表(或数据文件)设计;
1.1学生基本信息表包含的信息是学生编号、学生姓名、学生性别、学生年龄、家庭住址、联系电话等信息,设计时注意ID字段设为主键,设为Int类型,如表4.1所示:
表4.1学生基本信息表
字段名数据类型说明
IDInt学生编号
NameVarchar(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.7所示。
沈阳理工大学应用技术学院综合实验报告
图4.73.2修改学生信息界面,如图4.8所示。
图4.83.3.删除学生信息界面,如图4.9所示。
沈阳理工大学应用技术学院综合实验报告
图4.9
4.学生信息查询模块设计;
4.1按学号查找学生信息界面,如图4.10所示。
图4.10
4.2按姓名,学号查找学生信息界面,如图4.11所示。
沈阳理工大学应用技术学院综合实验报告
图4.11
实验总结:
通过本次实验设计,我对JAVA的知识又有了更深的了解,而且对Swing界面设计有了更深的领悟,而且更熟练使用JAVA和数据库的连接,以及对简单的数据库查询语言有了些许了解,然后在编程设计阶段还是遇到了许多问题,但是通过网上查询资料,以及和同学讨论这些问题都迎刃而解了,必须要有团结合作精神,而且要吃苦耐劳,耐心严谨,这次设计实验对我的知识技能和思维都是一个很好的锻炼。
附录
1(系统登录界面程序代码
importjava.awt.*;
importjava.awt.event.*;
importjavax.swing.*;
classWyFrameextendsFrameimplementsActionListener
{
Labell1,l2;
TextFieldt1,t2;
沈阳理工大学应用技术学院综合实验报告
Buttonb1,b2;
publicstaticintk;
publicWyFrame()
{
super("学生管理系统");
setBackground(Color.lightGray);
setLayout(null);
setSize(240,160);
this.setLocationRelativeTo(null);
l1=newLabel("用户名",Label.CENTER);
l2=newLabel("密码",Label.CENTER);
t1=newTextField();
t2=newTextField();
b1=newButton("登入");
b2=newButton("退出");
l1.setBounds(40,45,40,30);
l2.setBounds(40,80,40,30);
t1.setBounds(90,45,100,25);
t2.setBounds(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(newWindowAdapter(){
publicvoidwindowClosing(WindowEvente){
dispose();
System.exit(0);
}
});
setVisible(true);
}
publicvoidactionPerformed(ActionEvente)
{
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"))
{
MyMenuhyf=newMyMenu();
this.setVisible(false);
沈阳理工大学应用技术学院综合实验报告
}
else
{
if(t1.getText().toString().trim().equals("09321104"))
{
JOptionPane.showMessageDialog(this,"密码与用户名不匹配~");
}
else
JOptionPane.showMessageDialog(this,"用户名错误~");
}
}
if(k==2)
{
dispose();
System.exit(0);
}
}
}
publicclassLogin
{
publicstaticvoidmain(Stringargs[])
{
WyFramehyf=newWyFrame();
}
}
2.系统主界面程序代码(含有菜单)
importjava.awt.*;
importjava.awt.event.*;
importjava.util.*;
publicclassMyMenuextendsFrameimplementsActionListener
{
publicMyMenu()
{
super("学生管理系统");
setSize(400,300);
setBackground(Color.lightGray);
setVisible(true);
setLocationRelativeTo(null);
this.addWindowListener(newWindowAdapter(){
publicvoidwindowClosing(WindowEvente){
dispose();
System.exit(0);
}
});
Menufile=newMenu("文件");
MenuItemexit=newMenuItem("退出");
沈阳理工大学应用技术学院综合实验报告
file.add(exit);
Menustudent=newMenu("学生信息管理");
MenuItemins=newMenuItem("增加学生信息");
MenuItemdel=newMenuItem("删除学生信息");
MenuItemupd=newMenuItem("修改学生信息");
MenuItemsel=newMenuItem("查找学生信息");
student.add(ins);student.add(del);student.add(upd);student.add(sel);
MenuBarhyf=newMenuBar();
hyf.add(file);hyf.add(student);
setMenuBar(hyf);
exit.addActionListener(this);
ins.addActionListener(this);
del.addActionListener(this);
upd.addActionListener(this);
sel.addActionListener(this);
}
publicvoidactionPerformed(ActionEvente)
{
StringstrCmd=e.getActionCommand();
if(strCmd.equals("退出")){
System.exit(0);
}
if(strCmd.equals("增加学生信息")){
Insertins=newInsert();
}
if(strCmd.equals("删除学生信息")){
Insertdel=null;
}
if(strCmd.equals("修改学生信息")){
Updateupd=newUpdate();
}
if(strCmd.equals("查询学生信息")){
Selectsel=newSelect();
}
repaint();
}
}
3.添加学生信息界面程序代码
importjava.awt.*;
importjava.awt.event.*;
importjavax.swing.*;
importjava.util.*;
publicclassInsertextendsFrameimplementsActionListener,ItemListener
{
CheckboxGroupcg=newCheckboxGroup();
Labell1,l2,l3,l4,l5,l6,l7;
沈阳理工大学应用技术学院综合实验报告
TextFieldt1,t2,t3,t4,t5,t6,t7;
Buttonb1,b2;
Checkboxc1,c2;
publicstaticStudenthyf;
publicstaticStringa1,a2,a3,a4,a5,a6,a7;
publicInsert()
{
super("添加学生信息界面");
setBackground(Color.lightGray);
setLayout(null);
l1=newLabel("姓名",Label.CENTER);
l2=newLabel("性别",Label.CENTER);
l3=newLabel("出生日期",Label.CENTER);
l4=newLabel("学号",Label.CENTER);
l5=newLabel("计算机成绩",Label.CENTER);
l6=newLabel("英语成绩",Label.CENTER);
l7=newLabel("数学成绩",Label.CENTER);
c1=newCheckbox("男",cg,true);
c2=newCheckbox("女",cg,false);
c1.addItemListener(this);
c2.addItemListener(this);
t1=newTextField();
t2=newTextField();
t3=newTextField();
t4=newTextField();
t5=newTextField();
t6=newTextField();
t7=newTextField();
b1=newButton("确定");
b2=newButton("退出");
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);
add(c1);add(c2);
l1.setBounds(40,60,70,30);
l2.setBounds(40,90,70,30);
l3.setBounds(40,120,70,30);
l4.setBounds(40,150,70,30);
l5.setBounds(40,180,70,30);
l6.setBounds(40,210,70,30);
沈阳理工大学应用技术学院综合实验报告
l7.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.setBounds(120,240,100,30);
b1.setBounds(100,280,80,30);
b2.setBounds(200,280,80,30);
c1.setState(true);
a2="男";
addWindowListener(newWindowAdapter()
{
publicvoidwindowClosing(WindowEvente)
{
dispose();
System.exit(0);
}
});//关闭窗口
setSize(400,350);
setLocationRelativeTo(null);
setVisible(true);
}
publicvoiditemStateChanged(ItemEvente)
{
if(e.getItemSelectable()==c1)
a2="男";
if(e.getItemSelectable()==c2)
a2="女";
}
publicvoidactionPerformed(ActionEvente)
{
StringstrCmd=e.getActionCommand();
if(strCmd.equals("退出")){this.hide();}
if(strCmd.equals("确定"))
{
a1=t1.getText();
charc1[]=a2.toCharArray();
a3=t3.getText();
a4=t4.getText();
a5=t5.getText();
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.修改学生记录界面程序代码
importjava.awt.*;
importjava.awt.event.*;
importjavax.swing.*;
importjava.util.*;
publicclassUpdateextendsFrameimplementsActionListener
{
Labell1,l2,l3,l4,l5,l6,l7;
TextFieldt1,t2,t3,t4,t5,t6,t7;
Buttonb1,b2;
publicstaticStringa1,a2,a3,a4,a5,a6,a7;
publicUpdate()
{
super("学生管理增加学生界面");
setBackground(Color.lightGray);
setLayout(null);
l1=newLabel("姓名",Label.CENTER);
l2=newLabel("性别",Label.CENTER);
l3=newLabel("出生日期",Label.CENTER);
l4=newLabel("学号",Label.CENTER);
l5=newLabel("计算机成绩",Label.CENTER);
l6=newLabel("英语成绩",Label.CENTER);
l7=newLabel("数学成绩",Label.CENTER);
t1=newTextField();
t2=newTextField();
t3=newTextField();
t4=newTextField();
t5=newTextField();
t6=newTextField();
t7=newTextField();
b1=newButton("确定");
b2=newButton("退出");
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);
沈阳理工大学应用技术学院综合实验报告
l1.setBounds(40,60,70,30);
l2.setBounds(40,90,70,30);
l3.setBounds(40,120,70,30);
l4.setBounds(40,150,70,30);
l5.setBounds(40,180,70,30);
l6.setBounds(40,210,70,30);
l7.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);
b1.setBounds(100,280,80,30);
b2.setBounds(200,280,80,30);
addWindowListener(newWindowAdapter()
{
publicvoidwindowClosing(WindowEvente)
{
dispose();
System.exit(0);
}
});//关闭窗口
setSize(400,350);
setLocationRelativeTo(null);
setVisible(true);
}
publicvoidactionPerformed(ActionEvente)
{
StringstrCmd=e.getActionCommand();
if(strCmd.equals("退出")){this.hide();}
if(strCmd.equals("确定"))
{
a1=t1.getText();
Stringa2=t2.getText();
charc1[]=a2.toCharArray();
a3=t3.getText();
a4=t4.getText();
a5=t5.getText();
a6=t6.getText();
a7=t7.getText();
Insert.hyf.name=a1;
Insert.hyf.sex=c1[0];
Insert.hyf.birthday=a3;
Insert.hyf.number=a4;
沈阳理工大学应用技术学院综合实验报告
Insert.hyf.setcompScore(Integer.parseInt(a5.trim()));
Insert.hyf.setengScore(Integer.parseInt(a6.trim()));
Insert.hyf.setmathScore(Integer.parseInt(a7.trim()));
}
repaint();
}
}
5.查找学生记录界面程序设计
importjava.awt.*;
importjava.awt.event.*;
importjavax.swing.*;
importja