今天为大家分享一个java语言的汽车销售管理系统,目前系统已经完成了初步功能,后续会进一步完善。整个系统界面漂亮,有完整得源码,希望大家可以喜欢。喜欢的帮忙点赞和关注。一起编程、一起进步
开发环境
开发语言为Java,开发环境Eclipse或者IDEA都可以。数据库采用:MySQL。运行主程序,或者执行打开JAR文件即可以运行本程序。
系统框架
利用JDK自带的SWING框架开发,不需要安装第三方JAR包。MySQL数据库,纯窗体模式,直接运行Main文件即可以。同时带有详细得设计文档
主要功能
运行方法
1 运行Main.java文件
2 程序出现汽车销售系统的登陆的面板
系统主要功能
汽车销售管理系统主要有系统管理员、销售员、采购员、仓管员、财务员
1 系统管理员拥有全部功能,其功能包括:
客户信息管理
车辆信息管理
供应商管理
进货管理
销售管理
报表管理
库存管理
系统管理
2 销售员用户的功能:
销售管理
3 采购员具备的功能:
进货管理
4仓管员:
进货管理
盘点管理
5 财务员:
报表管理,销售金额和利润相关数据的统计
实现效果
关键代码
/**
*
*/
package frame;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Image;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRootPane;
import javax.swing.JTabbedPane;
import javax.swing.UIManager;
import javax.swing.border.BevelBorder;
import javax.swing.border.EmptyBorder;
import common.Tools;
/**
* 主窗体 @ CarSale
*
* @author chenwei 2015-4-13 上午9:27:50
* @version 1.0
*/
public class MainJFrame extends JFrame {
Font font = new Font("微软雅黑", 0, 15);
public static final int WIDTH = 980;// 设置窗体宽度
public static final int HEIGHT = 600;// 设置窗体高度
Container c = null;// 初始化面板容器
JPanel bg_panel;
public static JButton jb_cus = null;
public static String role;
public static int id;
public static String uname;
public static JLabel jl_user;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
public static JLabel jl = null;
public static JLabel jl_uid = null;
public static JLabel jl_fzuid = null;
public static JLabel jl_uname = null;// 登陆人名字
JButton jb_car = null;
JButton jb_gong = null;
/**
* 主窗体构造方法
*/
public MainJFrame(String role, int id, String uname) {
this.role = role;
this.id = id;
this.uname = uname;
setUndecorated(true);
setIconImage(Tools.getImage("LOGO.jpg"));
this.setTitle("蓝天汽车销售管理系统"); // 创建窗体对象
// this.setIconImage(Tools.getImage("LOGO.jpg"));
this.setResizable(false);// 设置窗体不能被改变
Dimension dm = Toolkit.getDefaultToolkit().getScreenSize();
// this.getRootPane().setWindowDecorationStyle(JRootPane.QUESTION_DIALOG);
// this.addComponentListener(new FrameListener()); // 添加窗体事件监听器
c = this.getContentPane();
c.setLayout(new BorderLayout()); // 设置布局管理器
this.setLocationRelativeTo(null);// 默认设置窗口位置为中间
this.getRootPane().setWindowDecorationStyle(JRootPane.QUESTION_DIALOG);
this.setBounds((dm.width - WIDTH) / 2, (dm.height - HEIGHT) / 2, WIDTH,
HEIGHT); // 设置窗体位置和大小
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); // 设置窗体默认的关闭方式
JTabbedPane navigationPanel = createNavigationPanel(); // 创建导航面板
this.getContentPane().add(navigationPanel, BorderLayout.NORTH); // 添加导航面板到窗体中
bg_panel = new JPanel();
JLabel bg_label = new JLabel(Tools.getIcon("zhuchuangti.jpg"));
bg_panel.add(bg_label, new Integer(Integer.MIN_VALUE));
this.add(bg_panel, BorderLayout.CENTER);
// Image img = Tools.getImage("logo.png");// 显示LOGO
// this.setIconImage(img);
/**
* 鼠标设置图片
*/
Toolkit tk = Toolkit.getDefaultToolkit();
Image img1 = Tools.getImage("shubiao.png");
Cursor cu = tk.createCustomCursor(img1, new Point(5, 5), "stick");
// Cursor cu1=new Cursor(Cursor.HAND_CURSOR);
// setCursor(cu);
// this.setIconImage(img);
// setUndecorated(true);
// this.setIconImage(img1);
this.setCursor(cu); // panel 也可以是其他组件
new ThreadTime().start();
this.setVisible(true); // 显示窗体
addWindowListener(new MyWindowListener());
}
/**
* 创建导航面板的方法
*/
private JTabbedPane createNavigationPanel() {
JTabbedPane tabbedPane = new JTabbedPane();
tabbedPane.setFocusable(false);
tabbedPane.setBorder(new EmptyBorder(0, 0, 0, 0));// 去除边框
tabbedPane.setBackground(new Color(132, 159, 184));
tabbedPane.setBorder(new BevelBorder(BevelBorder.RAISED));
/**
* JLable
*/
// 放置当前时间面板
jl = new JLabel();
jl.setBounds(WIDTH - 405, 5, 160, 25);
jl.setFont(font);
//
// 工号面板
jl_uid = new JLabel("工号:");
jl_uid.setBounds(WIDTH - 235, 5, 60, 25);
jl_uid.setFont(font);
c.add(jl_uid);
// 放置工号面板
jl_fzuid = new JLabel();
jl_fzuid.setBounds(WIDTH - 195, 5, 60, 25);
jl_fzuid.setText(id + "");
jl_fzuid.setFont(font);
c.add(jl_fzuid);
c.add(jl);
// 放置名字面板
jl_uname = new JLabel();
jl_uname.setBounds(WIDTH - 125, 5, 60, 25);
jl_uname.setFont(font);
jl_uname.setText(uname);
System.out.println("uname" + uname);
c.add(jl_uname);
jl_user = new JLabel();
jl_user.setText(role);
jl_user.setBounds(WIDTH - 70, 5, 120, 25);
jl_user.setFont(font);
c.add(jl_user);
/**
* // 基础信息管理面板
*/
final JPanel baseManagePanel = new JPanel(); // 基础信息管理面板
baseManagePanel.setBackground(new Color(160,192,213));
baseManagePanel.setLayout(new BoxLayout(baseManagePanel,
BoxLayout.X_AXIS));
jb_cus = new JButton(Tools.getIcon("kehuxinxiguanli.png"));
jb_cus.setBorder(new EmptyBorder(0, 0, 0, 0));// 去除边框
jb_cus.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new CusFrame(MainJFrame.this, true);
}
});
baseManagePanel.add(jb_cus);
baseManagePanel.add(jb_cus, "KeHuGuanLi");
jb_cus.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// new CusFrame();// 客户信息管理窗体
}
});
jb_car = new JButton(Tools.getIcon("cheliangxinxiguanli.png"));
jb_car.setBorder(new EmptyBorder(0, 0, 0, 0));// 去除边框
jb_car.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new CarFrame(MainJFrame.this, true);
}
});
baseManagePanel.add(jb_car);
baseManagePanel.add(jb_car, "ShangPinGuanLi");
jb_car.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// new CarFrame();// 车辆信息管理窗体
}
});
jb_gong = new JButton(Tools.getIcon("gongyingshangxinxiguanli.png"));
jb_gong.setBorder(new EmptyBorder(0, 0, 0, 0));// 去除边框
jb_gong.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new ProvideFrame(MainJFrame.this, true);
}
});
baseManagePanel.add(jb_gong);
baseManagePanel.add(jb_gong, "KeHuGuanLi");
jb_gong.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// new ProvideFrame();// 供货商信息管理窗体
}
});
/**
* 库存管理面板
*/
JPanel depotManagePanel = new JPanel(); // 库存管理面板
depotManagePanel.setBackground(new Color(160,192,213));
depotManagePanel.setLayout(new BoxLayout(depotManagePanel,
BoxLayout.X_AXIS));
JButton jb_pandian = new JButton(Tools.getIcon("kucunchaxun.png"));
depotManagePanel.add(jb_pandian);
jb_pandian.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new StorageFrame(MainJFrame.this, true);
}
});
jb_pandian.setBorder(new EmptyBorder(0, 0, 0, 0));// 去除边框
JButton jb_jgtz = new JButton(Tools.getIcon("jinxiaotongji.png"));
depotManagePanel.add(jb_jgtz);
jb_jgtz.setBorder(new EmptyBorder(0, 0, 0, 0));// 去除边框
jb_jgtz.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new StatisticsFrame(MainJFrame.this, true);
}
});
JPanel sellManagePanel = new JPanel(); // 销售管理面板
sellManagePanel.setBackground(new Color(160,192,213));
sellManagePanel.setLayout(new BoxLayout(sellManagePanel,
BoxLayout.X_AXIS));
JButton jb_xsd = new JButton(Tools.getIcon("xiaoshoudan.png"));
jb_xsd.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new SaleFrame(MainJFrame.this, true);
}
});
sellManagePanel.add(jb_xsd);
jb_xsd.setBorder(new EmptyBorder(0, 0, 0, 0));// 去除边框
/**
* 报表面板
*/
JPanel searchStatisticPanel = new JPanel(); // 报表面板
searchStatisticPanel.setBounds(0, 0, 600, 41);
searchStatisticPanel.setName("searchStatisticPanel");
searchStatisticPanel.setBackground(new Color(160,192,213));
searchStatisticPanel.setLayout(new BoxLayout(searchStatisticPanel,
BoxLayout.X_AXIS));
JButton jb_sytx = new JButton(Tools.getIcon("shouyitongji.png"));
jb_sytx.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new ProfitFrame(MainJFrame.this, true);
}
});
searchStatisticPanel.add(jb_sytx);
jb_sytx.setBorder(new EmptyBorder(0, 0, 0, 0));// 去除边框
// JButton jb_xsph = new JButton(Tools.getIcon("销售排行.png"));
// searchStatisticPanel.add(jb_xsph);
// jb_xsph.setBorder(new EmptyBorder(0, 0, 0, 0));// 去除边框
/**
* 进货管理面板
*/
JPanel stockManagePanel = new JPanel(); // 进货管理面板
stockManagePanel.setBackground(new Color(160,192,213));
stockManagePanel.setLayout(new BoxLayout(stockManagePanel,
BoxLayout.X_AXIS));
JButton jb_jhd = new JButton(Tools.getIcon("jinhuodan.png"));
jb_jhd.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new OrderFrame(MainJFrame.this, true);
}
});
JButton jb_ddgl = new JButton(Tools.getIcon("dingdanshenhe.png"));
stockManagePanel.add(jb_jhd);
jb_ddgl.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new CheckFrame(MainJFrame.this, true);
}
});
jb_jhd.setBorder(new EmptyBorder(0, 0, 0, 0));// 去除边框
if ("总经理".equals(role)) {
stockManagePanel.add(jb_ddgl);
jb_ddgl.setBorder(new EmptyBorder(0, 0, 0, 0));// 去除边框
}
System.out.println("=============>" + role);
/**
* 系统管理
*/
JPanel systemManagePanel = new JPanel(); // 系统管理面板
systemManagePanel.setBackground(new Color(160,192,213));
systemManagePanel.setLayout(new BoxLayout(systemManagePanel,
BoxLayout.X_AXIS));
JButton jb_user = new JButton(Tools.getIcon("yonghuguanli.png"));
jb_user.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new UserFrame(MainJFrame.this, true);
}
});
systemManagePanel.add(jb_user);
jb_user.setBorder(new EmptyBorder(0, 0, 0, 0));// 去除边框
// 将所有面板添加到导航面板中
tabbedPane.addTab(" 基础信息管理 ", null, baseManagePanel, "基础信息管理");
tabbedPane.addTab(" 进货管理 ", null, stockManagePanel, "进货管理");
tabbedPane.addTab(" 销售管理 ", null, sellManagePanel, "销售管理");
tabbedPane.addTab(" 报表管理 ", null, searchStatisticPanel, "报表管理 ");
tabbedPane.addTab(" 库存管理 ", null, depotManagePanel, "库存管理");
tabbedPane.addTab(" 系统管理 ", null, systemManagePanel, "系统管理");
// if (!"管理员".equals(name)) {
// tabbedPane.remove(5);
// }
if (role.contains("采购员")) {
// tabbedPane.remove(5);
// tabbedPane.remove(4);
// tabbedPane.remove(3);
// tabbedPane.remove(2);
// tabbedPane.remove(0);
jb_cus.setVisible(false);
jb_car.setVisible(false);
jb_gong.setVisible(false);
tabbedPane.setEnabledAt(5, false);
tabbedPane.setEnabledAt(4, false);
tabbedPane.setEnabledAt(3, false);
tabbedPane.setEnabledAt(2, false);
tabbedPane.setEnabledAt(0, false);
}
if (role.contains("销售员")) {
// tabbedPane.remove(5);
// tabbedPane.remove(4);
// tabbedPane.remove(3);
// tabbedPane.remove(1);
// tabbedPane.remove(0);
jb_cus.setVisible(false);
jb_car.setVisible(false);
jb_gong.setVisible(false);
tabbedPane.setEnabledAt(5, false);
tabbedPane.setEnabledAt(4, false);
tabbedPane.setEnabledAt(3, false);
tabbedPane.setEnabledAt(1, false);
tabbedPane.setEnabledAt(0, false);
}
if (role.contains("财务员")) {
//
// tabbedPane.remove(5);
// tabbedPane.remove(4);
// tabbedPane.remove(2);
// tabbedPane.remove(1);
// tabbedPane.remove(0);
jb_cus.setVisible(false);
jb_car.setVisible(false);
jb_gong.setVisible(false);
tabbedPane.setEnabledAt(5, false);
tabbedPane.setEnabledAt(4, false);
tabbedPane.setEnabledAt(2, false);
tabbedPane.setEnabledAt(1, false);
tabbedPane.setEnabledAt(0, false);
}
if (role.contains("仓管员")) {
//
// tabbedPane.remove(5);
// tabbedPane.remove(4);
// tabbedPane.remove(2);
// tabbedPane.remove(1);
// tabbedPane.remove(0);
jb_cus.setVisible(false);
jb_car.setVisible(false);
jb_gong.setVisible(false);
tabbedPane.setEnabledAt(5, false);
tabbedPane.setEnabledAt(3, false);
tabbedPane.setEnabledAt(2, false);
tabbedPane.setEnabledAt(1, false);
tabbedPane.setEnabledAt(0, false);
}
if (role.contains("总经理")) {
//tabbedPane.setEnabledAt(5, false);
// tabbedPane.remove(5);
}
return tabbedPane;
}
// class MyWindowListener implements WindowListener{
// @Override
// public void windowClosing(WindowEvent e) {
// int flag=JOptionPane.showConfirmDialog(null, "确认退出?",
// "消息",JOptionPane.YES_NO_CANCEL_OPTION);
// if(flag==JOptionPane.YES_OPTION){
// System.exit(0);
// }else{
// return;
// }
//
//
// }
class MyWindowListener implements WindowListener {
@Override
public void windowOpened(WindowEvent e) {
// TODO Auto-generated method stub
}
@Override
public void windowClosing(WindowEvent e) {
int flag = JOptionPane.showConfirmDialog(null, "确认退出?", "消息",
JOptionPane.YES_NO_CANCEL_OPTION);
if (flag == JOptionPane.YES_OPTION) {
System.out.println("关闭按钮" + flag);
System.exit(0);
} else {
return;
}
}
@Override
public void windowClosed(WindowEvent e) {
// TODO Auto-generated method stub
}
@Override
public void windowIconified(WindowEvent e) {
// TODO Auto-generated method stub
}
@Override
public void windowDeiconified(WindowEvent e) {
// TODO Auto-generated method stub
}
@Override
public void windowActivated(WindowEvent e) {
// TODO Auto-generated method stub
}
@Override
public void windowDeactivated(WindowEvent e) {
// TODO Auto-generated method stub
}
}
/**
* 时间线程
*
* @pakeage frame @ CarSale
* @author mobo 2015-4-24 下午2:22:09
* @version 1.0
*/
class ThreadTime extends Thread {
@Override
public void run() {
while (true) {
Date date = new Date();
String time = sdf.format(date);
jl.setText(time);
try {
sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
/**
* 主窗体菜单项的单击事件监听器 @ CarSale
*
* @author chenwei
* @2015-4-13 上午11:42:58
* @version 1.0
*/
/**
* 导航面板
*/
/**
* 控件布局
*/
public void init() {
// JButton
}
/**
* 主方法
*
* @param args
*/
public static void main(String[] args) {
try {
UIManager
.setLookAndFeel(new org.jvnet.substance.skin.SubstanceBusinessBlueSteelLookAndFeel());
} catch (Exception e) {
e.printStackTrace();
}
new MainJFrame("总经理", 10000, "莫博");
System.out.println(role);
}
}