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

📄 borrowdialog.java

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

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.*;

/**
 *
 * @author  Administrator
 */
public class BorrowDialog extends javax.swing.JDialog {
    sillClass sill;
    ToCenter tocenter;
    /** Creates new form TropeDialog */
    public BorrowDialog(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        tocenter = new ToCenter();
        tocenter.SetDialogToCenter(this);
    }
    
    public BorrowDialog(java.awt.Frame parent,boolean modal,sillClass sill){
        this(parent,modal);
        this.sill = sill;
        lookup_sort();
    }
    
    /** 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();
        sorttext = new javax.swing.JComboBox();
        jLabel2 = new javax.swing.JLabel();
        Nametext = new javax.swing.JComboBox();
        jLabel3 = new javax.swing.JLabel();
        idtext = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        nametext = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        purposetext = new javax.swing.JTextArea();
        jLabel6 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        annotationtext = new javax.swing.JTextArea();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jLabel7 = new javax.swing.JLabel();
        assetidtext = new javax.swing.JComboBox();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("\u9886\u7528");
        setResizable(false);
        jLabel1.setText("\u8bbe\u5907\u7c7b\u522b\uff1a");

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

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

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

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

        jLabel4.setText("\u804c\u5458\u59d3\u540d\uff1a");

        jLabel5.setText("\u501f\u7528\u7528\u9014\uff1a");

        purposetext.setColumns(10);
        purposetext.setRows(2);
        jScrollPane1.setViewportView(purposetext);

        jLabel6.setText("\u501f\u7528\u5907\u6ce8\uff1a");

        annotationtext.setColumns(10);
        annotationtext.setRows(2);
        jScrollPane2.setViewportView(annotationtext);

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

        jLabel7.setText("\u8bbe\u5907ID:");

        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(81, 81, 81)
                .add(jButton1)
                .add(53, 53, 53)
                .add(jButton2)
                .add(117, 117, 117))
            .add(layout.createSequentialGroup()
                .add(33, 33, 33)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(layout.createSequentialGroup()
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                            .add(jLabel2)
                            .add(jLabel1)
                            .add(org.jdesktop.layout.GroupLayout.LEADING, jLabel7))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED))
                    .add(jLabel3)
                    .add(layout.createSequentialGroup()
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                            .add(jLabel5)
                            .add(jLabel4)
                            .add(jLabel6))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)))
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jScrollPane2, 0, 0, Short.MAX_VALUE)
                    .add(jScrollPane1, 0, 0, Short.MAX_VALUE)
                    .add(nametext, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 253, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, idtext, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 253, Short.MAX_VALUE)
                    .add(Nametext, 0, 253, Short.MAX_VALUE)
                    .add(assetidtext, 0, 253, Short.MAX_VALUE)
                    .add(sorttext, 0, 253, Short.MAX_VALUE))
                .add(43, 43, 43))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .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(17, 17, 17)
                .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(22, 22, 22)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel7)
                    .add(assetidtext, 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(idtext, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel3))
                .add(19, 19, 19)
                .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(jLabel4))
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .add(16, 16, 16)
                        .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 56, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(layout.createSequentialGroup()
                        .add(32, 32, 32)
                        .add(jLabel5)))
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .add(16, 16, 16)
                        .add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 54, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(layout.createSequentialGroup()
                        .add(34, 34, 34)
                        .add(jLabel6)))
                .add(19, 19, 19)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jButton1)
                    .add(jButton2))
                .addContainerGap())
        );
        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void NametextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_NametextActionPerformed
        assetid_look_up();
    }//GEN-LAST:event_NametextActionPerformed

    private void sorttextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sorttextActionPerformed
        lookup_Name();
    }//GEN-LAST:event_sorttextActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        borrow();
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        this.dispose();
    }//GEN-LAST:event_jButton2ActionPerformed
    
    public void lookup_sort(){
        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 lookup_Name(){
        Nametext.removeAllItems();
        
        ResultSet resultset;
        String sort = (String)sorttext.getSelectedItem();
        
        OpendatabaseClass open = new OpendatabaseClass(sill.getconnection().transmitConnection());
        try {
            resultset = open.lookup_name(sort);
            while(resultset.next()){
                Nametext.addItem(resultset.getString("Name"));
            }
        } catch (SQLException ex) {
            ex.printStackTrace();
            JOptionPane.showMessageDialog(this, ex.getMessage(), "错误提示", JOptionPane.ERROR_MESSAGE);
        }
    }
    
    public void assetid_look_up(){
        assetidtext.removeAllItems();
        
        ResultSet resultset;
        String sort = (String)sorttext.getSelectedItem();
        String Name = (String)Nametext.getSelectedItem();
        
        OpendatabaseClass open = new OpendatabaseClass(sill.getconnection().transmitConnection());
        try {
            resultset = open.lookup_assetid(sort,Name);
            while(resultset.next()){
                assetidtext.addItem(resultset.getString("code"));
            }
        } catch (SQLException ex) {
            ex.printStackTrace();
            JOptionPane.showMessageDialog(this, ex.getMessage(), "错误提示", JOptionPane.ERROR_MESSAGE);
        }
    }
    
    public void borrow(){
        int assetid = 0;
        try{
            assetid = Integer.parseInt(assetidtext.getSelectedItem().toString());
        }catch(NumberFormatException e){
        }
        String sort = (String)sorttext.getSelectedItem();
        String Name = (String)Nametext.getSelectedItem();
        int id=0;
        try{
            id = Integer.parseInt(idtext.getText());
        }catch(NumberFormatException e){
            JOptionPane.showMessageDialog(this, "请正确输入您的ID,ID必须为数字!!!", "错误提示", JOptionPane.ERROR_MESSAGE);
            idtext.grabFocus();
            return;
        }
        String name = nametext.getText();
        String purpose = purposetext.getText();
        String annotation = annotationtext.getText();
        boolean judgement=false;
        String username;
        
        Calendar sj = Calendar.getInstance();
        String s = sj.getTime().toString();
        String time = sj.get(Calendar.YEAR)+ "-" + (sj.get(Calendar.MONTH)+1) +
                   "-" +sj.get(Calendar.DATE) + " " + s.substring(11,s.length()-9);
        
        OpendatabaseClass open = new OpendatabaseClass(sill.getconnection().transmitConnection());
        try {
            judgement = open.incumbency_attest(id,name);
            if(judgement == true){
                int i = 0;
                username = open.lookup_username();
                open.accretion_database(assetid,Name,time,id,name,username,purpose,annotation);
                i = open.amend_record(assetid,Name,name);
                if(i>0){
                    JOptionPane.showMessageDialog(this, "借出成功", "成功提示",
                                            JOptionPane.INFORMATION_MESSAGE);
                    DatabaseConnection dbc = new DatabaseConnection();
                    MainFrame.rm.setResult(dbc.getRs());
                    this.dispose();
                }
            }else{
                JOptionPane.showMessageDialog(this,"没有此Id或此姓名!!!", "失败提示", JOptionPane.ERROR_MESSAGE);
            }
        } catch (SQLException ex) {
            ex.printStackTrace();           
        }
    }
    
    // 变量声明 - 不进行修改//GEN-BEGIN:variables
    private javax.swing.JComboBox Nametext;
    private javax.swing.JTextArea annotationtext;
    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.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTextField nametext;
    private javax.swing.JTextArea purposetext;
    private javax.swing.JComboBox sorttext;
    // 变量声明结束//GEN-END:variables
    
}

⌨️ 快捷键说明

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