学生成绩管理系统.docx
- 文档编号:5206678
- 上传时间:2022-12-13
- 格式:DOCX
- 页数:29
- 大小:165.04KB
学生成绩管理系统.docx
《学生成绩管理系统.docx》由会员分享,可在线阅读,更多相关《学生成绩管理系统.docx(29页珍藏版)》请在冰豆网上搜索。
学生成绩管理系统
目录
一设计目的1
二功能介绍1
三程序流程1
四设计步骤1
1任务解析1
2功能实现1
3系统测试......................................................2
五设计总结.......................................................19
六参考文献19
一设计目的
巩固和加深学生对高级语言程序设计课程的基本知识的理解和掌握,掌握JAVA语言编程和程序调试的基本技能,利用JAVA语言进行基本的软件设计,提高运用JAVA语言解决实际问题的能力。
二功能介绍
实现学生成绩的(增、删、改、查询、持久化、成绩排序、成绩统计等功能)在文件中增加、删除学生信息,根据学号查询、修改学生信息。
统计功能求每个人的总分并按从高到低排序,通过这些操作对文件中的信息进行保存。
三程序流程
四设计步骤
1任务解析
具有新用户注册功能,具有注册用户登录功能,具有学生成绩的录入功能,要求只录入各科成绩,自动计算每个学生的总成绩。
具有数据查询功能,可以实现查询全部信息和按条件执行查询。
具有按条件删除数据功能。
2功能实现
(1)登录
进入登陆界面输入用户名及密码,通过查询数据库判断用户密码及存在,进入登录后的页面。
(2)操作页面
有查询、删除、修改、添加、等。
3系统测试
(1)登陆界面
importjava.awt.*;
importjava.awt.event.*;
importjava.sql.*;
importjavax.swing.*;
publicclassLoginextendsJFrame{
//声明标签,按钮,文本框,和密码框
privateJLabelJLb1;
privateJLabelJLb2;
privateJButtonOk_btn;
privateJButtonCancel_btn;
privateJTextFieldjtflduser;
privateJPasswordFieldjtpwdfld;
//声明窗口
privateJFrameframe;
publicLogin(){
frame=newJFrame("登陆");
Containercontent=frame.getContentPane();
//采用gridlayou布局管理器
content.setLayout(newGridLayout(3,2,20,20));
JLb1=newJLabel("用户名");
JLb2=newJLabel("密码");
//将标签置于剧中的位置
JLb1.setHorizontalAlignment(SwingConstants.CENTER);
JLb2.setHorizontalAlignment(SwingConstants.CENTER);
jtflduser=newJTextField();
jtpwdfld=newJPasswordField();
Ok_btn=newJButton("确定");
Cancel_btn=newJButton("取消");
//为按钮添加事件监听
Ok_btn.addActionListener(newActionHandler());
Cancel_btn.addActionListener(newActionHandler());
//添加标签,和文本框,密码框和那妞到窗口
content.add(JLb1);
content.add(jtflduser);
content.add(JLb2);
content.add(jtpwdfld);
content.add(Ok_btn);
content.add(Cancel_btn);
frame.pack();
//设定登陆窗口启动时出现在屏幕中央位置
frame.setLocationRelativeTo(null);
frame.setSize(300,200);
frame.setVisible(true);
}
//实现事件监听,激活组件响应
classActionHandlerimplementsActionListener{
publicvoidactionPerformed(ActionEvente)
{
Stringstr1,str2,sqlStr;
Objectobj=e.getSource();
//获得文本框和密码框的数据
str1=jtflduser.getText().trim();
str2=newString(jtpwdfld.getPassword()).trim();
try{
//点击确定按钮
if(obj.equals(Ok_btn))
{
if(str1.equals(""))
{JOptionPane.showMessageDialog(frame,"用户名不能为空");
return;
}//创建数据库链接
jdbcfileconn=newjdbcfile();
//产生登陆SQL语句
sqlStr="select*fromAdminwherename='"+str1+"'andpassword='"+str2+"'";
ResultSetresult=conn.executeQuery(sqlStr);
if(result.next())
{
//弹出对话框提示登陆成功
JOptionPane.showMessageDialog(frame,"登陆成功");
bookmainbookmain1=newbookmain();
bookmain1.go();
//关闭登陆窗口
frame.dispose();
//关闭数据链接
conn.close();
}
else
JOptionPane.showMessageDialog(frame,"用户名或密码错误");
}
elseif(obj.equals(Cancel_btn))
System.exit(0);
}
catch(ClassNotFoundExceptionce)
{System.out.println("SQLException:
"+ce.getMessage());}
catch(SQLExceptionex)
{System.out.println(ex);}
catch(Exceptions)
{s.printStackTrace();}
}
}
publicstaticvoidmain(Stringargs[])
{Loginlogin=newLogin();
}
}
(2)登陆后的界面
importjava.awt.*;
importjava.text.*;
importjavax.swing.*;
importjava.awt.event.*;
importjava.sql.*;
importjavax.swing.table.*;
importjava.io.*;
importjava.util.Vector;
publicclassasan1extendsWindowAdapterimplementsActionListener
{
JFrameframe;//进入系统界面
JFrameframe1;//主界面
JFrameFrame_Add;//添加学生的窗口
JFrameFrame_Del;//删除学生的窗口
JFrameFrame_Updata;//修改学生的窗口
JFrameFrame_Show;//查看学生的窗口
JTextFieldnum=newJTextField(20);//学号
JTextFieldname=newJTextField(20);//姓名
JTextFieldgreat=newJTextField(20);//计算机
JTextFieldenglish=newJTextField(20);//英语
JTextFieldmath=newJTextField(20);//数学
JTextFieldcomputer=newJTextField(20);//计算机
JComboBoxpl;
publicasan1()
{
stu_in();
}
publicvoidsetfont(JButtonbutton)//设置按钮的大小及字体
{
button.setFont(newFont("华文彩云",Font.PLAIN,18));
button.setForeground(java.awt.Color.blue);
}
publicvoidstu_in()
{
frame=newJFrame("学生成绩管理系统");
frame.setBounds(150,200,600,300);//窗口大小及开始在屏幕上的位置。
Containercp=frame.getContentPane();
cp.setLayout(newBorderLayout());
BackImagep=newBackImage();
p.setLayout(newGridBagLayout());
GridBagConstraintsc=newGridBagConstraints();
cp.add(p,BorderLayout.CENTER);
JLabellabel=newJLabel("xx大学计算机学院08级8班xx");
label.setFont(newFont("华文彩云",Font.PLAIN,30));
JButtonbut_in=newJButton("进入系统");
JButtonbut_out=newJButton("退出系统");
but_in.setFont(newFont("华文彩云",Font.PLAIN,30));
but_out.setFont(newFont("华文彩云",Font.PLAIN,30));
but_in.addActionListener(this);
but_out.addActionListener(this);
p.add(but_in,c);
p.add(but_out,c);
frame.add(label,BorderLayout.PAGE_START);
frame.setResizable(false);//窗口不随鼠标拖动而改变大小
frame.addWindowFocusListener(this);//添加窗口的监控类
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.show();
}
publicintmian_JFrame()throwsException
{
JPanelpane=newJPanel();
frame1=newJFrame("学生成绩管理系统");
JTablefriends=newJTable();
DefaultTableModeldt=newDefaultTableModel();
friends.setModel(dt);
VectorvecColumnName=newVector();//列名集合
intnumberOfColumns;
intb=1;
Stu_ChangeSadd=newStu_Change();
try
{
Sadd.stuSum();
Data_accessDB=newData_access();
numberOfColumns=DB.rsmd.getColumnCount();
//以下是显示数据库中的列名的代码
dt.addColumn("学号");
dt.addColumn("姓名");
dt.addColumn("班级");
dt.addColumn("英语");
dt.addColumn("数学");
dt.addColumn("计算机");
dt.addColumn("总分");
//以下是在表格中显示数据中的内容
while(DB.rs.next())
{
VectornewRow=newVector();
intc=1;
while(c<=numberOfColumns)
{
newRow.addElement(DB.rs.getString(c));
c++;
}
dt.addRow(newRow);
}
}catch(Exceptionex)
{
JOptionPane.showMessageDialog(null,"连接数据库失败","数据连接",JOptionPane.ERROR_MESSAGE);
return0;
};
friends.setPreferredScrollableViewportSize(newDimension(580,200));//设置表格的大小
friends.setRowHeight(25);//设置每行的高度为20
friends.setRowHeight(0,25);//设置第1行的高度为20
friends.setRowMargin
(2);//设置相邻两行单元格的距离5
friends.setRowSelectionAllowed(true);//设置可否被选择.默认为false
friends.setSelectionBackground(Color.white);//设置所选择行的背景色
friends.setSelectionForeground(Color.red);//设置所选择行的前景色
friends.setGridColor(Color.black);//设置网格线的颜色
friends.clearSelection();//取消选择
friends.setDragEnabled(false);//不懂这个
friends.setShowGrid(false);//是否显示网格线
friends.setShowHorizontalLines(false);//是否显示水平的网格线
friends.setShowVerticalLines(true);//是否显示垂直的网格线
//friends.setEditable(false);
friends.doLayout();
friends.setBackground(Color.lightGray);
JScrollPanepane3=newJScrollPane(friends);//JTable最好加在JScrollPane上
pane.setPreferredSize(newDimension(600,300));
pane.setBackground(Color.orange);
JPanelpanel=newJPanel(newFlowLayout());
JButtonbut1=newJButton("添加数据");
setfont(but1);
panel.add(but1);
JButtonbut2=newJButton("修改数据");
setfont(but2);
panel.add(but2);
JButtonbut3=newJButton("删除数据");
setfont(but3);
panel.add(but3);
JButtonbut4=newJButton("查看数据");
setfont(but4);
panel.add(but4);
JButtonbut5=newJButton("保存退出");
setfont(but5);
panel.add(but5);
JPanelpane2=newJPanel(newBorderLayout());
JLabellabel=newJLabel("xx大学计算机学院08级8班xx");
pane.add(panel,BorderLayout.PAGE_END);
pane.add(pane3,BorderLayout.SOUTH);
pane.add(label,BorderLayout.LINE_END);
but1.addActionListener(this);
but2.addActionListener(this);
but3.addActionListener(this);
but4.addActionListener(this);
but5.addActionListener(this);
frame1.setBounds(150,200,600,300);//窗口大小及开始在屏幕上的位置。
frame1.setContentPane(pane);
frame1.pack();
frame1.setResizable(false);//窗口不随鼠标拖动而改变大小
frame1.addWindowFocusListener(this);//添加窗口的监控类
frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame1.show();
return0;
}
publicvoidactionPerformed(ActionEvente)//各按钮的事件处理
{
Strings;
s=e.getActionCommand();//记录按钮的名称
//Objectobj=e.getSource();
//if(obj==add)
if(s=="退出系统")
{
try//延迟函数
{
Thread.currentThread().sleep(1000);
}
catch(InterruptedExceptione1){}
frame.setVisible(false);//窗口自动消失
}
elseif(s=="进入系统")
{
frame.setVisible(false);//窗口自动消失
try
{
mian_JFrame();
}catch(Exceptione1){};
}
elseif(s=="保存退出")
{
try//延迟函数
{
Thread.currentThread().sleep(500);
}
catch(InterruptedExceptione1){}
frame1.setVisible(false);//窗口自动消失
}
elseif(s=="添加数据")
{
try//延迟函数
{
stu_add();
}
catch(Exceptione1){}
}
elseif(s=="修改数据")
{
try//延迟函数
{
stu_updata();
}
catch(Exceptione1){}
}
elseif(s=="删除数据")
{
try//延迟函数
{
stu_del();
}
catch(Exceptione1){}
}
elseif(s=="查看数据")
{
try//延迟函数
{
stu_show();
}
catch(Exceptione1){}
}
elseif(s=="添加")
{
Stu_ChangeSadd=newStu_Change();
Sadd.stuAdd(num.getText(),name.getText(),great.getText(),Integer.valueOf(english.getText()),Integer.valueOf(math.getText()),Integer.valueOf(computer.getText()));
try//延迟函数
{
frame1.setVisible(false);//窗口自动消失
Frame_Add.setVisible(false);
mian_JFrame();
stu_add();
}
catch(Exceptione1){}
}
elseif(s=="清空")
{
num.setText("");//学号
name.setText("");//姓名
great.setText("");//计算机
english.setText("");//英语
math.setText("");//数学
computer.setText("");//计算机
}
elseif(s=="退出")
{
try//延迟函数
{
Frame_Add.setVisible(false);//窗口自动消
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 学生 成绩管理系统
![提示](https://static.bdocx.com/images/bang_tan.gif)