Program | Connection Database <% ' *****************************
' ******* connection Database tree Graph generator ********
'*****************************
' Suppose you have established the SQL Server database Unittree and created tables in the library:
' Units (ID Unit ordinal integer unique, name unit name string, upid parent unit ordinal number integer)
' Note: Upid=0 indicates that the unit is a root node unit;
' Enter some data such as: (1,aa,0) (2,aabb,1) (3,aacc,1) (4,aabb11,2)
' For the following program test.
%>
<% ' Establish a database connection
Set Conn=server.createobject ("Adodb.connection")
Conn.Open "Provider=sqloledb;data source=yoursrcname;user id=sa;password=;d atabase=unittree"
%>
<% ' Sub process: Spanning Tree Touzi node data
Sub TreeNode (Code)
sqlunit= "Select Id,name" &_
"From Units" &_
"Where upid=" &Code& "&_
"ORDER by ID"
Set Rsunit=conn. Execute (Sqlunit)
Do as not rsunit.eof
Response.Write ("Node" &rsunit ("ID") & "=appendchild" ("&" Node "&Code&", Foldernode ("" &rsunit ( "Name") & "', '" &rsunit ("ID") & "', 0)" &CHR (10))
Call TreeNode (Rsunit ("ID"))
Rsunit.movenext
Loop
End Sub
%>
<HTML>
<HEAD>
<title> Drill Analysis </title>
<script language= "JavaScript" >
/****************************** Generating tree Graph Data *********************************/
function Generatetree ()
{
Generating Tree Graph Data
-----VBScript-----
<%
' Display units
sqlunit0= "Select Id,name" &_
"From Units" &_
"Where Upid=0" &_
"ORDER by ID"
Set Rsunit0=conn. Execute (SQLUNIT0)
Root node Folderstree.
Response.Write ("Folderstree=foldernode" &rsunit0 ("Name") & "', '" &rsunit0 ("ID") & "', 1" &CHR ( 10))
Response.Write ("Node" &rsunit0 ("ID") & "=folderstree" &CHR (10))
Call TreeNode (RsUnit0 ("ID"))//child node data
%>
}
/**************************** Spanning tree graph end *******************************/
</Script>
<script language= "JavaScript" >
/************************ Correlation function *********************************/
Generate a Node
function Foldernode (Name,value,flagopen)
{
var Arrayaux
Arrayaux = new Array
ARRAYAUX[0] = flagopen//node off 0 or open 1
ARRAYAUX[1] = value//
ARRAYAUX[2] = name//Name
Return Arrayaux
}
In Arrayaux[3]. [n] Add its children
function appendchild (parent, child)
{
Parent[parent.length] = Child
return child
}
Draw a knot.
Parameter foldersnode: Knot point
Doc:d Ocument Object
Level: Levels of nodes
Lastnode: Whether the end of the node
Leftside: Pictures
function Redrawnode (Foldersnode, doc, Level, Lastnode, leftside)
{
Filename= "content.asp"//Set hyperlink file, can be rewritten according to your situation ......
if (level>0)//is not a root node
{
if (lastnode)//Last node
{
if (Foldersnode.length > 3)//have children
{
if (foldersnode[0])//And Open
{
Doc.write ("<a href= ' Javascript:top.openBranch (\" + foldersnode[2] + "\") ' > ')
Doc.write ("</a>")
}
Else
{//But off
Doc.write ("<a href= ' Javascript:top.openBranch (\" + foldersnode[2] + "\") ' > ')
Doc.write ("</a>")
}
}
else//No children
Doc.write ("
Leftside = leftside + "
}
else//non-final node
{
if (Foldersnode.length > 3)//have children
{
if (foldersnode[0])//And Open
{
Doc.write ("<a href= ' Javascript:top.openBranch (\" + foldersnode[2] + "\") ' > ')
Doc.write ("</a>")
}
Else
{//But off
Doc.write ("<a href= ' Javascript:top.openBranch (\" + foldersnode[2] + "\") ' > ')
Doc.write ("</a>")
}
}
else//No children
Doc.write ("
Leftside = leftside + "}
/****** hand-shaped icons and hyperlinks **********/
Doc.write ("<a href=" "+filename+" id= "+foldersnode[1]+" &name= "+foldersnode[2]+" "target=folderframe>" </a> ")
/******** Name and Hyperlink ********/
Doc.write ("<td valign=middle align=left nowrap>")
Doc.write ("<a href=" "+filename+" id= "+foldersnode[1]+" &name= "+foldersnode[2]+" "target=folderframe>" <font size=2 face= ' song body ' > ' +foldersnode[2]+ ' </font></a> ')
The above hyperlinks provide the QueryString value of Id,name ..... ..... ...... ........ ........ ....... ...
}
else//root Node
{
/****** hand-shaped icons and hyperlinks **********/
Doc.write ("<a href=" "+filename+" id= "+foldersnode[1]+" &name= "+foldersnode[2]+" "target=folderframe>" </a> ")
/******** Name and Hyperlink ********/
Doc.write ("<td valign=middle align=left nowrap>")
Doc.write ("<a href=" "+filename+" id= "+foldersnode[1]+" &name= "+foldersnode[2]+" "target=folderframe>" <font size=2 face= ' song body ' > ' +foldersnode[2]+ ' </font></a> ')
}
Doc.write ("</table>")
///////////////////////////////////////////////////////
if (Foldersnode.length > 3 && foldersnode[0])//have children and open then recursive display node
{
Level=level+1
for (i=3; i<foldersnode.length;i++)
if (i==foldersnode.length-1)
Redrawnode (Foldersnode[i], doc, level, 1, leftside)
Else
Redrawnode (Foldersnode[i], doc, level, 0, Leftside)
}
}
When the user clicks the layered +/+ number response, called by Openbranch
function Clickonfolderrec (Foldersnode, FolderName)
{
var i=0
if (foldersnode[2] = = folderName)
{
if (foldersnode[0])//If it is turned on, it is closed
Foldersnode[0] = 0
Else
Foldersnode[0] = 1
}
Else
{
for (i=3; i< foldersnode.length; i++)
Clickonfolderrec (Foldersnode[i], folderName)
}
}
Turn on or off the node (response when the user clicks on the layered + +/+ number)
function Openbranch (branchname)
{
Show Tree graph
function Redrawtree ()
{
var doc = Top.treeFrame.window.document
Record current scroll bar position
POSX = Doc.body.scrollLeft
Posy = Doc.body.scrollTop
Functions that respond when a Web page is loaded
function Initializetree ()
{
Generatetree ()
Redrawtree ()
}
/*********************** Correlation function End *************************/
</Script>
</HEAD>
</HTML>
<%
' The above procedure is tested and passed under win2000server+iis5.0+sqlserver2000.
'=========================================================
' ======= Author: Xiachuntao e-mail:bluesky_521@yeah.net = =
'=========================================================
%>
<!--
Contents of pleft.htm File:
<body>
<p Align=center><font size=2> is generating a tree graph, please wait ...</font>
</body>
Contents of pright.htm File:
<body>
<p Align=center><font size=2> Welcome to visit! </font>
</body>
content.asp files are written according to your needs.
The effect of program execution is almost the same as for Windows Resource Manager.
Closedfolder.gif is a 22*22 small figure, the rest of the picture is a small map of 16*22;
These images can be captured by grasping the image in the explorer.
-->
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.