1、Java课程设计超市库存管理系统附源代码可以直接运行 一、需求分析本系统主要是用来帮助小型超市进行库存管理系统,能够有效的帮助小型超市进行库存管理!其中包括增删改查等基本的应用。极大的提高了超市的库存管理效率,节省了大量的时间。*二、概要设计1、本系统的每一个功能模块都包含了多个功能。整个系统主要完成对超市商品的日常管理,包括进货管理,库存管理和供应商管理等方面。在功能上系统可以完成对相关信息的浏览、查询、添加、删除、修改等功能。本课题的核心之一是销售管理、库存管理和进货管理三者之间的联系,同时系统有完整的用户管理功能。本系统采用java语言和SQLServer2008作为开发工具。这种系统优
2、势在于系统比较简单,但功能强大,扩展性能也比较好,完全能够处理一般超市的日常任务2、 整体分为3个模块(货物,供应商,记录)每个模块之间相互关联,都有自己的增删改查!3、程序流程图如下:三、详细设计1、数据库设计Goods表:Lzs(用户登录名,密码):Recond表():记录表Supplier(供应商表):用户登录界面:设计代码如下:package source;import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.sql.*;SuppressWarnings(serial)public clas
3、s loginframe extends JFrame implements ActionListener JTextField 用户名; JPasswordField 密码; JButton 登录,重置; Box baseBox,box1,box2,box3;/盒式布局 ImagePanel p;/用于插入图片的面板 JSplitPane split;/拆分窗格 Font f;/设置字体 JLabel userName,psw; Function wMain; Connection con; Statement sql; ResultSet rs; String dbdriver = com
4、.microsoft.sqlserver.jdbc.SQLServerDriver; String dburl = jdbc:sqlserver:/localhost:1433;DatabaseName=LZS; String user = sa; String pass = 123; public loginframe() setLayout(new FlowLayout(); init(); setBounds(130,80,960,600); setVisible(true); setResizable(false); try Class.forName(dbdriver); catch
5、(ClassNotFoundException classnotfound) System.out.println(未能找到SQLServerDriver,请检查是否已加载SQLServer驱动); void init() f = new Font(幼圆,Font.BOLD,18); p = new ImagePanel(new ImageIcon(E:/Java文件/SuperMarket/picture/1.jpg).getImage(); 登录 = new JButton(登录); 登录.addActionListener(this); 重置 = new JButton(重置); 重置.
6、addActionListener(this); 用户名 = new JTextField(16); 用户名.setFont(f); 密码 = new JPasswordField(16); userName = new JLabel(用户名:); userName.setFont(f); psw = new JLabel(密码:); psw.setFont(f); box1 = Box.createVerticalBox(); box1.add(userName); box1.add(Box.createVerticalStrut(20); box1.add(psw); box2 = Box
7、.createVerticalBox(); box2.add(Box.createVerticalStrut(240); box2.add(用户名); box2.add(Box.createVerticalStrut(20); box2.add(密码); box2.add(Box.createVerticalStrut(20); box3 = Box.createHorizontalBox(); box3.add(登录); box3.add(Box.createHorizontalStrut(20); box3.add(重置); box2.add(box3); box2.add(Box.cre
8、ateVerticalStrut(200); baseBox = Box.createHorizontalBox(); baseBox.add(box1); baseBox.add(Box.createHorizontalStrut(15); baseBox.add(box2); /baseBox.add(登录); split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,false,p,baseBox); split.setDividerLocation(0.5); add(split,BorderLayout.PAGE_START); publi
9、c void actionPerformed(ActionEvent e) if(e.getSource() = 登录) String Uname = 用户名.getText().trim(); charpsw = 密码.getPassword(); String passWord = new String(psw); try con = DriverManager.getConnection(jdbc:sqlserver:/localhost:1433;DatabaseName=LZS,sa,123); System.out.println(数据库连接成功!); sql=con.create
10、Statement(); String string = SELECT * FROM lzs WHERE Uname= +Uname+ AND mima = +passWord+; rs = sql.executeQuery(string); if(rs.next() wMain = new Function(); wMain.setTitle(超市库存管理系统); wMain.setVisible(true); this.dispose(); / wMain.pack(); else JOptionPane.showMessageDialog(this, 您输入的用密码不正确,警告对话框,J
11、OptionPane.WARNING_MESSAGE); 密码.setText(null); 密码.requestFocus(); con.close(); catch(SQLException ee) ee.printStackTrace(); else if(e.getSource() = 重置) 用户名.setText(); 密码.setText(); 进入主界面:第一菜单(货物):第二菜单(供应商):第三菜单(记录):设计代码如下:package source;import java.awt.*;import java.awt.event.*;import javax.swing.*;
12、SuppressWarnings(serial)public class Function extends JFrame implements ActionListener Font f; /菜单栏 JMenuBar menubar;/菜单条 JMenu 货物,供应商,记录; /菜单 JMenuItem 货物管理,退出,供应商管理,查询记录,进货计划;/菜单项 /Box box; JLabel label; ImagePanel p;/用于插入图片的面板 /构造函数 Function() setLayout(new FlowLayout(); init(); setTitle(超市库存管理系统
13、); setLocation(20,30); setSize(1200,800); setBounds(130,80,960,600); setVisible(true); setResizable(false); void init() menubar = new JMenuBar(); f = new Font(华文行楷,Font.BOLD,50); Font f2 = new Font(宋体,0,12); p = new ImagePanel(new ImageIcon(E:Java文件/SuperMarket/picture/2.jpg).getImage(); /库房货物管理菜单 货
14、物 = new JMenu(货物); 货物.setFont(f2); 货物管理 = new JMenuItem(货物管理); 货物管理.setFont(f2); 货物管理.addActionListener(this); 退出 = new JMenuItem(退出); 退出.setFont(f2); 退出.addActionListener(this); 货物.add(货物管理); 货物.add(退出); menubar.add(货物); /货物供应商菜单 供应商 = new JMenu(供应商); 供应商.setFont(f2); 供应商管理 = new JMenuItem(供应商管理);
15、供应商管理.setFont(f2); 供应商管理.addActionListener(this); 供应商.add(供应商管理); menubar.add(供应商); /货物进货、入库和出库记录查询菜单 记录 = new JMenu(记录); 记录.setFont(f2); 查询记录 = new JMenuItem(查询记录); 查询记录.setFont(f2); 查询记录.addActionListener(this); 进货计划 = new JMenuItem(进货计划); 进货计划.setFont(f2); 进货计划.addActionListener(this); 记录.add(查询记
16、录); 记录.add(进货计划); menubar.add(记录); label = new JLabel(欢迎进入超市库存管理系统); label.setFont(f); p.add(label); label.setBounds(300,400,800,200); add(p,BorderLayout.CENTER); setJMenuBar(menubar); public void actionPerformed(ActionEvent e) if(e.getSource()=供应商管理) SupplierManage smTable = new SupplierManage(); s
17、mTable.setVisible(true); smTable.pack(); else if(e.getSource()=货物管理) goods goTable = new goods(); goTable.setVisible(true); goTable.pack(); else if(e.getSource()=查询记录) record reTable = new record(); reTable.setVisible(true); reTable.pack(); else if(e.getSource() =进货计划) plan plTable = new plan(); plT
18、able.setVisible(true); plTable.pack(); else if(e.getSource()=退出) this.dispose(); 进入第一菜单(货物管理):在此菜单下,可进行货物的增删改查操作,设计代码如下:package source;import java.awt.*;import java.awt.event.*;import java.sql.*;import javax.swing.*;import javax.swing.table.DefaultTableModel;SuppressWarnings(serial)public class good
19、s extends JFrame implements ActionListener JTable table; JLabel label; JTextField inputText; String name = 货物号,货物名,进货价,售价,折扣价,余量,余量预警值,供应商; String strings = new String8; JButton 添加,修改,删除,退出,确认修改; JPanel p; JLabel labels = new JLabel8; JTextField fields = new JTextField8; Box baseBox,box1,box2; Image
20、Panel pp;/用于插入图片的面板 JSplitPane split;/拆分窗格 DefaultTableModel deModel = null; Connection con; Statement sql; ResultSet rs; String dbdriver = com.microsoft.sqlserver.jdbc.SQLServerDriver; String dburl = jdbc:sqlserver:/localhost:1433;DatabaseName=LZS; String user = sa; String pass = 123; goods() setLa
21、yout(new BorderLayout(); init();/ Toolkit tk = Toolkit.getDefaultToolkit();/ Image img = tk.getImage(E:Java文件/SuperMarket/picture/2.jpg);/ setIconImage(img); setTitle(货物管理); setBounds(130,80,960,600); /setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setResizable(false); try Class.forName(dbdriver);
22、catch(ClassNotFoundException classnotfound) classnotfound.printStackTrace(); void init() pp = new ImagePanel(new ImageIcon(E:/Java文件/SuperMarket/picture/2.jpg).getImage(); 添加= new JButton(添加); 修改= new JButton(修改); 删除 = new JButton(删除); 退出 = new JButton(退出); 确认修改 = new JButton(确认修改); label = new JLab
23、el(请输入想要删除或修改的货物名:); inputText = new JTextField(8); 添加.addActionListener(this); 修改.addActionListener(this); 删除.addActionListener(this); 退出.addActionListener(this); 确认修改.addActionListener(this); p = new JPanel(); p.add(label); p.add(inputText); p.add(添加); p.add(修改); p.add(删除); p.add(退出); p.add(确认修改);
24、 add(p,BorderLayout.SOUTH); labels0 = new JLabel(货物号); labels1 = new JLabel(货物名); labels2 = new JLabel(进货价); labels3 = new JLabel(售价); labels4 = new JLabel(折扣价); labels5 = new JLabel(余量); labels6 = new JLabel(余量预警值); labels7 = new JLabel(供应商); for(int i = 0;i8;i+) fieldsi = new JTextField(20); /用盒式容
25、器装要录入的数据和标签 box1 = Box.createVerticalBox(); box1.add(Box.createVerticalStrut(15); for(int i = 0;i8;i+) box1.add(labelsi); box1.add(Box.createVerticalStrut(35); box2 = Box.createVerticalBox(); box2.add(Box.createVerticalStrut(10); for(int i = 0;i8;i+) box2.add(fieldsi); box2.add(Box.createVerticalStr
26、ut(14); baseBox = Box.createHorizontalBox(); baseBox.add(box1); baseBox.add(Box.createHorizontalStrut(15); baseBox.add(box2); /添加表格 add(baseBox,BorderLayout.EAST); deModel = new DefaultTableModel(name,0); table = new JTable(deModel); table.setCellSelectionEnabled(false); table.setEnabled(false); tab
27、le.setShowHorizontalLines(true); table.setShowVerticalLines(true); /add(new JScrollPane(table),BorderLayout.CENTER); split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,false,new JScrollPane(table),baseBox); split.setDividerLocation(0.5); add(split,BorderLayout.CENTER); String sqlString = select * fr
28、om goods; try /连接数据库 con = DriverManager.getConnection(dburl, user, pass); sql = con.createStatement(); JOptionPane.showMessageDialog(this, 数据库连接成功!,消息对话框,JOptionPane.INFORMATION_MESSAGE); rs = sql.executeQuery(sqlString); while(rs.next() for(int i = 0;i8;i+) stringsi=rs.getString(i+1);/把查询的结果填入表格中 deModel.addRow(strings); deModel.fireTableStructureChanged();/更新中的数据
copyright@ 2008-2023 冰点文库 网站版权所有
经营许可证编号:鄂ICP备19020893号-2