📄 frmloadqueryfile.frm
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form FrmLoadQueryFile
BorderStyle = 1 'Fixed Single
Caption = "查询信息"
ClientHeight = 5025
ClientLeft = 45
ClientTop = 330
ClientWidth = 7230
Icon = "FrmLoadQueryFile.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 5025
ScaleWidth = 7230
StartUpPosition = 2 'CenterScreen
Begin VB.CommandButton CmdOK
Caption = "确定(&O)"
Height = 375
Left = 6240
TabIndex = 10
Top = 4560
Width = 855
End
Begin VB.Frame Frame1
Height = 1215
Left = 120
TabIndex = 5
Top = 840
Width = 6975
Begin VB.TextBox TxtFileName
Height = 360
Left = 1200
TabIndex = 12
Top = 240
Width = 5535
End
Begin VB.ComboBox CbxObject
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 360
ItemData = "FrmLoadQueryFile.frx":030A
Left = 4680
List = "FrmLoadQueryFile.frx":0317
Style = 2 'Dropdown List
TabIndex = 7
Top = 720
Width = 2055
End
Begin VB.ComboBox CbxTypeCode
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 360
Left = 1200
Style = 2 'Dropdown List
TabIndex = 6
Top = 720
Width = 2055
End
Begin VB.Label Label3
BackStyle = 0 'Transparent
Caption = "文件名称"
Height = 255
Left = 240
TabIndex = 11
Top = 360
Width = 735
End
Begin VB.Label Label2
BackStyle = 0 'Transparent
Caption = "对象类型"
Height = 255
Left = 3600
TabIndex = 9
Top = 840
Width = 735
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "档案类型"
Height = 255
Left = 240
TabIndex = 8
Top = 840
Width = 735
End
End
Begin VB.PictureBox Picture2
BorderStyle = 0 'None
Height = 135
Left = 0
Picture = "FrmLoadQueryFile.frx":032B
ScaleHeight = 135
ScaleWidth = 7455
TabIndex = 1
Top = 600
Width = 7455
Begin VB.PictureBox Picture3
BorderStyle = 0 'None
Height = 135
Left = 1920
Picture = "FrmLoadQueryFile.frx":1B91
ScaleHeight = 135
ScaleWidth = 5655
TabIndex = 2
Top = 0
Width = 5655
End
End
Begin VB.PictureBox Picture1
BorderStyle = 0 'None
Height = 615
Left = 0
Picture = "FrmLoadQueryFile.frx":33BB
ScaleHeight = 615
ScaleWidth = 7455
TabIndex = 0
Top = 0
Width = 7455
Begin VB.Timer Timer1
Interval = 50
Left = 0
Top = 0
End
End
Begin MSComctlLib.ListView LVCondition
Height = 2295
Left = 120
TabIndex = 3
Top = 2160
Width = 6975
_ExtentX = 12303
_ExtentY = 4048
View = 3
LabelEdit = 1
LabelWrap = -1 'True
HideSelection = -1 'True
FullRowSelect = -1 'True
_Version = 393217
ForeColor = -2147483640
BackColor = -2147483643
BorderStyle = 1
Appearance = 1
NumItems = 6
BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628}
Key = "lk"
Object.Width = 706
EndProperty
BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 1
Text = "与或"
Object.Width = 1411
EndProperty
BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 2
Text = "字段名"
Object.Width = 1764
EndProperty
BeginProperty ColumnHeader(4) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 3
Text = "条件"
Object.Width = 1411
EndProperty
BeginProperty ColumnHeader(5) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 4
Text = "字段值"
Object.Width = 6174
EndProperty
BeginProperty ColumnHeader(6) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 5
Key = "rk"
Object.Width = 706
EndProperty
End
Begin MSComctlLib.ListView LVSQL
Height = 855
Left = 600
TabIndex = 4
Top = 2400
Visible = 0 'False
Width = 2655
_ExtentX = 4683
_ExtentY = 1508
View = 3
LabelWrap = -1 'True
HideSelection = -1 'True
FullRowSelect = -1 'True
_Version = 393217
ForeColor = -2147483640
BackColor = -2147483643
BorderStyle = 1
Appearance = 1
NumItems = 6
BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628}
Key = "lk"
Object.Width = 706
EndProperty
BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 1
Text = "与或"
Object.Width = 1411
EndProperty
BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 2
Text = "字段名"
Object.Width = 1764
EndProperty
BeginProperty ColumnHeader(4) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 3
Text = "条件"
Object.Width = 1411
EndProperty
BeginProperty ColumnHeader(5) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 4
Text = "字段值"
Object.Width = 6174
EndProperty
BeginProperty ColumnHeader(6) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 5
Key = "rk"
Object.Width = 706
EndProperty
End
End
Attribute VB_Name = "FrmLoadQueryFile"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim gTypeCode() As String '全局档案类型数组,对应cbxtypecode中的选项
Private Sub CmdOK_Click()
Unload Me
End Sub
'#####################################################################################
'窗体初始化
'pFilePath 查询文件路径 pViewFlag 是否显示窗体
'#####################################################################################
Public Sub FrmInit(pFilePath As String, pViewFlag As Boolean)
On Error GoTo Err
Dim tTempPos As Integer
tTempPos = InStr(1, StrReverse(pFilePath), "\")
If tTempPos <> 0 Then
TxtFileName.Text = StrReverse(Mid(StrReverse(pFilePath), 1, tTempPos - 1))
Else
TxtFileName.Text = ""
End If
'TxtFileName = pFilePath
CbxObject.ListIndex = 0
Set GblRdoRes = GblRdoCon.OpenResultset("select * from archive_type order by type_code", rdOpenDynamic, rdConcurRowVer)
CbxTypeCode.Clear
If Not GblRdoRes.EOF Then ReDim gTypeCode(1 To GblRdoRes.RowCount) As String
While Not GblRdoRes.EOF
CbxTypeCode.AddItem GblRdoRes.rdoColumns("Type_Name")
gTypeCode(GblRdoRes.AbsolutePosition) = GblRdoRes.rdoColumns("type_code")
'If GblRdoRes.AbsolutePosition > 1 Then Load m_Type_Code_Do(GblRdoRes.AbsolutePosition - 1)
GblRdoRes.MoveNext
Wend
If CbxTypeCode.ListCount > 1 Then
CbxTypeCode.ListIndex = 0
'Call AddViewField(gTypeCode(1), CbxObject.ListIndex)
'Call AddQueryField(gTypeCode(1), CbxObject.ListIndex)
End If
If pViewFlag = True Then
Call LoadQueryFile(pFilePath)
FrmLoadQueryFile.Show 1
End If
Err:
End Sub
'#####################################################################################
'加载指定的.qry文件并检验格式 pFilePath.qry文件的绝对路径
'#####################################################################################
Public Function LoadQueryFile(pFilePath As String) As Boolean
Dim tSql As String
Dim tWhereStr As String
Dim i, j As Integer
Dim t_Type_Code As String
Dim t_Field_Name As String '字段名称
Dim t_Dict_Type As String '数据字典
Dim tItem As ListItem
Dim t_Field_Value As String
Dim tFileFullName As String
Dim tStr As String
Dim tBool As Boolean
Dim tStrArray(1 To 6) As String
On Error GoTo Err
tFileFullName = pFilePath
If tFileFullName = "" Then GoTo Err
LVCondition.ListItems.Clear
LVSQL.ListItems.Clear
Close #2
Open tFileFullName For Input As #2
'档案类型
Line Input #2, tStr
tBool = False
CbxTypeCode.ListIndex = -1
For i = 0 To CbxTypeCode.ListCount - 1
If tStr = CbxTypeCode.List(i) Then
CbxTypeCode.ListIndex = i
tBool = True
Exit For
End If
Next i
If tBool = False Then GoTo Err
'对象类型
Line Input #2, tStr
CbxObject.ListIndex = CInt(tStr)
Line Input #2, tStr
Line Input #2, tStr
Do While tStr <> "显示条件" And Not EOF(2) '显示字段
Line Input #2, tStr ' 读入一行数据并将其赋予某变量。
Loop
Line Input #2, tStr
Do While tStr <> "条件" 'And Not EOF(2) '显示字段
For i = 1 To 6
Call GetValue(tStrArray(i), CStr(i), tStr)
If i = 1 Then
Set tItem = LVCondition.ListItems.Add(, "K" + Format(LVCondition.ListItems.Count + 1, "0000"), tStrArray(i))
Else
tItem.SubItems(i - 1) = tStrArray(i)
End If
Next i
Line Input #2, tStr ' 读入一行数据并将其赋予某变量。
Loop
Do '显示字段
Line Input #2, tStr
For i = 1 To 6
Call GetValue(tStrArray(i), CStr(i), tStr)
If i = 1 Then
Set tItem = LVSQL.ListItems.Add(, "K" + Format(LVSQL.ListItems.Count + 1, "0000"), tStrArray(i))
Else
tItem.SubItems(i - 1) = tStrArray(i)
End If
Next i
Line Input #2, tStr ' 读入一行数据并将其赋予某变量。
Loop Until EOF(2)
Close #2
'MsgBox "文件成功导入", vbExclamation, XTTS
LoadQueryFile = True
Exit Function
Err:
If EOF(2) Then
LoadQueryFile = True
Else
LoadQueryFile = False
End If
End Function
'#####################################################################################
'获取当前显示对应的sql语句 rQueryStr返回的查询语句 rTableName返回查询的表名 rWhereStr返回查询语句中的where子句
'#####################################################################################
Public Function GetQueryStr(rQueryStr As String, rTableName As String, rWhereStr As String) As Boolean
Dim tSql As String
Dim tWhereStr As String
Dim i As Integer
Dim j As Integer
On Error GoTo Err
tSql = "select * "
If CbxObject.ListIndex = 0 Then '文件
tSql = "select * from file_" + gTypeCode(CbxTypeCode.ListIndex + 1) + " where "
'LVResult.Tag = "0" '表类型标志
Else '案卷,盒
tSql = "select * from volume_" + gTypeCode(CbxTypeCode.ListIndex + 1) + " where "
'LVResult.Tag = "1" '表类型标志
End If
For i = 1 To LVSQL.ListItems.Count
tWhereStr = tWhereStr + " " + LVSQL.ListItems(i).Text
For j = 1 To LVSQL.ColumnHeaders.Count - 1
tWhereStr = tWhereStr + " " + LVSQL.ListItems(i).SubItems(j)
Next j
'Debug.Print tWhereStr
Next i
If tWhereStr = "" Then
MsgBox "您没有输入查询条件或是输入的查询条件不正确,请重新输入", vbExclamation, XTTS
GoTo Err
End If
tWhereStr = RemoveString(tWhereStr, "and", 0)
tWhereStr = RemoveString(tWhereStr, "or", 0)
rWhereStr = tWhereStr
rQueryStr = tSql + tWhereStr
If CbxObject.ListIndex = 0 Then '文件
rTableName = "file_" + gTypeCode(CbxTypeCode.ListIndex + 1)
Else
rTableName = "volume_" + gTypeCode(CbxTypeCode.ListIndex + 1)
End If
GetQueryStr = True
Exit Function
Err:
If FrmLoadQueryFile.Visible = True Then Unload FrmLoadQueryFile
GetQueryStr = False
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -