JSP實現樹型組織架構(7)--修改orgManage.jsp

來源:互聯網
上載者:User
js|架構  

<%@ page contentType="text/html;charset=Big5"%>
<%@ include file="orgConnInclude.jsp"%>

<%
request.setCharacterEncoding("big5");
PreparedStatement ps=null;
ResultSet rs=null;

String  queryCount=" select count(*) "+
                   " from ngb_org "+
                   " where total like ? ORDER BY TOTAL  ";
             
String queryName=" select * "+
                 " from ngb_org "+
                 " where total like ? ORDER BY TOTAL ";
%>

<html>
  <head>
  <meta http-equiv="Content-Type" content="text/html; charset=Big5">
    <title>管理組織架構</title>
    <style type="text/css">
<!--
.style1 {color: #FFFFFF}
.style2 {color: #0066FF}
-->
    </style>
  </head>
  <body>
    <form action="orgInsert.jsp">
      <fieldset>
        <legend align="Right">
          <span class="style2">新增組織架構</span>
        </legend>
        <p align="left" class="style2">所  屬   部  門
  
   
   
    <select name="fDep">
  <optgroup label="總經理室">
  <option value="總經理室">總經理室
    <%
     try{
     int i=1;
     ps=conn.prepareStatement(queryCount);
     ps.setString(1, "A10%");
     rs=ps.executeQuery();
     int result=1;
     while(rs.next())
     { result++;}
     //out.println(result);
    
     for( i=1; i<=result; i++){
     ps=conn.prepareStatement(queryName) ;
     String queryNameCondition="A"+(9+i)+"%";
     //out.println(queryNameCondition);
     ps.setString(1, queryNameCondition);
     ResultSet ors1=ps.executeQuery();
     String qa=null;
     String qaTemp=null;
     String qaTemp1=null;
     String obdep=null;
     String ocdep=null;
    
     while( ors1.next()){
      qa=ors1.getString("total");
     qaTemp=qa.substring(3,5);
     qaTemp1=qa.substring(3,6);
   
     %>
  
    
     <%
        queryNameCondition=qaTemp1+"%";
     //out.println(queryNameCondition);
     ps.setString(1, queryNameCondition);
     ResultSet ors2=ps.executeQuery();
     int oresult1=1;
     while(ors2.next())
     { oresult1++;}
     //out.println(result1);
     for(  i=1; i<=oresult1; i++){
     ps=conn.prepareStatement(queryName) ;
     ps.setString(1, queryNameCondition);
     ResultSet ors3=ps.executeQuery();
     String qb=null;
     String qbTemp=null;
     String qbTemp1=null;
     while( ors3.next()){
    
     qb=ors3.getString("total");
     qbTemp=qb.substring(3,5);
     qbTemp1=qb.substring(3,6);
     obdep=ors3.getString("name");
     %>
      <br>
      <optgroup label="<%=obdep%>">
     <option value="<%=obdep%>"><%=obdep%>
     <%
     ps=conn.prepareStatement(queryCount);
    
      queryNameCondition=qbTemp1+"%";
   
     
    
     //out.println(queryNameCondition);
     ps.setString(1, queryNameCondition);
     ResultSet ors4=ps.executeQuery();
     int oresult2=1;
     while(ors4.next())
     { oresult2++;}
     //out.println(result);
     for(  i=1; i<=oresult2; i++){
     ps=conn.prepareStatement(queryName) ;
     ps.setString(1, queryNameCondition);
     ResultSet ors5=ps.executeQuery();
     String qc=null;
     String qcTemp=null;
     String qcTemp1=null;
     while( ors5.next()){
     qc=ors5.getString("total");
     qcTemp=qc.substring(3,5);
     qcTemp1=qc.substring(3,6);
     ocdep=ors5.getString("name");
     %>
     <option value=<%=ocdep%>><%=ocdep%>
    
     <br>
     <%
        ps=conn.prepareStatement(queryCount);
   
       queryNameCondition=qcTemp1+"%";
 
    //out.println(queryNameCondition);
     ps.setString(1, queryNameCondition);
     ResultSet rs6=ps.executeQuery();
     int result3=1;
     while(rs6.next())
     { result3++;}
     //out.println(result3);
     for(  i=1; i<result3; i++){
     ps=conn.prepareStatement(queryName) ;
     ps.setString(1, queryNameCondition);
     ResultSet rs7=ps.executeQuery();
     while( rs7.next()){}}
     }
       ps=conn.prepareStatement(queryCount);
     queryNameCondition="E"+(i+9)+"%";
     //out.println(queryNameCondition);
     ps.setString(1, queryNameCondition);
     ResultSet rs8=ps.executeQuery();
     int result4=1;
     while(rs8.next())
     { result4++;}
     //out.println(result3);
     for(  i=1; i<=result4; i++){
     ps=conn.prepareStatement(queryName) ;
     ps.setString(1, queryNameCondition);
     ResultSet rs9=ps.executeQuery();
     while(rs9.next()){
    }}
          %> </optgroup><%
     }

     }}
      
    
    }
   
    }
     %>
    
   
   
   
    <!--optgroup label="製造處">
  <option value="製造處">製造處
  <option value="製造一部">製造一部
  <option value="製造二部">製造二部
  <option value="製造三部">製造三部
  </optgroup-->
  
   <%
       }
  catch(SQLException ose1)
  {ose1.printStackTrace();}
%>
  
  </select>
  </p>
        <p align="left" class="style2">新增部門名稱
        <input type="text" name="dep"/>
       <input type="submit" id="Submit" value="確認">
        </p>
      </fieldset>
    </form>
  <font color="#0099FF" size=4></font>
  <center>
 
 
 <font color="#0099FF" size=4><center>******有限公司組織架構圖</center></font>

  <table width="100%"  border="1" cellspacing="1" cellpadding="1">
    <tr>
      <!--th width="7%" rowspan="2" bgcolor="#0099FF" scope="col">   </th-->
      <th width="29%" bgcolor="#0099FF" scope="col"><span class="style1">總經理</span></th>
      <th width="19%" bgcolor="#0099FF" scope="col"><span class="style1">總經理直屬</span></th>
      <th width="19%" bgcolor="#0099FF" scope="col"><span class="style1">處級所屬</span></th>
      <th width="19%" bgcolor="#0099FF" scope="col"><span class="style1">部級所屬</span></th>
      <th width="19%" bgcolor="#0099FF" scope="col"><span class="style1">刪除部門</span></th>
    </tr>
    <%
    try{
     int i=1;
     ps=conn.prepareStatement(queryCount);
     ps.setString(1, "A10%");
     rs=ps.executeQuery();
     int result=1;
     while(rs.next())
     { result++;}
     //out.println(result);
    
     for( i=1; i<=result; i++){
     ps=conn.prepareStatement(queryName) ;
     String queryNameCondition="A"+(9+i)+"%";
     //out.println(queryNameCondition);
     ps.setString(1, queryNameCondition);
     ResultSet rs1=ps.executeQuery();
     String qa=null;
     String qaTemp=null;
     String qaTemp1=null;
    
     while( rs1.next()){
      qa=rs1.getString("total");
     qaTemp=qa.substring(3,5);
     qaTemp1=qa.substring(3,6);
   
     %>
    
    <tr bgcolor="#F0F8FF">
      <td width="29%" height="18"><%=rs1.getString("name")%></td>
      <td width="19%" height="18"> </td>
      <td width="19%" height="18"> </td>
      <td width="19%" height="18"> </td>
      <td width="19%" height="18"> <!--a href="orgDelete.jsp?name=<%=rs1.getString("name")%>">刪除部門</a--></td>
   
    </tr>
    <%
  
     queryNameCondition=qaTemp1+"%";
     //out.println(queryNameCondition);
     ps.setString(1, queryNameCondition);
     ResultSet rs2=ps.executeQuery();
     int result1=1;
     while(rs2.next())
     { result1++;}
     //out.println(result1);
     for(  i=1; i<=result1; i++){
     ps=conn.prepareStatement(queryName) ;
     ps.setString(1, queryNameCondition);
     ResultSet rs3=ps.executeQuery();
     String qb=null;
     String qbTemp=null;
     String qbTemp1=null;
     while( rs3.next()){
    
     qb=rs3.getString("total");
     qbTemp=qb.substring(3,5);
     qbTemp1=qb.substring(3,6);
      %>
    <tr bgcolor="#F0F8FF">
      <td width="29%" height="18"> </td>
      <td width="19%" height="18"><%=rs3.getString("name")%></td>
      <td width="19%" height="18"> </td>
      <td width="19%" height="18"> </td>
      <td width="19%" height="18"><a href="orgDelete.jsp?name=<%=rs3.getString("name")%>">刪除部門</a></td>
    </tr>
     <%
     ps=conn.prepareStatement(queryCount);
    
      queryNameCondition=qbTemp1+"%";
   
     
    
     //out.println(queryNameCondition);
     ps.setString(1, queryNameCondition);
     ResultSet rs4=ps.executeQuery();
     int result2=1;
     while(rs4.next())
     { result2++;}
     //out.println(result);
     for(  i=1; i<=result2; i++){
     ps=conn.prepareStatement(queryName) ;
     ps.setString(1, queryNameCondition);
     ResultSet rs5=ps.executeQuery();
     String qc=null;
     String qcTemp=null;
     String qcTemp1=null;
     while( rs5.next()){
     qc=rs5.getString("total");
     qcTemp=qc.substring(3,5);
     qcTemp1=qc.substring(3,6);
     %>
       
    <tr bgcolor="#F0F8FF">
      <td width="29%" height="18"> </td>
      <td width="19%" height="18"> </td>
      <td width="19%" height="18"><%=rs5.getString("name")%></td>
      <td width="19%" height="18"> </td>
      <td width="19%" height="18"><a href="orgDelete.jsp?name=<%=rs5.getString("name")%>">刪除部門</a></td>
    </tr>
    <%
    

     ps=conn.prepareStatement(queryCount);
   
       queryNameCondition=qcTemp1+"%";
 
    //out.println(queryNameCondition);
     ps.setString(1, queryNameCondition);
     ResultSet rs6=ps.executeQuery();
     int result3=1;
     while(rs6.next())
     { result3++;}
     //out.println(result3);
     for(  i=1; i<=result3; i++){
     ps=conn.prepareStatement(queryName) ;
     ps.setString(1, queryNameCondition);
     ResultSet rs7=ps.executeQuery();
     while( rs7.next()){
    %>
    <tr bgcolor="#F0F8FF">
      <td width="29%" height="18"> </td>
      <td width="19%" height="18"> </td>
      <td width="19%" height="18"> </td>
      <td width="19%" height="18"><%=rs7.getString("name")%></td>
      <td width="19%" height="18"><a href="orgDelete.jsp?name=<%=rs7.getString("name")%>">刪除部門</a></td>
    </tr>
     <%
     ps=conn.prepareStatement(queryCount);
     queryNameCondition="E"+(i+9)+"%";
     //out.println(queryNameCondition);
     ps.setString(1, queryNameCondition);
     ResultSet rs8=ps.executeQuery();
     int result4=1;
     while(rs8.next())
     { result4++;}
     //out.println(result3);
     for(  i=1; i<=result4; i++){
     ps=conn.prepareStatement(queryName) ;
     ps.setString(1, queryNameCondition);
     ResultSet rs9=ps.executeQuery();
     while(rs9.next()){
     rs9.getString("name");    %>
    <%}}%>
    <%}}%>
   <% }}%>
   <% }}%>
      <%}}%>
       
  </table>
  </body>
  <%}
  catch(SQLException se1)
  {se1.printStackTrace();}
  finally{conn.close();}%>
</html>

修改後添加的時候可以動態顯示父部門了




相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.