📄 form4.frm
字号:
Height = 300
Left = 1080
TabIndex = 1
Top = 240
Width = 2355
End
Begin VB.Label Label8
AutoSize = -1 'True
Caption = "房间类型"
Height = 180
Left = 240
TabIndex = 22
Top = 2040
Width = 720
End
Begin VB.Label Label2
Caption = "酒店名称"
Height = 255
Left = 225
TabIndex = 19
Top = 1680
Width = 735
End
Begin VB.Label Label5
AutoSize = -1 'True
Caption = "预定时间"
Height = 180
Left = 225
TabIndex = 16
Top = 1335
Width = 720
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "预定间数"
Height = 180
Left = 225
TabIndex = 15
Top = 990
Width = 720
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "预定天数"
Height = 180
Left = 225
TabIndex = 14
Top = 645
Width = 720
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "客户卡号"
Height = 180
Left = 225
TabIndex = 13
Top = 300
Width = 720
End
End
Begin MSDataGridLib.DataGrid DataGrid1
Align = 2 'Align Bottom
Height = 4245
Left = 0
TabIndex = 0
Top = 2880
Width = 10740
_ExtentX = 18944
_ExtentY = 7488
_Version = 393216
AllowUpdate = -1 'True
HeadLines = 2
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
MarqueeStyle = 3
BeginProperty Column00
EndProperty
BeginProperty Column01
EndProperty
EndProperty
End
End
Attribute VB_Name = "Form4"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Call clearAll
Call read
Command3.Enabled = True
End Sub
Private Sub Command2_Click()
If Text1.Text = "" Then
MsgBox "客户卡号不能为空!":
Exit Sub:
End If
If Text5.Text = "" Then
MsgBox "酒店名称不能为空!":
Exit Sub:
End If
If Combo1.Text = "" Then
MsgBox "房间类型不能为空!":
Exit Sub:
End If
Dim str As String
str = "update 定单表 set 酒店编号=" & Trim(Text6.Text) & ",客户卡号=" & Trim(Text1.Text) & _
",房间类型='" & ToID(Trim(Combo1.Text)) & "',天数=" & Trim(Text3.Text) & ",间数=" & Trim(Text4.Text) & _
",预定时间='" & DTPicker1.Value & "' where id=" & Text7.Text
If DoSql(str, False) = True Then
MsgBox "数据修改成功!"
Call inigrid
End If
End Sub
Private Sub Command3_Click()
If Text1.Text = "" Then
MsgBox "客户卡号不能为空!"
Exit Sub
End If
If Text5.Text = "" Then
MsgBox "酒店名称不能为空!":
Exit Sub:
End If
If Combo1.Text = "" Then
MsgBox "房间类型不能为空!":
Exit Sub:
End If
Dim str As String
str = "insert into 定单表(酒店编号,客户卡号,房间类型,天数,间数,预定时间) values(" & _
Trim(Text6.Text) & ",'" & Trim(Text1.Text) & "','" & ToID(Combo1.Text) & "'," & _
Trim(Text3.Text) & "," & Trim(Text4.Text) & ",'" & DTPicker1.Value & "')"
If DoSql(str, False) = True Then
MsgBox "数据添加成功!"
Call inigrid
End If
End Sub
Private Sub Command4_Click()
If Text1.Text = "" Then
MsgBox "客户卡号不能为空!":
Exit Sub:
End If
If Text5.Text = "" Then
MsgBox "酒店名称不能为空!":
Exit Sub:
End If
If Combo1.Text = "" Then
MsgBox "房间类型不能为空!":
Exit Sub:
End If
Dim str As String
str = "delete from 定单表 where id=" & DataGrid1.Columns(0).Text
If DoSql(str, False) = True Then
MsgBox "数据删除成功!"
Call inigrid
End If
End Sub
Private Sub DataGrid1_Click()
Command2.Enabled = True: Command4.Enabled = True
colid = DataGrid1.Columns(0).Text
Text1.Text = DataGrid1.Columns(1).Text
Text2.Text = DataGrid1.Columns(2).Text
Text3.Text = DataGrid1.Columns(4).Text
Text4.Text = DataGrid1.Columns(5).Text
Text5.Text = DataGrid1.Columns(2).Text
Text6.Text = DataGrid1.Columns(8).Text '酒店编号
Text7.Text = DataGrid1.Columns(0).Text '订单编号
DTPicker1.Value = DataGrid1.Columns(6).Text
DoSql "select 房间类型 from 酒店信息视图 where id=" & Text6.Text, True
Dim i As Integer
Combo1.Clear
For i = 1 To mAdoRec.RecordCount
Combo1.AddItem mAdoRec.Fields(0)
mAdoRec.MoveNext
Next i
Combo1.Text = DataGrid1.Columns(3).Text
End Sub
Private Sub DataGrid2_Click()
On Error Resume Next
Text5.Text = DataGrid2.Columns(1).Text
Text2.Text = DataGrid2.Columns(1).Text
Text6.Text = DataGrid2.Columns(0).Text
DoSql "select 房间类型 from 酒店信息视图 where id=" & DataGrid2.Columns(0).Text, True
Dim i As Integer
Combo1.Clear
For i = 0 To mAdoRec.RecordCount
Combo1.AddItem mAdoRec.Fields(0)
mAdoRec.MoveNext
Next i
End Sub
Private Sub Form_Load()
Call read
Call inigrid
End Sub
Private Sub Image1_Click()
Dim str As String
str = "select * from 酒店信息视图 where 酒店名称 like '%" & Trim(Text2.Text) & "%'"
Adodc2.ConnectionString = constr
Adodc2.CommandType = adCmdText
Adodc2.RecordSource = str
Set DataGrid2.DataSource = Adodc2
Adodc2.Refresh
DataGrid2.ReBind
Label7.Caption = "查询结果:" & Adodc2.Recordset.RecordCount & "条"
End Sub
Sub fill()
Dim str As String
str = "select * from 订单视图 where id=" & colid
DoSql str, True
Text1.Text = mAdoRec("客户卡号")
Text3.Text = mAdoRec("天数")
Text4.Text = mAdoRec("间数")
DTPicker1.Value = mAdoRec("预定时间")
Text5.Text = mAdoRec("酒店名称")
Combo1.Text = TOstr(mAdoRec("房间类型"))
Text6.Text = CStr(mAdoRec("酒店编号"))
End Sub
Function TOstr(id As Integer)
Dim str As String
str = "select 房间类型 from 房间类型表 where id=" & id
DoSql str, True
TOstr = mAdoRec.Fields(0)
End Function
Sub read() '读取所有房间类型放入房间类型
Dim str1 As String
str1 = "select * from 房间类型表 "
If DoSql(str1, True) = True Then
Dim i As Integer
Combo1.Clear
If mAdoRec.RecordCount > 0 Then
For i = 1 To mAdoRec.RecordCount
Combo1.AddItem mAdoRec(1)
mAdoRec.MoveNext
Next i
End If
End If
End Sub
Function ToID(str As String) '把房间类型名称转换成id
str = "select id from 房间类型表 where 房间类型='" & str & "'"
If DoSql(str, True) = True Then
ToID = mAdoRec.Fields("id")
End If
End Function
Sub inigrid() '初始化格子
Dim str As String
Adodc1.ConnectionString = constr
Adodc1.CommandType = adCmdTable
Adodc1.RecordSource = "订单视图"
Set DataGrid1.DataSource = Adodc1
Adodc1.Refresh
DataGrid1.ReBind
End Sub
Sub clearAll()
Text1.Text = "": Text2.Text = "": Text3.Text = ""
Text4.Text = "": Text5.Text = "":
End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer)
KeyAscii = ValiText(Text3.Text, KeyAscii, "0123456789", True)
End Sub
Private Sub Text4_KeyPress(KeyAscii As Integer)
KeyAscii = ValiText(Text4.Text, KeyAscii, "0123456789", True)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -