asp+js可拖动的树

<%@ Language=VBScript %>
<%Response.Expires=0%>
<%'if session("user_name")="" then  response.redirect "default.aspx"%>
<!--#include file="include/open_cn.asp"-->
<!--#include file="include/chchar.asp"-->
<html>
<head>
<title>网站欢迎您!!!</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta http-equiv="Pragma" content="no-cache"> 
<meta name="GENERATOR" content="hwedit">
<link href="images/default/default.css" rel="stylesheet" type="text/css">
<%
clickid=Request.Form ("theclickid")
clickflag=Request.Form ("theclickflag")
dragendid=Request.Form ("thedragendid")
dragendflag=Request.Form ("thedragendflag")
dragbeginid=Request.Form ("thedragbeginid")
dragbeginflag=Request.Form ("thedragbeginflag")
if (dragendid<>"") and (dragendflag<>"") and (dragbeginid<>"") and (dragbeginflag<>"") then
  '==================================================================================
  '结点图片拖入全部---被拖结点插入当前结点--要注意不能插入自己的下级节点中!
  if dragbeginflag="1" and dragendflag="3" and dragbeginid<>dragendid then
   flag=0
   flag1=0
   set rs1 = server.CreateObject ("ADODB.Recordset")
   rs1.CursorType=3
   rs1.CursorLocation=3
   rs1.LockType=2
   sql1="select NVL(max(seq)+1,1) theseq from all_unit  where parent_id=null and flag=0"
   rs1.Open sql1,conn
   if not rs1.EOF then
    if rs1.RecordCount=1 then
     flag=1
     theseq=rs1("theseq")
    else
     flag=1
     theseq=1
    end if
   rs1.Close
   else
    flag=1
    theseq=1
   end if
   set rs1=nothing
   '==开始插入
   if flag=1 then
    set commupunit = server.CreateObject ("ADODB.command")
    commupunit.ActiveConnection = conn
    commupunit.CommandType=1
    commupunit.CommandText="update all_unit set parent_id=null,seq="&theseq&" where id="&dragbeginid
    on error resume next
    commupunit.Execute
    if err<>0 then
     Response.Write "<SCRIPT LANGUAGE=javascript>"&chr(13)&chr(10)
     Response.Write "<!--"&chr(13)&chr(10)
     Response.write "alert('拖动类别失败!');"&chr(13)&chr(10)
     Response.Write "self.location='uc_unit_edit_list1.asp';"&chr(13)&chr(10)
     Response.Write "//-->"&chr(13)&chr(10)
     Response.Write "</SCRIPT>"&chr(13)&chr(10)
    end if
   end if
   Response.Write "<SCRIPT LANGUAGE=javascript>"&chr(13)&chr(10)
   Response.Write "<!--"&chr(13)&chr(10)
   Response.write ""&chr(13)&chr(10)
   Response.Write "self.parent.sfmxx.location=self.parent.sfmxx.location;"&chr(13)&chr(10)
   Response.Write "//-->"&chr(13)&chr(10)
   Response.Write "</SCRIPT>"&chr(13)&chr(10)
  end if
  '结点图片拖入全部---被拖结点插入当前结点--要注意不能插入自己的下级节点中!
  '==================================================================================


  '==================================================================================
  '结点图片拖入结点图片---被拖结点插入当前结点--要注意不能插入自己的下级节点中!
  if dragbeginflag="1" and dragendflag="1" and dragbeginid<>dragendid then
   set rs1 = server.CreateObject ("ADODB.Recordset")
   rs1.CursorType=3
   rs1.CursorLocation=3
   rs1.LockType=2
   sql1="select * from all_unit where id="&dragendid&" connect by prior id = parent_id  start with id="&dragbeginid
   rs1.Open sql1,conn
   flag=0
   if rs1.RecordCount<1 then
     flag=1
   end if
   set rs1=nothing
   set rs1 = server.CreateObject ("ADODB.Recordset")
   rs1.CursorType=3
   rs1.CursorLocation=3
   rs1.LockType=2
   sql1="select NVL(max(seq)+1,1) theseq from all_unit where parent_id="&dragendid&" and flag=0"
   rs1.Open sql1,conn
   flag1=0
   if not rs1.EOF then
    if rs1.RecordCount=1 then
     flag1=1
     theseq=rs1("theseq")
    else
     flag=1
     theseq=1
    end if
   rs1.Close
   else
    flag=1
    theseq=1
   end if
   set rs1=nothing
   '==开始插入
   if flag=1 and flag1=1 then
    set commupunit = server.CreateObject ("ADODB.command")
    commupunit.ActiveConnection = conn
    commupunit.CommandType=1
    commupunit.CommandText="update all_unit set parent_id="&dragendid&",seq="&theseq&" where id="&dragbeginid
    on error resume next
    commupunit.Execute
    if err<>0 then
     Response.Write "<SCRIPT LANGUAGE=javascript>"&chr(13)&chr(10)
     Response.Write "<!--"&chr(13)&chr(10)
     Response.write "alert('拖动类别失败!');"&chr(13)&chr(10)
     Response.Write "self.location='uc_unit_edit_list1.asp';"&chr(13)&chr(10)
     Response.Write "//-->"&chr(13)&chr(10)
     Response.Write "</SCRIPT>"&chr(13)&chr(10)
    end if
   end if
   Response.Write "<SCRIPT LANGUAGE=javascript>"&chr(13)&chr(10)
   Response.Write "<!--"&chr(13)&chr(10)
   Response.write ""&chr(13)&chr(10)
   Response.Write "self.parent.sfmxx.location=self.parent.sfmxx.location;"&chr(13)&chr(10)
   Response.Write "//-->"&chr(13)&chr(10)
   Response.Write "</SCRIPT>"&chr(13)&chr(10)
  end if
  '结点图片拖入结点图片---被拖结点插入当前结点--要注意不能插入自己的下级节点中!
  '==================================================================================
 
  '==================================================================================
  '叶子拖入全部---被拖叶子插入当前结点最后--要进行排序最大值加1即可
  if dragbeginflag="0" and dragendflag="3" and dragbeginid<>dragendid then
   set rs1 = server.CreateObject ("ADODB.Recordset")
   rs1.CursorType=3
   rs1.CursorLocation=3
   rs1.LockType=2
   sql1="select NVL(max(seq)+1,1) theseq from all_unit  where parent_id=null and flag=1"
   rs1.Open sql1,conn
   flag=0
   if not rs1.EOF then
    if rs1.RecordCount=1 then
     flag=1
     theseq=rs1("theseq")
    else
     flag=1
     theseq=1
    end if
   rs1.Close
   else
    flag=1
    theseq=1
   end if
   set rs1=nothing
   '==开始插入
   if flag=1 then
    set commupunit = server.CreateObject ("ADODB.command")
    commupunit.ActiveConnection = conn
    commupunit.CommandType=1
    commupunit.CommandText="update all_unit set parent_id=null,seq="&theseq&" where id="&dragbeginid
    on error resume next
    commupunit.Execute
    if err<>0 then
     Response.Write "<SCRIPT LANGUAGE=javascript>"&chr(13)&chr(10)
     Response.Write "<!--"&chr(13)&chr(10)
     Response.write "alert('拖动类别失败!');"&chr(13)&chr(10)
     Response.Write "self.location='uc_unit_edit_list1.asp';"&chr(13)&chr(10)
     Response.Write "//-->"&chr(13)&chr(10)
     Response.Write "</SCRIPT>"&chr(13)&chr(10)
    end if
   end if
   Response.Write "<SCRIPT LANGUAGE=javascript>"&chr(13)&chr(10)
   Response.Write "<!--"&chr(13)&chr(10)
   Response.write ""&chr(13)&chr(10)
   Response.Write "self.parent.sfmxx.location=self.parent.sfmxx.location;"&chr(13)&chr(10)
   Response.Write "//-->"&chr(13)&chr(10)
   Response.Write "</SCRIPT>"&chr(13)&chr(10)
  end if
  '叶子拖入全部---被拖叶子插入当前结点最后--要进行排序最大值加1即可
  '==================================================================================
 
 
    '==================================================================================
  '叶子拖入结点图片---被拖叶子插入当前结点最后--要进行排序最大值加1即可
  if dragbeginflag="0" and dragendflag="1" and dragbeginid<>dragendid then
   set rs1 = server.CreateObject ("ADODB.Recordset")
   rs1.CursorType=3
   rs1.CursorLocation=3
   rs1.LockType=2
   sql1="select NVL(max(seq)+1,1) theseq from all_unit  where parent_id="&dragendid&" and flag=1"
   rs1.Open sql1,conn
   flag=0
   if not rs1.EOF then
    if rs1.RecordCount=1 then
     flag=1
     theseq=rs1("theseq")
    else
     flag=1
     theseq=1
    end if
   rs1.Close
   else
    flag=1
    theseq=1
   end if
   set rs1=nothing
   '==开始插入
   if flag=1 then
    set commupunit = server.CreateObject ("ADODB.command")
    commupunit.ActiveConnection = conn
    commupunit.CommandType=1
    commupunit.CommandText="update all_unit set parent_id="&dragendid&",seq="&theseq&" where id="&dragbeginid
    on error resume next
    commupunit.Execute
    if err<>0 then
     Response.Write "<SCRIPT LANGUAGE=javascript>"&chr(13)&chr(10)
     Response.Write "<!--"&chr(13)&chr(10)
     Response.write "alert('拖动类别失败!');"&chr(13)&chr(10)
     Response.Write "self.location='uc_unit_edit_list1.asp';"&chr(13)&chr(10)
     Response.Write "//-->"&chr(13)&chr(10)
     Response.Write "</SCRIPT>"&chr(13)&chr(10)
    end if
   end if
   Response.Write "<SCRIPT LANGUAGE=javascript>"&chr(13)&chr(10)
   Response.Write "<!--"&chr(13)&chr(10)
   Response.write ""&chr(13)&chr(10)
   Response.Write "self.parent.sfmxx.location=self.parent.sfmxx.location;"&chr(13)&chr(10)
   Response.Write "//-->"&chr(13)&chr(10)
   Response.Write "</SCRIPT>"&chr(13)&chr(10)
  end if
  '叶子拖入结点图片---被拖叶子插入当前结点最后--要进行排序最大值加1即可
  '==================================================================================

  '==================================================================================
  '结点图片拖入叶子---被拖结点在当前叶子前插入--相当于拖入叶子的父文件夹中应排第一
  if dragbeginflag="1" and dragendflag="0" and dragbeginid<>dragendid then
   set rs1 = server.CreateObject ("ADODB.Recordset")
   rs1.CursorType=3
   rs1.CursorLocation=3
   rs1.LockType=2
   sql1="select * from all_unit where id="&dragendid
   rs1.Open sql1,conn
   flag=0
   flag1=0
   flag2=0
   if not rs1.eof then
    if rs1.RecordCount=1 then
     flag=1
     thepid=rs1("parent_id")
    end if
   end if
   set rs1=nothing
   if flag=1 then
    set rs1 = server.CreateObject ("ADODB.Recordset")
    rs1.CursorType=3
    rs1.CursorLocation=3
    rs1.LockType=2
    sql1="select * from all_unit where id="&thepid&" connect by prior id = parent_id  start with id="&dragbeginid
    rs1.Open sql1,conn
    flag=0
    if rs1.RecordCount<1 then
     flag2=1
    end if
    set rs1=nothing
   end if
   if flag=1 and flag1=1 then
    set rs1 = server.CreateObject ("ADODB.Recordset")
    rs1.CursorType=3
    rs1.CursorLocation=3
    rs1.LockType=2
    sql1="select NVL(max(seq)+1,1) theseq from all_unit  where parent_id="&thepid&" and flag=1"
    rs1.Open sql1,conn
    if not rs1.EOF then
     if rs1.RecordCount=1 then
      flag2=1
      theseq=rs1("theseq")
     end if
    end if
    set rs1=nothing
   end if
   '==开始插入
   if flag=1 and flag1=1 and flag2=1 then
    set commupunit = server.CreateObject ("ADODB.command")
    commupunit.ActiveConnection = conn
    commupunit.CommandType=1
    commupunit.CommandText="update all_unit set parent_id="&thepid&",seq="&theseq&" where id="&dragbeginid
    on error resume next
    commupunit.Execute
    if err<>0 then
     Response.Write "<SCRIPT LANGUAGE=javascript>"&chr(13)&chr(10)
     Response.Write "<!--"&chr(13)&chr(10)
     Response.write "alert('拖动类别失败!');"&chr(13)&chr(10)
     Response.Write "self.location='uc_unit_edit_list1.asp';"&chr(13)&chr(10)
     Response.Write "//-->"&chr(13)&chr(10)
     Response.Write "</SCRIPT>"&chr(13)&chr(10)
    end if
   end if
   Response.Write "<SCRIPT LANGUAGE=javascript>"&chr(13)&chr(10)
   Response.Write "<!--"&chr(13)&chr(10)
   Response.write ""&chr(13)&chr(10)
   Response.Write "self.parent.sfmxx.location=self.parent.sfmxx.location;"&chr(13)&chr(10)
   Response.Write "//-->"&chr(13)&chr(10)
   Response.Write "</SCRIPT>"&chr(13)&chr(10)
  end if
  '结点图片拖入叶子---被拖结点在当前叶子前插入--相当于拖入叶子的父文件夹中应排第一
  '==================================================================================

  '==================================================================================
  '叶子拖入叶子---被拖叶子在当前叶子前插入--排序运算!
  if dragbeginflag="0" and dragendflag="0" and dragbeginid<>dragendid then
   set rs1 = server.CreateObject ("ADODB.Recordset")
   rs1.CursorType=3
   rs1.CursorLocation=3
   rs1.LockType=2
   sql1="select * from all_unit where id="&dragendid
   rs1.Open sql1,conn
   flag=0
   flag1=0
   flag2=0
   theseq=0
   tempseq=0
   theendseq=0
   thelastseq=0
   if not rs1.eof then
    if rs1.RecordCount=1 then
     flag=1
     thepid=rs1("parent_id")
    end if
   end if
   set rs1=nothing
  
   if flag=1 then
     set rs1 = server.CreateObject ("ADODB.Recordset")
     rs1.CursorType=3
     rs1.CursorLocation=3
     rs1.LockType=2
     sql1="select * from all_unit where flag=1 and parent_id="&thepid&" order by seq asc"
     rs1.Open sql1,conn
     if not rs1.eof then
      if rs1.RecordCount=0 then
       flag1=1
       theseq=1
      else
       if rs1.recordCount=1 then
        flag1=1
        theendseq=cint(rs1("seq"))
       else
        do while not rs1.eof
         if cstr(rs1("id"))=dragendid then
           flag1=1
           thelastseq=cint(tempseq)
           theendseq=cint(rs1("seq"))
           exit do
         end if
         tempseq=rs1("seq")
         rs1.movenext
        loop
       end if
      end if
     end if
     set rs1=nothing
   end if
  
  
   '判断是否要后移后面的叶子
   if flag1=1 then
     if theseq>0 then
       '用theseq直接插
       flag2=1
     else
     '计算theseq
       if theendseq<>0 and thelastseq<>0 then
         if theendseq-thelastseq>1 then
           '不用挪动了
           flag2=1
           theseq=thelastseq+1
         else
           '要挪动
           theadd=0
           if theendseq-thelastseq=0 then
             theadd=2
           else
             if theendseq-thelastseq=1 then
               theadd=1
             end if
           end if
           if theadd<>0 then  
             set commupunit = server.CreateObject ("ADODB.command")
             commupunit.ActiveConnection = conn
             commupunit.CommandType=1
             commupunit.CommandText="update all_unit set seq=seq+"&theadd&" where parent_id="&thepid&"and flag=1 and seq>"&thelastseq
             on error resume next
             commupunit.Execute
             if err<>0 then
               Response.Write "<SCRIPT LANGUAGE=javascript>"&chr(13)&chr(10)
               Response.Write "<!--"&chr(13)&chr(10)
               Response.write "alert('排序失败!');"&chr(13)&chr(10)
               Response.Write "self.location='uc_unit_edit_list1.asp';"&chr(13)&chr(10)
               Response.Write "//-->"&chr(13)&chr(10)
               Response.Write "</SCRIPT>"&chr(13)&chr(10)
             else          
               flag2=1
               theseq=thelastseq+1
             end if
           end if
         end if
       end if
      
       if  theendseq<>0 and thelastseq=0 then
         if theendseq>1 then
           '不用挪
           flag2=1
           theseq=1
         else
             set commupunit = server.CreateObject ("ADODB.command")
             commupunit.ActiveConnection = conn
             commupunit.CommandType=1
             commupunit.CommandText="update all_unit set seq=seq+1 where flag=1 and parent_id="&thepid
             on error resume next
             commupunit.Execute
             if err<>0 then
               Response.Write "<SCRIPT LANGUAGE=javascript>"&chr(13)&chr(10)
               Response.Write "<!--"&chr(13)&chr(10)
               Response.write "alert('排序失败!');"&chr(13)&chr(10)
               Response.Write "self.location='uc_unit_edit_list1.asp';"&chr(13)&chr(10)
               Response.Write "//-->"&chr(13)&chr(10)
               Response.Write "</SCRIPT>"&chr(13)&chr(10)
             else          
               flag2=1
               theseq=1
             end if
         end if
       end if
     end if
   end if
   '==开始插入
   if flag=1 and flag1=1 and flag2=1 then
    set commupunit = server.CreateObject ("ADODB.command")
    commupunit.ActiveConnection = conn
    commupunit.CommandType=1
    commupunit.CommandText="update all_unit set parent_id="&thepid&",seq="&theseq&" where id="&dragbeginid
    on error resume next
    commupunit.Execute
    if err<>0 then
     Response.Write "<SCRIPT LANGUAGE=javascript>"&chr(13)&chr(10)
     Response.Write "<!--"&chr(13)&chr(10)
     Response.write "alert('拖动类别失败!');"&chr(13)&chr(10)
     Response.Write "self.location='uc_unit_edit_list1.asp';"&chr(13)&chr(10)
     Response.Write "//-->"&chr(13)&chr(10)
     Response.Write "</SCRIPT>"&chr(13)&chr(10)
    end if
   end if 
   Response.Write "<SCRIPT LANGUAGE=javascript>"&chr(13)&chr(10)
   Response.Write "<!--"&chr(13)&chr(10)
   Response.write ""&chr(13)&chr(10)
   Response.Write "self.parent.sfmxx.location=self.parent.sfmxx.location;"&chr(13)&chr(10)
   Response.Write "//-->"&chr(13)&chr(10)
   Response.Write "</SCRIPT>"&chr(13)&chr(10)
  end if
  '叶子拖入叶子---被拖叶子在当前叶子前插入--排序运算!
  '==================================================================================
 
 
  '==================================================================================
  '叶子拖入结点文字---等同于被拖叶子插入当前结点内并排最后--要进行排序最大值加1即可
  if dragbeginflag="0" and dragendflag="2" and dragbeginid<>dragendid then
   set rs1 = server.CreateObject ("ADODB.Recordset")
   rs1.CursorType=3
   rs1.CursorLocation=3
   rs1.LockType=2
   sql1="select NVL(max(seq)+1,1) theseq from all_unit  where parent_id="&dragendid&" and flag=1"
   rs1.Open sql1,conn
   flag=0
   if not rs1.EOF then
    if rs1.RecordCount=1 then
     flag=1
     theseq=rs1("theseq")
    else
     flag=1
     theseq=1
    end if
   rs1.Close
   else
    flag=1
    theseq=1
   end if
   set rs1=nothing
   '==开始插入
   if flag=1 then
    set commupunit = server.CreateObject ("ADODB.command")
    commupunit.ActiveConnection = conn
    commupunit.CommandType=1
    commupunit.CommandText="update all_unit set parent_id="&dragendid&",seq="&theseq&" where id="&dragbeginid
    on error resume next
    commupunit.Execute
    if err<>0 then
     Response.Write "<SCRIPT LANGUAGE=javascript>"&chr(13)&chr(10)
     Response.Write "<!--"&chr(13)&chr(10)
     Response.write "alert('拖动类别失败!');"&chr(13)&chr(10)
     Response.Write "self.location='uc_unit_edit_list1.asp';"&chr(13)&chr(10)
     Response.Write "//-->"&chr(13)&chr(10)
     Response.Write "</SCRIPT>"&chr(13)&chr(10)
    end if
   end if
   Response.Write "<SCRIPT LANGUAGE=javascript>"&chr(13)&chr(10)
   Response.Write "<!--"&chr(13)&chr(10)
   Response.write ""&chr(13)&chr(10)
   Response.Write "self.parent.sfmxx.location=self.parent.sfmxx.location;"&chr(13)&chr(10)
   Response.Write "//-->"&chr(13)&chr(10)
   Response.Write "</SCRIPT>"&chr(13)&chr(10)
  end if
  '叶子拖入结点文字---等同于被拖叶子插入当前结点内并排最后--要进行排序最大值加1即可
  '==================================================================================
 
  '==================================================================================
  '结点图片拖入结点文字---等同于被拖结点插入当前结点前一个位置--要进行排序
  if dragbeginflag="1" and dragendflag="2" and dragbeginid<>dragendid then
   flag=0
   flag1=0
   flag2=0
   flag3=0
   theseq=0
   tempseq=0
   theendseq=0
   thelastseq=0
   '==判断是否拖入自己子结点
   set rs1 = server.CreateObject ("ADODB.Recordset")
   rs1.CursorType=3
   rs1.CursorLocation=3
   rs1.LockType=2
   sql1="select * from all_unit where id="&dragendid&" connect by prior id = parent_id  start with id="&dragbeginid
   rs1.Open sql1,conn
   flag=0
   if rs1.RecordCount<1 then
     flag=1
   end if
   set rs1=nothing
  
   '==得到拖入结点父结点id
   if flag=1 then
    set rs1 = server.CreateObject ("ADODB.Recordset")
    rs1.CursorType=3
    rs1.CursorLocation=3
    rs1.LockType=2
    sql1="select * from all_unit where id="&dragendid
    rs1.Open sql1,conn
    if not rs1.eof then
     if rs1.RecordCount=1 then
      flag1=1
      thepid=rs1("parent_id")
     end if
    end if
    set rs1=nothing
   end if

   '==得到拖入结点父结点下的所有结点和排序
   if flag1=1 then
     set rs1 = server.CreateObject ("ADODB.Recordset")
     rs1.CursorType=3
     rs1.CursorLocation=3
     rs1.LockType=2
    
     if (isnull(thepid)) then
     sql1="select * from all_unit where flag=0 and parent_id is null order by seq asc"
     rs1.Open sql1,conn
     else
     sql1="select * from all_unit where flag=0 and parent_id="&thepid&" order by seq asc"
     rs1.Open sql1,conn
     end if
     'rs1.Open sql1,conn
     if not rs1.eof then
      if rs1.RecordCount=0 then
       flag2=1
       theseq=1
      else
       if rs1.recordCount=1 then
        flag2=1
        theendseq=cint(rs1("seq"))
       else
        do while not rs1.eof
         if cstr(rs1("id"))=dragendid then
           flag2=1
           thelastseq=cint(tempseq)
           theendseq=cint(rs1("seq"))
           exit do
         end if
         tempseq=rs1("seq")
         rs1.movenext
        loop
       end if
      end if
     end if
     set rs1=nothing
   end if

   '==判断是否要后移后面的叶子
   if flag2=1 then
     if theseq>0 then
       '用theseq直接插
       flag3=1
     else
     '计算theseq
       if theendseq<>0 and thelastseq<>0 then
         if theendseq-thelastseq>1 then
           '不用挪动了
           flag3=1
           theseq=thelastseq+1
         else
           '要挪动
           theadd=0
           if theendseq-thelastseq=0 then
             theadd=2
           else
             if theendseq-thelastseq=1 then
               theadd=1
             end if
           end if
           if theadd<>0 then  
             set commupunit = server.CreateObject ("ADODB.command")
             commupunit.ActiveConnection = conn
             commupunit.CommandType=1
             if (isnull(thepid)) then
             commupunit.CommandText="update all_unit set seq=seq+"&theadd&" where parent_id=null and flag=0 and seq>"&thelastseq
             else
             commupunit.CommandText="update all_unit set seq=seq+"&theadd&" where parent_id="&thepid&" and flag=0 and seq>"&thelastseq
             end if
             on error resume next
             commupunit.Execute
             if err<>0 then
               Response.Write "<SCRIPT LANGUAGE=javascript>"&chr(13)&chr(10)
               Response.Write "<!--"&chr(13)&chr(10)
               Response.write "alert('排序失败!');"&chr(13)&chr(10)
               Response.Write "self.location='uc_unit_edit_list1.asp';"&chr(13)&chr(10)
               Response.Write "//-->"&chr(13)&chr(10)
               Response.Write "</SCRIPT>"&chr(13)&chr(10)
             else          
               flag3=1
               theseq=thelastseq+1
             end if
           end if
         end if
       end if
      
       if theendseq<>0 and thelastseq=0 then
         if theendseq>1 then
           '不用挪
           flag2=1
           theseq=1
         else
             set commupunit = server.CreateObject ("ADODB.command")
             commupunit.ActiveConnection = conn
             commupunit.CommandType=1
             commupunit.CommandText="update all_unit set seq=seq+1 where flag=0 and parent_id="&thepid
             on error resume next
             commupunit.Execute
             if err<>0 then
               Response.Write "<SCRIPT LANGUAGE=javascript>"&chr(13)&chr(10)
               Response.Write "<!--"&chr(13)&chr(10)
               Response.write "alert('排序失败!');"&chr(13)&chr(10)
               Response.Write "self.location='uc_unit_edit_list1.asp';"&chr(13)&chr(10)
               Response.Write "//-->"&chr(13)&chr(10)
               Response.Write "</SCRIPT>"&chr(13)&chr(10)
             else          
               flag2=1
               theseq=1
             end if
         end if
       end if
     end if
   end if
   '==开始插入
   if flag=1 and flag1=1 and flag2=1 then
    set commupunit = server.CreateObject ("ADODB.command")
    commupunit.ActiveConnection = conn
    commupunit.CommandType=1
    if isnull(thepid) then
    commupunit.CommandText="update all_unit set parent_id=null,seq="&theseq&" where id="&dragbeginid
    else
    commupunit.CommandText="update all_unit set parent_id="&thepid&",seq="&theseq&" where id="&dragbeginid
    end if
    on error resume next
    commupunit.Execute
    if err<>0 then
     Response.Write "<SCRIPT LANGUAGE=javascript>"&chr(13)&chr(10)
     Response.Write "<!--"&chr(13)&chr(10)
     Response.write "alert('拖动类别失败!');"&chr(13)&chr(10)
     Response.Write "self.location='uc_unit_edit_list1.asp';"&chr(13)&chr(10)
     Response.Write "//-->"&chr(13)&chr(10)
     Response.Write "</SCRIPT>"&chr(13)&chr(10)
    end if
   end if 
   Response.Write "<SCRIPT LANGUAGE=javascript>"&chr(13)&chr(10)
   Response.Write "<!--"&chr(13)&chr(10)
   Response.write ""&chr(13)&chr(10)
   Response.Write "self.parent.sfmxx.location=self.parent.sfmxx.location;"&chr(13)&chr(10)
   Response.Write "//-->"&chr(13)&chr(10)
   Response.Write "</SCRIPT>"&chr(13)&chr(10)
  end if
  '结点图片拖入结点文字---等同于被拖结点插入当前结点后一个位置--要进行排序
  '==================================================================================
end if
%>

<STYLE>
.clicked
{
    CURSOR: hand;
    COLOR: white;
    BACKGROUND-COLOR: darkblue;
}
.unclicked
{
    CURSOR: hand;
    COLOR:  black;
    BACKGROUND-COLOR: white;
}
.dragbegin
{
    CURSOR: hand;
    COLOR:  gray;
    BACKGROUND-COLOR: silver;
}
.imgdragbegin
{
    CURSOR: hand;
    COLOR:  gray;
    BACKGROUND-COLOR: silver;
    filter: Gray;
}
.dragend
{
    CURSOR: hand;
    COLOR:  black;
    BACKGROUND-COLOR: silver;
}
.imgdragend
{
    CURSOR: hand;
    COLOR:  black;
    BACKGROUND-COLOR: silver;
    filter:Xray;
}
.docked
{
    POSITION: absolute;
    display:none;
    filter:alpha(opacity=100);
}

.actived
{
    POSITION: absolute;
    display:block;
    filter:alpha(opacity=50);
}
</STYLE>
<form action="uc_unit_edit_list1.asp" method=post name="formdrag" id="formdrag">
<INPUT type="hidden" id=theclickid name=theclickid value="<%=clickid%>">
<INPUT type="hidden" id=theclickflag name=theclickflag value="<%=clickflag%>">
<INPUT type="hidden" id=thedragendid name=thedragendid>
<INPUT type="hidden" id=thedragendflag name=thedragendflag>
<INPUT type="hidden" id=thedragbeginid name=thedragbeginid>
<INPUT type="hidden" id=thedragbeginflag name=thedragbeginflag>
</form>
<body οncοntextmenu="javascript:return false;" οndragstart="javascript:return false;" onselectstart ="javascript:return false;" οnselect="javascript:document.selection.empty();" οncοpy="javascript:document.selection.empty();" onbeforecopy="javascript:return false;"οnmοuseup="javascript:document.selection.empty();"  bgColor=White>
<div id="divf" class="docked" nowrap></div>
<SCRIPT LANGUAGE=javascript>
<!--
//配置物件位置
var f_orgnX = 200;
var f_orgnY = 0;

//设置物件位置
divf.style.pixelLeft = f_orgnX;
divf.style.pixelTop = f_orgnY;

//拖拽过程中相关变量
var draging = false; //是否处于拖拽中
var offsetX = 0;     //X方向左右偏移量
var offsetY = 0;     //Y方向上下偏移量

//================================================
//点击结点图片
function nodeclick(id,object){
 if (formdrag.thedragbeginid.value!=""){
   olddragfontid="font"+formdrag.thedragbeginid.value;
   document.getElementById(olddragfontid).className="unclicked";
   if (formdrag.thedragbeginflag.value=="1"){
     beginimg="node"+formdrag.thedragbeginid.value+"img";
     document.getElementById(beginimg).className="unclicked";
   }
 }
 if (formdrag.thedragendid.value!=""){
   olddragendfontid="font"+formdrag.thedragendid.value;
   document.getElementById(olddragendfontid).className="unclicked";
   if (formdrag.thedragendflag.value=="1"){
     endimg="node"+formdrag.thedragendid.value+"img";
     document.getElementById(endimg).className="unclicked";
   }
 }
 formdrag.thedragbeginflag.value="";
 formdrag.thedragbeginid.value="";
 formdrag.thedragendflag.value="";
 formdrag.thedragendid.value="";
 subtreediv = "tree"+id
 object.className="unclicked";
 if (document.all(subtreediv)){
 if (document.all(subtreediv).style.display == ""){
   document.all(subtreediv).style.display = "none";
   object.src = "images/sfm_list/close.gif";
 }
 else{
   document.all(subtreediv).style.display = "";
   object.src = "images/sfm_list/open.gif";
 }
 }

}

//================================================
//点击叶子文字
function  leafclick(id,object){
 if (formdrag.theclickid.value!=""){
   oldnodefontid="font"+formdrag.theclickid.value;
   document.all(oldnodefontid).className="unclicked";
 }else{
 theall.className = "unclicked";
 }
 if (formdrag.thedragbeginid.value!=""){
   olddragfontid="font"+formdrag.thedragbeginid.value;
   document.all(olddragfontid).className="unclicked";
 }
 if (formdrag.thedragendid.value!=""){
   olddragendfontid="font"+formdrag.thedragendid.value;
   document.all(olddragendfontid).className="unclicked";
 }
 nodefontid="font"+id;
 document.all(nodefontid).className="clicked";
 formdrag.theclickflag.value="0";
 formdrag.theclickid.value=id;
 formdrag.thedragbeginflag.value="";
 formdrag.thedragbeginid.value="";
 formdrag.thedragendflag.value="";
 formdrag.thedragendid.value="";
 parent.sfmxx.location.href="uc_unit_edit_change.asp?the_id="+id+"&the_flag=1"
}

//================================================
//点击结点文字
function  nodefontclick(id,object){
 if (formdrag.theclickid.value!=""){
   oldnodefontid="font"+formdrag.theclickid.value;
   document.all(oldnodefontid).className="unclicked";
 }else{
 theall.className = "unclicked";
 }
 
 if (formdrag.thedragbeginid.value!=""){
   olddragfontid="font"+formdrag.thedragbeginid.value;
   document.all(olddragfontid).className="unclicked";
 }
 if (formdrag.thedragendid.value!=""){
   olddragendfontid="font"+formdrag.thedragendid.value;
   document.all(olddragendfontid).className="unclicked";
 }
 nodefontid="font"+id;
 document.all(nodefontid).className="clicked";
 formdrag.theclickflag.value="1";
 formdrag.theclickid.value=id;
 formdrag.thedragbeginflag.value="";
 formdrag.thedragbeginid.value="";
 formdrag.thedragendflag.value="";
 formdrag.thedragendid.value="";
 parent.sfmxx.location.href="uc_unit_edit_change.asp?the_id="+id+"&the_flag=0"
}

//================================================
//点击全部按钮
function clickall(){
 if (formdrag.theclickid.value!=""){
   oldnodefontid="font"+formdrag.theclickid.value;
   document.all(oldnodefontid).className="unclicked";
 }else{
 theall.className = "unclicked";
 }
 if (formdrag.thedragbeginid.value!=""){
   olddragfontid="font"+formdrag.thedragbeginid.value;
   document.all(olddragfontid).className="unclicked";
 }
 if (formdrag.thedragendid.value!=""){
   olddragendfontid="font"+formdrag.thedragendid.value;
   document.all(olddragendfontid).className="unclicked";
 }
 theall.className ="clicked";
 formdrag.theclickflag.value="";
 formdrag.theclickid.value="";
 formdrag.thedragbeginflag.value="";
 formdrag.thedragbeginid.value="";
 formdrag.thedragendflag.value="";
 formdrag.thedragendid.value="";
 parent.sfmxx.location.href="uc_unit_edit_change.asp"
}


//================================================
//叶子节点开始拖
function  leafmousedown(id,object){
 if (event.button != 1){return;}
 draging = true;
 formdrag.thedragbeginflag.value="0";
 formdrag.thedragbeginid.value=id;
 object.className="dragbegin";
 divf.innerHTML = object.innerHTML; //复制内容
 offsetX = document.body.scrollLeft + event.clientX-object.style.pixelLeft;
 offsetY = document.body.scrollTop + event.clientY-object.style.pixelTop;
 //divf.className = "actived";
}
//================================================
//叶子节点结束拖
function  leafmouseup(id,object){
if (event.button != 1) { return; }
draging = false;
divf.className = "docked";
if (formdrag.thedragbeginid.value!=""){
 if (formdrag.thedragbeginid.value!=id){
  formdrag.thedragendflag.value="0";
  formdrag.thedragendid.value=id;
 
  //完成拖动提交表单!
  //alert("拖动完成!"+id);
  formdrag.submit();
  return false;
 }else{
  //alert("拖自己!"+id);
  return;
 }
}else{
 //alert("没有开始点!"+id);

 nodefontid="font"+id;
 document.all(nodefontid).className="upclicked";
 if (formdrag.thedragbeginflag.value=="1"){
   oldnodeimgid="node"+formdrag.thedragbeginflag.value+"img";
   document.all(oldnodeimgid).className="unclicked";
 }
 if (formdrag.theclickid.value!=""){
   oldnodefontid="font"+formdrag.theclickid.value;
   document.all(oldnodefontid).className="clicked";
 }
 nodefontid="font"+id;
 document.all(nodefontid).className="upclicked";
 formdrag.thedragbeginflag.value="";
 formdrag.thedragbeginid.value="";
 formdrag.thedragendflag.value="";
 formdrag.thedragendid.value="";
}
}

//================================================
//叶子节点拖动经过
function  leafmouseover(id,object){
 if ((id!=formdrag.thedragbeginid.value)&&(id!= formdrag.theclickid.value)&&(draging)){
 object.className="dragend";}
}

//================================================
//叶子节点拖动离开
function  leafmouseout(id,object){
 if ((id!=formdrag.thedragbeginid.value)&&(id!= formdrag.theclickid.value)&&(draging)){
 object.className="unclicked";}
}

 

//================================================
//结点图片节点开始拖动
function  nodemousedown(id,object){
 if (event.button != 1){return;}
 draging = true;
 formdrag.thedragbeginflag.value="1";
 formdrag.thedragbeginid.value=id;
 object.className="imgdragbegin";
 objectfontid="font"+id;
 divf.innerHTML = "<img src="+object.src+" class="+object.className+"WIDTH=16 HEIGHT=14 align=left><font style='font-size:9pt;'>"+document.getElementById(objectfontid).innerHTML+"</font>"
 object.parentElement.innerHTML;//复制内容
 offsetX = document.body.scrollLeft + event.clientX-object.style.pixelLeft;
 offsetY = document.body.scrollTop + event.clientY-object.style.pixelTop;
 //divf.className = "actived";
}


//================================================
//结点图片节点结束拖动
function  nodemouseup(id,object){
if (event.button != 1) { return; }
draging = false;
divf.className = "docked";
if (formdrag.thedragbeginid.value!=""){
 if (formdrag.thedragbeginid.value!=id){
  formdrag.thedragendflag.value="1";
  formdrag.thedragendid.value=id;
 
  //完成拖动提交表单!
  //alert("拖动完成!"+id);
  formdrag.submit();
  return false;
 }else{
  //alert("拖自己!"+id);
  nodefontid="font"+id;
  document.all(nodefontid).className="unclicked";
  return;
 }
}else{
 //alert("没有开始点!"+id);

 nodefontid="font"+id;
 document.all(nodefontid).className="unclicked";
 if (formdrag.thedragbeginid.value!=""){
   olddragfontid="font"+formdrag.thedragbeginid.value;
   document.all(olddragfontid).className="unclicked";
   if (formdrag.thedragbeginflag.value=="1"){
     beginimg="node"+formdrag.thedragbeginid.value+"img";
     document.getElementById(beginimg).className="unclicked";
   }
 }
 if (formdrag.thedragendid.value!=""){
   olddragfontid="font"+formdrag.thedragendid.value;
   document.all(olddragfontid).className="unclicked";
   if (formdrag.thedragendflag.value=="1"){
     endimg="node"+formdrag.thedragbeginid.value+"img";
     document.getElementById(endimg).className="unclicked";
   }
 }
 if (formdrag.theclickid.value!=""){
   oldnodefontid="font"+formdrag.theclickid.value;
   document.all(oldnodefontid).className="clicked";
 }
 divf.className = "docked";
 formdrag.thedragbeginflag.value="";
 formdrag.thedragbeginid.value="";
 formdrag.thedragendflag.value="";
 formdrag.thedragendid.value="";
}
}

//================================================
//全部节点结束拖动
function  allmouseup(){
if (event.button != 1) { return; }
draging = false;
divf.className = "docked";
if (formdrag.thedragbeginid.value!=""){
  formdrag.thedragendflag.value="3";
  formdrag.thedragendid.value="theall";
 
  //完成拖动提交表单!
  //alert("拖动完成!"+id);
  formdrag.submit();
  return false;
}else{
 //alert("没有开始点!"+id);

 nodefontid="theall";
 document.all(nodefontid).className="unclicked";
 if (formdrag.thedragbeginid.value!=""){
   olddragfontid="font"+formdrag.thedragbeginid.value;
   document.all(olddragfontid).className="unclicked";
   if (formdrag.thedragbeginflag.value=="1"){
     beginimg="node"+formdrag.thedragbeginid.value+"img";
     document.getElementById(beginimg).className="unclicked";
   }
 }
 if (formdrag.thedragendid.value!=""){
   olddragfontid="font"+formdrag.thedragendid.value;
   document.all(olddragfontid).className="unclicked";
   if (formdrag.thedragendflag.value=="1"){
     endimg="node"+formdrag.thedragbeginid.value+"img";
     document.getElementById(endimg).className="unclicked";
   }
 }
 if (formdrag.theclickid.value!=""){
   oldnodefontid="font"+formdrag.theclickid.value;
   document.all(oldnodefontid).className="clicked";
 }
 if (formdrag.theclickflag.value=="2"){
   theall.className="clicked";
 }
 divf.className = "docked";
 formdrag.thedragbeginflag.value="";
 formdrag.thedragbeginid.value="";
 formdrag.thedragendflag.value="";
 formdrag.thedragendid.value="";
}
}

//================================================
//全部结点拖动经过
function  allmouseover(){
 if (draging){ theall.className="dragend";}
}

//================================================
//全部节点拖动离开
function  allmouseout(){
 if (draging){ theall.className="unclicked";}
}


//================================================
//结点图片节点拖动经过
function  nodemouseover(id,object){
 if ((id!=formdrag.thedragbeginid.value)&&(draging)){
 object.className="imgdragend";}
}

//================================================
//结点图片节点拖动离开
function  nodemouseout(id,object){
 if ((id!=formdrag.thedragbeginid.value)&&(draging)){
 object.className="unclicked";}
}

//================================================
//结点节点拖动开始--此函数不用
function  nodefontmousedown(id,object){
}


//================================================
//结点节点拖动结束
function  nodefontmouseup(id,object){
if (event.button != 1) { return; }
draging = false;
divf.className = "docked";
if (formdrag.thedragbeginid.value!=""){
 if (formdrag.thedragbeginid.value!=id){
  formdrag.thedragendflag.value="2";
  formdrag.thedragendid.value=id;
  //完成拖动提交表单!
  //alert("2");
  formdrag.submit();
  return false;
 }else{
  //alert("拖自己!"+id);
  nodefontid="font"+id;
  document.all(nodefontid).className="unclicked";
  return;
 }
}else{
 nodefontid="font"+id;
 document.all(nodefontid).className="unclicked";
 if (formdrag.thedragbeginid.value!=""){
   olddragfontid="font"+formdrag.thedragbeginid.value;
   document.all(olddragfontid).className="unclicked";
   if (formdrag.thedragbeginflag.value=="1"){
     beginimg="node"+formdrag.thedragbeginid.value+"img";
     document.getElementById(beginimg).className="unclicked";
   }
 }
 if (formdrag.thedragendid.value!=""){
   olddragfontid="font"+formdrag.thedragendid.value;
   document.all(olddragfontid).className="unclicked";
   if (formdrag.thedragendflag.value=="1"){
     endimg="node"+formdrag.thedragbeginid.value+"img";
     document.getElementById(endimg).className="unclicked";
   }
 }
 if (formdrag.theclickid.value!=""){
   oldnodefontid="font"+formdrag.theclickid.value;
   document.all(oldnodefontid).className="clicked";
 }
 divf.className = "docked";
 formdrag.thedragbeginflag.value="";
 formdrag.thedragbeginid.value="";
 formdrag.thedragendflag.value="";
 formdrag.thedragendid.value="";
}
}

//================================================
//结点节点拖动经过
function  nodefontmouseover(id,object){
 if ((id!=formdrag.thedragbeginid.value)&&(draging)){
 object.className="dragend";}
}

//================================================
//结点节点拖动离开
function  nodefontmouseout(id,object){
 if ((id!=formdrag.thedragbeginid.value)&&(draging)){
 object.className="unclicked";}
}

//拖拽中
function ondrag()
{
  if (event.button != 1)
  {
    if (formdrag.thedragbeginid.value!=""){
      olddragfontid="font"+formdrag.thedragbeginid.value;
      document.all(olddragfontid).className="unclicked";
      if (formdrag.thedragbeginflag.value=="1"){
        beginimg="node"+formdrag.thedragbeginid.value+"img";
        document.getElementById(beginimg).className="unclicked";
      }
    }
    if (formdrag.thedragendid.value!=""){
      olddragfontid="font"+formdrag.thedragendid.value;
      document.all(olddragfontid).className="unclicked";
      if (formdrag.thedragendflag.value=="1"){
        endimg="node"+formdrag.thedragbeginid.value+"img";
        document.getElementById(endimg).className="unclicked";
      }
    }
    if (formdrag.theclickid.value!=""){
      oldnodefontid="font"+formdrag.theclickid.value;
      document.all(oldnodefontid).className="clicked";
    }
    divf.className = "docked";
    formdrag.thedragbeginflag.value="";
    formdrag.thedragbeginid.value="";
    formdrag.thedragendflag.value="";
    formdrag.thedragendid.value="";
    draging=false;
    return;
  }

  if(!draging) {  return; }
  //更新位置
  if((event.clientX)>(self.document.body.offsetWidth-40)){
  document.body.scrollLeft=document.body.scrollLeft+10;
  //alert("向右卷");
  }
  if(event.clientX<20){
   document.body.scrollLeft=document.body.scrolleft-10;
  //alert("向左卷");
  }
  if(event.clientY<(20)){
  document.body.scrollTop=document.body.scrollTop-10;
  //alert("向上卷");
  }
  if((event.clientY)>(self.document.body.offsetHeight-40)){
  //self.scroll(document.body.scrollLeft,document.body.scrollTop+10);
  document.body.scrollTop=document.body.scrollTop+10;
  }
  //event.returnValue = false;//让事件不传递
  if (divf.className!="actived"){divf.className="actived";}
  divf.style.pixelLeft = document.body.scrollLeft + event.clientX+2;
  divf.style.pixelTop = document.body.scrollTop + event.clientY+2;
}
//出窗口
function onout()
{


//alert("out");
}

function onup()
{
  if ((event.button == 1)&&(draging)){
    if (formdrag.thedragbeginid.value!=""){
      olddragfontid="font"+formdrag.thedragbeginid.value;
      document.all(olddragfontid).className="unclicked";
      if (formdrag.thedragbeginflag.value=="1"){
        beginimg="node"+formdrag.thedragbeginid.value+"img";
        document.getElementById(beginimg).className="unclicked";
      }
    }
    if (formdrag.thedragendid.value!=""){
      olddragfontid="font"+formdrag.thedragendid.value;
      document.all(olddragfontid).className="unclicked";
      if (formdrag.thedragendflag.value=="1"){
        endimg="node"+formdrag.thedragbeginid.value+"img";
        document.getElementById(endimg).className="unclicked";
      }
    }
    if (formdrag.theclickid.value!=""){
      oldnodefontid="font"+formdrag.theclickid.value;
      document.all(oldnodefontid).className="clicked";
    }
    divf.className = "docked";
    formdrag.thedragbeginflag.value="";
    formdrag.thedragbeginid.value="";
    formdrag.thedragendflag.value="";
    formdrag.thedragendid.value="";
    draging=false;
    return;
  }
}
document.onmousemove = ondrag;
document.onmouseout = onout
document.onmouseup = onup

//-->
</SCRIPT>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td height=5><img src="images/spacer.gif" width="1" height="1"></td></tr>
</table>
<table id="thetree" border="0" cellpadding="0" cellspacing="0">
<tr><td><font style="CURSOR: hand;" id="theall" name="theall" οnclick="javascript:clickall ();" οnmοuseup="javascript:allmouseup ();" οnmοuseοver="javascript:allmouseover ();" οnmοuseοut="javascript:allmouseout ();" <%
if clickid="" then
Response.Write "class='clicked'"
else
Response.Write "class='unclicked'"
end if
%>>◆全部</font>
</td></tr>
</table>
<%
''打开所有父层数据
set rs=Server.CreateObject("ADODB.Recordset")
rs.CursorLocation=3
rs.CursorType=3
rs.Open "select seq,to_char(id) id,to_char(parent_id) parent_id,unit_name,to_char(flag) flag from all_unit where parent_id is null order by flag,seq asc",conn,3,3

''列表主程序段
if rs.RecordCount>0 then%>
<table id="Table1" border="0" cellpadding="0" cellspacing="0">
<%
  do while not rs.eof
    ''打印父层数据信息
   %>
   <tr>
      <%
        if rs.RecordCount = 1 then%>
            <td><img id="line<%=rs("id")%>" src="images/sfm_list/line_L.gif" WIDTH="14" HEIGHT="14"></td>
      <%
        else
          if rs.RecordCount = rs.AbsolutePosition then%>
            <td><img id="Img1" src="images/sfm_list/line_L.gif" WIDTH="14" HEIGHT="14"></td>
      <%
          else
   %>
            <td><img id="Img2" src="images/sfm_list/line_E.gif" WIDTH="14" HEIGHT="14"></td>
      <%
          end if
        end if
     if rs("flag") = "0" then%>
   <td nowrap><img id="node<% =rs("id")%>img" name="node<% =rs("id")%>img" src="images/sfm_list/open.gif" onClick="javascript:nodeclick ('<% =rs("id")%>',this);" onMouseDown="javascript:nodemousedown ('<% =rs("id")%>',this);" onMouseUp="javascript:nodemouseup ('<% =rs("id")%>',this);" onMouseOver="javascript:nodemouseover ('<% =rs("id")%>',this);" onMouseOut="javascript:nodemouseout ('<% =rs("id")%>',this);" WIDTH="16" HEIGHT="14" align=left class="unclicked"><font id="font<%=rs("id")%>" name="font<%=rs("id")%>"  οnclick="javascript:nodefontclick ('<%=rs("id")%>',this);"  οnmοusedοwn="javascript:nodefontmousedown ('<% =rs("id")%>',this);" οnmοuseup="javascript:nodefontmouseup ('<% =rs("id")%>',this);" οnmοuseοver="javascript:nodefontmouseover ('<% =rs("id")%>',this);" οnmοuseοut="javascript:nodefontmouseout ('<% =rs("id")%>',this);" <%
      if rs("id")=clickid then
       Response.Write "class=clicked"
      else
       Response.Write "class=unclicked"
      end if
   %>><%=rs("unit_name")%></font></td>
     <%
     else%>
   <td nowrap><font id="font<%=rs("id")%>"  name="font<%=rs("id")%>" οnclick="javascript:leafclick ('<% =rs("id")%>',this);" οnmοusedοwn="javascript:leafmousedown ('<% =rs("id")%>',this);" οnmοuseup="javascript:leafmouseup ('<% =rs("id")%>',this);" οnmοuseοver="javascript:leafmouseover ('<% =rs("id")%>',this);" οnmοuseοut="javascript:leafmouseout ('<% =rs("id")%>',this);" <%
      if rs("id")=clickid then
       Response.Write "class=clicked"
      else
       Response.Write "class=unclicked"
      end if
   %>>◇<%=rs("unit_name")%></font></td>
     <%     
     end if%>
   </tr>
    <%
    ''子程序调用,子层数据处理
    Call ListSubPower(rs("id"),rs.RecordCount-rs.AbsolutePosition )
    rs.MoveNext
   loop%>
</table>
<%end if
''关闭父层数据集
rs.close
set rs=nothing


''子层数据处理子程序
Sub ListSubPower(id,line)
  ''打开隶属于上层 powerid 的所有子层数据信息
 set rs_sub=Server.CreateObject("ADODB.Recordset")
 rs_sub.CursorLocation = 3
 rs_sub.CursorType=3
   
    rs_sub.Open "select seq,to_char(id) id,to_char(parent_id) parent_id,unit_name,to_char(flag) flag  from all_unit where parent_id=" & id &" order by flag,seq asc",conn
    if rs_sub.RecordCount > 0 then%>
   
    <tr><%
    if line>0 then %>
      <td background="images/sfm_list/line_1.gif"><img src="images/spacer.gif" WIDTH="1" HEIGHT="1"></td>
    <%
    else%>
      <td><img src="images/spacer.gif" WIDTH="1" HEIGHT="1"></td>
    <%
    end if
    %></td>
    <td>
   <div id="tree<%=id%>">
        <table border="0" cellpadding="0" cellspacing="0"><% 
        ''列子层数据
      do while not rs_sub.eof
      %>
          <tr><%
        if rs_sub.RecordCount = 1 then%>
            <td><img id="line<%=rs_sub("id")%>" src="images/sfm_list/line_L.gif" WIDTH="14" HEIGHT="14"></td>
      <%
        else
          if rs_sub.RecordCount = rs_sub.AbsolutePosition then%>
            <td><img id="Img3" src="images/sfm_list/line_L.gif" WIDTH="14" HEIGHT="14"></td>
      <%
          else
   %>
            <td><img id="Img4" src="images/sfm_list/line_E.gif" WIDTH="14" HEIGHT="14"></td>
      <%
          end if
        end if
      if rs_sub("flag")="0" then%>
            <td nowrap><img id="node<%=rs_sub("id")%>img" name="node<% =rs_sub("id")%>img" src="images/sfm_list/open.gif" onClick="javascript:nodeclick ('<% =rs_sub("id")%>',this);" onMouseDown="javascript:nodemousedown ('<% =rs_sub("id")%>',this);" onMouseUp="javascript:nodemouseup ('<% =rs_sub("id")%>',this);" onMouseOver="javascript:nodemouseover ('<% =rs_sub("id")%>',this);" onMouseOut="javascript:nodemouseout ('<% =rs_sub("id")%>',this);" WIDTH="16" HEIGHT="14" align=left class="unclicked"></img><font id="font<% =rs_sub("id")%>" name="font<% =rs_sub("id")%>" οnclick="javascript:nodefontclick ('<%=rs_sub("id")%>',this);" οnmοusedοwn="javascript:nodefontmousedown ('<% =rs_sub("id")%>',this);" οnmοuseup="javascript:nodefontmouseup ('<% =rs_sub("id")%>',this);" οnmοuseοver="javascript:nodefontmouseover ('<% =rs_sub("id")%>',this);" οnmοuseοut="javascript:nodefontmouseout ('<% =rs_sub("id")%>',this);" <%
        if rs_sub("id")=clickid then
         Response.Write "class=clicked"
        else
         Response.Write "class=unclicked"
        end if
            %>><%display rs_sub("unit_name")%></font></td>
      <%
      else%>
            <td nowrap><font id="font<% = rs_sub("id")%>" name="font<% =rs_sub("id")%>" οnclick="javascript:leafclick ('<% =rs_sub("id")%>',this);" οnmοusedοwn="javascript:leafmousedown ('<% =rs_sub("id")%>',this);" οnmοuseup="javascript:leafmouseup ('<% =rs_sub("id")%>',this);" οnmοuseοver="javascript:leafmouseover ('<% =rs_sub("id")%>',this);" οnmοuseοut="javascript:leafmouseout ('<% =rs_sub("id")%>',this);" <%
        if rs_sub("id")=clickid then
         Response.Write "class=clicked"
        else
         Response.Write "class=unclicked"
        end if
            %>>◇<%display rs_sub("unit_name")%></font></td>
      <%     
      end if
      ''子程序调用,子层数据处理
      Call ListSubPower(rs_sub("id"),rs_sub.RecordCount - rs_sub.AbsolutePosition)
      rs_sub.MoveNext
      loop%>
          </tr>
        </table>
      </div>
    </td></tr>   
    <%
    end if
    ''关闭子层数据集
    rs_sub.close
    set rs_sub=nothing   
End Sub
%>

</body>
</html>
<!--#include file="include/close_cn.asp"-->

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值