📄 printinvoice.frm
字号:
Call ProcView(54, PrinXY(1))
Call ProcView(55, PrinXY(2))
Call ProcView(56, PrinXY(3))
For it = 1 To ListView1.ListItems.Count
Set ListView1.SelectedItem = ListView1.ListItems(it)
Select Case it
Case 1
Call ProcView(60, PrinXY(6))
Case 2
If ListView1.ListItems.Count = 2 Then
Call ProcView(61, PrinXY(7))
Else
Call ProcView(61, PrinXY(6))
End If
Case 3
If ListView1.ListItems.Count = 3 Then
Call ProcView(62, PrinXY(7))
Else
Call ProcView(62, PrinXY(6))
End If
Case 4
If ListView1.ListItems.Count = 4 Then
Call ProcView(63, PrinXY(7))
Else
Call ProcView(63, PrinXY(6))
End If
End Select
Next
'大写
Call ProcView(67, PrinXY(4))
Call ProcView(69, PrinXY(5))
'开始打印
Call StartPrint
'换页
Printer.NewPage
'计时器清0
kj = 0
Call RestFP
End Select
kj = kj + 1
Next
Screen.MousePointer = 0
If InStr(MdbR.RecordCount / 4, ".") > 0 Then
Call StartPrint
End If
NdMd.Execute "UPDATE 用户电费 SET 用户电费.[" & JJ & "]=1 WHERE 用户电费.组合编码>= '" & IIf(Len(Trim(Text4)) <> 4, UserSeek & Right("0000" + Trim(Text4), 4), UserSeek & Trim(Text4)) & "' and 用户电费.组合编码 <='" & IIf(Len(Trim(Text5)) <> 4, UserSeek & Right("0000" + Trim(Text5), 4), UserSeek & Trim(Text5)) & "'"
Printer.EndDoc
Else
MsgBox "没有数据要打印,请检查输入起始是否正确,或发票已开或用户停用!", vbExclamation
Exit Sub
End If
End With
End If
Exit Sub
hander:
Select Case Err.Number
Case 482:
MsgBox "打印机错误!请检查打印机是否存在!", vbExclamation
Exit Sub
Case Else
Resume Next
End Select
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Me.Move (Screen.Width - Me.Width) \ 2, (Screen.Height - Me.Height) \ 2 '1 - 950
Frame4.Enabled = False
Label7.Enabled = False
Label8.Enabled = False
Text4.Enabled = False
Text5.Enabled = False
Text3.Enabled = False
Frame3.Enabled = False
Label36.Enabled = False
Label37.Enabled = False
Label38.Enabled = False
Command1.Enabled = False
Label4.Caption = Label4.Caption
Label13.Caption = pbDw
If Len(UserSeek) = 0 Then
GzYue = Format(Month(Date), "0#")
Call sTruInfo
End If
OpenMdb
End Sub
Private Sub Option1_Click()
Label7.Enabled = False
Label8.Enabled = False
Picture1.Visible = True
Label36.Enabled = True
Label37.Enabled = True
Label38.Enabled = True
Frame3.Enabled = True
Frame4.Enabled = False
Text4.Enabled = False
Text5.Enabled = False
Text3.Enabled = True
Command1.Enabled = False
Text3.SelStart = 0
Text3.SelLength = Len(Text3)
Text3.SetFocus
End Sub
Private Sub Option2_Click()
Command1.Enabled = False
Frame3.Enabled = False
Text3.Enabled = False
Label36.Enabled = False
Label37.Enabled = False
Label38.Enabled = False
Picture1.Visible = True
Frame4.Enabled = True
Label7.Enabled = True
Label8.Enabled = True
Text4.Enabled = True
Text5.Enabled = True
Text4.SetFocus
End Sub
Private Sub Text3_Change()
Call CheckIsNumber(Text4)
End Sub
Sub Text3_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Set MdbR = NdMd.OpenRecordset("SELECT 用户电费.用户名称,用户电费.组合编码,用户电费.[" & JJ & "] AS 发票打印,用户电费.停用,用户电费.主表 From 用户电费 WHERE 用户电费.组合编码='" & UserSeek & Format(Trim(Text3), "0000") & "' and 用户电费.主表=-1")
If MdbR.RecordCount = 0 Then
MsgBox "无此用户,请检查代码的正确性!", vbCritical
Text3.SelStart = 0
Text3.SelLength = Len(Text3)
Text3.SetFocus
Else
Set MdbR = NdMd.OpenRecordset("SELECT SUM(用户电费.[" & HH & "]) AS 表计电量 From 用户电费 WHERE 用户电费.组合编码='" & UserSeek & Format(Trim(Text3), "0000") & "'")
If MdbR.Fields!表计电量 = 0 Or MdbR.Fields!表计电量 < 0 Then
MsgBox Text3 & "本次没有用电或本期抄表错误!", vbCritical
Text3.SelStart = 0
Text3.SelLength = Len(Text3)
Text3.SetFocus
Exit Sub
End If
Set MdbR = NdMd.OpenRecordset("SELECT 用户电费.用户名称,用户电费.组合编码,用户电费.[" & JJ & "] AS 发票打印,用户电费.停用,用户电费.主表 From 用户电费 WHERE 用户电费.组合编码='" & UserSeek & Format(Trim(Text3), "0000") & "' and 用户电费.主表=-1")
If MdbR.Fields!发票打印 = True Then
MsgBox Text3 & MdbR.Fields!用户名称 & "发票已打印,如要重新打印请先恢复此用户!", vbCritical
Text3.SelStart = 0
Text3.SelLength = Len(Text3)
Text3.SetFocus
Exit Sub
End If
If MdbR.Fields!停用 = True Then
MsgBox Text3 & MdbR.Fields!用户名称 & "已停止用电!", vbCritical
Text3.SelStart = 0
Text3.SelLength = Len(Text3)
Text3.SetFocus
Exit Sub
End If
Call ViewFP(MdbR.Fields!组合编码)
Command1.Enabled = True
'Text6.SetFocus
End If
End If
End Sub
Private Sub Text4_Change()
Call CheckIsNumber(Text4)
End Sub
Sub Text4_keyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If Text4.Text <> "" Then
Text5.SetFocus
End If
End If
End Sub
Private Sub Text5_Change()
Call CheckIsNumber(Text5)
End Sub
Sub Text5_keyPress(KeyAscii As Integer)
Dim SqlStr1 As String
If KeyAscii = 13 Then
If Text5.Text <> "" And Val(Text5) < Val(Text4) Then
MsgBox "数据输入有误!", vbCritical
Text5.SelStart = 0
Text5.SelLength = Len(Text5)
Text5.SetFocus
Else
SqlStr1 = "SELECT 用户电费.用户编码,用户电费.用户名称,用户电费.多价表," _
& "用户电费.[" & AAA & "] AS 上期示数, 用户电费.[" & AA & "] AS 本期示数," _
& "用户电费.表损, 用户电费.倍率,用户电费.[" & BB & "] AS 调整电量," _
& "用户电费.[" & CC & "] AS 本次电量, 用户电费.[" & DD & "] AS 合计电量," _
& "用户电费.电价,用户电费.[" & EE & "] AS 调整金额,用户电费.比率1,用户电费.比率1名称,用户电费.比率1电价,用户电费.比率1电量,用户电费.比率1电费,用户电费.比率2,用户电费.比率2名称,用户电费.比率2电价,用户电费.比率2电量,用户电费.比率2电费," _
& "用户电费.[" & FF & "] AS 滞纳金, 用户电费.[" & GG & "] AS 本次电费," _
& "用户电费.[" & HH & "] AS 合计电费," _
& "用户电费.组合编码,用户电费.[" & JJ & "] AS 打印,用户电费.主表 From 用户电费 " _
& "WHERE 用户电费.组合编码>= '" & IIf(Len(Trim(Text4)) <> 4, UserSeek & Right("0000" + Trim(Text4), 4), UserSeek & Trim(Text4)) & "' and 用户电费.组合编码 <='" & IIf(Len(Trim(Text5)) <> 4, UserSeek & Right("0000" + Trim(Text5), 4), UserSeek & Trim(Text5)) & "' and 用户电费.[" & JJ & "]=0 AND 用户电费.[" & DD & "]>0 and 用户电费.主表=-1 ORDER BY 用户电费.组合编码 ASC"
Set MdbR = NdMd.OpenRecordset(SqlStr1)
If MdbR.RecordCount <> 0 Then
MdbR.MoveLast
MdbR.MoveFirst
Label24.Caption = "本次打印:" & MdbR.RecordCount & "户" & "需发票纸:" & IIf(Val(Format((MdbR.RecordCount / 4), "00")) = 0, 1, Val(Format((MdbR.RecordCount / 4), "00"))) & "张"
Command1.Enabled = True
Command1.SetFocus
Else
MsgBox "未检索到用户信息!", vbInformation
Exit Sub
End If
End If
End If
End Sub
Sub ViewFP(yhbm As String)
Dim I As Integer, II As Integer, JSQ As Integer
Dim itm As ListItem
Dim DisPDL As Long, DispDF As Currency, HjFee As Currency, HjElec As Currency, Scye As Currency
Dim PriReco As Recordset, fpMDB As Recordset
Dim dispSer As String
On Error Resume Next
Set PriReco = NdMd.OpenRecordset("SELECT 用户电费.台区,用户电费.用户编码,用户电费.用户名称,用户电费.[" & AAA & "] AS 上期示数, 用户电费.[" & AA & "] AS 本期示数," _
& "用户电费.[" & CC & "] AS 本次电量,用户电费.[" & DDD & "] AS 上期余额,用户电费.[" & EE & "] AS 本期余额," _
& "用户电费.倍率,用户电费.表损, 用户电费.[" & BB & "] AS 调整电量,用户电费.[" & DD & "] AS 合计电量," _
& "用户电费.电价,用户电费.[" & GG & "] AS 本次电费,用户电费.[" & HH & "] AS 合计电费,用户电费.比率1电量,用户电费.比率1电价,用户电费.比率1电费,用户电费.比率2电量,用户电费.比率2电价,用户电费.比率2电费,用户电费.组合编码,用户电费.多价表,用户电费.多表序号 From 用户电费 WHERE 用户电费.组合编码='" & yhbm & "' order by 用户电费.多表序号")
PriReco.MoveLast
PriReco.MoveFirst
Label1(0).Caption = XcName ' PriReco.Fields(0) & ""
Label1(1).Caption = PriReco.Fields(1) & ""
Label1(2).Caption = PriReco.Fields(2) & ""
ListView1.ListItems.Clear
DisPDL = 0
DispDF = 0
Scye = 0
For I = 0 To PriReco.RecordCount - 1
If PriReco.Fields!多价表 Then
For JSQ = 0 To 2
Select Case JSQ
Case 0
Set itm = ListView1.ListItems.Add(, , Val(PriReco!上期示数))
If Not IsNull(PriReco!本期示数) Then
itm.SubItems(1) = Val(PriReco!本期示数)
End If
If Not IsNull(PriReco!比率1电量) Then
itm.SubItems(2) = PriReco!比率1电量
End If
If Not IsNull(PriReco!倍率) Then
itm.SubItems(3) = PriReco!倍率
End If
If Not IsNull(PriReco!表损) Then
itm.SubItems(4) = PriReco!表损
End If
If Not IsNull(PriReco!调整电量) Then
itm.SubItems(5) = PriReco!调整电量
End If
If Not IsNull(PriReco!比率1电价) Then
itm.SubItems(7) = Format(PriReco!比率1电价, "0.00")
End If
If Not IsNull(PriReco!比率1电费) Then
itm.SubItems(8) = Format(PriReco!比率1电费, "0.0")
End If
HjElec = HjElec + PriReco!比率1电量
HjFee = HjFee + PriReco!比率1电费
Case 1
Set itm = ListView1.ListItems.Add(, , Val(PriReco!上期示数))
If Not IsNull(PriReco!本期示数) Then
itm.SubItems(1) = Val(PriReco!本期示数)
End If
If Not IsNull(PriReco!比率2电量) Then
itm.SubItems(2) = PriReco!比率2电量
End If
If Not IsNull(PriReco!比率2电价) Then
itm.SubItems(7) = Format(PriReco!比率2电价, "0.00")
End If
If Not IsNull(PriReco!比率2电费) Then
itm.SubItems(8) = Format(PriReco!比率2电费, "0.0")
End If
HjElec = HjElec + PriReco!比率2电量
HjFee = HjFee + PriReco!比率2电费
Case 2
Set itm = ListView1.ListItems.Add(, , "合计:")
If Not IsNull(PriReco!本次电量) Then
itm.SubItems(2) = PriReco!本次电量
End If
If Not IsNull(PriReco!合计电量) Then
itm.SubItems(6) = PriReco!合计电量
End If
If Not IsNull(PriReco!合计电费) Then
itm.SubItems(8) = Format(PriReco!合计电费, "0.0")
End If
Scye = PriReco.Fields!上期余额
End Select
Next
Else
Set itm = ListView1.ListItems.Add(, , Val(PriReco!上期示数 & ""))
If Not IsNull(PriReco!本期示数) Then
itm.SubItems(1) = Val(PriReco!本期示数)
End If
If Not IsNull(PriReco!本次电量) Then
itm.SubItems(2) = PriReco!本次电量
End If
If Not IsNull(PriReco!倍率) Then
itm.SubItems(3) = PriReco!倍率
End If
If Not IsNull(PriReco!表损) Then
itm.SubItems(4) = PriReco!表损
End If
If Not IsNull(PriReco!调整电量) Then
itm.SubItems(5) = PriReco!调整电量
End If
If Not IsNull(PriReco!合计电量) Then
itm.SubItems(6) = PriReco!合计电量
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -