基于java的图书管理系统源代码(共64页).doc
《基于java的图书管理系统源代码(共64页).doc》由会员分享,可在线阅读,更多相关《基于java的图书管理系统源代码(共64页).doc(64页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、精选优质文档-倾情为你奉上声明:本系统是基于C/S的图书管理系统,主要使用的是Oracle数据库,下面附所有实现代码package library;import java.awt.BorderLayout;import java.awt.Container;import java.awt.GridLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.sql.ResultSet;import javax.swing.JButton;import javax.swing.J
2、ComboBox;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JTextField;public class book_add extends JFrame implements ActionListenerDataBaseManager db=new DataBaseManager();ResultSet rs;JPanel panel1,panel2;JLabel book_id_
3、label,book_name_label,author_label,press_label,press_date_label,price_label,book_num_label,borrowed_num_label,address;JTextField book_id_TextField,book_name_TextField,author_TextField,press_TextField,press_date_TextField,price_TextField,book_num_TextField,borrowed_count;JComboBox addresst;Container
4、c;JButton clear,add,exit;public book_add()super(添加图书信息);c=getContentPane();c.setLayout(new BorderLayout();book_id_label=new JLabel(编号,JLabel.CENTER);book_name_label=new JLabel(名称,JLabel.CENTER);author_label=new JLabel(作者,JLabel.CENTER);press_label=new JLabel(出版社,JLabel.CENTER);press_date_label=new J
5、Label(出版日期,JLabel.CENTER);price_label=new JLabel(价格,JLabel.CENTER);book_num_label=new JLabel(库存数,JLabel.CENTER);borrowed_num_label=new JLabel(已借阅数,JLabel.CENTER);address=new JLabel(藏书地址,JLabel.CENTER); book_id_TextField=new JTextField(15); book_name_TextField=new JTextField(15); author_TextField=new
6、 JTextField(15); press_TextField=new JTextField(15); press_date_TextField=new JTextField(15); price_TextField=new JTextField(15); book_num_TextField=new JTextField(15); borrowed_count=new JTextField(15); borrowed_count.setText(0); addresst=new JComboBox(); addresst.addItem(扬子津图书馆); addresst.addItem(
7、荷花池图书馆); addresst.addItem(瘦西湖图书馆); addresst.addItem(淮海路图书馆); panel1=new JPanel(); panel1.setLayout(new GridLayout(9,2); panel1.add(book_id_label); panel1.add(book_id_TextField); panel1.add(book_name_label); panel1.add(book_name_TextField); panel1.add(press_label); panel1.add(press_TextField); panel1
8、.add(author_label); panel1.add(author_TextField); panel1.add(press_date_label); panel1.add(press_date_TextField); panel1.add(price_label); panel1.add(price_TextField); panel1.add(book_num_label); panel1.add(book_num_TextField); panel1.add(borrowed_num_label); panel1.add(borrowed_count); panel1.add(a
9、ddress); panel1.add(addresst); panel2=new JPanel(); panel2.setLayout(new GridLayout(1,3); clear=new JButton(清空); clear.addActionListener(this); add=new JButton(添加); add.addActionListener(this); exit=new JButton(退出); exit.addActionListener(this); panel2.add(clear); panel2.add(add); panel2.add(exit);
10、c.add(panel1,BorderLayout.CENTER); c.add(panel2,BorderLayout.SOUTH); setVisible(true);public void actionPerformed(ActionEvent e)if(e.getSource()=exit)this.dispose();else if(e.getSource()=clear)book_id_TextField.setText();book_name_TextField.setText();author_TextField.setText();press_TextField.setTex
11、t();press_date_TextField.setText();price_TextField.setText();book_num_TextField.setText();else if(e.getSource()=add)if(book_id_TextField.getText().trim().equals()JOptionPane.showMessageDialog(null, 书号不能为空);else if(book_name_TextField.getText().trim().equals()JOptionPane.showMessageDialog(null, 书名不能为
12、空);else if(author_TextField.getText().trim().equals()JOptionPane.showMessageDialog(null, 作者不能为空);else if(press_TextField.getText().trim().equals()JOptionPane.showMessageDialog(null, 出版社不能为空);else if(press_date_TextField.getText().trim().equals()JOptionPane.showMessageDialog(null, 出版日期不能为空);else if(p
13、rice_TextField.getText().trim().equals()JOptionPane.showMessageDialog(null, 价格不能为空);else if(book_num_TextField.getText().trim().equals()JOptionPane.showMessageDialog(null, 库存不能为空);else if(borrowed_count.getText().trim().equals()JOptionPane.showMessageDialog(null, 借阅数不能为空);else tryString strSQL=inser
14、t into book(book_id,book_name,press,author,press_date,price,book_count,borrowed_count,store_address)values(+book_id_TextField.getText().trim()+,+book_name_TextField.getText().trim()+,+press_TextField.getText().trim()+,+author_TextField.getText().trim()+,+press_date_TextField.getText().trim()+,+price
15、_TextField.getText().trim()+,+book_num_TextField.getText().trim()+,+borrowed_count.getText().trim()+,+addresst.getSelectedItem()+);if(db.updateSql(strSQL)this.dispose();JOptionPane.showMessageDialog(null,添加图书成功);elseJOptionPane.showMessageDialog(null,添加图书失败);this.dispose();db.closeConnection();catch
16、(Exception ex)System.out.println(ex.toString();package library;import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.sql.ResultSet;import java.sql.SQLException;public class book_delete extends JFrame implements ActionListenerDataBaseManager db=new DataBaseManager();ResultSet rs;
17、Container c;JLabel TipLabel=new JLabel(请选择要删除的书名,JLabel.CENTER);JComboBox bb=new JComboBox();JButton yes,exit;JPanel panel1=new JPanel();public book_delete()super(删除图书信息);c=getContentPane();c.setLayout(new BorderLayout(); try String strSQL=select book_name from book where book_countborrowed_count; r
18、s=db.getResult(strSQL); while(rs.next() bb.addItem(rs.getString(1); catch(SQLException sqle)System.out.println(sqle.toString();catch(Exception ex)System.out.println(ex.toString();c.add(TipLabel,BorderLayout.NORTH);c.add(bb,BorderLayout.CENTER);yes=new JButton(确定);exit=new JButton(退出);yes.addActionLi
19、stener(this);exit.addActionListener(this);panel1.add(yes);panel1.add(exit);c.add(panel1,BorderLayout.SOUTH);setVisible(true);public void actionPerformed(ActionEvent e)if(e.getSource()=exit)this.dispose();else if(e.getSource()=yes)tryString strSQL=select borrowed_count from book where book_name=+bb.g
20、etSelectedItem()+;rs=db.getResult(strSQL);if(!rs.first()JOptionPane.showMessageDialog(null,书库里没有你要删除的书);elseString strSql=delete from book where book_name=+bb.getSelectedItem()+and borrowed_count=0;rs.first();int count=rs.getInt(1);if(!(count=0)JOptionPane.showMessageDialog(null,此书还有学生没有还,不可删除);else
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 基于 java 图书 管理 系统 源代码 64
限制150内