JAVA仓库管理系统(附源码+调试)
JAVA仓库管理系统——三只松鼠仓库管理系统
功能描述
(1)登录模块:登录信息等存储在数据库中
(2)基本档案管理模块:供货商管理,销售商管理,货品档案管理,仓库管理
(3)采购订货模块:用户可以通过查询条件(客户、订单号、订货日期)进行查询
(4)仓库入出库模块:可以对入出库商品信息进行增删改查等数据操作
(5)人员管理模块:对员工基本信息,联系方式进行增删改查等数据操作
(6)部门管理模块:对部门信息进行增删改查等数据操作
整体功能如此,本仓库系统以三只松鼠仓库管理系统为案例,进行相应界面上的优化,保证界面整洁干练,功能切合实际。
代码链接:https://pan.baidu.com/s/1F7dEBfny5aAU_AKpLpwCiA
提取码:3pxo
功能截图
1、登录模块
2、基本档案管理
3、采购订货模块
4、仓库入出库模块
5、人员管理模块
6、部门管理模块
部分关键代码
1、数据库链接
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | 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(); } } } |
2、主菜单设计
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 | 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(); } } } } |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构