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

📄 frm_updatelostbook.vb

📁 是关于图书管理系统的用vb.net 和access开发的
💻 VB
字号:
Imports System.Data.OleDb

Public Class frm_UpdateLostBook

    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 dataset1 As DataSet
    Dim dataAd As OleDbDataAdapter

    Private Sub isbntxt_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ISBNtxt.KeyPress

        Dim isbn As String = ""
        Dim status As String = ""

        If e.KeyChar = ChrW(System.Windows.Forms.Keys.Enter) Then

            dataset1 = New DataSet("dataset1")
            dataAd = New OleDbDataAdapter()

            myConnection.Open()

            myCommand = New OleDbCommand("select * from BookDetails where isbn= '" & ISBNtxt.Text & "'", myConnection)

            myReader = myCommand.ExecuteReader()


            While myReader.Read
                isbn = myReader("ISBN")
                status = myReader("Status")
            End While

            If isbn = "" Then
                MsgBox("This book is not in the database yet!")

                myReader.Close()
                myConnection.Close()
                myCommand.Dispose()

                Exit Sub
            End If

            If status <> "Lost" Then
                MsgBox("This book is not lost!")

                myReader.Close()
                myConnection.Close()
                myCommand.Dispose()

                Exit Sub
            End If




            myReader.Close()

            dataAd.SelectCommand = myCommand
            dataAd.Fill(dataset1, "BookDetails")

            DataGridView1.DataSource = dataset1

            DataGridView1.DataMember = "BookDetails"

            myConnection.Close()
            myCommand.Dispose()

        End If

    End Sub

    Private Sub addbt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles addbt.Click
        changeBookStatus()
    End Sub

    Sub changeBookStatus()
        myConnection.Open()

        myCommand = New OleDbCommand("Update BookDetails set Status= 'InLib',LibDate=#" & Date.Today.ToShortDateString & "# where ISBN='" & ISBNtxt.Text & "'", myConnection)

        myCommand.ExecuteNonQuery()

        myConnection.Close()
        myCommand.Dispose()
        myReader.Close()

        MsgBox("Add Success!")
    End Sub

    Private Sub exitbt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exitbt.Click
        Me.Close()
    End Sub
End Class

⌨️ 快捷键说明

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