<%@ 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 parent_id=request.getParameter("parent_id")==null?"":request.getParameter("parent_id");
        String menu_level = request.getParameter("menu_level") == null ? "" :request.getParameter("menu_level");
        String url="";
        if(parent_id.equals("0"))
          url="barmenu_first.jsp?id=0";
        else
          url="barmenu_modify.jsp?id="+parent_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";
        SeqIdGenerater theSeqIdGenerater=new SeqIdGenerater();
	int bar_id=theSeqIdGenerater.generatorKey("bar_menu");
	String order_id=request.getParameter("order_id")==null?"1":request.getParameter("order_id");
        String[] sqls=new String[2];
        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]= "insert into bar_menu(id,name,parent_id,menu_type,content_type,web_template_id,web_template_id2,menu_level,web_account,content,page_size,row_size,order_id) values("+bar_id+",'"+name+"',"+parent_id+",'"+menu_type+"','"+content_type+"','"+web_template_id+"','"+web_template_id2+"',"+menu_level+",'"+web_account+"','',"+page_size+","+row_size+","+order_id+")";
        
        DBOperation theDBOperation = new DBOperation();
      try {
        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=<%=parent_id%>";
	}
</script>
<html>
	<head>
		<title></title>
	</head>
	<body onload="javascript: process('<%=message%>','<%=url%>');">
	</body>
</html>