Java图书馆管理系统附全代码课程设计报告
图书管理系统java课程设计报告
图书管理系统java课程设计报告一、教学目标本课程旨在通过学习Java语言实现图书管理系统,使学生掌握Java编程的基本语法和面向对象编程思想,具备运用Java语言解决实际问题的能力。
具体目标如下:1.知识目标:–掌握Java基本语法和数据结构;–理解面向对象编程的基本概念和方法;–熟悉图书管理系统的业务流程和设计方法。
2.技能目标:–能够使用Java编写简单的程序;–能够运用面向对象编程思想进行程序设计;–能够独立完成图书管理系统的开发和调试。
3.情感态度价值观目标:–培养学生的团队合作意识和沟通能力;–培养学生的问题解决能力和创新精神;–培养学生的自主学习能力和持续进步意识。
二、教学内容本课程的教学内容主要包括Java基本语法、数据结构、面向对象编程思想和图书管理系统的设计与实现。
具体安排如下:1.Java基本语法:介绍Java语言的基本元素、运算符、控制结构等;2.数据结构:讲解数组、链表、栈和队列等基本数据结构的使用和实现;3.面向对象编程:讲解类和对象、继承和多态、封装等基本概念和应用;4.图书管理系统:介绍图书管理系统的业务需求、设计方法和实现技巧。
三、教学方法本课程采用讲授法、案例分析法和实验法等多种教学方法,以激发学生的学习兴趣和主动性。
1.讲授法:通过讲解基本概念、原理和方法,使学生掌握相关知识;2.案例分析法:通过分析实际案例,使学生理解图书管理系统的业务流程和设计方法;3.实验法:通过动手实践,使学生熟悉Java编程环境和开发工具,提高编程能力。
四、教学资源本课程的教学资源包括教材、参考书、多媒体资料和实验设备等。
1.教材:选用权威、实用的Java编程教材,如《Java核心技术》等;2.参考书:提供相关的Java编程参考书籍,如《Java编程思想》等;3.多媒体资料:制作课件、视频等多媒体教学资料,以便学生随时复习和巩固知识;4.实验设备:提供计算机、网络等实验设备,确保学生能够进行实验和实践。
Java 图书馆管理系统(附全代码)_课程设计报告之令狐采学创编
《数据库系统概论》课程报告欧阳家百(2021.03.07)课题名称:小型图书管理系统课题负责人名(学号):best同组成员名单(角色):指导教师:评阅成绩:评阅意见:提交报告时间:12月15日小型图书管理系统计算机科学与技术专业学生指导老师[摘要] 随着计算机技术的飞速发展,利用计算机来获得和处理信息是当今信息管理的一大特点。
伴随计算机硬件的快速发展,有关信息管理的软件——数据库系统软件也在迅猛发展着。
图书馆是高等院校的重要组成部门,是教师和学生获取知识的重要场所。
由于图书馆主要从事大量的图书资料的储存和流通。
所以一直以来,计算机在图书馆的图书管理中得到了广泛的应用。
本系统实现图书信息管理的系统化,规范化和自动化,以最大程度提高操作人员的办公效率。
关键词:JAVA、JDBC、SQL Server、数据库、图书馆管理一、实验题目:小型图书管理系统二、实验的目的和要求:完成一个小型图书管理系统,功能要求如下:1)能够通过书籍基本信息(包括:书号、书名、出版社、出版日期、作者、内容摘要)单个或以AND方式组合多个条件查询书籍信息;2)对于每一种书籍,除可查看其基本信息之外还可查看其总数以及目前在馆数量3)可增添新的书籍4)可删除已有书籍(如有读者借了该书籍尚未归还,则不允许删除)5)可修改书籍的基本信息6)能够通过读者基本信息(包括:证号、姓名、性别、系名、年级)单个或以AND方式组合多个条件查询读者信息7)对于每位读者除可查看其基本信息之外,还可查看其已借的书籍列表、数量、借还日期8)可增添新的读者9)可删除已有读者(如该读者有尚未归还的借书,则不允许删除)10)可修改读者的基本信息11)可完成借还书籍的手续12)还书时如超期,应该显示超期天数13)借书时如果有超期的书没有还,则不允许借书14)可查询有哪些读者有超期的书没有还,列出这些读者的基本信息三、实验的环境:1、硬件环境:CPU:Intel(R) Core i532302.60GHzRAM:8GB2、软件环境:操作系统:Windows 7 UltimateSP1编译软件:Eclipse LunaMicrosoft SQL Server四、系统ER图五、表结构定义(使用表格说明)六、系统功能模块1)能够通过书籍基本信息单个或组合多个条件查询书籍信息;2)对于每一种书籍,除可查看其基本信息之外还可查看其总数以及目前在馆数量3)可增添新的书籍4)可删除已有书籍(如有读者借了该书籍尚未归还,则不允许删除)5)可修改书籍的基本信息6)能够通过读者基本信息单个或组合多个条件查询读者信息7)对于每位读者除可查看其基本信息之外,还可查看其已借的书籍列表、数量、借还日期8)可增添新的读者9)可删除已有读者(如该读者有尚未归还的借书,则不允许删除)10)可修改读者的基本信息11)可完成借还书籍的手续12)还书时如超期,应该显示超期天数13)借书时如果有超期的书没有还,则不允许借书14)可查询有哪些读者有超期的书没有还,列出这些读者的基本信息七、程序框架流程图九、程序运行结果八、核心代码AddBook.javaimport java.awt.BorderLayout;import java.awt.Container;import java.awt.GridLayout;import java.awt.event.*;import java.util.ArrayList;import javax.swing.*; publicclassAddBookextends JFrame implements ActionListener {SQLOperation 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 pressTime = new JLabel("Press time:");JLabel bookAbstract = newJLabel("Abstract:");JLabel storage = new JLabel("Storage:");JLabel remain = new JLabel("Remain");JLabel remain1 = new JLabel("Update with Storage");JTextFieldnumberField = newJTextField(); JTextFieldnameField = newJTextField(); JTextFieldauthorField = newJTextField(); JTextFieldpressField = newJTextField(); JTextFieldpressTimeField = newJTextField(); JTextFieldabstractField = newJTextField(); JTextFieldstorageField = newJTextField();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);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(storage);p1.add(storageField);p1.add(remain);p1.add(remain1);p1.add(cancel);p1.add(confirm);cancel.addActionListener(this);confirm.addActionListener(this);}publicvoid actionPerformed(ActionEvent e) { // TODO Autogenerated method stubif (e.getSource() == cancel) {this.dispose();}if (e.getSource() == confirm) {this.dispose();BookInfo book = newBookInfo(numberField.getText(),nameField.getText(), authorField.getText(), pressField.getText(), pressTimeField.getText(), abstractField.getText(),Integer.parseInt(storageField.getText()),Integer.parseInt(storageField.getText()));ArrayList<String> strArray = new ArrayList<String>();strArray = op.addBookJudgement();intn = 0;intreplicate = 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 successfully!","Information",RMATION_MESSAGE);} else {JOptionPane.showMessageDialog(null, "This book(number) has already existed!", "Warning",RMATION_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.*; publicclassAddReaderextends JFrame implements ActionListener {SQLOperation op = 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 JTextField();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.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);}publicvoid actionPerformed(ActionEvent e) {// TODO Autogenerated 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(gradeField.getText()));ArrayList<String> strArray = new ArrayList<String>();strArray = op.addReaderJudgement();intn = 0;intreplicate = 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().equals("girl")) {JOptionPane.showMessageDialog(null,"In the Sex field, you can only input 'boy' or 'girl'!","Warning",RMATION_MESSAGE);} else {op.saveReader(reader);JOptionPane.showMessageDialog(null, "Add a reader successfully!", "Information",RMATION_MESSAGE);}} else {JOptionPane.showMessageDialog(null, "This reader(number) has already existed!", "Warning",RMATION_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.*;import javax.swing.table.DefaultTableModel; publicclassBookDetailsextends JFrame implementsActionListener {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 bookName = new JLabel("Book Name:");JLabel author = new JLabel("Author:");JLabel press = new JLabel("Press:");JLabel pressTime = new JLabel("Press time:");JLabel bookAbstract = newJLabel("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();JLabel pressTimeField = new JLabel();JLabel 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 Object[7][4];JTable table = new JTable(ob1, s);JScrollPane scrollPane = new JScrollPane(table);public BookDetails(String number) {BookInfo book = newBookInfo(number);ob1 = op.borrowListForBook(number);for (inti = 0; i < 5; i++) {DefaultTableModel books = new DefaultTableModel(ob1, s);for (intn = 0; n < 7; n++) {for (intm = 0; m < 4; m++) {ob1[n][m] = this.ob1[n][m];}table.setModel(books);table.invalidate();}}ArrayList<String> strArray = new ArrayList<String>();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)); abstractField.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)); 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(abstractField);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);}publicvoid actionPerformed(ActionEvent e) { // TODO Autogenerated method stubif (e.getSource() == cancel) {this.dispose();}}}BookInfo.javapublicclass BookInfo {private String number, name, author, press, pressTime, bookAbstract;privateinttotal, remain;// default constructorpublic BookInfo() {}public BookInfo(String number) {this.number = number;}public BookInfo(String number, String name) { this.number = number; = name;}public BookInfo(String number, String name, String author, String press,String pressTime, String bookAbstract, inttotal, intremain) {this.number = number; = name;this.author = author;this.press = press;this.pressTime = pressTime;this.bookAbstract = bookAbstract;this.total = total;this.remain = remain;}publicvoid setRemain(inti) {this.remain=i;}public String getNumber() { returnnumber;}public String getName() { returnname;}public String getAuthor() { returnauthor;}public String getPress() { returnpress;}public String getPressTime() { returnpressTime;}public String getBookAbstract() { returnbookAbstract;}publicint getTotal() { returntotal;}publicint getRemain() {returnremain;}}BookRetrieval.javaimport 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; classBookRetrievalextends JFrame implements ActionListener {SQLOperation 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 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 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","Abstract", "Storage", "Remain" };Object[][] ob = new Object[40][8];JTable table = new JTable(ob, s);JScrollPane scrollPane = new JScrollPane(table);public BookRetrieval() {BookInfo book = new BookInfo();ob = op.allBook(book);for (inti = 0; i < 5; i++) {DefaultTableModel books = new DefaultTableModel(ob, s);for (intn = 0; n < 20; n++) {for (intm = 0; m < 8; m++) {ob[n][m] = this.ob[n][m];}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);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 Dimension(400, 300));addBook.addActionListener(this);search.addActionListener(this);back.addActionListener(this);deleteBook.addActionListener(this);editBook.addActionListener(this);borrowBook.addActionListener(this); returnBook.addActionListener(this);}publicvoid actionPerformed(ActionEvent e) {if (e.getSource() == search) {ArrayList<String> strArray = new ArrayList<String>();strArray = op.addBookJudgement();String s1 = number.getText();String s2 = name.getText();intn = 0;intreplicate = 0;while (n < Integer.parseInt(strArray.get(0))) {n++;if (s1.equals(strArray.get(n))) {replicate++;}}ArrayList<String> strArray1 = new ArrayList<String>();strArray1 = op.addBookJudgement1();intn1 = 0;intreplicate1 = 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",RMATION_MESSAGE);} elseif (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_CL OSE);f.setTitle("Book Details");f.setLocation(300, 200);f.setSize(480, 470);f.setVisible(true);} elseif (replicate != 0) {BookDetails f = new BookDetails(s1);//f.setDefaultCloseOperation(JFrame.EXIT_ON_CL OSE);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.EXIT_ON_CL OSE);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_CLf.setTitle("Add a book");f.setLocation(300, 200);f.setSize(300, 400);f.setVisible(true);}if (e.getSource() == deleteBook) {DeleteBook f = new DeleteBook(); //f.setDefaultCloseOperation(JFrame.EXIT_ON_CL OSE);f.setTitle("Delete a book");f.setLocation(300, 200);f.setSize(300, 200);f.setVisible(true);}if (e.getSource() == borrowBook) {BorrowBook f = new BorrowBook();//f.setDefaultCloseOperation(JFrame.EXIT_ON_CLf.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_CL OSE);f.setTitle("Return a book");f.setLocation(300, 200);f.setSize(300, 200);f.setVisible(true);}if (e.getSource() == editBook) {SelectEdit f = new SelectEdit();//f.setDefaultCloseOperation(JFrame.EXIT_ON_CL OSE);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;import java.awt.GridLayout;import java.awt.event.*;import java.util.ArrayList;import javax.swing.*; publicclassBorrowBookextends JFrame implements ActionListener {SQLOperation op = new SQLOperation();Container c = getContentPane();JPanel p1 = new JPanel();JLabel bookNumber = 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.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);}publicvoid actionPerformed(ActionEvent e) {// TODO Autogenerated method stubif (e.getSource() == cancel) {this.dispose();}if (e.getSource() == borrow) {String bookNumber = numberField.getText();ArrayList<String> strArray = new ArrayList<String>();strArray = op.addBookJudgement();intn = 0;intreplicate = 0;while (n < Integer.parseInt(strArray.get(0))) {n++;if (bookNumber.equals(strArray.get(n))) { replicate++;}}String readerNumber = readerNumberField.getText();ArrayList<String> strArray1 = new ArrayList<String>();strArray1 = op.addReaderJudgement();intn1 = 0;intreplicate1 = 0;while (n1 < Integer.parseInt(strArray1.get(0))) { n1++;if (readerNumber.equals(strArray1.get(n1))) { replicate1++;}}if (replicate == 0 || replicate1 == 0) {JOptionPane.showMessageDialog(null,"Please input a correct book number and a reader number!","Warning",RMATION_MESSAGE);} else {BookInfo book = new BookInfo(bookNumber);ArrayList<String> s = new ArrayList<String>();s = op.outputBook(book);if (Integer.parseInt(s.get(7)) > 0) {ints1 = op.reBorrowCheck(numberField.getText(), readerNumberField.getText());if (s1 == 1) {JOptionPane.showMessageDialog(null,"You have borrowed this book, can not reborrowit!","Unsuccessful",RMATION_MESSAGE);} else { longcurrentTime = System.currentTimeMillis();if (op.deadLineCheck(readerNumberField.getText(), currentTime) != 0) {JOptionPane.showMessageDialog(null,"You have exceeded the deadline, please return these books first!","Unsuccessful",RMATION_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.inputBook(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);JOptionPane.showMessageDialog(null,"Borrowed this book successfully, you have 30 days to enjoy this book!","Successful",RMATION_MESSAGE);}}} else {JOptionPane.showMessageDialog(null, "This book has been borrowed!", "Unsuccessful",RMATION_MESSAGE);}}this.dispose();}}}BorrowList.Javaimport java.awt.BorderLayout;import java.awt.Container;import java.awt.Dimension;importjava.awt.Font;importjava.awt.GridLayout;import java.awt.event.*;importjava.util.ArrayList;import javax.swing.*;import javax.swing.table.DefaultTableModel; publicclassBorrowListextends JFrame implements ActionListener {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 Object[100][5];JTable table = new JTable(ob, s);JScrollPane scrollPane = newJScrollPane(table);public BorrowList() {// TODO Autogenerated constructor stubObject[][] ob1 = op.borrowList();for (inti = 0; i < 5; i++) {DefaultTableModel list = new DefaultTableModel(ob, s);for (intn = 0; n < 100; n++) {for (intm = 0; m < 5; m++) {ob[n][m] = ob1[n][m];}table.setModel(list);table.invalidate();}}c.add(p1, BorderLayout.CENTER);c.add(p2,BorderLayout.SOUTH); scrollPane.setBounds(0, 0, 800, 300);p1.add(scrollPane);p2.add(back);table.setPreferredScrollableViewportSize(new Dimension(400, 400));back.addActionListener(this);}publicvoid actionPerformed(ActionEvent e) { if (e.getSource() == back) {this.dispose();MyFrame f = new MyFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CL OSE);f.setTitle("Library Management System");f.setLocation(300, 200);f.setSize(580, 300);f.setVisible(true);}// TODO Autogenerated method stub}}Date.javaimport java.text.DateFormat;import java.text.SimpleDateFormat;publicclass Date {public Date(){}static String borrowTimeInterface(longtime) {SimpleDateFormat df = (SimpleDateFormat) DateFormat.getInstance();df.applyPattern("yyyyMMdd");String s = df.format(time);returns;}}DeleteBook.javaimport java.awt.BorderLayout;import java.awt.Container;import java.awt.GridLayout;import java.awt.event.*;import javax.swing.*; publicclassDeleteBookextends JFrame implements ActionListener {SQLOperation op = new SQLOperation();Container c = getContentPane();JPanel p1 = new JPanel();JLabel bookNumber = new JLabel("Book Number:");JTextField numberField = new JTextField();JButton cancel = new JButton("Cancel");JButton delete = new JButton("Delete!!");public DeleteBook() {c.add(p1, BorderLayout.NORTH);p1.setLayout(new GridLayout(2, 2, 20, 10));p1.add(bookNumber);p1.add(numberField);p1.add(cancel);p1.add(delete);cancel.addActionListener(this);delete.addActionListener(this);}publicvoid actionPerformed(ActionEvent e) {// TODO Autogenerated method stubif (e.getSource() == cancel) {this.dispose();}if (e.getSource() == delete) {BookInfo book = newBookInfo(numberField.getText());this.dispose();if (op.deleteBookCheck(numberField.getText()) != 0) {JOptionPane.showMessageDialog(null,"Delete the book unsuccessfully. The book bas been borrowed!","Warning",RMATION_MESSAGE);} else {if (op.deleteBook(book) == 1) {JOptionPane.showMessageDialog(null, "Delete the book successfully!", "Information",RMATION_MESSAGE);} else {JOptionPane.showMessageDialog(null,"Delete the book unsuccessfully. The book does notexist!","Warning",RMATION_MESSAGE);}}}}}DeleteReader.javaimport java.awt.BorderLayout;import java.awt.Container;import java.awt.GridLayout;import java.awt.event.*;import javax.swing.*; publicclassDeleteReaderextends JFrame implements ActionListener {SQLOperation op = new SQLOperation();Container c = getContentPane();JPanel p1 = new JPanel();JLabel readerNumber = new JLabel("Reader Number:");JTextField numberField = new JTextField();JButton cancel = new JButton("Cancel");JButton delete = new JButton("Delete!!"); public DeleteReader() {c.add(p1, BorderLayout.NORTH);p1.setLayout(new GridLayout(2, 2, 20, 10));p1.add(readerNumber);p1.add(numberField);p1.add(cancel);p1.add(delete);cancel.addActionListener(this);delete.addActionListener(this);}publicvoid actionPerformed(ActionEvent e) {// TODO Autogenerated method stubif (e.getSource() == cancel) {this.dispose();}if (e.getSource() == delete) {ReaderInfo reader = new ReaderInfo(numberField.getText());this.dispose();if(op.deleteReaderCheck(numberField.getText()) != 0) {JOptionPane.showMessageDialog(null,"Delete the reader unsuccessfully. Please return books first!","Warning",RMATION_MESSAGE);} else {if (op.deleteReader(reader) == 1) {JOptionPane.showMessageDialog(null, "Delete the reader successfully!", "Information",RMATION_MESSAGE);} else {JOptionPane.showMessageDialog(null,"Delete the reader unsuccessfully. The reader does not exist!","Warning",RMATION_MESSAGE);}}}}}EditBook.javaimport java.awt.BorderLayout;import java.awt.Container;import java.awt.GridLayout;import java.awt.event.*;import java.util.ArrayList;import javax.swing.*; publicclassEditBookextends JFrame implements ActionListener {。
Java 图书馆管理系统(附全代码)_课程设计报告之欧阳文创编
《数据库系统概论》课程报告课题名称:小型图书管理系统课题负责人名(学号):best同组成员名单(角色):指导教师:评阅成绩:评阅意见:提交报告时间:12月15日小型图书管理系统计算机科学与技术专业学生指导老师[摘要] 随着计算机技术的飞速发展,利用计算机来获得和处理信息是当今信息管理的一大特点。
伴随计算机硬件的快速发展,有关信息管理的软件——数据库系统软件也在迅猛发展着。
图书馆是高等院校的重要组成部门,是教师和学生获取知识的重要场所。
由于图书馆主要从事大量的图书资料的储存和流通。
所以一直以来,计算机在图书馆的图书管理中得到了广泛的应用。
本系统实现图书信息管理的系统化,规范化和自动化,以最大程度提高操作人员的办公效率。
关键词:JAVA、JDBC、SQL Server、数据库、图书馆管理一、实验题目:小型图书管理系统二、实验的目的和要求:完成一个小型图书管理系统,功能要求如下:1)能够通过书籍基本信息(包括:书号、书名、出版社、出版日期、作者、内容摘要)单个或以AND方式组合多个条件查询书籍信息;2)对于每一种书籍,除可查看其基本信息之外还可查看其总数以及目前在馆数量3)可增添新的书籍4)可删除已有书籍(如有读者借了该书籍尚未归还,则不允许删除)5)可修改书籍的基本信息6)能够通过读者基本信息(包括:证号、姓名、性别、系名、年级)单个或以AND 方式组合多个条件查询读者信息7)对于每位读者除可查看其基本信息之外,还可查看其已借的书籍列表、数量、借还日期8)可增添新的读者9)可删除已有读者(如该读者有尚未归还的借书,则不允许删除)10)可修改读者的基本信息11)可完成借还书籍的手续12)还书时如超期,应该显示超期天数13)借书时如果有超期的书没有还,则不允许借书14)可查询有哪些读者有超期的书没有还,列出这些读者的基本信息三、实验的环境:1、硬件环境:CPU:Intel(R) Core i532302.60GHzRAM:8GB2、软件环境:操作系统:Windows 7 Ultimate SP1编译软件:Eclipse LunaMicrosoft SQL Server四、系统ER图五、表结构定义(使用表格说明)六、系统功能模块1)能够通过书籍基本信息单个或组合多个条件查询书籍信息;2)对于每一种书籍,除可查看其基本信息之外还可查看其总数以及目前在馆数量3)可增添新的书籍4)可删除已有书籍(如有读者借了该书籍尚未归还,则不允许删除)5)可修改书籍的基本信息6)能够通过读者基本信息单个或组合多个条件查询读者信息7)对于每位读者除可查看其基本信息之外,还可查看其已借的书籍列表、数量、借还日期8)可增添新的读者9)可删除已有读者(如该读者有尚未归还的借书,则不允许删除)10)可修改读者的基本信息11)可完成借还书籍的手续12)还书时如超期,应该显示超期天数13)借书时如果有超期的书没有还,则不允许借书14)可查询有哪些读者有超期的书没有还,列出这些读者的基本信息七、程序框架流程图九、程序运行结果八、核心代码AddBook.javaimport java.awt.BorderLayout;import java.awt.Container;import java.awt.GridLayout;import java.awt.event.*;import java.util.ArrayList;import javax.swing.*; publicclassAddBookextends JFrame implements ActionListener {SQLOperation op = new SQLOperation();Container c = getContentPane();JPanel p1 = new JPanel();JLabel bookNumber = newJLabel("Book Number:");JLabel bookName = new JLabel("Book Name:");JLabel bookAuthor = newJLabel("Book Author:");JLabel press = new JLabel("Press:");JLabel pressTime = newJLabel("Press time:");JLabel bookAbstract = newJLabel("Abstract:");JLabel storage = newJLabel("Storage:");JLabel remain = newJLabel("Remain");JLabel remain1 = new JLabel("Update with Storage");JTextFieldnumberField = newJTextField(); JTextFieldnameField = newJTextField(); JTextFieldauthorField = newJTextField(); JTextFieldpressField = newJTextField();JTextFieldpressTimeField = newJTextField();JTextFieldabstractField = newJTextField();JTextFieldstorageField = newJTextField();JButton cancel = newJButton("Cancel");JButton confirm = newJButton("Confirm!!");public AddBook() {c.add(p1, 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(storage);p1.add(storageField);p1.add(remain);p1.add(remain1);p1.add(cancel);p1.add(confirm);cancel.addActionListener(this); confirm.addActionListener(this);}publicvoid actionPerformed(ActionEvent e) {// TODO Autogenerated method stubif (e.getSource() == cancel) {this.dispose();}if (e.getSource() == 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.getTe xt()));ArrayList<String> strArray = new ArrayList<String>();strArray = op.addBookJudgement();intn = 0;intreplicate = 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 successfully!", "Information",RMATION_MESSAGE);} else {JOptionPane.showMessageDialog(null,"This book(number) has already existed!", "Warning",RMATION_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.*; publicclassAddReaderextends JFrame implements ActionListener {SQLOperation op = new SQLOperation();Container c = getContentPane();JPanel p1 = new JPanel();JLabel readerNumber = newJLabel("Reader Number:");JLabel readerName = newJLabel("Reader Name:");JLabel sex = new JLabel("Sex:");JLabel dpt = newJLabel("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 cancel = newJButton("Cancel");JButton confirm = newJButton("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.add(grade);p1.add(gradeField);p1.add(cancel);p1.add(confirm);cancel.addActionListener(this);confirm.addActionListener(this);}publicvoid actionPerformed(ActionEvent e) {// TODO Autogenerated 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(gradeField.getText()));ArrayList<String> strArray = new ArrayList<String>();strArray = op.addReaderJudgement();intn = 0;intreplicate = 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().equals("girl ")) {JOptionPane.showMessageDialog(null,"In the Sex field, you can only input 'boy' or 'girl'!","Warning",RMATION_MESSAGE);} else {op.saveReader(reader);JOptionPane.showMessageDialog(null, "Add a reader successfully!", "Information",RMATION_MESSAGE);}} else {JOptionPane.showMessageDialog(null, "This reader(number) has already existed!", "Warning",RMATION_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.*;importjavax.swing.table.DefaultTableModel; publicclassBookDetailsextends JFrame implements ActionListener {SQLOperation op = new SQLOperation();Container c = getContentPane();JPanel p1 = new JPanel();JPanel p2 = new JPanel();JPanel p3 = new JPanel();JLabel bookNumber = newJLabel("Book Number:");JLabel bookName = new JLabel("Book Name:");JLabel author = newJLabel("Author:");JLabel press = new JLabel("Press:");JLabel pressTime = newJLabel("Press time:");JLabel bookAbstract = newJLabel("Abstract:");JLabel storage = newJLabel("Storage:");JLabel remain = newJLabel("Remain:");JLabel numberField = new JLabel();JLabel nameField = new JLabel();JLabel authorField = new JLabel();JLabel pressField = new JLabel();JLabel pressTimeField = newJLabel();JLabel abstractField = new JLabel();JLabel storageField = new JLabel();JLabel remainField = new JLabel();JButton cancel = newJButton("Cancel");JLabel details = new JLabel("Borrow and reaturn details");Object[] s = { "Reader number", "Borrow time", "Deadline", "Over time" };Object[][] ob1 = new Object[7][4];JTable table = new JTable(ob1, s);JScrollPane scrollPane = new JScrollPane(table);public BookDetails(String number) {BookInfo book = newBookInfo(number);ob1 = op.borrowListForBook(number);for (inti = 0; i < 5; i++) {DefaultTableModel books = new DefaultTableModel(ob1, s);for (intn = 0; n < 7; n++) {for (intm = 0; m < 4; m++) {ob1[n][m] = this.ob1[n][m];}table.setModel(books);table.invalidate();}}ArrayList<String> strArray = new ArrayList<String>();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)); abstractField.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));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(abstractField);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.setPreferredScrollableViewportSiz e(new Dimension(400, 100));cancel.addActionListener(this);}publicvoid actionPerformed(ActionEvent e) {// TODO Autogenerated method stubif (e.getSource() == cancel) {this.dispose();}}}BookInfo.javapublicclass BookInfo {private String number, name, author, press, pressTime, bookAbstract; privateinttotal, remain;// default constructorpublic BookInfo() {}public BookInfo(String number) {this.number = number;}public BookInfo(String number, String name) {this.number = number; = name;}public BookInfo(String number, String name, String author, String press,String pressTime, String bookAbstract, inttotal, intremain) { this.number = number; = name;this.author = author;this.press = press;this.pressTime = pressTime;this.bookAbstract = bookAbstract; this.total = total;this.remain = remain;}publicvoid setRemain(inti) { this.remain=i;}public String getNumber() { returnnumber;}public String getName() { returnname;}public String getAuthor() { returnauthor;}public String getPress() {returnpress;}public String getPressTime() { returnpressTime;}public String getBookAbstract() { returnbookAbstract;}publicint getTotal() { returntotal;}publicint getRemain() { returnremain;}}BookRetrieval.javaimport 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.*;importjavax.swing.table.DefaultTableModel; classBookRetrievalextends JFrame implements ActionListener {SQLOperation op = new SQLOperation();Container c = getContentPane();JPanel p1 = new JPanel();JPanel p4 = new JPanel();JPanel p5 = new JPanel();JLabel bookNumber = newJLabel("Book Number:");JLabel bookName = new JLabel("Book Name:");JTextField number = newJTextField();JTextField name = new JTextField();JButton back = new JButton("Back (Fresh)");JButton addBook = new JButton("Add a book");JButton deleteBook = newJButton("Delete a book");JButton editBook = newJButton("Edit a book");JButton search = newJButton("Search for details!");JButton borrowBook = newJButton("Borrow a book");JButton returnBook = newJButton("Return a book");Font font1 = new Font("00",Font.BOLD, 20);Object[] s = { "Number", "Name", "Author", "Press", "Press Time", "Abstract", "Storage", "Remain" };Object[][] ob = new Object[40][8];JTable table = new JTable(ob, s);JScrollPane scrollPane = new JScrollPane(table);public BookRetrieval() {BookInfo book = new BookInfo(); ob = op.allBook(book);for (inti = 0; i < 5; i++) {DefaultTableModel books = new DefaultTableModel(ob, s);for (intn = 0; n < 20; n++) {for (intm = 0; m < 8; m++) {ob[n][m] = this.ob[n][m];}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);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.setPreferredScrollableViewportSiz e(new Dimension(400, 300));addBook.addActionListener(this);search.addActionListener(this);back.addActionListener(this); deleteBook.addActionListener(this); editBook.addActionListener(this); borrowBook.addActionListener(this); returnBook.addActionListener(this);}publicvoid actionPerformed(ActionEvent e) {if (e.getSource() == search) {ArrayList<String> strArray = new ArrayList<String>();strArray = op.addBookJudgement();String s1 =number.getText();String s2 = name.getText(); intn = 0;intreplicate = 0;while (n <Integer.parseInt(strArray.get(0))) { n++;if (s1.equals(strArray.get(n))) { replicate++;}}ArrayList<String> strArray1 = new ArrayList<String>(); strArray1 = op.addBookJudgement1(); intn1 = 0;intreplicate1 = 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",RMATION_MESSAGE);} elseif (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.setSize(480, 470);f.setVisible(true);} elseif (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.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(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 = 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.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.BorderLayout;import java.awt.Container;import java.awt.GridLayout;import java.awt.event.*;import java.util.ArrayList;import javax.swing.*; publicclassBorrowBookextends JFrame implements ActionListener {SQLOperation op = new SQLOperation();Container c = getContentPane();JPanel p1 = new JPanel();JLabel bookNumber = newJLabel("Book Number:");JTextField numberField = new JTextField();JLabel readerNumber = newJLabel("Reader Number:");JTextField readerNumberField = new JTextField();JButton cancel = newJButton("Cancel");JButton borrow = newJButton("Borrow!!");public BorrowBook() {c.add(p1, BorderLayout.NORTH);p1.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);}publicvoid actionPerformed(ActionEvent e) {// TODO Autogenerated method stubif (e.getSource() == cancel) {this.dispose();}if (e.getSource() == borrow) {String bookNumber = numberField.getText();ArrayList<String> strArray = new ArrayList<String>();strArray = op.addBookJudgement();intn = 0;intreplicate = 0;while (n <Integer.parseInt(strArray.get(0))) {n++;if (bookNumber.equals(strArray.get(n))) {replicate++;}}String readerNumber = readerNumberField.getText();ArrayList<String>strArray1 = new ArrayList<String>(); strArray1 = op.addReaderJudgement();intn1 = 0;intreplicate1 = 0;while (n1 <Integer.parseInt(strArray1.get(0))) {n1++;if(readerNumber.equals(strArray1.get(n1))) {replicate1++;}}if (replicate == 0 || replicate1 == 0) {JOptionPane.showMessageDialog(null,"Please input a correct book number and a reader number!","Warning",RMATION_MESSAGE);} else {BookInfo book = new BookInfo(bookNumber);ArrayList<String> s = new ArrayList<String>();s = op.outputBook(book);if (Integer.parseInt(s.get(7)) > 0) { ints1 =op.reBorrowCheck(numberField.getText(), readerNumberField.getText());if (s1 == 1) {JOptionPane.showMessageDialog(null,"You have borrowed this book, can not reborrow it!","Unsuccessful",RMATION_MESSAGE);} else { longcurrentTime =System.currentTimeMillis();if(op.deadLineCheck(readerNumberField.get Text(),currentTime) != 0) {JOptionPane.showMessageDialog(null,"You have exceeded the deadline, please return these books first!", "Unsuccessful",RMATION_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.inputBook(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);JOptionPane.showMessageDialog(null,"Borrowed this book successfully, you have 30 days to enjoy this book!", "Successful",RMATION_MESSAGE);}}} else {JOptionPane.showMessageDialog(null, "This book has been borrowed!", "Unsuccessful",RMATION_MESSAGE);}}this.dispose();}}}BorrowList.Javaimport java.awt.BorderLayout;import java.awt.Container;import java.awt.Dimension;importjava.awt.Font;importjava.awt.GridLayout;import java.awt.event.*;importjava.util.ArrayList;import javax.swing.*;importjavax.swing.table.DefaultTableModel; publicclassBorrowListextends JFrame implements ActionListener {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 Object[100][5];JTable table = new JTable(ob, s);JScrollPane scrollPane = new JScrollPane(table);public BorrowList() {// TODO Autogenerated constructor stubObject[][] ob1 =op.borrowList();for (inti = 0; i < 5; i++) {DefaultTableModel list = new DefaultTableModel(ob, s);for (intn = 0; n < 100; n++) {for (intm = 0; m < 5; m++) {ob[n][m] = ob1[n][m];}table.setModel(list);table.invalidate();}}c.add(p1, BorderLayout.CENTER);c.add(p2,BorderLayout.SOUTH);scrollPane.setBounds(0, 0, 800, 300);p1.add(scrollPane);p2.add(back);table.setPreferredScrollableViewportSize(new Dimension(400, 400));back.addActionListener(this);}publicvoid actionPerformed(ActionEvent e) {if (e.getSource() == back) {this.dispose();MyFrame f = new MyFrame();f.setDefaultCloseOperation(JFrame.EXIT_ ON_CLOSE);f.setTitle("Library Management System");f.setLocation(300, 200);f.setSize(580, 300);f.setVisible(true);}// TODO Autogenerated method stub }}Date.javaimport java.text.DateFormat;import java.text.SimpleDateFormat; publicclass Date {public Date(){}static StringborrowTimeInterface(longtime) {SimpleDateFormat df = (SimpleDateFormat)DateFormat.getInstance();df.applyPattern("yyyyMMdd");String s = df.format(time); returns;。
java图书借阅管理系统课程设计报告 (2)
Java图书借阅管理系统课程设计报告1. 引言随着信息技术的发展,图书管理已经逐渐从传统的纸质管理转向数字化管理,借阅管理系统也逐渐成为图书馆及其他图书借阅机构管理图书借阅的重要工具。
为了提高图书借阅管理系统的效率和便利性,本课程设计将开发一个基于Java的图书借阅管理系统,以实现对图书借阅流程的自动化管理。
2. 系统需求分析2.1 功能需求系统需要满足以下功能需求: - 用户管理:包括添加用户、删除用户、修改用户信息等功能。
- 图书管理:包括图书的添加、删除、修改、查询等功能。
- 借阅管理:包括借阅图书、归还图书、查询借阅记录等功能。
- 图书统计:包括图书借阅情况的统计和报表生成。
- 系统设置:包括管理员账号密码的设置、系统参数的配置等功能。
2.2 性能需求系统需要实现以下性能需求: - 快速响应:系统需要能够快速响应用户的操作请求,保证用户体验。
- 并发管理:系统需要能够支持并发访问和操作,以满足多用户同时访问的需求。
- 数据安全:系统需要能够保护用户信息和借阅记录的安全性,防止非法访问和篡改。
2.3 界面设计系统需要提供简洁、直观的界面设计,以方便用户进行操作和管理。
界面设计应该符合常用的用户交互习惯,保证用户友好性和易使用性。
3. 系统设计3.1 架构设计系统将采用经典的三层架构设计,包括表现层、业务逻辑层和数据访问层。
表现层负责用户界面的展示和交互,业务逻辑层负责处理用户请求和数据处理逻辑,数据访问层负责与数据库进行数据交互。
3.2 数据库设计系统将采用关系型数据库存储数据,主要的数据表包括用户表、图书表和借阅记录表。
用户表用于存储用户的基本信息,包括用户名、密码、姓名、性别等;图书表用于存储图书的基本信息,包括图书名称、作者、出版社、价格等;借阅记录表用于存储用户的借阅记录,包括用户ID、图书ID、借阅日期、归还日期等。
3.3 模块设计系统将划分为用户管理模块、图书管理模块、借阅管理模块、统计报表模块和系统设置模块。
Java 图书馆管理系统 附全代码 课程设计报告
《数据库系统概论》课程报告课题名称:小型图书管理系统课题负责人名(学号):best同组成员名单(角色):指导教师:评阅成绩:评阅意见:提交报告时间:2015年12月15日小型图书管理系统计算机科学与技术专业学生指导老师[摘要]随着计算机技术的飞速发展,利用计算机来获得和处理信息是当今信息管理的一大特点。
伴随计算机硬件的快速发展,有关信息管理的软件——数据库系统软件也在迅猛发展着。
图书馆是高等院校的重要组成部门,是教师和学生获取知识的重要场所。
由于图书馆主要从事大量的图书资料的储存和流通。
所以一直以来,计算机在图书馆的图书管理中得到了广泛的应用。
本系统实现图书信息管理的系统化,规范化和自动化,以最大程度提高操作人员的办公效率。
关键词:JAVA、JDBC、SQL Server、数据库、图书馆管理一、实验题目:小型图书管理系统二、实验的目的和要求:完成一个小型图书管理系统,功能要求如下:1)能够通过书籍基本信息(包括:书号、书名、出版社、出版日期、作者、内容摘要)单个或以AND方式组合多个条件查询书籍信息;2)对于每一种书籍,除可查看其基本信息之外还可查看其总数以及目前在馆数量3)可增添新的书籍4)可删除已有书籍(如有读者借了该书籍尚未归还,则不允许删除)5)可修改书籍的基本信息6)能够通过读者基本信息(包括:证号、姓名、性别、系名、年级)单个或以AND方式组合多个条件查询读者信息7)对于每位读者除可查看其基本信息之外,还可查看其已借的书籍列表、数量、借还日期8)可增添新的读者9)可删除已有读者(如该读者有尚未归还的借书,则不允许删除)10)可修改读者的基本信息11)可完成借还书籍的手续12)还书时如超期,应该显示超期天数13)借书时如果有超期的书没有还,则不允许借书14)可查询有哪些读者有超期的书没有还,列出这些读者的基本信息三、实验的环境:1、硬件环境:CPU: Intel(R) Core i5-3230 2.60GHzRAM: 8GB2、软件环境:操作系统:Windows 7 Ultimate SP1编译软件:Eclipse LunaMicrosoft SQL Server 2014四、系统ER图五、表结构定义(使用表格说明)六、系统功能模块1)能够通过书籍基本信息单个或组合多个条件查询书籍信息;2)对于每一种书籍,除可查看其基本信息之外还可查看其总数以及目前在馆数量3)可增添新的书籍4)可删除已有书籍(如有读者借了该书籍尚未归还,则不允许删除)5)可修改书籍的基本信息6)能够通过读者基本信息单个或组合多个条件查询读者信息7)对于每位读者除可查看其基本信息之外,还可查看其已借的书籍列表、数量、借还日期8)可增添新的读者9)可删除已有读者(如该读者有尚未归还的借书,则不允许删除)10)可修改读者的基本信息11)可完成借还书籍的手续12)还书时如超期,应该显示超期天数13)借书时如果有超期的书没有还,则不允许借书14)可查询有哪些读者有超期的书没有还,列出这些读者的基本信息七、程序框架流程图九、程序运行结果八、核心代码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 = 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:"); 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 authorField = 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, 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(storage);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.getSource() == 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<String> strArray = newArrayList<String>();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 successfully!","Information",RMATION_MESSAGE);} else {JOptionPane.showMessageDialog(null,"This book(number) has already existed!", "Warning",RMATION_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 = 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 JTextField(); 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.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);}public void actionPerformed(ActionEvent e) {// TODO Auto-generated method stubif (e.getSource() == cancel) {this.dispose();}if (e.getSource() == confirm) {this.dispose();ReaderInfo reader = newReaderInfo(numberField.getText(),nameField.getText(), sexField.getText(),dptField.getText(),Integer.parseInt(gradeField.getText()));ArrayList<String> strArray = newArrayList<String>();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().equals("girl")) {JOptionPane.showMessageDialog(null,"In the Sex field, you can only input 'boy' or 'girl'!","Warning",RMATION_MESSAGE);} else {op.saveReader(reader);JOptionPane.showMessageDialog(null,"Add a reader successfully!", "Information",RMATION_MESSAGE);}} else {JOptionPane.showMessageDialog(null,"This reader(number) has already existed!", "Warning",RMATION_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.*;import 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 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();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 JLabel("Borrow and reaturn details"); Object[] s= { "Reader number", "Borrow time", "Deadline","Over time" };Object[][] ob1 = new Object[7][4];JTable table = new JTable(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++) {ob1[n][m] = this.ob1[n][m];}table.setModel(books);table.invalidate();}}ArrayList<String> strArray = new ArrayList<String>(); 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)); abstractField.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)); 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(abstractField);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(ActionEvent 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 = number;}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;this.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 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.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 JPanel();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 JButton("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","Abstract", "Storage", "Remain" };Object[][] ob = new Object[40][8];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 = 0; n < 20; n++) {for (int m = 0; m < 8; m++) {ob[n][m] = this.ob[n][m];}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);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 Dimension(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.getSource() == search) {ArrayList<String> strArray = newArrayList<String>();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<String> strArray1 = newArrayList<String>();strArray1 = 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",RMATION_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.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 MyFrame();//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(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 = 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.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.BorderLayout;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 bookNumber = 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.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.getSource() == cancel) {this.dispose();}if (e.getSource() == borrow) {String bookNumber = numberField.getText();ArrayList<String> strArray = newArrayList<String>();strArray = op.addBookJudgement();int n = 0;int replicate = 0;while (n < Integer.parseInt(strArray.get(0))) { n++;if (bookNumber.equals(strArray.get(n))) {replicate++;}}String readerNumber= readerNumberField.getText();ArrayList<String> strArray1 = newArrayList<String>();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) {JOptionPane.showMessageDialog(null,"Please input a correct book number and a reader number!","Warning",RMATION_MESSAGE);} else {BookInfo book = new BookInfo(bookNumber);ArrayList<String> s = new ArrayList<String>();s = op.outputBook(book);if (Integer.parseInt(s.get(7)) > 0) {int s1 =op.reBorrowCheck(numberField.getText(),readerNumberField.getText());if (s1 == 1) {JOptionPane.showMessageDialog(null,"You have borrowed this book, can not reborrow it!","Unsuccessful",RMATION_MESSAGE);} else {long currentTime =System.currentTimeMillis();if(op.deadLineCheck(readerNumberField.getText(),currentTime) != 0) {JOptionPane.showMessageDialog(null,"You have exceeded the deadline, please return these books first!","Unsuccessful",RMATION_MESSAGE);} else {BookInfo book1= new BookInfo(s.get(0), s.get(1),s.get(2), s.get(3), s.get(4), s.get(5),。
Java 图书馆管理系统(附全代码)_课程设计报告之欧阳史创编
《数据库系统概论》课程报告课题名称:小型图书管理系统课题负责人名(学号):best同组成员名单(角色):指导教师:评阅成绩:评阅意见:提交报告时间:12月15日小型图书管理系统计算机科学与技术专业学生指导老师[摘要] 随着计算机技术的飞速发展,利用计算机来获得和处理信息是当今信息管理的一大特点。
伴随计算机硬件的快速发展,有关信息管理的软件——数据库系统软件也在迅猛发展着。
图书馆是高等院校的重要组成部门,是教师和学生获取知识的重要场所。
由于图书馆主要从事大量的图书资料的储存和流通。
所以一直以来,计算机在图书馆的图书管理中得到了广泛的应用。
本系统实现图书信息管理的系统化,规范化和自动化,以最大程度提高操作人员的办公效率。
关键词:JAVA、JDBC、SQL Server、数据库、图书馆管理一、实验题目:小型图书管理系统二、实验的目的和要求:完成一个小型图书管理系统,功能要求如下:1)能够通过书籍基本信息(包括:书号、书名、出版社、出版日期、作者、内容摘要)单个或以AND方式组合多个条件查询书籍信息;2)对于每一种书籍,除可查看其基本信息之外还可查看其总数以及目前在馆数量3)可增添新的书籍4)可删除已有书籍(如有读者借了该书籍尚未归还,则不允许删除)5)可修改书籍的基本信息6)能够通过读者基本信息(包括:证号、姓名、性别、系名、年级)单个或以AND方式组合多个条件查询读者信息7)对于每位读者除可查看其基本信息之外,还可查看其已借的书籍列表、数量、借还日期8)可增添新的读者9)可删除已有读者(如该读者有尚未归还的借书,则不允许删除)10)可修改读者的基本信息11)可完成借还书籍的手续12)还书时如超期,应该显示超期天数13)借书时如果有超期的书没有还,则不允许借书14)可查询有哪些读者有超期的书没有还,列出这些读者的基本信息三、实验的环境:1、硬件环境:CPU:Intel(R) Core i532302.60GHzRAM:8GB2、软件环境:操作系统:Windows 7 Ultimate SP1编译软件:Eclipse LunaMicrosoft SQL Server四、系统ER图五、表结构定义(使用表格说明)六、系统功能模块1)能够通过书籍基本信息单个或组合多个条件查询书籍信息;2)对于每一种书籍,除可查看其基本信息之外还可查看其总数以及目前在馆数量3)可增添新的书籍4)可删除已有书籍(如有读者借了该书籍尚未归还,则不允许删除)5)可修改书籍的基本信息6)能够通过读者基本信息单个或组合多个条件查询读者信息7)对于每位读者除可查看其基本信息之外,还可查看其已借的书籍列表、数量、借还日期8)可增添新的读者9)可删除已有读者(如该读者有尚未归还的借书,则不允许删除)10)可修改读者的基本信息11)可完成借还书籍的手续12)还书时如超期,应该显示超期天数13)借书时如果有超期的书没有还,则不允许借书14)可查询有哪些读者有超期的书没有还,列出这些读者的基本信息七、程序框架流程图九、程序运行结果八、核心代码AddBook.javaimport java.awt.BorderLayout;import java.awt.Container;import java.awt.GridLayout;import java.awt.event.*;import java.util.ArrayList;import javax.swing.*; publicclassAddBookextends JFrame implements ActionListener {SQLOperation op = newSQLOperation();Container c = getContentPane();JPanel p1 = new JPanel();JLabel bookNumber = newJLabel("Book Number:");JLabel bookName = new JLabel("Book Name:");JLabel bookAuthor = newJLabel("Book Author:");JLabel press = new JLabel("Press:");JLabel pressTime = newJLabel("Press time:");JLabel bookAbstract = newJLabel("Abstract:");JLabel storage = newJLabel("Storage:");JLabel remain = newJLabel("Remain");JLabel remain1 = new JLabel("Update with Storage");JTextFieldnumberField = newJTextField(); JTextFieldnameField = newJTextField(); JTextFieldauthorField = newJTextField(); JTextFieldpressField = newJTextField();JTextFieldpressTimeField = newJTextField();JTextFieldabstractField = newJTextField();JTextFieldstorageField = newJTextField();JButton cancel = newJButton("Cancel");JButton confirm = newJButton("Confirm!!");public AddBook() {c.add(p1, 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(storage);p1.add(storageField);p1.add(remain);p1.add(remain1);p1.add(cancel);p1.add(confirm);cancel.addActionListener(this); confirm.addActionListener(this);}publicvoid actionPerformed(ActionEvent e) {// TODO Autogenerated method stubif (e.getSource() == cancel) {this.dispose();}if (e.getSource() == 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.getTe xt()));ArrayList<String> strArray = new ArrayList<String>();strArray = op.addBookJudgement();intn = 0;intreplicate = 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 successfully!", "Information",RMATION_MESSAGE);} else {JOptionPane.showMessageDialog(null,"This book(number) has already existed!", "Warning",RMATION_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.*; publicclassAddReaderextends JFrame implements ActionListener {SQLOperation op = new SQLOperation();Container c = getContentPane();JPanel p1 = new JPanel();JLabel readerNumber = newJLabel("Reader Number:");JLabel readerName = newJLabel("Reader Name:");JLabel sex = new JLabel("Sex:");JLabel dpt = newJLabel("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 cancel = newJButton("Cancel");JButton confirm = newJButton("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.add(grade);p1.add(gradeField);p1.add(cancel);p1.add(confirm);cancel.addActionListener(this);confirm.addActionListener(this);}publicvoid actionPerformed(ActionEvent e) {// TODO Autogenerated 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(gradeField.getText()));ArrayList<String> strArray = new ArrayList<String>();strArray = op.addReaderJudgement();intn = 0;intreplicate = 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().equals("girl ")) {JOptionPane.showMessageDialog(null,"In the Sex field, you can only input 'boy' or 'girl'!","Warning",RMATION_MESSAGE);} else {op.saveReader(reader);JOptionPane.showMessageDialog(null, "Add a reader successfully!", "Information",RMATION_MESSAGE);}} else {JOptionPane.showMessageDialog(null, "This reader(number) has already existed!", "Warning",RMATION_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.*;importjavax.swing.table.DefaultTableModel; publicclassBookDetailsextends JFrame implements ActionListener {SQLOperation op = new SQLOperation();Container c = getContentPane();JPanel p1 = new JPanel();JPanel p2 = new JPanel();JPanel p3 = new JPanel();JLabel bookNumber = newJLabel("Book Number:");JLabel bookName = new JLabel("Book Name:");JLabel author = newJLabel("Author:");JLabel press = new JLabel("Press:");JLabel pressTime = newJLabel("Press time:");JLabel bookAbstract = newJLabel("Abstract:");JLabel storage = newJLabel("Storage:");JLabel remain = newJLabel("Remain:");JLabel numberField = new JLabel();JLabel nameField = new JLabel();JLabel authorField = new JLabel();JLabel pressField = new JLabel();JLabel pressTimeField = newJLabel();JLabel abstractField = new JLabel();JLabel storageField = new JLabel();JLabel remainField = new JLabel();JButton cancel = newJButton("Cancel");JLabel details = new JLabel("Borrow and reaturn details");Object[] s = { "Reader number", "Borrow time", "Deadline", "Over time" };Object[][] ob1 = new Object[7][4];JTable table = new JTable(ob1, s);JScrollPane scrollPane = new JScrollPane(table);public BookDetails(String number) {BookInfo book = newBookInfo(number);ob1 = op.borrowListForBook(number);for (inti = 0; i < 5; i++) {DefaultTableModel books = new DefaultTableModel(ob1, s);for (intn = 0; n < 7; n++) {for (intm = 0; m < 4; m++) {ob1[n][m] = this.ob1[n][m];}table.setModel(books);table.invalidate();}}ArrayList<String> strArray = new ArrayList<String>();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)); abstractField.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));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(abstractField);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.setPreferredScrollableViewportSiz e(new Dimension(400, 100));cancel.addActionListener(this);}publicvoid actionPerformed(ActionEvent e) {// TODO Autogenerated method stubif (e.getSource() == cancel) {this.dispose();}}}BookInfo.javapublicclass BookInfo {private String number, name, author, press, pressTime, bookAbstract; privateinttotal, remain;// default constructorpublic BookInfo() {}public BookInfo(String number) {this.number = number;}public BookInfo(String number, String name) {this.number = number; = name;}public BookInfo(String number, String name, String author, String press,String pressTime, String bookAbstract, inttotal, intremain) { this.number = number; = name;this.author = author;this.press = press;this.pressTime = pressTime;this.bookAbstract = bookAbstract; this.total = total;this.remain = remain;}publicvoid setRemain(inti) { this.remain=i;}public String getNumber() { returnnumber;}public String getName() { returnname;}public String getAuthor() { returnauthor;}public String getPress() {returnpress;}public String getPressTime() { returnpressTime;}public String getBookAbstract() { returnbookAbstract;}publicint getTotal() { returntotal;}publicint getRemain() { returnremain;}}BookRetrieval.javaimport 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.*;importjavax.swing.table.DefaultTableModel; classBookRetrievalextends JFrame implements ActionListener {SQLOperation op = new SQLOperation();Container c = getContentPane();JPanel p1 = new JPanel();JPanel p4 = new JPanel();JPanel p5 = new JPanel();JLabel bookNumber = newJLabel("Book Number:");JLabel bookName = new JLabel("Book Name:");JTextField number = newJTextField();JTextField name = new JTextField();JButton back = new JButton("Back (Fresh)");JButton addBook = new JButton("Add a book");JButton deleteBook = newJButton("Delete a book");JButton editBook = newJButton("Edit a book");JButton search = newJButton("Search for details!");JButton borrowBook = newJButton("Borrow a book");JButton returnBook = newJButton("Return a book");Font font1 = new Font("00",Font.BOLD, 20);Object[] s = { "Number", "Name", "Author", "Press", "Press Time", "Abstract", "Storage", "Remain" };Object[][] ob = new Object[40][8];JTable table = new JTable(ob, s);JScrollPane scrollPane = new JScrollPane(table);public BookRetrieval() {BookInfo book = new BookInfo(); ob = op.allBook(book);for (inti = 0; i < 5; i++) {DefaultTableModel books = new DefaultTableModel(ob, s);for (intn = 0; n < 20; n++) {for (intm = 0; m < 8; m++) {ob[n][m] = this.ob[n][m];}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);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.setPreferredScrollableViewportSiz e(new Dimension(400, 300));addBook.addActionListener(this); search.addActionListener(this);back.addActionListener(this); deleteBook.addActionListener(this); editBook.addActionListener(this); borrowBook.addActionListener(this); returnBook.addActionListener(this);}publicvoid actionPerformed(ActionEvent e) {if (e.getSource() == search) {ArrayList<String> strArray = new ArrayList<String>();strArray = op.addBookJudgement();String s1 =number.getText();String s2 = name.getText(); intn = 0;intreplicate = 0;while (n <Integer.parseInt(strArray.get(0))) {n++;if (s1.equals(strArray.get(n))) { replicate++;}}ArrayList<String> strArray1 = new ArrayList<String>();strArray1 = op.addBookJudgement1();intn1 = 0;intreplicate1 = 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",RMATION_MESSAGE);} elseif (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.setSize(480, 470);f.setVisible(true);} elseif (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.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(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 = 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.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.BorderLayout;import java.awt.Container;import java.awt.GridLayout;import java.awt.event.*;import java.util.ArrayList;import javax.swing.*; publicclassBorrowBookextends JFrame implements ActionListener {SQLOperation op = new SQLOperation();Container c = getContentPane();JPanel p1 = new JPanel();JLabel bookNumber = newJLabel("Book Number:");JTextField numberField = new JTextField();JLabel readerNumber = newJLabel("Reader Number:");JTextField readerNumberField = new JTextField();JButton cancel = newJButton("Cancel");JButton borrow = newJButton("Borrow!!");public BorrowBook() {c.add(p1, BorderLayout.NORTH);p1.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);}publicvoid actionPerformed(ActionEvent e) {// TODO Autogenerated method stubif (e.getSource() == cancel) {this.dispose();}if (e.getSource() == borrow) {String bookNumber = numberField.getText();ArrayList<String> strArray = new ArrayList<String>();strArray = op.addBookJudgement();intn = 0;intreplicate = 0;while (n <Integer.parseInt(strArray.get(0))) {n++;if (bookNumber.equals(strArray.get(n))) {replicate++;}}String readerNumber = readerNumberField.getText();ArrayList<String> strArray1 = new ArrayList<String>();strArray1 = op.addReaderJudgement();intn1 = 0;intreplicate1 = 0;while (n1 <Integer.parseInt(strArray1.get(0))) {n1++;if(readerNumber.equals(strArray1.get(n1))) {replicate1++;}}if (replicate == 0 || replicate1 == 0) {JOptionPane.showMessageDialog(null,"Please input a correct book number and a reader number!","Warning",RMATION_MESSAGE);} else {BookInfo book = new BookInfo(bookNumber);ArrayList<String> s = new ArrayList<String>();s = op.outputBook(book);if (Integer.parseInt(s.get(7)) > 0) { ints1 =op.reBorrowCheck(numberField.getText(), readerNumberField.getText());if (s1 == 1) {JOptionPane.showMessageDialog(null,"You have borrowed this book, can not reborrow it!","Unsuccessful",RMATION_MESSAGE);} else { longcurrentTime =System.currentTimeMillis();if(op.deadLineCheck(readerNumberField.get Text(),currentTime) != 0) {JOptionPane.showMessageDialog(null,"You have exceeded the deadline, please return these books first!", "Unsuccessful",RMATION_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.inputBook(book1);StringborrowTime = 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);JOptionPane.showMessageDialog(null,"Borrowed this book successfully, youhave 30 days to enjoy this book!", "Successful",RMATION_MESSAGE);}}} else {JOptionPane.showMessageDialog(null, "This book has been borrowed!", "Unsuccessful",RMATION_MESSAGE);}}this.dispose();}}}BorrowList.Javaimport java.awt.BorderLayout;import java.awt.Container;import java.awt.Dimension; importjava.awt.Font;importjava.awt.GridLayout;import java.awt.event.*;importjava.util.ArrayList;import javax.swing.*;importjavax.swing.table.DefaultTableModel; publicclassBorrowListextends JFrame implements ActionListener {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 Object[100][5];JTable table = new JTable(ob, s);JScrollPane scrollPane = new JScrollPane(table);public BorrowList() {// TODO Autogenerated constructor stub Object[][] ob1 =op.borrowList();for (inti = 0; i < 5; i++) {DefaultTableModel list = new DefaultTableModel(ob, s);for (intn = 0; n < 100; n++) {for (intm = 0; m < 5; m++) {ob[n][m] = ob1[n][m];}table.setModel(list);table.invalidate();}}c.add(p1, BorderLayout.CENTER);c.add(p2,BorderLayout.SOUTH);scrollPane.setBounds(0, 0, 800, 300);p1.add(scrollPane);p2.add(back);table.setPreferredScrollableViewportSiz e(new Dimension(400, 400));back.addActionListener(this);}publicvoid actionPerformed(ActionEvent e) {if (e.getSource() == back) {this.dispose();MyFrame f = new MyFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ ON_CLOSE);f.setTitle("Library Management System");f.setLocation(300, 200);f.setSize(580, 300);f.setVisible(true);}// TODO Autogenerated method stub }}Date.javaimport java.text.DateFormat;import java.text.SimpleDateFormat; publicclass Date {public Date(){}static StringborrowTimeInterface(longtime) {SimpleDateFormat df = (SimpleDateFormat)DateFormat.getInstance();df.applyPattern("yyyyMMdd");String s = df.format(time); returns;}。
java图书馆管理系统课程设计
Java图书馆管理系统课程设计摘要本文介绍了一个基于Java的图书馆管理系统的课程设计。
该系统旨在帮助图书馆有效地管理图书借阅、归还以及读者信息管理等功能。
系统采用Java语言编写,利用面向对象的思想进行设计与实现,实现了图书的分类管理、借阅记录的管理、读者信息的管理等功能。
通过该系统的设计与实现,方便图书馆管理员进行日常的图书信息管理工作,同时提高读者借阅图书和归还图书的便捷性。
1.引言图书馆作为一个重要的文化及知识传播机构,其管理任务日益复杂。
借助计算机技术的发展,图书馆管理系统帮助图书馆实现了自动化的图书信息管理、借阅管理和读者管理等功能,极大地提高了工作效率与准确性。
本文介绍的Java图书馆管理系统具有以下特点:•使用Java语言编写,具有良好的跨平台性;•采用面向对象的思想设计,具有良好的扩展性与可维护性;•实现了图书分类管理、借阅记录管理、读者信息管理等功能,并提供了相应的操作界面;•提高了图书管理员的工作效率,提供了读者便捷的查询借阅信息和操作的途径。
2.系统设计2.1 需求分析在开始系统设计之前,我们需要对图书馆管理系统的需求进行分析。
根据实际需求,我们确定了以下功能模块:•图书管理:包括图书的添加、删除、修改和查询;•读者管理:包括读者的添加、删除、修改和查询;•借阅管理:包括借阅记录的添加、删除、修改和查询;•统计分析:包括图书借阅量和读者借阅排行等统计分析功能。
2.2 系统架构系统采用三层架构进行设计,分为表示层、业务逻辑层和数据访问层。
•表示层:负责展示图书馆管理系统的界面,接受用户的操作输入,并将输入传递给业务逻辑层进行处理;•业务逻辑层:负责处理用户操作的业务逻辑,包括图书管理、读者管理、借阅管理等功能的实现;•数据访问层:负责与数据库进行数据交互,包括读取图书信息、读者信息、借阅记录信息等。
2.3 类设计在系统设计过程中,我们根据功能模块的需求,设计了以下类:•图书类(Book):表示一本书的信息,包括书名、作者、出版社等;•读者类(Reader):表示一个读者的信息,包括姓名、年龄、性别等;•借阅记录类(BorrowRecord):表示一条借阅记录的信息,包括图书、读者、借阅时间等;•图书管理类(BookManager):实现图书的添加、删除、修改和查询功能;•读者管理类(ReaderManager):实现读者的添加、删除、修改和查询功能;•借阅管理类(BorrowManager):实现借阅记录的添加、删除、修改和查询功能;•统计分析类(StatisticsManager):实现图书借阅量和读者借阅排行等统计分析功能。
Java 图书馆管理系统(附全代码)_课程设计报告之欧阳语创编
《数据库系统概论》课程报告课题名称:小型图书管理系统课题负责人名(学号):best同组成员名单(角色):指导教师:评阅成绩:评阅意见:提交报告时间:12月15日小型图书管理系统计算机科学与技术专业学生指导老师[摘要] 随着计算机技术的飞速发展,利用计算机来获得和处理信息是当今信息管理的一大特点。
伴随计算机硬件的快速发展,有关信息管理的软件——数据库系统软件也在迅猛发展着。
图书馆是高等院校的重要组成部门,是教师和学生获取知识的重要场所。
由于图书馆主要从事大量的图书资料的储存和流通。
所以一直以来,计算机在图书馆的图书管理中得到了广泛的应用。
本系统实现图书信息管理的系统化,规范化和自动化,以最大程度提高操作人员的办公效率。
关键词:JAVA、JDBC、SQL Server、数据库、图书馆管理一、实验题目:小型图书管理系统二、实验的目的和要求:完成一个小型图书管理系统,功能要求如下:1)能够通过书籍基本信息(包括:书号、书名、出版社、出版日期、作者、内容摘要)单个或以AND方式组合多个条件查询书籍信息;2)对于每一种书籍,除可查看其基本信息之外还可查看其总数以及目前在馆数量3)可增添新的书籍4)可删除已有书籍(如有读者借了该书籍尚未归还,则不允许删除)5)可修改书籍的基本信息6)能够通过读者基本信息(包括:证号、姓名、性别、系名、年级)单个或以AND 方式组合多个条件查询读者信息7)对于每位读者除可查看其基本信息之外,还可查看其已借的书籍列表、数量、借还日期8)可增添新的读者9)可删除已有读者(如该读者有尚未归还的借书,则不允许删除)10)可修改读者的基本信息11)可完成借还书籍的手续12)还书时如超期,应该显示超期天数13)借书时如果有超期的书没有还,则不允许借书14)可查询有哪些读者有超期的书没有还,列出这些读者的基本信息三、实验的环境:1、硬件环境:CPU:Intel(R) Core i532302.60GHzRAM:8GB2、软件环境:操作系统:Windows 7 Ultimate SP1编译软件:Eclipse LunaMicrosoft SQL Server四、系统ER图五、表结构定义(使用表格说明)六、系统功能模块1)能够通过书籍基本信息单个或组合多个条件查询书籍信息;2)对于每一种书籍,除可查看其基本信息之外还可查看其总数以及目前在馆数量3)可增添新的书籍4)可删除已有书籍(如有读者借了该书籍尚未归还,则不允许删除)5)可修改书籍的基本信息6)能够通过读者基本信息单个或组合多个条件查询读者信息7)对于每位读者除可查看其基本信息之外,还可查看其已借的书籍列表、数量、借还日期8)可增添新的读者9)可删除已有读者(如该读者有尚未归还的借书,则不允许删除)10)可修改读者的基本信息11)可完成借还书籍的手续12)还书时如超期,应该显示超期天数13)借书时如果有超期的书没有还,则不允许借书14)可查询有哪些读者有超期的书没有还,列出这些读者的基本信息七、程序框架流程图九、程序运行结果八、核心代码AddBook.javaimport java.awt.BorderLayout;import java.awt.Container;import java.awt.GridLayout;import java.awt.event.*;import java.util.ArrayList;import javax.swing.*; publicclassAddBookextends JFrame implements ActionListener {SQLOperation op = new SQLOperation();Container c = getContentPane();JPanel p1 = new JPanel();JLabel bookNumber = newJLabel("Book Number:");JLabel bookName = newJLabel("Book Name:");JLabel bookAuthor = newJLabel("Book Author:");JLabel press = new JLabel("Press:");JLabel pressTime = newJLabel("Press time:");JLabel bookAbstract = new JLabel("Abstract:");JLabel storage = newJLabel("Storage:");JLabel remain = newJLabel("Remain");JLabel remain1 = newJLabel("Update with Storage"); JTextFieldnumberField = newJTextField(); JTextFieldnameField = newJTextField(); JTextFieldauthorField = newJTextField(); JTextFieldpressField = newJTextField();JTextFieldpressTimeField = newJTextField(); JTextFieldabstractField = newJTextField(); JTextFieldstorageField = newJTextField();JButton cancel = newJButton("Cancel");JButton confirm = newJButton("Confirm!!");public AddBook() {c.add(p1, 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(storage);p1.add(storageField);p1.add(remain);p1.add(remain1);p1.add(cancel);p1.add(confirm);cancel.addActionListener(this); confirm.addActionListener(this);}publicvoid actionPerformed(ActionEvent e) {// TODO Autogenerated method stubif (e.getSource() == cancel) {this.dispose();}if (e.getSource() == 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.getTex t()));ArrayList<String> strArray = new ArrayList<String>();strArray = op.addBookJudgement();intn = 0;intreplicate = 0;while (n <Integer.parseInt(strArray.get(0))) {n++;if(numberField.getText().equals(strArray.g et(n))) {replicate++;}}if (replicate == 0) {op.saveBook(book);JOptionPane.showMessageDialog(n ull, "Add a book successfully!", "Information",RMATION_MESSAGE);} else {JOptionPane.showMessageDialog(n ull,"This book(number) has alreadyexisted!", "Warning",RMATION_MESSA GE);}}}}AddReader.javaimport java.awt.BorderLayout;import java.awt.Container;import java.awt.GridLayout;import java.awt.event.*;import java.util.ArrayList;import javax.swing.*; publicclassAddReaderextends JFrame implements ActionListener {SQLOperation op = new SQLOperation();Container c = getContentPane();JPanel p1 = new JPanel();JLabel readerNumber = new JLabel("Reader Number:");JLabel readerName = newJLabel("Reader Name:");JLabel sex = new JLabel("Sex:");JLabel dpt = newJLabel("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 cancel = newJButton("Cancel");JButton confirm = newJButton("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.add(grade);p1.add(gradeField);p1.add(cancel);p1.add(confirm);cancel.addActionListener(this);confirm.addActionListener(this);}publicvoid actionPerformed(ActionEvent e) {// TODO Autogenerated 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(gradeField.getText()));ArrayList<String> strArray = new ArrayList<String>();strArray = op.addReaderJudgement(); intn = 0;intreplicate = 0;while (n <Integer.parseInt(strArray.get(0))) {n++;if(numberField.getText().equals(strArray.g et(n))) {replicate++;}}if (replicate == 0) {if (!sexField.getText().equals("boy")&& !sexField.getText().equals("girl")) {JOptionPane.showMessageDialog(null,"In the Sex field, you can only input'boy' or 'girl'!","Warning",RMATION_MESSAGE);} else {op.saveReader(reader);JOptionPane.showMessageDialog(n ull,"Add a reader successfully!", "Information",RMATION_MESSA GE);}} else {JOptionPane.showMessageDialog(n ull,"This reader(number) has already existed!", "Warning",RMATION_MESSA GE);}}}}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.*;importjavax.swing.table.DefaultTableModel; publicclassBookDetailsextends 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 bookName = newJLabel("Book Name:");JLabel author = newJLabel("Author:");JLabel press = new JLabel("Press:");JLabel pressTime = newJLabel("Press time:");JLabel bookAbstract = new JLabel("Abstract:");JLabel storage = newJLabel("Storage:");JLabel remain = newJLabel("Remain:");JLabel numberField = new JLabel();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 = newJButton("Cancel");JLabel details = new JLabel("Borrow and reaturn details");Object[] s = { "Reader number", "Borrow time", "Deadline", "Over time" };Object[][] ob1 = new Object[7][4];JTable table = new JTable(ob1, s);JScrollPane scrollPane = new JScrollPane(table);public BookDetails(String number) {BookInfo book = newBookInfo(number);ob1 = op.borrowListForBook(number); for (inti = 0; i < 5; i++) {DefaultTableModel books = new DefaultTableModel(ob1, s);for (intn = 0; n < 7; n++) {for (intm = 0; m < 4; m++) {ob1[n][m] = this.ob1[n][m];}table.setModel(books);table.invalidate();}}ArrayList<String> strArray = new ArrayList<String>();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)); abstractField.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));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(abstractField);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);}publicvoid actionPerformed(ActionEvent e) {// TODO Autogenerated method stubif (e.getSource() == cancel) {this.dispose();}}}BookInfo.javapublicclass BookInfo {private String number, name, author, press, pressTime, bookAbstract; privateinttotal, remain;// default constructorpublic BookInfo() {}public BookInfo(String number) { this.number = number;}public BookInfo(String number, String name) {this.number = number; = name;}public BookInfo(String number, String name, String author, String press,String pressTime, StringbookAbstract, inttotal, intremain) { this.number = number; = name;this.author = author;this.press = press;this.pressTime = pressTime; this.bookAbstract = bookAbstract; this.total = total;this.remain = remain;}publicvoid setRemain(inti) {this.remain=i;}public String getNumber() { returnnumber;}public String getName() { returnname;}public String getAuthor() {returnauthor;}public String getPress() { returnpress;}public String getPressTime() { returnpressTime;}public String getBookAbstract() { returnbookAbstract;}publicint getTotal() { returntotal;}publicint getRemain() { returnremain;}}BookRetrieval.javaimport 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.*;importjavax.swing.table.DefaultTableModel; classBookRetrievalextends JFrame implements ActionListener {SQLOperation 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 bookName = newJLabel("Book Name:");JTextField number = new JTextField();JTextField name = new JTextField();JButton back = new JButton("Back (Fresh)");JButton addBook = newJButton("Add a book");JButton deleteBook = new JButton("Delete a book");JButton editBook = newJButton("Edit a book");JButton search = newJButton("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", "Abstract", "Storage", "Remain" };Object[][] ob = new Object[40][8];JTable table = new JTable(ob, s);JScrollPane scrollPane = new JScrollPane(table);public BookRetrieval() {BookInfo book = new BookInfo();ob = op.allBook(book);for (inti = 0; i < 5; i++) {DefaultTableModel books = new DefaultTableModel(ob, s);for (intn = 0; n < 20; n++) {for (intm = 0; m < 8; m++) {ob[n][m] = this.ob[n][m];}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);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 Dimension(400, 300)); addBook.addActionListener(this); search.addActionListener(this);back.addActionListener(this); deleteBook.addActionListener(this); editBook.addActionListener(this); borrowBook.addActionListener(this); returnBook.addActionListener(this);}publicvoid actionPerformed(ActionEvent e) {if (e.getSource() == search) {ArrayList<String> strArray = new ArrayList<String>();strArray = op.addBookJudgement();String s1 =number.getText();String s2 = name.getText(); intn = 0;intreplicate = 0;while (n <Integer.parseInt(strArray.get(0))) {n++;if (s1.equals(strArray.get(n))) {replicate++;}}ArrayList<String> strArray1 = new ArrayList<String>(); strArray1 = op.addBookJudgement1(); intn1 = 0;intreplicate1 = 0;while (n1 <Integer.parseInt(strArray1.get(0))) {n1++;if (s2.equals(strArray1.get(n1))) {replicate1++;}}if (replicate == 0 && replicate1 == 0) {JOptionPane.showMessageDialog(n ull,"Please input a correct book number or name!","Warning",RMATION_MESSAGE);} elseif (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.setSize(480, 470);f.setVisible(true);} elseif (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.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(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 = 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.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.BorderLayout;import java.awt.Container;import java.awt.GridLayout;import java.awt.event.*;import java.util.ArrayList;import javax.swing.*; publicclassBorrowBookextends JFrame implements ActionListener {SQLOperation op = newSQLOperation();Container c = getContentPane();JPanel p1 = new JPanel();JLabel bookNumber = new JLabel("Book Number:");JTextField numberField = new JTextField();JLabel readerNumber = new JLabel("Reader Number:");JTextField readerNumberField = new JTextField();JButton cancel = newJButton("Cancel");JButton borrow = newJButton("Borrow!!");public BorrowBook() {c.add(p1, BorderLayout.NORTH);p1.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);}publicvoid actionPerformed(ActionEvent e) {// TODO Autogenerated method stubif (e.getSource() == cancel) {this.dispose();}if (e.getSource() == borrow) {String bookNumber = numberField.getText();ArrayList<String> strArray = new ArrayList<String>();strArray = op.addBookJudgement();intn = 0;intreplicate = 0;while (n <Integer.parseInt(strArray.get(0))) {n++;if (bookNumber.equals(strArray.get(n))) { replicate++;}}String readerNumber = readerNumberField.getText();ArrayList<String> strArray1 = new ArrayList<String>(); strArray1 = op.addReaderJudgement(); intn1 = 0;intreplicate1 = 0;while (n1 <Integer.parseInt(strArray1.get(0))) {n1++;if(readerNumber.equals(strArray1.get(n1))) {replicate1++;}}if (replicate == 0 || replicate1 == 0) {JOptionPane.showMessageDialog(null,"Please input a correct book number and a reader number!","Warning",RMATION_MESSAGE);} else {BookInfo book = new BookInfo(bookNumber);ArrayList<String> s = new ArrayList<String>();s = op.outputBook(book);if (Integer.parseInt(s.get(7)) > 0) {ints1 =op.reBorrowCheck(numberField.getText(), readerNumberField.getText());if (s1 == 1) {JOptionPane.showMessageDialog(null,"You have borrowed this book, can not reborrow it!","Unsuccessful",RMATION_MESSA GE);} else { longcurrentTime =System.currentTimeMillis();if(op.deadLineCheck(readerNumberField.g etText(),currentTime) != 0) {JOptionPane.showMessageDialog(null,"You have exceeded the deadline, please return these books first!", "Unsuccessful",RMATION_MESSA GE);} else {BookInfo book1 = newBookInfo(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.inputBook(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);JOptionPane.showMessageDialog(null,"Borrowed this book successfully, you have 30 days to enjoy this book!", "Successful",RMATION_MESSA GE);}}} else {JOptionPane.showMessageDialog(n ull,"This book has been borrowed!","Unsuccessful",RMATION_MESSA GE);}}this.dispose();}}}BorrowList.Javaimport java.awt.BorderLayout;import java.awt.Container;import java.awt.Dimension; importjava.awt.Font;importjava.awt.GridLayout;import java.awt.event.*;importjava.util.ArrayList;import javax.swing.*;importjavax.swing.table.DefaultTableModel; publicclassBorrowListextends JFrame implements ActionListener {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 Object[100][5];JTable table = new JTable(ob, s);JScrollPane scrollPane = new JScrollPane(table);public BorrowList() {// TODO Autogenerated constructor stubObject[][] ob1 =op.borrowList();for (inti = 0; i < 5; i++) {DefaultTableModel list = new DefaultTableModel(ob, s);for (intn = 0; n < 100; n++) {for (intm = 0; m < 5; m++) {ob[n][m] = ob1[n][m];}table.setModel(list);table.invalidate();}}c.add(p1, BorderLayout.CENTER);c.add(p2,BorderLayout.SOUTH); scrollPane.setBounds(0, 0, 800, 300);p1.add(scrollPane);p2.add(back);table.setPreferredScrollableViewportSize (new Dimension(400, 400));back.addActionListener(this);}publicvoid actionPerformed(ActionEvent e) {if (e.getSource() == back) {this.dispose();MyFrame f = new MyFrame();f.setDefaultCloseOperation(JFrame.EXIT_ ON_CLOSE);f.setTitle("Library Management System");f.setLocation(300, 200);f.setSize(580, 300);f.setVisible(true);}// TODO Autogenerated method stub }}Date.javaimport java.text.DateFormat;import java.text.SimpleDateFormat;。
Java图书管理系统设计报告
Java图书管理系统设计报告简介Java图书管理系统是一款用于管理图书馆借阅业务的应用程序。
该系统旨在简化图书馆的图书借阅和归还流程,提高图书馆的运作效率。
本文将对Java图书管理系统的设计进行详细介绍。
功能需求Java图书管理系统需要满足以下功能需求: 1. 用户注册和登录:用户可以注册新账号并通过账号密码登录系统。
2. 图书查询和展示:用户可以通过关键词搜索图书,并查看图书的详细信息和可借数量。
3. 图书借阅和归还:用户可以借阅图书,系统将相应图书的可借数量减少;用户还书时,系统将相应图书的可借数量增加。
4. 图书推荐:系统可以根据用户的借阅记录和兴趣,推荐适合用户的图书。
5. 借阅历史查询:用户可以查看自己的借阅历史记录。
系统设计数据库设计系统需要设计以下表格来存储数据: - 用户表(User):存储用户的账号、密码、姓名等信息。
- 图书表(Book):存储图书的信息,包括图书名称、作者、数量等。
- 借阅表(Borrow):存储用户的借阅记录,包括用户ID、图书ID、借阅日期等信息。
系统架构Java图书管理系统采用分层架构,包括以下几个层次: 1. 表现层(Presentation Layer):负责与用户进行交互,接收用户的输入和显示系统的输出。
2. 业务逻辑层(Business Logic Layer):处理具体的业务逻辑,例如用户登录、图书管理、借阅归还等。
3. 数据访问层(Data Access Layer):负责与数据库进行交互,包括插入、查询和更新数据的操作。
类设计系统设计需要定义以下几个类: 1. User类:表示用户,包括用户的账号、密码、姓名等属性。
2. Book类:表示图书,包括图书的名称、作者、数量等属性。
3. Borrow类:表示借阅记录,包括用户ID、图书ID、借阅日期等属性。
4. UserService类:处理与用户相关的逻辑,例如用户注册、登录等。
Java图书馆管理系统附全代码课程设计报告
J a v a图书馆管理系统附全代码课程设计报告 TPMK standardization office【 TPMK5AB- TPMK08- TPMK2C-《数据库系统概论》课程报告课题名称:小型图书管理系统课题负责人名(学号): best同组成员名单(角色):指导教师:评阅成绩:评阅意见:提交报告时间:2015年12月15日小型图书管理系统计算机科学与技术专业学生指导老师[摘要]随着计算机技术的飞速发展,利用计算机来获得和处理信息是当今信息管理的一大特点。
伴随计算机硬件的快速发展,有关信息管理的软件——数据库系统软件也在迅猛发展着。
图书馆是高等院校的重要组成部门,是教师和学生获取知识的重要场所。
由于图书馆主要从事大量的图书资料的储存和流通。
所以一直以来,计算机在图书馆的图书管理中得到了广泛的应用。
本系统实现图书信息管理的系统化,规范化和自动化,以最大程度提高操作人员的办公效率。
关键词:JAVA、JDBC、SQL Server、数据库、图书馆管理一、实验题目:小型图书管理系统二、实验的目的和要求:完成一个小型图书管理系统,功能要求如下:1)能够通过书籍基本信息(包括:书号、书名、出版社、出版日期、作者、内容摘要)单个或以AND方式组合多个条件查询书籍信息;2)对于每一种书籍,除可查看其基本信息之外还可查看其总数以及目前在馆数量3)可增添新的书籍4)可删除已有书籍(如有读者借了该书籍尚未归还,则不允许删除)5)可修改书籍的基本信息6)能够通过读者基本信息(包括:证号、姓名、性别、系名、年级)单个或以AND方式组合多个条件查询读者信息7)对于每位读者除可查看其基本信息之外,还可查看其已借的书籍列表、数量、借还日期8)可增添新的读者9)可删除已有读者(如该读者有尚未归还的借书,则不允许删除)10)可修改读者的基本信息11)可完成借还书籍的手续12)还书时如超期,应该显示超期天数13)借书时如果有超期的书没有还,则不允许借书14)可查询有哪些读者有超期的书没有还,列出这些读者的基本信息三、实验的环境:1、硬件环境:CPU: Intel(R) Core i5-3230 2.60GHzRAM: 8GB2、软件环境:操作系统:Windows 7 Ultimate SP1编译软件:Eclipse LunaMicrosoft SQL Server 2014四、系统ER 图图书管理员管理读者借阅管理编号性别姓名系名年级编号书名作者出版社出版时间摘要总量现存量用户名密码应还时间拥有权限删除图书修改读者修改图书删除读者添加读者添加图书超期时间借阅时间五、表结构定义(使用表格说明)六、系统功能模块1)能够通过书籍基本信息单个或组合多个条件查询书籍信息;2)对于每一种书籍,除可查看其基本信息之外还可查看其总数以及目前在馆数量3)可增添新的书籍4)可删除已有书籍(如有读者借了该书籍尚未归还,则不允许删除)5)可修改书籍的基本信息6)能够通过读者基本信息单个或组合多个条件查询读者信息7)对于每位读者除可查看其基本信息之外,还可查看其已借的书籍列表、数量、借还日期8)可增添新的读者9)可删除已有读者(如该读者有尚未归还的借书,则不允许删除)10)可修改读者的基本信息11)可完成借还书籍的手续12)还书时如超期,应该显示超期天数13)借书时如果有超期的书没有还,则不允许借书14)可查询有哪些读者有超期的书没有还,列出这些读者的基本信息七、程序框架流程图九、程序运行结果八、核心代码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 = 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:"); 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 authorField = 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, 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(storage);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.getSource() == confirm) {this.dispose();BookInfo book = newBookInfo(numberField.getText(),nameField.getText(), authorField.getText(),pressField.getText(), pressTimeField.getText(),abstractField.getText(), Integer.parseInt(storageField.getText()), Integer.parseInt(storageField.getText()));ArrayList<String> strArray = new ArrayList<String>();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 successfully!","Information", RMATION_MESSAGE);} else {JOptionPane.showMessageDialog(null,"This book(number) has already existed!", "Warning",RMATION_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 = 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 JTextField(); 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.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); }public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stubif (e.getSource() == cancel) {this.dispose();}if (e.getSource() == confirm) {this.dispose();ReaderInfo reader = newReaderInfo(numberField.getText(),nameField.getText(), sexField.getText(),dptField.getText(), Integer.parseInt(gradeField.getText()));ArrayList<String> strArray = new ArrayList<String>();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().equals("girl")) {JOptionPane.showMessageDialog(null,"In the Sex field, you can only input 'boy' or 'girl'!","Warning", RMATION_MESSAGE);} else {op.saveReader(reader);JOptionPane.showMessageDialog(null,"Add a reader successfully!", "Information",RMATION_MESSAGE);}} else {JOptionPane.showMessageDialog(null,"This reader(number) has already existed!", "Warning",RMATION_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.*;import 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 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();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 JLabel("Borrow and reaturn details");Object[] s = { "Reader number", "Borrow time", "Deadline", "Over time" };Object[][] ob1 = new Object[7][4];JTable table = new JTable(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++) {ob1[n][m] = this.ob1[n][m];}table.setModel(books);table.invalidate();}}ArrayList<String> strArray = new ArrayList<String>();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));abstractField.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)); 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(abstractField);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(ActionEvent 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 = number;}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;this.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 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.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 JPanel();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 JButton("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","Abstract", "Storage", "Remain" };Object[][] ob = new Object[40][8];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 = 0; n < 20; n++) {for (int m = 0; m < 8; m++) {ob[n][m] = this.ob[n][m];}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);p4.add(deleteBook);p4.add(borrowBook);p4.add(returnBook);。
JAVA数据库课程设计图书馆管理系统
架构模式:采用MVC(ModelView-Controller)模式进行系 统设计,实现前后端分离,提高 系统的可维护性和可扩展性。
数据库设计
数据库类型: MySQL
数据库结构:包 括用户表、图书 表、借阅表等
数据库操作:包 括增删改查等基 本操作
数据库优化:包 括索引优化、查 询优化等
界面设计
统计分析:图书借阅统计、用户借 阅统计等
系统维护:系统备份、系统恢复等
权限管理:用户权限分配、角色权 限管理等
数据需求分析
用户信息:包括用户名、密码、联 系方式等
图书信息:包括图书名称、作者、 出版社、出版日期、价格等
借阅信息:包括借阅时间、归还时 间、借阅状态等
管理员信息:包括管理员用户名、 密码、权限等
升级方式:自动升级或手动升 级
升级内容:数据库、服务器、 客户端等
升级注意事项:备份数据,确 保网络畅通,避免影响正常使 用
系统安全保障
访问控制:设置用户权限, 确保只有授权用户才能访问 系统
数据加密:对敏感数据进行 加密处理,防止数据泄露
备份与恢复:定期备份数据, 确保数据安全,并能在系统
故障时快速恢复
图书模块: 图书信息 管理、图 书借阅、 图书归还 等
管理员模 块:用户 管理、图 书管理、 系统管理 等
接口模块: 与数据库 交互的接 口设计
安全模块: 用户身份 验证、数 据加密等
性能优化 模块:提 高系统响 应速度和 稳定性
数据库连接实现
使用JDBC(Java Database Connectivity)技术进行数据库连接 连接参数包括:数据库URL、用户名、密码 连接成功后,可以使用SQL语句进行数据库操作 关闭连接时,需要释放资源,避免内存泄漏
图书馆管理java课程设计
图书馆管理java课程设计一、教学目标本课程的学习目标包括以下三个方面:1.知识目标:学生需要掌握Java语言的基础语法、数据结构、控制流程、文件操作等知识,了解面向对象编程的基本概念和方法,并能够运用Java语言实现简单的图书馆管理系统。
2.技能目标:学生能够熟练使用Java开发工具和环境,具备基本的代码调试和运行能力,能够独立完成图书馆管理系统的开发和维护。
3.情感态度价值观目标:培养学生对编程语言的兴趣和热情,增强学生的自主学习和问题解决能力,培养学生团队合作和沟通协作的精神。
二、教学内容本课程的教学内容主要包括以下几个部分:1.Java语言基础:Java语法、数据类型、运算符、控制流程、数组、字符串等。
2.面向对象编程:类和对象、封装、继承、多态、接口等。
3.数据结构:列表、栈、队列、链表、树、图等。
4.文件操作:文件读写、文件管理等。
5.图书馆管理系统:用户管理、图书管理、借阅管理等功能模块的设计和实现。
三、教学方法本课程的教学方法包括以下几种:1.讲授法:教师通过讲解和演示的方式,向学生传授Java语言的基本语法和编程方法。
2.案例分析法:教师通过分析具体的案例,引导学生理解和掌握面向对象编程的思想和方法。
3.实验法:学生通过动手实践,完成图书馆管理系统的开发和维护,提高编程能力和问题解决能力。
4.讨论法:学生分组讨论和合作,共同解决问题,培养团队合作和沟通协作的能力。
四、教学资源本课程的教学资源包括以下几种:1.教材:《Java编程思想》、《Java核心技术》等。
2.参考书:《Effective Java》、《深入理解Java虚拟机》等。
3.多媒体资料:教学视频、PPT课件等。
4.实验设备:计算机、网络设备等。
五、教学评估本课程的评估方式包括以下几个方面:1.平时表现:学生参与课堂讨论、提问、回答问题等活动的表现,以及课堂纪律和团队合作等情况。
2.作业:学生完成的练习题、编程作业和项目等,占总评的30%。
原创java图书馆管理系统课程设计报告
原创Java图书馆管理系统课程设计报告1. 引言本文档为Java图书馆管理系统课程设计报告,旨在介绍系统的设计与实现。
图书馆管理系统是一个管理图书馆馆藏图书、读者信息以及借还书等功能的软件系统。
本课程设计旨在通过使用Java编程语言和相关技术,构建一个简单但功能完善的图书馆管理系统。
2. 需求分析根据对图书馆管理系统的需求分析,我们确定了以下功能模块:图书管理、借阅管理、读者管理、系统登录和退出。
下面对每个功能模块进行详细说明:2.1 图书管理图书管理模块负责对图书进行管理,包括图书的添加、删除、修改和查询等功能。
管理员可以通过该模块完成对图书信息的操作,保证图书信息的准确性和完整性。
2.2 借阅管理借阅管理模块负责处理读者借阅图书的操作。
读者可以通过该模块查询图书的借阅情况,并进行借书和还书的操作。
借阅管理模块需要与图书管理模块进行交互,以确保图书库存和借阅情况的实时更新。
2.3 读者管理读者管理模块负责对读者信息进行管理,包括读者的注册、修改和查询等功能。
管理员可以通过该模块管理读者信息,并对读者进行权限的控制。
2.4 系统登录和退出系统登录和退出模块负责用户身份验证和系统的安全控制。
用户需要通过有效的用户名和密码进行登录,否则将无法操作系统。
系统退出时,需要进行数据保存和清理工作,确保系统数据的完整性和安全性。
3. 系统设计在系统设计阶段,我们采用面向对象的设计思想,将系统划分为多个类,并定义了它们的属性和方法。
下面是系统设计中的几个重要类:3.1 图书类(Book)图书类表示馆藏的图书。
它包含图书的编号、名称、作者、出版社和数量等属性,并提供对这些属性的访问方法。
public class Book {private int bookId;private String title;private String author;private String publisher;private int quantity;// Getters and setters// ...}3.2 读者类(Reader)读者类表示图书馆的读者。
图书管理系统java课程设计报告
图书管理系统 Java 课程设计报告1. 引言本报告旨在介绍一个基于 Java 的图书管理系统的设计和实现。
图书管理系统是一个常见的应用场景,通过该系统可以实现图书的借阅、归还、查询等功能。
在本报告中,我们将逐步讨论系统的设计思路和实现过程。
2. 系统需求分析在开始系统设计之前,我们首先需要分析系统的功能需求。
根据用户的需求和使用场景,我们确定了以下主要功能:1.用户登录与身份验证:系统需要支持用户的登录,并对用户进行身份验证,以确保只有授权用户能够使用系统。
2.图书管理:系统需要支持管理员对图书进行管理,包括添加新的图书、删除图书、更新图书信息等。
3.图书借阅与归还:系统需要支持用户对图书的借阅和归还操作,并记录借阅归还的时间。
4.图书查询:用户可以通过关键词查询图书,并获取相关的图书信息。
5.用户管理:管理员可以管理用户信息,包括添加新用户、删除用户等。
3. 系统设计基于以上需求分析,我们可以开始进行系统的设计。
我们将系统分为以下几个模块:3.1 用户模块用户模块负责处理用户的登录与身份验证。
用户需要提供正确的用户名和密码才能成功登录系统。
我们可以使用数据库来存储用户信息,并在用户登录时进行验证。
3.2 图书管理模块图书管理模块负责处理图书的添加、删除和更新等操作。
我们可以使用数据库来存储图书信息,并提供相应的接口供管理员使用。
3.3 图书借阅与归还模块图书借阅与归还模块负责处理用户对图书的借阅和归还操作。
我们可以使用数据库来记录借阅和归还的信息,并提供相应的接口供用户使用。
3.4 图书查询模块图书查询模块负责处理用户对图书的查询请求。
用户可以通过关键词进行图书的搜索,并获取相关的图书信息。
我们可以使用数据库来存储图书信息,并提供相应的接口供用户使用。
3.5 用户管理模块用户管理模块负责处理管理员对用户信息的管理。
管理员可以添加新用户、删除用户等操作。
我们可以使用数据库来存储用户信息,并提供相应的接口供管理员使用。
Java 图书馆管理系统(附全代码)_课程设计报告
《数据库系统概论》课程报告课题负责人名(学号): best同组成员名单(角色):指导教师:评阅成绩:评阅意见:提交报告时间:2015年12月15日小型图书管理系统计算机科学与技术专业学生指导老师[摘要]随着计算机技术的飞速发展,利用计算机来获得和处理信息是当今信息管理的一大特点。
伴随计算机硬件的快速发展,有关信息管理的软件——数据库系统软件也在迅猛发展着。
图书馆是高等院校的重要组成部门,是教师和学生获取知识的重要场所。
由于图书馆主要从事大量的图书资料的储存和流通。
所以一直以来,计算机在图书馆的图书管理中得到了广泛的应用。
本系统实现图书信息管理的系统化,规范化和自动化,以最大程度提高操作人员的办公效率。
关键词:JAVA、JDBC、SQL Server、数据库、图书馆管理一、实验题目:小型图书管理系统二、实验的目的和要求:完成一个小型图书管理系统,功能要求如下:1) 能够通过书籍基本信息(包括:书号、书名、出版社、出版日期、作者、内容摘要)单个或以AND方式组合多个条件查询书籍信息;2) 对于每一种书籍,除可查看其基本信息之外还可查看其总数以及目前在馆数量3) 可增添新的书籍4) 可删除已有书籍(如有读者借了该书籍尚未归还,则不允许删除)5) 可修改书籍的基本信息6) 能够通过读者基本信息(包括:证号、姓名、性别、系名、年级)单个或以AND方式组合多个条件查询读者信息7) 对于每位读者除可查看其基本信息之外,还可查看其已借的书籍列表、数量、借还日期8) 可增添新的读者9) 可删除已有读者(如该读者有尚未归还的借书,则不允许删除)10) 可修改读者的基本信息11) 可完成借还书籍的手续12) 还书时如超期,应该显示超期天数13) 借书时如果有超期的书没有还,则不允许借书14) 可查询有哪些读者有超期的书没有还,列出这些读者的基本信息三、实验的环境:1、硬件环境:CPU: Intel(R) Core i5-3230 2.60GHzRAM: 8GB2、软件环境:操作系统:Windows 7 Ultimate SP1编译软件:Eclipse LunaMicrosoft SQL Server 2014四、系统ER图五、表结构定义(使用表格说明)六、系统功能模块1) 能够通过书籍基本信息单个或组合多个条件查询书籍信息;2) 对于每一种书籍,除可查看其基本信息之外还可查看其总数以及目前在馆数量3) 可增添新的书籍4) 可删除已有书籍(如有读者借了该书籍尚未归还,则不允许删除)5) 可修改书籍的基本信息6) 能够通过读者基本信息单个或组合多个条件查询读者信息7) 对于每位读者除可查看其基本信息之外,还可查看其已借的书籍列表、数量、借还日期8) 可增添新的读者9) 可删除已有读者(如该读者有尚未归还的借书,则不允许删除)10) 可修改读者的基本信息11) 可完成借还书籍的手续12) 还书时如超期,应该显示超期天数13) 借书时如果有超期的书没有还,则不允许借书14) 可查询有哪些读者有超期的书没有还,列出这些读者的基本信息七、程序框架流程图九、程序运行结果八、核心代码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 = 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:");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 authorField = 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, 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(storage);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.getSource() == 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<String> strArray = new ArrayList<String>();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 successfully!","Information",RMATION_MESSAGE);} else {JOptionPane.showMessageDialog(null,"This book(number) has already existed!", "Warning",RMATION_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 = 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 JTextField();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.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);}public void actionPerformed(ActionEvent e) {// TODO Auto-generated method stubif (e.getSource() == cancel) {this.dispose();}if (e.getSource() == confirm) {this.dispose();ReaderInfo reader = newReaderInfo(numberField.getText(),nameField.getText(), sexField.getText(),dptField.getText(),Integer.parseInt(gradeField.getText()));ArrayList<String> strArray = new ArrayList<String>();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().equals("girl" )) {JOptionPane.showMessageDialog(null,"In the Sex field, you can only input 'boy' or 'girl'!","Warning", RMATION_MESSAGE);} else {op.saveReader(reader);JOptionPane.showMessageDialog(null,"Add a reader successfully!", "Information",RMATION_MESSA GE);}} else {JOptionPane.showMessageDialog(null,"This reader(number) has already existed!", "Warning",RMATION_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.*;import 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 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();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 JLabel("Borrow and reaturn details");Object[] s = { "Reader number", "Borrow time", "Deadline", "Over time" };Object[][] ob1 = new Object[7][4];JTable table = new JTable(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++) {ob1[n][m] = this.ob1[n][m];}table.setModel(books);table.invalidate();}}ArrayList<String> strArray = new ArrayList<String>(); 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)); abstractField.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));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(abstractField);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(ActionEvent 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 = number;}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;this.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 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.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 JPanel();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 JButton("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","Abstract", "Storage", "Remain" };Object[][] ob = new Object[40][8];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 = 0; n < 20; n++) {for (int m = 0; m < 8; m++) {ob[n][m] = this.ob[n][m];}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);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 Dimension(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.getSource() == search) {ArrayList<String> strArray = new ArrayList<String>();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<String> strArray1 = new ArrayList<String>();strArray1 = 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",RMATION_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.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 MyFrame();// 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(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 = 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.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.BorderLayout;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 bookNumber = 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.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.getSource() == cancel) {this.dispose();}if (e.getSource() == borrow) {String bookNumber = numberField.getText();ArrayList<String> strArray = new ArrayList<String>();strArray = op.addBookJudgement();int n = 0;int replicate = 0;while (n < Integer.parseInt(strArray.get(0))) {n++;if (bookNumber.equals(strArray.get(n))) {replicate++;}}String readerNumber = readerNumberField.getText();ArrayList<String> strArray1 = new ArrayList<String>();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) {JOptionPane.showMessageDialog(null,"Please input a correct book number and a reader number!","Warning", RMATION_MESSAGE);} else {BookInfo book = new BookInfo(bookNumber);ArrayList<String> s = new ArrayList<String>();s = op.outputBook(book);if (Integer.parseInt(s.get(7)) > 0) {int s1 =op.reBorrowCheck(numberField.getText(),readerNumberField.getText());if (s1 == 1) {JOptionPane.showMessageDialog(null,"You have borrowed this book, can not reborrow it!","Unsuccessfu l",JOptionPane. INFORMATION_MESSAGE);} else {long currentTime =System.currentTimeMillis();if(op.deadLineCheck(readerNumberField.getText(),currentTime) != 0) {JOptionPane.showMessageDialog (null,"You have exceeded the deadline, please return these books first!","Unsuc cessful",JOptio RMATION_MESSAGE);} else {BookInfo book1 = newBookInfo(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.inputBook(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.ge tText(),readerNumberField. getText(), borrowTime,deadline);JOptionPane.showMessageDialog (null,"Borro wed this book successfully, you have 30 days to enjoy this book!","Succe ssful",JOptio RMATION_MESSAGE);}}} else {JOptionPane.showMessageDialog(null,"This book has been borrowed!", "Unsuccessful",RMATION_MESSA GE);}}this.dispose();}}}BorrowList.Javaimport 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 ActionListener { 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 Object[100][5];JTable table = new JTable(ob, s);JScrollPane scrollPane = 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++) {ob[n][m] = ob1[n][m];}table.setModel(list);table.invalidate();}}c.add(p1, BorderLayout.CENTER);c.add(p2,BorderLayout.SOUTH);scrollPane.setBounds(0, 0, 800, 300);p1.add(scrollPane);p2.add(back);table.setPreferredScrollableViewportSize(new Dimension(400, 400));back.addActionListener(this);}public void actionPerformed(ActionEvent e) {if (e.getSource() == back) {this.dispose();MyFrame f = new MyFrame();f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);f.setTitle("Library Management System");f.setLocation(300, 200);f.setSize(580, 300);f.setVisible(true);}// TODO Auto-generated method stub}}Date.javaimport java.text.DateFormat;import java.text.SimpleDateFormat;public class Date {public Date(){}static String borrowTimeInterface(long time) {SimpleDateFormat df = (SimpleDateFormat) DateFormat.getInstance();df.applyPattern("yyyy-MM-dd");String s = df.format(time);return s;}}DeleteBook.javaimport java.awt.BorderLayout;import java.awt.Container;import java.awt.GridLayout;import java.awt.event.*;import javax.swing.*;public class DeleteBook extends JFrame implements ActionListener { SQLOperation op = new SQLOperation();Container c = getContentPane();JPanel p1 = new JPanel();JLabel bookNumber = new JLabel("Book Number:");JTextField numberField = new JTextField();JButton cancel = new JButton("Cancel");JButton delete = new JButton("Delete!!");public DeleteBook() {c.add(p1, BorderLayout.NORTH);p1.setLayout(new GridLayout(2, 2, 20, 10));p1.add(bookNumber);p1.add(numberField);p1.add(cancel);p1.add(delete);cancel.addActionListener(this);delete.addActionListener(this);}public void actionPerformed(ActionEvent e) {// TODO Auto-generated method stubif (e.getSource() == cancel) {this.dispose();}if (e.getSource() == delete) {BookInfo book = new BookInfo(numberField.getText());this.dispose();if (op.deleteBookCheck(numberField.getText()) != 0) {JOptionPane.showMessageDialog(null,"Delete the book unsuccessfully. The book bas been borrowed!","Warning", RMATION_MESSAGE);} else {if (op.deleteBook(book) == 1) {JOptionPane.showMessageDialog(null,"Delete the book successfully!", "Information",RMATION_MESSA GE);} else {JOptionPane.showMessageDialog(null,"Delete the book unsuccessfully. The book does not exist!","Warning", RMATION_MESSAGE);}}}}}DeleteReader.javaimport java.awt.BorderLayout;import java.awt.Container;import java.awt.GridLayout;import java.awt.event.*;import javax.swing.*;public class DeleteReader extends JFrame implements ActionListener { SQLOperation op = new SQLOperation();Container c = getContentPane();JPanel p1 = new JPanel();JLabel readerNumber = new JLabel("Reader Number:");JTextField numberField = new JTextField();JButton cancel = new JButton("Cancel");JButton delete = new JButton("Delete!!");public DeleteReader() {c.add(p1, BorderLayout.NORTH);p1.setLayout(new GridLayout(2, 2, 20, 10));p1.add(readerNumber);p1.add(numberField);p1.add(cancel);p1.add(delete);cancel.addActionListener(this);delete.addActionListener(this);}public void actionPerformed(ActionEvent e) {// TODO Auto-generated method stubif (e.getSource() == cancel) {this.dispose();}if (e.getSource() == delete) {ReaderInfo reader = newReaderInfo(numberField.getText());this.dispose();if (op.deleteReaderCheck(numberField.getText()) != 0) {JOptionPane.showMessageDialog(null,"Delete the reader unsuccessfully. Please return books first!","Warning", RMATION_MESSAGE);} else {if (op.deleteReader(reader) == 1) {JOptionPane.showMessageDialog(null,"Delete the reader successfully!", "Information",RMATION_MESSA GE);} else {JOptionPane.showMessageDialog(null,"Delete the reader unsuccessfully. The reader does not exist!","Warning", RMATION_MESSAGE);}}}}}EditBook.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 EditBook extends JFrame implements ActionListener { SQLOperation op = new SQLOperation();Container c = getContentPane();JPanel p1 = new JPanel();JLabel bookNumber = new JLabel("Book Number:");JLabel bookName = new JLabel("Book Name:");JLabel author = new JLabel("Book 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 remain1 = new JLabel("Update with storage");JLabel numberField = new JLabel();JTextField nameField = new JTextField();JTextField authorField = new JTextField();JTextField pressField = new JTextField();JTextField pressTimeField = new JTextField();JTextField abstractField = new JTextField();JTextField storageField = new JTextField();JTextField temp1 = new JTextField();JTextField temp2 = new JTextField();JButton cancel = new JButton("Cancel");JButton save = new JButton("Save!!");public EditBook(String number) {BookInfo book = new BookInfo(number);ArrayList<String> strArray = new ArrayList<String>();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));abstractField.setText(strArray.get(5));storageField.setText(strArray.get(6));temp1.setText(strArray.get(6));temp2.setText(strArray.get(7));c.add(p1, BorderLayout.NORTH);p1.setLayout(new GridLayout(9, 2, 20, 10));p1.add(bookNumber);p1.add(numberField);。
Java图书馆管理系统附全代码课程设计报告完整版
J a v a图书馆管理系统附全代码课程设计报告 HUA system office room 【HUA16H-TTMS2A-HUAS8Q8-《数据库系统概论》课程报告课题名称:小型图书管理系统课题负责人名(学号): best同组成员名单(角色):指导教师:评阅成绩:评阅意见:提交报告时间:2015年12月15日小型图书管理系统计算机科学与技术专业学生指导老师[摘要]随着计算机技术的飞速发展,利用计算机来获得和处理信息是当今信息管理的一大特点。
伴随计算机硬件的快速发展,有关信息管理的软件——数据库系统软件也在迅猛发展着。
图书馆是高等院校的重要组成部门,是教师和学生获取知识的重要场所。
由于图书馆主要从事大量的图书资料的储存和流通。
所以一直以来,计算机在图书馆的图书管理中得到了广泛的应用。
本系统实现图书信息管理的系统化,规范化和自动化,以最大程度提高操作人员的办公效率。
关键词:JAVA、JDBC、SQL Server、数据库、图书馆管理一、实验题目:小型图书管理系统二、实验的目的和要求:完成一个小型图书管理系统,功能要求如下:1)能够通过书籍基本信息(包括:书号、书名、出版社、出版日期、作者、内容摘要)单个或以AND方式组合多个条件查询书籍信息;2)对于每一种书籍,除可查看其基本信息之外还可查看其总数以及目前在馆数量3)可增添新的书籍4)可删除已有书籍(如有读者借了该书籍尚未归还,则不允许删除)5)可修改书籍的基本信息6)能够通过读者基本信息(包括:证号、姓名、性别、系名、年级)单个或以AND方式组合多个条件查询读者信息7)对于每位读者除可查看其基本信息之外,还可查看其已借的书籍列表、数量、借还日期8)可增添新的读者9)可删除已有读者(如该读者有尚未归还的借书,则不允许删除)10)可修改读者的基本信息11)可完成借还书籍的手续12)还书时如超期,应该显示超期天数13)借书时如果有超期的书没有还,则不允许借书14)可查询有哪些读者有超期的书没有还,列出这些读者的基本信息三、实验的环境:1、硬件环境:CPU: Intel(R) Core i5-3230 2.60GHzRAM: 8GB2、软件环境:操作系统:Windows 7 Ultimate SP1编译软件:Eclipse LunaMicrosoft SQL Server 2014四、系统ER 图图书管理员管理读者借阅管理编号性别姓名系名年级编号书名作者出版社出版时间摘要总量现存量用户名密码应还时间拥有权限删除图书修改读者修改图书删除读者添加读者添加图书超期时间借阅时间五、表结构定义(使用表格说明)六、系统功能模块1)能够通过书籍基本信息单个或组合多个条件查询书籍信息;2)对于每一种书籍,除可查看其基本信息之外还可查看其总数以及目前在馆数量3)可增添新的书籍4)可删除已有书籍(如有读者借了该书籍尚未归还,则不允许删除)5)可修改书籍的基本信息6)能够通过读者基本信息单个或组合多个条件查询读者信息7)对于每位读者除可查看其基本信息之外,还可查看其已借的书籍列表、数量、借还日期8)可增添新的读者9)可删除已有读者(如该读者有尚未归还的借书,则不允许删除)10)可修改读者的基本信息11)可完成借还书籍的手续12)还书时如超期,应该显示超期天数13)借书时如果有超期的书没有还,则不允许借书14)可查询有哪些读者有超期的书没有还,列出这些读者的基本信息七、程序框架流程图九、程序运行结果八、核心代码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 = 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:"); 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 authorField = 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, 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(storage);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.getSource() == confirm) {this.dispose();BookInfo book = newBookInfo(numberField.getText(),nameField.getText(), authorField.getText(),pressField.getText(), pressTimeField.getText(),abstractField.getText(), Integer.parseInt(storageField.getText()), Integer.parseInt(storageField.getText()));ArrayList<String> strArray = new ArrayList<String>();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 successfully!","Information", RMATION_MESSAGE);} else {JOptionPane.showMessageDialog(null,"This book(number) has already existed!", "Warning",RMATION_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 = 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 JTextField(); 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.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); }public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stubif (e.getSource() == cancel) {this.dispose();}if (e.getSource() == confirm) {this.dispose();ReaderInfo reader = newReaderInfo(numberField.getText(),nameField.getText(), sexField.getText(),dptField.getText(), Integer.parseInt(gradeField.getText()));ArrayList<String> strArray = new ArrayList<String>();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().equals("girl")) {JOptionPane.showMessageDialog(null,"In the Sex field, you can only input 'boy' or 'girl'!","Warning", RMATION_MESSAGE);} else {op.saveReader(reader);JOptionPane.showMessageDialog(null,"Add a reader successfully!", "Information",RMATION_MESSAGE);}} else {JOptionPane.showMessageDialog(null,"This reader(number) has already existed!", "Warning",RMATION_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.*;import 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 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();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 JLabel("Borrow and reaturn details");Object[] s = { "Reader number", "Borrow time", "Deadline", "Over time" };Object[][] ob1 = new Object[7][4];JTable table = new JTable(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++) {ob1[n][m] = this.ob1[n][m];}table.setModel(books);table.invalidate();}}ArrayList<String> strArray = new ArrayList<String>();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));abstractField.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)); 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(abstractField);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(ActionEvent 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 = number;}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;this.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 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.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 JPanel();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 JButton("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","Abstract", "Storage", "Remain" };Object[][] ob = new Object[40][8];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 = 0; n < 20; n++) {for (int m = 0; m < 8; m++) {ob[n][m] = this.ob[n][m];}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);p4.add(deleteBook);p4.add(borrowBook);p4.add(returnBook);。
原创java图书馆管理系统课程设计总结
原创Java图书馆管理系统课程设计总结一、引言本文档总结了我在课程中设计和开发的Java图书馆管理系统的经验。
该系统旨在提供一个高效、可靠的图书馆管理平台,以帮助图书馆更好地管理其图书、借阅情况和读者信息。
二、需求分析在设计系统之前,我首先进行了需求分析。
通过与图书馆管理员的交流,我确定了以下功能需求: 1. 图书管理:包括图书的添加、删除、更新和查询功能。
2. 读者管理:包括读者的注册、删除、更新和查询功能。
3. 借阅管理:包括借书和还书的操作,以及借阅记录的查询和统计功能。
三、系统设计3.1 系统架构图书馆管理系统采用三层架构,包括表示层、业务逻辑层和数据访问层。
- 表示层:负责与用户交互、展示数据和接收用户输入。
- 业务逻辑层:包含系统的核心业务逻辑,负责处理用户请求,协调表示层和数据访问层。
- 数据访问层:负责与数据库进行交互,提供数据访问接口供业务逻辑层调用。
3.2 类设计我设计了以下几个核心类: 1. Book类:表示图书对象,包含图书的编号、名称、作者等属性。
提供了图书的CRUD操作方法。
2. Reader类:表示读者对象,包含读者的编号、姓名、联系方式等属性。
提供了读者的CRUD操作方法。
3. Borrow类:表示借阅记录对象,包含借阅记录的编号、图书编号、读者编号、借书日期、还书日期等属性。
提供了借阅记录的CRUD操作方法。
4. LibraryManager类:表示图书馆管理员对象,负责处理用户请求,包括图书和读者的管理、借阅功能等。
四、开发和测试4.1 开发环境和工具本系统使用Java语言进行开发,使用Eclipse作为开发工具,MySQL作为数据库。
4.2 开发过程在开发过程中,我按照需求分析阶段的设计思路,依据类设计,逐步实现了系统的各个功能模块。
在每个阶段,我进行了单元测试和集成测试,以确保系统的功能正确性和稳定性。
4.3 测试结果经过多轮测试,系统在不同场景下表现良好。
Java 图书馆管理系统(附全代码)_课程设计报告材料
实用文档《数据库系统概论》课程报告课题名称:小型图书管理系统课题负责人名(学号): best同组成员名单(角色):指导教师:评阅成绩:评阅意见:提交报告时间:2015年12月15日小型图书管理系统计算机科学与技术专业学生指导老师[摘要]随着计算机技术的飞速发展,利用计算机来获得和处理信息是当今信息管理的一大特点。
伴随计算机硬件的快速发展,有关信息管理的软件——数据库系统软件也在迅猛发展着。
图书馆是高等院校的重要组成部门,是教师和学生获取知识的重要场所。
由于图书馆主要从事大量的图书资料的储存和流通。
所以一直以来,计算机在图书馆的图书管理中得到了广泛的应用。
本系统实现图书信息管理的系统化,规范化和自动化,以最大程度提高操作人员的办公效率。
关键词:JAVA、JDBC、SQL Server、数据库、图书馆管理一、实验题目:小型图书管理系统二、实验的目的和要求:完成一个小型图书管理系统,功能要求如下:1)能够通过书籍基本信息(包括:书号、书名、出版社、出版日期、作者、内容摘要)单个或以AND方式组合多个条件查询书籍信息;2)对于每一种书籍,除可查看其基本信息之外还可查看其总数以及目前在馆数量3)可增添新的书籍4)可删除已有书籍(如有读者借了该书籍尚未归还,则不允许删除)5)可修改书籍的基本信息6)能够通过读者基本信息(包括:证号、姓名、性别、系名、年级)单个或以AND方式组合多个条件查询读者信息7)对于每位读者除可查看其基本信息之外,还可查看其已借的书籍列表、数量、借还日期8)可增添新的读者9)可删除已有读者(如该读者有尚未归还的借书,则不允许删除)10)可修改读者的基本信息11)可完成借还书籍的手续12)还书时如超期,应该显示超期天数13)借书时如果有超期的书没有还,则不允许借书14)可查询有哪些读者有超期的书没有还,列出这些读者的基本信息三、实验的环境:1、硬件环境:CPU: Intel(R) Core i5-3230 2.60GHzRAM: 8GB2、软件环境:操作系统:Windows 7 Ultimate SP1编译软件:Eclipse LunaMicrosoft SQL Server 2014四、系统ER图图书管理员管理读者借阅管理编号性别姓名系名年级编号书名作者出版社出版时间摘要总量现存量用户名密码应还时间拥有权限删除图书修改读者修改图书删除读者添加读者添加图书超期时间借阅时间五、表结构定义(使用表格说明)六、系统功能模块1)能够通过书籍基本信息单个或组合多个条件查询书籍信息;2)对于每一种书籍,除可查看其基本信息之外还可查看其总数以及目前在馆数量3)可增添新的书籍4)可删除已有书籍(如有读者借了该书籍尚未归还,则不允许删除)5)可修改书籍的基本信息6)能够通过读者基本信息单个或组合多个条件查询读者信息7)对于每位读者除可查看其基本信息之外,还可查看其已借的书籍列表、数量、借还日期8)可增添新的读者9)可删除已有读者(如该读者有尚未归还的借书,则不允许删除)10)可修改读者的基本信息11)可完成借还书籍的手续12)还书时如超期,应该显示超期天数13)借书时如果有超期的书没有还,则不允许借书14)可查询有哪些读者有超期的书没有还,列出这些读者的基本信息七、程序框架流程图九、程序运行结果八、核心代码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 = 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:");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 authorField = 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, 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(storage);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.getSource() == 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<String> strArray = newArrayList<String>();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 booksuccessfully!","Information",RMATION_MESSAGE);} else {JOptionPane.showMessageDialog(null,"This book(number) has already existed!", "Warning",RMATION_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 = 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 JTextField(); 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.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);}public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stubif (e.getSource() == cancel) {this.dispose();}if (e.getSource() == confirm) {this.dispose();ReaderInfo reader = newReaderInfo(numberField.getText(),nameField.getText(), sexField.getText(),dptField.getText(),Integer.parseInt(gradeField.getText()));ArrayList<String> strArray = newArrayList<String>();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().equals("girl")) {JOptionPane.showMessageDialog(null,"In the Sex field, you can only input 'boy' or 'girl'!","Warning",RMATION_MESSAGE);} else {op.saveReader(reader);JOptionPane.showMessageDialog(null,"Add a reader successfully!", "Information",RMATION_MESSAGE);}} else {JOptionPane.showMessageDialog(null,"This reader(number) has alreadyexisted!", "Warning",RMATION_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.*;import 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 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();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 JLabel("Borrow and reaturn details");Object[] s = { "Reader number", "Borrow time", "Deadline", "Over time" };Object[][] ob1 = new Object[7][4];JTable table = new JTable(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++) {ob1[n][m] = this.ob1[n][m];}table.setModel(books);table.invalidate();}}ArrayList<String> strArray = new ArrayList<String>();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));abstractField.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));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(abstractField);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(ActionEvent 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 = number;}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;this.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 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.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 JPanel();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 JButton("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","Abstract", "Storage", "Remain" };Object[][] ob = new Object[40][8];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 = 0; n < 20; n++) {for (int m = 0; m < 8; m++) {ob[n][m] = this.ob[n][m];}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);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 Dimension(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.getSource() == search) {ArrayList<String> strArray = newArrayList<String>();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<String> strArray1 = newArrayList<String>();strArray1 = 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",RMATION_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.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 MyFrame();//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(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 = 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.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.BorderLayout;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 bookNumber = 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.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.getSource() == cancel) {this.dispose();}if (e.getSource() == borrow) {String bookNumber = numberField.getText();ArrayList<String> strArray = newArrayList<String>();strArray = op.addBookJudgement();int n = 0;int replicate = 0;while (n < Integer.parseInt(strArray.get(0))) {n++;if (bookNumber.equals(strArray.get(n))) {replicate++;}}String readerNumber = readerNumberField.getText();ArrayList<String> strArray1 = newArrayList<String>();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) {JOptionPane.showMessageDialog(null,"Please input a correct book number and a reader number!","Warning",RMATION_MESSAGE);} else {BookInfo book = new BookInfo(bookNumber);ArrayList<String> s = new ArrayList<String>();s = op.outputBook(book);if (Integer.parseInt(s.get(7)) > 0) {int s1 =op.reBorrowCheck(numberField.getText(),readerNumberField.getText());if (s1 == 1) {JOptionPane.showMessageDialog(null,"You have borrowed this book, can not reborrow it!","Unsuccessful", RMATION_MESSAGE);} else {long currentTime =System.currentTimeMillis();if(op.deadLineCheck(readerNumberField.getText(),currentTime) != 0) {JOptionPane.showMessageDialog(null,"You have exceeded the deadline, please return these books first!","Unsuccessful", RMATION_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.inputBook(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);JOptionPane.showMessageDialog(null,"Borrowed this book successfully, you have 30 days to enjoy this book!","Successful", RMATION_MESSAGE);}}} else {JOptionPane.showMessageDialog(null,"This book has been borrowed!", "Unsuccessful",RMATION_MESSAGE);}}this.dispose();}}}BorrowList.Javaimport 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 ActionListener {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 Object[100][5];JTable table = new JTable(ob, s);JScrollPane scrollPane = 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++) {ob[n][m] = ob1[n][m];}table.setModel(list);table.invalidate();}}c.add(p1, BorderLayout.CENTER);c.add(p2,BorderLayout.SOUTH);scrollPane.setBounds(0, 0, 800, 300);p1.add(scrollPane);p2.add(back);table.setPreferredScrollableViewportSize(new Dimension(400, 400));back.addActionListener(this);}public void actionPerformed(ActionEvent e) {if (e.getSource() == back) {this.dispose();MyFrame f = new MyFrame();f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);f.setTitle("Library Management System");f.setLocation(300, 200);f.setSize(580, 300);f.setVisible(true);}// TODO Auto-generated method stub}}Date.javaimport java.text.DateFormat;import java.text.SimpleDateFormat;public class Date {public Date(){}static String borrowTimeInterface(long time) {SimpleDateFormat df = (SimpleDateFormat) DateFormat.getInstance();df.applyPattern("yyyy-MM-dd");String s = df.format(time);return s;}}DeleteBook.javaimport java.awt.BorderLayout;import java.awt.Container;import java.awt.GridLayout;import java.awt.event.*;import javax.swing.*;public class DeleteBook extends JFrame implements ActionListener {SQLOperation op = new SQLOperation();Container c = getContentPane();JPanel p1 = new JPanel();JLabel bookNumber = new JLabel("Book Number:");JTextField numberField = new JTextField();JButton cancel = new JButton("Cancel");JButton delete = new JButton("Delete!!");public DeleteBook() {c.add(p1, BorderLayout.NORTH);p1.setLayout(new GridLayout(2, 2, 20, 10));p1.add(bookNumber);p1.add(numberField);p1.add(cancel);p1.add(delete);cancel.addActionListener(this);delete.addActionListener(this);}public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stubif (e.getSource() == cancel) {this.dispose();}if (e.getSource() == delete) {BookInfo book = newBookInfo(numberField.getText());this.dispose();if(op.deleteBookCheck(numberField.getText()) != 0) {JOptionPane.showMessageDialog(null,"Delete the book unsuccessfully. The book bas been borrowed!","Warning",RMATION_MESSAGE);} else {if (op.deleteBook(book) == 1) {JOptionPane.showMessageDialog(null,"Delete the book successfully!", "Information",RMATION_MESSAGE);} else {JOptionPane.showMessageDialog(null,"Delete the book unsuccessfully. The book does not exist!","Warning",RMATION_MESSAGE);}}}}}DeleteReader.javaimport java.awt.BorderLayout;import java.awt.Container;import java.awt.GridLayout;import java.awt.event.*;import javax.swing.*;public class DeleteReader extends JFrame implements ActionListener {SQLOperation op = new SQLOperation();Container c = getContentPane();JPanel p1 = new JPanel();JLabel readerNumber = new JLabel("Reader Number:");JTextField numberField = new JTextField();JButton cancel = new JButton("Cancel");JButton delete = new JButton("Delete!!");public DeleteReader() {c.add(p1, BorderLayout.NORTH);p1.setLayout(new GridLayout(2, 2, 20, 10));p1.add(readerNumber);p1.add(numberField);p1.add(cancel);p1.add(delete);cancel.addActionListener(this);delete.addActionListener(this);}public void actionPerformed(ActionEvent e) {// TODO Auto-generated method stubif (e.getSource() == cancel) {this.dispose();}if (e.getSource() == delete) {ReaderInfo reader = newReaderInfo(numberField.getText());this.dispose();if (op.deleteReaderCheck(numberField.getText()) != 0) {JOptionPane.showMessageDialog(null,"Delete the reader unsuccessfully.Please return books first!","Warning",RMATION_MESSAGE);} else {if (op.deleteReader(reader) == 1) {JOptionPane.showMessageDialog(null,"Delete the reader successfully!", "Information",RMATION_MESSAGE);} else {JOptionPane.showMessageDialog(null,"Delete the reader unsuccessfully. The reader does not exist!","Warning",RMATION_MESSAGE);}}}}}EditBook.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 EditBook extends JFrame implements ActionListener {SQLOperation op = new SQLOperation();Container c = getContentPane();JPanel p1 = new JPanel();JLabel bookNumber = new JLabel("Book Number:");JLabel bookName = new JLabel("Book Name:");JLabel author = new JLabel("Book 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 remain1 = new JLabel("Update with storage"); JLabel numberField = new JLabel();JTextField nameField = new JTextField();JTextField authorField = new JTextField();JTextField pressField = new JTextField();JTextField pressTimeField = new JTextField();JTextField abstractField = new JTextField();JTextField storageField = new JTextField();JTextField temp1 = new JTextField();JTextField temp2 = new JTextField();JButton cancel = new JButton("Cancel");JButton save = new JButton("Save!!");public EditBook(String number) {BookInfo book = new BookInfo(number);ArrayList<String> strArray = new ArrayList<String>();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));abstractField.setText(strArray.get(5));storageField.setText(strArray.get(6));temp1.setText(strArray.get(6));temp2.setText(strArray.get(7));c.add(p1, BorderLayout.NORTH);。
原创Java图书管理系统设计报告
原创Java图书管理系统设计报告1. 引言本文档详细介绍了一个原创的Java图书管理系统的设计和实现。
该系统旨在帮助图书馆管理人员更加高效地管理图书馆的图书信息、借阅记录以及读者信息。
通过使用该系统,图书馆管理人员可以简化图书管理过程并提高工作效率。
2. 系统概述2.1 功能介绍本图书管理系统主要包含以下功能:•图书管理:包括图书信息的录入、修改、删除以及查询功能。
•借阅管理:支持读者借阅图书和还书的操作,可以查询读者的借阅记录。
•读者管理:包括读者信息的录入、修改、删除以及查询功能。
2.2 开发环境该图书管理系统使用Java编程语言开发,并使用MySQL作为数据库存储数据。
开发所用的集成开发环境为Eclipse。
2.3 系统架构本系统采用三层架构,包括表示层、业务逻辑层和数据访问层。
•表示层:负责与用户界面进行交互,接收用户输入并将结果展示给用户。
•业务逻辑层:处理来自表示层的请求,调用数据访问层进行数据操作,并将结果返回给表示层。
•数据访问层:负责与数据库进行交互,执行数据库操作。
3. 系统设计3.1 数据库设计本系统使用MySQL作为数据库,设计了以下数据库表:•书目表(Book):包含图书的基本信息,如书名、作者、出版社等。
•借阅记录表(BorrowRecord):记录了读者借阅图书的历史记录。
•读者表(Reader):记录了读者的基本信息,如姓名、性别、年龄等。
3.2 类设计本系统包含以下主要类:•Book类:表示图书的实体类,包含了图书的各种属性和相关操作方法。
•BorrowRecord类:表示借阅记录的实体类,包含了借阅记录的各种属性和相关操作方法。
•Reader类:表示读者的实体类,包含了读者的各种属性和相关操作方法。
3.3 用户界面设计本系统的用户界面设计简洁明了,包括以下几个界面:•主界面:显示系统的各项功能操作入口。
•图书管理界面:显示图书的录入、修改、删除和查询功能。
•借阅管理界面:显示借阅图书和还书的操作,并可以查询读者的借阅记录。
图书管理系统java课程设计报告
图书管理系统java课程设计报告一、课程目标知识目标:1. 掌握Java语言面向对象编程的基本原理,包括类的定义、对象的创建、继承和多态;2. 学会使用Java集合框架,如List、Set等,进行数据存储和管理;3. 理解数据库连接和SQL语句执行过程,掌握JDBC操作数据库的基本方法;4. 了解图书管理系统的业务需求,能运用所学知识分析并实现系统功能。
技能目标:1. 培养学生运用面向对象思想进行问题分析和解决的能力;2. 提高学生使用Java语言编写程序、调试代码和解决问题的实践能力;3. 培养学生运用JDBC技术操作数据库,实现数据增删改查等基本功能;4. 培养学生团队协作、沟通表达和项目组织管理的能力。
情感态度价值观目标:1. 激发学生对计算机编程的兴趣,培养其主动学习和探究的精神;2. 培养学生严谨、踏实的学术态度,注重代码规范和编程习惯;3. 引导学生关注实际应用,体会所学知识在解决实际问题中的价值;4. 培养学生的团队协作意识,使其认识到团队合作的重要性。
本课程针对高年级学生,结合学科特点和教学要求,旨在通过图书管理系统Java课程设计,使学生在掌握Java编程基础和数据库操作技能的同时,培养其实际项目开发和团队协作能力。
课程目标具体、可衡量,为后续教学设计和评估提供明确依据。
二、教学内容1. Java面向对象编程基础:- 类的定义、属性、方法- 对象的创建、使用- 继承、多态、封装- 抽象类、接口2. Java集合框架:- List、Set、Map接口及其实现类- 集合的增删改查操作- 集合的迭代器、增强型for循环遍历3. 数据库基础与JDBC操作:- 数据库概念、SQL语言基础- JDBC驱动加载、数据库连接- PreparedStatement对象执行SQL语句- 结果集处理、事务管理4. 图书管理系统功能实现:- 系统需求分析- 类的设计与实现- 数据库表结构设计- 系统功能模块划分及实现教学内容按照课程目标进行选择和组织,确保科学性和系统性。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
《数据库系统概论》课程报告课题名称:小型图书管理系统课题负责人名(学号):best同组成员名单(角色):指导教师:评阅成绩:评阅意见:提交报告时间:2015年12月15日小型图书管理系统计算机科学与技术专业学生指导老师[摘要]随着计算机技术的飞速发展,利用计算机来获得和处理信息是当今信息管理的一大特点。
伴随计算机硬件的快速发展,有关信息管理的软件——数据库系统软件也在迅猛发展着。
图书馆是高等院校的重要组成部门,是教师和学生获取知识的重要场所。
由于图书馆主要从事大量的图书资料的储存和流通。
所以一直以来,计算机在图书馆的图书管理中得到了广泛的应用。
本系统实现图书信息管理的系统化,规范化和自动化,以最大程度提高操作人员的办公效率。
关键词:JAVA、JDBC、SQL Server、数据库、图书馆管理一、实验题目:小型图书管理系统二、实验的目的和要求:完成一个小型图书管理系统,功能要求如下:1)能够通过书籍基本信息(包括:书号、书名、出版社、出版日期、作者、内容摘要)单个或以AND方式组合多个条件查询书籍信息;2)对于每一种书籍,除可查看其基本信息之外还可查看其总数以及目前在馆数量3)可增添新的书籍4)可删除已有书籍(如有读者借了该书籍尚未归还,则不允许删除)5)可修改书籍的基本信息6)能够通过读者基本信息(包括:证号、姓名、性别、系名、年级)单个或以AND方式组合多个条件查询读者信息7)对于每位读者除可查看其基本信息之外,还可查看其已借的书籍列表、数量、借还日期8)可增添新的读者9)可删除已有读者(如该读者有尚未归还的借书,则不允许删除)10)可修改读者的基本信息11)可完成借还书籍的手续12)还书时如超期,应该显示超期天数13)借书时如果有超期的书没有还,则不允许借书14)可查询有哪些读者有超期的书没有还,列出这些读者的基本信息三、实验的环境:1、硬件环境:CPU: Intel(R) Core i5-3230 2.60GHzRAM: 8GB2、软件环境:操作系统:Windows 7 Ultimate SP1编译软件:Eclipse LunaMicrosoft SQL Server 2014四、系统ER图五、表结构定义(使用表格说明)六、系统功能模块1)能够通过书籍基本信息单个或组合多个条件查询书籍信息;2)对于每一种书籍,除可查看其基本信息之外还可查看其总数以及目前在馆数量3)可增添新的书籍4)可删除已有书籍(如有读者借了该书籍尚未归还,则不允许删除)5)可修改书籍的基本信息6)能够通过读者基本信息单个或组合多个条件查询读者信息7)对于每位读者除可查看其基本信息之外,还可查看其已借的书籍列表、数量、借还日期8)可增添新的读者9)可删除已有读者(如该读者有尚未归还的借书,则不允许删除)10)可修改读者的基本信息11)可完成借还书籍的手续12)还书时如超期,应该显示超期天数13)借书时如果有超期的书没有还,则不允许借书14)可查询有哪些读者有超期的书没有还,列出这些读者的基本信息七、程序框架流程图九、程序运行结果八、核心代码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 = 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:"); 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 authorField = 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, 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(storage);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.getSource() == 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<String> strArray = new ArrayList<String>();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 successfully!","Information",RMATION_MESSAGE);} else {JOptionPane.showMessageDialog(null,"This book(number) has already existed!", "Warning",RMATION_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 = 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 JTextField();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.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);}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(gradeField.getText())); ArrayList<String> strArray = new ArrayList<String>(); 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().equals("girl")) {JOptionPane.showMessageDialog(null,"In the Sex field, you can only input 'boy' or 'girl'!","Warning",RMATION_MESSAGE);} else {op.saveReader(reader);JOptionPane.showMessageDialog(null,"Add a reader successfully!", "Information",RMATION_MESSAGE);}} else {JOptionPane.showMessageDialog(null,"This reader(number) has already existed!", "Warning",RMATION_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.*;import 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 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();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 JLabel("Borrow and reaturn details");Object[] s = { "Reader number", "Borrow time", "Deadline", "Over time" };Object[][] ob1 = new Object[7][4];JTable table = new JTable(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++) {ob1[n][m] = this.ob1[n][m];}table.setModel(books);table.invalidate();}}ArrayList<String> strArray = new ArrayList<String>(); 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)); abstractField.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)); 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(abstractField);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(ActionEvent 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 = number;}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;this.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 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.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 JPanel();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 JButton("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", "Abstract", "Storage", "Remain" };Object[][] ob = new Object[40][8];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 = 0; n < 20; n++) {for (int m = 0; m < 8; m++) {ob[n][m] = this.ob[n][m];}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);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 Dimension(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.getSource() == search) {ArrayList<String> strArray = new ArrayList<String>();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<String> strArray1 = new ArrayList<String>(); strArray1 = 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",RMATION_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.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 MyFrame();// 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(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 = 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.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.BorderLayout;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 bookNumber = 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.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.getSource() == cancel) {this.dispose();}if (e.getSource() == borrow) {String bookNumber = numberField.getText();ArrayList<String> strArray = new ArrayList<String>();strArray = op.addBookJudgement();int n = 0;int replicate = 0;while (n < Integer.parseInt(strArray.get(0))) {n++;if (bookNumber.equals(strArray.get(n))) {replicate++;}}String readerNumber = readerNumberField.getText(); ArrayList<String> strArray1 = new ArrayList<String>(); 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) {JOptionPane.showMessageDialog(null,"Please input a correct book number and a reader number!","Warning",RMATION_MESSAGE);} else {BookInfo book = new BookInfo(bookNumber);ArrayList<String> s = new ArrayList<String>();s = op.outputBook(book);if (Integer.parseInt(s.get(7)) > 0) {int s1 = op.reBorrowCheck(numberField.getText(),readerNumberField.getText());if (s1 == 1) {JOptionPane.showMessageDialog(null,"You have borrowed this book, can not reborrow it!","Unsuccessful",RMATION_MESSAGE);} else {long currentTime = System.currentTimeMillis();if (op.deadLineCheck(readerNumberField.getText(),currentTime) != 0) {JOptionPane.showMessageDialog(null,"You have exceeded the deadline, please return these books first!","Unsuccessful",RMATION_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.inputBook(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);JOptionPane.showMessageDialog(null,"Borrowed this book successfully, you have 30 days to enjoy this book!","Successful",RMATION_MESSAGE);}}} else {JOptionPane.showMessageDialog(null,"This book has been borrowed!", "Unsuccessful",RMATION_MESSAGE);}}this.dispose();}}。