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

📄 returndialog.java

📁 用java写的固定资产管理系统原代码 这可是自己小组做的哦
💻 JAVA
字号:
/*
 * ReturnDialog.java
 *
 * Created on 2007年4月28日, 下午4:44
 *
 *此功能是用来实现设备归还
 */

package com.cn.szhaccp.set;

import com.cn.szhaccp.landing.ToCenter;
import com.cn.szhaccp.sill.*;
import java.sql.*;
import java.util.Calendar;
import javax.swing.JOptionPane;

/**
 *
 * @author  Administrator
 */
public class ReturnDialog extends javax.swing.JDialog {
    sillClass sill;
    ToCenter tocenter;
    
    /** Creates new form ReturnDialog */
    public ReturnDialog(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        tocenter = new ToCenter();
        tocenter.SetDialogToCenter(this);
    }
    
    public ReturnDialog(java.awt.Frame parent, boolean modal,sillClass sill){
        this(parent,modal);
        this.sill = sill;
        return_name();
        time();
    }
    
    /** 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();
        nametext = new javax.swing.JComboBox();
        jLabel2 = new javax.swing.JLabel();
        Nametext = new javax.swing.JComboBox();
        jLabel3 = new javax.swing.JLabel();
        timetext = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        idtext = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jLabel5 = new javax.swing.JLabel();
        assetidtext = new javax.swing.JComboBox();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        jLabel1.setText("\u501f\u7528\u804c\u5458\u59d3\u540d\uff1a");

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

        jLabel2.setText("\u8bbe \u5907 \u540d \u79f0\uff1a");

        jLabel3.setText("\u5f52 \u8fd8 \u65f6 \u95f4\uff1a");

        timetext.setEnabled(false);

        jLabel4.setText("\u5f52\u8fd8\u804c\u5458ID\uff1a");

        jButton1.setText("\u5f52  \u8fd8");
        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);
            }
        });

        jLabel5.setText("\u8bbe \u5907 \u7f16 \u53f7:");

        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(50, 50, 50)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jLabel2)
                    .add(jLabel3)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                        .add(org.jdesktop.layout.GroupLayout.LEADING, jLabel4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .add(org.jdesktop.layout.GroupLayout.LEADING, jLabel5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .add(jLabel1))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(nametext, 0, 201, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, timetext, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 201, Short.MAX_VALUE)
                    .add(assetidtext, 0, 201, Short.MAX_VALUE)
                    .add(Nametext, 0, 201, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, idtext, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 201, Short.MAX_VALUE))
                .add(68, 68, 68))
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                .addContainerGap(98, Short.MAX_VALUE)
                .add(jButton1)
                .add(50, 50, 50)
                .add(jButton2)
                .add(117, 117, 117))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(51, 51, 51)
                .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(23, 23, 23)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(Nametext, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel2))
                .add(26, 26, 26)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(assetidtext, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel5))
                .add(21, 21, 21)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel3)
                    .add(timetext, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(24, 24, 24)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(idtext, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel4))
                .add(37, 37, 37)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jButton1)
                    .add(jButton2))
                .add(51, 51, 51))
        );
        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
        time();
        Retrun();
    }//GEN-LAST:event_jButton1ActionPerformed

    private void nametextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nametextActionPerformed
        return_Name();
    }//GEN-LAST:event_nametextActionPerformed

    public void return_name(){
        OpendatabaseClass open = new OpendatabaseClass(sill.getconnection().transmitConnection());
        ResultSet resultset;
        try {
            resultset = open.lookup_incumbency_name();
            while(resultset.next()){
               nametext.addItem(resultset.getString("BorrowName"));
            }
        } catch (SQLException ex) {
            ex.printStackTrace();
            JOptionPane.showMessageDialog(this, ex.getMessage(), "错误提示", JOptionPane.ERROR_MESSAGE);
        }
    }
    
    public void return_Name(){
        Nametext.removeAllItems();
        
        ResultSet resultset;
        String Name = (String)nametext.getSelectedItem();
        
        OpendatabaseClass open = new OpendatabaseClass(sill.getconnection().transmitConnection());
        try {
            resultset = open.lookup_set_name(Name);
            while(resultset.next()){
                Nametext.addItem(resultset.getString("Code"));
            }
        } catch (SQLException ex) {
            ex.printStackTrace();
            JOptionPane.showMessageDialog(this, ex.getMessage(), "错误提示", JOptionPane.ERROR_MESSAGE);
        }
    }
    
     public void assetid_look_up(){
        assetidtext.removeAllItems();
        
        ResultSet resultset;
        String Name = (String)Nametext.getSelectedItem();
        String name = (String)nametext.getSelectedItem();
        
        OpendatabaseClass open = new OpendatabaseClass(sill.getconnection().transmitConnection());
        try {
            resultset = open.lookup_set_assetid(name,Name);
            while(resultset.next()){
                assetidtext.addItem(resultset.getString("code"));
            }
        } catch (SQLException ex) {
            ex.printStackTrace();
            JOptionPane.showMessageDialog(this, ex.getMessage(), "错误提示", JOptionPane.ERROR_MESSAGE);
        }
    }
    
    public void Retrun(){
        String name = (String)nametext.getSelectedItem();
        String Name = (String)Nametext.getSelectedItem();
        String time = timetext.getText();
        int id =0;
        try{
            id = Integer.parseInt(idtext.getText());
        }catch(NumberFormatException e){
            JOptionPane.showMessageDialog(this, "请正确输入员工ID", "错误提示", JOptionPane.ERROR_MESSAGE);
            idtext.grabFocus();
            return;
        }
        boolean judgement=false;
        String username;
        int assetid = 0;
        try{
            assetid = Integer.parseInt(assetidtext.getSelectedItem().toString());
        } catch(NullPointerException ex){
            JOptionPane.showMessageDialog(this, "请完整输入", "错误提示", JOptionPane.ERROR_MESSAGE);
            return;
        }
        OpendatabaseClass open = new OpendatabaseClass(sill.getconnection().transmitConnection());
        if(name.equalsIgnoreCase("") || Name.equalsIgnoreCase("")){
           JOptionPane.showMessageDialog(this, "请正确完整输入", "错误提示", JOptionPane.ERROR_MESSAGE);
        } else{
            try {
                judgement = open.incumbency_attest(id,name);
                if(judgement == true){
                    username = open.lookup_username();
                    open.return_record(assetid,Name,time,name,username);
                    open.delete_return(assetid,Name);
                    int i = 0;
                    i = open.return_disposal(assetid);
                    if(i>0){
                         JOptionPane.showMessageDialog(this, "归还成功!感谢您的使用!!", "成功提示", JOptionPane.INFORMATION_MESSAGE);
                         DatabaseConnection dbc = new DatabaseConnection();
                         MainFrame.rm.setResult(dbc.getRs());
                         this.dispose();
                    }else{
                        JOptionPane.showMessageDialog(this, "您没有正确的归还!!", "失败提示", JOptionPane.ERROR_MESSAGE);
                     }
                 }else{
                    JOptionPane.showMessageDialog(this,"这件设备不是您借用的!!!归还失败!", "错误提示", JOptionPane.ERROR_MESSAGE);
                 }
            } catch (SQLException ex) {
                ex.printStackTrace();
            }
        }
    }
    
    public void time(){
        Calendar sj = Calendar.getInstance();
        String s = sj.getTime().toString();
        timetext.setText(sj.get(Calendar.YEAR)+ "-" + (sj.get(Calendar.MONTH)+1) +
                   "-" +sj.get(Calendar.DATE) + " " + s.substring(11,s.length()-9));
    }
    
    // 变量声明 - 不进行修改//GEN-BEGIN:variables
    private javax.swing.JComboBox Nametext;
    private javax.swing.JComboBox assetidtext;
    private javax.swing.JTextField idtext;
    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.JLabel jLabel5;
    private javax.swing.JComboBox nametext;
    private javax.swing.JTextField timetext;
    // 变量声明结束//GEN-END:variables
    
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -