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

📄 userdelete.java~3~

📁 Java信息系统设计与开发实例(第二版)随书源代码.
💻 JAVA~3~
字号:
package bookmanager;import javax.swing.*;import com.borland.jbcl.layout.*;import java.awt.*;import java.awt.event.*;import java.sql.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2003</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class userDelete extends JFrame {  ResultSet rs;    //定义结果集  private DBManager db =new DBManager();//定义数据库操作对象  XYLayout xYLayout1 = new XYLayout();  JLabel jLabel2 = new JLabel();  JButton jButtonCancel = new JButton();  JLabel jLabel1 = new JLabel();  JTextField jTextFieldusername = new JTextField();  JButton jButtonOK = new JButton();  JPasswordField jPasswordold = new JPasswordField();  public userDelete() {    try {      jbInit();    }    catch(Exception e) {      e.printStackTrace();    }  }  public static void main(String[] args) {    userDelete userDelete = new userDelete();  }  private void jbInit() throws Exception {    jPasswordold.setText("");    jButtonOK.setFont(new java.awt.Font("Dialog", 0, 16));    jButtonOK.setText("确定");    jButtonOK.addMouseListener(new userDelete_jButtonOK_mouseAdapter(this));    jTextFieldusername.setFont(new java.awt.Font("Dialog", 0, 16));    jTextFieldusername.setText("");    jLabel1.setFont(new java.awt.Font("Dialog", 0, 16));    jLabel1.setText("用户名");    jButtonCancel.setFont(new java.awt.Font("Dialog", 0, 16));    jButtonCancel.setText("取消");    jButtonCancel.addMouseListener(new userDelete_jButtonCancel_mouseAdapter(this));     jLabel2.setFont(new java.awt.Font("Dialog", 0, 16));    jLabel2.setText("密码");    this.getContentPane().setLayout(xYLayout1);    xYLayout1.setWidth(400);    xYLayout1.setHeight(239);    this.getContentPane().add(jTextFieldusername, new XYConstraints(209, 18, 111, 38));    this.getContentPane().add(jLabel2, new XYConstraints(59, 85, 80, 34));    this.getContentPane().add(jLabel1, new XYConstraints(58, 19, 99, 34));    this.getContentPane().add(jPasswordold, new XYConstraints(210, 81, 111, 35));    this.getContentPane().add(jButtonOK, new XYConstraints(90, 174, 91, 31));    this.getContentPane().add(jButtonCancel, new XYConstraints(208, 175, 94, 30));  }  void jButtonCancel_mouseClicked(MouseEvent e) {          this.dispose();  }  void jButtonOK_mouseClicked(MouseEvent e) {    String strSQL ;       strSQL="select * from user where username='"+jTextFieldusername.getText().trim() +"' and password='"+jPasswordold.getText().trim()+"'";              rs=db.getResult(strSQL) ;       if(rs.equals(null ))         {JOptionPane.showMessageDialog(null,"用户名不存在,或原密码不正确!");                  }       else         {             strSQL="delete from user where username='"+jTextFieldusername.getText().trim() +"'";             if(db.executeSql(strSQL))                {JOptionPane.showMessageDialog(null,"成功删除!"); }             else                { JOptionPane.showMessageDialog(null," 删除失败,请重新操作!");      }           }  }}class userDelete_jButtonCancel_mouseAdapter extends java.awt.event.MouseAdapter {  userDelete adaptee;  userDelete_jButtonCancel_mouseAdapter(userDelete adaptee) {    this.adaptee = adaptee;  }  public void mouseClicked(MouseEvent e) {    adaptee.jButtonCancel_mouseClicked(e);  }}class userDelete_jButtonOK_mouseAdapter extends java.awt.event.MouseAdapter {  userDelete adaptee;  userDelete_jButtonOK_mouseAdapter(userDelete adaptee) {    this.adaptee = adaptee;  }  public void mouseClicked(MouseEvent e) {    adaptee.jButtonOK_mouseClicked(e);  }}

⌨️ 快捷键说明

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