1、学生档案管理系统Java程序南华大学计算机科学与技术学院Java精读程序分析报告 ( 2008 2009 学年度 第 一 学期 )程序名称: 学生档案管理系统专业班级: 计算机科学与技术专业061班指导老师: 谭敏生小组成员:姓名学号姓名学号姓名学号姓名学号姓名学号学生档案管理系统Java精读程序一/1. about.java /程序功能: 程序分析成员:/package studentsystem;import java.awt.*;import javax.swing.*;import java.awt.event.*;public class about extends JDialog
2、JPanel panel1 = new JPanel(); ImageIcon icon=new ImageIcon(xuan.jpg);/设置背景图片 JLabel jLabel1 = new JLabel(icon); JButton sure = new JButton(); public about(Frame frame, String title, boolean modal) super(frame, title, true); try jbInit(); pack(); catch(Exception ex) ex.printStackTrace(); public about
3、() this(null, , true); private void jbInit() throws Exception jLabel1.setText(); jLabel1.setBounds(new Rectangle(5, 5, 392, 250); panel1.setBounds(new Rectangle(0, 299, 1, 1); panel1.setLayout(null); jLabel1.setText(); jLabel1.setBounds(new Rectangle(-43, 0, 414, 245); sure.setBounds(new Rectangle(1
4、09, 243, 79, 29); sure.setFont(new java.awt.Font(Dialog, 0, 15); sure.setText(确 定); jLabel1.setToolTipText(leeyingzhang制作!); sure.addActionListener(new about_sure_actionAdapter(this); this.setTitle(呵呵!); this.getContentPane().add(panel1, null); this.getContentPane().add(sure, null); this.getContentP
5、ane().add(jLabel1, null); this.setBounds(200,200,330,310); this.getContentPane().setLayout(null); this.setVisible(true); void sure_actionPerformed(ActionEvent e) this.dispose(); class about_sure_actionAdapter implements java.awt.event.ActionListener about adaptee; about_sure_actionAdapter(about adap
6、tee) this.adaptee = adaptee; public void actionPerformed(ActionEvent e) adaptee.sure_actionPerformed(e); /2. addresult.java/程序功能: 程序分析成员:/package studentsystem;import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.sql.*;public class addresult extends JFrame JLabel jLabel1 = new
7、JLabel(); JComboBox ksbh = new JComboBox(); JLabel jLabel2 = new JLabel(); JLabel jLabel3 = new JLabel(); JLabel jLabel4 = new JLabel(); JLabel jLabel5 = new JLabel(); JLabel jLabel6 = new JLabel(); JComboBox xh = new JComboBox(); JComboBox kc = new JComboBox(); JComboBox bh = new JComboBox(); JText
8、Field xm = new JTextField(); JTextField fs = new JTextField(); JButton ok = new JButton(); JButton ocancel = new JButton(); Statement ps, is,kcs,cr,xms; ResultSet rs, as,xzkc,xsxm; Connection con; String url; public addresult() try jbInit(); catch (Exception e) e.printStackTrace(); /*JDBC-ODBC连接数据库,
9、并读取数据库*/ try Class.forName(sun.jdbc.odbc.JdbcOdbcDriver); Connection con = 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_REA
10、D_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 (Exception err)
11、String error = err.getMessage(); Log log=new Log(); log.addLog(rr,数据库连接出错); log.closeStream(); JOptionPane.showMessageDialog(null, 连接数据库错误!); try rs = ps.executeQuery(select distinct class_NO from student ); /ORDER BY class_NO DESC while (rs.next() / xh.addItem(rs.getString(student_ID); bh.addItem(r
12、s.getString(class_NO); xzkc = kcs.executeQuery(select * from gradecourse ); /ORDER BY class_NO DESC while (xzkc.next() / xh.addItem(rs.getString(student_ID); kc.addItem(xzkc.getString(course_Name); catch (Exception err) String error = err.getMessage(); JOptionPane.showMessageDialog(null, error); pub
13、lic static void main(String args) addresult addresult = new addresult(); private void jbInit() throws Exception jLabel1.setFont(new java.awt.Font(Dialog, 0, 15); jLabel1.setText(考试编号); jLabel1.setBounds(new Rectangle(13, 11, 67, 28); this.setLocale(java.util.Locale.getDefault(); this.setResizable(fa
14、lse); this.setState(Frame.NORMAL); this.setTitle(添加成绩信息); this.getContentPane().setLayout(null); ksbh.setFont(new java.awt.Font(Dialog, 0, 15); ksbh.setBounds(new Rectangle(77, 12, 132, 26); ksbh.addItem(期中); ksbh.addItem(期末); jLabel2.setBounds(new Rectangle(214, 8, 63, 28); jLabel2.setText(选择班号); j
15、Label2.setFont(new java.awt.Font(Dialog, 0, 15); jLabel3.setBounds(new Rectangle(7, 54, 67, 28); jLabel3.setText(选择学号); jLabel3.setFont(new java.awt.Font(Dialog, 0, 15); jLabel4.setBounds(new Rectangle(217, 51, 63, 28); jLabel4.setText(姓 名); jLabel4.setFont(new java.awt.Font(Dialog, 0, 15); jLabel5.
16、setBounds(new Rectangle(215, 89, 64, 28); jLabel5.setText(输入分数); jLabel5.setFont(new java.awt.Font(Dialog, 0, 15); jLabel6.setBounds(new Rectangle(9, 92, 67, 28); jLabel6.setText(选择课程); jLabel6.setFont(new java.awt.Font(Dialog, 0, 15); xh.setFont(new java.awt.Font(Dialog, 0, 15); xh.setBounds(new Re
17、ctangle(75, 55, 138, 24); xh.addItemListener(new addresult_xh_itemAdapter(this); kc.setFont(new java.awt.Font(Dialog, 0, 15); kc.setBounds(new Rectangle(75, 87, 138, 27); bh.setFont(new java.awt.Font(Dialog, 0, 15); bh.setBounds(new Rectangle(280, 8, 96, 27); bh.addItemListener(new addresult_bh_item
18、Adapter(this); xm.setText(); xm.setBounds(new Rectangle(280, 50, 96, 26); fs.setText(); fs.setBounds(new Rectangle(280, 90, 97, 27); ok.setBounds(new Rectangle(83, 142, 89, 32); ok.setFont(new java.awt.Font(Dialog, 0, 15); ok.setText(确 定); ok.addActionListener(new addresult_ok_actionAdapter(this); o
19、cancel.setText(退 出); ocancel.addActionListener(new addresult_ocancel_actionAdapter(this); ocancel.setBounds(new Rectangle(206, 142, 89, 32); ocancel.setFont(new java.awt.Font(Dialog, 0, 15); this.getContentPane().add(jLabel1, null); this.getContentPane().add(ksbh, null); this.getContentPane().add(jL
20、abel3, 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.getCont
21、entPane().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); void ocancel_actionPerformed(ActionEvent e) this.dispose(); void bh_itemStateChanged(ItemEvent
22、e) /从数据库中读取数据,并显示 try xh.removeAllItems(); as = is.executeQuery( select distinct student_ID from student where class_NO= + bh.getSelectedItem() + ); /ORDER BY class_NO DESC while (as.next() xh.addItem(as.getString(student_ID); catch (Exception err) err.printStackTrace(); String error = err.getMessag
23、e(); JOptionPane.showMessageDialog(null, error); void ok_actionPerformed(ActionEvent e) JOptionPane.showConfirmDialog(null, 确定添加!, 添加成绩, JOptionPane.YES_NO_OPTION); try cr.executeUpdate(Insert Into result Values( + ksbh.getSelectedItem().toString() + , + xh.getSelectedItem().toString() + , + xm.getT
24、ext().trim() + , + bh.getSelectedItem().toString() + , + kc.getSelectedItem().toString() + , + fs.getText().trim() + ); JOptionPane.showMessageDialog(null, 插入成绩成功!); Log log=new Log(); log.addLog(rr,插入成绩+ksbh.getSelectedItem().toString()+成功); log.closeStream(); this.dispose(); catch (Exception err)
25、err.printStackTrace(); String error = err.getMessage(); JOptionPane.showMessageDialog(null, error); void xh_itemStateChanged(ItemEvent e) /从数据库中读取数据,并显示 xm.setText(); try xsxm= xms.executeQuery( select student_Name from student where class_NO= + bh.getSelectedItem().toString().trim() + and student_I
26、D= + xh.getSelectedItem().toString().trim() + ); /ORDER BY class_NO DESC while (xsxm.next() xm.setText(xsxm.getString(student_Name); catch (Exception err) err.printStackTrace(); String error = err.getMessage(); JOptionPane.showMessageDialog(null, error); class addresult_ocancel_actionAdapter impleme
27、nts java.awt.event.ActionListener addresult adaptee; addresult_ocancel_actionAdapter(addresult adaptee) this.adaptee = adaptee; public void actionPerformed(ActionEvent e) adaptee.ocancel_actionPerformed(e); class addresult_bh_mouseAdapter extends java.awt.event.MouseAdapter addresult adaptee; addres
28、ult_bh_mouseAdapter(addresult adaptee) this.adaptee = adaptee; class addresult_bh_itemAdapter implements java.awt.event.ItemListener addresult adaptee; addresult_bh_itemAdapter(addresult adaptee) this.adaptee = adaptee; public void itemStateChanged(ItemEvent e) adaptee.bh_itemStateChanged(e); class
29、addresult_ok_actionAdapter implements java.awt.event.ActionListener addresult adaptee; addresult_ok_actionAdapter(addresult adaptee) this.adaptee = adaptee; public void actionPerformed(ActionEvent e) adaptee.ok_actionPerformed(e); class addresult_xh_itemAdapter implements java.awt.event.ItemListener
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1