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

📄 frmdepman.vb

📁 代码:是由本人自主开发完成的
💻 VB
字号:
Public Class frmdepman
    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 TvDep As System.Windows.Forms.TreeView
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents txtDepName As System.Windows.Forms.TextBox
    Friend WithEvents cmdADD As System.Windows.Forms.Button
    Friend WithEvents cmdModify As System.Windows.Forms.Button
    Friend WithEvents cmdDelete As System.Windows.Forms.Button
    Friend WithEvents cmdCanCel As System.Windows.Forms.Button
    Friend WithEvents ImageList1 As System.Windows.Forms.ImageList
    Friend WithEvents GbDep As System.Windows.Forms.GroupBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(frmdepman))
        Me.GbDep = New System.Windows.Forms.GroupBox
        Me.TvDep = New System.Windows.Forms.TreeView
        Me.ImageList1 = New System.Windows.Forms.ImageList(Me.components)
        Me.Label1 = New System.Windows.Forms.Label
        Me.txtDepName = New System.Windows.Forms.TextBox
        Me.cmdADD = New System.Windows.Forms.Button
        Me.cmdModify = New System.Windows.Forms.Button
        Me.cmdDelete = New System.Windows.Forms.Button
        Me.cmdCanCel = New System.Windows.Forms.Button
        Me.GbDep.SuspendLayout()
        Me.SuspendLayout()
        '
        'GbDep
        '
        Me.GbDep.Controls.Add(Me.TvDep)
        Me.GbDep.Location = New System.Drawing.Point(29, 8)
        Me.GbDep.Name = "GbDep"
        Me.GbDep.Size = New System.Drawing.Size(304, 272)
        Me.GbDep.TabIndex = 0
        Me.GbDep.TabStop = False
        Me.GbDep.Text = "院系信息--当前院系:[]"
        '
        'TvDep
        '
        Me.TvDep.BorderStyle = System.Windows.Forms.BorderStyle.None
        Me.TvDep.ImageList = Me.ImageList1
        Me.TvDep.Location = New System.Drawing.Point(16, 24)
        Me.TvDep.Name = "TvDep"
        Me.TvDep.Size = New System.Drawing.Size(272, 232)
        Me.TvDep.TabIndex = 0
        '
        'ImageList1
        '
        Me.ImageList1.ImageSize = New System.Drawing.Size(16, 16)
        Me.ImageList1.ImageStream = CType(resources.GetObject("ImageList1.ImageStream"), System.Windows.Forms.ImageListStreamer)
        Me.ImageList1.TransparentColor = System.Drawing.Color.Transparent
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(29, 291)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(72, 16)
        Me.Label1.TabIndex = 1
        Me.Label1.Text = "院系名称:"
        '
        'txtDepName
        '
        Me.txtDepName.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.txtDepName.Location = New System.Drawing.Point(93, 290)
        Me.txtDepName.MaxLength = 30
        Me.txtDepName.Name = "txtDepName"
        Me.txtDepName.Size = New System.Drawing.Size(240, 21)
        Me.txtDepName.TabIndex = 2
        Me.txtDepName.Text = ""
        '
        'cmdADD
        '
        Me.cmdADD.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.cmdADD.Location = New System.Drawing.Point(21, 320)
        Me.cmdADD.Name = "cmdADD"
        Me.cmdADD.Size = New System.Drawing.Size(64, 32)
        Me.cmdADD.TabIndex = 3
        Me.cmdADD.Text = "添  加"
        '
        'cmdModify
        '
        Me.cmdModify.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.cmdModify.Location = New System.Drawing.Point(109, 320)
        Me.cmdModify.Name = "cmdModify"
        Me.cmdModify.Size = New System.Drawing.Size(64, 32)
        Me.cmdModify.TabIndex = 4
        Me.cmdModify.Text = "修  改"
        '
        'cmdDelete
        '
        Me.cmdDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.cmdDelete.Location = New System.Drawing.Point(197, 320)
        Me.cmdDelete.Name = "cmdDelete"
        Me.cmdDelete.Size = New System.Drawing.Size(64, 32)
        Me.cmdDelete.TabIndex = 5
        Me.cmdDelete.Text = "删  除"
        '
        'cmdCanCel
        '
        Me.cmdCanCel.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.cmdCanCel.Location = New System.Drawing.Point(277, 320)
        Me.cmdCanCel.Name = "cmdCanCel"
        Me.cmdCanCel.Size = New System.Drawing.Size(64, 32)
        Me.cmdCanCel.TabIndex = 6
        Me.cmdCanCel.Text = "返  回"
        '
        'frmdepman
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(362, 367)
        Me.Controls.Add(Me.cmdCanCel)
        Me.Controls.Add(Me.cmdDelete)
        Me.Controls.Add(Me.cmdModify)
        Me.Controls.Add(Me.cmdADD)
        Me.Controls.Add(Me.txtDepName)
        Me.Controls.Add(Me.Label1)
        Me.Controls.Add(Me.GbDep)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
        Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
        Me.MaximizeBox = False
        Me.Name = "frmdepman"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "院系信息管理"
        Me.GbDep.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region
    Private Sub cmdCanCel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCanCel.Click
        Me.Close()
    End Sub

    Private Sub frmdepman_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        MyDep.Initials()
        CurDep.Initials()
        MyDep.LoadDepNodesToTV(TvDep)
    End Sub

    Private Sub TvDep_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TvDep.MouseDown
        TvDep.SelectedNode = TvDep.GetNodeAt(e.X, e.Y)
        If Not TvDep.SelectedNode Is Nothing Then
            If CurDep.DepartmentName = TvDep.SelectedNode.Text Then
                Exit Sub
            End If
            MyDep.GetDepInfo(MakeStr(TvDep.SelectedNode.Text))
            CurDep.Equal(MyDep)
            txtDepName.Text = CurDep.DepartmentName
            GbDep.Text = "院系信息--当前院系:[" & CurDep.DepartmentName & "]"
        Else
            txtDepName.Text = ""
            CurDep.Initials()
            GbDep.Text = "院系信息--当前院系:[]"
        End If

    End Sub

    Private Sub cmdADD_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdADD.Click
        If txtDepName.Text = "" Then
            txtDepName.Focus()
            Exit Sub
        End If
        If CurDep.UpDepartmentID > 0 Then
            Exit Sub
        End If
        If MyDep.IsInDB(MakeStr(txtDepName.Text)) Then
            MsgBox("院系[" & txtDepName.Text & "]已经存在", MsgBoxStyle.Exclamation, "大学语文考试系统V2.0")
            txtDepName.Text = ""
            txtDepName.Focus()
            Exit Sub
        Else
            MyDep.DepartmentID = MyDep.GetNewID()
            MyDep.DepartmentName = Trim(txtDepName.Text)
            MyDep.UpDepartmentID = CurDep.DepartmentID
            If MyDep.InsertDB() Then
                Dim tnode As TreeNode
                TvDep.BeginUpdate()
                If TvDep.SelectedNode Is Nothing Then
                    tnode = TvDep.Nodes.Add(Trim(txtDepName.Text))
                    tnode.ImageIndex = 0
                    tnode.SelectedImageIndex = 1
                Else
                    tnode = TvDep.SelectedNode.Nodes.Add(Trim(txtDepName.Text))
                    tnode.ImageIndex = 2
                    tnode.SelectedImageIndex = 3
                End If
                TvDep.EndUpdate()
            Else
                MyDep.Initials()
            End If
        End If
    End Sub

    Private Sub cmdModify_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdModify.Click
        If CurDep.DepartmentID <= 0 Then
            Exit Sub
        End If
        If Trim(txtDepName.Text) = "" Then
            Exit Sub
        End If
        If TvDep.SelectedNode Is Nothing Then
            Exit Sub
        End If
        If Trim(txtDepName.Text) = CurDep.DepartmentName Then
            Exit Sub
        End If
        If MyDep.IsInDB(MakeStr(txtDepName.Text)) Then
            MsgBox("院系[" & txtDepName.Text & "]已经存在", MsgBoxStyle.Exclamation, "大学语文考试系统V2.0")
            txtDepName.Text = ""
            txtDepName.Focus()
            Exit Sub
        End If
        MyDep.Equal(CurDep)
        MyDep.DepartmentName = Trim(txtDepName.Text)
        If MsgBox("您是否真的要修改该院系信息?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "大学语文考试系统V2.0") = MsgBoxResult.Yes Then
            If MyDep.ModifyDB() Then
                CurDep.Equal(MyDep)
                TvDep.BeginUpdate()
                TvDep.SelectedNode.Text = CurDep.DepartmentName
                TvDep.EndUpdate()
                txtDepName.Text = ""
                GbDep.Text = "院系信息--当前院系:[" & CurDep.DepartmentName & "]"
            End If
        End If
    End Sub

    Private Sub cmdDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDelete.Click
        If CurDep.DepartmentID <= 0 Then
            Exit Sub
        End If
        If TvDep.SelectedNode Is Nothing Then
            Exit Sub
        End If
        If Not (MyDep.GetDepChildNodes(CurDep.DepartmentID) Is Nothing) Then
            MsgBox("院系[" & CurDep.DepartmentName & "]存在孩子节点,不能删除。" & vbCrLf _
                    & "如果你要删除本节点,请确保该节点没有任何的孩子关系。", MsgBoxStyle.Exclamation, "大学语文考试系统V2.0")
            Exit Sub
        End If
        If MyDep.HaveMarjoys(CurDep.DepartmentID) Then
            MsgBox("院系[" & CurDep.DepartmentName & "]存在所属专业节点,不能删除。" & vbCrLf _
                                & "如果你要删除本节点,请确保该节点没有任何的所属专业。", MsgBoxStyle.Exclamation, "大学语文考试系统V2.0")
            Exit Sub
        End If
        If CurDep.DeleteDB() Then
            Dim tnode As TreeNode
            tnode = TvDep.SelectedNode()
            TvDep.BeginUpdate()
            TvDep.Nodes.Remove(tnode)
            TvDep.EndUpdate()
            txtDepName.Text = ""
            GbDep.Text = "院系信息--当前院系:[]"
        End If
    End Sub


    Private Sub frmdepman_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
        MyDep.Initials()
        CurDep.Initials()
    End Sub

    Private Sub frmdepman_Deactivate(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Deactivate
        MyDep.Initials()
        txtDepName.Text = ""
        CurDep.Initials()
        GbDep.Text = "院系信息--当前院系:[]"
    End Sub


End Class

⌨️ 快捷键说明

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