📄 mainframe.java
字号:
package file2;
import javax.swing.*;
import java.awt.*;
import java.sql.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class mainFrame extends JFrame implements ActionListener{
//声明各种面版
private loadPanel loadPane=null;
private ModifyPanel modifyPane=null;
private addPanel addPane=null;
private DeletePane deletePane=null;
private FirstCatalogPane firstCatalog=null;
private SecondCatalogPane secondCatalog=null;
private ThirdCatalogPane thirdCatalog=null;
private GoodsInPane goodsInPane=null;
private GoodsOutPane goodsOutPane=null;
private GoodsInToPane goodsInToPane=null;
private GoodsOutToPane goodsOutToPane=null;
private FirstCatalogToPane firstTo=null;
private SecondCatalogToPane secondTo=null;
private ThirdCatalogToPane thirdTo=null;
private GoodsInFromPane goodsInFromPane=null;
private GoodsOutFromPane goodsOutFromPane=null;
private FirstCatalogFromPane firstFrom=null;
private SecondCatalogFromPane secondFrom=null;
private ThirdCatalogFromPane thirdFrom=null;
private DeleteItemFromFirstCatalog deleteItemFromFirstCatalog=null;
private DeleteItemFromSecondCatalog deleteItemFromSecondCatalog=null;
private DeleteItemFromThirdCatalog deleteItemFromThirdCatalog=null;
private DeleteItemFromoperationRecord deleteItemFromoperationRecord=null;
private BestSalerPane bestSalerPane=null;
private TotalSaleConditionOfToday totalSaleConditionOfToday=null;
private TotalSaleConditionOfThisMonth totalSaleConditionOfThisMonth=null;
private TotalSaleConditionOfThisYear totalSaleConditionOfThisYear=null;
private TotalStore totalStore=null;
//声明菜单栏
private JMenuBar bar=null;
//声明菜单
private JMenu file=null;
private JMenu queryTotal=null;
private JMenu querySingle=null;
private JMenu queryStatics=null;
private JMenu administrator=null;
private JMenu inAndOut=null;//声明"进出货处理"菜单项
private JMenu help=null;
//声明"文件"菜单的菜单项
private JMenuItem load=null;
private JMenuItem importFrom=null;
private JMenuItem importTo=null;
//声明importTo的子菜单
private JMenuItem goodsInTo=null;
private JMenuItem goodsOutTo=null;
private JMenuItem first_Catalog_To=null;
private JMenuItem second_Catalog_To=null;
private JMenuItem third_Catalog_To=null;
private JMenuItem exit=null;
//声明"总体查询"菜单的菜单项,查询结果中应包括具体的赢利额,每一类有一个赢利统计,在最后一行还应该有总赢利的统计
private JMenuItem salesOfToday=null;
private JMenuItem salesOfThisMonth=null;
private JMenuItem salesOfThisYear=null;
private JMenuItem stores_in=null;
//声明"分类查询"菜单的菜单项,查询结果中应包括具体的赢利额,在最后一行还应该有总赢利的统计
private JMenuItem saleOfToday=null;
private JMenuItem saleOfThisMonth=null;
private JMenuItem saleOfThisYear=null;
private JMenuItem store_in=null;
//声明"统计信息"菜单的菜单项,统计信息中应包括具体的赢利额
private JMenuItem bestSaler=null;
//声明"管理员"菜单的菜单项
private JMenuItem add=null;
private JMenuItem modify=null;
private JMenuItem delete=null;
//声明"进出货处理"菜单的菜单项
private JMenuItem First_In=null;//声明录入商品大类菜单项
private JMenuItem Second_In=null;
private JMenuItem Third_In=null;
private JMenuItem goods_In=null;
private JMenuItem goods_Out=null;
private JMenuItem First_Delete=null;//声明删除商品大类菜单项
private JMenuItem Second_Delete=null;
private JMenuItem Third_Delete=null;
private JMenuItem goods_In_Out_Delete=null;
//声明"帮助"菜单的菜单项
private JMenuItem help_about=null;
public mainFrame(){
//在窗口中加入菜单栏
bar=new JMenuBar();
this.setJMenuBar(bar);
this.setTitle("闽南日化用品销售管理系统");
this.setSize(600, 500);
this.setLocation(100, 100);
//加入"文件"菜单及其菜单项
file=new JMenu("文件");
load=new JMenuItem("登陆系统");
importFrom=new JMenuItem("导入数据");
importTo=new JMenuItem("导出数据");
/*goodsInTo=new JMenuItem("进货情况");
goodsOutTo=new JMenuItem("出货情况");
first_Catalog_To=new JMenuItem("商品大类");
second_Catalog_To=new JMenuItem("商品明细类");
third_Catalog_To=new JMenuItem("具体商品");
*/
exit=new JMenuItem("退出系统");
file.add(load);
file.add(importFrom);
file.add(importTo);
file.add(exit);
bar.add(file);
//未登陆时置以下菜单项为不可用
importFrom.setEnabled(false);
importTo.setEnabled(false);
//加入"总体查询"菜单及其菜单项
queryTotal=new JMenu("总体查询");
salesOfToday=new JMenuItem("本日销售情况");
salesOfThisMonth=new JMenuItem("本月销售情况");
salesOfThisYear=new JMenuItem("本年销售情况");
stores_in=new JMenuItem("总体库存情况");
queryTotal.add(salesOfToday);
queryTotal.add(salesOfThisMonth);
queryTotal.add(salesOfThisYear);
queryTotal.add(stores_in);
bar.add(queryTotal);
//未登陆时置以下菜单项为不可用
salesOfToday.setEnabled(false);
salesOfThisMonth.setEnabled(false);
salesOfThisYear.setEnabled(false);
stores_in.setEnabled(false);
//加入"分类查询"菜单及其菜单项
querySingle=new JMenu("分类查询");
saleOfToday=new JMenuItem("本日销售情况");
saleOfThisMonth=new JMenuItem("本月销售情况");
saleOfThisYear=new JMenuItem("本年销售情况");
store_in=new JMenuItem("分类库存情况");
querySingle.add(saleOfToday);
querySingle.add(saleOfThisMonth);
querySingle.add(saleOfThisYear);
querySingle.add(store_in);
bar.add(querySingle);
//未登陆时置以下菜单项为不可用
saleOfToday.setEnabled(false);
saleOfThisMonth.setEnabled(false);
saleOfThisYear.setEnabled(false);
store_in.setEnabled(false);
//加入"统计信息"菜单及其菜单项
queryStatics=new JMenu("统计信息");
bestSaler=new JMenuItem("最畅销/最赢利/销售额最大的商品");
queryStatics.add(bestSaler);
bar.add(queryStatics);
bestSaler.setEnabled(false);
//加入"进出货处理"菜单及其菜单项
inAndOut=new JMenu("商品管理");
First_In=new JMenuItem("商品大类录入");
Second_In=new JMenuItem("商品明细类录入");
Third_In=new JMenuItem("具体商品录入");
goods_In=new JMenuItem("进货录入");
goods_Out=new JMenuItem("出货录入");
JMenuItem space=new JMenuItem("-----------------");
First_Delete=new JMenuItem("删除商品大类");
Second_Delete=new JMenuItem("删除商品明细类");
Third_Delete=new JMenuItem("删除具体商品");
goods_In_Out_Delete=new JMenuItem("删除进出货记录");
First_Delete.setEnabled(false);
Second_Delete.setEnabled(false);
Third_Delete.setEnabled(false);
goods_In_Out_Delete.setEnabled(false);
inAndOut.add(First_In);
inAndOut.add(Second_In);
inAndOut.add(Third_In);
inAndOut.add(goods_In);
inAndOut.add(goods_Out);
inAndOut.add(space);
inAndOut.add(First_Delete);
inAndOut.add(Second_Delete);
inAndOut.add(Third_Delete);
inAndOut.add(goods_In_Out_Delete);
bar.add(inAndOut);
First_In.setEnabled(false);
Second_In.setEnabled(false);
Third_In.setEnabled(false);
goods_In.setEnabled(false);
goods_Out.setEnabled(false);
//加入"管理员管理"菜单及其菜单项
administrator=new JMenu("管理员管理");
add=new JMenuItem("添加管理员");
modify=new JMenuItem("修改管理员信息");
delete=new JMenuItem("删除管理员");
administrator.add(add);
administrator.add(modify);
administrator.add(delete);
bar.add(administrator);
add.setEnabled(false);
modify.setEnabled(false);
delete.setEnabled(false);
//加入"帮助"菜单及其菜单项
help=new JMenu("帮助");
help_about=new JMenuItem("关于本系统");
help.add(help_about);
bar.add(help);
load.addActionListener(this);
importFrom.addActionListener(this);
importTo.addActionListener(this);
modify.addActionListener(this);
exit.addActionListener(this);
bestSaler.addActionListener(this);
salesOfToday.addActionListener(this);
salesOfThisMonth.addActionListener(this);
salesOfThisYear.addActionListener(this);
stores_in.addActionListener(this);
saleOfToday.addActionListener(this);
saleOfThisMonth.addActionListener(this);
saleOfThisYear.addActionListener(this);
store_in.addActionListener(this);
add.addActionListener(this);
delete.addActionListener(this);
First_In.addActionListener(this);
Second_In.addActionListener(this);
Third_In.addActionListener(this);
goods_In.addActionListener(this);
goods_Out.addActionListener(this);
First_Delete.addActionListener(this);
Second_Delete.addActionListener(this);
Third_Delete.addActionListener(this);
goods_In_Out_Delete.addActionListener(this);
help_about.addActionListener(this);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==exit){
System.exit(0);
}
if(e.getSource()==help_about){
JOptionPane.showMessageDialog(null, "只有在成功登陆本系统后才能进行各种操作,请您先登陆...", "提示", JOptionPane.INFORMATION_MESSAGE);
return;
}
if(e.getSource()==load){
loadPane=new loadPanel();
JDialog dialog=new JDialog(this,true);
dialog.setSize(350, 300);
dialog.setLocation(100, 50);
dialog.getContentPane().add(loadPane);
dialog.setVisible(true);
if(loadPane.getIsAdministrator()){
modify.setEnabled(true);
importFrom.setEnabled(true);
importTo.setEnabled(true);
salesOfToday.setEnabled(true);
salesOfThisMonth.setEnabled(true);
salesOfThisYear.setEnabled(true);
stores_in.setEnabled(true);
saleOfToday.setEnabled(true);
saleOfThisMonth.setEnabled(true);
saleOfThisYear.setEnabled(true);
store_in.setEnabled(true);
bestSaler.setEnabled(true);
add.setEnabled(true);
delete.setEnabled(true);
First_In.setEnabled(true);
Second_In.setEnabled(true);
Third_In.setEnabled(true);
goods_In.setEnabled(true);
goods_Out.setEnabled(true);
First_Delete.setEnabled(true);
Second_Delete.setEnabled(true);
Third_Delete.setEnabled(true);
goods_In_Out_Delete.setEnabled(true);
}
return;
}
//导出数据处理
if(e.getSource()==importTo){
String[] values={"出货情况","进货情况","所有商品大类","所有商品明细类","所有具体商品"};
String selectedValue=(String)JOptionPane.showInputDialog(null, "请选择导出数据类别:","数据的导出 ",JOptionPane.INFORMATION_MESSAGE,null,values,values[0]);
if(selectedValue==null){
//JOptionPane.showMessageDialog(null, "请选择导出数据类别!","警告",JOptionPane.ERROR_MESSAGE);
return;
}
if(selectedValue.equals("进货情况")){
goodsInToPane=new GoodsInToPane(this);
return;
}
if(selectedValue.equals("出货情况")){
goodsOutToPane=new GoodsOutToPane(this);
return;
}
if(selectedValue.equals("所有商品大类")){
firstTo=new FirstCatalogToPane(this);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -