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

📄 frmsjwh.vb

📁 一套简单的图书管理系统原代码,vb.NET,可供正在学飞VB.net的人使用.
💻 VB
📖 第 1 页 / 共 2 页
字号:
        '
        'TextBox7
        '
        Me.TextBox7.Enabled = False
        Me.TextBox7.Location = New System.Drawing.Point(320, 24)
        Me.TextBox7.Name = "TextBox7"
        Me.TextBox7.Size = New System.Drawing.Size(152, 21)
        Me.TextBox7.TabIndex = 13
        Me.TextBox7.Text = ""
        '
        'Label10
        '
        Me.Label10.Location = New System.Drawing.Point(272, 24)
        Me.Label10.Name = "Label10"
        Me.Label10.Size = New System.Drawing.Size(80, 24)
        Me.Label10.TabIndex = 12
        Me.Label10.Text = "作者:"
        '
        'TextBox4
        '
        Me.TextBox4.Enabled = False
        Me.TextBox4.Location = New System.Drawing.Point(88, 96)
        Me.TextBox4.Name = "TextBox4"
        Me.TextBox4.Size = New System.Drawing.Size(152, 21)
        Me.TextBox4.TabIndex = 9
        Me.TextBox4.Text = ""
        '
        'Label7
        '
        Me.Label7.Location = New System.Drawing.Point(8, 96)
        Me.Label7.Name = "Label7"
        Me.Label7.Size = New System.Drawing.Size(80, 24)
        Me.Label7.TabIndex = 8
        Me.Label7.Text = "书名:"
        '
        'ComboBox1
        '
        Me.ComboBox1.Enabled = False
        Me.ComboBox1.Items.AddRange(New Object() {"IT技术", "管理", "机电", "文学", "历史", "会计"})
        Me.ComboBox1.Location = New System.Drawing.Point(88, 64)
        Me.ComboBox1.Name = "ComboBox1"
        Me.ComboBox1.Size = New System.Drawing.Size(152, 20)
        Me.ComboBox1.TabIndex = 7
        '
        'Label5
        '
        Me.Label5.Location = New System.Drawing.Point(8, 64)
        Me.Label5.Name = "Label5"
        Me.Label5.Size = New System.Drawing.Size(96, 24)
        Me.Label5.TabIndex = 6
        Me.Label5.Text = "图书类别:"
        '
        'TextBox3
        '
        Me.TextBox3.Enabled = False
        Me.TextBox3.Location = New System.Drawing.Point(88, 24)
        Me.TextBox3.Name = "TextBox3"
        Me.TextBox3.Size = New System.Drawing.Size(152, 21)
        Me.TextBox3.TabIndex = 5
        Me.TextBox3.Text = ""
        '
        'Label6
        '
        Me.Label6.Location = New System.Drawing.Point(8, 24)
        Me.Label6.Name = "Label6"
        Me.Label6.Size = New System.Drawing.Size(96, 24)
        Me.Label6.TabIndex = 4
        Me.Label6.Text = "图书编号:"
        '
        'Label12
        '
        Me.Label12.Location = New System.Drawing.Point(496, 24)
        Me.Label12.Name = "Label12"
        Me.Label12.Size = New System.Drawing.Size(64, 24)
        Me.Label12.TabIndex = 16
        Me.Label12.Text = "册数:"
        '
        'TextBox8
        '
        Me.TextBox8.Enabled = False
        Me.TextBox8.Location = New System.Drawing.Point(576, 24)
        Me.TextBox8.Name = "TextBox8"
        Me.TextBox8.Size = New System.Drawing.Size(152, 21)
        Me.TextBox8.TabIndex = 17
        Me.TextBox8.Text = ""
        '
        'Label11
        '
        Me.Label11.Location = New System.Drawing.Point(496, 64)
        Me.Label11.Name = "Label11"
        Me.Label11.Size = New System.Drawing.Size(64, 24)
        Me.Label11.TabIndex = 18
        Me.Label11.Text = "出版日期:"
        '
        'DateTimePicker1
        '
        Me.DateTimePicker1.Enabled = False
        Me.DateTimePicker1.Location = New System.Drawing.Point(576, 64)
        Me.DateTimePicker1.Name = "DateTimePicker1"
        Me.DateTimePicker1.Size = New System.Drawing.Size(152, 21)
        Me.DateTimePicker1.TabIndex = 19
        '
        'DataGrid1
        '
        Me.DataGrid1.BackColor = System.Drawing.SystemColors.InactiveBorder
        Me.DataGrid1.CaptionVisible = False
        Me.DataGrid1.DataMember = ""
        Me.DataGrid1.Dock = System.Windows.Forms.DockStyle.Fill
        Me.DataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText
        Me.DataGrid1.Location = New System.Drawing.Point(0, 96)
        Me.DataGrid1.Name = "DataGrid1"
        Me.DataGrid1.ReadOnly = True
        Me.DataGrid1.Size = New System.Drawing.Size(768, 214)
        Me.DataGrid1.TabIndex = 4
        '
        'ComboBox2
        '
        Me.ComboBox2.Items.AddRange(New Object() {"IT技术", "管理", "机电", "文学", "历史", "会计"})
        Me.ComboBox2.Location = New System.Drawing.Point(104, 24)
        Me.ComboBox2.Name = "ComboBox2"
        Me.ComboBox2.Size = New System.Drawing.Size(136, 20)
        Me.ComboBox2.TabIndex = 7
        '
        'frmSjWh
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(768, 446)
        Me.Controls.Add(Me.DataGrid1)
        Me.Controls.Add(Me.GroupBox2)
        Me.Controls.Add(Me.GroupBox1)
        Me.Controls.Add(Me.ToolBar1)
        Me.Name = "frmSjWh"
        Me.Text = "书籍信息维护"
        Me.WindowState = System.Windows.Forms.FormWindowState.Maximized
        Me.GroupBox1.ResumeLayout(False)
        Me.GroupBox2.ResumeLayout(False)
        CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub frmSjWh_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If conn.State = ConnectionState.Closed Then
            conn.Open()
        End If
        comm.Connection = conn
        comm.CommandType = CommandType.Text
        comm.CommandText = "select * from 图书信息表"
        da.SelectCommand = comm
        da.Fill(ds, "图书信息表")
        bm = Me.BindingContext(ds, "图书信息表")
        DataGrid1.DataSource = ds.Tables("图书信息表")
        Label4.Text = ds.Tables("图书信息表").Rows.Count.ToString
        Me.DataGrid1_Click(Nothing, Nothing)
        If conn.State = ConnectionState.Open Then
            conn.Close()
        End If
        ToolBarButton8.Enabled = False
    End Sub

    Private Sub DataGrid1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.Click
        TextBox3.Text = ds.Tables("图书信息表").Rows(DataGrid1.CurrentRowIndex).Item(0)
        ComboBox1.SelectedItem = ds.Tables("图书信息表").Rows(DataGrid1.CurrentRowIndex).Item(1)
        TextBox4.Text = ds.Tables("图书信息表").Rows(DataGrid1.CurrentRowIndex).Item(2)
        TextBox5.Text = ds.Tables("图书信息表").Rows(DataGrid1.CurrentRowIndex).Item(5)
        TextBox6.Text = ds.Tables("图书信息表").Rows(DataGrid1.CurrentRowIndex).Item(4)
        TextBox7.Text = ds.Tables("图书信息表").Rows(DataGrid1.CurrentRowIndex).Item(3)
        TextBox8.Text = ds.Tables("图书信息表").Rows(DataGrid1.CurrentRowIndex).Item(6)
        DateTimePicker1.Text = ds.Tables("图书信息表").Rows(DataGrid1.CurrentRowIndex).Item(7)
    End Sub

    Private Sub ToolBar1_ButtonClick(ByVal sender As Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar1.ButtonClick
        Dim tsbh As String
        Select Case e.Button.Text
            Case "首记录"
                bm.Position = 0
                DataGrid1.CurrentRowIndex = bm.Position
                Me.DataGrid1_Click(Nothing, Nothing)
            Case "上一条"
                bm.Position = (bm.Position - 1)
                DataGrid1.CurrentRowIndex = bm.Position
                Me.DataGrid1_Click(Nothing, Nothing)
            Case "下一条"
                bm.Position = (bm.Position + 1)
                DataGrid1.CurrentRowIndex = bm.Position
                Me.DataGrid1_Click(Nothing, Nothing)
            Case "尾记录"
                bm.Position = (ds.Tables("图书信息表").Rows.Count - 1)
                DataGrid1.CurrentRowIndex = bm.Position
                Me.DataGrid1_Click(Nothing, Nothing)
            Case "删除"
                If conn.State = ConnectionState.Closed Then
                    conn.Open()
                End If
                Dim str As String
                tsbh = ds.Tables("图书信息表").Rows(DataGrid1.CurrentRowIndex).Item(0)
                If MsgBox("确定要删除这条记录吗?", MsgBoxStyle.YesNo, "删除提示") = MsgBoxResult.Yes Then
                    str = "delete from 图书信息表 where 图书编号='" & tsbh & "'"
                    'Dim del As Boolean
                    'del = UpdateDataBase(SqlStr)
                    comm.Connection = conn
                    comm.CommandType = CommandType.Text
                    comm.CommandText = str
                    da.SelectCommand = comm
                    da.Fill(ds, "图书信息表")
                    If Me.ds.Tables.Count <> 0 Then
                        ds.Clear()
                        comm.Connection = conn
                        comm.CommandType = CommandType.Text
                        comm.CommandText = "select * from 图书信息表 "
                        da.SelectCommand = comm
                        da.Fill(ds, "图书信息表")
                        MessageBox.Show("删除读者信息成功", "提示信息")
                    Else
                    End If
                    If conn.State = ConnectionState.Open Then
                        conn.Close()
                    End If
                Else
                    Exit Sub
                End If
            Case "修改"
                TextBox3.Enabled = True
                ComboBox1.Enabled = True
                TextBox4.Enabled = True
                TextBox5.Enabled = True
                TextBox6.Enabled = True
                TextBox7.Enabled = True
                TextBox8.Enabled = True
                DateTimePicker1.Enabled = True
                ToolBarButton8.Enabled = True
            Case "保存"
                If conn.State = ConnectionState.Closed Then
                    conn.Open()
                End If
                Dim str As String
                str = "update 图书信息表 set 图书类别 = '" & ComboBox1.SelectedItem & "',书名 = '" & TextBox4.Text & "',价格 = " & TextBox5.Text & ",出版社 = '" & TextBox6.Text & "',作者 = '" & TextBox7.Text & "',册数 = '" & TextBox8.Text & "',出版日期='" & DateTimePicker1.Value.Date & "' where 图书编号 = '" & TextBox3.Text & "'"
                comm.Connection = conn
                comm.CommandType = CommandType.Text
                comm.CommandText = str
                da.SelectCommand = comm
                da.Fill(ds, "图书信息表")
                If Me.ds.Tables.Count <> 0 Then
                    ds.Clear()
                    comm.Connection = conn
                    comm.CommandType = CommandType.Text
                    comm.CommandText = "select * from 图书信息表 "
                    da.SelectCommand = comm
                    da.Fill(ds, "图书信息表")
                    MessageBox.Show("图书信息保存成功", "提示信息")
                    TextBox3.Enabled = False
                    ComboBox1.Enabled = False
                    TextBox4.Enabled = False
                    TextBox5.Enabled = False
                    TextBox6.Enabled = False
                    TextBox7.Enabled = False
                    TextBox8.Enabled = False
                    DateTimePicker1.Enabled = False
                    ToolBarButton8.Enabled = False
                    Me.DataGrid1_Click(Nothing, Nothing)
                End If
        End Select
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ds.Clear()
        If conn.State = ConnectionState.Closed Then
            conn.Open()
        End If
        comm.Connection = conn
        comm.CommandType = CommandType.Text
        comm.CommandText = "select * from 图书信息表 where 图书类别 = '" & ComboBox2.SelectedItem & "'"
        da.SelectCommand = comm
        da.Fill(ds, "图书信息表")
        DataGrid1.DataSource = ds.Tables("图书信息表")
        Me.DataGrid1_Click(Nothing, Nothing)
        If conn.State = ConnectionState.Open Then
            conn.Close()
        End If
    End Sub
End Class

⌨️ 快捷键说明

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