📄 createuser.frm
字号:
Text1(Index).SetFocus
Exit Sub
End If
Set MdbR = NdMd.OpenRecordset("select 用户电费.镇代码,用户电费.村代码,用户电费.镇村代码,用户电费.组合编码,用户电费.用户编码,用户电费.辅助号,用户电费.抄表码,用户电费.多表户,用户电费.相数标识,用户电费.主表,用户电费.多表序号,用户电费.用户名称,用户电费.全称,用户电费.地址,用户电费.电话,用户电费.开户银行,用户电费.账号,用户电费.台区,用户电费.电价类别,用户电费.电价,用户电费.倍率,用户电费.表损,用户电费.用户类型,用户电费.台变类型,用户电费.[" & AAA & "] AS 上期示数,用户电费.电建,用户电费.三峡 from 用户电费 where 用户电费.组合编码 ='" & UserSeek & Trim(Text1(0).Text) & "' and 用户电费.主表=-1")
If MdbR.RecordCount <> 0 Then
Dim Uselect As Integer
Uselect = MsgBox(" 该编码的用户资料已存在,若该用户有多只电表" & Chr(13) & "请按[是]按钮开始增加电表资料,否则请按[否]按钮," & Chr(13) & "重新给该用户分配编码!", vbInformation + vbYesNo + vbDefaultButton2)
If Uselect = 6 Then '多表户
Text1(1).Text = MdbR.Fields!用户名称
Text1(2).Text = MdbR.Fields!全称
Text1(3).Text = MdbR.Fields!地址
Combo1(0).Text = MdbR.Fields!台区
If MdbR.Fields!台变类型 = "公用变" Then
Option1.Value = True
Else
If IsNull(MdbR.Fields!台变类型) Then
Option1.Value = True
Else
Option2.Value = True
End If
End If
Frame1.Enabled = False
Frame2.Enabled = True
Command1(0).Enabled = False
If Check1.Value = 1 Then
Set MdbR = NdMd.OpenRecordset("select max(val(用户电费.抄表码)) as sl from 用户电费 where 镇村代码='" & UserSeek & "'")
Text1(4).Text = Format(MdbR.Fields!sl + 1, "000000")
Text1(4).Enabled = False
zis = Val(Text1(4).Text) ' + 1
Combo1(1).SetFocus
Else
Text1(4).Enabled = True
Text1(4).SetFocus
End If
Command2(1).Enabled = True
'Text1(0).Locked = True
'Text1(1).SetFocus
Else
Text1(0) = ""
'Text1(0).SelStart = 0
'Text1(0).SelLength = Len(Text1(0))
Command1(0).Enabled = False
End If
Else
Text1(1).Locked = False
Text1(1).Text = ""
Text1(2).Text = ""
Text1(3).Text = ""
End If
' Case 2
Case 4 '分帐号
If Len(Text1(Index)) = 6 Then
Command2(0).Enabled = True
Else
Command2(0).Enabled = False
End If
Call CheckIsNumber(Text1(Index))
If Len(Trim(Text1(Index))) > 6 Then
MsgBox "用户辅助编码大于6位!", 48
Text1(Index).SetFocus
End If
Case 5 '倍率
Call CheckIsNumber(Text1(Index))
Case 6 '底度
Call CheckIsNumber(Text1(Index))
Case 7 '底度
Call CheckIsNumber(Text1(Index))
Case Else
If Text1(Index).Text <> Text1(Index).Tag Then
Command1(0).Caption = "保存档案(&S)"
End If
End Select
End Sub
'/////////////////////回车过程//////////////////////
'text
Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
On Error Resume Next
If KeyAscii = 13 Then
Select Case Index
Case 0 '编码
If Text1(Index).Text = "" Then
MsgBox "用户编码必须输入!", vbCritical, Me.Caption
Text1(Index).SetFocus
Exit Sub
ElseIf Len(Trim(Text1(Index).Text)) <> 4 Then
MsgBox "用户编码为4位!", vbCritical
Text1(Index).SetFocus
Exit Sub
Else
SendKeys "{tab}"
End If
Case 1
If Text1(Index).Text = "" Then
MsgBox "用户名称(简称)必须输入!", vbCritical, Me.Caption
Text1(Index).SetFocus
Exit Sub
Else
SendKeys "{tab}"
Text1(2).Text = Text1(1)
Text1(3).Text = XcName 'XzName & XcName
End If
Case 4
If Text1(Index).Text = "" Then
MsgBox "用户辅助编码必须输入!", vbCritical, Me.Caption
Text1(Index).SetFocus
Exit Sub
ElseIf Len(Trim(Text1(Index).Text)) <> 6 Then
MsgBox "用户辅助编码为6位!", vbCritical
Text1(Index).SetFocus
Exit Sub
Else
SendKeys "{tab}"
End If
Case Else
SendKeys "{tab}"
End Select
End If
End Sub
'combo
Private Sub Combo1_KeyPress(Index As Integer, KeyAscii As Integer)
If KeyAscii = 13 Then
SendKeys "{tab}"
End If
End Sub
'保存数据
Sub AppeData(RetuVal As Boolean)
'保存数据
On Error Resume Next
Set MdbR = NdMd.OpenRecordset("select count(*) as Sl from 用户电费 where 用户电费.组合编码 ='" & UserSeek & Trim(Text1(0).Text) & "' and 用户电费.主表=-1")
'找到主表信息
If MdbR.Fields!sl = 1 Then
'再找输入类型的总表数
Set MdbR = NdMd.OpenRecordset("select count(*) as Sl from 用户电费 where 用户电费.组合编码 ='" & UserSeek & Trim(Text1(0).Text) & "' and 用户电费.用户类型='普通照明'")
hjs = MdbR.Fields!sl
Set MdbR = NdMd.OpenRecordset("select count(*) as Sl from 用户电费 where 用户电费.组合编码 ='" & UserSeek & Trim(Text1(0).Text) & "' and 用户电费.用户类型='工业动力'")
jls = MdbR.Fields!sl
If Combo1(1).Text = "工业动力" Then
If jls = 3 Then
MsgBox "该户工业三相表已输入完毕,不允许再增加!", vbCritical
Combo1(1).ListIndex = 0
Combo1(1).SetFocus
Exit Sub
Else
If hjs + jls = 0 Then
zMeter = True
Else
zMeter = False
End If
Select Case jls
Case 0
XSBS = "A"
Case 1
XSBS = "B"
Case 2
XSBS = "C"
End Select
Call SaveUser
End If
Else
zMeter = False
Call SaveUser
End If
'恢复主表标记
RetuVal = False
Else
'找不到主表信息,则增加为主表信息
If Combo1(1).Text = "工业动力" Then
If jls > 3 Then
MsgBox "该户工业三相表已输入完毕,不允许再增加!", vbCritical
Combo1(1).SetFocus
Exit Sub
Else
If jls = 0 Then
zMeter = True
Else
zMeter = False
End If
Select Case jls
Case 0
XSBS = "A"
Case 1
XSBS = "B"
Case 2
XSBS = "C"
End Select
Call SaveUser
End If
Else
zMeter = True
Call SaveUser
End If
RetuVal = False
End If
Exit Sub
End Sub
Sub SaveUser()
On Error GoTo UpDataErr
Set MdbR = NdMd.OpenRecordset("select 用户电费.镇村名称,用户电费.镇代码,用户电费.村代码,用户电费.镇村代码,用户电费.组合编码,用户电费.用户编码,用户电费.辅助号,用户电费.抄表码,用户电费.台变类型,用户电费.多表户,用户电费.标签,用户电费.相数标识,用户电费.主表,用户电费.多表序号,用户电费.电价代码,用户电费.用户名称,用户电费.全称,用户电费.地址,用户电费.电话,用户电费.开户银行,用户电费.账号,用户电费.台区,用户电费.电价类别,用户电费.电价,用户电费.倍率,用户电费.表损,用户电费.用户类型,用户电费.[" & AAA & "] AS 上期示数,用户电费.电建,用户电费.三峡 from 用户电费 where 镇村代码='" & UserSeek & "'")
With MdbR
.AddNew
.Fields("镇代码") = XzCode
.Fields("村代码") = XcCode
.Fields("镇村代码") = UserSeek
.Fields!镇村名称 = Trim(XzName) & Trim(XcName)
.Fields("组合编码") = UserSeek & Trim(Text1(0).Text)
.Fields("用户编码") = Trim(Text1(0).Text)
.Fields!多表序号 = hjs + jls + 1
.Fields!抄表码 = Trim(Text1(4).Text) ' Format(MdbR.RecordCount + 1, "000000")
'zis = Format(MdbR.RecordCount + 1, "000000")
.Fields("辅助号") = Trim(Text1(4).Text)
.Fields!用户类型 = Trim(Combo1(1).Text)
.Fields("用户名称") = Mid(Text1(1).Text, 1, 10)
If Combo1(1).Text = "工业动力" Then
.Fields!标签 = Mid(Text1(1).Text, 1, 10) & "(" & XSBS & "相)"
.Fields("全称") = IIf(Len(Text1(2).Text) = 0, Mid(Text1(1).Text, 1, 10) & "(" & XSBS & "相)", Text1(2).Text)
Else
.Fields!标签 = Mid(Text1(1).Text, 1, 10) & "(" & Trim(Str(hjs + jls + 1)) & ")"
.Fields("全称") = IIf(Len(Text1(2).Text) = 0, Mid(Text1(1).Text, 1, 10) & "(" & Trim(Str(hjs + jls + 1)) & ")", Text1(2).Text)
End If
.Fields("地址") = IIf(Len(Text1(3).Text) = 0, Trim(XzName) & Trim(XcName), Text1(3).Text) 'Trim(XzName) & Trim(XcName)
.Fields("台区") = IIf(Len(Trim(Combo1(0).Text)) = 0, Trim(XzName) & Trim(XcName), Trim(Combo1(0).Text))
.Fields("电价代码") = Left(Combo1(2), 2)
.Fields("电价类别") = conv_str(Trim(Mid(Combo1(2).Text, 5, Val(InStr(Combo1(2).Text, "|")) - 5))) 'PriceName(Mid(Trim(Combo1(2).Text), 3, Len(Trim(Combo1(2).Text)) - 4), ".")
.Fields("表损") = Val(Mid(Text1(5).Text, 1, 6))
.Fields("倍率") = IIf(Len(Text1(6).Text) = 0, 1, Val(Mid(Text1(6).Text, 1, 6))) '
.Fields("电价") = Format(Val(Label6.Caption), "0.0000")
.Fields!台变类型 = IIf(Option1.Value, "公用变", "专用变")
'.Fields!电建 = 0.02 'Format(Val(Mid(Right(Combo1(2).Text, 14), 2, 6)), "0.0000")
'.Fields!三峡 = 0.004 'Format(Val(Mid(Right(Combo1(2).Text, 14), 9, 6)), "0.0000")
.Fields("上期示数") = Format(Left(Text1(7), 6), "000000")
If zMeter = True Then
.Fields!主表 = -1
End If
If Combo1(1).Text = "工业动力" Then
.Fields!相数标识 = XSBS
End If
.Update
End With
Dim itm As ListItem
Set itm = ListView2.ListItems.Add(, , hjs + jls + 1)
itm.SubItems(1) = Trim(Text1(4).Text)
itm.SubItems(2) = Trim(Combo1(1).Text)
If Combo1(1).Text = "工业动力" Then
itm.SubItems(3) = XSBS
End If
itm.SubItems(4) = Format(Left(Text1(7), 6), "000000")
itm.SubItems(5) = Val(Mid(Text1(5).Text, 1, 6))
itm.SubItems(6) = IIf(Len(Text1(6).Text) = 0, 1, Val(Mid(Text1(6).Text, 1, 6)))
itm.SubItems(7) = conv_str(Trim(Mid(Combo1(2).Text, 3, Val(InStr(Combo1(2).Text, "|")) - 3)))
itm.SubItems(8) = Format(Val(Label6.Caption), "0.0000")
hjs = 0
jls = 0
Exit Sub
UpDataErr:
MsgBox Err.Description, vbInformation
Exit Sub
End Sub
Sub ViewMeter()
Set MdbR = NdMd.OpenRecordset("SELECT 用户电费.多表序号 as 序号,用户电费.辅助号 as 辅助编码,用户电费.用户类型,用户电费.相数标识 as 相数,用户电费.[" & AAA & "] AS 底度,用户电费.表损, 用户电费.倍率,用户电费.电价类别,用户电费.电价 From 用户电费 WHERE trim(用户电费.镇村代码)='" & UserSeek & "' and trim(用户电费.用户编码)='" & Trim(ListView1.SelectedItem) & "' order by 用户电费.抄表码 asc")
Dim intCounter, intRecCount As Integer
Dim itm As ListItem
ListView2.ListItems.Clear
ListView2.SortKey = 0
ListView2.SortOrder = lvwAscending
If Not MdbR.eof Then
MdbR.MoveLast
intRecCount = MdbR.RecordCount
MdbR.MoveFirst
For intCounter = 0 To MdbR.RecordCount - 1
Set itm = ListView2.ListItems.Add(, , CStr(MdbR!序号))
itm.SubItems(1) = CStr(MdbR!辅助编码) & ""
itm.SubItems(2) = MdbR!用户类型 & ""
itm.SubItems(3) = MdbR!相数 & ""
itm.SubItems(4) = MdbR!底度 & ""
itm.SubItems(5) = MdbR!表损 & ""
itm.SubItems(6) = MdbR!倍率 & ""
itm.SubItems(7) = MdbR!电价类别 & ""
itm.SubItems(8) = Format(MdbR!电价, "0.000") & ""
MdbR.MoveNext
DoEvents
Next intCounter
ListView2.Sorted = True
End If
End Sub
Private Sub Text2_GotFocus(Index As Integer)
Text2(Index).BackColor = &HFFFF80
End Sub
Private Sub Text2_keyPress(Index As Integer, KeyAscii As Integer)
If KeyAscii = 13 Then
SendKeys "{tab}"
End If
End Sub
Private Sub Text2_LostFocus(Index As Integer)
Text2(Index).BackColor = vbWhite
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -