📄 d_delreader.java
字号:
/*
* D_delreader.java
*
* Created on 2007年6月23日, 下午8:39
*/
package 图书管理系统;
import javax.swing.*;
import java.sql.*;
public class D_delreader extends javax.swing.JFrame {
/** Creates new form D_delreader */
public D_delreader() {
initComponents();
con=connect.getcon();
stmt=connect.getstmt();
this.setTitle("删除读者");
this.setBounds(300,250,350,250);
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_dreaderID = new javax.swing.JTextField();
B_dreader = new javax.swing.JButton();
B_drcancel = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("\u8bf7\u8f93\u5165\u60a8\u6240\u8981\u5220\u9664\u7684\u8bfb\u8005\u7f16\u53f7:");
B_dreader.setText("\u5220\u9664");
B_dreader.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
B_dreaderActionPerformed(evt);
}
});
B_drcancel.setText("\u53d6\u6d88");
B_drcancel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
B_drcancelActionPerformed(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()
.addContainerGap()
.add(jLabel1))
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
.add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
.add(80, 80, 80)
.add(B_dreader)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(B_drcancel))
.add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
.add(116, 116, 116)
.add(T_dreaderID, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 143, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
.addContainerGap(71, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(jLabel1)
.add(26, 26, 26)
.add(T_dreaderID, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(36, 36, 36)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(B_dreader)
.add(B_drcancel))
.addContainerGap(25, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void B_drcancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_B_drcancelActionPerformed
// TODO 将在此处添加您的处理代码:
this.setVisible(false);
}//GEN-LAST:event_B_drcancelActionPerformed
private void B_dreaderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_B_dreaderActionPerformed
// TODO 将在此处添加您的处理代码:
try{
if(T_dreaderID.getText().trim().equals(""))
{
JOptionPane.showMessageDialog(null,"读者编号输入不能为空");
return;
}
if(JOptionPane.showConfirmDialog(null,"删除该读者将删除相应的借书记录,你确认要删除该读者吗?","温馨提示:",0)==0)
{
PreparedStatement sql=con.prepareStatement("delete from 借阅 where 读者编号=?");
sql.setString(1,T_dreaderID.getText().trim());
sql.executeUpdate();
sql=con.prepareStatement("delete from 读者 where 编号=?");
sql.setString(1,T_dreaderID.getText().trim());
sql.executeUpdate();
JOptionPane.showMessageDialog(null,"读者信息删除成功");
this.setVisible(false);
}
}
catch(Exception ee)
{
JOptionPane.showMessageDialog(null,"数据库访问失败!");
ee.printStackTrace();
}
}//GEN-LAST:event_B_dreaderActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new D_delreader().setVisible(true);
}
});
}
// 变量声明 - 不进行修改//GEN-BEGIN:variables
private javax.swing.JButton B_drcancel;
private javax.swing.JButton B_dreader;
private javax.swing.JTextField T_dreaderID;
private javax.swing.JLabel jLabel1;
// 变量声明结束//GEN-END:variables
private Connection con;
private Statement stmt;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -