JAVA学生成绩管理系统源码
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
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.addActionListener(this); pa4=new JPanel(); pa4.add(btu1); pa4.add(btu2); gbc.gridx=1;gbc.gridy=4;
VALUES
('"+t1.getText()+"','"+t2.getText()+"','"+
t3.getText()+"','"+t4.getText()+"','"+t5.getText()+"')";
String num1=t1.getText();
String num2=t1.getText();
}
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{
and 课程名='"+num3+"'";
ResultSet rs=stmt.executeQuery(sql1);
if(rs.next()){
stmt.executeUpdate(sql2);
JOptionPane.showMessageDialog(this, "删除成功!");
}
else{
JOptionPane.showMessageDialog(this, "没有此条记录!请重新输入");
String sql1=null,sql2=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()); }
}
else{
stmt.executeUpdate(sql1);
JOptionPane.showMessageDialog(this, "添加成功!");
}
t1.setText("");
t2.setText("");
t3.setText("");
来自百度文库
t4.setText("");
t5.setText("");
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,0,5); gbL.setConstraints(pa1,gbc); add(pa1); tf2.addActionListener(this); pa2=new JPanel(); pa2.add(lab2); pa2.add(tf2);
int 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){
//添加-------------------
try{
con=DriverManager.getConnection(url,"root","123");
stmt=con.createStatement();
sql1="INSERT INTO 学 生 成 绩 表
JTextField t1,t2,t3; JTable table; JButton 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("删除"); 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 sele="select * from 学 生 成 绩 表 where 学 号 ='"+num1+"' and 课 程 名
='"+num2+"'";
ResultSet rs=stmt.executeQuery(sele);
if(rs.next()){
JOptionPane.showMessageDialog(this, "已有该条记录,请核实!");
JTextField t1,t2,t3,t4,t5; JTable table; JButton but1; JLabel lab1,lab2,lab3,lab4,lab5; JPanel 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 JLabel("成绩"); 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 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);
='"+num3+"'";
con=DriverManager.getConnection(url,"root","123");
stmt=con.createStatement();
sql1="select * from 学生成绩表 where 学号='"+num1+"' and 姓名='"+num2+"'
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(); try{ ls=new loginsure(user,pass); this.setVisible(false); }catch (SQLException e1){ e1.printStackTrace(); }catch (ClassNotFoundException e1){ e1.printStackTrace(); } } if(e.getSource()==btu2){
文件 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{
stmt.close();
con.close();
}catch(SQLException ex){
System.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{
gbc.fill=GridBagConstraints.HORIZONTAL; gbc.anchor=GridBagConstraints.CENTER; lab1=new JLabel("请输入帐号"); lab2=new JLabel("请输入密码"); tf2=new JPasswordField(10);
if(e.getSource()==but1){
//删除----------------------------
try{
String num1=t1.getText();
String num2=t2.getText();
String num3=t3.getText();
sql2="delete from 学 生 成 绩 表 where 学 号 ='"+num1+"'and 课 程 名
btu1=new JButton("确定"); btu1.addActionListener(this); btu2=new JButton("退出"); btu2.addActionListener(this); pa4=new JPanel(); pa4.add(btu1); pa4.add(btu2); gbc.gridx=1;gbc.gridy=4;
VALUES
('"+t1.getText()+"','"+t2.getText()+"','"+
t3.getText()+"','"+t4.getText()+"','"+t5.getText()+"')";
String num1=t1.getText();
String num2=t1.getText();
}
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{
and 课程名='"+num3+"'";
ResultSet rs=stmt.executeQuery(sql1);
if(rs.next()){
stmt.executeUpdate(sql2);
JOptionPane.showMessageDialog(this, "删除成功!");
}
else{
JOptionPane.showMessageDialog(this, "没有此条记录!请重新输入");
String sql1=null,sql2=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()); }
}
else{
stmt.executeUpdate(sql1);
JOptionPane.showMessageDialog(this, "添加成功!");
}
t1.setText("");
t2.setText("");
t3.setText("");
来自百度文库
t4.setText("");
t5.setText("");
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,0,5); gbL.setConstraints(pa1,gbc); add(pa1); tf2.addActionListener(this); pa2=new JPanel(); pa2.add(lab2); pa2.add(tf2);
int 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){
//添加-------------------
try{
con=DriverManager.getConnection(url,"root","123");
stmt=con.createStatement();
sql1="INSERT INTO 学 生 成 绩 表
JTextField t1,t2,t3; JTable table; JButton 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("删除"); 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 sele="select * from 学 生 成 绩 表 where 学 号 ='"+num1+"' and 课 程 名
='"+num2+"'";
ResultSet rs=stmt.executeQuery(sele);
if(rs.next()){
JOptionPane.showMessageDialog(this, "已有该条记录,请核实!");
JTextField t1,t2,t3,t4,t5; JTable table; JButton but1; JLabel lab1,lab2,lab3,lab4,lab5; JPanel 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 JLabel("成绩"); 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 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);
='"+num3+"'";
con=DriverManager.getConnection(url,"root","123");
stmt=con.createStatement();
sql1="select * from 学生成绩表 where 学号='"+num1+"' and 姓名='"+num2+"'
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(); try{ ls=new loginsure(user,pass); this.setVisible(false); }catch (SQLException e1){ e1.printStackTrace(); }catch (ClassNotFoundException e1){ e1.printStackTrace(); } } if(e.getSource()==btu2){
文件 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{
stmt.close();
con.close();
}catch(SQLException ex){
System.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{
gbc.fill=GridBagConstraints.HORIZONTAL; gbc.anchor=GridBagConstraints.CENTER; lab1=new JLabel("请输入帐号"); lab2=new JLabel("请输入密码"); tf2=new JPasswordField(10);
if(e.getSource()==but1){
//删除----------------------------
try{
String num1=t1.getText();
String num2=t2.getText();
String num3=t3.getText();
sql2="delete from 学 生 成 绩 表 where 学 号 ='"+num1+"'and 课 程 名