<%@ page contentType="text/html;charset=GBK" %>
<%@ page import="gbase.db.*,java.sql.*,gbase.util.*,gbase.html.*"%>
<%@ include file="../checkLogin.jsp" %>
<%
	
	String message="操作失败";
	String name=request.getParameter("name")==null?"":request.getParameter("name");
        String id=request.getParameter("id")==null?"":request.getParameter("id");
        String parent_id=request.getParameter("parent_id") == null ? "" :request.getParameter("parent_id");
        String order_id=request.getParameter("order_id")==null?"1":request.getParameter("order_id");
        String url="main.jsp";
      try {
        String sql="select id from bar_menu where web_account='"+web_account+"' and parent_id in (select id from bar_menu where web_account='"+web_account+"' and parent_id="+id+")";
        DBOperation theDBOperation = new DBOperation();
        ResultSet rs=theDBOperation.getResultSet(sql);
        rs.last();
        int sum_count=rs.getRow();
        String sqls[]=new String[sum_count+2];
        rs.beforeFirst();
        int kk=0;
        while(rs.next())
        {
          sqls[kk]="delete from bar_menu where web_account='"+web_account+"' and id="+rs.getString("id")+"";
          kk++;
        }
        sqls[kk]="delete from bar_menu where web_account='"+web_account+"' and (id="+id+" or parent_id="+id+")";
        sqls[kk+1]= "update bar_menu set order_id=order_id-1 where parent_id="+parent_id+" and web_account='"+web_account+"' and order_id>"+order_id+"";
        System.out.println("sqls[kk+1]:"+sqls[kk+1]);
        int i=theDBOperation.executeSqls(sqls);
        if(i>0)
        {
          HtmlGenerater theHtmlGenerater=new HtmlGenerater();
          //theHtmlGenerater.geneAllHtml(web_account);
          message = "操作成功,请删除首页模板对应的栏目名称以及栏目链接,并重新进行网站发布!";
        }
        else
          message = "操作失败!";
      }
      catch (Exception ex) {
        message = "操作失败!";
      }
	
%>
<script language="javascript">
	function process ( message,url){
		alert(message);
		self.location = url;
		window.parent.detail_left.location="left.jsp?id=<%=id%>";
	}
</script>
<html>
	<head>
		<title></title>
	</head>
	<body onload="javascript: process('<%=message%>','<%=url%>');">
	</body>
</html>