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

📄 submitperiodaction.java

📁 上一上传oa系统漏掉web-inf文件夹
💻 JAVA
字号:
/*
 * Generated by MyEclipse Struts
 * Template path: templates/java/JavaClass.vtl
 */
package com.oa.manage.action;

import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.Calendar;

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 com.oa.db.Weeklycircle;
import com.oa.db.WeeklycircleDAO;

/** 
 * MyEclipse Struts
 * Creation date: 09-13-2007
 * 
 * XDoclet definition:
 * @struts.action validate="true"
 * @struts.action-forward name="success" path="/manage/neirong-zhoubao.jsp"
 */
public class SubmitperiodAction extends Action {
	/*
	 * Generated Methods
	 */
	 WeeklycircleDAO cdao;
//   WeeklyinputDAO  wdao;
	public WeeklycircleDAO getCdao() {
		return cdao;
	}
	public void setCdao(WeeklycircleDAO cdao) {
		this.cdao = cdao;
	}
	/** 
	 * Method execute
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 */
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		// TODO Auto-generated method stub
		GregorianCalendar gc = new GregorianCalendar();
		SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
		String period = request.getParameter("period");//要添加的期号
		String currentperiod = request.getParameter("select");
		HttpSession session = request.getSession();
		String username=(String)session.getAttribute("username");
		response.setCharacterEncoding("gbk");
		PrintWriter out=null;
		try {
			out = response.getWriter();
		} catch (IOException e) {
			// TODO 自动生成 catch 块
			e.printStackTrace();
		}
		List list = null;
		if(username!=null){
			list = cdao.QueryPeriodByperiod(Integer.parseInt(period));
			if(Integer.parseInt(period)>Integer.parseInt(currentperiod)+1){
				out.print("<script>alert('该期号还不能添加,请按期号顺序依次添加!');");
			    out.print("document.location.href='neirongzhoubao.do';");
			    out.print("</script>");
			    out.flush();
			}else if(list!=null&&list.size()!=0){
				out.print("<script>alert('该期号已存在!');");
			    out.print("document.location.href='neirongzhoubao.do';");
			    out.print("</script>");
			    out.flush();				
			}else{
				int upperiod = Integer.parseInt(period)-1;
				Weeklycircle cvo = new Weeklycircle();
				List list2 = cdao.QueryPeriodByperiod(upperiod);
				if(list2!=null&&list2.size()!=0){
					Weeklycircle vo = (Weeklycircle) list2.get(0);
					Date begindate = vo.getFirstdayofweek();
					Date enddate = vo.getEnddayofweek();
					cvo.setPeriod(Integer.parseInt(period));
					gc.setTime(begindate);
					gc.add(5, +7);
					gc.set(gc.get(Calendar.YEAR), gc.get(Calendar.MONTH), gc.get(Calendar.DATE));
					try {
						cvo.setFirstdayofweek(sf.parse(sf.format(gc.getTime())));
					} catch (java.text.ParseException e) {
						// TODO 自动生成 catch 块
						e.printStackTrace();
					}
					gc.setTime(enddate);
					gc.add(5, +7);
					gc.set(gc.get(Calendar.YEAR), gc.get(Calendar.MONTH), gc.get(Calendar.DATE));
					try {
						cvo.setEnddayofweek(sf.parse(sf.format(gc.getTime())));						
					} catch (java.text.ParseException e) {
						// TODO 自动生成 catch 块
						e.printStackTrace();
					}
					cdao.Save(cvo);
					out.print("<script>alert('期号添加成功!');");
				    out.print("document.location.href='neirongzhoubao.do';");
				    out.print("</script>");
				    out.flush();
				}							
			}		
		}else{ 		
		    out.print("<script>alert('您的操作超时,请重新登录!');");
		    out.print("window.open('manage/mlogin.jsp','_top');");
		    out.print("</script>");
		    out.flush();
		}
		return null;
	}
}

⌨️ 快捷键说明

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