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

📄 frmunpass.vb

📁 代码:是由本人自主开发完成的
💻 VB
📖 第 1 页 / 共 2 页
字号:
        MyStu.Initials()
        CurStu.Initials()
        MyGrade.Initials()
        CurGrade.Initials()
        updbset = Nothing
    End Sub
    Private Sub TvDep_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TvDep.MouseDown
        TvDep.SelectedNode = TvDep.GetNodeAt(e.X, e.Y)
        GbMarjoy.Text = "专业信息--当前专业[]"
        If Not TvDep.SelectedNode Is Nothing Then
            If CurDep.DepartmentName = TvDep.SelectedNode.Text Then
                Exit Sub
            End If
            MyDep.GetDepInfo(MakeStr(TvDep.SelectedNode.Text))
            CurDep.Equal(MyDep)
            GbDepartment.Text = "院系信息--当前院系:[" & CurDep.DepartmentName & "]"
            CurDep.LoadMarjoysToList(LbMarjoy)
        Else
            CurDep.Initials()
            MyDep.Initials()
            GbDepartment.Text = "院系信息--当前院系:[]"
        End If
        With DataGrid1
            .CaptionText = "不及格学生信息"
            .DataSource = Nothing
        End With
    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
        MyMar.MarjoyName = LbMarjoy.SelectedItem()
        GbMarjoy.Text = "专业信息--当前专业[" & Trim(MyMar.MarjoyName) & "]"
        MyMar.GetMarInfo(MyMar.MarjoyName, CurDep.DepartmentID)
        CurMar.Equal(MyMar)
        MyMar.GetMarInfo(CurMar.MarjoyName, CurDep.DepartmentID)
        updbset = MyGrade.GetUnPassStu(CurMar.MarjoyID, Trim(combtestyear.Text) & Trim(combtesttime.Text))
        If Not updbset Is Nothing Then
            DataGrid1.DataSource = updbset.Tables(0).DefaultView
            DataGrid1.CaptionText = "当前总共有[ " & updbset.Tables(0).Rows.Count & " ]个学生要打印"
            cmdOK.Enabled = True
            totalline = updbset.Tables(0).Rows.Count
        Else
            DataGrid1.DataSource = Nothing
            DataGrid1.CaptionText = "当前总共有[ " & 0 & " ]个学生要打印"
            cmdOK.Enabled = False
            totalline = 0
        End If

    End Sub

    Private Sub cmdCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCancel.Click
        Me.Close()
    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
        pagelinecount = 0

    End Sub

    Private Sub mypd_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles mypd.PrintPage
        If updbset Is Nothing Then
            e.Cancel = True
            Exit Sub
        End If
        Dim line As Integer

        line = 1
        Dim g As Graphics = e.Graphics
        Dim drawBrush As New SolidBrush(Color.Black)

        Dim mleft As Integer = e.MarginBounds.Left
        Dim mright As Integer = e.MarginBounds.Right
        Dim mtop As Integer = e.MarginBounds.Top
        Dim mbottom As Integer = e.MarginBounds.Bottom
        Dim mwidth As Integer = e.MarginBounds.Width
        Dim mheigth As Integer = e.MarginBounds.Height
        Dim x As Integer
        Dim y As Integer
        Dim x1 As Integer
        Dim y1 As Integer

        Dim mstring As String
        Dim i As Integer
        Dim t As Integer = mheigth / 30
        pagelinecount = t - 1
        If (totalline / pagelinecount) <= 0 Then
            totalpage = 1
        Else
            If totalline Mod pagelinecount Then
                Dim tpm As Integer
                tpm = totalline Mod pagelinecount
                If tpm * 2 <= pagelinecount Then
                    totalpage = totalline / pagelinecount + 1
                Else
                    totalpage = totalline / pagelinecount
                End If
            Else
                totalpage = totalline / pagelinecount
            End If
            End If
        mstring = "大学语文考试不及格学生名单"
        x = mleft + mwidth / 2 - g.MeasureString(mstring, fonthead).ToSize().Width / 2
        y = mtop / 4
        g.DrawString(mstring, fonthead, drawBrush, x, y)

        mstring = "制表人:西北大学文学院"
        x = mleft
        y = mtop - 20
        g.DrawString(mstring, fontcontext, drawBrush, x, y)

        mstring = "考试时间:" & Trim(combtestyear.Text) & "学年第" & Trim(combtesttime.Text) & "季"
        x = mleft + 255
        y = mtop - 20
        g.DrawString(mstring, fontcontext, drawBrush, x, y)

        mstring = "总共有:" & totalline.ToString & "人,共有:" & totalpage.ToString & "页"
        x = mleft + mwidth - g.MeasureString(mstring, fontcontext).ToSize().Width
        y = mtop - 20
        g.DrawString(mstring, fontcontext, drawBrush, x, y)

        Dim msize As Size = g.MeasureString(mstring, fontcontext).ToSize()

        e.Graphics.DrawRectangle(New Pen(Color.Black, 1), _
                         mleft, mtop, mwidth, mheigth)

        x = mleft
        x1 = x + mwidth
        y = mtop
        y1 = y

        For i = 0 To t - 2
            y = y + 30
            g.DrawLine(New Pen(drawBrush), x, y, x1, y)
        Next
        x = mleft + 120
        y = mtop
        x1 = x
        y1 = mtop + mheigth
        g.DrawLine(New Pen(drawBrush), x, y, x1, y1)

        x = mleft + 220
        y = mtop
        x1 = x
        y1 = mtop + mheigth
        g.DrawLine(New Pen(drawBrush), x, y, x1, y1)

        x = mleft + 220 + 80
        y = mtop
        x1 = x
        y1 = mtop + mheigth
        g.DrawLine(New Pen(drawBrush), x, y, x1, y1)

        x = (mwidth - 300) / 2 + mleft + 300
        y = mtop
        x1 = x
        y1 = mtop + mheigth
        g.DrawLine(New Pen(drawBrush), x, y, x1, y1)
        '============================打印表头========================================
        mstring = "学 号"
        x = mleft + 60 - g.MeasureString(mstring, fontcontext).ToSize().Width / 2
        y = mtop + 5
        g.DrawString(mstring, fontcontext, drawBrush, x, y)

        mstring = "姓 名"
        x = mleft + 120 + 50 - g.MeasureString(mstring, fontcontext).ToSize().Width / 2
        y = mtop + 5
        g.DrawString(mstring, fontcontext, drawBrush, x, y)

        mstring = "性 别"
        x = mleft + 220 + 40 - g.MeasureString(mstring, fontcontext).ToSize().Width / 2
        y = mtop + 5
        g.DrawString(mstring, fontcontext, drawBrush, x, y)

        mstring = "院 系"
        x = mleft + 300 + (mwidth - 300) / 4 - g.MeasureString(mstring, fontcontext).ToSize().Width / 2
        y = mtop + 5
        g.DrawString(mstring, fontcontext, drawBrush, x, y)

        mstring = "专 业"
        x = mleft + 300 + (mwidth - 300) / 2 + (mwidth - 300) / 4 - g.MeasureString(mstring, fontcontext).ToSize().Width / 2
        y = mtop + 5
        g.DrawString(mstring, fontcontext, drawBrush, x, y)
        '==================================打印内容==============================
        y = mtop
        While line <= pagelinecount And curline < totalline
            mstring = updbset.Tables(0).Rows(curline).Item(1)
            x = mleft + 60 - g.MeasureString(mstring, fontcontext).ToSize().Width / 2
            y = mtop + line * 30 + 5
            g.DrawString(mstring, fontcontext, drawBrush, x, y)

            mstring = updbset.Tables(0).Rows(curline).Item(0)
            x = mleft + 120 + 50 - g.MeasureString(mstring, fontcontext).ToSize().Width / 2
            ' y = y + 35
            g.DrawString(mstring, fontcontext, drawBrush, x, y)

            mstring = updbset.Tables(0).Rows(curline).Item(2)
            x = mleft + 220 + 40 - g.MeasureString(mstring, fontcontext).ToSize().Width / 2
            'y = y + 35
            g.DrawString(mstring, fontcontext, drawBrush, x, y)

            mstring = updbset.Tables(0).Rows(curline).Item(3)
            x = mleft + 300 + (mwidth - 300) / 4 - g.MeasureString(mstring, fontcontext).ToSize().Width / 2
            'y = y + 35
            g.DrawString(mstring, fontcontext, drawBrush, x, y)

            mstring = updbset.Tables(0).Rows(curline).Item(4)
            x = mleft + 300 + (mwidth - 300) / 2 + (mwidth - 300) / 4 - g.MeasureString(mstring, fontcontext).ToSize().Width / 2
            'y = y + 35
            g.DrawString(mstring, fontcontext, drawBrush, x, y)
            line = line + 1
            curline = curline + 1
        End While
        curpage = curpage + 1

        mstring = "每页31条记录 第 " & curpage.ToString & " 页"
        x = mleft + mwidth - g.MeasureString(mstring, fontcontext).ToSize().Width
        y = mbottom + 5
        g.DrawString(mstring, fontcontext, drawBrush, x, y)

        mstring = "开发人员:翼清  E-MAIL:smq65@163.com"
        x = mleft
        y = mbottom + 5
        g.DrawString(mstring, fontcontext, drawBrush, x, y)

        If curpage < totalpage Then
            e.HasMorePages = True
        Else
            e.HasMorePages = False
        End If
    End Sub

    Private Sub cmdOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdOK.Click
        Dim preprint As New PrintPreviewDialog
        mypd.PrinterSettings.PrinterName = printername
        preprint.Document = mypd
        preprint.ShowDialog()
    End Sub


    Private Sub combtestyear_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles combtestyear.SelectedIndexChanged
        updbset = Nothing
        updbset = MyGrade.GetUnPassStu(CurMar.MarjoyID, Trim(combtestyear.Text) & Trim(combtesttime.Text))
        If Not updbset Is Nothing Then
            DataGrid1.DataSource = updbset.Tables(0).DefaultView
            DataGrid1.CaptionText = "当前总共有[ " & updbset.Tables(0).Rows.Count & " ]个学生要打印"
            cmdOK.Enabled = True
            totalline = updbset.Tables(0).Rows.Count
        Else
            DataGrid1.DataSource = Nothing
            DataGrid1.CaptionText = "当前总共有[ " & 0 & " ]个学生要打印"
            cmdOK.Enabled = False
            totalline = 0
        End If
    End Sub

    Private Sub combtesttime_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles combtesttime.SelectedIndexChanged
        updbset = Nothing
        updbset = MyGrade.GetUnPassStu(CurMar.MarjoyID, Trim(combtestyear.Text) & Trim(combtesttime.Text))
        If Not updbset Is Nothing Then
            DataGrid1.DataSource = updbset.Tables(0).DefaultView
            DataGrid1.CaptionText = "当前总共有[ " & updbset.Tables(0).Rows.Count & " ]个学生要打印"
            cmdOK.Enabled = True
            totalline = updbset.Tables(0).Rows.Count
        Else
            DataGrid1.DataSource = Nothing
            DataGrid1.CaptionText = "当前总共有[ " & 0 & " ]个学生要打印"
            cmdOK.Enabled = False
            totalline = 0
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim preprint As New PrintDialog
        mypd.PrinterSettings.PrinterName = printername
        preprint.Document = mypd

        If preprint.ShowDialog() = DialogResult.OK Then
            mypd.Print()
        End If
    End Sub

    Private Sub FrmUnPass_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()
        MyGrade.Initials()
        CurGrade.Initials()
        GbDepartment.Text = "院系信息--当前院系:[]"
        GbMarjoy.Text = "专业信息--当前专业[]"
        DataGrid1.DataSource = Nothing
        DataGrid1.CaptionText = "当前总共有[ " & 0 & " ]个学生要打印"
        cmdOK.Enabled = False
        updbset = Nothing
    End Sub

   

    Private Sub cbprinter_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbprinter.SelectedIndexChanged
        If cbprinter.Items.Count > 0 Then
            printername = cbprinter.Text
            cmdOK.Enabled = True
            Button1.Enabled = True
        End If
    End Sub
End Class

⌨️ 快捷键说明

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