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

📄 frmqueryresult.frm

📁 一个功能强大、程序条理分明的学生学籍管理系统
💻 FRM
📖 第 1 页 / 共 2 页
字号:
VERSION 5.00
Object = "{65E121D4-0C60-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCHRT20.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Object = "{BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0"; "TABCTL32.OCX"
Begin VB.Form frmQueryResult 
   Caption         =   "成绩查询结果"
   ClientHeight    =   6810
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   9975
   LinkTopic       =   "Form2"
   MDIChild        =   -1  'True
   ScaleHeight     =   6810
   ScaleWidth      =   9975
   WindowState     =   2  'Maximized
   Begin TabDlg.SSTab sstabScore 
      Height          =   6735
      Left            =   0
      TabIndex        =   0
      Top             =   0
      Width           =   9855
      _ExtentX        =   17383
      _ExtentY        =   11880
      _Version        =   393216
      Tabs            =   2
      TabsPerRow      =   2
      TabHeight       =   970
      TabCaption(0)   =   " 浏览查询结果"
      TabPicture(0)   =   "frmQueryResult.frx":0000
      Tab(0).ControlEnabled=   -1  'True
      Tab(0).Control(0)=   "dgrQueryScore"
      Tab(0).Control(0).Enabled=   0   'False
      Tab(0).Control(1)=   "framOperGroup"
      Tab(0).Control(1).Enabled=   0   'False
      Tab(0).ControlCount=   2
      TabCaption(1)   =   " 图表显示"
      TabPicture(1)   =   "frmQueryResult.frx":0452
      Tab(1).ControlEnabled=   0   'False
      Tab(1).Control(0)=   "MSChartScore"
      Tab(1).ControlCount=   1
      Begin MSChart20Lib.MSChart MSChartScore 
         Height          =   5175
         Left            =   -74880
         OleObjectBlob   =   "frmQueryResult.frx":08A4
         TabIndex        =   2
         Top             =   720
         Width           =   9495
      End
      Begin VB.Frame framOperGroup 
         Height          =   1695
         Left            =   480
         TabIndex        =   3
         Top             =   4800
         Width           =   8055
         Begin VB.CommandButton cmdPrint 
            Caption         =   "通用打印"
            Height          =   375
            Left            =   6480
            TabIndex        =   11
            Top             =   240
            Width           =   1335
         End
         Begin VB.CommandButton cmdReport 
            Caption         =   "报表打印"
            Height          =   375
            Left            =   6480
            TabIndex        =   10
            Top             =   1200
            Width           =   1335
         End
         Begin VB.CommandButton cmdAveCour 
            Caption         =   "比率图"
            Height          =   375
            Left            =   1920
            TabIndex        =   9
            Top             =   1200
            Width           =   1455
         End
         Begin VB.CommandButton cmdStudScore 
            Caption         =   "图表显示"
            Height          =   375
            Left            =   1920
            TabIndex        =   7
            Top             =   720
            Width           =   1455
         End
         Begin VB.CommandButton cmdAveScore 
            Caption         =   "平均成绩:"
            Height          =   375
            Left            =   120
            TabIndex        =   5
            Top             =   240
            Width           =   1335
         End
         Begin VB.TextBox txtAveScore 
            Enabled         =   0   'False
            Height          =   375
            Left            =   1920
            TabIndex        =   4
            Top             =   240
            Width           =   1455
         End
         Begin VB.Label lblAveCour 
            Caption         =   "单科及格率:"
            Height          =   255
            Left            =   120
            TabIndex        =   8
            Top             =   1320
            Width           =   1335
         End
         Begin VB.Label lblStudScore 
            Caption         =   "学生个人成绩图:"
            Height          =   255
            Left            =   120
            TabIndex        =   6
            Top             =   840
            Width           =   1695
         End
      End
      Begin MSDataGridLib.DataGrid dgrQueryScore 
         Height          =   3735
         Left            =   360
         TabIndex        =   1
         Top             =   720
         Width           =   8895
         _ExtentX        =   15690
         _ExtentY        =   6588
         _Version        =   393216
         AllowUpdate     =   -1  'True
         AllowArrows     =   -1  'True
         HeadLines       =   1
         RowHeight       =   15
         BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ColumnCount     =   2
         BeginProperty Column00 
            DataField       =   ""
            Caption         =   ""
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   2052
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column01 
            DataField       =   ""
            Caption         =   ""
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   2052
               SubFormatType   =   0
            EndProperty
         EndProperty
         SplitCount      =   1
         BeginProperty Split0 
            BeginProperty Column00 
            EndProperty
            BeginProperty Column01 
            EndProperty
         EndProperty
      End
   End
End
Attribute VB_Name = "frmQueryResult"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public rsQueryResult As ADODB.Recordset

Private Sub cmdAveCour_Click()
    Dim iCount As Integer
    Dim iCol As Integer, iLevel As Integer
    
    '定义三个数组,用来存放与及格率相关的数据
    '及格的人数和不及格的人数
    Dim iArray(2) As Integer
    '及格率和不及格率
    Dim dblArray(2) As Double
    '存放两个字符串,分别对应于及格和不及格
    Dim strArray(2) As String
    
    Dim strCourseName As String
    
    'iLevel变量用以存放不及格的人数,初始化为0
    iLevel = 0
    
    On Error GoTo err
    If Not (rsQueryResult.EOF And rsQueryResult.BOF) Then
        rsQueryResult.MoveLast
        rsQueryResult.MoveFirst
        
        '取得课程名称值
        strCourseName = rsQueryResult("课程名称")
        '选该门课的总人数
        iCount = rsQueryResult.RecordCount
        '算出不几个人数,可以直接用SQL语句得出
        Do While Not rsQueryResult.EOF
            If rsQueryResult("成绩") < 60 Then
                iLevel = iLevel + 1
            End If
            rsQueryResult.MoveNext
        Loop
        '为数组分别赋值
        iArray(0) = iLevel
        iArray(1) = iCount - iLevel
        
        dblArray(0) = iLevel / iCount
        dblArray(1) = 1 - iLevel / iCount
    End If
    strArray(0) = "不及格"
    strArray(1) = "及格"
    
    With MSChartScore
        '指定MSChart控件的类型为饼状图类型
        .chartType = VtChChartType2dPie
        
        '设定行数和列数
        .RowCount = 1
        .ColumnCount = 2
        .ColumnLabelCount = .ColumnCount
        
        '将系列里的第一列颜色设置为蓝色
        '分别改变边界的颜色和内部的填充颜色
        .Plot.SeriesCollection(1).DataPoints(-1).EdgePen.VtColor.Set 255, 0, 0
        .Plot.SeriesCollection(1).DataPoints(-1).Brush.FillColor.Set 255, 0, 0

        '显示图列
        .ShowLegend = True
        .Title.Text = Space(2) & "《" & Trim$(strCourseName) & "》" & "的及格率统计图表" & Space(4)
        .Title.TextLayout.HorzAlignment = VtHorizontalAlignmentCenter
    End With
    
    '写RowLabel和ColumnLabel的时候,需要指明对应的行或列,否则出错。
    With MSChartScore
        .Row = 1
        For iCol = 1 To .ColumnCount
            .Column = iCol
            .Data = dblArray(iCol - 1)
            .ColumnLabel = strArray(iCol - 1) & "人数:" & iArray(iCol - 1) & Space(1)
        Next iCol
        .RowLabel = "及格率: " & Format(1 - iLevel / iCount, ".00%")
    End With
    
    sstabScore.Tab = 1
    Exit Sub
err:
    MsgBox err.Description
End Sub

Private Sub cmdAveScore_Click()
    Dim lngSumBase As Double
    Dim lngSumScore As Double
    Dim aveScore As Double
    lngSumBase = 0
    lngSumScore = 0
    aveScore = 0
    
    If Not (rsQueryResult.EOF And rsQueryResult.BOF) Then
        rsQueryResult.MoveFirst
    End If
    
    '完全可以通过一个SQL语句来完成下列循环的功能
    '在此只是演示一种方法
    With rsQueryResult
        Do While Not .EOF
            lngSumBase = lngSumBase + rsQueryResult("学分")
            lngSumScore = lngSumScore + rsQueryResult("学分") * rsQueryResult("成绩")
            .MoveNext
        Loop
        aveScore = lngSumScore / lngSumBase
    End With
    
    'Round函数,用来取四舍五入的值,第二个参数用以指定小数点后的为数,缺省的时候
    '四舍五入得到的结果是保留整数
    txtAveScore.Text = Round(aveScore, 2)
End Sub

Private Sub cmdPrint_Click()
    '定义一个ActiveX DLL工程中的类的实例
    Dim clsPrint As New clsPrintData
    
    '利用向类中的公用属性传递变量的方法,向Dll传递外部数据
    Set clsPrint.cnnConnection = gcnnConnection
    Set clsPrint.rsSource = rsQueryResult
    '显示打印窗体
    clsPrint.ShowPrintForm
End Sub

Private Sub cmdReport_Click()
    '定义设计好的报表的一个实例对象
    Dim temRpt As New RptQuery
    '先初始化设置好报表的标题
    Dim strHeader As String
    
    strHeader = "成绩查询结果"
    
    '打印过程中,鼠标显示为等待状态
    Screen.MousePointer = vbHourglass
    frmMainMDI.staMainMdi.Panels(2).Text = "正在写入文件,请等待......"
    
    '**********************************************************************
    '下面的这段代码非常有用,也具备一定的通用性,基本上能够实现利用Data Report来
    '动态的完成报表的打印
    
    '这段程序代码的关键技术部分是集合对象的应用,利用集合对象将设计阶段放置在报表
    '窗体上各个区域的各个控件分别按类型放置到集合中去,从而能够动态的去对这些控件
    '进行跟踪控制和访问
    
    On Error GoTo err
    
    '定义一个用来存放报表页眉区域内RptLabel控件的集合
    Dim colRptPageLbl As New Collection
    
    '定义一个用来存放报表页眉区域内RptTextBox控件的集合
    Dim colRptPageTxt As New Collection
    
    '定义一个用来存放报表细节区域内RptTextBox控件的集合
    Dim colRptDeatailTxt As New Collection
    
    '定义一个用来存放报表细节区域内RptLabel控件的集合

⌨️ 快捷键说明

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