?? bsbookinfo.java
字號:
?package com.bookstore.book;
import com.bookstore.db.DBSource;
import com.bookstore.BookStoreConst;
import com.bookstore.util.StringUtil;
import java.io.*;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;
import java.util.Map;
/**
* Created on 2006-5-15
* @author zhangh
*
* Window - Preferences - Java - Code Style - Code Templates
*/
public class BsBookInfo
{
DBSource dbconn = null;
public BsBookInfo(String pool) throws SQLException, IOException
{
dbconn = new DBSource();
dbconn.Init(pool);
if(pool==null)
pool = BookStoreConst.BOOKSTORESPOOL;
}
/**
* 添加圖書大類
* @param classifyName
* @param sort
* @throws SQLException
* @throws IOException
*/
public void addBookClassifyBig(String classifyName,String sort)
throws SQLException,IOException
{
String sql = "";
sql = "insert into book_classify_big(classifyName,classifySort) " +
"VALUES('"+classifyName+"','"+sort+"')";
dbconn.execute(sql);
}
/**
* 列出所有的圖書大類
* @return Vector
*/
public Vector getAllBookClassifyBig()throws SQLException,IOException
{
Vector v = null;
String sql = "";
sql = "select * from book_classify_big order by classifySort ";
v = dbconn.ListOfMapData(sql);
return v;
}
/**
* 修改圖書大類
* @param id
* @param classifyName
* @param sort
* @throws SQLException
* @throws IOException
*/
public void modifyBookClassifyBig(String id,
String classifyName,
String sort)throws SQLException,IOException
{
String sql = "";
sql = "update book_classify_big set classifyName = '"+classifyName+"'," +
"classifySort='"+sort+"' where id='"+id+"' ";
dbconn.execute(sql);
}
/**
* 刪除圖書大類
*/
public void deleteBookClassifyBig(String id)throws SQLException,IOException
{
String sql = "";
sql = "delete from book_classify_big where id = '"+id+"' ";
dbconn.execute(sql);
}
/**
* 取出圖書大類中的最大序號
* @return String
* @throws SQLException
* @throws IOException
*/
public String getMaxSortClassifyBig() throws SQLException,IOException
{
Vector v = null;
String sort = "";
String sql = "";
sql = "select max(classifySort) as classifySort from book_classify_big ";
v = dbconn.ListOfMapData(sql);
Map map = (Map)v.get(0);
sort = (String)map.get("classifySort");
if(sort == null)sort="0";
return sort;
}
/**
* 根據ID找出相對應的圖書大類名稱
* @param bigId
* @return String
* @throws SQLException
* @throws IOException
*/
public String getNameByClassifyBigId(String bigId) throws SQLException,IOException
{
Vector v = null;
String classifyName = "";
String sql = "";
sql = "select classifyName from book_classify_big where id = '"+bigId+"' ";
v = dbconn.ListOfMapData(sql);
if(v.size()>0)
{
Map map = (Map)v.get(0);
classifyName = (String)map.get("classifyName");
}
return classifyName;
}
/**
* 根據ID找出相對應的圖書分類名稱
* @param midId
* @return String
* @throws SQLException
* @throws IOException
*/
public String getNameByClassifyMidId(String midId) throws SQLException,IOException
{
Vector v = null;
String classifyName = "";
String sql = "";
sql = "select classifyName from book_classify_mid where id = '"+midId+"' ";
v = dbconn.ListOfMapData(sql);
if(v.size()>0)
{
Map map = (Map)v.get(0);
classifyName = (String)map.get("classifyName");
}
return classifyName;
}
/**
* 根據ID找出相對應的圖書細類
* @param smallId
* @return String
* @throws SQLException
* @throws IOException
*/
public String getNameByClassifySmallId(String smallId) throws SQLException,IOException
{
Vector v = null;
String classifyName = "";
String sql = "";
sql = "select classifyName from book_classify_small where id = '"+smallId+"' ";
v = dbconn.ListOfMapData(sql);
if(v.size()>0)
{
Map map = (Map)v.get(0);
classifyName = (String)map.get("classifyName");
}
return classifyName;
}
/**
* 添加圖書分類(中類)
* @param classifyBigId
* @param classifyName
* @param sort
* @throws SQLException
* @throws IOException
*/
public void addBookClassifyMid(String classifyBigId,
String classifyName,
String sort) throws SQLException,IOException
{
String sql = "";
sql = "insert into book_classify_mid(classifyBigId,classifyName,classifySort) " +
"VALUES('"+classifyBigId+"','"+classifyName+"','"+sort+"')";
dbconn.execute(sql);
}
/**
* 列出某圖書大類下的所有分類
* @param classifyBigId
* @return Vector
* @throws SQLException
* @throws IOException
*/
public Vector getBookClassifyMidByBigId(String classifyBigId)throws SQLException,IOException
{
Vector v = null;
String sql = "";
sql = "select * from book_classify_mid where classifyBigId='"+classifyBigId+"' " +
"order by classifySort ";
v = dbconn.ListOfMapData(sql);
return v;
}
/**
* 修改圖書分類(中類)
* @param id
* @param classifyName
* @param sort
* @throws SQLException
* @throws IOException
*/
public void modifyBookClassifyMid(String id,
String classifyName,
String sort)throws SQLException,IOException
{
String sql = "";
sql = "update book_classify_mid set classifyName = '"+classifyName+"'," +
"classifySort='"+sort+"' where id='"+id+"' ";
dbconn.execute(sql);
}
/**
* 刪除圖書分類
* @param id
* @throws SQLException
* @throws IOException
*/
public void deleteBookClassifyMid(String id)throws SQLException,IOException
{
String sql = "";
sql = "delete from book_classify_mid where id = '"+id+"' ";
dbconn.execute(sql);
}
/**
* 取出圖書分類中最大序號
* @return String
* @throws SQLException
* @throws IOException
*/
public String getMaxSortClassifyMid() throws SQLException,IOException
{
Vector v = null;
String sort = "";
String sql = "";
sql = "select max(classifySort) as classifySort from book_classify_mid ";
v = dbconn.ListOfMapData(sql);
Map map = (Map)v.get(0);
sort = (String)map.get("classifySort");
if(sort == null)sort="0";
return sort;
}
/**
* 添加圖書細類
* @param classifyMidId
* @param classifyName
* @param sort
* @throws SQLException
* @throws IOException
*/
public void addBookClassifySmall(String classifyMidId,
String classifyName,
String sort) throws SQLException,IOException
{
String sql = "";
sql = "insert into book_classify_small(classifyMidId,classifyName,classifySort) " +
"VALUES('"+classifyMidId+"','"+classifyName+"','"+sort+"')";
dbconn.execute(sql);
}
/**
* 列出某圖書分類下的所有細類
* @param classifyMidId
* @return Vector
* @throws SQLException
* @throws IOException
*/
public Vector getBookClassifySmallByBigMid(String classifyMidId)throws SQLException,IOException
{
Vector v = null;
String sql = "";
sql = "select * from book_classify_small where classifyMidId='"+classifyMidId+"' " +
"order by classifySort ";
v = dbconn.ListOfMapData(sql);
return v;
}
/**
* 修改圖書細類
* @param id
* @param classifyName
* @param sort
* @throws SQLException
* @throws IOException
*/
public void modifyBookClassifySmall(String id,
String classifyName,
String sort)throws SQLException,IOException
{
String sql = "";
sql = "update book_classify_small set classifyName = '"+classifyName+"'," +
"classifySort='"+sort+"' where id='"+id+"' ";
dbconn.execute(sql);
}
/**
* 刪除圖書細類
* @param id
* @throws SQLException
* @throws IOException
*/
public void deleteBookClassifySmall(String id)throws SQLException,IOException
{
String sql = "";
sql = "delete from book_classify_small where id = '"+id+"' ";
dbconn.execute(sql);
}
/**
* 取出圖書細類中的最大序號
* @return String
* @throws SQLException
* @throws IOException
*/
public String getMaxSortClassifySmall() throws SQLException,IOException
{
Vector v = null;
String sort = "";
String sql = "";
sql = "select max(classifySort) as classifySort from book_classify_small ";
v = dbconn.ListOfMapData(sql);
Map map = (Map)v.get(0);
sort = (String)map.get("classifySort");
if(sort == null)sort="0";
return sort;
}
/**
* 添加出版社
* @param publishName
* @param sort
* @throws SQLException
* @throws IOException
*/
public void addPublish(String publishName,
String sort) throws SQLException,IOException
{
System.out.println("publishName = "+publishName);
String sql = "";
sql = "insert into publish_manager(publishName,publishSort) " +
"VALUES('"+publishName+"','"+sort+"')";
dbconn.execute(sql);
}
/**
* 列出所有的出版社
* @return Vector
* @throws SQLException
* @throws IOException
*/
public Vector getAllPublish()throws SQLException,IOException
{
Vector v = null;
String sql = "";
sql = "select * from publish_manager order by publishSort ";
v = dbconn.ListOfMapData(sql);
return v;
}
/**
* 修改出版社信息
* @param id
* @param publishName
* @param sort
* @throws SQLException
* @throws IOException
*/
public void modifyPublish(String id,
String publishName,
String sort)throws SQLException,IOException
{
String sql = "";
sql = "update publish_manager set publishName = '"+publishName+"'," +
"publishSort='"+sort+"' where id='"+id+"' ";
dbconn.execute(sql);
}
/**
* 刪除出版社信息
* @param id
* @throws SQLException
* @throws IOException
*/
public void deletePublish(String id)throws SQLException,IOException
{
String sql = "";
sql = "delete from publish_manager where id = '"+id+"' ";
dbconn.execute(sql);
}
/**
* 取出最大出版社序號
* @return
* @throws SQLException
* @throws IOException
*/
public String getMaxSortPublish() throws SQLException,IOException
{
Vector v = null;
String sort = "";
String sql = "";
sql = "select max(publishSort) as classifySort from publish_manager ";
v = dbconn.ListOfMapData(sql);
Map map = (Map)v.get(0);
sort = (String)map.get("classifySort");
if(sort == null)sort="0";
return sort;
}
/**
* 根據ID找到相對應的出版社名稱
* @param id
* @return String
* @throws SQLException
* @throws IOException
*/
public String getNameByPublishId(String id) throws SQLException,IOException
{
Vector v = null;
String classifyName = "";
String sql = "";
sql = "select publishName from publish_manager where id = '"+id+"' ";
v = dbconn.ListOfMapData(sql);
if(v.size()>0)
{
Map map = (Map)v.get(0);
classifyName = (String)map.get("publishName");
}
return classifyName;
}
/**
* 添加國別信息
* @param nationName
* @param sort
* @throws SQLException
* @throws IOException
*/
public void addNation(String nationName,
String sort) throws SQLException,IOException
{
String sql = "";
sql = "insert into nation_manager(nationName,nationSort) " +
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -