前言:

随着小超市规模的发展不断扩大, 商品数量急剧增加, 有关商品的各种信息量也成倍增长。 超市时时刻刻都需要对商品各种信息进行统计分析。 而大型的超市管理系统功能过于强大而造成操作繁琐降低了小超市的工作效率。 超市管理系统是市场上最流行的超市上常用的系统之一, 由于刚学Java知识、所有功能设计的比较简单、只有商品信息的增删改查。实现对商品信息全面、 动态、及时的管理。本文系统的分析了软件开发的背景以过程;首先介绍了软件的开发环境, 其次介绍了本软件的详细设计过程: 数据库的设计、各个模块的设计和实现,以及具体界面的设计和功能。超市库存管理系统是基于 Java eclipse 作为开发工具 , Mysql 作为后台数据库支持。超市库存管理系统开发主要是界面程序的开发、数据库的建立、数据库的维护。应用程序功能完善,界面人机交互要好,而且操作简单。同时 JAVASwing语言简单,在较短的时间内能够开发出使用性强、 功能完善, 易于操作的程序, 也能实现与数据库的连接。

主要模块:

商品列表数据展示、商品信息添加、商品信息修改、商品信息删除、按照商品名称查询商品信息

1、功能介绍

功能截图:

查询商品列表信息:

添加商品信息:

修改商品信息:

删除商品信息:

删除之后需要刷新一下列表数据

​编号查询商品信息:

2、关键代码

2.1 主页功能

public class GoodsManage extends JFrame { private JTextField textField; Select select = new Select(); Updata updata = new Updata(); Object[] header= {"商品编号","商品名称","数量","单价"}; String sql = "SELECT goodsID,goodsname,num,price FROM goods"; Object[][] data= select.getGoods(sql); DefaultTableModel df = new DefaultTableModel(data, header); int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED; int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;  public GoodsManage() {  super("商品管理系统");  this.setBounds(0, 0, 700, 450);  this.setLocationRelativeTo(null);//让窗口在屏幕中间显示  this.setResizable(false);//让窗口大小不可改变  getContentPane().setLayout(null);    JTable jTable = new JTable(df);  JScrollPane jsp=new JScrollPane(jTable,v,h);  jsp.setBounds(10, 10, 515, 320);  getContentPane().add(jsp);    JButton button_1 = new JButton("显示所有商品");  button_1.addActionListener(new ActionListener() {   @Override   public void actionPerformed(ActionEvent e) {    String sql = "SELECT goodsID,goodsname,num,price FROM goods";    Object[][] data = Select.getGoods(sql);    df.setDataVector(data, header);   }  });   button_1.setBounds(535, 80, 127, 30);  getContentPane().add(button_1);    JButton button_2 = new JButton("修改商品");  button_2.setBounds(535, 140, 127, 30);  getContentPane().add(button_2);  button_2.addActionListener(new ActionListener() {   @Override   public void actionPerformed(ActionEvent e) {    if (jTable.getSelectedColumn()<0) {     JOptionPane.showMessageDialog(null, "请选择要修改的数据!");    } else {     int goodsID = Integer.parseInt(jTable.getValueAt(jTable.getSelectedRow(), 0).toString());     String name = jTable.getValueAt(jTable.getSelectedRow(), 1).toString();     int num = Integer.parseInt(jTable.getValueAt(jTable.getSelectedRow(), 2).toString());     String price = jTable.getValueAt(jTable.getSelectedRow(), 3).toString();     Goods goods = new Goods(goodsID,name,num,price);     GoodsXG goodsXG = new GoodsXG(goods);     goodsXG.setVisible(true);    }       }  });    JButton button_3 = new JButton("删除商品");  button_3.setBounds(535, 200, 127, 30);  getContentPane().add(button_3);  button_3.addActionListener(new ActionListener() {   @Override   public void actionPerformed(ActionEvent e) {    if (jTable.getSelectedColumn()<0) {     JOptionPane.showMessageDialog(null, "请选中要删除的数据!");    } else {     int goodsID = Integer.parseInt(jTable.getValueAt(jTable.getSelectedRow(), 0).toString());     String sql="delete from goods where goodsid="+goodsID;     int result = updata.addData(sql);     if (result>0) {      JOptionPane.showMessageDialog(null, "删除成功!");      JOptionPane.showMessageDialog(null, "记得刷新一下哦!");     } else {      JOptionPane.showMessageDialog(null, "删除失败!");     }    }   }  });    JButton button_4 = new JButton("添加商品");  button_4.setBounds(535, 258, 127, 30);  getContentPane().add(button_4);  button_4.addActionListener(new ActionListener() {   public void actionPerformed(ActionEvent arg0) {    GoodsADD goodsAdd = new GoodsADD();    goodsAdd.setVisible(true);   }  });    JLabel label = new JLabel("商品编号:");  label.setBounds(40, 354, 112, 32);  getContentPane().add(label);    textField = new JTextField();  textField.setBounds(154, 358, 127, 26);  getContentPane().add(textField);  textField.setColumns(10);    JButton button = new JButton("按编号查询");  button.addActionListener(new ActionListener() {   public void actionPerformed(ActionEvent arg0) {    String sql = "SELECT goodsID,goodsname,num,price FROM goods WHERE goodsid LIKE '%"+textField.getText()+"%'";    Object[][] data = Select.getGoods(sql);    df.setDataVector(data, header);   }  });  button.setBounds(305, 355, 112, 30);  getContentPane().add(button);    this.addWindowListener(new WindowAdapter() {       public void windowClosing(WindowEvent e) {    super.windowClosing(e);    //加入动作    GoodsManagement m = new GoodsManagement();    m.setVisible(true);    }  }); }  public static void main(String[] args) {  GoodsManage t = new GoodsManage();  t.setVisible(true); }}

更多相关文章

  1. android 包管理系统分析
  2. android 包管理系统分析
  3. 图书馆座位管理系统(android,java后台,mysql)
  4. 【Android】窗口机制分析与UI管理系统
  5. Android实现电池管理系统
  6. Android电池管理系统系统分析
  7. Android(安卓)电池管理系统
  8. HTML综合练习——网站后台管理系统 框架
  9. 想购一套生鲜配送管理系统,蔬果云和悦厚哪个更好用

随机推荐

  1. android强制隐藏输入法键盘(亲测可用,欢迎
  2. Android中点击按钮的事件处理实现步骤
  3. 反编译出错
  4. Android通过换载体实现再次辉煌
  5. Android中全屏无标题设置
  6. Visibility属性中invisible和gone 区别
  7. Android GPS相关文章
  8. android 用tcpdump抓取网络包
  9. Android--通过ContentResolver取得com.an
  10. Android(安卓)keystore 签名证书的作用以