JAVA编写的学生成绩管理系统.docx
- 文档编号:9278317
- 上传时间:2023-02-04
- 格式:DOCX
- 页数:58
- 大小:143.13KB
JAVA编写的学生成绩管理系统.docx
《JAVA编写的学生成绩管理系统.docx》由会员分享,可在线阅读,更多相关《JAVA编写的学生成绩管理系统.docx(58页珍藏版)》请在冰豆网上搜索。
JAVA编写的学生成绩管理系统
用JAVA编写的集美大学学生成绩管理系统
▼
标签:
数据库
学生成绩
集美大学
记录
主窗体
it
分类:
JAVA
开发平台Eclipse
版本1.0
完成时间2012.09.09
运行的基本条件
1.安装了WindowsSQL2005
2.进行了相应的设置,包括IIS的安装,可以参考网络上的资料
3.完全使用该系统,需要对数据库进行添加相应的表。
如没有进行这项工作,无法使用该系统,使用过程中会报错!
下面是运行中的界面:
下面是源代码:
importjava.awt.*;
importjava.sql.*;
importjavax.swing.*;
importjava.awt.event.*;
publicclasshcj
{
publicstaticMonitormymonitor=newMonitor();
publicstaticJLabelwelcome,usename1,password1;
publicstaticTextFieldusename2,password2;
publicstaticJButtonenter1,close1;
publicstaticJFrameEnterfrm;
publicstaticvoidmain(String[]args)
{
hcjmyke=newhcj();
}
//创建类名的构造方法
publichcj()
{
//登陆窗体布局
Enterfrm=newJFrame("登陆窗体");
Toolkitkit=Toolkit.getDefaultToolkit();
DimensionscreenSize=kit.getScreenSize();
intscreenWidth=screenSize.width;
intscreenHeight=screenSize.height;
welcome=newJLabel("欢迎进入集美大学成绩管理系统");
welcome.setFont(newFont("宋体",Font.BOLD,22));
usename1=newJLabel("用户名:
");
password1=newJLabel("密码:
");
usename2=newTextField(12);
password2=newTextField(12);
enter1=newJButton("确定");
close1=newJButton("退出");
JPanelp1=newJPanel();
JPanelp2=newJPanel();
JPanelp3=newJPanel();
JPanelp4=newJPanel();
JPanelp5=newJPanel();
password2.setEchoChar('*');
p4.add(usename1);
p4.add(usename2);
p4.add(enter1);
p5.add(password1);
p5.add(password2);
p5.add(close1);
p3.setLayout(newGridLayout(2,1));
p2.add("Center",welcome);
p3.add(p4);
p3.add(p5);
p1.add(p2);
p1.add(p3);
p1.setLayout(newGridLayout(2,1));
Containerk=Enterfrm.getContentPane();
k.add(p1);
Enterfrm.setSize(screenWidth/3,screenHeight/3);
Enterfrm.setLocation(480,200);
Enterfrm.addWindowListener(newWindowAdapter()
{
publicvoidwindowClosing(WindowEvente)
{
System.exit(0);
}
});
Enterfrm.show();
enter1.addActionListener(mymonitor);
close1.addActionListener(mymonitor);
}
}
//登陆窗口
classMonitorimplementsActionListener
{
publicStringun1="gaoxiushi",pw1="05";
publicStringun2="2009716040",pw2="593278100";
publicStringun3="1",pw3="1";
publicvoidactionPerformed(ActionEvente)
{
if(e.getSource()==hcj.enter1)
{
if((hcj.usename2.getText().equals(un1)&&hcj.password2.getText()
.equals(pw1))
||(hcj.usename2.getText().equals(un2)&&hcj.password2
.getText().equals(pw2))
||(hcj.usename2.getText().equals(un3)&&hcj.password2
.getText().equals(pw3)))
{
hcj.Enterfrm.setVisible(false);
mainfrmmf=newmainfrm();
}else
{
JOptionPane.showMessageDialog(null,"对不起您的输入有误,请重新输入!
");
hcj.usename2.setText("");
hcj.password2.setText("");
}
}
if(e.getSource()==hcj.close1)
{
System.exit(0);
}
}
}
//主窗体
classmainfrmimplementsActionListener
{
publicstaticJMenuTeacherMenu,StudentMenu,MarkMenu,HelpMenu;
publicstaticJMenuItemTMfind,TMedit,TMdelete,SMfind,SMedit,SMdelete,
MMfind,MMedit,MMalter,HMabout;
publicstaticJFramemainf;
publicstaticJLabelroom,room1;
publicmainfrm()
{
mainf=newJFrame("主窗体");
JMenuBarmyMenuBar=newJMenuBar();//创建菜单栏
TeacherMenu=newJMenu("教师管理");
TMfind=newJMenuItem("查询记录");
TMfind.addActionListener(this);
TMedit=newJMenuItem("录入记录");
TMedit.addActionListener(this);
TMdelete=newJMenuItem("删除记录");
TMdelete.addActionListener(this);
StudentMenu=newJMenu("学生管理");
SMfind=newJMenuItem("查询记录");
SMfind.addActionListener(this);
SMedit=newJMenuItem("录入记录");
SMedit.addActionListener(this);
SMdelete=newJMenuItem("删除记录");
SMdelete.addActionListener(this);
MarkMenu=newJMenu("成绩管理");
MMfind=newJMenuItem("成绩查询");
MMfind.addActionListener(this);
MMedit=newJMenuItem("成绩录入");
MMedit.addActionListener(this);
MMalter=newJMenuItem("修改");
MMalter.addActionListener(this);
HelpMenu=newJMenu("帮助");
HMabout=newJMenuItem("关于");
HMabout.addActionListener(this);
//将菜单栏添加到主窗体的框架中
mainf.setJMenuBar(myMenuBar);
myMenuBar.add(TeacherMenu);
myMenuBar.add(StudentMenu);
myMenuBar.add(MarkMenu);
myMenuBar.add(HelpMenu);
TeacherMenu.add(TMfind);
TeacherMenu.add(TMedit);
TeacherMenu.add(TMdelete);
StudentMenu.add(SMfind);
StudentMenu.add(SMedit);
StudentMenu.add(SMdelete);
MarkMenu.add(MMedit);
MarkMenu.add(MMfind);
MarkMenu.add(MMalter);
HelpMenu.add(HMabout);
JPanelpa1=newJPanel();
pa1.setLayout(newGridLayout(4,1));
JPanelpa2=newJPanel();
JPanelpa3=newJPanel();
JPanelpa4=newJPanel();
room=newJLabel("集美大学学生成绩管理信息系统");
room.setFont(newFont("宋体",Font.BOLD,35));
//获得框架的内容层板
mainf.getContentPane().add(pa1,BorderLayout.NORTH);
room1=newJLabel("JMU版权所有AllRightReversed");
room1.setFont(newFont("宋体",Font.BOLD,20));
//获得框架的内容层板
mainf.getContentPane().add(pa4,BorderLayout.SOUTH);
pa1.add(pa3);
pa1.add(pa2);
pa1.add(pa4);
pa2.add(room);
pa4.add(room1);
mainf.setSize(700,500);
mainf.setLocation(400,80);
mainf.setResizable(false);
mainf.addWindowListener(newWindowAdapter()
{
publicvoidwindowClosing(WindowEvente)
{
System.exit(0);
}
});
mainf.show();
}
publicvoidactionPerformed(ActionEvente)
{
if((e.getSource()==mainfrm.TMfind)
||(e.getSource()==mainfrm.TMedit)
||(e.getSource()==mainfrm.TMdelete))
{
teafrm1tf1=newteafrm1();
}
if((e.getSource()==mainfrm.SMfind)
||(e.getSource()==mainfrm.SMdelete))
{
stufrm1sf1=newstufrm1();
}
if(e.getSource()==mainfrm.SMedit)
{
stufrm2sf2=newstufrm2();
}
if(e.getSource()==mainfrm.MMfind)
{
markfrm1mf1=newmarkfrm1();
}
if((e.getSource()==mainfrm.MMalter)
||(e.getSource()==mainfrm.MMedit))
{
markfrm2mf2=newmarkfrm2();
}
if(e.getSource()==mainfrm.HMabout)
{
AboutFrmaf1=newAboutFrm();
}
}
}
//实现关于窗体类
classAboutFrmimplementsActionListener
{
staticJFrameaboutfrm=newJFrame("关于");
publicAboutFrm()
{
JLabelj1=newJLabel("集美大学学生成绩管理系统");
JTextAreata1=newJTextArea("设计者:
胡成健");
ta1.setEnabled(false);
JTextAreata2=newJTextArea("院系:
集美大学机械工程学院");
ta2.setEnabled(false);
JTextAreata3=newJTextArea("版权所有Copyright(C)2012");
ta3.setEnabled(false);
JButtonmbtn=newJButton("谢谢");
JPanelmp=newJPanel();
JPanelmp2=newJPanel();
aboutfrm.getContentPane().setLayout(newBorderLayout());
mp.setLayout(newGridLayout(4,1));
mp.add(j1);
mp.add(ta1);
mp.add(ta2);
mp.add(ta3);
mp2.add(mbtn);
Containerc=aboutfrm.getContentPane();
c.add(mp,"North");
c.add(mp2,"South");
mbtn.addActionListener(this);
aboutfrm.setSize(220,150);
aboutfrm.setLocation(500,250);
//aboutfrm.setTitle("记事本");
aboutfrm.setResizable(false);
aboutfrm.show();
}
publicvoidactionPerformed(ActionEvente)
{
AboutFrm.aboutfrm.dispose();
}
}
//查询、录入、删除教师记录窗体
classteafrm1implementsActionListener
{//throwsIOException
Stringid,name,sex,department,phone;
Connectionconn;
ResultSetrs;
Statementst;
publicstaticJFrameteaf;
publicJPanelp1,p2,p3,p4,p5,p6,p7,p8;
publicJLabelNumL,nameL,sexL,departmentL,phoneL;
publicJTextFieldtf,Num,nameT,sexT,departmentT,phoneT;
publicJButtonsearch,closeT,delete,insert;
publicteafrm1()
{
//窗体布局
teaf=newJFrame("查询、录入、删除教师记录");
teaf.setSize(360,360);
teaf.setResizable(false);
id=newString();
name=newString();
sex=newString();
department=newString();
phone=newString();
NumL=newJLabel("教师号:
");
nameL=newJLabel("姓名:
");
sexL=newJLabel("性别:
");
departmentL=newJLabel("部门:
");
phoneL=newJLabel("电话:
");
tf=newJTextField(16);
Num=newJTextField(20);
nameT=newJTextField(20);
sexT=newJTextField(20);
departmentT=newJTextField(20);
phoneT=newJTextField(20);
p1=newJPanel();
p2=newJPanel();
p3=newJPanel();
p4=newJPanel();
p5=newJPanel();
p6=newJPanel();
p7=newJPanel();
p8=newJPanel();
delete=newJButton("删除");
search=newJButton("查找");
insert=newJButton("录入");
closeT=newJButton("退出");
closeT.addActionListener(this);
p2.add(search);
p2.add(tf);
p3.add(NumL);
p3.add(Num);
p4.add(nameL);
p4.add(nameT);
p5.add(sexL);
p5.add(sexT);
p6.add(departmentL);
p6.add(departmentT);
p7.add(phoneL);
p7.add(phoneT);
p8.add(insert);
p8.add(delete);
p8.add(closeT);
p1.setLayout(newGridLayout(7,1));
p1.add(p2);
p1.add(p3);
p1.add(p4);
p1.add(p5);
p1.add(p6);
p1.add(p7);
p1.add(p8);
Containerc=teaf.getContentPane();
c.add(p1);
teaf.addWindowListener(newWindowAdapter()
{
publicvoidwindowClosing(WindowEvente)
{
teafrm1.teaf.dispose();
}
});
teaf.setLocation(200,200);
teaf.show();
search.addActionListener(this);
delete.addActionListener(this);
insert.addActionListener(this);
conDB();
}
//以下是连接数据库
publicvoidconDB()
{
try
{
//加载数据库驱动
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}catch(ClassNotFoundExceptione)
{
JOptionPane.showMessageDialog(null,"数据库加载失败!
");
}
try
{
//连接数据库
conn=DriverManager.getConnection("jdbc:
odbc:
odbctest");
st=conn.createStatement();
}
catch(SQLExceptione)
{
JOptionPane.showMessageDialog(null,"数据库连接失败!
");
}
}
//以下是关闭数据库
publicvoidcloseDB()
{
try
{
conn.close();
}
catch(SQLExceptione)
{
JOptionPane.showMessageDialog(null,"数据库关闭失败!
");
}
}
//以下是针对数据库的各种操作
publicvoidactionPerformed(ActionEvente)
{
//以下执行查询教师记录操作
if(e.getSource()==search)
{
try
{
Stringid=tf.getText();
StringstrSQL="selectteanum,teaname,sex,department,phone"
+"fromteacherwhereteanum='"+id+"'";
ResultSetrs=st.executeQuery(strSQL);
intcount=0;
while(rs.ne
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- JAVA 编写 学生 成绩管理系统
![提示](https://static.bdocx.com/images/bang_tan.gif)