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

📄 formcollege.vb

📁 学生信息管理系统
💻 VB
字号:
Public Class FormCollege    Inherits FormBase    Private m_oCollege As College#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 lblName As System.Windows.Forms.Label
    Friend WithEvents lblAddress As System.Windows.Forms.Label
    Friend WithEvents lblPhone As System.Windows.Forms.Label
    Friend WithEvents lblMaster As System.Windows.Forms.Label
    Friend WithEvents lblIntro As System.Windows.Forms.Label
    Friend WithEvents txtName As System.Windows.Forms.TextBox
    Friend WithEvents txtAddress As System.Windows.Forms.TextBox
    Friend WithEvents txtPhone As System.Windows.Forms.TextBox
    Friend WithEvents txtMaster As System.Windows.Forms.TextBox
    Friend WithEvents txtIntro As System.Windows.Forms.TextBox
    Friend WithEvents cmCollege As System.Windows.Forms.ContextMenu
    Friend WithEvents miAddCollege As System.Windows.Forms.MenuItem
    Friend WithEvents miEditCollege As System.Windows.Forms.MenuItem
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()        Me.lblName = New System.Windows.Forms.Label
        Me.lblAddress = New System.Windows.Forms.Label
        Me.lblPhone = New System.Windows.Forms.Label
        Me.lblMaster = New System.Windows.Forms.Label
        Me.lblIntro = New System.Windows.Forms.Label
        Me.txtName = New System.Windows.Forms.TextBox
        Me.txtAddress = New System.Windows.Forms.TextBox
        Me.txtPhone = New System.Windows.Forms.TextBox
        Me.txtMaster = New System.Windows.Forms.TextBox
        Me.txtIntro = New System.Windows.Forms.TextBox
        Me.cmCollege = New System.Windows.Forms.ContextMenu
        Me.miAddCollege = New System.Windows.Forms.MenuItem
        Me.miEditCollege = New System.Windows.Forms.MenuItem
        '
        'lblName
        '
        Me.lblName.AutoSize = True
        Me.lblName.Location = New System.Drawing.Point(32, 32)
        Me.lblName.Name = "lblName"
        Me.lblName.Size = New System.Drawing.Size(29, 17)
        Me.lblName.TabIndex = 0
        Me.lblName.Text = "名称"
        '
        'lblAddress
        '
        Me.lblAddress.AutoSize = True
        Me.lblAddress.Location = New System.Drawing.Point(32, 72)
        Me.lblAddress.Name = "lblAddress"
        Me.lblAddress.Size = New System.Drawing.Size(29, 17)
        Me.lblAddress.TabIndex = 1
        Me.lblAddress.Text = "地址"
        '
        'lblPhone
        '
        Me.lblPhone.AutoSize = True
        Me.lblPhone.Location = New System.Drawing.Point(32, 112)
        Me.lblPhone.Name = "lblPhone"
        Me.lblPhone.Size = New System.Drawing.Size(29, 17)
        Me.lblPhone.TabIndex = 2
        Me.lblPhone.Text = "电话"
        '
        'lblMaster
        '
        Me.lblMaster.AutoSize = True
        Me.lblMaster.Location = New System.Drawing.Point(32, 152)
        Me.lblMaster.Name = "lblMaster"
        Me.lblMaster.Size = New System.Drawing.Size(29, 17)
        Me.lblMaster.TabIndex = 3
        Me.lblMaster.Text = "院长"
        '
        'lblIntro
        '
        Me.lblIntro.AutoSize = True
        Me.lblIntro.Location = New System.Drawing.Point(32, 192)
        Me.lblIntro.Name = "lblIntro"
        Me.lblIntro.Size = New System.Drawing.Size(29, 17)
        Me.lblIntro.TabIndex = 4
        Me.lblIntro.Text = "介绍"
        '
        'txtName
        '
        Me.txtName.Location = New System.Drawing.Point(80, 24)
        Me.txtName.Name = "txtName"
        Me.txtName.Size = New System.Drawing.Size(280, 21)
        Me.txtName.TabIndex = 5
        Me.txtName.Text = ""
        '
        'txtAddress
        '
        Me.txtAddress.Location = New System.Drawing.Point(80, 64)
        Me.txtAddress.Name = "txtAddress"
        Me.txtAddress.Size = New System.Drawing.Size(280, 21)
        Me.txtAddress.TabIndex = 6
        Me.txtAddress.Text = ""
        '
        'txtPhone
        '
        Me.txtPhone.Location = New System.Drawing.Point(80, 104)
        Me.txtPhone.Name = "txtPhone"
        Me.txtPhone.Size = New System.Drawing.Size(280, 21)
        Me.txtPhone.TabIndex = 7
        Me.txtPhone.Text = ""
        '
        'txtMaster
        '
        Me.txtMaster.Location = New System.Drawing.Point(80, 144)
        Me.txtMaster.Name = "txtMaster"
        Me.txtMaster.Size = New System.Drawing.Size(280, 21)
        Me.txtMaster.TabIndex = 8
        Me.txtMaster.Text = ""
        '
        'txtIntro
        '
        Me.txtIntro.Location = New System.Drawing.Point(80, 184)
        Me.txtIntro.Multiline = True
        Me.txtIntro.Name = "txtIntro"
        Me.txtIntro.Size = New System.Drawing.Size(280, 136)
        Me.txtIntro.TabIndex = 9
        Me.txtIntro.Text = ""
        '
        'cmCollege
        '
        Me.cmCollege.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.miAddCollege, Me.miEditCollege})
        '
        'miAddCollege
        '
        Me.miAddCollege.Index = 0
        Me.miAddCollege.Text = "添加学院"
        '
        'miEditCollege
        '
        Me.miEditCollege.Index = 1
        Me.miEditCollege.Text = "修改学院"
        '
        'FormCollege
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(648, 461)
        Me.Name = "FormCollege"

        AddControl()
    End Sub#End Region    '添加控件到FormBase.GroupBox2中    Private Sub AddControl()        '将所有控件添加到GroupBox1
        Me.GroupBox1.Controls.Add(Me.txtAddress)
        Me.GroupBox1.Controls.Add(Me.txtIntro)
        Me.GroupBox1.Controls.Add(Me.txtName)
        Me.GroupBox1.Controls.Add(Me.txtMaster)
        Me.GroupBox1.Controls.Add(Me.txtPhone)
        Me.GroupBox1.Controls.Add(Me.lblAddress)
        Me.GroupBox1.Controls.Add(Me.lblIntro)
        Me.GroupBox1.Controls.Add(Me.lblName)
        Me.GroupBox1.Controls.Add(Me.lblPhone)
        Me.GroupBox1.Controls.Add(Me.lblMaster)
    End Sub    '读取窗体各控件值,并设置m_oCollege对象实例相应属性    Private Function GetControl() As Boolean
        If Object.Equals(Me.m_oCollege, Nothing) Then
            GetControl = False
        Else
            '读取控件值
            Me.m_oCollege.Name = Me.txtName.Text
            Me.m_oCollege.Intro = Me.txtIntro.Text
            Me.m_oCollege.Address = Me.txtAddress.Text
            Me.m_oCollege.Master = Me.txtMaster.Text
            Me.m_oCollege.Phone = Me.txtPhone.Text
            GetControl = True
        End If
    End Function    '根据m_oCollege对象实例的属性设置窗体各控件值    Private Function SetControl() As Boolean        If Object.Equals(Me.m_oCollege, Nothing) Then
            SetControl = False
        Else
            '设置控件值
            Me.txtName.Text = Me.m_oCollege.Name
            Me.txtIntro.Text = Me.m_oCollege.Intro
            Me.txtPhone.Text = Me.m_oCollege.Phone
            Me.txtAddress.Text = Me.m_oCollege.Address
            Me.txtMaster.Text = Me.m_oCollege.Master
            SetControl = True
        End If
    End Function    '初始化TreeView    Protected Overrides Sub InitTreeView()        '清空节点
        Me.tvStudent.Nodes(0).Nodes.Clear()
        '添加右键菜单
        'Me.tvStudent.ContextMenu = Me.cmStudent
        '填充节点
        Dim dtTemp As DataTable = CommonDB.DbBase.DataInterface.Execute4DS("select id,name from college").Tables(0)
        Dim tnRoot As TreeNode = tvStudent.Nodes(0)
        Dim tnCollege As TreeNode
        For Each drTemp As DataRow In dtTemp.Rows
            tnCollege = New TreeNode(drTemp(1), 1, 1)
            tnCollege.Tag = drTemp(0)
            tnRoot.Nodes.Add(tnCollege)
        Next
        tvStudent.ExpandAll()
    End Sub    '初始化窗体    Protected Overrides Sub Init()        Me.Text = "学院管理"
        lblCaption.Text = "学院管理 College"
        btnOk.Text = "确认"
        btnCancel.Text = "重置"
        tvStudent.ContextMenu = cmCollege

        Me.btnOk.Enabled = False
    End Sub    Protected Overrides Sub OK()        If GetControl() Then
            Me.m_oCollege.Update()
            InitTreeView()
            Me.btnOk.Enabled = False
            MessageBox.Show("学院更新成功!")
        End If
    End Sub    Protected Overrides Sub Cancel()        'MessageBox.Show("Cancel")
        SetControl()
    End Sub    Protected Overrides Sub FormClose()        Me.m_oCollege = Nothing
    End Sub    Protected Overrides Sub SelectNode()        '
    End Sub    Private Sub miAddCollege_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles miAddCollege.Click
        Me.m_oCollege = New College
        SetControl()
        btnOk.Enabled = True
    End Sub

    Private Sub miEditCollege_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles miEditCollege.Click
        Me.m_oCollege = New College(CInt(tvStudent.SelectedNode.Tag))
        SetControl()
        btnOk.Enabled = True
    End Sub

    Private Sub cmCollege_Popup(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmCollege.Popup
        If tvStudent.SelectedNode.ImageIndex < 1 Then
            miEditCollege.Visible = False
        Else
            miEditCollege.Visible = True
        End If
    End Sub
End Class

⌨️ 快捷键说明

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