Abre en asp

Contenu du snippet

ce code permet a& l'aide de 2 requet SQL (1 de propagation et 1 d'affichage) de realiser un abre.

Source / Exemple :


<%
'vertical space between cell
Vspace = 40
'horizontal space between cell
Hspace = 10
'width of cell
width = 160
'height of cell
height =80
Set Ma_conn = Server.CreateObject("ADODB.Connection")
DSN_base = "DSN=rh;"
Ma_conn.open DSN_base
Dim LastY
Dim FirstChild() : Redim FirstChild(0)
Dim LastChild() : Redim LastChild(0)
Function Draw(Clef, X, Y)
	If Ubound(FirstChild) < Y Then
		Redim Preserve FirstChild(Y)
		Redim Preserve LastChild(Y)
		Redim Preserve From(Y)
		FirstChild(Y) = Hspace
		LastChild(Y) = 0
	ElseIf Y = LastY-1 Then
		If FirstChild(Y) = 0 Then
			FirstChild(Y) = FirstChild(LastY)+(LastChild(LastY)-(width+Hspace))/2
			FirstChild(Y) = Cint(Right(Cstr(FirstChild(Y)),Len(Cstr(FirstChild(Y))) - InStrRev(Cstr(FirstChild(Y)),".")))
			LastChild(Y) = 0
		Else
			LastChild(Y) = FirstChild(LastY)+(LastChild(LastY)-(width+Hspace))/2-FirstChild(Y)
			LastChild(Y) = Cint(Right(Cstr(LastChild(Y)),Len(LastChild(Y)) - InStrRev(Cstr(LastChild(Y)),".")))
		End If
		FirstChild(LastY)=FirstChild(LastY)+LastChild(LastY)+Hspace
		LastChild(LastY)=0
	End If
	PosX = FirstChild(Y)+Cint(Right(Cstr(width/2),Len(width/2) - InStrRev(Cstr(width/2),".")))
	PosY = Y*(Vspace+height)-height-Vspace/2
	ma_div = "<div style='position:absolute;top:" & PosY & ";left:" & PosX & ";width:" & LastChild(Y) & ";height:" & height & ";color:black;font-size:11px;text-align=center'><hr align='center' noshade width='100%' size='3'></div>"
	response.write ma_div
	PosX = FirstChild(Y) + LastChild(Y)
	PosY = Y*(Vspace+height)-height
	Set result2 = Ma_conn.Execute(REQUETTE SQL POUR l'AFFICHAGE DES DONNEES)
	ma_div = "<div style='position:absolute;top:" & PosY & ";left:" & PosX & ";width:" & width & ";height:" & height & ";color:black;background-color:white;font-size:11px;text-align=center'>AFFICHAGES DES DONNEES</div>"
	response.write ma_div
	result2.close
	Set result2 = nothing
	LastChild(Y)=LastChild(Y)+Hspace+width
	LastY = Y
End Function
Function DrawTree(racine, X, Y)
	tmp = 1
	Set result1 = Ma_conn.Execute("REQUETTE SQL POU LA PROPAGATION DE L'ARBRE")
	While Not result1.EOF
		first = DrawTree(result1("ClefDePropagation"), tmp, y + 1)
		tmp = tmp + 1
		result1.MoveNext
	Wend
	Draw chef, X, Y
	result1.close
	Set result1 = nothing
	father = chef
End Function
%>
appel : DrawTree MaClef, 1, 1
exemple de requete
requete de propagation : SELECT Clef2 FROM Aebre WHERE Clef1 ="& racine
exemple de rquete d'affichage : SELECT nom, prenom, login FROM personne WHERE id_pers = " & Clef

A voir également

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.