VB航空公司管理信息系统 第14页
mrc.Close
If gintKmode = 1 Then
MsgBox "订票成功!航班为" & Trim(txtItem(0)) & "从" & Trim(Combo1(0)) & "到" & Trim(Combo1(1)) & "的" & Trim(Combo1(2)) & "机票,票价为" & Trim(Combo1(3) * Combo1(6) / 100) & "元!", vbOKOnly + vbExclamation, "订票记录"
For intCount = 0 To 1
txtItem(intCount) = ""
Next intCount
mblChange = False
‘重新显示机票信息
Unload frmTicket
frmTicket.txtSQL = "select * from ticketInfo"
frmTicket.Show
ElseIf gintKmode = 2 Then
MsgBox "修改订票信息成功!修改后的航班为" & Trim(txtItem(0)) & "从" & Trim(Combo1(0)) & "到" & Trim(Combo1(1)) & "的" & Trim(Combo1(2)) & "机票,票价为" & Trim(Combo1(3) * Combo1(6) / 100) & "元!", vbOKOnly + vbExclamation, "订票记录"
Unload Me
‘重新显示机票信息
Unload frmTicket
frmTicket.txtSQL = "select * from ticketInfo"
frmTicket.Show
End If
End Sub
11.3 修改订票信息
在机票信息列表中选择需要修改的记录,然后单击“修改”按钮,当前记录将出现在如图9-19所示的窗体中。修改完毕,单击“保存”按钮,修改后的记录保存到数据库中。
11.4 删除订票信息
选择机票信息列表中需要删除的记录,然后单击“删除”按钮,可以删除所选记录。
11.5 查询订票信息
在如图9-25所示的机票信息列表中,单击“查询”按钮,出现如图9-27所示的对话框。
图9-27 机票信息查询窗体
窗体载入时自动在列表框中添加出发城市、到达城市和舱位类型的信息,代码如下:
Private Sub Form_Load()
Dim i As Integer
Dim sSql As String
Dim txtSQL As String
Dim MsgText As String
Dim mrc As ADODB.Recordset
‘清除列表框中内容
For i = 0 To 2
Combo1(i).Clear
Next i
‘选择所有与出发城市有关的信息
txtSQL = "select distinct departCity from airlineInfo "
Set mrc = ExecuteSQL(txtSQL, MsgText)
‘判断数据集对象是否为空
If Not mrc.EOF Then
Do While Not mrc.EOF
Combo1(0).AddItem mrc.Fields(0)
mrc.MoveNext
Loop
End If
‘关闭数据集对象
mrc.Close
‘选择所有与到达城市有关的信息
txtSQL = "select distinct arrivalCity from airlineInfo"
Set mrc = ExecuteSQL(txtSQL, MsgText)
‘判断数据集对象是否为空
If Not mrc.EOF Then
Do While Not mrc.EOF
Combo1(1).AddItem mrc.Fields(0)
mrc.MoveNext
Loop
End If
mrc.Close
‘选择所有与舱位类型有关的信息
txtSQL = "select distinct serviceName from serviceInfo"
Set mrc = ExecuteSQL(txtSQL, MsgText)
‘判断数据集对象是否为空
If Not mrc.EOF Then
Do While Not mrc.EOF
Combo1(2).AddItem mrc.Fields(0)
mrc.MoveNext
Loop
End If
mrc.Close
End Sub
输入查询内容完毕,单击“确定”按钮将自动组合产生查询语句。满足查询条件的记录显示在如图9-25所示的机票信息列表中,代码如下:
Private Sub cmdOK_Click()
Dim txtSQL As String
Dim MsgText As String
Dim mrc As ADODB.Recordset
Dim intCount As Integer
Dim sMeg As String
Dim i, j, k
‘判断是否选择相应信息
For intCount = 0 To 1
If Trim(Combo1(intCount) & " ") = "" Then
Select Case intCount
Case 0
sMeg = "出发城市"
Case 1
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
‘判断是否输入舱位类型
If Not (Trim(Combo1(2)) = "") Then
txtSQL = "select * from ticketInfo where ticketDate = '" & Trim(txtItem(0)) & "' and departCity = '" & Trim(Combo1(0)) & "' and arrivalCity = '" & Trim(Combo1(1)) & "' and serviceType = '" & Trim(Combo1(2)) & "'"
‘执行查询语句
Set mrc = ExecuteSQL(txtSQL, MsgText)
‘计算经济舱剩余机票数量
If Trim(Combo1(2)) = "经济舱" Then
intCount = ticketCsum - mrc.RecordCount
‘计算公务舱剩余机票数量
ElseIf Trim(Combo1(2)) = "公务舱" Then
intCount = ticketMsum - mrc.RecordCount
Else
intCount = ticketFsum - mrc.RecordCount
End If
‘判断机票剩余数量
If intCount > 0 Then
MsgBox Trim(txtItem(0)) & "从" & Trim(Combo1(0)) & "到" & Trim(Combo1(1)) &
<< 上一页 [11] [12] [13] [14] [15] [16] 下一页
VB航空公司管理信息系统 第14页下载如图片无法显示或论文不完整,请联系qq752018766