📄 delete_workman_dialog.java
字号:
/*
* delete_workman_Dialog.java
*
* Created on 2007年4月30日, 下午12:39
*
*此功能是用来删除能借用设备的职员的记录
*/
package com.cn.szhaccp.set;
import com.cn.szhaccp.landing.ToCenter;
import com.cn.szhaccp.sill.*;
import java.sql.*;
import javax.swing.JOptionPane;
/**
*
* @author Administrator
*/
public class delete_workman_Dialog extends javax.swing.JDialog {
sillClass sill;
ToCenter tocenter;
/** Creates new form delete_workman_Dialog */
public delete_workman_Dialog(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
tocenter = new ToCenter();
tocenter.SetDialogToCenter(this);
}
public delete_workman_Dialog(java.awt.Frame parent, boolean modal,sillClass sill){
this(parent,modal);
this.sill = sill;
acquire_name();
}
/** 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();
codetext = new javax.swing.JComboBox();
jLabel3 = new javax.swing.JLabel();
dutytext = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
annotationtext = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("\u5220\u9664\u804c\u5458");
jLabel1.setText("\u804c\u5458\u59d3\u540d\uff1a");
jLabel2.setText("\u804c\u5458\u7f16\u53f7\uff1a");
nametext.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
nametextActionPerformed(evt);
}
});
jLabel3.setText("\u804c\u5458\u804c\u52a1\uff1a");
dutytext.setEditable(false);
jLabel4.setText("\u804c\u5458\u5907\u6ce8\uff1a");
annotationtext.setEditable(false);
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);
}
});
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(37, 37, 37)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel1)
.add(jLabel2)
.add(jLabel3)
.add(jLabel4))
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
.add(layout.createSequentialGroup()
.add(6, 6, 6)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
.add(org.jdesktop.layout.GroupLayout.LEADING, dutytext)
.add(org.jdesktop.layout.GroupLayout.LEADING, codetext, 0, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(org.jdesktop.layout.GroupLayout.LEADING, nametext, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 158, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
.add(layout.createSequentialGroup()
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(annotationtext))))
.add(layout.createSequentialGroup()
.add(62, 62, 62)
.add(jButton1)
.add(33, 33, 33)
.add(jButton2)))
.addContainerGap(43, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(28, 28, 28)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel1)
.add(nametext, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(27, 27, 27)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel2)
.add(codetext, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(35, 35, 35)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel3)
.add(dutytext, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(38, 38, 38)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jButton1)
.add(jButton2))
.add(30, 30, 30))
.add(layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel4)
.add(annotationtext, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(87, 87, 87))))
);
pack();
}// </editor-fold>//GEN-END:initComponents
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();
}//GEN-LAST:event_jButton1ActionPerformed
private void nametextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nametextActionPerformed
acquire_code();
acquire();
}//GEN-LAST:event_nametextActionPerformed
public void acquire_name(){
OpendatabaseClass open = new OpendatabaseClass(sill.getconnection().transmitConnection());
ResultSet resultset;
try {
resultset = open.lookup_workman_name();
while(resultset.next()){
nametext.addItem(resultset.getString("name"));
}
} catch (SQLException ex) {
ex.printStackTrace();
JOptionPane.showMessageDialog(this, ex.getMessage(), "错误提示", JOptionPane.ERROR_MESSAGE);
}
}
public void acquire_code(){
codetext.removeAllItems();
String name = (String)nametext.getSelectedItem();
OpendatabaseClass open = new OpendatabaseClass(sill.getconnection().transmitConnection());
ResultSet resultset;
try {
resultset = open.lookup_workman_code(name);
while(resultset.next()){
codetext.addItem(resultset.getString("code"));
}
} catch (SQLException ex) {
ex.printStackTrace();
JOptionPane.showMessageDialog(this, ex.getMessage(), "错误提示", JOptionPane.ERROR_MESSAGE);
}
}
public void acquire(){
String name = (String)nametext.getSelectedItem();
String code = (String)codetext.getSelectedItem();
OpendatabaseClass open = new OpendatabaseClass(sill.getconnection().transmitConnection());
ResultSet resultset;
try {
resultset = open.lookup_workman(code,name);
while(resultset.next()){
dutytext.setText(resultset.getString("duty"));
annotationtext.setText(resultset.getString("remark"));
}
} catch (SQLException ex) {
ex.printStackTrace();
JOptionPane.showMessageDialog(this, ex.getMessage(), "错误提示", JOptionPane.ERROR_MESSAGE);
}
}
public void delete(){
String name = (String)nametext.getSelectedItem();
String code = (String)codetext.getSelectedItem();
OpendatabaseClass open = new OpendatabaseClass(sill.getconnection().transmitConnection());
try {
int i = 0;
i = JOptionPane.showConfirmDialog(this,"是否要删除它???");
if(i == 0){
open.delete_workman(code,name);
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.JTextField annotationtext;
private javax.swing.JComboBox codetext;
private javax.swing.JTextField dutytext;
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.JLabel jLabel4;
private javax.swing.JComboBox nametext;
// 变量声明结束//GEN-END:variables
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -