⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 c087b29a9a50001d1dc6bad43998f314

📁 学生管理系统.对学生信息管理的一个应用软件!
💻
字号:
import java.awt.*;

import javax.swing.*;

import java.awt.event.*;
import java.sql.*;
class studentMess1 extends JFrame implements ActionListener
{   Button button1,button2,button3;
    TextField text1,text2,text3,text4,text5,text6,text7;
    Label label1,label2,label3,label4,label5,label6,label7;
    studentMess1(String s)
    {
    	super(s);
    	setLayout(new FlowLayout());
 	    button1=new Button("修改");
        //button2=new Button("确定");
        button2=new Button("添加");
        button3=new Button("删除");
        label1 =new Label("学号");
        text1=new TextField(10);
        add(label1);
        add(text1);
        label2 =new Label("姓名");
        text2=new TextField(10);
        add(label2);
        add(text2);
        label3 =new Label("性别");
        text3=new TextField(10);
        add(label3);
        add(text3);
        label4 =new Label("系别");
        text4=new TextField(10);
        add(label4);
        add(text4);
        label5 =new Label("班级");
        text5=new TextField(6);
        add(label5);
        add(text5);
        label6 =new Label("出生年月");
        text6=new TextField(10);
        add(label6);
        add(text6);
        label7 =new Label("籍贯");
        text7=new TextField(20);
        add(label7);
        add(text7);
        
       
        add(button1);
        //add(button2);
        add(button2);
        add(button3);
        button1.addActionListener(this);
        //button2.addActionListener(this);
        button2.addActionListener(this);
        button3.addActionListener(this);
        this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        setBounds(120,120,300,300);
        setVisible(true);
  	    validate();
    }
    public void actionPerformed(ActionEvent e)
    {
    	
    	if(e.getSource()==button2){
    		Connection con;
 		   Statement sql;
 		   ResultSet rs;
 		   try{
 			   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
 		   }catch(ClassNotFoundException k){
 			   System.out.println(""+k);
 		   }
 		   try{
 			   con=DriverManager.getConnection("jdbc:odbc:sun","","");
 			   sql=con.createStatement();
 			   String no,name,sex,series,cla,bir,home,recode,addstr;
 			   no=text1.getText();
 			   name=text2.getText();
 			   sex=text3.getText();
 			   series=text4.getText();
 			   cla=text5.getText();
 			   bir=text6.getText();
 			   home=text7.getText();
 	   	   	 	
 			   addstr="INSERT INTO 学生个人信息表 VALUES ('"+no+"','"+name+"','"+sex+"','"+
 			   			series+"','"+cla+"','"+bir+"','"+home+"')";
 			   System.out.println(addstr);
 			   sql.executeUpdate(addstr);
 			   con.close();
 		   }catch(SQLException ee){
 			   System.out.print(ee);
 		   }
    	}
    	if(e.getSource()==button1){
    		Connection con;
 		   Statement sql;
 		   ResultSet rs;
 		   try{
 			   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
 		   }catch(ClassNotFoundException k){
 			   System.out.println(""+k);
 		   }
 		   try{
 			   con=DriverManager.getConnection("jdbc:odbc:sun","","");
 			   sql=con.createStatement();
 			  String no,name,sex,series,cla,bir,home,recode,updatestr=null;
			   no=text1.getText();
			   name=text2.getText();
			   sex=text3.getText();
			   series=text4.getText();
			   cla=text5.getText();
			   bir=text6.getText();
			   home=text7.getText();
 			   
 	   	   	   if(sex!=null)
 	   	   		   updatestr="UPDATE 学生个人信息表 SET  sex= '" + sex+ "' WHERE no='" + no + "'"+" OR name = "+name+"'";
 	   	   	   if(series!=null)
 	   	   		   updatestr="UPDATE 学生个人信息表 SET  deparment= '" + series+ "' WHERE no='" + no + "'"+" OR name = "+name+"'";
 	   	   	   if(cla!=null)
 	   	   		   updatestr="UPDATE 学生个人信息表 SET  banji= '" + cla+ "' WHERE no='" + no + "'"+" OR name = "+name+"'";
 	   	   	   if(bir!=null)
 	   	   		   updatestr="UPDATE 学生个人信息表 SET  birthday= '" + bir + "' WHERE no='" + no + "'"+" OR name = "+name+"'";
 	   	   	   if(home!=null)
 	   	   		   updatestr="UPDATE 学生个人信息表 SET  nativeplace= '" + home+ "' WHERE no='" + no + "'"+" OR name = "+name+"'";
 	   	   	   
 	   	   	   System.out.println(updatestr);
 			   sql.executeUpdate(updatestr);
 			   con.close();
 		   }catch(SQLException ee){
 			   System.out.print(ee);
 		   }
    	}
    	if(e.getSource()==button3){
    		Connection con;
 		   Statement sql;
 		   ResultSet rs;
 		   try{
 			   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
 		   }catch(ClassNotFoundException k){
 			   System.out.println(""+k);
 		   }
 		   try{
 			   con=DriverManager.getConnection("jdbc:odbc:sun","","");
 			   sql=con.createStatement();
 			   String no,name,delstr=null;
			   no=text1.getText();
			   name=text2.getText();
 	   	   	   delstr="DELETE FROM login WHERE name = '" + name+ "' OR no = '"+no+"'";
 			 
 			   
 	   	   	   System.out.println(delstr);
 			   sql.executeUpdate(delstr);
 			   con.close();
 		   }catch(SQLException ee){
 			   System.out.print(ee);
 		   }
    	}
 	   
    }
	
}
/*public class SmessageManage
{  public static void main(String args[])
  {  studentMess1 win=new studentMess1("学生信息") ;
  }
}*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -