📄 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 + -