📄 booksale.java
字号:
JOptionPane.showMessageDialog(null,"已经成功进货~~");
}
}
catch(NumberFormatException e1){JOptionPane.showMessageDialog(null,"您还没输入或者输入内容或格式错误");}
}
}
//退货操作界面
class back extends JFrame implements ActionListener
{
private static final long serialVersionUID = 1L;
method methods=new method();
Font myFont=new Font("宋体",Font.PLAIN,16);
JPanel showpanel=new JPanel();
JButton backreturntoselect;//返回到选择界面
JButton backconfirm;//确定
JButton backclear;//查询
JLabel backISBN;//salehint 显示"ISBN编号"
JTextField TbackISBN;//ISBN编号
JLabel backamount;//stockamount显示"退货数量"
JTextField Tbackamount;//退货数量
JLabel backbookinf;//showsaleinf显示"退货后本书的详细信息如下"
JLabel backbookinf1;//showsaleinf1显示"退货详细信息"
JTextArea backshow=new JTextArea();//statshow用来显示某书的销售的详细信息
JScrollPane backshowscroll=new JScrollPane(backshow);
JTextArea backshow1=new JTextArea();//statshow用来显示某书的销售的详细信息
JScrollPane backshowscroll1=new JScrollPane(backshow1);
selectface selectface;
public back(selectface selectptr)
{
super("欢迎进入图书销售系统退货界面");
selectface=selectptr;
Color color=Color.blue;
backISBN=new JLabel("ISBN编号*");
backISBN.setFont(myFont);
backISBN.setForeground(color);
backISBN.setSize(80,25);
backISBN.setLocation(10,10);
TbackISBN=new JTextField();
TbackISBN.setFont(myFont);
TbackISBN.setForeground(color);
TbackISBN.setSize(185,25);
TbackISBN.setLocation(100,10);
backamount=new JLabel("退货数量*");
backamount.setFont(myFont);
backamount.setForeground(color);
backamount.setSize(80,25);
backamount.setLocation(10,50);
Tbackamount=new JTextField();
Tbackamount.setFont(myFont);
Tbackamount.setForeground(color);
Tbackamount.setSize(185,25);
Tbackamount.setLocation(100,50);
backbookinf=new JLabel("退货书本信息:");
backbookinf.setFont(myFont);
backbookinf.setForeground(color);
backbookinf.setSize(135,25);
backbookinf.setLocation(10,85);
backbookinf1=new JLabel("退货详细信息:");
backbookinf1.setFont(myFont);
backbookinf1.setForeground(color);
backbookinf1.setSize(135,25);
backbookinf1.setLocation(155,85);
backshowscroll.setSize(135,150);
backshowscroll.setLocation(10,110);
backshowscroll1.setSize(135,150);
backshowscroll1.setLocation(155,110);
backreturntoselect=new JButton("返回");
backreturntoselect.setFont(myFont);
backreturntoselect.setSize(80,20);
backreturntoselect.setLocation(15,300);
backconfirm=new JButton("确定");
backconfirm.setFont(myFont);
backconfirm.setSize(80,20);
backconfirm.setLocation(105,300);
backclear=new JButton("清除");
backclear.setFont(myFont);
backclear.setSize(80,20);
backclear.setLocation(195,300);
Container backcp=getContentPane();
backcp.setBackground(Color.white);
backcp.setLayout(null);//将布局方式设置为空
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(300,400);
setResizable(false);
backcp.add(backISBN);
backcp.add(TbackISBN);
backcp.add(backamount);
backcp.add(Tbackamount);
backcp.add(backbookinf);
backcp.add(backbookinf1);
backcp.add(backshowscroll);
backcp.add(backshowscroll1);
backcp.add(backreturntoselect);
backcp.add(backconfirm);
backcp.add(backclear);
backreturntoselect.addActionListener(this);
backconfirm.addActionListener(this);
backclear.addActionListener(this);
backcp.setBackground(new Color(230,230,250));//设置随机的背景颜色
setVisible(false);
}
public void actionPerformed(ActionEvent e)
{
int backmount=0;
float totalbackprice=0;//退货的书的总价格
int tokucunmount=0;//mount3为退书的数量和库存量相加的结果
if(e.getSource()==backreturntoselect)
{
this.setVisible(false);
selectface.setVisible(true);
}
else if(e.getSource()==backclear)
{
clear();
}
else
try
{
if(e.getSource()==backconfirm)
{
String backmount1=Tbackamount.getText();
backmount=Integer.parseInt(backmount1);
String backISBN=TbackISBN.getText();
String querysql="select * from kucun where ISBN ='"+backISBN+"'";
methods.querykucun(querysql,backshow);
String kucunbookname=methods.kucunbookname;//将库存的图书的书名赋值给kucunboolname
float kucunprice=methods.kucunprice;//将库存的图书的价格赋值给kucunprice
int nowmount=methods.nowmount;//将库存中书的数量赋值给nowmount
if(methods.querykucun(querysql,backshow)==0)//读者需要的书在库存中不存在的情况
{
JOptionPane.showMessageDialog(null,"输入有错误或者您的书不是在本店买的!");
}
else
{
totalbackprice=backmount*(methods.kucunprice);
String insertsql="insert into tuihuo values('"+kucunbookname+"','"+backISBN+"',"+kucunprice+",'"+methods.returnTime()+"',"+backmount+","+totalbackprice+")";
methods.change(insertsql);
tokucunmount=nowmount+backmount;
String updatesql="update kucun set nowmount="+(tokucunmount)+" where ISBN='"+backISBN+"'";
methods.change(updatesql);
backshow1.setText("退货时间"+methods.returnTime()+"\n数量为:"+backmount+"\n单价为:"+kucunprice+"\n总金额为:"+backmount*kucunprice);
JOptionPane.showMessageDialog(null,"操作已经成功完成~ ~");
}
}
}catch(Exception ex){JOptionPane.showMessageDialog(null,"您还没输入或者是输入的格式错误");}
}
private void clear()
{
TbackISBN.setText(null);
Tbackamount.setText(null);
backshow.setText(null);
backshow1.setText(null);
}
}
//统计操作窗口
class stat extends JFrame implements ActionListener,ItemListener
{
private static final long serialVersionUID = 1L;
method methods=new method();
JButton statconfirm;
JButton statreturntoselect;
JButton statclear;
JLabel selectmonth;//selectmonth 显示"请选择要查询的月份"
JLabel showlist;//showlist显示"下面是此月图书销售排行榜"
JLabel showsaleinf;//showsaleinf显示"下面是本月的收支情况"
JTextArea statshow1=new JTextArea();//statshow1用来显示某月的销售信息
JScrollPane statshowscroll1=new JScrollPane(statshow1);
JTextArea statshow2=new JTextArea();//statshow2用来显示某月的销售排行榜
JScrollPane statshowscroll2=new JScrollPane(statshow2);
selectface selectface;
public stat(selectface selectptr)
{
super("欢迎进入图书销售系统统计界面");
selectface=selectptr;
selectmonth=new JLabel("请选择您要查询的月份");
selectmonth.setSize(180,30);
selectmonth.setLocation(10,10);
String str[]={"请选择","1","2","3","4","5","6","7","8","9","10","11","12"};
JComboBox Month=new JComboBox(str);
Month.setSize(70,20);
Month.setLocation(210,15);
showlist=new JLabel("下面是本月图书销售排行榜");
showlist.setSize(200,20);
showlist.setLocation(10,50);
statshowscroll1.setBackground(new Color(240,248,255));
statshowscroll1.setSize(275,70);
statshowscroll1.setLocation(10,80);
showsaleinf=new JLabel("下面是本月的收支情况");
showsaleinf.setSize(200,20);
showsaleinf.setLocation(10,160);
statshowscroll2.setBackground(new Color(240,248,255));
statshowscroll2.setSize(275,70);
statshowscroll2.setLocation(10,190);
statconfirm=new JButton("确定");
statconfirm.setSize(80,20);
statconfirm.setLocation(105,300);
statreturntoselect=new JButton("返回");
statreturntoselect.setSize(80,20);
statreturntoselect.setLocation(15,300);
statclear=new JButton("清除");
statclear.setSize(80,20);
statclear.setLocation(195, 300);
Container statcp=getContentPane();
statcp.setLayout(null);//将布局方式设置为空
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(300,400);
statcp.add(selectmonth);
statcp.add(Month);
statcp.add(showlist);
statcp.add(showsaleinf);
statcp.add(statshowscroll1);
statcp.add(statshowscroll2);
statcp.add(statreturntoselect);
statcp.add(statconfirm);
statcp.add(statclear);
Month.addItemListener(this);
statclear.addActionListener(this);
statconfirm.addActionListener(this);
statreturntoselect.addActionListener(this);
statcp.setBackground(new Color(240,248,255));//设置随机的背景颜色
setVisible(false);//将窗口设置为可见
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==statreturntoselect)
{
this.setVisible(false);
selectface.setVisible(true);
}
else if(e.getSource()==statclear)
{
statshow1.setText(null);
statshow2.setText(null);
}
/*if(e.getSource()==statconfirm)
{
methods.queryrxiaoshou(statshow1,int selectm);
}*/
}
public void itemStateChanged(ItemEvent e)
{
JComboBox choice=(JComboBox)e.getItemSelectable();
try
{
for(int i=1;i<=12;i++)
{
if(choice.getSelectedIndex()==i)
{
statshow1.setText(null);
statshow2.setText(null);
methods.queryrxiaoshou(statshow1,i);
if(statshow1.getText().length()==0)
{
JOptionPane.showMessageDialog(null,"没有您要查询的结果");
}
else
{
float stocktotalprice=methods.stocktotalprice("jhuoku","buytime",i);
float backtotalprice=methods.stocktotalprice("tuihuo","thtime",i);
float selltotalprice=methods.stocktotalprice("rxiaoshou","selltime",i);
float profit=selltotalprice-(stocktotalprice+backtotalprice);
statshow2.setText(i+"月的进货总额:"+stocktotalprice+"\n"+i+"月的退货总额为:"+backtotalprice+"\n"+i+"月的销售总额为"+selltotalprice+"\n"+i+"月的利润为:"+profit);
}
}
}
}catch(Exception el){System.out.print(el.getMessage());}
}
}
//添加界面
class add extends JFrame implements ChangeListener
{
private static final long serialVersionUID = 1L;
selectface selectface;
method methods=new method();
JTabbedPane jtp;
JPanel kucunadd=new JPanel();//库存添加的面板
JPanel manageradd=new JPanel(); //人员管理添加的面板
JPanel provideradd=new JPanel(); //供应商添加的面板
JPanel backadd=new JPanel();//返回选择界面
String option[]={"管理人员的添加","供应商的添加","库存的添加","返回"};
//人员管理添加的各控件
JButton add1=new JButton("添加");
JButton add1clear=new JButton("清除");
JLabel add1hint=new JLabel("请在下面输入要添加的信息");
JLabel add1emploerID=new JLabel("ID*");
JTextField Tadd1emploerID=new JTextField();
JPasswordField Tadd1emploerPS;
JPasswordField Tadd1emploerPS1;
JLabel add1emploerPS=new JLabel("PS*");
JLabel add1emploerPS1=new JLabel("PS*");
JLabel morePS=new JLabel("请再输入一遍");
JLabel add1exe=new JLabel("权限*");
JTextField Tadd1exe=new JTextField();
//库存添加的各控件
JButton add2=new JButton("添加");
JButton add2clear=new JButton("清除");
JLabel add2hint=new JLabel("请在下面输入要添加的信息");
JLabel add2bookname=new JLabel("书名*");
JTextField Tadd2bookname=new JTextField();
JLabel add2bookISBN=new JLabel("ISBN编号*");
JTextField Tadd2bookISBN=new JTextField();
JLabel add2bookprice=new JLabel("价格*");
JTextField Tadd2bookprice=new JTextField();
JLabel add2bookmount=new JLabel("数量*");
JTextField Tadd2bookmount=new JTextField();
JLabel add2bookauthor=new JLabel("作者");
JTextField Tadd2bookauthor=new JTextField();
//供应商添加的各控件
JButton add3=new JButton("添加");
JButton add3clear=new JButton("清除");
JLabel add3hint=new JLabel("请在下面输入要添加的信息");
JLabel add3bookname=new JLabel("书名*");
JTextField Tadd3bookname=new JTextField();
JLabel add3bookISBN=new JLabel("ISBN编号*");
JTextField Tadd3bookISBN=new JTextField();
JLabel add3bookprice=new JLabel("价格*");
JTextField Tadd3bookprice=new JTextField();
JLabel add3provider=new JLabel("供应商*");
JTextField Tadd3provider=new JTextField();
JLabel add3connectway=new JLabel("联系方式");
JTextField Tadd3connectway=new JTextField();
public add(selectface selectptr)
{
super("欢迎进入图书销售系统添加界面");
selectface=selectptr;
Container addcp=getContentPane();
jtp=new JTabbedPane();
jtp.addTab("库存添加",kucunadd);
jtp.addTab("人员管理添加",manageradd);
jtp.addTab("供应商添加",provideradd);
jtp.addTab("返回",backadd);
add1hint.setSize(200,25);
add1hint.setLocation(10,10);
add1emploerID.setSize(40,25);
add1emploerID.setLocation(10,45);
Tadd1emploerID.setSize(170,25);
Tadd1emploerID.setLocation(60,45);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -