?? frm_readerdetails.vb
字號:
Me.Button3.Location = New System.Drawing.Point(274, 255)
Me.Button3.Name = "Button3"
Me.Button3.Size = New System.Drawing.Size(109, 25)
Me.Button3.TabIndex = 3
Me.Button3.Text = "退出"
'
'frm_ReaderDetails
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(411, 289)
Me.Controls.Add(Me.Button3)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.BtnAdd)
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_ReaderDetails"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "添加讀者信息"
Me.GroupBox1.ResumeLayout(False)
Me.GroupBox1.PerformLayout()
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Me.Close()
End Sub
Sub clearFields()
TxtReaderNo.Text = ""
TxtReaderName.Text = ""
TxtAddress.Text = ""
TxtPhone.Text = ""
TxtCell.Text = ""
TxtEmail.Text = ""
End Sub
Sub display_MSG(ByVal myMsg As String)
MsgBox(myMsg, MsgBoxStyle.Information, "圖書館管理系統")
End Sub
Private Sub TxtReaderNo_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TxtReaderNo.KeyPress
Dim strChar As String
strChar = e.KeyChar
Select Case strChar
Case ChrW(System.Windows.Forms.Keys.Enter)
If checkTextbox(TxtReaderNo) = False Then
display_MSG("請在文本框中輸入讀者信息!")
Else
If checkIfValidNumber() = False Then
display_MSG("無效讀者編號,請重新輸入!")
Else
If checkTextbox(TxtReaderNo) = True Then
TxtReaderName.Focus()
End If
End If
End If
Case Else
'什么也不做
End Select
End Sub
Private Sub TextBox2_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)
If checkTextbox(TxtReaderName) = False Then
display_MSG("Please fill in the field!")
Else
If checkTextbox(TxtReaderName) = True Then
TxtAddress.Focus()
End If
End If
Case Else
'do nothing
End Select
End Sub
Private Sub TextBox3_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TxtAddress.KeyPress
Dim strChar As String
strChar = e.KeyChar
Select Case strChar
Case ChrW(System.Windows.Forms.Keys.Enter)
If checkTextbox(TxtAddress) = False Then
display_MSG("Please fill in the field!")
Else
If checkTextbox(TxtAddress) = True Then
TxtPhone.Focus()
End If
End If
Case Else
'do nothing
End Select
End Sub
Private Sub TextBox5_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TxtPhone.KeyPress
Dim strChar As String
strChar = e.KeyChar
Select Case strChar
Case ChrW(System.Windows.Forms.Keys.Enter)
If checkTextbox(TxtPhone) = False Then
display_MSG("Please fill in the field!")
Else
If checkTextbox(TxtPhone) = True Then
TxtCell.Focus()
End If
End If
Case Else
'do nothing
End Select
End Sub
Private Sub TextBox6_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TxtCell.KeyPress
Dim strChar As String
strChar = e.KeyChar
Select Case strChar
Case ChrW(System.Windows.Forms.Keys.Enter)
TxtEmail.Focus()
Case Else
'什么也不做
End Select
End Sub
Private Sub TextBox7_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TxtEmail.KeyPress
Dim strChar As String
strChar = e.KeyChar
Select Case strChar
Case ChrW(System.Windows.Forms.Keys.Enter)
BtnAdd.Focus()
Case Else
'do nothing
End Select
End Sub
Function checkTextbox(ByVal t As TextBox)
If t.Text = "" Then
Return False
Else
Return True
End If
End Function
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
clearFields()
TxtReaderNo.Focus()
End Sub
Function RegisterReader()
IssueTag = "3"
IssueTagUsed = "0"
MyConnection.Open()
Try
MyCommand = New OleDbCommand("INSERT INTO ReaderDetails VALUES('" & TxtReaderNo.Text & "','" & TxtReaderName.Text & "', '" & TxtAddress.Text & "','" & TxtPhone.Text & "','" & TxtCell.Text & "','" & TxtEmail.Text & "','" & IssueTag & "','" & IssueTagUsed & "')", MyConnection)
MyCommand.ExecuteNonQuery()
Catch c As Exception
MsgBox(c.ToString)
End Try
MyConnection.Close()
MyCommand.Dispose()
End Function
Private Sub BtnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnAdd.Click
If checkIfAlreadyExists() = True Then
display_MSG("讀者編號已存在,請重新輸入!")
ElseIf checkIfAlreadyExists() = False Then
RegisterReader()
MsgBox("新讀者已注冊!", MsgBoxStyle.Information, "圖書館管理系統")
clearFields()
End If
End Sub
Function checkIfAlreadyExists() As Boolean
MyConnection.Open()
MyCommand = New OleDbCommand("SELECT * FROM ReaderDetails WHERE ReaderNo ='" & TxtReaderNo.Text & "'", MyConnection)
MyReader = MyCommand.ExecuteReader()
Dim TempString As String
While MyReader.Read
TempString = MyReader("ReaderNo")
End While
MyConnection.Close()
MyReader.Close()
MyCommand.Dispose()
If TxtReaderNo.Text = TempString Then
Return True
Else
If TxtReaderNo.Text <> TempString Then
Return False
End If
End If
End Function
Function checkIfValidNumber() As Boolean
Dim myBool As Boolean = False
MyConnection.Open()
MyCommand = New OleDbCommand("SELECT * FROM ReaderNo ", MyConnection)
MyReader = MyCommand.ExecuteReader()
While MyReader.Read
If TxtReaderNo.Text = MyReader("RNo") Then
myBool = True
End If
End While
MyConnection.Close()
MyReader.Close()
MyCommand.Dispose()
Return myBool
End Function
Private Sub frm_ReaderDetails_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -