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

📄 form1.vb

📁 这是一个比较完整的java语言编写的文件系统程序
💻 VB
字号:
Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows 窗体设计器生成的代码 "

    Public Sub New()
        MyBase.New()

        '该调用是 Windows 窗体设计器所必需的。
        InitializeComponent()

        '在 InitializeComponent() 调用之后添加任何初始化

    End Sub

    '窗体重写 dispose 以清理组件列表。
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Windows 窗体设计器所必需的
    Private components As System.ComponentModel.IContainer

    '注意: 以下过程是 Windows 窗体设计器所必需的
    '可以使用 Windows 窗体设计器修改此过程。
    '不要使用代码编辑器修改它。
    Friend WithEvents TreeView1 As System.Windows.Forms.TreeView
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents OleDbConnection1 As System.Data.OleDb.OleDbConnection
    Friend WithEvents OleDbCommand1 As System.Data.OleDb.OleDbCommand
    Friend WithEvents Button2 As System.Windows.Forms.Button
    Friend WithEvents Button3 As System.Windows.Forms.Button
    Friend WithEvents Button5 As System.Windows.Forms.Button
    Friend WithEvents Button6 As System.Windows.Forms.Button
    Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
    Friend WithEvents Button4 As System.Windows.Forms.Button
    Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
    Friend WithEvents Label1 As System.Windows.Forms.Label
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.TreeView1 = New System.Windows.Forms.TreeView
        Me.Button1 = New System.Windows.Forms.Button
        Me.OleDbConnection1 = New System.Data.OleDb.OleDbConnection
        Me.OleDbCommand1 = New System.Data.OleDb.OleDbCommand
        Me.Button2 = New System.Windows.Forms.Button
        Me.Button3 = New System.Windows.Forms.Button
        Me.Button5 = New System.Windows.Forms.Button
        Me.Button6 = New System.Windows.Forms.Button
        Me.TextBox1 = New System.Windows.Forms.TextBox
        Me.Button4 = New System.Windows.Forms.Button
        Me.ComboBox1 = New System.Windows.Forms.ComboBox
        Me.Label1 = New System.Windows.Forms.Label
        Me.SuspendLayout()
        '
        'TreeView1
        '
        Me.TreeView1.ImageIndex = -1
        Me.TreeView1.Location = New System.Drawing.Point(8, 88)
        Me.TreeView1.Name = "TreeView1"
        Me.TreeView1.SelectedImageIndex = -1
        Me.TreeView1.Size = New System.Drawing.Size(184, 320)
        Me.TreeView1.TabIndex = 0
        '
        'Button1
        '
        Me.Button1.Font = New System.Drawing.Font("华文新魏", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
        Me.Button1.Location = New System.Drawing.Point(224, 88)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(200, 32)
        Me.Button1.TabIndex = 1
        Me.Button1.Text = "添加用户"
        '
        'OleDbConnection1
        '
        Me.OleDbConnection1.ConnectionString = "Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database L" & _
        "ocking Mode=1;Data Source=fm.mdb;Mode=Share Deny None;Jet OLEDB:Engine Type=5;Pr" & _
        "ovider=""Microsoft.Jet.OLEDB.4.0"";Jet OLEDB:System database=;Jet OLEDB:SFP=False;" & _
        "persist security info=False;Extended Properties=;Jet OLEDB:Compact Without Repli" & _
        "ca Repair=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Create System Databas" & _
        "e=False;Jet OLEDB:Don't Copy Locale on Compact=False;User ID=Admin;Jet OLEDB:Glo" & _
        "bal Bulk Transactions=1"
        '
        'OleDbCommand1
        '
        Me.OleDbCommand1.Connection = Me.OleDbConnection1
        '
        'Button2
        '
        Me.Button2.Font = New System.Drawing.Font("华文新魏", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
        Me.Button2.Location = New System.Drawing.Point(224, 144)
        Me.Button2.Name = "Button2"
        Me.Button2.Size = New System.Drawing.Size(200, 32)
        Me.Button2.TabIndex = 2
        Me.Button2.Text = "删除用户"
        '
        'Button3
        '
        Me.Button3.Font = New System.Drawing.Font("华文新魏", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
        Me.Button3.Location = New System.Drawing.Point(224, 208)
        Me.Button3.Name = "Button3"
        Me.Button3.Size = New System.Drawing.Size(200, 32)
        Me.Button3.TabIndex = 3
        Me.Button3.Text = "新建文件"
        '
        'Button5
        '
        Me.Button5.Font = New System.Drawing.Font("华文新魏", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
        Me.Button5.Location = New System.Drawing.Point(224, 264)
        Me.Button5.Name = "Button5"
        Me.Button5.Size = New System.Drawing.Size(200, 32)
        Me.Button5.TabIndex = 5
        Me.Button5.Text = "删除文件"
        '
        'Button6
        '
        Me.Button6.Font = New System.Drawing.Font("华文行楷", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
        Me.Button6.Location = New System.Drawing.Point(232, 400)
        Me.Button6.Name = "Button6"
        Me.Button6.Size = New System.Drawing.Size(64, 24)
        Me.Button6.TabIndex = 6
        Me.Button6.Text = "刷新列表"
        '
        'TextBox1
        '
        Me.TextBox1.Location = New System.Drawing.Point(232, 312)
        Me.TextBox1.Name = "TextBox1"
        Me.TextBox1.ReadOnly = True
        Me.TextBox1.Size = New System.Drawing.Size(184, 22)
        Me.TextBox1.TabIndex = 7
        Me.TextBox1.Text = ""
        '
        'Button4
        '
        Me.Button4.Enabled = False
        Me.Button4.Font = New System.Drawing.Font("华文新魏", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
        Me.Button4.Location = New System.Drawing.Point(352, 400)
        Me.Button4.Name = "Button4"
        Me.Button4.Size = New System.Drawing.Size(64, 24)
        Me.Button4.TabIndex = 9
        Me.Button4.Text = "确定"
        '
        'ComboBox1
        '
        Me.ComboBox1.Enabled = False
        Me.ComboBox1.Items.AddRange(New Object() {"是", "否"})
        Me.ComboBox1.Location = New System.Drawing.Point(232, 360)
        Me.ComboBox1.Name = "ComboBox1"
        Me.ComboBox1.Size = New System.Drawing.Size(184, 22)
        Me.ComboBox1.TabIndex = 10
        '
        'Label1
        '
        Me.Label1.Font = New System.Drawing.Font("华文行楷", 15.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
        Me.Label1.Location = New System.Drawing.Point(24, 16)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(392, 24)
        Me.Label1.TabIndex = 11
        Me.Label1.Text = "文件管理"
        Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(7, 15)
        Me.BackColor = System.Drawing.SystemColors.Control
        Me.ClientSize = New System.Drawing.Size(448, 446)
        Me.Controls.Add(Me.Label1)
        Me.Controls.Add(Me.ComboBox1)
        Me.Controls.Add(Me.Button4)
        Me.Controls.Add(Me.TextBox1)
        Me.Controls.Add(Me.Button6)
        Me.Controls.Add(Me.Button5)
        Me.Controls.Add(Me.Button3)
        Me.Controls.Add(Me.Button2)
        Me.Controls.Add(Me.Button1)
        Me.Controls.Add(Me.TreeView1)
        Me.Font = New System.Drawing.Font("华文新魏", 10.5!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
        Me.Name = "Form1"
        Me.Text = "网络(3) 湛博彦"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim add_u_form As New filesmanager.Form2
        add_u_form.Show()

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Call sx()
    End Sub
    Sub sx()

        TreeView1.Nodes.Clear()
        OleDbConnection1.Open()
        Dim reader As OleDb.OleDbDataReader
        Dim t_user As String
        Dim myfm As TreeNode
        OleDbCommand1.CommandText = "select * from ut"
        reader = OleDbCommand1.ExecuteReader

        Do While reader.Read
            t_user = reader("u_name").ToString
            Dim newNode1 As TreeNode = New TreeNode(t_user)
            TreeView1.Nodes.Add(newNode1)
        Loop
        OleDbConnection1.Close()
    End Sub

    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        Call sx()
        
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        Dim add_u_form As New filesmanager.Form3
        add_u_form.Show()

    End Sub

    

    Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
        Dim snstr As String
        Dim SelectNode As TreeNode
        '定义节点
        Dim i As Integer
        '定义循环变量       
        snstr = TreeView1.SelectedNode.Text
        '取得节点目录
        Dim sfiles As String
        SelectNode = TreeView1.SelectedNode
        
        '取得节点
        SelectNode.Nodes.Clear()
        '先清空子节点
        If (TreeView1.SelectedNode.Parent Is Nothing) Then
            OleDbConnection1.Open()
            Dim reader As OleDb.OleDbDataReader
            OleDbCommand1.CommandText = "select * from ft"
            ' where f_user = '" & TreeView1.SelectedNode.Text & "'
            reader = OleDbCommand1.ExecuteReader

            Do While reader.Read
                sfiles = reader("f_name").ToString
                Dim newNode1 As TreeNode = New TreeNode(sfiles)
                TreeView1.SelectedNode.Nodes.Add(newNode1)
            Loop
        Else
        End If
        OleDbConnection1.Close()

    End Sub
 
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        
        Button3.Enabled = False
        Button4.Enabled = True
        TextBox1.ReadOnly = False
        TextBox1.Text = "请输入文件名"

        ComboBox1.Enabled = True
        ComboBox1.Text = "请选择是否受保护"
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click

        OleDbConnection1.Open()
        OleDbCommand1.CommandText = "delete from ft where f_name = '" & TreeView1.SelectedNode.Text & "'"
        OleDbCommand1.ExecuteNonQuery()
        MessageBox.Show("添加成功!!")
        OleDbConnection1.Close()
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        OleDbConnection1.Open()
        OleDbCommand1.CommandText = "insert into ft (f_name,f_protect,f_user) values('" & TextBox1.Text & "','" & ComboBox1.Text & "','" & TreeView1.SelectedNode.Text & "')"
        OleDbCommand1.ExecuteNonQuery()
        MessageBox.Show("添加成功!!")
        OleDbConnection1.Close()
        Button3.Enabled = True
        Button4.Enabled = False
        TextBox1.ReadOnly = True
        TextBox1.Text = ""

        ComboBox1.Enabled = False
        ComboBox1.Text = ""
    End Sub
End Class

⌨️ 快捷键说明

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