📄 frmroomman.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form FrmRoomMan
Caption = "房间信息管理"
ClientHeight = 4230
ClientLeft = 60
ClientTop = 345
ClientWidth = 9945
Icon = "FrmRoomMan.frx":0000
LinkTopic = "Form1"
ScaleHeight = 4230
ScaleWidth = 9945
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton Cmd_Status
Caption = "更改状态"
Height = 495
Left = 6030
TabIndex = 9
Top = 3480
Width = 1215
End
Begin VB.ComboBox ComboRtype
Height = 300
Left = 1320
Style = 2 'Dropdown List
TabIndex = 8
Top = 180
Width = 1815
End
Begin MSDataGridLib.DataGrid DataGrid1
Height = 2535
Left = 120
TabIndex = 7
Top = 720
Width = 9735
_ExtentX = 17171
_ExtentY = 4471
_Version = 393216
AllowUpdate = 0 'False
HeadLines = 1
RowHeight = 15
BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ColumnCount = 2
BeginProperty Column00
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column01
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
SplitCount = 1
BeginProperty Split0
BeginProperty Column00
EndProperty
BeginProperty Column01
EndProperty
EndProperty
End
Begin VB.ComboBox ComboStatus
Height = 300
ItemData = "FrmRoomMan.frx":0CCA
Left = 5040
List = "FrmRoomMan.frx":0CE0
Style = 2 'Dropdown List
TabIndex = 4
Top = 180
Width = 1695
End
Begin VB.CommandButton Cmd_Add
Caption = "添 加"
Height = 495
Left = 720
TabIndex = 3
Top = 3480
Width = 1215
End
Begin VB.CommandButton Cmd_Edit
Caption = "修 改"
Height = 495
Left = 2490
TabIndex = 2
Top = 3480
Width = 1215
End
Begin VB.CommandButton Cmd_Delt
Caption = "删 除"
Height = 495
Left = 4260
TabIndex = 1
Top = 3480
Width = 1215
End
Begin VB.CommandButton Cmd_Close
Caption = "返 回"
Height = 495
Left = 7800
TabIndex = 0
Top = 3480
Width = 1215
End
Begin MSAdodcLib.Adodc Adodc2
Height = 375
Left = 0
Top = 3840
Visible = 0 'False
Width = 1815
_ExtentX = 3201
_ExtentY = 661
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 8
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = ""
OLEDBString = ""
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = ""
Caption = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "客房类型"
Height = 180
Left = 240
TabIndex = 6
Top = 240
Width = 720
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "客房状态"
Height = 180
Left = 3840
TabIndex = 5
Top = 240
Width = 720
End
End
Attribute VB_Name = "FrmRoomMan"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public Sub Refresh_Room()
'判断ComboRtype组合框listindex,在数组Arr_RoomType()得到对应的类别编号
Dim sql1 As String '保存客房类型的查询条件
Dim sql2 As String '保存客房状态的查询条件
Dim sqlStr As String
'设置客户类型的查询条件,选择全部时没有查询条件
If ComboRtype.ListIndex > 0 Then
sql1 = " And t.TypeName='" + Trim(ComboRtype.Text) + "'"
Else
sql1 = ""
End If
'设置客户状态的查询条件,选择全部时没有查询条件
If ComboStatus.ListIndex > 0 Then
sql2 = " And r.Status=" + Trim(ComboStatus.ListIndex - 1)
Else
sql2 = ""
End If
'返回查询条件
sqlStr = sql1 + sql2
'strSql表示设置的查询条件
Adodc2.ConnectionString = Conn
Adodc2.RecordSource = "SELECT r.RoomNo As 房间编号, t.TypeName as 房间类型," _
+ " t.RoomNum as 房间个数, t.BedNum as 床位数量, r.Position as 朝向," _
+ " r.Price as 价格, (CASE r.status When 0 Then '空房' " _
+ " When 1 Then '预定' When 2 Then '入住' When 3 Then '退房' Else '维修' End) As 状态," _
+ " r.ObjList as 物品清单 FROM Room r, RoomType t WHERE r.TypeId=t.TypeId " _
+ sqlStr + " ORDER BY r.RoomNo"
Adodc2.Refresh
Set DataGrid1.DataSource = Adodc2
DataGrid1.Columns(0).Width = 1000 '房间编号
DataGrid1.Columns(1).Width = 1200 '房间类型
DataGrid1.Columns(2).Width = 1000 '房间个数
DataGrid1.Columns(3).Width = 1000 '床位个数
DataGrid1.Columns(4).Width = 800 '朝向
DataGrid1.Columns(5).Width = 1400 '价格
DataGrid1.Columns(6).Width = 800 '状态
DataGrid1.Columns(7).Width = 2000 '物品清单
End Sub
Private Sub ComboRtype_Click()
'点击客房类型时更改记录内容
Refresh_Room
End Sub
Private Sub ComboStatus_Click()
'点击客房状态时更改记录内容
Refresh_Room
End Sub
Private Sub Cmd_Add_Click()
FrmRoomEdit.Modify = False '添加新房间
FrmRoomEdit.Show 1
End Sub
Private Sub Cmd_Close_Click()
Unload Me
End Sub
Private Sub Cmd_Delt_Click()
'判断是否选择了要删除的记录
If Adodc2.Recordset.EOF = True Then
MsgBox "请选择要删除的记录"
Exit Sub
End If
'要求用户确认删除
If MsgBox("是否删除当前记录", vbYesNo, "请确认") = vbYes Then
MyRoom.Delete (Trim(Adodc2.Recordset.Fields(0)))
Refresh_Room
End If
End Sub
Private Sub Cmd_Edit_Click()
'判断是否选择了要修改的记录
If Adodc2.Recordset.EOF = True Then
MsgBox "请选择要修改的记录"
Exit Sub
End If
'对FrmRoomTypeEdit窗体对象进行初始化
With FrmRoomEdit
.OrgRId = Trim(Adodc2.Recordset.Fields(0)) '客房
.txtRId = Trim(Adodc2.Recordset.Fields(0)) '客房编号
.dco_RType.Text = Trim(Adodc2.Recordset.Fields(1)) '客房类型
If Trim(Adodc2.Recordset.Fields(4)) <> "" Then
.cmbDrt = Trim(Adodc2.Recordset.Fields(4)) '房间朝向
End If
.txtPrice = Adodc2.Recordset.Fields(5) '房间价格
If Trim(Adodc2.Recordset.Fields(6)) <> "" Then
If Trim(Adodc2.Recordset.Fields(6)) = "空房" Then
.ComboStatus.ListIndex = 0
ElseIf Trim(Adodc2.Recordset.Fields(6)) = "预定" Then
.ComboStatus.ListIndex = 1
ElseIf Trim(Adodc2.Recordset.Fields(6)) = "入住" Then
.ComboStatus.ListIndex = 2
ElseIf Trim(Adodc2.Recordset.Fields(6)) = "退房" Then
.ComboStatus.ListIndex = 3
ElseIf Trim(Adodc2.Recordset.Fields(6)) = "维修" Then
.ComboStatus.ListIndex = 4
End If
End If
If Trim(Adodc2.Recordset.Fields(7)) <> "" Then
.txtList = Trim(Adodc2.Recordset.Fields(7)) '物品清单
End If
'设置修改状态
.Modify = True
.Show 1
End With
End Sub
Private Sub Cmd_Status_Click()
'更改客房状态
If Adodc2.Recordset.EOF = True Then
MsgBox "请选择记录"
Exit Sub
End If
FrmRoomStatus.lblRoomNo = Trim(Adodc2.Recordset.Fields(0))
FrmRoomStatus.lblStatus = Trim(Adodc2.Recordset.Fields(6))
FrmRoomStatus.Show 1
'刷新显示
Refresh_Room
End Sub
Private Sub Form_Load()
Dim j As Integer
'读取客户类别到数组Arr_CustType()中
ComboRtype.Clear
ComboRtype.AddItem ("全部")
MyRoomType.Loadtype
'依次把数组Arr_RoomType()中的数据添加到ComboRtype组合框中
j = 0
Do While Arr_RoomType(j) <> ""
ComboRtype.AddItem Arr_RoomType(j)
j = j + 1
Loop
ComboRtype.ListIndex = 0
ComboStatus.ListIndex = 0
Refresh_Room
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -