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

📄 applyaction.java

📁 中应用程序的访问权限对Java Web Console 中应用程序的访问权限 成功登录 Web 控制台后,可能无法自动访问在该控制台中注册的所有应用程序。通常,必须安装应用程序,才能让所有的用户在控制
💻 JAVA
字号:
package edu.yinhe.mis.control;

import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.beanutils.BeanUtils;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import edu.yinhe.mis.dto.ApplyDTO;
import edu.yinhe.mis.dto.OutlineDTO;
import edu.yinhe.mis.vo.ApplyVO;
import edu.yinhe.mis.vo.TeacherVO;
import edu.yinhe.system.common.AppException;
import edu.yinhe.system.control.BaseAction;

/**
 * 
 * @author 贺志国
 *
 */
public class ApplyAction extends BaseAction{
	    /**
	     * 添加申请人信息
		 * @param form  ApplyForm对象
		 * @param request 请求响应
		 * @param response 响应结果
		 * Creation date:04-30-2008 
		 * @throws AppException 应用异常
	     * @return forward 转发到相应的页面
	     * 
	     */
	
	public ActionForward applyAdd(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response){
			ApplyForm applyForm = (ApplyForm)form;	
			ApplyDTO dto=new ApplyDTO();
//			ArrayList list = new ArrayList();
			ActionForward forward=mapping.getInputForward();
			String applyTime = request.getParameter("applyTime");
			String startDate = request.getParameter("startDate");
			String endDate = request.getParameter("endDate");
			
			String start = startDate.substring(0, 10);
			String end = endDate.substring(0, 10);
				try {
										
					BeanUtils.copyProperties(dto, applyForm);
                    service.setDataSource(getDataSource(request,"mydatasource"));
                    if(applyTime==null){
						applyTime="";
					}else{
						dto.setApplyTime(applyTime);
					} 
                    
                    dto.setStartDate(start);
                    dto.setEndDate(end);
                    boolean flag = (Boolean) service.create(dto);
                   if(flag){
                		   forward = mapping.findForward("ss");
                   }
				} catch (IllegalAccessException e) {
					e.printStackTrace();
				} catch (InvocationTargetException e) {
					e.printStackTrace();
				} catch (AppException e) {
					e.printStackTrace();
				}
		 return forward;
	 }
	    /**
	     * 查看调课申请人
	     * @param form  ApplyForm对象
		 * @param request 请求响应
		 * @param response 响应结果
		 * Creation date:04-30-2008 
		 * @throws AppException 应用异常
	     * @return forward 转发到check.jsp页面
	     */
	public ActionForward query(ActionMapping mapping, ActionForm form,
             HttpServletRequest request, HttpServletResponse response){
			ApplyForm applyForm = (ApplyForm)form;	
			ApplyDTO dto= new ApplyDTO();
			ApplyVO vo = null;
			ArrayList list = new ArrayList();
			ActionForward forward = mapping.getInputForward();
			String pageNo= request.getParameter("pageNo");
				try {
					int currentPage = 1;//当前页
					int rowperPage = 6;//每页多少行
					int totalPage = 0;//总页数
					int totals = 0;
					
					if(pageNo==null||"".equals(pageNo)){
						pageNo = "1";
					}
					currentPage = Integer.parseInt(pageNo);
					dto.setCurrentPage(String.valueOf(currentPage));
					dto.setRowperPage(String.valueOf(rowperPage));
					BeanUtils.copyProperties(dto, applyForm);
                    service.setDataSource(getDataSource(request,"mydatasource"));
					Object[] objs = null;
                    objs = (Object[]) service.list(dto);
                    totals = (Integer) objs[0];
                    totalPage = (totals/rowperPage)+((totals%rowperPage>0)?1:0);
                    
                    request.setAttribute("totals",totals);
                    request.setAttribute("currentPage", currentPage);
                    request.setAttribute("totalPage",totalPage);
                    list = (ArrayList) objs[1];
				    if(list.size()>0){
				    	request.setAttribute("list", list);
				    	forward = mapping.findForward("check");
				    }
				} catch (IllegalAccessException e) {
					e.printStackTrace();
				} catch (InvocationTargetException e) {
					e.printStackTrace();
				} catch (AppException e) {
					e.printStackTrace();
				}
	
		      return forward;
	 }
	
	    /**
	     * 查看申请人的详细信息
	     * @param form  ApplyForm对象
		 * @param request 请求响应
		 * @param response 响应结果
		 * Creation date:04-30-2008 
		 * @throws AppException 应用异常
	     * @return forward 转发到checkList.jsp页面
	     */
	public ActionForward queryAll(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response){
		ApplyForm applyForm = (ApplyForm)form;	
		ApplyDTO dto= new ApplyDTO();
		ApplyVO vo = new ApplyVO();
		ArrayList list = new ArrayList();
		ActionForward forward = mapping.getInputForward();
		
		String id = request.getParameter("id");
			try {
				BeanUtils.copyProperties(dto, applyForm);
                service.setDataSource(getDataSource(request,"mydatasource"));
                dto.setId(Integer.parseInt(id));
                vo = (ApplyVO) service.findById(dto);
			    if(vo!=null){
			    	request.setAttribute("vo", vo);
			    	forward = mapping.findForward("checkList");
			    }
			} catch (IllegalAccessException e) {
				e.printStackTrace();
			} catch (InvocationTargetException e) {
				e.printStackTrace();
			} catch (AppException e) {
				e.printStackTrace();
			}

	      return forward;
	 }
	
	    /**
	     * 查找替代人action
	     * @param form  ApplyForm对象
		 * @param request 请求响应
		 * @param response 响应结果
		 * Creation date:04-30-2008 
		 * @throws AppException 应用异常
	     * @return forward 转发到相应的页面
    	 */
	public ActionForward findInsteadMan(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response){
		ApplyForm applyForm = (ApplyForm)form;	
		ApplyDTO dto= new ApplyDTO();
		ApplyVO vo = new ApplyVO();
		TeacherVO tvo = new TeacherVO();
		ArrayList list = new ArrayList();
		String teachCourse = request.getParameter("teachCourse");
		String id = request.getParameter("id");
		System.out.println(teachCourse);
		System.out.println(id);
		ActionForward forward = mapping.getInputForward();
			try {
				BeanUtils.copyProperties(dto, applyForm);
                service.setDataSource(getDataSource(request,"mydatasource"));
                
                dto.setId(Integer.parseInt(id));
                dto.setTeachCourse(teachCourse);
                Object[] objs = (Object[]) service.load(dto);
                vo = (ApplyVO) objs[0];
                list = (ArrayList) objs[1];
			    if(vo!=null&&list.size()>0){
			    	request.setAttribute("vo", vo);
			    	session.setAttribute("list", list);
			    	forward = mapping.findForward("findInsteadMan");
			    }
			} catch (IllegalAccessException e) {
				e.printStackTrace();
			} catch (InvocationTargetException e) {
				e.printStackTrace();
			} catch (AppException e) {
				e.printStackTrace();
			}

	      return forward;
	 }
	
	/**
	 * 供另一个方法在界面调用
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 */
	public ActionForward findInsteadMan_1(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response){
		ApplyForm applyForm = (ApplyForm)form;	
		ApplyDTO dto= new ApplyDTO();
		ApplyVO vo = new ApplyVO();
		TeacherVO tvo = new TeacherVO();
		ArrayList list = new ArrayList();
		String teachCourse = request.getParameter("teachCourse");
		String id = request.getParameter("id");
		String teacher_no = request.getParameter("teacher_no");
		System.out.println(teacher_no+"1");
		System.out.println(teachCourse+"2");
		System.out.println(id+"3");
		ActionForward forward = mapping.getInputForward();
			try {
				BeanUtils.copyProperties(dto, applyForm);
                service.setDataSource(getDataSource(request,"mydatasource"));
               
                dto.setTeacher_no(teacher_no);
                dto.setId(Integer.parseInt(id));
                dto.setTeachCourse(teachCourse);
                Object[] objs = (Object[]) service.load(dto);
                vo = (ApplyVO) objs[0];
                list = (ArrayList) objs[1];
			    if(vo!=null&&list.size()>0){
			    	request.setAttribute("vo", vo);
			    	request.setAttribute("list", list);
			    	forward = mapping.findForward("findInsteadMan");
			    }
			} catch (IllegalAccessException e) {
				e.printStackTrace();
			} catch (InvocationTargetException e) {
				e.printStackTrace();
			} catch (AppException e) {
				e.printStackTrace();
			}

	      return null;
	 }
	
	/**
     * 修改替代人action
     * @param form  ApplyForm对象
	 * @param request 请求响应
	 * @param response 响应结果
	 * Creation date:04-30-2008 
	 * @throws AppException 应用异常
     * @return forward 转发到相应的页面
	 */
	public ActionForward viewInstead(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response){
			ApplyForm applyForm = (ApplyForm)form;	
			//response.setCharacterEncoding("gb2312");
			ApplyDTO dto=new ApplyDTO();
			ApplyVO vo=new ApplyVO();
			Map map = new HashMap();
			ActionForward forward=mapping.getInputForward();
			String teacher_name = request.getParameter("teacher_name");
			String id = request.getParameter("id");
			String agree = request.getParameter("currentPage");
			System.out.println(agree);
			try {
										
					BeanUtils.copyProperties(dto, applyForm);
                    service.setDataSource(getDataSource(request,"mydatasource"));
                    
                    //转码问题
//					String name = new String(teacher_name.getBytes("iso-8859-1"),"gb2312");
                  
					System.out.println(teacher_name+"YYYY");
					System.out.println(id+"YYYY");
					if(agree==null){
						agree = "";
					}else{	
						dto.setCurrentPage(agree);
					}
					if(teacher_name==null){
						teacher_name = "";
					}else{
					   dto.setTeacher_name(teacher_name);
					}if(id==null){
						id= "";
					}else{
                      dto.setId(Integer.parseInt(id));
					}
                    
                    map  =  (Map) service.modify(dto);
//                   String m = (String) map.get("1");
//                    Set s = map.keySet();
                     vo = (ApplyVO) map.get("1");
                    System.out.println( map.get("1"));
				    if(map.containsKey("1")&&vo!=null){
				    	request.setAttribute("vo", vo);
				    	ArrayList list1 = (ArrayList)session.getAttribute("list");
				    	TeacherVO tvo = (TeacherVO)list1.get(0);
				    	request.setAttribute("tvo", tvo);
				    	forward = mapping.findForward("checkList");
				    }else if(map.containsKey("0")){
				    	forward = mapping.findForward("succeed");
				    	
				    }
				} catch (IllegalAccessException e) {
					e.printStackTrace();
				} catch (InvocationTargetException e) {
					e.printStackTrace();
				} catch (AppException e) {
					e.printStackTrace();
				}
		 return forward;
	 }
	
	/**
	 * 在大纲表中提取课程
	 * @param mapping 响应转发请求
	 * @param form  ApplyForm对象
	 * @param request 请求响应
	 * @param response 响应结果
	 * @return null 无返回
	 * Creation date:05-07-2008 
	 */
	public ActionForward findcourse(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response){
		ApplyForm applyForm=(ApplyForm) form;
		ActionForward forward=mapping.getInputForward();
	  	OutlineDTO dto=new OutlineDTO();
		ArrayList list=null;
		Object[] objs=null;
		try {
			
			   dto.setRowPerPage("1000");
		       dto.setCurrentPage("1");
				service.setDataSource(this.getDataSource(request,"mydatasource"));
				 objs=(Object[])service.alllist(dto);
				 list=(ArrayList)objs[1];
				if(list.size()!=0){
					request.setAttribute("clist",list);
				}

		}catch (AppException e) {
			e.printStackTrace();
		}
		
		return null;
	}
	
	
	public ActionForward queryApplyMan(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response){
		ArrayList list = new ArrayList();
		ActionForward forward = mapping.getInputForward();
		
			try {
                service.setDataSource(getDataSource(request,"mydatasource"));
                list = (ArrayList) service.findAll();
			    if(list.size()>0){
			    	request.getSession().setAttribute("list", list);
			    	forward = mapping.findForward("applyTiaoke");
			    }
			} catch (AppException e) {
				e.printStackTrace();
			}

	      return forward;
	 }
	
}

⌨️ 快捷键说明

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