<%@ page contentType="text/html;charset=GBK" %>
<%@ page import="gbase.db.*,java.util.*,gbase.util.*,java.text.*"%>
<%@ page import="gbase.html.*,gbase.init.*,gbase.db.*,java.sql.*"%>
<jsp:useBean id="myEnv" scope="application" class="com.jdon.web.UserEnvFront"/>
<jsp:setProperty name="myEnv" property="*"/>
<LINK href="images/style.css" type=text/css rel=stylesheet>
<%@ page import="java.util.*,gbase.init.*,
                 com.jivesoftware.util.*,
                 com.jivesoftware.forum.*,
                 com.jivesoftware.forum.util.*"
%>
<%String web_account= request.getParameter("web_account")==null?"":request.getParameter("web_account");%>
<%@ include file="workcheck.jsp" %>
<%
	String message="操作失败";
	String action = request.getParameter("action")==null?"":request.getParameter("action");
	String url="web_titleinfo_list.jsp?web_account="+web_account;
	String id=request.getParameter("id")==null?"":request.getParameter("id");
        String title=request.getParameter("title")==null?"":request.getParameter("title");
        String title_desc=request.getParameter("title_desc")==null?"":request.getParameter("title_desc");
        String bar_id=request.getParameter("bar_id")==null?"0":request.getParameter("bar_id");
        String special_id=(request.getParameter("special_id")==null || request.getParameter("special_id").equals(""))?"0":request.getParameter("special_id");
	String content=request.getParameter("content")==null?"":request.getParameter("content");
	ConvertSql theConvertSql=new ConvertSql();
        content=theConvertSql.convertSqlValue(content);
        
        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_titleinfo set title='"+title+"',title_desc='"+title_desc+"',bar_id="+bar_id+",special_id="+special_id+",content='"+content+"',create_date='"+create_date+"' where  web_account='"+web_account+"' and id="+id+"";
	  }
	else if(action.equals("delete"))
	  sql="delete from web_titleinfo  where  web_account='"+web_account+"' and id="+id+"";
	else
	  {
	  SeqIdGenerater theSeqIdGenerater=new SeqIdGenerater();
	  int seqId=theSeqIdGenerater.generatorKey("web_titleinfo");
	  id=Integer.toString(seqId);
	  sql="insert into web_titleinfo(id,title,title_desc,bar_id,special_id,content,create_date,web_account,user_account) values("+seqId+",'"+title+"','"+title_desc+"',"+bar_id+","+special_id+",'"+content+"','"+create_date+"','"+web_account+"','"+username+"')";
	  }
	//out.println(sql);
	
        try {
        int ii=theDBOperation.executeSql(sql);
        if(ii>0)
          {
          HtmlGenerater theHtmlGenerater=new HtmlGenerater();
          theHtmlGenerater.geneFirstHtml(web_account);
          if(action.equals("delete")){
          id="";
          }
          theHtmlGenerater.geneBarByContentIdHtml(web_account,bar_id,id,title); 
          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>