⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 update_workman_dialog.java

📁 用java写的固定资产管理系统原代码 这可是自己小组做的哦
💻 JAVA
字号:
/*
 * update_workman_Dialog.java
 *
 * Created on 2007年4月30日, 下午1:35
 *
 *此功能是用来修改职员的记录
 */

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 update_workman_Dialog extends javax.swing.JDialog {
    sillClass sill;
    ToCenter tocenter;
    
    /** Creates new form update_workman_Dialog */
    public update_workman_Dialog(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        tocenter = new ToCenter();
        tocenter.SetDialogToCenter(this);
    }
    
    public update_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();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        nametext = new javax.swing.JComboBox();
        codetext = new javax.swing.JComboBox();
        dutytext = new javax.swing.JTextField();
        annotationtext = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("\u4fee\u6539\u804c\u5458\u8bb0\u5f55");
        jLabel1.setText("\u804c\u5458\u59d3\u540d\uff1a");

        jLabel2.setText("\u804c\u5458\u7f16\u53f7\uff1a");

        jLabel3.setText("\u804c\u5458\u804c\u52a1\uff1a");

        jLabel4.setText("\u804c\u5458\u5907\u6ce8\uff1a");

        nametext.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nametextActionPerformed(evt);
            }
        });

        jButton1.setText("\u4fee  \u6539");
        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(38, 38, 38)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                            .add(jLabel1)
                            .add(jLabel2)
                            .add(jLabel3)
                            .add(jLabel4))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                            .add(nametext, 0, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .add(codetext, 0, 140, Short.MAX_VALUE)
                            .add(annotationtext)
                            .add(dutytext, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE)))
                    .add(layout.createSequentialGroup()
                        .add(53, 53, 53)
                        .add(jButton1)
                        .add(35, 35, 35)
                        .add(jButton2)))
                .addContainerGap(43, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(33, 33, 33)
                .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(28, 28, 28)
                .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(30, 30, 30)
                .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(30, 30, 30)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jButton1)
                    .add(jButton2))
                .addContainerGap(39, Short.MAX_VALUE))
        );
        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
        update();
    }//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 update(){
        String name = (String)nametext.getSelectedItem();
        String code = (String)codetext.getSelectedItem(); 
        String duty = dutytext.getText();
        String annotation = annotationtext.getText();
        
        OpendatabaseClass open = new OpendatabaseClass(sill.getconnection().transmitConnection());
        try {
            open.delete_workman(code,name);
            open.add_workman(code,name,duty,annotation);
            JOptionPane.showMessageDialog(this, "修改成功!!", "修改提示", 
                        JOptionPane.INFORMATION_MESSAGE);
            DatabaseConnection dbc = new DatabaseConnection();
            MainFrame.rm.setResult(dbc.getRs());
            this.dispose();
        } 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 + -