<%@ page contentType="text/html;charset=GBK" %>
<%@ page import="gbase.db.*"%>
<%@ include file="../checkLogin.jsp" %>
<%
	
	String message="操作失败";
	String url="user_list1.jsp";
	
      DBOperation theDBOperation = new DBOperation();
      String user_id=request.getParameter("user_id")==null?"":request.getParameter("user_id");
      int rowCount = Integer.parseInt(request.getParameter("rowCount") == null ?
                                     "0" : request.getParameter("rowCount"));
     System.out.println("rowCount:"+rowCount);
     String[] role_id = new String[rowCount];
     String[] sql = new String[rowCount+1];
     sql[0] = "delete from web_user_role where user_id='" + user_id + "'";
     System.out.println("MODIFY sql[0]:"+sql[0]);
    for (int i = 0; i < rowCount; i++){
      int k=i+1;
      role_id[i] = request.getParameter("role_id"+k) == null ?"" : request.getParameter("role_id"+k);
      sql[i+1] = "insert into web_user_role values('"+user_id+"','"+ role_id[i]+"')";
      System.out.println("MODIFY sql["+i+1+"]:" + sql[i+1]);
    }
    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>