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

📄 huanhudianaction.java

📁 jxc 企业资源系统ERP 的一部分
💻 JAVA
字号:
package com.luoin.struts.action;

import java.util.ArrayList;
import java.util.List;

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

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import dao.HuanhudianDAO;

public class HuanhudianAction extends Action{
	
	private HuanhudianDAO huanhuod = new HuanhudianDAO();
	private List huanhuos = new ArrayList();

	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)  throws Exception{

		HttpSession session = request.getSession();
	//按日期查询
		String year = request.getParameter("bornYear");
		String month = request.getParameter("bornMonth");
		String day = request.getParameter("bornDay");
		String startDate = null;
		String endDate = null;
		String date = year+"-"+month+"-"+day;

		try
		{		
			 if(year != null && month.equals("0") && day.equals("0"))
			{
				startDate = year+"-01-01";
				endDate = year+"-12-31";
				huanhuos = huanhuod.findYear(startDate,endDate);
				String[] nian = {startDate,endDate,"year"};
				session.setAttribute("date", nian);
				//年查询		
			}else if(year != null && month.equals("0")==false && day.equals("0"))
			{
				startDate = year+"-"+month+"-01";
				endDate = year+"-"+month+"-31";
				huanhuos = huanhuod.findMonth(startDate,endDate);	
				String[] yue = {startDate,endDate,"month"};
				session.setAttribute("date", yue);
				//月查询
	
			}else if(year != null && month.equals("0")==false && day.equals("0")==false)
			{	
				huanhuos = huanhuod.findDate(date);	
				String[] ri = {date,"day","ldy"};
				session.setAttribute("date", ri);
			
				//日查询
		
			}else if(year == null && month == null && day == null)
			{
				String[] temp = (String[])session.getAttribute("date");
				if(temp != null && temp[2].equals("year") == true)
				{
					huanhuos = huanhuod.findYear(temp[0],temp[1]);	
				}else if(temp != null && temp[2].equals("month") == true)
				{
					huanhuos = huanhuod.findMonth( temp[0],temp[1]);	
				}else if(temp != null && temp[1].equals("day") == true)
				{
					huanhuos = huanhuod.findDate(temp[0]);	
				}else{
					huanhuos= huanhuod.findAll();
				}
			}else{
				huanhuos= huanhuod.findAll();
			}
		}catch(Exception e)
		{
			e.printStackTrace();
		}
	
		request.setAttribute("huanhuos", huanhuos);
		return mapping.findForward("huanhuo");
	}
	
}

⌨️ 快捷键说明

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