|
|
|
@ -40,282 +40,337 @@ import com.lingnan.supermarket.view.base.BaseView;
|
|
|
|
|
|
|
|
|
|
import java.awt.*;
|
|
|
|
|
|
|
|
|
|
//主界面类,继承自BaseView,实现了ActionListener、MouseListener和WindowListener接口。
|
|
|
|
|
|
|
|
|
|
public class MainView extends BaseView implements ActionListener, MouseListener, WindowListener {
|
|
|
|
|
|
|
|
|
|
JMenuBar menuBar; // 菜单栏
|
|
|
|
|
JMenu settingMenu, helpMenu; // 设置菜单和帮助菜单
|
|
|
|
|
JMenuItem skinMenuItem, configMenuItem; // 皮肤菜单项和配置菜单项
|
|
|
|
|
JSplitPane containerPanel; // 主界面容器,分为左右两部分
|
|
|
|
|
CardLayout rightPanelLayout; // 右侧面板的布局管理器
|
|
|
|
|
JPanel leftPanel, rightPanel; // 左侧和右侧的面板
|
|
|
|
|
|
|
|
|
|
/* 菜单栏 */
|
|
|
|
|
JLabel logoLabel, userMenuLabel1, homeMenuLabel, userMenuLabel, inMenuLabel,
|
|
|
|
|
outMenuLabel, storageMenuLabel, supplierMenuLabel, catalogMenuLabel;
|
|
|
|
|
|
|
|
|
|
static JLabel remindMenuLabel; // 全局调用刷新的提醒标签
|
|
|
|
|
|
|
|
|
|
JPanel bottomPanel; // 底部面板
|
|
|
|
|
JLabel timeLabel; // 显示时间的标签
|
|
|
|
|
JPanel purposePanel, timePanel; // 显示当前位置和时间的面板
|
|
|
|
|
JLabel purposeLabel; // 显示当前位置的标签
|
|
|
|
|
|
|
|
|
|
JButton saveBtn, unSaveBtn, cancleBtn; // 退出时的按钮
|
|
|
|
|
|
|
|
|
|
Timer timer; // 定时器,用于更新时间
|
|
|
|
|
|
|
|
|
|
private User user; // 从登录界面传过来的用户信息
|
|
|
|
|
private BufferImpl bufferImpl; // 缓存实现类
|
|
|
|
|
private Image bgImage; // 背景图片
|
|
|
|
|
private String iconSkin; // 图标皮肤
|
|
|
|
|
private int skin; // 当前皮肤编号
|
|
|
|
|
private Vector<Production> vP = new Vector<Production>(); // 用于进货缓存
|
|
|
|
|
private int location; // 当前界面的位置
|
|
|
|
|
private int sSuper = -1; // 界面权限
|
|
|
|
|
|
|
|
|
|
private static inOrderServiceImpl inOrderImpl = new inOrderServiceImpl(); // 进货订单服务实现类
|
|
|
|
|
private static int unConfirmmark; // 未确认订单数量
|
|
|
|
|
|
|
|
|
|
//构造函数,初始化主界面并设置用户信息和皮肤
|
|
|
|
|
public MainView(User user, int skin, String iconSkin) {
|
|
|
|
|
super(1300, 850, "新民超市管理系统欢迎您", user, skin);
|
|
|
|
|
timer = new Timer(1000, this); // 创建定时器,每秒触发一次
|
|
|
|
|
timer.start(); // 启动定时器
|
|
|
|
|
this.user = user; // 设置用户信息
|
|
|
|
|
this.sSuper = user.getUsuper(); // 获取用户权限
|
|
|
|
|
System.out.println("userid=" + user.getId()); // 打印用户ID
|
|
|
|
|
this.addWindowListener(this); // 添加窗口监听器
|
|
|
|
|
this.skin = skin; // 设置皮肤编号
|
|
|
|
|
this.iconSkin = iconSkin; // 设置图标皮肤路径
|
|
|
|
|
ImageIcon icon = new ImageIcon(iconSkin); // 创建图标
|
|
|
|
|
this.setIconImage(icon.getImage()); // 设置窗口图标
|
|
|
|
|
|
|
|
|
|
// 获取未进货的信息
|
|
|
|
|
public class MainView extends BaseView implements ActionListener, MouseListener,WindowListener{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JMenuBar menuBar;
|
|
|
|
|
JMenu settingMenu,helpMenu;
|
|
|
|
|
|
|
|
|
|
JMenuItem skinMenuItem,configMenuItem;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JSplitPane containerPanel;
|
|
|
|
|
|
|
|
|
|
CardLayout rightPanelLayout;
|
|
|
|
|
JPanel leftPanel,rightPanel;
|
|
|
|
|
|
|
|
|
|
/*菜单栏*/
|
|
|
|
|
JLabel logoLabel,userMenuLabel1,homeMenuLabel,userMenuLabel,inMenuLabel,
|
|
|
|
|
outMenuLabel,storageMenuLabel,supplierMenuLabel,catalogMenuLabel;
|
|
|
|
|
|
|
|
|
|
static JLabel remindMenuLabel;/*全局调用刷新*/
|
|
|
|
|
|
|
|
|
|
JPanel bottomPanel;
|
|
|
|
|
|
|
|
|
|
JLabel timeLabel;
|
|
|
|
|
|
|
|
|
|
JPanel purposePanel,timePanel;
|
|
|
|
|
JLabel purposeLabel;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JButton saveBtn,unSaveBtn,cancleBtn;/*退出时按钮*/
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
Timer timer;
|
|
|
|
|
|
|
|
|
|
private User user ;/*从登录界面传过来的用户信息*/
|
|
|
|
|
|
|
|
|
|
private BufferImpl bufferImpl;
|
|
|
|
|
|
|
|
|
|
private Image bgImage ;
|
|
|
|
|
private String iconSkin;
|
|
|
|
|
private int skin;
|
|
|
|
|
|
|
|
|
|
private Vector<Production> vP=new Vector<Production>() ;/*用于进货缓存*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private int location;
|
|
|
|
|
|
|
|
|
|
private int sSuper=-1;//界面权限
|
|
|
|
|
|
|
|
|
|
private static inOrderServiceImpl inOrderImpl = new inOrderServiceImpl();
|
|
|
|
|
private static int unConfirmmark;/*未确认订单*/
|
|
|
|
|
|
|
|
|
|
public MainView(User user,int skin,String iconSkin) {
|
|
|
|
|
super(1300,850,"新民超市管理系统欢迎您",user,skin);
|
|
|
|
|
timer = new Timer(1000,this);
|
|
|
|
|
timer.start();
|
|
|
|
|
this.user = user;
|
|
|
|
|
|
|
|
|
|
this.sSuper=user.getUsuper();//界面权限
|
|
|
|
|
System.out.println("userid="+user.getId());
|
|
|
|
|
this.addWindowListener(this);
|
|
|
|
|
|
|
|
|
|
this.skin = skin;
|
|
|
|
|
this.iconSkin = iconSkin;
|
|
|
|
|
ImageIcon icon=new ImageIcon(iconSkin); //xxx代表图片存放路径,2.png图片名称及格式
|
|
|
|
|
this.setIconImage(icon.getImage());
|
|
|
|
|
|
|
|
|
|
//获得未进货的信息
|
|
|
|
|
Vector<InOrder> vInOrder;
|
|
|
|
|
vInOrder = inOrderImpl.findUnconfirmInOrder(); // 查找未确认的进货订单
|
|
|
|
|
unConfirmmark = vInOrder.size(); // 设置未确认订单数量
|
|
|
|
|
vInOrder = inOrderImpl.findUnconfirmInOrder();
|
|
|
|
|
unConfirmmark=vInOrder.size();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
initView(user, skin); // 初始化界面
|
|
|
|
|
initView(user,skin);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//构造函数,初始化主界面并设置用户信息
|
|
|
|
|
public MainView(User user) {
|
|
|
|
|
super(1300, 850, "新民超市管理系统欢迎您");
|
|
|
|
|
timer = new Timer(1000, this); // 创建定时器,每秒触发一次
|
|
|
|
|
timer.start(); // 启动定时器
|
|
|
|
|
this.user = user; // 设置用户信息
|
|
|
|
|
this.sSuper = user.getUsuper(); // 获取用户权限
|
|
|
|
|
System.out.println("userid=" + user.getId()); // 打印用户ID
|
|
|
|
|
this.addWindowListener(this); // 添加窗口监听器
|
|
|
|
|
|
|
|
|
|
// 获取未进货的信息
|
|
|
|
|
super(1300,850,"新民超市管理系统欢迎您");
|
|
|
|
|
timer = new Timer(1000,this);
|
|
|
|
|
timer.start();
|
|
|
|
|
this.user = user;
|
|
|
|
|
|
|
|
|
|
this.sSuper=user.getUsuper();//界面权限
|
|
|
|
|
System.out.println("userid="+user.getId());
|
|
|
|
|
this.addWindowListener(this);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获得未进货的信息
|
|
|
|
|
Vector<InOrder> vInOrder;
|
|
|
|
|
vInOrder = inOrderImpl.findUnconfirmInOrder(); // 查找未确认的进货订单
|
|
|
|
|
unConfirmmark = vInOrder.size(); // 设置未确认订单数量
|
|
|
|
|
vInOrder = inOrderImpl.findUnconfirmInOrder();
|
|
|
|
|
unConfirmmark=vInOrder.size();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
initView(user, skin); // 初始化界面
|
|
|
|
|
initView(user,skin);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//刷新提醒标签,更新未确认订单数量
|
|
|
|
|
public static void refreshRemind() {
|
|
|
|
|
Vector<InOrder> vInOrder;
|
|
|
|
|
vInOrder = inOrderImpl.findUnconfirmInOrder(); // 查找未确认的进货订单
|
|
|
|
|
unConfirmmark = vInOrder.size(); // 更新未确认订单数量
|
|
|
|
|
remindMenuLabel.setText("待确认进货:" + unConfirmmark); // 更新提醒标签的文本
|
|
|
|
|
vInOrder = inOrderImpl.findUnconfirmInOrder();
|
|
|
|
|
unConfirmmark=vInOrder.size();
|
|
|
|
|
remindMenuLabel.setText("待确认进货:"+unConfirmmark);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//初始化界面,设置菜单栏、左侧菜单栏、右侧内容面板等
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* public static User getUserInf() {
|
|
|
|
|
return user;
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void initView(User user, int skin) {
|
|
|
|
|
/* 菜单栏 */
|
|
|
|
|
menuBar = new JMenuBar(); // 创建菜单栏
|
|
|
|
|
settingMenu = new JMenu("设置"); // 创建设置菜单
|
|
|
|
|
helpMenu = new JMenu("帮助"); // 创建帮助菜单
|
|
|
|
|
skinMenuItem = new JMenuItem("随机切换皮肤", new ImageIcon("static\\icon\\skin.png")); // 创建皮肤菜单项
|
|
|
|
|
configMenuItem = new JMenuItem("参数设置", new ImageIcon("static\\icon\\setting.png")); // 创建配置菜单项
|
|
|
|
|
skinMenuItem.addActionListener(this); // 为皮肤菜单项添加事件监听器
|
|
|
|
|
settingMenu.add(configMenuItem); // 将配置菜单项添加到设置菜单
|
|
|
|
|
settingMenu.add(skinMenuItem); // 将皮肤菜单项添加到设置菜单
|
|
|
|
|
menuBar.add(settingMenu); // 将设置菜单添加到菜单栏
|
|
|
|
|
menuBar.add(helpMenu); // 将帮助菜单添加到菜单栏
|
|
|
|
|
setJMenuBar(menuBar); // 设置窗口的菜单栏
|
|
|
|
|
|
|
|
|
|
//左边菜单栏设置
|
|
|
|
|
protected void initView(User user,int skin) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*菜单栏*/
|
|
|
|
|
menuBar = new JMenuBar();
|
|
|
|
|
|
|
|
|
|
settingMenu = new JMenu("设置");
|
|
|
|
|
|
|
|
|
|
helpMenu = new JMenu("帮助");
|
|
|
|
|
|
|
|
|
|
skinMenuItem = new JMenuItem("随机切换皮肤",new ImageIcon("static\\icon\\skin.png"));
|
|
|
|
|
|
|
|
|
|
/* for(int i = 3;i<9;i++) {
|
|
|
|
|
|
|
|
|
|
}*/
|
|
|
|
|
configMenuItem = new JMenuItem("参数设置",new ImageIcon("static\\icon\\setting.png"));
|
|
|
|
|
skinMenuItem.addActionListener(this);
|
|
|
|
|
|
|
|
|
|
settingMenu.add(configMenuItem);
|
|
|
|
|
settingMenu.add(skinMenuItem);
|
|
|
|
|
menuBar.add(settingMenu);
|
|
|
|
|
menuBar.add(helpMenu);
|
|
|
|
|
|
|
|
|
|
setJMenuBar(menuBar);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*左边菜单栏设置*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
bgImage = ImageIO.read(new File("static\\bg\\bg" + skin + ".jpg")); // 读取背景图片
|
|
|
|
|
bgImage = ImageIO.read(new File("static\\bg\\bg"+skin+".jpg"));
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
e.printStackTrace(); // 捕获并打印异常
|
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
leftPanel = new BGPanel(bgImage); // 创建带有背景图片的面板
|
|
|
|
|
leftPanel.setLayout(null); // 设置布局为空,自定义布局
|
|
|
|
|
|
|
|
|
|
//菜单栏:用户登录信息
|
|
|
|
|
System.out.println("用户头像地址==" + user.getImg()); // 打印用户头像地址
|
|
|
|
|
JLabel logoLabel = new JLabel(new ImageIcon(user.getImg()), JLabel.LEFT); // 创建用户头像标签
|
|
|
|
|
System.out.println(user.getImg()); // 打印用户头像地址
|
|
|
|
|
leftPanel.add(logoLabel); // 将用户头像标签添加到左侧面板
|
|
|
|
|
logoLabel.setBounds(25, 30, 150, 150); // 设置用户头像标签的位置和大小
|
|
|
|
|
|
|
|
|
|
//账号名字
|
|
|
|
|
String x = UsuperIcon(user.getUsuper()); // 根据用户权限返回对应的图标地址
|
|
|
|
|
System.out.println("身份地址:" + x); // 打印身份图标地址
|
|
|
|
|
userMenuLabel1 = new JLabel("|" + user.getUsername() + "|" + user.getRname(), new ImageIcon(x), JLabel.LEFT); // 创建用户信息标签
|
|
|
|
|
userMenuLabel1.setFont(FontUtil.userFont); // 设置字体
|
|
|
|
|
userMenuLabel1.addMouseListener(this); // 添加鼠标监听器
|
|
|
|
|
userMenuLabel1.setBounds(20, 170, 180, 32); // 设置位置和大小
|
|
|
|
|
userMenuLabel1.setForeground(Color.white); // 设置字体颜色为白色
|
|
|
|
|
leftPanel.add(userMenuLabel1); // 将用户信息标签添加到左侧面板
|
|
|
|
|
|
|
|
|
|
// 菜单栏:首页
|
|
|
|
|
homeMenuLabel = new JLabel("新民首页", new ImageIcon("static\\icon\\home1.png"), JLabel.LEFT); // 创建首页标签
|
|
|
|
|
homeMenuLabel.setFont(FontUtil.menuFont); // 设置字体
|
|
|
|
|
homeMenuLabel.addMouseListener(this); // 添加鼠标监听器
|
|
|
|
|
homeMenuLabel.setBounds(20, 250, 150, 32); // 设置位置和大小
|
|
|
|
|
homeMenuLabel.setForeground(Color.white); // 设置字体颜色为白色
|
|
|
|
|
leftPanel.add(homeMenuLabel); // 将首页标签添加到左侧面板
|
|
|
|
|
|
|
|
|
|
// 菜单栏:人员管理
|
|
|
|
|
userMenuLabel = new JLabel("人员管理", new ImageIcon("static\\icon\\user1.png"), JLabel.LEFT); // 创建人员管理标签
|
|
|
|
|
userMenuLabel.setFont(FontUtil.menuFont); // 设置字体
|
|
|
|
|
userMenuLabel.addMouseListener(this); // 添加鼠标监听器
|
|
|
|
|
userMenuLabel.setBounds(20, 300, 150, 32); // 设置位置和大小
|
|
|
|
|
userMenuLabel.setForeground(Color.white); // 设置字体颜色为白色
|
|
|
|
|
leftPanel.add(userMenuLabel); // 将人员管理标签添加到左侧面板
|
|
|
|
|
|
|
|
|
|
// 菜单栏:进货系统
|
|
|
|
|
inMenuLabel = new JLabel("进货系统", new ImageIcon("static\\icon\\in1.png"), JLabel.LEFT); // 创建进货系统标签
|
|
|
|
|
inMenuLabel.setFont(FontUtil.menuFont); // 设置字体
|
|
|
|
|
inMenuLabel.addMouseListener(this); // 添加鼠标监听器
|
|
|
|
|
inMenuLabel.setBounds(20, 350, 150, 32); // 设置位置和大小
|
|
|
|
|
inMenuLabel.setForeground(Color.white); // 设置字体颜色为白色
|
|
|
|
|
leftPanel.add(inMenuLabel); // 将进货系统标签添加到左侧面板
|
|
|
|
|
|
|
|
|
|
// 菜单栏:收银系统
|
|
|
|
|
outMenuLabel = new JLabel("收银系统", new ImageIcon("static\\icon\\out1.png"), JLabel.LEFT); // 创建收银系统标签
|
|
|
|
|
outMenuLabel.setFont(FontUtil.menuFont); // 设置字体
|
|
|
|
|
outMenuLabel.addMouseListener(this); // 添加鼠标监听器
|
|
|
|
|
outMenuLabel.setBounds(20, 400, 150, 32); // 设置位置和大小
|
|
|
|
|
outMenuLabel.setForeground(Color.white); // 设置字体颜色为白色
|
|
|
|
|
leftPanel.add(outMenuLabel); // 将收银系统标签添加到左侧面板
|
|
|
|
|
|
|
|
|
|
// 菜单栏:库存
|
|
|
|
|
storageMenuLabel = new JLabel("商品库存", new ImageIcon("static\\icon\\storage1.png"), JLabel.LEFT); // 创建库存标签
|
|
|
|
|
storageMenuLabel.setFont(FontUtil.menuFont); // 设置字体
|
|
|
|
|
storageMenuLabel.addMouseListener(this); // 添加鼠标监听器
|
|
|
|
|
storageMenuLabel.setBounds(20, 450, 150, 32); // 设置位置和大小
|
|
|
|
|
storageMenuLabel.setForeground(Color.white); // 设置字体颜色为白色
|
|
|
|
|
leftPanel.add(storageMenuLabel); // 将库存标签添加到左侧面板
|
|
|
|
|
|
|
|
|
|
// 菜单栏:供应商
|
|
|
|
|
supplierMenuLabel = new JLabel("供应商", new ImageIcon("static\\icon\\supplier1.png"), JLabel.LEFT); // 创建供应商标签
|
|
|
|
|
supplierMenuLabel.setFont(FontUtil.menuFont); // 设置字体
|
|
|
|
|
supplierMenuLabel.addMouseListener(this); // 添加鼠标监听器
|
|
|
|
|
supplierMenuLabel.setBounds(20, 500, 150, 32); // 设置位置和大小
|
|
|
|
|
supplierMenuLabel.setForeground(Color.white); // 设置字体颜色为白色
|
|
|
|
|
leftPanel.add(supplierMenuLabel); // 将供应商标签添加到左侧面板
|
|
|
|
|
|
|
|
|
|
// 菜单栏:商品目录
|
|
|
|
|
catalogMenuLabel = new JLabel("商品目录", new ImageIcon("static\\icon\\catalog1.png"), JLabel.LEFT); // 创建商品目录标签
|
|
|
|
|
catalogMenuLabel.setFont(FontUtil.menuFont); // 设置字体
|
|
|
|
|
catalogMenuLabel.addMouseListener(this); // 添加鼠标监听器
|
|
|
|
|
catalogMenuLabel.setBounds(20, 550, 150, 32); // 设置位置和大小
|
|
|
|
|
catalogMenuLabel.setForeground(Color.white); // 设置字体颜色为白色
|
|
|
|
|
leftPanel.add(catalogMenuLabel); // 将商品目录标签添加到左侧面板
|
|
|
|
|
|
|
|
|
|
// 提醒进货确认模块
|
|
|
|
|
remindMenuLabel = new JLabel("待确认进货:" + unConfirmmark, new ImageIcon("static\\icon\\remind1.png"), JLabel.LEFT); // 创建提醒标签
|
|
|
|
|
remindMenuLabel.setFont(FontUtil.remindFont); // 设置字体
|
|
|
|
|
remindMenuLabel.addMouseListener(this); // 添加鼠标监听器
|
|
|
|
|
remindMenuLabel.setBounds(0, 650, 200, 32); // 设置位置和大小
|
|
|
|
|
remindMenuLabel.setForeground(Color.white); // 设置字体颜色为白色
|
|
|
|
|
leftPanel.add(remindMenuLabel); // 将提醒标签添加到左侧面板
|
|
|
|
|
|
|
|
|
|
rightPanelLayout = new CardLayout(); // 创建卡片布局管理器
|
|
|
|
|
|
|
|
|
|
// 0.超市首页展示
|
|
|
|
|
JPanel homePanel = new HomeView(this); // 创建首页面板
|
|
|
|
|
|
|
|
|
|
// 1.用户管理界面:用户的列表
|
|
|
|
|
JPanel userPanel = new UserView(this); // 创建用户管理面板
|
|
|
|
|
|
|
|
|
|
// 2.进货系统界面
|
|
|
|
|
JPanel inPanel = new InView(this, user, vP, 1); // 创建进货系统面板
|
|
|
|
|
|
|
|
|
|
// 3收银系统界面
|
|
|
|
|
JPanel outPanel = new OutView(this, user); // 创建收银系统面板
|
|
|
|
|
|
|
|
|
|
// 4.库存系统界面
|
|
|
|
|
JPanel storagePanel = new StorageView(this); // 创建库存系统面板
|
|
|
|
|
|
|
|
|
|
// 5.供应商界面
|
|
|
|
|
JPanel supplierPanel = new SupplierView(this); // 创建供应商面板
|
|
|
|
|
|
|
|
|
|
// 6商品目录界面
|
|
|
|
|
JPanel ProdCatalogPanel = new ProdCatalogView(this); // 创建商品目录面板
|
|
|
|
|
|
|
|
|
|
// 7商品目录界面
|
|
|
|
|
JPanel superPanel = new SuperView(this); // 创建普通用户界面
|
|
|
|
|
|
|
|
|
|
// 8进货信息提示
|
|
|
|
|
JPanel inPanel2 = new InView(this, user, vP, 0); // 创建进货信息提示面板
|
|
|
|
|
|
|
|
|
|
/* 添加界面并给索引 */
|
|
|
|
|
rightPanel = new JPanel(rightPanelLayout); // 创建右侧内容面板
|
|
|
|
|
rightPanel.add(homePanel, "0"); // 添加首页面板并设置索引
|
|
|
|
|
rightPanel.add(userPanel, "1"); // 添加用户管理面板并设置索引
|
|
|
|
|
rightPanel.add(inPanel, "2"); // 添加进货系统面板并设置索引
|
|
|
|
|
rightPanel.add(outPanel, "3"); // 添加收银系统面板并设置索引
|
|
|
|
|
rightPanel.add(storagePanel, "4"); // 添加库存系统面板并设置索引
|
|
|
|
|
rightPanel.add(supplierPanel, "5"); // 添加供应商面板并设置索引
|
|
|
|
|
rightPanel.add(ProdCatalogPanel, "6"); // 添加商品目录面板并设置索引
|
|
|
|
|
rightPanel.add(superPanel, "7"); // 添加普通用户面板并设置索引
|
|
|
|
|
rightPanel.add(inPanel2, "8"); // 添加进货信息提示面板并设置索引
|
|
|
|
|
|
|
|
|
|
containerPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPanel, rightPanel); // 创建左右分割面板
|
|
|
|
|
containerPanel.setDividerLocation(180); // 设置分割位置
|
|
|
|
|
containerPanel.setDividerSize(0); // 设置分割线宽度为0
|
|
|
|
|
|
|
|
|
|
bottomPanel = new JPanel(); // 创建底部面板
|
|
|
|
|
bottomPanel.setBackground(Color.WHITE); // 设置背景颜色为白色
|
|
|
|
|
bottomPanel.setLayout(new BorderLayout()); // 设置布局为边界布局
|
|
|
|
|
|
|
|
|
|
purposePanel = new JPanel(); // 创建当前位置面板
|
|
|
|
|
purposePanel.setLayout(new FlowLayout(FlowLayout.LEFT)); // 设置布局为流式布局(左对齐)
|
|
|
|
|
purposePanel.setBackground(Color.WHITE); // 设置背景颜色为白色
|
|
|
|
|
purposeLabel = new JLabel("当前位置是:超市首页"); // 创建当前位置标签
|
|
|
|
|
purposePanel.add(purposeLabel); // 将当前位置标签添加到当前位置面板
|
|
|
|
|
|
|
|
|
|
timePanel = new JPanel(); // 创建时间面板
|
|
|
|
|
timePanel.setLayout(new FlowLayout(FlowLayout.TRAILING)); // 设置布局为流式布局(右对齐)
|
|
|
|
|
timePanel.setBackground(Color.WHITE); // 设置背景颜色为白色
|
|
|
|
|
timeLabel = new JLabel(DateUtil.dateToString(new Date(), null)); // 创建时间标签
|
|
|
|
|
timePanel.add(timeLabel); // 将时间标签添加到时间面板
|
|
|
|
|
|
|
|
|
|
bottomPanel.add(purposePanel, "West"); // 将当前位置面板添加到底部面板的左侧
|
|
|
|
|
bottomPanel.add(timePanel, "East"); // 将时间面板添加到底部面板的右侧
|
|
|
|
|
Container container = getContentPane(); // 获取内容面板
|
|
|
|
|
container.add(containerPanel, "Center"); // 将主界面容器添加到内容面板的中间
|
|
|
|
|
container.add(bottomPanel, "South"); // 将底部面板添加到内容面板的底部
|
|
|
|
|
leftPanel = new BGPanel(bgImage);/*皮肤*/
|
|
|
|
|
leftPanel.setLayout(null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*菜单栏:用户登录信息*/
|
|
|
|
|
System.out.println("用户头像地址=="+user.getImg());
|
|
|
|
|
JLabel logoLabel = new JLabel(new ImageIcon(user.getImg()),JLabel.LEFT);
|
|
|
|
|
System.out.println(user.getImg());
|
|
|
|
|
leftPanel.add(logoLabel);
|
|
|
|
|
logoLabel.setBounds(25, 30,150,150);
|
|
|
|
|
|
|
|
|
|
/*账号名字*/
|
|
|
|
|
String x = UsuperIcon(user.getUsuper());/*判断权限返回icon地址*/
|
|
|
|
|
System.out.println("身份地址:"+x);
|
|
|
|
|
userMenuLabel1 = new JLabel("|"+user.getUsername()+"|"+user.getRname(),new ImageIcon(x),JLabel.LEFT);
|
|
|
|
|
userMenuLabel1.setFont(FontUtil.userFont);
|
|
|
|
|
userMenuLabel1.addMouseListener(this);
|
|
|
|
|
userMenuLabel1.setBounds(20, 170,180,32);
|
|
|
|
|
userMenuLabel1.setForeground(Color.white);
|
|
|
|
|
leftPanel.add(userMenuLabel1);/*添加用户选项到菜单栏*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*菜单栏:首页*/
|
|
|
|
|
homeMenuLabel = new JLabel("新民首页",new ImageIcon("static\\icon\\home1.png"),JLabel.LEFT);
|
|
|
|
|
homeMenuLabel.setFont(FontUtil.menuFont);
|
|
|
|
|
homeMenuLabel.addMouseListener(this);
|
|
|
|
|
homeMenuLabel.setBounds(20, 250,150,32);
|
|
|
|
|
homeMenuLabel.setForeground(Color.white);
|
|
|
|
|
leftPanel.add(homeMenuLabel);/*添加用户选项到菜单栏*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*菜单栏:人员管理*/
|
|
|
|
|
userMenuLabel = new JLabel("人员管理",new ImageIcon("static\\icon\\user1.png"),JLabel.LEFT);
|
|
|
|
|
userMenuLabel.setFont(FontUtil.menuFont);
|
|
|
|
|
userMenuLabel.addMouseListener(this);
|
|
|
|
|
userMenuLabel.setBounds(20, 300,150,32);
|
|
|
|
|
userMenuLabel.setForeground(Color.white);
|
|
|
|
|
leftPanel.add(userMenuLabel);/*添加用户选项到菜单栏*/
|
|
|
|
|
|
|
|
|
|
/*菜单栏:进货系统*/
|
|
|
|
|
inMenuLabel = new JLabel("进货系统",new ImageIcon("static\\icon\\in1.png") ,JLabel.LEFT);
|
|
|
|
|
inMenuLabel.setFont(FontUtil.menuFont);
|
|
|
|
|
inMenuLabel.addMouseListener(this);
|
|
|
|
|
inMenuLabel.setBounds(20, 350,150,32);
|
|
|
|
|
inMenuLabel.setForeground(Color.white);
|
|
|
|
|
leftPanel.add(inMenuLabel);
|
|
|
|
|
|
|
|
|
|
/*菜单栏:收银系统*/
|
|
|
|
|
outMenuLabel = new JLabel("收银系统",new ImageIcon("static\\icon\\out1.png") ,JLabel.LEFT);
|
|
|
|
|
outMenuLabel.setFont(FontUtil.menuFont);
|
|
|
|
|
outMenuLabel.addMouseListener(this);
|
|
|
|
|
outMenuLabel.setBounds(20, 400,150,32);
|
|
|
|
|
outMenuLabel.setForeground(Color.white);
|
|
|
|
|
leftPanel.add(outMenuLabel);
|
|
|
|
|
|
|
|
|
|
/*菜单栏:库存*/
|
|
|
|
|
storageMenuLabel = new JLabel("商品库存",new ImageIcon("static\\icon\\storage1.png") ,JLabel.LEFT);
|
|
|
|
|
storageMenuLabel.setFont(FontUtil.menuFont);
|
|
|
|
|
storageMenuLabel.addMouseListener(this);
|
|
|
|
|
storageMenuLabel.setBounds(20, 450,150,32);
|
|
|
|
|
storageMenuLabel.setForeground(Color.white);
|
|
|
|
|
leftPanel.add(storageMenuLabel);
|
|
|
|
|
|
|
|
|
|
/*菜单栏:供应商*/
|
|
|
|
|
supplierMenuLabel = new JLabel("供应商",new ImageIcon("static\\icon\\supplier1.png") ,JLabel.LEFT);
|
|
|
|
|
supplierMenuLabel.setFont(FontUtil.menuFont);
|
|
|
|
|
supplierMenuLabel.addMouseListener(this);
|
|
|
|
|
supplierMenuLabel.setBounds(20, 500,150,32);
|
|
|
|
|
supplierMenuLabel.setForeground(Color.white);
|
|
|
|
|
leftPanel.add(supplierMenuLabel);
|
|
|
|
|
|
|
|
|
|
/*菜单栏:商品目录*/
|
|
|
|
|
catalogMenuLabel = new JLabel("商品目录",new ImageIcon("static\\icon\\catalog1.png") ,JLabel.LEFT);
|
|
|
|
|
catalogMenuLabel.setFont(FontUtil.menuFont);
|
|
|
|
|
catalogMenuLabel.addMouseListener(this);
|
|
|
|
|
catalogMenuLabel.setBounds(20,550,150,32);
|
|
|
|
|
catalogMenuLabel.setForeground(Color.white);
|
|
|
|
|
leftPanel.add(catalogMenuLabel);
|
|
|
|
|
|
|
|
|
|
/*提醒进货确认模块*/
|
|
|
|
|
remindMenuLabel = new JLabel("待确认进货:"+unConfirmmark,new ImageIcon("static\\icon\\remind1.png") ,JLabel.LEFT);
|
|
|
|
|
remindMenuLabel.setFont(FontUtil.remindFont);
|
|
|
|
|
remindMenuLabel.addMouseListener(this);
|
|
|
|
|
remindMenuLabel.setBounds(0,650,200,32);
|
|
|
|
|
remindMenuLabel.setForeground(Color.white);
|
|
|
|
|
leftPanel.add(remindMenuLabel);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rightPanelLayout = new CardLayout();
|
|
|
|
|
|
|
|
|
|
//0.超市首页展示
|
|
|
|
|
JPanel homePanel = new HomeView(this);
|
|
|
|
|
|
|
|
|
|
//1.用户管理界面:用户的列表
|
|
|
|
|
JPanel userPanel = new UserView(this);
|
|
|
|
|
|
|
|
|
|
//2.进货系统界面
|
|
|
|
|
JPanel inPanel = new InView(this,user,vP,1);
|
|
|
|
|
|
|
|
|
|
//3收银系统界面
|
|
|
|
|
JPanel outPanel = new OutView(this,user);
|
|
|
|
|
|
|
|
|
|
//4.库存系统界面
|
|
|
|
|
JPanel storagePanel = new StorageView(this);
|
|
|
|
|
|
|
|
|
|
//5.供应商界面
|
|
|
|
|
JPanel supplierPanel = new SupplierView(this);
|
|
|
|
|
|
|
|
|
|
//6商品目录界面
|
|
|
|
|
JPanel ProdCatalogPanel = new ProdCatalogView(this);
|
|
|
|
|
|
|
|
|
|
//7商品目录界面
|
|
|
|
|
JPanel superPanel = new SuperView(this);
|
|
|
|
|
|
|
|
|
|
//8进货信息提示
|
|
|
|
|
JPanel inPanel2 = new InView(this,user,vP,0);
|
|
|
|
|
|
|
|
|
|
/*添加界面并给索引*/
|
|
|
|
|
rightPanel = new JPanel(rightPanelLayout);
|
|
|
|
|
rightPanel.add(homePanel, "0");
|
|
|
|
|
rightPanel.add(userPanel, "1");
|
|
|
|
|
rightPanel.add(inPanel, "2");
|
|
|
|
|
rightPanel.add(outPanel, "3");
|
|
|
|
|
rightPanel.add(storagePanel, "4");
|
|
|
|
|
rightPanel.add(supplierPanel, "5");
|
|
|
|
|
rightPanel.add(ProdCatalogPanel, "6");
|
|
|
|
|
rightPanel.add(superPanel, "7");
|
|
|
|
|
rightPanel.add(inPanel2, "8");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
containerPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,leftPanel,rightPanel);
|
|
|
|
|
containerPanel.setDividerLocation(180);
|
|
|
|
|
containerPanel.setDividerSize(0);
|
|
|
|
|
|
|
|
|
|
bottomPanel = new JPanel();//默认的布局是流式布局
|
|
|
|
|
|
|
|
|
|
bottomPanel.setBackground(Color.WHITE);
|
|
|
|
|
bottomPanel.setLayout(new BorderLayout());
|
|
|
|
|
|
|
|
|
|
purposePanel = new JPanel();
|
|
|
|
|
purposePanel.setLayout(new FlowLayout(FlowLayout.LEFT));
|
|
|
|
|
purposePanel.setBackground(Color.WHITE);
|
|
|
|
|
purposeLabel = new JLabel("当前位置是:超市首页");
|
|
|
|
|
purposePanel.add(purposeLabel);
|
|
|
|
|
|
|
|
|
|
timePanel=new JPanel();
|
|
|
|
|
timePanel.setLayout(new FlowLayout(FlowLayout.TRAILING));
|
|
|
|
|
timePanel.setBackground(Color.WHITE);
|
|
|
|
|
timeLabel = new JLabel(DateUtil.dateToString(new Date(),null));
|
|
|
|
|
timePanel.add(timeLabel);
|
|
|
|
|
|
|
|
|
|
bottomPanel.add(purposePanel,"West");
|
|
|
|
|
bottomPanel.add(timePanel,"East");
|
|
|
|
|
Container container = getContentPane();
|
|
|
|
|
container.add(containerPanel,"Center");
|
|
|
|
|
container.add(bottomPanel,"South");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
|
|
Object source = e.getSource(); // 获取事件来源
|
|
|
|
|
timeLabel.setText(DateUtil.dateToString(new Date(), null)); // 更新时间标签
|
|
|
|
|
if (source == skinMenuItem) /* 换肤 */ {
|
|
|
|
|
System.out.println("切换皮肤"); // 打印日志
|
|
|
|
|
Random random = new Random(); // 创建随机数生成器
|
|
|
|
|
skin = random.nextInt(10); // 随机生成皮肤编号
|
|
|
|
|
this.dispose(); // 关闭当前窗口
|
|
|
|
|
new MainView(user, skin, iconSkin); // 重新创建主界面
|
|
|
|
|
Object source = e.getSource();
|
|
|
|
|
timeLabel.setText(DateUtil.dateToString(new Date(),null));
|
|
|
|
|
if(source==skinMenuItem)/*换肤*/{
|
|
|
|
|
System.out.println("切换皮肤");
|
|
|
|
|
Random random=new Random();
|
|
|
|
|
skin=random.nextInt(10);
|
|
|
|
|
this.dispose();
|
|
|
|
|
new MainView(user,skin,iconSkin);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//左侧菜单栏点击事件处理方法。
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* cwf 2024/12/11
|
|
|
|
|
* 修改不同权限用户的功能代码
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
/* 左侧菜单栏点击事件 */
|
|
|
|
|
public void mouseClicked(MouseEvent e) {
|
|
|
|
|
Object source = e.getSource(); // 获取点击事件的来源
|
|
|
|
|
|
|
|
|
@ -422,146 +477,175 @@ public class MainView extends BaseView implements ActionListener, MouseListener,
|
|
|
|
|
refreshRemove(); // 刷新当前界面的位置信息
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//刷新当前界面的位置信息。
|
|
|
|
|
public void refreshRemove() {
|
|
|
|
|
purposePanel.removeAll(); // 移除当前位置面板的所有组件
|
|
|
|
|
if (location == 0) {
|
|
|
|
|
purposeLabel = new JLabel("当前位置是:" + homeMenuLabel.getText()); // 设置当前位置为首页
|
|
|
|
|
} else if (location == 1) {
|
|
|
|
|
purposeLabel = new JLabel("当前位置是:" + userMenuLabel.getText()); // 设置当前位置为人员管理
|
|
|
|
|
} else if (location == 2) {
|
|
|
|
|
purposeLabel = new JLabel("当前位置是:" + inMenuLabel.getText()); // 设置当前位置为进货系统
|
|
|
|
|
} else if (location == 3) {
|
|
|
|
|
purposeLabel = new JLabel("当前位置是:" + outMenuLabel.getText()); // 设置当前位置为收银系统
|
|
|
|
|
} else if (location == 4) {
|
|
|
|
|
purposeLabel = new JLabel("当前位置是:" + storageMenuLabel.getText()); // 设置当前位置为库存系统
|
|
|
|
|
} else if (location == 5) {
|
|
|
|
|
purposeLabel = new JLabel("当前位置是:" + supplierMenuLabel.getText()); // 设置当前位置为供应商
|
|
|
|
|
} else {
|
|
|
|
|
purposeLabel = new JLabel("当前位置是:" + catalogMenuLabel.getText()); // 设置当前位置为商品目录
|
|
|
|
|
//获取当前位置
|
|
|
|
|
public void refreshRemove(){
|
|
|
|
|
|
|
|
|
|
purposePanel.removeAll();
|
|
|
|
|
if(location==0){
|
|
|
|
|
purposeLabel = new JLabel("当前位置是:"+homeMenuLabel.getText());
|
|
|
|
|
|
|
|
|
|
}else if(location==1){
|
|
|
|
|
purposeLabel = new JLabel("当前位置是:"+userMenuLabel.getText());
|
|
|
|
|
|
|
|
|
|
}else if(location==2){
|
|
|
|
|
purposeLabel = new JLabel("当前位置是:"+inMenuLabel.getText());
|
|
|
|
|
|
|
|
|
|
}else if(location==3){
|
|
|
|
|
purposeLabel = new JLabel("当前位置是:"+outMenuLabel.getText());
|
|
|
|
|
|
|
|
|
|
}else if(location==4){
|
|
|
|
|
purposeLabel = new JLabel("当前位置是:"+storageMenuLabel.getText());
|
|
|
|
|
|
|
|
|
|
}else if(location==5){
|
|
|
|
|
purposeLabel = new JLabel("当前位置是:"+supplierMenuLabel.getText());
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
purposeLabel = new JLabel("当前位置是:"+catalogMenuLabel.getText());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
purposePanel.add(purposeLabel); // 将当前位置标签添加到当前位置面板
|
|
|
|
|
purposePanel.add(purposeLabel);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void mousePressed(MouseEvent e) {
|
|
|
|
|
// 鼠标按下事件,暂未实现
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void mouseReleased(MouseEvent e) {
|
|
|
|
|
// 鼠标释放事件,暂未实现
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
// 鼠标焦点时
|
|
|
|
|
@Override/*鼠标焦点时*/
|
|
|
|
|
public void mouseEntered(MouseEvent e) {
|
|
|
|
|
Object source = e.getSource(); // 获取事件来源
|
|
|
|
|
if (source == homeMenuLabel) {
|
|
|
|
|
homeMenuLabel.setForeground(new Color(18, 150, 219)); // 设置字体颜色
|
|
|
|
|
homeMenuLabel.setIcon(new ImageIcon("static\\icon\\home2.png")); // 设置图标
|
|
|
|
|
Object source = e.getSource();
|
|
|
|
|
if(source==homeMenuLabel) {
|
|
|
|
|
homeMenuLabel.setForeground(new Color(18, 150, 219));
|
|
|
|
|
homeMenuLabel.setIcon(new ImageIcon("static\\icon\\home2.png"));
|
|
|
|
|
}
|
|
|
|
|
if (source == userMenuLabel) {
|
|
|
|
|
userMenuLabel.setForeground(new Color(18, 150, 219)); // 设置字体颜色
|
|
|
|
|
userMenuLabel.setIcon(new ImageIcon("static\\icon\\user2.png")); // 设置图标
|
|
|
|
|
} else if (source == inMenuLabel) {
|
|
|
|
|
inMenuLabel.setForeground(new Color(18, 150, 219)); // 设置字体颜色
|
|
|
|
|
inMenuLabel.setIcon(new ImageIcon("static\\icon\\in2.png")); // 设置图标
|
|
|
|
|
} else if (source == outMenuLabel) {
|
|
|
|
|
outMenuLabel.setForeground(new Color(18, 150, 219)); // 设置字体颜色
|
|
|
|
|
outMenuLabel.setIcon(new ImageIcon("static\\icon\\out2.png")); // 设置图标
|
|
|
|
|
} else if (source == storageMenuLabel) {
|
|
|
|
|
storageMenuLabel.setForeground(new Color(18, 150, 219)); // 设置字体颜色
|
|
|
|
|
storageMenuLabel.setIcon(new ImageIcon("static\\icon\\storage2.png")); // 设置图标
|
|
|
|
|
} else if (source == supplierMenuLabel) {
|
|
|
|
|
supplierMenuLabel.setForeground(new Color(18, 150, 219)); // 设置字体颜色
|
|
|
|
|
supplierMenuLabel.setIcon(new ImageIcon("static\\icon\\supplier2.png")); // 设置图标
|
|
|
|
|
} else if (source == catalogMenuLabel) {
|
|
|
|
|
catalogMenuLabel.setForeground(new Color(18, 150, 219)); // 设置字体颜色
|
|
|
|
|
catalogMenuLabel.setIcon(new ImageIcon("static\\icon\\catalog2.png")); // 设置图标
|
|
|
|
|
} else if (source == userMenuLabel1) {
|
|
|
|
|
userMenuLabel1.setForeground(new Color(18, 150, 219)); // 设置字体颜色
|
|
|
|
|
if(source==userMenuLabel) {
|
|
|
|
|
userMenuLabel.setForeground(new Color(18, 150, 219));
|
|
|
|
|
userMenuLabel.setIcon(new ImageIcon("static\\icon\\user2.png"));
|
|
|
|
|
}else if(source==inMenuLabel) {
|
|
|
|
|
inMenuLabel.setForeground(new Color(18, 150, 219));
|
|
|
|
|
inMenuLabel.setIcon(new ImageIcon("static\\icon\\in2.png"));
|
|
|
|
|
}else if(source==outMenuLabel) {
|
|
|
|
|
outMenuLabel.setForeground(new Color(18, 150, 219));
|
|
|
|
|
outMenuLabel.setIcon(new ImageIcon("static\\icon\\out2.png"));
|
|
|
|
|
}else if(source==storageMenuLabel) {
|
|
|
|
|
storageMenuLabel.setForeground(new Color(18, 150, 219));
|
|
|
|
|
storageMenuLabel.setIcon(new ImageIcon("static\\icon\\storage2.png"));
|
|
|
|
|
}else if(source==supplierMenuLabel) {
|
|
|
|
|
supplierMenuLabel.setForeground(new Color(18, 150, 219));
|
|
|
|
|
supplierMenuLabel.setIcon(new ImageIcon("static\\icon\\supplier2.png"));
|
|
|
|
|
}else if(source==catalogMenuLabel) {
|
|
|
|
|
catalogMenuLabel.setForeground(new Color(18, 150, 219));
|
|
|
|
|
catalogMenuLabel.setIcon(new ImageIcon("static\\icon\\catalog2.png"));
|
|
|
|
|
} else if(source==userMenuLabel1) {
|
|
|
|
|
userMenuLabel1.setForeground(new Color(18, 150, 219));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void mouseExited(MouseEvent e) {
|
|
|
|
|
Object source = e.getSource(); // 获取事件来源
|
|
|
|
|
if (source == homeMenuLabel) {
|
|
|
|
|
homeMenuLabel.setForeground(Color.white); // 设置字体颜色为白色
|
|
|
|
|
homeMenuLabel.setIcon(new ImageIcon("static\\icon\\home1.png")); // 设置图标
|
|
|
|
|
} else if (source == userMenuLabel) {
|
|
|
|
|
userMenuLabel.setForeground(Color.white); // 设置字体颜色为白色
|
|
|
|
|
userMenuLabel.setIcon(new ImageIcon("static\\icon\\user1.png")); // 设置图标
|
|
|
|
|
} else if (source == inMenuLabel) {
|
|
|
|
|
inMenuLabel.setForeground(Color.white); // 设置字体颜色为白色
|
|
|
|
|
inMenuLabel.setIcon(new ImageIcon("static\\icon\\in1.png")); // 设置图标
|
|
|
|
|
} else if (source == outMenuLabel) {
|
|
|
|
|
outMenuLabel.setForeground(Color.white); // 设置字体颜色为白色
|
|
|
|
|
outMenuLabel.setIcon(new ImageIcon("static\\icon\\out1.png")); // 设置图标
|
|
|
|
|
} else if (source == storageMenuLabel) {
|
|
|
|
|
storageMenuLabel.setForeground(Color.white); // 设置字体颜色为白色
|
|
|
|
|
storageMenuLabel.setIcon(new ImageIcon("static\\icon\\storage1.png")); // 设置图标
|
|
|
|
|
} else if (source == supplierMenuLabel) {
|
|
|
|
|
supplierMenuLabel.setForeground(Color.white); // 设置字体颜色为白色
|
|
|
|
|
supplierMenuLabel.setIcon(new ImageIcon("static\\icon\\supplier1.png")); // 设置图标
|
|
|
|
|
} else if (source == catalogMenuLabel) {
|
|
|
|
|
catalogMenuLabel.setForeground(Color.white); // 设置字体颜色为白色
|
|
|
|
|
catalogMenuLabel.setIcon(new ImageIcon("static\\icon\\catalog1.png")); // 设置图标
|
|
|
|
|
} else {
|
|
|
|
|
userMenuLabel1.setForeground(Color.white); // 设置字体颜色为白色
|
|
|
|
|
Object source = e.getSource();
|
|
|
|
|
if(source==homeMenuLabel) {
|
|
|
|
|
homeMenuLabel.setForeground(Color.white);
|
|
|
|
|
homeMenuLabel.setIcon(new ImageIcon("static\\icon\\home1.png"));
|
|
|
|
|
} else if(source==userMenuLabel) {
|
|
|
|
|
userMenuLabel.setForeground(Color.white);
|
|
|
|
|
userMenuLabel.setIcon(new ImageIcon("static\\icon\\user1.png"));
|
|
|
|
|
}else if(source==inMenuLabel) {
|
|
|
|
|
inMenuLabel.setForeground(Color.white);
|
|
|
|
|
inMenuLabel.setIcon(new ImageIcon("static\\icon\\in1.png"));
|
|
|
|
|
}else if(source==outMenuLabel) {
|
|
|
|
|
outMenuLabel.setForeground(Color.white);
|
|
|
|
|
outMenuLabel.setIcon(new ImageIcon("static\\icon\\out1.png"));
|
|
|
|
|
}else if(source==storageMenuLabel) {
|
|
|
|
|
storageMenuLabel.setForeground(Color.white);
|
|
|
|
|
storageMenuLabel.setIcon(new ImageIcon("static\\icon\\storage1.png"));
|
|
|
|
|
}else if(source==supplierMenuLabel) {
|
|
|
|
|
supplierMenuLabel.setForeground(Color.white);
|
|
|
|
|
supplierMenuLabel.setIcon(new ImageIcon("static\\icon\\supplier1.png"));
|
|
|
|
|
}else if(source==catalogMenuLabel) {
|
|
|
|
|
catalogMenuLabel.setForeground(Color.white);
|
|
|
|
|
catalogMenuLabel.setIcon(new ImageIcon("static\\icon\\catalog1.png"));
|
|
|
|
|
} else {
|
|
|
|
|
userMenuLabel1.setForeground(Color.white);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void initView() {
|
|
|
|
|
// 初始化界面,未实现
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void windowOpened(WindowEvent e) {
|
|
|
|
|
// 窗口打开事件,未实现
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void windowClosing(WindowEvent e) {
|
|
|
|
|
Object source = e.getSource(); // 获取事件来源
|
|
|
|
|
if (source == this) { // 关闭窗口时检查进货系统和出货系统是否还有记录
|
|
|
|
|
this.vP = InView.getVector(); // 获取进货缓存
|
|
|
|
|
System.out.println("v的size=" + vP.size()); // 打印进货缓存大小
|
|
|
|
|
bufferImpl = new BufferImpl(); // 创建缓存实现类
|
|
|
|
|
if (vP.size() != 0 || bufferImpl.allOutBuffer().size() != 0) { // 如果购物车还有记录
|
|
|
|
|
CloseDialog closeDialog = new CloseDialog(this, vP); // 创建关闭对话框
|
|
|
|
|
closeDialog.setVisible(true); // 显示关闭对话框
|
|
|
|
|
} else {
|
|
|
|
|
System.exit(0); // 退出程序
|
|
|
|
|
}
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
Object source = e.getSource();
|
|
|
|
|
if(source==this) {/*关闭窗口时检查进货系统和出货系统是否还有记录*/
|
|
|
|
|
this.vP =InView.getVector();
|
|
|
|
|
System.out.println("v的size="+vP.size());
|
|
|
|
|
bufferImpl = new BufferImpl();
|
|
|
|
|
if(vP.size()!=0||bufferImpl.allOutBuffer().size()!=0) {/*如果购物车还有记录*/
|
|
|
|
|
CloseDialog closeDialog = new CloseDialog(this,vP);
|
|
|
|
|
closeDialog.setVisible(true);
|
|
|
|
|
}else
|
|
|
|
|
System.exit(0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@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
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|