<%@ page contentType="text/html;charset=GBK" %>
<%@ include file="../checkLogin.jsp" %>
<%@ page import="java.sql.*,gbase.db.*,java.util.*,gbase.util.*,java.text.*"%>
<%
	
	String message="操作失败";
	String action = request.getParameter("action")==null?"":request.getParameter("action");
	String url="web_timer_task_list.jsp";
	
	String id=request.getParameter("id")==null?"":request.getParameter("id");
        String task_name=request.getParameter("task_name")==null?"":request.getParameter("task_name");
        String web_collection_id=request.getParameter("web_collection_id")==null?"":request.getParameter("web_collection_id");
        String circle_flag=request.getParameter("circle_flag")==null?"":request.getParameter("circle_flag");
        String timer_time=request.getParameter("timer_time")==null?"":request.getParameter("timer_time");
        String timer_week=request.getParameter("timer_week")==null?"":request.getParameter("timer_week");
        String timer_day=request.getParameter("timer_day")==null?"":request.getParameter("timer_day");
        
	SimpleDateFormat timeformat = new SimpleDateFormat("yyyy-MM-dd");
        java.util.Date date = Calendar.getInstance().getTime();
        String create_date = timeformat.format(date).toString();
        
        String sql="";
        
        DBOperation theDBOperation = new DBOperation();
        
	if(action.equals("update"))
	  { 
	  sql="update web_timer_task set task_name='"+task_name+"',web_collection_id="+web_collection_id+",circle_flag="+circle_flag+",timer_time='"+timer_time+"',timer_week='"+timer_week+"',timer_day='"+timer_day+"' where id="+id+"";
	  }
	else if(action.equals("delete"))
	  sql="delete from web_timer_task  where id="+id+"";
	else
	  {
	  SeqIdGenerater theSeqIdGenerater=new SeqIdGenerater();
	  int seqId=theSeqIdGenerater.generatorKey("web_timer_task");
	  sql="insert into web_timer_task(id,task_name,web_collection_id,circle_flag,timer_time,timer_week,timer_day,create_date,web_account) values("+seqId+",'"+task_name+"',"+web_collection_id+","+circle_flag+",'"+timer_time+"','"+timer_week+"','"+timer_day+"','"+create_date+"','"+web_account+"')";
	  }
	//out.println(sql);
	
        try {
        int i=theDBOperation.executeSql(sql);
        if(i>0)
          {
          message = "操作成功!";
          }
        else
          message = "操作失败!";
      }
      catch (Exception ex) {
        message = "操作失败!";
      }
	
%>
<script language="javascript">
	function process ( message,url){
		alert(message);
		self.location = url;
	}
</script>
<html>
	<head>
		<title></title>
	</head>
	<body onload="javascript: process('<%=message%>','<%=url%>');">
	</body>
</html>