📄 frmcountgrade.vb
字号:
countchilddbset = Nothing
pagelinecount = 0
End Sub
Private Sub mypd_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles mypd.PrintPage
If countdbset Is Nothing Then
e.Cancel = True
Exit Sub
End If
Dim line As Integer
Dim celwidth 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 + 200
y = mtop
x1 = x
y1 = mtop + mheigth
g.DrawLine(New Pen(drawBrush), x, y, x1, y1)
celwidth = (mwidth - 200) / 5
x = mleft + 200 + celwidth
y = mtop
x1 = x
y1 = mtop + mheigth
g.DrawLine(New Pen(drawBrush), x, y, x1, y1)
x = mleft + 200 + celwidth * 2
y = mtop
x1 = x
y1 = mtop + mheigth
g.DrawLine(New Pen(drawBrush), x, y, x1, y1)
x = mleft + 200 + celwidth * 3
y = mtop
x1 = x
y1 = mtop + mheigth
g.DrawLine(New Pen(drawBrush), x, y, x1, y1)
x = mleft + 200 + celwidth * 4
y = mtop
x1 = x
y1 = mtop + mheigth
g.DrawLine(New Pen(drawBrush), x, y, x1, y1)
'============================打印表头========================================
mstring = "院系名称"
x = mleft + 100 - g.MeasureString(mstring, fontcontext).ToSize().Width / 2
y = mtop + 5
g.DrawString(mstring, fontcontext, drawBrush, x, y)
mstring = "报名人数"
x = mleft + 200 + celwidth / 2 - g.MeasureString(mstring, fontcontext).ToSize().Width / 2
y = mtop + 5
g.DrawString(mstring, fontcontext, drawBrush, x, y)
mstring = "及格人数"
x = mleft + 200 + celwidth + celwidth / 2 - g.MeasureString(mstring, fontcontext).ToSize().Width / 2
y = mtop + 5
g.DrawString(mstring, fontcontext, drawBrush, x, y)
mstring = "优秀人数"
x = mleft + 200 + celwidth * 2 + celwidth / 2 - g.MeasureString(mstring, fontcontext).ToSize().Width / 2
y = mtop + 5
g.DrawString(mstring, fontcontext, drawBrush, x, y)
mstring = "及格率"
x = mleft + 200 + celwidth * 3 + celwidth / 2 - g.MeasureString(mstring, fontcontext).ToSize().Width / 2
y = mtop + 5
g.DrawString(mstring, fontcontext, drawBrush, x, y)
mstring = "优秀率"
x = mleft + 200 + celwidth * 4 + celwidth / 2 - 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 = MyDep.GetDepName(countdbset.Tables(0).Rows(curline).Item(0))
If Len(Trim(mstring)) > 0 Then
Dim totalnum As Single
Dim perf As Single
Dim passn As Single
x = mleft + 100 - g.MeasureString(mstring, fontcontext).ToSize().Width / 2
y = mtop + line * 30 + 5
g.DrawString(mstring, fontcontext, drawBrush, x, y)
totalnum = MyCountGrd.GetTotalNum(countdbset.Tables(0).Rows(curline).Item(0))
mstring = totalnum.ToString
x = mleft + 200 + celwidth / 2 - g.MeasureString(mstring, fontcontext).ToSize().Width / 2
' y = y + 35
g.DrawString(mstring, fontcontext, drawBrush, x, y)
passn = MyCountGrd.GetPassNum(countdbset.Tables(0).Rows(curline).Item(0))
mstring = passn.ToString
x = mleft + 200 + celwidth + celwidth / 2 - g.MeasureString(mstring, fontcontext).ToSize().Width / 2
'y = y + 35
g.DrawString(mstring, fontcontext, drawBrush, x, y)
perf = MyCountGrd.GetPerfectedNum(countdbset.Tables(0).Rows(curline).Item(0), Val(Trim(TextBox1.Text)))
mstring = perf.ToString
x = mleft + 200 + celwidth * 2 + celwidth / 2 - g.MeasureString(mstring, fontcontext).ToSize().Width / 2
'y = y + 35
g.DrawString(mstring, fontcontext, drawBrush, x, y)
If totalnum <= 0 Then
mstring = "-"
Else
mstring = Int((passn / totalnum) * 100).ToString
mstring = mstring & "%"
End If
x = mleft + 200 + celwidth * 3 + celwidth / 2 - g.MeasureString(mstring, fontcontext).ToSize().Width / 2
'y = y + 35
g.DrawString(mstring, fontcontext, drawBrush, x, y)
If totalnum <= 0 Then
mstring = "-"
Else
mstring = Int((perf / totalnum) * 100).ToString
mstring = mstring & "%"
End If
x = mleft + 200 + celwidth * 4 + celwidth / 2 - g.MeasureString(mstring, fontcontext).ToSize().Width / 2
'y = y + 35
g.DrawString(mstring, fontcontext, drawBrush, x, y)
line = line + 1
curline = curline + 1
End If
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 cmdCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCancel.Click
Me.Close()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.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 PrintDialog
mypd.PrinterSettings.PrinterName = printername
preprint.Document = mypd
If preprint.ShowDialog() = DialogResult.OK Then
mypd.Print()
End If
End If
End Sub
Private Sub FrmCountGrade_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
MyCountGrd.Initials()
MyDep.Initials()
CurDep.Initials()
MyMar.Initials()
CurMar.Initials()
MyStu.Initials()
CurStu.Initials()
MyGrade.Initials()
CurGrade.Initials()
countdbset = Nothing
countchilddbset = Nothing
End Sub
Private Sub FrmCountGrade_Deactivate(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Deactivate
MyCountGrd.Initials()
MyDep.Initials()
CurDep.Initials()
MyMar.Initials()
CurMar.Initials()
MyStu.Initials()
CurStu.Initials()
MyGrade.Initials()
CurGrade.Initials()
countdbset = Nothing
countchilddbset = 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 + -