📄 teacherscoreactions.java
字号:
/* * TeacherScoreActions.java * * Created on 2006年6月9日, 上午4:16 * * 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 TeacherScoreActions extends org.apache.struts.actions.DispatchAction { private Integer classId; private Integer courseId; private int count; private ScoreService ss = (ScoreService)ServiceFactory.makeService("ScoreService"); private ClassCourseService ccs = (ClassCourseService)ServiceFactory.makeService("ClassCourseService"); private void loadForm(javax.servlet.http.HttpServletRequest request){ 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.count = Integer.parseInt(request.getParameter("count")); }catch(Exception e){ this.count = 0; } } public ActionForward view(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { try{ loadForm(request); ClassCourse classCourse = ccs.get(classId,courseId); Integer teacherId = ((Teacher)request.getSession().getAttribute("Teacher")).getId(); request.setAttribute("scores",ss.getByTeacherIdAndCourseIdAndClassId(teacherId,courseId,classId)); }catch(StoreException se){ request.setAttribute(Const.MESSAGES,"数据库出错"); return mapping.findForward(Const.STORE_EXCEPTION); } return mapping.findForward(Const.VIEW); } public ActionForward update(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { try{ loadForm(request); Integer teacherId = ((Teacher)request.getSession().getAttribute("Teacher")).getId(); if(count!=0){ for(int i=1;i<=count;i++){ Integer studentId = new Integer(Integer.parseInt(request.getParameter("studentId"+i))); Integer courseId = new Integer(Integer.parseInt(request.getParameter("courseId"+i))); Integer value = new Integer(Integer.parseInt(request.getParameter("value"+i))); System.out.println(""+studentId+""+courseId+""+value); ss.updateByTeacherIdAndStudentIdAndCourseId(teacherId,studentId,courseId,value); } } request.setAttribute(Const.MESSAGES,"录入成绩成功"); }catch(StoreException se){ request.setAttribute(Const.MESSAGES,"数据库出错"); return mapping.findForward(Const.STORE_EXCEPTION); } return mapping.findForward(Const.UPDATE); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -