📄 cruise.frm
字号:
VERSION 5.00
Begin VB.Form CRUISE
BackColor = &H00C0C0FF&
Caption = "行程"
ClientHeight = 6105
ClientLeft = 60
ClientTop = 450
ClientWidth = 7515
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
LinkTopic = "Form1"
MDIChild = -1 'True
Picture = "CRUISE.frx":0000
ScaleHeight = 6105
ScaleWidth = 7515
Begin VB.Frame Frame1
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "查询"
ForeColor = &H80000008&
Height = 1455
Left = 480
TabIndex = 23
Top = 3240
Width = 4335
Begin VB.CommandButton cmdFindOK
Caption = "查询确认"
Height = 375
Left = 120
TabIndex = 26
Top = 960
Width = 1215
End
Begin VB.TextBox Findtxt
Height = 375
Left = 1440
TabIndex = 25
Top = 360
Width = 2775
End
Begin VB.ComboBox FindCombo
Height = 360
ItemData = "CRUISE.frx":21C74
Left = 120
List = "CRUISE.frx":21C7E
TabIndex = 24
Text = "查找"
Top = 360
Width = 1215
End
End
Begin VB.CommandButton cmdAdd
Caption = "添加"
Height = 375
Left = 480
TabIndex = 22
Top = 2640
Visible = 0 'False
Width = 1095
End
Begin VB.CommandButton cmdSave
Caption = "保存"
Height = 375
Left = 1920
TabIndex = 21
Top = 2640
Width = 1095
End
Begin VB.CommandButton cmdCancel
Caption = "取消"
Height = 375
Left = 3360
TabIndex = 20
Top = 2640
Width = 1095
End
Begin VB.CommandButton cmdExit
Caption = "退出"
Height = 375
Left = 4800
TabIndex = 19
Top = 2640
Width = 1095
End
Begin VB.CommandButton cmdUpdata
Caption = "修改"
Height = 375
Left = 480
TabIndex = 18
Top = 2640
Visible = 0 'False
Width = 1095
End
Begin VB.TextBox cruise_cdtxt
Height = 375
Left = 1080
TabIndex = 10
Top = 120
Width = 1215
End
Begin VB.TextBox cruise_nmtxt
Height = 375
Left = 3960
TabIndex = 9
Top = 120
Width = 3495
End
Begin VB.TextBox des_citytxt
Height = 375
Left = 1080
TabIndex = 8
Top = 720
Width = 1575
End
Begin VB.TextBox country_nmtxt
Height = 375
Left = 3960
TabIndex = 7
Top = 720
Width = 1335
End
Begin VB.TextBox durationtxt
Height = 375
Left = 1080
TabIndex = 6
Top = 1320
Width = 855
End
Begin VB.TextBox pricetxt
Height = 375
Left = 3360
TabIndex = 5
Top = 1320
Width = 1095
End
Begin VB.ComboBox airfareCombo
Height = 360
ItemData = "CRUISE.frx":21C92
Left = 6000
List = "CRUISE.frx":21C9C
TabIndex = 4
Text = "Yes"
Top = 1320
Width = 735
End
Begin VB.CommandButton cmdFirst
Caption = "<<"
Height = 375
Left = 480
TabIndex = 3
Top = 2040
Width = 1095
End
Begin VB.CommandButton cmdPreviouse
Caption = "<"
Height = 375
Left = 1920
TabIndex = 2
Top = 2040
Width = 1095
End
Begin VB.CommandButton cmdNext
Caption = ">"
Height = 375
Left = 3360
TabIndex = 1
Top = 2040
Width = 1095
End
Begin VB.CommandButton cmdLast
Caption = ">>"
Height = 375
Left = 4800
TabIndex = 0
Top = 2040
Width = 1095
End
Begin VB.Label record_counts
BackColor = &H00C0E0FF&
BackStyle = 0 'Transparent
Caption = "Label10"
Height = 495
Left = 2520
TabIndex = 27
Top = 5160
Width = 2895
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
BackColor = &H00C0C0FF&
BackStyle = 0 'Transparent
Caption = "编号:"
Height = 255
Left = 480
TabIndex = 17
Top = 240
Width = 615
End
Begin VB.Label Label2
Alignment = 1 'Right Justify
BackColor = &H00C0C0FF&
BackStyle = 0 'Transparent
Caption = "行程名:"
Height = 255
Left = 3120
TabIndex = 16
Top = 240
Width = 855
End
Begin VB.Label Label3
Alignment = 1 'Right Justify
BackColor = &H00C0C0FF&
BackStyle = 0 'Transparent
Caption = "目的地:"
Height = 255
Left = 240
TabIndex = 15
Top = 840
Width = 855
End
Begin VB.Label Label4
Alignment = 1 'Right Justify
BackColor = &H00C0C0FF&
BackStyle = 0 'Transparent
Caption = "国家:"
Height = 255
Left = 3360
TabIndex = 14
Top = 840
Width = 615
End
Begin VB.Label Label5
Alignment = 1 'Right Justify
BackColor = &H00C0C0FF&
BackStyle = 0 'Transparent
Caption = "行程天数:"
Height = 255
Left = 0
TabIndex = 13
Top = 1440
Width = 1095
End
Begin VB.Label Label6
Alignment = 1 'Right Justify
BackColor = &H00C0C0FF&
BackStyle = 0 'Transparent
Caption = "票价:"
Height = 255
Left = 2760
TabIndex = 12
Top = 1440
Width = 615
End
Begin VB.Label Label7
Alignment = 1 'Right Justify
BackColor = &H00C0C0FF&
BackStyle = 0 'Transparent
Caption = "是否含票:"
Height = 255
Left = 4920
TabIndex = 11
Top = 1440
Width = 1095
End
End
Attribute VB_Name = "CRUISE"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim cnn As ADODB.Connection
Dim rs As ADODB.Recordset
Private Sub cmdAdd_Click()
Dim cnt As Long
Dim val As String
Display_False
val = ""
rs.MoveFirst
Do While rs.EOF = False
val = rs!cruise_cd
rs.MoveNext
Loop
cnt = CLng(Mid(val, 2, Len(val) - 1))
cnt = cnt + 1
If cnt >= 0 And cnt <= 9 Then
val = "M00" & CStr(cnt)
cruise_cdtxt = val
ElseIf cnt >= 10 And cnt <= 99 Then
val = "M0" & CStr(cnt)
cruise_cdtxt = val
ElseIf cnt >= 100 And cnt <= 999 Then
val = "M" & CStr(cnt)
cruise_cdtxt = val
Else
MsgBox ("没有可用卡号,要使用与管理员联系,请管理员调整卡号位数!")
rs.CancelUpdate
End If
cruise_nmtxt.Text = ""
des_citytxt.Text = ""
country_nmtxt.Text = ""
durationtxt.Text = ""
pricetxt.Text = ""
airfareCombo.Text = "Yes"
End Sub
Private Sub cmdCancel_Click()
rs.Cancel
If cmdAdd.Visible = True Then
rs.MoveFirst
End If
Display
Display_True
FindCombo.Enabled = True
Findtxt.Enabled = True
cmdFindOK.Enabled = True
End Sub
Private Sub cmdExit_Click()
Unload CRUISE
End Sub
Private Sub cmdFindOK_Click()
Dim str1 As String, str2 As String
Select Case FindCombo.Text
Case Is = "行程号"
str1 = "cruise_cd= '" & Trim(Findtxt) & "'"
Case Is = "行程名"
str1 = "cruise_nm= '" & Trim(Findtxt) & "'"
Case Else
str2 = "请按" + FindCombo.Text + "类型进行查询!"
MsgBox str2, , "警告"
Exit Sub
End Select
On Error GoTo err
rs.MoveFirst
rs.Find (str1)
If rs.EOF Then
MsgBox "没有查到满足条件的记录"
Else
Display
End If
Exit Sub
err:
MsgBox err.Description
End Sub
Private Sub cmdSave_Click()
If cruise_nmtxt.Text = Empty Then
MsgBox "行程名不能为空!"
cruise_nmtxt.SetFocus
Exit Sub
ElseIf Len(Trim(cruise_nmtxt.Text)) > 30 Then
MsgBox "行程名长度不能起过30!"
cruise_nmtxt.SetFocus
Exit Sub
End If
If des_citytxt.Text = Empty Then
MsgBox "目的地不能为空!"
des_citytxt.SetFocus
Exit Sub
ElseIf Len(Trim(des_citytxt.Text)) > 15 Then
MsgBox "目的地长度不能超过15!"
des_citytxt.SetFocus
Exit Sub
End If
If country_nmtxt.Text = Empty Then
MsgBox "国家名不能为空!"
country_nmtxt.SetFocus
Exit Sub
ElseIf Len(Trim(country_nmtxt.Text)) > 10 Then
MsgBox "国家名长度超过10!"
country_nmtxt.SetFocus
Exit Sub
End If
If durationtxt.Text = Empty Then
MsgBox "行程天数不能为空!"
durationtxt.SetFocus
Exit Sub
ElseIf Len(Trim(durationtxt.Text)) > 4 Then
MsgBox "行程天数长度不能超过4!"
durationtxt.SetFocus
Exit Sub
End If
If pricetxt.Text = Empty Then
MsgBox "票价不能为空!"
pricetxt.SetFocus
Exit Sub
ElseIf Len(Trim(pricetxt.Text)) > 10 Then
MsgBox "票价长度不能超过10!"
pricetxt.SetFocus
Exit Sub
End If
If airfareCombo.Text = Empty Then
MsgBox "是否含机票不能为空!"
airfareCombo.SetFocus
Exit Sub
ElseIf airfareCombo.Text <> "Yes" And airfareCombo.Text <> "No" Then
MsgBox "是否含机票只能为 Yes 或者是 No!"
airfareCombo.SetFocus
Exit Sub
End If
If cmdAdd.Visible = True Then
rs.AddNew
End If
rs!cruise_cd = cruise_cdtxt.Text
If cruise_nmtxt.Text <> Empty Then rs!cruise_nm = cruise_nmtxt.Text
If des_citytxt.Text <> Empty Then rs!des_city = des_citytxt.Text
If country_nmtxt.Text <> Empty Then rs!country_nm = country_nmtxt.Text
If durationtxt.Text <> Empty Then rs!duration = durationtxt.Text
If pricetxt.Text <> Empty Then rs!price = pricetxt.Text
If airfareCombo.Text <> Empty Then rs!airfare = airfareCombo.Text
rs.Update
MsgBox "保存成功!"
If cmdAdd.Visible = True Then
rs.MoveLast
End If
Display
Display_True
FindCombo.Enabled = True
Findtxt.Enabled = True
cmdFindOK.Enabled = True
record_counts.Caption = "当前记录:" + Str(rs.AbsolutePosition) + "/" + Str(rs.RecordCount)
End Sub
Private Sub cmdUpdata_Click()
Display_False
End Sub
Private Sub FindCombo_Click()
Select Case Trim(FindCombo.Text)
Case Is = "行程号"
Findtxt.Text = "M"
Case Is = "行程名"
Findtxt.Text = ""
Case Else
End Select
End Sub
Private Sub Form_Load()
Set cnn = New ADODB.Connection
cnn.ConnectionString = "FILE NAME=" & App.Path & "\Tourist.udl"
cnn.Open
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
rs.Open "CRUISE", cnn, adOpenDynamic, adLockOptimistic, adCmdTable
CRUISE.WindowState = 2
Display
Display_True
FindCombo.Enabled = True
Findtxt.Enabled = True
cmdFindOK.Enabled = True
record_counts.Caption = "当前记录:" + Str(rs.AbsolutePosition) + "/" + Str(rs.RecordCount)
End Sub
Private Sub Form_Unload(Cancel As Integer)
rs.Close
Set rs = Nothing
cnn.Close
Set cnn = Nothing
End Sub
Private Sub Display()
cruise_cdtxt.Text = rs!cruise_cd
cruise_nmtxt.Text = rs!cruise_nm
des_citytxt.Text = rs!des_city
country_nmtxt.Text = rs!country_nm
durationtxt.Text = rs!duration
pricetxt.Text = rs!price
airfareCombo.Text = rs!airfare
record_counts.Caption = "当前记录:" + Str(rs.AbsolutePosition) + "/" + Str(rs.RecordCount)
End Sub
Private Sub cmdFirst_Click()
rs.MoveFirst
Display
End Sub
Private Sub cmdLast_Click()
rs.MoveLast
Display
End Sub
Private Sub cmdNext_Click()
With rs
.MoveNext
If .EOF Then .MoveLast
End With
Display
End Sub
Private Sub cmdPreviouse_Click()
With rs
.MovePrevious
If .BOF Then .MoveFirst
End With
Display
End Sub
Private Sub Display_True()
Dim ctl As Control
For Each ctl In Controls
If TypeOf ctl Is TextBox Or TypeOf ctl Is ComboBox Or TypeOf ctl Is CommandButton Then
ctl.Enabled = False
End If
Next ctl
cmdExit.Enabled = True
cmdFirst.Enabled = True
cmdPreviouse.Enabled = True
cmdNext.Enabled = True
cmdLast.Enabled = True
cmdAdd.Enabled = True
cmdUpdata.Enabled = True
End Sub
Private Sub Display_False()
Dim ctl As Control
For Each ctl In Controls
If TypeOf ctl Is TextBox Or TypeOf ctl Is ComboBox Or TypeOf ctl Is CommandButton Then
ctl.Enabled = True
End If
Next ctl
cruise_cdtxt.Enabled = False
cmdFirst.Enabled = False
cmdPreviouse.Enabled = False
cmdNext.Enabled = False
cmdLast.Enabled = False
cmdAdd.Enabled = False
cmdUpdata.Enabled = False
End Sub
Private Sub durationtxt_KeyPress(KeyAscii As Integer)
If KeyAscii <= 32 Then Exit Sub
If Not IsNumeric(Chr(KeyAscii)) Then
KeyAscii = 0
MsgBox "行程天数必须是数字!", vbOKOnly, "输入提示"
End If
End Sub
Private Sub pricetxt_KeyPress(KeyAscii As Integer)
If KeyAscii <= 32 Then Exit Sub
If Not IsNumeric(Chr(KeyAscii)) Then
KeyAscii = 0
MsgBox "票价必须是数字!", vbOKOnly, "输入提示"
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -