📄 frmquerycenter.frm
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "msflxgrd.ocx"
Begin VB.Form frmQueryCenter
Caption = "中心信息查询窗口"
ClientHeight = 5640
ClientLeft = -6420
ClientTop = 1575
ClientWidth = 8565
Icon = "frmQueryCenter.frx":0000
LinkTopic = "Form1"
MDIChild = -1 'True
ScaleHeight = 5640
ScaleWidth = 8565
Begin VB.Frame famQuery
Caption = "中心信息查询"
Height = 2055
Left = 240
TabIndex = 10
Top = 240
Width = 5655
Begin VB.CheckBox chkStatus
Caption = " 按状态"
Height = 300
Left = 960
TabIndex = 3
Top = 1440
Width = 1335
End
Begin VB.CheckBox chkProvince
Caption = " 按所属省"
Height = 300
Left = 960
TabIndex = 2
Top = 960
Width = 1335
End
Begin VB.CheckBox chkCenterName
Caption = " 按 名 称"
Height = 300
Left = 960
TabIndex = 1
Top = 480
Width = 1335
End
Begin VB.ComboBox cmbStatus
Height = 315
Left = 3120
TabIndex = 6
Text = "cmbStatus"
Top = 1440
Width = 1215
End
Begin VB.ComboBox cmbProvince
Height = 315
Left = 3120
TabIndex = 5
Text = "cmbProvince"
Top = 960
Width = 1215
End
Begin VB.ComboBox cmbCenterName
Height = 315
Left = 3120
TabIndex = 4
Text = "cmbCenterName"
Top = 480
Width = 1215
End
End
Begin VB.CommandButton cmdExit
Caption = "退 出"
Height = 375
Left = 6720
Style = 1 'Graphical
TabIndex = 9
Top = 1860
Width = 1695
End
Begin VB.CommandButton cmdQuery
Caption = "查 询"
Height = 375
Left = 6720
Style = 1 'Graphical
TabIndex = 8
Top = 1080
Width = 1695
End
Begin VB.CommandButton cmdShowAllCenter
Caption = "显示全部中心"
Height = 375
Left = 6720
Style = 1 'Graphical
TabIndex = 7
Top = 300
Width = 1695
End
Begin MSFlexGridLib.MSFlexGrid mfgShow
Height = 3240
Left = 195
TabIndex = 0
Top = 2445
Width = 8175
_ExtentX = 14420
_ExtentY = 5715
_Version = 393216
AllowUserResizing= 3
End
End
Attribute VB_Name = "frmQueryCenter"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub chkCenterName_Click()
If chkCenterName.Value = 1 Then
cmbCenterName.Enabled = True
ElseIf chkCenterName.Value = 0 Then
cmbCenterName.Enabled = False
End If
End Sub
Private Sub chkProvince_Click()
If chkProvince.Value = 1 Then
cmbProvince.Enabled = True
ElseIf chkProvince.Value = 0 Then
cmbProvince.Enabled = False
End If
End Sub
Private Sub chkStatus_Click()
If chkStatus.Value = 1 Then
cmbStatus.Enabled = True
ElseIf chkStatus.Value = 0 Then
cmbStatus.Enabled = False
End If
End Sub
Private Sub cmdExit_Click()
'关闭记录集,RsClose函数 见模块MdlConnection
RsClose rs
'关闭窗体
Unload Me
End Sub
Private Sub cmdQuery_Click()
Dim strTempName As String
Dim strTempPro As String
Dim strTempStatus As String
If chkCenterName.Value = 0 And chkProvince.Value = 0 And chkStatus = 0 Then
MsgBox "您没选择任何查询类型" & Chr(10) & "请选择至少一种!", vbOKOnly + vbExclamation, "提示"
Exit Sub
End If
If chkCenterName.Value = 1 Then
If cmbCenterName.Text = "" Then
MsgBox "您选择了按名称查询" & Chr(10) & "请选择中心名称!", vbOKOnly + vbExclamation, "提示"
Exit Sub
Else
strTempName = " cname='" & Trim(cmbCenterName.Text) & "' "
End If
End If
If chkProvince.Value = 1 Then
If cmbProvince.Text = "" Then
MsgBox "您选择了按所属省查询" & Chr(10) & "请选择所属省名称!", vbOKOnly + vbExclamation, "提示"
Exit Sub
Else
strTempPro = " province='" & Trim(cmbProvince.Text) & "' "
End If
End If
If chkStatus.Value = 1 Then
If cmbStatus.Text = "" Then
MsgBox "您选择了按中心状态查询" & Chr(10) & "请选择中心状态!", vbOKOnly + vbExclamation, "提示"
Exit Sub
Else
strTempStatus = " centerstatus='" & Trim(cmbStatus.Text) & "' "
End If
End If
strFind = "select * from syscenterinfo where"
If strTempName <> "" Then
If strTempPro <> "" Then
If strTempStatus <> "" Then
strFind = strFind & strTempName & " and " & strTempPro & " and " & strTempStatus
Else
strFind = strFind & strTempName & " and " & strTempPro
End If
Else
If strTempStatus <> "" Then
strFind = strFind & strTempName & " and " & strTempStatus
Else
strFind = strFind & strTempName
End If
End If
Else
If strTempPro <> "" Then
If strTempStatus <> "" Then
strFind = strFind & strTempPro & " and " & strTempStatus
Else
strFind = strFind & strTempPro
End If
Else
If strTempStatus <> "" Then
strFind = strFind & strTempStatus
Else
strFind = ""
End If
End If
End If
'Debug.Print strFind
RsClose rs
'打开表syscenterinfo,创建记录集
RsOpen rs, con, strFind, "adcmdtext"
If rs.BOF And rs.EOF Then
'隐藏MSFlexGrid控件
mfgShow.Visible = False
'缩小窗体
Me.Width = 8700
Me.Height = 3000
MsgBox "没有符合条件的记录!", vbOKOnly + vbInformation, "查询结果"
RsClose rs
Exit Sub
Else
'添MSFlexGrid控件台头
ShowCenterTitle
RsClose rs
End If
End Sub
Private Sub cmdShowAllCenter_Click()
cmbCenterName.Enabled = False
cmbProvince.Enabled = False
cmbStatus.Enabled = False
'向组合框添入数据
'DisplayRefresh
RsClose rs
'打开表syscenterinfo,创建记录集
RsOpen rs, con, "syscenterinfo", "adcmdtable"
'添MSFlexGrid控件台头
ShowCenterTitle
RsClose rs
End Sub
Private Sub Form_Load()
'设置窗体的背景色为GetColor函数的返回值,GetColor函数 见模块MdlSystem
Me.BackColor = GetColor
Me.Width = 8700
Me.Height = 3000
'遍历窗体上的所有控件,改变颜色为GetColor函数的返回值(GetColor函数 见模块MdlSystem)
Dim ctlcontrol As Control
For Each ctlcontrol In Controls
ctlcontrol.BackColor = GetColor
Next
'设置控件的各种属性,字体大小,对齐类型,清空文本显示
For Each ctlcontrol In Controls
ctlcontrol.FontSize = 10
If TypeOf ctlcontrol Is ComboBox Then
ctlcontrol.Clear
End If
Next
'隐藏MSFlexGrid控件
mfgShow.Visible = False
cmbCenterName.Enabled = False
cmbProvince.Enabled = False
cmbStatus.Enabled = False
'向组合框添入数据
DisplayRefresh
End Sub
Private Sub Form_LostFocus()
'关闭记录集,RsClose函数 见模块MdlConnection
RsClose rs
End Sub
Private Sub Form_Unload(Cancel As Integer)
'关闭记录集,RsClose函数 见模块MdlConnection
RsClose rs
End Sub
Private Sub ShowCenterTitle()
'计数器
Dim i As Long, j As Long
'颜色标识
Dim markColor As Boolean
'显示MSFlexGrid控件
mfgShow.Height = 3000
mfgShow.Width = 8175
mfgShow.Visible = True
frmQueryCenter.Width = 8700
frmQueryCenter.Height = 6000
'设置MSFlexGrid控件的第0行、第0列的背景色
mfgShow.BackColorFixed = GetColor
'统计记录总数
intRow = 0
Do While (Not rs.EOF)
intRow = intRow + 1
rs.MoveNext
Loop
'MSFlexGrid控件的总行数和列数
mfgShow.Rows = intRow + 1
mfgShow.Cols = 15
'设定表格的各列宽度
mfgShow.ColWidth(0) = 400
mfgShow.ColWidth(1) = 1000
mfgShow.ColWidth(2) = 1500
mfgShow.ColWidth(3) = 800
mfgShow.ColWidth(4) = 800
mfgShow.ColWidth(5) = 800
mfgShow.ColWidth(6) = 800
mfgShow.ColWidth(7) = 1000
mfgShow.ColWidth(8) = 2500
mfgShow.ColWidth(9) = 800
mfgShow.ColWidth(10) = 1500
mfgShow.ColWidth(11) = 1500
mfgShow.ColWidth(12) = 1000
mfgShow.ColWidth(13) = 1000
mfgShow.ColWidth(14) = 800
'添MSFlexGrid控件台头
mfgShow.TextMatrix(0, 1) = "中心代码"
mfgShow.TextMatrix(0, 2) = "中心名称"
mfgShow.TextMatrix(0, 3) = "中心类型"
mfgShow.TextMatrix(0, 4) = "所属区域"
mfgShow.TextMatrix(0, 5) = "城市"
mfgShow.TextMatrix(0, 6) = "所属省"
mfgShow.TextMatrix(0, 7) = "联系人"
mfgShow.TextMatrix(0, 8) = "地址"
mfgShow.TextMatrix(0, 9) = "邮政编码"
mfgShow.TextMatrix(0, 10) = "电话"
mfgShow.TextMatrix(0, 11) = "传真"
mfgShow.TextMatrix(0, 12) = "联系人E-Mail"
mfgShow.TextMatrix(0, 13) = "中心网址"
mfgShow.TextMatrix(0, 14) = "中心状态"
'显示每行的行数
mfgShow.Col = 0
For i = 1 To intRow
mfgShow.Row = i
mfgShow.Text = i
Next
'添入数据
rs.MoveFirst
mfgShow.Row = 0
markColor = True
Do While (Not rs.EOF)
mfgShow.Row = mfgShow.Row + 1
For i = 1 To 14
mfgShow.Col = i
mfgShow.Text = rs.Fields.Item(i).Value
If markColor = False Then
mfgShow.CellBackColor = GetColor
Else
mfgShow.CellBackColor = &HC0C0C0
End If
Next
rs.MoveNext
markColor = Not markColor
Loop
End Sub
Private Sub DisplayRefresh()
Dim ctlcontrol As Control
'清空组合框文本显示
For Each ctlcontrol In Controls
If TypeOf ctlcontrol Is ComboBox Then
ctlcontrol.Clear
End If
Next
'从表SysCenterInfo中取得所有的公司名称,放入cmbCenterName中
strFind = "select cname from syscenterinfo"
RsOpen rsTemp, con, strFind, "adcmdtext"
Do While (rsTemp.EOF = False)
cmbCenterName.AddItem rsTemp.Fields("cname")
rsTemp.MoveNext
Loop
RsClose rsTemp
'从表TempProvince中取得所有的所属省,放入cmbProvince中
strFind = "select * from tempProvince"
RsOpen rsTemp, con, strFind, "adcmdtext"
Do While (rsTemp.EOF = False)
cmbProvince.AddItem rsTemp.Fields("province")
rsTemp.MoveNext
Loop
RsClose rsTemp
'从表TempCenterStatus中取得所有的中心状态,放入CenterStatus中
strFind = "select * from tempCenterStatus"
RsOpen rsTemp, con, strFind, "adcmdtext"
Do While (rsTemp.EOF = False)
cmbStatus.AddItem rsTemp.Fields("centerstatus")
rsTemp.MoveNext
Loop
RsClose rsTemp
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -