📄 frmzhengshu.vb
字号:
updbset = MyGrade.GetPassStu(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
totalpage = updbset.Tables(0).Rows.Count
Else
DataGrid1.DataSource = Nothing
DataGrid1.CaptionText = "当前总共有[ " & 0 & " ]个学生要打印"
cmdOK.Enabled = False
totalpage = 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
fontcontext = New Font("Arial", 10, FontStyle.Bold)
drawBrush = New SolidBrush(Color.Black)
If totalpage <= 0 Then
curpage = 0
e.Cancel = True
Else
curpage = 0
End If
End Sub
Private Sub mypd_EndPrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs) Handles mypd.EndPrint
fontcontext.Dispose()
drawBrush.Dispose()
drawBrush = 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 CheckBox2.Checked Then
If sigstudbset Is Nothing Then
e.Cancel = True
Exit Sub
End If
Dim g As Graphics = e.Graphics
Dim mstring As String
Dim x As Single
Dim y As Single
mstring = sigstudbset.Tables(0).Rows(0).Item("姓名")
x = CurPriSet.PLeft
y = CurPriSet.PNameTop
g.DrawString(mstring, fontcontext, drawBrush, x, y)
mstring = sigstudbset.Tables(0).Rows(0).Item("性别")
y = CurPriSet.PSexTop
g.DrawString(mstring, fontcontext, drawBrush, x, y)
mstring = sigstudbset.Tables(0).Rows(0).Item("院系名称")
y = CurPriSet.PDepTop
g.DrawString(mstring, fontcontext, drawBrush, x, y)
mstring = sigstudbset.Tables(0).Rows(0).Item("专业名称")
y = CurPriSet.PMarTop
g.DrawString(mstring, fontcontext, drawBrush, x, y)
Dim tmpstring As String
tmpstring = sigstudbset.Tables(0).Rows(0).Item("学号")
mstring = Microsoft.VisualBasic.Left(tmpstring, 4)
mstring = mstring & "级"
y = CurPriSet.PGradTop
g.DrawString(mstring, fontcontext, drawBrush, x, y)
mstring = CurPriSet.BianHao
y = CurPriSet.PBianHTop
g.DrawString(mstring, fontcontext, drawBrush, x, y)
Dim mylong As Long
mylong = Int(CurPriSet.BianHao)
mylong = mylong + 1
CurPriSet.BianHao = mylong.ToString
CurPriSet.ModifyBianhao(CurPriSet.BianHao)
mstring = sigstudbset.Tables(0).Rows(0).Item("姓名")
x = CurPriSet.PRNameLeft
y = CurPriSet.PRNameTop
g.DrawString(mstring, fontcontext, drawBrush, x, y)
mstring = testyear
x = CurPriSet.PRTestYearLeft
g.DrawString(mstring, fontcontext, drawBrush, x, y)
mstring = testmon
x = CurPriSet.PRTestMonLeft
y = CurPriSet.PRTestMonTop
g.DrawString(mstring, fontcontext, drawBrush, x, y)
mstring = veryear
x = CurPriSet.PRVerYearLeft
y = CurPriSet.PRVerYearTop
g.DrawString(mstring, fontcontext, drawBrush, x, y)
mstring = vermon
x = CurPriSet.PRVerMonLeft
g.DrawString(mstring, fontcontext, drawBrush, x, y)
mstring = verdate
x = CurPriSet.PRVerDateLeft
g.DrawString(mstring, fontcontext, drawBrush, x, y)
e.HasMorePages = False
sigstudbset = Nothing
Else
If updbset Is Nothing Then
e.Cancel = True
Exit Sub
End If
Dim g As Graphics = e.Graphics
Dim mstring As String
Dim x As Single
Dim y As Single
mstring = updbset.Tables(0).Rows(curpage).Item("姓名")
x = CurPriSet.PLeft
y = CurPriSet.PNameTop
g.DrawString(mstring, fontcontext, drawBrush, x, y)
mstring = updbset.Tables(0).Rows(curpage).Item("性别")
y = CurPriSet.PSexTop
g.DrawString(mstring, fontcontext, drawBrush, x, y)
mstring = updbset.Tables(0).Rows(curpage).Item("院系名称")
y = CurPriSet.PDepTop
g.DrawString(mstring, fontcontext, drawBrush, x, y)
mstring = updbset.Tables(0).Rows(curpage).Item("专业名称")
y = CurPriSet.PMarTop
g.DrawString(mstring, fontcontext, drawBrush, x, y)
Dim tmpstring As String
tmpstring = updbset.Tables(0).Rows(curpage).Item("学号")
mstring = Microsoft.VisualBasic.Left(tmpstring, 4)
mstring = mstring & "级"
y = CurPriSet.PGradTop
g.DrawString(mstring, fontcontext, drawBrush, x, y)
mstring = CurPriSet.BianHao
y = CurPriSet.PBianHTop
g.DrawString(mstring, fontcontext, drawBrush, x, y)
Dim mylong As Long
mylong = Int(CurPriSet.BianHao)
mylong = mylong + 1
CurPriSet.BianHao = mylong.ToString
CurPriSet.ModifyBianhao(CurPriSet.BianHao)
mstring = updbset.Tables(0).Rows(curpage).Item("姓名")
x = CurPriSet.PRNameLeft
y = CurPriSet.PRNameTop
g.DrawString(mstring, fontcontext, drawBrush, x, y)
mstring = testyear
x = CurPriSet.PRTestYearLeft
g.DrawString(mstring, fontcontext, drawBrush, x, y)
mstring = testmon
x = CurPriSet.PRTestMonLeft
y = CurPriSet.PRTestMonTop
g.DrawString(mstring, fontcontext, drawBrush, x, y)
mstring = veryear
x = CurPriSet.PRVerYearLeft
y = CurPriSet.PRVerYearTop
g.DrawString(mstring, fontcontext, drawBrush, x, y)
mstring = vermon
x = CurPriSet.PRVerMonLeft
g.DrawString(mstring, fontcontext, drawBrush, x, y)
mstring = verdate
x = CurPriSet.PRVerDateLeft
g.DrawString(mstring, fontcontext, drawBrush, x, y)
curpage = curpage + 1
If curpage < totalpage Then
e.HasMorePages = True
Else
e.HasMorePages = False
End If
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.GetPassStu(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
totalpage = updbset.Tables(0).Rows.Count
Else
DataGrid1.DataSource = Nothing
DataGrid1.CaptionText = "当前总共有[ " & 0 & " ]个学生要打印"
cmdOK.Enabled = False
totalpage = 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.GetPassStu(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
totalpage = updbset.Tables(0).Rows.Count
Else
DataGrid1.DataSource = Nothing
DataGrid1.CaptionText = "当前总共有[ " & 0 & " ]个学生要打印"
cmdOK.Enabled = False
totalpage = 0
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
GroupBox2.Visible = True
GroupBox3.Visible = False
CheckBox1.Checked = False
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ValData()
End Sub
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Checked = True Then
GroupBox2.Visible = False
GroupBox3.Visible = True
showData()
Else
CurPriSet.GetInfo()
ValData()
GroupBox2.Visible = True
GroupBox3.Visible = False
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim preprint As New PrintDialog
If totalpage = 0 Then
Exit Sub
End If
mypd.PrinterSettings.PrinterName = printername
' preprint.AllowSomePages = True
preprint.AllowSomePages = True
preprint.AllowSelection = True
If CheckBox2.Checked = False Then
mypd.PrinterSettings.FromPage = 1
mypd.PrinterSettings.ToPage = totalpage
mypd.PrinterSettings.MinimumPage = 1
mypd.PrinterSettings.MaximumPage = totalpage
End If
preprint.Document = mypd
If preprint.ShowDialog() = DialogResult.OK Then
mypd.Print()
End If
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Dim psd As New PageSetupDialog
With psd
.Document = mypd
.PageSettings = mypd.DefaultPageSettings
End With
If psd.ShowDialog = DialogResult.OK Then
mypd.DefaultPageSettings = psd.PageSettings
End If
End Sub
Private Sub DataGrid1_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.CurrentCellChanged
sigstudbset = Nothing
If DataGrid1.CurrentRowIndex < 0 Then
Exit Sub
End If
If DataGrid1.Item(DataGrid1.CurrentRowIndex, 0) Is Nothing Then
Exit Sub
End If
sigstudbset = MyGrade.GetStuDetailInfo(DataGrid1.Item(DataGrid1.CurrentRowIndex, 1), Trim(combtestyear.Text) & Trim(combtesttime.Text))
End Sub
Private Sub frmzhengshu_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()
GbMarjoy.Text = "专业信息--当前专业[]"
GbDepartment.Text = "院系信息--当前院系:[]"
DataGrid1.DataSource = Nothing
DataGrid1.CaptionText = "当前总共有[ " & 0 & " ]个学生要打印"
cmdOK.Enabled = False
totalpage = 0
updbset = Nothing
sigstudbset = 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 + -