树型菜单的实现

时间:2022-05-03 11:57:21

<!---
@FileName:tree3.jsp
@Author:曾斌
@Description:树型菜单
@Date:2005-2-23
--->
<%@ include file="../comm/relogin_frame.jsp"%>
<%@ include file="../comm/db.jsp"%>
<STYLE type=text/css>A:link {
 FONT-SIZE: 9pt; TEXT-DECORATION: none
}
A:active {
 FONT-SIZE: 9pt; TEXT-DECORATION: none
}
A:visited {
 FONT-SIZE: 9pt; TEXT-DECORATION: none
}
</STYLE>
<html>
<script  language=javascript> 
 function display1(num) { 
  if (document.all("subtree"+num).style.display=="none"){
            document.all("subtree"+num).style.display="";
   document.all("image"+num).src="../images/t_sub.gif";    
 }else {
         document.all("subtree"+num).style.display="none";
   document.all("image"+num).src="../images/t_plus.gif";
   
 }
}
</script> 

<%

   String roleid=(String)session.getAttribute("roleid");
   String staffid = (String)session.getAttribute("staffid");
   if(roleid==null||staffid==null) {
//if(true) {
     %>
     <script>
      alert("你超过60分钟没有访问该页面,请重新登录!");
      top.location="../index.jsp";
     </script>

     <% 
}
     if(roleid==null) roleid="000000";
     if(staffid==null) staffid="000000";
%>

<br>
<BODY style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; BACKGROUND-COLOR: #6699cc"  >

<%

 if(staffid==null) staffid="9999";
 if(roleid==null) roleid="DDD";
 String sql2 ="";
 Connection conn = ds.getConnection();
 PreparedStatement stmt =null;// conn.createStatement();
 ResultSet rs = null;
// String sql = "select * from t_sys_sub_area  order by subareaid";
String sql = "select a.* from t_sys_sub_area a, (select distinct subareaid     from dss_sys.V_SYS_STAFF_PRIV      where staffid = '"+staffid+"' ) b where a.subareaid = b.subareaid ";
//System.out.println(sql);
stmt = conn.prepareStatement(sql);
rs  = stmt.executeQuery();
 //rs = stmt.executeQuery(sql);
 int size = rs.getFetchSize();
 int i = 0;

 while(rs.next()) {
          int key = i + 1;
    i++;
          String Content = "zhugan" + key;
          String Aux = "subtree" + key;
          String item = "image" + key;
    String tt=""+key;
 %>

<SPAN id=<%=Content%> style="CURSOR: hand; COLOR: #ffffff;font: normal bold 8pt/9pt Times, serif;" onclick=display1(<%=key%>)>
<%if("subtree1".equals(Aux)){%>
<IMG src="../images/t_sub.gif" align=absMiddle name=<%=item%>><%=rs.getString("subareaname")%>
</SPAN>
<BR>


<DIV id=<%=Aux%> style="DISPLAY: ' '">
<%}else{%>
<IMG src="../images/t_plus.gif" align=absMiddle name=<%=item%>><%=rs.getString("subareaname")%>
</SPAN>
<BR>
<DIV id=<%=Aux%> style="DISPLAY: 'none'">
<%}%>
<%           

   ResultSet rs2 = null;   
   sql2=" select * from v_sys_staff_priv  where staffid='"+staffid+"' and subareaid='"+rs.getString("subareaid")+"'";
   //System.out.println(sql2);
   stmt = conn.prepareStatement(sql2);
   rs2  = stmt.executeQuery();
//   rs2 = stmt2.executeQuery(sql2);
   while (rs2.next())  {                                            
            %>
   <IMG src="../images/line_05.gif"align=absMiddle>
   <A
   href="right.jsp?subjectid=<%=rs2.getString("subjectid")%>"
   target=right>
   <FONT color=#ffffff><%=rs2.getString("subjectname")%></FONT>
   </A>
   <BR>
   <%
    }
   if(rs2!=null) rs2.close();
   //if(stmt2!=null) stmt2.close();
   
   %>

</DIV>
<%
}
if(rs!=null) rs.close();
if(stmt!=null) stmt.close();
if(conn!=null) conn.close();
%>
</body>
</html>