📄 delete_dialog.java
字号:
/*
* delete_Dialog.java
*
* Created on 2007年4月30日, 上午8:29
*
*此功能是用来删除设备记录
*/
package com.cn.szhaccp.set;
import com.cn.szhaccp.landing.ToCenter;
import com.cn.szhaccp.sill.*;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.swing.JOptionPane;
/**
*
* @author Administrator
*/
public class delete_Dialog extends javax.swing.JDialog {
sillClass sill;
ToCenter tocenter;
/** Creates new form delete_Dialog */
public delete_Dialog(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
tocenter = new ToCenter();
tocenter.SetDialogToCenter(this);
}
public delete_Dialog(java.awt.Frame parent,boolean modal,sillClass sill){
this(parent,modal);
this.sill = sill;
acquire();
}
/** 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();
jLabel2 = new javax.swing.JLabel();
Nametext = new javax.swing.JComboBox();
sorttext = new javax.swing.JComboBox();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jLabel3 = new javax.swing.JLabel();
statetext = new javax.swing.JTextField();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("\u5220\u9664");
jLabel1.setText("\u8bbe\u5907\u7c7b\u522b\uff1a");
jLabel2.setText("\u8bbe\u5907\u540d\u79f0\uff1a");
Nametext.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
NametextActionPerformed(evt);
}
});
sorttext.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
sorttextActionPerformed(evt);
}
});
jButton1.setText("\u5220 \u9664");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton2.setText("\u53d6 \u6d88");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jLabel3.setText("\u8d44\u4ea7\u72b6\u6001\uff1a");
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(53, 53, 53)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
.add(layout.createSequentialGroup()
.add(jButton1)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(jButton2))
.add(layout.createSequentialGroup()
.add(jLabel3)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(statetext))
.add(layout.createSequentialGroup()
.add(jLabel2)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(Nametext, 0, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.add(layout.createSequentialGroup()
.add(jLabel1)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(sorttext, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 148, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(53, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(48, 48, 48)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel1)
.add(sorttext, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(31, 31, 31)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel2)
.add(Nametext, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(34, 34, 34)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel3)
.add(statetext, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 42, Short.MAX_VALUE)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jButton1)
.add(jButton2))
.add(53, 53, 53))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void NametextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_NametextActionPerformed
acquire_state();
}//GEN-LAST:event_NametextActionPerformed
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
this.dispose();
}//GEN-LAST:event_jButton2ActionPerformed
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
delete_set();
}//GEN-LAST:event_jButton1ActionPerformed
private void sorttextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sorttextActionPerformed
acquire_name();
}//GEN-LAST:event_sorttextActionPerformed
public void acquire(){
OpendatabaseClass open = new OpendatabaseClass(sill.getconnection().transmitConnection());
ResultSet resultset;
try {
resultset = open.lookup_sort();
while(resultset.next()){
sorttext.addItem(resultset.getString("sort"));
}
} catch (SQLException ex) {
ex.printStackTrace();
JOptionPane.showMessageDialog(this, ex.getMessage(), "错误提示", JOptionPane.ERROR_MESSAGE);
}
}
public void acquire_name(){
Nametext.removeAllItems();
String sort = (String) sorttext.getSelectedItem();
OpendatabaseClass open = new OpendatabaseClass(sill.getconnection().transmitConnection());
ResultSet resultset;
try {
resultset = open.lookup_name2(sort);
while(resultset.next()){
Nametext.addItem(resultset.getString("Name"));
}
} catch (SQLException ex) {
ex.printStackTrace();
JOptionPane.showMessageDialog(this, ex.getMessage(), "错误提示", JOptionPane.ERROR_MESSAGE);
}
}
public void acquire_state(){
String sort = (String)sorttext.getSelectedItem();
String Name = (String)Nametext.getSelectedItem();
OpendatabaseClass open = new OpendatabaseClass(sill.getconnection().transmitConnection());
ResultSet resultset;
String state = "";
try {
resultset = open.lookup_state(sort,Name);
while(resultset.next()){
state = resultset.getString("state");
}
if(state.equalsIgnoreCase("0")){
statetext.setText("该设备已经借出");
}else if(state.equalsIgnoreCase("1")){
statetext.setText("设备处于正常状态");
}else if(state.equalsIgnoreCase("2")){
statetext.setText("设备正处于维修状态");
}else if(state.equalsIgnoreCase("3")){
statetext.setText("设备现以报废");
}
} catch (SQLException ex) {
ex.printStackTrace();
JOptionPane.showMessageDialog(this, ex.getMessage(), "错误提示", JOptionPane.ERROR_MESSAGE);
}
}
public void delete_set(){
String Name = (String) Nametext.getSelectedItem();
String sort = (String) sorttext.getSelectedItem();
OpendatabaseClass open = new OpendatabaseClass(sill.getconnection().transmitConnection());
ResultSet resultset;
String state = "";
try {
resultset = open.lookup_state(sort,Name);
while(resultset.next()){
state = resultset.getString("state");
}
if(state.equalsIgnoreCase("0")){
JOptionPane.showMessageDialog(this, "该设备已经借出,不能删除", "错误提示", JOptionPane.ERROR_MESSAGE);
}else{
int i = 0;
i = JOptionPane.showConfirmDialog(this,"是否要删除它???");
if(i == 0){
open.update_record(Name,sort);
JOptionPane.showMessageDialog(this, "删除成功!!", "删除提示",
JOptionPane.INFORMATION_MESSAGE);
DatabaseConnection dbc = new DatabaseConnection();
MainFrame.rm.setResult(dbc.getRs());
this.dispose();
}else{
return;
}
}
} catch (SQLException ex) {
ex.printStackTrace();
JOptionPane.showMessageDialog(this, ex.getMessage(), "错误提示", JOptionPane.ERROR_MESSAGE);
}
}
// 变量声明 - 不进行修改//GEN-BEGIN:variables
private javax.swing.JComboBox Nametext;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JComboBox sorttext;
private javax.swing.JTextField statetext;
// 变量声明结束//GEN-END:variables
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -