?? books.java
字號(hào):
package mypkg;
import java.sql.*;
import java.text.*;
public class books extends Execute_DB
{
//定義類成員變量
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.jpg";
this.Intro = "";
this.RecommendNumber = 0;
this.strSql="";
}
//向books數(shù)據(jù)表中添加一條新記錄
public boolean add_book()
{
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;
}
//修改類成員變量BookID對(duì)應(yīng)的圖書信息
public boolean modify_info()
{
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;
}
//刪除類DeleteBookID中對(duì)應(yīng)的圖書信息
public boolean delete_book(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 showform3()
{
this.strSql="select * from formsendno ";
try
{
ResultSet rs = super.exeSqlQuery(this.strSql);
if (rs.next())
{
this.BookName=rs.getString("BookName");
this.Author=rs.getString("Author");
this.Pub=rs.getString("pub");
this.Price=rs.getFloat("Price");
return true;
}
else
{
return false;
}
}
catch(Exception ex)
{
return false;
}
}
//獲取類成員變量BookID對(duì)應(yīng)的圖書信息
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())
{
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
{
return false;
}
}
catch(Exception ex)
{
return false;
}
}
//獲取所有普通圖書信息,返回一個(gè)ResultSet類型對(duì)象
public ResultSet show_books()
{
this.strSql="select * from books";
ResultSet rs = null;
try
{
rs = super.exeSqlQuery(this.strSql);
}
catch(Exception ex)
{
System.out.println(ex.toString());
}
return rs;
}
//獲得按RecommendNumber排序的圖書集合,返回一個(gè)ResultSet類型對(duì)象
public ResultSet show_books_ByRecommendNumber()
{
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;
}
//以BookName、Author、Pub、SortID為條件搜索books數(shù)據(jù)表,獲得符合條件的記錄,返回一個(gè)ResultSet類型對(duì)象
public ResultSet search_books(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;
}
//更改類成員變量BookID對(duì)應(yīng)的記錄中RecommendNumber的值
public boolean modify_RecommendNumber()
{
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;
}
//設(shè)置類成員變量BookID的值
public void setBookID(long BookID)
{
this.BookID = BookID;
}
//獲取類成員變量BookID的值
public long getBookID()
{
return this.BookID;
}
//設(shè)置類成員變量BookName的值
public void setBookName(String BookName)
{
this.BookName = BookName;
}
//獲取類成員變量BookName的值
public String getBookName()
{
return this.BookName;
}
//設(shè)置類成員變量Author的值
public void setAuthor(String Author)
{
this.Author = Author;
}
//獲取類成員變量Author的值
public String getAuthor()
{
return this.Author;
}
//設(shè)置類成員變量Pub的值
public void setPub(String Pub)
{
this.Pub = Pub;
}
//獲取類成員變量Pub的值
public String getPub()
{
return this.Pub;
}
//設(shè)置類成員變量Price的值
public void setPrice(float Price)
{
this.Price = Price;
}
//獲取類成員變量Price的值
public float getPrice()
{
return this.Price;
}
//設(shè)置類成員變量SortID的值
public void setSortID(long SortID)
{
this.SortID = SortID;
}
//獲取類成員變量SortID的值
public long getSortID()
{
return this.SortID;
}
//設(shè)置類成員變量PicUrl的值
public void setPicUrl(String PicUrl)
{
this.PicUrl = PicUrl;
}
//獲取類成員變量PicUrl的值
public String getPicUrl()
{
return this.PicUrl;
}
//設(shè)置類成員變量Intro的值
public void setIntro(String Intro)
{
this.Intro = Intro;
}
//獲取類成員變量Intro的值
public String getIntro()
{
return this.Intro;
}
//設(shè)置類成員變量RecommendNumber的值
public void setRecommendNumber(int RecommendNumber)
{
this.RecommendNumber = RecommendNumber;
}
//獲取類成員變量RecommendNumber的值
public int getRecommendNumber()
{
return this.RecommendNumber;
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -