Response.Redirect(url)
End Sub
End Class
8.构件模糊查询页面
说明:以下代码为按功能模糊查询的页面vb代码,按作者,类别,项目,名称模糊查询页面的查询代码与之相仿。
页面1
Imports System.Data
Imports System.Data.SqlClient
Public Class ComponentFunctionSearch
Inherits System.Web.UI.Page
Protected WithEvents imabtnSearch As System.Web.UI.WebControls.ImageButton
Protected WithEvents ddroplChoise As System.Web.UI.WebControls.DropDownList
Protected WithEvents mydatalist As System.Web.UI.WebControls.DataList
Protected WithEvents lblKeyshow As System.Web.UI.WebControls.Label
Protected WithEvents lblchoise As System.Web.UI.WebControls.Label
Protected WithEvents txtKey As System.Web.UI.WebControls.TextBox
#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 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 url As String
Dim mycomm As SqlCommand
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”)
lblKeyshow.Text=”关键字:”+Key
lblchoise.Text=”查询选项:”+choise
mycomm=New SqlCommand(”select count(ComponentFunctionName) from view_Function where ComponentFunctionName like’%”+Key+”%’”,MyConnection)
If(CType(mycomm.ExecuteScalar(),Integer)=0)Then
url=”NoData.aspx?txtKey.text=”+Key+”&;choise=”+choise
Response.Redirect(url)
End If
MyCommand=New SqlDataAdapter(”select ComponentFunctionName,ComponentName,ComponentIntroduction,FunctionDeion from view_Function where ComponentFunctionName like’%”+Key+”%’”,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
页面2
Imports System.Data
Imports System.Data.SqlClient
Public Class MoreVerBasicInf
Inherits System.Web.UI.Page
Protected WithEvents imabtnSearch As System.Web.UI.WebControls.ImageButton
Protected WithEvents ddroplChoise As System.Web.UI.WebControls.DropDownList
Protected WithEvents txtKey As System.Web.UI.WebControls.TextBox
Protected WithEvents myDataList As System.Web.UI.WebControls.DataList
#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 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
Dim ID As String
MyConnection=New SqlConnection(”server=(local);database=Componentsystem;trusted_connection=yes”)
MyConnection.Open()
Key=Request.QueryString.Item(”txtkey.text”)
choise=Request.QueryString.Item(”choise”)
ID=Request.QueryString(”VersionID”)
MyCommand=New SqlDataAdapter(”select*from View_DownLoad where VersionID=’”
+ID+”’”,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