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

📄 scstfrom.java~14~

📁 这个是学生考试系统,里面有完整的代码加数据库SQL server
💻 JAVA~14~
字号:
package testsystem;

import java.awt.*;
import java.sql.*;
import javax.swing.*;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class scstFrom extends JFrame {
    private ImageIcon im1 = new ImageIcon("img\\red_forum.gif");
    public scstFrom() {
        try {
            jbInit();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    private void jbInit() throws Exception {
        this.getContentPane().setBackground(new Color(226, 176, 226));
        this.setResizable(false);
        setTitle("删除试题");
        jLabel2.setFont(new java.awt.Font("隶书", Font.BOLD, 20));
        getContentPane().setLayout(null);
        jt1.setBounds(new Rectangle(100, 78, 172, 34));
        jLabel2.setForeground(SystemColor.desktop);
        jLabel2.setHorizontalAlignment(SwingConstants.CENTER);
        jLabel2.setText("试  题  删  除");
        jLabel2.setBounds(new Rectangle(87, 18, 191, 33));
        jLabel1.setForeground(Color.red);
        jButton1.addActionListener(new scstFrom_jButton1_actionAdapter(this));
        jButton1.setIcon(im1);
        this.getContentPane().add(jLabel2);
        jButton1.setBounds(new Rectangle(131, 189, 111, 35));
        jButton1.setText("删除");
        this.getContentPane().add(jt1);
        this.getContentPane().add(jLabel1);
        this.getContentPane().add(jButton1);
        jLabel1.setText("请输入要删除的试题编号,一但删除不可恢复请重新添加!");
        jLabel1.setBounds(new Rectangle(39, 139, 319, 26));
    }

    public static void main(String[] args) {
        scstFrom scstfrom = new scstFrom();
    }

    JTextField jt1 = new JTextField();
    JLabel jLabel1 = new JLabel();
    JLabel jLabel2 = new JLabel();
    JButton jButton1 = new JButton();
    public void jButton1_actionPerformed(ActionEvent e) {
         String num=jt1.getText().trim();
         Connection con=null;
         Statement s1=null;
         ResultSet rs=null;
         try
         {
             if(num.length()!=0)
             {
                 try
                {
                    Integer num1=Integer.parseInt(num);
                }
                catch(Exception ce)
                {
                    JOptionPane.showMessageDialog(null,"编号必须是数字!","提示",JOptionPane.ERROR_MESSAGE);
                }
                con=DBcon.link();
                s1=con.createStatement();
                rs=s1.executeQuery("select * from Question where Num='"+num+"'");
                if(rs.next())
                {
                    s1.executeUpdate("delete from Question where Num="+num+"");
                    JOptionPane.showMessageDialog(null,""+num+"号试题删除成功!");
                    int p=JOptionPane.showConfirmDialog(null,"您是否还要添加?","提示",JOptionPane.YES_NO_OPTION);
                    if(p!=0)
                    {
                        this.setVisible(false);
                    }
                    else
                    {
                        jt1.setText("");
                        jt1.requestFocus();
                        return;
                    }
                }
                else
                {
                    JOptionPane.showMessageDialog(null,"对不起,您要删除的试题编号不存在!");
                    jt1.setText("");
                    jt1.requestFocus();
                }
             }
             else
             {
                 JOptionPane.showMessageDialog(null,"信息未填完全,无法添加!");
             }

         }
         catch(SQLException co)
         {
             co.getMessage();
         }
    }
}


class scstFrom_jButton1_actionAdapter implements ActionListener {
    private scstFrom adaptee;
    scstFrom_jButton1_actionAdapter(scstFrom adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jButton1_actionPerformed(e);
    }
}

⌨️ 快捷键说明

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