⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 borrowbook.vb

📁 这是一个完善的图书馆管理系统.后台数据库采用ACCESS.
💻 VB
📖 第 1 页 / 共 3 页
字号:
        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 = "关闭"
        '
        '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 = "选择图书关键字"
        '
        '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 = "图书编号"
        '
        '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 = "先在读者编号处输入读者编号然后按回车键,调出读者信息 再在图书编号/条码处输入图书的编号/条码调出图书信息"
        '
        '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 = "借书"
        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 = "图书编号"
    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 编号='" & 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("类别") Then
                            txtReaderType.Text = dr("类别")
                        End If
                        If Not dr.IsNull("单位部门") Then
                            txtReaderDepartment.Text = dr("单位部门")
                        End If
                        If Not dr.IsNull("联系电话") Then
                            txtReaderTelephone.Text = dr("联系电话")
                        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("借书次数") Then
                            txtLendCount.Text = dr("借书次数")
                        End If
                        If Not dr.IsNull("可借书数") Then
                            txtCanBorrowCount.Text = dr("可借书数")
                        End If
                        If Not dr.IsNull("未还书数") Then
                            txtUnReturnedCount.Text = dr("未还书数")
                        End If
                        If Not dr.IsNull("备注") Then
                            txtDemo.Text = dr("备注")
                        End If
                        txtReturnTime.Text = CDate(txtBorrowTime.Text).AddDays(CInt(dr.Item("借书期限")))
                        borrowstr = "select * from 借出图书 where 借书者编号='" & 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 图书 where 图书编号='" & txtBookId.Text & "'"
                    Else
                        bookstr = "select * from 图书 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("找不到此书")
                    Else
                        Dim dr As DataRow = bookds.Tables(0).Rows(0)
                        If Not dr.IsNull("书名") Then
                            txtBookName.Text = dr.Item("书名")
                        End If
                        If Not dr.IsNull("类别") Then
                            txtBookType.Text = dr("类别")
                        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("出版时间") Then
                            txtPublishTime.Text = dr("出版时间")
                        End If
                        If Not dr.IsNull("图书价格") Then
                            txtBookPrice.Text = dr("图书价格")
                        End If
                        If Not dr.IsNull("图书总数") Then
                            txtBookCount.Text = dr("图书总数")
                        End If
                        If Not dr.IsNull("现存数量") Then
                            txtExistCount.Text = dr("现存数量")
                        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("未还书数") >= readerdr.Item("可借书数") Then
                MsgBox("读者的可借书数已经达到上限")
            Else
                Dim bookdr As DataRow = bookds.Tables(0).Rows(0)
                If bookdr.Item("现存数量") < 1 Then
                    MsgBox("此书已全部借出")
                Else
                    Dim str As String = "图书编号='" & txtBookId.Text & "'"
                    Dim dr As DataRow() = borrowds.Tables(0).Select(str)
                    If dr.GetLength(0) > 1 Then
                        MsgBox("读者已经借了此书,并且还未还")
                    Else
                        Dim borrowdr As DataRow = borrowds.Tables(0).NewRow
                        borrowdr.Item("图书编号") = txtBookId.Text
                        borrowdr.Item("书名") = bookdr.Item("书名")
                        borrowdr.Item("借书者编号") = readerdr.Item("编号")
                        borrowdr.Item("借书者") = readerdr.Item("姓名")
                        borrowdr.Item("借书日期") = txtBorrowTime.Text
                        borrowdr.Item("应还日期") = txtReturnTime.Text
                        borrowdr.Item("在馆") = "否"
                        borrowdr.Item("条形码") = bookdr.Item("条形码")
                        borrowdr.Item("出版社") = bookdr.Item("出版社")
                        borrowdr.Item("出版时间") = bookdr.Item("出版时间")
                        borrowdr.Item("类别") = bookdr.Item("类别")
                        borrowdr.Item("图书价格") = bookdr.Item("图书价格")
                        borrowds.Tables(0).Rows.Add(borrowdr)
                        OleConn.Adapter.SelectCommand.CommandText = borrowstr
                        OleConn.UpDate(borrowds.Tables(0))
                        borrowds.AcceptChanges()

                        readerdr.BeginEdit()
                        readerdr.Item("未还书数") = readerdr.Item("未还书数") + 1
                        readerdr.Item("借书次数") = readerdr.Item("借书次数") + 1
                        readerdr.Item("借书日期") = txtBorrowTime.Text
                        readerdr.EndEdit()
                        OleConn.Adapter.SelectCommand.CommandText = readerstr
                        OleConn.UpDate(readerds.Tables(0))
                        readerds.AcceptChanges()
                        txtUnReturnedCount.Text = readerdr.Item("未还书数")
                        txtLendCount.Text = readerdr.Item("借书次数")

                        bookdr.BeginEdit()
                        bookdr.Item("现存数量") = bookdr.Item("现存数量") - 1
                        bookdr.Item("借出次数") = bookdr.Item("借出次数") + 1
                        bookdr.EndEdit()
                        OleConn.Adapter.SelectCommand.CommandText = bookstr
                        OleConn.UpDate(bookds.Tables(0))
                        bookds.AcceptChanges()
                        txtExistCount.Text = bookdr.Item("现存数量")

                        btnLend.Enabled = False
                        MsgBox("借书成功")
                    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

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -