学生档案管理系统Java程序.docx
- 文档编号:5916232
- 上传时间:2023-01-02
- 格式:DOCX
- 页数:150
- 大小:62.13KB
学生档案管理系统Java程序.docx
《学生档案管理系统Java程序.docx》由会员分享,可在线阅读,更多相关《学生档案管理系统Java程序.docx(150页珍藏版)》请在冰豆网上搜索。
学生档案管理系统Java程序
南华大学
计算机科学与技术学院
Java精读程序分析报告
(2008~2009学年度第一学期)
程序名称:
学生档案管理系统
专业班级:
计算机科学与技术专业061班
指导老师:
谭敏生
小组成员:
姓名
学号
姓名
学号
姓名
学号
姓名
学号
姓名
学号
学生档案管理系统
——Java精读程序一
//☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆//
1.about.java//程序功能:
程序分析成员:
//☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆//
packagestudentsystem;
importjava.awt.*;
importjavax.swing.*;
importjava.awt.event.*;
publicclassaboutextendsJDialog{
JPanelpanel1=newJPanel();
ImageIconicon=newImageIcon("xuan.jpg");//设置背景图片
JLabeljLabel1=newJLabel(icon);
JButtonsure=newJButton();
publicabout(Frameframe,Stringtitle,booleanmodal){
super(frame,title,true);
try{
jbInit();
pack();
}
catch(Exceptionex){
ex.printStackTrace();
}
}
publicabout(){
this(null,"",true);
}
privatevoidjbInit()throwsException{
jLabel1.setText("");
jLabel1.setBounds(newRectangle(5,5,392,250));
panel1.setBounds(newRectangle(0,299,1,1));
panel1.setLayout(null);
jLabel1.setText("");
jLabel1.setBounds(newRectangle(-43,0,414,245));
sure.setBounds(newRectangle(109,243,79,29));
sure.setFont(newjava.awt.Font("Dialog",0,15));
sure.setText("确定");
jLabel1.setToolTipText("leeyingzhang制作!
");
sure.addActionListener(newabout_sure_actionAdapter(this));
this.setTitle("呵呵!
");
this.getContentPane().add(panel1,null);
this.getContentPane().add(sure,null);
this.getContentPane().add(jLabel1,null);
this.setBounds(200,200,330,310);
this.getContentPane().setLayout(null);
this.setVisible(true);
}
voidsure_actionPerformed(ActionEvente){
this.dispose();
}
}
classabout_sure_actionAdapterimplementsjava.awt.event.ActionListener{
aboutadaptee;
about_sure_actionAdapter(aboutadaptee){
this.adaptee=adaptee;
}
publicvoidactionPerformed(ActionEvente){
adaptee.sure_actionPerformed(e);
}
}
//☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆//
2.addresult.java//程序功能:
程序分析成员:
//☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆//
packagestudentsystem;
importjavax.swing.*;
importjava.awt.*;
importjava.awt.event.*;
importjava.sql.*;
publicclassaddresult
extendsJFrame{
JLabeljLabel1=newJLabel();
JComboBoxksbh=newJComboBox();
JLabeljLabel2=newJLabel();
JLabeljLabel3=newJLabel();
JLabeljLabel4=newJLabel();
JLabeljLabel5=newJLabel();
JLabeljLabel6=newJLabel();
JComboBoxxh=newJComboBox();
JComboBoxkc=newJComboBox();
JComboBoxbh=newJComboBox();
JTextFieldxm=newJTextField();
JTextFieldfs=newJTextField();
JButtonok=newJButton();
JButtonocancel=newJButton();
Statementps,is,kcs,cr,xms;
ResultSetrs,as,xzkc,xsxm;
Connectioncon;
Stringurl;
publicaddresult(){
try{
jbInit();
}
catch(Exceptione){
e.printStackTrace();
}
/****************JDBC-ODBC连接数据库,并读取数据库*************/
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connectioncon=DriverManager.getConnection(
"jdbc:
odbc:
lee",
"sa","123");
ps=con.createStatement(ResultSet.
TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
is=con.createStatement(ResultSet.
TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
kcs=con.createStatement(ResultSet.
TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
cr=con.createStatement(ResultSet.
TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
xms=con.createStatement(ResultSet.
TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
}
catch(Exceptionerr){
Stringerror=err.getMessage();
Loglog=newLog();
log.addLog("\r\r","数据库连接出错");
log.closeStream();
JOptionPane.showMessageDialog(null,"连接数据库错误!
");
}
try{
rs=ps.executeQuery("selectdistinctclass_NOfromstudent");//ORDERBYclass_NODESC
while(rs.next()){
//xh.addItem(rs.getString("student_ID"));
bh.addItem(rs.getString("class_NO"));
xzkc=kcs.executeQuery("select*fromgradecourse");//ORDERBYclass_NODESC
while(xzkc.next()){
//xh.addItem(rs.getString("student_ID"));
kc.addItem(xzkc.getString("course_Name"));
}
}
}
catch(Exceptionerr){
Stringerror=err.getMessage();
JOptionPane.showMessageDialog(null,error);
}
}
publicstaticvoidmain(String[]args){
addresultaddresult=newaddresult();
}
privatevoidjbInit()throwsException{
jLabel1.setFont(newjava.awt.Font("Dialog",0,15));
jLabel1.setText("考试编号");
jLabel1.setBounds(newRectangle(13,11,67,28));
this.setLocale(java.util.Locale.getDefault());
this.setResizable(false);
this.setState(Frame.NORMAL);
this.setTitle("添加成绩信息");
this.getContentPane().setLayout(null);
ksbh.setFont(newjava.awt.Font("Dialog",0,15));
ksbh.setBounds(newRectangle(77,12,132,26));
ksbh.addItem("期中");
ksbh.addItem("期末");
jLabel2.setBounds(newRectangle(214,8,63,28));
jLabel2.setText("选择班号");
jLabel2.setFont(newjava.awt.Font("Dialog",0,15));
jLabel3.setBounds(newRectangle(7,54,67,28));
jLabel3.setText("选择学号");
jLabel3.setFont(newjava.awt.Font("Dialog",0,15));
jLabel4.setBounds(newRectangle(217,51,63,28));
jLabel4.setText("姓名");
jLabel4.setFont(newjava.awt.Font("Dialog",0,15));
jLabel5.setBounds(newRectangle(215,89,64,28));
jLabel5.setText("输入分数");
jLabel5.setFont(newjava.awt.Font("Dialog",0,15));
jLabel6.setBounds(newRectangle(9,92,67,28));
jLabel6.setText("选择课程");
jLabel6.setFont(newjava.awt.Font("Dialog",0,15));
xh.setFont(newjava.awt.Font("Dialog",0,15));
xh.setBounds(newRectangle(75,55,138,24));
xh.addItemListener(newaddresult_xh_itemAdapter(this));
kc.setFont(newjava.awt.Font("Dialog",0,15));
kc.setBounds(newRectangle(75,87,138,27));
bh.setFont(newjava.awt.Font("Dialog",0,15));
bh.setBounds(newRectangle(280,8,96,27));
bh.addItemListener(newaddresult_bh_itemAdapter(this));
xm.setText("");
xm.setBounds(newRectangle(280,50,96,26));
fs.setText("");
fs.setBounds(newRectangle(280,90,97,27));
ok.setBounds(newRectangle(83,142,89,32));
ok.setFont(newjava.awt.Font("Dialog",0,15));
ok.setText("确定");
ok.addActionListener(newaddresult_ok_actionAdapter(this));
ocancel.setText("退出");
ocancel.addActionListener(newaddresult_ocancel_actionAdapter(this));
ocancel.setBounds(newRectangle(206,142,89,32));
ocancel.setFont(newjava.awt.Font("Dialog",0,15));
this.getContentPane().add(jLabel1,null);
this.getContentPane().add(ksbh,null);
this.getContentPane().add(jLabel3,null);
this.getContentPane().add(jLabel6,null);
this.getContentPane().add(kc,null);
this.getContentPane().add(xm,null);
this.getContentPane().add(bh,null);
this.getContentPane().add(fs,null);
this.getContentPane().add(jLabel5,null);
this.getContentPane().add(jLabel4,null);
this.getContentPane().add(jLabel2,null);
this.getContentPane().add(xh,null);
this.getContentPane().add(ocancel,null);
this.getContentPane().add(ok,null);
this.setBounds(300,300,400,250);
this.setVisible(true);
}
voidocancel_actionPerformed(ActionEvente){
this.dispose();
}
voidbh_itemStateChanged(ItemEvente){//从数据库中读取数据,并显示
try{xh.removeAllItems();
as=is.executeQuery(
"selectdistinctstudent_IDfromstudentwhereclass_NO='"+
bh.getSelectedItem()+"'");//ORDERBYclass_NODESC
while(as.next()){
xh.addItem(as.getString("student_ID"));
}
}
catch(Exceptionerr){
err.printStackTrace();
Stringerror=err.getMessage();
JOptionPane.showMessageDialog(null,error);
}
}
voidok_actionPerformed(ActionEvente){
JOptionPane.showConfirmDialog(null,
"确定添加!
","添加成绩",JOptionPane.YES_NO_OPTION);
try{
cr.executeUpdate("InsertIntoresultValues('"+
ksbh.getSelectedItem().toString()+
"','"+
xh.getSelectedItem().toString()+
"','"+xm.getText().trim()+"','"+
bh.getSelectedItem().toString()+
"','"+
kc.getSelectedItem().toString()+
"','"+fs.getText().trim()+"')");
JOptionPane.showMessageDialog(null,"插入成绩成功!
");
Loglog=newLog();
log.addLog("\r\r","插入成绩"+ksbh.getSelectedItem().toString()+"成功");
log.closeStream();
this.dispose();
}
catch(Exceptionerr){
err.printStackTrace();
Stringerror=err.getMessage();
JOptionPane.showMessageDialog(null,error);
}
}
voidxh_itemStateChanged(ItemEvente){//从数据库中读取数据,并显示
xm.setText("");
try{
xsxm=xms.executeQuery(
"selectstudent_Namefromstudentwhereclass_NO='"+
bh.getSelectedItem().toString().trim()+"'andstudent_ID='"+
xh.getSelectedItem().toString().trim()+"'");//ORDERBYclass_NODESC
while(xsxm.next()){
xm.setText(xsxm.getString("student_Name"));
}
}
catch(Exceptionerr){
err.printStackTrace();
Stringerror=err.getMessage();
JOptionPane.showMessageDialog(null,error);
}
}
}
classaddresult_ocancel_actionAdapter
implementsjava.awt.event.ActionListener{
addresultadaptee;
addresult_ocancel_actionAdapter(addresultadaptee){
this.adaptee=adaptee;
}
publicvoidactionPerformed(ActionEvente){
adaptee.ocancel_actionPerformed(e);
}
}
classaddresult_bh_mouseAdapter
extendsjava.awt.event.MouseAdapter{
addresultadaptee;
addresult_bh_mouseAdapter(addresultadaptee){
this.adaptee=adaptee;
}
}
classaddresult_bh_itemAdapter
implementsjava.awt.event.ItemListener{
addresultadaptee;
addresult_bh_itemAdapter(addresultadaptee){
this.adaptee=adaptee;
}
publicvoiditemStateChanged(ItemEvente){
adaptee.bh_itemStateChanged(e);
}
}
classaddresult_ok_actionAdapterimplementsjava.awt.event.ActionListener{
addresultadaptee;
addresult_ok_actionAdapter(addresultadaptee){
this.adaptee=adaptee;
}
publicvoidactionPerformed(ActionEvente){
adaptee.ok_actionPerformed(e);
}
}
classaddresult_xh_itemAdapterimplementsjava.awt.event.ItemListener{
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 学生 档案管理系统 Java 程序
![提示](https://static.bdocx.com/images/bang_tan.gif)