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

📄 frmstu.vb

📁 代码:是由本人自主开发完成的
💻 VB
📖 第 1 页 / 共 3 页
字号:
    End Sub

    Private Sub LbMarjoy_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LbMarjoy.SelectedIndexChanged
        If CurDep.DepartmentID <= 0 Then
            Exit Sub
        End If
        If CombEnterTime.Text = "" Then
            Exit Sub
        End If
        MyMar.MarjoyName = LbMarjoy.SelectedItem()
        GbMarjoy.Text = "专业信息--当前专业[" & Trim(MyMar.MarjoyName) & "]"
        MyMar.GetMarInfo(MyMar.MarjoyName, CurDep.DepartmentID)
        CurMar.Equal(MyMar)
        studbset = MyStu.GetStudentsByMar(CurMar.MarjoyID, CombEnterTime.Text)
        If Not studbset Is Nothing Then
            DGStudent.DataSource = studbset.Tables(0).DefaultView
            DGStudent.CaptionText = "学生信息--当前条件下总共有[ " & Trim(Str(studbset.Tables(0).Rows.Count)) & " ]条记录"
            txtStuName.Text = DGStudent.Item(0, 1)
            txtStuID.Text = DGStudent.Item(0, 2)
            combSexy.Text = DGStudent.Item(0, 3)
            txtDepartment.Text = DGStudent.Item(0, 4)
            txtMarjoy.Text = DGStudent.Item(0, 5)
        Else
            DGStudent.DataSource = Nothing
            DGStudent.CaptionText = "学生信息--没有学生记录"
        End If
    End Sub

    Private Sub CombEnterTime_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CombEnterTime.SelectedIndexChanged
        If CurDep.DepartmentID <= 0 Then
            Exit Sub
        End If
        If CurMar.MarjoyID <= 0 Then
            Exit Sub
        End If
        studbset = MyStu.GetStudentsByMar(CurMar.MarjoyID, CombEnterTime.Text)
        If Not studbset Is Nothing Then
            DGStudent.DataSource = studbset.Tables(0).DefaultView
            DGStudent.CaptionText = "学生信息--当前条件下总共有[ " & Trim(Str(studbset.Tables(0).Rows.Count)) & " ]条记录"
            txtStuName.Text = DGStudent.Item(0, 1)
            txtStuID.Text = DGStudent.Item(0, 2)
            combSexy.Text = DGStudent.Item(0, 3)
            txtDepartment.Text = DGStudent.Item(0, 4)
            txtMarjoy.Text = DGStudent.Item(0, 5)
        Else
            DGStudent.DataSource = Nothing
            DGStudent.CaptionText = "学生信息--没有学生记录"
        End If
    End Sub
    Private Sub DGStudent_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DGStudent.Click
        If DGStudent.CurrentRowIndex < 0 Then
            clearform()
            Exit Sub
        End If
        UpdatedData(False)
        SaveFlag = "取消"
        txtStuName.Text = DGStudent.Item(DGStudent.CurrentRowIndex, 1)
        txtStuID.Text = DGStudent.Item(DGStudent.CurrentRowIndex, 2)
        combSexy.Text = DGStudent.Item(DGStudent.CurrentRowIndex, 3)
        txtDepartment.Text = DGStudent.Item(DGStudent.CurrentRowIndex, 4)
        txtMarjoy.Text = DGStudent.Item(DGStudent.CurrentRowIndex, 5)
        MyStu.GetStuInfo(Trim(txtStuID.Text))
        CurStu.Equal(MyStu)
    End Sub

    Private Sub DGStudent_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DGStudent.CurrentCellChanged
        If DGStudent.Item(DGStudent.CurrentRowIndex, 0) Is Nothing Then
            Exit Sub
        End If
        UpdatedData(False)
        SaveFlag = "取消"
        txtStuName.Text = DGStudent.Item(DGStudent.CurrentRowIndex, 1)
        txtStuID.Text = DGStudent.Item(DGStudent.CurrentRowIndex, 2)
        combSexy.Text = DGStudent.Item(DGStudent.CurrentRowIndex, 3)
        txtDepartment.Text = DGStudent.Item(DGStudent.CurrentRowIndex, 4)
        txtMarjoy.Text = DGStudent.Item(DGStudent.CurrentRowIndex, 5)
        MyStu.GetStuInfo(Trim(txtStuID.Text))
        CurStu.Equal(MyStu)
    End Sub

    Private Sub cmdAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAdd.Click
        If CurMar.MarjoyID <= 0 Then
            MsgBox("请选择当前要操作的院系与专业!", MsgBoxStyle.Exclamation, "大学语文考试系统V2.0")
            Exit Sub
        End If
        clearform()
        UpdatedData(True)
        SaveFlag = "添加"
    End Sub

    Private Sub cmdModify_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdModify.Click
        If CurMar.MarjoyID <= 0 Then
            MsgBox("请选择当前要操作的院系与专业!", MsgBoxStyle.Exclamation, "大学语文考试系统V2.0")
            Exit Sub
        End If
        UpdatedData(True)
        SaveFlag = "修改"
    End Sub

    Private Sub cmdCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCancel.Click
        UpdatedData(False)
        SaveFlag = "取消"
        txtStuName.Text = CurStu.StudentName
        txtStuID.Text = CurStu.StudentCardID
        combSexy.Text = CurStu.Sexy
        txtDepartment.Text = CurDep.DepartmentName
        txtMarjoy.Text = CurMar.MarjoyName
    End Sub

    Private Sub cmdDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDelete.Click
        If SaveFlag = "取消" Then
            If MsgBox("您是否真的要删除该学生的信息", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "大学语文考试系统V2.0") = MsgBoxResult.Yes Then
                If CurStu.StudentID > 0 Then
                    Dim tempstuid As Integer
                    tempstuid = CurStu.StudentID
                    If CurStu.DeleteDB() Then
                        MyGrade.DeleteGradeByStu(tempstuid)
                        studbset = MyStu.GetStudentsByMar(CurMar.MarjoyID, CombEnterTime.Text)
                        If Not studbset Is Nothing Then
                            DGStudent.DataSource = studbset.Tables(0).DefaultView
                            DGStudent.CaptionText = "学生信息--当前条件下总共有[ " & Trim(Str(studbset.Tables(0).Rows.Count)) & " ]条记录"
                            txtStuName.Text = DGStudent.Item(0, 1)
                            txtStuID.Text = DGStudent.Item(0, 2)
                            combSexy.Text = DGStudent.Item(0, 3)
                            txtDepartment.Text = DGStudent.Item(0, 4)
                            txtMarjoy.Text = DGStudent.Item(0, 5)
                            MyStu.GetStuInfo(Trim(txtStuID.Text))
                            CurStu.Equal(MyStu)
                        Else
                            DGStudent.DataSource = Nothing
                            DGStudent.CaptionText = "学生信息--没有学生记录"
                            CurStu.Initials()
                        End If
                    End If
                End If
            End If
        End If
    End Sub

    Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSave.Click
        If SaveFlag = "添加" Then
            If Trim(txtStuName.Text) = "" Then
                MsgBox("姓名不能为空!", MsgBoxStyle.Exclamation, "大学语文考试系统V2.0")
                txtStuName.Focus()
                Exit Sub
            End If
            If Trim(txtStuID.Text) = "" Then
                MsgBox("学号不能为空!", MsgBoxStyle.Exclamation, "大学语文考试系统V2.0")
                txtStuID.Focus()
                Exit Sub
            End If
            If MyStu.IsInDB(MakeStr(txtStuID.Text)) Then
                MsgBox("学号[" & Trim(txtStuID.Text) & "]已经存在!不能重复插入", MsgBoxStyle.Exclamation, "大学语文考试系统V2.0")
                txtStuID.Text = ""
                txtStuID.Focus()
                Exit Sub
            End If
            MyStu.StudentID = MyStu.GetNewID()
            MyStu.StudentName = Trim(txtStuName.Text)
            MyStu.StudentCardID = Trim(txtStuID.Text)
            MyStu.Sexy = Trim(combSexy.Text)
            MyStu.MarjoyID = CurMar.MarjoyID
            If MyStu.InsertDB() Then
                UpdatedData(False)
                studbset = MyStu.GetStudentsByMar(CurMar.MarjoyID, CombEnterTime.Text)
                If Not studbset Is Nothing Then
                    DGStudent.DataSource = studbset.Tables(0).DefaultView
                    DGStudent.CaptionText = "学生信息--当前条件下总共有[ " & Trim(Str(studbset.Tables(0).Rows.Count)) & " ]条记录"
                    txtStuName.Text = DGStudent.Item(0, 1)
                    txtStuID.Text = DGStudent.Item(0, 2)
                    combSexy.Text = DGStudent.Item(0, 3)
                    txtDepartment.Text = DGStudent.Item(0, 4)
                    txtMarjoy.Text = DGStudent.Item(0, 5)
                    MyStu.GetStuInfo(Trim(txtStuID.Text))
                    CurStu.Equal(MyStu)
                Else
                    DGStudent.DataSource = Nothing
                    DGStudent.CaptionText = "学生信息--没有学生记录"
                    CurStu.Initials()
                End If
                SaveFlag = "取消"
            Else
                UpdatedData(False)
                txtStuName.Text = CurStu.StudentName
                txtStuID.Text = CurStu.StudentCardID
                combSexy.Text = CurStu.Sexy
                SaveFlag = "取消"
            End If
            Exit Sub
        End If
        If SaveFlag = "修改" Then
            If Trim(txtStuName.Text) = "" Then
                MsgBox("姓名不能为空!", MsgBoxStyle.Exclamation, "大学语文考试系统V2.0")
                txtStuName.Focus()
                Exit Sub
            End If
            If Trim(txtStuID.Text) = "" Then
                MsgBox("学号不能为空!", MsgBoxStyle.Exclamation, "大学语文考试系统V2.0")
                txtStuID.Focus()
                Exit Sub
            End If
            If Trim(txtStuID.Text) <> CurStu.StudentCardID Then
                If MyStu.IsInDB(MakeStr(txtStuID.Text)) Then
                    MsgBox("学号[" & Trim(txtStuID.Text) & "]已经存在!不能重复插入", MsgBoxStyle.Exclamation, "大学语文考试系统V2.0")
                    txtStuID.Text = CurStu.StudentCardID
                    txtStuID.Focus()
                    Exit Sub
                End If
            End If
            MyStu.Equal(CurStu)
            MyStu.StudentCardID = Trim(txtStuID.Text)
            MyStu.StudentName = Trim(txtStuName.Text)
            MyStu.Sexy = Trim(combSexy.Text)
            If MyStu.ModifyDB() Then
                CurStu.Equal(MyStu)
                If Not DGStudent.Item(DGStudent.CurrentRowIndex, 0) Is Nothing Then
                    DGStudent.Item(DGStudent.CurrentRowIndex, 1) = CurStu.StudentName
                    DGStudent.Item(DGStudent.CurrentRowIndex, 2) = CurStu.StudentCardID
                    DGStudent.Item(DGStudent.CurrentRowIndex, 3) = CurStu.Sexy
                End If
            Else
                MyStu.Initials()
            End If
            UpdatedData(False)
            SaveFlag = "取消"
        End If
    End Sub

    Private Sub cmdQuery_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdQuery.Click
        If Trim(txtquery.Text) = "" Then
            Exit Sub
        Else
            studbset = Nothing
            studbset = MyStu.QueryStu(txtquery.Text)
            clearform()
            txtMarjoy.Text = ""
            txtDepartment.Text = ""
            UpdatedData(False)
            If studbset Is Nothing Then
                DGStudent.DataSource = Nothing
                DGStudent.CaptionText = "学生信息--没有学生记录"
            Else
                DGStudent.DataSource = studbset.Tables(0).DefaultView
                DGStudent.CaptionText = "学生信息--当前条件下总共有[ " & Trim(Str(studbset.Tables(0).Rows.Count)) & " ]条记录"
                txtStuName.Text = DGStudent.Item(0, 1)
                txtStuID.Text = DGStudent.Item(0, 2)
                combSexy.Text = DGStudent.Item(0, 3)
                txtDepartment.Text = DGStudent.Item(0, 4)
                txtMarjoy.Text = DGStudent.Item(0, 5)
            End If
        End If
    End Sub

    Private Sub cmdFlash_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdFlash.Click
        MyDep.Initials()
        CurDep.Initials()
        MyMar.Initials()
        CurMar.Initials()
        MyStu.Initials()
        CurStu.Initials()
        clearform()
        txtMarjoy.Text = ""
        UpdatedData(False)
        MyDep.LoadDepNodesToTV(TvDep)
        LbMarjoy.Items.Clear()
        DGStudent.DataSource = Nothing
        DGStudent.CaptionText = "学生信息--没有学生记录"
        GbDepartment.Text = "院系信息--当前院系:[]"
        GbMarjoy.Text = "专业信息--当前专业[]"

    End Sub

    Private Sub frmstu_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
        MyDep.Initials()
        CurDep.Initials()
        MyMar.Initials()
        CurMar.Initials()
        MyStu.Initials()
        CurStu.Initials()
        studbset = Nothing
    End Sub

    Private Sub frmstu_Deactivate(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Deactivate
        MyDep.Initials()
        CurDep.Initials()
        MyMar.Initials()
        CurMar.Initials()
        MyStu.Initials()
        CurStu.Initials()
        DGStudent.DataSource = Nothing
        DGStudent.CaptionText = "学生信息--没有学生记录"
        GbDepartment.Text = "院系信息--当前院系:[]"
        GbMarjoy.Text = "专业信息--当前专业[]"
        clearform()
        studbset = Nothing
    End Sub
End Class

⌨️ 快捷键说明

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