本人承接各種高校C語言、C++、Java語言,JSP、python,delphi等課程設計以及ppt、計算機二級考試資料等,以及常見的電腦故障有需要的私信我或者微信:15813406574
本系統實現簡單的倉庫管理功能,可以對倉庫及產品信息進行登記、修改、刪除等。
程序的基本功能:
1.增加、修改、刪除一個倉庫資料。
2.增加、修改、刪除一個產品資料。
3.按條件顯示倉庫資料(條件有按編號、名稱等)。
4.按條件顯示產品資料(條件有按編號、名稱等)。
5.查找指定產品的數量。
6 . 用戶登錄以及退出
基本要求就是這些,我們還在此基礎對功能以及界面進行優化,以三顆松鼠為參考對象,進行設計。廢話不多說先上運行截圖。
一、登錄界面
二、主頁界面
三、部分功能展示
功能就不一一展示了。
接下來就是數據庫方面的設計了。
數據庫中的表太多,我們這里就展示一兩個表吧。
源碼展示(源碼太多,這里只展示部分代碼)
一、數據庫鏈接
package com.szss.dao; import java.sql.*; public class GetConnection { private Connection con; //定義數據庫連接類對象 private PreparedStatement pstm; private String user="sa"; //連接數據庫用戶名 private String password="123456"; //連接數據庫密碼 private String className="com.microsoft.sqlserver.jdbc.SQLServerDriver"; //數據庫驅動 private String url="jdbc:sqlserver://localhost:1433;DatabaseName=db_supermarket"; //連接數據庫的URL public GetConnection(){ try{ Class.forName(className); }catch(ClassNotFoundException e){ System.out.println("加載數據庫驅動失敗!"); e.printStackTrace(); } } /**創建數據庫連接*/ public Connection getCon(){ try { con=DriverManager.getConnection(url,user,password); //獲取數據庫連接 } catch (SQLException e) { System.out.println("創建數據庫連接失敗!"); con=null; e.printStackTrace(); } return con; //返回數據庫連接對象 } public void doPstm(String sql,Object[] params){ if(sql!=null&&!sql.equals("")){ if(params==null) params=new Object[0]; getCon(); if(con!=null){ try{ System.out.println(sql); pstm=con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY); for(int i=0;i<params.length;i++){ pstm.setObject(i+1,params[i]); } pstm.execute(); }catch(SQLException e){ System.out.println("doPstm()方法出錯!"); e.printStackTrace(); } } } } public ResultSet getRs() throws SQLException{ return pstm.getResultSet(); } public int getCount() throws SQLException{ return pstm.getUpdateCount(); } public void closed(){ try{ if(pstm!=null) pstm.close(); }catch(SQLException e){ System.out.println("關閉pstm對象失敗!"); e.printStackTrace(); } try{ if(con!=null){ con.close(); } }catch(SQLException e){ System.out.println("關閉con對象失敗!"); e.printStackTrace(); } } }

二、主頁界面顯示
package com.szss.mainFrame; import static javax.swing.BorderFactory.createTitledBorder; import java.awt.Color; import java.awt.EventQueue; import java.awt.Font; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.SwingConstants; import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.border.EmptyBorder; import javax.swing.border.TitledBorder; import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.TreePath; import javax.swing.tree.TreeSelectionModel; import com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel; import com.szss.bean.User; import com.szss.panel.DepotPanel; import com.szss.panel.DeptPanel; import com.szss.panel.FeelWarePanel; import com.szss.panel.JoinDepotPanel; import com.szss.panel.MyJPanel; import com.szss.panel.OutDepotPanel; import com.szss.panel.PersonnelPanel; import com.szss.panel.SellPanel; import com.szss.panel.StockPanel; import com.szss.panel.WarePanel; import com.szss.util.Session; import com.szss.widget.BGPanel; import com.szss.widget.GlassButton; import com.szss.widget.SmallScrollPanel; import java.awt.Dimension; import java.awt.GridLayout; import javax.swing.ButtonGroup; import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.JTree; import javax.swing.JScrollPane; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; public class RemoveButtomFrame extends JFrame { private MyJPanel contentPane; private BGPanel backPanel; private SmallScrollPanel moduleButtonGroup = null; private JTree tree; private JPanel panel; FeelWarePanel panelFeel = new FeelWarePanel(); JPanel panel_1 = new JPanel(); JLabel fristLabel = new JLabel("基本檔案管理"); private BGPanel jPanel = null; private ButtonGroup buttonGroup = null; private GlassButton workSpaceButton = null; private GlassButton progressButton = null; private GlassButton bookProjectButton = null; private GlassButton chukuButton = null; private GlassButton personnelManagerButton = null; private GlassButton deptManagerButton = null; JLabel label_1 = new JLabel("您當前的位置是:"); /** * Create the frame. */ public RemoveButtomFrame() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 934, 625); contentPane = new MyJPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.add(getModuleButtonGroup()); setTitle("三只松鼠管理系統"); contentPane.setLayout(null); setResizable(false); JPanel clockpanel = new JPanel(); clockpanel.setBackground(new Color(255,175,175)); clockpanel.setBounds(10, 120, 248, 130); contentPane.add(clockpanel); clockpanel.setLayout(null); JPanel panel_1 = new JPanel(); panel_1.setBounds(0, 210, 276, 1); clockpanel.add(panel_1); panel_1.setLayout(null); User user = Session.getUser(); //獲取登錄用戶對象 String info = "<html><body>" + "<font color=#FFFFFF>你 好:</font>" + "<font color=yellow><b>" + user.getUserName() + "</b></font>" + "<font color=#FFFFFF> 歡 迎 登 錄</font>" + "</body></html>"; //定義窗體顯示內容 JLabel label = new JLabel(info); //定義顯示指定內容的標簽對象 label.setBackground(Color.yellow); label.setBounds(70, 30, 128, 35); clockpanel.add(label); contentPane.add(getContentPanel()); // 在主窗體中添加 } private BGPanel getContentPanel() { if (backPanel == null) { backPanel = new BGPanel(); backPanel.setBackground(new Color(255,175,175)); backPanel.setSize(629, 416); // 內容顯示區主面板 backPanel.setLocation(279, 149); backPanel.setLayout(null); label_1.setHorizontalAlignment(SwingConstants.RIGHT); label_1.setVerticalAlignment(SwingConstants.BOTTOM); label_1.setBounds(38, 38, 96, 15); backPanel.setBorder(createTitledBorder(null, "基本檔案管理", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.TOP, new Font("sansserif", Font.BOLD, 12), new Color(59, 59, 59))); backPanel.add(label_1); fristLabel.setBounds(133, 38, 123, 15); backPanel.add(fristLabel); panel_1.setBounds(10, 63, 611, 343); panel_1.setLayout(null); backPanel.add(panel_1); JScrollPane scrollPane = new JScrollPane(); panel_1.add(scrollPane); JScrollPane scrollPane_1 = new JScrollPane(); scrollPane_1.setBackground(new Color(255,175,175)); scrollPane_1.setBounds(0, 0, 138, 334); panel_1.add(scrollPane_1); DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode( "基本檔案管理"); DefaultMutableTreeNode childNode1 = new DefaultMutableTreeNode( "供貨商管理"); DefaultMutableTreeNode childNode2 = new DefaultMutableTreeNode( "銷售商管理"); DefaultMutableTreeNode childNode3 = new DefaultMutableTreeNode( "貨品檔案管理"); DefaultMutableTreeNode childNode4 = new DefaultMutableTreeNode( "倉庫管理"); rootNode.add(childNode1); rootNode.add(childNode2); rootNode.add(childNode3); rootNode.add(childNode4); tree = new JTree(rootNode); scrollPane_1.setColumnHeaderView(tree); final JPanel sellPanel = new JPanel(); sellPanel.setBackground(new Color(255,175,175)); sellPanel.setBounds(138, 0, 473, 343); sellPanel.setLayout(null); panel_1.add(sellPanel); tree.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION); TreeSelectionModel treeSelectionModel = tree.getSelectionModel(); treeSelectionModel .setSelectionMode(TreeSelectionModel.CONTIGUOUS_TREE_SELECTION); tree.addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { if (!tree.isSelectionEmpty()) { TreePath selectionPaths = tree.getSelectionPath(); Object path = selectionPaths.getLastPathComponent(); DefaultMutableTreeNode node = (DefaultMutableTreeNode) path; String userObject = (String) node.getUserObject(); repaint(); if (userObject.equals("供貨商管理")) { fristLabel.setText("供貨商管理"); sellPanel.removeAll(); sellPanel.add(panelFeel.getMessage()); } else if (userObject.equals("銷售商管理")) { fristLabel.setText("銷售商管理"); sellPanel.removeAll(); SellPanel sell = new SellPanel(); sellPanel.add(sell.getMessage()); repaint(); } else if (userObject.equals("貨品檔案管理")) { fristLabel.setText("貨品檔案管理"); sellPanel.removeAll(); WarePanel warePanel = new WarePanel(); sellPanel.add(warePanel.getMessage()); repaint(); } else if (userObject.equals("倉庫管理")) { fristLabel.setText("倉庫管理"); sellPanel.removeAll(); DepotPanel depotPanel = new DepotPanel(); sellPanel.add(depotPanel.getMessage()); repaint(); } } } }); } return backPanel; } private SmallScrollPanel getModuleButtonGroup() { if (moduleButtonGroup == null) { moduleButtonGroup = new SmallScrollPanel();// 創建移動面板 moduleButtonGroup.setBounds(250, 20, 434, 68); moduleButtonGroup.setOpaque(false); // 將按鈕組面板作為移動面板的視圖 moduleButtonGroup.setViewportView(getJPanel()); moduleButtonGroup.getAlphaScrollPanel() .setViewportView(getJPanel()); // 添加鼠標事件監聽器 } return moduleButtonGroup; } public BGPanel getJPanel() { if (jPanel == null) { GridLayout gridLayout = new GridLayout(); //定義網格布局管理器 gridLayout.setRows(1); //設置網格布局管理器的行數 gridLayout.setHgap(0); //設置組件間水平間距 gridLayout.setVgap(0); //設置組件間垂直間距 jPanel = new BGPanel(); // // 設置布局管理器 jPanel.setLayout(gridLayout); // 設置初始大小 jPanel.setPreferredSize(new Dimension(400, 50)); jPanel.setOpaque(false); // 添加按鈕 jPanel.add(getWorkSpaceButton(), null); jPanel.add(getProgressButton(), null); jPanel.add(getrukuButton(), null); jPanel.add(getchukuButton(), null); jPanel.add(getPersonnelManagerButton(), null); jPanel.add(getDeptManagerButton(), null); if (buttonGroup == null) { buttonGroup = new ButtonGroup(); } // 把所有按鈕添加到一個組控件中 buttonGroup.add(getProgressButton()); buttonGroup.add(getWorkSpaceButton()); buttonGroup.add(getrukuButton()); buttonGroup.add(getchukuButton()); buttonGroup.add(getPersonnelManagerButton()); buttonGroup.add(getDeptManagerButton()); } return jPanel; } // 基本檔案管理按鈕 private GlassButton getWorkSpaceButton() { if (workSpaceButton == null) { workSpaceButton = new GlassButton(); workSpaceButton.setActionCommand("基本檔案管理"); //設置按鈕的動作命令 workSpaceButton.setIcon(new ImageIcon(getClass().getResource( "/com/szss/frame/buttonIcons/myWorkSpace.png"))); //定義按鈕的初始化背景 ImageIcon icon = new ImageIcon(getClass().getResource( "/com/szss/frame/buttonIcons/myWorkSpace2.png")); //創建圖片對象 workSpaceButton.setRolloverIcon(icon); //設置按鈕的翻轉圖片 workSpaceButton.setSelectedIcon(icon); //設置按鈕被選中時顯示圖片 workSpaceButton.setSelected(true); workSpaceButton.addActionListener(new toolsButtonActionAdapter()); //按鈕的監聽器 } return workSpaceButton; } // 采購進貨管理按鈕 private GlassButton getProgressButton() { if (progressButton == null) { progressButton = new GlassButton(); progressButton.setActionCommand("采購進貨"); progressButton.setText(""); progressButton.setIcon(new ImageIcon(getClass().getResource( "/com/szss/frame/buttonIcons/caigou1.png"))); ImageIcon icon = new ImageIcon(getClass().getResource( "/com/szss/frame/buttonIcons/caigou2.png")); progressButton.setRolloverIcon(icon); progressButton.setSelectedIcon(icon); progressButton.addActionListener(new toolsButtonActionAdapter()); } return progressButton; } // 倉庫管理 private GlassButton getrukuButton() { if (bookProjectButton == null) { bookProjectButton = new GlassButton(); bookProjectButton.setActionCommand("倉庫入庫"); // bookProjectButton.setText("圖書計划"); ImageIcon icon = new ImageIcon(getClass().getResource( "/com/szss/frame/buttonIcons/ruku2.png")); bookProjectButton.setSelectedIcon(icon); bookProjectButton.setRolloverIcon(icon); bookProjectButton.setIcon(new ImageIcon(getClass().getResource( "/com/szss/frame/buttonIcons/ruku1.png"))); bookProjectButton.addActionListener(new toolsButtonActionAdapter()); } return bookProjectButton; } // 倉庫出庫管理 private GlassButton getchukuButton() { if (chukuButton == null) { chukuButton = new GlassButton(); chukuButton.setActionCommand("倉庫出庫"); ImageIcon icon = new ImageIcon(getClass().getResource( "/com/szss/frame/buttonIcons/chuku1.png")); chukuButton.setSelectedIcon(icon); chukuButton.setRolloverIcon(icon); chukuButton.setIcon(new ImageIcon(getClass().getResource( "/com/szss/frame/buttonIcons/chuku2.png"))); chukuButton.addActionListener(new toolsButtonActionAdapter()); } return chukuButton; } // 人員管理系統 private GlassButton getPersonnelManagerButton() { if (personnelManagerButton == null) { personnelManagerButton = new GlassButton(); // personnelManagerButton.setText("人員管理"); personnelManagerButton.setActionCommand("查詢及統計系統"); // personnelManagerButton.setCursor(new // Cursor(Cursor.DEFAULT_CURSOR)); ImageIcon imageIcon = new ImageIcon(getClass().getResource( "/com/szss/frame/buttonIcons/person2.png")); personnelManagerButton.setIcon(imageIcon); ImageIcon icon = new ImageIcon(getClass().getResource( "/com/szss/frame/buttonIcons/person1.png")); personnelManagerButton.setRolloverIcon(icon); personnelManagerButton.setSelectedIcon(icon); personnelManagerButton.setFocusPainted(false); personnelManagerButton .addActionListener(new toolsButtonActionAdapter()); } return personnelManagerButton; } // 部門管理系統 private GlassButton getDeptManagerButton() { if (deptManagerButton == null) { deptManagerButton = new GlassButton(); deptManagerButton.setActionCommand("查詢及統計系統"); // personnelManagerButton.setCursor(new // Cursor(Cursor.DEFAULT_CURSOR)); ImageIcon imageIcon = new ImageIcon(getClass().getResource( "/com/szss/frame/buttonIcons/deptButton.png")); deptManagerButton.setIcon(imageIcon); ImageIcon icon = new ImageIcon(getClass().getResource( "/com/szss/frame/buttonIcons/deptButton2.png")); deptManagerButton.setRolloverIcon(icon); deptManagerButton.setSelectedIcon(icon); deptManagerButton.setFocusPainted(false); deptManagerButton.addActionListener(new toolsButtonActionAdapter()); } return deptManagerButton; } class toolsButtonActionAdapter implements ActionListener { @Override public void actionPerformed(ActionEvent e) { if (e.getSource() == workSpaceButton) { backPanel.removeAll(); backPanel.add(label_1); fristLabel.setBounds(133, 38, 123, 15); backPanel.add(fristLabel); panel_1.setBounds(10, 63, 611, 376); backPanel.add(panel_1); fristLabel.setText("基本檔案管理"); repaint(); } if (e.getSource() == progressButton) { backPanel.removeAll(); backPanel.add(label_1); fristLabel.setBounds(133, 38, 123, 15); backPanel.add(fristLabel); panel_1.setBounds(10, 63, 611, 386); StockPanel stockPanl = new StockPanel(); fristLabel.setText("采購訂貨"); backPanel.add(stockPanl); repaint(); } if (e.getSource() == bookProjectButton) { backPanel.removeAll(); backPanel.add(label_1); fristLabel.setBounds(133, 38, 123, 15); backPanel.add(fristLabel); panel_1.setBounds(10, 63, 611, 386); JoinDepotPanel joinPanel = new JoinDepotPanel(); backPanel.add(joinPanel); fristLabel.setText("倉庫入庫"); repaint(); } if (e.getSource() == chukuButton) { backPanel.removeAll(); backPanel.add(label_1); fristLabel.setBounds(133, 38, 123, 15); backPanel.add(fristLabel); panel_1.setBounds(10, 63, 611, 386); OutDepotPanel outPanel = new OutDepotPanel(); backPanel.add(outPanel); fristLabel.setText("倉庫出庫"); repaint(); } if (e.getSource() == deptManagerButton) { backPanel.removeAll(); backPanel.add(label_1); fristLabel.setBounds(133, 38, 123, 15); backPanel.add(fristLabel); panel_1.setBounds(10, 63, 611, 386); DeptPanel outPanel = new DeptPanel(); backPanel.add(outPanel); fristLabel.setText("部門管理"); repaint(); } if (e.getSource() == personnelManagerButton) { backPanel.removeAll(); panel_1.setBounds(10, 63, 611, 386); PersonnelPanel panel = new PersonnelPanel(); backPanel.add(panel); repaint(); } } } }
篇幅限定,代碼就不一一展示。