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

📄 return_dialog.java

📁 用java写的固定资产管理系统原代码 这可是自己小组做的哦
💻 JAVA
字号:
/*
 * return_Dialog.java
 *
 * Created on 2007年5月9日, 下午5:52
 */

package com.cn.szhaccp.sill;

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

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

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

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

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

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

        timetext.setEnabled(false);

        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);
            }
        });

        Nametext.setEnabled(false);

        nametext.setEnabled(false);

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

        IDtext.setEditable(false);

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(layout.createSequentialGroup()
                        .addContainerGap()
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(layout.createSequentialGroup()
                                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(jLabel3)
                                    .add(jLabel4))
                                .add(16, 16, 16)
                                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                                    .add(idtext)
                                    .add(timetext, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 212, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                            .add(layout.createSequentialGroup()
                                .add(48, 48, 48)
                                .add(jButton1)
                                .add(80, 80, 80)
                                .add(jButton2))))
                    .add(layout.createSequentialGroup()
                        .add(29, 29, 29)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jLabel1)
                            .add(jLabel2)
                            .add(jLabel5))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(IDtext, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 212, Short.MAX_VALUE)
                            .add(Nametext, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 212, Short.MAX_VALUE)
                            .add(nametext, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 212, Short.MAX_VALUE))))
                .add(45, 45, 45))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(24, 24, 24)
                .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(15, 15, 15)
                .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(20, 20, 20)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel5)
                    .add(IDtext, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 18, Short.MAX_VALUE)
                .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(23, 23, 23)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel4)
                    .add(idtext, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(25, 25, 25)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jButton2)
                    .add(jButton1))
                .add(39, 39, 39))
        );
        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
    
    public void settext(){
        if(MainFrame.table.getSelectedRow() != -1){
            Nametext.setText(MainFrame.rm.getValueAt(MainFrame.table.getSelectedRow(),7).toString());
            nametext.setText(MainFrame.rm.getValueAt(MainFrame.table.getSelectedRow(),1).toString());
            IDtext.setText(MainFrame.rm.getValueAt(MainFrame.table.getSelectedRow(),0).toString());
        } else {
            JOptionPane.showMessageDialog(this,"请选中要归还的资产!","错误",JOptionPane.ERROR_MESSAGE);
        }
    }
    
    public void Retrun(){
        String name = nametext.getText();
        String Name = Nametext.getText();
        String time = timetext.getText();
        int id =0;
        try{
            id = Integer.parseInt(idtext.getText());
        }catch(NumberFormatException e){
            JOptionPane.showMessageDialog(this, e.getMessage(), "错误提示", JOptionPane.ERROR_MESSAGE);
            idtext.grabFocus();
            return;
        }
        boolean judgement=false;
        String username;
        int ID = Integer.parseInt(IDtext.getText());
        
        OpendatabaseClass open = new OpendatabaseClass(sill.getconnection().transmitConnection());
        if(Name.equalsIgnoreCase("")){
            JOptionPane.showMessageDialog(this,"这件设备是没有借用的!!!归还失败!", "错误提示", JOptionPane.ERROR_MESSAGE);
            return;
        }
        try {
            judgement = open.incumbency_attest(id,Name);
            if(judgement == true){
                username = open.lookup_username();
                open.return_record(ID,name,time,Name,username);
                open.delete_return(ID,name);
                int i = 0;
                i = open.return_disposal(ID);
                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();
            JOptionPane.showMessageDialog(this, ex.getMessage(), "错误", JOptionPane.ERROR_MESSAGE);
        }
    }
    
    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.JTextField IDtext;
    public javax.swing.JTextField Nametext;
    public 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;
    public javax.swing.JTextField nametext;
    private static javax.swing.JTextField timetext;
    // 变量声明结束//GEN-END:variables
    
}

⌨️ 快捷键说明

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