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

📄 frmmarjoy.vb

📁 代码:是由本人自主开发完成的
💻 VB
📖 第 1 页 / 共 2 页
字号:
        Me.Controls.Add(Me.gbDepName)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
        Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
        Me.MaximizeBox = False
        Me.Name = "frmmarjoy"
        Me.Text = "专业信息管理"
        Me.gbDepName.ResumeLayout(False)
        Me.GroupBox1.ResumeLayout(False)
        CType(Me.DGMarjoy, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub

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

    Private Sub frmmarjoy_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        MyDep.Initials()
        CurDep.Initials()
        MyMar.Initials()
        CurMar.Initials()
        MyDep.LoadDepNodesToTV(TvDepartment)
    End Sub
 
    Private Sub TvDepartment_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TvDepartment.MouseDown
        TvDepartment.SelectedNode = TvDepartment.GetNodeAt(e.X, e.Y)
        If Not TvDepartment.SelectedNode Is Nothing Then
            If CurDep.DepartmentName = TvDepartment.SelectedNode.Text Then
                Exit Sub
            End If
            MyDep.GetDepInfo(MakeStr(TvDepartment.SelectedNode.Text))
            CurDep.Equal(MyDep)
            depdbset = Nothing
            depdbset = MyDep.GetMarjoys(CurDep.DepartmentID)
            If Not (depdbset Is Nothing) Then
                DGMarjoy.DataSource = depdbset.Tables(0).DefaultView
                DGMarjoy.CaptionText = "[ " & CurDep.DepartmentName & " ]" & _
                                       "总共有[ " & depdbset.Tables(0).Rows.Count & " ]个专业"
            Else
                DGMarjoy.DataSource = Nothing
                DGMarjoy.CaptionText = "[ " & CurDep.DepartmentName & " ]" & _
                                       "总共有[ " & Trim("0") & " ]个专业"
            End If
            gbDepName.Text = "院系信息--当前院系:[ " & CurDep.DepartmentName & " ]"
            txtMarName.Text = ""
        Else
            CurDep.Initials()
            DGMarjoy.DataSource = Nothing
            DGMarjoy.CaptionText = "专业信息"
            gbDepName.Text = "院系信息--当前院系:[]"
            txtMarName.Text = ""
        End If
    End Sub

    Private Sub DGMarjoy_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DGMarjoy.CurrentCellChanged
        If DGMarjoy.Item(DGMarjoy.CurrentRowIndex, 0) Is Nothing Then
            txtMarName.Text = ""
            Exit Sub
        End If
        MyMar.MarjoyName = DGMarjoy.Item(DGMarjoy.CurrentRowIndex, 1)
        MyMar.MarjoyID = DGMarjoy.Item(DGMarjoy.CurrentRowIndex, 0)
        MyMar.DepartmentID = DGMarjoy.Item(DGMarjoy.CurrentRowIndex, 2)
        CurMar.Equal(MyMar)
        txtMarName.Text = DGMarjoy.Item(DGMarjoy.CurrentRowIndex, 1)
    End Sub

    Private Sub DGMarjoy_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DGMarjoy.Click
        If DGMarjoy.CurrentRowIndex < 0 Then
            txtMarName.Text = ""
            Exit Sub
        End If
        MyMar.MarjoyName = DGMarjoy.Item(DGMarjoy.CurrentRowIndex, 1)
        MyMar.MarjoyID = DGMarjoy.Item(DGMarjoy.CurrentRowIndex, 0)
        MyMar.DepartmentID = DGMarjoy.Item(DGMarjoy.CurrentRowIndex, 2)
        CurMar.Equal(MyMar)
        txtMarName.Text = DGMarjoy.Item(DGMarjoy.CurrentRowIndex, 1)
    End Sub

    Private Sub cmdADD_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdADD.Click
        If Trim(txtMarName.Text) = "" Then
            txtMarName.Focus()
            Exit Sub
        End If
        If CurDep.DepartmentID <= 0 Then
            Exit Sub
        End If
        If MyMar.IsInDB(MakeStr(txtMarName.Text), CurDep.DepartmentID) Then
            MsgBox("专业[ " & txtMarName.Text & " ]已经存在", MsgBoxStyle.Exclamation, "大学语文考试系统V2.0")
            txtMarName.Text = ""
            txtMarName.Focus()
            Exit Sub
        End If
        MyMar.MarjoyID = MyMar.GetNewID
        MyMar.MarjoyName = Trim(txtMarName.Text)
        MyMar.DepartmentID = CurDep.DepartmentID
        If MyMar.InsertDB() Then
            CurMar.Equal(MyMar)
            depdbset = Nothing
            depdbset = MyDep.GetMarjoys(CurDep.DepartmentID)
            If Not (depdbset Is Nothing) Then
                DGMarjoy.DataSource = depdbset.Tables(0).DefaultView
                DGMarjoy.CaptionText = "[ " & CurDep.DepartmentName & " ]" & _
                                       "总共有[ " & depdbset.Tables(0).Rows.Count & " ]个专业"
            Else
                DGMarjoy.DataSource = Nothing
                DGMarjoy.CaptionText = "[ " & CurDep.DepartmentName & " ]" & _
                                       "总共有[ " & Trim("0") & " ]个专业"
            End If
        End If
    End Sub

    Private Sub cmdModify_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdModify.Click
        If Trim(txtMarName.Text) = "" Then
            txtMarName.Focus()
            Exit Sub
        End If
        If CurDep.DepartmentID <= 0 Then
            Exit Sub
        End If
        If Trim(txtMarName.Text) = CurMar.MarjoyName Then
            Exit Sub
        End If
        If MyMar.IsInDB(MakeStr(txtMarName.Text), CurDep.DepartmentID) Then
            MsgBox("专业[ " & txtMarName.Text & " ]已经存在", MsgBoxStyle.Exclamation, "大学语文考试系统V2.0")
            txtMarName.Text = ""
            txtMarName.Focus()
            Exit Sub
        End If
        MyMar.Equal(CurMar)
        MyMar.MarjoyName = Trim(txtMarName.Text)
        If MsgBox("您是否真的要修改该院系信息?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "大学语文考试系统V2.0") = MsgBoxResult.Yes Then
            If MyMar.ModifyDB() Then
                CurMar.Equal(MyMar)
                DGMarjoy.Item(DGMarjoy.CurrentRowIndex, 1) = CurMar.MarjoyName
            End If
        End If
    End Sub

    Private Sub cmdDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDelete.Click
        If Trim(txtMarName.Text) = "" Then
            Exit Sub
        End If
        If CurDep.DepartmentID <= 0 Then
            Exit Sub
        End If
        If CurMar.MarjoyID <= 0 Then
            Exit Sub
        End If
        If MyMar.HaveStudents(CurMar.MarjoyID) Then
            MsgBox("专业[" & CurMar.MarjoyName & "]存在学生,不能删除。" & vbCrLf _
                      & "如果你要删除本专业,请确保该专业没有任何的学生。", MsgBoxStyle.Exclamation, "大学语文考试系统V2.0")
            Exit Sub
        End If
        If CurMar.DeleteDB() Then
            depdbset = Nothing
            depdbset = MyDep.GetMarjoys(CurDep.DepartmentID)
            If Not (depdbset Is Nothing) Then
                DGMarjoy.DataSource = depdbset.Tables(0).DefaultView
                DGMarjoy.CaptionText = "[ " & CurDep.DepartmentName & " ]" & _
                                       "总共有[ " & depdbset.Tables(0).Rows.Count & " ]个专业"
            Else
                DGMarjoy.DataSource = Nothing
                DGMarjoy.CaptionText = "[ " & CurDep.DepartmentName & " ]" & _
                                       "总共有[ " & Trim("0") & " ]个专业"
            End If
            MyMar.Initials()
            txtMarName.Text = ""
        End If
    End Sub

    Private Sub cmdFresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdFresh.Click
        MyDep.Initials()
        CurDep.Initials()
        MyDep.LoadDepNodesToTV(TvDepartment)
        depdbset = Nothing
        DGMarjoy.DataSource = Nothing
        DGMarjoy.CaptionText = "专业信息"
    End Sub

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

    Private Sub frmmarjoy_Deactivate(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Deactivate
        MyDep.Initials()
        CurDep.Initials()
        MyMar.Initials()
        CurMar.Initials()
        DGMarjoy.DataSource = Nothing
        DGMarjoy.CaptionText = "专业信息"
        gbDepName.Text = "院系信息--当前院系:[]"
        txtMarName.Text = ""
    End Sub
End Class

⌨️ 快捷键说明

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