s1(java)项目实战(固定资产管理)(set_ Asset_OP )

来源:互联网 发布:淘宝logo设计理念 编辑:程序博客网 时间:2024/04/30 18:13

package set;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2007</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.Rectangle;

public class Asset_OP extends JPanel {
    //操作部分按钮
    private JButton btn_kind_set = new JButton();
    private JButton btn_manager_set = new JButton();
    private JButton btn_employee_set = new JButton();
    private String user  ;
    public Asset_OP(String _user) {
        try {
            this.user = _user;
            jbInit();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    private void jbInit() throws Exception {
        this.setLayout(null);
        this.setSize(new Dimension(500, 400));
        btn_kind_set.setBounds(new Rectangle(65, 69, 100, 32));
        btn_kind_set.setToolTipText("");
        btn_kind_set.setText("科目设置");
        btn_manager_set.setBounds(new Rectangle(208, 67, 100, 32));
        btn_manager_set.setText("管理员设置");
        btn_employee_set.setBounds(new Rectangle(352, 66, 100, 32));
        btn_employee_set.setSelectedIcon(null);
        btn_employee_set.setText("雇员设置");
        this.add(btn_employee_set);
        this.add(btn_manager_set);
        this.add(btn_kind_set);
        btn_kind_set.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                kinds_choice();
            }
        });
        btn_manager_set.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                manager_op();
            }
        });
        btn_employee_set.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {

                employee_set();
            }
        });
    }

    private void employee_set() {
        Asset_employe_set aes = new Asset_employe_set(user);
        this.removeAll();
        this.add(aes);
        this.updateUI();
    }

    private void manager_op() {
        if (user.equals("admin")) {
            Asset_manager_set ams = new Asset_manager_set();
            this.removeAll();
            this.add(ams);
            this.updateUI();
        } else {
            ManagerMidify mm = new ManagerMidify(user);
            Dimension frmsize = getSize();
            Point loc = getLocation();
            mm.setLocation((frmsize.width - mm.WIDTH) / 2 + loc.x,
                           (frmsize.height - mm.HEIGHT) / 2 + loc.y);
            mm.setSize(250, 250);
            mm.setModal(true);
            mm.setVisible(true);
        }
    }

    private void kinds_choice() {
        kindschoice km = new kindschoice();
        Dimension frmsize = getSize();
        Point loc = getLocation();
        km.setLocation((frmsize.width - km.WIDTH) / 2 + loc.x,
                       (frmsize.height - km.HEIGHT) / 2 + loc.y);
        km.setSize(250, 180);
        km.setResizable(false);
        km.setModal(true);
        km.setVisible(true);
        String kindstr;
        if(km.getkindstr()!=null)
        {
            kindstr = km.getkindstr().trim();
        }else
        {
            kindstr = "";
        }
        km.closedialog();
        if (kindstr.trim().equals("一级科目")) {
            Asset_kinds_set_father aksf = new Asset_kinds_set_father(user);
            this.removeAll();
            this.add(aksf);
            this.updateUI();
        } else if (kindstr.trim().equals("二级科目"))
        {
            Asset_kinds_set_child aksc = new Asset_kinds_set_child(user);
            this.removeAll();
            this.add(aksc);
            this.updateUI();
        }
    }
    public String getusername()
    {
        return user;
    }
}

原创粉丝点击