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

📄 student.java

📁 改经的学生学籍管理系统
💻 JAVA
字号:
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.sql.*;
public class Student extends JFrame 
{ private JButton but1,but2,but3,but4;

Label bl=new Label();
	private Connection connect;
	private Consql consql;
	private Statement stmt;
	private ResultSet rs;
   public Student()
{
 super("成绩综合测评程序");
  	consql=new Consql();
 FlowLayout layout = new FlowLayout();
 Container c=getContentPane();
 c.setLayout(layout);
  bl.setText("成绩测评程序");
bl.setAlignment(Label.CENTER);
c.add(bl);
 but1=new JButton("查询");
 but1.addActionListener(new handle1());
 c.add(but1);
 but2=new JButton("添加");
 but2.addActionListener(new handle2());
 c.add(but2);
 but3=new JButton("删除");
 but3.addActionListener(new handle3());
 c.add(but3);
 but4=new JButton("退出");
 but4.addActionListener(new handle4());
 c.add(but4); 
 setSize(400,300);
 show();
       try
      {
      
      connect=consql.connect();
      stmt=connect.createStatement();
      }
      catch(SQLException e)
  	  {
  		  System.out.println("SQLException6:"+e.getMessage());
  	  } 
 	}
public class handle4 implements ActionListener
{
 	
    public void actionPerformed(ActionEvent e){
    try
      {
 	  stmt.close();
      consql.closeconnect();
      }
      catch(SQLException ce)
  	  {
  		  System.out.println("SQLException4:"+ce.getMessage());
  	  } 
	System.exit(0);	
}
	}
 public class handle1 implements ActionListener
{
	public void actionPerformed(ActionEvent e){
	new ShowWin();
		}
	}
public class handle2 implements ActionListener
{
	public void actionPerformed(ActionEvent e)
	{
	new ShowWin();
		}
	
	}

public class handle3 implements ActionListener
{
	public void actionPerformed(ActionEvent e){
		String title="删除对话框";
		String content="请输入学号:";
		int dialogtype=JOptionPane.QUESTION_MESSAGE;
		String stdnum=JOptionPane.showInputDialog(null,content,title,dialogtype);
		try
		{

		String num="select * from results where number="+stdnum;
		rs=stmt.executeQuery(num);
		if(!rs.next())
		{
			JOptionPane.showMessageDialog(null,"没有这个学号的数据!","信息提示",JOptionPane.INFORMATION_MESSAGE); 
		}
		else
		{
		try
		{

		String delstdnum="delete from results where number="+stdnum;
		stmt.executeUpdate(delstdnum);
		}
		catch(SQLException ce)
  	  {
  		  System.out.println("SQLException7:"+ce.getMessage());
  	  }
  	  JOptionPane.showMessageDialog(null,"删除成功!","信息提示",JOptionPane.INFORMATION_MESSAGE); 
		}
		}
		catch(SQLException cee)
		{
			 System.out.println("SQLException8:"+cee.getMessage());
		}
		}
		}
 	public static void main(String args[])
 { 
 Student app = new Student();
 	app.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
   
 }
	}

⌨️ 快捷键说明

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