예제 #1
0
  /** *******************图书借阅********************** */
  private void bookborrow(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    // 查询读者信息
    readerForm.setBarcode(request.getParameter("barcode"));
    ReaderForm reader = (ReaderForm) readerDAO.queryM(readerForm);
    request.setAttribute("readerinfo", reader);
    // 查询读者的借阅信息
    request.setAttribute("borrowinfo", borrowDAO.borrowinfo(request.getParameter("barcode")));
    // 完成借阅
    String f = request.getParameter("f");
    String key = request.getParameter("inputkey");
    if (key != null && !key.equals("")) {
      String operator = request.getParameter("operator");
      BookForm bookForm = bookDAO.queryB(f, key);
      if (bookForm != null) {
        int ret = borrowDAO.insertBorrow(reader, bookDAO.queryB(f, key), operator);
        if (ret == 1) {
          request.setAttribute("bar", request.getParameter("barcode"));
          request.getRequestDispatcher("bookBorrow_ok.jsp").forward(request, response);

        } else {
          request.setAttribute("error", "添加借阅信息失败!");
          request.getRequestDispatcher("error.jsp").forward(request, response);
        }
      } else {
        request.setAttribute("error", "没有该图书!");
        request.getRequestDispatcher("error.jsp").forward(request, response);
      }
    } else {
      request.getRequestDispatcher("bookBorrow.jsp").forward(request, response);
    }
  }
예제 #2
0
 /** *******************图书归还********************** */
 private void bookback(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   // 查询读者信息
   readerForm.setBarcode(request.getParameter("barcode"));
   ReaderForm reader = (ReaderForm) readerDAO.queryM(readerForm);
   request.setAttribute("readerinfo", reader);
   // 查询读者的借阅信息
   request.setAttribute("borrowinfo", borrowDAO.borrowinfo(request.getParameter("barcode")));
   if (request.getParameter("id") != null) {
     int id = Integer.parseInt(request.getParameter("id"));
     String operator = request.getParameter("operator");
     if (id > 0) { // 执行归还操作
       int ret = borrowDAO.back(id, operator);
       if (ret == 0) {
         request.setAttribute("error", "图书归还失败!");
         request.getRequestDispatcher("error.jsp").forward(request, response);
       } else {
         request.setAttribute("bar", request.getParameter("barcode"));
         request.getRequestDispatcher("bookBack_ok.jsp").forward(request, response);
       }
     }
   } else {
     request.getRequestDispatcher("bookBack.jsp").forward(request, response);
   }
 }