borrow return

pull/1/head
xicheny 5 years ago
parent 8fdc4ce338
commit 8cda9b3036

@ -17,66 +17,78 @@
String sql1 = "select * from borrow_card where ID =" + user; String sql1 = "select * from borrow_card where ID =" + user;
ResultSet rs1 = borrow.executeQuery(sql1); ResultSet rs1 = borrow.executeQuery(sql1);
if(session.getAttribute("manager")!=null){ if(session.getAttribute("manager")!=null){
if (rs1.next()) { if (rs1.next()) {
String sql2 = "select * from books where ID =" + book; int cardstatus = Integer.parseInt(rs1.getString("STATUS"));
ResultSet rs2 = borrow.executeQuery(sql2); if(cardstatus!=0){
String sql2 = "select * from books where ID =" + book;
if(rs2.next()){ ResultSet rs2 = borrow.executeQuery(sql2);
//out.println(psw1 + " " + psw2);
//String id = session.getAttribute("manager").toString();
int status=Integer.parseInt(rs2.getString("STATUS"));
if(rs2.next()){
if(status==1){ //out.println(psw1 + " " + psw2);
String sql = "insert borrow_books(CARD_ID,BOOK_ID,BORROW_DATE,END_DATE)values('" + user + "','" + book //String id = session.getAttribute("manager").toString();
+ "','" + date1 + "','" + date2 + "');";
try { int status=Integer.parseInt(rs2.getString("STATUS"));
int i = borrow.executeUpdate(sql);
if (i == 1) {
%> if(status==1){
<script> String sql = "insert borrow_books(CARD_ID,BOOK_ID,BORROW_DATE,END_DATE)values('" + user + "','" + book
alert('借阅成功!'); + "','" + date1 + "','" + date2 + "');";
window.location.href = "02borrow.jsp"; try {
</script> int i = borrow.executeUpdate(sql);
if (i == 1) {
<% %>
String sql3="update books set STATUS=0 where ID="+book; <script>
borrow.executeUpdate(sql3); alert('借阅成功!');
window.location.href = "02borrow.jsp";
</script>
} else { <%
%> String sql3="update books set STATUS=0 where ID="+book;
<script> borrow.executeUpdate(sql3);
alert('借阅未成功!');
window.location.href = "02borrow.jsp"; } else {
</script> %>
<% <script>
} alert('借阅未成功!');
} catch (Exception e) { window.location.href = "02borrow.jsp";
%> </script>
<script> <%
alert('借阅未成功!'); }
window.location.href = "02borrow.jsp"; } catch (Exception e) {
</script> %>
<% <script>
} alert('借阅未成功!');
window.location.href = "02borrow.jsp";
</script>
<%
}
}else{
%>
<script>
alert('该图书已借出!');
window.location.href = "02borrow.jsp";
</script>
<%
}
}else{ }else{
%> %>
<script> <script>
alert('该图书已借出!'); alert('该图书不存在');
window.location.href = "02borrow.jsp"; window.location.href = "02borrow.jsp";
</script> </script>
<% <%
} }
}else{ }else{
%> %>
<script> <script>
alert('该图书不存在!'); alert('借阅证已被挂失或注销');
window.location.href = "02borrow.jsp"; window.location.href = "02borrow.jsp";
</script> </script>
<% <%
} }
} else { } else {
%> %>
<script> <script>

Loading…
Cancel
Save