import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.table.*;
import java.sql.*;
import java.util.*;
import java.sql.Date;
import javax.swing.event.*;
import java.io.*;
import java.applet.Applet;
import java.net.MalformedURLException;
import java.net.URL;
import java.applet.AudioClip;
public class MainFrame implements ActionListener{
JDesktopPane dp=new JDesktopPane();//内部框架容器
JFrame mf=new JFrame("图书销售管理系统");
JMenuBar menu=new JMenuBar();
JMenu staff=new JMenu("职员");
JMenu member=new JMenu("会员");
JMenu book=new JMenu("图书");
JMenu sale=new JMenu("销售");
JMenu help=new JMenu("帮助");
JMenuItem sscan=new JMenuItem("浏览");
JMenuItem slook=new JMenuItem("查找");
JMenuItem sinsert=new JMenuItem("插入");
JMenuItem sdelete=new JMenuItem("删除");
JMenuItem supdate=new JMenuItem("修改");
JMenuItem mscan=new JMenuItem("浏览");
JMenuItem mlook=new JMenuItem("查找");
JMenuItem minsert=new JMenuItem("插入");
JMenuItem mdelete=new JMenuItem("删除");
JMenuItem mupdate=new JMenuItem("修改");
JMenuItem bscan=new JMenuItem("浏览");
JMenuItem blook=new JMenuItem("查找");
JMenuItem binsert=new JMenuItem("插入");
JMenuItem bdelete=new JMenuItem("删除");
JMenuItem bupdate=new JMenuItem("修改");
JMenuItem bbuy=new JMenuItem("购入");
JMenuItem bstore=new JMenuItem("库存统计");
JMenuItem osale=new JMenuItem("非会员购买");
JMenuItem msale=new JMenuItem("会员购买");
JMenuItem count=new JMenuItem("统计");
JMenuItem ask=new JMenuItem("库存查询");
JMenuItem music=new JMenuItem("背景音乐开始");
JMenuItem hf=new JMenuItem("帮助信息");
JMenuItem music2=new JMenuItem("背景音乐结束");
Connection con= null;
Statement stmt=null;
ResultSet rs= null;
PreparedStatement pstmt=null;
String name;//书名、会员名、职工名
String no;//书号、会员号、职工号
String bir;//出生日期,出版日期
String sex;//性别
String tel;//联系方式
String date;//出生日期,出版日期
String oprice;//售价
String sum;//图书库存量
String print;//出版社
String au;//作者
String year;
String month;
String day;
String lname;
URL cb;
AudioClip aau;
public MainFrame(){
mf.add(dp);
dp.setBackground(Color.blue);
menu.add(staff);
menu.add(member);
menu.add(book);
menu.add(sale);
menu.add(help);
staff.add(sscan);
sscan.addActionListener(this);
staff.add(slook);
slook.addActionListener(this);
staff.add(sinsert);
sinsert.addActionListener(this);
staff.add(sdelete);
sdelete.addActionListener(this);
staff.add(supdate);
supdate.addActionListener(this);
book.add(bscan);
bscan.addActionListener(this);
book.add(blook);
blook.addActionListener(this);
book.add(binsert);
binsert.addActionListener(this);
book.add(bdelete);
bdelete.addActionListener(this);
book.add(bupdate);
bupdate.addActionListener(this);
book.add(bbuy);
bbuy.addActionListener(this);
book.add(ask);
ask.addActionListener(this);
book.add(bstore);
bstore.addActionListener(this);
member.add(mscan);
mscan.addActionListener(this);
member.add(mlook);
mlook.addActionListener(this);
member.add(minsert);
minsert.addActionListener(this);
member.add(mdelete);
mdelete.addActionListener(this);
member.add(mupdate);
mupdate.addActionListener(this);
sale.add(osale);
osale.addActionListener(this);
sale.add(msale);
msale.addActionListener(this);
sale.add(count);
count.addActionListener(this);
help.add(hf);
help.add(music);
help.add(music2);
hf.addActionListener(this);
music.addActionListener(this);
music2.addActionListener(this);
mf.setJMenuBar(menu);
mf.setSize(1200,700);
mf.setVisible(true);
mf.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
} } );
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}catch(Exception eee){}
try{
File f = new File("F:\\When there was me and you.wav");
cb = f.toURL();
aau = Applet.newAudioClip(cb);
}catch(Exception eeee){}
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==sscan){//职工信息浏览
sscanf sca=new sscanf();
dp.add(sca);
try {
sca.setSelected(true);
} catch (java.beans.PropertyVetoException ex) {
System.out.println("Exception while selecting");
}
try{
con=DriverManager.getConnection("jdbc:odbc:Book","","");
stmt=con.createStatement();
rs=stmt.executeQuery("select * from staff");
while(rs.next()){
Vector v=new Vector();
no=rs.getString("sno");
name=rs.getString("sname");
tel=rs.getString("stel");
date=rs.getString("sbir");
sex=rs.getString("ssex");
v.add(no);
v.add(name);
v.add(sex);
v.add(date);
v.add(tel);
sca.tableModel.addRow(v);
}
}catch(Exception ex){}
try{
con.close();
}catch(Exception e5){}
}
else if(e.getSource()==bscan){//图书信息浏览
bscanf bca=new bscanf();
dp.add(bca);
try{
bca.setSelected(true);
}catch(Exception eex){}
try{
con=DriverManager.getConnection("jdbc:odbc:Book","","");
stmt=con.createStatement();
rs=stmt.executeQuery("select * from book");
while(rs.next()){
Vector v=new Vector();
no=rs.getString("bno");
name=rs.getString("bname");
oprice=Double.toString(rs.getDouble("bprice"));
date=rs.getString("bout");
sum=rs.getString("bsnum");
print=rs.getString("bprint");
au=rs.getString("bau");
v.add(no);
v.add(name);
v.add(oprice);
v.add(sum);
v.add(print);
v.add(au);
v.add(date);
bca.tableModel.addRow(v);
}
}catch(Exception ex){}
try{
con.close();
}catch(Exception e6){}
}
else if(e.getSource()==mscan){//会员信息浏览
mscanf mca=new mscanf();
dp.add(mca);
try{
mca.setSelected(true);
}catch(Exception eex){}
try{
con=DriverManager.getConnection("jdbc:odbc:Book","","");
stmt=con.createStatement();
rs=stmt.executeQuery("select * from member");
while(rs.next()){
Vector v=new Vector();
no=rs.getString("mno");
name=rs.getString("mname");
tel=rs.getString("mtel");
date=rs.getString("mbir");
sex=rs.getString("msex");
sum=Double.toString(rs.getDouble("mbuy"));
v.add(no);
v.add(name);
v.add(sex);
v.add(date);
v.add(tel);
v.add(sum);
mca.tableModel.addRow(v);
}
}catch(Exception ex){}
try{
con.close();
}catch(Exception e4){}
}
else if(e.getSource()==slook){
slookf slo=new slookf();
dp.add(slo);
}
else if(e.getSource()==blook){
blookf blo=new blookf();
dp.add(blo);
}
else if(e.getSource()==mlook){
mlookf mlo=new mlookf();
dp.add(mlo);
}
else if(e.getSource()==sinsert){
sinsertf sin=new sinsertf();
dp.add(sin);
}
else if(e.getSource()==minsert){
minsertf min=new minsertf();
dp.add(min);
}
else if(e.getSource()==binsert){
binsertf bin=new binsertf();
dp.add(bin);
}
else if(e.getSource()==sdelete){
dstafff dsf=new dstafff
- 1
- 2
- 3
- 4
前往页