Java+Swing+Mysql实现超市管理系统

一、系统介绍

1.开发环境

操作系统:Win10

开发工具 :IDEA2018

JDK版本:jdk1.8

数据库:Mysql8.0

2.技术选型

Java+Swing+Mysql

3.功能模块

4.系统功能

1.系统登录登出

管理员可以登录、退出系统

2.商品信息管理

管理员可以对商品信息进行查询、添加、修改、删除等操作。

3.出库信息管理

管理员可以对出库信息进行查询、添加、修改、删除等操作。

4.入库信息管理

管理员可以对入库信息进行查询、添加、修改、删除等操作。

5.客户信息管理

管理员可以对客户信息进行查询、添加、修改、删除等操作。

6.供应商信息管理

管理员可以对供应商信息进行查询、添加、修改、删除等操作。

5.工程结构

二、系统展示

1.登录页面

2.主页面

3.商品展示

4.商品新增

5.出库展示

6.出库新增

7.入库展示

8.入库新增

9.客户展示

10.客户新增

11.供应商展示

12.供应商新增

13.关于我们

三、部分代码

AdminDao


package com.sjsq.dao;import java.util.ArrayList;
import java.util.List;import com.sjsq.model.Admin;
import com.sjsq.utils.DBUtil;/*** 管理员登录*/
public class AdminDao {/*** 登录** @param username* @param password* @return* @throws Exception*/public boolean login(String username, String password) throws Exception {List<Object> paramList = new ArrayList<>();paramList.add(username);paramList.add(password);Admin admin = DBUtil.getObject("select * from t_admin where username=? and password=?", paramList, Admin.class);if (admin != null) {return true;}return false;}}

CustomerDao


package com.sjsq.dao;import java.util.ArrayList;
import java.util.List;import com.sjsq.model.Customer;
import com.sjsq.utils.DBUtil;
import com.sjsq.utils.StringUtil;/*** 客户信息操作*/
public class CustomerDao {/*** 查询所有客户** @return* @throws Exception*/public List<Customer> getAll() throws Exception {return DBUtil.getQueryList("select * from t_customer order by id asc", Customer.class);}/*** 条件查询** @param name* @return* @throws Exception*/public List<Customer> search(String name) throws Exception {List<Object> paramList = new ArrayList<>();StringBuffer sb = new StringBuffer("select * from t_customer where 1=1");if (!StringUtil.isEmpty(name)) {sb.append(" and name like ?");paramList.add("%" + name + "%");}sb.append(" order by id asc");return DBUtil.getQueryList(sb.toString(), paramList, Customer.class);}/*** 保存客户信息** @param customer* @return* @throws Exception*/public int save(Customer customer) throws Exception {List<Object> paramList = new ArrayList<>();paramList.add(customer.getName());paramList.add(customer.getPhone());paramList.add(customer.getAddress());return DBUtil.execute("insert into t_customer(name,phone,address) values(?,?,?)", paramList);}/*** 更新客户信息** @param customer* @return* @throws Exception*/public int update(Customer customer) throws Exception {List<Object> paramList = new ArrayList<>();paramList.add(customer.getName());paramList.add(customer.getPhone());paramList.add(customer.getAddress());paramList.add(customer.getId());return DBUtil.execute("update t_customer set name=?,phone=?,address=? where id=?", paramList);}/*** 根据id查询客户信息** @param id* @return* @throws Exception*/public Customer getById(int id) throws Exception {List<Object> paramList = new ArrayList<>();paramList.add(id);return DBUtil.getObject("select * from t_customer where id=?", paramList, Customer.class);}/*** 删除** @param id* @return* @throws Exception*/public int delete(int id) throws Exception {List<Object> paramList = new ArrayList<>();paramList.add(id);return DBUtil.execute("delete from t_customer where id=?", paramList);}}

StringUtil


package com.sjsq.utils;import java.util.regex.Matcher;
import java.util.regex.Pattern;/*** 字符串转化类*/
public class StringUtil {//数据库字段驼峰命名转换private static Pattern linePattern = Pattern.compile("_(\\w)");private static Pattern humpPattern = Pattern.compile("[A-Z]");// 判断字符串为空public static boolean isEmpty(String str) {if ("".equals(str) || str == null) {return true;} else {return false;}}// 判断字符串不为空public static boolean isNotEmpty(String str) {if (!"".equals(str) && str != null) {return true;} else {return false;}}/*** 下划线转驼峰*/public static String lineToHump(String str) {str = str.toLowerCase();Matcher matcher = linePattern.matcher(str);StringBuffer sb = new StringBuffer();while (matcher.find()) {matcher.appendReplacement(sb, matcher.group(1).toUpperCase());}matcher.appendTail(sb);return sb.toString();}/*** 驼峰转下划线(单写法,效率低于{@link #humpToLine2(String)})*/public static String humpToLine(String str) {return str.replaceAll("[A-Z]", "_$0").toLowerCase();}/*** 驼峰转下划线,效率比上面高*/public static String humpToLine2(String str) {Matcher matcher = humpPattern.matcher(str);StringBuffer sb = new StringBuffer();while (matcher.find()) {matcher.appendReplacement(sb, "_" + matcher.group(0).toLowerCase());}matcher.appendTail(sb);return sb.toString();}}

LoginFrame


package com.sjsq.view;import com.sjsq.dao.AdminDao;
import com.sjsq.utils.StringUtil;import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;/*** 登录系统*/
public class LoginFrame extends JFrame {private JPanel contentPane;private JTextField unameText;private JPasswordField pwdText;private AdminDao userDao = new AdminDao();/*** 主函数*/public static void main(String[] args) {EventQueue.invokeLater(new Runnable() {public void run() {try {LoginFrame frame = new LoginFrame();frame.setVisible(true);} catch (Exception e) {e.printStackTrace();}}});}/*** 创建窗体*/public LoginFrame() {setTitle("超市商品信息管理系统");setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);setBounds(100, 100, 450, 300);setLocationRelativeTo(null);contentPane = new JPanel();contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));setContentPane(contentPane);contentPane.setLayout(null);JLabel lblNewLabel = new JLabel("系统登录");lblNewLabel.setFont(new Font("宋体", Font.PLAIN, 25));lblNewLabel.setBounds(177, 32, 108, 25);contentPane.add(lblNewLabel);JLabel lblNewLabel_1 = new JLabel("账号:");lblNewLabel_1.setBounds(98, 89, 54, 15);contentPane.add(lblNewLabel_1);JLabel lblNewLabel_2 = new JLabel("密码:");lblNewLabel_2.setBounds(98, 152, 54, 15);contentPane.add(lblNewLabel_2);unameText = new JTextField();unameText.setBounds(148, 86, 166, 21);contentPane.add(unameText);unameText.setColumns(10);pwdText = new JPasswordField();pwdText.setBounds(148, 149, 166, 21);contentPane.add(pwdText);JButton btnNewButton = new JButton("登录");btnNewButton.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {String username = unameText.getText();String password = pwdText.getText();if (StringUtil.isEmpty(username)) {JOptionPane.showMessageDialog(contentPane, "请输入账号", "系统提示", JOptionPane.WARNING_MESSAGE);return;}if (StringUtil.isEmpty(password)) {JOptionPane.showMessageDialog(contentPane, "请输入密码", "系统提示", JOptionPane.WARNING_MESSAGE);return;}try {// 登录账号验证boolean flag = userDao.login(username, password);if (flag) {//跳转主界面JOptionPane.showMessageDialog(contentPane, "登录成功!");MainFrame main = new MainFrame();main.setVisible(true);// 释放所有本机屏幕资源dispose();} else {JOptionPane.showMessageDialog(contentPane, "用户名密码错误!", "系统提示", JOptionPane.WARNING_MESSAGE);return;}} catch (Exception e1) {e1.printStackTrace();JOptionPane.showMessageDialog(contentPane, "登录异常:" + e1.getMessage(), "系统提示", JOptionPane.WARNING_MESSAGE);return;}}});btnNewButton.setBounds(146, 202, 76, 23);contentPane.add(btnNewButton);JButton btnNewButton_1 = new JButton("退出");btnNewButton_1.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {dispose();}});btnNewButton_1.setBounds(237, 202, 76, 23);contentPane.add(btnNewButton_1);}}

CustomerAddFrame


package com.sjsq.view;import com.sjsq.dao.CustomerDao;
import com.sjsq.model.Customer;
import com.sjsq.utils.StringUtil;import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;/*** 新增客户信息类*/
public class CustomerAddFrame extends JFrame {// 定义内容面板private JPanel contentPane;// 定义姓名文本private JTextField nameText;private JTextField phoneText;private JTextField addressText;private CustomerDao customerDao = new CustomerDao();/*** Create the frame.*/public CustomerAddFrame() {setTitle("新增客户信息");setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);setBounds(100, 100, 353, 351);setLocationRelativeTo(null);contentPane = new JPanel();contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));setContentPane(contentPane);contentPane.setLayout(null);JLabel lblNewLabel = new JLabel("客户名称:");lblNewLabel.setBounds(29, 34, 92, 15);contentPane.add(lblNewLabel);// 创建空白文本nameText = new JTextField();// 设置位置大小nameText.setBounds(113, 31, 182, 21);// 添加到面板contentPane.add(nameText);// 设置内容宽度nameText.setColumns(15);JLabel lblNewLabel_1 = new JLabel("联系电话:");lblNewLabel_1.setBounds(29, 84, 92, 15);contentPane.add(lblNewLabel_1);phoneText = new JTextField();phoneText.setBounds(113, 81, 182, 21);contentPane.add(phoneText);phoneText.setColumns(10);JLabel lblNewLabel_5 = new JLabel("客户地址:");lblNewLabel_5.setBounds(29, 148, 91, 15);contentPane.add(lblNewLabel_5);addressText = new JTextField();addressText.setBounds(113, 145, 182, 21);contentPane.add(addressText);addressText.setColumns(10);JButton btnNewButton = new JButton("保存");btnNewButton.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {// 获取输入的信息String name = nameText.getText();String phone = phoneText.getText();String address = addressText.getText();// 判断输入为空,弹出相应提示if (StringUtil.isEmpty(name)) {JOptionPane.showMessageDialog(contentPane, "请输入客户名称", "系统提示", JOptionPane.WARNING_MESSAGE);return;}if (StringUtil.isEmpty(phone)) {JOptionPane.showMessageDialog(contentPane, "请输入联系电话", "系统提示", JOptionPane.WARNING_MESSAGE);return;}if (StringUtil.isEmpty(address)) {JOptionPane.showMessageDialog(contentPane, "请输入客户地址", "系统提示", JOptionPane.WARNING_MESSAGE);return;}// 创建对象Customer customer = new Customer();// 保存信息到对象中customer.setName(name);customer.setPhone(phone);customer.setAddress(address);try {// 新增信息customerDao.save(customer);} catch (Exception e1) {// TODO Auto-generated catch blocke1.printStackTrace();JOptionPane.showMessageDialog(contentPane, "保存异常:" + e1.getMessage(), "系统提示", JOptionPane.WARNING_MESSAGE);return;}JOptionPane.showMessageDialog(contentPane, "保存成功!");dispose();}});btnNewButton.setBounds(113, 215, 74, 23);contentPane.add(btnNewButton);JButton btnNewButton_1 = new JButton("取消");btnNewButton_1.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {dispose();}});btnNewButton_1.setBounds(220, 215, 74, 23);contentPane.add(btnNewButton_1);}}

四、其他

1.更多系统

Java+Swing系统系列实现

Java+Swing实现斗地主游戏

Java+Swing实现图书管理系统

Java+Swing实现医院管理系统

Java+Swing实现考试管理系统

Java+Swing实现酒店管理系统

Java+Swing实现超市管理系统

Java+Swing实现电影购票系统

Java+Swing实现仓库管理系统-1

Java+Swing实现仓库管理系统-2

Java+Swing实现进销存管理系统

Java+Swing实现自助取款机系统

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

Java+Swing实现停车场管理系统

Java+Swing实现学生信息管理系统-1

Java+Swing实现学生信息管理系统-2

Java+Swing实现学生宿舍管理系统

Java+Swing实现学生选课管理系统

Java+Swing实现学生成绩管理系统

Java+Swing实现学校教材管理系统

Java+Swing实现学校教务管理系统

Java+Swing实现企业人事管理系统

Java+Swing实现电子相册管理系统

Java+Swing实现超市管理系统-TXT存储数据

Java+Swing实现自助取款机系统-TXT存储数据

Java+Swing实现宠物商店管理系统-TXT存储数据

Java+JSP系统系列实现

Java+JSP实现学生图书管理系统

Java+JSP实现学生信息管理系统

Java+JSP实现用户信息管理系统

Java+JSP实现教师信息管理系统

Java+JSP实现学生宿舍管理系统

Java+JSP实现商品信息管理系统

Java+JSP实现宠物信息管理系统

Java+JSP实现学生成绩管理系统

Java+Servlet系统系列实现

Java+Servlet+JSP实现航空订票系统

Java+Servlet+JSP实现新闻发布系统

Java+Servlet+JSP学生宿舍管理系统

Java+Servlet+JSP实现图书管理系统

Java+Servlet+JSP实现停车场管理系统

Java+Servlet+JSP实现房屋租赁管理系统

Java+Servlet+JSP实现学生信息管理系统

Java+Servlet+JSP实现学生选课管理系统

Java+Servlet+JSPl实现学生选课签到系统

Java+Servlet+JSP实现宠物诊所管理系统

Java+Servlet+JSP实现学生成绩管理系统-1

Java+Servlet+JSP实现学生成绩管理系统-2

Java+SSM系统系列实现

Java+SSM+JSP实现网上考试系统

Java+SSM+JSP实现宠物商城系统

Java+SSM+JSP实现超市管理系统

Java+SSM+JSP实现学生成绩管理系统

Java+SSM+JSP实现学生信息管理系统

Java+SSM+JSP实现药品信息管理系统

Java+SSM+JSP实现汽车信息管理系统

Java+SSM+Jspl实现商品信息管理系统

Java+SSM+JSP+Maven实现网上书城系统

Java+SSM+JSP+Maven实现学校教务管理系统

Java+SSH系统系列实现

Java+SSH+JSP实现在线考试系统

Java+SSH+JSP实现医院在线挂号系统

Java+Springboot系统系列实现

Java+Springboot+H-ui+Maven实现营销管理系统

Java+Springboot+Bootstrap+Maven实现网上商城系统

Java+Springboot+Bootstrap+Maven实现景区旅游管理系统

1.更多JavaWeb系统请关注专栏。

https://blog.csdn.net/helongqiang/category_10020130.html

2.更多JavaSwing系统请关注专栏。

https://blog.csdn.net/helongqiang/category_6229101.html

2.源码下载

sql在sql文件夹下面

系统账号信息如下,此处是管理员权限

账号:admin 密码:admin

下载地址:Java+Swing+Mysql实现超市管理系统

3.运行项目

关注B站:水坚石青

后期有更多干货视频推出!!!

Eclipse如何导入JavaSwing项目超详细教程

4.备注

如有侵权请联系我删除。

5.支持博主

如果您觉得此文对您有帮助,请点赞加关注加收藏。祝您生活愉快!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/199858.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Android画布Canvas绘制drawBitmap基于源Rect和目的Rect,Kotlin

Android画布Canvas绘制drawBitmap基于源Rect和目的Rect&#xff0c;Kotlin <?xml version"1.0" encoding"utf-8"?> <androidx.appcompat.widget.LinearLayoutCompat xmlns:android"http://schemas.android.com/apk/res/android"xmlns…

Cannot find module ‘node:url‘报错处理

在运行vite搭建的项目时&#xff0c;遇到Cannot find module node:url’报错。具体错误如图所示&#xff1a; 造成以上问题的原因是node版本较低。Vite 需要 Node.js 版本 14.18&#xff0c;16。 解决方案&#xff1a; 上面是通过nvm切换高版本node。 再次执行运行命令&…

基于Springboot的社区医院管理服务系统(有报告)。Javaee项目,springboot项目。

演示视频&#xff1a; 基于Springboot的社区医院管理服务系统&#xff08;有报告&#xff09;。Javaee项目&#xff0c;springboot项目。 项目介绍&#xff1a; 采用M&#xff08;model&#xff09;V&#xff08;view&#xff09;C&#xff08;controller&#xff09;三层体系…

如何保障Redis的安全性?

身份验证和访问控制&#xff1a; 认证密码&#xff08;requirepass&#xff09;&#xff1a; 在Redis配置文件中设置 requirepass 参数&#xff0c;要求客户端连接时提供密码。确保密码的复杂度&#xff0c;定期更新密码&#xff0c;以防泄漏。网络绑定&#xff08;bind&#x…

QLineEdit 的 InputMask掩码

QLineEdit 的 InputMask掩码 A&#xff1a;只能输入字母&#xff0c;且不可省略 a&#xff1a;只能输入字母&#xff0c;可以省略 N&#xff1a;只能输入 字母和数字&#xff0c;且不可省略 n&#xff1a;只能输入 字母和数字&#xff0c;可以省略 X&#xff1a;可以输入任意字…

如何写好一篇硬件经验总结文档

大家好,这里是大话硬件。 今天这篇文章想分享一个工作方法,主要用在如何写好一篇硬件问题总结文档上。 我们在工作中不可避免会碰到一些复杂的硬件问题,这些问题可能出现在项目研发过程中,也可能来自客户的反馈。 当困扰大家很久的棘手问题被解决完后,如果被总结成一篇…

C语言--每日选择题--Day36

第一题 1. 以下关于指针的说法,正确的是() A&#xff1a;int *const p 与 int const *p等价 B&#xff1a;const int *p 与 int *const p等价 C&#xff1a;const int *p 与 int const *p 等价 D&#xff1a;int *p[10] 与 int (*p)[10] 等价 答案及解析 C const 在*的左侧&…

代码随想录 509. 斐波那契数

题目 斐波那契数 &#xff08;通常用 F(n) 表示&#xff09;形成的序列称为 斐波那契数列 。该数列由 0 和 1 开始&#xff0c;后面的每一项数字都是前面两项数字的和。也就是&#xff1a; F(0) 0&#xff0c;F(1) 1 F(n) F(n - 1) F(n - 2)&#xff0c;其中 n > 1 给定…

后端架构的一些知识

目录 一.抖音 二.大型网站是如何管理海量的数据的 三.大型网站停机一天会造成多大损失 四.如何设计一套安全&#xff0c;健壮&#xff0c;可扩展&#xff0c;稳定性强的后端系统 五.如何在不影响原来代码的基础上进行功能更新 六.大型网站一年都不停机吗 七.线上业务出现…

缓存穿透、击穿、雪崩

缓存穿透&#xff1a; 指的是恶意用户或攻击者通过请求不存在于缓存和后端存储中的数据来使得所有请求都落到后端存储上&#xff0c;导致系统瘫痪。 解决方案&#xff1a; 通常包括使用布隆过滤器或者黑白名单等方式来过滤掉无效请求&#xff0c;以及在应用程序中加入缓存预热…

leetcode5 最长公共前缀三种python解法

14. 最长公共前缀 编写一个函数来查找字符串数组中的最长公共前缀。 如果不存在公共前缀&#xff0c;返回空字符串 ""。 示例 1&#xff1a; 输入&#xff1a;strs ["flower","flow","flight"] 输出&#xff1a;"fl"示…

SpringSecurity6 | 默认用户生成

SpringSecurity6 | 默认用户生成 ✅作者简介&#xff1a;大家好&#xff0c;我是Leo&#xff0c;热爱Java后端开发者&#xff0c;一个想要与大家共同进步的男人&#x1f609;&#x1f609; &#x1f34e;个人主页&#xff1a;Leo的博客 &#x1f49e;当前专栏&#xff1a; Java…

理解DuLinkList L中的“”引用符号

在C中&#xff0c;DuLinkList &L 这种形式的参数表示 L 是一个 DuLinkList 类型的引用。这里的 & 符号表示引用。 引用是C的一个特性&#xff0c;它提供了一种方式来访问已存在的变量的别名。当你对引用进行操作时&#xff0c;实际上是在操作它所引用的变量。如果你在…

CoreDNS实战(十)-kubernetes插件

CoreDNS作为现阶段k8s的默认DNS服务以及服务发现的重要一环&#xff0c;其内置的kubernetes插件可谓是举足轻重。本文主要讲解介绍CoreDNS内置的核心插件kubernetes的使用方式和适用场景。 CoreDNS的kubernetes插件的具体实现遵循k8s官方提供的标准指南Kubernetes DNS-Based S…

从0开始学Spring、Springboot总结笔记(持续更新中~)

文章目录 一.基于SpringBoot进行Web开发入门1.IDEA编译器中创建springboot工程扩展&#xff1a;如何解决pom.xml文件中“找不到Maven插件”的问题&#xff1f; 2.Springboot项目如何编写请求类和请求方法并启动访问编写请求类和请求方法启动Springboot访问 一些学习资源参考 一…

如何搭建eureka-server

在Spring Cloud项目的pom文件中添加eureka-server的starter依赖坐标 <project xmlns"http://maven.apache.org/POM/4.0.0" xmlns:xsi"http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation"http://maven.apache.org/POM/4.0.0 http://ma…

人工智能学习4(特征选择)

编译工具&#xff1a;PyCharm 有些编译工具在绘图的时候不需要写plt.show()或者是print就可以显示绘图结果或者是显示打印结果&#xff0c;pycharm需要&#xff08;matplotlib.pyplot&#xff09; 文章目录 编译工具&#xff1a;PyCharm 特征选择嵌入法特征选择练习&#xff…

云原生的 CI/CD 框架tekton - Trigger(二)

上一篇为大家详细介绍了tekton - pipeline&#xff0c;由于里面涉及到的概念比较多&#xff0c;因此需要好好消化下。同样&#xff0c;今天在特别为大家分享下tekton - Trigger以及案例演示&#xff0c;希望可以给大家提供一种思路哈。 文章目录 1. Tekton Trigger2. 工作流程3…

Linux高级系统编程中的系统调用

概念 是操作系统提供给用户使其可以操作内核提供服务的一组函数接口。 用户态和内核态&#xff1a; 引入 &#xff1a; 整个 计算机系统 的。好比你写 一个程序&#xff0c;但是因为你对 硬件操作 不熟悉&#xff0c;出现 问题&#xff0c;那么影响范围是多大&#xff1f;是整…

数据结构(超详细讲解!!)第二十六节 图(中)

1.存储结构 1.邻接矩阵 图的邻接矩阵表示法&#xff08;Adjacency Matrix&#xff09;也称作数组表示法。它采用两个数组来表示图&#xff1a; 一个是用于存储顶点信息的一维数组&#xff1b;另一个是用于存储图中顶点之间关联关系的二维数组&#xff0c;这个关联关系数组被…