📄 frm_todayissueview.vb
字号:
Imports System.Data.OleDb
Imports System.DateTime
Imports System.Math
Public Class frm_TodayIssueView
Inherits System.Windows.Forms.Form
Dim MyConnection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "\Library.mdb")
Dim MyCommand As OleDbCommand
Dim MyReader As OleDbDataReader
Dim dbset As New DataSet
Dim dataA As New OleDbDataAdapter
Dim currentDate As Date
Dim SQLString As String
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
Friend WithEvents DataGrid1 As System.Windows.Forms.DataGrid
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents TxtIssueNo As System.Windows.Forms.TextBox
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents TxtBookName As System.Windows.Forms.TextBox
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents TxtReaderName As System.Windows.Forms.TextBox
Friend WithEvents BtnOK As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frm_TodayIssueView))
Me.GroupBox1 = New System.Windows.Forms.GroupBox
Me.DataGrid1 = New System.Windows.Forms.DataGrid
Me.Label1 = New System.Windows.Forms.Label
Me.TxtIssueNo = New System.Windows.Forms.TextBox
Me.Label2 = New System.Windows.Forms.Label
Me.TxtBookName = New System.Windows.Forms.TextBox
Me.Label3 = New System.Windows.Forms.Label
Me.TxtReaderName = New System.Windows.Forms.TextBox
Me.BtnOK = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.GroupBox1.SuspendLayout()
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'GroupBox1
'
Me.GroupBox1.Controls.Add(Me.DataGrid1)
Me.GroupBox1.Location = New System.Drawing.Point(10, 9)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(656, 275)
Me.GroupBox1.TabIndex = 0
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "今日借阅的书籍"
'
'DataGrid1
'
Me.DataGrid1.BackColor = System.Drawing.SystemColors.Info
Me.DataGrid1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.DataGrid1.CaptionVisible = False
Me.DataGrid1.DataMember = ""
Me.DataGrid1.GridLineStyle = System.Windows.Forms.DataGridLineStyle.None
Me.DataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText
Me.DataGrid1.Location = New System.Drawing.Point(10, 17)
Me.DataGrid1.Name = "DataGrid1"
Me.DataGrid1.Size = New System.Drawing.Size(637, 250)
Me.DataGrid1.TabIndex = 0
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.Location = New System.Drawing.Point(19, 296)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(41, 12)
Me.Label1.TabIndex = 1
Me.Label1.Text = "借阅号"
'
'TxtIssueNo
'
Me.TxtIssueNo.Location = New System.Drawing.Point(66, 293)
Me.TxtIssueNo.Name = "TxtIssueNo"
Me.TxtIssueNo.Size = New System.Drawing.Size(120, 21)
Me.TxtIssueNo.TabIndex = 2
'
'Label2
'
Me.Label2.AutoSize = True
Me.Label2.Location = New System.Drawing.Point(212, 298)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(53, 12)
Me.Label2.TabIndex = 3
Me.Label2.Text = "书籍名称"
'
'TxtBookName
'
Me.TxtBookName.Location = New System.Drawing.Point(281, 293)
Me.TxtBookName.Name = "TxtBookName"
Me.TxtBookName.Size = New System.Drawing.Size(120, 21)
Me.TxtBookName.TabIndex = 4
'
'Label3
'
Me.Label3.AutoSize = True
Me.Label3.Location = New System.Drawing.Point(435, 300)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(53, 12)
Me.Label3.TabIndex = 5
Me.Label3.Text = "读者姓名"
'
'TxtReaderName
'
Me.TxtReaderName.Location = New System.Drawing.Point(513, 293)
Me.TxtReaderName.Name = "TxtReaderName"
Me.TxtReaderName.Size = New System.Drawing.Size(120, 21)
Me.TxtReaderName.TabIndex = 6
'
'BtnOK
'
Me.BtnOK.Location = New System.Drawing.Point(111, 334)
Me.BtnOK.Name = "BtnOK"
Me.BtnOK.Size = New System.Drawing.Size(195, 25)
Me.BtnOK.TabIndex = 7
Me.BtnOK.Text = "确定"
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(351, 334)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(195, 25)
Me.Button2.TabIndex = 8
Me.Button2.Text = "关闭"
'
'frm_TodayIssueView
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(670, 376)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.BtnOK)
Me.Controls.Add(Me.TxtReaderName)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.TxtBookName)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.TxtIssueNo)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.GroupBox1)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "frm_TodayIssueView"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "今日借阅查询"
Me.GroupBox1.ResumeLayout(False)
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
#End Region
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
Function loadIntoGridByDateOnly()
dbset.Clear()
MyConnection.Open()
MyCommand = New OleDbCommand(SQLString & " idate = '" & currentDate.Now.ToShortDateString & "'", MyConnection)
dataA = New OleDbDataAdapter(MyCommand)
dataA.fill(dbset, "IssueBook")
DataGrid1.ReadOnly = True
DataGrid1.DataSource = dbset.Tables("IssueBook")
MyReader = MyCommand.ExecuteReader()
While MyReader.Read
End While
MyConnection.Close()
MyReader.Close()
MyCommand.dispose()
End Function
Function loadIntoGridByBookNameAndDate()
dbset.Clear()
MyConnection.Open()
MyCommand = New OleDbCommand(SQLString & " idate = '" & currentDate.Now.ToShortDateString & "' AND BookName LIKE '" & TxtBookName.Text & "%'", MyConnection)
dataA = New OleDbDataAdapter(MyCommand)
dataA.fill(dbset, "IssueBook")
DataGrid1.ReadOnly = True
DataGrid1.DataSource = dbset.Tables("IssueBook")
MyReader = MyCommand.ExecuteReader()
While MyReader.Read
End While
MyConnection.Close()
MyReader.Close()
MyCommand.dispose()
End Function
Function loadIntoGridByReaderNameAndDate()
dbset.Clear()
MyConnection.Open()
MyCommand = New OleDbCommand(SQLString & " idate = '" & currentDate.Now.ToShortDateString & "' AND ReaderName LIKE '" & TxtReaderName.Text & "%'", MyConnection)
dataA = New OleDbDataAdapter(MyCommand)
dataA.fill(dbset, "IssueBook")
DataGrid1.ReadOnly = True
DataGrid1.DataSource = dbset.Tables("IssueBook")
MyReader = MyCommand.ExecuteReader()
While MyReader.Read
End While
MyConnection.Close()
MyReader.Close()
MyCommand.dispose()
End Function
Function loadByIssueNoAndDate()
dbset.Clear()
MyConnection.Open()
MyCommand = New OleDbCommand(SQLString & " idate = '" & currentDate.Now.ToShortDateString & "' AND IssueNo LIKE '" & TxtIssueNo.Text & "%'", MyConnection)
dataA = New OleDbDataAdapter(MyCommand)
dataA.fill(dbset, "IssueBook")
DataGrid1.ReadOnly = True
DataGrid1.DataSource = dbset.Tables("IssueBook")
MyReader = MyCommand.ExecuteReader()
While MyReader.Read
End While
MyConnection.Close()
MyReader.Close()
MyCommand.dispose()
End Function
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TxtIssueNo.KeyPress
Dim strChar As String
strChar = e.KeyChar
Select Case strChar
Case ChrW(System.Windows.Forms.Keys.Enter)
TxtBookName.Focus()
Case Else
End Select
End Sub
Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TxtBookName.KeyPress
Dim strChar As String
strChar = e.KeyChar
Select Case strChar
Case ChrW(System.Windows.Forms.Keys.Enter)
TxtReaderName.Focus()
Case Else
End Select
End Sub
Private Sub TextBox3_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TxtReaderName.KeyPress
Dim strChar As String
strChar = e.KeyChar
Select Case strChar
Case ChrW(System.Windows.Forms.Keys.Enter)
BtnOK.Focus()
Case Else
End Select
End Sub
Private Sub frm_TodayIssueView_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
SQLString += "SELECT IssueNo AS 借阅号, SN AS 书籍编号,"
SQLString += "BookName AS 书籍名称, AuthorName AS 作者名称,"
SQLString += "ReaderNo AS 读者编号,ReaderName AS 读者姓名,"
SQLString += "Itype AS 费用类型, ddate AS 过期期限"
SQLString += " FROM IssueBook WHERE "
TxtIssueNo.Focus()
End Sub
Private Sub BtnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnOK.Click
If TxtIssueNo.Text <> "" And TxtBookName.Text = "" And TxtReaderName.Text = "" Then
loadByIssueNoAndDate()
Else
If TxtIssueNo.Text = "" And TxtBookName.Text <> "" And TxtReaderName.Text = "" Then
loadIntoGridByBookNameAndDate()
Else
If TxtIssueNo.Text = "" And TxtBookName.Text = "" And TxtReaderName.Text <> "" Then
loadIntoGridByReaderNameAndDate()
Else
If TxtIssueNo.Text = "" And TxtBookName.Text = "" And TxtReaderName.Text = "" Then
loadIntoGridByDateOnly()
End If
End If
End If
End If
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -