图书管理系统--java代码
java项目开发实例图书信息管理系统开发及源码
j a v a项目开发实例图书信息管理系统开发及源码集团文件发布号:(9816-UATWW-MWUB-WUNN-INNUL-DQQTY-图书信息管理系统一、系统功能概述:根据图书信息管理系统的特点,可以将本系统分为2大功能模块,分别为:基础数据维护、系统数据维护。
本系统各个部分及其包括的具体功能模块如下图所示:二、数据库设计:图书信息表:图书类别表:用户信息表:读者信息表:三、系统源代码:ewInstance();conn = (dbUrl, dbUser, dbPwd);"数据库连接成功!");}elsereturn;} catch (Exception ee) {();}}xecuteQuery(sql);} catch (SQLException e) {();return null;} finally {}}xecuteUpdate(sql);} catch (SQLException e) {quals("[Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]DELETE 语句与 COLUMN REFERENCE 约束'FK_TB_BORRO_REFERENCE_TB_BOOKI' 冲突。
该冲突发生于数据库'db_library',表 'tb_borrow', column 'bookISBN'。
"))return -1;} finally {}}etLayout(borderLayout);setIconifiable(true); dd(panel);final JLabel label_2 = new JLabel();("图书编号:");(label_2);ISBN = new JTextField("请输入13位书号",13);(new MyDocument(13)); dd(panel_1, ;final FlowLayout flowLayout = new FlowLayout();(2);(30);;(flowLayout);buttonadd= new JButton();(new addBookActionListener()); ("添加");(buttonadd);buttonclose = new JButton();(new CloseActionListener());("关闭");(buttonclose);final JLabel label_5 = new JLabel(); ImageIcon bookAddIcon=(""); (bookAddIcon);(new Dimension(400, 80));(new LineBorder, 1, false)); getContentPane().add(label_5, ; ("新书定购(LOGO图片)");setVisible(true);rim()).isEmpty()){(null, "添加书号重复!");return;}}}class ISBNkeyListener extends KeyAdapter {public void keyPressed(final KeyEvent e) {if () == 13){();}}}class CloseActionListener implements ActionListener { ength()==0){(null, "书号文本框不可以为空");return;}if().length()!=13){(null, "书号文本框输入位数为13位");return;}if().length()==0){(null, "图书名称文本框不可以为空");return;}if().length()==0){(null, "作者文本框不可以为空");return;}if().length()==0){(null, "出版日期文本框不可以为空");return;}if().length()==0){(null, "单价文本框不可以为空");return;}String ISBNs=().trim();rim();String bookNames=().trim();String writers=().trim();String publishers=(String)().trim();String pubDates=().trim();String prices=().trim();int i=(ISBNs,bookTypes, bookNames, writers, translators, publishers, if(i==1){(null, "添加成功");doDefaultCloseAction();}}}class NumberListener extends KeyAdapter { public void keyTyped(KeyEvent e) {String numStr="09."+(char)8;if())<0){();}}}}et()));results[i][1]=booktypename;results[i][2]=();results[i][3]=();results[i][4]=();results[i][5]=();results[i][6]=();results[i][7]=();}return results;}public BookModiAndDelIFrame() {super();final BorderLayout borderLayout = new BorderLayout();getContentPane().setLayout(borderLayout);setIconifiable(true);setClosable(true);setTitle("图书信息修改与删除");setBounds(100, 100, 640, 406);dd(panel_1, ;final FlowLayout flowLayout = new FlowLayout();(2);(30);;(flowLayout);final JButton button = new JButton();(new addBookActionListener());("修改");(button);final JButton button_2 = new JButton();(new ActionListener(){public void actionPerformed(final ActionEvent e) {String ISBNs=().trim();int i=(ISBNs);if(i==1){(null, "删除成功");Object[][] results=getFileStates());dd(headLogo, ;final JPanel panel_2 = new JPanel();final BorderLayout borderLayout_1 = new BorderLayout();(5);(borderLayout_1);(new EmptyBorder(5, 10, 5, 10));getContentPane().add(panel_2);final JScrollPane scrollPane = new JScrollPane();(scrollPane);Object[][] results=getFileStates());columnNames = new String[]{"图书编号", "图书类别", "图书名称", "作者", "译者", "出版商", "出版日期","价格"};table = new JTable(results,columnNames);;oString().trim();typeids = (selRow, 1).toString().trim();bookNames = (selRow, 2).toString().trim();writers = (selRow, 3).toString().trim();translators = (selRow, 4).toString().trim();publishers = (selRow, 5).toString().trim();dates = (selRow, 6).toString().trim();prices = (selRow, 7).toString().trim();(ISBNs);ength()==0){(null, "书号文本框不可以为空或则输入数字不可以大于13个");return;}if().length()!=13){(null, "书号文本框输入位数为13位");return;}if().length()==0){(null, "图书名称文本框不可以为空");return;}if().length()==0){(null, "作者文本框不可以为空");return;}if().length()==0){(null, "出版人文本框不可以为空");}ength()==0){(null, "出版日期文本框不可以为空");return;}if().length()==0){(null, "单价文本框不可以为空");return;}String ISBNs=().trim();rim();String bookNames=().trim();String writers=().trim();String publishers=().trim();String pubDates=().trim();String prices=().trim();int i=(ISBNs, bookTypes, bookNames, writers, translators, publishers, (pubDates), (prices));if(i==1){(null, "修改成功");Object[][] results=getFileStates());+(char)8;();}}}}dd(panel, ;final JLabel label_4 = new JLabel();ImageIcon bookTypeAddIcon=("");(bookTypeAddIcon);(new Dimension(360, 80));("图书类别图片(400*80)");(label_4);final JPanel panel_3 = new JPanel();(new FlowLayout());getContentPane().add(panel_3, ;final JLabel label_1 = new JLabel();(new Dimension(20, 50));(label_1);final JLabel label_2 = new JLabel();(new Dimension(90, 20));("图书类别名称:");(label_2);(new MyDocument(20));(30);(bookTypeName);final JButton button = new JButton();("保存");(new ActionListener(){public void actionPerformed(final ActionEvent e) { if().length()==0){(null, "图书类别文本框不可为空");return;}int i=().trim());if(i==1){(null, "添加成功!");doDefaultCloseAction();}else{(null, "图书类别名已存在,请重新输入!");}}});(button);final JButton buttonDel = new JButton();(new ActionListener(){public void actionPerformed(final ActionEvent e) {doDefaultCloseAction();}});(buttonDel);setVisible(true);}class NumberListener extends KeyAdapter {public void keyTyped(KeyEvent e) {String numStr="09."+(char)8;if())<0){();}}}}dd(panel, ;final JLabel logoLabel = new JLabel();ImageIcon bookTypeModiAndDelIcon=("");(bookTypeModiAndDelIcon);(new Dimension(400, 80));(logoLabel);final JPanel panel_1 = new JPanel(); getContentPane().add(panel_1);final JScrollPane scrollPane = new JScrollPane(); (new Dimension(400, 130));(scrollPane);model=new DefaultTableModel();Object[][] results=getFileStates());(results,columnNames);table = new JTable();(model);(new TableListener());(table);final JPanel panel_2 = new JPanel();(panel_2);final GridLayout gridLayout = new GridLayout(0, 6);(5);(5);(gridLayout);(new Dimension(400, 26));final JLabel label = new JLabel();("类别编号:");BookTypeId = new JTextField();(false);(BookTypeId);final JLabel label_1 = new JLabel();("类别名称:");(label_1);comboBox = new JComboBox();bookTypeModel= (DefaultComboBoxModel)();oString().trim());(selRow, 1).toString().trim());}}class ButtonAddListener implements ActionListener{ public void actionPerformed(ActionEvent e){Object selectedItem = ();int i=().trim(),());if(i==1){(null, "修改成功");Object[][] results=getFileStates());(results,columnNames);(model);}}class ButtonDelListener implements ActionListener{ public void actionPerformed(ActionEvent e){int i=().trim());if(i==1){(null, "删除成功");Object[][] results=getFileStates());(results,columnNames);(model);}}}class CloseActionListener implements ActionListener { etLayout(borderLayout);setTitle("图书馆管理系统登录");setBounds(100, 100, 285, 194);final JPanel panel = new JPanel();(new BorderLayout());(new EmptyBorder(0, 0, 0, 0));getContentPane().add(panel);final JPanel panel_2 = new JPanel();final GridLayout gridLayout = new GridLayout(0, 2);(20);(gridLayout);(panel_2);final JLabel label = new JLabel();;(new Dimension(0, 0));(new Dimension(0, 0));(label);("用户名:");username = new JTextField(20);(new Dimension(0, 0));(username);final JLabel label_1 = new JLabel(); ;(label_1);("密码:");password = new JPasswordField(20); (new MyDocument(6));('*');etSystemLookAndFeelClassName());new LoginIFrame();dd(toolBar, ; final JLabel label = new JLabel(); (0, 0, 0, 0);().getSize());("<html><img width=" + + " height="+ + " src='"+ ().getResource("/")+ "'></html>");}});(label,new Integer);getContentPane().add(DESKTOP_PANE);}/*** 创建工具栏** @return JToolBar*/private JToolBar createToolBar() { etLayout(new GridBagLayout());setBounds(100, 100, 300, 228);final JLabel label_4 = new JLabel();(new Font("", , 14));;("<html>注:每个<b>操作员</b>只能修改自己的密码。
java实现简单的图书管理系统
java实现简单的图书管理系统本⽂实例为⼤家分享了java实现简单的图书管理系统的具体代码,供⼤家参考,具体内容如下⼀、项⽬分布Book类: 定义了书的⼀些属性(书名,作者,价格,分类,状态)并且写了属性的get、set⽅法Library类: 写了登录函数(1、普通⽤户,2、管理员,3、退出系统),Person类:定义的⼈的属性(姓名,性别,年龄)并且写了属性的get、set⽅法,定义了⼀些书。
operate接⼝:操作的接⼝,操作⽅法:查询/查阅,删除/借阅,增加/还书,显⽰书籍列表Root类:继承了Person类,实现operate(查阅,删除,增加,显⽰书籍列表)接⼝User类:继承了Person类,实现operate(查询,借阅,还书,显⽰书籍列表)接⼝Main类:Main中的主函数开启整个项⽬。
模型图:声明:本项⽬只是⼀个简单的⾯向对象⼊门⼩项⽬,有⼀些基础理论需要掌握,⽐如对象,类,抽象类,接⼝,继承,实现,数组及数组的操作,for循环,while循环,switch语句,if语句。
⼆、代码展⽰1.Book类public class Book {private String name; //书名private String author; //作者public double price; //价格private String category; //分类private boolean state; //状态 true-未借出 false-已借出//通过构造函数给定书的属性public Book(String name,String author,double price,String category,boolean state){this.author = author; = name;this.price = price;this.category = category;this.state = state;}public Book() { //默认10本书this(10);}public Book(int i) {Person.books = new Book[i];}//属性的获取和设置public String getName() {return name;}public void setName(String name) { = name;}public String getAuthor() {return author;}public void setAuthor(String author) {this.author = author;}public double getPrice() {return price;}public void setPrice(double price) {this.price = price;}public String getCategory() {return category;}public void setCategory(String category) {this.category = category;}public boolean getState() {return state;}public void setState(boolean state) {this.state = state;}}2.Library类import java.util.Scanner;public class Library {Scanner sc = new Scanner(System.in);//登录函数:显⽰登录界⾯进⾏选择登录public void login() {int count = 0;Person p = null;while (count < 2) {System.out.println("===============jewel图书管理系统===============");System.out.println("欢迎讨论指正! qq505791225"+"\n");System.out.println("请登录:1.普通⽤户 2.管理员登录 3.退出系统");int n = sc.nextInt();//通过输⼊的值进⾏登录判断if (n == 3) {return;}switch (n) {case 1:System.out.println("请输⼊姓名:");String Uname = sc.next();System.out.println("请输⼊性别:");String Usex = sc.next();System.out.println("请输⼊年龄:");int Uage = sc.nextInt();p = new User(Uname,Usex,Uage); //构造普通⽤户对象System.out.println("登录成功!");System.out.println("当前普通⽤户:"+"姓名:" + p.getName() + " "+"性别:" + p.getSex() + " "+"年龄"+ p.getAge()); //普通⽤户循环操作while (true) {System.out.println("请输⼊你的操作: 1.查询书籍 2.借阅书籍 3.归还书籍 4.显⽰书籍列表 5.退出");int i = sc.nextInt();if (i == 5) {System.out.println("您已成功退出!");break;}else {p.operate(); //调⽤普通⽤户的操作⽅法}}break;case 2:System.out.println("请输⼊管理员姓名:");String Rname = sc.next();System.out.println("请输⼊性别:");String Rsex = sc.next();System.out.println("请输⼊年龄:");int Rage = sc.nextInt();p = new Root(Rname,Rsex,Rage);//构造管理员对象System.out.println("登录成功!");System.out.println("当前管理员:"+"姓名:" + p.getName() + " "+"性别:" + p.getSex() + " "+"年龄" + p.getAge()); while (true) {System.out.println("请输⼊你的操作: 1.整理书籍 2.查阅书籍 3.增加书籍 4.删除书籍 5.显⽰书籍列表 6.退出");int j = sc.nextInt();if (j == 6) {System.out.println("您已成功退出!");break;}else{p.operate();//调⽤管理员的操作⽅法}} break;}}}}3.Person类(抽象类)abstract class Person {public String name;public String sex;public int age;/*** 默认定义10本书籍。
图书管理系统java代码
项目下的包及类:数据库bookcollection表book(bookID设置为自增)表user表userbook登录注册页面:package bookDB;import java.awt。
*;import java。
awt.event。
ActionEvent;import java.awt。
event。
ActionListener;import javax.swing.*;public class RLogin extends JFrame implements ActionListener{//Container c;String sex;int type;// 创建登录组件JLabel jlabel0 = new JLabel(”登录:”);JLabel jLabel1 = new JLabel("学号(或职工号):");JLabel jLabel2 = new JLabel(”密码:");JTextField userID1 = new JTextField(10);JTextField password1 = new JTextField(10);JButton btn_ok1 = new JButton(); // 创建登录确定按钮// 创建注册组件JLabel jlabel00 = new JLabel("注册:”);JLabel jLabel3 = new JLabel("姓名:");JLabel jLabel4 = new JLabel(”性别:”);JLabel jLabel5 = new JLabel("密码:");JLabel jLabel6 = new JLabel("学号(或职工号):");JLabel jLabel7 = new JLabel("院系:");JLabel jLabel8 = new JLabel("专业:");JLabel jLabel9 = new JLabel(”用户类别:");JTextField name = new JTextField(10);JTextField password2 = new JTextField(10);JTextField ID2 = new JTextField(10);JTextField department = new JTextField(10);JTextField major = new JTextField(10);JRadioButton rb1[]; // 单选按钮,用于设定性别JRadioButton rb2[];//用户类型选择JButton btn_ok2 = new JButton();// 创建注册确定按钮// 构造函数public RLogin(){super("登录/注册:"); // 调用JFrame的构造函数String[] sex = {"男”, ”女" };String[]type = {"本科生","研究生",”老师"};JPanel panel1 = new JPanel(new FlowLayout());// 使用JPanel类创建面板,该类是JComponent类的子类,后者又扩展Container//每个JPanel都是一个Container,因此,可以向JPanel添加包括面板在内的组件//this。
用Java写一个图书管理系统的代码
用Java写一个图书管理系统的代码```import java.util.*;public class BookManager {// Create a list for book storageprivate List<Book> books;public BookManager() {books = new ArrayList<Book>();}// Add a book to the listpublic void addBook(Book book) {books.add(book);}// Remove a book from the listpublic void removeBook(Book book) {books.remove(book);}// Get all books in the listpublic List<Book> getAllBooks() {return books;}// Search a book by book namepublic List<Book> searchByName(String name) {List<Book> resultBooks = new ArrayList<Book>();for (Book book : books) {if (book.getName().equals(name)) {resultBooks.add(book);}}return resultBooks;}// Search a book by author namepublic List<Book> searchByAuthor(String author) { List<Book> resultBooks = new ArrayList<Book>(); for (Book book : books) {if (book.getAuthor().equals(author)) {resultBooks.add(book);}}return resultBooks;}}class Book {private String name;private String author;public Book(String name, String author) { = name;this.author = author;}public String getName() {return name;}public void setName(String name) { = name;}public String getAuthor() {return author;}public void setAuthor(String author) { this.author = author;}}```。
Java图书管理系统-附源码
图书信息删除:
图书信息显示:
图书借阅:
图书归还:
分析总结:
本程序在数据库设计方面可以改为多张表存储的方式,用三张表来记录图书信息,借阅关系和学生信息,这样可以减少数据冗余,还可以增加一些其他功能,比如图书挂失等功能。由于刚刚接触到Java界面设计,所以本程序在界面设计方面还有有待改进的地方。
JMenuItem itemDelete = new JMenuItem();
JMenuItem itemSelect = new JMenuItem();
JMenuItem itБайду номын сангаасmBook = new JMenuItem();
JMenuItem itemReturn = new JMenuItem();
图书ID,图书名称,图书所有者,图书的状态,图书使用者(允许为空)均为varchar(50)类型,在Java中可以方便的查询。图书存储信息的具体内容如下图所示:
功能模块:
程序设计:
主框架设计:
主框架上方包含三个按钮,分别是“系统管理”、“图书信息管理”和“图书流通管理”,定义JMenuBar类的对象、JMenu类的对象和JMenuItem类的对象,分别表示菜单栏、菜单组和菜单选项,然后调用初始化函数,将不同类的对象通过setText()函数设定不同的文本,然后将其添加到窗口容器中。对每个按钮分别添加不同的消息监听,响应相应的消息,调用不同的类完成不同的功能。消息监听功能详见源代码bookMain类。
删除图书信息模块:
调用bookDel类的构造函数产生一个该类的对象,在初始化函数中显示信息输入对话框,提示用户输入要删除图书的ID。完成输入后,点击确定按钮,消息监听模块将调用bookBean的构造函数产生一个该类的对象,通过该对象调用bookBean的bookDel函数,执行删除的SQL语句,通过delete语句完成图书信息的删除功能。
图书管理系统源码(java实现)
【图书管理系统】【MainPro包】1.系统登录页面public class Login extends Frame {private static final long serialVersionUID = -1758475247807861408L;TextField text_user;TextField text_pass;public Login() {1 this.setTitle("登录");this.setLayout(null);//默认流式布局this.setSize(260, 170);/* 定义标签与文本框*/Label lbUser = new Label("用户名:");text_user = new TextField();Label lbPass = new Label("密码:");text_pass = new TextField();Button btn_ok = new Button("确定");Button btn_cancel = new Button("取消");lbUser.setBounds(40, 53, 60, 20);//x,y,width,heightlbPass.setBounds(40, 83, 60, 20);text_user.setBounds(100, 50, 120, 20);text_pass.setBounds(100, 80, 120, 20);btn_ok.setBounds(45, 120, 80, 25); // 确定按钮btn_cancel.setBounds(135, 120, 80, 25); // 取消按钮/* 添加标签与文本框*/add(lbUser);add(lbPass);add(text_user);add(text_pass);add(btn_ok);add(btn_cancel);setLocationRelativeTo(null); // 使窗体在屏幕上居中放置this.setVisible(true); // 使窗体可见btn_ok.addActionListener((new ActionListener() {public void actionPerformed(ActionEvent e) {btn_okActionPerformed(e);//自定义确定按钮触发的实施过程}}));btn_cancel.addActionListener((new ActionListener() {public void actionPerformed(ActionEvent e) {DbOp.Close(); // 关闭数据库System.exit(0);}}));this.addWindowListener(new WindowAdapter() {/* 关闭窗口*/// 重写windowClosing()方法public void windowClosing(WindowEvent e) {DbOp.Close(); // 关闭数据库System.exit(0);} }); }public void btn_okActionPerformed(ActionEvent e) {String user = text_user.getText();String pass = text_pass.getText();String is_admin;// 如果用户名或密码任一为空,则终止后续操作if (user.equals("")||pass.equals("")) {JOptionPane.showMessageDialog(null, "用户名或密码不能为空!");return;}try {// 核对用户名和密码String sql = "select * from user where username=" + "'" + user + "' and password=" + "'" + pass + "'";ResultSet rs = DbOp.executeQuery(sql);// 如果此用户存在,则记录其状态(否:不是管理员,是:是管理员)if (rs.next()) {is_admin = rs.getString("is_admin");} else {JOptionPane.showMessageDialog(null, "用户名或密码不正确!");return;}GlobalVar.login_user = user; // 记录登录的用户名ShowMain show = new ShowMain(); // 调用主程序// 只有管理员才能使用"基础管理"和"借阅管理"菜单show.setRights(is_admin);// 释放窗体及其全部组件的屏幕资源,即使释放登录窗体dispose(); // 释放当前窗体} catch (SQLException e1) {JOptionPane.showMessageDialog(null, "用户数据库有误!");}}}2.系统首页页面public class ShowMain extends Frame {private static final long serialVersionUID = 5003296786441785470L;MenuBar menuBar;Menu jcwh, jcwh_book, jcwh_reader;//基础维护:图书维护、读者维护Menu jywh, cxgl, xtgl;//借阅维护、查询管理、系统管理MenuItemjcwh_book_add,jcwh_book_update,jcwh_book_delete,jcwh_reader_add,jcwh_reader_update,jcwh_reader_delete;MenuItem jywh_borrow, jywh_back;MenuItem cxgl_book, cxgl_reader;MenuItem xtgl_update_pass, xtgl_exit;public void setRights(String rights) {// 如果不是管理员,则禁止用户维护图书信息和读者信息以及禁止进行借阅管理,即只能查询if (rights.equals("否")) {jywh.setEnabled(false);jcwh.setEnabled(false);}}public ShowMain() {setTitle("图书管理系统");setLayout(new BorderLayout());setSize(640, 480);menuBar = new MenuBar();jcwh = new Menu("基础维护");// 基础维护菜单jcwh_book = new Menu("图书维护");// 图书维护菜单jcwh_book_add = new MenuItem("添加");// 添加图书菜单jcwh_book_update = new MenuItem("修改");// 修改图书菜单jcwh_book_delete = new MenuItem("删除");// 删除图书菜单jcwh_reader = new Menu("读者维护");// 读者维护菜单jcwh_reader_add = new MenuItem("添加读者");// 添加读者菜单jcwh_reader_update = new MenuItem("修改读者");jcwh_reader_delete = new MenuItem("删除读者");jywh = new Menu("借阅管理");jywh_borrow = new MenuItem("借书管理");jywh_back = new MenuItem("还书管理");cxgl = new Menu("查询管理");cxgl_book = new MenuItem("图书查询");cxgl_reader = new MenuItem("读者查询");xtgl = new Menu("系统管理");xtgl_update_pass = new MenuItem("修改密码");xtgl_exit = new MenuItem("退出系统");// 添加图书菜单jcwh_book.add(jcwh_book_add);jcwh_book.add(jcwh_book_update);jcwh_book.add(jcwh_book_delete);jcwh.add(jcwh_book);jcwh_reader.add(jcwh_reader_add);jcwh_reader.add(jcwh_reader_update);jcwh_reader.add(jcwh_reader_delete);jcwh.add(jcwh_reader);jywh.add(jywh_borrow);jywh.add(jywh_back);cxgl.add(cxgl_book);cxgl.add(cxgl_reader);xtgl.add(xtgl_update_pass);xtgl.add(xtgl_exit);menuBar.add(jcwh);menuBar.add(jywh);menuBar.add(cxgl);menuBar.add(xtgl);setMenuBar(menuBar);setLocationRelativeTo(null); // 使窗体在屏幕上居中放置setVisible(true); // 使窗体可见jcwh_book_add.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new BookManeger("save");} });jcwh_book_update.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new BookManeger("update");} });jcwh_book_delete.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new BookManeger("delete");} });jcwh_reader_add.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new ReaderManeger("save");} });jcwh_reader_update.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new ReaderManeger("update");} });jcwh_reader_delete.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new ReaderManeger("delete");} });jywh_borrow.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new Borrow();} });jywh_back.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new Back();} });cxgl_book.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new BookQuery();} });cxgl_reader.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new ReaderQuery();} });xtgl_update_pass.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new UpdatePassword();} });xtgl_exit.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {DbOp.Close(); // 关闭数据库System.exit(0);}});this.addWindowListener(new WindowAdapter() {/* 关闭窗口*/// 重写windowClosing()方法public void windowClosing(WindowEvent e) {DbOp.Close(); // 关闭数据库System.exit(0);}});}}3.图书管理public class BookManeger extends JFrame {private static final long serialVersionUID = 377287301994613384L;private Label lbbookid_c = new Label("图书编号");private TextField tf_bookid_c = new TextField();private Label lbbookid = new Label("图书编号");private TextField tf_bookid = new TextField();private Label lbbookname = new Label("图书名称");private TextField tf_bookname = new TextField();private Label lbbooktype = new Label("图书类别");private Choice tf_booktype = new Choice();private Label lbauthor = new Label("作者");private TextField tf_author = new TextField();private Label lbtranslator = new Label("译者");private TextField tf_translator = new TextField();private Label lbpublisher = new Label("出版社");private TextField tf_publisher = new TextField();private Label lbpublish_time = new Label("出版时间");private TextField tf_publish_time = new TextField();private Label lbprice = new Label("定价");private TextField tf_price = new TextField();private Label lbstock = new Label("库存数量");private TextField tf_stock = new TextField();private Button queryBtn = new Button("查询");private Button saveBtn = new Button("保存");private Button closeBtn = new Button("关闭");private String optionStr;BookManeger(String str) {optionStr = str;ggFrame(optionStr);saveBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {HashMap<String, Object> map = new HashMap<String, Object>();map.put("bookid", tf_bookid);map.put("bookname", tf_bookname);map.put("booktype", tf_booktype);map.put("author", tf_author);map.put("translator", tf_translator);map.put("publisher", tf_publisher);map.put("publish_time", tf_publish_time);map.put("price", tf_price);map.put("stock", tf_stock);int i ;if(optionStr.equals("delete")){i = Jcwh.btn_delActionPerformed(e, map);}else{i = Jcwh.btn_saveActionPerformed(e, map,optionStr);}if (i == 1) {String showInfo = "";if(optionStr.equals("save")){showInfo = "图书添加成功!";}else if(optionStr.equals("update")){showInfo = "图书修改成功!";}else if(optionStr.equals("delete")){showInfo = "图书删除成功!";}JOptionPane.showMessageDialog(null, showInfo);// 清空全部文本框clearAllTextfield();}}});closeBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {dispose(); // 释放当前窗体}});/* 关闭窗口*/this.addWindowListener(new WindowAdapter() {public void windowClosing(WindowEvent e) { // 关闭当前窗口dispose(); // 释放当前窗体}});}private void ggFrame(String str) {setLayout(null);setSize(500, 320);lbbookid.setBounds(50, 40, 50, 20); // 图书编号tf_bookid.setBounds(110, 40, 100, 20);lbbookname.setBounds(240, 40, 50, 20); // 图书名称tf_bookname.setBounds(300, 40, 100, 20);lbbooktype.setBounds(50, 80, 50, 20); // 图书类别tf_booktype.setBounds(110, 80, 100, 20);tf_booktype.add("科技");tf_booktype.add("文学");tf_booktype.add("社科");tf_booktype.add("其他");lbauthor.setBounds(240, 80, 50, 20); // 作者tf_author.setBounds(300, 80, 100, 20);lbtranslator.setBounds(50, 120, 50, 20); // 设置译者tf_translator.setBounds(110, 120, 100, 20);lbpublisher.setBounds(240, 120, 50, 20); // 出版社tf_publisher.setBounds(300, 120, 100, 20);lbpublish_time.setBounds(50, 160, 50, 20); // 出版时间tf_publish_time.setBounds(110, 160, 100, 20);lbprice.setBounds(240, 160, 50, 20); // 定价tf_price.setBounds(300, 160, 100, 20);lbstock.setBounds(50, 200, 50, 20); // 库存数量tf_stock.setBounds(110, 200, 100, 20);saveBtn.setBounds(150, 240, 80, 25); // 保存按钮closeBtn.setBounds(280, 240, 80, 25);// 关闭按钮if(str.equals("save")){setTitle("添加图书");}else if(str.equals("update")){setTitle("修改图书");lbbookid_c.setBounds(100, 10, 50, 20); // 图书编号tf_bookid_c.setBounds(160, 10, 100, 20);tf_bookid.setEditable(false);//修改的图书信息中id不可以修改queryBtn.setBounds(280, 10, 80, 20); // 查询按钮add(lbbookid_c);add(tf_bookid_c);add(queryBtn);queryBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {HashMap<String, Object> map = new HashMap<String, Object>();map.put("bookid", tf_bookid_c);Book book = (Book)Jcwh.btn_queryActionPerformed(e,map).get("book");if(book!=null){tf_bookid.setText(book.getId());tf_bookname.setText(book.getBookname());// 将Choice的选定项设置为其名称等于指定字符串的项tf_booktype.select(book.getBooktype());tf_author.setText(book.getAuthor());tf_translator.setText(book.getTranslator());tf_publisher.setText(book.getPublisher());tf_publish_time.setText(book.getPublish_time().toString());tf_price.setText(String.valueOf(book.getPrice()));tf_stock.setText(String.valueOf(book.getStock()));}}});saveBtn.setLabel("修改");//将按钮显示文字修改成“修改”}else if(str.equals("delete")){setTitle("删除图书");lbbookid_c.setBounds(100, 10, 50, 20); // 图书编号tf_bookid_c.setBounds(160, 10, 100, 20);tf_bookid.setEditable(false);//修改的图书信息中id不可以修改queryBtn.setBounds(280, 10, 80, 20); // 查询按钮add(lbbookid_c);add(tf_bookid_c);add(queryBtn);queryBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {HashMap<String, Object> map = new HashMap<String, Object>();map.put("bookid", tf_bookid_c);Book book = (Book)Jcwh.btn_queryActionPerformed(e,map).get("book");if(book!=null){tf_bookid.setText(book.getId());tf_bookname.setText(book.getBookname());// 将Choice的选定项设置为其名称等于指定字符串的项tf_booktype.select(book.getBooktype());tf_author.setText(book.getAuthor());tf_translator.setText(book.getTranslator());tf_publisher.setText(book.getPublisher());tf_publish_time.setText(book.getPublish_time().toString());tf_price.setText(String.valueOf(book.getPrice()));tf_stock.setText(String.valueOf(book.getStock()));}}});saveBtn.setLabel("删除");//将按钮显示文字修改成“删除”}add(lbbookid);add(tf_bookid);add(lbbookname);add(tf_bookname);add(lbbooktype);add(tf_booktype);add(lbauthor);add(tf_author);add(lbtranslator);add(tf_translator);add(lbpublisher);add(tf_publisher);add(lbpublish_time);add(tf_publish_time);add(lbprice);add(tf_price);add(lbstock);add(tf_stock);add(saveBtn);add(closeBtn);setLocationRelativeTo(null); // 使窗体在屏幕上居中放置setVisible(true); // 使窗体可见}private void clearAllTextfield() {tf_bookid.setText("");tf_bookname.setText("");tf_author.setText("");tf_translator.setText("");tf_publisher.setText("");tf_publish_time.setText("");tf_price.setText("");tf_stock.setText("");}}4.读者管理public class ReaderManeger extends JFrame {private static final long serialVersionUID = -2399939451497711745L;Label lbreaderid_c = new Label("读者编号");TextField tf_readerid_c = new TextField();Label lbreaderid = new Label("读者编号");TextField tf_readerid = new TextField();Label lbreadername = new Label("读者姓名");TextField tf_readername = new TextField();Label lbreadertype = new Label("读者类别");Choice tf_readertype = new Choice();Label lbsex = new Label("性别");Choice tf_sex = new Choice();Label lbmax_num = new Label("可借数量");TextField tf_max_num = new TextField();Label lbdays_num = new Label("可借天数");TextField tf_days_num = new TextField();Button queryBtn = new Button("查询");Button saveBtn = new Button("保存");Button closeBtn = new Button("关闭");private String optionStr;//保存、修改、删除ReaderManeger(String str){optionStr = str;ggFrame(optionStr);saveBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {HashMap<String, Object> map = new HashMap<String, Object>();map.put("readerid", tf_readerid);map.put("readername", tf_readername);map.put("readertype", tf_readertype);map.put("sex", tf_sex);map.put("days_num", tf_days_num);map.put("max_num", tf_max_num);int i ;if(optionStr.equals("delete")){i = Jcwh.btn_delReaderActionPerformed(e, map);}else{i = Jcwh.btn_saveReaderActionPerformed(e,map,optionStr);}if (i == 1) {String showInfo = "";if(optionStr.equals("save")){showInfo = "读者添加成功!";}else if(optionStr.equals("update")){showInfo = "读者修改成功!";}else if(optionStr.equals("delete")){showInfo = "读者删除成功!";}JOptionPane.showMessageDialog(null, showInfo);// 清空全部文本框clearAllTextfield();}}});closeBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {dispose(); // 释放当前窗体}});this.addWindowListener(new WindowAdapter() {public void windowClosing(WindowEvent e) { // 关闭当前窗口dispose(); // 释放当前窗体}});}private void ggFrame(String str) {setLayout(null);setTitle("添加读者信息");setSize(500, 230);lbreaderid.setBounds(50, 50, 50, 20);tf_readerid.setBounds(110, 50, 100, 20);lbreadername.setBounds(240, 50, 50, 20);tf_readername.setBounds(300, 50, 100, 20);lbreadertype.setBounds(50, 80, 50, 20);tf_readertype.setBounds(110, 80, 100, 20);tf_readertype.add("教师");tf_readertype.add("学生");tf_readertype.add("职工");lbsex.setBounds(240, 80, 50, 20);tf_sex.setBounds(300, 80, 100, 20);tf_sex.add("男");tf_sex.add("女");lbmax_num.setBounds(50, 110, 50, 20);tf_max_num.setBounds(110, 110, 100, 20);lbdays_num.setBounds(240, 110, 50, 20);tf_days_num.setBounds(300, 110, 100, 20);saveBtn.setBounds(150, 150, 80, 25);closeBtn.setBounds(280, 150, 80, 25);if(str.equals("save")){setTitle("添加读者");}else if(str.equals("update")){setTitle("修改读者");lbreaderid_c.setBounds(100, 10, 50, 20);tf_readerid_c.setBounds(160, 10, 100, 20);tf_readerid.setEditable(false);queryBtn.setBounds(280, 10, 80, 20);add(lbreaderid_c);add(tf_readerid_c);add(queryBtn);queryBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {HashMap<String, Object> map = new HashMap<String, Object>();map.put("readerid", tf_readerid_c);Reader reader = (Reader)Jcwh.btn_queryReaderActionPerformed(e,map).get("reader");if(reader!=null){tf_readerid.setText(reader.getId());tf_readername.setText(reader.getReadername());tf_readertype.select(reader.getReadertype());tf_sex.select(reader.getSex());tf_days_num.setText(String.valueOf(reader.getDays_num()));tf_max_num.setText(String.valueOf(reader.getMax_num()));}}});saveBtn.setLabel("修改");//将按钮显示文字修改成“修改”}else if(str.equals("delete")){setTitle("删除图书");lbreaderid_c.setBounds(100, 10, 50, 20);tf_readerid_c.setBounds(160, 10, 100, 20);tf_readerid.setEditable(false);queryBtn.setBounds(280, 10, 80, 20);add(lbreaderid_c);add(tf_readerid_c);add(queryBtn);queryBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {HashMap<String, Object> map = new HashMap<String, Object>();map.put("readerid", tf_readerid_c);Reader reader = (Reader)Jcwh.btn_queryReaderActionPerformed(e,map).get("reader");if(reader!=null){tf_readerid.setText(reader.getId());tf_readername.setText(reader.getReadername());tf_readertype.select(reader.getReadertype());tf_sex.select(reader.getSex());tf_days_num.setText(String.valueOf(reader.getDays_num()));tf_max_num.setText(String.valueOf(reader.getMax_num()));}}});saveBtn.setLabel("删除");//将按钮显示文字修改成“删除”}add(lbreaderid);add(lbreadername);add(lbreadertype);add(lbsex);add(lbmax_num);add(lbdays_num);add(tf_readerid);add(tf_readername);add(tf_max_num);add(tf_days_num);add(tf_readertype);add(tf_sex);add(saveBtn);add(closeBtn);setLocationRelativeTo(null);setVisible(true);}private void clearAllTextfield() {tf_readerid.setText("");tf_readername.setText("");tf_max_num.setText("");tf_days_num.setText("");}public static void main(String[] args) {ReaderManeger r = new ReaderManeger("update");}}5.借书public class Borrow extends Frame {private static final long serialVersionUID = -1036076990599464079L;String SepLine = "-------------------------------------------------";Label lbbookid = new Label("图书编号");Label lbreaderid = new Label("读者编号");TextField tf_bookid = new TextField();TextField tf_readerid = new TextField();Button queryBtn = new Button("查询");Label lbbookinfo = new Label(SepLine + "图书信息" + SepLine); Label lbbookname = new Label("图书名称:");Label tf_bookname = new Label("xx");Label lbauthor = new Label("作者:");Label tf_author = new Label("xx");Label lbpublisher = new Label("出版社:");Label tf_publisher = new Label("xx");Label lbpublish_time = new Label("出版时间:");Label tf_publish_time = new Label("xx");Label lbprice = new Label("定价:");Label tf_price = new Label("xx");Label lbstock = new Label("库存数量:");Label tf_stock = new Label("xx");Label lbreaderinfo = new Label(SepLine + "读者信息" + SepLine); Label lbreadername = new Label("读者姓名:");Label tf_readername = new Label("xx");Label lbreadertype = new Label("读者类型:");Label tf_readertype = new Label("xx");Label lbmax_num = new Label("最大可借数:");Label tf_max_num = new Label("xx");Label lbdays_num = new Label("最大可借天数:");Label tf_days_num = new Label("xx");Label lbborrowinfo = new Label(SepLine + "借阅信息" + SepLine); Label lbborrowednum = new Label("该读者已借图书数量:"); Label tf_borrowednum = new Label("xx");Label lbif_borrow = new Label("该读者是否可借所选图书:"); Label tf_if_borrow = new Label("xx");Label lbborrow_date = new Label("借阅日期:");Label tf_borrow_date = new Label("xx");Button borrowBtn = new Button("借出");Button closeBtn = new Button("关闭");public Borrow() {setLayout(null);setTitle("借阅图书");setSize(500, 420);this.setForeground(Color.BLACK); // 设置前景色为黑色lbbookid.setBounds(30, 40, 50, 25); // 图书编号tf_bookid.setBounds(90, 40, 90, 20);lbreaderid.setBounds(200, 40, 50, 25); // 读者编号tf_readerid.setBounds(260, 40, 90, 20);queryBtn.setBounds(370, 40, 80, 25); // 查询按钮lbbookinfo.setBounds(30, 70, 440, 25); // 图书信息提示条lbbookname.setBounds(30, 100, 60, 25); // 图书名称tf_bookname.setBounds(90, 100, 200, 25);lbauthor.setBounds(310, 100, 60, 25); // 作者tf_author.setBounds(370, 100, 90, 25);lbpublisher.setBounds(30, 125, 60, 25); // 出版社tf_publisher.setBounds(90, 125, 200, 25);lbpublish_time.setBounds(310, 125, 60, 25); // 出版时间tf_publish_time.setBounds(370, 125, 90, 25);lbprice.setBounds(30, 150, 60, 25); // 定价tf_price.setBounds(90, 150, 200, 25);lbstock.setBounds(310, 150, 60, 25); // 库存数量tf_stock.setBounds(370, 150, 90, 25);lbreaderinfo.setBounds(30, 180, 440, 25); // 读者信息提示条lbreadername.setBounds(30, 205, 60, 25); // 读者姓名tf_readername.setBounds(90, 205, 90, 25);lbreadertype.setBounds(310, 205, 60, 25); // 读者类型tf_readertype.setBounds(370, 205, 90, 25);lbmax_num.setBounds(30, 230, 75, 25); // 最大可借数tf_max_num.setBounds(105, 230, 90, 25);lbdays_num.setBounds(310, 230, 85, 25); // 最大可借天数tf_days_num.setBounds(395, 230, 70, 25);lbborrowinfo.setBounds(30, 260, 440, 25); // 借阅信息提示条lbborrowednum.setBounds(30, 285, 120, 25);// 已借图书数量tf_borrowednum.setBounds(150, 285, 50, 25);lbif_borrow.setBounds(30, 310, 145, 25); // 是否可借tf_if_borrow.setBounds(175, 310, 50, 25);lbborrow_date.setBounds(30, 335, 60, 25);// 借书日期tf_borrow_date.setBounds(90, 335, 100, 25);borrowBtn.setBounds(160, 365, 80, 25);// 借出按钮borrowBtn.setEnabled(false); // 开始时禁用借出按钮closeBtn.setBounds(260, 365, 80, 25);// 关闭按钮queryBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) { btn_querywActionPerformed(e); } }); borrowBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) { btn_borrowActionPerformed(e); } });closeBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) { setForeground(Color.BLACK); dispose(); } }); this.addWindowListener(new WindowAdapter() {public void windowClosing(WindowEvent e) {setForeground(Color.BLACK); // 设置前景色为黑色dispose(); // 关闭窗体}});add(lbbookid);add(lbreaderid);add(queryBtn);add(lbbookinfo);add(lbbookname);add(lbauthor);add(lbpublisher);add(lbpublish_time);add(lbprice);add(lbstock);add(lbreaderinfo);add(lbreadername);add(lbreadertype);add(lbmax_num);add(lbdays_num);add(lbborrowinfo);add(lbborrowednum);add(lbif_borrow);add(lbborrow_date);add(borrowBtn);add(closeBtn);setLocationRelativeTo(null); // 使窗体在屏幕上居中放置setVisible(true); // 使窗体可见setForeground(Color.RED); // 设置前景色为红色add(tf_bookid);add(tf_readerid);add(tf_bookname);add(tf_author);add(tf_publisher);add(tf_publish_time);add(tf_price);add(tf_stock);add(tf_readername);add(tf_readertype);add(tf_max_num);add(tf_days_num);add(tf_borrowednum);add(tf_if_borrow);add(tf_borrow_date);}// 图书和读者查询private void btn_querywActionPerformed(ActionEvent e) {String bookid = tf_bookid.getText();String readerid = tf_readerid.getText();// 如果图书编号或读者编号两者均为空,或者有一个为空,则返回if (bookid.equals("") || readerid.equals("")) {JOptionPane.showMessageDialog(null, "图书编号和读者编号均不能为空!");init(); // 重新初始化各参数并禁止借出按钮return;}// 按编号查询图书,结果存入book对象中Book book = BookSelect.SelectBookById(bookid);if (book != null) { // 如果查询到结果,将其显示在各文本框中tf_bookname.setText(book.getBookname());tf_author.setText(book.getAuthor());tf_publisher.setText(book.getPublisher());tf_publish_time.setText(book.getPublish_time().toString());tf_price.setText(String.valueOf((book.getPrice())));tf_stock.setText(String.valueOf(book.getStock()));} else {JOptionPane.showMessageDialog(null, "图书编号有误,查无此书!");init(); // 重新初始化各参数并禁止借出按钮return;}if (book.getStock() == 0) {JOptionPane.showMessageDialog(null, "图书已无库存,无法借阅!");init(); // 重新初始化各参数并禁止借出按钮return;}// 按编号查询读者,结果存入reader对象中Reader reader = ReaderSelect.selectReaderById(readerid);// 如果查询到结果,将其显示在各文本框中if (reader != null) {tf_readername.setText(reader.getReadername());tf_readertype.setText(reader.getReadertype());tf_max_num.setText(String.valueOf(reader.getMax_num()));tf_days_num.setText(String.valueOf(reader.getDays_num()));} else {JOptionPane.showMessageDialog(null, "读者编号有误,查无此人!");init(); // 重新初始化各参数并禁止借出按钮return;}// 查询指定读者是否已借过指定图书且未归还if (IfBorrowBack.findbook(bookid, readerid)) {JOptionPane.showMessageDialog(null, "该读者已借阅所选图书,且未归还!");init(); // 重新初始化各参数并禁止借出按钮return;}// 统计读者所借图书数量int borrowednum = statborrowednum(readerid);tf_borrowednum.setText(String.valueOf(borrowednum));// 如果读者已借图书尚未超出其允许最大借书量,则允许其继续借阅所选图书if (borrowednum < reader.getMax_num()) {tf_if_borrow.setText("是");// 创建一个简单日期格式对象,注意:MM一定要用大写SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");// 创建日期变量,其内容为当前日期Date currentdate = new Date();// 将日期按指定格式输出String borrowdate = sdf.format(currentdate);tf_borrow_date.setText(borrowdate);borrowBtn.setEnabled(true); // 使借出按钮有效} else {JOptionPane.showMessageDialog(null, "该读者借书过多,无法继续借阅!");init(); // 重新初始化各参数并禁止借出按钮return;}}// 填写借出图书记录private void btn_borrowActionPerformed(ActionEvent e) {String sql;String bookid = tf_bookid.getText();String readerid = tf_readerid.getText();String borrowdate = tf_borrow_date.getText();// 为borrow表增加借书记录sql = "insert into borrow (book_id,reader_id,"+ "borrow_date,if_back) values('" + bookid + "','" + readerid + "','" + borrowdate + "','否')";。
java课程设计图书馆管理系统代码
Java课程设计:图书馆管理系统代码介绍本文档是关于使用Java编写的图书馆管理系统代码的设计和实现。
图书馆管理系统是一种用于管理图书馆藏书、借还书籍和读者信息的应用程序。
它可以帮助图书馆提高管理效率和服务质量,并提供方便的读者查询和借还书的功能。
功能和需求1.用户管理:图书馆管理员可以添加、删除和编辑读者信息,包括姓名、联系方式和借书情况等。
2.图书管理:管理员可以添加、删除和编辑图书信息,包括书名、作者、出版日期和库存数量等。
3.借书和还书功能:读者可以借阅图书,管理员可以归还已借出的图书,并更新库存数量。
4.图书查询功能:读者可以根据图书名称、作者或出版日期等条件进行图书查询,以了解图书的详细信息和当前库存情况。
5.借阅记录查询:管理员可以查询读者的借阅记录,包括借阅时间、归还时间和借阅状态等。
系统设计数据模型系统设计采用面向对象的编程思想,主要包括以下几个类:图书馆类(Library)•属性:–读者列表(Reader[] readers)–图书列表(Book[] books)•方法:–添加读者(addReader)–删除读者(removeReader)–编辑读者信息(editReader)–添加图书(addBook)–删除图书(removeBook)–编辑图书信息(editBook)–借书(borrowBook)–还书(returnBook)–图书查询(searchBook)–借阅记录查询(searchRecords)读者类(Reader)•属性:–姓名(String name)–联系方式(String contact)–借阅记录列表(Record[] records)•方法:–借书(borrowBook)–还书(returnBook)图书类(Book)•属性:–书名(String title)–作者(String author)–出版日期(Date publicationDate)–库存数量(int quantity)•方法:–增加库存(increaseQuantity)–减少库存(decreaseQuantity)借阅记录类(Record)•属性:–图书(Book book)–读者(Reader reader)–借阅日期(Date borrowDate)–归还日期(Date returnDate)•方法:–设置归还日期(setReturnDate)系统流程图下图展示了图书馆管理系统的基本流程:graph LRA[开始] --> B[登录]B --> C{用户类型}C -->|管理员| E[管理图书馆]C -->|读者| F[查询图书]F --> G{查询类型}G -->|书名| H[查询结果]G -->|作者| H[查询结果]G -->|出版日期| H[查询结果]F --> I[返回主菜单]I --> FE --> J{操作类型}J -->|添加读者| K[输入读者信息]K --> L[保存读者信息]J -->|删除读者| M[输入读者ID]M --> N[删除读者信息]J -->|编辑读者| O[输入读者ID]O --> P[输入更新信息]P --> Q[更新读者信息]J -->|添加图书| R[输入图书信息]R --> S[保存图书信息]J -->|删除图书| T[输入图书ID]T --> U[删除图书信息]J -->|编辑图书| V[输入图书ID]V --> W[输入更新信息]W --> X[更新图书信息]J -->|借书| Y[输入读者ID和图书ID]Y --> Z[创建借阅记录]J -->|还书| A1[输入借阅记录ID]A1 --> B1[设置归还日期]B1 --> C1[更新借阅记录]J -->|查询借阅记录| D1[输入读者ID]D1 --> E1[查询借阅记录信息]代码实现以下是Java图书馆管理系统的代码实现:public class Library {private Reader[] readers;private Book[] books;public void addReader(Reader reader) {// 添加读者}public void removeReader(int readerId) {// 删除读者}public void editReader(int readerId, Reader reader) { // 编辑读者信息}public void addBook(Book book) {// 添加图书}public void removeBook(int bookId) {// 删除图书}public void editBook(int bookId, Book book) { // 编辑图书信息}public void borrowBook(int readerId, int bookId) { // 借书}public void returnBook(int recordId) {// 还书}public Book[] searchBook(String keyword) {// 图书查询}public Record[] searchRecords(int readerId) { // 借阅记录查询}}public class Reader {private String name;private String contact;private Record[] records;public void borrowBook(int bookId) {// 借书}public void returnBook(int recordId) {// 还书}}public class Book {private String title;private String author;private Date publicationDate;private int quantity;public void increaseQuantity(int amount) {// 增加库存}public void decreaseQuantity(int amount) {// 减少库存}}public class Record {private Book book;private Reader reader;private Date borrowDate;private Date returnDate;public void setReturnDate(Date returnDate) {// 设置归还日期}}快速开始编译和运行图书馆管理系统的示例代码,请按照以下步骤:1.准备Java开发环境。
用java做的一个图书管理系统的源代码.doc
用 java 做的一个图书管理系统的源代码import .*;import .*;public class T{public static void main(String[] args) throws Exception{Connection conn=null;Statement stmt=null;ResultSet rs=null;while(true){Scanner scanner=new Scanner;"请输入用户名:");String username2=();"请输入密码:");String password2=();if(!("")||(""))){try{("");conn=("jdbc:odbc:book","","");String sql="select * from ww where username='"+username2+"'";stmt=();rs=(sql);if()){if("password").equals(password2)){"*********欢迎来山东科技大学图书馆管理系统********");while(true){" 1.图书信息");" 2. 读者信息");" 3. 管理员信息");" 4.借阅信息");" 5. 还书信息");" 6.逾期罚款或损坏赔偿信息");出");" 请输入选择功能的序号:"); int a=();switch(a){case 1:" 图书信息 : ");" 1. 查询图书信息 : ");" 2. 插入图书信息 : ");" 3. 删除图书信息 : ");" 4. 修改图书信息 : ");int a1=();switch(a1){case 1:" " "欢迎进入图书信息查询系统1. 无条件查询图书信息:2. 条件查询图书信息::");");");int d=();switch(d){case 1:int llll=0;无条件查询图书信息:");String Sql0 = "SELECT * FROM systembook ";rs= (Sql0);while()){String bookID =(1);String bookNo =(2);String bookName =(3);String bookWriter =(4);String bookPub =(5);","+bookNo+","+bookName+","+ bookWriter+","+bookPub);}"是否继续插入 yes/no no 返回主菜单 ");String k=();if("yes"))};if("no")){llll=1;};}break;条件查询图书信息 : ");" 1. 单条件查询图书信息: ");" 2. 模糊条件查询图书信息: ");" 3. 多表连接查询图书信息: ");" 4. 嵌套查询图书信息 : ");" 5. 谓词演算查询");int c12=();switch(c12){case 1:" 1.单条件查询 :");" 1.按图书名编码号查询图书信息:");int ddd=0;while(ddd!=1){"请输入图书编码号:");String A=();String sql1= "SELECT * FROM systembook WHERE bookID ='"+A+"' ";rs= (sql1);int x=0;while()){String a2 =(1);String b2 =(2);String c2 =(3);String d2 =(4);String e2 =(5);","+b2+" ,"+c2+","+d2+","+e2);x++;}if(x==0){" 查无此书 ,请重新输入 ");else{"是否继续按姓名查询yes/no no 返回主菜单 ");String k=();if("yes")){};if("no")){ddd=1;};};}break;case 2:" 2.模糊查询图书信息:");int dc=0;while(dc!=1){" 请用户输入图书名字中的模糊关键字");String E=();String sq123= "SELECT * FROM systembook WHERE bookName LIKE'"+E+"%'";rs= (sq123);int z=0;while()){String a2 =(1);String b2 =(2);String c2 =(3);String d2 =(4);String e2 =(5);","+b2+" ,"+c2+","+d2+","+e2);z++;}if(z==0){" 查无此书 ,请重新输入 ");}else{"是否继续输入图书名字中的模糊关键字yes/no no 返回主菜单 ");String k=();if("yes")){};if("no")){dc=1;表连接查询查询图书信息: ");int dq=0;while(dq!=1){" 查询逾期罚款或是赔偿表中的读者的相关信息");" 请输入逾期罚款或是赔偿的读者编码号");String F=();String sq1234= "SELECT * FROM fine,borrowbook,systemreader WHERE = AND = AND ='"+F+"' ";rs= (sq1234);int n=0;while()){String a2 =(1);String b2 =(2);String c2 =(3);String d2 =(4);String e2 =(5);","+b2+" ,"+c2+","+d2+","+e2);n++;}if(n==0){" 查无此人 ,请重新输入 ");}else{" 是否继续输入图书名字中的模糊关键字yes/no no 返回主菜单 ");if("yes")){};if("no")){ddd=1;};}}break;case 4:" 4.嵌套查询图书信息:");int dq1=0;while(dq1!=1){"查询某读者所在年级女读者的相关信息");"请输入某读者的读者编号");String G=();String sq12345= "SELECT * FROM systemreader WHERE reaGrade=(SELECT reaGrade FROM systemreader WHERE reaID='"+G+"') AND reasex='女'"; rs= (sq12345);int m=0;while()){String a2 =(1);String b2 =(2);String c2 =(3);String d2 =(4);String e2 =(5);","+b2+" ,"+c2+","+d2+","+e2);m++;}if(m==0){" 查无此书 ,请重新输入 ");}else{"是否继续输入读者编号yes/no no 返回主菜单 ");if("yes")){};if("no")){d=1;};}}break;case 5:" 5. 谓词演算查询:");int dq1123=0;while(dq1123!=1){"查询借阅了某本书的读者的相关信息");"请输入该书的名字");String H=();String sq123456= "SELECT* FROM systemreader WHERE reaID IN (SELECT reaID FROM borrowbook WHERE bookName='"+H+"')";rs= (sq123456);int l=0;while()){String a2 =(1);String b2 =(2);String c2 =(3);String d2 =(4);String e2 =(5);","+b2+" ,"+c2+","+d2+","+e2);l++;}if(l==0){" 查无此人 ,请重新输入 ");}else{" 是否继续输入图书名字yes/no no 返回主菜单");String k=();if("yes")){} ;if("no")){d=1;};}}break;}查询图书信息 :");String Sql = "SELECT * FROM systembook ";rs= (Sql);while()){插入图书信息: " 请按顺序插入图书条码号");,图书索书号,图书名字,图书作者,图书出版社");String str=();String []splitst=(",");String a11=splitst[0];String a12=splitst[1];String a13=splitst[2];String a14=splitst[3];String a15=splitst[4];String insertSql="INSERT INTO systembook(bookID,bookNo,bookName,bookWriter,bookPub) VALUES('"+a11+"','"+a12+"','"+a13+"','"+a14+"','"+a15+"')";int i=(insertSql);删除图书信息:");"请输入要删除的图书编号:");String Str=();String []Splitst=(",");String b3=Splitst[0];String sql1="SELECT * FROM systembook where bookID='"+b3+"'";rs= (sql1);int kkk=0;while()){String a22 =(1);String b22 =(2);String c22 =(3);String d22 =(4);String e22 =(5);String f22 =(6);","+b22+" ,"+c22+","+d22+","+e22+","+f22);kkk++;}if(kkk==0){"没有这本书,请重新输入");}else{{String deleSql= "DELETE FROM systembook WHEREbookID='"+b3+"'";int p=(deleSql);修改图书信息:");"请输入修改的图书ID");String S=();String sql1="SELECT * FROM systembook where bookID='"+S+"'";rs= (sql1);int lll=0;while()){String a222 =(1);String b222 =(2);String c222 =(3);String d222 =(4);String e222 =(5);String f222 =(6);","+b222+" ,"+c222+","+d222+","+e222+","+f222);lll++;}if(lll==0){"没有这本书,请重新输入");}else{"要将书名改为");String bbb=();String updateSql1="UPDATE systembook SET bookName='"+bbb+"' WHERE bookID='"+S+"'";int hh=(updateSql1);查询读者信息" 2. 插入读者信息 :");" 3. 删除读者信息 :");" 4. 修改读者信息:"int b1=();switch(b1){case 1:" 1. 查询读者信息 :"); :);");String ssql = "SELECT * FROM systemreader ";rs= (ssql);while()){插入读者信息 :");"请按顺序插入借书卡证号读者名字读者学号读者性别读者LBID 读者类型读者学院读者年级读者专业办证日期");String str=();String []splitst=(",");String b11=splitst[0];String b12=splitst[1];String b13=splitst[2];String b14=splitst[3];String b15=splitst[4];String b16=splitst[5];String b17=splitst[6];String b18=splitst[7];String b19=splitst[8];String b20=splitst[9];String insertSql="INSERT INTOsystemreader(reaID,reaName,reaNo,reaSex,reaLBID,reaType,reaDep,reaGrade,reaPre,reaDate) VALUES('"+b11+"','"+b12+"','"+b13+"','"+b14+"','"+b15+"','"+b16+"','"+b17+"','"+b18+"','"+b19+"' ,'"+b20+"')";int n=(insertSql);删除读者信息:");"请输入要删除的读者证号:");String Str=();String []Splitst=(",");String r=Splitst[0];String sql1="SELECT * FROM systemreader where reaID='"+r+"'";rs= (sql1);int kkk=0;while()){String a22 =(1);String b22 =(2);String c22 =(3);String d22 =(4);String e22 =(5);String f22 =(6);String g22 =(7);String h22 =(8);String i22 =(9);","+b22+" ,"+c22+","+d22+","+e22+","+f22+","+g22+","+h22+","+i22);kkk++;}if(kkk==0){"没有这个读者,请重新输入");}else{修改读者信息:");"请输入修改以后的读者的ID ");String S=();查询管理员信息 : ");" 2. 插入管理员信息 : ");" 3. 删除管理员信息 : ");" 4. 修改管理员信息 : ");" 5. 返回上一级");int c11=();switch(c11){case 1:" 1. 查询管理员信息: ");String Ssql = "SELECT * FROM manager ";rs= (Ssql);while()){插入管理员信息 :");" 请按顺序插入管理员的编号,管理员的姓名,管理员的性别,所管书库,电话,地址 ");String str=();String []splitst=(",");String a11=splitst[0];String a12=splitst[1];String a13=splitst[2];String a14=splitst[3];String a15=splitst[4];String a16=splitst[5];String insertSql="INSERT INTOmanager(mID,mName,mSex,mAuth,mTeleph,mAddre)VALUES('"+a11+"','"+a12+"','"+a13+"','"+a14+"','"+a15+"','"+a16+"')";int i=(insertSql);删除管理员信息:");"请输入要删除的管理员编号 :");String Str=();String []Splitst=(",");String b3=Splitst[0];String sql1="SELECT * FROM manager where mID='"+b3+"'";rs= (sql1);int kkk=0;while()){String a22 =(1);String b22 =(2);String c22 =(3);String d22 =(4);String e22 =(5);String f22 =(6);","+b22+" ,"+c22+","+d22+","+e22+","+f22);kkk++;}if(kkk==0){"没有这个管理员,请重新输入");}else{修改管理员信息: ");" 请输入要修改的管理员编号:");String S=();String []Ssplitst=(",");String c1=Ssplitst[0];String sql1="SELECT * FROM manager where mID='"+S+"'";rs= (sql1);int lll=0;while()){String a222 =(1);String b222 =(2);String c222 =(3);String d222 =(4);String e222 =(5);String f222 =(6);","+b222+" ,"+c222+","+d222+","+e222+","+f222);lll++;}if(lll==0){"没有这个管理员,请重新输入");}else{查询图书借阅信息信息: ");" 2. 插入图书借阅信息 : ");" 3. 删除图书借阅信息 : ");" 4. 修改图书借阅信息 : ");" 5. 返回上一级");int d=();switch(d){case 1:" 1. 查询图书借阅信息:");String Sql4 = "SELECT * FROM borrowbook ";rs= (Sql4);while()){String bookID =(1);String reaID =(2);String outDate =(3);String yhDate =(4);","+reaID+","+outDate+","+yhDate);}break;case 2:int zz=0;while(zz!=1){" 2. 插入图书借阅信息:");"请按顺序插入图书的的编号 ,读者编号 ,图书借出日期 ,图书归还日期 ");String str=();String []splitst=(",");String a11=splitst[0];String a12=splitst[1];String a13=splitst[2];String a14=splitst[3];删除图书借阅信息:");"请输入要删除的图书条码号 :");String Str=();String []Splitst=(",");String b3=Splitst[0];String sql1="SELECT * FROM borrowbook where bookID='"+b3+"'";rs= (sql1);int kkk=0;while()){String a22 =(1);String b22 =(2);String c22 =(3);String d22 =(4);修改借阅读书信息:");"请输入要修改的图书的 ID ");String S=();String []Ssplitst=(",");String c1=Ssplitst[0];String sql1="SELECT * FROM borrowbook where bookID='"+S+"'";rs= (sql1);int lll=0;while()){String a222 =(1);String b222 =(2);String c222 =(3);String d222 =(4);查询还书信息 : ");" 2. 插入还书信息 : ");" 3. 删除还书信息 : ");" 4. 修改还书信息 : ");" 5. 返回上一级");int e=();switch(e){case 1:"1. 查询还书信息 : ");sql = "SELECT * FROM return ";rs= (sql);while()){String reaID =(1);String bookID =(2);String bookName =(3);String inDate =(4);","+bookID+","+bookName+","+ inDate);}break;case 2:" 2. 插入还书信息:");"请按顺序插入读者卡号 ,图书编号 ,图书名称 ,还书日期 ");String str=();String []splitst=(",");String e1=splitst[0];String e2=splitst[1];String e3=splitst[2];String e4=splitst[3];String insertSql="INSERT INTO returnbook(reaID,bookID,bookName,inDate) VALUES('"+e1+"','"+e2+"','"+e3+"','"+e4+"')";int h=(insertSql); 删除还书书信息: ");"请输入要删除的读者证号:");String Str=();String []Splitst=(",");String f3=Splitst[0];String deleSql= "DELETE FROM return WHERE reaID='"+f3+"'";int w=(deleSql);查询罚款信息:");" 2. 插入罚款信息 : ");" 3. 删除罚款信息 : ");" 4. 修改罚款信息 : ");int g=();switch(g){case 1:"1. 查询罚款信息 : ");String Sssql = "SELECT * FROM fine ";rs= (Sssql);while()){插入罚款信息 : ");" 请按顺序插入读者卡号 , 图书编号 ,借书日期,超出日期 ,应缴罚款 ");String str=();String []splitst=(",");String g1=splitst[0];String g2=splitst[1];String g3=splitst[2];String g4=splitst[3];String g5=splitst[4];删除罚款信息 : ");"请输入要删除的读者证号:");String Str=();String []Splitst=(",");String r=Splitst[0];String deleSql= "DELETE FROM fine WHERE reaID='"+r+"'";int x=(deleSql); 查询借阅历史信息 : ");" 2. 插入借阅历史信息 : ");" 3. 删除借阅历史信息 : ");" 4. 修改借阅历史信息 : ");" 5. 返回上一级");int h=();switch(h){case 1:" 1. 查询历史借阅信息:");String Sql7 = "SELECT * FROM borrowhistory ";rs= (Sql7);while()){String bookID =(1);String reaID =(2);String bookName=(3);String bookWriter=(4);String outDate =(5);String yhDate =(6);","+reaID+","+bookName+","+bookWriter+","+outDate+","+yhDate);}break;case 2:" 2. 插入图书历史借阅信息:");"请按顺序插入图书的的编号 ,读者编号 ,,图书借出日期 ,图书归还日期 ");String str=();String []splitst=(",");String a11=splitst[0];String a12=splitst[1];String a13=splitst[2];String a14=splitst[3];删除图书历史借阅信息:");" 请输入要删除的图书条码号:");String Str=();String []Splitst=(",");String d3=Splitst[0];String deleSql= "DELETE bookID FROM borrowhistory WHERE bookID='"+d3+"'";int k=(deleSql);修改图书借阅历史信息" 请输入要修改的图书的借出日期String S=();:");");String []Ssplitst=(",");String c1=Ssplitst[0];String updateSql="UPDATE borrow SET outDate='"+c1+"' WHERE bookName=' 数据库 '";int t=(updateSql); // 返回记录影响的条数if(t!=0){" 修改成功 !");}break;}}}}}else{"非法用户! ");}}catch(SQLException e) {();}//();();();}}}}。
用java做的一个图书管理系统的源代码
用j a v a做的一个图书管理系统的源代码标准化文件发布号:(9312-EUATWW-MWUB-WUNN-INNUL-DQQTY-用java做的一个图书管理系统的源代码import .*;import .*;public class T{public static void main(String[] args) throws Exception{Connection conn=null;Statement stmt=null;ResultSet rs=null;while(true){Scanner scanner=new Scanner;"请输入用户名:");String username2=();"请输入密码:");String password2=();if(!("")||(""))){try{("");conn=("jdbc:odbc:book","","");String sql="select * from ww where username='"+username2+"'"; stmt=();rs=(sql);if()){if("password").equals(password2)){"*********欢迎来山东科技大学图书馆管理系统********"); while(true){" 1.图书信息 ");" 2.读者信息 ");" 3.管理员信息 ");" 4.借阅信息 ");" 5.还书信息 ");" 6.逾期罚款或损坏赔偿信息");出 ");" 请输入选择功能的序号 :");int a=();switch(a){case 1:" 图书信息: ");" 1. 查询图书信息: ");" 2. 插入图书信息: ");" 3. 删除图书信息: ");" 4. 修改图书信息: ");int a1=();switch(a1){case 1:" 欢迎进入图书信息查询系统: ");" 1. 无条件查询图书信息: ");" 2. 条件查询图书信息: ");int d=();switch(d){case 1:int llll=0;无条件查询图书信息: ");String Sql0 = "SELECT * FROM systembook ";rs= (Sql0);while()){String bookID =(1);String bookNo =(2);String bookName =(3);String bookWriter =(4);String bookPub =(5);","+bookNo+","+bookName+","+ bookWriter+","+bookPub); }"是否继续插入yes/no no返回主菜单");String k=();if("yes")){};if("no")){llll=1;};}break;条件查询图书信息: ");" 1. 单条件查询图书信息: ");" 2. 模糊条件查询图书信息: ");" 3. 多表连接查询图书信息: ");" 4. 嵌套查询图书信息: ");" 5. 谓词演算查询 ");int c12=();switch(c12){case 1:" 1.单条件查询: ");" 1.按图书名编码号查询图书信息: ");int ddd=0;while(ddd!=1){"请输入图书编码号:");String A=();String sql1= "SELECT * FROM systembook WHERE bookID ='"+A+"' ";rs= (sql1);int x=0;while()){String a2 =(1);String b2 =(2);String c2 =(3);String d2 =(4);String e2 =(5);","+b2+" ,"+c2+","+d2+","+e2);x++;}if(x==0){"查无此书,请重新输入");}else{"是否继续按姓名查询yes/no no返回主菜单");String k=();if("yes")){};if("no")){ddd=1;};};}break;case 2:" 2.模糊查询图书信息: ");int dc=0;while(dc!=1){"请用户输入图书名字中的模糊关键字");String E=();String sq123= "SELECT * FROM systembook WHERE bookName LIKE'"+E+"%'";rs= (sq123);int z=0;while()){String a2 =(1);String b2 =(2);String c2 =(3);String d2 =(4);String e2 =(5);","+b2+" ,"+c2+","+d2+","+e2);z++;}if(z==0){"查无此书,请重新输入");else{"是否继续输入图书名字中的模糊关键字yes/no no返回主菜单");String k=();if("yes")){};if("no")){dc=1;表连接查询查询图书信息: ");int dq=0;while(dq!=1){"查询逾期罚款或是赔偿表中的读者的相关信息");"请输入逾期罚款或是赔偿的读者编码号");String F=();String sq1234= "SELECT * FROM fine,borrowbook,systemreader WHERE = AND = AND ='"+F+"' ";rs= (sq1234);int n=0;while()){String a2 =(1);String b2 =(2);String c2 =(3);String d2 =(4);String e2 =(5);","+b2+" ,"+c2+","+d2+","+e2);n++;}if(n==0){"查无此人,请重新输入");}else{"是否继续输入图书名字中的模糊关键字yes/no no返回主菜单");String k=();if("yes")){};if("no")){ddd=1;};}}break;case 4:" 4.嵌套查询图书信息: ");int dq1=0;while(dq1!=1){"查询某读者所在年级女读者的相关信息");"请输入某读者的读者编号");String G=();String sq12345= "SELECT * FROM systemreader WHERE reaGrade=(SELECT reaGrade FROM systemreader WHERE reaID='"+G+"') AND reasex='女'";rs= (sq12345);int m=0;while()){String a2 =(1);String b2 =(2);String c2 =(3);String d2 =(4);String e2 =(5);","+b2+" ,"+c2+","+d2+","+e2);m++;}if(m==0){"查无此书,请重新输入");}else{"是否继续输入读者编号yes/no no返回主菜单");String k=();if("yes"))};if("no")){d=1;};}}break;case 5:" 5. 谓词演算查询: ");int dq1123=0;while(dq1123!=1){"查询借阅了某本书的读者的相关信息");"请输入该书的名字");String H=();String sq123456= "SELECT * FROM systemreader WHERE reaID IN (SELECT reaID FROM borrowbook WHERE bookName='"+H+"')";rs= (sq123456);int l=0;while()){String a2 =(1);String b2 =(2);String c2 =(3);String d2 =(4);String e2 =(5);","+b2+" ,"+c2+","+d2+","+e2);l++;}if(l==0){"查无此人,请重新输入");}else{"是否继续输入图书名字yes/no no返回主菜单");String k=();if("yes")){};if("no")){d=1;};}}break;}查询图书信息: ");String Sql = "SELECT * FROM systembook ";rs= (Sql);while()){插入图书信息: ");"请按顺序插入图书条码号,图书索书号,图书名字,图书作者,图书出版社");String str=();String []splitst=(",");String a11=splitst[0];String a12=splitst[1];String a13=splitst[2];String a14=splitst[3];String a15=splitst[4];String insertSql="INSERT INTOsystembook(bookID,bookNo,bookName,bookWriter,bookPub)VALUES('"+a11+"','"+a12+"','"+a13+"','"+a14+"','"+a15+"')";int i=(insertSql); 删除图书信息: ");"请输入要删除的图书编号:");String Str=();String []Splitst=(",");String b3=Splitst[0];String sql1="SELECT * FROM systembook where bookID='"+b3+"'";rs= (sql1);int kkk=0;while()){String a22 =(1);String b22 =(2);String c22 =(3);String d22 =(4);String e22 =(5);String f22 =(6);","+b22+" ,"+c22+","+d22+","+e22+","+f22);kkk++;}if(kkk==0){"没有这本书,请重新输入");}else{{String deleSql= "DELETE FROM systembook WHERE bookID='"+b3+"'";int p=(deleSql); 修改图书信息: ");"请输入修改的图书ID ");String S=();String sql1="SELECT * FROM systembook where bookID='"+S+"'"; rs= (sql1);int lll=0;while()){String a222 =(1);String b222 =(2);String c222 =(3);String d222 =(4);String e222 =(5);String f222 =(6);","+b222+" ,"+c222+","+d222+","+e222+","+f222);lll++;}if(lll==0){"没有这本书,请重新输入");}else{"要将书名改为");String bbb=();String updateSql1="UPDATE systembook SET bookName='"+bbb+"' WHERE bookID='"+S+"'";int hh=(updateSql1); 查询读者信息: ");" 2. 插入读者信息: ");" 3. 删除读者信息: ");" 4. 修改读者信息: " );int b1=();switch(b1){case 1:" 1. 查询读者信息: ");String ssql = "SELECT * FROM systemreader ";rs= (ssql);while()){插入读者信息: ");"请按顺序插入借书卡证号读者名字读者学号读者性别读者LBID 读者类型读者学院读者年级读者专业办证日期");String str=();String []splitst=(",");String b11=splitst[0];String b12=splitst[1];String b13=splitst[2];String b14=splitst[3];String b15=splitst[4];String b16=splitst[5];String b17=splitst[6];String b18=splitst[7];String b19=splitst[8];String b20=splitst[9];String insertSql="INSERT INTOsystemreader(reaID,reaName,reaNo,reaSex,reaLBID,reaType,reaDep,reaGrade,reaPr e,reaDate)VALUES('"+b11+"','"+b12+"','"+b13+"','"+b14+"','"+b15+"','"+b16+"','"+b17+"','"+b18 +"','"+b19+"','"+b20+"')";int n=(insertSql); 删除读者信息: ");"请输入要删除的读者证号:");String Str=();String []Splitst=(",");String r=Splitst[0];String sql1="SELECT * FROM systemreader where reaID='"+r+"'";rs= (sql1);int kkk=0;while()){String a22 =(1);String b22 =(2);String c22 =(3);String d22 =(4);String e22 =(5);String f22 =(6);String g22 =(7);String h22 =(8);String i22 =(9);","+b22+" ,"+c22+","+d22+","+e22+","+f22+","+g22+","+h22+","+i22); kkk++;}if(kkk==0){"没有这个读者,请重新输入");}else{修改读者信息: ");"请输入修改以后的读者的ID ");String S=();查询管理员信息: ");" 2. 插入管理员信息: ");" 3. 删除管理员信息: ");" 4. 修改管理员信息: ");" 5. 返回上一级 ");int c11=();switch(c11){case 1:" 1. 查询管理员信息: ");String Ssql = "SELECT * FROM manager ";rs= (Ssql);while()){插入管理员信息: ");"请按顺序插入管理员的编号,管理员的姓名,管理员的性别,所管书库,电话,地址");String str=();String []splitst=(",");String a11=splitst[0];String a12=splitst[1];String a13=splitst[2];String a14=splitst[3];String a15=splitst[4];String a16=splitst[5];String insertSql="INSERT INTOmanager(mID,mName,mSex,mAuth,mTeleph,mAddre)VALUES('"+a11+"','"+a12+"','"+a13+"','"+a14+"','"+a15+"','"+a16+"')";int i=(insertSql); 删除管理员信息: ");"请输入要删除的管理员编号:");String Str=();String []Splitst=(",");String b3=Splitst[0];String sql1="SELECT * FROM manager where mID='"+b3+"'";rs= (sql1);int kkk=0;while()){String a22 =(1);String b22 =(2);String c22 =(3);String d22 =(4);String e22 =(5);String f22 =(6);","+b22+" ,"+c22+","+d22+","+e22+","+f22);kkk++;}if(kkk==0){"没有这个管理员,请重新输入");}else{修改管理员信息: ");"请输入要修改的管理员编号: ");String S=();String []Ssplitst=(",");String c1=Ssplitst[0];String sql1="SELECT * FROM manager where mID='"+S+"'"; rs= (sql1);int lll=0;while()){String a222 =(1);String b222 =(2);String c222 =(3);String d222 =(4);String e222 =(5);String f222 =(6);","+b222+" ,"+c222+","+d222+","+e222+","+f222); lll++;}if(lll==0){"没有这个管理员,请重新输入");}else{查询图书借阅信息信息: ");" 2. 插入图书借阅信息: ");" 3. 删除图书借阅信息: ");" 4. 修改图书借阅信息: ");" 5. 返回上一级 ");int d=();switch(d){case 1:" 1. 查询图书借阅信息: ");String Sql4 = "SELECT * FROM borrowbook ";rs= (Sql4);while()){String bookID =(1);String reaID =(2);String outDate =(3);String yhDate =(4);","+reaID+","+outDate+","+yhDate);}break;case 2:int zz=0;while(zz!=1){" 2. 插入图书借阅信息: ");"请按顺序插入图书的的编号,读者编号,图书借出日期,图书归还日期");String str=();String []splitst=(",");String a11=splitst[0];String a12=splitst[1];String a13=splitst[2];String a14=splitst[3];删除图书借阅信息: ");"请输入要删除的图书条码号:");String Str=();String []Splitst=(",");String b3=Splitst[0];String sql1="SELECT * FROM borrowbook where bookID='"+b3+"'";rs= (sql1);int kkk=0;while()){String a22 =(1);String b22 =(2);String c22 =(3);String d22 =(4);修改借阅读书信息: ");"请输入要修改的图书的ID ");String S=();String []Ssplitst=(",");String c1=Ssplitst[0];String sql1="SELECT * FROM borrowbook where bookID='"+S+"'";rs= (sql1);int lll=0;while()){String a222 =(1);String b222 =(2);String c222 =(3);String d222 =(4);查询还书信息: ");" 2. 插入还书信息: ");" 3. 删除还书信息: ");" 4. 修改还书信息: ");" 5. 返回上一级 ");int e=();switch(e){case 1:" 1. 查询还书信息: ");sql = "SELECT * FROM return ";rs= (sql);while()){String reaID =(1);String bookID =(2);String bookName =(3);String inDate =(4);","+bookID+","+bookName+","+ inDate);}break;case 2:" 2. 插入还书信息: ");"请按顺序插入读者卡号,图书编号,图书名称,还书日期");String str=();String []splitst=(",");String e1=splitst[0];String e2=splitst[1];String e3=splitst[2];String e4=splitst[3];String insertSql="INSERT INTOreturnbook(reaID,bookID,bookName,inDate)VALUES('"+e1+"','"+e2+"','"+e3+"','"+e4+"')";int h=(insertSql); 删除还书书信息: ");"请输入要删除的读者证号:");String Str=();String []Splitst=(",");String f3=Splitst[0];String deleSql= "DELETE FROM return WHERE reaID='"+f3+"'";int w=(deleSql); 查询罚款信息: ");" 2. 插入罚款信息: ");" 3. 删除罚款信息: ");" 4. 修改罚款信息: ");int g=();switch(g){case 1:" 1. 查询罚款信息: ");String Sssql = "SELECT * FROM fine ";rs= (Sssql);while()){插入罚款信息: ");"请按顺序插入读者卡号,图书编号,借书日期,超出日期,应缴罚款");String str=();String []splitst=(",");String g1=splitst[0];String g2=splitst[1];String g3=splitst[2];String g4=splitst[3];String g5=splitst[4];删除罚款信息: ");"请输入要删除的读者证号:");String Str=();String []Splitst=(",");String r=Splitst[0];String deleSql= "DELETE FROM fine WHERE reaID='"+r+"'";int x=(deleSql); 查询借阅历史信息: ");" 2. 插入借阅历史信息: ");" 3. 删除借阅历史信息: ");" 4. 修改借阅历史信息: ");" 5. 返回上一级 ");int h=();switch(h){case 1:" 1. 查询历史借阅信息: ");String Sql7 = "SELECT * FROM borrowhistory ";rs= (Sql7);while()){String bookID =(1);String reaID =(2);String bookName=(3);String bookWriter=(4);String outDate =(5);String yhDate =(6);","+reaID+","+bookName+","+bookWriter+","+outDate+","+yhDate);}break;case 2:" 2. 插入图书历史借阅信息: ");"请按顺序插入图书的的编号,读者编号,,图书借出日期,图书归还日期");String str=();String []splitst=(",");String a11=splitst[0];String a12=splitst[1];String a13=splitst[2];String a14=splitst[3];删除图书历史借阅信息: ");"请输入要删除的图书条码号:");String Str=();String []Splitst=(",");String d3=Splitst[0];String deleSql= "DELETE bookID FROM borrowhistory WHEREbookID='"+d3+"'";int k=(deleSql); 修改图书借阅历史信息: ");"请输入要修改的图书的借出日期 ");String S=();String []Ssplitst=(",");String c1=Ssplitst[0];String updateSql="UPDATE borrow SET outDate='"+c1+"' WHERE bookName='数据库'";int t=(updateSql); //返回记录影响的条数if(t!=0){"修改成功!");}break;}}}}}else{"非法用户!");}}catch(SQLException e) { ();}//();();();}}}}。
java编写的图书管理系统源代码
/用户登陆数据库代码:importjava.sql.*;classDatabase{Connectioncon;ResultSetrs;Statementstmt;publicDatabase(){try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");//加载JDBC-ODBC桥驱动程序Stringurl="jdbcdbc:HDB";con=DriverManager.getConnection(url);//连接数据库HDB//stmt提供一个创建SQL查询、执行查询、得到返回结果的空间stmt= //con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,//ResultSet.CONCUR_READ_ONLY);}catch(Exceptionex){System.out.println(ex);}}/*根据用户名,获取密码*/publicStringgetPswd(Stringname){try{//rs为执行SQL语句所查询的结果赋给结果集对象rsrs=stmt.executeQuery("SELECTpswdFROMUserWHEREName='"+name+"'");st();//把rs的指针移到最后一行if(rs.getRow()==0){returnnull;}else{StringpswdDB=rs.getString("Pswd");//获取rs结果集中的pswd列的数据returnpswdDB;}}catch(Exceptione){System.out.println(e);returnnull;}}/*增加一行用户名、密码数据*/publicbooleaninsertData(Stringname,Stringpswd){try{Strings=getPswd(name);if(s==null){intrtn=stmt.executeUpdate("INSERTINTOUserVALUES('"+name+"','"+pswd+"')");if(rtn!=0)returntrue;}else{returnfalse;}returnfalse;}catch(Exceptionet){System.out.println(et);returnfalse;}}}//进库数据库代码:importjava.sql.Connection;importjava.sql.DriverManager;importjava.sql.ResultSet;importjava.sql.Statement;classBookDatabase{Connectioncon;ResultSetrs;Statementstmt;publicBookDatabase(){try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");//加载JDBC-ODBC桥驱动程序Stringurl="jdbcdbc:Book";con=DriverManager.getConnection(url);//连接数据库HDB//stmt提供一个创建SQL查询、执行查询、得到返回结果的空间stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);}catch(Exceptionex){System.out.println(ex);}}/*增加一行用户名、密码数据*/publicbooleaninsertData(Stringid,Stringname,Stringwhere,Stringprice,Stringdate){try{intrtn=stmt.executeUpdate("INSERTINTOBookVALUES('"+id +"','"+name+"','"+where+"','"+price+"','"+date+"')");if(rtn!=0){returntrue;}else{returnfalse;}}catch(Exceptionet){System.out.println(et);returnfalse;}}/**publicbooleandeleteData(Stringid){try{intrtn=*stmt.executeUpdate("DELETEFROMBookWHEREid=001");if(rtn!=0){ *returntrue;}else{returnfalse;}}catch(Exceptione){*System.out.println(e);returnfalse;}}publicbooleanSelect(String*id){try{intrtn=stmt.executeUpdate("SELECT*FROMBookInWHERE *id='"+id+"'");**if(rtn!=0){returntrue;}else{returnfalse;}}catch(Exception*e){System.out.println(e);returnfalse;}}*/}//出库数据库代码:importjava.sql.Connection;importjava.sql.DriverManager;importjava.sql.ResultSet;importjava.sql.Statement;classBookDatabase1{Connectioncon;ResultSetrs;Statementstmt;publicBookDatabase1(){try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");//加载JDBC-ODBC桥驱动程序Stringurl="jdbcdbc:Book";con=DriverManager.getConnection(url);//连接数据库HDB//stmt提供一个创建SQL查询、执行查询、得到返回结果的空间stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);}catch(Exceptionex){System.out.println(ex);}}/**增加一行用户名、密码数据publicbooleaninsertData(Stringid,Stringname,String*where,String**price,Stringdate){try{intrtn=stmt.executeUpdate("INSERTINTO*BookInVALUES('"+id+**"','"+name+"','"+where+"','"+price+"','"+date+"')");**if(rtn!=0){returntrue;}else{returnfalse;}}catch(Exception*et){System.out.println(et);returnfalse;}}*/publicbooleandeleteData(Stringid){try{intrtn=stmt.executeUpdate("DELETEFROMBookWHEREid='"+id+"'");if(rtn!=0){returntrue;}else{returnfalse;}}catch(Exceptione){System.out.println(e);returnfalse;}}/**publicbooleanSelect(Stringid){try{intrtn=*stmt.executeUpdate("SELECT*FROMBookInWHEREid='"+id+"'");if(rtn!=*0){returntrue;}else{returnfalse;}}catch(Exceptione){*System.out.println(e);returnfalse;}}*/}//查询数据库代码;importjava.awt.*;importjava.awt.event.*;importjava.sql.*;importjavax.swing.*;classBookDatabase2extendsJFrame{Stringnumber,name,address,prices,day;Connectioncon;Statementstmt=null;ResultSetresult=null;Stringsql=null;publicBookDatabase2(){try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");//加载JDBC-ODBC桥驱动程序Stringurl="jdbc:odbc:Book";con=DriverManager.getConnection(url);//连接数据库HDB//stmt提供一个创建SQL查询、执行查询、得到返回结果的空间stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);}catch(Exceptionex){System.out.println(ex);}}publicvoidselect(Stringid){try{sql="SELECT*FROMBookwhereid='"+id+"'";result=stmt.executeQuery(sql);while(result.next()){number=result.getString(1);name=result.getString(2);address=result.getString(3);prices=result.getString(4);day=result.getString(4);}JOptionPane.showMessageDialog(BookDatabase2.this,"成功查询图书!\n"+"图书ID:"+number+"\n"+"图书名称:"+name+"\n"+"出版社"+address+"\n"+"价格:"+prices+"\n"+"出版日期:"+day+"\n","提示",JOptionPane.ERROR_MESSAGE);}catch(Exceptione){System.out.println(e);}}。
图书借阅管理系统java代码
以我给的标题写原创文档,最低1200字,要求以Markdown文本格式输出,不要带图片和AI、人工智能、Markdown、GPT等关键词,标题为:图书借阅管理系统java代码# 图书借阅管理系统Java代码## 一、介绍图书借阅管理系统是一个帮助图书馆管理图书借阅情况的系统。
本系统基于Java开发,采用面向对象的编程方式,实现了对图书信息、借阅记录等数据的管理与处理。
用户可以通过该系统查询图书信息、借阅图书、归还图书,并实现了管理员对系统的管理功能。
## 二、功能模块### 1. 图书管理模块- 实现对图书信息的添加、删除、修改和查询功能。
- 对图书的分类管理,方便用户按照分类查找图书信息。
### 2. 用户管理模块- 用户注册与登录功能,保证用户数据的安全。
- 用户查询借阅情况、借阅历史等个人信息。
### 3. 借阅管理模块- 实现图书的借阅功能,包括借书日期、归还日期等信息的记录。
- 用户借阅超时提醒,确保图书及时归还。
### 4. 管理员模块- 管理员登录后可以对图书信息、用户信息进行管理。
- 实现图书归还、逾期处理等功能。
## 三、系统架构本系统采用MVC(Model-View-Controller)架构,实现了模型层、视图层、控制层之间的分离,提高了系统的灵活性和可维护性。
具体架构如下:1. Model层:负责处理数据的逻辑操作,包括对图书信息、用户信息、借阅记录等数据的管理。
2. View层:负责系统的界面展示,包括用户界面和管理员界面。
3. Controller层:负责处理用户请求,调用Model层的方法,并将结果返回给View层进行展示。
## 四、代码示例以下是借阅图书的Java代码示例:```javapublic class BorrowBook {private Book book;private User user;private Date borrowDate;private Date returnDate;// Constructorpublic BorrowBook(Book book, User user, Date borrowDate, Date returnDate) {this.book = book;er = user;this.borrowDate = borrowDate;this.returnDate = returnDate;}// Getters and setters}```以上代码实现了一个借阅图书的类`BorrowBook`,包含了借阅的图书信息、用户信息,借阅时间和归还时间。
java图书管理系统代码版
目录第1章本设计所要达到的目的和要求设计目的设计要求第2章设计内容第3 章开发和运行环境介绍第4章需求分析1、本设计所要达到的目的和要求设计目的管理信息系统(MIS)的应用已深入到社会的各行各业,它是信息、软件与科学管理相结合的产物。
MIS的开发过程不仅是一个编写应用程序的过程,而且是一个以软件工程的思想为指导,从可行性研究开始,经过系统分析、系统设计、系统实施到等主要阶段的规范开发过程。
本题目实现的是JAVA系统,我们选择的是图书馆管理系统,不同角色的用户登录,用户信息的管理包括密码管理,及用户借还书,用户对图书信息及本人借还情况的查询,超级管理员对图书信息的增删查改,用户信息的增删查改及借还情况总的查询。
设计要求1、主题明确,软体开发要有创新性,能体现SQL的存储过程、触发器、游标技术等;2、用高级语言结合SQL Server数据库进行开发;3、写出数据库关系模式及相应的数据库表关系图;4、绘制成绩MIS相应的系统流程图、E-R图等;5、完成成绩MIS登陆界面、主界面、图书信息录入、图书信息查询和其各项设计与操作。
2、设计内容我们设计的图书馆管理系统主要用于对图书馆日常工作的管理,主要任务是用计算机对读者、图书等各种信息进行日常管理,如查询、修改、增加、删除、图书借阅和归还的管理等。
本系统实现了图书馆的信息化管理,完成了图书馆管理系统的基本功能。
该系统主要包括读者用户登录系统、管理员用户登入系统、图书管理系统、图书借阅、图书和用户信息查询子系统四个部分,各部分主要功能如下:读者用户登录子系统:用于数据库的连接,主界面的设计和读者身份用户的登录管理。
管理员用户登入系统:用于管理员用户的管理,如图书添加、图书信息修改。
图书管理系统:用于图书信息的管理,如新书入库、图书信息修改、图书信息删除。
图书借阅系统:用于用户借阅和归还图书。
图书和用户信息查询:图书和用户信息的查询。
留言系统:用于留言管理。
3、开发和运行环境介绍开发语言:前台开发语言为java,后台数据库为SQL server2000运行环境:eclipseEclipse是著名的跨平台的自有(IDE)。
java书店管理系统源代码
java书店管理系统源代码Java 源代码public class loaduser {public String user;public String password;boolean b1;loaduser(String s1,String s2){user=s1;password=s2;}void load(){System.out.println(" 书店管理销售系统");System.out.println("**************************************" );System.out.println(" 1、登录系统");System.out.println(" 2、退出系统");System.out.println("**************************************" );System.out.println("请选择:");int m;Scanner s=new Scanner(System.in);m=s.nextInt();if(m==1){for(int i=0;i<3;i++){System.out.println("请输入账户名和密码");String s3,s4;Scanner ss=new Scanner(System.in);s3=s.next();s4=s.next();if(user.equals(s3)&&password.equals(s4)) b1=true ;else b1=false;if(i==0&&b1==false)System.out.println("用户名或密码输入错误一次,还有两次机会!");if(i==1&&b1==false)System.out.println("用户名或密码输入错误两次,还有一次机会!");if(i==2&&b1==false){System.out.println("三次输入错误,退出系统!");System.exit(0);}if(b1==true){System.out.println("登录成功~");break;}}}if(m==2)System.exit(0);}package manger;import java.util.ArrayList; import java.util.Scanner; import manger.vip;import System.menu;public class vipmanger {static ArrayList<vip> vipgroup=new ArrayList<vip>(); public vipmanger(){vipgroup.add(new vip("001","王芳",100));vipgroup.add(new vip("002","李娜",60));vipgroup.add(new vip("003","杨丽",50));vipgroup.add(new vip("004","孙洁",150));vipgroup.add(new vip("005","肖青",300));}static void addd(){System.out.println("请一次输入编号,姓名,积分"); String S1,S2;int A;Scanner s=new Scanner(System.in);S1=s.next();S2=s.next();A=s.nextInt();vip v1=new vip (S1,S2,A);vipgroup.add(v1);}static void delete(){System.out.println("请输入要求删除的会员编号:"); String s;Scanner me=new Scanner (System.in);s=me.next();boolean b1=true;for(int i=0;i<vipgroup.size();i++)if(s.equals(vipgroup.get(i).ID)){vipgroup.remove(i);b1=false;}if(b1)System.out.println("查无此会员~");}static void correct(){System.out.println("请输入要修改信息的会员编号:"); String sss;Scanner s=new Scanner(System.in);sss=s.next();boolean b1=true;for(int i=0;i<vipgroup.size();i++)if(sss.equals(vipgroup.get(i).ID)){b1=false;System.out.println("请输入新的姓名和积分:");String ss1;Scanner s7=new Scanner(System.in);ss1=s7.next();vipgroup.get(i).name=ss1;int b;Scanner s8=new Scanner(System.in);b=s8.nextInt();vipgroup.get(i).score=b;}if(b1==true)System.out.println("查无此会员~");}static void select(){System.out.println("请输入要查询的会员编号:");String s;Scanner me=new Scanner(System.in);s=me.next();boolean b1=true ;for(int i=0;i<vipgroup.size();i++)if(s.equals(vipgroup.get(i).ID)){System.out.println(vipgroup.get(i).ID +" "+vipgroup.get(i).name+""+vipgroup.get(i).score);b1=false ;}if(b1==true)System.out.println("查无此会员~");}static void show(){for(int i=0;i<vipgroup.size();i++)System.out.println(vipgroup.get(i).ID+" "+vipgroup.get(i).name+" "+vipgroup.get(i).score);}public static void exchange(String s1,int a,int b){boolean b1=true;for(int i=0;i<vipgroup.size();i++)if(s1.equals(vipgroup.get(i).ID)){if(vipgroup.get(i).score<(a*b))System.out.println("积分不足,不能兑换~");else vipgroup.get(i).score-=a*b;b1=false;}if(b1==true)System.out.println("查无此会员,不能兑换~");}public static void shop(String s1,int a,int b){boolean b1=true;for( inti=0;i<vipgroup.size();i++)if(s1.equals(vipgroup.get(i).ID)){vipgroup.get(i).score+=a*b;b1=false;}if(b1==true)System.out.println("查无此会员,不能购买!"); }public static boolean start(){menu m=new menu();m.vip();int x;Scanner me= new Scanner(System.in);x=me.nextInt();switch(x){case 1:show();break;case 2:delete(); break;case 3:addd();break;case 4:correct();break;case 5:select();break;case 6:return false;}return true;}}public class book {public String number;public String name;public int price;public int jf;book(String s1,String s2,int a,int b){number=s1;name=s2;price=a;jf=b;}}package manger;import java.util.ArrayList;import java.util.Scanner;import System.menu;public class bookmanger {static ArrayList<book> bookgroup=new ArrayList<book>(); public bookmanger(){bookgroup.add(new book("001","c语言",20,20)); bookgroup.add(new book("002","大学英语",22,22)); bookgroup.add(new book("003","高等数学",28,28));}static void show(){for(int i=0;i<bookgroup.size();i++)System.out.println(bookgroup.get(i).number+""+bookgroup.get(i).name+" "+bookgroup.get(i).price+" "+bookgroup.get(i).jf);}static void addd(){System.out.println("请依次输入书籍的编号,名称,价格,积分:"); String S1,S2;int A,B;Scanner s=new Scanner(System.in);S1=s.next();S2=s.next();A=s.nextInt();B=s.nextInt();book b1=new book(S1,S2,A,B);bookgroup.add(b1);}static void delete(){System.out.println("请输入要删除的书籍编号:");String s11;Scanner me=new Scanner(System.in);s11=me.next();boolean b1=true;for(int i=0;i<bookgroup.size();i++)if(s11.equals(bookgroup.get(i).number)){bookgroup.remove(i);b1=false;}if(b1)System.out.println("查无此书~");}public static int price(String s1 ){int a=0;int i;for( i=0;i<bookgroup.size();i++)if(s1.equals(bookgroup.get( i).number))a=bookgroup.get(i).price;return a;}public static String name(String s1){String a = "无此书";for(inti=0;i<bookgroup.size();i++)if(s1.equals(bookgroup.get(i).nu mber))a=bookgroup.get(i).name;return a;}public static boolean start(){menu m=new menu();m.bookmanger();int x;Scanner me= new Scanner(System.in);x=me.nextInt();switch(x){case 1:show();break;case 2:delete();break;case 3:addd();break;case 4:return false;}return true;}}public class gift {public String number;public String caption ;public int costjf;gift(String s1,String s2,int a){ number=s1;caption=s2;costjf=a;}}package manger;import java.util.ArrayList; import java.util.Scanner;import manger.vipmanger;import manger.vip;import System.menu;import manger.gift;public class giftmanger {static ArrayList<gift> giftgroup=new ArrayList<gift>(); public giftmanger(){giftgroup.add(new gift("001","鼠标垫",100));giftgroup.add(new gift("002","书夹子",50));giftgroup.add(new gift("003","中性笔",30));}static void show(){for(int i=0;i<giftgroup.size();i++)System.out.println(giftgroup.get(i).number+""+giftgroup.get(i).caption+" "+giftgroup.get(i).costjf); }static void delete(){System.out.println("请输入要删除的礼品编号:");String s;Scanner ss=new Scanner(System.in);s=ss.next();boolean b1=true;for(int i=0;i<giftgroup.size();i++)if(s.equals(giftgroup.get(i).number)){giftgroup.remove(i);b1=false;}if(b1)System.out.println("查无此礼品~");}static void addd(){System.out.println("请输入要添加的礼品编号,名称,所需积分:"); String s1,s2;int a;Scanner me=new Scanner(System.in);s1=me.next();s2=me.next();a=me.nextInt();gift g1=new gift(s1,s2,a);giftgroup.add(g1);}static void exchange(){String s1,s2,c="无此礼品";int a,b=0;giftmanger.show();Scanner me=new Scanner(System.in);System.out.println("请输入您的会员编号:");s1=me.next();System.out.println("请输入您要兑换的礼品编号:");s2=me.next();System.out.println("请输入您要兑换的礼品数量:");a=me.nextInt();boolean b1=true;for(inti=0;i<giftgroup.size();i++)if(s2.equals(giftgroup.get(i).number)){b=giftgroup.get(i).costjf;c=giftgroup.get(i).caption;b1=false;}if(b1==true)System.out.println("查无此礼品~");else vipmanger.exchange(s1, a, b);System.out.println("兑换结果:");System.out.println("礼品名称"+" "+"礼品积分"+" "+"礼品数量"+" "+"消耗积分");System.out.println(c+" "+b+" "+a+""+(a*b));}public static boolean start(){menu m=new menu();m.gift();int x;Scanner me= new Scanner(System.in);x=me.nextInt();switch(x){case 1:show();break;case 2:delete();break;case 3:addd();break;case 4:exchange();break;case 5:return false;}return true;}}public class shoping {static void shop(){bookmanger.show();String s1,s2,s3;int a,b=0;Scanner me=new Scanner(System.in);System.out.println("请输入您的会员编号:");s1=me.next();System.out.println("请输入书籍编号:");s2=me.next();System.out.println("请输入购买数量:");a=me.nextInt();b=bookmanger.price(s2);s3=(s2);System.out.println("书名"+" "+"单价"+" "+"数量"+" "+"总价");System.out.println(s3+" "+b+" "+a+" "+(a*b)); vipmanger.shop(s1, a, b);}public static boolean start(){menu m=new menu();m.shopping();int x;Scanner me= new Scanner(System.in);x=me.nextInt();switch(x){case 1:shop();break;case 2:return false;}return true;}}public class menu {void mainmenu(){System.out.println(" 书店管理系统");System.out.println("****************************"); System.out.println("书店管理系统");System.out.println(" 1、会员管理");System.out.println(" 2、书籍管理");System.out.println(" 3、购物结算");System.out.println(" 4、积分兑换礼品");System.out.println(" 5、注销");System.out.println("****************************"); }public void vip(){System.out.println("书店管理系统>会员管理:"); System.out.println("****************************"); System.out.println("1、显示会员信息");System.out.println("2、删除会员");System.out.println("3、添加会员");System.out.println("4、修改会员信息");System.out.println("5、查询会员");System.out.println("6、返回上层菜单");System.out.println("****************************"); }public void bookmanger(){System.out.println("书店管理系统>书籍管理:"); System.out.println("****************************"); System.out.println("1、书籍信息查询");System.out.println("2、删除书籍");System.out.println("3、添加书籍");System.out.println("4、返回上层菜单");System.out.println("****************************"); }public void shopping(){System.out.println("书店管理系统>购物结算:");System.out.println("****************************"); System.out.println("1、购物");System.out.println("2、返回上层菜单");System.out.println("****************************"); }public void gift(){System.out.println("书店管理系统>礼品兑换:"); System.out.println("****************************"); System.out.println("1、礼品信息");System.out.println("2、删除礼品");System.out.println("3、添加礼品");System.out.println("4、兑换礼品");System.out.println("5、返回上层菜单");System.out.println("****************************"); }public static void main(String[] args) {loaduser u1=new loaduser("manger","416426");u1.load();menu m1=new menu();vipmanger vip=new vipmanger();bookmanger book=new bookmanger();giftmanger gi=new giftmanger();while (true){m1.mainmenu();int x;Scanner me=new Scanner(System.in);x=me.nextInt();switch(x){case 1:while( vipmanger.start());break ; case 2:while(bookmanger.start());break; case 3:while(shoping.start());break;case 4:while(giftmanger.start());break; case 5:u1.load();}}}}内部资料,请勿外传~精品资料精品资料精品资料精品资料精品资料序号名称规格型号单位数量备注一制冷系统1 压缩机组 4AV10 台 42 冷凝器 LN-70 台 13 贮氨器 ZA-1.5 台 14 桶泵组合 ZWB-1.5 台 15 氨液分离器 AF-65 台 16 集油器 JY-219 台 17 空气分离器 KF-32 台 18 紧急泄氨器 JX-108 台 1 9 冷风机 KLL-250 台 8 10 冷风机 KLD-150 台4 11 冷风机 KLD-100 台 2 12 阀门套 86 13 电磁阀套 6 14 管道及支架吨18.6 3 15 管道及设备保温 m22 16 管道保温包扎镀锌板吨 1.6 17 附件套 1 二气调系统 1 中空纤维制氮机 CA-30B 台 1 2 二氧化碳洗涤器 GA-15 台 1 3 气动电磁阀 D100 台 14 4 电脑控制系统 CNJK-406 台 1 5 信号转换器 8线台1 6 果心温度探头台 7 37 库气平衡袋 5 m 个 7 8 库气安全阀液封式个 7 9 小活塞空压机 0.05/7 台 1 10 PVC管套 1 11 附件套 1 三水冷系统 1 冷却塔 DBNL-100 台 2 32 水泵 SBL80-160I 台 23 水泵 SBL50-160I 台 24 阀门套 305 管道及支架吨 2.86 附件套 1 四电仪控系统 1 电器控制柜套 1 2 照明系统套 1 3 电线电缆套 1 4 桥架管线套 1 5 附件套 1。
用java做的一个图书管理系统的源代码
用java做的一个图书管理系统的源代码import java.sql.*;import java.util.*;public class T{public static void main(String[] args) throws Exception{Connection conn=null;Statement stmt=null;ResultSet rs=null;while(true){Scanner scanner=new Scanner(System.in);System.out.println("请输入用户名:");String username2=scanner.next();System.out.println("请输入密码:");String password2=scanner.next();if(!(username2.equals("")||password2.equals(""))){try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");conn=DriverManager.getConnection("jdbc:odbc:book","","");String sql="select * from ww where username='"+username2+"'";stmt=conn.createStatement();rs=stmt.executeQuery(sql);if(rs.next()){if(rs.getString("password").equals(password2)){System.out.println("*********欢迎来山东科技大学图书馆管理系统********");while(true){System.out.println(" 1.图书信息");System.out.println(" 2.读者信息");System.out.println(" 3.管理员信息");System.out.println(" 4.借阅信息");System.out.println(" 5.还书信息");System.out.println(" 6.逾期罚款或损坏赔偿信息");//System.out.println(" 7.退出");System.out.println(" 请输入选择功能的序号:");int a=scanner.nextInt();switch(a){case 1:System.out.println(" 图书信息: ");System.out.println(" 1. 查询图书信息: ");System.out.println(" 2. 插入图书信息: ");System.out.println(" 3. 删除图书信息: ");System.out.println(" 4. 修改图书信息: ");int a1=scanner.nextInt();switch(a1){case 1:System.out.println(" 欢迎进入图书信息查询系统: ");System.out.println(" 1. 无条件查询图书信息: ");System.out.println(" 2. 条件查询图书信息: ");int d=scanner.nextInt();switch(d){case 1:int llll=0;//int mm=0;while(llll!=1){System.out.println(" 1. 无条件查询图书信息: ");String Sql0 = "SELECT * FROM systembook ";rs= stmt.executeQuery(Sql0);while(rs.next()){String bookID =rs.getString(1);String bookNo =rs.getString(2);String bookName =rs.getString(3);String bookWriter =rs.getString(4);String bookPub =rs.getString(5);System.out.println(bookID+","+bookNo+","+bookName+","+ bookWriter+","+bookPub);}System.out.println("是否继续插入?yes/no no返回主菜单");String k=scanner.next();if(k.startsWith("yes")){System.out.println();};if(k.startsWith("no")){llll=1;System.out.println();};}break;//break;case 2:System.out.println(" 2. 条件查询图书信息: ");System.out.println(" 1. 单条件查询图书信息: ");System.out.println(" 2. 模糊条件查询图书信息: ");System.out.println(" 3. 多表连接查询图书信息: ");System.out.println(" 4. 嵌套查询图书信息: ");System.out.println(" 5. 谓词演算查询");int c12=scanner.nextInt();switch(c12){case 1:System.out.println(" 1.单条件查询: ");System.out.println(" 1.按图书名编码号查询图书信息: ");int ddd=0;while(ddd!=1){System.out.println("请输入图书编码号:");String A=scanner.next();String sql1= "SELECT * FROM systembook WHERE bookID ='"+A+"' ";rs= stmt.executeQuery(sql1);int x=0;while(rs.next()){String a2 =rs.getString(1);String b2 =rs.getString(2);String c2 =rs.getString(3);String d2 =rs.getString(4);String e2 =rs.getString(5);System.out.println(a2+","+b2+" ,"+c2+","+d2+","+e2);x++;}if(x==0){System.out.println("查无此书,请重新输入");}else{System.out.println("是否继续按姓名查询?yes/no no返回主菜单");String k=scanner.next();if(k.startsWith("yes")){System.out.println();};if(k.startsWith("no")){ddd=1;System.out.println();};};}break;case 2:System.out.println(" 2.模糊查询图书信息: ");int dc=0;while(dc!=1){System.out.println("请用户输入图书名字中的模糊关键字");String E=scanner.next();String sq123= "SELECT * FROM systembook WHERE bookName LIKE'"+E+"%'";rs= stmt.executeQuery(sq123);int z=0;while(rs.next()){String a2 =rs.getString(1);String b2 =rs.getString(2);String c2 =rs.getString(3);String d2 =rs.getString(4);String e2 =rs.getString(5);System.out.println(a2+","+b2+" ,"+c2+","+d2+","+e2);z++;}if(z==0){System.out.println("查无此书,请重新输入");}else{System.out.println("是否继续输入图书名字中的模糊关键字?yes/no no返回主菜单");String k=scanner.next();if(k.startsWith("yes")){System.out.println();};if(k.startsWith("no")){dc=1;System.out.println();// break;};}}break;case 3:System.out.println(" 3.多表连接查询查询图书信息: ");int dq=0;while(dq!=1){System.out.println("查询逾期罚款或是赔偿表中的读者的相关信息");System.out.println("请输入逾期罚款或是赔偿的读者编码号");String F=scanner.next();String sq1234= "SELECT * FROM fine,borrowbook,systemreader WHERE fine.bookID=borrowbook.bookID AND borrowbook.reaID=systemreader.reaID AND fine.bookID='"+F+"' ";rs= stmt.executeQuery(sq1234);int n=0;while(rs.next()){String a2 =rs.getString(1);String b2 =rs.getString(2);String c2 =rs.getString(3);String d2 =rs.getString(4);String e2 =rs.getString(5);System.out.println(a2+","+b2+" ,"+c2+","+d2+","+e2);n++;}if(n==0){System.out.println("查无此人,请重新输入");}else{System.out.println("是否继续输入图书名字中的模糊关键字?yes/no no返回主菜单");String k=scanner.next();if(k.startsWith("yes")){System.out.println();};if(k.startsWith("no")){ddd=1;System.out.println();};}}break;case 4:System.out.println(" 4.嵌套查询图书信息: ");int dq1=0;System.out.println("查询某读者所在年级女读者的相关信息");System.out.println("请输入某读者的读者编号");String G=scanner.next();String sq12345= "SELECT * FROM systemreader WHERE reaGrade=(SELECT reaGrade FROM systemreader WHERE reaID='"+G+"') AND reasex='女'";rs= stmt.executeQuery(sq12345);int m=0;while(rs.next()){String a2 =rs.getString(1);String b2 =rs.getString(2);String c2 =rs.getString(3);String d2 =rs.getString(4);String e2 =rs.getString(5);System.out.println(a2+","+b2+" ,"+c2+","+d2+","+e2);m++;}if(m==0){System.out.println("查无此书,请重新输入");}else{System.out.println("是否继续输入读者编号?yes/no no 返回主菜单");String k=scanner.next();if(k.startsWith("yes")){System.out.println();};if(k.startsWith("no")){d=1;System.out.println();};}}break;System.out.println(" 5. 谓词演算查询:");int dq1123=0;while(dq1123!=1){System.out.println("查询借阅了某本书的读者的相关信息");System.out.println("请输入该书的名字");String H=scanner.next();String sq123456= "SELECT * FROM systemreader WHERE reaID IN (SELECT reaID FROM borrowbook WHERE bookName='"+H+"')";rs= stmt.executeQuery(sq123456);int l=0;while(rs.next()){String a2 =rs.getString(1);String b2 =rs.getString(2);String c2 =rs.getString(3);String d2 =rs.getString(4);String e2 =rs.getString(5);System.out.println(a2+","+b2+" ,"+c2+","+d2+","+e2);l++;}if(l==0){System.out.println("查无此人,请重新输入");}else{System.out.println("是否继续输入图书名字?yes/no no返回主菜单");String k=scanner.next();if(k.startsWith("yes")){System.out.println();};if(k.startsWith("no")){d=1;System.out.println();};}}break;}//c12break;}break;/*case 1:System.out.println(" 1. 查询图书信息: ");String Sql = "SELECT * FROM systembook ";rs= stmt.executeQuery(Sql);while(rs.next()){//String str =scanner.next();String bookID =rs.getString(1);String bookNo =rs.getString(2);String bookName =rs.getString(3);String bookWriter =rs.getString(4);String bookPub =rs.getString(5);System.out.println(bookID+","+bookNo+","+bookName+","+ bookWriter+","+bookPub);}break;*/case 2:int zz=0;while(zz!=1){System.out.println(" 2. 插入图书信息: ");System.out.println("请按顺序插入图书条码号,图书索书号,图书名字,图书作者,图书出版社");String str=scanner.next();String []splitst=str.split(",");String a11=splitst[0];String a12=splitst[1];String a13=splitst[2];String a14=splitst[3];String a15=splitst[4];String insertSql="INSERT INTO systembook(bookID,bookNo,bookName,bookWriter,bookPub)VALUES('"+a11+"','"+a12+"','"+a13+"','"+a14+"','"+a15+"')";int i=stmt.executeUpdate(insertSql); //返回记录影响的条数if(i!=0){System.out.println("插入成功!"); }System.out.println("是否继续插入?yes/no no返回主菜单");String k=scanner.next();if(k.startsWith("yes")){System.out.println();};if(k.startsWith("no")){zz=1;System.out.println();};}break;case 3:int ll=0;//int mm=0;while(ll!=1){System.out.println(" 3. 删除图书信息: ");System.out.println("请输入要删除的图书编号:");String Str=scanner.next();String []Splitst=Str.split(",");String b3=Splitst[0];String sql1="SELECT * FROM systembook where bookID='"+b3+"'";rs= stmt.executeQuery(sql1);int kkk=0;while(rs.next()){String a22 =rs.getString(1);String b22 =rs.getString(2);String c22 =rs.getString(3);String d22 =rs.getString(4);String e22 =rs.getString(5);String f22 =rs.getString(6);System.out.println(a22+","+b22+" ,"+c22+","+d22+","+e22+","+f22);kkk++;}if(kkk==0){System.out.println( "没有这本书,请重新输入");}else{{String deleSql= "DELETE FROM systembook WHERE bookID='"+b3+"'";int p=stmt.executeUpdate(deleSql); //返回记录影响的条数if(p!=0){System.out.println("删除成功!");}System.out.println("是否继续删除?yes/no no返回主菜单");String l=scanner.next();if(l.startsWith("yes")){System.out.println();};if(l.startsWith("no")){ll=1;System.out.println();};};}}break;case 4:int mm=0;while(mm!=1){System.out.println(" 4. 修改图书信息: ");System.out.println("请输入修改的图书ID ");String S=scanner.next();String sql1="SELECT * FROM systembook where bookID='"+S+"'";rs= stmt.executeQuery(sql1);int lll=0;while(rs.next()){String a222 =rs.getString(1);String b222 =rs.getString(2);String c222 =rs.getString(3);String d222 =rs.getString(4);String e222 =rs.getString(5);String f222 =rs.getString(6);System.out.println(a222+","+b222+" ,"+c222+","+d222+","+e222+","+f222);lll++;}if(lll==0){System.out.println( "没有这本书,请重新输入");}else{System.out.println("要将书名改为");String bbb=scanner.next();String updateSql1="UPDATE systembook SET bookName='"+bbb+"' WHERE bookID='"+S+"'";int hh=stmt.executeUpdate(updateSql1); //返回记录影响的条数if(hh!=0){System.out.println("修改成功!");}System.out.println("是否继续修改yes/no no返回主菜单");String o=scanner.next();if(o.startsWith("yes")){System.out.println();};if(o.startsWith("no")){mm=1;System.out.println();};}}break;}break;/* String updateSql="UPDATE systembook SET bookCopy='"+c1+"' WHERE bookName='数据库管理'";int t=stmt.executeUpdate(updateSql); //返回记录影响的条数if(t!=0){System.out.println("修改成功!");}break;}break;*/case 2:System.out.println(" 读者信息: ");System.out.println(" 1. 查询读者信息: ");System.out.println(" 2. 插入读者信息: ");System.out.println(" 3. 删除读者信息: ");System.out.println(" 4. 修改读者信息: " );int b1=scanner.nextInt();switch(b1){case 1:System.out.println(" 1. 查询读者信息: ");String ssql = "SELECT * FROM systemreader ";rs= stmt.executeQuery(ssql);while(rs.next()){//String str =scanner.next();String reaID=rs.getString(1);String reaName =rs.getString(2);String reaLBID =rs.getString(3);String reaNo =rs.getString(4);String reaSex =rs.getString(5);String reaType =rs.getString(6);String reaDep =rs.getString(7);String reaGrade =rs.getString(8);String reaPre =rs.getString(9);String reaDate =rs.getString(10);System.out.println(reaID+","+reaName+","+reaNo+","+reaSex+","+reaLBID+","+reaType+","+reaD ep+","+reaGrade+","+reaPre+","+reaDate);}break;case 2:int zz=0;while(zz!=1){System.out.println(" 2. 插入读者信息: ");System.out.println("请按顺序插入借书卡证号读者名字读者学号读者性别读者LBID 读者类型读者学院读者年级读者专业办证日期");String str=scanner.next();String []splitst=str.split(",");String b11=splitst[0];String b12=splitst[1];String b13=splitst[2];String b14=splitst[3];String b15=splitst[4];String b16=splitst[5];String b17=splitst[6];String b18=splitst[7];String b19=splitst[8];String b20=splitst[9];String insertSql="INSERT INTO systemreader(reaID,reaName,reaNo,reaSex,reaLBID,reaType,reaDep,reaGrade,reaPre,reaDate) VALUES('"+b11+"','"+b12+"','"+b13+"','"+b14+"','"+b15+"','"+b16+"','"+b17+"','"+b18+"','"+b19+"' ,'"+b20+"')";int n=stmt.executeUpdate(insertSql); //返回记录影响的条数if(n!=0){System.out.println("插入成功!"); }System.out.println("是否继续插入?yes/no no返回主菜单");String k=scanner.next();if(k.startsWith("yes")){System.out.println();};if(k.startsWith("no")){zz=1;System.out.println();};}break;case 3:int ll=0;while(ll!=1){System.out.println(" 3. 删除读者信息: ");System.out.println("请输入要删除的读者证号:");String Str=scanner.next();String []Splitst=Str.split(",");String r=Splitst[0];String sql1="SELECT * FROM systemreader where reaID='"+r+"'";rs= stmt.executeQuery(sql1);int kkk=0;while(rs.next()){String a22 =rs.getString(1);String b22 =rs.getString(2);String c22 =rs.getString(3);String d22 =rs.getString(4);String e22 =rs.getString(5);String f22 =rs.getString(6);String g22 =rs.getString(7);String h22 =rs.getString(8);String i22 =rs.getString(9);System.out.println(a22+","+b22+" ,"+c22+","+d22+","+e22+","+f22+","+g22+","+h22+","+i22);kkk++;}if(kkk==0){System.out.println( "没有这个读者,请重新输入");}else{//System.out.println( "您是否真的要删除? yes/no");//String k=scanner.next();//if(k.startsWith("y")){String deleSql= "DELETE FROM systemreader WHERE reaID='"+r+"'";int p=stmt.executeUpdate(deleSql); //返回记录影响的条数if(p!=0){System.out.println("删除成功!");}System.out.println("是否继续删除?yes/no no返回主菜单");String l=scanner.next();if(l.startsWith("yes")){System.out.println();};if(l.startsWith("no")){ll=1;System.out.println();};};}}/* String deleSql= "DELETE FROM systemreader WHERE reaID='"+r+"'";int m=stmt.executeUpdate(deleSql); //返回记录影响的条数if(m!=0){System.out.println("删除成功!");}*/break;case 4:int mm=0;while(mm!=1){System.out.println(" 4. 修改读者信息: ");System.out.println("请输入修改以后的读者的ID ");String S=scanner.next();// String []Ssplitst=S.split(",");//String tt=Ssplitst[0];String sql1="SELECT * FROM systemreader where reaID='"+S+"'";rs= stmt.executeQuery(sql1);int lll=0;while(rs.next()){String a222 =rs.getString(1);String b222 =rs.getString(2);String c222 =rs.getString(3);String d222 =rs.getString(4);String e222 =rs.getString(5);String f222 =rs.getString(6);String g222 =rs.getString(7);String h222 =rs.getString(8);String i222 =rs.getString(9);String j222 =rs.getString(10);System.out.println(a222+","+b222+" ,"+c222+","+d222+","+e222+","+f222+","+g222+","+h222+", "+i222+","+j222);lll++;}if(lll==0){System.out.println( "没有这个人,请重新输入");}else{System.out.println("要将名字改为");String bb=scanner.next();String updateSql="UPDATE systemreader SET reaName='"+bb+"' WHERE reaID='"+S+"'";int hh=stmt.executeUpdate(updateSql); //返回记录影响的条数if(hh!=0){System.out.println("修改成功!");}System.out.println("是否继续修改yes/no no返回主菜单");String o=scanner.next();if(o.startsWith("yes")){System.out.println();};if(o.startsWith("no")){mm=1;System.out.println();};}}break;/* String updateSql="UPDATE systemreader SET reaSex='"+tt+"' WHERE reaID='20030101'";int l=stmt.executeUpdate(updateSql); //返回记录影响的条数if(l!=0){System.out.println("修改成功!");}break;*/}break;case 3:System.out.println(" 管理员信息: ");System.out.println(" 1. 查询管理员信息: ");System.out.println(" 2. 插入管理员信息: ");System.out.println(" 3. 删除管理员信息: ");System.out.println(" 4. 修改管理员信息: ");System.out.println(" 5. 返回上一级");int c11=scanner.nextInt();switch(c11){case 1:System.out.println(" 1. 查询管理员信息: ");String Ssql = "SELECT * FROM manager ";rs= stmt.executeQuery(Ssql);while(rs.next()){// String str =scanner.next();String mID =rs.getString(1);String mName=rs.getString(2);String mSex =rs.getString(3);System.out.println(mID+","+mName+","+mSex);}break;case 2:int zz=0;while(zz!=1){System.out.println(" 2. 插入管理员信息: ");System.out.println("请按顺序插入管理员的编号,管理员的姓名,管理员的性别,所管书库,电话,地址");String str=scanner.next();String []splitst=str.split(",");String a11=splitst[0];String a12=splitst[1];String a13=splitst[2];String a14=splitst[3];String a15=splitst[4];String a16=splitst[5];String insertSql="INSERT INTO manager(mID,mName,mSex,mAuth,mTeleph,mAddre)VALUES('"+a11+"','"+a12+"','"+a13+"','"+a14+"','"+a15+"','"+a16+"')";int i=stmt.executeUpdate(insertSql); //返回记录影响的条数if(i!=0){System.out.println("插入成功!");}System.out.println("是否继续插入?yes/no no返回主菜单");String k=scanner.next();if(k.startsWith("yes")){System.out.println();};if(k.startsWith("no")){zz=1;System.out.println();};}break;case 3:int ll=0;while(ll!=1){System.out.println(" 3. 删除管理员信息: ");System.out.println("请输入要删除的管理员编号:");String Str=scanner.next();String []Splitst=Str.split(",");String b3=Splitst[0];String sql1="SELECT * FROM manager where mID='"+b3+"'";rs= stmt.executeQuery(sql1);int kkk=0;while(rs.next()){String a22 =rs.getString(1);String b22 =rs.getString(2);String c22 =rs.getString(3);String d22 =rs.getString(4);String e22 =rs.getString(5);String f22 =rs.getString(6);System.out.println(a22+","+b22+" ,"+c22+","+d22+","+e22+","+f22);kkk++;}if(kkk==0){System.out.println( "没有这个管理员,请重新输入");}else{//System.out.println( "您是否真的要删除? yes/no");//String k=scanner.next();//if(k.startsWith("y")){String deleSql= "DELETE FROM manager WHERE mID='"+b3+"'";int p=stmt.executeUpdate(deleSql); //返回记录影响的条数if(p!=0){System.out.println("删除成功!");}System.out.println("是否继续删除?yes/no no返回主菜单");String l=scanner.next();if(l.startsWith("yes")){System.out.println();};if(l.startsWith("no")){ll=1;System.out.println();};};}}/* String deleSql= "DELETE mID FROM manager WHERE mID='"+b3+"'";int k=stmt.executeUpdate(deleSql); //返回记录影响的条数if(k!=0){System.out.println("删除成功!");}*/break;case 4:int mm=0;while(mm!=1){System.out.println(" 4. 修改管理员信息: ");System.out.println("请输入要修改的管理员编号:");String S=scanner.next();String []Ssplitst=S.split(",");String c1=Ssplitst[0];String sql1="SELECT * FROM manager where mID='"+S+"'";rs= stmt.executeQuery(sql1);int lll=0;while(rs.next()){String a222 =rs.getString(1);String b222 =rs.getString(2);String c222 =rs.getString(3);String d222 =rs.getString(4);String e222 =rs.getString(5);String f222 =rs.getString(6);System.out.println(a222+","+b222+" ,"+c222+","+d222+","+e222+","+f222);lll++;}if(lll==0){System.out.println( "没有这个管理员,请重新输入");}else{// System.out.println( "要修改的信息");//String aa=scanner.next();System.out.println("要将它改为");String bb=scanner.next();String updateSql="UPDATE manager SET mName='"+bb+"' WHERE mID='"+S+"'";int hh=stmt.executeUpdate(updateSql); //返回记录影响的条数if(hh!=0){System.out.println("修改成功!");}System.out.println("是否继续修改yes/no no返回主菜单");String o=scanner.next();if(o.startsWith("yes")){System.out.println();};if(o.startsWith("no")){mm=1;System.out.println();};}}break;}break;/*String updateSql="UPDATE manager SET mSex='"+c1+"' WHERE mID=1";int t=stmt.executeUpdate(updateSql); //返回记录影响的条数if(t!=0){System.out.println("修改成功!");}}break;*/case 4:System.out.println(" 图书借阅信息: ");System.out.println(" 1. 查询图书借阅信息信息: ");System.out.println(" 2. 插入图书借阅信息: ");System.out.println(" 3. 删除图书借阅信息: ");System.out.println(" 4. 修改图书借阅信息: ");System.out.println(" 5. 返回上一级");int d=scanner.nextInt();switch(d){case 1:System.out.println(" 1. 查询图书借阅信息: ");String Sql4 = "SELECT * FROM borrowbook ";rs= stmt.executeQuery(Sql4);while(rs.next()){String bookID =rs.getString(1);String reaID =rs.getString(2);String outDate =rs.getString(3);String yhDate =rs.getString(4);System.out.println(bookID+","+reaID+","+outDate+","+yhDate);}break;case 2:int zz=0;while(zz!=1){System.out.println(" 2. 插入图书借阅信息: ");System.out.println("请按顺序插入图书的的编号,读者编号,图书借出日期,图书归还日期");String str=scanner.next();String []splitst=str.split(",");String a11=splitst[0];String a12=splitst[1];String a13=splitst[2];String a14=splitst[3];//String a15=splitst[4];//String a16=splitst[5];String insertSql="INSERT INTO borrowbook(bookID,reaID,outDate,yhDate) VALUES('"+a11+"','"+a12+"','"+a13+"','"+a14+"')";int ii=stmt.executeUpdate(insertSql); //返回记录影响的条数if(ii!=0){System.out.println("插入成功!");}System.out.println("是否继续插入?yes/no no返回主菜单");String k=scanner.next();if(k.startsWith("yes")){System.out.println();};if(k.startsWith("no")){zz=1;System.out.println();};}break;case 3:int ll=0;while(ll!=1){System.out.println(" 3. 删除图书借阅信息: ");System.out.println("请输入要删除的图书条码号:");String Str=scanner.next();String []Splitst=Str.split(",");String b3=Splitst[0];String sql1="SELECT * FROM borrowbook where bookID='"+b3+"'";rs= stmt.executeQuery(sql1);int kkk=0;while(rs.next()){String a22 =rs.getString(1);String b22 =rs.getString(2);String c22 =rs.getString(3);String d22 =rs.getString(4);// String e22 =rs.getString(5);//String f22 =rs.getString(6);System.out.println(a22+","+b22+" ,"+c22+","+d22);kkk++;}if(kkk==0){System.out.println( "没有这本书,请重新输入");}else{//System.out.println( "您是否真的要删除? yes/no");//String k=scanner.next();//if(k.startsWith("y")){String deleSql= "DELETE FROM borrowbook WHERE bookID='"+b3+"'";int p=stmt.executeUpdate(deleSql); //返回记录影响的条数if(p!=0){System.out.println("删除成功!");}System.out.println("是否继续删除?yes/no no返回主菜单");String l=scanner.next();if(l.startsWith("yes")){System.out.println();};if(l.startsWith("no")){ll=1;System.out.println();};}}}/* String deleSql= "DELETE bookID FROM borrowbook WHERE bookID='"+b3+"'";int k=stmt.executeUpdate(deleSql); //返回记录影响的条数if(k!=0){System.out.println("删除成功!");}*/break;case 4:int mm=0;while(mm!=1)System.out.println(" 4. 修改借阅读书信息: ");System.out.println("请输入要修改的图书的ID ");String S=scanner.next();String []Ssplitst=S.split(",");String c1=Ssplitst[0];String sql1="SELECT * FROM borrowbook where bookID='"+S+"'";rs= stmt.executeQuery(sql1);int lll=0;while(rs.next()){String a222 =rs.getString(1);String b222 =rs.getString(2);String c222 =rs.getString(3);String d222 =rs.getString(4);//String e222 =rs.getString(5);//String f222 =rs.getString(6);System.out.println(a222+","+b222+" ,"+c222+","+d222);lll++;}if(lll==0){System.out.println( "没有这条记录,请重新输入");}else{// System.out.println( "要修改的信息");//String aa=scanner.next();System.out.println("要将借阅日期改为");String bb=scanner.next();String updateSql="UPDATE borrowbook SET outDate='"+bb+"' WHERE bookID='"+S+"'";int hh=stmt.executeUpdate(updateSql); //返回记录影响的条数if(hh!=0){System.out.println("修改成功!");}System.out.println("是否继续修改yes/no no返回主菜单");String o=scanner.next();if(o.startsWith("yes")){System.out.println();};if(o.startsWith("no")){mm=1;System.out.println();};}break;}break;。
基于java的图书管理系统源代码
声明:本系统是基于C/S的图书管理系统,主要使用的是Oracle数据库,下面附所有实现代码package library;import java.awt。
BorderLayout;import java.awt.Container;import java。
awt.GridLayout;import java。
awt。
event.ActionEvent;import java.awt.event。
ActionListener;import java。
sql.ResultSet;import javax。
swing。
JButton;import javax.swing.JComboBox;import javax。
swing。
JFrame;import javax。
swing.JLabel;import javax.swing。
JOptionPane;import javax.swing.JPanel;import javax.swing.JTextField;public class book_add extends JFrame implements ActionListener{DataBaseManager db=new DataBaseManager();ResultSet rs;JPanel panel1,panel2;JLabel book_id_label,book_name_label,author_label,press_label,press_date_label,price_label,book_num_label,borrowed_num_label,address;JTextField book_id_TextField,book_name_TextField,author_TextField,press_TextField,press_date_TextField,price_TextField,book_num_TextField, borrowed_count;JComboBox addresst;Container c;JButton clear,add,exit;public book_add(){super("添加图书信息”);c=getContentPane();c.setLayout(new BorderLayout());book_id_label=new JLabel("编号",JLabel.CENTER);book_name_label=new JLabel(”名称",JLabel.CENTER);author_label=new JLabel(”作者”,JLabel.CENTER);press_label=new JLabel("出版社",JLabel。
用java做的一个图书管理系统的源代码
用java做的一个图书管理系统的源代码import java。
sql.*;import java。
util。
*;public class T{public static void main(String[] args)throws Exception{Connection conn=null;Statement stmt=null;ResultSet rs=null;while(true){Scanner scanner=new Scanner(System.in);System。
out。
println(”请输入用户名:");String username2=scanner.next();System。
out.println("请输入密码:");String password2=scanner.next();if(!(username2.equals(”")||password2。
equals(””))){try{Class.forName("sun。
jdbc.odbc。
JdbcOdbcDriver”);conn=DriverManager。
getConnection("jdbc:odbc:book",””,"”);String sql=”select *from ww where username='”+username2+"’”;stmt=conn.createStatement();rs=stmt。
executeQuery(sql);if(rs.next()){if(rs。
getString(”password”).equals(password2)){System。
out。
println("*********欢迎来山东科技大学图书馆管理系统********”);while(true){System。
Java-项目开发实例-图书信息管理系统开发文档及源码
图书信息管理系统一、系统功能概述:根据图书信息管理系统的特点,可以将本系统分为2大功能模块,分别为:基础数据维护、系统数据维护。
本系统各个部分及其包括的具体功能模块如下图所示:二、数据库设计:图书信息表:字段名说明类型长度及备注ISBN 国际标准书号Varchar(13) 主键typeId 图书类型id IntBookname 书名Varchar(40)Writer 作者Varchar(21)Translater 译者Varchar(30) 可以为空Publisher 出版社Varchar(50)Date 出版日期SmalldatetimePrice 价格money图书类别表:用户信息表:三、系统源代码:Com.zhang.dao:Dao.java //数据库的连接与操作类package com.zhang.dao;import java.sql.Connection;import java.sql.Date;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import java.util.ArrayList;import java.util.List;import com.zhang.model.BookInfo;import com.zhang.model.BookType;import com.zhang.model.Operator;import com.zhang.model.Reader;import er;public class Dao {protected static String dbClassName ="com.microsoft.sqlserver.jdbc.SQLServerDriver";protected static String dbUrl = "jdbc:sqlserver://localhost:1433;"+ "DatabaseName=db_lib;SelectMethod=Cursor";protected static String dbUser = "sa";protected static String dbPwd = "zhangyong";protected static String second = null;private static Connection conn = null;//创建数据库连接private Dao() {try {if (conn == null) {Class.forName(dbClassName).newInstance();conn= DriverManager.getConnection(dbUrl, dbUser, dbPwd);System.out.println("数据库连接成功!");}elsereturn;} catch (Exception ee) {ee.printStackTrace();}}//执行查询private static ResultSet executeQuery(String sql) {try {if(conn==null)new Dao();returnconn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR _UPDATABLE).executeQuery(sql);} catch (SQLException e) {e.printStackTrace();return null;} finally {}}//执行更新private static int executeUpdate(String sql) {try {if(conn==null)new Dao();return conn.createStatement().executeUpdate(sql);} catch (SQLException e) {System.out.println(e.getMessage());//if(e.getMessage().equals("[Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]DELETE 语句与 COLUMN REFERENCE 约束'FK_TB_BORRO_REFERENCE_TB_BOOKI' 冲突。
Java编写的简单图书管理系统
Java编写的简单图书管理系统主界面代码实现package Library;import java.awt.BorderLayout;import java.awt.Color;import java.awt.Container;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import javax.swing.ImageIcon;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JPasswordField;import javax.swing.JTextField;public class Login extends JFrame {private static final long serialVersionUID = 1L; private JLabel jlUsername;private JLabel jlPwd;private JTextField txtUsername; //用户名private JTextField txtPassword; //密码private JButton jbOk;private JButton jbCancel;public JLabel getJlUsername() {if(jlUsername==null){jlUsername=new JLabel("账号");jlUsername.setForeground(Color.BLACK);jlUsername.setBounds(118, 40, 85, 30);}return jlUsername;}public JLabel getJlPwd() {if(jlPwd==null){jlPwd=new JLabel("密码");jlPwd.setForeground(Color.BLACK);jlPwd.setBounds(118, 100, 85, 30);}return jlPwd;}public JTextField getTxtUsername() {if(txtUsername==null){txtUsername=new JTextField(20);txtUsername.setBounds(180,40 , 200, 30);}return txtUsername;}public JTextField getTxtPassword() {if(txtPassword==null){txtPassword=new JPasswordField(20);txtPassword.setBounds(180, 100, 200, 30);}return txtPassword;}public JButton getJbOk() {if(jbOk==null){jbOk=new JButton("登陆");jbOk.setBounds(150, 180, 90, 30);//jbOk.addActionListener(this);}return jbOk;}public JButton getJbCancel() {if(jbCancel==null){jbCancel=new JButton("取消");jbCancel.setBounds(300, 180, 90, 30);}return jbCancel;}public Login(String title){super(title);//JFrame frame=new JFrame();Container cantainer=this.getContentPane();this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);ImageIcon img= new ImageIcon("F:\\Java\\传习\\src\\Library\\ZF`XY`H48I_}U)C4~}M2~C4.jpg");//这是背景图片JLabel imgLabel = new JLabel(img);//将背景图放在标签里。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
图书管理系统---java代码:import java.awt.*;import java.awt.event.*;import java.sql.*;import java.util.*;import javax.swing.*;// --------------------------------------------------------------------------------------------------------- class Tsgl {public static void main(String args[]) {dbframe db = new dbframe("图书管理程序");}}// 图书管理系统主界面class dbframe extends Frame implements ActionListener {MenuBar daohang = new MenuBar(); // 建立菜单栏Menu mfile = new Menu("功能"); // 建立“功能”菜单组Menu mhelp = new Menu("帮助"); // 建立“帮助”菜单组MenuItem mdenglu = new MenuItem("登陆");MenuItem mchaxun = new MenuItem("查询");MenuItem mtianjia = new MenuItem("添加");MenuItem mshanchu = new MenuItem("删除");MenuItem mexit = new MenuItem("退出");MenuItem mhelpp = new MenuItem("关于");Denglu pdenglu=new Denglu();Ptianjia ptianjia = new Ptianjia();Pmain pmain = new Pmain();Pchaxun pchaxun = new Pchaxun();Pshanchu pshanchu = new Pshanchu();dbframe(String s) { // 在窗口上添加菜单选项setTitle(s);mfile.add(mdenglu);mfile.add(mtianjia);mfile.add(mchaxun);mfile.add(mshanchu);mfile.add(mexit);mhelp.add(mhelpp);daohang.add(mfile);daohang.add(mhelp);setMenuBar(daohang);add(pmain);addWindowListener(new WindowAdapter() {public void windowClosing(WindowEvent e) {System.exit(0);}});setBounds(200, 200, 340, 250);setResizable(false);setVisible(true);mexit.addActionListener(this);mdenglu.addActionListener(this);mtianjia.addActionListener(this);mchaxun.addActionListener(this);mshanchu.addActionListener(this);mhelpp.addActionListener(this);validate();} // 窗口事件监听public void actionPerformed(ActionEvent e) {if (e.getSource() == mexit)System.exit(0);if(e.getSource()==mdenglu){removeAll();add(pdenglu);validate();}if (e.getSource() == mtianjia) {removeAll();add(ptianjia);validate();} // 图书添加功能if (e.getSource() == mchaxun) {removeAll();add(pchaxun);validate();} // 图书查询功能if (e.getSource() == mshanchu) {removeAll();add(pshanchu);validate();} // 图书删除功能if (e.getSource() == mhelpp) {JOptionPane.showMessageDialog(this, "欢迎使用图书管理系统", "关于本系统",RMATION_MESSAGE);}} // 各功能菜单事件监听}//class Ptianjia extends Panel implements ActionListener {TextField tname, tauthor, tpublish, tdate, tcomment;Label lname, lauthor, lpublish, ldate, lcomment;Button btn;Ptianjia() {setLayout(null);btn = new Button("添加"); // 创建“添加”按钮tname = new TextField();tauthor = new TextField();tpublish = new TextField();tdate = new TextField();tcomment = new TextField(); // 创建5个文本框lname = new Label("书名");lauthor = new Label("作者");lpublish = new Label("出版社");ldate = new Label("出版日期");lcomment = new Label("评论");add(lname);add(tname);add(lauthor);add(tauthor);add(lpublish);add(tpublish);add(ldate);add(tdate);add(lcomment);add(tcomment);add(btn); // 添加“按钮”到窗口面板上lname.setBounds(10, 10, 70, 25);tname.setBounds(90, 10, 220, 25);lauthor.setBounds(10, 40, 70, 25);tauthor.setBounds(90, 40, 220, 25);lpublish.setBounds(10, 70, 70, 25);tpublish.setBounds(90, 70, 220, 25);ldate.setBounds(10, 100, 70, 25);tdate.setBounds(90, 100, 220, 25);lcomment.setBounds(10, 130, 70, 25);tcomment.setBounds(90, 130, 220, 25);btn.setBounds(130, 160, 70, 25); // 设置按钮位置btn.addActionListener(this); // 设置按钮监听setSize(340, 250); // 设置窗口大小setBackground(Color.white); // 设置窗口背景颜色setVisible(true);validate();}public void actionPerformed(ActionEvent e) {String sname = tname.getText();String sauthor = tauthor.getText();String spublish = tpublish.getText();String sdate = tdate.getText();String scomment = tcomment.getText();String insertstr = "insert into book values" + "(" + "'" + sname + "'"+ "," + "'" + sauthor + "'" + "," + "'" + spublish + "'" + ","+ "'" + sdate + "'" + "," + "'" + scomment + "'" + ")"; // SQL语句Connection con;Statement sta;ResultSet rs;try {Class.forName("oracle.jdbc.driver.OracleDriver"); // 加载JDBC驱动} catch (ClassNotFoundException ee) {System.out.println("" + ee);}try {con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl", "sa", "orcl"); // 连接数据库sta = con.createStatement();sta.executeUpdate(insertstr); // 执行SQL语句con.close(); // 关闭数据库tname.setText("");tauthor.setText("");tpublish.setText("");tdate.setText("");tcomment.setText(""); // 重新初始化文本框内容JOptionPane.showMessageDialog(this, "添加成功", "图书管理系统",RMATION_MESSAGE);} catch (SQLException eee) {System.out.println("" + eee);tname.setText("");tauthor.setText("");tpublish.setText("");tdate.setText("");tcomment.setText("");JOptionPane.showMessageDialog(this, "添加失败", "图书管理系统",JOptionPane.WARNING_MESSAGE);}}}class Pmain extends Panel { // 窗口面板布局Label l1 = new Label("图书管理系统", Label.CENTER);Label l2 = new Label("计算机学院", Label.RIGHT);Label l3 = new Label("", Label.RIGHT);Label l4 = new Label("作者:JHL", Label.RIGHT);Pmain() {setLayout(null);setBackground(Color.white);add(l1);add(l2);add(l3);add(l4);l1.setBounds(10, 60, 320, 40);l2.setBounds(240, 120, 80, 22);l3.setBounds(240, 142, 80, 22);l4.setBounds(240, 164, 80, 22);setSize(340, 250);setVisible(true);validate();}}class Pchaxun extends Panel implements ActionListener {// 图书查询Choice cchaxun;TextField tchaxun;Button btnchaxun;TextArea tachaxun;Pchaxun() {setLayout(null);cchaxun = new Choice(); // 创建下拉菜单cchaxun.add("书名");cchaxun.add("作者");cchaxun.add("出版社");tchaxun = new TextField();btnchaxun = new Button("查询"); // 创建按钮tachaxun = new TextArea(); // 创建多行文本框add(cchaxun);add(tchaxun);add(btnchaxun);add(tachaxun);tchaxun.setText("");cchaxun.setBounds(10, 10, 65, 20);tchaxun.setBounds(85, 10, 180, 20);btnchaxun.setBounds(275, 10, 40, 20);tachaxun.setBounds(10, 40, 305, 145);cchaxun.select(0); // 下拉菜单的初始选项setSize(340, 250); // 设置窗口大小setBackground(Color.white);setVisible(true);btnchaxun.addActionListener(this);validate();}public void actionPerformed(ActionEvent e) {int i = cchaxun.getSelectedIndex();String s = tchaxun.getText();if (s.equals(""))JOptionPane.showMessageDialog(this, "查询内容不能为空", "查询系统",JOptionPane.WARNING_MESSAGE);else {Connection con;Statement sql;ResultSet rs;try {Class.forName("oracle.jdbc.driver.OracleDriver"); // 加载JDBC驱动} catch (ClassNotFoundException ee) {System.out.println("" + ee);}try {con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl", "sa", "orcl");// 连接数据库sql = con.createStatement();if (i == 0) // 根据下拉菜单的选项执行不同的SQL语句rs = sql.executeQuery("select * from book where bookName ="+ "'" + s + "'");else if (i == 1)rs = sql.executeQuery("select * from book where author ="+ "'" + s + "'");elsers = sql.executeQuery("select * from book where publisher ="+ "'" + s + "'");tachaxun.setText("");String panduan = "false";while (rs.next()) {panduan = "true";tachaxun.append("书名:" + rs.getString(1) + "\n");tachaxun.append("作者:" + rs.getString(2) + "\n");tachaxun.append("出版社:" + rs.getString(3) + "\n");tachaxun.append("出版日期:" + rs.getString(4) + "\n");tachaxun.append("评论:" + rs.getString(5) + "\n");} // 显示查询到的图书信息rs = sql.executeQuery("select count(*) from book"); // 统计所有图书数while (rs.next()) {tachaxun.append("图书馆暂有" + rs.getString(1) + "本图书");} // 显示所有图书数量信息con.close(); // 关闭数据库if (panduan.equals("false"))JOptionPane.showMessageDialog(this, "没有该记录", "查询系统",JOptionPane.WARNING_MESSAGE);} catch (SQLException eee) {System.out.println(eee);}}}}class Pshanchu extends Panel implements ActionListener { // 删除功能模块Choice cshanchu;TextField tshanchu;Button btnshanchu;Label l1 = new Label("", Label.CENTER);Label l2 = new Label("计算机学院", Label.RIGHT);Label l3 = new Label("", Label.RIGHT);Label l4 = new Label("作者:ZCS", Label.RIGHT);Pshanchu() {setLayout(null);cshanchu = new Choice(); // 创建下拉菜单cshanchu.add("书名");tshanchu = new TextField();btnshanchu = new Button("删除"); // 创建按钮add(cshanchu);add(tshanchu);add(btnshanchu);add(l1);add(l2);add(l3);add(l4); // 添加标签、按钮等到窗口面板tshanchu.setText("");cshanchu.setBounds(10, 10, 65, 20);tshanchu.setBounds(85, 10, 180, 20);btnshanchu.setBounds(275, 10, 40, 20);l1.setBounds(10, 40, 300, 40);l2.setBounds(240, 130, 80, 22);l3.setBounds(240, 152, 80, 22);l4.setBounds(240, 174, 80, 22);cshanchu.select(0);setSize(340, 250); // 设置窗口大小setBackground(Color.white);setVisible(true);btnshanchu.addActionListener(this);validate();}public void actionPerformed(ActionEvent e) {String s = tshanchu.getText();if (s.equals(""))JOptionPane.showMessageDialog(this, "请输入要删除的图书", "删除功能",JOptionPane.WARNING_MESSAGE);else {Connection con;Statement sql;ResultSet rs;try {Class.forName("oracle.jdbc.driver.OracleDriver");} catch (ClassNotFoundException ee) {System.out.println("" + ee);}try {con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl", "sa", "orcl");sql = con.createStatement();rs = sql.executeQuery("select * from book where bookName ="+ "'" + s + "'");if (!rs.next())JOptionPane.showMessageDialog(this, "没有该图书", "删除功能",JOptionPane.WARNING_MESSAGE);else {int n = JOptionPane.showConfirmDialog(this, "确认删除吗?","删除功能", JOptionPane.YES_NO_OPTION);if (n == JOptionPane.YES_OPTION) {sql.executeUpdate("delete from book where bookName ="+ "'" + s + "'");JOptionPane.showMessageDialog(this, "删除成功", "删除功能",RMATION_MESSAGE);tshanchu.setText("");} elsetshanchu.setText("");con.close();}} catch (SQLException eee) {System.out.println(eee);}}}}class Denglu extends Panel implements ActionListener {Label lzhanghao;TextField tzhanghao;Label lmima;TextField tmima;Button bdenglu;Denglu(){setLayout(null);lzhanghao=new Label("账号");tzhanghao=new TextField();lmima=new Label("密码");tmima=new TextField();bdenglu=new Button("登陆");add(lzhanghao);add(tzhanghao);add(lmima);add(tmima);add(bdenglu);tzhanghao.setText("");tmima.setText("");lzhanghao.setBounds(50, 25, 50, 30);tzhanghao.setBounds(100, 30, 200, 20);lmima.setBounds(50, 80, 50, 30);tmima.setBounds(100, 80, 200, 20);bdenglu.setBounds(140, 130, 50, 30);setBackground(Color.white);setVisible(true);bdenglu.addActionListener(this);validate();}public void actionPerformed(ActionEvent e) {String x=tzhanghao.getText();String y=tmima.getText();if(x.equals("weifang")&&y.equals("123") ){JOptionPane.showMessageDialog(this, "登陆成功", "提示",RMATION_MESSAGE);}else{JOptionPane.showMessageDialog(this, "账号或者密码错误","提示",JOptionPane.WARNING_MESSAGE);}}}。