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

📄 book.java

📁 教材管理系统,一个完整的学校教材管理系统,可以作为大学生课程设计使用
💻 JAVA
字号:
package tom.bean;
import java.sql.*;
import java.util.*;
import tom.bean.Dbconnection;
public class Book {
	private String action;
    private String id;
    private int bookid;
    private String bookname;
    private int booktypeid;
    private String author;
    private String bookconcern;
    private String bookdate;
    private int leavingbook;
    private String total;
    private String condition;
    private ResultSet rs;
    private String selectbookid;
    private String message;
    private int rowcount;
    private String result;

    public Book() {
    	result=null;
    }
    public void setSelectbookid(String s)
    {
    	selectbookid=s;
    }
    public String getSelectbookid()
    {
    	return selectbookid;
    }
    //
    public void setAction(String s)
    {
    	action=s;
    }
    public String getAction()
    {
    	return action;
    }
    //
    public void setId(String s)
    {
    	id=s;
    }
    public String getId()
    {
    	return id;
    }
    //
    public void setBookid(int n)
    {
    	bookid=n;
    }
    public int getBookid()
    {
    	return bookid;
    }
    //
    public void setLeavingbook(int n)
    {
    	leavingbook=n;
    }
    public int getLeavingbook()
    {
    	return leavingbook;
    }
    //
    public void setBookname(String s)
    {
    	bookname=s;
    }
    public String getBookname()
    {
    	return bookname;
    }
    //
    public void setBooktypeid(int n)
    {
    	booktypeid=n;
    }
    public int getBooktypeid()
    {
    	return booktypeid;
    }
    //
    public void setAuthor(String s)
    {
    	author=s;
    }
    public String getAuthor()
    {
    	return author;
    }
    //
    public void setBookconcern(String s)
    {
    	bookconcern=s;
    }
    public String getBookconcern()
    {
    	return bookconcern;
    }
    //
    public void setBookdate(String s)
    {
    	bookdate=s;
    }
    public String getBookdate()
    {
    	return bookdate;
    }
    //
    public void setTotal(String s)
    {
    	total=s;
    }
    public String getTotal()
    {
    	return total;
    }
    public String getMessage()
    {
    	return message;
    }
    public int getRowcount()
    {
    	return rowcount;
    }
    public ResultSet booklist()
    {
    	condition="SELECT bookid,bookname,booktype.booktype,author,bookconcern,bookdate,leavingbook FROM book,booktype where book.booktypeid=booktype.booktypeid";
        Dbconnection e=new Dbconnection();
        e.condb();
        rs=e.select(condition);
        rowcount=e.getRowcount();
        return rs;
    }
    public void selectspec()
    {
    	condition="SELECT * from book where bookid="+bookid;
    	Dbconnection e=new Dbconnection();
        e.condb();
    	rs=e.select(condition);
    	try{
    		rs.next();
    		bookid=rs.getInt(1);
    		bookname=rs.getString(2);
    		author=rs.getString(3);
    		bookconcern=rs.getString(4);
    		bookdate=rs.getString(5);
    		booktypeid=rs.getInt(6);
    		leavingbook=rs.getInt(7);
    	}
    	catch(SQLException f){message="error";}
    }
    public void Managebooks()
    {
    	if(action.equals("add"))
    	condition="INSERT INTO book(bookname,author,bookconcern,bookdate,booktypeid,leavingbook) VALUES"+"("+"'"+bookname+"',"+"'"+author+"',"+"'"+bookconcern+"',"+"'"+bookdate+"','"+booktypeid+"',"+Integer.valueOf(total)+")";
        if(action.equals("edit"))
        condition="update book set bookname='"+bookname+"',author='"+author+"',bookconcern='"+bookconcern+"',bookdate='"+bookdate+"',booktypeid="+booktypeid+",leavingbook=leavingbook+"+Integer.valueOf(total)+"where bookid="+id;
        Dbconnection e=new Dbconnection();
        e.condb();
    	e.update(condition);
        message=e.getMessage();
    	  	
    }
    public void Deletebook(String id)
    {
     condition="DELETE FROM book WHERE bookid="+id;
     
     Dbconnection e=new Dbconnection();
        e.condb();
    	e.update(condition);
        message=e.getMessage();
    }
    public String getResult()
    {   StringBuffer buffer=new StringBuffer();
    	condition="select bookid,bookname from book where leavingbook<30";
    	Dbconnection e=new Dbconnection();
    	e.condb();
    	rs=e.select(condition);
    	try{while(rs.next())
    	    {int id=rs.getInt(1);
    	     String name=rs.getString(2);
    	     buffer.append("编号:"+String.valueOf(id)+"&nbsp;教材名称:"+name+"&nbsp;&nbsp;");
    	    }
    	}
    	catch(SQLException f){System.out.println(f);}
    	    result=new String(buffer);
    	    return result;
    	
    }
    public static void main(String args[])
    {
    	Book book=new Book();
    	//book.setId("1");
    	//book.Deletebook("1");
    	//String s=book.getMessage();
    	//System.out.print(s);
    	String m=book.getResult();
    	System.out.println(m);
    }
}

⌨️ 快捷键说明

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