Protected WithEvents imabtnSearch As System.Web.UI.WebControls.ImageButton
Protected WithEvents mydatalist As System.Web.UI.WebControls.DataList
#Region”Web 窗体设计器生成的代码”
’该调用是Web 窗体设计器所必需的。
Private Sub InitializeComponent()End Sub
Private Sub Page_(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles MyBase.Init
’CODEGEN:此方法调用是Web窗体设计器所必需的
’不要使用代码编辑器修改它。
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles MyBase.Load
If Not(Page.IsPostBack)Then
Dim Ds As DataSet
Dim Key As String
Dim choise As String
Dim MyConnection As SqlConnection
Dim MyCommand As SqlDataAdapter
MyConnection=New SqlConnection(”server=(local);database=Componentsystem;trusted_connection=yes”)
MyConnection.Open()
Key=Request.QueryString.Item(”txtkey.text”)
choise=Request.QueryString.Item(”choise”)
MyCommand=New SqlDataAdapter(”select ComponentFunctionName,FunctionDeion from tb_ComponentFunction”,MyConnection)
Ds=New DataSet()
MyCommand.Fill(Ds,”goujian”)
mydatalist.DataSource=Ds.Tables(”goujian”).DefaultView
mydatalist.DataBind()
End If
End Sub
Private Sub imabtnSearch_Click(ByVal sender As System.Object,ByVal e AsSystem.Web.UI. ImageClickEventArgs)Handles imabtnSearch.Click
Dim val As String
Dim Choise As String
Dim url As String
Choise=ddroplChoise.SelectedItem.Text
If(txtKey.Text=””)Then
url=”error.aspx?Choise=”+Choise
Response.Redirect(url)
Else
If(Choise=”构件名称”)Then
url=”Componentnamesearch.aspx?txtKey.text=”+Trim(txtKey.Text)+”
&;choise=”+Choise
Response.Redirect(url)
End If
If(Choise=”构件功能”)Then
url=”ComponentFunctionSearch.aspx?txtKey.text=”+Trim(txtKey.Text)+”
&;choise=”+Choise
Response.Redirect(url)
End If
If(Choise=”构件项目”)Then
url=”ProjectSearch.aspx?txtKey.text=”+Trim(txtKey.Text)+”&;choise=”
+Choise
Response.Redirect(url)
End If
If(Choise=”构件作者”)Then
url=”CreatorSearch.aspx?txtKey.text=”+Trim(txtKey.Text)+”&;choise=”+Choise
Response.Redirect(url)
End If
If(Choise=”构件类别”)Then
url=”CategorySearch.aspx?txtKey.text=”+Trim(txtKey.Text)+”&;choise=”
+Choise
Response.Redirect(url)
End If
End If
End Sub
End Class
10.类查询页面
说明:以下代码为类查询页面VB代码。
页面1(TreeView)
Imports System.Data
Imports System.Data.SqlClient
Imports Microsoft.Web.UI.WebControls
Public Class treeview
Inherits System.Web.UI.Page
Protected WithEvents mytreeview As Microsoft.Web.UI.WebControls.TreeView#Region”Web窗体设计器生成的代码”
’该调用是Web窗体设计器所必需的。
Private Sub InitializeComponent()End Sub
P rivate Sub Page_(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles MyBase.Init
’CODEGEN:此方法调用是Web窗体设计器所必需的
’不要使用代码编辑器修改它。
InitializeComponent()
End Sub
#End Region
Private versionID As String
Private ClassID 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 wherecomponentFunctionName=’”+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)
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)