Search in sources :

Example 1 with Instructor

use of Model.Instructor 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 Instructor

use of Model.Instructor 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 Instructor

use of Model.Instructor in project Happourse_online_study_web by infiq2000.

the class TakeCourse 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"));
    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);
        request.setAttribute("course_id", course_id);
        RequestDispatcher dispatcher = request.getRequestDispatcher("/takecourse.jsp");
        dispatcher.forward(request, response);
    } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : SQLException(java.sql.SQLException) Instructor(Model.Instructor) Courses(Model.Courses) RequestDispatcher(javax.servlet.RequestDispatcher)

Example 4 with Instructor

use of Model.Instructor in project Happourse_online_study_web by infiq2000.

the class InstructorUtil method getIns_Info.

public Instructor getIns_Info(int ins_id) throws SQLException {
    Connection myConn = null;
    PreparedStatement myStmt = null;
    ResultSet myRS = null;
    try {
        myConn = dataSource.getConnection();
        String sql = "select * from instructor where ins_id = ?";
        myStmt = myConn.prepareStatement(sql);
        myStmt.setInt(1, ins_id);
        myRS = myStmt.executeQuery();
        Instructor ins = null;
        while (myRS.next()) {
            String ins_name = myRS.getString("ins_name");
            String major = myRS.getString("major");
            String desciption = myRS.getString("description");
            int total_course = myRS.getInt("total_course");
            double total_rating = myRS.getDouble("total_rating");
            int aid = myRS.getInt("aid");
            ins = new Instructor(ins_id, ins_name, major, desciption, total_course, total_rating, aid);
        }
        return ins;
    } finally {
        myConn.close();
    }
}
Also used : Instructor(Model.Instructor) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement)

Aggregations

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