欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

基于Mysql+JavaSwing的超市商品管理系統(tǒng)設(shè)計與實現(xiàn)

 更新時間:2021年09月26日 10:19:45   作者:java李楊勇  
本項目是使用Java swing開發(fā),可實現(xiàn)超市管理系統(tǒng)商品列表信息查詢、添加商品信息和修改商品管理以及刪除商品信息和安裝商品信息查詢等功能。界面設(shè)計和功能比較簡單基礎(chǔ)、適合作為Java課設(shè)設(shè)計以及學(xué)習(xí)技術(shù)使用,需要的朋友可以參考一下

前言:

     隨著小超市規(guī)模的發(fā)展不斷擴大, 商品數(shù)量急劇增加, 有關(guān)商品的各種信息量也成倍增長。 超市時時刻刻都需要對商品各種信息進行統(tǒng)計分析。 而大型的超市管理系統(tǒng)功能過于強大而造成操作繁瑣降低了小超市的工作效率。 超市管理系統(tǒng)是市場上最流行的超市上常用的系統(tǒng)之一, 由于剛學(xué)Java知識、所有功能設(shè)計的比較簡單、只有商品信息的增刪改查。實現(xiàn)對商品信息全面、 動態(tài)、及時的管理。本文系統(tǒng)的分析了軟件開發(fā)的背景以過程;首先介紹了軟件的開發(fā)環(huán)境, 其次介紹了本軟件的詳細設(shè)計過程: 數(shù)據(jù)庫的設(shè)計、各個模塊的設(shè)計和實現(xiàn),以及具體界面的設(shè)計和功能。超市庫存管理系統(tǒng)是基于 Java eclipse 作為開發(fā)工具 , Mysql 作為后臺數(shù)據(jù)庫支持。超市庫存管理系統(tǒng)開發(fā)主要是界面程序的開發(fā)、數(shù)據(jù)庫的建立、數(shù)據(jù)庫的維護。應(yīng)用程序功能完善,界面人機交互要好,而且操作簡單。同時 JAVASwing語言簡單,在較短的時間內(nèi)能夠開發(fā)出使用性強、 功能完善, 易于操作的程序, 也能實現(xiàn)與數(shù)據(jù)庫的連接。

主要模塊:

商品列表數(shù)據(jù)展示、商品信息添加、商品信息修改、商品信息刪除、按照商品名稱查詢商品信息

1、功能介紹

功能截圖:

查詢商品列表信息:

添加商品信息:

修改商品信息:

刪除商品信息:

刪除之后需要刷新一下列表數(shù)據(jù)

​編號查詢商品信息:

2、關(guān)鍵代碼

2.1 主頁功能

public class GoodsManage extends JFrame {
 private JTextField textField;
 Select select = new Select();
 Updata updata = new Updata();
 Object[] header= {"商品編號","商品名稱","數(shù)量","單價"};
 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("商品管理系統(tǒng)");
  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, "請選擇要修改的數(shù)據(jù)!");
    } 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, "請選中要刪除的數(shù)據(jù)!");
    } 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);
 }
}

2.2 添加商品信息

public class GoodsADD extends JFrame {
 private JTextField id,name,num,price;
 private JButton button;
 private JButton button_1;
 
 public GoodsADD() {
  super("商品管理系統(tǒng)");
  this.setBounds(0, 0, 400, 450);
  this.setLocationRelativeTo(null);//讓窗口在屏幕中間顯示
  this.setResizable(false);//讓窗口大小不可改變
  getContentPane().setLayout(null);
  
  JLabel label = new JLabel("商品編號:");
  label.setBounds(85, 89, 87, 22);
  getContentPane().add(label);
  
  id = new JTextField();
  id.setBounds(147, 90, 142, 21);
  getContentPane().add(id);
  id.setColumns(10);
  
  JLabel label_1 = new JLabel("商品名稱");
  label_1.setBounds(85, 139, 87, 22);
  getContentPane().add(label_1);
  
  name = new JTextField();
  name.setColumns(10);
  name.setBounds(147, 140, 142, 21);
  getContentPane().add(name);
  
  JLabel label_2 = new JLabel("數(shù)量:");
  label_2.setBounds(85, 193, 87, 22);
  getContentPane().add(label_2);
  
  num = new JTextField();
  num.setColumns(10);
  num.setBounds(147, 194, 142, 21);
  getContentPane().add(num);
  
  JLabel label_3 = new JLabel("單價:");
  label_3.setBounds(85, 241, 87, 22);
  getContentPane().add(label_3);
  
  price = new JTextField();
  price.setColumns(10);
  price.setBounds(147, 242, 142, 21);
  getContentPane().add(price);
  
  button = new JButton("確定");
  button.setBounds(78, 317, 93, 23);
  getContentPane().add(button);
  button.addActionListener(new ActionListener() {
   public void actionPerformed(ActionEvent arg0) {
    String addId = id.getText();
    String addName = name.getText();
    String addNum = num.getText();
    String addPrice = num.getText();
    if (addName.equals("")||addName.equals("")||addNum.equals("")||addPrice.equals("")) {
     JOptionPane.showMessageDialog(null, "請完整輸入要添加的數(shù)據(jù)");
    } else {
     String sql="INSERT INTO goods VALUES("+addId+",'"+addName+"','"+addNum+"','"+addPrice+"')";
     int result = Updata.addData(sql);
     if (result>0) {
      JOptionPane.showMessageDialog(null, "添加成功!");
                  JOptionPane.showMessageDialog(null, "記得刷新一下哦!");
      dispose();
//      GoodsManage i = new GoodsManage();
//      i.setVisible(true);
     } else {
      JOptionPane.showMessageDialog(null, "添加失敗!");
     }
    }
 
   }
  });
  
  button_1 = new JButton("取消");
  button_1.setBounds(208, 317, 93, 23);
  getContentPane().add(button_1);
  button_1.addActionListener(new ActionListener() {
   public void actionPerformed(ActionEvent arg0) {
    dispose();
   }
  });
  
 }
}

2.3 數(shù)據(jù)庫設(shè)計

商品表

CREATE TABLE `NewTable` (
`goodsID`  int(11) NOT NULL ,
`goodsName`  varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
`num`  int(11) NOT NULL ,
`price`  decimal(10,4) NOT NULL ,
PRIMARY KEY (`goodsID`)
)
ENGINE=InnoDB
DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci
ROW_FORMAT=COMPACT
;

到此這篇關(guān)于基于Mysql+JavaSwing的超市商品管理系統(tǒng)設(shè)計與實現(xiàn)的文章就介紹到這了,更多相關(guān)Mysql+JavaSwing的超市商品管理系統(tǒng)設(shè)計與實現(xiàn)內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • 詳解Linux終端 MySQL常用操作指令

    詳解Linux終端 MySQL常用操作指令

    這篇文章主要介紹了Linux終端 MySQL常用操作指令的相關(guān)知識,非常不錯,具有參考借鑒價值,需要的朋友可以參考下
    2018-02-02
  • 關(guān)于com.mysql.jdbc.Driver與com.mysql.cj.jdbc.Driver的區(qū)別

    關(guān)于com.mysql.jdbc.Driver與com.mysql.cj.jdbc.Driver的區(qū)別

    這篇文章主要介紹了關(guān)于com.mysql.jdbc.Driver與com.mysql.cj.jdbc.Driver的區(qū)別及說明,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2023-08-08
  • 在MySQL數(shù)據(jù)庫中使用C執(zhí)行SQL語句的方法

    在MySQL數(shù)據(jù)庫中使用C執(zhí)行SQL語句的方法

    與PostgreSQL相似,可使用許多不同的語言來訪問MySQL,包括C、C++、Java和Perl。從Professional Linux Programming中第5章有關(guān)MySQL的下列章節(jié)中,Neil Matthew和Richard Stones使用詳盡的MySQL C接口向我們介紹了如何在MySQL數(shù)據(jù)庫中執(zhí)行SQL語句。
    2012-10-10
  • mysql數(shù)據(jù)庫中字符集亂碼問題原因及解決

    mysql數(shù)據(jù)庫中字符集亂碼問題原因及解決

    這篇文章主要介紹了mysql數(shù)據(jù)庫中字符集亂碼問題原因及解決,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-08-08
  • MySQL中的insert set 和 insert values用法

    MySQL中的insert set 和 insert values用法

    這篇文章主要介紹了MySQL中的insert set 和 insert values用法說明,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-08-08
  • Mysql關(guān)于進程中的死鎖和解除鎖問題

    Mysql關(guān)于進程中的死鎖和解除鎖問題

    Mysql 經(jīng)常會遇到語句或者存儲過程長時間沒有反應(yīng),大概率就是掛掉了,或者死鎖了,這篇文章主要介紹了Mysql關(guān)于進程中的死鎖和解除鎖問題,本文給大家介紹的非常詳細,需要的朋友可以參考下
    2023-07-07
  • MySQL兩個查詢?nèi)绾魏喜⒊梢粋€結(jié)果詳解

    MySQL兩個查詢?nèi)绾魏喜⒊梢粋€結(jié)果詳解

    利用union關(guān)鍵字,可以給出多條select語句,并將它們的結(jié)果組合成單個結(jié)果集,下面這篇文章主要給大家介紹了關(guān)于MySQL兩個查詢?nèi)绾魏喜⒊梢粋€結(jié)果的相關(guān)資料,文中通過圖文介紹的非常詳細,需要的朋友可以參考下
    2022-08-08
  • MySQL中主鍵為0與主鍵自排約束的關(guān)系詳解(細節(jié))

    MySQL中主鍵為0與主鍵自排約束的關(guān)系詳解(細節(jié))

    這篇文章主要給大家介紹了關(guān)于MySQL中主鍵為0與主鍵自排約束的關(guān)系的相關(guān)資料,主要介紹的是其中的一些非常細的細節(jié),對大家學(xué)習(xí)或者使用mysql具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2018-05-05
  • Mysql誤刪數(shù)據(jù)解決方案及kill語句原理

    Mysql誤刪數(shù)據(jù)解決方案及kill語句原理

    這篇文章主要介紹了Mysql誤刪數(shù)據(jù)解決方案及kill語句原理,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下
    2020-09-09
  • 詳解MySQL中的外鍵約束問題

    詳解MySQL中的外鍵約束問題

    這篇文章主要介紹了詳解MySQL中的外鍵約束問題,針對在MySQL中使用InnoDB表的情況,需要的朋友可以參考下
    2015-07-07

最新評論