Swing/GUI企业进销存进货销售仓储管理系统-JAVA【毕业设计、快速开发、源码、开题报告】

 

功能介绍

部分功能模块代码

package org.rancode.module.view;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.GridLayout;
import java.awt.Toolkit;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.math.BigDecimal;
import java.util.List;
import java.util.UUID;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;

import org.jb2011.lnf.beautyeye.ch3_button.BEButtonUI;
import org.rancode.framework.util.Item;
import org.rancode.framework.util.MyFont;
import org.rancode.module.services.Impl.CategoryServiceImpl;
import org.rancode.module.services.Impl.GoodsServiceImpl;
import org.rancode.module.services.Impl.WarehouseServiceImpl;

public class AddGoodsJFrame extends JFrame implements MouseListener {

	// 定义全局组件
	JPanel backgroundPanel, labelPanel, contentPanel, buttonPanel;
	JLabel label_name, label_price, label_origin, label_stock, label_warehouse, label_category;
	JTextField name, price, origin, stock;
	JComboBox warehouse, category;
	JButton button_add;

	// 获得屏幕的大小
	final static int width = Toolkit.getDefaultToolkit().getScreenSize().width;
	final static int height = Toolkit.getDefaultToolkit().getScreenSize().height;

	// 父面板对象
	GoodsManagerJPanel parentPanel;

	public AddGoodsJFrame(GoodsManagerJPanel parentPanel) {
		this.parentPanel = parentPanel;

		initBackgroundPanel();

		this.add(backgroundPanel);

		this.setTitle("添加商品");
		this.setSize(640, 360);
		this.setVisible(true);
		this.setLocationRelativeTo(null);
		this.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
	}

	// 初始化背景面板
	public void initBackgroundPanel() {
		backgroundPanel = new JPanel(new BorderLayout());

		initContentPanel();
		initButtonPanel();
		initLabelPanel();

		backgroundPanel.add(labelPanel, "North");
		backgroundPanel.add(contentPanel, "Center");
		backgroundPanel.add(buttonPanel, "South");
	}

	// 初始化label面板
	public void initLabelPanel() {

		labelPanel = new JPanel();

		JLabel title = new JLabel("商品信息");
		title.setFont(MyFont.Static);

		labelPanel.add(title);
	}

	// 初始化商品信息面板
	public void initContentPanel() {
		contentPanel = new JPanel(new GridLayout(6, 2));

		label_name = new JLabel("商品名称", JLabel.CENTER);
		label_price = new JLabel("商品价格", JLabel.CENTER);
		label_origin = new JLabel("商品产地", JLabel.CENTER);
		label_stock = new JLabel("商品库存", JLabel.CENTER);
		label_warehouse = new JLabel("所属仓库", JLabel.CENTER);
		label_category = new JLabel("所属分类", JLabel.CENTER);

		name = new JTextField("");
		price = new JTextField("");
		origin = new JTextField("");
		stock = new JTextField("");

		// 商品种类下拉框
		category = new JComboBox();
		CategoryServiceImpl categoryService = new CategoryServiceImpl();
		List<Object[]> list_category = null;
		try {
			list_category = categoryService.selectAll();
		} catch (Exception e) {
			e.printStackTrace();
		}
		if (list_category != null) {
			int sign = 0;
			for (int i = 0; i < list_category.size(); i++) {
				String id = (String) list_category.get(i)[0];
				String name = (String) list_category.get(i)[1];
				category.addItem(new Item(id, name));
			}
		}

		// 仓库下拉框
		warehouse = new JComboBox();
		WarehouseServiceImpl warehouseService = new WarehouseServiceImpl();
		List<Object[]> list_warehouse = null;
		try {
			list_warehouse = warehouseService.selectAll();
		} catch (Exception e) {
			e.printStackTrace();
		}
		if (list_warehouse != null) {
			int sign = 0;
			for (int i = 0; i < list_warehouse.size(); i++) {
				String id = (String) list_warehouse.get(i)[0];
				String name = (String) list_warehouse.get(i)[1];
				warehouse.addItem(new Item(id, name));
			}
		}

		contentPanel.add(label_name);
		contentPanel.add(name);
		contentPanel.add(label_price);
		contentPanel.add(price);
		contentPanel.add(label_origin);
		contentPanel.add(origin);
		contentPanel.add(label_stock);
		contentPanel.add(stock);
		contentPanel.add(label_category);
		contentPanel.add(category);
		contentPanel.add(label_warehouse);
		contentPanel.add(warehouse);

	}

	// 初始化按钮面板
	public void initButtonPanel() {
		buttonPanel = new JPanel();

		button_add = new JButton("保存");
		button_add.setUI(new BEButtonUI().setNormalColor(BEButtonUI.NormalColor.lightBlue));
		button_add.setForeground(Color.white);
		button_add.setFont(MyFont.Static);
		button_add.addMouseListener(this);

		buttonPanel.add(button_add);
	}

	// 鼠标点击事件
	@Override
	public void mouseClicked(MouseEvent e) {
		if (e.getSource() == button_add) {

			String name_String = name.getText().trim();
			String price_String = price.getText().trim();
			String origin_String = origin.getText().trim();
			String stock_String = stock.getText().trim();

			if (name_String.isEmpty()) {
				JOptionPane.showMessageDialog(null, "请输入商品名称");
			} else if (price_String.isEmpty()) {
				JOptionPane.showMessageDialog(null, "请输入商品价格");
			} else if (origin_String.isEmpty()) {
				JOptionPane.showMessageDialog(null, "请输入商品产地");
			} else if (stock_String.isEmpty()) {
				JOptionPane.showMessageDialog(null, "请输入商品库存");
			} else {
				int result = 0;
				double price_double = Double.valueOf(price_String);
				BigDecimal price_decimal = BigDecimal.valueOf(price_double);
				double stock_double = Double.valueOf(stock_String);
				String warehouse_id = ((Item) warehouse.getSelectedItem()).getKey();
				String category_id = ((Item) category.getSelectedItem()).getKey();
				String id = UUID.randomUUID().toString().replaceAll("-", "");
				Object[] params = { id, name_String, price_decimal, origin_String, stock_double, warehouse_id,
						category_id };
				GoodsServiceImpl goodsService = new GoodsServiceImpl();
				try {
					result = goodsService.insertById(params);
				} catch (Exception e1) {
					e1.printStackTrace();
				}
				if (result > 0) {
					JOptionPane.showMessageDialog(null, "添加商品成功");
					this.setVisible(false);
					parentPanel.refreshTablePanel();
				}
			}
		}

	}

	@Override
	public void mouseEntered(MouseEvent arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void mouseExited(MouseEvent arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void mousePressed(MouseEvent arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void mouseReleased(MouseEvent arg0) {
		// TODO Auto-generated method stub

	}

}
package org.rancode.module.services.Impl;

import java.util.List;
import java.util.Vector;

import org.rancode.module.dao.Impl.BaseDaoImpl;
import org.rancode.module.services.GoodsService;

public class GoodsServiceImpl implements GoodsService {
	
	//条件查询商品
	@Override
	public Vector<Vector> selectByCondition(Object[] paraArray) throws Exception {
		Vector<Vector> rows = new Vector<Vector>();
		BaseDaoImpl dao = new BaseDaoImpl();
		StringBuilder sqlBuilder = new StringBuilder(
				"select g.id,g.name,g.price,g.origin,c.name as categoryName,w.name as warehouseName, g.stock,w.id as warehouseId,c.id as categoryId "
						+ "from goods g,warehouse w,category c "
						+ "where 1=1 and g.del_flag='0' and w.del_flag='0' and c.del_flag='0' and g.warehouse_id=w.id and g.category_id=c.id ");
		if (!"全部".equals(paraArray[0])) {
			sqlBuilder.append(" and g.category_id='" + paraArray[0] + "'");
		}
		if (!"全部".equals(paraArray[1])) {
			sqlBuilder.append(" and g.warehouse_id='" + paraArray[1] + "'");
		}
		String sql = sqlBuilder.toString();
		List<Object[]> list = dao.select(sql, 9, null);
		if (!list.isEmpty()) {
			for (Object[] object : list) {
				Vector temp = new Vector<String>();
				for (int i = 0; i < object.length; i++) {
					temp.add(object[i]);
				}
				rows.add(temp);
			}
		}

		return rows;
	}
	
	//逻辑删除商品
	@Override
	public int deleteById(Object[] paraArray) throws Exception {
		BaseDaoImpl dao = new BaseDaoImpl();
		int result = 0;
		result = dao.update("update goods set del_flag='1' where id=?", paraArray);
		return result;
	}
	
	//通过id修改销售单
	@Override
	public int updateById(Object[] paraArray) throws Exception {
		BaseDaoImpl dao = new BaseDaoImpl();
		int result = 0;
		result = dao.update("update goods set name=?,price=?,origin=?,stock=?,warehouse_id=?,category_id=? where id=?",
				paraArray);
		return result;
	}
	
	//插入销售单
	@Override
	public int insertById(Object[] paraArray) throws Exception {
		BaseDaoImpl dao = new BaseDaoImpl();
		int result = 0;
		result = dao.insert(
				"insert into goods(id,name,price,origin,stock,warehouse_id,category_id,del_flag)  values(?,?,?,?,?,?,?,'0')",
				paraArray);
		return result;
	}
	
	//查询所有销售单
	@Override
	public List selectAll() throws Exception {
		BaseDaoImpl dao = new BaseDaoImpl();
		String sql = "select id,name from goods where 1=1 and del_flag='0' ";
		List<Object[]> list = dao.select(sql, 2, null);
		return list;
	}
	
	//通过id查询销售单
	@Override
	public List selectById(Object[] paraArray) throws Exception {
		BaseDaoImpl dao = new BaseDaoImpl();
		String sql = "select c.id,c.name,w.id,w.name,g.stock " + "from goods g,category c,warehouse w "
				+ "where g.category_id=c.id and g.warehouse_id=w.id and g.del_flag='0' and c.del_flag='0' and w.del_flag='0' and g.id=?";
		List<Object[]> list = dao.select(sql, 5, paraArray);
		return list;
	}
	
	//通过id修改库存
	@Override
	public int updateStockById(Object[] paraArray) throws Exception {
		BaseDaoImpl dao = new BaseDaoImpl();
		int result = 0;
		result = dao.update("update goods set stock=stock+? where id=?", paraArray);
		return result;
	}

}

论文目录

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
(1)选择“基础信息管理”/“客户信息管理”按钮,在弹出的窗体中进行对客户信息添加、修改以及删除操作。 (2)选择“基础信息管理”/“商品信息管理”按钮,在弹出的窗体中进行对商品信息添加、修改以及删除操作。 (3)选择“基础信息管理”/“供应商信息管理”按钮,在弹出的窗体中进行对供应商信息添加、修改以及删除操作。 (4)选择“进货管理”/“进货单”按钮,在弹出的窗体中进行添加进货单、商品入库信息操作。 (5)选择“进货管理”/“进货退货”按钮,在弹出的窗体中进行添加退货信息操作。 (6)选择“销售管理”/“销售单”按钮,在弹出的窗体中进行添加商品销售信息操作。 (7)选择“销售管理”/“销售退货”按钮,在弹出的窗体中进行添加商品退货信息操作。 (8)选择“查询统计”/“客户信息查询”按钮,在弹出的窗体中进行对客户信息的查询操作。 (9)选择“查询统计”/“商品信息查询”按钮,在弹出的窗体中进行对商品信息的查询操作。 (10)选择“查询统计”/“供应商信息查询”按钮,在弹出的窗体中进行对供应商信息的查询操作。 (11)选择“查询统计”/“销售信息查询”按钮,在弹出的窗体中进行对销售信息进行查询操作。 (12)选择“查询统计”/“销售退货查询”按钮,在弹出的窗体中进行对销售退货信息的查询操作。 (13)选择“查询统计”/“入库查询”按钮,在弹出的窗体中进行对商品入库信息的查询操作。 (14)选择“查询统计”/“入库退货查询”按钮,在弹出的窗体中进行对入库商品退货的信息查询操作。 (15)选择“查询统计”/“销售排行”按钮,在弹出的窗体中进行对销售信息排行查询操作。 (16)选择“库存管理”/“库存盘点”按钮,在弹出的窗体中进行查看商品的库存的品种数、剩余数量等信息操作。 (17)选择“库存管理”/“价格调整”按钮,在弹出的窗体中进行对商品价格的调整操作。 (18)选择“系统管理”/“操作员管理”按钮,在弹出的窗体中进行对操作员信息的添加、修改以及删除操作。 (19)选择“系统管理”/“更改密码”按钮,在弹出的窗体中进行对操作员的密码修改操作。 (20)选择“系统管理”/“权限管理”按钮,在弹出的窗体中进行对用户的权限设置操作。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值