📄 frm_checkadm.vb
字号:
Imports System.Data.OleDb
Public Class frm_checkAdm
Dim myConnection As New OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0; Data source=D:\library.mdb")
Dim myCommand As OleDbCommand
Dim myReader As OleDbDataReader
Dim readerNoStr As String = ""
Dim isbnStr As String = ""
Dim readerNoArray As Array
Dim isbnArray As Array
Private Sub admNotxt_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles admNotxt.KeyPress
If e.KeyChar = ChrW(System.Windows.Forms.Keys.Enter) Then
passwordtxt.Focus()
End If
End Sub
Private Sub passwordtxt_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles passwordtxt.KeyPress
If e.KeyChar = ChrW(System.Windows.Forms.Keys.Enter) Then
If checkValidAdm() Then
setInfo()
freeze()
updateFine()
MsgBox("completed!")
Me.Close()
End If
End If
End Sub
Sub freeze()
Dim i As Integer
readerNoArray = readerNoStr.Split(",")
myConnection.Open()
For i = 0 To readerNoArray.Length - 2
Dim tempReaderNo As String
tempReaderNo = readerNoArray(i)
myCommand = New OleDbCommand("Update ReaderDetails set Status= 'Freeze' where ReaderNo='" & tempReaderNo & "'", myConnection)
myCommand.ExecuteNonQuery()
Next
myConnection.Close()
myCommand.Dispose()
End Sub
Sub setInfo()
Try
myConnection.Open()
myCommand = New OleDbCommand("select * from RentBook where Status='Nreturned'and [DueDate]= #" & Date.Today & "#", myConnection)
myReader = myCommand.ExecuteReader
While myReader.Read
readerNoStr += myReader("ReaderNo").ToString + ","
isbnStr += myReader("ISBN").ToString + ","
End While
myConnection.Close()
myCommand.Dispose()
myReader.Close()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Sub updateFine()
Dim i As Integer
isbnArray = isbnStr.Split(",")
myConnection.Open()
For i = 0 To isbnArray.Length - 2
Dim tempReaderNo As String
tempReaderNo = readerNoArray(i)
myCommand = New OleDbCommand("INSERT INTO Fine VALUES( " & _
"'" & isbnArray(i) & "','" & readerNoArray(i) & "','" & Date.Today.ToShortDateString & _
" ',Null ,'" & admNotxt.Text & "', 0,'UnPaid','Late Returning')", myConnection)
myCommand.ExecuteNonQuery()
Next
myConnection.Close()
myCommand.Dispose()
End Sub
Function checkValidAdm() As Boolean
Dim admNo As String = ""
Dim password As String = ""
myConnection.Open()
myCommand = New OleDbCommand("select * from Administrator where AdmNo = '" & admNotxt.Text & _
"'", myConnection)
myReader = myCommand.ExecuteReader()
While myReader.Read
admNo = myReader("AdmNo")
password = myReader("Password")
End While
myConnection.Close()
myReader.Close()
myCommand.Dispose()
If admNo = "" Then
MsgBox("Invalid Administrator ID!")
Else
If password = passwordtxt.Text Then
Return True
Else
MsgBox("Invalid Administrator Password!")
Return False
End If
End If
End Function
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -