コード例 #1
0
  public void AddGrades(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    HttpSession session = request.getSession();
    this.adminDAO = new AdminDAO();
    ShowGradesForm form = new ShowGradesForm();
    form.setStu_num((String) request.getParameter("stu_num"));
    form.setCourse_id((String) request.getParameter("course_id"));
    form.setScore(request.getParameter("score"));
    String college_id = (String) session.getAttribute("adm_college");

    if (form.getStu_num() == null
        || form.getStu_num() == ""
        || form.getCourse_id() == null
        || form.getCourse_id() == ""
        || form.getScore() == null
        || form.getScore() == "") {
      // response.sendRedirect("update.jsp");
    } else {
      System.out.println("stu num:" + form.getStu_num());
      System.out.println("course id:" + form.getCourse_id());
      System.out.println("score:" + form.getScore());
      System.out.println("college id:" + college_id);

      int result = adminDAO.checkAddInfo(form.getStu_num(), form.getCourse_id(), form.getScore());
      if (result != 0) {
        System.out.println("result:" + result);
        session.setAttribute("addmode", Integer.toString(result));
        response.sendRedirect("update.jsp");
      } else if (adminDAO.addScore(form) != 0) {
        response.sendRedirect("add_ok.jsp");
      } else {
        System.out.println("添加失败");
      }
    }
  }
コード例 #2
0
 public void updateNotification(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   NotificationForm notificationForm1 = null;
   Collection courInfo = adminDAO.queryNotification();
   int flag = 0;
   if (courInfo != null && !courInfo.isEmpty()) {
     Iterator it = courInfo.iterator();
     while (it.hasNext()) {
       notificationForm1 = (NotificationForm) it.next();
       NotificationForm notificationForm2 = new NotificationForm();
       notificationForm2.setNotificationId(notificationForm1.getNotificationId());
       notificationForm2.setAuthorId(notificationForm1.getAuthorId());
       notificationForm2.setCollegeId(notificationForm1.getCollegeId());
       notificationForm2.setTitle(notificationForm1.getTitle());
       notificationForm2.setContent(
           request.getParameter(Integer.toString(notificationForm1.getNotificationId())));
       flag = adminDAO.updateNotification(notificationForm2);
       if (flag != 1) break;
     }
     if (flag == 1) response.sendRedirect("queryUpdateNotification.jsp");
     else System.out.println("Update notification error!");
   } else {
     System.out.println("Notification is empty!");
   }
 }
コード例 #3
0
 private void addAcdemicDeanInfo(HttpServletRequest request, HttpServletResponse response)
     throws SQLException, IOException {
   AcdemicDeanForm form = new AcdemicDeanForm();
   form.setUser(request.getParameter("user"));
   form.setPwd(request.getParameter("pwd"));
   form.setCollegeName(request.getParameter("collegename"));
   System.out.println(form.getCollegeName());
   int rs = adminDAO.addAcdemicDean(form);
   if (rs == -1) {
     response.sendRedirect("addAcdemic_error.jsp");
   } else if (rs == 1) {
     response.sendRedirect("addAcdemic_ok.jsp");
   }
 }
コード例 #4
0
 public void deleteNotification(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   Collection coll = adminDAO.queryNotification();
   Iterator it = coll.iterator();
   int flag = 0;
   while (it.hasNext()) {
     NotificationForm notificationForm1 = (NotificationForm) it.next();
     System.out.println(
         request.getParameter(Integer.toString(notificationForm1.getNotificationId())));
     if (request.getParameter(Integer.toString(notificationForm1.getNotificationId())) != null) {
       if (request
           .getParameter(Integer.toString(notificationForm1.getNotificationId()))
           .equals("on")) {
         NotificationForm notificationForm2 = new NotificationForm();
         notificationForm2.setNotificationId(notificationForm1.getNotificationId());
         flag = adminDAO.deleteNotification(notificationForm2);
         if (flag != 1) break;
       }
     }
   }
   if (flag == 1) response.sendRedirect("queryDeleteNotification.jsp");
   else System.out.println("Delete notification error!");
 }
コード例 #5
0
 public void insertNotification(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   NotificationForm notificationForm = new NotificationForm();
   notificationForm.setAuthorId(request.getParameter("account"));
   notificationForm.setCollegeId(0);
   notificationForm.setTitle(request.getParameter("title"));
   notificationForm.setContent(request.getParameter("content"));
   int flag = adminDAO.insertNotification(notificationForm);
   if (flag == 1) {
     System.out.println("Releasing notices success!");
     response.sendRedirect("queryNotification.jsp");
   } else if (flag == 2) response.sendRedirect("titleExistError.jsp");
   else System.out.println("Insert notification error!");
 }
コード例 #6
0
 private void modifyPwd(HttpServletRequest request, HttpServletResponse response) {
   AdminModifyPwdForm form = new AdminModifyPwdForm();
   form.setAccount(request.getParameter("account"));
   form.setOldPwd(request.getParameter("oldPwd"));
   form.setNewPwd(request.getParameter("newPwd"));
   form.setCnewPwd(request.getParameter("cnewPwd"));
   int rs = adminDAO.modifyPwd(form);
   if (rs != 0) {
     try {
       response.sendRedirect("modify_ok.jsp");
     } catch (IOException e) {
       e.printStackTrace();
     }
   }
 }
コード例 #7
0
 private void deleteAcdemicDeanInfo(HttpServletRequest request, HttpServletResponse response) {
   String[] result = request.getParameterValues("choose");
   for (int i = 0; i < result.length; i++) {
     try {
       adminDAO.deleteAcdemicDean(result[i]);
     } catch (SQLException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     }
   }
   try {
     response.sendRedirect("deleteAcdemic_ok.jsp");
   } catch (IOException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
 }
コード例 #8
0
  public void ModifyGrades(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    this.adminDAO = new AdminDAO();
    ShowGradesForm form = new ShowGradesForm();
    HttpSession session = request.getSession();
    form.setStu_num((String) session.getAttribute("setgrades_stu_num"));
    form.setCourse_id((String) session.getAttribute("setgrades_course_id"));
    form.setScore(request.getParameter("score"));

    System.out.println("stu num:" + form.getStu_num());
    System.out.println("course id:" + form.getCourse_id());
    System.out.println("score:" + form.getScore());

    if (adminDAO.updateScore(form) != 0) {
      response.sendRedirect("modify_ok.jsp");
    } else {
      System.out.println("修改失败");
    }
  }
コード例 #9
0
 private void adminInsertCourse(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   CourseForm courseForm = new CourseForm();
   System.out.println(request.getParameter("courseId"));
   courseForm.setId(Integer.valueOf(request.getParameter("courseId")));
   courseForm.setNameC(request.getParameter("nameC"));
   courseForm.setNameE(request.getParameter("nameE"));
   courseForm.setCredit(Float.valueOf(request.getParameter("credit")));
   courseForm.setWeekHour(Integer.valueOf(request.getParameter("weekHour")));
   courseForm.setSemester(request.getParameter("semester"));
   courseForm.setTeacherMode(request.getParameter("teachMode"));
   courseForm.setCollegeId(Integer.valueOf(request.getParameter("collegeId")));
   courseForm.setYear(request.getParameter("courseYear"));
   int flag = adminDAO.insertCourse(courseForm);
   if (flag == 2) {
     response.sendRedirect("idExistError.jsp");
   } else if (flag == 1) response.sendRedirect("queryCourse.jsp");
   else if (flag == 0) {
     System.out.println("insert error");
   }
 }