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

📄 printcblist.frm

📁 适合乡镇供电所使用电费处理系统v3 软件
💻 FRM
📖 第 1 页 / 共 2 页
字号:
    ListView1.ListItems.Clear
    If Not MdbR.eof Then
          MdbR.MoveFirst
          For intCounter = 0 To MdbR.RecordCount - 1
              If MdbR!多价表 Then
                 Set itm1 = ListView1.ListItems.Add(, , CStr(MdbR!用户编码))
                 itm1.ForeColor = &HC000C0
                 itm1.SubItems(1) = MdbR!用户名称 & ""
                 itm1.ListSubItems(1).ForeColor = &HC000C0
                 itm1.SubItems(2) = MdbR!上期示数 & ""
                 itm1.ListSubItems(2).ForeColor = &HC000C0
                 itm1.SubItems(3) = MdbR!本期示数 & ""
                 itm1.ListSubItems(3).ForeColor = &HC000C0
              Else
              If MdbR!用户类型 = "工业动力" Then
                 Set itm1 = ListView1.ListItems.Add(, , CStr(MdbR!用户编码))
                 itm1.ForeColor = &HFF0000
                 itm1.SubItems(1) = MdbR!用户名称 & ""
                 itm1.ListSubItems(1).ForeColor = &HFF0000
                 itm1.SubItems(2) = MdbR!上期示数 & ""
                 itm1.ListSubItems(2).ForeColor = &HFF0000
                 itm1.SubItems(3) = MdbR!本期示数 & ""
                 itm1.ListSubItems(3).ForeColor = &HFF0000
              Else
                  Set itm1 = ListView1.ListItems.Add(, , CStr(MdbR!用户编码))
                  itm1.ForeColor = vbBlack
                  itm1.SubItems(1) = MdbR!用户名称 & ""
                  itm1.ListSubItems(1).ForeColor = vbBlack
                  itm1.SubItems(2) = MdbR!上期示数 & ""
                  itm1.ListSubItems(2).ForeColor = vbBlack
                  itm1.SubItems(3) = MdbR!本期示数 & ""
                  itm1.ListSubItems(3).ForeColor = vbBlack
               End If
            End If
                itm1.SubItems(4) = IIf(MdbR!调整电量 = 0, "", MdbR!调整电量)
                itm1.SubItems(5) = IIf(MdbR!本次电量 = 0, "", MdbR!本次电量)
                itm1.SubItems(6) = IIf(MdbR!合计电量 = 0, "", MdbR!合计电量)
                itm1.SubItems(7) = Format(MdbR!电价 & "", "0.000")
                itm1.SubItems(8) = IIf(MdbR!调整金额 = 0, "", Format(MdbR!调整金额, "0.00"))
                itm1.SubItems(9) = IIf(MdbR!本次电费 = 0, "", Format(MdbR!本次电费, "0.00"))
                itm1.SubItems(10) = IIf(MdbR!合计电费 = 0, "", Format(MdbR!合计电费, "0.00"))
                MdbR.MoveNext
                DoEvents
          Next
          ListView1.Sorted = True
     Else
          MsgBox XzName & XcName & GzYue & "月用户纪录为空!", vbCritical
          Screen.MousePointer = 0
          Exit Sub
     End If
     Screen.MousePointer = 0
End Sub


Private Sub Text1_Change()
 Call CheckIsNumber(Text1)
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
   If KeyAscii = 13 Then
      Text2.SetFocus
   End If
End Sub


Private Sub Text2_Change()
 Call CheckIsNumber(Text2)
End Sub

Private Sub Text2_keyPress(KeyAscii As Integer)
   If KeyAscii = 13 Then
       If Text1 <> "" And Text2 <> "" Then   '判断是否选择输出
          Set MdbR = NdMd.OpenRecordset("SELECT 用户电费.用户编码,用户电费.用户名称,用户电费.[" & AAA & "] AS 上期示数, 用户电费.[" & AA & "] AS 本期示数, 用户电费.倍率,用户电费.[" & BB & "] AS 调整电量,用户电费.[" & CC & "] AS 本次电量, 用户电费.[" & DD & "] AS 合计电量,用户电费.电价,用户电费.[" & EE & "] AS 调整金额, 用户电费.[" & FF & "] AS 滞纳金, 用户电费.[" & GG & "] AS 本次电费, 用户电费.[" & HH & "] AS 合计电费,用户电费.台区,用户电费.组合编码,用户电费.辅助号 From 用户电费 where 用户电费.镇村代码 ='" & UserSeek & "' and  用户电费.用户编码 >='" & Trim(Text1) & "' and  用户电费.用户编码 <='" & Trim(Text2) & "' order by [用户电费].[用户编码] asc")
       End If
   End If

End Sub

Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
    If Check1.Value = 1 Then   '表格
       If Text1 <> "" And Text2 <> "" Then   '判断是否选择输出
          Set MdbR = NdMd.OpenRecordset("SELECT 用户电费.用户编码,用户电费.用户名称,用户电费.[" & AAA & "] AS 上期示数, 用户电费.[" & AA & "] AS 本期示数, 用户电费.倍率,用户电费.[" & BB & "] AS 调整电量,用户电费.[" & CC & "] AS 本次电量, 用户电费.[" & DD & "] AS 合计电量,用户电费.电价,用户电费.[" & EE & "] AS 调整金额, 用户电费.[" & FF & "] AS 滞纳金, 用户电费.[" & GG & "] AS 本次电费, 用户电费.[" & HH & "] AS 合计电费,用户电费.台区,用户电费.组合编码,用户电费.辅助号 From 用户电费 where 用户电费.镇村代码 ='" & UserSeek & "' and  用户电费.用户编码 >='" & Trim(Text1) & "' and  用户电费.用户编码 <='" & Trim(Text2) & "' order by [用户电费].[用户编码] asc")
          Call StartCellPrint
       Else
          Set MdbR = NdMd.OpenRecordset("SELECT 用户电费.用户编码,用户电费.用户名称,用户电费.[" & AAA & "] AS 上期示数, 用户电费.[" & AA & "] AS 本期示数, 用户电费.倍率,用户电费.[" & BB & "] AS 调整电量,用户电费.[" & CC & "] AS 本次电量, 用户电费.[" & DD & "] AS 合计电量,用户电费.电价,用户电费.[" & EE & "] AS 调整金额, 用户电费.[" & FF & "] AS 滞纳金, 用户电费.[" & GG & "] AS 本次电费, 用户电费.[" & HH & "] AS 合计电费,用户电费.台区,用户电费.组合编码,用户电费.辅助号 From 用户电费 where 用户电费.镇村代码 ='" & UserSeek & "' order by [用户电费].[用户编码] asc")
          Call StartCellPrint
       End If
    Else              '无表格
       If Text1 <> "" And Text2 <> "" Then   '判断是否选择输出
          Set MdbR = NdMd.OpenRecordset("SELECT 用户电费.用户编码,用户电费.用户名称,用户电费.[" & AAA & "] AS 上期示数, 用户电费.[" & AA & "] AS 本期示数, 用户电费.倍率,用户电费.[" & BB & "] AS 调整电量,用户电费.[" & CC & "] AS 本次电量, 用户电费.[" & DD & "] AS 合计电量,用户电费.电价,用户电费.[" & EE & "] AS 调整金额, 用户电费.[" & FF & "] AS 滞纳金, 用户电费.[" & GG & "] AS 本次电费, 用户电费.[" & HH & "] AS 合计电费,用户电费.台区,用户电费.组合编码,用户电费.辅助号 From 用户电费 where 用户电费.镇村代码 ='" & UserSeek & "' and  用户电费.用户编码 >='" & Trim(Text1) & "' and  用户电费.用户编码 <='" & Trim(Text2) & "' order by [用户电费].[用户编码] asc")
          Call StartNoCellPrint
       Else
          Set MdbR = NdMd.OpenRecordset("SELECT 用户电费.用户编码,用户电费.用户名称,用户电费.[" & AAA & "] AS 上期示数, 用户电费.[" & AA & "] AS 本期示数, 用户电费.倍率,用户电费.[" & BB & "] AS 调整电量,用户电费.[" & CC & "] AS 本次电量, 用户电费.[" & DD & "] AS 合计电量,用户电费.电价,用户电费.[" & EE & "] AS 调整金额, 用户电费.[" & FF & "] AS 滞纳金, 用户电费.[" & GG & "] AS 本次电费, 用户电费.[" & HH & "] AS 合计电费,用户电费.台区,用户电费.组合编码,用户电费.辅助号 From 用户电费 where 用户电费.镇村代码 ='" & UserSeek & "' order by [用户电费].[用户编码] asc")
          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
    On Error GoTo hander
    dian_fei = 0#
    dian_liang = 0
    count_user = 0
    zong_user = 0
    users = 0
    Screen.MousePointer = 11
    head_title = XcName & "抄表清单(" & GzNian & " 年" & GzYue & "月份)"
    total_page = (MdbR.RecordCount + 28) / 28
    Call printer_init
    Call printer_string(0, 0, Space(23) & head_title)
    Printer.Print Space(5) & "填制单位:" & pbDw & XzName, 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 MdbR.RecordCount - 1
        If count_user < 28 Then
           With MdbR
           Printer.Print "│" & Left(.Fields("用户编码") & Space(12), 4) & "│" & Left(.Fields("辅助号") & Space(8), 6) & "│" & Left(Trim(.Fields("用户名称")) & Space(20), 16 - convert_str(Trim(.Fields("用户名称")))) & "│" & Right(Space(8) & .Fields("本期示数"), 8) & "│" & Right(Space(8) & .Fields("上期示数"), 8) & "│" & Left(.Fields("调整电量") & Space(8), 4) & "│" & Left(.Fields("倍率") & Space(6), 4) & "│" & Right(Space(10) & .Fields("合计电量"), 8) & "│" & Left(Format(.Fields("电价"), "0.000") & Space(8), 6) & "│" & Right(Space(10) & Format(.Fields("调整金额"), "0.00"), 8) & "│" & Right(Space(10) & Format(.Fields("合计电费"), "0.00"), 8) & "│"
           Printer.Print "├──┼───┼────────┼────┼────┼──┼──┼────┼───┼────┼────┤"
           dian_liang = dian_liang + CLng(.Fields("合计电量"))
           dian_fei = dian_fei + CDbl(.Fields("合计电费") & 0)
           count_user = count_user + 1
           End With
         Else
           With MdbR
           Printer.Print "│" & Left(.Fields("用户编码") & Space(12), 4) & "│" & Left(.Fields("辅助号") & Space(8), 6) & "│" & Left(Trim(.Fields("用户名称")) & Space(20), 16 - convert_str(Trim(.Fields("用户名称")))) & "│" & Right(Space(8) & .Fields("本期示数"), 8) & "│" & Right(Space(8) & .Fields("上期示数"), 8) & "│" & Left(.Fields("调整电量") & Space(8), 4) & "│" & Left(.Fields("倍率") & Space(6), 4) & "│" & Right(Space(10) & .Fields("合计电量"), 8) & "│" & Left(Format(.Fields("电价"), "0.000") & Space(8), 6) & "│" & Right(Space(10) & Format(.Fields("调整金额"), "0.00"), 8) & "│" & Right(Space(10) & Format(.Fields("合计电费"), "0.00"), 8) & "│"
           Printer.Print "└──┴───┴────────┴────┴────┴──┴──┴────┴───┴────┴────┘"
           dian_liang = dian_liang + CLng(.Fields("合计电量"))
           dian_fei = dian_fei + CDbl(.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 MdbR.eof Then
             MdbR.MoveNext
         End If
    Next
    With MdbR
    Printer.Print "│" & Left(.Fields("用户编码") & Space(12), 4) & "│" & Left(.Fields("辅助号") & Space(8), 6) & "│" & Left(Trim(.Fields("用户名称")) & Space(20), 16 - convert_str(Trim(.Fields("用户名称")))) & "│" & Right(Space(8) & .Fields("本期示数"), 8) & "│" & Right(Space(8) & .Fields("上期示数"), 8) & "│" & Left(.Fields("调整电量") & Space(8), 4) & "│" & Left(.Fields("倍率") & Space(6), 4) & "│" & Right(Space(10) & .Fields("合计电量"), 8) & "│" & Left(Format(.Fields("电价"), "0.000") & Space(8), 6) & "│" & Right(Space(10) & Format(.Fields("调整金额"), "0.00"), 8) & "│" & Right(Space(10) & Format(.Fields("合计电费"), "0.00"), 8) & "│"
    Printer.Print "└──┴───┴────────┴────┴────┴──┴──┴───┴────┴───┴────┴────┴──┘"
    dian_liang = dian_liang + CLng(.Fields("合计电量"))
    dian_fei = dian_fei + CDbl(.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
    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 MdbR
       total_page = (.RecordCount + 60) / 60
       Call printer_init
       Call printer_string(0, 0, Space(30) & head_title)
       Printer.Print Space(8) & "单位:" & XcName, Space(5) & "日期:" & Format(Date, "long date"), Space(9) & "单位:KWH/元" & Space(15) & "共" & total_page - 1 & "页"   '   total_page - 1
       Printer.Print "     ─────────────────────────────────────────────────────"
       Printer.CurrentX = 0
       Printer.Print "     编码  辅助号  用户名称         本期示数  上期示数  加减 倍率 滞纳金  合计电量  电价  本期余额  合计金额"    '  台区"
       For i = 0 To .RecordCount - 1
           Printer.Print Space(5) & Left(.Fields("用户编码") & Space(12), 4) & "  " & Left(.Fields("辅助号") & Space(8), 6) & "  " & Left(Trim(.Fields("用户名称")) & Space(20), 16 - convert_str(Trim(.Fields("用户名称")))) & Right(Space(8) & .Fields("本期示数"), 8) & "  " & Right(Space(8) & .Fields("上期示数"), 8) & "    " & Left(.Fields("调整电量") & Space(8), 4) & " " & Left(.Fields("倍率") & Space(6), 4) & Left(Format(.Fields("滞纳金"), "0.00") & Space(8), 6) & Right(Space(10) & .Fields("合计电量"), 8) & "    " & Left(Format(.Fields("电价"), "0.000") & Space(8), 6) & Right(Space(10) & Format(.Fields("调整金额"), "0.00"), 8) & "  " & Right(Space(10) & Format(.Fields("合计电费"), "0.00"), 8)     '& "   " & Left(.Fields("台区") & Space(6), 4)
           dian_liang = dian_liang + CLng(.Fields("合计电量"))
           dian_fei = dian_fei + CDbl(.Fields("合计电费"))
           count_user = count_user + 1
           If Not .eof Then
                  .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.00") & "元" & Space(20) & " 第" & Printer.Page & "页"
              Printer.NewPage
              dian_fei = 0#
              dian_liang = 0
              count_user = 0
              Call printer_string(0, 0, Space(30) & head_title)
              
              Printer.Print Space(8) & "单位:" & XcName, Space(5) & "日期:" & Format(Date, "long date"), Space(9) & "单位:KWH/元" & Space(15) & "共" & 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.00") & "元" & Space(20) & " 第" & 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

⌨️ 快捷键说明

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