📄 gradestataction.java
字号:
package edu.yinhe.mis.control;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import org.apache.commons.beanutils.BeanUtils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import edu.yinhe.mis.dto.GradeDTO;
import edu.yinhe.mis.dto.GradeStatDTO;
import edu.yinhe.mis.vo.GradeStatVO;
import edu.yinhe.system.common.AppException;
import edu.yinhe.system.control.BaseAction;
public class GradeStatAction extends BaseAction{
/**
* Method count 统计考生成绩
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
* author 何亮
*/
public ActionForward stat(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
System.out.println("method:stat");
Integer flag=0;
GradeStatForm gsf=new GradeStatForm();
GradeStatDTO gsdto=new GradeStatDTO();
ActionForward forward=new ActionForward();
try {
service.setDataSource(getDataSource(request,"mydatasource"));
flag = (Integer) service.findAll();
if(flag==0){
service.modify(gsdto);//成绩统计成功 将状态值改为1
forward=mapping.findForward("plan");
}
} catch (AppException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return forward;
}
public ActionForward fetle(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
System.out.println("method:fetle-stat");
ActionForward forward=new ActionForward();
GradeStatVO gsvo=new GradeStatVO();
try {
service.setDataSource(getDataSource(request,"mydatasource"));
gsvo=(GradeStatVO) service.alllist();
Integer i=gsvo.getFatle();
if(i==0){//0表示没有统计成绩
forward=mapping.findForward("stat");//转发到统计成绩的方法
}
if(i==1){//1表示成绩已经统计
forward=mapping.findForward("plan");
}
} catch (AppException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return forward;
}
public ActionForward plan(ActionMapping mapping,ActionForm form,
HttpServletRequest request,HttpServletResponse response){
System.out.println("method:plan");
GradeStatForm gsf=(GradeStatForm) form;
GradeStatDTO gsdto=new GradeStatDTO();
ActionForward forward=new ActionForward();
ArrayList alist=new ArrayList();
try {
BeanUtils.copyProperties(gsdto, gsf);
service.setDataSource(getDataSource(request,"mydatasource"));
alist=(ArrayList) service.alllist(gsdto);
request.setAttribute("plan", alist);
forward=mapping.findForward("plansuccess");
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvocationTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (AppException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return forward;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -