📄 printtotal.frm
字号:
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9.75
Charset = 134
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
MarqueeStyle = 2
BeginProperty Column00
EndProperty
BeginProperty Column01
EndProperty
EndProperty
End
End
Begin VB.Image Image1
Height = 585
Left = 3735
Stretch = -1 'True
Top = 6465
Visible = 0 'False
Width = 885
End
End
End
Attribute VB_Name = "PrintTotal"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Check1_Click()
If Check1.Value = 1 Then
MSChart.EditCopy
Set Image1.Picture = Clipboard.GetData
Else
Clipboard.Clear
End If
End Sub
Private Sub Combo1_Click()
MSChart.ChartType = Combo1.ListIndex
End Sub
Private Sub Command1_Click(Index As Integer)
Select Case Index
Case 1 '打印
Select Case SSTab1.Tab
Case 0 '按村组
Call Print_To(0)
Case 1 '按台区
Call Print_To(1)
Case 2 '按电价
Call Print_To(2)
End Select
Case 2
Unload Me
End Select
End Sub
Private Sub Command2_Click()
Frame2.Visible = True
Frame1.Visible = False
MSChart.ToolTipText = "双击返回"
End Sub
Private Sub Form_Load()
If Screen.Width \ Screen.TwipsPerPixelX = 800 And Screen.Height \ Screen.TwipsPerPixelY = 600 Then
Me.Move (Screen.Width - Me.Width) / 2, (Screen.Height - Me.Height) / 1 - 400
Else
Me.Move (Screen.Width - Me.Width) / 2, (Screen.Height - Me.Height) / 2
End If
Adodc1.ConnectionString = "DBQ=" & App.Path & "\Data\eletricity.Mdb" & ";Driver={Microsoft Access Driver (*.mdb)};DriverId=281;FIL=MS Access;MaxBufferSize=2048;MaxScanRows=8;PageTimeout=5;PWD=;SafeTransactions=0;Threads=3;UID=admin;UserCommitSync=Yes;"
Call SSTab1_Click(1)
SSTab1.Tab = 0
Frame2.Visible = False
End Sub
Private Sub MSChart_DblClick()
Frame1.Visible = True
Frame2.Visible = False
End Sub
Private Sub Option1_Click()
On Error Resume Next
Combo1.Clear
Combo1.AddItem "1条形" '1
Combo1.AddItem "3线" '3
Combo1.AddItem "5区域" '5
Combo1.AddItem "7步骤" '7
Combo1.AddItem "9组合" '9
Combo1.AddItem "14饼图" '14
Combo1.AddItem "16X.Y散点图" '16
Combo1.ListIndex = 0
End Sub
Private Sub Option2_Click()
On Error Resume Next
Combo1.Clear
Combo1.AddItem "0条形" '0
Combo1.AddItem "2行" '2
Combo1.AddItem "4区域" '4
Combo1.AddItem "6步骤" '6
Combo1.AddItem "8组合" '8
Combo1.ListIndex = 0
End Sub
Private Sub SSTab1_Click(PreviousTab As Integer)
Select Case SSTab1.Tab
Case 0
Adodc1.RecordSource = "SELECT 用户电费.镇村代码,sum(" & CC & ") AS 本月电量,sum(" & DD & ") AS 总电量,sum(" & GG & ") AS 本月电费,sum(" & HH & ") AS 总电费,COUNT(*) AS 用户数 From 用户电费 where 用户电费.镇村代码 ='" & UserSeek & "' GROUP BY 用户电费.镇村代码"
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
Call CellFormat(DataGrid1)
Set MSChart.DataSource = Adodc1
Case 1
Adodc1.RecordSource = "SELECT 用户电费.台区,sum(" & CC & ") AS 本月电量,sum(" & DD & ") AS 总电量,sum(" & GG & ") AS 本月电费,sum(" & HH & ") AS 总电费,COUNT(*) AS 用户数 From 用户电费 where 用户电费.镇村代码 ='" & UserSeek & "' GROUP BY 用户电费.台区"
Adodc1.Refresh
Set DataGrid2.DataSource = Adodc1
Call CellFormat(DataGrid2)
Case 2
Adodc1.RecordSource = "SELECT 用户电费.电价类别," _
& "Sum(" & CC & ") AS 本月电量," _
& "Sum(" & DD & ") AS 总电量," _
& "Sum(" & GG & ") AS 本月电费," _
& "Sum(" & HH & ") AS 总电费," _
& "COUNT(*) AS 用户数 From 用户电费 " _
& "Where 用户电费.镇村代码 ='" & UserSeek & "' " _
& "GROUP BY 用户电费.电价类别"
Adodc1.Refresh
Set DataGrid3.DataSource = Adodc1
Call CellFormat(DataGrid3)
End Select
End Sub
Sub CellFormat(Oj As Object)
With Oj
.Columns(0).Width = 1200
.Columns(0).Alignment = dbgCenter
.Columns(1).Width = 1500
.Columns(1).Alignment = dbgRight
.Columns(2).Width = 1500
.Columns(2).Alignment = dbgRight
.Columns(3).NumberFormat = "0.00"
.Columns(3).Width = 1500
.Columns(3).Alignment = dbgRight
.Columns(4).NumberFormat = "0.00"
.Columns(4).Width = 1500
.Columns(4).Alignment = dbgRight
.Columns(5).Width = 1000
.Columns(5).Alignment = dbgCenter
End With
End Sub
Sub SetPrinterFont(obj As Object)
Printer.Font.Name = obj.Font.Name
Printer.Font.Size = obj.Font.Size
Printer.Font.Bold = obj.Font.Bold
Printer.Font.Italic = obj.Font.Italic
Printer.Font.Underline = obj.Font.Underline
Printer.Font.Strikethrough = obj.Font.Strikethrough
End Sub
Sub Print_To(SstabI As Integer)
Dim head_title As String
Dim tdl, dl As Integer
Dim tdf, df As Double
Dim tu As Integer
Dim u As Integer
Dim k As Integer
On Error GoTo hander
dl = 0
tdl = 0
tdf = 0#
df = 0#
u = 0
tu = 0
' Dim CX As Single, CY As Single
' CX = (Printer.ScaleWidth - ScaleWidth) / 2
' CY = (Printer.ScaleHeight - ScaleHeight) / 2
Call printer_init
If Check1.Value = 1 Then
Printer.PaintPicture Image1.Picture, 15, 18 'Image1.Left, Image1.Top
End If
Screen.MousePointer = 11
With Adodc1.Recordset
If .RecordCount <> 0 Then
Select Case SstabI
Case 0
head_title = pbDw & XcName & "汇总明细表(按村组)"
Case 1
head_title = pbDw & XcName & "汇总明细表(按台区)"
Case 2
head_title = pbDw & XcName & "汇总明细表(按电价)"
End Select
Call printer_string(0, 0, Space(23) & head_title)
Printer.Print Space(10) & "填制单位:" & XzName & XcName & Space(20) & "制表日期:" & Format(Date, "long date")
'─││┆┈┄┆┊┌┐└┘├┤┬┴┼╱╲「」
Printer.Print "───────────────────────────────────────────"
Select Case SstabI
Case 0
Printer.Print " 村组名称 本月电量 合计电量 本月电费 滞纳金 合计电费 用户数"
Case 1
Printer.Print "台 区 本月电量 合计电量 本月电费 滞纳金 合计电费 用户数"
Case 2
Printer.Print " 用电类别 本月电量 合计电量 本月电费 滞纳金 合计电费 用户数"
End Select
Do Until .eof
dl = 0
df = 0#
u = 0
With Adodc1.Recordset
If .RecordCount <> 0 Then
k = 1
Do Until .eof
If k = 1 Then
Select Case SstabI
Case 0
Printer.Print Space(1) & Left(Trim(.Fields("地址")) & Space(10), 18 - convert_str(.Fields("地址"))) & Space(2) & Left(Space(1) & .Fields("本月电量") & Space(10), 7) & Right(Space(15) & .Fields("总电量"), 10) & Space(4) & Right(Space(20) & Format(.Fields("本月电费"), "0.00"), 14) & Space(10) & Right(Space(20) & Format(.Fields("总电费"), "0.00"), 14) & Right(Space(14) & .Fields("用户数"), 9)
Case 1
Printer.Print Space(3) & Left(Trim(.Fields("台区")) & Space(10), 14 - convert_str(.Fields("台区"))) & Space(2) & Left(Space(1) & .Fields("本月电量") & Space(10), 7) & Right(Space(15) & .Fields("总电量"), 10) & Space(4) & Right(Space(20) & Format(.Fields("本月电费"), "0.00"), 14) & Space(10) & Right(Space(20) & Format(.Fields("总电费"), "0.00"), 14) & Right(Space(14) & .Fields("用户数"), 9)
Case 2
Printer.Print Space(3) & Left(Trim(.Fields("电价类别")) & Space(10), 14 - convert_str(.Fields("电价类别"))) & Space(2) & Left(Space(1) & .Fields("本月电量") & Space(10), 7) & Right(Space(15) & .Fields("总电量"), 10) & Space(4) & Right(Space(20) & Format(.Fields("本月电费"), "0.00"), 14) & Space(10) & Right(Space(20) & Format(.Fields("总电费"), "0.00"), 14) & Right(Space(14) & .Fields("用户数"), 9)
End Select
k = k + 1
Else
Select Case SstabI
Case 0
Printer.Print Space(1) & Left(Trim(.Fields("地址")) & Space(10), 18 - convert_str(.Fields("地址"))) & Space(2) & Left(Space(1) & .Fields("本月电量") & Space(10), 7) & Right(Space(15) & .Fields("总电量"), 10) & Space(4) & Right(Space(20) & Format(.Fields("本月电费"), "0.00"), 14) & Space(10) & Right(Space(20) & Format(.Fields("总电费"), "0.00"), 14) & Right(Space(14) & .Fields("用户数"), 9)
Case 1
Printer.Print Space(3) & Left(Trim(.Fields("台区")) & Space(10), 14 - convert_str(.Fields("台区"))) & Space(2) & Left(Space(1) & .Fields("本月电量") & Space(10), 7) & Right(Space(15) & .Fields("总电量"), 10) & Space(4) & Right(Space(20) & Format(.Fields("本月电费"), "0.00"), 14) & Space(10) & Right(Space(20) & Format(.Fields("总电费"), "0.00"), 14) & Right(Space(14) & .Fields("用户数"), 9)
Case 2
Printer.Print Space(3) & Left(Trim(.Fields("电价类别")) & Space(10), 14 - convert_str(.Fields("电价类别"))) & Space(2) & Left(Space(1) & .Fields("本月电量") & Space(10), 7) & Right(Space(15) & .Fields("总电量"), 10) & Space(4) & Right(Space(20) & Format(.Fields("本月电费"), "0.00"), 14) & Space(10) & Right(Space(20) & Format(.Fields("总电费"), "0.00"), 14) & Right(Space(14) & .Fields("用户数"), 9)
End Select
End If
dl = dl + .Fields("本月电量")
df = df + .Fields("本月电费")
tdl = tdl + .Fields("总电量")
tdf = tdf + .Fields("总电费")
tu = tu + .Fields("用户数")
u = u + .Fields("用户数")
If Not .eof Then
.MoveNext
End If
Loop
Printer.Print "───────────────────────────────────────────"
Printer.Print "小 计:" & Space(5) & Right(Space(30) & dl, 10) & "Kwh" & Space(16) & Right(Space(20) & Format(df, "0.00"), 12) & "元"
Printer.Print "───────────────────────────────────────────"
End If
End With
If Not .eof Then
.MoveNext
End If
Loop
Printer.Print "======================================================================================"
Printer.Print "总 计:" & Space(16) & Right(Space(30) & tdl, 10) & "Kwh" & Space(26) & Right(Space(20) & Format(tdf, "0.00"), 12) & "元" & Space(4) & Right(Space(10) & tu, 4) & "户"
Printer.EndDoc
End If
End With
Screen.MousePointer = 0
Clipboard.Clear
Exit Sub
hander:
If Err.Number = 482 Then
MsgBox "未安装打印机或打印机错误!", vbCritical
Screen.MousePointer = 0
Exit Sub
Else
Resume Next
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -