《JAVA图书馆管理系统(附全代码)_课程设计报告.pdf》由会员分享,可在线阅读,更多相关《JAVA图书馆管理系统(附全代码)_课程设计报告.pdf(82页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、数据库系统概论课程报告数据库系统概论课程报告课题名称:课题名称:小型小型图书管理系统图书管理系统课题负责人名(学号) :best同组成员名单(角色) :指导教师:评阅成绩:评阅成绩:评阅意见:提交报告时间:2015 年 12 月 15 日课程名称:数据库系统概论-1-小型图书小型图书管理系统管理系统计算机科学与技术 专业学生学生指导老师指导老师 摘要摘要 随着计算机技术的飞速发展,利用计算机来获得和处理信息是当今信息管理的一大特点。伴随计算机硬件的快速发展,有关信息管理的软件数据库系统软件也在迅猛发展着。图书馆是高等院校的重要组成部门,是教师和学生获取知识的重要场所。由于图书馆主要从事大量的图
2、书资料的储存和流通。所以一直以来,计算机在图书馆的图书管理中得到了广泛的应用。本系统实现图书信息管理的系统化,规范化和自动化,以最大程度提高操作人员的办公效率。关键词关键词:JAVA、JDBC、SQL Server、数据库、图书馆管理课程名称:数据库系统概论-2-一、实验题目:小型图书管理系统二、实验的目的和要求:完成一个小型图书管理系统,功能要求如下:1)能够通过书籍基本信息(包括:书号、书名、出版社、出版日期、作者、内容摘要)单个或以 AND 方式组合多个条件查询书籍信息;2)对于每一种书籍, 除可查看其基本信息之外还可查看其总数以及目前在馆数量3)可增添新的书籍4)可删除已有书籍(如有读
3、者借了该书籍尚未归还,则不允许删除)5)可修改书籍的基本信息6)能够通过读者基本信息(包括:证号、姓名、性别、系名、年级)单个或以 AND 方式组合多个条件查询读者信息7)对于每位读者除可查看其基本信息之外, 还可查看其已借的书籍列表、数量、借还日期8)可增添新的读者9)可删除已有读者 (如该读者有尚未归还的借书, 则不允许删除)10) 可修改读者的基本信息课程名称:数据库系统概论-3-11) 可完成借还书籍的手续12) 还书时如超期,应该显示超期天数13) 借书时如果有超期的书没有还,则不允许借书14) 可查询有哪些读者有超期的书没有还, 列出这些读者的基本信息三、实验的环境:1、硬件环境:
4、CPU: Intel(R) Core i5-3230 2.60GHzRAM: 8GB2、软件环境:操作系统:Windows 7 Ultimate SP1编译软件:Eclipse LunaMicrosoft SQL Server 2014四、系统 ER 图课程名称:数据库系统概论-4-五、表结构定义(使用表格说明)课程名称:数据库系统概论-5-课程名称:数据库系统概论-6-课程名称:数据库系统概论-7-六、系统功能模块1)能够通过书籍基本信息单个或组合多个条件查询书籍信息;2)对于每一种书籍, 除可查看其基本信息之外还可查看其总数以课程名称:数据库系统概论-8-及目前在馆数量3)可增添新的书籍4
5、)可删除已有书籍(如有读者借了该书籍尚未归还,则不允许删除)5)可修改书籍的基本信息6)能够通过读者基本信息单个或组合多个条件查询读者信息7)对于每位读者除可查看其基本信息之外, 还可查看其已借的书籍列表、数量、借还日期8)可增添新的读者9)可删除已有读者 (如该读者有尚未归还的借书, 则不允许删除)10) 可修改读者的基本信息11) 可完成借还书籍的手续12) 还书时如超期,应该显示超期天数13) 借书时如果有超期的书没有还,则不允许借书14) 可查询有哪些读者有超期的书没有还, 列出这些读者的基本信息七、程序框架流程图课程名称:数据库系统概论-9-课程名称:数据库系统概论-10-九、程序运
6、行结果课程名称:数据库系统概论-11-课程名称:数据库系统概论-12-课程名称:数据库系统概论-13-课程名称:数据库系统概论-14-课程名称:数据库系统概论-15-八、核心代码AddBook.javaimport java.awt.BorderLayout;import java.awt.Container;import java.awt.GridLayout;import java.awt.event.*;import java.util.ArrayList;import javax.swing.*;课程名称:数据库系统概论-16-public class AddBook extends
7、JFrame implements ActionListenerSQLOperation op = new SQLOperation();Container c = getContentPane();JPanel p1 = new JPanel();JLabel bookNumber = new JLabel(Book Number:);JLabel bookName = new JLabel(Book Name:);JLabel bookAuthor = new JLabel(Book Author:);JLabel press = new JLabel(Press:);JLabel pre
8、ssTime = new JLabel(Press time:);JLabel bookAbstract = new JLabel(Abstract:);JLabel storage = new JLabel(Storage:);JLabel remain = new JLabel(Remain);JLabel remain1 = new JLabel(Update with Storage);JTextField numberField = new JTextField();JTextField nameField = new JTextField();JTextField authorFi
9、eld = new JTextField();JTextField pressField = new JTextField();JTextField pressTimeField = new JTextField();JTextField abstractField = new JTextField();JTextField storageField = new JTextField();JButton cancel = new JButton(Cancel);JButton confirm = new JButton(Confirm!);public AddBook() c.add(p1,
10、BorderLayout.NORTH);p1.setLayout(new GridLayout(9, 2, 20, 10);p1.add(bookNumber);p1.add(numberField);p1.add(bookName);p1.add(nameField);p1.add(bookAuthor);p1.add(authorField);p1.add(press);p1.add(pressField);p1.add(pressTime);p1.add(pressTimeField);p1.add(bookAbstract);p1.add(abstractField);p1.add(s
11、torage);课程名称:数据库系统概论-17-p1.add(storageField);p1.add(remain);p1.add(remain1);p1.add(cancel);p1.add(confirm);cancel.addActionListener(this);confirm.addActionListener(this);public void actionPerformed(ActionEvent e) / TODO Auto-generated method stubif (e.getSource() = cancel) this.dispose();if (e.getSo
12、urce() = confirm) this.dispose();BookInfo book = new BookInfo(numberField.getText(),nameField.getText(), authorField.getText(),pressField.getText(),pressTimeField.getText(),abstractField.getText(),Integer.parseInt(storageField.getText(),Integer.parseInt(storageField.getText();ArrayList strArray = ne
13、wArrayList();strArray = op.addBookJudgement();int n = 0;int replicate = 0;while (n Integer.parseInt(strArray.get(0) n+;if(numberField.getText().equals(strArray.get(n) replicate+;if (replicate = 0) op.saveBook(book);JOptionPane.showMessageDialog(null, Add a book课程名称:数据库系统概论-18-successfully!,Informati
14、on,JOptionPane.INFORMATION_MESSAGE); else JOptionPane.showMessageDialog(null,This book(number) has already existed!,Warning,JOptionPane.INFORMATION_MESSAGE);AddReader.javaimport java.awt.BorderLayout;import java.awt.Container;import java.awt.GridLayout;import java.awt.event.*;import java.util.ArrayL
15、ist;import javax.swing.*;public class AddReader extends JFrame implementsActionListener SQLOperation op = new SQLOperation();Container c = getContentPane();JPanel p1 = new JPanel();JLabel readerNumber = new JLabel(Reader Number:);课程名称:数据库系统概论-19-JLabel readerName = new JLabel(Reader Name:);JLabel se
16、x = new JLabel(Sex:);JLabel dpt = new JLabel(Department:);JLabel grade = new JLabel(Grade:);JTextField numberField = new JTextField();JTextField nameField = new JTextField();JTextField sexField = new JTextField();JTextField dptField = new JTextField();JTextField gradeField = new JTextField();JButton
17、 cancel = new JButton(Cancel);JButton confirm = new JButton(Confirm!);public AddReader() c.add(p1, BorderLayout.NORTH);p1.setLayout(new GridLayout(6, 2, 20, 10);p1.add(readerNumber);p1.add(numberField);p1.add(readerName);p1.add(nameField);p1.add(sex);p1.add(sexField);p1.add(dpt);p1.add(dptField);p1.
18、add(grade);p1.add(gradeField);p1.add(cancel);p1.add(confirm);cancel.addActionListener(this);confirm.addActionListener(this);public void actionPerformed(ActionEvent e) / TODO Auto-generated method stubif (e.getSource() = cancel) this.dispose();if (e.getSource() = confirm) this.dispose();ReaderInfo re
19、ader = new课程名称:数据库系统概论-20-ReaderInfo(numberField.getText(),nameField.getText(), sexField.getText(),dptField.getText(),Integer.parseInt(gradeField.getText();ArrayList strArray = newArrayList();strArray = op.addReaderJudgement();int n = 0;int replicate = 0;while (n Integer.parseInt(strArray.get(0) n+;
20、if(numberField.getText().equals(strArray.get(n) replicate+;if (replicate = 0) if (!sexField.getText().equals(boy)& !sexField.getText().equals(girl) JOptionPane.showMessageDialog(null,In the Sex field, you can onlyinput boy or girl!,Warning,JOptionPane.INFORMATION_MESSAGE); else op.saveReader(reader)
21、;JOptionPane.showMessageDialog(null,Add a reader successfully!,Information,JOptionPane.INFORMATION_MESSAGE); else JOptionPane.showMessageDialog(null,This reader(number) has alreadyexisted!, Warning,JOptionPane.INFORMATION_MESSAGE);课程名称:数据库系统概论-21-BookDetails.javaimport java.awt.BorderLayout;import j
22、ava.awt.Container;import java.awt.Dimension;import java.awt.GridLayout;import java.awt.event.*;import java.util.ArrayList;import javax.swing.*;import javax.swing.table.DefaultTableModel;public class BookDetails extends JFrame implementsActionListener SQLOperation op = new SQLOperation();Container c
23、= getContentPane();JPanel p1 = new JPanel();JPanel p2 = new JPanel();JPanel p3 = new JPanel();JLabel bookNumber = new JLabel(Book Number:);JLabel bookName = new JLabel(Book Name:);JLabel author = new JLabel(Author:);JLabel press = new JLabel(Press:);JLabel pressTime = new JLabel(Press time:);JLabel
24、bookAbstract = new JLabel(Abstract:);JLabel storage = new JLabel(Storage:);JLabel remain = new JLabel(Remain:);JLabel numberField = new JLabel();JLabel nameField = new JLabel();JLabel authorField = new JLabel();JLabel pressField = new JLabel();课程名称:数据库系统概论-22-JLabel pressTimeField = new JLabel();JLa
25、bel abstractField = new JLabel();JLabel storageField = new JLabel();JLabel remainField = new JLabel();JButton cancel = new JButton(Cancel);JLabel details = new JLabel(Borrow and reaturn details);Object s = Reader number, Borrow time, Deadline,Over time ;Object ob1 = new Object74;JTable table = new J
26、Table(ob1, s);JScrollPane scrollPane = new JScrollPane(table);public BookDetails(String number) BookInfo book = new BookInfo(number);ob1 = op.borrowListForBook(number);for (int i = 0; i 5; i+) DefaultTableModel books = new DefaultTableModel(ob1,s);for (int n = 0; n 7; n+) for (int m = 0; m 4; m+) ob
27、1nm = this.ob1nm;table.setModel(books);table.invalidate();ArrayList strArray = new ArrayList();strArray = op.outputBook(book);numberField.setText(number);nameField.setText(strArray.get(1);authorField.setText(strArray.get(2);pressField.setText(strArray.get(3);pressTimeField.setText(strArray.get(4);ab
28、stractField.setText(strArray.get(5);storageField.setText(strArray.get(6);remainField.setText(strArray.get(7);c.add(p1, BorderLayout.NORTH);c.add(p2, BorderLayout.CENTER);c.add(p3, BorderLayout.SOUTH);p1.setLayout(new GridLayout(9, 2, 20, 10);课程名称:数据库系统概论-23-p1.add(bookNumber);p1.add(numberField);p1.
29、add(bookName);p1.add(nameField);p1.add(author);p1.add(authorField);p1.add(press);p1.add(pressField);p1.add(pressTime);p1.add(pressTimeField);p1.add(bookAbstract);p1.add(abstractField);p1.add(storage);p1.add(storageField);p1.add(remain);p1.add(remainField);p1.add(details);scrollPane.setBounds(0, 0, 8
30、00, 300);p2.add(scrollPane);p3.add(cancel);table.setPreferredScrollableViewportSize(newDimension(400, 100);cancel.addActionListener(this);public void actionPerformed(ActionEvent e) / TODO Auto-generated method stubif (e.getSource() = cancel) this.dispose();课程名称:数据库系统概论-24-BookInfo.javapublic class B
31、ookInfo private String number, name, author, press, pressTime,bookAbstract;private int total, remain;/ default constructorpublic BookInfo() public BookInfo(String number) this.number = number;public BookInfo(String number, String name) this.number = number;this.name = name;public BookInfo(String num
32、ber, String name, String author,String press,String pressTime, String bookAbstract, int total,int remain) this.number = number;this.name = name;this.author = author;this.press = press;this.pressTime = pressTime;this.bookAbstract = bookAbstract;this.total = total;this.remain = remain;public void setR
33、emain(int i) this.remain=i;public String getNumber() return number;public String getName() 课程名称:数据库系统概论-25-return name;public String getAuthor() return author;public String getPress() return press;public String getPressTime() return pressTime;public String getBookAbstract() return bookAbstract;publi
34、c int getTotal() return total;public int getRemain() return remain;BookRetrieval.javaimport java.awt.BorderLayout;import java.awt.Container;import java.awt.Dimension;import java.awt.Font;课程名称:数据库系统概论-26-import java.awt.GridLayout;import java.awt.event.*;import java.util.ArrayList;import javax.swing.
35、*;import javax.swing.table.DefaultTableModel;class BookRetrieval extends JFrame implements ActionListenerSQLOperation op = new SQLOperation();Container c = getContentPane();JPanel p1 = new JPanel();JPanel p4 = new JPanel();JPanel p5 = new JPanel();JLabel bookNumber = new JLabel(Book Number:);JLabel
36、bookName = new JLabel(Book Name:);JTextField number = new JTextField();JTextField name = new JTextField();JButton back = new JButton(Back (Fresh);JButton addBook = new JButton(Add a book);JButton deleteBook = new JButton(Delete a book);JButton editBook = new JButton(Edit a book);JButton search = new
37、 JButton(Search for details!);JButton borrowBook = new JButton(Borrow a book);JButton returnBook = new JButton(Return a book);Font font1 = new Font(00, Font.BOLD, 20);Object s = Number, Name, Author, Press, PressTime,Abstract, Storage, Remain ;Object ob = new Object408;JTable table = new JTable(ob,
38、s);JScrollPane scrollPane = new JScrollPane(table);public BookRetrieval() BookInfo book = new BookInfo();ob = op.allBook(book);for (int i = 0; i 5; i+) DefaultTableModel books = new DefaultTableModel(ob,s);for (int n = 0; n 20; n+) 课程名称:数据库系统概论-27-for (int m = 0; m 8; m+) obnm = this.obnm;table.setM
39、odel(books);table.invalidate();c.add(p4, BorderLayout.NORTH);c.add(p1, BorderLayout.CENTER);c.add(p5, BorderLayout.SOUTH);search.setFont(font1);p4.setLayout(new GridLayout(2, 4, 20, 10);p4.add(back);p4.add(addBook);p4.add(editBook);p4.add(deleteBook);p4.add(borrowBook);p4.add(returnBook);p1.setLayou
40、t(null);scrollPane.setBounds(0, 0, 800, 300);p1.add(scrollPane);p5.setLayout(new GridLayout(5, 1, 0, 0);p5.add(bookNumber);p5.add(number);p5.add(bookName);p5.add(name);p5.add(search);table.setPreferredScrollableViewportSize(newDimension(400, 300);addBook.addActionListener(this);search.addActionListe
41、ner(this);back.addActionListener(this);deleteBook.addActionListener(this);editBook.addActionListener(this);borrowBook.addActionListener(this);returnBook.addActionListener(this);public void actionPerformed(ActionEvent e) if (e.getSource() = search) 课程名称:数据库系统概论-28-ArrayList strArray = newArrayList();
42、strArray = op.addBookJudgement();String s1 = number.getText();String s2 = name.getText();int n = 0;int replicate = 0;while (n Integer.parseInt(strArray.get(0) n+;if (s1.equals(strArray.get(n) replicate+;ArrayList strArray1 = newArrayList();strArray1 = op.addBookJudgement1();int n1 = 0;int replicate1
43、 = 0;while (n1 Integer.parseInt(strArray1.get(0) n1+;if (s2.equals(strArray1.get(n1) replicate1+;if (replicate = 0 & replicate1 = 0) JOptionPane.showMessageDialog(null,Please input a correct book number orname!,Warning,JOptionPane.INFORMATION_MESSAGE); else if (replicate != 0 | replicate1 != 0) if (
44、replicate = 0 & replicate1 != 0) BookInfo book = new BookInfo(s1, s2);String s = op.searchBookByName(book);BookDetails f = new BookDetails(s);/f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);f.setTitle(Book Details);f.setLocation(300, 200);f.setSize(480, 470);课程名称:数据库系统概论-29-f.setVisible(true); els
45、e if (replicate != 0) BookDetails f = new BookDetails(s1);/f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);f.setTitle(Book Details);f.setLocation(300, 200);f.setSize(480, 470);f.setVisible(true);if (e.getSource() = back) this.dispose();MyFrame f = new MyFrame();/f.setDefaultCloseOperation(JFrame.EX
46、IT_ON_CLOSE);f.setTitle(Library Management System);f.setLocation(300, 200);f.setSize(580, 300);f.setVisible(true);if (e.getSource() = addBook) AddBook f = new AddBook();/f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);f.setTitle(Add a book);f.setLocation(300, 200);f.setSize(300, 400);f.setVisible(t
47、rue);if (e.getSource() = deleteBook) DeleteBook f = new DeleteBook();/f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);f.setTitle(Delete a book);f.setLocation(300, 200);课程名称:数据库系统概论-30-f.setSize(300, 200);f.setVisible(true);if (e.getSource() = borrowBook) BorrowBook f = new BorrowBook();/f.setDefaul
48、tCloseOperation(JFrame.EXIT_ON_CLOSE);f.setTitle(Borrow a book);f.setLocation(300, 200);f.setSize(300, 200);f.setVisible(true);if (e.getSource() = returnBook) ReturnBook f = new ReturnBook();/f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);f.setTitle(Return a book);f.setLocation(300, 200);f.setSize
49、(300, 200);f.setVisible(true);if (e.getSource() = editBook) SelectEdit f = new SelectEdit();/f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);f.setTitle(Edit a book);f.setLocation(300, 200);f.setSize(300, 200);f.setVisible(true);BorrowBook.javaimport java.awt.BorderLayout;import java.awt.Container;i
50、mport java.awt.GridLayout;课程名称:数据库系统概论-31-import java.awt.event.*;import java.util.ArrayList;import javax.swing.*;public class BorrowBook extends JFrame implementsActionListener SQLOperation op = new SQLOperation();Container c = getContentPane();JPanel p1 = new JPanel();JLabel bookNumber = new JLabe