求解释代码,注释 谢谢
Namespace LibraryPartial Class AdvSearch
Inherits System.Web.UI.Page
#Region " Web 窗体设计器生成的代码 "
'该调用是 Web 窗体设计器所必需的。
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
'注意: 以下占位符声明是 Web 窗体设计器所必需的。
'不要删除或移动它。
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
Dim obj As BookController = New BookController
BookingBtn.Visible = False
If Not Session("UserID") Is Nothing Then
If obj.AllowBooking(Session("UserID")) = True Then
BookingBtn.Visible = True
End If
End If
End If
End Sub
Private Sub BindGrid()
If Not Session("sqlstr") Is Nothing Then
Dim sqlstr As String = CType(Session("sqlstr"), String)
Dim obj As DBController = New DBController
obj.BindDBGrd(sqlstr, ResultGrid)
Session("sqlstr") = sqlstr
End If
End Sub
Private Sub SearchBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SearchBtn.Click
Dim sqlstr As String = "select * from BookInfo where 1=1 "
If txtBookName.Text.ToString.Trim <> "" Then
sqlstr += " and BookName like '%" + txtBookName.Text.ToString.Trim + "%' "
End If
If txtPubName.Text.ToString.Trim <> "" Then
sqlstr += " and PubName like '%" + txtPubName.Text.ToString.Trim + "%' "
End If
If txtBookAuthor.Text.ToString.Trim <> "" Then
sqlstr += " and BookAuthor like '%" + txtBookAuthor.Text.ToString.Trim + "%' "
End If
If txtISBN.Text.ToString.Trim <> "" Then
sqlstr += " and ISBN like '%" + txtISBN.Text.ToString.Trim + "%' "
End If
If txtSeries.Text.ToString.Trim <> "" Then
sqlstr += " and Series like '%" + txtSeries.Text.ToString.Trim + "%' "
End If
If txtSearchNO.Text.ToString.Trim <> "" Then
sqlstr += " and SearchNO like '%" + txtSearchNO.Text.ToString.Trim + "%' "
End If
If txtSubject.Text.ToString.Trim <> "" Then
sqlstr += " and Subject like '%" + txtSubject.Text.ToString.Trim + "%' "
End If
If txtPubDate.Text.ToString.Trim <> "" Then
sqlstr += " and PubDate >='" + txtPubDate.Text.ToString.Trim + "' "
End If
If LanguageList.SelectedValue <> "所有语种" Then
sqlstr += " and Language = '" + LanguageList.SelectedValue + "' "
End If
If StyleList.SelectedValue <> "所有类型" Then
sqlstr += " and BookStyle = '" + StyleList.SelectedValue + "' "
End If
Session("sqlstr") = sqlstr
BindGrid()
End Sub
Private Sub ResetBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ResetBtn.Click
txtBookName.Text = ""
txtPubName.Text = ""
txtBookAuthor.Text = ""
txtISBN.Text = ""
txtSeries.Text = ""
txtSearchNO.Text = ""
txtSubject.Text = ""
txtPubDate.Text = ""
LanguageList.SelectedIndex = 0
StyleList.SelectedIndex = 0
End Sub
Private Sub ResultGrid_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles ResultGrid.PageIndexChanged
ResultGrid.CurrentPageIndex = e.NewPageIndex
BindGrid()
End Sub
Private Sub ResultGrid_SortCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridSortCommandEventArgs) Handles ResultGrid.SortCommand
Dim sqlstr As String
If viewstate("sortexp") Is Nothing Then
viewstate("sortexp") = e.SortExpression.ToString
ElseIf viewstate("sortexp") = e.SortExpression.ToString Then
viewstate("sortexp") += " desc"
Else
viewstate("sortexp") = e.SortExpression.ToString
End If
If Not Session("sqlstr") Is Nothing Then
sqlstr = CType(Session("sqlstr"), String)
Dim obj As DBController = New DBController
obj.BindDBGrd(sqlstr, ResultGrid, Viewstate("sortexp"))
End If
End Sub
Private Sub ViewBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ViewBtn.Click
Dim i As Integer
Dim str As String = ""
Dim myCheckBox As CheckBox
For i = 0 To ResultGrid.Items.Count - 1
myCheckBox = CType(ResultGrid.Items(i).FindControl("ChckBox"), CheckBox)
If myCheckBox.Checked = True Then
If str <> "" Then
str += "_" + ResultGrid.Items(i).Cells(6).Text
Else
str += ResultGrid.Items(i).Cells(6).Text
End If
End If
Next
If str <> "" Then
Response.Redirect("ViewList.aspx?IDList=" + str)
End If
End Sub
Public Function EditState(ByVal state As Integer) As String
Select Case state
Case 1 : Return "流通"
Case 2 : Return "收藏"
Case 3 : Return "丢失"
End Select
End Function
Private Sub BookingBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BookingBtn.Click
Dim i As Integer
Dim userID As String = Session("UserID")
Dim str As String = ""
Dim myCheckBox As CheckBox
For i = 0 To ResultGrid.Items.Count - 1
myCheckBox = CType(ResultGrid.Items(i).FindControl("ChckBox"), CheckBox)
If myCheckBox.Checked = True Then
str += " insert into BookingInfo (UserID,BookID,BookingState) values('" + userID + "'," + ResultGrid.Items(i).Cells(6).Text + ",0)"
End If
Next
Dim obj As DBController = New DBController
obj.ExecNonSql(str)
Response.Write("<script>javascript:alert('预约成功!!!')</script>")
End Sub
End Class
End Namespace
--------------------编程问答-------------------- 觉得没设么课解释的,都是基本组件事件SearchBtn_Click中是组合sql语句,其他的grid相关的,看帮助也就清楚了
补充:.NET技术 , ASP.NET