📄 frmqueryclient.frm
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "Msflxgrd.ocx"
Begin VB.Form frmQueryClient
Caption = "客户查询"
ClientHeight = 4095
ClientLeft = 60
ClientTop = 345
ClientWidth = 6270
LinkTopic = "Form1"
ScaleHeight = 4095
ScaleWidth = 6270
StartUpPosition = 3 'Windows Default
Begin MSFlexGridLib.MSFlexGrid fgClients
Height = 1695
Left = 120
TabIndex = 6
Top = 2280
Width = 6015
_ExtentX = 10610
_ExtentY = 2990
_Version = 393216
End
Begin VB.Frame Frame1
Caption = "查询方式"
Height = 1815
Left = 120
TabIndex = 0
Top = 120
Width = 6015
Begin VB.CommandButton cmdCancel
Caption = "返回(&C)"
Height = 375
Left = 4320
TabIndex = 8
Top = 1080
Width = 1215
End
Begin VB.CommandButton cmdQuery
Caption = "查询(&Q)"
Height = 375
Left = 4320
TabIndex = 7
Top = 480
Width = 1215
End
Begin VB.OptionButton optQueryType
Caption = "查询全部"
Height = 255
Index = 2
Left = 240
TabIndex = 5
Top = 1320
Width = 1335
End
Begin VB.TextBox txtProducts
Height = 285
Left = 1680
TabIndex = 4
Top = 840
Width = 2055
End
Begin VB.OptionButton optQueryType
Caption = "按产品范围"
Height = 495
Index = 1
Left = 240
TabIndex = 3
Top = 720
Width = 1215
End
Begin VB.TextBox txtClientName
Height = 285
Left = 1680
TabIndex = 2
Top = 360
Width = 2055
End
Begin VB.OptionButton optQueryType
Caption = "按客户名称"
Height = 495
Index = 0
Left = 240
TabIndex = 1
Top = 240
Width = 1215
End
End
Begin VB.Label Label1
Caption = "查询结果:"
Height = 255
Left = 240
TabIndex = 9
Top = 2040
Width = 975
End
End
Attribute VB_Name = "frmQueryClient"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public sqlStr As String
Public msgText As String
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdQuery_Click()
queryClients
End Sub
Sub queryClients()
Dim rs As ADODB.Recordset
Dim i As Integer
Dim j As Integer
If optQueryType(0).Value = True Then
If txtClientName.Text = "" Then
MsgBox "请输入客户名!!"
End If
sqlStr = "select * from client where clientName LIKE '%" & txtClientName.Text & "%'"
End If
If optQueryType(1).Value = True Then
If txtProducts.Text = "" Then
MsgBox "请输入查询条件!!"
End If
sqlStr = "select * from client where products LIKE '%" & txtProducts.Text & "%'"
End If
If optQueryType(2).Value = True Then
sqlStr = "select * from client"
End If
Set rs = ExecuteSQL(sqlStr, msgText)
If rs.RecordCount = 0 Then
MsgBox "没有查找满足条件的数据!", vbExclamation, "提示"
fgClients.Rows = 1
Else
fgClients.Rows = rs.RecordCount + 1
fgClients.Cols = 9
'设定行高
For i = 0 To fgClients.Rows - 1
fgClients.RowHeight(i) = 280
Next i
'设定列的属性
fgClients.Row = 0
For i = 0 To fgClients.Cols - 1
fgClients.Col = i '指定当前列为第i列
fgClients.FixedAlignment(i) = 4 '每列内容居中显示
Select Case i
Case 0
fgClients.ColWidth(i) = 600 '设定列宽
fgClients.Text = "编号"
Case 1
fgClients.ColWidth(i) = 2200 '设定列宽
fgClients.Text = "客户名称"
Case 2
fgClients.ColWidth(i) = 1000 '设定列宽
fgClients.Text = "产品范围"
Case 3
fgClients.ColWidth(i) = 700 '设定列宽
fgClients.Text = "联系人"
Case 4
fgClients.ColWidth(i) = 1000 '设定列宽
fgClients.Text = "联系电话"
Case 5
fgClients.ColWidth(i) = 1000 '设定列宽
fgClients.Text = "email"
Case 6
fgClients.ColWidth(i) = 1500 '设定列宽
fgClients.Text = "联系地址"
Case 7
fgClients.ColWidth(i) = 1000 '设定列宽
fgClients.Text = "备注"
End Select
Next i
'rs.MoveFirst
i = 1
While (Not rs.EOF)
fgClients.Row = i
For j = 0 To fgClients.Cols - 1
fgClients.Col = j '设置当前为列为第j列
fgClients.CellAlignment = 4 '每列内容居中显示
Select Case j
Case 0
fgClients.Text = rs.Fields("clientID")
Case 1
fgClients.Text = rs.Fields("clientName")
Case 2
fgClients.Text = rs.Fields("products")
Case 3
fgClients.Text = rs.Fields("contact")
Case 4
fgClients.Text = rs.Fields("telno")
Case 5
fgClients.Text = rs.Fields("email")
Case 6
fgClients.Text = rs.Fields("address")
Case 7
fgClients.Text = rs.Fields("memo")
End Select
Next j
rs.MoveNext
i = i + 1
Wend
End If
rs.Close
End Sub
Private Sub txtClientName_GotFocus()
optQueryType(0).Value = True
End Sub
Private Sub txtProducts_Click()
optQueryType(1).Value = True
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -