⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sharesubprogram.java

📁 图书管管理系统是基于JAVA的 很好的
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*
 * ShareSubprogram.java
 *
 * Created on 2007年11月10日, 下午2:16
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package h6.action;

import java.sql.*;
import java.util.*; 
import java.text.*;
import java.lang.*;


/**
 *
 * @author dinga
 */
public class ShareSubprogram {
    
    /** Creates a new instance of ShareSubprogram */
    public ShareSubprogram() {
    }
    
    /**
     *该方法判断所给读者证号是否在库中存在
     *@param readerID 要查询是否存在的读者的读者证号
     *@return 如果存在,返回true
     *@return 如果不存在,返回false
     */
    public static boolean readerExist(String readerID) throws SQLException {
        boolean exist = true;
        String conditions[] = {"password"};
        ResultSet reserchwhetherwin;
        DataBase result = new DataBase();
        
        reserchwhetherwin = result.search("reader",conditions,"reader_ID='" + readerID + "'");
        exist = reserchwhetherwin.next();
        /**
         *关闭对象
         */    
        reserchwhetherwin.close();
        result.closeConnection();
        return exist;
    }
    
    /**
     *该方法判断所给读者用户名是否在库中存在
     *@param userName 要查询是否存在的读者的用户名
     *@return 如果存在,返回true
     *@return 如果不存在,返回false
     */    
    public static boolean readerUserNameExist(String userName) throws SQLException {
        boolean exist = true;
        String conditions[] = {"password"};
        ResultSet reserchwhetherwin;
        DataBase result = new DataBase();
        
        reserchwhetherwin = result.search("reader",conditions,"user_name='" + userName + "'");
        exist = reserchwhetherwin.next();
        
        reserchwhetherwin.close();
        result.closeConnection();
        return exist;
    }
    
    /**
     *该方法判断所给管理员用户名是否在库中存在
     *@param userName 要查询是否存在的管理员的用户名
     *@return 如果存在,返回true
     *@return 如果不存在,返回false
     */
    public static boolean administratorExist(String userName) throws SQLException {
        boolean exist = true;
        String conditions[] = {"password"};
        ResultSet reserchwhetherwin;
        DataBase result = new DataBase();
        
        reserchwhetherwin = result.search("administrator",conditions,"name='" + userName + "'");
        exist = reserchwhetherwin.next();
        
        reserchwhetherwin.close();
        result.closeConnection();
        return exist;
    }
    
    /**
     *该方法判断所给书籍的ISBN号是否在书表中存在
     *@param ISBN 要查询是否存在的书籍的ISBN号
     *@return 如果存在,返回true
     *@return 如果不存在,返回false
     */
    public static boolean bookExist(String ISBN) throws SQLException {
        boolean exist = true;
        String conditions[] = {"ISBN"};
        ResultSet reserchwhetherwin;
        DataBase result = new DataBase();
        
        reserchwhetherwin = result.search("book",conditions,"ISBN='" + ISBN + "'");
        exist = reserchwhetherwin.next();
        
        reserchwhetherwin.close();
        result.closeConnection();
        return exist;
    }
    
    /**
     *该方法判断所给书籍的ISBN号是否在新书表中存在
     *@param ISBN 要查询是否存在的书籍的ISBN号
     *@return 如果存在,返回true
     *@return 如果不存在,返回false
     */
    public static boolean bookExistInNew(String ISBN) throws SQLException {
        boolean exist = true;
        String conditions[] = {"ISBN"};
        ResultSet reserchwhetherwin;
        DataBase result = new DataBase();
        
        reserchwhetherwin = result.search("newbook",conditions,"ISBN='" + ISBN + "'");
        exist = reserchwhetherwin.next();
       
        reserchwhetherwin.close();
        result.closeConnection();
        return exist;
    }
    
    /**
     *该方法判断所给ISBN号的书籍是否被借出了
     *@param ISBN 要查询是否被借出的书籍的ISBN号
     *@return 如果是,返回ture
     *@return 如果不是,返回flase
     */
    public static boolean bookIsGone(String ISBN) throws SQLException {
        boolean loan = true;
        String conditions[] = {"ISBN"};
        ResultSet reserchwhetherwin;
        DataBase result = new DataBase();
        
        reserchwhetherwin = result.search("loan",conditions,"ISBN='" + ISBN + "'");
        loan = reserchwhetherwin.next();
        
        reserchwhetherwin.close();
        result.closeConnection();
        return loan;
    }
    
    /**
     *该方法判断表中是否已经存在本次暂存信息
     *@param readerID 请求暂存操作的读者的读者证号
     *@param ISBN 读者请求暂存的书籍的ISBN号
     *@return 如果是,返回true
     *@return 如果不是,返回false
     */    
    public static boolean despositExist(String readerID,String ISBN) throws SQLException {
        boolean exist = true;
        String conditions[] = {"ISBN"};
        ResultSet reserchwhetherwin;
        DataBase result = new DataBase();
        
        reserchwhetherwin = result.search("tempbasket",conditions,"reader_ID='" + readerID + "' and ISBN ='" + ISBN +"'");
        exist = reserchwhetherwin.next();
        
        reserchwhetherwin.close();
        result.closeConnection();
        return exist;
    }
    
    /**
     *该方法判断所给ISBN号的书籍是否在图书馆内有流通本
     *@param ISBN 要查询是否在馆的书籍的ISBN号
     *@return 如果是,返回true
     *@return 如果不是,返回false
     */    
    public static boolean bookInLibrary(String ISBN) throws SQLException {
        boolean exist = true;
        String conditions[] = {"total_number,lend_number"};
        ResultSet reserchwhetherwin;
        DataBase result = new DataBase();
        
        reserchwhetherwin = result.search("book",conditions,"ISBN='" + ISBN + "'");
        if (reserchwhetherwin.next())
            exist = reserchwhetherwin.getInt(1) > reserchwhetherwin.getInt(2);
        
        reserchwhetherwin.close();
        result.closeConnection();
        return exist;
    }
    
    /**
     *该方法判断所给readerID的读者是否已经达到预约书籍的上限
     *@param readerID 要查询是否到达预约上限的读者的读者证号
     *@return 如果是,返回false
     *@return 如果不是,返回true
     */   
    public static boolean bookingEnabled(String readerID) throws SQLException {
        boolean enabled = false;
        String conditions[] = {"count(*)"};
        ResultSet reserchwhetherwin;
        DataBase result = new DataBase();
        
        reserchwhetherwin = result.search("booking",conditions,"reader_ID='" + readerID + "'");
        if (reserchwhetherwin.next())
        {   
            int i = reserchwhetherwin.getInt(1);
            SystemParameter sp = new SystemParameter();
            enabled = Integer.valueOf(sp.getBookingNumber()).intValue() > i;
        }
        
        reserchwhetherwin.close();
        result.closeConnection();
        return enabled;
    }
  
    /**
     *该方法判断所给readerID的读者是否已经达到借阅书籍的上限
     *@param readerID 要查询是否到达预约上限的读者的读者证号
     *@return 如果是,返回false
     *@return 如果不是,返回true
     */   
    public static boolean loanEnabled(String readerID) throws SQLException {
        boolean enabled = false;
        String conditions[] = {"count(*)"};
        ResultSet reserchwhetherwin;
        DataBase result = new DataBase();
        
        reserchwhetherwin=result.search("loan",conditions,"reader_ID='" + readerID + "'");
        if (reserchwhetherwin.next())
        {   
            int i = reserchwhetherwin.getInt(1);
            SystemParameter x=new SystemParameter();
            enabled = Integer.parseInt(x.getLoanNumber()) > i;
        }
        
        reserchwhetherwin.close();
        result.closeConnection();
        return enabled;
    }
    
    /**
     *该方法判断此次预约的信息是否已经存在
     *@param readerID 请求预约书籍的读者的读者证号
     *@param ISBN 读者希望预约的书籍的ISBN号
     *@return 如果是,返回true
     *@return 如果不是,返回false
     */    
    public static boolean bookingExist(String readerID,String ISBN) throws SQLException {
        boolean exist = true;
        String conditions[] = {"ISBN"};
        ResultSet reserchwhetherwin;
        DataBase result = new DataBase();
        
        reserchwhetherwin = result.search("booking",conditions,"reader_ID='" + readerID + "' and ISBN = '" + ISBN + "'");
        exist = reserchwhetherwin.next();
        
        reserchwhetherwin.close();
        result.closeConnection();
        return exist;
    }
    
    /**
     *该方法判断所给信息的书籍是否已经被借出
     *@param ISBN 要查询状态的书籍的ISBN号

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -