📄 main_ftcx.frm
字号:
Begin VB.CommandButton Command1
BackColor = &H00C0C0C0&
Caption = "8401"
Height = 870
Index = 20
Left = 4395
Style = 1 'Graphical
TabIndex = 8
Top = 2760
Width = 1080
End
Begin VB.CommandButton Command1
BackColor = &H00C0C0C0&
Caption = "8402"
Height = 870
Index = 21
Left = 135
Style = 1 'Graphical
TabIndex = 7
Top = 3615
Width = 1080
End
Begin VB.CommandButton Command1
BackColor = &H00C0C0C0&
Caption = "8403"
Height = 870
Index = 22
Left = 1200
Style = 1 'Graphical
TabIndex = 6
Top = 3615
Width = 1080
End
Begin VB.CommandButton Command1
BackColor = &H00C0C0C0&
Caption = "8404"
Height = 870
Index = 23
Left = 2265
Style = 1 'Graphical
TabIndex = 5
Top = 3615
Width = 1080
End
Begin VB.CommandButton Command1
BackColor = &H00C0C0C0&
Caption = "8406"
Height = 870
Index = 24
Left = 3330
Style = 1 'Graphical
TabIndex = 4
Top = 3615
Width = 1080
End
Begin VB.CommandButton Command1
BackColor = &H00C0C0C0&
Caption = "8408"
Height = 870
Index = 25
Left = 4395
Style = 1 'Graphical
TabIndex = 3
Top = 3615
Width = 1080
End
End
Begin VB.Frame Frame2
Caption = "注释"
Height = 540
Left = 45
TabIndex = 0
Top = 4560
Width = 7440
Begin VB.Label Labsyl
ForeColor = &H000000FF&
Height = 285
Left = 5730
TabIndex = 1
Top = 225
Width = 855
End
Begin VB.Label Labsy
ForeColor = &H000000FF&
Height = 285
Left = 690
TabIndex = 28
Top = 210
Width = 780
End
Begin VB.Label Labkx
ForeColor = &H000000FF&
Height = 285
Left = 2145
TabIndex = 29
Top = 225
Width = 705
End
Begin VB.Label Labwx
ForeColor = &H000000FF&
Height = 285
Left = 3540
TabIndex = 30
Top = 225
Width = 915
End
Begin VB.Label Lab4
Caption = "入住: 空闲: 维修: 房间使用率:"
ForeColor = &H00FF0000&
Height = 270
Left = 75
TabIndex = 31
Top = 225
Width = 7335
End
End
Begin VB.Image Image1
Height = 360
Left = 6315
Picture = "main_ftcx.frx":09E3
Stretch = -1 'True
Top = 735
Width = 345
End
Begin VB.Label Lab1
BackStyle = 0 'Transparent
Caption = "入住"
ForeColor = &H000040C0&
Height = 390
Left = 6780
TabIndex = 36
Top = 750
Width = 510
End
Begin VB.Label Lab2
BackStyle = 0 'Transparent
Caption = "空闲"
ForeColor = &H000040C0&
Height = 390
Left = 6780
TabIndex = 35
Top = 1500
Width = 510
End
Begin VB.Label Lab3
BackStyle = 0 'Transparent
Caption = "维修"
ForeColor = &H000040C0&
Height = 390
Left = 6780
TabIndex = 34
Top = 2205
Width = 510
End
Begin VB.Image Image2
Height = 360
Left = 6315
Picture = "main_ftcx.frx":1225
Stretch = -1 'True
Top = 2130
Width = 345
End
End
Attribute VB_Name = "main_ftcx"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Form_Activate()
'定义一个整型变量
Dim i As Integer
'定义一个字符串变量
Dim criteria As String
Dim DBcnn As New ADODB.Connection
Dim DBrs1 As New ADODB.Recordset
Dim DBrs2 As New ADODB.Recordset
Dim DBrs3 As New ADODB.Recordset
If DBcnn.State = 0 Then
Dim connectstr As String
connectstr = "Provider=Microsoft.jet.OLEDB.4.0;Data Source=" & _
App.Path & "\KFGL.mdb;Persist Security Info=False"
DBcnn.CursorLocation = adUseClient
DBcnn.Open connectstr
End If
If DBrs1.State = 1 Then
DBrs1.Close
End If
If DBrs2.State = 1 Then
DBrs2.Close
End If
If DBrs3.State = 1 Then
DBrs3.Close
End If
'设置并执行sql语句,以返回包含客房(kf)表中的所有酒店客房记录的数据集DBrs1
sql = "select * from kf "
Set DBrs1 = DBcnn.Execute(sql)
' 设置并执行sql语句,以返回包含客房(kf)表中的所有已经入住的酒店客房
'记录的数据集DBrs2
sql = "select * from kf where kf.房态 like '%入住%'"
Set DBrs2 = DBcnn.Execute(sql)
'设置并执行sql语句,以返回包含客房(kf)表中的所有处于维修状态的酒店客房
'记录的数据集DBrs3
sql = "select * from kf where kf.房态 like '%维修%'"
Set DBrs3 = DBcnn.Execute(sql)
'在Frame1容器中的命令按钮的显示图像
For i = 1 To 25
'设置数据集对象DBrs1的filter属性,以返回所选命令按钮对应的房间号的相关信息
criteria = "房间号='" & Trim(Command1(i).Caption) & "'"
DBrs1.Filter = criteria
'判断数据集DBrs1是否包含该房间
If Not DBrs1.EOF Then
'数据集DBrs1包含该房间,根据该房间的住宿状态,在命令按钮上显示相应的图像
If DBrs1.Fields("房态") = "空房" Then
'该客房处于空房状态,在命令按钮上显示空房对应的图像
Command1(i).Picture = LoadPicture("")
End If
If DBrs1.Fields("房态") = "入住" Then
'该客房处于入住状态,在命令按钮上显示入住对应的图像
Command1(i).Picture = LoadPicture(App.Path & "\image\rz.ico")
End If
If DBrs1.Fields("房态") = "维修" Then
'该客房处于维修状态,在命令按钮上显示维修对应的图像
Command1(i).Picture = LoadPicture(App.Path & "\image\wx.ico")
End If
End If
Next i
If Not DBrs2.EOF Then DBrs2.MoveLast
If Not DBrs3.EOF Then DBrs3.MoveLast
'在Labsy控件中显示客房入住数
Labsy.Caption = DBrs2.RecordCount
'在Labwx控件中显示客房维修数
Labwx.Caption = DBrs3.RecordCount
'在Labkx控件中显示客房空闲数
Labkx.Caption = 25 - Val(Labwx.Caption) - Val(Labsy.Caption)
'在Labsyl控件中显示客房使用率
Labsyl.Caption = Val(Labsy.Caption) / 25 * 100 & "%"
End Sub
Private Sub Form_Unload(Cancel As Integer)
main.Enabled = True
End Sub
Private Sub Command1_Click(Index As Integer) '查询住宿信息
If Index >= 0 And Index <= 25 Then
'使用被单击的命令按钮对应的房间号给住宿信息窗体中的全局变量housename赋值
'以在住宿信息查询窗体main_zscx中显示该房间的住宿信息
main_zscx.housenumber = Command1(Index).Caption
End If
'装载住宿信息查询窗体main_zscx
Load main_zscx
'显示住宿信息查询窗体main_zscx
main_zscx.Show
End Sub
Private Sub Command2_Click()
Unload Me
main.Enabled = True
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -