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

📄 returnbook.vb

📁 这是一个完善的图书馆管理系统.后台数据库采用ACCESS.
💻 VB
📖 第 1 页 / 共 3 页
字号:
        Me.txtPublishTime.TabIndex = 1
        Me.txtPublishTime.Text = ""
        '
        'Label25
        '
        Me.Label25.Location = New System.Drawing.Point(384, 240)
        Me.Label25.Name = "Label25"
        Me.Label25.Size = New System.Drawing.Size(56, 23)
        Me.Label25.TabIndex = 0
        Me.Label25.Text = "现存数量"
        '
        'txtBookPrice
        '
        Me.txtBookPrice.Enabled = False
        Me.txtBookPrice.Location = New System.Drawing.Point(80, 235)
        Me.txtBookPrice.Name = "txtBookPrice"
        Me.txtBookPrice.Size = New System.Drawing.Size(104, 21)
        Me.txtBookPrice.TabIndex = 1
        Me.txtBookPrice.Text = ""
        '
        'Label26
        '
        Me.Label26.Location = New System.Drawing.Point(8, 208)
        Me.Label26.Name = "Label26"
        Me.Label26.Size = New System.Drawing.Size(56, 16)
        Me.Label26.TabIndex = 0
        Me.Label26.Text = "作者"
        '
        'txtBookAuthor
        '
        Me.txtBookAuthor.Enabled = False
        Me.txtBookAuthor.Location = New System.Drawing.Point(80, 203)
        Me.txtBookAuthor.Name = "txtBookAuthor"
        Me.txtBookAuthor.Size = New System.Drawing.Size(104, 21)
        Me.txtBookAuthor.TabIndex = 1
        Me.txtBookAuthor.Text = ""
        '
        'labInfo
        '
        Me.labInfo.BackColor = System.Drawing.SystemColors.Control
        Me.labInfo.ForeColor = System.Drawing.Color.Blue
        Me.labInfo.Location = New System.Drawing.Point(8, 176)
        Me.labInfo.Name = "labInfo"
        Me.labInfo.Size = New System.Drawing.Size(56, 16)
        Me.labInfo.TabIndex = 0
        Me.labInfo.Text = "图书编号"
        '
        'txtBookId
        '
        Me.txtBookId.Enabled = False
        Me.txtBookId.Location = New System.Drawing.Point(80, 171)
        Me.txtBookId.Name = "txtBookId"
        Me.txtBookId.Size = New System.Drawing.Size(104, 21)
        Me.txtBookId.TabIndex = 1
        Me.txtBookId.Text = ""
        '
        'Label28
        '
        Me.Label28.Location = New System.Drawing.Point(384, 207)
        Me.Label28.Name = "Label28"
        Me.Label28.Size = New System.Drawing.Size(56, 23)
        Me.Label28.TabIndex = 0
        Me.Label28.Text = "出版日期"
        '
        'Label30
        '
        Me.Label30.Location = New System.Drawing.Point(8, 240)
        Me.Label30.Name = "Label30"
        Me.Label30.Size = New System.Drawing.Size(56, 16)
        Me.Label30.TabIndex = 0
        Me.Label30.Text = "价格"
        '
        'Label22
        '
        Me.Label22.Location = New System.Drawing.Point(192, 240)
        Me.Label22.Name = "Label22"
        Me.Label22.Size = New System.Drawing.Size(56, 16)
        Me.Label22.TabIndex = 0
        Me.Label22.Text = "图书总数"
        '
        'frmReturnBook
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(760, 509)
        Me.Controls.Add(Me.grdLendBook)
        Me.Controls.Add(Me.GroupBox3)
        Me.Controls.Add(Me.Label4)
        Me.Controls.Add(Me.GroupBox5)
        Me.Controls.Add(Me.GroupBox4)
        Me.Controls.Add(Me.GroupBox1)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
        Me.Name = "frmReturnBook"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "还书"
        CType(Me.grdLendBook, System.ComponentModel.ISupportInitialize).EndInit()
        Me.GroupBox3.ResumeLayout(False)
        Me.GroupBox5.ResumeLayout(False)
        Me.GroupBox4.ResumeLayout(False)
        Me.GroupBox1.ResumeLayout(False)
        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 frmReturnBook_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        txtReturnTime.Text = Date.Now.ToShortDateString
    End Sub

    Private Sub rdoBookId_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles rdoBookId.Click
        labInfo.Text = "图书编号"
    End Sub

    Private Sub rdoBarCode_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles rdoBarCode.Click
        labInfo.Text = "条形码"
    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
                        borrowstr = "select * from 借出图书 where 借书者编号='" & txtReaderId.Text & "' and 在馆='否'"
                        borrowds.Clear()
                        OleConn.SelectQuery(borrowstr, borrowds)
                        grdLendBook.SetDataBinding(borrowds, "Table")
                        txtBookId.Enabled = True
                        btnReturn.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
                        If rdoBookId.Checked Then
                            borrowstr = "select * from 借出图书 where 借书者编号='" & txtReaderId.Text & _
                                "' and 在馆='否' and 图书编号='" & txtBookId.Text & "'"
                        Else
                            borrowstr = "select * from 借出图书 where 借书者编号='" & txtReaderId.Text & _
                                "' and 在馆='否' and 条形码='" & txtBookId.Text & "'"
                        End If
                        borrowds.Clear()
                        OleConn.SelectQuery(borrowstr, borrowds)
                        grdLendBook.SetDataBinding(borrowds, "Table")
                        If borrowds.Tables.Count > 0 And borrowds.Tables(0).Rows.Count > 0 Then
                            txtBorrowTime.Text = borrowds.Tables(0).Rows(0).Item("借书日期")
                            btnReturn.Enabled = True
                        End If
                    End If
                Catch ex As Exception
                    OleConn.DisplayError(ex)
                End Try
            End If
        End If
    End Sub

    Private Sub btnReturn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnReturn.Click
        Try
            Dim readerdr As DataRow = readerds.Tables(0).Rows(0)
            Dim bookdr As DataRow = bookds.Tables(0).Rows(0)
            Dim borrowdr As DataRow = borrowds.Tables(0).Rows(0)
            borrowdr.BeginEdit()
            borrowdr.Item("还书日期") = txtReturnTime.Text
            borrowdr.Item("在馆") = "是"
            borrowdr.EndEdit()
            OleConn.Adapter.SelectCommand.CommandText = borrowstr
            OleConn.UpDate(borrowds.Tables(0))
            borrowds.AcceptChanges()

            readerdr.BeginEdit()
            readerdr.Item("未还书数") = readerdr.Item("未还书数") - 1
            readerdr.Item("还书日期") = txtReturnTime.Text
            readerdr.EndEdit()
            OleConn.Adapter.SelectCommand.CommandText = readerstr
            OleConn.UpDate(readerds.Tables(0))
            readerds.AcceptChanges()
            txtUnReturnedCount.Text = readerdr.Item("未还书数")
            
            bookdr.BeginEdit()
            bookdr.Item("现存数量") = bookdr.Item("现存数量") + 1
            bookdr.EndEdit()
            OleConn.Adapter.SelectCommand.CommandText = bookstr
            OleConn.UpDate(bookds.Tables(0))
            bookds.AcceptChanges()
            txtExistCount.Text = bookdr.Item("现存数量")

            btnReturn.Enabled = False
            MsgBox("还书成功")
        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 = ""
        txtBorrowTime.Text = ""
        btnReturn.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 + -