基于java+mysql的swing+mysql花店鲜花销售信息管理系统进销存(java+swing+mysql)

基于java+mysql的swing+mysql花店鲜花销售信息管理系统进销存(java+swing+mysql)

私信源码获取及调试交流

运行环境

Java≥8、MySQL≥5.7

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

基于java的Swing+MySQL花店鲜花销售信息管理系统进销存(java+swing+mysql)

管理员

admin 123456

普通员工

user 123456


	public StockInputManagerJPanel(User user) {
		this.user = user;

		backgroundPanel = new JPanel(new BorderLayout());

		initTopPanel();
		initTablePanel();
	}

	// 初始化顶部面板
	public void initTopPanel() {

		topPanel = new JPanel(new BorderLayout());

		initToolPanel();
		initSearchPanel();

		backgroundPanel.add(topPanel, "North");

	}

	// 初始化工具面板
	public void initToolPanel() {

		toolPanel = new JPanel();
		// 工具图标
		Icon icon_add = new ImageIcon("image/add.png");
		tool_add = new JLabel(icon_add);
		tool_add.setToolTipText("新建入库单");
		tool_add.addMouseListener(this);

		Icon icon_modify = new ImageIcon("image/modify.png");
		tool_modify = new JLabel(icon_modify);
		tool_modify.setToolTipText("修改入库单");
		tool_modify.addMouseListener(this);

		Icon icon_delete = new ImageIcon("image/delete.png");
		tool_delete = new JLabel(icon_delete);
		tool_delete.setToolTipText("删除入库单");
		tool_delete.addMouseListener(this);

		toolPanel.add(tool_add);
		// 隐藏入库单修改操作
		/* toolPanel.add(tool_modify); */
		toolPanel.add(tool_delete);

		topPanel.add(toolPanel, "West");

	}

			for (Object[] object : list_warehouse) {
				select_warehouse.addItem(new Item((String) object[0], (String) object[1]));
			}
		}
		select_warehouse.addActionListener(this);

		// 标签
		label_category = new JLabel("商品种类");
		label_warehouse = new JLabel("所属仓库");

		searchPanel.add(label_category);
		searchPanel.add(select_category);
		searchPanel.add(label_warehouse);
		searchPanel.add(select_warehouse);

		topPanel.add(searchPanel, "East");

	}

	// 初始化数据表格面板
	public void initTablePanel() {

		String conditionParams[] = { "全部", "全部" };
		String params[] = { "商品id", "花的名称", "价格(元)", "产地", "所属分类", "所属仓库", "库存", "仓库id", "分类id" };
		GoodsServiceImpl goodsService = new GoodsServiceImpl();
		Vector<Vector> vector = new Vector<Vector>();
		try {
			vector = goodsService.selectByCondition(conditionParams);
		} catch (Exception e) {
			e.printStackTrace();
		}

		baseTableModule = new BaseTableModule(params, vector);

		table = new JTable(baseTableModule);
		Tools.setTableStyle(table);
		DefaultTableColumnModel dcm = (DefaultTableColumnModel) table.getColumnModel();// 获取列模型
		dcm.getColumn(0).setMinWidth(0); // 将第一列的最小宽度、最大宽度都设置为0
		dcm.getColumn(0).setMaxWidth(0);
		dcm.getColumn(7).setMinWidth(0); // 将第8列的最小宽度、最大宽度都设置为0
		dcm.getColumn(7).setMaxWidth(0);
		dcm.getColumn(8).setMinWidth(0); // 将第9列的最小宽度、最大宽度都设置为0
		dcm.getColumn(8).setMaxWidth(0);

		jScrollPane = new JScrollPane(table);
		Tools.setJspStyle(jScrollPane);
	// 鼠标点击事件
	@Override
	public void mouseClicked(MouseEvent e) {
		if (e.getSource() == tool_add) {
			new AddGoodsJFrame(this);
		} else if (e.getSource() == tool_modify) {
			int row = table.getSelectedRow();
			if (row < 0) {
				JOptionPane.showMessageDialog(null, "请选择商品");
			} else {
				new ModifyGoodsJFrame(this, table, row);
			}

		} else if (e.getSource() == tool_delete) {
			int row = table.getSelectedRow();
			if (row < 0) {
				JOptionPane.showMessageDialog(null, "请选择商品");
			} else {
				String id = (String) table.getValueAt(row, 0);
				int result = JOptionPane.showConfirmDialog(null, "是否确定删除?", "用户提示", JOptionPane.YES_NO_OPTION);
				if (result == 0) {
					String[] params = { id };
					GoodsServiceImpl goodsService = new GoodsServiceImpl();
					try {
						int tempresult = goodsService.deleteById(params);
						if (tempresult > 0) {
							JOptionPane.showMessageDialog(null, "商品删除成功!");
							refreshTablePanel();
						}
					} catch (Exception e1) {
						e1.printStackTrace();
					}
				}
			}
		}

	}

	// 鼠标划入事件
	@Override
	public void mouseEntered(MouseEvent e) {
		if (e.getSource() == tool_add) {
			tool_add.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
		} else if (e.getSource() == tool_modify) {
			tool_modify.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
		} else if (e.getSource() == tool_delete) {
			tool_delete.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
		}
	}

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

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

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

		buttonPanel.add(button_modify);
	}

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

			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 = (String) table.getValueAt(selectedRow, 0);

public class StockOrderServiceImpl implements StockOrderService {
	
	//条件查询入库单
	@Override
	public Vector<Vector> selectStockInputByCondition(Object[] paraArray) throws Exception {
		Vector<Vector> rows = new Vector<Vector>();
		BaseDaoImpl dao = new BaseDaoImpl();
		StringBuilder sqlBuilder = new StringBuilder(
				"select s.id,s.bill_no,g.name,s.amount,c.name,w.name,u.name,c.id,w.id "
						+ " from stock_order s,goods g,user u,category c,warehouse w "
						+ " where s.handler_id=u.id and s.goods_id=g.id and s.category_id=c.id and s.warehouse_id=w.id and s.sign='0' and s.del_flag='0' and g.del_flag='0' and c.del_flag=0 and w.del_flag='0' ");
		String name = paraArray[0].toString().trim();
		if (!name.isEmpty()) {
			sqlBuilder.append(" and g.name like '%" + paraArray[0] + "%' ");
		}
		if (!"全部".equals(paraArray[1])) {
			sqlBuilder.append(" and s.category_id='" + paraArray[1] + "' ");
		}
		if (!"全部".equals(paraArray[2])) {
			sqlBuilder.append(" and s.warehouse_id='" + paraArray[2] + "' ");
		}
		if (!"全部".equals(paraArray[3])) {
			sqlBuilder.append(" and s.handler_id='" + paraArray[3] + "' ");
		}
		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 void mouseReleased(MouseEvent arg0) {
		// TODO Auto-generated method stub

	}

}

/**
 * 用户管理功能面板
 */
public class UserManagerJPanel implements MouseListener {

	// 定义全局组件
	ImagePanel backgroundPanel;
	JPanel contentPanel, labelPanel, textPanel, buttonPanel;
	JTextField username = new JTextField(10);
	JPasswordField password = new JPasswordField(10);
	JTextField identify = new JTextField(10);
	JButton button_modify, button_save;

	// 定义大小变量
	int width;
	int height;

	// 定义用户对象
				baseData.setText("<html><font color='black'>" + "花的数据" + "</font>&nbsp;</html>");
			}
		} else if (e.getSource() == purchase_sale_stock) {
			if (sign_purchase_sale_stock == 0) {
				purchase_sale_stock.setText("<html><font color='black'>" + "销售信息管理" + "</font>&nbsp;</html>");
			}
		} else if (e.getSource() == userManager) {
			if (sign_userManager == 0) {
				userManager.setText("<html><font color='black'>" + "用户管理" + "</font>&nbsp;</html>");
			}
		}

	}

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

	}

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

	}

	@Override
	public void actionPerformed(ActionEvent e) {

	}
	
}


public class ModifyGoodsJFrame 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_modify;

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

	// 表格对象
	JTable table;
	int selectedRow;
	GoodsManagerJPanel parentPanel;

	public ModifyGoodsJFrame(GoodsManagerJPanel parentPanel, JTable table, int selectedRow) {
		this.table = table;
	JPanel backgroundPanel, labelPanel, contentPanel, buttonPanel;
	JLabel label_billno, label_name, label_amount, label_category, label_warehouse, label_handler;
	JTextField billno, name, amount, category, warehouse, handler;
	JButton button_modify;

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

	// 表格对象
	JTable table;
	int selectedRow;
	StockOutputManagerJPanel parentPanel;

	public ModifyStockOutputJFrame(StockOutputManagerJPanel parentPanel, JTable table, int selectedRow) {
		this.table = table;
		this.selectedRow = selectedRow;
		this.parentPanel = parentPanel;

		initBackgroundPanel();

		this.add(backgroundPanel);

		this.setTitle("修改出库单");
		this.setSize(480, 270);
		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面板
	JLabel tool_add, tool_modify, tool_delete;

	public WarehouseManagerJPanel() {

		backgroundPanel = new JPanel(new BorderLayout());

		initTopPanel();
		initTablePanel();
	}

	// 初始化顶部面板
	public void initTopPanel() {

		topPanel = new JPanel(new BorderLayout());

		initToolPanel();

		backgroundPanel.add(topPanel, "North");

	}

	// 初始化工具面板
	public void initToolPanel() {

		toolPanel = new JPanel();
		// 工具图标
		Icon icon_add = new ImageIcon("image/add.png");
		tool_add = new JLabel(icon_add);
		tool_add.setToolTipText("新建仓库");
		tool_add.addMouseListener(this);

		Icon icon_modify = new ImageIcon("image/modify.png");
		tool_modify = new JLabel(icon_modify);
		tool_modify.setToolTipText("修改仓库");
		tool_modify.addMouseListener(this);

		Icon icon_delete = new ImageIcon("image/delete.png");
		tool_delete = new JLabel(icon_delete);
		tool_delete.setToolTipText("删除仓库");
		tool_delete.addMouseListener(this);

		toolPanel.add(tool_add);
		toolPanel.add(tool_modify);
		toolPanel.add(tool_delete);
			e.printStackTrace();
		}
		select_warehouse.addItem(new Item("全部", "全部"));
		if (list_warehouse != null) {
			for (Object[] object : list_warehouse) {
				select_warehouse.addItem(new Item((String) object[0], (String) object[1]));
			}
		}
		select_warehouse.addActionListener(this);

		// 标签
		label_name = new JLabel("商品名称");
		label_category = new JLabel("商品种类");
		label_warehouse = new JLabel("所属仓库");

		searchPanel.add(label_name);
		searchPanel.add(input_name);
		searchPanel.add(label_category);
		searchPanel.add(select_category);
		searchPanel.add(label_warehouse);
		searchPanel.add(select_warehouse);

		topPanel.add(searchPanel, "East");

	}

	// 初始化数据表格面板
	public void initTablePanel() {

		String conditionParams[] = { "", "全部", "全部", "全部" };
		if (user != null) {
			if ("0".equals(user.getIdentity())) {
				conditionParams[3] = user.getId();
			}
		}
		String params[] = { "入库单id", "订单号", "商品名称", "入库数量", "所属分类", "所属仓库", "经手人", "分类id", "仓库id" };
		StockOrderServiceImpl stockOrderService = new StockOrderServiceImpl();
		Vector<Vector> vector = new Vector<Vector>();
		try {
			vector = stockOrderService.selectStockInputByCondition(conditionParams);
		} catch (Exception e) {
			e.printStackTrace();
		}
		if (e.getSource() == home) {
			if (sign_home == 0) {
				home.setText("<html><font color='black'>" + "首页" + "</font>&nbsp;</html>");
			}
		} else if (e.getSource() == baseData) {
			if (sign_baseData == 0) {
				baseData.setText("<html><font color='black'>" + "花的数据" + "</font>&nbsp;</html>");
			}
		} else if (e.getSource() == purchase_sale_stock) {
			if (sign_purchase_sale_stock == 0) {
				purchase_sale_stock.setText("<html><font color='black'>" + "销售信息管理" + "</font>&nbsp;</html>");
			}
		} else if (e.getSource() == userManager) {
			if (sign_userManager == 0) {
				userManager.setText("<html><font color='black'>" + "用户管理" + "</font>&nbsp;</html>");
			}
		}

	}

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

	}

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

	}

	@Override
	public void actionPerformed(ActionEvent e) {

	}
	
}

		BaseDaoImpl dao = new BaseDaoImpl();
		StringBuilder sqlBuilder = new StringBuilder(
				"select s.id,s.bill_no,g.name,s.amount,c.name,w.name,u.name,c.id,w.id "
						+ " from stock_order s,goods g,user u,category c,warehouse w "
						+ " where s.handler_id=u.id and s.goods_id=g.id and s.category_id=c.id and s.warehouse_id=w.id and s.sign='0' and s.del_flag='0' and g.del_flag='0' and c.del_flag=0 and w.del_flag='0' ");
		String name = paraArray[0].toString().trim();
		if (!name.isEmpty()) {
			sqlBuilder.append(" and g.name like '%" + paraArray[0] + "%' ");
		}
		if (!"全部".equals(paraArray[1])) {
			sqlBuilder.append(" and s.category_id='" + paraArray[1] + "' ");
		}
		if (!"全部".equals(paraArray[2])) {
			sqlBuilder.append(" and s.warehouse_id='" + paraArray[2] + "' ");
		}
		if (!"全部".equals(paraArray[3])) {
			sqlBuilder.append(" and s.handler_id='" + paraArray[3] + "' ");
		}
		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;
	}
	
	//通过id逻辑删除入库单
	@Override
	public int deleteStockInputById(Object[] paraArray) throws Exception {
		BaseDaoImpl dao = new BaseDaoImpl();
		int result = 0;
		result = dao.update("update stock_order set del_flag='1' where id=?", paraArray);
		return result;
	}

public class AddStockOutputJFrame extends JFrame implements MouseListener, ActionListener {

	// 定义全局组件
	JPanel backgroundPanel, labelPanel, contentPanel, buttonPanel;
	JLabel label_name, label_amount, label_category, label_warehouse;
	JComboBox select_name, select_category, select_warehouse;;
	JTextField amount;
	JButton button_add;

	// 商品库存
	double goods_stock;

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

	// 表格对象
	JTable table;
	int selectedRow;
	StockOutputManagerJPanel parentPanel;

	// 用户对象
	User user;

	public AddStockOutputJFrame(User user, StockOutputManagerJPanel parentPanel) {
		this.user = user;
		this.parentPanel = parentPanel;

		initBackgroundPanel();

		this.add(backgroundPanel);

		this.setTitle("添加出库单");
		this.setSize(480, 270);
		this.setVisible(true);
		this.setLocationRelativeTo(null);
		this.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
	}

public class GoodsManagerJPanel implements ActionListener, MouseListener {

	// 定义全局组件
	JPanel backgroundPanel, topPanel, toolPanel, searchPanel, tablePanel;
	JComboBox select_category, select_warehouse;
	BaseTableModule baseTableModule;
	JTable table;
	JScrollPane jScrollPane;
	JLabel label_category, label_warehouse, tool_add, tool_modify, tool_delete;

	public GoodsManagerJPanel() {

		backgroundPanel = new JPanel(new BorderLayout());

		initTopPanel();
		initTablePanel();
	}

	// 初始化顶部面板
	public void initTopPanel() {

		topPanel = new JPanel(new BorderLayout());

	}
	
	//通过id修改入库单
	@Override
	public int updateStockInputById(Object[] paraArray) throws Exception {
		BaseDaoImpl dao = new BaseDaoImpl();
		int result = 0;
		result = dao.update("update stock_order set amount=? where id=?", paraArray);
		return result;
	}
	
	//插入入库单
	@Override
	public int insertStockInput(Object[] paraArray) throws Exception {
		BaseDaoImpl dao = new BaseDaoImpl();
		int result = 0;
		result = dao.insert(
				"insert into stock_order(id,bill_no,handler_id,warehouse_id,category_id,amount,goods_id,sign)  values(?,?,?,?,?,?,?,'0')",
				paraArray);
		return result;
	}
	
	//条件查询出库单
	@Override
	public Vector<Vector> selectStockOutputByCondition(Object[] paraArray) throws Exception {
		Vector<Vector> rows = new Vector<Vector>();
		BaseDaoImpl dao = new BaseDaoImpl();
		StringBuilder sqlBuilder = new StringBuilder(
				"select s.id,s.bill_no,g.name,s.amount,c.name,w.name,u.name,c.id,w.id "
						+ " from stock_order s,goods g,user u,category c,warehouse w "
						+ " where s.handler_id=u.id and s.goods_id=g.id and s.category_id=c.id and s.warehouse_id=w.id and s.sign='1' and s.del_flag='0' and g.del_flag='0' and c.del_flag=0 and w.del_flag='0' ");
		String name = paraArray[0].toString().trim();
		if (!name.isEmpty()) {
			sqlBuilder.append(" and g.name like '%" + paraArray[0] + "%' ");
		}
		if (!"全部".equals(paraArray[1])) {
			sqlBuilder.append(" and s.category_id='" + paraArray[1] + "' ");
		}
		if (!"全部".equals(paraArray[2])) {
			sqlBuilder.append(" and s.warehouse_id='" + paraArray[2] + "' ");
		}
		if (!"全部".equals(paraArray[3])) {
			sqlBuilder.append(" and s.handler_id='" + paraArray[3] + "' ");
		}
		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);

public class StockInputManagerJPanel implements ActionListener, MouseListener, DocumentListener {

	// 定义全局组件
	JPanel backgroundPanel, topPanel, toolPanel, searchPanel, tablePanel;
	JComboBox select_category, select_warehouse;
	JTextField input_name;
	BaseTableModule baseTableModule;
	JTable table;
	JScrollPane jScrollPane;
	JLabel label_name, label_category, label_warehouse, tool_add, tool_modify, tool_delete;

	// 用户对象
	User user;

	public StockInputManagerJPanel(User user) {
		this.user = user;

		backgroundPanel = new JPanel(new BorderLayout());

		initTopPanel();
		initTablePanel();
	}


}

public class ModifyStockInputJFrame extends JFrame implements MouseListener {

	// 定义全局组件
	JPanel backgroundPanel, labelPanel, contentPanel, buttonPanel;
	JLabel label_billno, label_name, label_amount, label_category, label_warehouse, label_handler;
	JTextField billno, name, amount, category, warehouse, handler;
	JButton button_modify;

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

	// 表格对象
	JTable table;
	int selectedRow;
	StockInputManagerJPanel parentPanel;

	public ModifyStockInputJFrame(StockInputManagerJPanel parentPanel, JTable table, int selectedRow) {
		this.table = table;
		this.selectedRow = selectedRow;
		this.parentPanel = parentPanel;

		initBackgroundPanel();

		this.add(backgroundPanel);

		this.setTitle("修改入库单");
		this.setSize(480, 270);
		this.setVisible(true);

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

  • 9
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

java毕业

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值