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

📄 frmdzwh.vb

📁 简单的VFP 图书管理系统
💻 VB
📖 第 1 页 / 共 2 页
字号:
        'ComboBox3
        '
        Me.ComboBox3.Enabled = False
        Me.ComboBox3.Items.AddRange(New Object() {"3本", "5本", "10本", "20本", "50本"})
        Me.ComboBox3.Location = New System.Drawing.Point(352, 104)
        Me.ComboBox3.Name = "ComboBox3"
        Me.ComboBox3.Size = New System.Drawing.Size(136, 20)
        Me.ComboBox3.TabIndex = 24
        '
        'Label10
        '
        Me.Label10.Location = New System.Drawing.Point(264, 104)
        Me.Label10.Name = "Label10"
        Me.Label10.Size = New System.Drawing.Size(120, 24)
        Me.Label10.TabIndex = 23
        Me.Label10.Text = "可借书数:"
        '
        'ComboBox2
        '
        Me.ComboBox2.Enabled = False
        Me.ComboBox2.Items.AddRange(New Object() {"学生", "教师", "教授", "博士", "博士后"})
        Me.ComboBox2.Location = New System.Drawing.Point(352, 64)
        Me.ComboBox2.Name = "ComboBox2"
        Me.ComboBox2.Size = New System.Drawing.Size(136, 20)
        Me.ComboBox2.TabIndex = 22
        '
        'Label9
        '
        Me.Label9.Location = New System.Drawing.Point(264, 64)
        Me.Label9.Name = "Label9"
        Me.Label9.Size = New System.Drawing.Size(120, 24)
        Me.Label9.TabIndex = 21
        Me.Label9.Text = "读者类别:"
        '
        'TextBox5
        '
        Me.TextBox5.Enabled = False
        Me.TextBox5.Location = New System.Drawing.Point(352, 24)
        Me.TextBox5.Name = "TextBox5"
        Me.TextBox5.Size = New System.Drawing.Size(136, 21)
        Me.TextBox5.TabIndex = 20
        Me.TextBox5.Text = ""
        '
        'Label8
        '
        Me.Label8.Location = New System.Drawing.Point(264, 24)
        Me.Label8.Name = "Label8"
        Me.Label8.Size = New System.Drawing.Size(120, 24)
        Me.Label8.TabIndex = 19
        Me.Label8.Text = "学    号:"
        '
        'ComboBox1
        '
        Me.ComboBox1.Enabled = False
        Me.ComboBox1.Items.AddRange(New Object() {"男", "女"})
        Me.ComboBox1.Location = New System.Drawing.Point(96, 104)
        Me.ComboBox1.Name = "ComboBox1"
        Me.ComboBox1.Size = New System.Drawing.Size(136, 20)
        Me.ComboBox1.TabIndex = 18
        '
        'Label7
        '
        Me.Label7.Location = New System.Drawing.Point(8, 104)
        Me.Label7.Name = "Label7"
        Me.Label7.Size = New System.Drawing.Size(120, 24)
        Me.Label7.TabIndex = 17
        Me.Label7.Text = "读者性别:"
        '
        'TextBox4
        '
        Me.TextBox4.Enabled = False
        Me.TextBox4.Location = New System.Drawing.Point(96, 64)
        Me.TextBox4.Name = "TextBox4"
        Me.TextBox4.Size = New System.Drawing.Size(136, 21)
        Me.TextBox4.TabIndex = 16
        Me.TextBox4.Text = ""
        '
        'Label6
        '
        Me.Label6.Location = New System.Drawing.Point(8, 64)
        Me.Label6.Name = "Label6"
        Me.Label6.Size = New System.Drawing.Size(120, 24)
        Me.Label6.TabIndex = 15
        Me.Label6.Text = "读者姓名:"
        '
        'TextBox3
        '
        Me.TextBox3.Enabled = False
        Me.TextBox3.Location = New System.Drawing.Point(96, 24)
        Me.TextBox3.Name = "TextBox3"
        Me.TextBox3.Size = New System.Drawing.Size(136, 21)
        Me.TextBox3.TabIndex = 14
        Me.TextBox3.Text = ""
        '
        'Label5
        '
        Me.Label5.Location = New System.Drawing.Point(8, 24)
        Me.Label5.Name = "Label5"
        Me.Label5.Size = New System.Drawing.Size(120, 24)
        Me.Label5.TabIndex = 13
        Me.Label5.Text = "读者编号:"
        '
        'frmDzWh
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(760, 438)
        Me.Controls.Add(Me.GroupBox2)
        Me.Controls.Add(Me.DataGrid1)
        Me.Controls.Add(Me.GroupBox1)
        Me.Controls.Add(Me.ToolBar1)
        Me.Name = "frmDzWh"
        Me.Text = "读者信息维护"
        Me.GroupBox1.ResumeLayout(False)
        CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).EndInit()
        Me.GroupBox2.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub frmDzWh_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("读者信息表")
        'DataGrid1.DataSource = dt.DefaultView
        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 ToolBar1_ButtonClick(ByVal sender As Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar1.ButtonClick
        Dim i As New Integer
        Dim dzbh As String
        Select Case e.Button.Text
            Case "首记录"
                ''bm.Position = 0
                'i = Me.DataGrid1.CurrentRowIndex
                'i = 0
                'Me.DataGrid1.CurrentRowIndex = i
                bm.Position = 0
                DataGrid1.CurrentRowIndex = bm.Position
                Me.DataGrid1_Click(Nothing, Nothing)
            Case "上一条"
                'If bm.Position <> 0 Then
                '    bm.Position -= 1
                'End If
                'i = Me.DataGrid1.CurrentRowIndex
                'i -= 1
                'Me.DataGrid1.CurrentRowIndex = i
                bm.Position = (bm.Position - 1)
                DataGrid1.CurrentRowIndex = bm.Position

                Me.DataGrid1_Click(Nothing, Nothing)
            Case "下一条"
                'If bm.Position <> 0 Then
                '    bm.Position += 1
                'End If
                'i = Me.DataGrid1.CurrentRowIndex
                'i += 1
                'Me.DataGrid1.CurrentRowIndex = i
                bm.Position = (bm.Position + 1)
                DataGrid1.CurrentRowIndex = bm.Position

                Me.DataGrid1_Click(Nothing, Nothing)

            Case "尾记录"
                'bm.Position = bm.Count
                bm.Position = (ds.Tables("读者信息表").Rows.Count - 1)
                DataGrid1.CurrentRowIndex = bm.Position
                Me.DataGrid1_Click(Nothing, Nothing)
            Case "修改"
                    TextBox3.Enabled = True
                    TextBox4.Enabled = True
                    TextBox5.Enabled = True
                    ComboBox1.Enabled = True
                    ComboBox2.Enabled = True
                    ComboBox3.Enabled = True
                ComboBox4.Enabled = True
                ToolBarButton8.Enabled = True
                'TextBox3.Text = ds.Tables("读者信息表").Rows(DataGrid1.CurrentRowIndex).Item(0)
                'TextBox4.Text = ds.Tables("读者信息表").Rows(DataGrid1.CurrentRowIndex).Item(1)
                'ComboBox1.SelectedItem = ds.Tables("读者信息表").Rows(DataGrid1.CurrentRowIndex).Item(2)
                'TextBox5.Text = ds.Tables("读者信息表").Rows(DataGrid1.CurrentRowIndex).Item(3)
                'ComboBox2.SelectedItem = ds.Tables("读者信息表").Rows(DataGrid1.CurrentRowIndex).Item(4)
                'ComboBox3.SelectedItem = ds.Tables("读者信息表").Rows(DataGrid1.CurrentRowIndex).Item(5)
                'ComboBox4.SelectedItem = ds.Tables("读者信息表").Rows(DataGrid1.CurrentRowIndex).Item(6)
            Case "删除"
                    If conn.State = ConnectionState.Closed Then
                        conn.Open()
                    End If
                    Dim str As String
                    dzbh = ds.Tables("读者信息表").Rows(DataGrid1.CurrentRowIndex).Item(0)
                    If MsgBox("确定要删除这条记录吗?", MsgBoxStyle.YesNo, "删除提示") = MsgBoxResult.Yes Then
                        str = "delete from 读者信息表 where 读者编号='" & dzbh & "'"
                        '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 "保存"
                    If conn.State = ConnectionState.Closed Then
                        conn.Open()
                    End If
                    'dzbh = ds.Tables("读者信息表").Rows(DataGrid1.CurrentRowIndex).Item(0)
                    Dim str As String
                    str = "update 读者信息表 set 读者姓名 = '" & TextBox4.Text & "',读者性别 = '" & ComboBox1.SelectedItem & "',学号 = '" & TextBox5.Text & "',读者类别 = '" & ComboBox2.SelectedItem & "',最多可借书数 = '" & ComboBox3.SelectedItem & "',借书证状态 = '" & ComboBox4.SelectedItem & "' 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
                        TextBox4.Enabled = False
                        TextBox5.Enabled = False
                        ComboBox1.Enabled = False
                        ComboBox2.Enabled = False
                        ComboBox3.Enabled = False
                    ComboBox4.Enabled = False
                    Me.DataGrid1_Click(Nothing, Nothing)
                    ToolBarButton8.Enabled = False
                    End If
            Case "退出"
                    Me.Close()
        End Select
    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)
        TextBox4.Text = ds.Tables("读者信息表").Rows(DataGrid1.CurrentRowIndex).Item(1)
        ComboBox1.SelectedItem = ds.Tables("读者信息表").Rows(DataGrid1.CurrentRowIndex).Item(2)
        TextBox5.Text = ds.Tables("读者信息表").Rows(DataGrid1.CurrentRowIndex).Item(3)
        ComboBox2.SelectedItem = ds.Tables("读者信息表").Rows(DataGrid1.CurrentRowIndex).Item(4)
        ComboBox3.SelectedItem = ds.Tables("读者信息表").Rows(DataGrid1.CurrentRowIndex).Item(5)
        ComboBox4.SelectedItem = ds.Tables("读者信息表").Rows(DataGrid1.CurrentRowIndex).Item(6)
    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 读者姓名 = '" & TextBox2.Text & "'"
        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 + -