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

📄 addbook.vb

📁 这是一个完善的图书馆管理系统.后台数据库采用ACCESS.
💻 VB
📖 第 1 页 / 共 2 页
字号:
        '
        Me.Label8.Location = New System.Drawing.Point(8, 152)
        Me.Label8.Name = "Label8"
        Me.Label8.Size = New System.Drawing.Size(48, 16)
        Me.Label8.TabIndex = 0
        Me.Label8.Text = "类别"
        '
        'txtCount
        '
        Me.txtCount.Location = New System.Drawing.Point(248, 122)
        Me.txtCount.Name = "txtCount"
        Me.txtCount.Size = New System.Drawing.Size(120, 21)
        Me.txtCount.TabIndex = 7
        Me.txtCount.Text = "10"
        '
        'Label9
        '
        Me.Label9.Location = New System.Drawing.Point(184, 123)
        Me.Label9.Name = "Label9"
        Me.Label9.Size = New System.Drawing.Size(56, 16)
        Me.Label9.TabIndex = 0
        Me.Label9.Text = "图书总数"
        '
        'Label10
        '
        Me.Label10.Location = New System.Drawing.Point(184, 156)
        Me.Label10.Name = "Label10"
        Me.Label10.Size = New System.Drawing.Size(56, 16)
        Me.Label10.TabIndex = 0
        Me.Label10.Text = "存放位置"
        '
        'txtPrice
        '
        Me.txtPrice.Location = New System.Drawing.Point(72, 184)
        Me.txtPrice.Name = "txtPrice"
        Me.txtPrice.TabIndex = 10
        Me.txtPrice.Text = "60"
        '
        'Label11
        '
        Me.Label11.Location = New System.Drawing.Point(8, 184)
        Me.Label11.Name = "Label11"
        Me.Label11.Size = New System.Drawing.Size(56, 16)
        Me.Label11.TabIndex = 0
        Me.Label11.Text = "图书价格"
        '
        'Label12
        '
        Me.Label12.Location = New System.Drawing.Point(184, 189)
        Me.Label12.Name = "Label12"
        Me.Label12.Size = New System.Drawing.Size(56, 16)
        Me.Label12.TabIndex = 0
        Me.Label12.Text = "入馆时间"
        '
        'txtAddTime
        '
        Me.txtAddTime.Enabled = False
        Me.txtAddTime.Location = New System.Drawing.Point(248, 187)
        Me.txtAddTime.Name = "txtAddTime"
        Me.txtAddTime.Size = New System.Drawing.Size(120, 21)
        Me.txtAddTime.TabIndex = 11
        Me.txtAddTime.Text = ""
        '
        'cmbType
        '
        Me.cmbType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.cmbType.Location = New System.Drawing.Point(72, 152)
        Me.cmbType.Name = "cmbType"
        Me.cmbType.Size = New System.Drawing.Size(100, 20)
        Me.cmbType.TabIndex = 8
        '
        'cmbPublishTime
        '
        Me.cmbPublishTime.Location = New System.Drawing.Point(248, 90)
        Me.cmbPublishTime.Name = "cmbPublishTime"
        Me.cmbPublishTime.Size = New System.Drawing.Size(120, 20)
        Me.cmbPublishTime.TabIndex = 5
        '
        'btnSave
        '
        Me.btnSave.Location = New System.Drawing.Point(8, 248)
        Me.btnSave.Name = "btnSave"
        Me.btnSave.Size = New System.Drawing.Size(56, 32)
        Me.btnSave.TabIndex = 1
        Me.btnSave.Text = "保存"
        '
        'btnClear
        '
        Me.btnClear.Location = New System.Drawing.Point(172, 248)
        Me.btnClear.Name = "btnClear"
        Me.btnClear.Size = New System.Drawing.Size(56, 32)
        Me.btnClear.TabIndex = 2
        Me.btnClear.Text = "清空"
        '
        'btnClose
        '
        Me.btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.btnClose.Location = New System.Drawing.Point(336, 248)
        Me.btnClose.Name = "btnClose"
        Me.btnClose.Size = New System.Drawing.Size(56, 32)
        Me.btnClose.TabIndex = 3
        Me.btnClose.Text = "关闭"
        '
        'mcdPublishTime
        '
        Me.mcdPublishTime.Location = New System.Drawing.Point(107, 117)
        Me.mcdPublishTime.Name = "mcdPublishTime"
        Me.mcdPublishTime.TabIndex = 4
        Me.mcdPublishTime.Visible = False
        '
        'frmAddBook
        '
        Me.AcceptButton = Me.btnSave
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.CancelButton = Me.btnClose
        Me.ClientSize = New System.Drawing.Size(402, 285)
        Me.Controls.Add(Me.mcdPublishTime)
        Me.Controls.Add(Me.btnSave)
        Me.Controls.Add(Me.GroupBox1)
        Me.Controls.Add(Me.btnClear)
        Me.Controls.Add(Me.btnClose)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
        Me.MaximizeBox = False
        Me.Name = "frmAddBook"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "添加图书"
        Me.GroupBox1.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private DataReader As System.Data.OleDb.OleDbDataReader

    Private Sub frmAddBook_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        txtAddTime.Text = Date.Now.ToShortDateString
        Try
            OleConn.SelectQuery("select * from 图书类别", DataReader)
            While DataReader.Read
                cmbType.Items.Add(DataReader.Item(0))
            End While
            DataReader.Close()

            OleConn.SelectQuery("select * from 存放位置", DataReader)
            While DataReader.Read
                cmbLocation.Items.Add(DataReader.Item(0))
            End While
            DataReader.Close()
        Catch ex As Exception
            OleConn.DisplayError(ex)
        End Try
    End Sub

    Private Sub cmbPublishTime_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles cmbPublishTime.MouseDown
        mcdPublishTime.Visible = True
    End Sub

    Private Sub mcdPublishTime_DateSelected(ByVal sender As Object, ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles mcdPublishTime.DateSelected
        cmbPublishTime.Text = e.Start.ToShortDateString
        mcdPublishTime.Visible = False
        txtPages.Focus()
    End Sub

    Private Sub mcdPublishTime_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles mcdPublishTime.MouseLeave
        mcdPublishTime.Visible = False
    End Sub

    Private Sub btnClear_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnClear.Click
        txtId.Text = ""
        txtBarCode.Text = ""
        txtName.Text = ""
        txtPublisher.Text = ""
        txtAuthor.Text = ""
        cmbPublishTime.Text = ""
        txtPages.Text = ""
        txtCount.Text = ""
        txtPrice.Text = ""
        mcdPublishTime.Visible = False
    End Sub

    Private Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click
        If txtId.Text = "" Then
            MsgBox("请输入图书编号")
            txtId.Focus()
        ElseIf txtBarCode.Text = "" Then
            MsgBox("请输入图书条形码")
            txtBarCode.Focus()
        ElseIf txtName.Text = "" Then
            MsgBox("请输入书名")
            txtName.Focus()
        ElseIf txtPublisher.Text = "" Then
            MsgBox("请输入出版社")
            txtPublisher.Focus()
        ElseIf txtAuthor.Text = "" Then
            MsgBox("请输入作者")
            txtAuthor.Focus()
        ElseIf cmbPublishTime.Text = "" Then
            MsgBox("请输入出版时间")
            cmbPublishTime.Focus()
        ElseIf txtPages.Text = "" Then
            MsgBox("请输入图书页数")
        ElseIf txtCount.Text = "" Then
            MsgBox("请输入图书总数")
            txtCount.Focus()
        ElseIf cmbType.SelectedIndex < 0 Then
            MsgBox("请选择图书类别")
            cmbType.Focus()
        ElseIf cmbLocation.SelectedIndex < 0 Then
            MsgBox("请选择图书存放位置")
            cmbLocation.Focus()
        ElseIf txtPrice.Text = "" Then
            MsgBox("请输入图书价格")
            txtPrice.Focus()
        Else
            Dim str As String = "INSERT INTO 图书(图书编号, 条形码, 书名, 作者, 出版社, 出版时间, 页数" & _
                ", 类别, 现存数量, 存放位置, 图书总数, 入馆时间, 图书价格) VALUES('" & txtId.Text & "', '" & _
                txtBarCode.Text & "', '" & txtName.Text & "', '" & txtAuthor.Text & "', '" & _
                txtPublisher.Text & "', '" & cmbPublishTime.Text & "', " & CInt(txtPages.Text) & ", '" & _
                cmbType.SelectedItem & "', " & CInt(txtCount.Text) & ", '" & cmbLocation.SelectedItem & _
                "', " & CInt(txtCount.Text) & ", '" & txtAddTime.Text & "', " & txtPrice.Text & ")"
            Try
                OleConn.InsertQuery(str)
                MsgBox("添加成功")
                txtId.Text = ""
                txtBarCode.Text = ""
                txtName.Text = ""
                txtId.Focus()
            Catch ex As Exception
                OleConn.DisplayError(ex)
            End Try
        End If
    End Sub
End Class

⌨️ 快捷键说明

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