<%@ page contentType="text/html;charset=GBK" %>
<%@ page import="gbase.db.*,gbase.menu.*"%>
<%@ include file="../checkLogin.jsp" %>
<%
	
	String message="操作失败";
	
	String role_id = request.getParameter("role_id") == null ? "" :
        request.getParameter("role_id");
        String role_name = request.getParameter("role_name") == null ? "" :
        request.getParameter("role_name");
        String url="role_menu.jsp?role_id="+role_id+"&role_name="+role_name;
        DBOperation theDBOperation = new DBOperation();
      int rowCount = Integer.parseInt(request.getParameter("rowCount") == null ?
                                     "0" : request.getParameter("rowCount"));
     String[] menu_id = new String[rowCount];
     String check;
     int j = 0;
     for (int i = 0; i < rowCount; i++) {
       check = request.getParameter("menu_id" + i) == null ? "" :
           request.getParameter("menu_id" + i);
       //System.out.println("check ["+i+"]:" + check);
       if (!check.equals("")) {
         menu_id[j] = check;
         j++;
       }
     }
     String[] sql = new String[j+1];
     sql[0] = "delete from web_role_menu where role_id=" + role_id + "";
     //this.logger.debug("MODIFY sql[0]:"+sql[0]);
     for (int k = 0; k < j; k++) {
      sql[k+1] = "insert into web_role_menu values("+role_id+",'"+ menu_id[k]+"')";
      //this.logger.debug("MODIFY sql["+k+"]:" + sql[k]);
    }
    try {
       int i=theDBOperation.executeSqls(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>