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

📄 frmclassbrower.frm

📁 学生信息管理系统
💻 FRM
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "msflxgrd.ocx"
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form frmClassBrower 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "浏览班级"
   ClientHeight    =   5115
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   10095
   LinkTopic       =   "Form2"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   5115
   ScaleWidth      =   10095
   Begin VB.CommandButton cmdDelete 
      Caption         =   "删除"
      Height          =   375
      Left            =   2040
      TabIndex        =   4
      Top             =   4560
      Width           =   975
   End
   Begin VB.CommandButton cmdModify 
      Caption         =   "修改"
      Height          =   375
      Left            =   1080
      TabIndex        =   3
      Top             =   4560
      Width           =   975
   End
   Begin VB.CommandButton cmdFind 
      Caption         =   "查找"
      Height          =   375
      Left            =   120
      TabIndex        =   2
      Top             =   4560
      Width           =   975
   End
   Begin MSComctlLib.TreeView trvClass 
      Height          =   4455
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   2895
      _ExtentX        =   5106
      _ExtentY        =   7858
      _Version        =   393217
      HideSelection   =   0   'False
      LineStyle       =   1
      Style           =   7
      HotTracking     =   -1  'True
      Appearance      =   1
   End
   Begin MSFlexGridLib.MSFlexGrid flgClassData 
      Height          =   4815
      Left            =   3000
      TabIndex        =   1
      Top             =   120
      Width           =   7005
      _ExtentX        =   12356
      _ExtentY        =   8493
      _Version        =   393216
      Cols            =   1
      BackColor       =   16777215
      BackColorFixed  =   12632256
      ForeColorFixed  =   0
      BackColorSel    =   16777215
      ForeColorSel    =   255
      BackColorBkg    =   -2147483624
      AllowBigSelection=   -1  'True
      SelectionMode   =   1
      AllowUserResizing=   3
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
   End
End
Attribute VB_Name = "frmClassBrower"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'----------------------------------frmClassBrower.frm----------------------------------
Option Explicit

'显示表格中班级名称
Public Sub ShowClassTitle()
    Dim i As Integer
    
    flgClassData.Clear
    With flgClassData
        .Cols = 8
        .TextMatrix(0, 1) = "年级"
        .TextMatrix(0, 2) = "班级"
        .TextMatrix(0, 3) = "教室"
        .TextMatrix(0, 4) = "年制"
        .TextMatrix(0, 5) = "专业"
        .TextMatrix(0, 6) = "班主任"
        .TextMatrix(0, 7) = "备注"
        .ColWidth(0) = 100
        .ColWidth(1) = 1300
        .ColWidth(2) = 1200
        .ColWidth(3) = 800
        .ColWidth(4) = 800
        .ColWidth(5) = 800
        .ColWidth(6) = 800
        .ColWidth(7) = 5000
        
        .FixedRows = 1
        
        For i = 1 To 7
          .ColAlignment(i) = 0
        Next
        
        .FillStyle = flexFillSingle
        .Col = 0
        .Row = 0
        .RowSel = 1
        .ColSel = .Cols - 1
        .CellAlignment = 4
        .Row = 1
    End With
End Sub

'显示班级数据
Public Sub ShowClassData()
    Dim i As Integer
    '声明ADODB.Recordset对象变量
    Dim objRecordset As ADODB.Recordset
    
    Set objRecordset = ExecuteSQL(Trim(strSQL))
    
    '如果有数据,将数据库中的班级数据显示在表格中
    If objRecordset.EOF = False Then
        objRecordset.MoveFirst
        With flgClassData
            .Rows = 1
            Do While Not objRecordset.EOF
                .Rows = .Rows + 1
                For i = 1 To objRecordset.Fields.Count
                    .TextMatrix(.Rows - 1, i) = objRecordset.Fields(i - 1)
                Next
                objRecordset.MoveNext
            Loop
            objRecordset.Close
        End With
    '如果没有数据,
    Else
        If blnFindClass = True Then
            frmClassBrower.Hide
            frmClassFind.Show
            MsgBox "对不起,没有此班级的档案记录!", vbOKOnly, "查询"
            frmClassFind.ZOrder (0)
            frmClassFind.txtClass(0).SetFocus
        End If
    End If
End Sub

'删除
Private Sub cmdDelete_Click()
    '声明ADODB.Recordset对象变量
    Dim objRecordset As ADODB.Recordset
        
    strUserManage = UserManage(2)
    If strUserManage = "ReadOnly" Then
        MsgBox "对不起,你是只读用户不能删除记录,请与管理员联系!", vbInformation + vbOKOnly, " 警告"
        Exit Sub
    End If
    
    If Trim(flgClassData.TextMatrix(flgClassData.Row, 1)) = "" Then
        MsgBox "你还没有选择记录!", vbOKOnly + vbExclamation, "警告"
        Exit Sub
    End If
    
    If MsgBox("确定要删除班级为 " & Trim(Me.flgClassData.TextMatrix(flgClassData.Row, 2)) & " 的记录吗?" & Chr(13) _
        & Chr(10) & "继续会导致该班级在成绩记录的数据丢失,继续吗?", vbOKCancel + vbExclamation, "警告") = vbOK Then
        strSQL = "delete * from Documents where 班级='" & Trim(Me.flgClassData.TextMatrix(flgClassData.Row, 2)) & "'"
        
        Set objRecordset = ExecuteSQL(strSQL)
        '删除在成绩表中的所有该班级的记录
        strSQL = "select * from Scores where 学号 in (select from Documents where 班级='" & Trim(Me.flgClassData.TextMatrix(flgClassData.Row, 2)) & "')"
        
        Set objRecordset = ExecuteSQL(strSQL)
        '删除该班级的记录
        strSQL = "delete * from Classes where 班级='" & Trim(Me.flgClassData.TextMatrix(flgClassData.Row, 2)) & "'"
        
        Set objRecordset = ExecuteSQL(strSQL)
    End If
    
    '显示表格中班级名称
    ShowClassTitle
    '显示班级数据
    ShowClassData
End Sub

'查找
Private Sub cmdFind_Click()
    frmClassFind.Show
End Sub

'修改
Private Sub cmdModify_Click()
    On Error GoTo ErroeTrap
    
    If Trim(flgClassData.TextMatrix(flgClassData.Row, 1)) = "" Then
        MsgBox "你还没有选择记录!", vbOKOnly + vbExclamation, "警告"
        Exit Sub
    Else
        strUserManage = UserManage(2)
        If strUserManage = "ReadOnly" Then
            MsgBox "对不起,你是只读用户不能修改记录,请与管理员联系!", vbInformation + vbOKOnly, " 警告"
            Exit Sub
        End If
        
        '显示班级修改界面
        blnModifyClass = True
        frmClassModify.Show
        frmClassModify.ClassLoad
        frmClassModify.ZOrder 0
    End If
    Exit Sub
    
ErroeTrap:
End Sub

'当窗体活动时初始化控件
Private Sub Form_Activate()
    If blnFindClass = True Then
        frmClassFind.ZOrder 0
        Exit Sub
    ElseIf blnModifyClass = True Then
        ShowClassData
        blnModifyClass = False
    Else
        ClassTree
    End If
End Sub

'使用TreeView控件显示班级名称
Public Sub ClassTree()
    Dim objNode As Node
    Dim objRecordset As ADODB.Recordset
    Dim objSubRecordset As ADODB.Recordset
    Dim strSQL As String
    Dim strClass As String
    
    trvClass.Nodes.Clear
    
    '显示根节点
    strClass = "年级"
    trvClass.LineStyle = tvwRootLines
    '查询年级
    strSQL = "select distinct 年级 from Classes order by 年级"
    Set objRecordset = ExecuteSQL(strSQL)
    '查询班级
    strSQL = "select distinct 年级,班级 from Classes order by 年级,班级"
    Set objSubRecordset = ExecuteSQL(strSQL)
    
    objRecordset.MoveFirst
    '将班级信息添加到TreeView控件中
    Do Until objRecordset.EOF
        objSubRecordset.MoveFirst
        Set objNode = trvClass.Nodes.Add(, , strClass, objRecordset.Fields(0))
        
        Do While Not objSubRecordset.EOF
            If objSubRecordset.Fields(0) = objRecordset.Fields(0) Then
                Set objNode = trvClass.Nodes.Add(strClass, tvwChild, , objSubRecordset.Fields(1))
            End If
            objSubRecordset.MoveNext
        Loop
        
        strClass = strClass & "1"
        objRecordset.MoveNext
    Loop
    
    objSubRecordset.Close
    objRecordset.Close
    Set objRecordset = Nothing
    Set objSubRecordset = Nothing
End Sub

'双击TreeView控件显示班级具体信息
Private Sub trvClass_DblClick()
    On Error GoTo ErrorTrap
    
    If trvClass.SelectedItem.Index = 0 Then
        flgClassData.Clear
        Exit Sub
    End If
    
    strSQL = trvClass.Nodes.Item(trvClass.SelectedItem.Index)
    strSQL = " select * from Classes where 年级='" & Trim(strSQL) & "' or 班级='" & Trim(strSQL) & "' order by 年级 ,班级 "
'    printstr = strSQL
    
    Me.ShowClassTitle
    Me.ShowClassData
    Exit Sub
    
ErrorTrap:
    flgClassData.Clear
End Sub

⌨️ 快捷键说明

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