📄 deleteaction.java~11~
字号:
package informationsystem.gui;
import java.awt.event.*;
import informationsystem.gui.MainWindow;
import informationsystem.database.DBHandler;
import informationsystem.information.*;
public class DeleteAction
implements ActionListener {
public DeleteAction() {
try {
jbInit();
}
catch (Exception ex) {
ex.printStackTrace();
}
}
private MainWindow window;
private DBHandler db = new DBHandler();
public DeleteAction(MainWindow window) {
this.window = window;
}
/**
* Invoked when an action occurs.
*
* @param e ActionEvent
* @todo Implement this java.awt.event.ActionListener method
*/
public void actionPerformed(ActionEvent e) {
try {
String number = this.window.jTextField1.getText();
if (number.equals("")) {
this.window.jTextPane1.setText("请输入价格!");
return;
}
if (!db.validate(number)) { // 判断数据库中是否有要删除的记录,如没有则显示提示框
this.window.jTextField1.setText("");
this.window.jTextPane1.setText("数据库中没有您要删除的价格!");
}
else {
if (HardDisk.deleteStudent(number)) {
this.window.jTextField1.setText("");
this.window.jTextField2.setText("");
this.window.jTextField3.setText("");
this.window.jTextField4.setText("");
this.window.jTextField5.setText("");
this.window.jTextPane1.setText("记录已成功删除!");
}
else {
this.window.jTextPane1.setText("记录删除失败!");
}
}
}
catch (Exception ex) {
ex.printStackTrace();
}
}
private void jbInit() throws Exception {
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -