Search in sources :

Example 1 with Chapter

use of Model.Chapter in project Happourse_online_study_web by infiq2000.

the class CourseDetail method doGet.

/**
 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
 */
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    int course_id = Integer.parseInt(request.getParameter("course_id"));
    int uid = (int) request.getSession(false).getAttribute("uid");
    int aid = (int) request.getSession(false).getAttribute("aid");
    try {
        /* Account ac = accUtil.getAccount(aid); */
        Account acc = accUtil.getAccount(aid);
        request.setAttribute("account", acc);
        request.setAttribute("course_id", course_id);
    } catch (SQLException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
    try {
        Courses detailC = courseUtil.getCourseDetail(course_id);
        request.setAttribute("course_detail", detailC);
        String cate = insUtil.getCate(detailC.getCid());
        request.setAttribute("cate", cate);
        Instructor ins_info = insUtil.getIns_Info(detailC.getIns_id());
        request.setAttribute("ins_info", ins_info);
        List<Chapter> list_chapter = lecUtil.getChapterOfCourse(detailC.getCourses_id());
        request.setAttribute("chapter", list_chapter);
        RequestDispatcher dispatcher;
        if (courseUtil.checkSignedCourse(course_id, uid) == null) {
            dispatcher = request.getRequestDispatcher("/Course_detail.jsp");
        } else {
            dispatcher = request.getRequestDispatcher("/CourseSigned.jsp");
        }
        dispatcher.forward(request, response);
    } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : Account(Model.Account) SQLException(java.sql.SQLException) Instructor(Model.Instructor) Chapter(Model.Chapter) Courses(Model.Courses) RequestDispatcher(javax.servlet.RequestDispatcher)

Example 2 with Chapter

use of Model.Chapter in project Happourse_online_study_web by infiq2000.

the class RemoveCourse method doGet.

/**
 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
 */
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    int course_id = Integer.parseInt(request.getParameter("course_id"));
    int uid = (int) request.getSession(false).getAttribute("uid");
    request.setAttribute("course_id", course_id);
    try {
        Courses detailC = courseUtil.getCourseDetail(course_id);
        request.setAttribute("course_detail", detailC);
        String cate = insUtil.getCate(detailC.getCid());
        request.setAttribute("cate", cate);
        Instructor ins_info = insUtil.getIns_Info(detailC.getIns_id());
        request.setAttribute("ins_info", ins_info);
        List<Chapter> list_chapter = lecUtil.getChapterOfCourse(detailC.getCourses_id());
        request.setAttribute("chapter", list_chapter);
        courseUtil.removeCourse(uid, course_id);
        RequestDispatcher dispatcher = request.getRequestDispatcher("/Course_detail.jsp");
        dispatcher.forward(request, response);
    } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : SQLException(java.sql.SQLException) Instructor(Model.Instructor) Chapter(Model.Chapter) Courses(Model.Courses) RequestDispatcher(javax.servlet.RequestDispatcher)

Example 3 with Chapter

use of Model.Chapter in project Happourse_online_study_web by infiq2000.

the class LectureUtil method getChapterOfCourse.

public List<Chapter> getChapterOfCourse(int course_id) throws SQLException {
    Connection myConn = null;
    PreparedStatement myStmt = null;
    ResultSet myRS = null;
    myConn = dataSource.getConnection();
    String sql = "select * from chapter where course_id = ? ";
    myStmt = myConn.prepareStatement(sql);
    myStmt.setInt(1, course_id);
    myRS = myStmt.executeQuery();
    List<Chapter> chapter = new ArrayList<>();
    int dem = 0;
    while (myRS.next()) {
        dem++;
        int chap_id = myRS.getInt("chap_id");
        String name = myRS.getString("name");
        chapter.add(new Chapter(chap_id, name, course_id));
    }
    System.out.println(dem);
    return chapter;
}
Also used : Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) Chapter(Model.Chapter) ArrayList(java.util.ArrayList) PreparedStatement(java.sql.PreparedStatement)

Aggregations

Chapter (Model.Chapter)3 Courses (Model.Courses)2 Instructor (Model.Instructor)2 SQLException (java.sql.SQLException)2 RequestDispatcher (javax.servlet.RequestDispatcher)2 Account (Model.Account)1 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 ArrayList (java.util.ArrayList)1