📄 frmlogfilter.frm
字号:
VERSION 5.00
Begin VB.Form frmLogFilter
BorderStyle = 3 'Fixed Dialog
Caption = "范围筛选"
ClientHeight = 1890
ClientLeft = 5490
ClientTop = 1980
ClientWidth = 6135
Icon = "frmLogFilter.frx":0000
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 1890
ScaleWidth = 6135
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton cmdCancel
Cancel = -1 'True
Caption = "取消(&C)"
Height = 345
Left = 4080
TabIndex = 13
Top = 1440
Width = 1065
End
Begin VB.CommandButton cmdOK
Caption = "确定(&O)"
Default = -1 'True
Height = 345
Left = 1080
TabIndex = 12
Top = 1440
Width = 1065
End
Begin VB.ComboBox cboSubSys
Height = 300
Left = 4245
Style = 2 'Dropdown List
TabIndex = 11
Top = 120
Width = 1815
End
Begin VB.ComboBox cboAccount
Height = 300
Left = 1080
Style = 2 'Dropdown List
TabIndex = 10
Top = 960
Width = 1815
End
Begin VB.ComboBox cboComputer
Height = 300
Left = 1080
Style = 2 'Dropdown List
TabIndex = 3
Top = 120
Width = 1815
End
Begin VB.ComboBox cboUser
Height = 300
Left = 1080
Style = 2 'Dropdown List
TabIndex = 2
Top = 540
Width = 1815
End
Begin VB.ComboBox cboYear
Height = 300
Left = 4245
Style = 2 'Dropdown List
TabIndex = 1
Top = 540
Width = 1815
End
Begin VB.ComboBox cboMonth
Height = 300
Left = 4245
Style = 2 'Dropdown List
TabIndex = 0
Top = 960
Width = 1815
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "子系统(&U):"
Height = 180
Left = 3120
TabIndex = 9
Top = 180
Width = 900
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "账套(&A):"
Height = 180
Left = 120
TabIndex = 8
Top = 1020
Width = 720
End
Begin VB.Label Label15
AutoSize = -1 'True
Caption = "登录月份(&M):"
Height = 180
Left = 3120
TabIndex = 7
Top = 1020
Width = 1080
End
Begin VB.Label Label12
AutoSize = -1 'True
Caption = "站点(&S):"
Height = 180
Left = 120
TabIndex = 6
Top = 180
Width = 720
End
Begin VB.Label Label13
AutoSize = -1 'True
Caption = "操作员(&U):"
Height = 180
Left = 120
TabIndex = 5
Top = 600
Width = 900
End
Begin VB.Label Label14
AutoSize = -1 'True
Caption = "会计年度(&Y):"
Height = 180
Left = 3120
TabIndex = 4
Top = 600
Width = 1080
End
End
Attribute VB_Name = "frmLogFilter"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Option Base 1
Private m_sQuery As String
Private m_sDelete As String
Public OK As Boolean
Public Property Get usQuery() As String
usQuery = m_sQuery
End Property
Public Property Get usDelete() As String
usDelete = m_sDelete
End Property
Private Sub Form_Load()
Dim rSt As ADODB.Recordset
Dim i As Long
Set rSt = New ADODB.Recordset
With rSt
.CursorLocation = adUseClient
'装入站点名称
.Open "select distinct ComputerName from tSYS_Manage", _
gloSys.cnnSys, adOpenStatic, adLockReadOnly
cboComputer.AddItem "*(所有)"
Do Until .EOF
cboComputer.AddItem .Fields(0).Value
.MoveNext
Loop
cboComputer.ListIndex = 0
.Close
'装入操作员代码及名称
.Open "select * from tSYS_User order by UserID", _
gloSys.cnnSys, adOpenStatic, adLockReadOnly
cboUser.AddItem "*(所有)"
Do Until .EOF
cboUser.AddItem "[" & .Fields("userID").Value & "]" & _
.Fields("userName").Value
.MoveNext
Loop
cboUser.ListIndex = 0
.Close
'装入年度
.Open "select distinct year from tSYS_Period order by 1", _
gloSys.cnnSys, adOpenStatic, adLockReadOnly
cboYear.AddItem "*(所有)"
Do Until .EOF
cboYear.AddItem .Fields(0).Value
.MoveNext
Loop
cboYear.ListIndex = 0
.Close
'装入月度
cboMonth.AddItem "*(所有)"
For i = 1 To 12
cboMonth.AddItem i
Next i
cboMonth.ListIndex = 0
'装入账套号及名称
.Open "select accountID,accountName from tSYS_Account " & _
"order by accountID", _
gloSys.cnnSys, adOpenStatic, adLockReadOnly
cboAccount.AddItem "*(所有)"
Do Until .EOF
cboAccount.AddItem "[" & .Fields(0).Value & "]" & _
.Fields(1).Value
.MoveNext
Loop
cboAccount.ListIndex = 0
.Close
'装入子系统代码及名称
.Open "select * from tSYS_SubSys", _
gloSys.cnnSys, adOpenStatic, adLockReadOnly
cboSubSys.AddItem "*(所有)"
Do Until .EOF
cboSubSys.AddItem "[" & .Fields("subsysID").Value & _
"]" & .Fields("subsysName").Value
.MoveNext
Loop
cboSubSys.ListIndex = 0
.Close
End With
Set rSt = Nothing
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If UnloadMode = vbFormControlMenu Then
Cancel = 1
Call cmdCancel_Click
End If
End Sub
Private Sub cmdCancel_Click()
OK = False
Me.Hide
End Sub
Private Sub cmdOk_Click()
Dim sStr(6) As String
Dim sStrDel(6) As String
Dim i As Long
Dim sSql As String
'取各个条件到字符串数组
If cboComputer.ListIndex = 0 Then
sStr(1) = ""
sStrDel(1) = ""
Else
sStr(1) = "A.ComputerName='" & cboComputer.text & "'"
sStrDel(1) = "ComputerName='" & cboComputer.text & "'"
End If
If cboUser.ListIndex = 0 Then
sStr(2) = ""
sStrDel(2) = ""
Else
sStr(2) = "A.UserID='" & Mid$(cboUser.text, 2, _
InStr(1, cboUser.text, "]") - InStr(1, cboUser.text, "[") - 1) & "'"
sStrDel(2) = "UserID='" & Mid$(cboUser.text, 2, _
InStr(1, cboUser.text, "]") - InStr(1, cboUser.text, "[") - 1) & "'"
End If
If cboYear.ListIndex = 0 Then
sStr(3) = ""
sStrDel(3) = ""
Else
sStr(3) = "A.AccountYear='" & cboYear.text & "'"
sStrDel(3) = "AccountYear='" & cboYear.text & "'"
End If
If cboMonth.ListIndex = 0 Then
sStr(4) = ""
sStrDel(4) = ""
Else
Select Case g_FLAT
Case "SQL"
sStr(4) = "datepart(MM,A.LoginDateTime)='" & _
Format(cboMonth.text, "00") & "'"
sStrDel(4) = "datepart(MM,LoginDateTime)='" & _
Format(cboMonth.text, "00") & "'"
Case "ORACLE"
sStr(4) = "to_char(A.LoginDateTime,'MM')='" & _
Format(cboMonth.text, "00") & "'"
sStrDel(4) = "to_char(LoginDateTime,'MM')='" & _
Format(cboMonth.text, "00") & "'"
End Select
End If
If cboAccount.ListIndex = 0 Then
sStr(5) = ""
sStrDel(5) = ""
Else
sStr(5) = "A.AccountID='" & Mid$(cboAccount.text, 2, _
InStr(1, cboAccount.text, "]") - InStr(1, cboAccount.text, "[") - 1) & "'"
sStrDel(5) = "AccountID='" & Mid$(cboAccount.text, 2, _
InStr(1, cboAccount.text, "]") - InStr(1, cboAccount.text, "[") - 1) & "'"
End If
If cboSubSys.ListIndex = 0 Then
sStr(6) = ""
sStrDel(6) = " "
Else
sStr(6) = "A.SubSysID='" & Mid$(cboSubSys.text, 2, _
InStr(1, cboSubSys.text, "]") - InStr(1, cboSubSys.text, "[") - 1) & "'"
sStrDel(6) = "SubSysID='" & Mid$(cboSubSys.text, 2, _
InStr(1, cboSubSys.text, "]") - InStr(1, cboSubSys.text, "[") - 1) & "'"
End If
'连接各条件,形成查询语句的 WHERE 子句
m_sQuery = ""
m_sDelete = ""
For i = LBound(sStr) To UBound(sStr)
If sStr(i) <> "" Then
m_sQuery = m_sQuery & sStr(i) & " and "
m_sDelete = m_sDelete & sStrDel(i) & " and "
End If
Next i
If m_sQuery <> "" Then
m_sQuery = Left$(m_sQuery, Len(m_sQuery) - 5)
End If
If m_sDelete <> "" Then
m_sDelete = Left$(m_sDelete, Len(m_sDelete) - 5)
End If
OK = True
Me.Hide
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -