📄 form8.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form Form8
BorderStyle = 1 'Fixed Single
Caption = "客户登记"
ClientHeight = 8820
ClientLeft = 45
ClientTop = 435
ClientWidth = 7185
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
LinkTopic = "Form8"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 8820
ScaleWidth = 7185
StartUpPosition = 3 '窗口缺省
Begin MSAdodcLib.Adodc Adodc3
Height = 615
Left = 5160
Top = 8160
Visible = 0 'False
Width = 1935
_ExtentX = 3413
_ExtentY = 1085
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 = "Adodc3"
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 MSAdodcLib.Adodc Adodc2
Height = 615
Left = 2520
Top = 8160
Visible = 0 'False
Width = 2055
_ExtentX = 3625
_ExtentY = 1085
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 1
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=信息表.mdb;Persist Security Info=False"
OLEDBString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=信息表.mdb;Persist Security Info=False"
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = $"Form8.frx":0000
Caption = "Adodc2"
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 MSAdodcLib.Adodc Adodc1
Height = 615
Left = 0
Top = 8160
Visible = 0 'False
Width = 1935
_ExtentX = 3413
_ExtentY = 1085
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 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=信息表.mdb;Persist Security Info=False"
OLEDBString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=信息表.mdb;Persist Security Info=False"
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = "select 房间号 from 客房信息表 where 状态=0"
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.CommandButton Command2
Caption = "取消"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 3720
TabIndex = 11
Top = 6000
Width = 1215
End
Begin VB.CommandButton Command1
BackColor = &H8000000D&
Caption = "确定"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 1080
TabIndex = 10
Top = 6000
Width = 1215
End
Begin VB.ComboBox Combo1
CausesValidation= 0 'False
DataField = "房间号"
DataSource = "Adodc1"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 300
ItemData = "Form8.frx":004F
Left = 3480
List = "Form8.frx":0056
TabIndex = 9
Top = 3600
Width = 1695
End
Begin VB.TextBox Text5
Alignment = 1 'Right Justify
Height = 375
Left = 3480
TabIndex = 8
Text = "0"
Top = 4440
Width = 1695
End
Begin VB.TextBox Text3
Height = 375
Left = 3480
TabIndex = 7
Text = "2008-8-2"
Top = 2520
Width = 1695
End
Begin VB.TextBox Text2
Height = 375
Left = 3480
TabIndex = 6
Text = "2008-7-16"
Top = 1560
Width = 1695
End
Begin VB.TextBox Text1
Height = 375
Left = 3480
TabIndex = 5
Top = 600
Width = 1695
End
Begin VB.Label Label5
Caption = "押金:"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 2040
TabIndex = 4
Top = 4560
Width = 735
End
Begin VB.Label Label4
Caption = "房间号:"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 2040
TabIndex = 3
Top = 3600
Width = 975
End
Begin VB.Label Label3
Caption = "退房时间:"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 2040
TabIndex = 2
Top = 2640
Width = 1095
End
Begin VB.Label Label2
Caption = "入住时间:"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 2040
TabIndex = 1
Top = 1680
Width = 975
End
Begin VB.Label Label1
Caption = "客户姓名:"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 2040
TabIndex = 0
Top = 720
Width = 975
End
End
Attribute VB_Name = "Form8"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim sql As String
Dim rs As New ADODB.Recordset
Dim cnn As ADODB.Connection
Dim spl1 As String
Dim rs1 As New ADODB.Recordset
Dim cnn1 As ADODB.Connection
Dim d1 As Date
Dim d2 As Date
Dim d5 As Integer
Dim i As Integer
Private Sub Command1_Click()
Set cnn = New ADODB.Connection
cnn.Open "provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\信息表.mdb;Persist Security Info=False"
If Trim(Text1.Text) = "" Then
MsgBox "该项为必填项", vbOKOnly + vbExclamation, ""
Text1.SetFocus
Exit Sub
ElseIf Trim(Text2.Text) = "" Then
MsgBox "该项为必填项", vbOKOnly + vbExclamation, ""
Text2.SetFocus
Exit Sub
ElseIf Trim(Text3.Text) = "" Then
MsgBox "该项不能为空", vbOKOnly + vbExclamation, ""
Text3.SetFocus
Exit Sub
ElseIf Trim(Text5.Text) = "" Then
MsgBox "该项不能为空", vbOKOnly + vbExclamation, ""
Text5.SetFocus
Exit Sub
ElseIf Not IsDate(Text2.Text) Or Not IsDate(Text3.Text) Then
MsgBox "输入日期格式不正确!" + Chr(13) + Chr(10) + "如:2008-8-8", vbOKOnly + vbExclamation, "提示"
Exit Sub
Else
sql = "select * from 入住客户信息" '将入住客户信息写入数据库
rs.Open sql, cnn, adOpenKeyset, adLockPessimistic
rs.AddNew
rs.Fields(0) = Text1.Text
rs.Fields(1) = Text2.Text
rs.Fields(2) = Text3.Text
rs.Fields(3) = Combo1.Text
rs.Fields(4) = Text5.Text
rs.Update
rs.Close
MsgBox "登记成功", vbOKOnly + vbExclamation, ""
Unload Me
Set cnn1 = New ADODB.Connection '将已经被订的房间的状态写为“1”,即已有客户入住
cnn1.Open "provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\信息表.mdb;Persist Security Info=False"
sql1 = "select 客房信息表.状态 from 入住客户信息,客房信息表 where 入住客户信息.房间号=客房信息表.房间号"
rs1.Open sql1, cnn1, adOpenKeyset, adLockPessimistic
If rs1.EOF And rs1.BOF Then
Exit Sub
Else
rs1.MoveFirst
While (rs1.EOF = False)
rs1.Fields("状态") = 1
rs1.Update
rs1.MoveNext
Wend
End If
End If
End Sub
Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
i = Adodc1.Recordset.RecordCount
For n = 1 To i
Combo1.List(n - 1) = Adodc1.Recordset.Fields(0)
Adodc1.Recordset.MoveNext
Next n
End Sub
'以下是我想实现某种功能但运行出错的代码,错误提示为:对象变量或with变量未设置。该功能是:在按“押金”标签后,自动生成押金金额。
'如果老师有空,请帮忙分析一下以下的代码,使本系统更加完善,谢谢!
'd1 = CDate(Text2.Text)
'd2 = CDate(Text3.Text)
'd3 = DateSerial(Year(d1), Month(d1), Day(d1))
'd4 = DateSerial(Year(d2), Month(d2), Day(d2))
'd5 = d4 - d3
'While (Adodc2.Recordset.EOF = False)
'If Adodc2.Recordset.Fields("房间号") = Combo1.Text Then
'Text5.Text = d5 * Val(Adodc2.Recordset.Fields("客房价格"))
'End If
'Adodc2.Recordset.MoveNext
'Wend
'End If
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -