📄 quebook.aspx.vb
字号:
Imports System.Data.SqlClient
Public Class quebook
Inherits System.Web.UI.Page
#Region " Web 窗体设计器生成的代码 "
'该调用是 Web 窗体设计器所必需的。
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents Label2 As System.Web.UI.WebControls.Label
Protected WithEvents Label3 As System.Web.UI.WebControls.Label
Protected WithEvents Label4 As System.Web.UI.WebControls.Label
Protected WithEvents Label5 As System.Web.UI.WebControls.Label
Protected WithEvents Label6 As System.Web.UI.WebControls.Label
Protected WithEvents Label7 As System.Web.UI.WebControls.Label
Protected WithEvents Label8 As System.Web.UI.WebControls.Label
Protected WithEvents Form1 As System.Web.UI.HtmlControls.HtmlForm
Protected WithEvents Label9 As System.Web.UI.WebControls.Label
Protected WithEvents radAllBook As System.Web.UI.WebControls.RadioButton
Protected WithEvents radInlibBook As System.Web.UI.WebControls.RadioButton
Protected WithEvents txtBook_code As System.Web.UI.WebControls.TextBox
Protected WithEvents txtBook_name As System.Web.UI.WebControls.TextBox
Protected WithEvents txtBook_pub As System.Web.UI.WebControls.TextBox
Protected WithEvents txtBook_isbn As System.Web.UI.WebControls.TextBox
Protected WithEvents txtBook_author As System.Web.UI.WebControls.TextBox
Protected WithEvents dtpBook_pubdate As System.Web.UI.WebControls.TextBox
Protected WithEvents dbg As System.Web.UI.WebControls.DataGrid
Protected WithEvents btnQuery As System.Web.UI.WebControls.Button
Protected WithEvents cboBook_sort As System.Web.UI.WebControls.DropDownList
Protected WithEvents LabelInfo As System.Web.UI.WebControls.Label
Protected WithEvents RegularExpressionValidator1 As System.Web.UI.WebControls.RegularExpressionValidator
'注意: 以下占位符声明是 Web 窗体设计器所必需的。
'不要删除或移动它。
Private designerPlaceholderDeclaration As System.Object
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 IsPostBack Then
BindComboBox1()
End If
'Me.DataBind()
End Sub
Function BindComboBox1()
Dim cnLib2004 As SqlConnection
Dim cmdbooksort As SqlCommand
Dim drBooksort As SqlDataReader
cnLib2004 = New SqlConnection(ConfigurationSettings.AppSettings("cncstr"))
cmdbooksort = New SqlCommand
With cmdbooksort
.CommandType = CommandType.StoredProcedure
.Connection = cnLib2004
.CommandText = "selectBookSort"
End With
Try
cnLib2004.Open()
drBooksort = cmdbooksort.ExecuteReader
Me.cboBook_sort.DataSource = drBooksort
Me.cboBook_sort.DataTextField = "Book_sort"
Me.cboBook_sort.DataBind()
Me.cboBook_sort.Items.Add("全部类别")
Me.cboBook_sort.SelectedIndex = Me.cboBook_sort.Items.Count - 1
Catch ex As Exception
Response.Redirect("error.aspx?errmsg=" + ex.Message.Replace(Chr(13), "<BR>"))
Finally
cnLib2004.Close()
End Try
End Function
Function search()
Dim cn As New SqlClient.SqlConnection(ConfigurationSettings.AppSettings("cncstr"))
Dim cmd As New SqlCommand
Dim dr As SqlDataReader
With cmd
If Me.radAllBook.Checked = True Then
.CommandText = "searchBook"
Else
.CommandText = "searchBookInlib"
End If
.CommandType = CommandType.StoredProcedure
.Connection = cn
End With
Dim mBook_code As New SqlParameter("@Book_code", SqlDbType.NVarChar, 50) '1
Dim mBook_name As New SqlParameter("@Book_name", SqlDbType.NVarChar, 50) '2
Dim mBook_pub As New SqlParameter("@Book_pub", SqlDbType.NVarChar, 50) '3
Dim mBook_isbn As New SqlParameter("@Book_isbn", SqlDbType.NVarChar, 50) '4
Dim mBook_pubdate As New SqlParameter("@Book_pubdate", SqlDbType.SmallDateTime, 4) '5
Dim mBook_author As New SqlParameter("@Book_author", SqlDbType.NVarChar, 50) '6
Dim mBook_sort As New SqlParameter("@Book_sort", SqlDbType.NVarChar, 50) '11
With cmd.Parameters
.Add(mBook_code)
.Add(mBook_name)
.Add(mBook_pub)
.Add(mBook_isbn)
.Add(mBook_pubdate)
.Add(mBook_author)
.Add(mBook_sort)
End With
'赋值
mBook_code.Value = Me.txtBook_code.Text.Trim '1
mBook_name.Value = Me.txtBook_name.Text.Trim '2
mBook_pub.Value = Me.txtBook_pub.Text.Trim '3
mBook_isbn.Value = Me.txtBook_isbn.Text.Trim '4
If Me.dtpBook_pubdate.Text.Trim <> "" Then
mBook_pubdate.Value = CType(Me.dtpBook_pubdate.Text.Trim, Date) '5
Else
mBook_pubdate.Value = CType("1990-01-01", Date)
End If
mBook_author.Value = Me.txtBook_author.Text.Trim '6
If Me.cboBook_sort.SelectedIndex <> Me.cboBook_sort.Items.Count - 1 Then
mBook_sort.Value = Me.cboBook_sort.SelectedValue '11
Else
mBook_sort.Value = ""
End If
'Response.Write(mBook_sort.Value)
Try
cn.Open()
dr = cmd.ExecuteReader
Me.dbg.DataSource = dr
Me.dbg.DataBind()
Me.LabelInfo.Text = "共检索到" + Me.dbg.Items.Count.ToString + "条记录"
' Me.Label8.Text = "共检索到" + ds.Tables(0).Rows.Count.ToString + "条记录"
Catch ex As Exception
Response.Redirect("error.aspx?errmsg=" + ex.Message.Replace(Chr(13), "<BR>"))
Finally
cn.Close()
If Not cn Is Nothing Then
cn.Dispose()
End If
End Try
End Function
Private Sub btnQuery_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnQuery.Click
Me.search()
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -