VB航空公司管理信息系统 第12页
图9-25 显示机票信息的窗体
11.2 添加订票信息窗体的创建
在机票信息列表中单击“添加”按钮,将出现如图9-26所示的窗体,用来添加订票信息。
图9-26 添加订票信息的窗体
机票信息包括两部分:航线信息和客户信息。选择出发城市和到达城市,将得到相应的航线信息;选择客户姓名得到相应的客户信息。窗体载入时要求在列表框中加入所有有关航线和客户的信息,代码如下:
Private Sub Form_Load()
Dim intCount As Integer
Dim MsgText As String
Dim i As Integer
Dim mrcc As ADODB.Recordset
‘判断所处状态,添加或者修改
If gintKmode = 1 Then
Me.Caption = Me.Caption & "添加"
‘产生随机的订票编号
txtticket = GetRkno()
ElseIf gintKmode = 2 Then
Set mrc = ExecuteSQL(txtSQL, MsgText)
‘判断数据集对象是否为空
If mrc.EOF = False Then
With mrc
txtticket = .Fields(0)
txtItem(0) = .Fields(7)
txtItem(1) = .Fields(12)
End With
End If
Me.Caption = Me.Caption & "修改"
End If
‘清楚列表框中内容
For i = 0 To 6
Combo1(i).Clear
Next i
‘选择数据库中所有与出发城市有关的信息
txtSQL = "select distinct departCity from airlineInfo "
Set mrcc = ExecuteSQL(txtSQL, MsgText)
‘判断数据集对象是否为空
If Not mrcc.EOF Then
Do While Not mrcc.EOF
Combo1(0).AddItem mrcc.Fields(0)
mrcc.MoveNext
Loop
End If
‘关闭数据集对象
mrcc.Close
‘选择数据库中所有与到达城市有关的信息
txtSQL = "select distinct arrivalCity from airlineInfo"
Set mrcc = ExecuteSQL(txtSQL, MsgText)
‘判断数据集对象是否为空
If Not mrcc.EOF Then
Do While Not mrcc.EOF
Combo1(1).AddItem mrcc.Fields(0)
mrcc.MoveNext
Loop
End If
‘关闭数据集对象
mrcc.Close
‘选择数据库中所有与舱位等级有关的信息
txtSQL = "select distinct serviceName from serviceInfo"
Set mrcc = ExecuteSQL(txtSQL, MsgText)
‘判断数据集对象是否为空
If Not mrcc.EOF Then
Do While Not mrcc.EOF
Combo1(2).AddItem mrcc.Fields(0)
mrcc.MoveNext
Loop
End If
‘关闭数据集对象
mrcc.Close
‘选择数据库中所有与客户姓名有关的信息
txtSQL = "select distinct customerName from customerInfo"
Set mrcc = ExecuteSQL(txtSQL, MsgText)
‘判断数据集对象是否为空
If Not mrcc.EOF Then
Do While Not mrcc.EOF
Combo1(4).AddItem mrcc.Fields(0)
mrcc.MoveNext
Loop
End If
‘关闭数据集对象
mrcc.Close
mblChange = False
End Sub
选择出发城市和到达城市,然后选择舱位类型,将自动显示票价,并用不可见文本框(txtairline、txtairline等)记载航线编号、客户编号等信息。实现代码加在列表框的Click事件中,如下:
Private Sub Combo1_Click(Index As Integer)
Dim mrcc As ADODB.Recordset
Dim mrcd As ADODB.Recordset
Dim MsgText As String
‘判断列表框编号
If Index = 2 Then
‘判断出发城市和到达城市是否选择
If Not (Trim(Combo1(0)) = "" Or Trim(Combo1(1)) = "") Then
txtSQL = "select * from airlineInfo where departCity = '" & Trim(Combo1(0)) & "' and arrivalCity = '" & Trim(Combo1(1)) & "'"
Set mrcc = ExecuteSQL(txtSQL, MsgText)
‘判断数据集对象是否为空
If Not mrcc.EOF Then
txtairline = mrcc.Fields(0)
ticketCsum = mrcc!planeNO
If Trim(Combo1(2)) = "经济舱" Then
Combo1(3).Clear
Combo1(3).AddItem mrcc.Fields(7)
Combo1(3).ListIndex = 0
ElseIf Trim(Combo1(2)) = "公务舱" Then
Combo1(3).Clear
Combo1(3).AddItem mrcc.Fields(8)
Combo1(3).ListIndex = 0
Else
Combo1(3).Clear
Combo1(3).AddItem mrcc.Fields(9)
Combo1(3).ListIndex = 0
End If
End If
‘关闭数据集对象
mrcc.Close
<< 上一页 [11] [12] [13] [14] [15] [16] 下一页