Java图书馆管理系统附全代码课程设计报告
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 = 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();}}。
java图书管理系统课程设计
java图书管理系统课程设计一、教学目标本课程旨在通过学习Java图书管理系统,让学生掌握Java编程的基本语法和面向对象编程思想,学会使用Java开发一个简单的图书管理系统。
通过本课程的学习,学生将能够:1.掌握Java基本语法、数据类型、运算符、控制结构等基础知识。
2.理解面向对象编程的基本概念,如类、对象、封装、继承、多态等。
3.学会使用Java开发工具,如Eclipse、IntelliJ IDEA等。
4.熟练使用Java编写图书管理系统的各个模块,如图书添加、删除、查询、借还书等功能。
5.培养学生的编程思维和解决问题的能力。
二、教学内容本课程的教学内容主要包括Java基础知识、面向对象编程、Java开发工具的使用以及图书管理系统的开发。
具体安排如下:1.Java基础知识:第1-4周,学习Java基本语法、数据类型、运算符、控制结构等。
2.面向对象编程:第5-8周,学习类与对象、封装、继承、多态等概念及应用。
3.Java开发工具:第9-10周,学习Eclipse、IntelliJ IDEA等开发工具的使用。
4.图书管理系统开发:第11-16周,通过项目驱动的方式,分模块开发图书管理系统,包括图书添加、删除、查询、借还书等功能。
三、教学方法为了激发学生的学习兴趣和主动性,本课程将采用多种教学方法相结合的方式,如讲授法、讨论法、案例分析法、实验法等。
具体如下:1.讲授法:用于讲解Java基本语法、数据类型、运算符、控制结构等基础知识。
2.讨论法:用于探讨面向对象编程的概念及应用,鼓励学生发表自己的见解。
3.案例分析法:通过分析实际案例,让学生学会使用Java开发图书管理系统。
4.实验法:让学生动手实践,实际编写代码,培养学生的编程能力。
四、教学资源为了支持本课程的教学内容和教学方法的实施,我们将准备以下教学资源:1.教材:《Java核心技术卷I 基础知识》2.参考书:《Java编程思想》3.多媒体资料:教学PPT、视频教程4.实验设备:计算机、网络环境5.在线编程平台:LeetCode、牛客网等,用于学生练习和测试编程能力。
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课程设计
图书信息管理系统java课程设计一、课程目标知识目标:1. 学生能理解图书信息管理系统的基本原理,掌握Java语言在系统开发中的应用。
2. 学生能掌握面向对象编程思想,运用类与对象的概念实现系统功能。
3. 学生能了解数据库的基本操作,通过Java实现对图书信息的管理。
技能目标:1. 学生能运用Java语言编写简单的图书信息管理系统,具备基本的编程能力。
2. 学生能通过本课程的学习,掌握分析问题、设计解决方案、编写代码和调试程序的能力。
3. 学生能通过小组合作,提高团队协作和沟通能力。
情感态度价值观目标:1. 学生对Java编程产生兴趣,培养主动学习和解决问题的积极性。
2. 学生在课程学习中,养成认真负责、严谨细致的学习态度。
3. 学生通过本课程的学习,认识到编程在现实生活中的应用价值,激发创新意识。
课程性质:本课程为实践性较强的课程,结合理论教学和实际操作,培养学生的编程能力和实际应用能力。
学生特点:学生处于高年级阶段,已具备一定的Java编程基础,对面向对象编程有一定了解,但实际操作能力有待提高。
教学要求:结合学生特点,注重理论与实践相结合,提高学生的实际操作能力。
将课程目标分解为具体的学习成果,以便在教学过程中进行有效评估。
二、教学内容1. 理论部分:- 图书信息管理系统概述:介绍系统基本功能、模块划分及Java语言在系统开发中的应用。
- 面向对象编程基础:回顾类、对象、继承、封装、多态等概念。
- 数据库基础知识:讲解数据库的基本操作,如创建表、插入数据、查询数据等。
2. 实践部分:- 系统需求分析:指导学生分析图书信息管理系统的功能需求,明确系统目标。
- 系统设计:教授学生如何设计系统架构,划分模块,编写类和接口。
- 编码实现:指导学生运用Java语言编写图书信息管理系统的各个功能模块。
- 系统测试与调试:教授学生如何进行单元测试、集成测试,查找并修复程序错误。
教材章节关联:1. 理论部分:参照教材第3章“Java面向对象编程”和第6章“数据库编程”。
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图书馆管理系统附全代码课程设计报告
《数据库系统概论》课程报告课题名称:小型图书管理系统课题负责人名(学号): 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_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();}}}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_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));。
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图书馆管理系统附全代码课程设计报告精编WORD版
J a v a图书馆管理系统附全代码课程设计报告精编W O R D版IBM system office room 【A0816H-A0912AAAHH-GX8Q8-《数据库系统概论》课程报告课题名称:小型图书管理系统课题负责人名(学号):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 = 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 = 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 = 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 = 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 = 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",。
原创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. 图书管理系统功能实现:- 系统需求分析- 类的设计与实现- 数据库表结构设计- 系统功能模块划分及实现教学内容按照课程目标进行选择和组织,确保科学性和系统性。
2021年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 i53230 2.60GHz RAM: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 = 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");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 = 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();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 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 (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_CLOS E);f.setTitle("Book Details");f.setLocation(300, 200);f.setSize(480, 470);f.setVisible(true);} elseif (replicate != 0) {BookDetails f = newBookDetails(s1);//f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS E);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_CLOS E);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_CLOS E);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_CLOS E);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_CLOS E);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_CLOS E);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_CLOS E);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 reborrow it!", "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);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, 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 = 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_CLOS E);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 {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();。
java版图书管理系统课程设计报告
java版图书管理系统课程设计报告第一章系统概述当今时代是飞速发展的信息时代。
在各行各业中离不开信息处理,这正是计算机网被广泛应用于管理信息系统的外部环境。
计算机的最大好处在于利用它能够进行信息管理。
使用计算机进行信息处理,不仅提高了工作效率,而且大大的提高了其安全性。
尤其对于复杂的信息管理,计算机能够充分发挥它的优越性。
计算机进行信息管理与管理信息系统的开发密切相关,系统的开发是系统管理的前提。
本系统就是为了管理好图书馆信息而设计的。
图书馆作为一种信息资源的集聚地,图书和用户借阅资料繁多,包含很多的信息数据的管理。
该软件最终的使用者是学校,公司,图书馆管理者,并提供以下的功能:1.默认页提供关于图书馆管理系统的基本信息;2.图书馆管理者可以根据读者信息创建读者的帐户;3.如果读者输入的 ID 在数据库不存在,系统将显示错误页;4.图书馆管理者必须先登录才能在了解图书馆的详细信息和自己的基本信息,并可以对图书进行添加、查找、修改、注销等的操作,还可对读者进行管理与归类;5.读者必须先登录才能对图书进行借阅、归还、续借等操作。
第二章需求分析2.1 需求2.1.1功能需求2.1.1.1登录界面为了方便进行管理,我们设置了一个统一的登陆界面。
对于不同身份的人由系统自动判断。
2.1.1.1.1 用户登录(1) 用户信息此模块包括用户的姓名、密码、年龄和性别。
(2) 图书信息此模块包括图书的类别、名称、作者、出版社、以及图书馆里的现有数量。
(3) 借阅图书此模块包括借阅图书的用户、借阅的时间。
(4) 密码的更改管理员可根据自己的喜好更改自己的登录密码。
登录界面流程图2.1.1.2 图书信息管理2.1.1.2.1图书清单1.图书名2.图书编号3.类型4.作者5.已借出的本数6.所剩本数2.1.1.2.2新进图书信息2.1.1.2.3图书查询(1)按作者(2)按图书名2.1.1.2.4图书信息的更新及删除对图书信息进行修改,添加或删除。
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-3230RAM: 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)可查询有哪些读者有超期的书没有还,列出这些读者的基本信息七、程序框架流程图九、程序运行结果八、核心代码import.*;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() {(p1, ;(new GridLayout(9, 2, 20, 10)); (bookNumber); (numberField); (bookName); (nameField); (bookAuthor); (authorField);(press);(pressField); (pressTime); (pressTimeField); (bookAbstract); (abstractField); (storage);(storageField);(remain);(remain1);(cancel);(confirm);(this);(this);}public void actionPerformed(ActionEvent e) {etText()),()));ArrayList<String> strArray = new ArrayList<String>();strArray = ();int n = 0;int replicate = 0;while (n < (0))) {n++;if ().equals(n))) {replicate++;}}if (replicate == 0) {(book);(null, "Add a book successfully!","Information", ;} else {(null,"This book(number) has already existed!", "Warning",;}}}}import.*;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() {(p1, ;(new GridLayout(6, 2, 20, 10));(readerNumber);(numberField);(readerName);(nameField);(sex);(sexField);(dpt);(dptField);(grade);(gradeField);(cancel);(confirm);(this);(this);}public void actionPerformed(ActionEvent e) {quals(n))) {replicate++;}}if (replicate == 0) {if (!().equals("boy")&& !().equals("girl")) {JOptionPane.showMessageDialog(null,"In the Sex field, you can only input 'boy' or 'girl'!","Warning", ;} else {(reader);(null,"Add a reader successfully!", "Information",;}} else {(null,"This reader(number) has already existed!", "Warning",;}}}}import.*;import 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 = (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] = [n][m];}(books);();}}ArrayList<String> strArray = new ArrayList<String>(); strArray = (book);(number);(1));(2));(3));(4));(5));(6));(7));(p1, ;(p2, ;(p3, ;(new GridLayout(9, 2, 20, 10)); (bookNumber); (numberField); (bookName); (nameField);(author); (authorField);(press);(pressField); (pressTime); (pressTimeField); (bookAbstract); (abstractField); (storage);(storageField);(remain);(remainField);(details);(0, 0, 800, 300);(scrollPane);(cancel);(new Dimension(400, 100));(this);}public void actionPerformed(ActionEvent e) {;import 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", , 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 = (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] = [n][m];}(books);();}}(p4, ;(p1, ;(p5, ;(font1);(new GridLayout(2, 4, 20, 10)); (back);(addBook); (editBook);(deleteBook); (borrowBook); (returnBook);(null);(0, 0, 800, 300); (scrollPane);(new GridLayout(5, 1, 0, 0)); (bookNumber); (number); (bookName); (name);(search);(new Dimension(400, 300)); (this);(this);(this);(this);(this);(this);(this);}public void actionPerformed(ActionEvent e) {if () == search) {ArrayList<String> strArray = new ArrayList<String>();strArray = ();String s1 = ();String s2 = ();int n = 0;int replicate = 0;while (n < (0))) {n++;if (n))) {replicate++;}}ArrayList<String> strArray1 = new ArrayList<String>(); strArray1 = ();int n1 = 0;int replicate1 = 0;while (n1 < (0))) {n1++;if (n1))) {replicate1++;}}if (replicate == 0 && replicate1 == 0) {(null,"Please input a correct book number or name!","Warning", ;} else if (replicate != 0 || replicate1 != 0) {if (replicate == 0 && replicate1 != 0) {BookInfo book = new BookInfo(s1, s2);String s = (book);BookDetails f = new BookDetails(s);;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() {(p1, ;(new GridLayout(3, 2, 20, 10));(bookNumber);(numberField);(readerNumber);(readerNumberField);(cancel);(borrow);(this);(this);}public void actionPerformed(ActionEvent e) {howMessageDialog(null,"Please input a correct book number and a reader number!","Warning", ;} else {BookInfo book = new BookInfo(bookNumber);ArrayList<String> s = new ArrayList<String>();s = (book);if (7)) > 0) {int s1 = (),());if (s1 == 1) {JOptionPane.showMessageDialog(null,"You have borrowed this book, can not reborrow it!","Unsuccessful",;} else {long currentTime = ();if (),currentTime) != 0) {JOptionPane.showMessageDialog(null,"You have exceeded the deadline, please return these books first!","Unsuccessful",;} else {BookInfo book1 = new BookInfo(0), (1),(2), (3), (4), (5),(6)),(7)) - 1);(book1);String borrowTime = (System.currentTimeMillis());String deadline = (System.currentTimeMillis() + 00l); (),(), borrowTime,deadline);JOptionPane.showMessageDialog(null,"Borrowed this book successfully, you have 30 days to enjoy this book!","Successful",;}}} else {(null,"This book has been borrowed!", "Unsuccessful",;}}();}}}import.*;import 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() {;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() {(p1, ;(new GridLayout(2, 2, 20, 10));(bookNumber);(numberField);(cancel);(delete);(this);(this);}public void actionPerformed(ActionEvent e) {howMessageDialog(null,"Delete the book unsuccessfully. The book bas been borrowed!","Warning", ;} else {if (book) == 1) {(null,"Delete the book successfully!", "Information",;} else {JOptionPane.showMessageDialog(null,"Delete the book unsuccessfully. The book does not exist!","Warning", ;}}}}}import.*;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() {(p1, ;(new GridLayout(2, 2, 20, 10));(readerNumber);(numberField);(cancel);(delete);(this);(this);}public void actionPerformed(ActionEvent e) {howMessageDialog(null,"Delete the reader unsuccessfully. Please return books first!","Warning", ;} else {if (reader) == 1) {(null,"Delete the reader successfully!", "Information",;} else {JOptionPane.showMessageDialog(null,"Delete the reader unsuccessfully. The reader does not exist!","Warning", ;}}}}}import.*;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 = (book);(number);(1));(2));(3));(4));(5));(6));(6));(7));(p1, ;(new GridLayout(9, 2, 20, 10)); (bookNumber); (numberField); (bookName); (nameField);(author); (authorField);(press);(pressField); (pressTime); (pressTimeField); (bookAbstract); (abstractField);(storage);(storageField);(remain);(remain1);(cancel);(save);(this);(this);}public void actionPerformed(ActionEvent e) { etText()), i);(book);(null, "Edit the book successfully!","Information", ;();}}}import.*;public class EditReader 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:");JLabel numberField = new JLabel();JTextField nameField = new JTextField();JTextField sexField = new JTextField();JTextField dptField = new JTextField();JTextField gradeField = new JTextField();JButton cancel = new JButton("Cancel");JButton save = new JButton("Save!!");public EditReader(String number) {(number);ReaderInfo reader = new ReaderInfo(number);ArrayList<String> strArray = new ArrayList<String>();strArray = (reader);(number);(1));(2));(3));(4));(p1, ;(new GridLayout(6, 2, 20, 10)); (readerNumber); (numberField); (readerName); (nameField);(sex);(sexField);(dpt);(dptField);(grade);(gradeField);(cancel);(save);(this);(this);}public void actionPerformed(ActionEvent e) {quals("boy")&& !().equals("girl")) {JOptionPane.showMessageDialog(null,"In the Sex field, you can only input 'boy' or。
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_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);。
- 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.*;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 = new JLabel("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 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();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 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();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 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 (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 Auto-generated 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;}Java图书馆管理系统附全代码课程设计报告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;}}21 / 21。