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

📄 books.java

📁 在eclispe下写的电子务平台
💻 JAVA
字号:
package dlut;

import java.sql.*;

public class Books extends ExecuteDB
{
	
	private long bookID;    
	private String bookName;       
	private String author;   
	private String pub;
	private float price;
	private String picUrl;
	private long sortID;   
	private String intro;
	private int recommendNumber;
	private String strSql;
	
    
    
	public Books()
	{
		this.bookID=0;        
		this.bookName="";		
		this.author="";		
		this.sortID=0;	
		this.price=0;
		this.pub="";
		this.picUrl = "00000000000000.gif";
		this.intro = "";
		this.recommendNumber = 0;
		this.strSql=""; 
	}
   
	
	public boolean addBook()
	{
        
		this.strSql="insert into books ";
		this.strSql=this.strSql + "(";        
		this.strSql=this.strSql + "BookName,";  
		this.strSql=this.strSql + "Author,";
		this.strSql=this.strSql + "Pub,";
		this.strSql=this.strSql + "Price,";
		this.strSql=this.strSql + "SortID,"; 
		this.strSql=this.strSql + "PicUrl,"; 
		this.strSql=this.strSql + "Intro,"; 
		this.strSql=this.strSql + "RecommendNumber";              
		this.strSql=this.strSql + ") ";        
		this.strSql=this.strSql + "values(";
		this.strSql=this.strSql + "'" + this.bookName + "',";	
		this.strSql=this.strSql + "'" + this.author + "',";
		this.strSql=this.strSql + "'" + this.pub + "',";
		this.strSql=this.strSql + "'" + this.price + "',";
		this.strSql=this.strSql + "'" + this.sortID + "',";	
		this.strSql=this.strSql + "'" + this.picUrl + "',";	
		this.strSql=this.strSql + "'" + this.intro + "',";
		this.strSql=this.strSql + "'" + this.recommendNumber + "'";
		this.strSql=this.strSql + ")";
		
		boolean isAdd = super.exeSql(this.strSql);
		
		
		return isAdd;
	}   
   
	public boolean modifyInfo()
	{
		this.strSql="update books set ";	
		this.strSql=this.strSql + "BookName=" + "'" + this.bookName + "',";
		this.strSql=this.strSql + "Author=" + "'" + this.author + "',";		
		this.strSql=this.strSql + "Pub=" + "'" + this.pub + "',";	
		this.strSql=this.strSql + "Price=" + "'" + this.price + "',";	
		this.strSql=this.strSql + "SortID=" + "'" + this.sortID + "',";	
		this.strSql=this.strSql + "PicUrl=" + "'" + this.picUrl + "',";
		this.strSql=this.strSql + "Intro=" + "'" + this.intro + "'";	
		this.strSql=this.strSql + " where BookID=" + this.bookID;		
		
		boolean isUpdate = super.exeSql(this.strSql);		
		return isUpdate;
	}	
   
	public boolean deleteBook(String DeleteBookID)
	{
		this.strSql="delete from books where BookID in (";
		this.strSql=this.strSql + DeleteBookID + ")";
		
		boolean isDelete = super.exeSql(this.strSql);		
		return isDelete;
	}
	
   
	public boolean  init()
	{
		this.strSql="select * from books where BookID=";
		this.strSql=this.strSql + this.bookID;  
		
		System.out.println(strSql); 
		
		try
		{
			ResultSet rs = super.exeSqlQuery(this.strSql);
			if (rs.next())
			{
				
				System.out.println("not null");
				
				this.bookID=rs.getLong("BookID");                
				this.bookName=rs.getString("BookName"); 
				this.pub=rs.getString("Pub");
				this.author=rs.getString("Author");
				this.picUrl=rs.getString("PicUrl");   
				this.price=rs.getFloat("Price");
				this.sortID=rs.getInt("SortID");   
				this.intro=rs.getString("Intro");
				this.recommendNumber=rs.getInt("RecommendNumber");
				return true;
			}
			else
			{
				
				System.out.println("null");
				
				return false;			
			} 
		}
		catch(Exception ex)
		{		 
			ex.printStackTrace();
			return false;
		}
	}
	
	public ResultSet showBooks()
	{
		this.strSql="select * from books";
		ResultSet rs = null;              
		try
		{
			rs = super.exeSqlQuery(this.strSql); 
		}
		catch(Exception ex)
		{
			System.out.println(ex.toString());            
		}
		return rs;        
	} 
	
	public ResultSet showBooksByRecommendNumber()
	{
		this.strSql="select * from books order by RecommendNumber desc";
		ResultSet rs = null;              
		try
		{
			rs = super.exeSqlQuery(this.strSql); 
		}
		catch(Exception ex)
		{
			System.out.println(ex.toString());            
		}
		return rs;        
	} 
   
	public ResultSet searchBooks(String BookName,String Author,String Pub,long SortID)
	{
		this.strSql="select * from books where";
		this.strSql=this.strSql + " BookName like '%" + BookName +"%'";    
		this.strSql=this.strSql + " and Author like '%" + Author +"%'"; 
		this.strSql=this.strSql + " and Pub like '%" + Pub +"%'";
		if(SortID != 0)
		{
			this.strSql=this.strSql + " and SortID =" + SortID;		
		}
		
		ResultSet rs = null;              
		try
		{
			rs = super.exeSqlQuery(this.strSql); 
		}
		catch(Exception ex)
		{
			System.out.println(ex.toString());            
		}
		return rs;        
	} 

	public boolean modifyRecommendNumber()
	{
		this.strSql="update books set ";
		this.strSql=this.strSql + "RecommendNumber=" + "'" + this.recommendNumber + "'";
		this.strSql=this.strSql + " where BookID =" + this.bookID;
		
		boolean isUpdate = super.exeSql(this.strSql);		
		return isUpdate;
	}
    
	public void setBookID(long BookID)
	{
		this.bookID = BookID;	
	}   
 
	public long getBookID()
	{
		return this.bookID;	
	} 
	
 	public void setBookName(String BookName)
	{
		this.bookName = BookName;	
	}   
 
	public String getBookName()
	{
		return this.bookName;	
	} 
	
 	public void setAuthor(String Author)
	{
		this.author = Author;	
	}   
 
	public String getAuthor()
	{
		return this.author;	
	} 
	
 	public void setPub(String Pub)
	{
		this.pub = Pub;	
	}   
  
	public String getPub()
	{
		return this.pub;	
	} 
	
 	public void setPrice(float Price)
	{
		this.price = Price;	
	}   
 
	public float getPrice()
	{
		return this.price;	
	} 
	
 	public void setSortID(long SortID)
	{
		this.sortID = SortID;	
	}   

	public long getSortID()
	{
		return this.sortID;	
	}
	 	 
 	public void setPicUrl(String PicUrl)
	{
		this.picUrl = PicUrl;	
	}   
  
	public String getPicUrl()
	{
		return this.picUrl;	
	} 
	 
 	public void setIntro(String Intro)
	{
		this.intro = Intro;	
	}   
 
	public String getIntro()
	{
		return this.intro;	
	} 
	
 	public void setRecommendNumber(int RecommendNumber)
	{
		this.recommendNumber = RecommendNumber;	
	}   
 
	public int getRecommendNumber()
	{
		return this.recommendNumber;	
	} 
}

⌨️ 快捷键说明

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