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

📄 mainframe.java

📁 用java写的固定资产管理系统原代码 这可是自己小组做的哦
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            }


            public void mouseEntered(MouseEvent e) {
            }

            public void mouseExited(MouseEvent e) {
            }

            public void mousePressed(MouseEvent e) {
            }

            public void mouseReleased(MouseEvent e) {
            }
        }); 
        
        borrow.addActionListener(new ActionListener() {
           public void actionPerformed(ActionEvent e) {
                if(table.getSelectedRow() == -1){
                     JOptionPane.showMessageDialog(MainFrame.this,"请先在表上选择一条记录", "错误提示", JOptionPane.ERROR_MESSAGE);
                } else if(table.getColumnCount() != 9){
                     JOptionPane.showMessageDialog(MainFrame.this,"该功能只能在资产信息中使用!","错误",JOptionPane.ERROR_MESSAGE);
                } else if(rm.getValueAt(table.getSelectedRow(),7) != null) {
                   JOptionPane.showMessageDialog(MainFrame.this,"这件物品已经被借出!","错误",JOptionPane.ERROR_MESSAGE);
                   return;
                } else {
                   demesne_Dialog.setDefaultLookAndFeelDecorated(true);
                   demesne_Dialog demesne = new demesne_Dialog(MainFrame.this,true,sill);
                   demesne.setResizable(false);
                   demesne.setVisible(true);  
                }
           } 
        });
        
        back.addActionListener(new ActionListener() {
           public void actionPerformed(ActionEvent e) {
                if(table.getSelectedRow() == -1){    
                    JOptionPane.showMessageDialog(MainFrame.this,"请先在表上选择一条记录", "错误提示", JOptionPane.ERROR_MESSAGE);         
                } else if(table.getColumnCount() != 9){
                     JOptionPane.showMessageDialog(MainFrame.this,"该功能只能在资产信息中使用!","错误",JOptionPane.ERROR_MESSAGE);
                } else if(MainFrame.rm.getValueAt(MainFrame.table.getSelectedRow(),7) == null) {
                    JOptionPane.showMessageDialog(MainFrame.this,"当前资产未被借出!何来归还?","错误",JOptionPane.ERROR_MESSAGE);
                    return;
                } else {
                    return_Dialog.setDefaultLookAndFeelDecorated(true);
                    return_Dialog rd = new return_Dialog(MainFrame.this,true,sill);
                    rd.setResizable(false);
                    rd.setVisible(true);
                }
                    
           } 
        });
        
        changePerson.addActionListener(new ActionListener() {
           public void actionPerformed(ActionEvent e) {
               update_workman_Dialog.setDefaultLookAndFeelDecorated(true);
               update_workman_Dialog update = new update_workman_Dialog(MainFrame.this,true,sill);
               update.setVisible(true); 
           } 
        });
        
        delPersons.addActionListener(new ActionListener() {
           public void actionPerformed(ActionEvent e) {
               delete_workman_Dialog.setDefaultLookAndFeelDecorated(true);
               delete_workman_Dialog delete = new delete_workman_Dialog(MainFrame.this,true,sill);
               delete.setVisible(true);
           } 
        });
        
        addPersons.addActionListener(new ActionListener() {
           public void actionPerformed(ActionEvent e) {
               add_workman_Dialog.setDefaultLookAndFeelDecorated(true);
               add_workman_Dialog add = new add_workman_Dialog(MainFrame.this,true,sill);
               add.setVisible(true);
           } 
        });
        
        this.addWindowListener(new WindowListener() {
           public void windowClosed(WindowEvent e) {
           }
           public void windowActivated(WindowEvent e) {
           }
           public void windowClosing(WindowEvent e) {
               if(JOptionPane.showConfirmDialog(MainFrame.this,"确定退出?","提示",JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) {
                    try {
                        stmt = dbc.getConn().createStatement();
                        stmt.executeUpdate("UPDATE Users SET State = 0 WHERE State = 1");
                        System.exit(1);
                    } catch (SQLException ex) {
                        ex.printStackTrace();
                    }
                }
           }
           public void windowDeactivated(WindowEvent e) {
           }
           public void windowDeiconified(WindowEvent e) {
           }
           public void windowIconified(WindowEvent e) {
           }
           public void windowOpened(WindowEvent e) {
           }
        });
        
        borrow.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/cn/szhaccp/sill/q1.jpg")));
        back.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/cn/szhaccp/sill/2.jpg")));
        addPersons.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/cn/szhaccp/sill/3.jpg")));
    	changePerson.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/cn/szhaccp/sill/4.jpg")));
        delPersons.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/cn/szhaccp/sill/5.jpg")));
        jtb.add(borrow);
        jtb.add(back);
        jtb.add(addPersons);
        jtb.add(changePerson);
        jtb.add(delPersons);
        userLabel.setBounds(10,25,100,30);
        this.add(userLabel);
        username.setText(this.getUser());
        username.setBounds(115,25,100,30);
        this.add(username);
        time.setBounds(10,50,100,30);
        this.add(time);
        timeLabel.setText(this.getTime());
        timeLabel.setBounds(115,50,100,30);
        this.add(timeLabel);
        jtb.setBounds(220,21,580,60);
        this.add(jtb);
        panel.setBounds(0,80,800,579);
        panel.setLayout(bl);
        this.add(panel);
        panel.add(jsp,BorderLayout.CENTER);
    	jsp.setDividerLocation(135);
    	jsp.setDividerSize(5);
    	jsp.add(scrollpane,JSplitPane.LEFT);
    	freshTree();
    	jsp.add(mypanel,JSplitPane.RIGHT);
    	mypanel.setLayout(bl1);
    	mypanel.add(jsp1,BorderLayout.CENTER);
    	jsp1.setOrientation(JSplitPane.VERTICAL_SPLIT);
        jsp1.setDividerLocation(220);
    	jsp1.add(sp,JSplitPane.BOTTOM);
    	sp.getViewport().add(table);
    	try {
    		rm.setResult(dbc.getRs());
    	} catch(SQLException e) {
    		e.printStackTrace();
    	}
        jsp1.add(lastPanel,JSplitPane.TOP);
        lastPanel.setLayout(border);
        tabPane = new tabPaneFrame();
        lastPanel.add(tabPane,BorderLayout.CENTER);
    }
    
    public static void freshTree() {
        ShowTree tree = new ShowTree();
        tree.ShowTrees();
    	scrollpane.getViewport().add(tree.getTree());
    }
    public String getUser() {
        try {
            stmt = dbc.getConn().createStatement();            
            rs = stmt.executeQuery("SELECT *FROM Users WHERE State = 1");
            if(rs.next()) {
                return rs.getString("Name");
            }
        } catch(SQLException ex) {
            ex.printStackTrace();
        }
        return "";
    }
    
    public String getTime() {
        Calendar now = Calendar.getInstance();
        return String.valueOf(now.get(Calendar.YEAR)) + "-" + String.valueOf(now.get(Calendar.MONTH)+1) + "-" + String.valueOf(now.get(Calendar.DATE) + "  " + String.valueOf(now.get(Calendar.HOUR)) + ":" + String.valueOf(now.get(Calendar.MINUTE)));
    }
            
    private JMenuBar jbar = new JMenuBar();
    private JMenu userManage = new JMenu("用户管理");    
    private JMenuItem adduser = new JMenuItem("添加用户");
    private JMenuItem amenduser = new JMenuItem("修改用户");
    private JMenuItem exit = new JMenuItem("退出"); 
    private JMenu assetManage = new JMenu("资产管理");
    
    private JMenu infoManage = new JMenu("设备管理");
    private JMenuItem infoadd = new JMenuItem("添加设备记录");
    private JMenuItem infodelete = new JMenuItem("删除设备记录");
    private JMenuItem infoupdate = new JMenuItem("修改设备记录");
    
    private JMenu lookandfeel = new JMenu("改变外观");
    private JMenuItem look1 = new JMenuItem("样式一");
    private JMenuItem look2 = new JMenuItem("样式二");
    
    private JMenuItem assetBorrow = new JMenuItem("资产领用");
    private JMenuItem assetRestore = new JMenuItem("资产归还");
    private JMenuItem RestoreRecord = new JMenuItem("归还记录");
    private JMenuItem BorrowRecord = new JMenuItem("借用记录");
    private JMenu personManage = new JMenu("人员管理");
    private JMenuItem addPerson = new JMenuItem("添加人员记录");
    private JMenuItem delPerson = new JMenuItem("删除人员记录");
    private JMenuItem searchPerson = new JMenuItem("修改人员记录");
    private BorderLayout bl = new BorderLayout();
    private BorderLayout bl1 = new BorderLayout();
    private JSplitPane jsp = new JSplitPane();
    private JSplitPane jsp1 = new JSplitPane();
    private JPanel panel = new JPanel();
    private JPanel mypanel = new JPanel();
    private JPanel lastPanel = new JPanel();
    private static JScrollPane scrollpane = new JScrollPane();
    private JScrollPane sp = new JScrollPane();
    private DatabaseConnection dbc = new DatabaseConnection();
    public static ResultModel rm = new ResultModel();
    public static JTable table = new JTable(rm);
    private BorderLayout border = new BorderLayout();
    
    private JToolBar jtb = new JToolBar();
    private JButton addPersons = new JButton();
    private JButton changePerson = new JButton();
    private JButton delPersons = new JButton();
    private JButton borrow = new JButton();
    private JButton back = new JButton();
    private JLabel userLabel = new JLabel("<html><font color = 'red'>当前登陆用户:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font></html>");
    private JLabel username = new JLabel();
    private JLabel time = new JLabel("<html><font color = 'blue'>登&nbsp;&nbsp;陆&nbsp;&nbsp;时&nbsp;&nbsp;间:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font></html>");
    private JLabel timeLabel = new JLabel();
    
    private Statement stmt;
    private ResultSet rs;
    
    private tabPaneFrame tabPane = new tabPaneFrame();
    private LookandFeel look = new LookandFeel();
    sillClass sill = new sillClass();
    private int width = 800;
    private int height = 600;

}

⌨️ 快捷键说明

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