<%@ page contentType="text/html;charset=GBK" %>
<%@ include file="../checkLogin.jsp" %>
<%@ page import="gbase.db.*,java.util.*,gbase.util.*,java.text.*"%>
<%
	
	String message="操作失败";
	String action = request.getParameter("action")==null?"":request.getParameter("action");
	ConvertSql theConvertSql=new ConvertSql();
	
	String id = request.getParameter("id") == null ? "" :request.getParameter("id");
        String itemname=request.getParameter("itemname") == null ? "" :request.getParameter("itemname");   
        String bar_id=request.getParameter("bar_id") == null ? "0" :request.getParameter("bar_id");    
        String webname=request.getParameter("webname") == null ? "" :request.getParameter("webname");      
        String listurl=request.getParameter("listurl") == null ? "" :request.getParameter("listurl");      
        String web_encoding=request.getParameter("web_encoding") == null ? "" :request.getParameter("web_encoding");       
        String itemdoem=request.getParameter("itemdoem") == null ? "" :request.getParameter("itemdoem");  
        itemdoem=theConvertSql.convertSqlValue(itemdoem);
        String logintype=request.getParameter("logintype") == null ? "0" :request.getParameter("logintype");       
        String loginurl=request.getParameter("loginurl") == null ? "" :request.getParameter("loginurl");      
        String loginposturl=request.getParameter("loginposturl") == null ? "" :request.getParameter("loginposturl");       
        String inputloginuser=request.getParameter("inputloginuser") == null ? "" :request.getParameter("inputloginuser");      
        String loginuser=request.getParameter("loginuser") == null ? "" :request.getParameter("loginuser");       
        String inputloginpass=request.getParameter("inputloginpass") == null ? "" :request.getParameter("inputloginpass");       
        String loginpass=request.getParameter("loginpass") == null ? "" :request.getParameter("loginpass");     
        String loginfalse=request.getParameter("loginfalse") == null ? "" :request.getParameter("loginfalse");   
        
        String url="web_collection_content2.jsp?id="+id+"&action="+action;
           
	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") || action.equals("view"))
	  { 
	  sql="update web_collection set itemname='"+itemname+"',bar_id="+bar_id+",webname='"+webname+"',listurl='"+listurl+"',web_encoding='"+web_encoding+"',itemdoem='"+itemdoem+"',logintype="+logintype+",loginurl='"+loginurl+"',loginposturl='"+loginposturl+"',inputloginuser='"+inputloginuser+"',loginuser='"+loginuser+"',inputloginpass='"+inputloginpass+"',loginpass='"+loginpass+"',loginfalse='"+loginfalse+"' where id="+id+"";
	  }
	else
	  {
	  SeqIdGenerater theSeqIdGenerater=new SeqIdGenerater();
	  int seqId=theSeqIdGenerater.generatorKey("web_collection");
	  sql="insert into web_collection(id,itemname,bar_id,webname,listurl,web_encoding,itemdoem,logintype,loginurl,loginposturl,inputloginuser,loginuser,inputloginpass,loginpass,loginfalse,web_account) values("+seqId+",'"+itemname+"',"+bar_id+",'"+webname+"','"+listurl+"','"+web_encoding+"','"+itemdoem+"',"+logintype+",'"+loginurl+"','"+loginposturl+"','"+inputloginuser+"','"+loginuser+"','"+inputloginpass+"','"+loginpass+"','"+loginfalse+"','"+web_account+"')";
	  url="web_collection_content2.jsp?id="+seqId+"&action=view";
	  }
	//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>