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

📄 fixassertpanel.java

📁 固定资产管理
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package stage_project;

import java.awt.*;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2008</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class FixAssertPanel extends JPanel {
    public FixAssertPanel() {
        try {
            jbInit();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    private void jbInit() throws Exception {
        MainbodyFrame mf = new MainbodyFrame();
        this.setLayout(null);
        setSize(new Dimension(960, 600));



        jLabel1.setText("资产编号:");
        jLabel1.setBounds(new Rectangle(207, 200, 58, 30));
        jLabel2.setText("大类编号:");
        jLabel2.setBounds(new Rectangle(207, 250, 58, 30));
        jLabel3.setText("样       式:");
        jLabel3.setBounds(new Rectangle(207, 300, 58, 30));
        jLabel4.setText("购入日期:");
        jLabel4.setBounds(new Rectangle(207, 350, 58, 30));
        jLabel5.setText("购  入  人:");
        jLabel5.setBounds(new Rectangle(207, 400, 58, 30));
        cboMainId.setBounds(new Rectangle(274, 250, 130, 30));
        cboMainId.addItemListener(new FixAssertPanel_cboMainId_itemAdapter(this));
        txtAssertId.setText("");
        txtAssertId.setBounds(new Rectangle(274, 200, 130, 30));
        cboZiLeiBianHao.setBounds(new Rectangle(563, 250, 130, 30));
        txtType.setText("");
        txtType.setBounds(new Rectangle(274, 300, 130, 30));
        txtBuyDate.setText("");
        txtBuyDate.setBounds(new Rectangle(274, 350, 130, 30));
        txtBuyer.setText("");
        txtBuyer.setBounds(new Rectangle(274, 400, 130, 30));
        jLabel6.setText("产品名称:");
        jLabel6.setBounds(new Rectangle(497, 200, 58, 30));
        jLabel7.setText("子类编号:");
        jLabel7.setBounds(new Rectangle(497, 250, 58, 30));
        jLabel8.setText("价      格:");
        jLabel8.setBounds(new Rectangle(497, 300, 58, 30));
        jLabel9.setText("状      态:");
        jLabel9.setBounds(new Rectangle(497, 350, 58, 30));
        jLabel10.setText("备      注:");
        jLabel10.setBounds(new Rectangle(497, 400, 58, 30));
        txtAssertName.setText("");
        txtAssertName.setBounds(new Rectangle(563, 200, 130, 30));
        txtPrice.setText("");
        txtPrice.setBounds(new Rectangle(563, 300, 130, 30));
        txtRemark.setText("");
        txtRemark.setBounds(new Rectangle(563, 400, 130, 30));
        btnAdd.setBounds(new Rectangle(247, 477, 70, 25));
        btnAdd.setText("增  加");
        btnAdd.addActionListener(new FixAssertPanel_jButton1_actionAdapter(this));
        btnMod.setBounds(new Rectangle(361, 477, 70, 25));
        btnMod.setText("修  改");
        btnMod.addActionListener(new FixAssertPanel_btnMod_actionAdapter(this));
        btnDel.setBounds(new Rectangle(485, 477, 70, 25));
        btnDel.setText("删  除");
        btnDel.addActionListener(new FixAssertPanel_btnDel_actionAdapter(this));
        btnSel.setBounds(new Rectangle(601, 477, 70, 25));
        btnSel.setText("查  询");
        btnSel.addActionListener(new FixAssertPanel_btnSel_actionAdapter(this));
        cboZhuangTai.setBounds(new Rectangle(563, 350, 130, 30));
        lbiTime.setFont(new java.awt.Font("Dialog", Font.PLAIN, 15));
        lbiTime.setHorizontalAlignment(SwingConstants.CENTER);
        lbiTime.setText("");
        lbiTime.setBounds(new Rectangle(757, 45, 162, 50));
        lblBeijing.setIcon(img);
        lblBeijing.setBounds(new Rectangle(0, 0, 960, 600));
        cboMainId.setBounds(new Rectangle(274, 250, 130, 30));
        cboZhuangTai.setBounds(new Rectangle(563, 350, 130, 30));
        this.add(cboMainId);
        this.add(txtRemark);
        this.add(jLabel10);
        this.add(jLabel9);
        this.add(txtPrice);
        this.add(jLabel8);
        this.add(cboZiLeiBianHao);
        this.add(jLabel7);
        this.add(txtAssertName);
        this.add(btnAdd);
        this.add(btnMod);
        this.add(jLabel1);
        this.add(jLabel5);
        this.add(jLabel4);
        this.add(jLabel3);
        this.add(jLabel2);
        this.add(cboZhuangTai);
        this.add(lbiTime);
        this.add(jLabel6);
        this.add(txtBuyer);
        this.add(txtBuyDate);
        this.add(txtAssertId);
        this.add(txtType);
        this.add(btnDel);
        this.add(btnSel);
        this.add(lblBeijing);
        String sqlmainid = "select catename from category ";
        ArrayList arr1 = new ArrayList();
        arr1 = db.getId(sqlmainid);
        //调用类
        DBAccess db = new DBAccess();
        String sql ="select catename from category ";
        ArrayList arr = db.getId(sql);
        //往下拉列表中添加数据
        cboMainId.addItem("请选择...");
        for (int i = 1; i < arr.size()-1; i++) {
            if (arr.get(i).equals(arr.get(i-1))) {
                continue;
            }
            cboMainId.addItem(arr.get(i-1));
        }
        cboMainId.addItem(arr1.get(arr1.size() - 1));
        cboZiLeiBianHao.addItem("请选择...");
        //资产状态
        cboZhuangTai.addItem("正常");
        cboZhuangTai.addItem("维修");
        cboZhuangTai.addItem("报废");
        //时间显示
        TimeClass tc = new TimeClass();
        lbiTime.setText(tc.getTime());
    }

    JLabel jLabel1 = new JLabel();
    JLabel jLabel2 = new JLabel();
    JLabel jLabel3 = new JLabel();
    JLabel jLabel4 = new JLabel();
    JLabel jLabel5 = new JLabel();
    JComboBox cboMainId = new JComboBox(); //大类编号
    JTextField txtAssertId = new JTextField();
    JTextField txtType = new JTextField();
    JTextField txtBuyDate = new JTextField();
    JTextField txtBuyer = new JTextField();
    JLabel jLabel6 = new JLabel();
    JLabel jLabel7 = new JLabel();
    JLabel jLabel8 = new JLabel();
    JLabel jLabel9 = new JLabel();
    JLabel jLabel10 = new JLabel();
    JTextField txtAssertName = new JTextField();
    JComboBox cboZiLeiBianHao = new JComboBox(); //子类编号
    JTextField txtPrice = new JTextField();
    JTextField txtRemark = new JTextField();
    JButton btnAdd = new JButton();
    JButton btnMod = new JButton();
    JButton btnDel = new JButton();
    JButton btnSel = new JButton();
    DBAccess db = new DBAccess();
    JComboBox cboZhuangTai = new JComboBox(); //状态

    ImageIcon img = new ImageIcon("xiubei.gif");
    JLabel lblBeijing = new JLabel(img);
    JLabel lbiTime = new JLabel();
    //添加固定资产按钮事件
    public void jButton1_actionPerformed(ActionEvent e) {
        //文本信息
        String assertId = txtAssertId.getText(); //资产编号
        String assertName = txtAssertName.getText(); //资产名称
        String maincatename = cboMainId.getSelectedItem().toString(); //主类名称
        String sortname = cboZiLeiBianHao.getSelectedItem().toString(); //子类名称
        String maincateid = null; //主类编号
        String sortid = null; //子类编号
        String status = cboZhuangTai.getSelectedItem().toString(); //状态
        String type = txtType.getText(); //样式
        String price = txtPrice.getText(); //价格
        float p = 0;
        String buyDate = txtBuyDate.getText(); //购入日期
        String buyer = txtBuyer.getText(); //购入人
        String remark = txtRemark.getText(); //备注
        //资产编号不能重复
        String sql1 = "select * from asset where assetid = '" + assertId +
                      "'";
        boolean b1 = db.jiancha(sql1);
        if (b1) {
            JOptionPane.showMessageDialog(this,
                                          "添加" + "\n" + assertId +
                                          "资产编号已经存在,请重新选择资产编号");
            return;
        }
        //资产编号不能为空
        if (assertId.equals("")) {
            JOptionPane.showMessageDialog(this, "资产编号不能为空 ");
            return;
        }
        //资产编号必须为数字
        for (int i = 0; i < assertId.length(); i++) {
            char mci = assertId.charAt(i);
            if (!Character.isDigit(mci)) {
                JOptionPane.showMessageDialog(this, "资产编号必须为数字 ");
                return;
            }
        }
        //资产名称不能为空
        if (assertName.equals("")) {
            JOptionPane.showMessageDialog(this, "资产名称不能为空 ");
            return;
        }
        //资产价格不能为空
        if (price.equals("")) {
            JOptionPane.showMessageDialog(this, "资产价格不能为空 ");
            return;
        } else {
            p = Float.parseFloat(price);
        }
        //资产购入日期不能为空
        if (buyDate.equals("")) {
            JOptionPane.showMessageDialog(this, "资产购入日期不能为空 ");
            return;
        }
        //大类编号不能为“请选择。。。”
        if(maincatename.equals("请选择...")){
            JOptionPane.showMessageDialog(this,"请选择大类编号");
            return;
        }
        //执行SQL语句
        String sql2 = "select * from category where catename = '" +
                      maincatename +
                      "'and subcatename='" + sortname + "'";
        //  System.out.println(sql2);--------------------------------测试语句
        ArrayList arr = db.chaxun(sql2, 4);
        maincateid = arr.get(0).toString();

⌨️ 快捷键说明

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