PageIndexChanged
startIndex=e.NewPageIndex*Mydatagrid.PageSize
Mydatagrid.CurrentPageIndex=e.NewPageIndex
MYbind(lblClassID.Text)
End Sub
End Class
页面2
Imports System.Data
Imports System.Data.SqlClient
Imports Microsoft.Web.UI.WebControls
Public Class wfrmTreeClass
Inherits System.Web.UI.Page
Protected WithEvents MyTreeView As Microsoft.Web.UI.WebControls.TreeView#Region”Web窗体设计器生成的代码”
’该调用是Web窗体设计器所必需的。
Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles MyBase.Init
’CODEGEN:此方法调用是Web窗体设计器所必需的
’不要使用代码编辑器修改它。
InitializeComponent()
End Sub
#End Region
Private BaseID As String
Private ClassID As String
Private VersionID As String
Private BaseName As String
Protected WithEvents lblClassName As System.Web.UI.WebControls.Label
Protected WithEvents Label2 As System.Web.UI.WebControls.Label
Protected WithEvents lblClassID As System.Web.UI.WebControls.Label
Protected WithEvents Label5 As System.Web.UI.WebControls.Label
Protected WithEvents lblClass As System.Web.UI.WebControls.Label
Protected WithEvents btnReturn As System.Web.UI.WebControls.Button
Private FormSender As String
Private Sub Tree()
Dim MyConnection As SqlConnection
MyConnection=New SqlConnection (”server=(local);database=ComponentSystem;
Trusted_Connection=yes”)
MyConnection.Open()
Dim dsTree As New DataSet()
Dim strSQL As String
strSQL=”Select ComponentFunctionName from tb_ComponentFunction”
Dim count As String
Dim sqlcommand As New SqlCommand(strSQL,MyConnection)
Dim sqladapt As New SqlDataAdapter(strSQL,MyConnection)
sqladapt.Fill(dsTree,”Function”)
’得到功能记录数
count=”select Count(ComponentFunctionID)from tb_ComponentFunction”
sqlcommand=New SqlCommand(count,MyConnection)
Dim i As Integer
i=CType(sqlcommand.ExecuteScalar(),Integer)
MyTreeView.Nodes.Clear()
’Function
Dim num As Integer
For num=0 To i—1
Dim col As DataColumn
Dim row As DataRow
Dim item As New TreeNode()
col=dsTree.Tables(”Function”).Columns(0)
row=dsTree.Tables(”Function”).Rows(num)
item.Text=row.Item(0)
Dim j As Integer
strSQL=”select ComponentName from view_Function where componentFunctionName=’”
+item.Text+”’”
sqladapt=New SqlDataAdapter(strSQL,MyConnection)
sqladapt.Fill(dsTree,item.Text)
count=”select Count(ComponentName)from view_Function where componentFunctionName=’”+item.Text+”’”
sqlcommand=New SqlCommand(count,MyConnection)
j=CType(sqlcommand.ExecuteScalar(),Integer)
Dim num1 As Integer
For num1=0 To j—1
Dim col1 As DataColumn
Dim row1 As DataRow
Dim item1 As New TreeNode()
col1=dsTree.Tables(item.Text).Columns(0)
row1=dsTree.Tables(item.Text).Rows(num1)
item1.Text=row1.Item(0)
’version
Dim k As Integer
strSQL=”select ComponentVersion,VersionID from view_Version where ComponentName=’”+item1.Text+”’”
sqladapt=New SqlDataAdapter(strSQL,MyConnection)
sqladapt.Fill(dsTree,item1.Text)
count=”select Count(Componentversion)from view_Version where ComponentName=’”+item1.Text+”’”
sqlcommand=New SqlCommand(count,MyConnection)
k=CType(sqlcommand.ExecuteScalar(),Integer)
Dim num2 As Integer
For num2=0 To k—1
Dim col2 As DataColumn
Dim row2 As DataRow
Dim item2 As New TreeNode()
col2=dsTree.Tables(item1.Text).Columns(0)
row2=dsTree.Tables(item1.Text).Rows(num2)
item2.Text=row2.Item(0)
versionID=dsTree.Tables(item1.Text).Rows(num2).Item(1)
’Class
Dim h As Integer
strSQL=”select CLassName,ClassId from view_Class where VersionID=’”
+versionID+”’”
sqladapt=New SqlDataAdapter(strSQL,MyConnection)
sqladapt.Fill(dsTree,versionID)
count=”select Count(ClassName)from view_Class where VersionID=’”+versionID+”’”
sqlcommand=New SqlCommand(count,MyConnection)
h=CType(sqlcommand.ExecuteScalar(),Integer)
Dim num3 As Integer
For num3=0 To h— 1
Dim col3 As DataColumn
Dim row3 As DataRow
Dim item3 As New TreeNode()
col3=dsTree.Tables(versionID).Columns(0)
row3=dsTree.Tables(versionID).Rows(num3)
BaseID=dsTree.Tables(VersionID).Rows(num3).Item(1)
item3.Text=row3.Item(0)
BaseName=row3.Item(0)
If(FormSender=”Base”)Then
item3.NavigateUrl=”wfrmBase.aspx?BaseID=”+BaseID+”&;CLassID=”
+ClassID+”&;BaseName=”+BaseName
item3.Target=”_self”
ElseIf(FormSender=”Super”)Then
item3.NavigateUrl=”wfrmSuper.aspx?BaseID=”+BaseID+”&;CLassID=”+ClassID+”&;BaseName=”+BaseName
item3.Target=”_self”
End If
item2.Nodes.Add(item3)
Next
item1.Nodes.Add(item2)
Next
item.Nodes.Add(item1)
Next
MyTreeView.Nodes.Add(item)
Next
End Sub
Private Sub Page_Load(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles MyBase.Load
Dim MyConnection As SqlConnection
MyConnection=New SqlConnection (”server=(local);database=ComponentSystem;
Trusted_Connection=yes”)
MyConnection.Open()
Dim StrSQL As String
ClassID=Request.QueryString(”ClassID”)
FormSender=Request.QueryString(”FormSender”)
StrSQL=”Select ClassName from tb_ClassInformation where ClassID=’”+ClassID+”’”
Dim myComm As SqlCommand=New SqlCommand(StrSQL,MyConnection)
lblClassName.Text=CType(myComm.ExecuteScalar(),String)
lblClassID.Text=ClassID
If(FormSender=”Base”)Then
lblClass.Text=”添加基类”
ElseIf(FormSender=”Super”)Then
lblClass.Text=”添加父类”
End If
Tree()
’在此处放置初始化页的用户代码
End Sub
Private Sub btnReturn_Click(ByVal sender As System.Object,ByVal e AsSystem.EventArgs)Handles btnReturn.Click
Dim url As String
If(FormSender=”Base”)Then
url=”wfrmBase.aspx?BaseId=”+”&;CLassID=”+ClassID
ElseIf(FormSender=”Super”)Then
url=”wfrmSuper.aspx?SuperID=”+”&;CLassID=”+ClassID
End If