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

📄 formprofession.vb

📁 学生信息管理系统
💻 VB
字号:
Imports CommonDB
Public Class FormProfession    Inherits FormBase    Private m_oProfession As Profession#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 lblCollege As System.Windows.Forms.Label
    Friend WithEvents lblName As System.Windows.Forms.Label
    Friend WithEvents lblIntro As System.Windows.Forms.Label
    Friend WithEvents cmbCollege As System.Windows.Forms.ComboBox
    Friend WithEvents txtName As System.Windows.Forms.TextBox
    Friend WithEvents txtIntro As System.Windows.Forms.TextBox
    Friend WithEvents cmProfession As ContextMenu
    Friend WithEvents miAddProfession As MenuItem
    Friend WithEvents miEditProfession As MenuItem
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()        Me.lblCollege = New System.Windows.Forms.Label
        Me.lblName = New System.Windows.Forms.Label
        Me.lblIntro = New System.Windows.Forms.Label
        Me.cmbCollege = New System.Windows.Forms.ComboBox
        Me.txtName = New System.Windows.Forms.TextBox
        Me.txtIntro = New System.Windows.Forms.TextBox
        Me.cmProfession = New ContextMenu
        Me.miAddProfession = New MenuItem
        Me.miEditProfession = New MenuItem

        '
        'lblCollege
        '
        Me.lblCollege.AutoSize = True
        Me.lblCollege.Location = New System.Drawing.Point(40, 40)
        Me.lblCollege.Name = "lblCollege"
        Me.lblCollege.Size = New System.Drawing.Size(54, 17)
        Me.lblCollege.TabIndex = 0
        Me.lblCollege.Text = "所属学院"
        '
        'lblName
        '
        Me.lblName.AutoSize = True
        Me.lblName.Location = New System.Drawing.Point(40, 80)
        Me.lblName.Name = "lblName"
        Me.lblName.Size = New System.Drawing.Size(54, 17)
        Me.lblName.TabIndex = 1
        Me.lblName.Text = "专业名称"
        '
        'lblIntro
        '
        Me.lblIntro.AutoSize = True
        Me.lblIntro.Location = New System.Drawing.Point(40, 120)
        Me.lblIntro.Name = "lblIntro"
        Me.lblIntro.Size = New System.Drawing.Size(54, 17)
        Me.lblIntro.TabIndex = 2
        Me.lblIntro.Text = "专业介绍"
        'me
        'cmbCollege
        '
        Me.cmbCollege.Location = New System.Drawing.Point(96, 32)
        Me.cmbCollege.Name = "cmbCollege"
        Me.cmbCollege.Size = New System.Drawing.Size(280, 20)
        Me.cmbCollege.TabIndex = 3
        Me.cmbCollege.Text = "请选择"
        '
        'txtName
        '
        Me.txtName.Location = New System.Drawing.Point(96, 72)
        Me.txtName.Name = "txtName"
        Me.txtName.Size = New System.Drawing.Size(280, 21)
        Me.txtName.TabIndex = 4
        Me.txtName.Text = ""
        '
        'txtIntro
        '
        Me.txtIntro.Location = New System.Drawing.Point(96, 112)
        Me.txtIntro.Multiline = True
        Me.txtIntro.Name = "txtIntro"
        Me.txtIntro.Size = New System.Drawing.Size(280, 176)
        Me.txtIntro.TabIndex = 5
        Me.txtIntro.Text = ""
        '
        'cmProfession
        '
        Me.cmProfession.MenuItems.Add(miAddProfession)
        Me.cmProfession.MenuItems.Add(miEditProfession)
        '
        'miAddProfession
        '
        Me.miAddProfession.Index = 0
        Me.miAddProfession.Text = "添加专业"
        '
        'miEditProfession
        '
        Me.miEditProfession.Index = 1
        Me.miEditProfession.Text = "修改专业"
        '
        'AddControls to Groupbox1,so they can show in the FormBase
        AddControls()
        '
        'FormProfession
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(640, 461)
        Me.Name = "FormProfession"
    End Sub#End Region    Private Sub AddControls()        Me.GroupBox1.Controls.Add(Me.lblCollege)
        Me.GroupBox1.Controls.Add(Me.lblName)
        Me.GroupBox1.Controls.Add(Me.lblIntro)
        Me.GroupBox1.Controls.Add(Me.cmbCollege)
        Me.GroupBox1.Controls.Add(Me.txtName)
        Me.GroupBox1.Controls.Add(Me.txtIntro)
    End Sub    '读取窗体各控件值,并设置m_oProfession对象实例相应属性    Private Function GetControl() As Boolean
        If Object.Equals(Me.m_oProfession, Nothing) Then
            GetControl = False
        Else
            '读取控件值
            Me.m_oProfession.Name = Me.txtName.Text
            Me.m_oProfession.Intro = Me.txtIntro.Text
            Me.m_oProfession.CollegeId = Me.cmbCollege.SelectedValue
            GetControl = True
        End If
    End Function    '根据m_oProfession对象实例的属性设置窗体各控件值    Private Function SetControl() As Boolean        If Object.Equals(Me.m_oProfession, Nothing) Then
            SetControl = False
        Else
            '设置控件值
            Me.txtName.Text = Me.m_oProfession.Name
            Me.txtIntro.Text = Me.m_oProfession.Intro
            Me.cmbCollege.SelectedValue = Me.m_oProfession.CollegeId
            SetControl = True
        End If
    End Function    '初始化TreeView    Protected Overrides Sub InitTreeView()        '清空节点
        Me.tvStudent.Nodes(0).Nodes.Clear()
        '添加右键菜单
        Me.tvStudent.ContextMenu = Me.cmProfession
        '填充节点
        Dim dtTemp As DataTable = CommonDB.DbBase.DataInterface.Execute4DS("select college_id,college_name,id,name from v_profession order by college_id").Tables(0)
        Dim tnRoot As TreeNode = tvStudent.Nodes(0)
        Dim iCurrentCollege As Integer = 0
        Dim tnCollege, tnProfession As TreeNode
        For Each drTemp As DataRow In dtTemp.Rows
            If iCurrentCollege = drTemp(0) Then
                tnProfession = New TreeNode(drTemp(3), 2, 2)
                tnProfession.Tag = drTemp(2)
                tnCollege.Nodes.Add(tnProfession)
            Else
                tnCollege = New TreeNode(drTemp(1), 1, 1)
                tnCollege.Tag = drTemp(0)
                tnRoot.Nodes.Add(tnCollege)
                iCurrentCollege = drTemp(0)
            End If
        Next
        tvStudent.ExpandAll()
    End Sub    '初始化窗体    Protected Overrides Sub Init()        Me.Text = "专业管理"
        lblCaption.Text = "专业管理 Profession"
        btnOk.Text = "确认"
        btnCancel.Text = "重置"
        '填充cmbCollege
        cmbCollege.Items.Clear()
        cmbCollege.DisplayMember = "name"
        cmbCollege.ValueMember = "id"
        cmbCollege.DataSource = DbBase.DataInterface.Execute4DS("select id,name from college").Tables(0).DefaultView
        Me.btnOk.Enabled = False
    End Sub    Protected Overrides Sub OK()        If GetControl() Then
            Me.m_oProfession.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_oProfession = Nothing
    End Sub    Protected Overrides Sub SelectNode()        '
    End Sub    Private Sub cmProfession_Popup(ByVal sender As Object, ByVal e As EventArgs) Handles cmProfession.Popup        If tvStudent.SelectedNode.ImageIndex = 1 Then
            miAddProfession.Visible = True
            miEditProfession.Visible = False
        ElseIf tvStudent.SelectedNode.ImageIndex = 2 Then
            miAddProfession.Visible = False
            miEditProfession.Visible = True
        Else
            miEditProfession.Visible = False
            miAddProfession.Visible = False
        End If
    End Sub    Private Sub miAddProfessin_Click(ByVal sender As Object, ByVal e As EventArgs) Handles miAddProfession.Click
        Me.m_oProfession = New Profession
        Me.m_oProfession.CollegeId = tvStudent.SelectedNode.Tag
        SetControl()
        btnOk.Enabled = True
    End Sub    Private Sub miEditProfession_Click(ByVal sender As Object, ByVal e As EventArgs) Handles miEditProfession.Click
        Me.m_oProfession = New Profession(CInt(tvStudent.SelectedNode.Tag))
        SetControl()
        btnOk.Enabled = True
    End SubEnd Class

⌨️ 快捷键说明

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