java项目(学生成绩管理系统)
更新时间:2024-04-20 02:12:01 阅读量: 综合文库 文档下载
《Java程序设计实训》
学生成绩管理系统
设计数据库:
CREATE DATABASE 学生成绩管理系统
(1)教师信息表创建:
create table 教师信息表(
教师ID varchar(8) primary key ,
教师姓名 varchar(8) not null unique, 登录密码 varchar(8) not null, )
(2)学籍信息表创建:
create table 学籍信息表(
学号 varchar(15) primary key, 姓名 varchar(8) not null , 年龄 varchar(10), 出生日期 varchar(10), 性别 varchar(4) ,
班级 varchar(8) not null , 专业 varchar(5) , 民族 varchar(10),
登录密码 varchar(6) not null)
(3)成绩信息表创建:
create table 成绩信息表(
学号 varchar(15),
计算机网络 varchar(8), 计算机专业英语 smallint, 计算机信息技术基础 smallint, Java程序设计 smallint ,
数据库应用实训教程 smallint , 高等数学 smallint , Xml smallint ,)
概要结构分析: 教师登录 学生成绩管理系统登录界面 学生登录 1.登录界面和主界面
import javax.swing.*;
import javax.swing.table.DefaultTableModel; import java.awt.*; import java.awt.event.*; import java.sql.*;
class myConnection{ResultSet re;
public myConnection(){}
public ResultSet getResult(String sql){
try{Class.forName(\);
Connection conn=DriverManager.getConnection(\学生
添加学生信息 添加学生成绩 修改学生信息 删除学生信息 查看学生信息 查看学生成绩 查看学生信息 查看学生成绩 添加学生信息 成绩管理系统\,\,\);
Statement
stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet re=stmt.executeQuery(sql); return re;}
System.out.println(\+e.toString()); return null;}}
catch(Exception e){
public boolean executeSql(String sql){
try{Class.forName(\);
Connection conn=DriverManager.getConnection(\学生
成绩管理系统\,\,\); Statement stmt=conn.createStatement();
stmt.executeUpdate(sql); conn.commit(); return true;}
System.out.println(\+e.toString()); return false;}}}
catch(Exception e){
class stuMainFrame extends JFrame implements ActionListener {JMenuBar jmb = new JMenuBar();
JMenu Message = new JMenu(\信息\); JMenu Score = new JMenu(\查询\);
JMenuItem Item1 = new JMenuItem(\添加学生信息\); JMenuItem mName=new JMenuItem(\学生成绩查询\); JMenuItem mScore=new JMenuItem(\按成绩查询\); JMenuItem mNam1=new JMenuItem(\查询学生信息\); JLabel label = new JLabel();
public stuMainFrame(){ImageIcon icon = new label.setIcon(icon);
label.setBounds(0, 0, icon.getIconWidth(), add(label);
setSize(label.getWidth(),label.getHeight());
this.setJMenuBar(jmb); jmb.add(Message); jmb.add(Score); Message.add(Item1); Score.add(mNam1); Score.add(mName); Score.add(mScore);
Item1.addActionListener(this); mName.addActionListener(this);
ImageIcon(\);
icon.getIconHeight());
mScore.addActionListener(this); mNam1.addActionListener(this); }
public void actionPerformed(ActionEvent e) {if(e.getSource()==Item1)
{ new addForm().setVisible(true);} else if(e.getSource()==mName) { dispose();
new Score1().setVisible(true);} else if(e.getSource()==mScore)
{new scoreQueryForm().setVisible(true);} else if(e.getSource()==mNam1) {dispose();
new Serch1().setVisible(true);}}}
class mainFrame extends JFrame implements ActionListener{ JLabel label = new JLabel(); JMenuBar mBar= new JMenuBar(); JPanel p=new JPanel();
private JMenu mSystem,mOperate,mQuery,mHelp,myMenuUser; private JMenuItem
mFile,mNew,mOpen,mExit,mAdd,mDel,mModify,mName,miShow,mScore,mAbout,miUser,mAddSc;
public mainFrame()
{ this.setJMenuBar(mBar);
ImageIcon icon = new ImageIcon(\);
label.setIcon(icon);
label.setBounds(0, 0, icon.getIconWidth(), add(label);
setSize(label.getWidth(),label.getHeight()); myMenuUser=new JMenu(\用户\);
miUser=new JMenuItem(\编辑用户\); myMenuUser.add(miUser);
icon.getIconHeight());
mSystem=new JMenu(\系统\); mOperate=new JMenu(\数据操作\); mQuery=new JMenu(\查询\); mHelp=new JMenu(\帮助\); mBar.add(mSystem); mBar.add(mOperate); mBar.add(mQuery); mBar.add(mHelp); mBar.add(myMenuUser); mFile=new JMenuItem(\文件\); mNew=new JMenuItem(\新建\);
mOpen=new JMenuItem(\打开\); mExit=new JMenuItem(\退出\); mSystem.add(mFile); mSystem.add(mNew); mSystem.add(mOpen); mSystem.addSeparator(); mSystem.add(mExit);
mAdd=new JMenuItem(\添加基本信息\); mAddSc=new JMenuItem(\添加成绩信息\); mDel=new JMenuItem(\删除\); mModify=new JMenuItem(\修改\); mOperate.add(mAdd); mOperate.add(mAddSc); mOperate.add(mDel); mOperate.add(mModify);
mName=new JMenuItem(\查询学生信息\); mScore=new JMenuItem(\查询学生成绩\); miShow=new JMenuItem(\全部显示\); mQuery.add(mName); mQuery.add(mScore); mQuery.addSeparator(); mQuery.add(miShow);
mAbout=new JMenuItem(\软件信息\); mHelp.add(mAbout);
mExit.addActionListener(this); mAdd.addActionListener(this); mDel.addActionListener(this); mModify.addActionListener(this); mName.addActionListener(this); mScore.addActionListener(this); mAbout.addActionListener(this); miShow.addActionListener(this); miUser.addActionListener(this); mAddSc.addActionListener(this);}
public void actionPerformed(ActionEvent e){
if(e.getSource()==mExit){
dispose();
new CJ().setVisible(true);} else if(e.getSource()==mAbout){
JOptionPane.showMessageDialog(this,\学生成绩管理系统\\n\\n电信学院\\n\\n2012年3月\,\软件信息\,JOptionPane.INFORMATION_MESSAGE);} else if(e.getSource()==mAdd){ dispose();
new addForm().setVisible(true);}
else if(e.getSource()==mAddSc){ dispose();
new addScore().setVisible(true);} else if(e.getSource()==mDel){ dispose();
new deleteForm().setVisible(true);} else if(e.getSource()==mName){ dispose();
new Serch().setVisible(true);} else if(e.getSource()==mScore){ dispose();
new Score().setVisible(true);} else if(e.getSource()==mModify){
new modifyForm().setVisible(true);} else if(e.getSource()==miUser){ new userFrame().setVisible(true);} else if(e.getSource()==miShow){
new freshTable().setVisible(true); }}} class CJ extends JFrame implements ActionListener{
JLabel t1=new JLabel(\号:\); JLabel t3=new JLabel(\密码:\); JLabel label = new JLabel(); public String zh=null;
JTextField t2=new JTextField(null,15);
JTextField t4=new JPasswordField(null,15); JRadioButton b=new JRadioButton(\教师\); JRadioButton b1=new JRadioButton(\学生\); JButton jB1=new JButton(\登录\); JButton jB2=new JButton(\取消\);
public CJ (){super(\学生生成绩管理系统\); setLayout(null);
jB1.setBounds(110,170,60,20); jB1.setBackground(Color.red); add(jB1);
jB2.setBounds(210,170,60,20); jB2.setBackground(Color.red); add(jB2);
t1.setBounds(90,50,80,35); add(t1);
t2.setBounds(120,50,150,35); add(t2);
t3.setBounds(90,100,80,35); add(t3);
t4.setBounds(120,100,150,35);
add(t4);
b.setBounds(200,20,70,30); b1.setBounds(120,20,70,30);
ButtonGroup bg=new ButtonGroup(); b.setSelected(false); b1.setSelected(true); b1.setSelected(false);
add(b);bg.add(b);add(b1); bg.add(b1);
b.setContentAreaFilled(false); b1.setContentAreaFilled(false);
ImageIcon icon = new ImageIcon(\); label.setIcon(icon);
label.setBounds(0, 0, icon.getIconWidth(), icon.getIconHeight()); add(label);
setSize(label.getWidth(),label.getHeight()); setResizable(false); setVisible(true); setLocation(300,300);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jB1.addActionListener(this); jB2.addActionListener(this);}
public void actionPerformed(ActionEvent e) { if (e.getSource()==jB2){
System.exit(0);}
String username , password; username = t2.getText(); if(b.isSelected()) {
if (username.toString().equals(\)){
JOptionPane.showMessageDialog(null, \请输入用户名\,
else if (e.getSource()==jB1){
password = t4.getText();
\温馨提示\, JOptionPane.INFORMATION_MESSAGE); }
else if (password.toString().equals(\)){
JOptionPane.showMessageDialog(null, \请输入密码\, \
温馨提示\, JOptionPane.INFORMATION_MESSAGE); }
else{
myConnection conn=new myConnection(); ResultSet rs;
String sql=\教师信息表 where 教师
ID='\+username.toString()+\登录密码 = '\+password.toString()+\; try{
rs=conn.getResult(sql);
rs.last();
if(rs.getRow()==1)
{ setVisible(false); rs.beforeFirst(); while(rs.next()){ this.dispose();
sql=\学籍信息表\; mainFrame mf=new mainFrame();
mf.setLayout(null); mf.setVisible(true); mf.setLocation(300,300); mf.setResizable(false);
mf.setTitle(\学生成绩管理系统:教师登录界面\);
mf.addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e){ } });
System.exit(0);
mf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JOptionPane.showMessageDialog( null ,rs.getString(\教师姓名\)+\老师!您好!欢迎登录学生成绩管理系统!\ ) ; }
}
else{
JOptionPane.showMessageDialog(null, \用户名或密码错
误\, \登录失败\, JOptionPane.INFORMATION_MESSAGE); }
}
catch(Exception er){ }
if (username.toString().equals(\)){
} }
System.out.println(er.toString());
if(b1.isSelected()) {
JOptionPane.showMessageDialog(null, \请输入用户名\,
\温馨提示\, JOptionPane.INFORMATION_MESSAGE); }
else if (password.toString().equals(\)){
JOptionPane.showMessageDialog(null, \请输入密码\, \
温馨提示\, JOptionPane.INFORMATION_MESSAGE); }
else{
myConnection conn=new myConnection(); ResultSet rs;
String sql=\学籍信息表 where 学号
='\+t2.getText().toString()+\登录密码 =
'\+t4.getText().toString()+\;
try{
rs=conn.getResult(sql); rs.last();
if(rs.getRow()==1)
{ setVisible(false); rs.beforeFirst(); while(rs.next()){ this.dispose();
sql=\学籍信息表\; stuMainFrame smf =new stuMainFrame(); smf.setSize(500,400);
smf.setVisible(true); smf.setResizable(false);
smf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
smf.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){ }
System.exit(0);
});
JOptionPane.showMessageDialog( null ,rs.getString(\
学生姓名\)+\同学!您好!欢迎登录学生成绩管理系统!\ ) ; } }
else{
JOptionPane.showMessageDialog(null, \用户名或密码错
误\, \登录失败\, JOptionPane.INFORMATION_MESSAGE); }}
catch(Exception er){
System.out.println(er.toString()); }} }}}
public static void main(String[] args) {
try{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch(Exception e){} CJ frame=new CJ(); new mainFrame();
stuMainFrame stu = new stuMainFrame();}}
2.添加学生基本信息
import javax.swing.*;
import javax.swing.table.DefaultTableModel; import java.awt.*; import java.awt.event.*;
import java.sql.*;
public class addForm extends JFrame implements ActionListener { JLabel label1 = new JLabel(\添加基本信息\,JLabel.CENTER);
JLabel labxuehao=new JLabel(\学号:\,JLabel.CENTER); JLabel labyear=new JLabel(\年龄:\,JLabel.CENTER); JLabel labName=new JLabel(\姓名:\,JLabel.CENTER);
JLabel labDate=new JLabel(\出生日期:\,JLabel.CENTER); JLabel labclass=new JLabel(\班级:\,JLabel.CENTER); JLabel labzy=new JLabel(\专业:\,JLabel.CENTER); JLabel labmz=new JLabel(\民族:\,JLabel.CENTER); JLabel labsex = new JLabel(\性别:\,JLabel.CENTER); JTextField txtName=new JTextField(20); JTextField txtDate=new JTextField(18); JTextField txtXueHao=new JTextField(20); JTextField txtYear=new JTextField(20); JTextField txtClass=new JTextField(20); JTextField txtZY=new JTextField(20); JTextField txtMZ=new JTextField(20); ButtonGroup bgp = new ButtonGroup();
JRadioButton man = new JRadioButton(\男\); JRadioButton women = new JRadioButton(\女\);
JButton btnAdd=new JButton(\添加\); JButton btnCancel=new JButton(\返回\); JButton btnReset = new JButton(\重置\); JPanel jpl=new JPanel(); //创建面板对象 Connection con; Statement sql; ResultSet rs; addForm() {
super(\添加学生信息\);
this.setResizable(false); this.setSize(550,450); this.setVisible(true); this.setLocation(300,300);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.add(jpl); jpl.setLayout(null);
btnAdd.addActionListener(this); btnReset.addActionListener(this); btnCancel.addActionListener(this); jpl.setBackground(Color.cyan); man.setBackground(Color.cyan); women.setBackground(Color.cyan); label1.setBounds(100,20,300,20);
jpl.add(label1);
labxuehao.setBounds(100,50,70,20); jpl.add(labxuehao);
txtXueHao.setBounds(190,50,140,20); jpl.add(txtXueHao);
labName.setBounds(100,90,70,20); jpl.add(labName);
txtName.setBounds(190,90,140,20); jpl.add(txtName);
labsex.setBounds(110,130,60,20); jpl.add(labsex);
man.setBounds(190,130,60,20); women.setBounds(270,130,60,20); jpl.add(man); jpl.add(women); bgp.add(man); bgp.add(women);
labyear.setBounds(100,180,70,20); jpl.add(labyear);
txtYear.setBounds(190,180,140,20); jpl.add(txtYear);
labDate.setBounds(100,210,70,20); jpl.add(labDate);
txtDate.setBounds(190,210,140,20); jpl.add(txtDate);
labmz.setBounds(100,240,70,20); jpl.add(labmz);
txtMZ.setBounds(190,240,140,20); jpl.add(txtMZ);
labclass.setBounds(100,270,70,20); jpl.add(labclass);
txtClass.setBounds(190,270,140,20); jpl.add(txtClass);
labzy.setBounds(100,300,70,20); jpl.add(labzy);
txtZY.setBounds(190,300,140,20); jpl.add(txtZY);
btnReset.setBounds(80,350,90,20); btnAdd.setBounds(200,350,90,20); btnCancel.setBounds(320,350,90,20); jpl.add(btnReset); jpl.add(btnAdd);
jpl.add(btnCancel);}
public void actionPerformed(ActionEvent e)
{ if(e.getSource()==btnCancel){
dispose();
new mainFrame().setVisible(true);} if(e.getSource()==btnAdd)
{if (txtXueHao.getText().toString().equals(\)){
JOptionPane.showMessageDialog(null, \请输入学号\, \温馨提示\, JOptionPane.INFORMATION_MESSAGE);
}else if (txtName.getText().toString().equals(\)){
JOptionPane.showMessageDialog(null, \请输入姓名\, \温馨提示\, JOptionPane.INFORMATION_MESSAGE);
}else if (txtYear.getText().toString().equals(\)){
JOptionPane.showMessageDialog(null, \请输入年龄\, \温馨提示\, JOptionPane.INFORMATION_MESSAGE);
}else if (txtDate.getText().toString().equals(\)){
JOptionPane.showMessageDialog(null, \出生日期\, \温馨提示\, JOptionPane.INFORMATION_MESSAGE);
}else if (txtZY.getText().toString().equals(\)){
JOptionPane.showMessageDialog(null, \请输入专业\, \温馨提示\, JOptionPane.INFORMATION_MESSAGE);
}else if (txtMZ.getText().toString().equals(\)){
JOptionPane.showMessageDialog(null, \请输入民族\, \温馨提示\, JOptionPane.INFORMATION_MESSAGE);
}else if (txtClass.getText().toString().equals(\)){
JOptionPane.showMessageDialog(null, \请输入班级\, \温馨提示\, JOptionPane.INFORMATION_MESSAGE);}
else{ String sex;
if(man.isSelected()) { sex=\男\;} else
{ sex=\女\; } try
{Class.forName(\);} catch (ClassNotFoundException ce)
{JOptionPane.showMessageDialog(null,ce.getMessage());} try{
Connection con = DriverManager.getConnection(\
学生成绩管理系统\,\,\);
Statement stmt = con.createStatement();
int a = stmt.executeUpdate(\学籍信息表(学号 ,
登录密码,姓名,年龄 , 出生日期 , 性别 , 班级,专业,民
族)values('\+txtXueHao.getText()+\+00000+\+txtName.getText()+\+txtYear.getText()+\+txtDate.getText()+\+sex+\+txtClass.getText()+\+txtZY.getText()+\+txtMZ.getText()+\);
if(a==1)
{JOptionPane.showMessageDialog(null,\已成功添加\,\温馨提示\,JOptionPane.INFORMATION_MESSAGE);}
else
{JOptionPane.showMessageDialog(null,\添加失败\,\温馨提示\,JOptionPane.INFORMATION_MESSAGE);}
stmt.close();} catch (SQLException se)
{JOptionPane.showMessageDialog(null,se.getMessage());}}} txtZY.setText(\); txtMZ.setText(\); txtName.setText(\); txtDate.setText(\); txtXueHao.setText(\); txtYear.setText(\);
txtXueHao.requestFocus();}}
else{ txtClass.setText(\);
public static void main(String[] args) {addForm amg = new addForm();}}
3.添加学生成绩
import java.awt.*;
import javax.swing.*; import java.awt.event.*; import java.sql.*;
public class addScore extends JFrame implements ActionListener {static addScore ss;
JLabel[] label = {new JLabel(\学号:\) , new JLabel(\计算机网络:\) , new JLabel(\操作系统:\) , new JLabel(\计算机专业英语:\) , new JLabel(\计算机信息技术基础:\) , new JLabel(\程序设计:\) , new JLabel(\数据库应用实训教程:\) , new JLabel(\高等数学:\) , new JLabel(\:\)}; JTextField[] txt = {new JTextField() , new JTextField() , new JTextField() , new JTextField() , new JTextField() ,new JTextField() , new JTextField() ,new JTextField() ,new JTextField() };
JButton add = new JButton(\添加\); JButton reset = new JButton(\重置\); JButton Cancel=new JButton(\返回\); JPanel jpl = new JPanel();
JLabel title = new JLabel(\添加学生成绩\ , JLabel.CENTER);
Font f = new Font(\黑体\ , Font.BOLD , 16 ); int s=100;
public addScore() {
super(\添加学生信息\);
this.setResizable(false); this.setSize(500,600);
this.setDefaultCloseOperation(EXIT_ON_CLOSE); this.setVisible(true); this.add(jpl);
Cancel.addActionListener(this); add.addActionListener(this); reset.addActionListener(this); jpl.setLayout(null);
title.setBounds(150,40,200,20); title.setFont(f);
title.setForeground(Color.red); jpl.setBackground(Color.LIGHT_GRAY); jpl.add(title);
for(int i = 0 ; i label[i].setBounds(100,s,140,20); jpl.add(label[i]); txt[i].setBounds(260,s,140,20); jpl.add(txt[i]); s=s+40; } add.setBounds(100,s,80,20); reset.setBounds(200,s,80,20); Cancel.setBounds(300,s,80,20); jpl.add(add); jpl.add(reset); jpl.add(Cancel); public void actionPerformed(ActionEvent e) { if(e.getSource()==Cancel){ dispose(); new mainFrame().setVisible(true); else if(e.getSource()==add) {try {Class.forName(\);} catch (ClassNotFoundException ce) {JOptionPane.showMessageDialog(ss,ce.getMessage());} try{Connection con = DriverManager.getConnection(\ } 学生成绩管理系统\,\,\); Statement stmt = con.createStatement(); int a = stmt.executeUpdate(\into 成绩信息表(学号 , 计 算机网络 , Linux操作系统 , 计算机专业英语 , 计算机信息技术基础 , Java程序设计 , 数据库应用实训教程 , 高等数学 , Xml)values('\+txt[0].getText()+\+txt[1].getText()+\+txt[2].getText()+\+txt[3].getText()+\+txt[4].getText()+\+txt[5].getText()+\+txt[6].getText()+\+txt[7].getText()+\+txt[8].getText()+\);if(a==1) {JOptionPane.showMessageDialog(ss,\添加成功\);} else {JOptionPane.showMessageDialog(ss,\添加失败\);}} catch (SQLException se) {JOptionPane.showMessageDialog(ss,se.getMessage()); }} else {for(int i = 0 ; i {txt[i].setText(\); txt[0].requestFocus(); }}} public static void main(String[] args) {addScore as = new addScore();}} 4.修改学生信息: import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.sql.*; public class modifyForm extends JFrame implements ActionListener { JPanel jpl = new JPanel(); JLabel SCH = new JLabel(\修改学生信息\,JLabel.CENTER); Font f = new Font(\楷体\,Font.BOLD+Font.ITALIC,30); JLabel label1 = new JLabel(\请输入学号:\,JLabel.CENTER); JButton btnQuery = new JButton(\查询\); JLabel label2 = new JLabel(\姓名:\,JLabel.CENTER); JLabel labyear=new JLabel(\年龄:\,JLabel.CENTER); JLabel labDate=new JLabel(\出生日期:\,JLabel.CENTER); JLabel label5 = new JLabel(\性别:\,JLabel.CENTER); JLabel label3 = new JLabel(\班级:\,JLabel.CENTER); JLabel label4 = new JLabel(\专业:\,JLabel.CENTER); JLabel labmz=new JLabel(\民族:\,JLabel.CENTER); ButtonGroup bgp = new ButtonGroup(); JRadioButton man = new JRadioButton(\男\); JRadioButton women = new JRadioButton(\女\); JTextField tyear = new JTextField(); JTextField tDate = new JTextField(); JTextField tmz = new JTextField(); JTextField num = new JTextField(); JTextField nam = new JTextField(); JTextField clas = new JTextField(); JTextField scl = new JTextField(); JButton btnModify = new JButton(\修改\); JButton btnCancel = new JButton(\取消\); Connection con; Statement sql; ResultSet rs; int re; public modifyForm() { this.setSize(560,460); this.setVisible(true); this.setResizable(false); SCH.setForeground(Color.red); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.add(jpl); jpl.setBackground(Color.cyan); man.setBackground(Color.cyan); women.setBackground(Color.cyan); jpl.setLayout(null); btnQuery.addActionListener(this); btnModify.addActionListener(this); btnCancel.addActionListener(this); SCH.setBounds(100,20,300,20); jpl.add(SCH); label1.setBounds(100,60,100,20); jpl.add(label1); num.setBounds(220,60,140,20); jpl.add(num); btnQuery.setBounds(120,100,90,20); btnModify.setBounds(230,100,90,20); btnCancel.setBounds(340,100,90,20); jpl.add(btnQuery); jpl.add(btnModify); jpl.add(btnCancel); label2.setBounds(100,150,70,20); jpl.add(label2); nam.setBounds(190,150,140,20); jpl.add(nam); labyear.setBounds(100,180,70,20); jpl.add(labyear); tyear.setBounds(190,180,140,20); jpl.add(tyear); labDate.setBounds(100,210,70,20); jpl.add(labDate); tDate.setBounds(190,210,140,20); jpl.add(tDate); label5.setBounds(100,250,70,20); jpl.add(label5); man.setBounds(205,250,60,20); women.setBounds(285,250,60,20); bgp.add(man); bgp.add(women); jpl.add(man); jpl.add(women); label3.setBounds(100,290,70,20); jpl.add(label3); clas.setBounds(190,290,140,20); jpl.add(clas); label4.setBounds(100,320,70,20); jpl.add(label4); scl.setBounds(190,320,140,20); jpl.add(scl); labmz.setBounds(100,350,70,20); jpl.add(labmz); tmz.setBounds(190,350,140,20); jpl.add(tmz); } public void actionPerformed(ActionEvent ae){ if(ae.getSource()==btnCancel){ dispose();new mainFrame().setVisible(true);} else if(ae.getSource()==btnQuery){ try{ Class.forName(\);} catch(ClassNotFoundException e){ } try{con=DriverManager.getConnection(\学生成绩管理系统\,\,\); sql=con.createStatement(); rs=sql.executeQuery(\学籍信息表 where 学号='\+num.getText()+\); if(rs.next()){ num.setText(rs.getString(\学号\)); nam.setText(rs.getString(\姓名\)); tyear.setText(rs.getString(\年龄\).toString()); tDate.setText(rs.getString(\出生日期\)); if(rs.getString(\性别\).equals(\男\)) {man.setSelected(true);} else {women.setSelected(true);} clas.setText(rs.getString(\班级\)); scl.setText(rs.getString(\专业\)); tmz.setText(rs.getString(\民族\)); btnModify.setEnabled(true); nam.setEditable(true); tyear.setEditable(true); tDate.setEditable(true); clas.setEditable(true); scl.setEditable(true); tmz.setEditable(true); }else{ JOptionPane.showMessageDialog(null, \不存在该记录!\, \温馨提示\, JOptionPane.INFORMATION_MESSAGE); btnModify.setEnabled(false); tyear.setText(\); tDate.setText(\); tmz.setText(\); num.setText(\); nam.setText(\); clas.setText(\); scl.setText(\); num.requestFocus(); nam.setEditable(false); tyear.setEditable(false); tDate.setEditable(false); clas.setEditable(false); scl.setEditable(false); tmz.setEditable(false); }}catch(SQLException e){ } } else if(ae.getSource()==btnModify) { try {con=DriverManager.getConnection(\学生成绩管理系统 \,\,\); sql=con.createStatement(); re=sql.executeUpdate(\学籍信息表 set 姓名 ='\+nam.getText()+\年龄='\+tyear.getText()+\出生日期='\+tDate.getText()+\班级='\+clas.getText()+\专业='\+scl.getText()+\民族='\+tmz.getText()+\学号='\+num.getText()+\); if(re==1) {JOptionPane.showMessageDialog(null,\记录修改完毕!\,\温馨提示\,JOptionPane.INFORMATION_MESSAGE);} else {JOptionPane.showMessageDialog(null,\记录修改失败!\,\温馨提示\,JOptionPane.INFORMATION_MESSAGE); }sql.close();} catch (SQLException se) {JOptionPane.showMessageDialog(null,se.getMessage());}} else{btnModify.setEnabled(false); tyear.setText(\); tDate.setText(\); tmz.setText(\); num.setText(\); nam.setText(\); clas.setText(\); scl.setText(\); num.requestFocus(); nam.setEditable(false); tyear.setEditable(false); tDate.setEditable(false); clas.setEditable(false); scl.setEditable(false); tmz.setEditable(false); } } public static void main(String[] args) { new modifyForm(); }} 5.删除学生信息 import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.sql.*; public class deleteForm extends JFrame implements ActionListener { JPanel jpl = new JPanel(); JLabel SCH = new JLabel(\删除学生信息\,JLabel.CENTER); Font f = new Font(\楷体\,Font.BOLD+Font.ITALIC,30); JLabel label1 = new JLabel(\请输入学号:\,JLabel.CENTER); JButton btnQuery = new JButton(\查询\); JLabel label2 = new JLabel(\姓名:\,JLabel.CENTER); JLabel labyear=new JLabel(\年龄:\,JLabel.CENTER); JLabel labDate=new JLabel(\出生日期:\,JLabel.CENTER); JLabel label5 = new JLabel(\性别:\,JLabel.CENTER); JLabel label3 = new JLabel(\班级:\,JLabel.CENTER); JLabel label4 = new JLabel(\专业:\,JLabel.CENTER); JLabel labmz=new JLabel(\民族:\,JLabel.CENTER); ButtonGroup bgp = new ButtonGroup(); JRadioButton man = new JRadioButton(\男\); JRadioButton women = new JRadioButton(\女\); JTextField tyear = new JTextField(); JTextField tDate = new JTextField(); JTextField tmz = new JTextField(); JTextField num = new JTextField(); JTextField nam = new JTextField(); JTextField clas = new JTextField(); JTextField scl = new JTextField(); JButton btnDelete = new JButton(\删除\); JButton btnCancel = new JButton(\取消\); Connection con; Statement sql; ResultSet rs; int re; deleteForm() { this.setSize(560,460); this.setVisible(true); this.setResizable(false); SCH.setForeground(Color.red); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.add(jpl); jpl.setBackground(Color.cyan); man.setBackground(Color.cyan); women.setBackground(Color.cyan); jpl.setLayout(null); btnQuery.addActionListener(this); btnCancel.addActionListener(this); SCH.setBounds(100,20,300,20); jpl.add(SCH); label1.setBounds(100,60,100,20); jpl.add(label1); num.setBounds(220,60,140,20); jpl.add(num); btnQuery.setBounds(120,100,90,20); btnCancel.setBounds(340,100,90,20); jpl.add(btnQuery); jpl.add(btnDelete); jpl.add(btnCancel); label2.setBounds(100,150,70,20); jpl.add(label2); nam.setBounds(190,150,140,20); jpl.add(nam); labyear.setBounds(100,180,70,20); btnDelete.addActionListener(this); btnDelete.setBounds(230,100,90,20); jpl.add(labyear); tyear.setBounds(190,180,140,20); jpl.add(tyear); labDate.setBounds(100,210,70,20); jpl.add(labDate); tDate.setBounds(190,210,140,20); jpl.add(tDate); label5.setBounds(100,250,70,20); jpl.add(label5); man.setBounds(205,250,60,20); women.setBounds(285,250,60,20); bgp.add(man); bgp.add(women); jpl.add(man); jpl.add(women); label3.setBounds(100,290,70,20); jpl.add(label3); clas.setBounds(190,290,140,20); jpl.add(clas); label4.setBounds(100,320,70,20); jpl.add(label4); scl.setBounds(190,320,140,20); jpl.add(scl); labmz.setBounds(100,350,70,20); jpl.add(labmz); tmz.setBounds(190,350,140,20); jpl.add(tmz); btnDelete.setEnabled(false);//取消删除按钮的功能 nam.setEditable(false); tyear.setEditable(false); tDate.setEditable(false); clas.setEditable(false); scl.setEditable(false); tmz.setEditable(false); setVisible(true); num.requestFocus(); } public void actionPerformed(ActionEvent ae) { if(ae.getSource()==btnCancel){ dispose();new mainFrame().setVisible(true);} else if(ae.getSource()==btnQuery){ try{Class.forName(\);} catch(ClassNotFoundException e){} try{con=DriverManager.getConnection(\学生成绩管理系统 \,\,\); sql=con.createStatement(); rs=sql.executeQuery(\学籍信息表 where 学号='\+num.getText()+\); if(rs.next()){ num.setText(rs.getString(\学号\)); nam.setText(rs.getString(\姓名\)); tyear.setText(rs.getString(\年龄\).toString()); tDate.setText(rs.getString(\出生日期\)); if(rs.getString(\性别\).equals(\男\)) {man.setSelected(true);} else {women.setSelected(true);} clas.setText(rs.getString(\班级\)); scl.setText(rs.getString(\专业\)); tmz.setText(rs.getString(\民族\)); btnDelete.setEnabled(true); nam.setEditable(true); tyear.setEditable(true); tDate.setEditable(true); clas.setEditable(true); scl.setEditable(true); tmz.setEditable(true); }else{JOptionPane.showMessageDialog(null, \不存在该记录!\, \温馨提示\, JOptionPane.INFORMATION_MESSAGE); btnDelete.setEnabled(false); tyear.setText(\); tDate.setText(\); tmz.setText(\); num.setText(\); nam.setText(\); clas.setText(\); scl.setText(\); num.requestFocus(); nam.setEditable(false); tyear.setEditable(false); tDate.setEditable(false); clas.setEditable(false); scl.setEditable(false); tmz.setEditable(false);} }catch(SQLException e){}} else if(ae.getSource()== btnDelete) {try{ //实现删除功能 con=DriverManager.getConnection(\学生成绩管 理系统\,\,\); sql=con.createStatement(); re=sql.executeUpdate(\学籍信息表 where 学号='\+num.getText()+\); if(re==1) {JOptionPane.showMessageDialog(null,\记录删除完毕!\,\ 温馨提示\,JOptionPane.INFORMATION_MESSAGE);} else {JOptionPane.showMessageDialog(null,\记录删除失败!\,\ 温馨提示\,JOptionPane.INFORMATION_MESSAGE);} sql.close();} catch (SQLException se) {JOptionPane.showMessageDialog(null,se.getMessage());}} else{ btnDelete.setEnabled(false); tyear.setText(\); tDate.setText(\); tmz.setText(\); num.setText(\); nam.setText(\); clas.setText(\); scl.setText(\); num.requestFocus(); nam.setEditable(false); tyear.setEditable(false); tDate.setEditable(false); clas.setEditable(false); scl.setEditable(false); tmz.setEditable(false); }} public static void main(String[] args) { new deleteForm();}} 6.学生信息查询与成绩查询 import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.awt.font.*; import java.sql.*; public class Score extends JFrame implements ActionListener { static Score s; JLabel title = new JLabel(\查询成绩\,JLabel.CENTER); Font f = new Font(\楷体\,Font.BOLD+Font.ITALIC,16); JPanel jpl = new JPanel(); JLabel label1 = new JLabel(\请输入学号:\,JLabel.CENTER); JTextField num = new JTextField(); JButton serch = new JButton(\查询成绩\); JButton reset = new JButton(\重置\); JLabel label2 = new JLabel(\计算机网络:\,JLabel.LEFT); JLabel label3 = new JLabel(\操作系统:\,JLabel.LEFT); JLabel label4 = new JLabel(\计算机专业英语:\,JLabel.LEFT); JLabel label5 = new JLabel(\计算机信息技术基础:\,JLabel.LEFT); JLabel label6 = new JLabel(\程序设计:\,JLabel.LEFT); JLabel label7 = new JLabel(\数据库:\,JLabel.LEFT); JLabel label8 = new JLabel(\高等数学:\,JLabel.LEFT); JLabel label9 = new JLabel(\:\,JLabel.LEFT); JButton Cancel=new JButton(\返回\); JTextField[] txt ={ new JTextField() , new JTextField() , new JTextField() , new JTextField() , new JTextField() , new JTextField() ,new JTextField() , new JTextField()}; static int p = 140; public Score() { super(\查询分数\); this.setResizable(false); this.setSize(500,550); this.setVisible(true); title.setForeground(Color.red); jpl.setBackground(Color.LIGHT_GRAY); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.add(jpl); jpl.setLayout(null); title.setBounds(100,20,300,20); jpl.add(title); label1.setBounds(100,60,90,20); jpl.add(label1); num.setBounds(210,60,140,20); jpl.add(num); serch.setBounds(100,100,90,20); reset.setBounds(200,100,90,20); Cancel.setBounds(300,100,90,20); jpl.add(serch); jpl.add(reset); jpl.add(Cancel); serch.addActionListener(this); reset.addActionListener(this); Cancel.addActionListener(this); label2.setBounds(100,140,140,20); label3.setBounds(100,180,140,20); label4.setBounds(100,220,140,20); label5.setBounds(100,260,140,20); label6.setBounds(100,300,140,20); label7.setBounds(100,340,140,20); label8.setBounds(100,380,140,20); label9.setBounds(100,420,140,20); jpl.add(label2); jpl.add(label3); jpl.add(label4); jpl.add(label5); title.setFont(f); jpl.add(label6); jpl.add(label7); jpl.add(label8); jpl.add(label9); for(int i = 0 ;i jpl.add(txt[i]); p=p+40;}} public void actionPerformed(ActionEvent e) {if(e.getSource()==Cancel){ dispose(); new mainFrame().setVisible(true); } if(e.getSource()==serch) {String id = num.getText(); try{Class.forName(\);} catch (ClassNotFoundException ce) {JOptionPane.showMessageDialog(s,ce.getMessage());} try{Connection con = DriverManager.getConnection(\ 学生成绩管理系统\,\,\); Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery(\成绩信息 表 where 学号 ='\ + id + \); while(rs.next()) {for(int i = 0 ; i {txt[i].setText(rs.getString(i+2));}}} catch (SQLException se) {JOptionPane.showMessageDialog(s,se.getMessage());}} else {for(int i = 0;i {txt[i].setText(\);} num.setText(\);}} public static void main(String[] args) {Score s = new Score();}} import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.sql.*; public class Serch extends JFrame implements ActionListener { static Serch s; JPanel jpl = new JPanel(); JLabel SCH = new JLabel(\查询学生信息\,JLabel.CENTER); JLabel label1 = new JLabel(\请输入学号:\,JLabel.CENTER); JButton serch = new JButton(\查询\); JLabel label2 = new JLabel(\姓名:\,JLabel.CENTER); JLabel labyear=new JLabel(\年龄:\,JLabel.CENTER); JLabel labDate=new JLabel(\出生日期:\,JLabel.CENTER); JLabel label5 = new JLabel(\性别:\,JLabel.CENTER); JLabel label3 = new JLabel(\班级:\,JLabel.CENTER); JLabel label4 = new JLabel(\专业:\,JLabel.CENTER); JLabel labmz=new JLabel(\民族:\,JLabel.CENTER); ButtonGroup bgp = new ButtonGroup(); JRadioButton man = new JRadioButton(\男\); JRadioButton women = new JRadioButton(\女\); JTextField tyear = new JTextField(); JTextField tDate = new JTextField(); JTextField tmz = new JTextField(); JTextField num = new JTextField(); JTextField nam = new JTextField(); JTextField clas = new JTextField(); JTextField scl = new JTextField(); JButton reset = new JButton(\重置\); JButton caln = new JButton(\取消\); public Serch() { this.setSize(560,460); this.setVisible(true); this.setResizable(false); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.add(jpl); jpl.setBackground(Color.cyan); man.setBackground(Color.cyan); women.setBackground(Color.cyan); jpl.setLayout(null); serch.addActionListener(this); reset.addActionListener(this); caln.addActionListener(this); SCH.setBounds(100,20,300,20); jpl.add(SCH); label1.setBounds(100,60,100,20); jpl.add(label1); num.setBounds(220,60,140,20); jpl.add(num); serch.setBounds(120,100,90,20); reset.setBounds(230,100,90,20); caln.setBounds(340,100,90,20); jpl.add(serch); jpl.add(reset); jpl.add(caln); label2.setBounds(100,150,70,20); jpl.add(label2); nam.setBounds(190,150,140,20); jpl.add(nam); labyear.setBounds(100,180,70,20); jpl.add(labyear); tyear.setBounds(190,180,140,20); jpl.add(tyear); labDate.setBounds(100,210,70,20); jpl.add(labDate); tDate.setBounds(190,210,140,20); jpl.add(tDate); label5.setBounds(100,250,70,20); jpl.add(label5); man.setBounds(205,250,60,20); women.setBounds(285,250,60,20); bgp.add(man); bgp.add(women); jpl.add(man); jpl.add(women); label3.setBounds(100,290,70,20); jpl.add(label3); clas.setBounds(190,290,140,20); jpl.add(clas); label4.setBounds(100,320,70,20); jpl.add(label4); scl.setBounds(190,320,140,20); jpl.add(scl); labmz.setBounds(100,350,70,20); jpl.add(labmz); tmz.setBounds(190,350,140,20); jpl.add(tmz);} public void actionPerformed(ActionEvent e) {if(e.getSource()==caln){ dispose(); new mainFrame().setVisible(true);} else if(e.getSource()== serch){ try{Class.forName(\);} catch(ClassNotFoundException se){} try{Connection con=DriverManager.getConnection(\学生成绩管理系统\,\,\); Statement stmt=con.createStatement(); ResultSet rs = stmt.executeQuery(\学籍信息表 if(rs.next()){num.setText(rs.getString(\学号\)); nam.setText(rs.getString(\姓名\)); tyear.setText(rs.getString(\年龄\).toString()); tDate.setText(rs.getString(\出生日期\)); if(rs.getString(\性别\).equals(\男\)) {man.setSelected(true);} else where 学号='\+num.getText()+\); {women.setSelected(true);} clas.setText(rs.getString(\班级\)); scl.setText(rs.getString(\专业\)); tmz.setText(rs.getString(\民族\)); }else{JOptionPane.showMessageDialog(null, \不存在该记录! \, \温馨提示\, JOptionPane.INFORMATION_MESSAGE); tyear.setText(\); tDate.setText(\); tmz.setText(\); num.setText(\); nam.setText(\); clas.setText(\); scl.setText(\); num.requestFocus();} }catch(SQLException se){}}} public static void main(String[] args) {Serch sch = new Serch();}}
正在阅读:
java项目(学生成绩管理系统)04-20
第二章 学前儿童社会性发展05-10
印度认证01-13
高三数学二轮复习1 - 4 - 2数列求和及综合应用课时巩固过关练理03-30
探究不同活性炭浓度对薄荷植物组织培养的影响 - 图文03-06
青岛输油管道爆炸事件案例分析10-23
中考英语专题(13)简单句03-25
2016年年会总经理总结致辞01-16
小升初语文模拟检测试题含答案05-23
- 多层物业服务方案
- (审判实务)习惯法与少数民族地区民间纠纷解决问题(孙 潋)
- 人教版新课标六年级下册语文全册教案
- 词语打卡
- photoshop实习报告
- 钢结构设计原理综合测试2
- 2014年期末练习题
- 高中数学中的逆向思维解题方法探讨
- 名师原创 全国通用2014-2015学年高二寒假作业 政治(一)Word版
- 北航《建筑结构检测鉴定与加固》在线作业三
- XX县卫生监督所工程建设项目可行性研究报告
- 小学四年级观察作文经典评语
- 浅谈110KV变电站电气一次设计-程泉焱(1)
- 安全员考试题库
- 国家电网公司变电运维管理规定(试行)
- 义务教育课程标准稿征求意见提纲
- 教学秘书面试技巧
- 钢结构工程施工组织设计
- 水利工程概论论文
- 09届九年级数学第四次模拟试卷
- 管理系统
- 成绩
- 项目
- 学生
- java
- 儿科病中医诊疗方案
- 惯性导航与组合导航论文
- 纪律作风整顿自查报告
- 上海交通大学物理期中考试卷2003年大学物理力学考题(答案)(A)
- 大理宾川鸡足山旅游资源文化内涵的挖掘及其发展措施
- 2017年上期《汽车机械识图》期末考试试卷2017.6.3
- 劳社部发〔2005〕29号
- 2012-2013(2)高数试题A
- 语文课程标准学习心得体会
- 大学生创业基础TRIZ案例
- 职业技能大赛对机电一体化技术专业教学改革意义与实践研究院级科
- 广东省惠州市2013届高三第二次调研考试数学试题(文科)
- 分析化学练习题(第3章 误差与数据处理)(1)
- 陕西省易地扶贫搬迁户档案
- 八年级生物下实验通知单
- 计算机网络故障的一般识别与解决方法论文
- 2稿:中小企业成本管理问题研究
- 二一一年度校级先进团支部、优秀团干部
- 白酒市场的调研报告范文
- 2017年天水市中考数学试卷(Word版) - 图文