购物系统 (GUI)

一、前言

1 研究背景

随着电子商务的快速发展,越来越多的消费者选择在网上购物。为了提高用户体验、提升交易效率和管理便捷性,许多企业和个人开始开发和使用各种类型的购物系统商城。而基于Java Swing的购物系统商城正是应运而生的一种应用。Java Swing作为一个强大的GUI工具包,为开发人员提供了丰富的图形用户界面组件,能够设计出直观、友好的用户界面,适用于开发各种类型的应用程序,包括购物系统商城。

2 目的和意义

基于Java Swing的购物系统商城的研究和开发具有重要的目的和意义:

提高用户体验:通过Java Swing提供的丰富图形用户界面组件,设计出直观、友好的用户界面,提高用户在购物过程中的体验和满意度。

  1. 提升交易效率:

购物系统商城能够提供便捷的商品浏览、选择、下单和支付功能,提升了交易效率,满足了消费者对便捷购物的需求。

  1. 管理便捷性:

购物系统商城能够对商品、订单、用户信息等进行有效管理,包括库存管理、订单管理、用户管理等,提高了商家对商城的管理效率。

  1. 技术应用和推广:

基于Java Swing的购物系统商城可以充分利用Java语言的跨平台特性,在不同的操作系统上运行,为电子商务的技术应用和推广提供了可能。

  1. 促进电子商务发展:

购物系统商城的研究和应用,有助于促进电子商务的发展,推动线上交易模式的普及和应用,促进经济的数字化转型。

因此,基于Java Swing的购物系统商城的研究和开发具有重要的现实意义和应用价值,能够提高用户体验、提升交易效率和管理便捷性,推动电子商务的发展。

3编程环境与工具

根据本系统体系结构特点和使用本系统的用户特点,编程环境与工具的配置如表1-1所示:

表1-1 开发环境表

Tab. 1-1 Development environment table

类别

标准配置

开发语言

Java

开发工具

Eclipse

开发环境

JDK 8.0

数据库

MySql 5.6

二、购物管理系统概述 

1主要业务流程

(1)用户及管理员登录流程图

对于系统的安全性的第一关,就是用户想要进入系统,必须通过登录窗口,输入自己的登录信息才可以进行登录,用户输入的信息准确无误后才可以进入到操作系统界面,进行功能模块的相对应操作,如果用户输入的信息不正确,则窗口出现提示框,用户登录失败,返回到第一步进行重新输入,

(2)信息添加流程

对于购物管理系统,需要随时添加所需要的数据信息,对于用户添加信息,需要根据添加界面,根据选框的内容进行填写所要添加的数据信息,信息输入完成后判断数据信息是否符合要求,符合要求则添加完成,用户所添加的信息不符合要求,则需要返回到第一步,重新输入数据信息,再进行判断操作,

(3)信息删除流程

不管是哪个用户角色进入到不通的系统操作界面,都可以进行不同的信息内容的操作功能,对用系统数据信息的删除,用户一旦将信息删除,那么该删除的数据信息将无法恢复,所以用户在对数据删除事,一定判断删除的内容是否是确定要删除的,确定无误后选择确定删除操作,如图3-3所示。

三、需求分析与设计

1 系统需求分析

基于Java Swing的购物系统商城是一个面向用户的在线购物平台,提供丰富的商品种类和便捷的商品管理功能。用户可以通过该系统浏览各种商品完成购买。

该商城包含以下主要特点:

  1. 商品种类丰富:

商城涵盖了多种商品种类,包括服装、电子产品、食品、家居用品等,满足用户不同领域的购物需求。

  1. 用户友好的界面设计:

商城提供了简洁直观的用户界面,用户可以方便地注册、登录、浏览商品、搜索商品,并将商品加入购物车进行购买。

2 数据库设计

ID

名称

类型

是否主键

解释

1

id

int

不能

编号

2

productName

varchar

不是主键

不能

产品

3

productTime

varchar

不是主键

不能

保质期

4

price

float

不是主键

不能

价格

5

productDesc

varchar

不是主键

不能

备注

6

productTypeId

int

不是主键

不能

类型id

此为商品表,包含商品类,包含商品编号,商品名称。

ID

名称

类型

是否主键

解释

1

id

int

不能

编号

2

productTypeName

varchar

不是主键

不能

类型名

3

productTypeDesc

varchar

不是主键

不能

备注

此为商品类型表,包含类型类,包含商品类型商品备注。

3 界面设计

  1. 首页

  1. 商城主功能

  1. 退出

四、归纳与总结

基于Java Swing的购物系统商城是一个功能强大的在线购物平台,具有丰富的商品种类和完善的商品管理功能。以下是对该商城的归纳总结:

  1. 商品种类丰富:

商城覆盖了多种商品种类,包括服装、电子产品、食品、家居用品等,满足用户在不同领域的购物需求。

  1. 商品管理功能完善:

管理员可以对商品进行添加、编辑、删除等操作,包括商品信息的管理和维护,确保商品信息的准确性和完整性。

  1. 用户友好的界面设计:

商城提供了简洁直观的用户界面,用户可以方便地注册、登录、浏览商品、搜索商品,并进行购买。

综上所述,基于Java Swing的购物系统商城通过丰富的商品种类和完善的商品管理功能,为用户提供了便捷、安全、高效的购物体验,同时也为管理员提供了便捷的商品管理和维护功能。这使得商城成为一个理想的购物平台,满足了用户的购物需求,提高了商品管理的效率。

相关代码

public class ProductManageInterFrm extends javax.swing.JInternalFrame {



Dbutil dbutil = new Dbutil();

ProductDao productDao = new ProductDao();

ProductTypeDao productTypeDao = new ProductTypeDao();



/** Creates new form ProductManageInterFrm */

public ProductManageInterFrm() {

initComponents();

this.setLocation(200, 50);

this.fillTable(new Product());

this.fillProductType("search");

this.fillProductType("modify");

}



private void fillProductType(String type) {

Connection con = null;

ProductType productType = null;

try {

con = dbutil.getCon();

ResultSet rs = productTypeDao.productTypeList(con,

new ProductType());



if ("search".equals(type)) {



productType = new ProductType();

productType.setProductTypeName("请选择....");

productType.setId(-1);

this.s_jcbProductType.addItem(productType);

}

while (rs.next()) {

productType = new ProductType();

productType.setId(rs.getInt("id"));

productType.setProductTypeName(rs.getString("productTypeName"));



if ("search".equals(type)) {

this.s_jcbProductType.addItem(productType);

} else if ("modify".equals(type)) {

this.jcb_productType.addItem(productType);

}

}
public ProductBuyInterFrm() {

initComponents();

this.setLocation(200, 20);

this.fillTable(new Product());

this.fillChosenTable();

this.fillProductType("search");

this.fillProductType("putInto");

}



private void fillProductType(String type) {

Connection con = null;

ProductType productType = null;

try {

con = dbutil.getCon();

ResultSet rs = productTypeDao.productTypeList(con,

new ProductType());



if ("search".equals(type)) {



productType = new ProductType();

productType.setProductTypeName("请选择....");

productType.setId(-1);

this.s_jcbProductType.addItem(productType);

}

while (rs.next()) {

productType = new ProductType();

productType.setId(rs.getInt("id"));

productType.setProductTypeName(rs.getString("productTypeName"));



if ("search".equals(type)) {

this.s_jcbProductType.addItem(productType);

} else if ("putInto".equals(type)) {

this.jcb_productType.addItem(productType);

}

}



} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

} finally {

try {

dbutil.closeCon(con);

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

}



private void fillTable(Product product) {

DefaultTableModel dtm = (DefaultTableModel) productTable.getModel();



dtm.setRowCount(0);//要把前面的数据释放掉

Connection con = null;

try {

con = dbutil.getCon();

ResultSet rs = productDao.productList(con, product);

while (rs.next()) {

Vector v = new Vector();

v.add(rs.getInt("id"));

v.add(rs.getString("productName"));

v.add(rs.getString("productTime"));

v.add(rs.getFloat("price"));

v.add(rs.getString("productDesc"));

v.add(rs.getString("productTypeName"));



dtm.addRow(v);

}

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

} finally {

try {

dbutil.closeCon(con);

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}



}
public class ProductAddInterFrm extends javax.swing.JInternalFrame {



Dbutil dbutil = new Dbutil();

ProductTypeDao productTypeDao = new ProductTypeDao();

ProductDao productDao = new ProductDao();



/** Creates new form ProductAddInterFrm */

public ProductAddInterFrm() {

initComponents();

this.setLocation(200, 50);

this.fillProductType();

if (this.jcb_ProductType.getItemCount() > 0) {



this.jcb_ProductType.setSelectedIndex(0);

}

}



private void fillProductType() {

Connection con = null;

ProductType productType = null;

try {

con = dbutil.getCon();

ResultSet rs = productTypeDao.productTypeList(con,

new ProductType());

while (rs.next()) {

productType = new ProductType();

productType.setId(rs.getInt("id"));

productType.setProductTypeName(rs.getString("productTypeName"));

this.jcb_ProductType.addItem(productType);

}

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

} finally {

try {

dbutil.closeCon(con);

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

}
public MainFrm() {

initComponents();

//设置最大 化

this.setExtendedState(JFrame.MAXIMIZED_BOTH);

}



/** This method is called from within the constructor to

 * initialize the form.

 * WARNING: Do NOT modify this code. The content of this method is

 * always regenerated by the Form Editor.

 */

//GEN-BEGIN:initComponents

// <editor-fold defaultstate="collapsed" desc="Generated Code">

private void initComponents() {



table = new javax.swing.JDesktopPane();

jMenuBar1 = new javax.swing.JMenuBar();

jMenu1 = new javax.swing.JMenu();

jMenu3 = new javax.swing.JMenu();

jmiProductTypeAdd = new javax.swing.JMenuItem();

jmiProductTypeModify = new javax.swing.JMenuItem();

jMenu4 = new javax.swing.JMenu();

jmiProductAdd = new javax.swing.JMenuItem();

jmiProductModify = new javax.swing.JMenuItem();

jmiExit = new javax.swing.JMenuItem();

jMenu2 = new javax.swing.JMenu();

jMenuItem6 = new javax.swing.JMenuItem();



setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

setTitle("\u5546\u57ce\u7cfb\u7edf\u4e3b\u754c\u9762");



jMenu1.setIcon(new javax.swing.ImageIcon(

"./images\\base.png")); // NOI18N

jMenu1.setText("\u57fa\u672c\u6570\u636e\u7ef4\u62a4");



jMenu3.setIcon(new javax.swing.ImageIcon(

"./images\\manager.gif")); // NOI18N

jMenu3.setText("\u5546\u54c1\u79cd\u7c7b\u7ba1\u7406");



jmiProductTypeAdd.setIcon(new javax.swing.ImageIcon(

"./images\\add.png"));public MainFrm() {

initComponents();

//设置最大 化

this.setExtendedState(JFrame.MAXIMIZED_BOTH);

}



/** This method is called from within the constructor to

 * initialize the form.

 * WARNING: Do NOT modify this code. The content of this method is

 * always regenerated by the Form Editor.

 */

//GEN-BEGIN:initComponents

// <editor-fold defaultstate="collapsed" desc="Generated Code">

private void initComponents() {



table = new javax.swing.JDesktopPane();

jMenuBar1 = new javax.swing.JMenuBar();

jMenu1 = new javax.swing.JMenu();

jMenu3 = new javax.swing.JMenu();

jmiProductTypeAdd = new javax.swing.JMenuItem();

jmiProductTypeModify = new javax.swing.JMenuItem();

jMenu4 = new javax.swing.JMenu();

jmiProductAdd = new javax.swing.JMenuItem();

jmiProductModify = new javax.swing.JMenuItem();

jmiExit = new javax.swing.JMenuItem();

jMenu2 = new javax.swing.JMenu();

jMenuItem6 = new javax.swing.JMenuItem();



setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

setTitle("\u5546\u57ce\u7cfb\u7edf\u4e3b\u754c\u9762");



jMenu1.setIcon(new javax.swing.ImageIcon(

"./images\\base.png")); // NOI18N

jMenu1.setText("\u57fa\u672c\u6570\u636e\u7ef4\u62a4");



jMenu3.setIcon(new javax.swing.ImageIcon(

"./images\\manager.gif")); // NOI18N

jMenu3.setText("\u5546\u54c1\u79cd\u7c7b\u7ba1\u7406");



jmiProductTypeAdd.setIcon(new javax.swing.ImageIcon(

"./images\\add.png"));

  • 6
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值