📄 clsreservation.cls
字号:
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "ClsReservation"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
'local variable(s) to hold propery value(s)
Private mvarNoOfPeople As Integer
Private mvarCustId As String
Private mvarCheckInDate As Data
Private mvarNoOfDays As Integer
Private mvarRoomTypes As String
Private mvarRoomNo As Integer
Private mvarRate As Long
Dim cn As New ADODB.Connection
Dim cmdreserv As New ADODB.Command
Dim cmdroom As New ADODB.Command
'property to store the custid
Public Property Let CustId(ByVal vData As String)
mvarCustId = vData
End Property
'property to return the custid
Public Property Get CustId() As String
CustId = mvarCustId
End Property
'method to insert the new record in the Reservation table and update the Room table
Public Sub SaveReservation()
Dim strreserv As String
Dim strRoom As String
Set cmdreserv = New ADODB.Command
Set cmdroom = New ADODB.Command
strreserv = "Insert into reservation values( ' " & mvarCustId & " '," & mvarRoomNo & ", " & mvarNoOfPeople & ", ' " & mvarCheckInDate & " '," & mvarNoOfDays & " )"
cmdreserv.ActiveConnection = cn
cmdreserv.CommandText = strreserv
cmdreserv.CommandType = adCmdText
cmdreserv.Execute
strRoom = "Update Room set status ='N' where room_no= " & mvarRoomNo & " and room_type_cd=' " & mvarRoomTypes & " ' "
cmdroom.ActiveConnection = cn
cmdroom.CommandText = strRoom
cmdroom.CommandType = adCmdText
cmdroom.Execute
End Sub
'property to store the Rate
Public Property Let Rate(ByVal vData As Long)
mvarRate = vData
End Property
'property to return the rate
Public Property Get Rate() As Long
Rate = mvarRate
End Property
'property to store the RoomNo
Public Property Get RoonNo() As Integer
RoomNo = mvarRoomNo
End Property
'Property to store the Roomtype
Public Property Let RoomTypes(ByVal vData As String)
mvarRoomTypes = vData
End Property
'property to return the RoomType
Public Property Get RoomType() As String
RoomTypes = mvarRoomTypes
End Property
'property to store the NoOfDays
Public Property Let NoOfDays(ByVal vData As Integer)
mvarNoOfDays = vData
End Property
'property to retrurn the NoOfDays
Public Property Get NoOfDays() As Integer
NoOfDays = mvarNoOfDays
End Property
'property to store the CheckInDdate
Public Property Let CheckInDate(ByVal vData As Data)
mvarCheckInDate = vData
End Property
'property to return the CheckInDate
Public Property Get CheckInDate() As Data
CheckInDate = mvarCheckInDate
End Property
'property to store the NoOfPeople
Public Property Let NoOfPeople(ByVal vData As Integer)
mvarNoOfPeople = vData
End Property
'property to return the NoOfPeople
Public Property Get NoOfPeople() As Integer
NoOfPeople = mvarNoOfPeople
End Property
Private Sub class_Initialize()
Set cn = New ADODB.Connection
'change the DSN to the one you have created.
cn.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=hotels;Data Source=01B21976EE594F3"
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -