📄 frmcompanylookup.frm
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form frmCompanyLookup
BorderStyle = 1 'Fixed Single
Caption = "Company"
ClientHeight = 5355
ClientLeft = 45
ClientTop = 330
ClientWidth = 7500
LinkTopic = "Form2"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 5355
ScaleWidth = 7500
StartUpPosition = 2 'CenterScreen
Begin VB.PictureBox Picture1
Align = 2 'Align Bottom
BorderStyle = 0 'None
Height = 375
Left = 0
ScaleHeight = 375
ScaleWidth = 7500
TabIndex = 6
Top = 4980
Width = 7500
Begin VB.PictureBox Picture2
BorderStyle = 0 'None
Height = 345
Left = 3000
ScaleHeight = 345
ScaleWidth = 4155
TabIndex = 7
Top = 0
Width = 4150
Begin VB.CommandButton btnFirst
Height = 315
Left = 2760
Style = 1 'Graphical
TabIndex = 11
ToolTipText = "First 250"
Top = 10
Width = 315
End
Begin VB.CommandButton btnPrev
Height = 315
Left = 3075
Style = 1 'Graphical
TabIndex = 10
ToolTipText = "Previous 250"
Top = 10
Width = 315
End
Begin VB.CommandButton btnLast
Height = 315
Left = 3705
Style = 1 'Graphical
TabIndex = 9
ToolTipText = "Last 250"
Top = 10
Width = 315
End
Begin VB.CommandButton btnNext
Height = 315
Left = 3390
Style = 1 'Graphical
TabIndex = 8
ToolTipText = "Next 250"
Top = 10
Width = 315
End
Begin VB.Label lblPageInfo
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "0 - 0 of 0"
Height = 255
Left = 120
TabIndex = 12
Top = 60
Width = 2535
End
End
Begin VB.Label lblCurrentRecord
AutoSize = -1 'True
Caption = "Selected Record: 0"
Height = 195
Left = 120
TabIndex = 13
Top = 60
Width = 1365
End
End
Begin VB.PictureBox picLine
Align = 2 'Align Bottom
BackColor = &H80000014&
BorderStyle = 0 'None
Height = 15
Index = 0
Left = 0
ScaleHeight = 15
ScaleWidth = 7500
TabIndex = 5
Top = 4950
Width = 7500
End
Begin VB.PictureBox picLine
Align = 2 'Align Bottom
BackColor = &H80000010&
BorderStyle = 0 'None
Height = 15
Index = 1
Left = 0
ScaleHeight = 15
ScaleWidth = 7500
TabIndex = 4
Top = 4965
Width = 7500
End
Begin VB.CommandButton cmdCancel
Caption = "Cancel"
Height = 375
Left = 6510
TabIndex = 3
Top = 4440
Width = 735
End
Begin VB.CommandButton cmdOK
Caption = "OK"
Height = 375
Left = 5640
TabIndex = 2
Top = 4440
Width = 795
End
Begin VB.TextBox txtSearch
Height = 315
Left = 3180
TabIndex = 1
Top = 120
Width = 1515
End
Begin VB.ComboBox cboField
Height = 315
ItemData = "frmCompanyLookup.frx":0000
Left = 1560
List = "frmCompanyLookup.frx":000D
Style = 2 'Dropdown List
TabIndex = 0
Top = 120
Width = 1515
End
Begin MSComctlLib.ListView lvList
Height = 3435
Left = 30
TabIndex = 14
Top = 900
Width = 7260
_ExtentX = 12806
_ExtentY = 6059
View = 3
LabelEdit = 1
LabelWrap = 0 'False
HideSelection = 0 'False
FullRowSelect = -1 'True
GridLines = -1 'True
_Version = 393217
Icons = "ImageList1"
SmallIcons = "ImageList1"
ForeColor = -2147483640
BackColor = -2147483643
Appearance = 1
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
NumItems = 6
BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628}
Text = "Company"
Object.Width = 2937
EndProperty
BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 1
Text = "Last Name"
Object.Width = 2240
EndProperty
BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 2
Text = "First Name"
Object.Width = 3863
EndProperty
BeginProperty ColumnHeader(4) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 3
Text = "Address"
Object.Width = 4762
EndProperty
BeginProperty ColumnHeader(5) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 4
Text = "Tel No"
Object.Width = 2424
EndProperty
BeginProperty ColumnHeader(6) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 5
Text = "Customer ID"
Object.Width = 0
EndProperty
End
Begin VB.Shape shpBar
BackColor = &H80000010&
BackStyle = 1 'Opaque
BorderColor = &H80000010&
Height = 240
Left = 30
Top = 600
Width = 6915
End
Begin VB.Label lblTitle
BackStyle = 0 'Transparent
Caption = "Customers"
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000014&
Height = 210
Left = 105
TabIndex = 16
Top = 600
Width = 4815
End
Begin VB.Label Label1
Caption = "Search"
Height = 285
Left = 210
TabIndex = 15
Top = 120
Width = 1185
End
End
Attribute VB_Name = "frmCompanyLookup"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public RefForm As Form
Dim CURR_COL As Integer
Dim rsCompany As New Recordset
Dim RecordPage As New clsPaging
Dim SQLParser As New clsSQLSelectParser
'Procedure used to filter records
Public Sub FilterRecord(ByVal srcCondition As String)
SQLParser.RestoreStatement
SQLParser.wCondition = srcCondition
ReloadRecords SQLParser.SQLStatement
End Sub
Public Sub RefreshRecords()
SQLParser.RestoreStatement
ReloadRecords SQLParser.SQLStatement
End Sub
'Procedure for reloadingrecords
Public Sub ReloadRecords(ByVal srcSQL As String)
'-In this case I used SQL because it is faster than Filter function of VB
'-when hundling millions of records.
On Error GoTo err
With rsCompany
If .State = adStateOpen Then .Close
.Open srcSQL
End With
RecordPage.Refresh
FillList 1
Exit Sub
err:
If err.Number = -2147217913 Then
srcSQL = Replace(srcSQL, "'", "", , , vbTextCompare)
Resume
ElseIf err.Number = -2147217900 Then
MsgBox "Invalid search operation.", vbExclamation
SQLParser.RestoreStatement
srcSQL = SQLParser.SQLStatement
Resume
Else
prompt_err err, Name, "ReloadRecords"
End If
End Sub
Private Sub btnClose_Click()
Unload Me
End Sub
Private Sub btnFirst_Click()
If RecordPage.PAGE_CURRENT <> 1 Then FillList 1
End Sub
Private Sub btnLast_Click()
If RecordPage.PAGE_CURRENT <> RecordPage.PAGE_TOTAL Then FillList RecordPage.PAGE_TOTAL
End Sub
Private Sub btnNext_Click()
If RecordPage.PAGE_CURRENT <> RecordPage.PAGE_TOTAL Then FillList RecordPage.PAGE_NEXT
End Sub
Private Sub btnPrev_Click()
If RecordPage.PAGE_CURRENT <> 1 Then FillList RecordPage.PAGE_PREVIOUS
End Sub
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdOk_Click()
Call lvList_DblClick
End Sub
Private Sub Form_Load()
'Set the graphics for the controls
With mdiMain
'For listview
Set lvList.SmallIcons = .i16x16
Set lvList.Icons = .i16x16
btnFirst.Picture = .i16x16.ListImages(3).Picture
btnPrev.Picture = .i16x16.ListImages(4).Picture
btnNext.Picture = .i16x16.ListImages(5).Picture
btnLast.Picture = .i16x16.ListImages(6).Picture
btnFirst.DisabledPicture = .i16x16g.ListImages(3).Picture
btnPrev.DisabledPicture = .i16x16g.ListImages(4).Picture
btnNext.DisabledPicture = .i16x16g.ListImages(5).Picture
btnLast.DisabledPicture = .i16x16g.ListImages(6).Picture
End With
With SQLParser
.Fields = "Company, LastName, FirstName, Address, TelNo, CompanyID"
.Tables = "Company"
.SortOrder = "Company ASC"
.SaveStatement
End With
If rsCompany.State = 1 Then rsCompany.Close
rsCompany.CursorLocation = adUseClient
Debug.Print CN
rsCompany.Open SQLParser.SQLStatement, CN, adOpenStatic, adLockReadOnly
With RecordPage
.Start rsCompany, 75
FillList 1
End With
cboField.ListIndex = 0
End Sub
Private Sub FillList(ByVal whichPage As Long)
RecordPage.CurrentPosition = whichPage
Screen.MousePointer = vbHourglass
Me.Enabled = False
Call pageFillListView(lvList, rsCompany, RecordPage.PageStart, RecordPage.PageEnd, 15, 2, False, True, , , , "CompanyID")
Me.Enabled = True
Screen.MousePointer = vbDefault
SetNavigation
'Display the page information
lblPageInfo.Caption = "Record " & RecordPage.PageInfo
'Display the selected record
lvList_Click
End Sub
Private Sub Form_Resize1()
On Error Resume Next
If WindowState <> vbMinimized Then
If Me.Width < 9195 Then Me.Width = 9195
If Me.Height < 4500 Then Me.Height = 4500
shpBar.Width = ScaleWidth
lvList.Width = Me.ScaleWidth
lvList.Height = (Me.ScaleHeight - Picture1.Height) - lvList.Top
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
' mdiMain.RemToWin Me.Caption
' mdiMain.HideTBButton "", True
Set frmCustomerLookup = Nothing
End Sub
Private Sub SetNavigation()
With RecordPage
If .PAGE_TOTAL = 1 Then
btnFirst.Enabled = False
btnPrev.Enabled = False
btnNext.Enabled = False
btnLast.Enabled = False
ElseIf .PAGE_CURRENT = 1 Then
btnFirst.Enabled = False
btnPrev.Enabled = False
btnNext.Enabled = True
btnLast.Enabled = True
ElseIf .PAGE_CURRENT = .PAGE_TOTAL And .PAGE_CURRENT > 1 Then
btnFirst.Enabled = True
btnPrev.Enabled = True
btnNext.Enabled = False
btnLast.Enabled = False
Else
btnFirst.Enabled = True
btnPrev.Enabled = True
btnNext.Enabled = True
btnLast.Enabled = True
End If
End With
End Sub
Private Sub lvList_Click()
On Error GoTo err
lblCurrentRecord.Caption = "Selected Record: " & RightSplitUF(lvList.SelectedItem.Tag)
Exit Sub
err:
lblCurrentRecord.Caption = "Selected Record: NONE"
End Sub
Private Sub lvList_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
'Sort the listview
If ColumnHeader.Index - 1 <> CURR_COL Then
lvList.SortOrder = 0
Else
lvList.SortOrder = Abs(lvList.SortOrder - 1)
End If
lvList.SortKey = ColumnHeader.Index - 1
lvList.Sorted = True
CURR_COL = ColumnHeader.Index - 1
End Sub
Private Sub lvList_DblClick()
RefForm.txtCompany.Text = lvList.SelectedItem
Unload Me
End Sub
Private Sub lvList_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = 38 Or KeyCode = 40 Or KeyCode = 33 Or KeyCode = 34 Then lvList_Click
End Sub
Private Sub lvList_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
' If Button = 2 Then PopupMenu mdiMain.mnuRecA
End Sub
Private Sub Picture1_Resize()
Picture2.Left = Picture1.ScaleWidth - Picture2.ScaleWidth
End Sub
Private Sub txtSearch_Change()
If txtSearch.Text = "" Then RefreshRecords
FilterRecord "[" & cboField.Text & "] Like '" & txtSearch.Text & "%'"
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -