<%@ page contentType="text/html;charset=GBK" %>
<%@ page import="gbase.db.*,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 url="barmenu_modify.jsp?id="+id;
        
        String menu_type=request.getParameter("menu_type")==null?"0":request.getParameter("menu_type");
        String content_type=request.getParameter("content_type")==null?"0":request.getParameter("content_type");
        String web_template_id=request.getParameter("web_template_id")==null?"0":request.getParameter("web_template_id");
        String web_template_id2=request.getParameter("web_template_id2")==null?"0":request.getParameter("web_template_id2");
        if(web_template_id2.equals(""))web_template_id2="0";
        String page_size=request.getParameter("page_size")==null?"0":request.getParameter("page_size");
        if(page_size.equals(""))page_size="0";
        String row_size=request.getParameter("row_size")==null?"0":request.getParameter("row_size");
        if(row_size.equals(""))row_size="0";
        String order_id=request.getParameter("order_id")==null?"1":request.getParameter("order_id");
        String old_order_id=request.getParameter("old_order_id")==null?"1":request.getParameter("old_order_id");
        String parent_id=request.getParameter("parent_id") == null ? "" :request.getParameter("parent_id");
        DBOperation theDBOperation = new DBOperation();
        int i=0;
        if(!old_order_id.equals(order_id))
        {
        String[] sqls=new String[3];
        sqls[0]= "update bar_menu set order_id=order_id+1 where parent_id="+parent_id+" and web_account='"+web_account+"' and order_id>="+order_id+"";
        sqls[1]= "update bar_menu set name='"+name+"',menu_type='"+menu_type+"',content_type='"+content_type+"',web_template_id='"+web_template_id+"',web_template_id2='"+web_template_id2+"',page_size="+page_size+",row_size="+row_size+",order_id="+order_id+" where web_account='"+web_account+"' and id="+id+"";
        sqls[2]= "update bar_menu set order_id=order_id-1 where parent_id="+parent_id+" and web_account='"+web_account+"' and order_id>"+old_order_id+"";
        i=theDBOperation.executeSqls(sqls);
        }
        else
        {
        String sql = "update bar_menu set name='"+name+"',menu_type='"+menu_type+"',content_type='"+content_type+"',web_template_id='"+web_template_id+"',web_template_id2='"+web_template_id2+"',page_size="+page_size+",row_size="+row_size+" where web_account='"+web_account+"' and id="+id+"";
        i=theDBOperation.executeSql(sql);
        }
        
      try {
        
        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>