![java学生成绩管理系统源码_第1页](http://file1.renrendoc.com/fileroot_temp2/2021-1/19/fff1001e-0dc6-46b7-88db-c1d46effed83/fff1001e-0dc6-46b7-88db-c1d46effed831.gif)
![java学生成绩管理系统源码_第2页](http://file1.renrendoc.com/fileroot_temp2/2021-1/19/fff1001e-0dc6-46b7-88db-c1d46effed83/fff1001e-0dc6-46b7-88db-c1d46effed832.gif)
![java学生成绩管理系统源码_第3页](http://file1.renrendoc.com/fileroot_temp2/2021-1/19/fff1001e-0dc6-46b7-88db-c1d46effed83/fff1001e-0dc6-46b7-88db-c1d46effed833.gif)
![java学生成绩管理系统源码_第4页](http://file1.renrendoc.com/fileroot_temp2/2021-1/19/fff1001e-0dc6-46b7-88db-c1d46effed83/fff1001e-0dc6-46b7-88db-c1d46effed834.gif)
![java学生成绩管理系统源码_第5页](http://file1.renrendoc.com/fileroot_temp2/2021-1/19/fff1001e-0dc6-46b7-88db-c1d46effed83/fff1001e-0dc6-46b7-88db-c1d46effed835.gif)
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、文件addmessage.java代码:import java.awt.*;import java.awt.event.*;import java.sql.*;import java.util.*;import javax.swing.*;import javax.swing.table.*;class addmessage extends JFrame implements ActionListener JTextField t1,t2,t3,t4,t5; JTable table; JButton but1; JLabel lab1,lab2,lab3,lab4,lab5; JPanel
2、p1; addmessage() super(增加); setBounds(350,100,470,400); setLayout(new GridLayout(1,1,10,10); p1=new JPanel(); lab1=new JLabel(学号); t1=new JTextField(10); lab2=new JLabel(姓名); t2=new JTextField(10); lab3=new JLabel(课程名); t3=new JTextField(10); lab4=new JLabel(状态); t4=new JTextField(10); lab5=new JLab
3、el(成绩); t5=new JTextField(10); but1=new JButton(添加); but1.addActionListener(this); p1.add(lab1); p1.add(t1); p1.add(lab2); p1.add(t2); p1.add(lab3); p1.add(t3); p1.add(lab4); p1.add(t4); p1.add(lab5); p1.add(t5); p1.add(but1); add(p1); setVisible(true); public void actionPerformed(ActionEvent e) int
4、 i=0 ; String sql1=null,sql2=null,update=null;String url=jdbc:mysql:/localhost:3306/学生成绩系统; Connection con; Statement stmt;try Class.forName(org.gjt.mm.mysql.Driver); catch(java.lang.ClassNotFoundException e1) System.err.println(ClassNotFoundException:+e1.getMessage(); if(e.getSource()=but1) /添加- tr
5、y con=DriverManager.getConnection(url,root,123); stmt=con.createStatement(); sql1=INSERT INTO 学生成绩表 VALUES (+t1.getText()+,+t2.getText()+,+t3.getText()+,+t4.getText()+,+t5.getText()+); String num1=t1.getText(); String num2=t1.getText(); String sele=select * from 学生成绩表 where 学号=+num1+ and 课程名=+num2+;
6、 ResultSet rs=stmt.executeQuery(sele); if(rs.next() JOptionPane.showMessageDialog(this, 已有该条记录,请核实!); else stmt.executeUpdate(sql1); JOptionPane.showMessageDialog(this, 添加成功!); t1.setText(); t2.setText(); t3.setText(); t4.setText(); t5.setText(); stmt.close(); con.close(); catch(SQLException ex) Sys
7、tem.err.println(SQLException:+ex.getMessage(); 文件deletemessage.java代码import java.awt.*;import java.awt.event.*;import java.sql.*;import java.util.*;import javax.swing.*;import javax.swing.table.*;class deletemessage extends JFrame implements ActionListener JTextField t1,t2,t3; JTable table; JButton
8、but1; JLabel lab1,lab2,lab3; JPanel p1; deletemessage() super(删除); setBounds(350,100,470,400); setLayout(new GridLayout(1,1,10,10); p1=new JPanel(); lab1=new JLabel(学号); t1=new JTextField(10); lab2=new JLabel(姓名); t2=new JTextField(10); lab3=new JLabel(课程名); t3=new JTextField(10); but1=new JButton(删
9、除); but1.addActionListener(this); p1.add(lab1); p1.add(t1); p1.add(lab2); p1.add(t2); p1.add(lab3); p1.add(t3); p1.add(but1); add(p1); setVisible(true); public void actionPerformed(ActionEvent e) String sql1=null,sql2=null;String url=jdbc:mysql:/localhost:3306/学生成绩系统; Connection con; Statement stmt;
10、try Class.forName(org.gjt.mm.mysql.Driver); catch(java.lang.ClassNotFoundException e1) System.err.println(ClassNotFoundException:+e1.getMessage(); if(e.getSource()=but1) /删除- try String num1=t1.getText(); String num2=t2.getText(); String num3=t3.getText(); sql2=delete from 学生成绩表 where 学号=+num1+and 课
11、程名=+num3+; con=DriverManager.getConnection(url,root,123); stmt=con.createStatement(); sql1=select * from 学生成绩表 where 学号=+num1+ and 姓名=+num2+ and 课程名=+num3+; ResultSet rs=stmt.executeQuery(sql1); if(rs.next() stmt.executeUpdate(sql2); JOptionPane.showMessageDialog(this, 删除成功!); else JOptionPane.showM
12、essageDialog(this, 没有此条记录!请重新输入); t1.setText(); stmt.close(); con.close(); catch(SQLException ex) System.err.println(SQLException:+ex.getMessage(); 文件entry.java代码import java.awt.*;import java.awt.event.*;import java.sql.*;import javax.swing.*;class entry extends JFrame implements ActionListener int
13、flag=1; String user,pass; JPanel pa; JLabel lab1,lab2; JTextField tf1; JPasswordField tf2; JButton btu1,btu2; JPanel pa1,pa2,pa4; entry()super(学生成绩管理系统);setBounds(400,200,400,300);GridBagLayout gbL=new GridBagLayout(); GridBagConstraints gbc=new GridBagConstraints(); setLayout(gbL); gbc.fill=GridBag
14、Constraints.HORIZONTAL;gbc.anchor=GridBagConstraints.CENTER; lab1=new JLabel(请输入帐号);lab2=new JLabel(请输入密码); tf2=new JPasswordField(10); tf2.setEchoChar(*);tf1=new JTextField(10);tf1.addActionListener(this);pa1=new JPanel();pa1.add(lab1);pa1.add(tf1);gbc.gridx=1;gbc.gridy=1; gbc.insets=new Insets(2,5
15、,0,5);gbL.setConstraints(pa1,gbc);add(pa1);tf2.addActionListener(this);pa2=new JPanel();pa2.add(lab2);pa2.add(tf2); gbc.gridx=1;gbc.gridy=2; gbc.insets=new Insets(2,5,2,5);gbL.setConstraints(pa2,gbc);add(pa2); btu1=new JButton(确定);btu1.addActionListener(this);btu2=new JButton(退出);btu2.addActionListe
16、ner(this);pa4=new JPanel();pa4.add(btu1);pa4.add(btu2);gbc.gridx=1;gbc.gridy=4; gbc.insets=new Insets(2,5,2,5);gbL.setConstraints(pa4,gbc);add(pa4); public void actionPerformed(ActionEvent e) loginsure ls; if(e.getSource()=btu1) user=tf1.getText(); pass=tf2.getText(); tryls=new loginsure(user,pass);
17、this.setVisible(false); catch (SQLException e1)e1.printStackTrace(); catch (ClassNotFoundException e1)e1.printStackTrace(); if(e.getSource()=btu2) dispose(); System.exit(0); class loginsure int i=0; String name=null,pwd=null, ustype=null; public loginsure(String s,String a) throws SQLException,Class
18、NotFoundExceptionString driver =org.gjt.mm.mysql.Driver; Class.forName(driver); String URL = jdbc:mysql:/localhost:3306/学生成绩系统; Connection conn = DriverManager.getConnection(URL,root,123); Statement stmt=conn.createStatement(); ResultSet rs = stmt.executeQuery(select * from 用户管理表); while (rs.next()
19、name=rs.getString(用户名).trim(); pwd=rs.getString(密码).trim(); ustype=rs.getString(权限组).trim(); if (s.equals(name)&a.equals(pwd) i=1; if(ustype.trim().equals(管理员) teacher tea=new teacher(); tea.setVisible(true); if(ustype.trim().equals(学生) student stu=new student(name); stu.setVisible(true); if(i=0) JO
20、ptionPane.showMessageDialog(null, 用户名或者密码错误, 警告,JOptionPane.WARNING_MESSAGE); stmt.close();conn.close(); 文件inquiry.java代码import java.awt.*;import java.awt.event.*;import java.sql.*;import java.util.*;import javax.swing.*;import javax.swing.table.*;class inquiry extends JFrame implements ActionListen
21、er JTextField t1; JTable table; JButton but1; JLabel lab1; JPanel p1; JTable table1=null; DefaultTableModel demod1=null; String n=课程名,状态,成绩; String data=new String00; String No; inquiry(String no) super(成绩); No=no; setBounds(350,100,470,400); p1=new JPanel(); lab1=new JLabel(课程名); t1=new JTextField(
22、10); but1=new JButton(查询成绩); but1.addActionListener(this); p1.add(lab1); p1.add(t1); p1.add(but1); demod1=new DefaultTableModel(data,n); table1=new JTable(demod1); JScrollPane s1=new JScrollPane(table1); p1.add(s1); add(p1); setVisible(true); public void actionPerformed(ActionEvent e) int i=0; Strin
23、g sql1;String url=jdbc:mysql:/localhost:3306/学生成绩系统; Connection con; Statement stmt;try Class.forName(org.gjt.mm.mysql.Driver); catch(java.lang.ClassNotFoundException e1) System.err.println(ClassNotFoundException:+e1.getMessage(); if(e.getSource()=but1) try String num=t1.getText(); sql1=select * fro
24、m 学生成绩表 where 学号=+No+; if(!num.equals() sql1=select * from 学生成绩表 where 课程名=+num+and 学号=+No+; con=DriverManager.getConnection(url,root,123); stmt=con.createStatement(); ResultSet rs=stmt.executeQuery(sql1); removeAllRecord(); while(rs.next() Vector data=new Vector(); data.addElement(rs.getString(3);
25、data.addElement(rs.getString(4); data.addElement(rs.getString(5); demod1.addRow(data); i=1; if(i=0) JOptionPane.showMessageDialog(this, 没有此课程!请重新输入); table1.revalidate(); t1.setText(); stmt.close(); con.close(); catch(SQLException ex) System.err.println(SQLException:+ex.getMessage(); public void rem
26、oveAllRecord()/将界面上的所有记录清空 int rowcount; while(true)/删除所有存在的行rowcount = demod1.getRowCount()-1; if(rowcount = 0) demod1.removeRow(rowcount); demod1.setRowCount(rowcount); else break; 文件main.java代码import java.awt.*;import java.awt.event.*;import java.sql.*;import java.util.*;import javax.swing.*;publ
27、ic class main public static void main(String args)entry ent=new entry();ent.setVisible(true); ent.setResizable(false); 文件record.java代码import java.awt.*;import java.awt.event.*;import java.sql.*;import java.util.*;import javax.swing.*;import javax.swing.table.*;class record extends JFrame implements
28、ActionListener JTextField t1; TextArea t; JButton but1; JLabel L1; JPanel p1; JTable table1=null; DefaultTableModel demod1=null; String n=平均成绩,优秀,良好,不及格; String data=new String00; public record() super(统计); setBounds(350,30,470,610); setLayout(new GridLayout(1,1,10,10); p1=new JPanel(); L1=new JLabe
29、l(课程名); but1=new JButton(查询); but1.addActionListener(this); t1=new JTextField(10); p1.add(L1); p1.add(t1); p1.add(but1); demod1=new DefaultTableModel(data,n); table1=new JTable(demod1); JScrollPane s1=new JScrollPane(table1); p1.add(s1); add(p1); setVisible(true); public void actionPerformed(ActionE
30、vent e) int i=0; String sql1; String sql2;String url=jdbc:mysql:/localhost:3306/学生成绩系统; Connection con; Statement stmt;try Class.forName(org.gjt.mm.mysql.Driver); catch(java.lang.ClassNotFoundException e1) System.err.println(ClassNotFoundException:+e1.getMessage(); if(e.getSource()=but1) try String
31、num1=t1.getText(); if(num1.equals() JOptionPane.showMessageDialog(this, 学号不能为空,请输入学号!,JOptionPane.WARNING_MESSAGE); else sql1=select * from 学生成绩表 where 学号=+num1+; sql1=select avg(成绩) from 学生成绩表 where 课程名=+num1+; sql2=select count(*) from 学生成绩表 where 课程名=+num1+ and 成绩=90; con=DriverManager.getConnect
32、ion(url,root,123); stmt=con.createStatement(); ResultSet rs=stmt.executeQuery(sql1); removeAllRecord(); while(rs.next() Vector data=new Vector(); data.addElement(rs.getInt(1); /*data.addElement(rs.getString(3); data.addElement(rs.getString(4); data.addElement(rs.getString(5);*/ demod1.addRow(data);
33、i=1; rs=stmt.executeQuery(sql2); while(rs.next() int n = rs.getInt(1); System.out.println(n); if(i=0) JOptionPane.showMessageDialog(this, 没有此条记录!请重新输入); table1.revalidate(); t1.setText(); stmt.close(); con.close(); catch(SQLException ex) System.err.println(SQLException:+ex.getMessage(); public void
34、removeAllRecord()/将界面上的所有记录清空 int rowcount; while(true)/删除所有存在的行rowcount = demod1.getRowCount()-1; if(rowcount = 0) demod1.removeRow(rowcount); demod1.setRowCount(rowcount); else break; 文件revise.java代码import java.awt.*;import java.awt.event.*;import java.sql.*;import java.util.*;import javax.swing.*
35、;import javax.swing.table.*;class revise extends JFrame implements ActionListener JTextField t1,t2,t3,t4,t5; JTable table; JButton but1; JLabel lab1,lab2,lab3,lab4,lab5; JPanel p1; int n=0; revise() super(修改); setBounds(350,100,470,400); setLayout(new GridLayout(1,1,10,10); p1=new JPanel(); lab1=new
36、 JLabel(学号); t1=new JTextField(10); lab2=new JLabel(姓名); t2=new JTextField(10); lab3=new JLabel(课程名); t3=new JTextField(10); lab4=new JLabel(状态); t4=new JTextField(10); lab5=new JLabel(成绩); t5=new JTextField(10); but1=new JButton(修改); but1.addActionListener(this); p1.add(lab1); p1.add(t1); p1.add(la
37、b2); p1.add(t2); p1.add(lab3); p1.add(t3); p1.add(lab4); p1.add(t4); p1.add(lab5); p1.add(t5); p1.add(but1); add(p1); setVisible(true); public void actionPerformed(ActionEvent e) String sql1=null,update=null;String url=jdbc:mysql:/localhost:3306/学生成绩系统; Connection con; Statement stmt;try Class.forNa
38、me(org.gjt.mm.mysql.Driver); catch(java.lang.ClassNotFoundException e1) System.err.println(ClassNotFoundException:+e1.getMessage(); if(e.getSource()=but1) /修改- try String num1=t3.getText(); String num2=t1.getText(); /String num3=t5.getText(); n= Integer.valueOf(t5.getText().intValue(); System.out.pr
39、int(n); con=DriverManager.getConnection(url,root,123); stmt=con.createStatement(); sql1=select * from 学生成绩表 where 学号=+num2+ and 课程名=+num1+; update=update 学生成绩表 set 课程名=+t3.getText()+,状态=+t4.getText()+,成绩 =+n+ where 学号=+num2+; ResultSet rs=stmt.executeQuery(sql1); if(rs.next() stmt.executeUpdate(upda
40、te); JOptionPane.showMessageDialog(this, 修改成功!); else JOptionPane.showMessageDialog(this, 没有此条记录!请重新输入); t1.setText(); t2.setText(); t3.setText(); t4.setText(); t5.setText(); stmt.close(); con.close(); catch(SQLException ex) System.err.println(SQLException:+ex.getMessage(); 文件student.java代码import ja
41、va.awt.*;import java.awt.event.*;import java.sql.*;import java.util.*;import javax.swing.*;class student extends JFrame implements ActionListener inquiry cho; JMenuBar mb; JMenu m1; JMenuItem mt1,mt2; String No; Icon icon; JLabel lab; student(String no)super(学生);icon=new ImageIcon(123.jpg); lab=new
42、JLabel(icon); add(lab);No=no; setBounds(130,10,800,500); JMenuBar mb=new JMenuBar(); setJMenuBar(mb); m1=new JMenu(操作); mt1=new JMenuItem(查询成绩); mt2=new JMenuItem(退出); m1.add(mt1); mt1.addActionListener(this); m1.addSeparator(); m1.add(mt2); mt2.addActionListener(this); m1.addActionListener(this); mb.add(m1); public void actionPerformed(ActionEvent e) if(e.getSource()=mt1) cho=new inquiry(No); if(e.getSource()=mt2) dispose();
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 26《好的故事》说课稿-2024-2025学年语文六年级上册统编版
- 1场景歌说课稿-2024-2025学年统编版语文二年级上册
- 2024年秋一年级道德与法治下册 第二单元 我和大自然 5 风儿轻轻吹说课稿 新人教版
- 18古诗三首浪淘沙(其一)说课稿-2024-2025学年六年级上册语文统编版
- 8 设计制作小车(二) 说课稿-2024-2025学年科学四年级上册教科版
- 23《月光曲》说课稿-2024-2025学年语文六年级上册统编版
- 1 24时计时法(说课稿)-2024-2025学年三年级上册数学人教版001
- 2023九年级道德与法治上册 第三单元 文明与家园 第五课 守望精神家园第2框 凝聚价值追求说课稿 新人教版
- 2025北京市饲料采购合同新
- 2025建造船舶所要用到的合同
- 农产品贮运与加工考试题(附答案)
- 学校财务年终工作总结4
- 2025年人民教育出版社有限公司招聘笔试参考题库含答案解析
- 康复医学治疗技术(士)复习题及答案
- 《血管性血友病》课件
- 2025年汽车加气站作业人员安全全国考试题库(含答案)
- 2024年司法考试完整真题及答案
- 高三日语一轮复习日语助词「に」和「を」的全部用法课件
- 2024年山东省高考政治试卷真题(含答案逐题解析)
- 2024年执业药师继续教育专业答案
- 2024-2025学年人教版七年级数学上册期末达标测试卷(含答案)
评论
0/150
提交评论