End If
‘关闭数据集对象
mrcc.Close
End If
ElseIf Index = 4 Then
‘选择相应客户姓名的记录
txtSQL = "select customerNO,customerType from customerInfo where customerName = '" & Trim(Combo1(4)) & "'"
Set mrcc = ExecuteSQL(txtSQL, MsgText)
‘判断数据集对象是否为空
If Not mrcc.EOF Then
txtcustomer = mrcc.Fields(0)
Combo1(5).Clear
Combo1(5).AddItem mrcc.Fields(1)
Combo1(5).ListIndex = 0
‘选择客户对应的客户类型
txtSQL = "select distinct discount from customerType where ctypeName = '" & Trim(Combo1(5)) & "'"
Set mrcd = ExecuteSQL(txtSQL, MsgText)
‘判断数据集对象是否为空
If Not mrcd.EOF Then
Combo1(6).Clear
Combo1(6).AddItem mrcd.Fields(0)
Combo1(6).ListIndex = 0
End If
‘关闭数据集对象
mrcd.Close
End If
‘关闭数据集对象
mrcc.Close
End If
End Sub
选择航线信息和客户信息后,输入机票日期,单击“保存”按钮,订票信息保存到数据库中。除了对数据格式的检查,还要检查相应航班是否满员。代码如下:
Private Sub cmdSave_Click()
Dim intCount As Integer
Dim sMeg As String
Dim MsgText As String
‘判断列表框中内容是否为空
For intCount = 0 To 6
If Trim(Combo1(intCount) & " ") = "" Then
Select Case intCount
Case 0
sMeg = "出发城市"
Case 1
sMeg = "到达城市"
Case 2
sMeg = "舱位类型"
Case 3
sMeg = ""
Case 4
sMeg = "顾客姓名"
Case 5
sMeg = ""
Case 6
sMeg = ""
End Select
sMeg = sMeg & "不能为空!"
MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
Combo1(intCount).SetFocus
Exit Sub
End If
Next intCount
‘判断机票日期是否输入
If Trim(txtItem(0)) = "" Then
sMeg = "出发日期不能为空!"
MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
txtItem(0).SetFocus
Exit Sub
End If
‘判断输入机票日期是否为日期型数据
If IsDate(txtItem(0)) Then
txtItem(0) = Format(txtItem(0), "yyyy-mm-dd")
Else
MsgBox "时间应输入日期(yyyy-mm-dd)!", vbOKOnly + vbExclamation, "警告"
txtItem(0).SetFocus
Exit Sub
End If
'判断是否有相同内容的记录
txtSQL = "select * from ticketInfo where ticketNO<>'" & Trim(txtticket) & "' and customerNO ='" & Trim(txtcustomer) & "' and ticketDate = '" & Trim(txtItem(0)) & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.EOF = False Then
MsgBox "已经存在相同顾客订票的记录!", vbOKOnly + vbExclamation, "警告"
txtItem(1).SetFocus
Exit Sub
End If
'先删除已有记录
txtSQL = "delete from ticketInfo where ticketNO='" & Trim(txtticket) & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
'判断航班是否满员
txtSQL = "select * from ticketInfo where airlineNO = '" & Trim(txtairline) & " ' and ticketDate = '" & Trim(txtItem(0)) & "' and serviceType = '" & Trim(Combo1(2)) & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
‘判断数据集对象是否为空
If Not mrc.EOF Then
If Combo1(2) = "经济舱" Then
If mrc.RecordCount > (ticketCsum - 1) Then
MsgBox "对不起,该航班经济舱已经满员", vbOKOnly + vbExclamation, "警告"
Exit Sub
End If
ElseIf Combo1(2) = "公务舱" Then
If mrc.RecordCount > (ticketMsum - 1) Then
MsgBox "对不起,该航班公务舱已经满员", vbOKOnly + vbExclamation, "警告"
Exit Sub
End If
Else
If mrc.RecordCount > (ticketFsum - 1) Then
MsgBox "对不起,该航班头等舱已经满员", vbOKOnly + vbExclamation, "警告"
Exit Sub
End If
End If
End If
‘关闭数据集对象
mrc.Close
'再加入新记录
txtSQL = "select * from ticketInfo"
Set mrc = ExecuteSQL(txtSQL, MsgText)
mrc.AddNew
mrc.Fields(0) = txtticket
mrc.Fields(1) = txtcustomer
For intCount = 2 To 4
mrc.Fields(intCount) = Trim(Combo1(intCount + 2))
Next intCount
mrc.Fields(5) = txtairline
For intCount = 6 To 7
mrc.Fields(intCount) = Trim(Combo1(intCount - 6))
Next intCount
mrc.Fields(8) = Trim(txtItem(0))
For intCount = 9 To 10
mrc.Fields(intCount) = Trim(Combo1(intCount - 7))
Next intCount
mrc.Fields(11) = Trim(Combo1(3) * Combo1(6) / 100)
mrc.Fields(12) = txtItem(1)
‘更新数据集
mrc.Update
‘关闭数据集对象
<< 上一页 [11] [12] [13] [14] [15] [16] 下一页