Java+Swing+mysql5实现超市商品管理系统

  • 一、系统介绍
    • 1.系统功能
    • 2.环境配置
    • 3.数据库
    • 4.工程截图
  • 二、系统展示
    • 1.登录页
      • 1.1登录成功
    • 2.添加商品
    • 3.商品列表
    • 4.查询商品
    • 5.修改商品
    • 6.删除商品
    • 7.退出系统
  • 三、部分代码
    • DBConn.java
    • LoginFrm.java
    • Goods.java
  • 四、其他
    • 获取源码

一、系统介绍

1.系统功能

1.登录系统
2.添加商品
3.商品列表
4.查询商品
5.修改商品
6.删除商品
7.退出系统

2.环境配置

JDK版本:1.8
Mysql:5.7

3.数据库

/*
SQLyog Enterprise v12.09 (64 bit)
MySQL - 5.7.14 : Database - swing_goods
*********************************************************************
*//*!40101 SET NAMES utf8 */;/*!40101 SET SQL_MODE=''*/;/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
CREATE DATABASE /*!32312 IF NOT EXISTS*/`swing_goods` /*!40100 DEFAULT CHARACTER SET latin1 */;USE `swing_goods`;/*Table structure for table `goods` */DROP TABLE IF EXISTS `goods`;CREATE TABLE `goods` (`id` int(11) NOT NULL AUTO_INCREMENT,`name` varchar(20) DEFAULT NULL,`number` int(11) DEFAULT NULL,`price` decimal(10,2) DEFAULT '0.00',PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;/*Data for the table `goods` */insert  into `goods`(`id`,`name`,`number`,`price`) values (1,'农夫山泉矿泉水',100,'3.00'),(2,'优乐美奶茶',200,'10.00');/*Table structure for table `user` */DROP TABLE IF EXISTS `user`;CREATE TABLE `user` (`id` int(11) NOT NULL AUTO_INCREMENT,`username` varchar(20) DEFAULT NULL,`userpass` varchar(20) DEFAULT NULL,PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;/*Data for the table `user` */insert  into `user`(`id`,`username`,`userpass`) values (1,'admin','123456');/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

4.工程截图

二、系统展示

1.登录页

1.1登录成功

2.添加商品

3.商品列表

4.查询商品

5.修改商品

6.删除商品



7.退出系统

三、部分代码

DBConn.java

package cn.com.util;import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;public class DBConn {private static String driverName = "com.mysql.jdbc.Driver";private static String url = "jdbc:mysql://localhost:3306/swing_goods?characterEncoding=utf8";private static String userName = "root";private static String password = "root";private Connection conn;private Statement stmt;public DBConn() {try {Class.forName(driverName);} catch (ClassNotFoundException e) {e.printStackTrace();}}/*** 连接数据库* * @return* @throws SQLException*/public Connection getConnection() throws SQLException {return DriverManager.getConnection(url, userName, password);}/*** 释放资源*/public void close() {try {if (conn != null) {conn.close();}if (stmt != null) {stmt.close();}} catch (SQLException e) {e.printStackTrace();}}}

LoginFrm.java

package cn.com.view;import java.awt.EventQueue;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.border.EmptyBorder;import cn.com.dao.UserDao;
import cn.com.model.User;
import cn.com.util.DBConn;
import cn.com.util.StringUtil;public class LoginFrm extends JFrame {private JPanel contentPane;private JTextField username_txt;private JPasswordField password_txt;private DBConn db=new DBConn();private UserDao userDao=new UserDao();/*** Launch the application.*/public static void main(String[] args) {EventQueue.invokeLater(new Runnable() {public void run() {try {LoginFrm frame = new LoginFrm();frame.setVisible(true);} catch (Exception e) {e.printStackTrace();}}});}/*** Create the frame.*/public LoginFrm() {setResizable(false);setTitle("\u7BA1\u7406\u5458\u767B\u5F55");setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);setBounds(100, 100, 450, 300);contentPane = new JPanel();contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));setContentPane(contentPane);JLabel lblNewLabel = new JLabel("\u8D85\u5E02\u5546\u54C1\u7BA1\u7406\u7CFB\u7EDF");lblNewLabel.setFont(new Font("微软雅黑", Font.PLAIN, 24));JLabel lblNewLabel_1 = new JLabel("\u7528\u6237\u540D:");JLabel lblNewLabel_2 = new JLabel("\u5BC6\u7801:");username_txt = new JTextField();username_txt.setColumns(10);password_txt = new JPasswordField();JButton btnNewButton = new JButton("\u767B\u5F55");btnNewButton.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {LoginActionPerformed(e);}});JButton btnNewButton_1 = new JButton("\u91CD\u7F6E");btnNewButton_1.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {ResetActionPerformed(e);}});GroupLayout gl_contentPane = new GroupLayout(contentPane);gl_contentPane.setHorizontalGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING).addGroup(gl_contentPane.createSequentialGroup().addGap(114).addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING).addGroup(gl_contentPane.createSequentialGroup().addComponent(lblNewLabel_2).addPreferredGap(ComponentPlacement.UNRELATED).addComponent(password_txt, 224, 224, 224).addPreferredGap(ComponentPlacement.RELATED)).addGroup(gl_contentPane.createSequentialGroup().addComponent(lblNewLabel_1).addPreferredGap(ComponentPlacement.RELATED).addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING).addComponent(lblNewLabel).addComponent(username_txt, 226, 226, 226)))).addGap(48)).addGroup(Alignment.LEADING, gl_contentPane.createSequentialGroup().addGap(153).addComponent(btnNewButton).addPreferredGap(ComponentPlacement.UNRELATED).addComponent(btnNewButton_1).addContainerGap(157, Short.MAX_VALUE)));gl_contentPane.setVerticalGroup(gl_contentPane.createParallelGroup(Alignment.LEADING).addGroup(gl_contentPane.createSequentialGroup().addGap(50).addComponent(lblNewLabel).addGap(18).addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE).addComponent(lblNewLabel_1).addComponent(username_txt, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)).addGap(18).addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE).addComponent(lblNewLabel_2).addComponent(password_txt, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)).addGap(18).addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE).addComponent(btnNewButton).addComponent(btnNewButton_1)).addContainerGap(60, Short.MAX_VALUE)));contentPane.setLayout(gl_contentPane);this.setLocationRelativeTo(null);}protected void ResetActionPerformed(ActionEvent e) {// TODO Auto-generated method stubthis.username_txt.setText("");this.password_txt.setText("");}protected void LoginActionPerformed(ActionEvent e) {// TODO Auto-generated method stubString username=this.username_txt.getText();String password=new String(this.password_txt.getPassword());if(StringUtil.isEmpty(username)) {JOptionPane.showMessageDialog(null, "用户名不能为空");return;}if(StringUtil.isEmpty(password)) {JOptionPane.showMessageDialog(null, "密码不能为空");return;}User user=new User(username,password);Connection conn=null;try {conn=db.getConnection();User current_user=userDao.login(conn,user);if(current_user!=null) {JOptionPane.showMessageDialog(null, "登录成功");dispose();new MainFrm().setVisible(true);}else {JOptionPane.showMessageDialog(null, "用户名或者密码错误");}} catch (Exception e1) {// TODO Auto-generated catch blocke1.printStackTrace();}}
}

Goods.java

package cn.com.model;public class Goods {private Integer id; private String name;private Integer number;private Float price;public Goods() {super();// TODO Auto-generated constructor stub}public Goods(String name, Integer number,  Float price) {super();        this.name = name;this.number = number;this.price = price;}public Integer getId() {return id;}public void setId(Integer id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}public Integer getNumber() {return number;}public void setNumber(Integer number) {this.number = number;}public Float getPrice() {return price;}public void setPrice(Float price) {this.price = price;}}

四、其他

获取源码

点击以下链接获取源码,数据库文件在swing_goods.sql文件里面。
Java+Swing+Mysql实现超市商品管理系统源码

Java+Swing+Mysql实现通讯录管理系统源码

Java+Swing+Mysql实现图书管理系统源码

Java+Swing+mysql5实现超市商品管理系统相关推荐

  1. 计算机毕业设计SSM超市商品管理系统【附源码数据库】

    项目运行 环境配置: Jdk1.8 + Tomcat7.0 + Mysql + HBuilderX(Webstorm也行)+ Eclispe(IntelliJ IDEA,Eclispe,MyEclis ...

  2. [附源码]Python计算机毕业设计超市商品管理系统

    项目运行 环境配置: Pychram社区版+ python3.7.7 + Mysql5.7 + HBuilderX+list pip+Navicat11+Django+nodejs. 项目技术: dj ...

  3. Java---设计【超市商品管理系统】

    超市商品管理系统 设计要求 实现代码 运行结果 设计要求 设计超市商品管理系统,实现以下功能: (1)输入5种商品名称.价格和数量: (2)统计商品的总价格及平均价格,最高价和最低价: (3)按价格降 ...

  4. Eclipse+Java+Swing+Mysql实现员工信息管理系统

    目录 一.系统介绍 1.开发环境 2.技术选型 3.系统功能 4.数据库 二.系统展示 1.登录系统 2.主页面 3.部门管理 4.职位管理 5.员工管理 三.部分代码 AdminDao.java D ...

  5. (附源码)计算机毕业设计ssm超市商品管理系统

    项目运行 环境配置: Jdk1.8 + Tomcat7.0 + Mysql + HBuilderX(Webstorm也行)+ Eclispe(IntelliJ IDEA,Eclispe,MyEclis ...

  6. Eclipse+Java+Swing+Mysql实现学生信息管理系统

    目录 一.系统介绍 1.开发环境 2.技术选型 3.系统功能 4.数据库 二.系统展示 1.注册系统 2.登录系统 3.系统主页面 4.添加学生信息 5.修改学生信息 6.查询学生信息 三.部分代码 ...

  7. 【java毕业设计】基于java+swing+CS的图书销售管理系统GUI设计与实现(毕业论文+程序源码)——图书销售管理系统

    基于java+swing+CS的图书销售管理系统GUI设计与实现(毕业论文+程序源码) 大家好,今天给大家介绍基于java+swing+CS的图书销售管理系统GUI设计与实现,文章末尾附有本毕业设计的 ...

  8. C++语言课程设计——超市商品管理系统

    一.问题要求 使用C++语言编写程序,模拟超市的商品销售.进货.库存等一些列增删改查的功能 二.源码与安装 源码下载链接 百度网盘链接:点击跳转,提取码:BigG 安装教程 下载上述链接的文件,是一个 ...

  9. MFC超市商品管理系统学生成绩管理系统学生信息管理系统通讯录管理系统图书管理系统

    MFC超市商品管理系统学生成绩管理系统学生信息管理系统通讯录管理系统图书管理系统 序号 题目 数组保存数据 文件保存数据 数据库保存数据 1 超市商品管理系统 2 学生成绩管理系统 3 学生信息管理系 ...

最新文章

  1. 报错解决:InvalidArgumentError: Received a label value of 101 which is outside the valid range of [0, 101
  2. vaddin使用技巧
  3. CentOS中使用Docker来部署Tomcat
  4. OpenGL normalviewer普通视图的实例
  5. 如何正确选择仓储物流供应商?
  6. 计算机病毒及其防治评课,区初中信息技术教研活动公开课评课感想
  7. 10月15日发布?一加7T系列概念图曝光:依旧后置竖排相机模组
  8. PostgreSQL 为什么不要滥用unlogged table hash index
  9. 032-IDUtils 工具类模板
  10. java mybatis cms_java cms系统 springmvc mybatis
  11. 关闭Dynamipsgui的自动更新
  12. 改变linux环境背景色,改变Linux 字体和背景颜色
  13. 用Java实现后台统计图
  14. 百度未授权使用地图API,可能是因为您提供的密钥不是有效的百度LBS开放平台密钥.
  15. 解读MT7620A上的DTS文件
  16. Untiy导入package时报错
  17. 树莓派hwclock命令参数及用法详解--linux显示/设置硬件时钟命令
  18. 2014522420145238《信息安全系统设计基础》实验三
  19. asp源码爱好者福利,asp调用微信扫一扫代码,用asp写的调用微信内置扫一扫功能源码下载
  20. 《论系统工程》--钱学森

热门文章

  1. 当遗传学遇上Excel格式化,科学家们也只能认输
  2. 【Python爬虫】 爬取京东商品图片并下载
  3. ltspice语言中文_LTspice下载|LTspice(电路仿真软件)下载v4.14r 中文免费版 附安装教程 - 欧普软件下载...
  4. java金花_炸金花绝对大小计算、比较及排序算法(Java),包含花色参与和不参与大小比较...
  5. STM32与RC522简单公交卡系统的设计
  6. Elasticsearch 脚本安全使用指南
  7. hihoCoder#1082 : 然而沼跃鱼早就看穿了一切(做题总结)
  8. 云XR平台支持沉浸式体验应用快速落地
  9. 新型勒索软件PYSA浅析
  10. 第一代计算机网络那一年,奔腾电脑是哪一年上市的?