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

📄 frmcountgrade.vb

📁 代码:是由本人自主开发完成的
💻 VB
📖 第 1 页 / 共 2 页
字号:
Imports System.Drawing
Imports System.Drawing.Printing
Public Class FrmCountGrade
    Inherits System.Windows.Forms.Form

#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 GroupBox4 As System.Windows.Forms.GroupBox
    Friend WithEvents combtesttime As System.Windows.Forms.ComboBox
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents combtestyear As System.Windows.Forms.ComboBox
    Friend WithEvents cmdOK As System.Windows.Forms.Button
    Friend WithEvents cmdCancel As System.Windows.Forms.Button
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents mypd As System.Drawing.Printing.PrintDocument
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents Label25 As System.Windows.Forms.Label
    Friend WithEvents cbprinter As System.Windows.Forms.ComboBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.GroupBox4 = New System.Windows.Forms.GroupBox
        Me.combtesttime = New System.Windows.Forms.ComboBox
        Me.Label1 = New System.Windows.Forms.Label
        Me.combtestyear = New System.Windows.Forms.ComboBox
        Me.Label2 = New System.Windows.Forms.Label
        Me.cmdOK = New System.Windows.Forms.Button
        Me.cmdCancel = New System.Windows.Forms.Button
        Me.mypd = New System.Drawing.Printing.PrintDocument
        Me.Label4 = New System.Windows.Forms.Label
        Me.TextBox1 = New System.Windows.Forms.TextBox
        Me.Button1 = New System.Windows.Forms.Button
        Me.Label25 = New System.Windows.Forms.Label
        Me.cbprinter = New System.Windows.Forms.ComboBox
        Me.GroupBox4.SuspendLayout()
        Me.SuspendLayout()
        '
        'GroupBox4
        '
        Me.GroupBox4.Controls.Add(Me.combtesttime)
        Me.GroupBox4.Controls.Add(Me.Label1)
        Me.GroupBox4.Controls.Add(Me.combtestyear)
        Me.GroupBox4.Controls.Add(Me.Label2)
        Me.GroupBox4.Location = New System.Drawing.Point(44, 8)
        Me.GroupBox4.Name = "GroupBox4"
        Me.GroupBox4.Size = New System.Drawing.Size(380, 48)
        Me.GroupBox4.TabIndex = 4
        Me.GroupBox4.TabStop = False
        Me.GroupBox4.Text = "考试时间:"
        '
        'combtesttime
        '
        Me.combtesttime.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.combtesttime.Items.AddRange(New Object() {"1", "2"})
        Me.combtesttime.Location = New System.Drawing.Point(200, 16)
        Me.combtesttime.Name = "combtesttime"
        Me.combtesttime.Size = New System.Drawing.Size(56, 20)
        Me.combtesttime.TabIndex = 2
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(144, 20)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(56, 16)
        Me.Label1.TabIndex = 1
        Me.Label1.Text = "学年第"
        '
        'combtestyear
        '
        Me.combtestyear.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.combtestyear.Location = New System.Drawing.Point(24, 18)
        Me.combtestyear.Name = "combtestyear"
        Me.combtestyear.Size = New System.Drawing.Size(104, 20)
        Me.combtestyear.TabIndex = 0
        '
        'Label2
        '
        Me.Label2.Location = New System.Drawing.Point(264, 20)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(32, 16)
        Me.Label2.TabIndex = 3
        Me.Label2.Text = "季"
        '
        'cmdOK
        '
        Me.cmdOK.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.cmdOK.Location = New System.Drawing.Point(24, 120)
        Me.cmdOK.Name = "cmdOK"
        Me.cmdOK.Size = New System.Drawing.Size(80, 32)
        Me.cmdOK.TabIndex = 12
        Me.cmdOK.Text = "打印预览"
        '
        'cmdCancel
        '
        Me.cmdCancel.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.cmdCancel.Location = New System.Drawing.Point(328, 120)
        Me.cmdCancel.Name = "cmdCancel"
        Me.cmdCancel.Size = New System.Drawing.Size(80, 32)
        Me.cmdCancel.TabIndex = 13
        Me.cmdCancel.Text = "返    回"
        '
        'mypd
        '
        '
        'Label4
        '
        Me.Label4.Location = New System.Drawing.Point(40, 80)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(112, 16)
        Me.Label4.TabIndex = 14
        Me.Label4.Text = "优秀率最低分数:"
        '
        'TextBox1
        '
        Me.TextBox1.Location = New System.Drawing.Point(144, 74)
        Me.TextBox1.Name = "TextBox1"
        Me.TextBox1.Size = New System.Drawing.Size(64, 21)
        Me.TextBox1.TabIndex = 15
        Me.TextBox1.Text = "70"
        '
        'Button1
        '
        Me.Button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.Button1.Location = New System.Drawing.Point(176, 120)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(80, 32)
        Me.Button1.TabIndex = 16
        Me.Button1.Text = "打     印"
        '
        'Label25
        '
        Me.Label25.Location = New System.Drawing.Point(216, 78)
        Me.Label25.Name = "Label25"
        Me.Label25.Size = New System.Drawing.Size(80, 16)
        Me.Label25.TabIndex = 20
        Me.Label25.Text = "选择打印机:"
        '
        'cbprinter
        '
        Me.cbprinter.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.cbprinter.Location = New System.Drawing.Point(304, 74)
        Me.cbprinter.Name = "cbprinter"
        Me.cbprinter.Size = New System.Drawing.Size(120, 20)
        Me.cbprinter.TabIndex = 19
        '
        'FrmCountGrade
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(450, 175)
        Me.Controls.Add(Me.Label25)
        Me.Controls.Add(Me.cbprinter)
        Me.Controls.Add(Me.Button1)
        Me.Controls.Add(Me.TextBox1)
        Me.Controls.Add(Me.Label4)
        Me.Controls.Add(Me.cmdOK)
        Me.Controls.Add(Me.cmdCancel)
        Me.Controls.Add(Me.GroupBox4)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
        Me.MaximizeBox = False
        Me.Name = "FrmCountGrade"
        Me.Text = "测试结果统计"
        Me.GroupBox4.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region
    Dim countdbset As DataSet
    Dim countchilddbset As DataSet
    Dim fonthead As Font = Nothing
    Dim fontcontext As Font = Nothing
    Dim totalpage As Integer
    Dim curpage As Integer
    Dim totalline As Integer
    Dim curline As Integer
    Dim pagelinecount As Integer = 0
    Dim printername As String = Nothing
    Private Sub FrmCountGrade_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim i As Integer
        Dim yy As Integer
        For i = 2000 To 2050
            combtestyear.Items.Add(i.ToString)
        Next
        yy = Year(Now())
        combtesttime.Text = 1
        combtestyear.Text = yy.ToString
        MyCountGrd.Initials()
        MyDep.Initials()
        CurDep.Initials()
        MyMar.Initials()
        CurMar.Initials()
        MyStu.Initials()
        CurStu.Initials()
        MyGrade.Initials()

        CurGrade.Initials()
        countdbset = Nothing
        countchilddbset = Nothing

        Dim pkInstalledPrinters As String
        For i = 0 To PrinterSettings.InstalledPrinters.Count - 1
            pkInstalledPrinters = PrinterSettings.InstalledPrinters.Item(i)
            cbprinter.Items.Add(pkInstalledPrinters)
        Next
        If cbprinter.Items.Count = 0 Then
            cmdOK.Enabled = False
            Button1.Enabled = False
            MsgBox("没有一台有效的打印机!", MsgBoxStyle.Exclamation, "大学语文考试系统V2.0")
        Else
            cbprinter.SelectedIndex = 0
            printername = cbprinter.Items(cbprinter.SelectedIndex)
        End If
    End Sub
    Private Sub mergedbset(ByVal tmpdbset As DataSet)
        countdbset.Merge(tmpdbset)
    End Sub
    Private Sub cmdOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdOK.Click
        If MsgBox("你是否打印" & Trim(combtestyear.Text) & "学年第" & Trim(combtesttime.Text) & "次考试分析结果?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "翼清考试系统V2.0") = MsgBoxResult.Yes Then
            MyCountGrd.Equal(Trim(combtestyear.Text) & Trim(combtesttime.Text))
            countdbset = Nothing
            countchilddbset = Nothing
            countdbset = MyCountGrd.GetTestInfo()
            countchilddbset = MyCountGrd.GetTestInfobychild()

            If Not countdbset Is Nothing Then
                If Not countchilddbset Is Nothing Then
                    mergedbset(countchilddbset)

                End If
                totalline = countdbset.Tables(0).Rows.Count
            Else
                If Not countchilddbset Is Nothing Then
                    mergedbset(countchilddbset)
                    totalline = countdbset.Tables(0).Rows.Count
                Else
                    totalline = 0
                    Exit Sub
                End If
            End If
            Dim preprint As New PrintPreviewDialog
            mypd.PrinterSettings.PrinterName = printername
            preprint.Document = mypd

            preprint.ShowDialog()
        End If
    End Sub
    Private Sub mypd_BeginPrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs) Handles mypd.BeginPrint
        fonthead = New Font("Arial", 16, FontStyle.Bold)
        fontcontext = New Font("Arial", 10, FontStyle.Bold)

        If totalline <= 0 Then
            totalpage = 0
            curpage = 0
            curline = 0
            e.Cancel = True
        Else
            curpage = 0
            curline = 0
        End If
        pagelinecount = 0
    End Sub

    Private Sub mypd_EndPrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs) Handles mypd.EndPrint
        fonthead.Dispose()
        fontcontext.Dispose()
        fonthead = Nothing
        fontcontext = Nothing
        countdbset = Nothing

⌨️ 快捷键说明

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