?? userdelete.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 + -