1、网上书店完整代码附录 全部源代码package class Connect private static Connection con = null; private static String url=jdbc:oracle:thin:localhost:1521:ORCL; private static String driver = ; private static String user = scott; private static String pwd = tiger; public static Connection getConnection() try (driver); c
2、on = (url, user, pwd); 数据库连接成功!); catch (ClassNotFoundException e) 驱动加载失败!); catch (SQLException e) 数据库连接失败!); return con; public static void main(String args) (); package class docMenuAction implements ActionListener RegisterFrame register = null; JPanel cusPanel = null; JPanel docPanel = null; pub
3、lic docMenuAction(RegisterFrame register) = register; = ; = ; public void actionPerformed(ActionEvent e) 于用户搜索商品 public ArrayList getAllSellerGoods() ArrayList list = new ArrayList(); conn = (); try statement = (); String sql = select * from goods a,seller b where =; resultSet = (sql); while() Selle
4、r seller = new Seller(); (seller_name); (address); Goods goods = new Goods(); (seller); (goods_id); (goods_name); (seller_id); (discount); (num); (price); 2012-9-192012-9-192012-9-192012-9-19etImage(); (null); (null); (false);etImage(); (600, 400); ; (null); (menuBar,; setGoodsPanel(); ; (goodsPanel
5、,; ; setSouthPanel(); setOrderPanel(); (southPanel,; quals() (null, 请输入商品编号或商品数量!); else int id = (); int num = (String) (); goods = (id); if(null, 您确定要购买吗)=0) if()=0) (null, 商品编号输入错误!); else if()num) (null, 商品数量不足!); else ()-num); (goods); OrderDao order = new OrderDao(); (goods, num); (null, 购买成功!
6、); setAr(); setOr(); (); else ); etName(); ari7=().getAddress(); private void setArNull() for(int i=0;i;i+) for(int j=0;jari.length;j+) arij=; etName(); ori3=().getPrice(); ori4=().getDiscount(); ori5=().getPrice()*().getDiscount()*; ori6=(); ori7=().getName(); ori8=().getAddress(); private void set
7、OrNull() for(int i=0;i;i+) for(int j=0;jori.length;j+) orij=; public static void main(String args) BuyerFrame frame = new BuyerFrame(); (true); package class LoginFrame extends JFrame private JLabel userNameLabel = new JLabel(用户名:); private JLabel pwdLabel = new JLabel(密 码:); private JTextField useN
8、ameText = new JTextField(); private JPasswordField pws = new JPasswordField(); private JLabel roleLabel = new JLabel(角色:); private JComboBox roleBox = new JComboBox(new String商家,买家); private JButton bt = new JButton(确定); private JButton btR = new JButton(取消); private String flag = null; public Login
9、Frame() init(); private void init() (320, 280); (登录); (new ImageIcon(images/).getImage(); (null); (false); ; (null); (40, 20, 150, 30); (userNameLabel); (120, 20, 150, 30); (useNameText); (40, 80, 150, 30); (pwdLabel); (120, 80, 150, 30); (pws); (40, 140, 70, 30); (roleLabel); (120, 140, 150, 30); (
10、roleBox); (40, 200, 70, 30); (btR); (new ActionListener() Override public void actionPerformed(ActionEvent e) quals(f) flag = seller; if(买家.equals(f) flag = customer; if(seller.equals(flag) Seller seller = (), (); -+(); if()=null) (null, 用户名或密码输入错误); else setVisible(false); SellerFrame fame = new Se
11、llerFrame(); (true); if(customer.equals(flag) Buyer buyer = (), (); if()=null) (null, 用户名或密码输入错误); else setVisible(false); BuyerFrame frame = new BuyerFrame(); (true); 2012-9-20etImage(); (300, 400);etImage(); (600, 400); ; (null); (menuBar,; setGoodsPanel(); ; (goodsPanel,; ; setSouthPanel(); setOr
12、derPanel(); (southPanel,; quals() (null, 请输入商品编号!); else int id = (); UpdateFrame frame = new UpdateFrame(); Goods goods = new GoodsDao().getOneGoods(id); if()!=0) (goods); (goods); (true); else (null, 商品编号输入错误!); ); (btDelet); quals() (null, 请输入商品编号!); else int id = (); GoodsDao dao = new GoodsDao(
13、); if(null, 您确定要删除吗)=0) if(id)!=0) (null, 删除成功!); else (null, 商品编号输入错误!); else ); (btAdd); (new ActionListener() Override public void actionPerformed(ActionEvent e) etName(); ari7=().getAddress(); private void setArNull() for(int i=0;i;i+) for(int j=0;jari.length;j+) arij=; etName(); ori3=().getPric
14、e(); ori4=().getDiscount(); ori5=().getPrice()*().getDiscount()*; ori6=(); ori7=(); private void setOrNull() for(int i=0;i;i+) for(int j=0;jori.length;j+) orij=; public static void main(String args) SellerFrame frame = new SellerFrame(); (true); package class UpdateFrame extends JFrame private stati
15、c final Goods Goods = null; private JLabel lbName = new JLabel(商品名:); private JLabel lbPrice = new JLabel(价格:); private JLabel lbDiscount = new JLabel(折扣:); private JLabel lbNum = new JLabel(数量:); private JTextField fieldName = new JTextField(20); private JTextField fieldPrice = new JTextField(20);
16、private JTextField fieldDiscount = new JTextField(20); private JTextField fieldNum = new JTextField(20); private JButton btSure = new JButton(修改); private JButton btCancel = new JButton(取消); private Goods goods = new Goods(); public UpdateFrame() init(); private void init() (320, 330); (修改商品信息); (ne
17、w ImageIcon(images/).getImage(); (null); (null); (false);/ ; (null); setText(goods); setContentPanel(); private void setContentPanel() (30, 30, 80, 30); (130, 30, 150, 30); (30, 90, 80, 30); (130, 90, 150, 30); (30, 150, 80, 30); (130, 150, 150, 30); (30, 200, 80, 30); (130, 200, 150, 30); (30, 250,
18、 70, 30); (210, 250, 70, 30); (lbName); (fieldName); (lbPrice); (fieldPrice); (lbDiscount); (fieldDiscount); (lbNum); (fieldNum); (btCancel); (btSure); (new ActionListener() Override public void actionPerformed(ActionEvent e) / TODO Auto-generated method stub setVisible(false); ); (new ActionListene
19、r() Override public void actionPerformed(ActionEvent e) / TODO Auto-generated method stub if(null, 您确定要修改吗)=0) GoodsDao dao = new GoodsDao(); (); (); (); (); (goods); setVisible(false); (null, 修改成功!); else / ); public void setText(Goods goods) (); (); (); (); public Goods getGoods() return goods; pu
20、blic void setGoods(Goods goods) = goods; public static void main(String args) UpdateFrame frame = new UpdateFrame(); (true); 数据库SQL语句:create table seller( seller_id varchar2(20) primary key, seller_name varchar2(20), pwd varchar2(20), address varchar2(200)insert into seller values(niclascage,长理专卖店,1
21、23456,湖南长沙)select * from sellerdrop table sellercommitcreate table buyer( buyer_id varchar(20) primary key, buyer_name varchar(20), pwd varchar2(20), address varchar(200)insert into buyer values(lina,林大专卖店,123456,湖南长沙)select * from buyerdrop table buyer create table goods( goods_id int primary key,
22、seller_id varchar(20), goods_name varchar(50), price int, discount int, num int, constraint fk_seller_id foreign key(seller_id) references seller(seller_id)insert into goods values(1,niclascage,Java,40,8,20)select * from goodsdrop table goods create table orders( order_id int primary key, goods_id i
23、nt, seller_id varchar(20), buyer_id varchar(20), num int, constraint fk_goods_id foreign key(goods_id) references goods(goods_id), constraint fk_sellers_id foreign key(seller_id) references seller(seller_id), constraint fk_buyer_id foreign key(buyer_id) references buyer(buyer_id)select * from ordersinsert into orders values(1,1,niclascage,lina,2)drop table orders;drop table goods;drop table buyer;drop table seller;
copyright@ 2008-2023 冰点文库 网站版权所有
经营许可证编号:鄂ICP备19020893号-2