Java图书馆管理系统(附全代码)-课程设计报告_第1页
Java图书馆管理系统(附全代码)-课程设计报告_第2页
Java图书馆管理系统(附全代码)-课程设计报告_第3页
Java图书馆管理系统(附全代码)-课程设计报告_第4页
Java图书馆管理系统(附全代码)-课程设计报告_第5页
已阅读5页,还剩76页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、数据库系统概论课程报告课题名称: 小型图书管理系统课题负责人名(学号): best同组成员名单(角色): 指导教师: 评阅成绩: 评阅意见: 提交报告时间:2015年12月15日小型图书管理系统 计算机科学与技术 专业学生 指导老师 摘要 随着计算机技术的飞速发展,利用计算机来获得和处理信息是当今信息管理的一大特点。伴随计算机硬件的快速发展,有关信息管理的软件数据库系统软件也在迅猛发展着。图书馆是高等院校的重要组成部门,是教师和学生获取知识的重要场所。由于图书馆主要从事大量的图书资料的储存和流通。所以一直以来,计算机在图书馆的图书管理中得到了广泛的应用。本系统实现图书信息管理的系统化,规范化和

2、自动化,以最大程度提高操作人员的办公效率。关键词:JAVA、JDBC、SQL Server、数据库、图书馆管理一、实验题目:小型图书管理系统二、实验的目的和要求:完成一个小型图书管理系统,功能要求如下:能够通过书籍基本信息(包括:书号、书名、出版社、出版日期、作者、内容摘要)单个或以AND方式组合多个条件查询书籍信息;对于每一种书籍,除可查看其基本信息之外还可查看其总数以及目前在馆数量可增添新的书籍可删除已有书籍(如有读者借了该书籍尚未归还,则不允许删除)可修改书籍的基本信息能够通过读者基本信息(包括:证号、姓名、性别、系名、年级)单个或以AND方式组合多个条件查询读者信息对于每位读者除可查看

3、其基本信息之外,还可查看其已借的书籍列表、数量、借还日期可增添新的读者可删除已有读者(如该读者有尚未归还的借书,则不允许删除)可修改读者的基本信息可完成借还书籍的手续还书时如超期,应该显示超期天数借书时如果有超期的书没有还,则不允许借书可查询有哪些读者有超期的书没有还,列出这些读者的基本信息三、实验的环境:1、硬件环境:CPU: Intel(R) Core i5-3230 2.60GHz RAM: 8GB2、软件环境:操作系统:Windows 7 Ultimate SP1 编译软件:Eclipse Luna Microsoft SQL Server 2014四、系统ER图五、表结构定义(使用表

4、格说明)六、系统功能模块能够通过书籍基本信息单个或组合多个条件查询书籍信息;对于每一种书籍,除可查看其基本信息之外还可查看其总数以及目前在馆数量可增添新的书籍可删除已有书籍(如有读者借了该书籍尚未归还,则不允许删除)可修改书籍的基本信息能够通过读者基本信息单个或组合多个条件查询读者信息对于每位读者除可查看其基本信息之外,还可查看其已借的书籍列表、数量、借还日期可增添新的读者可删除已有读者(如该读者有尚未归还的借书,则不允许删除)可修改读者的基本信息可完成借还书籍的手续还书时如超期,应该显示超期天数借书时如果有超期的书没有还,则不允许借书可查询有哪些读者有超期的书没有还,列出这些读者的基本信息七

5、、程序框架流程图九、程序运行结果八、核心代码AddBook.javaimport java.awt.BorderLayout;import java.awt.Container;import java.awt.GridLayout;import java.awt.event.*;import java.util.ArrayList;import javax.swing.*;public class AddBook extends JFrame implements ActionListener SQLOperation op = new SQLOperation();Container c =

6、 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 pressTime = new JLabel(Press time:);JLabel bookAbstract = new JLabel(Abstract:);JLabe

7、l 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 authorField = new JTextField();JTextField pressField = new JTextField();JTextField pressTi

8、meField = 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, BorderLayout.NORTH);p1.setLayout(new GridLayout(9, 2, 20, 10);p1.add(bookNumber);p

9、1.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(storage);p1.add(storageField);p1.add(remain);p1.add(remain1);p1.add(cancel);p1.add(

10、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();BookInfo book = new BookInfo(numberField.getText(),nameField.getT

11、ext(), authorField.getText(),pressField.getText(), pressTimeField.getText(),abstractField.getText(), Integer.parseInt(storageField.getText(),Integer.parseInt(storageField.getText();ArrayList strArray = new ArrayList();strArray = op.addBookJudgement();int n = 0;int replicate = 0;while (n Integer.pars

12、eInt(strArray.get(0) n+;if (numberField.getText().equals(strArray.get(n) replicate+;if (replicate = 0) op.saveBook(book);JOptionPane.showMessageDialog(null, Add a book successfully!,Information, JOptionPane.INFORMATION_MESSAGE); else JOptionPane.showMessageDialog(null,This book(number) has already e

13、xisted!, Warning,JOptionPane.INFORMATION_MESSAGE);AddReader.javaimport java.awt.BorderLayout;import java.awt.Container;import java.awt.GridLayout;import java.awt.event.*;import java.util.ArrayList;import javax.swing.*;public class AddReader extends JFrame implements ActionListener SQLOperation op =

14、new SQLOperation();Container c = getContentPane();JPanel p1 = new JPanel();JLabel readerNumber = new JLabel(Reader Number:);JLabel readerName = new JLabel(Reader Name:);JLabel sex = new JLabel(Sex:);JLabel dpt = new JLabel(Department:);JLabel grade = new JLabel(Grade:);JTextField numberField = new J

15、TextField();JTextField nameField = new JTextField();JTextField sexField = new JTextField();JTextField dptField = new JTextField();JTextField gradeField = new JTextField();JButton cancel = new JButton(Cancel);JButton confirm = new JButton(Confirm!);public AddReader() c.add(p1, BorderLayout.NORTH);p1.

16、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.add(grade);p1.add(gradeField);p1.add(cancel);p1.add(confirm);cancel.addActionListener(this);confirm.addActionListener(this

17、);public void actionPerformed(ActionEvent e) / TODO Auto-generated method stubif (e.getSource() = cancel) this.dispose();if (e.getSource() = confirm) this.dispose();ReaderInfo reader = new ReaderInfo(numberField.getText(),nameField.getText(), sexField.getText(),dptField.getText(), Integer.parseInt(g

18、radeField.getText();ArrayList strArray = new ArrayList();strArray = op.addReaderJudgement();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) if (!sexField.getText().equals(boy)& !sexField.getText()

19、.equals(girl) JOptionPane.showMessageDialog(null,In the Sex field, you can only input boy or girl!,Warning, JOptionPane.INFORMATION_MESSAGE); else op.saveReader(reader);JOptionPane.showMessageDialog(null,Add a reader successfully!, Information,JOptionPane.INFORMATION_MESSAGE); else JOptionPane.showM

20、essageDialog(null,This reader(number) has already existed!, Warning,JOptionPane.INFORMATION_MESSAGE);BookDetails.javaimport java.awt.BorderLayout;import java.awt.Container;import java.awt.Dimension;import java.awt.GridLayout;import java.awt.event.*;import java.util.ArrayList;import javax.swing.*;imp

21、ort javax.swing.table.DefaultTableModel;public class BookDetails extends JFrame implements ActionListener SQLOperation op = new SQLOperation();Container c = getContentPane();JPanel p1 = new JPanel();JPanel p2 = new JPanel();JPanel p3 = new JPanel();JLabel bookNumber = new JLabel(Book Number:);JLabel

22、 bookName = new JLabel(Book Name:);JLabel author = new JLabel(Author:);JLabel press = new JLabel(Press:);JLabel pressTime = new JLabel(Press time:);JLabel bookAbstract = new JLabel(Abstract:);JLabel storage = new JLabel(Storage:);JLabel remain = new JLabel(Remain:);JLabel numberField = new JLabel();

23、JLabel nameField = new JLabel();JLabel authorField = new JLabel();JLabel pressField = new JLabel();JLabel pressTimeField = new JLabel();JLabel abstractField = new JLabel();JLabel storageField = new JLabel();JLabel remainField = new JLabel();JButton cancel = new JButton(Cancel);JLabel details = new J

24、Label(Borrow and reaturn details);Object s = Reader number, Borrow time, Deadline, Over time ;Object ob1 = new Object74;JTable table = new JTable(ob1, s);JScrollPane scrollPane = new JScrollPane(table);public BookDetails(String number) BookInfo book = new BookInfo(number);ob1 = op.borrowListForBook(

25、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+) ob1nm = this.ob1nm;table.setModel(books);table.invalidate();ArrayList strArray = new ArrayList();strArray = op.outputBook(book);numberField.setText(number);nameF

26、ield.setText(strArray.get(1);authorField.setText(strArray.get(2);pressField.setText(strArray.get(3);pressTimeField.setText(strArray.get(4);abstractField.setText(strArray.get(5);storageField.setText(strArray.get(6);remainField.setText(strArray.get(7);c.add(p1, BorderLayout.NORTH);c.add(p2, BorderLayo

27、ut.CENTER);c.add(p3, BorderLayout.SOUTH);p1.setLayout(new GridLayout(9, 2, 20, 10);p1.add(bookNumber);p1.add(numberField);p1.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(abstra

28、ctField);p1.add(storage);p1.add(storageField);p1.add(remain);p1.add(remainField);p1.add(details);scrollPane.setBounds(0, 0, 800, 300);p2.add(scrollPane);p3.add(cancel);table.setPreferredScrollableViewportSize(new Dimension(400, 100);cancel.addActionListener(this);public void actionPerformed(ActionEv

29、ent e) / TODO Auto-generated method stubif (e.getSource() = cancel) this.dispose();BookInfo.javapublic class BookInfo private String number, name, author, press, pressTime, bookAbstract;private int total, remain;/ default constructorpublic BookInfo() public BookInfo(String number) this.number = numb

30、er;public BookInfo(String number, String name) this.number = number; = name;public BookInfo(String number, String name, String author, String press,String pressTime, String bookAbstract, int total, int remain) this.number = number; = name;this.author = author;this.press = press;thi

31、s.pressTime = pressTime;this.bookAbstract = bookAbstract;this.total = total;this.remain = remain;public void setRemain(int i) this.remain=i;public String getNumber() return number;public String getName() return name;public String getAuthor() return author;public String getPress() return press;public

32、 String getPressTime() return pressTime;public String getBookAbstract() return bookAbstract;public 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;import java.awt.

33、GridLayout;import java.awt.event.*;import java.util.ArrayList;import javax.swing.*;import javax.swing.table.DefaultTableModel;class BookRetrieval extends JFrame implements ActionListener SQLOperation op = new SQLOperation();Container c = getContentPane();JPanel p1 = new JPanel();JPanel p4 = new JPan

34、el();JPanel p5 = new JPanel();JLabel bookNumber = new JLabel(Book Number:);JLabel 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 JButt

35、on(Delete a book);JButton editBook = new JButton(Edit a book);JButton search = new 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, Press Time,

36、Abstract, Storage, Remain ;Object ob = new Object408;JTable table = new JTable(ob, 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

37、 = 0; n 20; n+) for (int m = 0; m 8; m+) obnm = this.obnm;table.setModel(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);

38、p4.add(deleteBook);p4.add(borrowBook);p4.add(returnBook);p1.setLayout(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(new Dime

39、nsion(400, 300);addBook.addActionListener(this);search.addActionListener(this);back.addActionListener(this);deleteBook.addActionListener(this);editBook.addActionListener(this);borrowBook.addActionListener(this);returnBook.addActionListener(this);public void actionPerformed(ActionEvent e) if (e.getSo

40、urce() = search) ArrayList strArray = new ArrayList();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 = new ArrayList();strAr

41、ray1 = op.addBookJudgement1();int n1 = 0;int replicate1 = 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 or name!,Warning, JOptionPane.INFORMATION_

42、MESSAGE); else if (replicate != 0 | replicate1 != 0) if (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

43、.setSize(480, 470);f.setVisible(true); else 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 MyFr

44、ame();/ f.setDefaultCloseOperation(JFrame.EXIT_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

45、(300, 200);f.setSize(300, 400);f.setVisible(true);if (e.getSource() = deleteBook) DeleteBook f = new DeleteBook();/ f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);f.setTitle(Delete a book);f.setLocation(300, 200);f.setSize(300, 200);f.setVisible(true);if (e.getSource() = borrowBook) BorrowBook f =

46、 new BorrowBook();/ f.setDefaultCloseOperation(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

47、.setLocation(300, 200);f.setSize(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.BorderL

48、ayout;import java.awt.Container;import java.awt.GridLayout;import java.awt.event.*;import java.util.ArrayList;import javax.swing.*;public class BorrowBook extends JFrame implements ActionListener SQLOperation op = new SQLOperation();Container c = getContentPane();JPanel p1 = new JPanel();JLabel book

49、Number = new JLabel(Book Number:);JTextField numberField = new JTextField();JLabel readerNumber = new JLabel(Reader Number:);JTextField readerNumberField = new JTextField();JButton cancel = new JButton(Cancel);JButton borrow = new JButton(Borrow!);public BorrowBook() c.add(p1, BorderLayout.NORTH);p1

50、.setLayout(new GridLayout(3, 2, 20, 10);p1.add(bookNumber);p1.add(numberField);p1.add(readerNumber);p1.add(readerNumberField);p1.add(cancel);p1.add(borrow);cancel.addActionListener(this);borrow.addActionListener(this);public void actionPerformed(ActionEvent e) / TODO Auto-generated method stubif (e.

51、getSource() = cancel) this.dispose();if (e.getSource() = borrow) String bookNumber = numberField.getText();ArrayList strArray = new ArrayList();strArray = op.addBookJudgement();int n = 0;int replicate = 0;while (n Integer.parseInt(strArray.get(0) n+;if (bookNumber.equals(strArray.get(n) replicate+;S

52、tring readerNumber = readerNumberField.getText();ArrayList strArray1 = new ArrayList();strArray1 = op.addReaderJudgement();int n1 = 0;int replicate1 = 0;while (n1 Integer.parseInt(strArray1.get(0) n1+;if (readerNumber.equals(strArray1.get(n1) replicate1+;if (replicate = 0 | replicate1 = 0) JOptionPa

53、ne.showMessageDialog(null,Please input a correct book number and a reader number!,Warning, JOptionPane.INFORMATION_MESSAGE); else BookInfo book = new BookInfo(bookNumber);ArrayList s = new ArrayList();s = op.outputBook(book);if (Integer.parseInt(s.get(7) 0) int s1 = op.reBorrowCheck(numberField.getT

54、ext(),readerNumberField.getText();if (s1 = 1) JOptionPane.showMessageDialog(null,You have borrowed this book, can not reborrow it!,Unsuccessful,JOptionPane.INFORMATION_MESSAGE); else long currentTime = System.currentTimeMillis();if (op.deadLineCheck(readerNumberField.getText(),currentTime) != 0) JOp

55、tionPane.showMessageDialog(null,You have exceeded the deadline, please return these books first!,Unsuccessful,JOptionPane.INFORMATION_MESSAGE); else BookInfo book1 = new BookInfo(s.get(0), s.get(1),s.get(2), s.get(3), s.get(4), s.get(5),Integer.parseInt(s.get(6),Integer.parseInt(s.get(7) - 1);op.inp

56、utBook(book1);String borrowTime = Long.toString(System.currentTimeMillis();String deadline = Long.toString(System.currentTimeMillis() + 2592000000l);System.out.println(borrowTime);System.out.println(deadline);op.insertBorrow(numberField.getText(),readerNumberField.getText(), borrowTime,deadline);JOp

57、tionPane.showMessageDialog(null,Borrowed this book successfully, you have 30 days to enjoy this book!,Successful,JOptionPane.INFORMATION_MESSAGE); else JOptionPane.showMessageDialog(null,This book has been borrowed!, Unsuccessful,JOptionPane.INFORMATION_MESSAGE);this.dispose();BorrowList.Javaimport

58、java.awt.BorderLayout;import java.awt.Container;import java.awt.Dimension;import java.awt.Font;import java.awt.GridLayout;import java.awt.event.*;import java.util.ArrayList;import javax.swing.*;import javax.swing.table.DefaultTableModel;public class BorrowList extends JFrame implements ActionListene

59、r SQLOperation op = new SQLOperation();Container c = getContentPane();JPanel p1 = new JPanel();JPanel p2 = new JPanel();JButton back=new JButton(Back);Object s = Book number, Reader number, Borrow time, Deadline,OverTime;Object ob = new Object1005;JTable table = new JTable(ob, s);JScrollPane scrollP

60、ane = new JScrollPane(table);public BorrowList() / TODO Auto-generated constructor stubObject ob1 = op.borrowList();for (int i = 0; i 5; i+) DefaultTableModel list = new DefaultTableModel(ob, s);for (int n = 0; n 100; n+) for (int m = 0; m 5; m+) obnm = ob1nm;table.setModel(list);table.invalidate();

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论