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

📄 printurgelist.frm

📁 适合乡镇供电所使用电费处理系统v3 软件
💻 FRM
📖 第 1 页 / 共 2 页
字号:
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

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 - 750
   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;"
   Adodc1.RecordSource = "SELECT 用户电费.用户编码,用户电费.用户名称,用户电费.[" & AAA & "] AS 上期示数, 用户电费.[" & aa & "] AS 本期示数,用户电费.表损, 用户电费.倍率,用户电费.[" & BB & "] AS 调整电量,用户电费.[" & CC & "] AS 本次电量, 用户电费.[" & DD & "] AS 合计电量,用户电费.电价,用户电费.[" & EE & "] AS 调整金额, 用户电费.[" & FF & "] AS 滞纳金, 用户电费.[" & GG & "] AS 本次电费, 用户电费.[" & HH & "] AS 合计电费,用户电费.[" & II & "] AS 代扣信息,用户电费.[" & JJ & "] AS 发票打印,用户电费.[" & KK & "] AS 交费情况,用户电费.组合编码,用户电费.辅助号,用户电费.台区 From 用户电费 WHERE 用户电费.镇村代码='" & UserSeek & "' and  用户电费.[" & II & "]=0 order by 用户电费.组合编码 asc"
   Adodc1.Refresh
   Set DataGrid1.DataSource = Adodc1
   With DataGrid1
       .Columns(0).Width = 1000
       .Columns(0).Alignment = dbgCenter
       
       .Columns(1).Width = 2000
       
       .Columns(2).Width = 1200
       .Columns(2).Alignment = dbgCenter
       .Columns(3).Width = 1200
       .Columns(3).Alignment = dbgCenter
       
       .Columns(4).Width = 800
       .Columns(4).Alignment = dbgRight
       
       .Columns(5).Width = 1200
       .Columns(5).Alignment = dbgRight
       .Columns(6).Width = 1200
       .Columns(6).Alignment = dbgRight
       .Columns(7).Width = 1200
       .Columns(7).Alignment = dbgRight
       .Columns(8).Width = 1200
       .Columns(8).NumberFormat = "0.000"
       .Columns(8).Alignment = dbgRight
       .Columns(9).Width = 1200
       .Columns(9).Alignment = dbgRight
       .Columns(9).NumberFormat = "0.00"
       .Columns(10).Width = 1200
       .Columns(10).Alignment = dbgRight
       .Columns(10).NumberFormat = "0.00"
       .Columns(11).Width = 1200
       .Columns(11).Alignment = dbgRight
       .Columns(11).NumberFormat = "0.00"
       .Columns(12).Width = 1200
       .Columns(12).Alignment = dbgRight
       .Columns(12).NumberFormat = "0.00"
       .Columns(13).Width = 800
       .Columns(13).Alignment = dbgCenter
   End With
End Sub

Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
    If Check1.Value = 1 Then   '表格
       If Text1 <> "" And Text2 <> "" Then   '判断是否选择输出
          Call Ptype(1)
          Call StartCellPrint
       Else
          Call Ptype(2)
          Call StartCellPrint
       End If
    Else              '无表格
       If Text1 <> "" And Text2 <> "" Then   '判断是否选择输出
          Call Ptype(1)
          Call StartNoCellPrint
       Else
          Call Ptype(2)
          Call StartNoCellPrint
       End If
    End If
End Sub

Private Sub Toolbar2_ButtonClick(ByVal Button As MSComctlLib.Button)
    Unload Me
End Sub

'开始有表格打印
Sub StartCellPrint()
    Dim i As Integer
    Dim count_user As String
    Dim dian_liang As Long
    Dim dian_fei As Double
    Dim head_title As String
    Dim zong_user As Long
    Dim users As Long
    Dim total_page As Integer
    Dim mydb As New ADODB.Connection
    
    '─││┆┈┄┆┊┌┐└┘├┤┬┴┼╱╲「」
    On Error GoTo hander
    dian_fei = 0#
    dian_liang = 0
    count_user = 0
    zong_user = 0
    users = 0
    Screen.MousePointer = 11
    head_title = pbDw & XzName & XcName & "催费清单(" & GzNian & " 年" & GzYue & "月份)"
    total_page = (Adodc1.Recordset.RecordCount + 28) / 28
    Call printer_init
    Call printer_string(0, 0, Space(23) & head_title)
      '─││┆┈┄┆┊┌┐└┘├ ┤┬ ┴ ┼╱╲「」
    Printer.Print Space(5) & "填制单位:" & XcName, Space(5) & "制表日期:" & Format(Date, "long date"), Space(5) & "单位:KWH/元" & Space(10) & "共" & IIf(total_page = 0, total_page + 1, total_page - 1) & "页"
    Printer.Print "───────────────────────────────────────────────────────────"
    Printer.Print "┌──┬───┬────────┬────┬────┬──┬──┬───┬────┬───┬────┬────┬──┐"
    Printer.Print "│表码│辅助号│   用 户  名 称 │本期示数│上期示数│退补│倍率│滞纳金│合计电量│电 价 │调整金额│合计金额│台区│"
    Printer.Print "├──┼───┼────────┼────┼────┼──┼──┼───┼────┼───┼────┼────┼──┤"
    
    For i = 0 To Adodc1.Recordset.RecordCount - 1
        If count_user < 28 Then
           With Adodc1
           Printer.Print "│" & Left(.Recordset.Fields("用户编码") & Space(12), 4) & "│" & Left(.Recordset.Fields("辅助号") & Space(8), 6) & "│" & Left(Trim(.Recordset.Fields("用户名称")) & Space(20), 16 - convert_str(Trim(.Recordset.Fields("用户名称")))) & "│" & Right(Space(8) & .Recordset.Fields("本期示数"), 8) & "│" & Right(Space(8) & .Recordset.Fields("上期示数"), 8) & "│" & Left(.Recordset.Fields("调整电量") & Space(8), 4) & "│" & Left(.Recordset.Fields("倍率") & Space(6), 4) & "│" & Left(Format(.Recordset.Fields("滞纳金"), "0.00") & Space(8), 6) & "│" & Right(Space(10) & .Recordset.Fields("合计电量"), 8) & "│" & Left(Format(.Recordset.Fields("电价"), "0.000") & Space(8), 6) & "│" & Right(Space(10) & Format(.Recordset.Fields("调整金额"), "0.00"), 8) & "│" & Right(Space(10) & Format(.Recordset.Fields("合计电费"), "0.00"), 8) & "│" & Left(.Recordset.Fields("台区") & Space(6), 4) & "│"
           Printer.Print "├──┼───┼────────┼────┼────┼──┼──┼───┼────┼───┼────┼────┼──┤"
           dian_liang = dian_liang + CLng(.Recordset.Fields("合计电量"))
           dian_fei = dian_fei + CDbl(.Recordset.Fields("合计电费") & 0)
           count_user = count_user + 1
           End With
         Else
           With Adodc1
           Printer.Print "│" & Left(.Recordset.Fields("用户编码") & Space(12), 4) & "│" & Left(.Recordset.Fields("辅助号") & Space(8), 6) & "│" & Left(Trim(.Recordset.Fields("用户名称")) & Space(20), 16 - convert_str(Trim(.Recordset.Fields("用户名称")))) & "│" & Right(Space(8) & .Recordset.Fields("本期示数"), 8) & "│" & Right(Space(8) & .Recordset.Fields("上期示数"), 8) & "│" & Left(.Recordset.Fields("调整电量") & Space(8), 4) & "│" & Left(.Recordset.Fields("倍率") & Space(6), 4) & "│" & Left(Format(.Recordset.Fields("滞纳金"), "0.00") & Space(8), 6) & "│" & Right(Space(10) & .Recordset.Fields("合计电量"), 8) & "│" & Left(Format(.Recordset.Fields("电价"), "0.000") & Space(8), 6) & "│" & Right(Space(10) & Format(.Recordset.Fields("调整金额"), "0.00"), 8) & "│" & Right(Space(10) & Format(.Recordset.Fields("合计电费"), "0.00"), 8) & "│" & Left(.Recordset.Fields("台区") & Space(6), 4) & "│"
           Printer.Print "└──┴───┴────────┴────┴────┴──┴──┴───┴────┴───┴────┴────┴──┘"
           dian_liang = dian_liang + CLng(.Recordset.Fields("合计电量"))
           dian_fei = dian_fei + CDbl(.Recordset.Fields("合计电费"))
           count_user = count_user + 1
           Printer.Print " ──────────────────────────────────────────────────────────"
           Printer.Print Space(5) & "本页户数:" & count_user & Space(10) & "本页电量:(KWH)" & dian_liang & Space(10) & "本页金额:(元)" & Format(dian_fei, "0.00") & Space(10) & "第" & Printer.Page & "页"
           Printer.NewPage
           count_user = 0
           dian_fei = 0#
           dian_liang = 0
           Call printer_string(0, 0, Space(23) & head_title)
           Printer.Print Space(5) & "填制单位:" & XcName, Space(5) & "制表日期" & Format(Date, "long date"), Space(5) & "单位:KWH/元" & Space(10) & "共" & total_page - 1 & "页"
           Printer.Print "────────────────────────────────────────────────────────"
           Printer.Print "┌──┬───┬────────┬────┬────┬──┬──┬───┬────┬───┬────┬────┬──┐"
           Printer.Print "│表码│辅助号│   用 户  名 称 │本期示数│上期示数│退补│倍率│滞纳金│合计电量│电 价 │调整金额│合计金额│台区│"
           Printer.Print "├──┼───┼────────┼────┼────┼──┼──┼───┼────┼───┼────┼────┼──┤"
           End With
         End If
         '此处加入换页代码
         
         If Not Adodc1.Recordset.eof Then
             Adodc1.Recordset.MoveNext
         End If
    Next
    With Adodc1
    Printer.Print "│" & Left(.Recordset.Fields("用户编码") & Space(12), 4) & "│" & Left(.Recordset.Fields("辅助号") & Space(8), 6) & "│" & Left(Trim(.Recordset.Fields("用户名称")) & Space(20), 16 - convert_str(Trim(.Recordset.Fields("用户名称")))) & "│" & Right(Space(8) & .Recordset.Fields("本期示数"), 8) & "│" & Right(Space(8) & .Recordset.Fields("上期示数"), 8) & "│" & Left(.Recordset.Fields("调整电量") & Space(8), 4) & "│" & Left(.Recordset.Fields("倍率") & Space(6), 4) & "│" & Left(Format(.Recordset.Fields("滞纳金"), "0.00") & Space(8), 6) & "│" & Right(Space(10) & .Recordset.Fields("合计电量"), 8) & "│" & Left(Format(.Recordset.Fields("电价"), "0.000") & Space(8), 6) & "│" & Right(Space(10) & Format(.Recordset.Fields("调整金额"), "0.00"), 8) & "│" & Right(Space(10) & Format(.Recordset.Fields("合计电费"), "0.00"), 8) & "│" & Left(.Recordset.Fields("台区") & Space(6), 4) & "│"
    Printer.Print "└──┴───┴────────┴────┴────┴──┴──┴───┴────┴───┴────┴────┴──┘"
    dian_liang = dian_liang + CLng(.Recordset.Fields("合计电量"))
    dian_fei = dian_fei + CDbl(.Recordset.Fields("合计电费"))
    count_user = count_user + 1
    Printer.Print " ────────────────────────────────────────────────────────; """
    Printer.Print Space(5) & "本页户数:" & count_user & Space(10) & "本页电量(KWH):" & dian_liang & Space(10) & "本页金额(元):" & Format(dian_fei, "0.00") & Space(10) & "第" & Printer.Page & "页"
    End With
    Printer.EndDoc
    Screen.MousePointer = 0
    MsgBox "打印完毕!", vbInformation
    Exit Sub
hander:
        If Err.Number = 482 Then
           MsgBox "打印机错误!", vbCritical
           Screen.MousePointer = 0
           Exit Sub
        Else
           Resume Next
        End If

End Sub

'开始无表格输出
Sub StartNoCellPrint()
    Dim i As Integer
    Dim count_user As String
    Dim dian_liang As Long
    Dim dian_fei As Double
    Dim head_title As String
    Dim zong_user As Long
    Dim users As Long
    Dim total_page As Integer
    Dim mydb As New ADODB.Connection
    
    '─││┆┈┄┆┊┌┐└┘├┤┬┴┼╱╲「」
    On Error GoTo hander
    dian_fei = 0#
    dian_liang = 0
    count_user = 0
    zong_user = 0
    users = 0
    Screen.MousePointer = 11
    head_title = pbDw & XzName & XcName & "催费清单(" & GzNian & " 年" & GzYue & "月份)"
       With Adodc1
       total_page = (.Recordset.RecordCount + 60) / 61
       Call printer_init
       Call printer_string(0, 0, Space(26) & head_title)
       Printer.Print Space(5) & "填制单位:" & XcName, Space(5) & "制表日期" & Format(Date, "long date"), Space(5) & "单位:KWH/元" & Space(10) & "共" & total_page - 1 & "页"
       Printer.Print "────────────────────────────────────────────────────────"
       Printer.CurrentX = 0
       Printer.Print "表码  辅助号  用户名称         本期示数  上期示数  退补 倍率 滞纳金  合计电量  电价  调整金额  合计金额  台区"
       For i = 0 To .Recordset.RecordCount - 1
          ' Call printer_record(.Recordset.Fields("用户编码"), .Recordset.Fields("辅助号"), .Recordset.Fields("用户名称"), .Recordset.Fields("本期示数"), .Recordset.Fields("上期示数"), .Recordset.Fields("调整电量"), .Recordset.Fields("倍率"), .Recordset.Fields("滞纳金"), .Recordset.Fields("合计电量"), .Recordset.Fields("电价"), .Recordset.Fields("调整金额"), .Recordset.Fields("合计电费"), .Recordset.Fields("台区"))
          ' Printer.Print " " & .Recordset.Fields!用户编码 & Space(2) & .Recordset.Fields!辅助号 & Space(2) & Left(Trim(.Recordset.Fields("用户名称")) & Space(20), 16 - convert_str(Trim(.Recordset.Fields("用户名称")))) & .Recordset.Fields!本期示数 & Space(4) & .Recordset.Fields!上期示数 & Space(4) & .Recordset.Fields!调整电量 & Space(4) & .Recordset.Fields!倍率 & Space(4) & Format(.Recordset.Fields!滞纳金, "0.00") & Space(4) & .Recordset.Fields!合计电量 & Space(8) & Format(.Recordset.Fields!电价, "0.000") & Space(4) & Format(.Recordset.Fields!调整金额, "0.00") & Space(4) & Format(.Recordset.Fields!合计电费, "0.00") & Space(4) & .Recordset.Fields!台区
           Printer.Print Left(.Recordset.Fields("用户编码") & Space(12), 4) & "  " & Left(.Recordset.Fields("辅助号") & Space(8), 6) & "  " & Left(Trim(.Recordset.Fields("用户名称")) & Space(20), 16 - convert_str(Trim(.Recordset.Fields("用户名称")))) & Right(Space(8) & .Recordset.Fields("本期示数"), 8) & "  " & Right(Space(8) & .Recordset.Fields("上期示数"), 8) & "    " & Left(.Recordset.Fields("调整电量") & Space(8), 4) & " " & Left(.Recordset.Fields("倍率") & Space(6), 4) & Left(Format(.Recordset.Fields("滞纳金"), "0.00") & Space(8), 6) & Right(Space(10) & .Recordset.Fields("合计电量"), 8) & "    " & Left(Format(.Recordset.Fields("电价"), "0.000") & Space(8), 6) & Right(Space(10) & Format(.Recordset.Fields("调整金额"), "0.00"), 8) & "  " & Right(Space(10) & Format(.Recordset.Fields("合计电费"), "0.00"), 8) & "   " & Left(.Recordset.Fields("台区") & Space(6), 4)
           dian_liang = dian_liang + CLng(.Recordset.Fields("合计电量"))
           dian_fei = dian_fei + CDbl(.Recordset.Fields("合计电费"))
           count_user = count_user + 1
           If Not .Recordset.eof Then
                  .Recordset.MoveNext
           End If
           If count_user > 59 Then
              Printer.Print "────────────────────────────────────────────────────────"
              Printer.Print "本页表数:" & count_user & Space(15) & "合计电量:" & dian_liang & "KWH" & Space(10) & "合计金额:" & Format(dian_fei, "0.0000") & "元" & Space(20) & " 第" & Printer.Page & "页"
              Printer.NewPage
              dian_fei = 0#
              dian_liang = 0
              count_user = 0
              Call printer_string(0, 0, Space(23) & head_title)
              
              Printer.Print Space(5) & "填制单位:" & XcName, Space(5) & "制表日期" & Format(Date, "long date"), Space(5) & "单位:KWH/元" & Space(10) & "共" & total_page - 1 & "页"
              Printer.Print "────────────────────────────────────────────────────────"
              Printer.CurrentX = 0
              Printer.Print "表码  辅助号  用户名称         本期示数  上期示数  退补 倍率 滞纳金  合计电量  电价  调整金额  合计金额  台区"
           End If
       Next
       Printer.Print "────────────────────────────────────────────────────────"
       Printer.Print "本页表数:" & count_user & Space(15) & "合计电量:" & dian_liang & "KWH" & Space(10) & "合计金额:" & Format(dian_fei, "0.0000") & "元" & Space(20) & " 第" & Printer.Page & "页"
       End With
       Call PrinterEnd
       Screen.MousePointer = 0
       MsgBox "打印结束!", vbInformation
       Exit Sub

hander:
        If Err.Number = 482 Then
           MsgBox "打印机错误!", vbCritical
           Screen.MousePointer = 0
           Exit Sub
        Else
           Resume Next
        End If

End Sub

Sub Ptype(ByVal Tp As Integer)
    If Tp = 1 Then
          Adodc1.RecordSource = "SELECT 用户电费.用户编码,用户电费.用户名称,用户电费.[" & AAA & "] AS 上期示数, 用户电费.[" & aa & "] AS 本期示数,用户电费.表损, 用户电费.倍率,用户电费.[" & BB & "] AS 调整电量,用户电费.[" & CC & "] AS 本次电量, 用户电费.[" & DD & "] AS 合计电量,用户电费.电价,用户电费.[" & EE & "] AS 调整金额, 用户电费.[" & FF & "] AS 滞纳金, 用户电费.[" & GG & "] AS 本次电费, 用户电费.[" & HH & "] AS 合计电费,用户电费.[" & II & "] AS 代扣信息,用户电费.[" & JJ & "] AS 发票打印,用户电费.[" & KK & "] AS 交费情况,用户电费.组合编码,用户电费.辅助号,用户电费.台区 From 用户电费 WHERE  用户电费.镇村代码='" & UserSeek & "' and  用户电费.用户编码 <='" & Trim(Text2) & "' order by 用户电费.组合编码 asc"
          Adodc1.Refresh
    Else
          Adodc1.RecordSource = "SELECT 用户电费.用户编码,用户电费.用户名称,用户电费.[" & AAA & "] AS 上期示数, 用户电费.[" & aa & "] AS 本期示数,用户电费.表损, 用户电费.倍率,用户电费.[" & BB & "] AS 调整电量,用户电费.[" & CC & "] AS 本次电量, 用户电费.[" & DD & "] AS 合计电量,用户电费.电价,用户电费.[" & EE & "] AS 调整金额, 用户电费.[" & FF & "] AS 滞纳金, 用户电费.[" & GG & "] AS 本次电费, 用户电费.[" & HH & "] AS 合计电费,用户电费.[" & II & "] AS 代扣信息,用户电费.[" & JJ & "] AS 发票打印,用户电费.[" & KK & "] AS 交费情况,用户电费.组合编码,用户电费.台区 From 用户电费 WHERE 用户电费.镇村代码='" & UserSeek & "' order by 用户电费.组合编码 asc"
          Adodc1.Refresh
    End If
End Sub

⌨️ 快捷键说明

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