Return Book
.style3 {font-size: 24px}
.style4 {font-size: 18px}
-->
UserRights
ModifyMessage
BookSearch
BookReturn
HaveBorrow
Return Book
Title:
***
try{
int flag=0,flag1=0;String studentnumber="";
String id=Library.getid();
Connection conn=Library.getConn();
Statement stmt,stmt1;
stmt = conn.createStatement();
stmt1 = conn.createStatement();
ResultSet rs4 = stmt.executeQuery("select * from borrowbook where id ='" + id + "' and title ='" + request.getParameter("title") + "' and returndata = '0'");
if(rs4.next()){//判断在borrowbook表中是否有当前用户指定书名的书的未还记录,即returndata="0"
stmt1.executeUpdate("update borrowbook set returndata = '" + (new java.util.Date().getYear()*365 + new java.util.Date().getMonth()*31 + new java.util.Date().getDay()) + "' where title ='" + request.getParameter("title") + "'and id ='" + id + "' and returndata = '0'");
//一个用户不会有病到在一本书还没还的情况下,再借一本相同的书吧
ResultSet rs6 = stmt.executeQuery("select * from book where title ='" + request.getParameter("title") + "'");
while(rs6.next()){
int oldinbook = Integer.parseInt(rs6.getString("innumber"));
int oldoutbook = Integer.parseInt(rs6.getString("outnumber"));
String newinbook = "update book set innumber ='" + (oldinbook+1) +"' where title ='" + request.getParameter("title") + "'";
stmt1.executeUpdate(newinbook);
String newoutbook = "update book set outnumber ='" + (oldoutbook-1) +"' where title ='" + request.getParameter("title") + "'";
stmt1.executeUpdate(newoutbook);
// out.println("You succeed in returning this book.");
}
}
}catch (Exception ex) {
response.sendRedirect("fail.jsp");
ex.printStackTrace();}
%>