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

📄 checkinfoaction.java

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

import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.InvocationTargetException;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

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.CheckInfoDTO;
import edu.yinhe.mis.dto.DictionaryDTO;
import edu.yinhe.mis.dto.QuestionDTO;
import edu.yinhe.mis.vo.CheckInfoVO;
import edu.yinhe.mis.vo.TestPaperVO;
import edu.yinhe.system.common.AppException;
import edu.yinhe.system.control.BaseAction;
import edu.yinhe.system.vo.PaginationVO;

/**
 * @author 孙文
 *
 */

public class CheckInfoAction extends BaseAction{
	
	/**
	 * 显示获得科目名称和试卷名称
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return 跑到infoadd页面
	 */
	public ActionForward getcreate1(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
//		System.out.println("---------getcreate1-------");
		ActionForward forward=mapping.findForward("");
		ArrayList alist=null;
		try {
			service.setDataSource(getDataSource(request,"mydatasource"));
			alist=(ArrayList) service.alllist();
			if(alist!=null){
				request.setAttribute("addlist", alist);
				forward=mapping.findForward("infoadd");//转发相应的jsp
			}
			
		} catch (AppException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return forward;
		
	}
	
	/**
	 * 获得科目名称的试卷名称
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return 查出object_Name对应的TestPaper_NO信息
	 */
	public ActionForward getTestPaper(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
	 		response.setContentType("text/html;charset=gbk");
	 		StringBuffer s=new StringBuffer();
	 		TestPaperVO testPaperVO=null;
		    String subject=request.getParameter("subject");
		    try {
				subject=new String(subject.getBytes("iso-8859-1"),"gbk");
			} catch (UnsupportedEncodingException e2) {
		
				e2.printStackTrace();
			}
		    
		try {
			service.setDataSource(getDataSource(request,"mydatasource"));//设置连接,固定写法,这个service是从BaseAction继承过来
			ArrayList alist=(ArrayList)service.list(subject);//调用服务层的方法
			int flag=0;
			
			for(Iterator it=alist.iterator();it.hasNext();){
				testPaperVO=(TestPaperVO)it.next();
				if(flag>0){
					s.append(":");
				}
				s.append(testPaperVO.getTestPaper_Name());
				s.append(",");
				s.append(testPaperVO.getTestPaper_NO());
				flag++;
			}
		}catch (AppException e) {
			e.printStackTrace();
		} 
		try {
			PrintWriter out=response.getWriter();
			out.println(s);
			out.flush();
			out.close();
		} catch (IOException e1) {
			e1.printStackTrace();
		}
		return null;
		
	}
	
	/**
	 * 此方法是用来查询所有的记录
	 * @param form 要与SchoolForm中的变量对应
	 * @param request 请求数据时所用的变量
	 * @param response 返回数据时用的变量
	 * @param mapping
	 * @return 返回值是转发的页面
	 */
	public ActionForward query(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		CheckInfoForm checkInfoForm = (CheckInfoForm) form;
		CheckInfoDTO checkInfoDTO = new CheckInfoDTO();
		PaginationVO paginationVO = new PaginationVO();
		ActionForward forward = mapping.findForward("");
		Object[] obj = null;
		String currentPage = request.getParameter("currentPage");
		if(currentPage == null||"".equals(currentPage)){
			currentPage = "1";
		}
		try {
			try {
				BeanUtils.copyProperties(checkInfoDTO,checkInfoForm);

				
			} catch (IllegalAccessException e) {
				e.printStackTrace();
			} catch (InvocationTargetException e) {
				e.printStackTrace();
			}
			paginationVO.setCurrentPage(Integer.parseInt(currentPage));
			checkInfoDTO.setRowPerPage("6");
			checkInfoDTO.setCurrentPage(currentPage);
			service.setDataSource(getDataSource(request,"mydatasource"));
			obj = (Object[])service.findAll(checkInfoDTO);

			int count = ((Integer)obj[0]).intValue();
			paginationVO.setResultsNumber(count);
			paginationVO.setRowsPerPage(6);
			paginationVO.setAllPages((count/paginationVO.getRowsPerPage())+(count%paginationVO.getRowsPerPage()>0?1:0));
			List qlist = (List)obj[1];
			if(qlist!=null&&qlist.size()!=0){
				request.setAttribute("qlist", qlist);
				request.setAttribute("paginationVO", paginationVO);
				request.setAttribute("checkInfoDTO", checkInfoDTO);
				forward = mapping.findForward("infofish");
			}
		} catch (AppException e) {
			e.printStackTrace();
		}

		return forward;
				
	}
	
	/**
	 * 到say面页
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return 到say面页
	 */
	public ActionForward getcreate2(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
//		System.out.println("---------getcreate2-------");
		ActionForward forward=mapping.findForward("say");

		return forward;

	}
	
	/**
	 * 向数据库增加对应信息
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return 重新回到check1页面
	 */
	public ActionForward getinsert(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		response.setContentType("text/html;charset=gbk");
		Integer count=Integer.parseInt(request.getParameter("count"));
	    String check_begintime=request.getParameter("starttime");
	    String check_finishtime=request.getParameter("endtime");
	    String testPaper_no=request.getParameter("testpaperID");
	    String object_name=request.getParameter("subject");
	    CheckInfoDTO  checkInfoDTO =new CheckInfoDTO();
		ActionForward forward=null;
		Integer flag =0;
		checkInfoDTO.setCount(count);
		checkInfoDTO.setCheck_begintime(check_begintime);
		checkInfoDTO.setCheck_finishtime(check_finishtime);
		checkInfoDTO.setTestPaper_no(testPaper_no);
		checkInfoDTO.setObject_name(object_name);
		
		try {
			service.setDataSource(getDataSource(request,"mydatasource"));//设置连接,固定写法,这个service是从BaseAction继承过来
			flag =(Integer) service.create(checkInfoDTO);
			if(flag==1){
				forward=mapping.findForward("infoadd1");
			
			}
		}catch (AppException e) {
			e.printStackTrace();
		}
		return forward;
		
	}
	
	/**
	 * 获得数据库对应信息
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return 重新回到 页面
	 */
	public ActionForward getupdate(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
//		System.out.println("---------getcreate2-------");
		Integer checkid=Integer.parseInt(request.getParameter("check_id"));
		ActionForward forward=mapping.findForward("");
		ArrayList alist=new ArrayList();
		
		try {
			service.setDataSource(getDataSource(request,"mydatasource"));//设置连接,固定写法,这个service是从BaseAction继承过来
			alist =(ArrayList) service.load(checkid);//调用服务层的方法

				if(alist!=null){
					request.setAttribute("inftvo", alist);
					forward=mapping.findForward("suppose");//转发相应的jsp
				}

		}catch (AppException e) {
			e.printStackTrace();
		}
		return forward;
		
	}
	
	/**
	 * 修改数据库对应信息
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return 重新回到suppose1页面
	 */
	public ActionForward getupdate1(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		CheckInfoForm checkInfoForm = (CheckInfoForm) form;
//		System.out.println("---------getupdate1-------");
		CheckInfoDTO checkInfoDTO=new CheckInfoDTO();
		Integer check_id=Integer.parseInt(request.getParameter("check_id"));
		Integer count=Integer.parseInt(request.getParameter("count"));
		String check_begintime=request.getParameter("starttime");
		String check_finishtime=request.getParameter("endtime");
		 
		checkInfoDTO.setCheck_id(check_id);
		checkInfoDTO.setCount(count);
		checkInfoDTO.setCheck_begintime(check_begintime);
		checkInfoDTO.setCheck_finishtime(check_finishtime);
		ActionForward forward=mapping.findForward("");
		Integer flag=0;
		try {
			service.setDataSource(getDataSource(request,"mydatasource"));//设置连接,固定写法,这个service是从BaseAction继承过来
			flag=(Integer) service.modify(checkInfoDTO);
			if(flag==1){
				checkInfoForm = null;
				form = null;
				forward=mapping.findForward("suppose1");
			}
		} catch (AppException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		return forward;

	}
	
	/**
	 * 批量删除数据库对应信息
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return 重新回到infofish1页面
	 */
	public ActionForward getdelet(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
//		System.out.println("---------getdelet-------");
		CheckInfoForm checkInfoForm = (CheckInfoForm) form;
		CheckInfoDTO checkInfoDTO=new CheckInfoDTO();
		ActionForward forward=null;
		Object[] array = null;
		Integer flag =0;
		try {
			BeanUtils.copyProperties(checkInfoDTO, checkInfoForm);
			service.setDataSource(getDataSource(request,"mydatasource"));//设置连接,固定写法,这个service是从BaseAction继承过来
			array=request.getParameterValues("check");
			if(array != null&&array.length>0){
				flag =(Integer) service.remove(array);//调用服务层的方法
				if(flag==1){
					forward=mapping.findForward("suppose1");//转发相应的jsp
				}
			}else{
				forward=mapping.findForward("suppose1");
			}
		}catch (AppException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			e.printStackTrace();
		}
		return forward;
		
	}
	
	/**
	 * 删除数据库对应信息
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return 重新回到suppose1页面
	 */
	public ActionForward getdel(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
//		System.out.println("---------getdelet-------");
		CheckInfoForm checkInfoForm = (CheckInfoForm) form;
		CheckInfoDTO checkInfoDTO=new CheckInfoDTO();
		Integer check_id=Integer.parseInt(request.getParameter("check_id"));
		ActionForward forward=null;
		Integer flag =0;
		try {
			BeanUtils.copyProperties(checkInfoDTO, checkInfoForm);
			service.setDataSource(getDataSource(request,"mydatasource"));//设置连接,固定写法,这个service是从BaseAction继承过来
			flag =(Integer) service.findByObject(check_id);//调用服务层的方法
			if(flag==1){
				forward=mapping.findForward("suppose1");//转发相应的jsp
			}
		}catch (AppException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			e.printStackTrace();
		}
		return forward;
		
	}
	
}

⌨️ 快捷键说明

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