📄 d_delbook.java~1~
字号:
/*
* D_delbook.java
*
* Created on 2007年6月22日, 上午11:21
*/
package 图书管理系统;
import javax.swing.*;
import java.sql.*;
public class D_delbook extends javax.swing.JFrame {
/** Creates new form D_delbook */
public D_delbook() {
initComponents();
con=connect.getcon();
stmt=connect.getstmt();
this.setTitle("图书作废处理");
this.setBounds(300,250,250,200);
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc=" 生成的代码 ">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
T_dbookID = new javax.swing.JTextField();
B_bdel = new javax.swing.JButton();
B_bcancel = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("\u8bf7\u8f93\u5165\u60a8\u6240\u8981\u5220\u9664\u7684\u56fe\u4e66\u53f7:");
B_bdel.setText("\u5220\u9664");
B_bdel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
B_bdelActionPerformed(evt);
}
});
B_bcancel.setText("\u53d6\u6d88");
B_bcancel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
B_bcancelActionPerformed(evt);
}
});
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(23, 23, 23)
.add(jLabel1))
.add(layout.createSequentialGroup()
.add(50, 50, 50)
.add(B_bdel)
.add(58, 58, 58)
.add(B_bcancel))
.add(layout.createSequentialGroup()
.add(78, 78, 78)
.add(T_dbookID, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 109, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(66, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(jLabel1)
.add(22, 22, 22)
.add(T_dbookID, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 41, Short.MAX_VALUE)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(B_bdel)
.add(B_bcancel))
.add(24, 24, 24))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void B_bcancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_B_bcancelActionPerformed
// TODO 将在此处添加您的处理代码:
this.setVisible(false);
}//GEN-LAST:event_B_bcancelActionPerformed
private void B_bdelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_B_bdelActionPerformed
// TODO 将在此处添加您的处理代码:
try{
if(T_dbookID.getText().trim().equals(""))
{
JOptionPane.showMessageDialog(null,"图书号输入不能为空");
return;
}
if(JOptionPane.showConfirmDialog(null,"删除该图书将删除相应的借书记录,你确认要删除该图书吗?","温馨提示:",0)==0)
{
PreparedStatement sql=con.prepareStatement("delete from 借阅 where 书号=?");
sql.setString(1,T_dbookID.getText().trim());
sql.executeUpdate();
sql=con.prepareStatement("delete from 图书 where 书号=?");
sql.setString(1,T_dbookID.getText().trim());
sql.executeUpdate();
JOptionPane.showMessageDialog(null,"图书信息删除成功");
this.setVisible(false);
}
}
catch(Exception ee)
{
JOptionPane.showMessageDialog(null,"数据库访问失败!");
ee.printStackTrace();
}
}//GEN-LAST:event_B_bdelActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new D_delbook().setVisible(true);
}
});
}
// 变量声明 - 不进行修改//GEN-BEGIN:variables
private javax.swing.JButton B_bcancel;
private javax.swing.JButton B_bdel;
private javax.swing.JTextField T_dbookID;
private javax.swing.JLabel jLabel1;
// 变量声明结束//GEN-END:variables
private Connection con;
private Statement stmt;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -