//查找一条记录统一函数
private Hashtable searchOneData(String sql)
{
Hashtable hash = new Hashtable();
ResultSet rs = selectRecord(sql);
Statement stmt = null;
try{
//取得列数和列名
ResultSetMetaData rsmd = rs.getMetaData();
int cols = rsmd.getColumnCount();
if(rs.next())
{
for(int i=1;i<=cols;i++)
{
String field = ds.toString(rsmd.getColumnName(i));
String value = ds.toString(rs.getString(i));
hash.put(field,value);
}
}
}catch(Exception e){System.out.println("运行时出错:"+e);}
finally{
if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}
}
return hash;
}
}//设置借阅ID
public void setID(String i)
{
id = i;
}
//取得所有信息内容
public Vector getData()
{
String sql = "";
sql = "select * from KJB2_KJXX_JYB where ZT='"+strZero+"' order by JYID";
return searchData(sql);
}
//分页取得所有信息
public Vector getPageData(int page)
{
String sql ="";
sql="select * from KJB2_KJXX_JYB where ZT='"+strZero+"' order by JYID";
return getOnePage(sql,page,20);
}
//根据借阅号取得此详细信息
public Hashtable getOneData(String id)
{
String sql="";
sql = "select * from KJB2_KJXX_JYB where JYID="+id+"";
return searchOneData(sql);
}
//删除库信息
public int delJYXX(String id)
{
String sql="";
sql="delete from KJB2_KJXX_JYB where JYID="+id;
return deleteRecord(sql);
}
//新增借阅记录,参数
public int[] addBorrow(Hashtable hash)
{
System.out.println("批量处理新增借阅。。。。。。");
String sql="";
int intID = makeID("KJB2_KJXX_JYB","JYID","","",true);
String strID=String.valueOf(intID);
String strZJH = ds.toString((String)hash.get("ZJH"));//证件号
String strSQH = ds.toString((String)hash.get("SQH"));//索取号
String strJYSJ = ds.toString((String)hash.get("JYSJ"));//借阅时间
String strREADERID = "";
String strBOOKID = "";
String strDQSJ = "";
String strXJCS = "";
//根据读者证件号取的读者ID//根据读者ID取得规则ID,然后取得可以借阅天数,
sql=" select KJB2_KJXX_READER.RULEID,KJB2_KJXX_READER.READERID,KJB2_KJXX_RULE.KJYSJ "
+" from KJB2_KJXX_READER,KJB2_KJXX_RULE "
+" where KJB2_KJXX_READER.ZJH='"+strZJH+"' and KJB2_KJXX_READER.RULEID=KJB2_KJXX_RULE.RULEID ";
Hashtable hashReId=(Hashtable)searchOneData(sql);
strREADERID=ds.toString((String)hashReId.get("READERID"));
String strKJYSJ=ds.toString((String)hashReId.get("KJYSJ"));
//根据索取号取得书本ID
sql="select BOOKID from KJB2_KJXX_STORE where SQH='"+strSQH+"'";
Hashtable hashBKID=(Hashtable)searchOneData(sql);
strBOOKID = ds.toString((String)hashBKID.get("BOOKID"));
//新增操作
createStatement();
clearBatch();
sql=" insert into KJB2_KJXX_JYB(JYID,READERID,BOOKID,JYSJ,DQSJ,ZT,XJCS) "
+" values("+strID+","+strREADERID+","+strBOOKID+",'"+strJYSJ
+"',to_char((to_date('"+strJYSJ+"','yyyy-MM-dd')+"+strKJYSJ+"),'yyyy-MM-dd')"
+",'"+strZero+"','"+strZero+"')";
addBatch(sql);
sql="update KJB2_KJXX_STORE set ZT='借出' where BOOKID="+strBOOKID;
addBatch(sql);
sql="update KJB2_KJXX_READER set LJJS=LJJS+1 where READERID="+strREADERID;
addBatch(sql);
int result[]=executeBatch();
closeStm();
return result;
}
//取消借阅11
public int[] delBorrow(String id)
{
System.out.println("批量处理取消借阅。。。。。");
String sql="";
sql="select BOOKID from KJB2_KJXX_JYB where JYID="+id;
Hashtable hash=(Hashtable)searchOneData(sql);
String strBOOKID=(String)hash.get("BOOKID");
createStatement();
clearBatch();
sql="update KJB2_KJXX_JYB set ZT='"+strOne+"' where JYID="+id;
addBatch(sql);
sql="update KJB2_KJXX_STORE set ZT='可借' where BOOKID="+strBOOKID;
addBatch(sql);
int result[]=executeBatch();
closeStm();
return result;
}
//判断证件号的合法性
public boolean isValidate(String zjh)
{
String sql="";
sql="select * from KJB2_KJXX_READER where ZJH='"+zjh+"' and ZT='注册'";
Hashtable hash=(Hashtable)searchOneData(sql);
if(hash.isEmpty())
return false;
else
return true;
}
//判断某书是否可以被借
public boolean ifCanBorrow(String sqh)
{
String sql="";
sql="select * from KJB2_KJXX_STORE where ZT='可借'";
Vector vect=(Vector)searchData(sql);
if(vect.isEmpty())
return false;
else
return true;
}
图书借阅的界面JSP代码:
DealString是main中的一个类,jsp 代码中调用了这个类。
<%
DealString ds = new DealString();
//取得菜单类别
String strType = ds.toString(request.getParameter("txt_type"));
String strType1 = ds.toString(request.getParameter("txt_type1"));
String strEdit = ds.toString(request.getParameter("txt_edit"));
String strID = ds.toString(request.getParameter("txt_id"));
String zgbh = ds.toString((String)session.getAttribute("zgbh"));
<td align="center"><strong>书名</strong></td>
<td align="center"><strong>索取号</strong></td>
<td align="center"><strong>借阅日期</strong></td>
<td align="center"><strong>到期日期</strong></td>
<td align="center"><strong>续借次数</strong></td>
<td align="center"><strong>状态</strong></td>
上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] ... 下一页 >>