📄 booksale.java
字号:
add1emploerPS.setSize(40,25);
add1emploerPS.setLocation(10,80);
Tadd1emploerPS=new JPasswordField();
Tadd1emploerPS.setSize(170,25);
Tadd1emploerPS.setLocation(60,80);
add1emploerPS1.setSize(40,25);
add1emploerPS1.setLocation(10,115);
Tadd1emploerPS1=new JPasswordField();
Tadd1emploerPS1.setSize(170,25);
Tadd1emploerPS1.setLocation(60,115);
morePS.setSize(100,25);
morePS.setLocation(235,115);
add1exe.setSize(40,25);
add1exe.setLocation(10,150);
Tadd1exe.setSize(170,25);
Tadd1exe.setLocation(60,150);
add1clear.setSize(80,25);
add1clear.setLocation(40,260);
add1.setSize(100,25);
add1.setLocation(140,260);
manageradd.add(add1hint);
manageradd.add(add1emploerID);
manageradd.add(Tadd1emploerID);
manageradd.add(add1emploerPS);
manageradd.add(Tadd1emploerPS);
manageradd.add(add1emploerPS1);
manageradd.add(Tadd1emploerPS1);
manageradd.add(morePS);
manageradd.add(add1exe);
manageradd.add(Tadd1exe);
manageradd.add(add1clear);
manageradd.add(add1);
add1clear.addActionListener(new manageradd());
add1.addActionListener(new manageradd());
manageradd.setLayout(null);
manageradd.setBackground(new Color(240,248,255));
//*******************
add2hint.setSize(200,25);
add2hint.setLocation(10,10);
add2bookname.setSize(80,25);
add2bookname.setLocation(10,45);
Tadd2bookname.setSize(170,25);
Tadd2bookname.setLocation(100,45);
add2bookISBN.setSize(80,25);
add2bookISBN.setLocation(10,80);
Tadd2bookISBN.setSize(170,25);
Tadd2bookISBN.setLocation(100,80);
add2bookprice.setSize(80,25);
add2bookprice.setLocation(10,115);
Tadd2bookprice.setSize(170,25);
Tadd2bookprice.setLocation(100,115);
add2bookmount.setSize(80,25);
add2bookmount.setLocation(10,150);
Tadd2bookmount.setSize(170,25);
Tadd2bookmount.setLocation(100,150);
add2bookauthor.setSize(80,25);
add2bookauthor.setLocation(10,185);
Tadd2bookauthor.setSize(170,25);
Tadd2bookauthor.setLocation(100,185);
add2clear.setSize(80,25);
add2clear.setLocation(40,260);
add2.setSize(100,25);
add2.setLocation(140,260);
kucunadd.add(add2hint);
kucunadd.add(add2bookname);
kucunadd.add(Tadd2bookname);
kucunadd.add(add2bookISBN);
kucunadd.add(Tadd2bookISBN);
kucunadd.add(add2bookprice);
kucunadd.add(Tadd2bookprice);
kucunadd.add(add2bookmount);
kucunadd.add(Tadd2bookmount);
kucunadd.add(add2bookauthor);
kucunadd.add(Tadd2bookauthor);
kucunadd.add(add2clear);
kucunadd.add(add2);
add2clear.addActionListener(new kucunadd());
add2.addActionListener(new kucunadd());
kucunadd.setLayout(null);
kucunadd.setBackground(new Color(240,248,255));
//***********************
add3hint.setSize(200,25);
add3hint.setLocation(10,10);
add3bookname.setSize(80,25);
add3bookname.setLocation(10,45);
Tadd3bookname.setSize(170,25);
Tadd3bookname.setLocation(100,45);
add3bookISBN.setSize(80,25);
add3bookISBN.setLocation(10,80);
Tadd3bookISBN.setSize(170,25);
Tadd3bookISBN.setLocation(100,80);
add3bookprice.setSize(80,25);
add3bookprice.setLocation(10,115);
Tadd3bookprice.setSize(170,25);
Tadd3bookprice.setLocation(100,115);
add3provider.setSize(80,25);
add3provider.setLocation(10,150);
Tadd3provider.setSize(170,25);
Tadd3provider.setLocation(100,150);
add3connectway.setSize(80,25);
add3connectway.setLocation(10,185);
Tadd3connectway.setSize(170,25);
Tadd3connectway.setLocation(100,185);
add3clear.setSize(80,25);
add3clear.setLocation(40,260);
add3.setSize(100,25);
add3.setLocation(140,260);
provideradd.add(add3hint);
provideradd.add(add3bookname);
provideradd.add(Tadd3bookname);
provideradd.add(add3bookISBN);
provideradd.add(Tadd3bookISBN);
provideradd.add(add3bookprice);
provideradd.add(Tadd3bookprice);
provideradd.add(add3connectway);
provideradd.add(Tadd3connectway);
provideradd.add(add3provider);
provideradd.add(Tadd3provider);
provideradd.add(add3clear);
provideradd.add(add3);
add3clear.addActionListener(new provideradd());
add3.addActionListener(new provideradd());
provideradd.setLayout(null);
provideradd.setBackground(new Color(240,248,255));
//**************************
addcp.add(jtp);//将选项卡加入窗体中
jtp.addChangeListener(this);
this.setSize(330,420);
}
public void stateChanged(ChangeEvent e)
{
if(e.getSource()==jtp)
{
final int i=((JTabbedPane)e.getSource()).getSelectedIndex();
this.setTitle("您选择了"+option[i]);
if(option[i]=="返回")
{
this.setVisible(false);
selectface.setVisible(true);
}
}
}
private class kucunadd implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==add2clear)
{
Tadd2bookmount.setText(null);
Tadd2bookprice.setText(null);
Tadd2bookauthor.setText(null);
Tadd2bookname.setText(null);
Tadd2bookISBN.setText(null);
} else
try
{
String bookname2=Tadd2bookname.getText();
String bookISBN2=Tadd2bookISBN.getText();
float bookprice2=Float.parseFloat(Tadd2bookprice.getText());
int bookmount2=Integer.parseInt(Tadd2bookmount.getText());
String bookauthor2=Tadd2bookauthor.getText();
if(e.getSource()==add2)
{
if(bookname2.length()==0||bookISBN2.length()==0)
{
JOptionPane.showMessageDialog(null,"您必须输入书名和ISBN编号");
}
else
{
String kucunsql="insert into kucun values('"+bookname2+"','"+bookISBN2+"',"+bookprice2+","+bookmount2+",'"+bookauthor2+"')";
methods.change(kucunsql);
JOptionPane.showMessageDialog(null," 添加操作成功~~");
}
}
}catch(NumberFormatException e2){JOptionPane.showMessageDialog(null,"您可能还没有输入完整");}
}
}
private class provideradd implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==add3clear)
{
Tadd3provider.setText(null);
Tadd3bookprice.setText(null);
Tadd3connectway.setText(null);
Tadd3bookname.setText(null);
Tadd3bookISBN.setText(null);
}else
try
{
String bookname3=Tadd3bookname.getText();
String bookISBN3=Tadd3bookISBN.getText();
float bookprice3=Float.parseFloat(Tadd3bookprice.getText());
String bookprovider3=Tadd3provider.getText();
String connectway3=Tadd3connectway.getText();
if(e.getSource()==add3)
{
if(bookname3.length()==0||bookISBN3.length()==0)
{
JOptionPane.showMessageDialog(null,"您必须输入书名和ISBN编号");
}
else
{
String providersql="insert into provider values('"+bookname3+"','"+bookISBN3+"',"+bookprice3+",'"+bookprovider3+"','"+connectway3+"')";
methods.change(providersql);
JOptionPane.showMessageDialog(null," 添加操作成功~~");
}
}
}catch(Exception ee){JOptionPane.showMessageDialog(null,"您可能还没有输入完整");}
}
}
private class manageradd implements ActionListener
{
@SuppressWarnings("deprecation")
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==add1clear)
{
Tadd1emploerID.setText(null);
Tadd1emploerPS.setText(null);
Tadd1emploerPS1.setText(null);
Tadd1exe.setText(null);
}
String emploerID1=Tadd1emploerID.getText();
String emploerPS1=Tadd1emploerPS.getText();
String emploerPS2=Tadd1emploerPS1.getText();
String exe1=Tadd1exe.getText();
if(e.getSource()==add1)
{
if(emploerPS1.length()==0||emploerID1.length()==0||exe1.length()==0||emploerPS2.length()==0)
{
JOptionPane.showMessageDialog(null,"您必须输入所有的选项");
}
else if(!emploerPS1.equals(emploerPS2))
{
JOptionPane.showMessageDialog(null,"您两次输入的密码不一致!");
}
else if(!exe1.equals("manager")&&!exe1.equals("emploer"))
{
JOptionPane.showMessageDialog(null,"您输入的权限有错误,应该为manager或者emplper");
}
else
{
String managersql="insert into manager values('"+emploerID1+"','"+emploerPS1+"','"+exe1+"')";
methods.change(managersql);
JOptionPane.showMessageDialog(null," 添加操作成功~~");
Tadd1emploerID.setText(null);
Tadd1emploerPS.setText(null);
Tadd1emploerPS1.setText(null);
Tadd1exe.setText(null);
}
}
}
}
}
//删除操作
class delete extends JFrame implements ActionListener,ItemListener
{
private static final long serialVersionUID = 1L;
method methods=new method();
JLabel hint;//显示"请输入要删除的信息"
JLabel hint1;//显示"请选择要删除的项"
JLabel bookISBN;//显示"ISBN编号"
JLabel bookname;//显示"书名"
JLabel provider;//显示"供应商"
JLabel ID;//显示"ID"
JLabel Password;//显示"请输入要删除的信息"
JTextField TbookISBN;
JTextField Tbookname;
JTextField Tprovider;
JButton deletekucun;//删除库存
JButton deletemanager;//删除管理员
JButton deleteprovider;//删除供应商
JButton deleteclear;//清除
JButton returntoselect;//返回到主界面
JRadioButton addchoice1;
JRadioButton addchoice2;
JRadioButton addchoice3;
Font myFont=new Font("宋体",Font.PLAIN,16);
Color color=new Color(34,139,34);
selectface selectface;
public delete(selectface selectptr)
{
super("欢迎进入图书销售系统删除界面");
selectface=selectptr;
hint=new JLabel("********请输入要删除的信息********");
hint.setFont(myFont);
hint.setForeground(color);
hint.setSize(280,25);
hint.setLocation(10,10);
hint1=new JLabel("********请选择要删除的表项********");
hint1.setFont(myFont);
hint1.setForeground(color);
hint1.setSize(280,25);
hint1.setLocation(10,220);
ID=new JLabel("ID*");
ID.setFont(myFont);
ID.setForeground(color);
ID.setSize(30,25);
ID.setLocation(10,45);
ID.setVisible(false);
TbookISBN=new JTextField();
TbookISBN.setFont(myFont);
TbookISBN.setForeground(color);
TbookISBN.setSize(160,25);
TbookISBN.setLocation(120,80);
Tbookname=new JTextField();
Tbookname.setFont(myFont);
Tbookname.setForeground(color);
Tbookname.setSize(160,25);
Tbookname.setLocation(120,45);
Tprovider=new JTextField();
Tprovider.setFont(myFont);
Tprovider.setForeground(color);
Tprovider.setSize(160,25);
Tprovider.setLocation(120,115);
Tprovider.setVisible(false);
Password=new JLabel("Password*");
Password.setFont(myFont);
Password.setForeground(color);
Password.setSize(80,25);
Password.setLocation(10,80);
Password.setVisible(false);
bookname=new JLabel("书名*");
bookname.setFont(myFont);
bookname.setForeground(color);
bookname.setSize(50,25);
bookname.setLocation(10,45);
bookISBN=new JLabel("ISBN编号*");
bookISBN.setFont(myFont);
bookISBN.setForeground(color);
bookISBN.setSize(80,25);
bookISBN.setLocation(10,80);
provider=new JLabel("供应商*");
provider.setFont(myFont);
provider.setForeground(color);
provider.setSize(80,25);
provider.setLocation(10,115);
provider.setVisible(false);
deleteclear=new JButton("清除");
deleteclear.setFont(myFont);
deleteclear.setForeground(color);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -