精华内容
下载资源
问答
  • 这是基于Eclipse平台 图书管理系统,可添加书目读者信息,包含了数据库。
  • 图书管理系统 java

    2020-12-20 15:30:14
    图书管理系统以方便、快捷、费用低的优点正慢慢地进入人们的生活,将传统的图书管理方式彻底地解脱出来,提高效率,减轻工作人员以往繁忙的工作,减小出错的概率,使读者可以花更多的时间在选择书和看书上,从而使...
  • 基于Java和MySQL的图书管理系统

    万次阅读 多人点赞 2018-06-20 21:41:17
    Java图书管理系统 设计人:wangyunpeng_bio ...本次作业利用JAVA开发工具Eclipse和MySQL数据库来开发这个图书管理系统。该系统要解决的图书管理所要解决的问题,可以满足图书管理基本要求,包括添加、管理等功能。...

    Java图书管理系统

    设计人:wangyunpeng_bio

    项目需求

    随着计算机的普及和应用水平的提高,经过考察比较,决定利用自己的Java知识开发小型的图书管理系统,方便图书的管理。
    图书管理系统是典型的信息管理系统。本次作业利用JAVA开发工具Eclipse和MySQL数据库来开发这个图书管理系统。该系统要解决的图书管理所要解决的问题,可以满足图书管理基本要求,包括添加、管理等功能。该系统能根据用户的需求,快捷方便的为读者提供借阅服务
    图书管理系统应有以下功能:

    1. 读者库管理
    2. 书库管理
    3. 借阅管理
    4. 读者信息查询

    图书管理系统主要针对书库的操作功能、所以系统应尽量满足需求、同时亦不可有多余或繁复的功能、令系统的操作和功能混乱。

    项目地址

    本项目地址:https://github.com/wangyunpengbio/Library/
    免费下载方法:点那个“Clone or download”,再点“Download ZIP”就行了,感兴趣的话,大家可以点个Star
    如果实在太初学者,不会下载的话,就在csdn上下载吧https://download.csdn.net/download/qq_29300341/9667678

    需求分析

    A.业务流程:

    No. 业务流程 需求
    1. 图书管理员登入系统 图书管理员需使用账号和密码登入。
    2. 新增读者资料 新增读者资料,如姓名、性别、职位等。
    3. 新增书籍资料 新增书籍资料,如书名、价格、种类等。
    4. 读者库管理 选中读者库里的读者信息,即可更新和删除。
    5. 书库管理 可以按“书编号查询”和“书名模糊查询”,继而选中书籍信息,即可更新和删除书籍分为在库和借出
    6 借阅管理 输入读者编号,即可检阅读者的数据和借阅的图书,检阅顾客的数据和购买纪录。
    7. 读者登入系统 读者需使用账号和密码登入。
    8 借书 按书名模糊搜索,选中即可借阅图书
    9 还书 检阅自己的读者信息以及已经借阅的图书,点击归还即可,不允许更改或删除读者数据,只允许查询,更改和删除功能由管理员负责。

    以下是使用 实体联系模型-Entity Relationship来分析。

    B.归纳实体和属性

    No. 业务流程 对应的实体 实体的属性值
    1. 图书管理员登入系统 Librarian nameUser password
    2. 新增读者资料 Reader idReader nameReader kind sex password
    3. 新增书籍资料 Book Author Publisher idBook,nameBook,price,kind,author,publisher Author.name, Author.workplace Publisher.name, Publisher.address
    4. 读者库管理 Reader idReader nameReader kind sex password
    5. 书库管理 Book idBook nameBook price kind autor publisher
    6. 借阅管理 Borrow idReader idBook lendDate dueDate overtime
    7. 读者登入系统 Reader idReader password
    8 借书 Borrow idReader idBook lendDate dueDate overtime
    9 还书 Borrow idReader idBook lendDate dueDate overtime

    C.实体的模型

    在这里插入图片描述

    D.ER-实体关系

    Author,Publisher To Book&Borrow&Reader To Librarian
    在这里插入图片描述

    设计

    项目文件夹中,(代码总计:4800+行)
    doc文件夹存放着生成的文档注释,可点击其中的index文件查看整个项目的注释

    Src包下面含有五个包

    • Database用于存储数据库连接操作
    • Frame用于存储各个窗体界面
    • Model用于存储各个实体(表)对应的数据模型
    • Out_of_date用于存储初始时候写的界面,后来舍弃,不再调用。
    • SqlTools用于存储操作数据库的增删改查方法

    image文件夹用于存放相关的界面图片,按钮图片
    备注:程序不同界面的入口已经全部注释掉了,MainFrame是程序的唯一入口

    程序细节设计:

    1. 登陆界面的密码回显,伴有跳转动画(此处利用了多线程,控制线程存活时间)
    2. 表格直接选中即可修改数据,更新数据时候默认有原始数据,可按不同方式搜索图书;
    3. 新增借阅信息时候,自动加入当前时间,并计算归还时间。(SQL函数NOW())
    4. 界面按钮,背景用Photoshop的重新设计,图形用户界面友好;
    5. 数据库设计达到第三范式,去除了所有非主属性对任何候选关键字的传递信依赖,冗余度低。
    6. 变量和方法命名符合规范,可读性强
    7. 不同的Model实体(表)对应不同的SqlTools操作,分开存放,程序复用性好,易扩展。
      使用
    8. 将SQL语句导入,字符集选utf8,不然有可能显示不了中文,数据库名称为library
      create database library;
    9. 推荐使用Mysql Front这个MySQL的前台,支持多句sql语句一起执行,百度第一个链接即可下载。
      http://dlsw.baidu.com/sw-search-sp/soft/6c/17997/MySQL-Front_V5.3.4.214_Setup.1435658094.exe
    10. Java环境中加入数据库的驱动,源程序里database包里DatabaseTools.java文件是有关数据库连接的操作源程序的用户名和密码皆为root,数据库名为:library不同电脑上运行需要稍微改一下这个代码。
    11. 登陆:
      图书管理员:用户名root密码 root或者wangyp密码123456
      **读者:用户名001密码 root **(注:数据库内读者的密码初始值皆为root)
    12. 在不同计算机上Eclipse使用,可能需要重新建立Java类库的路径
      本程序用1.8的jdk写的,所以最好用1.8的jre。
      代码放在1.8下面运行,连警告都不会出现,1.7和1.6显示效果不好。
      awt 和 swing 都依赖虚拟机的具体实现。所以不同平台表现不大一样。如果用javafx,界面才可以移植。
      而且编写用的笔记本电脑是高分屏,在本机上显示大小是正好的,到别的电脑上面有可能会出现界面过大的情况。
    13. 具体的文档注释已经生成,打开doc文件夹其中的index文件查看整个项目的注释
      在这里插入图片描述
    展开全文
  • Java+Swing图书管理系统一、系统介绍二、系统展示1.注册2.登录3.用户端-图书查询及借阅4.用户端-借阅记录及归还5.管理员端-添加图书类别6.管理员端-修改图书类别7.管理员端-添加图书8.管理员端-修改图书9.管理员端-...

    一、系统介绍

    该系统实现用户注册登录功能。用户端实现书籍查询,借书,还书功能。用户能够查询自己的借书记录。管理员能够上架图书,下架图书,添加图书类别,修改图书类别,删除图书类别,添加图书信息,修改图书信息,修改用户信息,查询图书借阅归还记录。

    二、系统展示

    1.注册

    在这里插入图片描述

    2.登录

    在这里插入图片描述

    3.用户端-图书查询及借阅

    在这里插入图片描述

    4.用户端-借阅记录及归还

    在这里插入图片描述

    5.管理员端-添加图书类别

    在这里插入图片描述

    6.管理员端-修改图书类别

    在这里插入图片描述

    7.管理员端-添加图书

    在这里插入图片描述

    8.管理员端-修改图书

    在这里插入图片描述

    9.管理员端-管理用户信息

    在这里插入图片描述

    10.管理员端-查询借阅信息

    在这里插入图片描述

    三、系统实现

    基本类什么的就不列出来了,直接上页面。

    AdminMainFrm.java

    package com.sjsq.view;
    
    import java.awt.event.ActionEvent;
    
    import javax.swing.GroupLayout;
    import javax.swing.JDesktopPane;
    import javax.swing.JFrame;
    import javax.swing.JMenu;
    import javax.swing.JMenuBar;
    import javax.swing.JMenuItem;
    import javax.swing.JOptionPane;
    import javax.swing.WindowConstants;
    
    public class AdminMainFrm extends JFrame {
    
    	private JDesktopPane jD_table;
    	private JMenu jMenu1;
    	private JMenu jMenu2;
    	private JMenu jMenu3;
    	private JMenu jMenu4;
    	private JMenuBar jMenuBar1;
    	private JMenuItem jMenuItem1;
    	private JMenuItem jMenuItem2;
    	private JMenuItem jMenuItem3;
    	private JMenuItem jMenuItem4;
    	private JMenuItem jMenuItem5;
    	private JMenuItem jMenuItem6;
    	private JMenuItem jMenuItem7;
    	
    	
    	public AdminMainFrm() {
    		initComponents();
    		// 设置位置
    		setBounds(100, 200, 1050, 650);
    		// 居中显示
    		this.setLocationRelativeTo(null);
    	}
    
    	private void initComponents() {
    
    		jD_table = new JDesktopPane();
    		jMenuBar1 = new JMenuBar();
    		jMenu1 = new JMenu();
    		jMenu2 = new JMenu();
    		jMenuItem1 = new JMenuItem();
    		jMenuItem2 = new JMenuItem();
    		jMenu3 = new JMenu();
    		jMenuItem4 = new JMenuItem();
    		jMenuItem5 = new JMenuItem();
    		jMenu4 = new JMenu();
    		jMenuItem6 = new JMenuItem();
    		jMenuItem7 = new JMenuItem();
    		jMenuItem3 = new JMenuItem();
    
    		setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    		setTitle("管理员主界面");
    
    		jMenu1.setText("基本数据管理");
    
    		jMenu2.setText("类别管理");
    		jMenu2.addActionListener(new java.awt.event.ActionListener() {
    			public void actionPerformed(java.awt.event.ActionEvent evt) {
    				jMenu2ActionPerformed(evt);
    			}
    
    			private void jMenu2ActionPerformed(ActionEvent evt) {
    				
    
    			}
    		});
    
    		jMenuItem1.setText("图书类别添加");
    		jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
    			public void actionPerformed(java.awt.event.ActionEvent evt) {
    				jMenuItem1ActionPerformed(evt);
    			}
    		});
    		jMenu2.add(jMenuItem1);
    
    		jMenuItem2.setText("图书类别修改");
    		jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
    			public void actionPerformed(java.awt.event.ActionEvent evt) {
    				jMenuItem2ActionPerformed(evt);
    			}
    		});
    		jMenu2.add(jMenuItem2);
    
    		jMenu1.add(jMenu2);
    
    		jMenu3.setText("书籍管理");
    
    		jMenuItem4.setText("书籍添加");
    		jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
    			public void actionPerformed(java.awt.event.ActionEvent evt) {
    				jMenuItem4ActionPerformed(evt);
    			}
    		});
    		jMenu3.add(jMenuItem4);
    
    		jMenuItem5.setText("书籍修改");
    		jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
    			public void actionPerformed(java.awt.event.ActionEvent evt) {
    				jMenuItem5ActionPerformed(evt);
    			}
    		});
    		jMenu3.add(jMenuItem5);
    
    		jMenu1.add(jMenu3);
    
    		jMenu4.setText("用户管理");
    
    		jMenuItem6.setText("用户信息");
    		jMenuItem6.addActionListener(new java.awt.event.ActionListener() {
    			public void actionPerformed(java.awt.event.ActionEvent evt) {
    				jMenuItem6ActionPerformed(evt);
    			}
    		});
    		jMenu4.add(jMenuItem6);
    
    		jMenuItem7.setText("借还信息");
    		jMenuItem7.addActionListener(new java.awt.event.ActionListener() {
    			public void actionPerformed(java.awt.event.ActionEvent evt) {
    				jMenuItem7ActionPerformed(evt);
    			}
    		});
    		jMenu4.add(jMenuItem7);
    
    		jMenu1.add(jMenu4);
    
    		jMenuItem3.setText("退出系统");
    		jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
    			public void actionPerformed(java.awt.event.ActionEvent evt) {
    				jMenuItem3ActionPerformed(evt);
    			}
    		});
    		jMenu1.add(jMenuItem3);
    
    		jMenuBar1.add(jMenu1);
    
    		setJMenuBar(jMenuBar1);
    
    		GroupLayout layout = new GroupLayout(getContentPane());
    		getContentPane().setLayout(layout);
    		layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
    				.addComponent(jD_table, GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE));
    		layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
    				.addComponent(jD_table, GroupLayout.DEFAULT_SIZE, 279, Short.MAX_VALUE));
    
    		pack();
    	}
    		
    
    	// 借还信息
    	private void jMenuItem7ActionPerformed(java.awt.event.ActionEvent evt) {
    		BorrowDetailFrm b = new BorrowDetailFrm();
    		b.setVisible(true);
    		this.jD_table.add(b);
    	}
    
    	// 用户信息
    	private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {
    		UserInfoFrm userInfoFrm = new UserInfoFrm();
    		userInfoFrm.setVisible(true);
    		this.jD_table.add(userInfoFrm);
    	}
    
    	private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {
    		BookTypeAddFrm addFrm = new BookTypeAddFrm();
    		addFrm.setVisible(true);
    		this.jD_table.add(addFrm);
    	}
    
    	private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {
    		BookManagerFrm bookManagerFrm = new BookManagerFrm();
    		bookManagerFrm.setVisible(true);
    		this.jD_table.add(bookManagerFrm);
    
    	}
    
    	private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {
    		BookAddFrm bookAddFrm = new BookAddFrm();
    		bookAddFrm.setVisible(true);
    		this.jD_table.add(bookAddFrm);
    	}
    
    	private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {
    		BookTypeManagerFrm bookTypeManagerFrm = new BookTypeManagerFrm();
    		bookTypeManagerFrm.setVisible(true);
    		this.jD_table.add(bookTypeManagerFrm);
    	}
    
    	private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {
    		int i = JOptionPane.showConfirmDialog(null, "确认退出系统");
    		if (i == 0) {
    			this.dispose();
    		}
    	}
    
    	public static void main(String args[]) {
    		java.awt.EventQueue.invokeLater(new Runnable() {
    			public void run() {
    				new AdminMainFrm().setVisible(true);
    			}
    		});
    	}
    
    }
    

    BookAddFrm.java

    package com.sjsq.view;
    
    import java.sql.Connection;
    import java.sql.ResultSet;
    import java.util.Vector;
    
    import javax.swing.GroupLayout;
    import javax.swing.JButton;
    import javax.swing.JInternalFrame;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.JTextField;
    import javax.swing.LayoutStyle;
    import javax.swing.table.DefaultTableModel;
    
    import com.sjsq.dao.BookDao;
    import com.sjsq.dao.BorrowDetailDao;
    import com.sjsq.model.Book;
    import com.sjsq.model.BorrowDetail;
    import com.sjsq.util.DbUtil;
    import com.sjsq.util.StringUtil;
    import com.sjsq.util.TimeUtil;
    
    public class BookInfoFrm extends JInternalFrame {
    	
    	private JTextField bookIdText;
    	private JTextField bookName;
    	private JTextField bookNameText;
    	private JTable bookTable;
    	private JButton jB_borrow;
    	private JButton jButton1;
    	private JLabel jLabel1;
    	private JLabel jLabel2;
    	private JLabel jLabel3;
    	private JPanel jPanel1;
    	private JScrollPane jScrollPane1;
    	
    	DbUtil dbUtil = new DbUtil();
    	BookDao bookDao = new BookDao();
    	BorrowDetailDao borrowDetailDao = new BorrowDetailDao();
    
    	
    	public BookInfoFrm() {
    		initComponents();
    		fillTable(new Book());
    		setTitle("书籍信息");
    		this.setLocation(200, 50);
    	}
    
    	private void fillTable(Book book) {
    		DefaultTableModel model = (DefaultTableModel) bookTable.getModel();
    		model.setRowCount(0);
    		Connection con = null;
    		try {
    			con = dbUtil.getCon();
    			book.setStatus(1);
    			ResultSet list = bookDao.list(con, book);
    			while (list.next()) {
    				Vector rowData = new Vector();
    				rowData.add(list.getInt("id"));
    				rowData.add(list.getString("book_name"));
    				rowData.add(list.getString("type_name"));
    				rowData.add(list.getString("author"));
    				rowData.add(list.getString("remark"));
    				model.addRow(rowData);
    			}
    		} catch (Exception e) {
    			
    			e.printStackTrace();
    		} finally {
    			try {
    				dbUtil.closeCon(con);
    			} catch (Exception e) {
    				
    				e.printStackTrace();
    			}
    		}
    	}
    
    	
    	private void initComponents() {
    
    		jScrollPane1 = new JScrollPane();
    		bookTable = new JTable();
    		jPanel1 = new JPanel();
    		jLabel1 = new JLabel();
    		bookNameText = new JTextField();
    		jButton1 = new JButton();
    		jB_borrow = new JButton();
    		jLabel2 = new JLabel();
    		bookIdText = new JTextField();
    		jLabel3 = new JLabel();
    		bookName = new JTextField();
    
    		setClosable(true);
    
    		bookTable.setModel(new DefaultTableModel(new Object[][] {
    
    		}, new String[] { "编号", "书名", "类型", "作者", "描述" }) {
    			boolean[] canEdit = new boolean[] { false, false, false, false, false };
    
    			public boolean isCellEditable(int rowIndex, int columnIndex) {
    				return canEdit[columnIndex];
    			}
    		});
    		bookTable.addMouseListener(new java.awt.event.MouseAdapter() {
    			public void mousePressed(java.awt.event.MouseEvent evt) {
    				bookTableMousePressed(evt);
    			}
    		});
    		jScrollPane1.setViewportView(bookTable);
    
    		jLabel1.setText("书籍名称:");
    
    		bookNameText.addActionListener(new java.awt.event.ActionListener() {
    			public void actionPerformed(java.awt.event.ActionEvent evt) {
    				bookNameTextActionPerformed(evt);
    			}
    		});
    
    		jButton1.setText("查询");
    		jButton1.addActionListener(new java.awt.event.ActionListener() {
    			public void actionPerformed(java.awt.event.ActionEvent evt) {
    				jButton1ActionPerformed(evt);
    			}
    		});
    
    		GroupLayout jPanel1Layout = new GroupLayout(jPanel1);
    		jPanel1.setLayout(jPanel1Layout);
    		jPanel1Layout.setHorizontalGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
    				.addGroup(GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
    						.addGap(42, 42, 42).addComponent(jLabel1).addGap(36, 36, 36)
    						.addComponent(bookNameText, GroupLayout.PREFERRED_SIZE, 130,
    								GroupLayout.PREFERRED_SIZE)
    						.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 149, Short.MAX_VALUE)
    						.addComponent(jButton1).addGap(45, 45, 45)));
    		jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
    				.addGroup(jPanel1Layout.createSequentialGroup().addGap(23, 23, 23)
    						.addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
    								.addComponent(jButton1).addComponent(jLabel1).addComponent(bookNameText,
    										GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
    										GroupLayout.PREFERRED_SIZE))
    						.addContainerGap(30, Short.MAX_VALUE)));
    
    		jB_borrow.setText("借书");
    		jB_borrow.addActionListener(new java.awt.event.ActionListener() {
    			public void actionPerformed(java.awt.event.ActionEvent evt) {
    				jB_borrowActionPerformed(evt);
    			}
    		});
    
    		jLabel2.setText("编号:");
    
    		bookIdText.setEditable(false);
    
    		jLabel3.setText("书名:");
    
    		bookName.setEditable(false);
    
    		GroupLayout layout = new GroupLayout(getContentPane());
    		getContentPane().setLayout(layout);
    		layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout
    				.createSequentialGroup().addGap(22, 22, 22)
    				.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout
    						.createSequentialGroup().addComponent(jLabel2)
    						.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
    						.addComponent(bookIdText, GroupLayout.PREFERRED_SIZE, 95,
    								GroupLayout.PREFERRED_SIZE)
    						.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel3)
    						.addGap(18, 18, 18)
    						.addComponent(bookName, GroupLayout.PREFERRED_SIZE, 127,
    								GroupLayout.PREFERRED_SIZE)
    						.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 102, Short.MAX_VALUE)
    						.addComponent(jB_borrow).addGap(88, 88, 88))
    						.addGroup(layout.createSequentialGroup()
    								.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
    										.addComponent(jPanel1, GroupLayout.Alignment.TRAILING,
    												GroupLayout.DEFAULT_SIZE,
    												GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    										.addComponent(jScrollPane1, GroupLayout.Alignment.TRAILING,
    												GroupLayout.DEFAULT_SIZE, 507, Short.MAX_VALUE))
    								.addContainerGap(38, Short.MAX_VALUE)))));
    		layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
    				.addGroup(layout.createSequentialGroup()
    						.addComponent(jPanel1, GroupLayout.PREFERRED_SIZE,
    								GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
    						.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
    						.addComponent(jScrollPane1, GroupLayout.PREFERRED_SIZE, 225,
    								GroupLayout.PREFERRED_SIZE)
    						.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 35, Short.MAX_VALUE)
    						.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
    								.addComponent(jLabel2).addComponent(jLabel3)
    								.addComponent(bookIdText, GroupLayout.PREFERRED_SIZE,
    										GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
    								.addComponent(bookName, GroupLayout.PREFERRED_SIZE,
    										GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
    								.addComponent(jB_borrow))
    						.addGap(27, 27, 27)));
    
    		pack();
    	}
    		
    
    	private void jB_borrowActionPerformed(java.awt.event.ActionEvent evt) {
    		String bookId = this.bookIdText.getText();
    		String bookName = this.bookName.getText();
    		if (StringUtil.isEmpty(bookId) || StringUtil.isEmpty(bookName)) {
    			JOptionPane.showMessageDialog(null, "请选择相关书籍");
    			return;
    		}
    		BorrowDetail borrowDetail = new BorrowDetail();
    		borrowDetail.setUserId(LoginFrm.currentUser.getUserId());
    		borrowDetail.setBookId(Integer.parseInt(bookId));
    		borrowDetail.setStatus(1);
    		borrowDetail.setBorrowTime(TimeUtil.getTime());
    		Connection con = null;
    		try {
    			con = dbUtil.getCon();
    
    			// 先查询是否有该书在借
    			ResultSet list = borrowDetailDao.list(con, borrowDetail);
    			while (list.next()) {
    				JOptionPane.showMessageDialog(null, "该书已在借,请先还再借");
    				return;
    			}
    			int i = borrowDetailDao.add(con, borrowDetail);
    			if (i == 1) {
    				JOptionPane.showMessageDialog(null, "借书成功");
    			} else {
    				JOptionPane.showMessageDialog(null, "借书失败");
    			}
    		} catch (Exception e) {
    			
    			e.printStackTrace();
    			JOptionPane.showMessageDialog(null, "借书异常");
    		} finally {
    			try {
    				dbUtil.closeCon(con);
    			} catch (Exception e) {
    				
    				e.printStackTrace();
    			}
    		}
    
    	}
    
    	private void bookTableMousePressed(java.awt.event.MouseEvent evt) {
    		int row = this.bookTable.getSelectedRow();
    		Object bookId = this.bookTable.getValueAt(row, 0);
    		Object bookName = this.bookTable.getValueAt(row, 1);
    		this.bookIdText.setText(bookId.toString());
    		this.bookName.setText(bookName.toString());
    	}
    
    	private void bookNameTextActionPerformed(java.awt.event.ActionEvent evt) {
    	}
    
    	private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    		String bookName = this.bookNameText.getText();
    		Book book = new Book();
    		book.setBookName(bookName);
    		fillTable(book);
    	}
    
    }
    

    BookManagerFrm.java

    package com.sjsq.view;
    
    import java.math.BigDecimal;
    import java.sql.Connection;
    import java.sql.ResultSet;
    import java.util.Vector;
    
    import javax.swing.BorderFactory;
    import javax.swing.GroupLayout;
    import javax.swing.JButton;
    import javax.swing.JComboBox;
    import javax.swing.JInternalFrame;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.JTextField;
    import javax.swing.LayoutStyle;
    import javax.swing.table.DefaultTableModel;
    
    import com.sjsq.dao.BookDao;
    import com.sjsq.dao.BookTypeDao;
    import com.sjsq.model.Book;
    import com.sjsq.model.BookType;
    import com.sjsq.util.DbUtil;
    import com.sjsq.util.StringUtil;
    
    public class BookManagerFrm extends JInternalFrame {
    	
    	private JTextField authorText;
    	private JTextField bookId;
    	private JTextField bookName;
    	private JTextField bookNameText;
    	private JTable bookTable;
    	private JButton jButton1;
    	private JButton jButton2;
    	private JComboBox jCB_status;
    	private JComboBox jCB_type2;
    	private JLabel jLabel1;
    	private JLabel jLabel10;
    	private JLabel jLabel11;
    	private JLabel jLabel3;
    	private JLabel jLabel4;
    	private JLabel jLabel5;
    	private JLabel jLabel6;
    	private JLabel jLabel7;
    	private JLabel jLabel8;
    	private JLabel jLabel9;
    	private JPanel jPanel1;
    	private JPanel jPanel2;
    	private JScrollPane jScrollPane1;
    	private JTextField numberText;
    	private JTextField priceText;
    	private JTextField publishText;
    	private JTextField remarkText;
    	
    	
    	DbUtil dbUtil = new DbUtil();
    	BookTypeDao bookTypeDao = new BookTypeDao();
    	BookDao bookDao = new BookDao();
    
    	
    	public BookManagerFrm() {
    		initComponents();
    		this.jCB_status.addItem("上架");
    		this.jCB_status.addItem("下架");
    		fillBookTable(new Book());
    		fillBookType();
    		setTitle("书籍修改");
    		this.setLocation(125, 10);
    	}
    
    	private void fillBookType() {
    		Connection con = null;
    		try {
    			con = dbUtil.getCon();
    			ResultSet list = bookTypeDao.list(con, new BookType());
    			while (list.next()) {
    				BookType bookType = new BookType();
    				bookType.setTypeId(list.getInt("id"));
    				bookType.setTypeName(list.getString("type_name"));
    				this.jCB_type2.addItem(bookType);
    			}
    		} catch (Exception e) {
    			
    			e.printStackTrace();
    		} finally {
    			try {
    				dbUtil.closeCon(con);
    			} catch (Exception e) {
    				
    				e.printStackTrace();
    			}
    		}
    	}
    
    	private void fillBookTable(Book book) {
    		DefaultTableModel model = (DefaultTableModel) bookTable.getModel();
    		model.setRowCount(0);
    		Connection con = null;
    		try {
    			con = dbUtil.getCon();
    			ResultSet resultSet = bookDao.list(con, book);
    			while (resultSet.next()) {
    				Vector rowData = new Vector();
    				rowData.add(resultSet.getInt("id"));
    				rowData.add(resultSet.getString("book_name"));
    				rowData.add(resultSet.getString("type_name"));
    				rowData.add(resultSet.getString("author"));
    				rowData.add(resultSet.getDouble("price"));
    				rowData.add(resultSet.getInt("number"));
    				if (resultSet.getInt("status") == 1) {
    					rowData.add("上架");
    				} else {
    					rowData.add("下架");
    				}
    				model.addRow(rowData);
    			}
    		} catch (Exception e) {
    			
    			e.printStackTrace();
    		} finally {
    			try {
    				dbUtil.closeCon(con);
    			} catch (Exception e) {
    				
    				e.printStackTrace();
    			}
    		}
    	}
    
    	
    	
    	private void initComponents() {
    
    		jPanel1 = new JPanel();
    		jLabel1 = new JLabel();
    		bookNameText = new JTextField();
    		jButton1 = new JButton();
    		jScrollPane1 = new JScrollPane();
    		bookTable = new JTable();
    		jPanel2 = new JPanel();
    		jLabel3 = new JLabel();
    		bookId = new JTextField();
    		jLabel4 = new JLabel();
    		bookName = new JTextField();
    		jLabel5 = new JLabel();
    		authorText = new JTextField();
    		jLabel6 = new JLabel();
    		publishText = new JTextField();
    		jLabel7 = new JLabel();
    		priceText = new JTextField();
    		jLabel8 = new JLabel();
    		numberText = new JTextField();
    		jLabel9 = new JLabel();
    		jLabel10 = new JLabel();
    		jCB_type2 = new JComboBox();
    		jLabel11 = new JLabel();
    		remarkText = new JTextField();
    		jButton2 = new JButton();
    		jCB_status = new JComboBox();
    
    		setClosable(true);
    
    		jPanel1.setBorder(BorderFactory.createTitledBorder("查询操作"));
    
    		jLabel1.setText("书名:");
    
    		jButton1.setText("查询");
    		jButton1.addActionListener(new java.awt.event.ActionListener() {
    			public void actionPerformed(java.awt.event.ActionEvent evt) {
    				jButton1ActionPerformed(evt);
    			}
    		});
    
    		GroupLayout jPanel1Layout = new GroupLayout(jPanel1);
    		jPanel1.setLayout(jPanel1Layout);
    		jPanel1Layout.setHorizontalGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
    				.addGroup(jPanel1Layout.createSequentialGroup().addGap(25, 25, 25).addComponent(jLabel1)
    						.addGap(18, 18, 18)
    						.addComponent(bookNameText, GroupLayout.PREFERRED_SIZE, 171,
    								GroupLayout.PREFERRED_SIZE)
    						.addGap(62, 62, 62).addComponent(jButton1).addContainerGap(299, Short.MAX_VALUE)));
    		jPanel1Layout
    				.setVerticalGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
    						.addGroup(jPanel1Layout.createSequentialGroup().addGroup(jPanel1Layout
    								.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(jLabel1)
    								.addComponent(bookNameText, GroupLayout.PREFERRED_SIZE,
    										GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
    								.addComponent(jButton1)).addContainerGap(22, Short.MAX_VALUE)));
    
    		bookTable.setModel(new DefaultTableModel(new Object[][] {
    
    		}, new String[] { "编号", "书名", "类别", "作者", "价格", "库存", "状态" }) {
    			boolean[] canEdit = new boolean[] { false, false, false, false, false, false, false };
    
    			public boolean isCellEditable(int rowIndex, int columnIndex) {
    				return canEdit[columnIndex];
    			}
    		});
    		bookTable.addMouseListener(new java.awt.event.MouseAdapter() {
    			public void mousePressed(java.awt.event.MouseEvent evt) {
    				bookTableMousePressed(evt);
    			}
    		});
    		jScrollPane1.setViewportView(bookTable);
    
    		jPanel2.setBorder(BorderFactory.createTitledBorder("书籍操作"));
    
    		jLabel3.setText("编号:");
    
    		bookId.setEditable(false);
    
    		jLabel4.setText("书名:");
    
    		jLabel5.setText("作者:");
    
    		jLabel6.setText("出版:");
    
    		jLabel7.setText("价格:");
    
    		jLabel8.setText("库存:");
    
    		jLabel9.setText("状态:");
    
    		jLabel10.setText("类别:");
    
    		jLabel11.setText("描述:");
    
    		jButton2.setText("修改");
    		jButton2.addActionListener(new java.awt.event.ActionListener() {
    			public void actionPerformed(java.awt.event.ActionEvent evt) {
    				jButton2ActionPerformed(evt);
    			}
    		});
    
    		GroupLayout jPanel2Layout = new GroupLayout(jPanel2);
    		jPanel2.setLayout(jPanel2Layout);
    		jPanel2Layout.setHorizontalGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
    				.addGroup(jPanel2Layout.createSequentialGroup()
    						.addGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(
    								jPanel2Layout.createSequentialGroup().addGap(26, 26, 26).addGroup(jPanel2Layout
    										.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(
    												jPanel2Layout.createSequentialGroup().addComponent(jLabel9)
    														.addPreferredGap(
    																LayoutStyle.ComponentPlacement.RELATED)
    														.addComponent(jCB_status, 0, 117, Short.MAX_VALUE))
    										.addGroup(GroupLayout.Alignment.TRAILING,
    												jPanel2Layout
    														.createSequentialGroup().addGroup(jPanel2Layout
    																.createParallelGroup(
    																		GroupLayout.Alignment.LEADING)
    																.addComponent(jLabel3).addComponent(jLabel6))
    														.addPreferredGap(
    																LayoutStyle.ComponentPlacement.RELATED,
    																GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    														.addGroup(jPanel2Layout
    																.createParallelGroup(
    																		GroupLayout.Alignment.TRAILING,
    																		false)
    																.addComponent(publishText,
    																		GroupLayout.Alignment.LEADING)
    																.addComponent(bookId,
    																		GroupLayout.Alignment.LEADING,
    																		GroupLayout.DEFAULT_SIZE, 117,
    																		Short.MAX_VALUE))))
    										.addGap(39, 39, 39)
    										.addGroup(jPanel2Layout.createParallelGroup(
    												GroupLayout.Alignment.LEADING, false)
    												.addGroup(jPanel2Layout.createSequentialGroup().addComponent(jLabel10)
    														.addGap(27, 27,
    																27)
    														.addComponent(jCB_type2, 0,
    																GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    												.addGroup(GroupLayout.Alignment.TRAILING,
    														jPanel2Layout.createSequentialGroup().addComponent(jLabel7)
    																.addGap(27, 27, 27).addComponent(priceText))
    												.addGroup(jPanel2Layout.createSequentialGroup().addComponent(jLabel4)
    														.addGap(27, 27, 27).addComponent(
    																bookName, GroupLayout.PREFERRED_SIZE, 108,
    																GroupLayout.PREFERRED_SIZE)))
    										.addGap(18, 18, 18)
    										.addGroup(jPanel2Layout
    												.createParallelGroup(GroupLayout.Alignment.LEADING)
    												.addGroup(jPanel2Layout.createSequentialGroup().addComponent(jLabel11)
    														.addGap(18, 18, 18).addComponent(remarkText,
    																GroupLayout.PREFERRED_SIZE, 172,
    																GroupLayout.PREFERRED_SIZE))
    												.addGroup(jPanel2Layout
    														.createParallelGroup(GroupLayout.Alignment.TRAILING,
    																false)
    														.addGroup(GroupLayout.Alignment.LEADING,
    																jPanel2Layout.createSequentialGroup()
    																		.addComponent(jLabel8).addGap(18, 18, 18)
    																		.addComponent(numberText))
    														.addGroup(GroupLayout.Alignment.LEADING,
    																jPanel2Layout.createSequentialGroup()
    																		.addComponent(jLabel5).addGap(20, 20, 20)
    																		.addComponent(authorText,
    																				GroupLayout.PREFERRED_SIZE,
    																				106,
    																				GroupLayout.PREFERRED_SIZE))))
    										.addGap(97, 97, 97))
    								.addGroup(jPanel2Layout.createSequentialGroup().addGap(108, 108, 108)
    										.addComponent(jButton2)))
    						.addContainerGap()));
    		jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
    				.addGroup(jPanel2Layout.createSequentialGroup().addGroup(jPanel2Layout
    						.createParallelGroup(GroupLayout.Alignment.LEADING)
    						.addGroup(jPanel2Layout.createSequentialGroup().addGroup(jPanel2Layout
    								.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(jLabel3)
    								.addComponent(bookId, GroupLayout.PREFERRED_SIZE,
    										GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
    								.addGap(18, 18, 18)
    								.addGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
    										.addComponent(jLabel6)
    										.addComponent(publishText, GroupLayout.PREFERRED_SIZE,
    												GroupLayout.DEFAULT_SIZE,
    												GroupLayout.PREFERRED_SIZE)
    										.addComponent(jLabel7)
    										.addComponent(priceText, GroupLayout.PREFERRED_SIZE,
    												GroupLayout.DEFAULT_SIZE,
    												GroupLayout.PREFERRED_SIZE)
    										.addComponent(jLabel8).addComponent(numberText,
    												GroupLayout.PREFERRED_SIZE,
    												GroupLayout.DEFAULT_SIZE,
    												GroupLayout.PREFERRED_SIZE))
    								.addGap(18, 18, 18)
    								.addGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
    										.addComponent(jLabel9)
    										.addComponent(jCB_status, GroupLayout.PREFERRED_SIZE,
    												GroupLayout.DEFAULT_SIZE,
    												GroupLayout.PREFERRED_SIZE)
    										.addComponent(jLabel10)
    										.addComponent(jCB_type2, GroupLayout.PREFERRED_SIZE,
    												GroupLayout.DEFAULT_SIZE,
    												GroupLayout.PREFERRED_SIZE)
    										.addComponent(jLabel11).addComponent(remarkText,
    												GroupLayout.PREFERRED_SIZE,
    												GroupLayout.DEFAULT_SIZE,
    												GroupLayout.PREFERRED_SIZE)))
    						.addGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
    								.addComponent(jLabel4)
    								.addComponent(bookName, GroupLayout.PREFERRED_SIZE,
    										GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
    								.addComponent(authorText, GroupLayout.PREFERRED_SIZE,
    										GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
    								.addComponent(jLabel5)))
    						.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 42, Short.MAX_VALUE)
    						.addComponent(jButton2).addGap(28, 28, 28)));
    
    		GroupLayout layout = new GroupLayout(getContentPane());
    		getContentPane().setLayout(layout);
    		layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout
    				.createSequentialGroup().addGap(31, 31, 31)
    				.addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING, false)
    						.addComponent(jPanel1, GroupLayout.Alignment.LEADING,
    								GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE,
    								Short.MAX_VALUE)
    						.addComponent(jScrollPane1, GroupLayout.Alignment.LEADING).addComponent(jPanel2,
    								GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 668,
    								Short.MAX_VALUE))
    				.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    		layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
    				.addGroup(layout.createSequentialGroup()
    						.addComponent(jPanel1, GroupLayout.PREFERRED_SIZE,
    								GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
    						.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
    						.addComponent(jScrollPane1, GroupLayout.PREFERRED_SIZE, 186,
    								GroupLayout.PREFERRED_SIZE)
    						.addGap(18, 18, 18).addComponent(jPanel2, GroupLayout.DEFAULT_SIZE,
    								GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    						.addContainerGap()));
    
    		pack();
    	}
    
    	
    
    	private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    		String bookName = this.bookNameText.getText();
    		Book book = new Book();
    		book.setBookName(bookName);
    		fillBookTable(book);
    	}
    
    	private void bookTableMousePressed(java.awt.event.MouseEvent evt) {
    		int row = bookTable.getSelectedRow();
    		Integer bookId = (Integer) bookTable.getValueAt(row, 0);
    		Book book = new Book();
    		book.setBookId(bookId);
    		Connection con = null;
    		try {
    			con = dbUtil.getCon();
    			ResultSet list = bookDao.list(con, book);
    			if (list.next()) {
    				this.bookId.setText(list.getString("id"));
    				this.bookName.setText(list.getString("book_name"));
    				this.authorText.setText(list.getString("author"));
    				this.publishText.setText(list.getString("publish"));
    				this.priceText.setText(list.getString("price"));
    				this.numberText.setText(list.getString("number"));
    				this.remarkText.setText(list.getString("remark"));
    				int status = list.getInt("status");
    				if (status == 1) {
    					this.jCB_status.setSelectedIndex(0);
    				} else {
    					this.jCB_status.setSelectedIndex(1);
    				}
    				int typeId = list.getInt("type_id");
    				int count = this.jCB_type2.getItemCount();
    				for (int i = 0; i < count; i++) {
    					BookType bookType = (BookType) this.jCB_type2.getItemAt(i);
    					if (bookType.getTypeId() == typeId) {
    						this.jCB_type2.setSelectedIndex(i);
    					}
    				}
    			}
    		} catch (Exception e) {
    			
    			e.printStackTrace();
    		} finally {
    			try {
    				dbUtil.closeCon(con);
    			} catch (Exception e) {
    				
    				e.printStackTrace();
    			}
    		}
    	}
    
    	private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
    		String bookName = this.bookName.getText();
    		String author = this.authorText.getText();
    		String publish = this.publishText.getText();
    		String priceStr = this.priceText.getText();
    		String numberStr = this.numberText.getText();
    		String remark = this.remarkText.getText();
    		String bookId = this.bookId.getText();
    		if (StringUtil.isEmpty(bookId) || StringUtil.isEmpty(bookName) || StringUtil.isEmpty(author)
    				|| StringUtil.isEmpty(publish) || StringUtil.isEmpty(priceStr) || StringUtil.isEmpty(numberStr)
    				|| StringUtil.isEmpty(remark)) {
    			JOptionPane.showMessageDialog(null, "请输入相关内容");
    			return;
    		}
    		BookType selectedItem = (BookType) jCB_type2.getSelectedItem();
    		Integer typeId = selectedItem.getTypeId();
    		int index = jCB_status.getSelectedIndex();
    
    		int number;
    		double price;
    		try {
    			number = Integer.parseInt(numberStr);
    			price = new BigDecimal(priceStr).setScale(2, BigDecimal.ROUND_DOWN).doubleValue();
    		} catch (Exception e) {
    			JOptionPane.showMessageDialog(null, "参数错误");
    			return;
    		}
    		Book book = new Book();
    		book.setBookId(Integer.parseInt(bookId));
    		book.setBookName(bookName);
    		book.setAuthor(author);
    		book.setBookTypeId(typeId);
    		book.setNumber(number);
    		book.setPrice(price);
    		book.setPublish(publish);
    		book.setRemark(remark);
    		book.setStatus(1);
    		if (index == 0) {
    			book.setStatus(1);
    		} else if (index == 1) {
    			book.setStatus(2);
    		}
    		Connection con = null;
    		try {
    			con = dbUtil.getCon();
    			int i = bookDao.update(con, book);
    			if (i == 1) {
    				JOptionPane.showMessageDialog(null, "修改成功");
    			} else {
    				JOptionPane.showMessageDialog(null, "修改失败");
    			}
    		} catch (Exception e) {
    			
    			e.printStackTrace();
    			JOptionPane.showMessageDialog(null, "修改异常");
    		} finally {
    			try {
    				dbUtil.closeCon(con);
    			} catch (Exception e) {
    				
    				e.printStackTrace();
    			}
    		}
    
    		fillBookTable(new Book());
    	}
    
    }
    

    BookInfoFrm.java

    package com.sjsq.view;
    
    import java.sql.Connection;
    import java.sql.ResultSet;
    import java.util.Vector;
    
    import javax.swing.GroupLayout;
    import javax.swing.JButton;
    import javax.swing.JInternalFrame;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.JTextField;
    import javax.swing.LayoutStyle;
    import javax.swing.table.DefaultTableModel;
    
    import com.sjsq.dao.BookDao;
    import com.sjsq.dao.BorrowDetailDao;
    import com.sjsq.model.Book;
    import com.sjsq.model.BorrowDetail;
    import com.sjsq.util.DbUtil;
    import com.sjsq.util.StringUtil;
    import com.sjsq.util.TimeUtil;
    
    public class BookInfoFrm extends JInternalFrame {
    	
    	private JTextField bookIdText;
    	private JTextField bookName;
    	private JTextField bookNameText;
    	private JTable bookTable;
    	private JButton jB_borrow;
    	private JButton jButton1;
    	private JLabel jLabel1;
    	private JLabel jLabel2;
    	private JLabel jLabel3;
    	private JPanel jPanel1;
    	private JScrollPane jScrollPane1;
    	
    	DbUtil dbUtil = new DbUtil();
    	BookDao bookDao = new BookDao();
    	BorrowDetailDao borrowDetailDao = new BorrowDetailDao();
    
    	
    	public BookInfoFrm() {
    		initComponents();
    		fillTable(new Book());
    		setTitle("书籍信息");
    		this.setLocation(200, 50);
    	}
    
    	private void fillTable(Book book) {
    		DefaultTableModel model = (DefaultTableModel) bookTable.getModel();
    		model.setRowCount(0);
    		Connection con = null;
    		try {
    			con = dbUtil.getCon();
    			book.setStatus(1);
    			ResultSet list = bookDao.list(con, book);
    			while (list.next()) {
    				Vector rowData = new Vector();
    				rowData.add(list.getInt("id"));
    				rowData.add(list.getString("book_name"));
    				rowData.add(list.getString("type_name"));
    				rowData.add(list.getString("author"));
    				rowData.add(list.getString("remark"));
    				model.addRow(rowData);
    			}
    		} catch (Exception e) {
    			
    			e.printStackTrace();
    		} finally {
    			try {
    				dbUtil.closeCon(con);
    			} catch (Exception e) {
    				
    				e.printStackTrace();
    			}
    		}
    	}
    
    	
    	private void initComponents() {
    
    		jScrollPane1 = new JScrollPane();
    		bookTable = new JTable();
    		jPanel1 = new JPanel();
    		jLabel1 = new JLabel();
    		bookNameText = new JTextField();
    		jButton1 = new JButton();
    		jB_borrow = new JButton();
    		jLabel2 = new JLabel();
    		bookIdText = new JTextField();
    		jLabel3 = new JLabel();
    		bookName = new JTextField();
    
    		setClosable(true);
    
    		bookTable.setModel(new DefaultTableModel(new Object[][] {
    
    		}, new String[] { "编号", "书名", "类型", "作者", "描述" }) {
    			boolean[] canEdit = new boolean[] { false, false, false, false, false };
    
    			public boolean isCellEditable(int rowIndex, int columnIndex) {
    				return canEdit[columnIndex];
    			}
    		});
    		bookTable.addMouseListener(new java.awt.event.MouseAdapter() {
    			public void mousePressed(java.awt.event.MouseEvent evt) {
    				bookTableMousePressed(evt);
    			}
    		});
    		jScrollPane1.setViewportView(bookTable);
    
    		jLabel1.setText("书籍名称:");
    
    		bookNameText.addActionListener(new java.awt.event.ActionListener() {
    			public void actionPerformed(java.awt.event.ActionEvent evt) {
    				bookNameTextActionPerformed(evt);
    			}
    		});
    
    		jButton1.setText("查询");
    		jButton1.addActionListener(new java.awt.event.ActionListener() {
    			public void actionPerformed(java.awt.event.ActionEvent evt) {
    				jButton1ActionPerformed(evt);
    			}
    		});
    
    		GroupLayout jPanel1Layout = new GroupLayout(jPanel1);
    		jPanel1.setLayout(jPanel1Layout);
    		jPanel1Layout.setHorizontalGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
    				.addGroup(GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
    						.addGap(42, 42, 42).addComponent(jLabel1).addGap(36, 36, 36)
    						.addComponent(bookNameText, GroupLayout.PREFERRED_SIZE, 130,
    								GroupLayout.PREFERRED_SIZE)
    						.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 149, Short.MAX_VALUE)
    						.addComponent(jButton1).addGap(45, 45, 45)));
    		jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
    				.addGroup(jPanel1Layout.createSequentialGroup().addGap(23, 23, 23)
    						.addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
    								.addComponent(jButton1).addComponent(jLabel1).addComponent(bookNameText,
    										GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
    										GroupLayout.PREFERRED_SIZE))
    						.addContainerGap(30, Short.MAX_VALUE)));
    
    		jB_borrow.setText("借书");
    		jB_borrow.addActionListener(new java.awt.event.ActionListener() {
    			public void actionPerformed(java.awt.event.ActionEvent evt) {
    				jB_borrowActionPerformed(evt);
    			}
    		});
    
    		jLabel2.setText("编号:");
    
    		bookIdText.setEditable(false);
    
    		jLabel3.setText("书名:");
    
    		bookName.setEditable(false);
    
    		GroupLayout layout = new GroupLayout(getContentPane());
    		getContentPane().setLayout(layout);
    		layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout
    				.createSequentialGroup().addGap(22, 22, 22)
    				.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout
    						.createSequentialGroup().addComponent(jLabel2)
    						.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
    						.addComponent(bookIdText, GroupLayout.PREFERRED_SIZE, 95,
    								GroupLayout.PREFERRED_SIZE)
    						.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel3)
    						.addGap(18, 18, 18)
    						.addComponent(bookName, GroupLayout.PREFERRED_SIZE, 127,
    								GroupLayout.PREFERRED_SIZE)
    						.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 102, Short.MAX_VALUE)
    						.addComponent(jB_borrow).addGap(88, 88, 88))
    						.addGroup(layout.createSequentialGroup()
    								.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
    										.addComponent(jPanel1, GroupLayout.Alignment.TRAILING,
    												GroupLayout.DEFAULT_SIZE,
    												GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    										.addComponent(jScrollPane1, GroupLayout.Alignment.TRAILING,
    												GroupLayout.DEFAULT_SIZE, 507, Short.MAX_VALUE))
    								.addContainerGap(38, Short.MAX_VALUE)))));
    		layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
    				.addGroup(layout.createSequentialGroup()
    						.addComponent(jPanel1, GroupLayout.PREFERRED_SIZE,
    								GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
    						.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
    						.addComponent(jScrollPane1, GroupLayout.PREFERRED_SIZE, 225,
    								GroupLayout.PREFERRED_SIZE)
    						.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 35, Short.MAX_VALUE)
    						.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
    								.addComponent(jLabel2).addComponent(jLabel3)
    								.addComponent(bookIdText, GroupLayout.PREFERRED_SIZE,
    										GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
    								.addComponent(bookName, GroupLayout.PREFERRED_SIZE,
    										GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
    								.addComponent(jB_borrow))
    						.addGap(27, 27, 27)));
    
    		pack();
    	}
    		
    
    	private void jB_borrowActionPerformed(java.awt.event.ActionEvent evt) {
    		String bookId = this.bookIdText.getText();
    		String bookName = this.bookName.getText();
    		if (StringUtil.isEmpty(bookId) || StringUtil.isEmpty(bookName)) {
    			JOptionPane.showMessageDialog(null, "请选择相关书籍");
    			return;
    		}
    		BorrowDetail borrowDetail = new BorrowDetail();
    		borrowDetail.setUserId(LoginFrm.currentUser.getUserId());
    		borrowDetail.setBookId(Integer.parseInt(bookId));
    		borrowDetail.setStatus(1);
    		borrowDetail.setBorrowTime(TimeUtil.getTime());
    		Connection con = null;
    		try {
    			con = dbUtil.getCon();
    
    			// 先查询是否有该书在借
    			ResultSet list = borrowDetailDao.list(con, borrowDetail);
    			while (list.next()) {
    				JOptionPane.showMessageDialog(null, "该书已在借,请先还再借");
    				return;
    			}
    			int i = borrowDetailDao.add(con, borrowDetail);
    			if (i == 1) {
    				JOptionPane.showMessageDialog(null, "借书成功");
    			} else {
    				JOptionPane.showMessageDialog(null, "借书失败");
    			}
    		} catch (Exception e) {
    			
    			e.printStackTrace();
    			JOptionPane.showMessageDialog(null, "借书异常");
    		} finally {
    			try {
    				dbUtil.closeCon(con);
    			} catch (Exception e) {
    				
    				e.printStackTrace();
    			}
    		}
    
    	}
    
    	private void bookTableMousePressed(java.awt.event.MouseEvent evt) {
    		int row = this.bookTable.getSelectedRow();
    		Object bookId = this.bookTable.getValueAt(row, 0);
    		Object bookName = this.bookTable.getValueAt(row, 1);
    		this.bookIdText.setText(bookId.toString());
    		this.bookName.setText(bookName.toString());
    	}
    
    	private void bookNameTextActionPerformed(java.awt.event.ActionEvent evt) {
    	}
    
    	private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    		String bookName = this.bookNameText.getText();
    		Book book = new Book();
    		book.setBookName(bookName);
    		fillTable(book);
    	}
    
    }
    

    BookTypeAddFrm.java

    package com.sjsq.view;
    
    import java.sql.Connection;
    
    import javax.swing.GroupLayout;
    import javax.swing.JButton;
    import javax.swing.JInternalFrame;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JScrollPane;
    import javax.swing.JTextArea;
    import javax.swing.JTextField;
    
    import com.sjsq.dao.BookTypeDao;
    import com.sjsq.model.BookType;
    import com.sjsq.util.DbUtil;
    import com.sjsq.util.StringUtil;
    
    public class BookTypeAddFrm extends JInternalFrame {
    	
    	private JButton jButton1;
    	private JButton jButton2;
    	private JLabel jLabel1;
    	private JLabel jLabel2;
    	private JScrollPane jScrollPane1;
    	private JTextField typeNameText;
    	private JTextArea typeRemarkTtext;
    	
    	DbUtil dbUtil = new DbUtil();
    	BookTypeDao bookTypeDao = new BookTypeDao();
    
    	
    	public BookTypeAddFrm() {
    		initComponents();
    		setTitle("图书类别添加");
    		this.setLocation(200, 50);
    	}
    
    	
    	private void initComponents() {
    
    		jLabel1 = new JLabel();
    		jLabel2 = new JLabel();
    		jButton1 = new JButton();
    		typeNameText = new JTextField();
    		jScrollPane1 = new JScrollPane();
    		typeRemarkTtext = new JTextArea();
    		jButton2 = new JButton();
    
    		setClosable(true);
    
    		jLabel1.setText("图书类别名称:");
    
    		jLabel2.setText("类别说明:");
    
    		jButton1.setText("添加");
    		jButton1.addActionListener(new java.awt.event.ActionListener() {
    			public void actionPerformed(java.awt.event.ActionEvent evt) {
    				jButton1ActionPerformed(evt);
    			}
    		});
    
    		typeRemarkTtext.setColumns(20);
    		typeRemarkTtext.setRows(5);
    		jScrollPane1.setViewportView(typeRemarkTtext);
    
    		jButton2.setText("重置");
    		jButton2.addActionListener(new java.awt.event.ActionListener() {
    			public void actionPerformed(java.awt.event.ActionEvent evt) {
    				jButton2ActionPerformed(evt);
    			}
    		});
    
    		GroupLayout layout = new GroupLayout(getContentPane());
    		getContentPane().setLayout(layout);
    		layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
    				.addGroup(layout.createSequentialGroup().addGap(49, 49, 49)
    						.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
    								.addGroup(layout.createSequentialGroup().addComponent(jLabel2).addGap(18, 18, 18)
    										.addComponent(jScrollPane1))
    								.addGroup(layout.createSequentialGroup().addComponent(jLabel1).addGap(18, 18, 18)
    										.addComponent(typeNameText, GroupLayout.PREFERRED_SIZE, 241,
    												GroupLayout.PREFERRED_SIZE))
    								.addGroup(layout.createSequentialGroup().addComponent(jButton1).addGap(53, 53, 53)
    										.addComponent(jButton2)))
    						.addGap(179, 179, 179)));
    		layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout
    				.createSequentialGroup().addGap(35, 35, 35)
    				.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(jLabel1)
    						.addComponent(typeNameText, GroupLayout.PREFERRED_SIZE,
    								GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
    				.addGap(43, 43, 43)
    				.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(jLabel2)
    						.addComponent(jScrollPane1, GroupLayout.PREFERRED_SIZE, 134,
    								GroupLayout.PREFERRED_SIZE))
    				.addGap(41, 41, 41).addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
    						.addComponent(jButton1).addComponent(jButton2))
    				.addContainerGap(62, Short.MAX_VALUE)));
    
    		pack();
    	}
    		
    
    	private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    		String typeName = this.typeNameText.getText();
    		String typeRemark = this.typeRemarkTtext.getText();
    		if (StringUtil.isEmpty(typeName) || StringUtil.isEmpty(typeRemark)) {
    			JOptionPane.showMessageDialog(null, "请输入相关信息");
    			return;
    		}
    		BookType bookType = new BookType();
    		bookType.setTypeName(typeName);
    		bookType.setRemark(typeRemark);
    		Connection con = null;
    		try {
    			con = dbUtil.getCon();
    			int i = bookTypeDao.add(con, bookType);
    			if (i == 1) {
    				JOptionPane.showMessageDialog(null, "添加成功");
    				reset();
    			} else if (i == 2) {
    				JOptionPane.showMessageDialog(null, "添加失败,类别已存在");
    			} else {
    				JOptionPane.showMessageDialog(null, "添加失败");
    			}
    		} catch (Exception e) {
    			
    			e.printStackTrace();
    		} finally {
    			try {
    				dbUtil.closeCon(con);
    			} catch (Exception e) {
    				
    				e.printStackTrace();
    			}
    		}
    	}
    
    	private void reset() {
    		this.typeNameText.setText("");
    		this.typeRemarkTtext.setText("");
    	}
    
    	private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
    		reset();
    	}
    
    }
    

    BookTypeManagerFrm.java

    package com.sjsq.view;
    
    import java.sql.Connection;
    import java.sql.ResultSet;
    import java.util.Vector;
    
    import javax.swing.BorderFactory;
    import javax.swing.GroupLayout;
    import javax.swing.JButton;
    import javax.swing.JInternalFrame;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.JTextField;
    import javax.swing.LayoutStyle;
    import javax.swing.table.DefaultTableModel;
    
    import com.sjsq.dao.BookTypeDao;
    import com.sjsq.model.BookType;
    import com.sjsq.util.DbUtil;
    import com.sjsq.util.StringUtil;
    
    public class BookTypeManagerFrm extends JInternalFrame {
    	
    	private JButton jButton1;
    	private JButton jButton2;
    	private JLabel jLabel1;
    	private JLabel jLabel2;
    	private JLabel jLabel3;
    	private JPanel jPanel1;
    	private JScrollPane jScrollPane1;
    	private JTextField typeIdText;
    	private JTextField typeNameText;
    	private JTextField typeRemarkText;
    	private JTable typeTable;
    	
    	
    	DbUtil dbUtil = new DbUtil();
    	BookTypeDao bookTypeDao = new BookTypeDao();
    
    	
    	public BookTypeManagerFrm() {
    		initComponents();
    		fillTable();
    		setTitle("图书类别修改");
    		this.setLocation(200, 30);
    	}
    
    	private void fillTable() {
    		DefaultTableModel model = (DefaultTableModel) typeTable.getModel();
    		model.setRowCount(0);
    		Connection con = null;
    		try {
    			con = dbUtil.getCon();
    			ResultSet list = bookTypeDao.list(con, new BookType());
    			while (list.next()) {
    				Vector rowData = new Vector();
    				rowData.add(list.getInt("id"));
    				rowData.add(list.getString("type_name"));
    				rowData.add(list.getString("remark"));
    				model.addRow(rowData);
    			}
    		} catch (Exception e) {
    			
    			e.printStackTrace();
    		} finally {
    			try {
    				dbUtil.closeCon(con);
    			} catch (Exception e) {
    				
    				e.printStackTrace();
    			}
    		}
    	}
    	
    	private void initComponents() {
    
    		jScrollPane1 = new JScrollPane();
    		typeTable = new JTable();
    		jPanel1 = new JPanel();
    		jLabel1 = new JLabel();
    		jLabel2 = new JLabel();
    		jLabel3 = new JLabel();
    		typeIdText = new JTextField();
    		typeNameText = new JTextField();
    		typeRemarkText = new JTextField();
    		jButton1 = new JButton();
    		jButton2 = new JButton();
    
    		setClosable(true);
    
    		typeTable.setModel(new DefaultTableModel(new Object[][] {
    
    		}, new String[] { "编号", "类别名称", "类别描述" }) {
    			boolean[] canEdit = new boolean[] { false, false, false };
    
    			public boolean isCellEditable(int rowIndex, int columnIndex) {
    				return canEdit[columnIndex];
    			}
    		});
    		typeTable.addMouseListener(new java.awt.event.MouseAdapter() {
    			public void mousePressed(java.awt.event.MouseEvent evt) {
    				typeTableMousePressed(evt);
    			}
    		});
    		jScrollPane1.setViewportView(typeTable);
    
    		jPanel1.setBorder(BorderFactory.createTitledBorder("表单操作"));
    		jPanel1.setToolTipText("");
    
    		jLabel1.setText("编号:");
    
    		jLabel2.setText("类别名称:");
    
    		jLabel3.setText("描述:");
    
    		typeIdText.setEditable(false);
    
    		jButton1.setText("修改");
    		jButton1.addActionListener(new java.awt.event.ActionListener() {
    			public void actionPerformed(java.awt.event.ActionEvent evt) {
    				jButton1ActionPerformed(evt);
    			}
    		});
    
    		jButton2.setText("删除");
    		jButton2.addActionListener(new java.awt.event.ActionListener() {
    			public void actionPerformed(java.awt.event.ActionEvent evt) {
    				jButton2ActionPerformed(evt);
    			}
    		});
    
    		GroupLayout jPanel1Layout = new GroupLayout(jPanel1);
    		jPanel1.setLayout(jPanel1Layout);
    		jPanel1Layout.setHorizontalGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
    				.addGroup(jPanel1Layout.createSequentialGroup().addGroup(jPanel1Layout
    						.createParallelGroup(GroupLayout.Alignment.LEADING)
    						.addGroup(jPanel1Layout.createSequentialGroup().addGap(22, 22, 22).addGroup(jPanel1Layout
    								.createParallelGroup(GroupLayout.Alignment.LEADING, false)
    								.addGroup(jPanel1Layout.createSequentialGroup().addComponent(jLabel3).addGap(18, 18, 18)
    										.addComponent(typeRemarkText))
    								.addGroup(jPanel1Layout.createSequentialGroup().addComponent(jLabel1).addGap(18, 18, 18)
    										.addComponent(typeIdText, GroupLayout.PREFERRED_SIZE, 123,
    												GroupLayout.PREFERRED_SIZE)
    										.addGap(18, 18, 18)
    										.addGroup(jPanel1Layout
    												.createParallelGroup(GroupLayout.Alignment.LEADING)
    												.addComponent(jButton2)
    												.addGroup(jPanel1Layout.createSequentialGroup().addComponent(jLabel2)
    														.addGap(18, 18, 18).addComponent(typeNameText,
    																GroupLayout.PREFERRED_SIZE, 133,
    																GroupLayout.PREFERRED_SIZE))))))
    						.addGroup(jPanel1Layout.createSequentialGroup().addGap(41, 41, 41).addComponent(jButton1)))
    						.addContainerGap(43, Short.MAX_VALUE)));
    		jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
    				.addGroup(jPanel1Layout.createSequentialGroup().addGroup(jPanel1Layout
    						.createParallelGroup(GroupLayout.Alignment.LEADING)
    						.addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
    								.addComponent(jLabel1).addComponent(jLabel2).addComponent(typeNameText,
    										GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
    										GroupLayout.PREFERRED_SIZE))
    						.addComponent(typeIdText, GroupLayout.PREFERRED_SIZE,
    								GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
    						.addGap(27, 27, 27)
    						.addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
    								.addComponent(jLabel3).addComponent(typeRemarkText,
    										GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
    										GroupLayout.PREFERRED_SIZE))
    						.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 41, Short.MAX_VALUE)
    						.addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
    								.addComponent(jButton1).addComponent(jButton2))
    						.addContainerGap()));
    
    		GroupLayout layout = new GroupLayout(getContentPane());
    		getContentPane().setLayout(layout);
    		layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout
    				.createSequentialGroup().addGap(42, 42, 42)
    				.addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
    						.addComponent(jPanel1, GroupLayout.Alignment.LEADING,
    								GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE,
    								Short.MAX_VALUE)
    						.addComponent(jScrollPane1, GroupLayout.Alignment.LEADING,
    								GroupLayout.PREFERRED_SIZE, 452, GroupLayout.PREFERRED_SIZE))
    				.addContainerGap(49, Short.MAX_VALUE)));
    		layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
    				.addGroup(layout.createSequentialGroup().addContainerGap()
    						.addComponent(jScrollPane1, GroupLayout.PREFERRED_SIZE, 137,
    								GroupLayout.PREFERRED_SIZE)
    						.addGap(51, 51, 51)
    						.addComponent(jPanel1, GroupLayout.PREFERRED_SIZE,
    								GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
    						.addContainerGap(30, Short.MAX_VALUE)));
    
    		pack();
    	}
    		
    
    	private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
    		String typeId = this.typeIdText.getText();
    		if (StringUtil.isEmpty(typeId)) {
    			JOptionPane.showMessageDialog(null, "请选择相关信息");
    			return;
    		}
    		Connection con = null;
    		try {
    			con = dbUtil.getCon();
    			int i = bookTypeDao.delete(con, typeId);
    			if (i == 1) {
    				JOptionPane.showMessageDialog(null, "删除成功");
    				fillTable();
    			} else if (i == 2) {
    				JOptionPane.showMessageDialog(null, "删除失败-类别最少保留一个");
    			} else if (i == 3) {
    				JOptionPane.showMessageDialog(null, "删除失败-该类别下有书籍");
    			} else {
    				JOptionPane.showMessageDialog(null, "删除失败");
    			}
    		} catch (Exception e) {
    			
    			e.printStackTrace();
    			JOptionPane.showMessageDialog(null, "删除异常");
    		} finally {
    			try {
    				dbUtil.closeCon(con);
    			} catch (Exception e) {
    				
    				e.printStackTrace();
    			}
    		}
    	}
    
    	private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    		String typeId = this.typeIdText.getText();
    		String typeName = this.typeNameText.getText();
    		String typeRemark = this.typeRemarkText.getText();
    		if (StringUtil.isEmpty(typeName) || StringUtil.isEmpty(typeRemark)) {
    			JOptionPane.showMessageDialog(null, "请输入相关信息");
    			return;
    		}
    		BookType bookType = new BookType();
    		bookType.setTypeId(Integer.parseInt(typeId));
    		bookType.setTypeName(typeName);
    		bookType.setRemark(typeRemark);
    		Connection con = null;
    		try {
    			con = dbUtil.getCon();
    			int i = bookTypeDao.update(con, bookType);
    			if (i == 1) {
    				JOptionPane.showMessageDialog(null, "修改成功");
    				fillTable();
    			} else {
    				JOptionPane.showMessageDialog(null, "修改失败");
    			}
    		} catch (Exception e) {
    			
    			e.printStackTrace();
    			JOptionPane.showMessageDialog(null, "修改异常");
    		} finally {
    			try {
    				dbUtil.closeCon(con);
    			} catch (Exception e) {
    				
    				e.printStackTrace();
    			}
    		}
    	}
    
    	private void typeTableMousePressed(java.awt.event.MouseEvent evt) {
    		int row = this.typeTable.getSelectedRow();
    		this.typeIdText.setText(typeTable.getValueAt(row, 0).toString());
    		this.typeNameText.setText(typeTable.getValueAt(row, 1).toString());
    		this.typeRemarkText.setText(typeTable.getValueAt(row, 2).toString());
    	}
    
    }
    

    BorrowDetailFrm.java

    package com.sjsq.view;
    
    import java.sql.Connection;
    import java.sql.ResultSet;
    import java.util.Vector;
    
    import javax.swing.GroupLayout;
    import javax.swing.JInternalFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.table.DefaultTableModel;
    
    import com.sjsq.dao.BorrowDetailDao;
    import com.sjsq.model.BorrowDetail;
    import com.sjsq.util.DbUtil;
    import com.sjsq.util.TimeUtil;
    
    public class BorrowDetailFrm extends JInternalFrame {
    	
    	private JTable detailTable;
    	private JScrollPane jScrollPane1;
    	
    	
    	DbUtil dbUtil = new DbUtil();
    	BorrowDetailDao borrowDetailDao = new BorrowDetailDao();
    
    	
    	public BorrowDetailFrm() {
    		initComponents();
    		fillTable(new BorrowDetail());
    		setTitle("借还信息");
    		this.setLocation(200, 50);
    	}
    
    	private void fillTable(BorrowDetail borrowDetail) {
    		DefaultTableModel model = (DefaultTableModel) detailTable.getModel();
    		model.setRowCount(0);
    		Connection con = null;
    		try {
    			con = dbUtil.getCon();
    			ResultSet list = borrowDetailDao.list(con, borrowDetail);
    			while (list.next()) {
    				Vector rowData = new Vector();
    				rowData.add(list.getString("username"));
    				rowData.add(list.getString("book_name"));
    				int status = list.getInt("status");
    				if (status == 1) {
    					rowData.add("在借");
    				} else {
    					rowData.add("已还");
    				}
    				rowData.add(TimeUtil.getDateByTime(list.getLong("borrow_time")));
    				if (status == 2) {
    					rowData.add(TimeUtil.getDateByTime(list.getLong("return_time")));
    				}
    				model.addRow(rowData);
    			}
    		} catch (Exception e) {
    			
    			e.printStackTrace();
    		} finally {
    			try {
    				dbUtil.closeCon(con);
    			} catch (Exception e) {
    				
    				e.printStackTrace();
    			}
    		}
    	}
    
    	
    	private void initComponents() {
    
    		jScrollPane1 = new JScrollPane();
    		detailTable = new JTable();
    
    		setClosable(true);
    
    		detailTable.setModel(new DefaultTableModel(new Object[][] {
    
    		}, new String[] { "借书人", "书名", "状态", "借书时间", "还书时间" }) {
    			boolean[] canEdit = new boolean[] { false, false, false, false, false };
    
    			public boolean isCellEditable(int rowIndex, int columnIndex) {
    				return canEdit[columnIndex];
    			}
    		});
    		jScrollPane1.setViewportView(detailTable);
    
    		GroupLayout layout = new GroupLayout(getContentPane());
    		getContentPane().setLayout(layout);
    		layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
    				.addGroup(layout.createSequentialGroup().addContainerGap()
    						.addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 700, Short.MAX_VALUE)
    						.addContainerGap()));
    		layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
    				.addGroup(layout
    						.createSequentialGroup().addContainerGap().addComponent(jScrollPane1,
    								GroupLayout.PREFERRED_SIZE, 366, GroupLayout.PREFERRED_SIZE)
    						.addContainerGap(25, Short.MAX_VALUE)));
    
    		pack();
    	}
    		
    }
    

    LoginFrm.java

    package com.sjsq.view;
    
    import java.sql.Connection;
    
    import javax.swing.GroupLayout;
    import javax.swing.JButton;
    import javax.swing.JComboBox;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JTextField;
    import javax.swing.LayoutStyle;
    import javax.swing.WindowConstants;
    
    import com.sjsq.dao.UserDao;
    import com.sjsq.model.User;
    import com.sjsq.util.DbUtil;
    import com.sjsq.util.StringUtil;
    
    public class LoginFrm extends JFrame {
    	public static User currentUser;
    	private JButton jB_login;
    	private JButton jB_reset;
    	private JLabel jLabel1;
    	private JLabel jLabel2;
    	private JLabel jLabel3;
    	private JTextField passwordText;
    	private JComboBox role;
    	private JTextField userNameText;
    	
    	UserDao userDao = new UserDao();
    	DbUtil dbUtil = new DbUtil();
    
    	
    	public LoginFrm() {
    		initComponents();
    		this.role.addItem("学生");
    		this.role.addItem("管理员");
    		this.setLocationRelativeTo(null);
    	}
    
    	
    	private void initComponents() {
    
    		jLabel1 = new JLabel();
    		jLabel2 = new JLabel();
    		jLabel3 = new JLabel();
    		jB_login = new JButton();
    		jB_reset = new JButton();
    		userNameText = new JTextField();
    		passwordText = new JTextField();
    		role = new JComboBox();
    
    		setTitle("用户登录");
    		setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    		setResizable(false);
    
    		jLabel1.setText("账号:");
    
    		jLabel2.setText("密码:");
    
    		jLabel3.setText("角色:");
    
    		jB_login.setText("登录");
    		jB_login.addActionListener(new java.awt.event.ActionListener() {
    			public void actionPerformed(java.awt.event.ActionEvent evt) {
    				jB_loginActionPerformed(evt);
    			}
    		});
    
    		jB_reset.setText("重置");
    		jB_reset.addActionListener(new java.awt.event.ActionListener() {
    			public void actionPerformed(java.awt.event.ActionEvent evt) {
    				jB_resetActionPerformed(evt);
    			}
    		});
    
    		GroupLayout layout = new GroupLayout(getContentPane());
    		getContentPane().setLayout(layout);
    		layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout
    				.createSequentialGroup().addGap(59, 59, 59)
    				.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
    						.addGroup(layout.createSequentialGroup().addComponent(jB_login).addGap(87, 87, 87)
    								.addComponent(jB_reset))
    						.addGroup(layout.createSequentialGroup()
    								.addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
    										.addComponent(jLabel3).addComponent(jLabel2).addComponent(jLabel1))
    								.addGap(18, 18, 18)
    								.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
    										.addComponent(userNameText, GroupLayout.DEFAULT_SIZE, 150,
    												Short.MAX_VALUE)
    										.addComponent(passwordText)
    										.addComponent(role, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
    				.addContainerGap(137, Short.MAX_VALUE)));
    		layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout
    				.createSequentialGroup().addGap(49, 49, 49)
    				.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(jLabel1)
    						.addComponent(userNameText, GroupLayout.PREFERRED_SIZE,
    								GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
    				.addGap(45, 45, 45)
    				.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(jLabel2)
    						.addComponent(passwordText, GroupLayout.PREFERRED_SIZE,
    								GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
    				.addGap(33, 33, 33)
    				.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(jLabel3)
    						.addComponent(role, GroupLayout.PREFERRED_SIZE,
    								GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
    				.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 42, Short.MAX_VALUE)
    				.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(jB_login)
    						.addComponent(jB_reset))
    				.addGap(37, 37, 37)));
    
    		pack();
    	}
    
    	
    
    	private void jB_loginActionPerformed(java.awt.event.ActionEvent evt) {
    		String userName = this.userNameText.getText();
    		String password = this.passwordText.getText();
    		int index = this.role.getSelectedIndex();
    		if (StringUtil.isEmpty(userName) || StringUtil.isEmpty(password)) {
    			JOptionPane.showMessageDialog(null, "请输入相关信息");
    			return;
    		}
    		User user = new User();
    		user.setUserName(userName);
    		user.setPassword(password);
    		if (index == 0) {
    			user.setRole(1);
    		} else {
    			user.setRole(2);
    		}
    		Connection con = null;
    		try {
    			con = dbUtil.getCon();
    			User login = userDao.login(con, user);
    			currentUser = login;
    			if (login == null) {
    				JOptionPane.showMessageDialog(null, "登录失败");
    			} else {
    				// 角色 1普通 2管理员
    				if (index == 0) {
    					// 学生
    					this.dispose();
    					new UserMainFrm().setVisible(true);
    				} else {
    					// 管理员
    					
    					this.dispose();
    					new AdminMainFrm().setVisible(true);
    				}
    			}
    		} catch (Exception e) {
    			
    			e.printStackTrace();
    			JOptionPane.showMessageDialog(null, "登录异常");
    		} finally {
    			try {
    				dbUtil.closeCon(con);
    			} catch (Exception e) {
    				
    				e.printStackTrace();
    			}
    		}
    
    	}
    
    	private void reset() {
    		this.userNameText.setText("");
    		this.passwordText.setText("");
    	}
    
    	private void jB_resetActionPerformed(java.awt.event.ActionEvent evt) {
    		reset();
    	}
    
    	public static void main(String args[]) {
    		java.awt.EventQueue.invokeLater(new Runnable() {
    			public void run() {
    				new LoginFrm().setVisible(true);
    			}
    		});
    	}
    
    }
    

    RegisterFrm.java

    package com.sjsq.view;
    
    import java.sql.Connection;
    
    import javax.swing.GroupLayout;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JTextField;
    import javax.swing.LayoutStyle;
    import javax.swing.WindowConstants;
    
    import com.sjsq.dao.UserDao;
    import com.sjsq.model.User;
    import com.sjsq.util.DbUtil;
    import com.sjsq.util.StringUtil;
    
    public class RegisterFrm extends JFrame {
    	
    	private JButton jButton1;
    	private JButton jButton2;
    	private JLabel jLabel1;
    	private JLabel jLabel2;
    	private JTextField passwordText;
    	private JTextField userNameText;
    	
    	
    	DbUtil dbUtil = new DbUtil();
    	UserDao userDao = new UserDao();
    
    	
    	public RegisterFrm() {
    		initComponents();
    		this.setLocationRelativeTo(null);
    	}
    
    	
    	private void initComponents() {
    
    		jLabel1 = new JLabel();
    		jLabel2 = new JLabel();
    		jButton1 = new JButton();
    		jButton2 = new JButton();
    		userNameText = new JTextField();
    		passwordText = new JTextField();
    
    		setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    		setTitle("用户注册");
    		setResizable(false);
    
    		jLabel1.setText("账号:");
    
    		jLabel2.setText("密码:");
    
    		jButton1.setText("注册");
    		jButton1.addActionListener(new java.awt.event.ActionListener() {
    			public void actionPerformed(java.awt.event.ActionEvent evt) {
    				jButton1ActionPerformed(evt);
    			}
    		});
    
    		jButton2.setText("重置");
    		jButton2.addActionListener(new java.awt.event.ActionListener() {
    			public void actionPerformed(java.awt.event.ActionEvent evt) {
    				jButton2ActionPerformed(evt);
    			}
    		});
    
    		GroupLayout layout = new GroupLayout(getContentPane());
    		getContentPane().setLayout(layout);
    		layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout
    				.createSequentialGroup().addGap(60, 60, 60)
    				.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
    						.addGroup(layout.createSequentialGroup().addComponent(jButton1).addGap(77, 77, 77)
    								.addComponent(jButton2))
    						.addGroup(layout.createSequentialGroup()
    								.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
    										.addComponent(jLabel1).addComponent(jLabel2))
    								.addGap(37, 37, 37)
    								.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
    										.addComponent(passwordText).addComponent(userNameText,
    												GroupLayout.DEFAULT_SIZE, 144, Short.MAX_VALUE))))
    				.addContainerGap(123, Short.MAX_VALUE)));
    		layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout
    				.createSequentialGroup().addGap(49, 49, 49)
    				.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(jLabel1)
    						.addComponent(userNameText, GroupLayout.PREFERRED_SIZE,
    								GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
    				.addGap(48, 48, 48)
    				.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(jLabel2)
    						.addComponent(passwordText, GroupLayout.PREFERRED_SIZE,
    								GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
    				.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 68, Short.MAX_VALUE)
    				.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(jButton1)
    						.addComponent(jButton2))
    				.addGap(64, 64, 64)));
    
    		pack();
    	}
    		
    
    	private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    		String userName = this.userNameText.getText();
    		String password = this.passwordText.getText();
    		if (StringUtil.isEmpty(userName) || StringUtil.isEmpty(password)) {
    			JOptionPane.showMessageDialog(null, "请输入相关信息");
    			return;
    		}
    		User user = new User();
    		user.setUserName(userName);
    		user.setPassword(password);
    		user.setRole(1);
    		Connection con = null;
    		try {
    			con = dbUtil.getCon();
    			int i = userDao.addUser(con, user);
    			if (i == 2) {
    				JOptionPane.showMessageDialog(null, "该用户名已存在,请重新注册");
    			} else if (i == 0) {
    				JOptionPane.showMessageDialog(null, "注册失败");
    			} else {
    				JOptionPane.showMessageDialog(null, "注册成功");
    				this.dispose();
    				new LoginFrm().setVisible(true);
    			}
    		} catch (Exception e) {
    			
    			e.printStackTrace();
    		} finally {
    			try {
    				dbUtil.closeCon(con);
    			} catch (Exception e) {
    				
    				e.printStackTrace();
    			}
    		}
    	}
    
    	private void reset() {
    		this.userNameText.setText("");
    		this.passwordText.setText("");
    	}
    
    	private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
    		reset();
    	}
    
    	public static void main(String args[]) {
    		java.awt.EventQueue.invokeLater(new Runnable() {
    			public void run() {
    				new RegisterFrm().setVisible(true);
    			}
    		});
    	}
    
    }
    

    UserBorrowDetail.java

    package com.sjsq.view;
    
    import java.sql.Connection;
    import java.sql.ResultSet;
    import java.util.Vector;
    
    import javax.swing.GroupLayout;
    import javax.swing.JButton;
    import javax.swing.JInternalFrame;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.JTextField;
    import javax.swing.LayoutStyle;
    import javax.swing.table.DefaultTableModel;
    
    import com.sjsq.dao.BorrowDetailDao;
    import com.sjsq.model.BorrowDetail;
    import com.sjsq.util.DbUtil;
    import com.sjsq.util.StringUtil;
    import com.sjsq.util.TimeUtil;
    
    public class UserBorrowDetail extends JInternalFrame {
    	
    	private JTextField borrowIdText;
    	private JTable borrowTbale;
    	private JButton jB_return;
    	private JLabel jLabel1;
    	private JScrollPane jScrollPane1;
    	
    	
    	DbUtil dbUtil = new DbUtil();
    	BorrowDetailDao borrowDetailDao = new BorrowDetailDao();
    
    	
    	public UserBorrowDetail() {
    		initComponents();
    		fillTable(new BorrowDetail());
    		this.jB_return.setVisible(false);
    		setTitle("借还信息");
    		this.setLocation(200, 50);
    	}
    
    	private void fillTable(BorrowDetail borrowDetail) {
    		DefaultTableModel model = (DefaultTableModel) borrowTbale.getModel();
    		model.setRowCount(0);
    		Integer userId = LoginFrm.currentUser.getUserId();
    		Connection con = null;
    		try {
    			con = dbUtil.getCon();
    			borrowDetail.setUserId(userId);
    			ResultSet list = borrowDetailDao.list(con, borrowDetail);
    			while (list.next()) {
    				Vector rowData = new Vector();
    				rowData.add(list.getInt("id"));
    				rowData.add(list.getString("book_name"));
    				int status = list.getInt("status");
    				if (status == 1) {
    					rowData.add("在借");
    				}
    				if (status == 2) {
    					rowData.add("已还");
    				}
    				rowData.add(TimeUtil.getDateByTime(list.getLong("borrow_time")));
    				if (status == 2) {
    					rowData.add(TimeUtil.getDateByTime(list.getLong("return_time")));
    				}
    				model.addRow(rowData);
    			}
    		} catch (Exception e) {
    			
    			e.printStackTrace();
    		} finally {
    			try {
    				dbUtil.closeCon(con);
    			} catch (Exception e) {
    				
    				e.printStackTrace();
    			}
    		}
    	}
    	
    	private void initComponents() {
    
    		jScrollPane1 = new JScrollPane();
    		borrowTbale = new JTable();
    		jLabel1 = new JLabel();
    		borrowIdText = new JTextField();
    		jB_return = new JButton();
    
    		setClosable(true);
    
    		borrowTbale.setModel(new DefaultTableModel(new Object[][] {
    
    		}, new String[] { "编号", "书名", "状态", "借书时间", "还书时间" }) {
    			boolean[] canEdit = new boolean[] { false, false, false, false, false };
    
    			public boolean isCellEditable(int rowIndex, int columnIndex) {
    				return canEdit[columnIndex];
    			}
    		});
    		borrowTbale.addMouseListener(new java.awt.event.MouseAdapter() {
    			public void mousePressed(java.awt.event.MouseEvent evt) {
    				borrowTbaleMousePressed(evt);
    			}
    		});
    		jScrollPane1.setViewportView(borrowTbale);
    
    		jLabel1.setText("编号:");
    
    		borrowIdText.setEditable(false);
    
    		jB_return.setText("还书");
    		jB_return.addActionListener(new java.awt.event.ActionListener() {
    			public void actionPerformed(java.awt.event.ActionEvent evt) {
    				jB_returnActionPerformed(evt);
    			}
    		});
    
    		GroupLayout layout = new GroupLayout(getContentPane());
    		getContentPane().setLayout(layout);
    		layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
    				.addGroup(layout.createSequentialGroup().addGap(35, 35, 35).addComponent(jLabel1).addGap(38, 38, 38)
    						.addComponent(borrowIdText, GroupLayout.PREFERRED_SIZE, 114,
    								GroupLayout.PREFERRED_SIZE)
    						.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 282, Short.MAX_VALUE)
    						.addComponent(jB_return).addGap(44, 44, 44))
    				.addGroup(layout.createSequentialGroup().addContainerGap()
    						.addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 700, Short.MAX_VALUE)
    						.addContainerGap()));
    		layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout
    				.createSequentialGroup()
    				.addComponent(jScrollPane1, GroupLayout.PREFERRED_SIZE, 239,
    						GroupLayout.PREFERRED_SIZE)
    				.addGap(18, 18, 18)
    				.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(jLabel1)
    						.addComponent(borrowIdText, GroupLayout.PREFERRED_SIZE,
    								GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
    						.addComponent(jB_return))
    				.addContainerGap(26, Short.MAX_VALUE)));
    
    		pack();
    	}
    		
    
    	private void jB_returnActionPerformed(java.awt.event.ActionEvent evt) {
    		String BorrowStr = this.borrowIdText.getText();
    		if (StringUtil.isEmpty(BorrowStr)) {
    			JOptionPane.showMessageDialog(null, "请选择未还的书籍");
    			return;
    		}
    		BorrowDetail detail = new BorrowDetail();
    		detail.setBorrowId(Integer.parseInt(BorrowStr));
    		detail.setStatus(2);
    		detail.setReturnTime(TimeUtil.getTime());
    		Connection con = null;
    		try {
    			con = dbUtil.getCon();
    			int i = borrowDetailDao.returnBook(con, detail);
    			if (i == 1) {
    				JOptionPane.showMessageDialog(null, "还书成功");
    			} else {
    				JOptionPane.showMessageDialog(null, "还书失败");
    			}
    		} catch (Exception e) {
    			
    			e.printStackTrace();
    			JOptionPane.showMessageDialog(null, "还书异常");
    		} finally {
    			try {
    				dbUtil.closeCon(con);
    			} catch (Exception e) {
    				
    				e.printStackTrace();
    			}
    		}
    		fillTable(new BorrowDetail());
    	}
    
    	private void borrowTbaleMousePressed(java.awt.event.MouseEvent evt) {
    		int row = borrowTbale.getSelectedRow();
    		Integer borrowId = (Integer) borrowTbale.getValueAt(row, 0);
    		String status = (String) borrowTbale.getValueAt(row, 2);
    		this.borrowIdText.setText(borrowId.toString());
    		if (status.equals("在借")) {
    			this.jB_return.setVisible(true);
    		} else {
    			this.jB_return.setVisible(false);
    		}
    	}
    }
    

    UserInfoFrm.java

    package com.sjsq.view;
    
    import java.sql.Connection;
    import java.sql.ResultSet;
    import java.util.Vector;
    
    import javax.swing.BorderFactory;
    import javax.swing.GroupLayout;
    import javax.swing.JButton;
    import javax.swing.JInternalFrame;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.JTextField;
    import javax.swing.LayoutStyle;
    import javax.swing.table.DefaultTableModel;
    
    import com.sjsq.dao.UserDao;
    import com.sjsq.model.User;
    import com.sjsq.util.DbUtil;
    import com.sjsq.util.StringUtil;
    
    public class UserInfoFrm extends JInternalFrame {
    	
    	private JButton jButton1;
    	private JButton jButton2;
    	private JLabel jLabel1;
    	private JLabel jLabel2;
    	private JLabel jLabel3;
    	private JLabel jLabel4;
    	private JLabel jLabel5;
    	private JPanel jPanel1;
    	private JPanel jPanel2;
    	private JScrollPane jScrollPane1;
    	private JTextField passwordText;
    	private JTextField userIdText;
    	private JTextField userNameText;
    	private JTextField userNaneSelectText;
    	private JTable userTable;
    	
    	
    	DbUtil dbUtil = new DbUtil();
    	UserDao userDao = new UserDao();
    
    	
    	public UserInfoFrm() {
    		initComponents();
    		fillTable(new User());
    		setTitle("用户信息");
    		this.setLocation(200, 50);
    	}
    
    	private void fillTable(User user) {
    		DefaultTableModel model = (DefaultTableModel) userTable.getModel();
    		model.setRowCount(0);
    
    		Connection con = null;
    		try {
    			con = dbUtil.getCon();
    			ResultSet list = userDao.list(con, user);
    			while (list.next()) {
    				Vector rowData = new Vector();
    				rowData.add(list.getInt("id"));
    				rowData.add(list.getString("username"));
    				rowData.add(list.getString("password"));
    				model.addRow(rowData);
    			}
    		} catch (Exception e) {
    			
    			e.printStackTrace();
    		} finally {
    			try {
    				dbUtil.closeCon(con);
    			} catch (Exception e) {
    				
    				e.printStackTrace();
    			}
    		}
    	}
    
    	
    	private void initComponents() {
    
    		jLabel2 = new JLabel();
    		jScrollPane1 = new JScrollPane();
    		userTable = new JTable();
    		jPanel1 = new JPanel();
    		jLabel1 = new JLabel();
    		jButton1 = new JButton();
    		userNaneSelectText = new JTextField();
    		jPanel2 = new JPanel();
    		jLabel3 = new JLabel();
    		userIdText = new JTextField();
    		jLabel4 = new JLabel();
    		userNameText = new JTextField();
    		jLabel5 = new JLabel();
    		passwordText = new JTextField();
    		jButton2 = new JButton();
    
    		jLabel2.setText("jLabel2");
    
    		setClosable(true);
    
    		userTable.setModel(new DefaultTableModel(new Object[][] {
    
    		}, new String[] { "编号", "账号", "密码" }) {
    			boolean[] canEdit = new boolean[] { false, false, false };
    
    			public boolean isCellEditable(int rowIndex, int columnIndex) {
    				return canEdit[columnIndex];
    			}
    		});
    		userTable.addMouseListener(new java.awt.event.MouseAdapter() {
    			public void mousePressed(java.awt.event.MouseEvent evt) {
    				userTableMousePressed(evt);
    			}
    		});
    		jScrollPane1.setViewportView(userTable);
    
    		jPanel1.setBorder(BorderFactory.createTitledBorder("表单操作"));
    
    		jLabel1.setText("账号:");
    
    		jButton1.setText("查询");
    		jButton1.addActionListener(new java.awt.event.ActionListener() {
    			public void actionPerformed(java.awt.event.ActionEvent evt) {
    				jButton1ActionPerformed(evt);
    			}
    		});
    
    		GroupLayout jPanel1Layout = new GroupLayout(jPanel1);
    		jPanel1.setLayout(jPanel1Layout);
    		jPanel1Layout.setHorizontalGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
    				.addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addComponent(jLabel1)
    						.addGap(18, 18, 18)
    						.addComponent(userNaneSelectText, GroupLayout.DEFAULT_SIZE, 184, Short.MAX_VALUE)
    						.addGap(18, 18, 18).addComponent(jButton1).addContainerGap()));
    		jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
    				.addGroup(jPanel1Layout.createSequentialGroup().addGroup(jPanel1Layout
    						.createParallelGroup(GroupLayout.Alignment.LEADING)
    						.addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
    								.addComponent(jLabel1).addComponent(userNaneSelectText,
    										GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
    										GroupLayout.PREFERRED_SIZE))
    						.addComponent(jButton1))
    						.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    
    		jPanel2.setBorder(BorderFactory.createTitledBorder("用户操作"));
    
    		jLabel3.setText("编号:");
    
    		userIdText.setEditable(false);
    
    		jLabel4.setText("账号:");
    
    		jLabel5.setText("密码:");
    
    		jButton2.setText("修改");
    		jButton2.addActionListener(new java.awt.event.ActionListener() {
    			public void actionPerformed(java.awt.event.ActionEvent evt) {
    				jButton2ActionPerformed(evt);
    			}
    		});
    
    		GroupLayout jPanel2Layout = new GroupLayout(jPanel2);
    		jPanel2.setLayout(jPanel2Layout);
    		jPanel2Layout.setHorizontalGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
    				.addGroup(jPanel2Layout.createSequentialGroup().addContainerGap()
    						.addGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
    								.addGroup(jPanel2Layout.createSequentialGroup().addComponent(jLabel3)
    										.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
    										.addComponent(userIdText, GroupLayout.PREFERRED_SIZE, 85,
    												GroupLayout.PREFERRED_SIZE)
    										.addGap(18, 18, 18).addComponent(jLabel4))
    								.addGroup(jPanel2Layout.createSequentialGroup().addComponent(jLabel5)
    										.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
    										.addComponent(passwordText, GroupLayout.PREFERRED_SIZE, 88,
    												GroupLayout.PREFERRED_SIZE)))
    						.addGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
    								.addGroup(jPanel2Layout.createSequentialGroup().addGap(37, 37, 37).addComponent(
    										userNameText, GroupLayout.PREFERRED_SIZE, 94,
    										GroupLayout.PREFERRED_SIZE))
    								.addGroup(jPanel2Layout.createSequentialGroup().addGap(8, 8, 8).addComponent(jButton2)))
    						.addContainerGap(26, Short.MAX_VALUE)));
    		jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
    				.addGroup(jPanel2Layout.createSequentialGroup()
    						.addGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
    								.addComponent(jLabel3).addComponent(jLabel4)
    								.addComponent(userIdText, GroupLayout.PREFERRED_SIZE,
    										GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
    								.addComponent(userNameText, GroupLayout.PREFERRED_SIZE,
    										GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
    						.addGap(29, 29, 29)
    						.addGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
    								.addComponent(jLabel5)
    								.addComponent(passwordText, GroupLayout.PREFERRED_SIZE,
    										GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
    								.addComponent(jButton2))
    						.addContainerGap(37, Short.MAX_VALUE)));
    
    		GroupLayout layout = new GroupLayout(getContentPane());
    		getContentPane().setLayout(layout);
    		layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout
    				.createSequentialGroup().addGap(24, 24, 24)
    				.addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
    						.addComponent(jPanel2, GroupLayout.Alignment.LEADING,
    								GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE,
    								Short.MAX_VALUE)
    						.addComponent(jScrollPane1, GroupLayout.Alignment.LEADING, 0, 0, Short.MAX_VALUE)
    						.addComponent(jPanel1, GroupLayout.Alignment.LEADING,
    								GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE,
    								Short.MAX_VALUE))
    				.addGap(226, 226, 226)));
    		layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
    				.addGroup(layout.createSequentialGroup()
    						.addComponent(jPanel1, GroupLayout.PREFERRED_SIZE,
    								GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
    						.addGap(28, 28, 28)
    						.addComponent(jScrollPane1, GroupLayout.PREFERRED_SIZE, 136,
    								GroupLayout.PREFERRED_SIZE)
    						.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
    						.addComponent(jPanel2, GroupLayout.PREFERRED_SIZE,
    								GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
    						.addContainerGap(16, Short.MAX_VALUE)));
    
    		pack();
    	}
    		
    
    	private void userTableMousePressed(java.awt.event.MouseEvent evt) {
    		int row = this.userTable.getSelectedRow();
    		this.userIdText.setText(userTable.getValueAt(row, 0).toString());
    		this.userNameText.setText(userTable.getValueAt(row, 1).toString());
    		this.passwordText.setText(userTable.getValueAt(row, 2).toString());
    	}
    
    	private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
    		String userId = this.userIdText.getText();
    		String userName = this.userNameText.getText();
    		String password = this.passwordText.getText();
    		if (StringUtil.isEmpty(userName) || StringUtil.isEmpty(password)) {
    			JOptionPane.showMessageDialog(null, "请输入相关信息");
    			return;
    		}
    		User user = new User();
    		user.setUserId(Integer.parseInt(userId));
    		user.setUserName(userName);
    		user.setPassword(password);
    		Connection con = null;
    		try {
    			con = dbUtil.getCon();
    			int i = userDao.update(con, user);
    			if (i == 1) {
    				JOptionPane.showMessageDialog(null, "修改成功");
    				fillTable(new User());
    			} else {
    				JOptionPane.showMessageDialog(null, "修改失败");
    			}
    		} catch (Exception e) {
    			
    			e.printStackTrace();
    			JOptionPane.showMessageDialog(null, "修改异常");
    		} finally {
    			try {
    				dbUtil.closeCon(con);
    			} catch (Exception e) {
    				
    				e.printStackTrace();
    			}
    		}
    	}
    
    	private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    		String userName = this.userNaneSelectText.getText();
    		User user = new User();
    		user.setUserName(userName);
    		fillTable(user);
    	}
    
    }
    

    UserMainFrm.java

    package com.sjsq.view;
    
    import javax.swing.GroupLayout;
    import javax.swing.JDesktopPane;
    import javax.swing.JFrame;
    import javax.swing.JMenu;
    import javax.swing.JMenuBar;
    import javax.swing.JMenuItem;
    import javax.swing.JOptionPane;
    import javax.swing.WindowConstants;
    
    public class UserMainFrm extends JFrame {
    
    	private JMenu jMenu1;
    	private JMenuBar jMenuBar1;
    	private JMenuItem jMenuItem1;
    	private JMenuItem jMenuItem2;
    	private JMenuItem jMenuItem3;
    	private JDesktopPane userMainjdp;
    
    	public UserMainFrm() {
    		initComponents();
    		// 设置位置
    		setBounds(100, 200, 1050, 650);
    		// 居中显示
    		this.setLocationRelativeTo(null);
    	}
    
    	private void initComponents() {
    
    		userMainjdp = new JDesktopPane();
    		jMenuBar1 = new JMenuBar();
    		jMenu1 = new JMenu();
    		jMenuItem1 = new JMenuItem();
    		jMenuItem2 = new JMenuItem();
    		jMenuItem3 = new JMenuItem();
    
    		setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    		setTitle("图书者主界面");
    		
    		jMenu1.setText("基本信息");
    
    		jMenuItem1.setText("书籍信息");
    		jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
    			public void actionPerformed(java.awt.event.ActionEvent evt) {
    				jMenuItem1ActionPerformed(evt);
    			}
    		});
    		jMenu1.add(jMenuItem1);
    
    		jMenuItem2.setText("借书记录");
    		jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
    			public void actionPerformed(java.awt.event.ActionEvent evt) {
    				jMenuItem2ActionPerformed(evt);
    			}
    		});
    		jMenu1.add(jMenuItem2);
    
    		jMenuItem3.setText("退出系统");
    		jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
    			public void actionPerformed(java.awt.event.ActionEvent evt) {
    				jMenuItem3ActionPerformed(evt);
    			}
    		});
    		jMenu1.add(jMenuItem3);
    
    		jMenuBar1.add(jMenu1);
    
    		setJMenuBar(jMenuBar1);
    
    		GroupLayout layout = new GroupLayout(getContentPane());
    		getContentPane().setLayout(layout);
    		layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(userMainjdp,
    				GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE));
    		layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(userMainjdp,
    				GroupLayout.DEFAULT_SIZE, 279, Short.MAX_VALUE));
    
    		pack();
    	}
    
    	private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {
    		int i = JOptionPane.showConfirmDialog(null, "确认退出系统");
    		if (i == 0) {
    			this.dispose();
    		}
    	}
    
    	private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {
    		UserBorrowDetail userBorrowDetail = new UserBorrowDetail();
    		userBorrowDetail.setVisible(true);
    		this.userMainjdp.add(userBorrowDetail);
    	}
    
    	private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {
    		BookInfoFrm infoFrm = new BookInfoFrm();
    		infoFrm.setVisible(true);
    		this.userMainjdp.add(infoFrm);
    	}
    
    	public static void main(String args[]) {
    		java.awt.EventQueue.invokeLater(new Runnable() {
    			public void run() {
    				new UserMainFrm().setVisible(true);
    			}
    		});
    	}
    
    }
    

    UserManagerFrm.java

    package com.sjsq.view;
    
    import javax.swing.GroupLayout;
    import javax.swing.JInternalFrame;
    
    public class UserManagerFrm extends JInternalFrame {
    
    	public UserManagerFrm() {
    		initComponents();
    	}
    
    	private void initComponents() {
    
    		setClosable(true);
    
    		GroupLayout layout = new GroupLayout(getContentPane());
    		getContentPane().setLayout(layout);
    		layout.setHorizontalGroup(
    				layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGap(0, 394, Short.MAX_VALUE));
    		layout.setVerticalGroup(
    				layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGap(0, 278, Short.MAX_VALUE));
    
    		pack();
    	}
    
    }
    

    四、其他

    1.其他系统实现

    Java+Swing实现仓库管理系统
    Java+Swing实现学生信息管理系统
    Java+Swing实现学生宿舍管理系统
    Java+Swing实现学生选课管理系统
    Java+Swing实现电子相册管理系统
    Java+Swing实现斗地主游戏

    2.获取源码

    请联系QQ:3079118617

    展开全文
  • 图书仓库管理系统java+sql+eclipse经典打造课程设计
  • 图书管理系统刚开始学Java本身写的一个小项目分享一下:mysql源码连接:git功能:系统分管理员界面与用户界面数据库管理员:实现对图书的增、删、改、查,对全部借阅历史的搜索及全部帐户的信息,用户的权限与管理,...

    图书管理系统

    刚开始学Java本身写的一个小项目分享一下:mysql

    源码连接:git

    功能:系统分管理员界面与用户界面数据库

    管理员:实现对图书的增、删、改、查,对全部借阅历史的搜索及全部帐户的信息,用户的权限与管理,设定密码,借阅图书及对本身帐户的资料修改eclipse

    用户:实现对图书的借阅功能、查看本身的借阅历史,在用户帐户方面实现修改密码以及修改我的信息功能ui

    另外:当数据库中用户表为空,则第一个注册的用户默认为管理员.net

    下面上图:3d

    登陆界面:blog

    3b35d1d054007f6b9dc47f4e8ec48cfb.png

    注册界面:

    481150daa1dce3fb666bd75652cc1d69.png

    用户登陆:

    主界面:

    7e9c434d6acdf1d851ef9c9a33246012.png

    图书查询界面:

    088e5ddd7671d3d46fae1e5c1362ac87.png

    图书借还界面:

    a187e894f3d8daf3550a47366d4b92f3.png

    帐户管理界面:

    7001a64c411f75c4a6522f3f5a9b3c56.png

    借书记录:

    1c9b4003b7d09623064c95743b339b83.png

    管理员登陆:

    主界面、图书查询、图书借阅界面与用户相同

    帐户管理:

    ec1c830fd0e173e57067481332d7ec4a.png

    借书记录:

    b178c456e29a2e1f182f46be65983880.png

    帐户信息:

    07421d5127cc59ac6e3eaebf159c6f9f.png

    修改权限:

    42fde1b6845b900dc4107f427e8f41eb.png

    图书管理界面:

    44f71cc06f67ed4f6c91ea7bf6b4802b.png

    添加图书:

    11a8b8e6bc2d7a1506d2074abfae2401.png

    -------------------------------------------------------------我是分割线-------------------------------------------------

    下面对个人图书管理系统的数据库方面作介绍:

    个人数据库用的是Mysql  5.7 版本的对数据库没要求均可以,在建表写代码过程当中为了方便使用了Navicat Premium 12链接数据库建表。项目文件夹中有mis数据库的.sql文件,只需在本身的数据库中建立mis数据库将.sql文件导入mis数据库便可

    建立了数据库mis,在mis中建立了booktable(图书表)、usertable(用户表)、borrowrecords(借书记录)、bookcategory(图书类别)

    d797fe9c0a2d60721f2ea4da95d3e8b7.png

    booktable

    另外booktable表格中的category属性参照bookcategory表当作外键

    e3be5b0695bf2ef3b496d535b1869fbd.png

    b3aa92152ead6101b3b81b8ffae2a728.png

    609ac57a4332affef4c5c9d9280a4b99.png

    usertable

    c4d522fca675623ade8ebe1ede25b52f.png

    5cbd1cfce80f64e28deb3352f2e60553.png

    borrowrecords

    9d3201de0328cd4ea4670a91e306ae54.png

    0af9d4ca9fa06f9f86074b357108456a.png

    bookcategory

    063826ba7f8ceb571d37b805c0c8731a.png

    7697f03e4e88bfd2483bcec69f2eaf9f.png

    ------------------------------------------------------我是分割线------------------------------------------------------------

    因为个人Jdk是12.0的版本因此若是版本比12.0的低,导入项目会出现项目上出现红色感叹号,解决方案以下:

    项目右键->Build Path->Configure Build Path...

    9c99179e06a184617457ef259c75405c.png

    Librarise->JRE System Library [JavaSE - 12]->Remove

    97fc85ece8d5dce234841da227c6ec43.png

    继续Librarise界面选中Modulepath->Add Library...

    618f80508ba2ce0d740e9cff2c9c9c34.png

    JRE System Library  -> Next

    99a475316855aef301b026f74cfe27e5.png

    Execution  environment -> 下拉框中选中本身的JDK 版本  ->Finish

    dfb9335b680ad7c95ddd6d1d42f644d2.png

    ------------------------------------------------------我是分割线--------------------------------------------------------

    完成上面的JDK修改和数据库及表格的建立就能够运行图书管理项目了,话很少说,上项目连接:

    展开全文
  • 图书管理系统java+MySQL

    2017-12-30 14:40:32
    在大学期间做的一个实验,属于一个小型的图书管理系统,里面是全部的代码,但是需要自己转移到eclipse自己创建包什么的,代码复制就好
  • 对初学java的朋友很有帮助,采用mvc架构kaifa,让初学者更容易熟悉mvc架构开发
  • 图书管理系统java

    2019-01-25 14:14:41
    图书管理系统java的有图形界面,用eclipse写的
  • eclipse做地图书管理系统,带数据库,和使用说明,及数据库的建模。希望能给各位同志一些帮助,供大家参考!图书馆管理系统是图书馆管理工作中不可缺少的部分,它对于图书馆的管理者和使用者都非常重要,所以图书...
  • java图书管理系统

    2018-01-11 10:47:40
    java图书管理系统,连接Oracle数据库,导入即可运行,eclipse编译
  • 图书管理系统 Java Eclipse MySQL

空空如也

空空如也

1 2 3 4 5 ... 17
收藏数 322
精华内容 128
关键字:

eclipse图书管理系统java

java 订阅