?? borrowbook.vb
字號(hào):
Me.btnLend.Location = New System.Drawing.Point(16, 16)
Me.btnLend.Name = "btnLend"
Me.btnLend.Size = New System.Drawing.Size(48, 32)
Me.btnLend.TabIndex = 0
Me.btnLend.Text = "借出"
'
'btnClear
'
Me.btnClear.Location = New System.Drawing.Point(104, 16)
Me.btnClear.Name = "btnClear"
Me.btnClear.Size = New System.Drawing.Size(48, 32)
Me.btnClear.TabIndex = 0
Me.btnClear.Text = "清空"
'
'btnClose
'
Me.btnClose.Location = New System.Drawing.Point(192, 16)
Me.btnClose.Name = "btnClose"
Me.btnClose.Size = New System.Drawing.Size(48, 32)
Me.btnClose.TabIndex = 0
Me.btnClose.Text = "關(guān)閉"
'
'GroupBox5
'
Me.GroupBox5.Controls.Add(Me.rdoBookId)
Me.GroupBox5.Controls.Add(Me.rdoBarCode)
Me.GroupBox5.Location = New System.Drawing.Point(592, 0)
Me.GroupBox5.Name = "GroupBox5"
Me.GroupBox5.Size = New System.Drawing.Size(168, 160)
Me.GroupBox5.TabIndex = 3
Me.GroupBox5.TabStop = False
Me.GroupBox5.Text = "選擇圖書(shū)關(guān)鍵字"
'
'rdoBookId
'
Me.rdoBookId.Checked = True
Me.rdoBookId.Location = New System.Drawing.Point(16, 32)
Me.rdoBookId.Name = "rdoBookId"
Me.rdoBookId.TabIndex = 0
Me.rdoBookId.TabStop = True
Me.rdoBookId.Text = "圖書(shū)編號(hào)"
'
'rdoBarCode
'
Me.rdoBarCode.Location = New System.Drawing.Point(16, 72)
Me.rdoBarCode.Name = "rdoBarCode"
Me.rdoBarCode.TabIndex = 0
Me.rdoBarCode.Text = "條形碼"
'
'Label4
'
Me.Label4.BackColor = System.Drawing.Color.FromArgb(CType(255, Byte), CType(192, Byte), CType(128, Byte))
Me.Label4.Location = New System.Drawing.Point(592, 168)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(168, 104)
Me.Label4.TabIndex = 4
Me.Label4.Text = "先在讀者編號(hào)處輸入讀者編號(hào)然后按回車(chē)鍵,調(diào)出讀者信息 再在圖書(shū)編號(hào)/條碼處輸入圖書(shū)的編號(hào)/條碼調(diào)出圖書(shū)信息"
'
'grdLendBook
'
Me.grdLendBook.DataMember = ""
Me.grdLendBook.Dock = System.Windows.Forms.DockStyle.Bottom
Me.grdLendBook.HeaderForeColor = System.Drawing.SystemColors.ControlText
Me.grdLendBook.Location = New System.Drawing.Point(0, 327)
Me.grdLendBook.Name = "grdLendBook"
Me.grdLendBook.ReadOnly = True
Me.grdLendBook.Size = New System.Drawing.Size(760, 184)
Me.grdLendBook.TabIndex = 5
'
'frmBorrowBook
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(760, 511)
Me.Controls.Add(Me.grdLendBook)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.GroupBox5)
Me.Controls.Add(Me.GroupBox4)
Me.Controls.Add(Me.GroupBox3)
Me.Controls.Add(Me.GroupBox1)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
Me.MaximizeBox = False
Me.Name = "frmBorrowBook"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "借書(shū)"
Me.GroupBox1.ResumeLayout(False)
Me.GroupBox3.ResumeLayout(False)
Me.GroupBox4.ResumeLayout(False)
Me.GroupBox5.ResumeLayout(False)
CType(Me.grdLendBook, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
Private bookds As New DataSet
Private readerds As New DataSet
Private borrowds As New DataSet
Private bookstr As String
Private readerstr As String
Private borrowstr As String
Private Sub rdoBookId_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rdoBookId.CheckedChanged
labInfo.Text = "圖書(shū)編號(hào)"
End Sub
Private Sub rdoBarCode_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rdoBarCode.CheckedChanged
labInfo.Text = "條形碼"
End Sub
Private Sub frmBorrowBook_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
txtBorrowTime.Text = Date.Now.ToShortDateString
End Sub
Private Sub txtReaderId_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtReaderId.KeyDown
If e.KeyCode = Keys.Return Then
If txtReaderId.Text <> "" Then
readerstr = "select * from 讀者 where 編號(hào)='" & txtReaderId.Text & "'"
Try
readerds.Clear()
OleConn.SelectQuery(readerstr, readerds)
If readerds.Tables.Count < 1 Or readerds.Tables(0).Rows.Count < 1 Then
MsgBox("找不到此讀者")
Else
Dim dr As DataRow = readerds.Tables(0).Rows(0)
If Not dr.IsNull("姓名") Then
txtReaderName.Text = dr("姓名")
End If
If Not dr.IsNull("性別") Then
txtReaderSex.Text = dr("性別")
End If
If Not dr.IsNull("類(lèi)別") Then
txtReaderType.Text = dr("類(lèi)別")
End If
If Not dr.IsNull("單位部門(mén)") Then
txtReaderDepartment.Text = dr("單位部門(mén)")
End If
If Not dr.IsNull("聯(lián)系電話") Then
txtReaderTelephone.Text = dr("聯(lián)系電話")
End If
If Not dr.IsNull("住址") Then
txtReaderAddress.Text = dr("住址")
End If
If Not dr.IsNull("登記日期") Then
txtReaderAddTime.Text = dr("登記日期")
End If
If Not dr.IsNull("借書(shū)次數(shù)") Then
txtLendCount.Text = dr("借書(shū)次數(shù)")
End If
If Not dr.IsNull("可借書(shū)數(shù)") Then
txtCanBorrowCount.Text = dr("可借書(shū)數(shù)")
End If
If Not dr.IsNull("未還書(shū)數(shù)") Then
txtUnReturnedCount.Text = dr("未還書(shū)數(shù)")
End If
If Not dr.IsNull("備注") Then
txtDemo.Text = dr("備注")
End If
txtReturnTime.Text = CDate(txtBorrowTime.Text).AddDays(CInt(dr.Item("借書(shū)期限")))
borrowstr = "select * from 借出圖書(shū) where 借書(shū)者編號(hào)='" & txtReaderId.Text & "' and 在館='否'"
borrowds.Clear()
OleConn.SelectQuery(borrowstr, borrowds)
grdLendBook.SetDataBinding(borrowds, "Table")
txtBookId.Enabled = True
btnLend.Enabled = False
txtBookId.Focus()
End If
Catch ex As Exception
OleConn.DisplayError(ex)
End Try
End If
End If
End Sub
Private Sub txtBookId_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtBookId.KeyDown
If e.KeyCode = Keys.Return Then
If txtBookId.Text <> "" Then
Try
If rdoBookId.Checked Then
bookstr = "select * from 圖書(shū) where 圖書(shū)編號(hào)='" & txtBookId.Text & "'"
Else
bookstr = "select * from 圖書(shū) where 條形碼='" & txtBookId.Text & "'"
End If
bookds.Clear()
OleConn.SelectQuery(bookstr, bookds)
If bookds.Tables.Count < 1 Or bookds.Tables(0).Rows.Count < 1 Then
MsgBox("找不到此書(shū)")
Else
Dim dr As DataRow = bookds.Tables(0).Rows(0)
If Not dr.IsNull("書(shū)名") Then
txtBookName.Text = dr.Item("書(shū)名")
End If
If Not dr.IsNull("類(lèi)別") Then
txtBookType.Text = dr("類(lèi)別")
End If
If Not dr.IsNull("作者") Then
txtBookAuthor.Text = dr("作者")
End If
If Not dr.IsNull("出版社") Then
txtPublisher.Text = dr("出版社")
End If
If Not dr.IsNull("出版時(shí)間") Then
txtPublishTime.Text = dr("出版時(shí)間")
End If
If Not dr.IsNull("圖書(shū)價(jià)格") Then
txtBookPrice.Text = dr("圖書(shū)價(jià)格")
End If
If Not dr.IsNull("圖書(shū)總數(shù)") Then
txtBookCount.Text = dr("圖書(shū)總數(shù)")
End If
If Not dr.IsNull("現(xiàn)存數(shù)量") Then
txtExistCount.Text = dr("現(xiàn)存數(shù)量")
End If
btnLend.Enabled = True
End If
Catch ex As Exception
OleConn.DisplayError(ex)
End Try
End If
End If
End Sub
Private Sub btnLend_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLend.Click
Try
Dim readerdr As DataRow = readerds.Tables(0).Rows(0)
If readerdr.Item("未還書(shū)數(shù)") >= readerdr.Item("可借書(shū)數(shù)") Then
MsgBox("讀者的可借書(shū)數(shù)已經(jīng)達(dá)到上限")
Else
Dim bookdr As DataRow = bookds.Tables(0).Rows(0)
If bookdr.Item("現(xiàn)存數(shù)量") < 1 Then
MsgBox("此書(shū)已全部借出")
Else
Dim str As String = "圖書(shū)編號(hào)='" & txtBookId.Text & "'"
Dim dr As DataRow() = borrowds.Tables(0).Select(str)
If dr.GetLength(0) > 1 Then
MsgBox("讀者已經(jīng)借了此書(shū),并且還未還")
Else
Dim borrowdr As DataRow = borrowds.Tables(0).NewRow
borrowdr.Item("圖書(shū)編號(hào)") = txtBookId.Text
borrowdr.Item("書(shū)名") = bookdr.Item("書(shū)名")
borrowdr.Item("借書(shū)者編號(hào)") = readerdr.Item("編號(hào)")
borrowdr.Item("借書(shū)者") = readerdr.Item("姓名")
borrowdr.Item("借書(shū)日期") = txtBorrowTime.Text
borrowdr.Item("應(yīng)還日期") = txtReturnTime.Text
borrowdr.Item("在館") = "否"
borrowdr.Item("條形碼") = bookdr.Item("條形碼")
borrowdr.Item("出版社") = bookdr.Item("出版社")
borrowdr.Item("出版時(shí)間") = bookdr.Item("出版時(shí)間")
borrowdr.Item("類(lèi)別") = bookdr.Item("類(lèi)別")
borrowdr.Item("圖書(shū)價(jià)格") = bookdr.Item("圖書(shū)價(jià)格")
borrowds.Tables(0).Rows.Add(borrowdr)
OleConn.Adapter.SelectCommand.CommandText = borrowstr
OleConn.UpDate(borrowds.Tables(0))
borrowds.AcceptChanges()
readerdr.BeginEdit()
readerdr.Item("未還書(shū)數(shù)") = readerdr.Item("未還書(shū)數(shù)") + 1
readerdr.Item("借書(shū)次數(shù)") = readerdr.Item("借書(shū)次數(shù)") + 1
readerdr.Item("借書(shū)日期") = txtBorrowTime.Text
readerdr.EndEdit()
OleConn.Adapter.SelectCommand.CommandText = readerstr
OleConn.UpDate(readerds.Tables(0))
readerds.AcceptChanges()
txtUnReturnedCount.Text = readerdr.Item("未還書(shū)數(shù)")
txtLendCount.Text = readerdr.Item("借書(shū)次數(shù)")
bookdr.BeginEdit()
bookdr.Item("現(xiàn)存數(shù)量") = bookdr.Item("現(xiàn)存數(shù)量") - 1
bookdr.Item("借出次數(shù)") = bookdr.Item("借出次數(shù)") + 1
bookdr.EndEdit()
OleConn.Adapter.SelectCommand.CommandText = bookstr
OleConn.UpDate(bookds.Tables(0))
bookds.AcceptChanges()
txtExistCount.Text = bookdr.Item("現(xiàn)存數(shù)量")
btnLend.Enabled = False
MsgBox("借書(shū)成功")
End If
End If
End If
Catch ex As Exception
OleConn.DisplayError(ex)
End Try
End Sub
Private Sub btnClear_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnClear.Click
borrowds.Clear()
txtReaderId.Text = ""
txtReaderName.Text = ""
txtReaderSex.Text = ""
txtReaderType.Text = ""
txtReaderDepartment.Text = ""
txtReaderTelephone.Text = ""
txtReaderAddress.Text = ""
txtReaderAddTime.Text = ""
txtLendCount.Text = ""
txtCanBorrowCount.Text = ""
txtUnReturnedCount.Text = ""
txtDemo.Text = ""
txtBookId.Text = ""
txtBookName.Text = ""
txtBookType.Text = ""
txtBookAuthor.Text = ""
txtPublisher.Text = ""
txtPublishTime.Text = ""
txtBookPrice.Text = ""
txtBookCount.Text = ""
txtExistCount.Text = ""
txtReturnTime.Text = ""
btnLend.Enabled = False
txtReaderId.Focus()
End Sub
Private Sub btnClose_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnClose.Click
Me.Close()
End Sub
End Class
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -