⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 classcourseactions.java

📁 are are are are are are are are are are are are
💻 JAVA
字号:
/*
 * ClassCourseActions.java
 *
 * Created on 2006年6月7日, 上午9:35
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package enova.web.struts.action;

import javax.servlet.http.*;
import org.apache.struts.action.*;
import enova.service.*;
import enova.pojo.*;
import enova.util.Const;

/**
 *
 * @author vlinux
 */
public class ClassCourseActions extends org.apache.struts.actions.DispatchAction {
    
    private Integer classId;
    private Integer courseId;
    private Integer year;
    private String term;
    private Integer specialId;
    private ClassCourseService ccs = (ClassCourseService)ServiceFactory.makeService("ClassCourseService");
    
    private void loadForm(javax.servlet.http.HttpServletRequest request){
        this.term = request.getParameter("term");
        try{
            this.classId = new Integer(Integer.parseInt(request.getParameter("classId")));
        }catch(Exception e){
            this.classId = null;
        }
        try{
            this.courseId = new Integer(Integer.parseInt(request.getParameter("courseId")));
        }catch(Exception e){
            this.courseId = null;
        }
        try{
            this.year = new Integer(Integer.parseInt(request.getParameter("year")));
        }catch(Exception e){
            this.year = null;
        }
        try{
            this.specialId = new Integer(Integer.parseInt(request.getParameter("specialId")));
        }catch(Exception e){
            this.specialId = null;
        }
    }
    
    //添加
    public ActionForward add(ActionMapping mapping, ActionForm actionForm,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        try{
            loadForm(request);
            ClassCourse cc = new ClassCourse(classId,courseId);
            ccs.create(cc);
        }catch(StoreException se){
            request.setAttribute(Const.MESSAGES,"数据库出错");
            return mapping.findForward(Const.STORE_EXCEPTION);
        }catch(UniqueException ue){
            request.setAttribute(Const.MESSAGES,"该记录已经存在");
            return mapping.findForward(Const.ADD);
        }
        request.setAttribute(Const.MESSAGES,"创建成功");
        return mapping.findForward(Const.ADD);
    }
    
    
    
    //删除
    public ActionForward delete(ActionMapping mapping, ActionForm actionForm,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        try{
            loadForm(request);
            ccs.delete(classId,courseId);
            request.setAttribute("classCourses",ccs.getByClassIdAndYearAndTerm(null,null,null));
        }catch(StoreException se){
            request.setAttribute(Const.MESSAGES,"数据库出错");
            return mapping.findForward(Const.STORE_EXCEPTION);
        }catch(NotExistException nee){
            request.setAttribute(Const.MESSAGES,"记录不存在");
            return mapping.findForward(Const.VIEW);
        }
        request.setAttribute(Const.MESSAGES,"删除成功");
        return mapping.findForward(Const.VIEW);
    }
    
    
    
    //获取
    public ActionForward get(ActionMapping mapping, ActionForm actionForm,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        try{
            loadForm(request);
            request.setAttribute("classcourses",ccs.get(classId,courseId));
        }catch(StoreException se){
            request.setAttribute(Const.MESSAGES,"数据库出错");
            return mapping.findForward(Const.STORE_EXCEPTION);
        }
        return mapping.findForward(Const.UPDATE);
    }
    
    
    
    //查看
    public ActionForward view(ActionMapping mapping, ActionForm actionForm,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        try{
            loadForm(request);
            java.util.List list = null;
            if( classId!=null && year!=null && term!=null && term.length()>0 )
                list = ccs.getByClassIdAndYearAndTerm(classId,year,term);
            else if( specialId!=null && year!=null && term!=null && term.length()>0 )
                list = ccs.getBySpecialIdAndYearAndTerm(specialId,year,term);
            else{
                list = ccs.getByClassIdAndYearAndTerm(null,null,null);
                request.setAttribute(Const.MESSAGES,"班级或者专业必须选择一个");
            }
            request.setAttribute("classCourses",list);
        }catch(StoreException se){
            request.setAttribute(Const.MESSAGES,"数据库出错");
            return mapping.findForward(Const.STORE_EXCEPTION);
        }
        return mapping.findForward(Const.VIEW);
    }
    
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -