frmTicket1.frm
上传用户:darkchong
上传日期:2007-06-21
资源大小:44k
文件大小:18k
- VERSION 5.00
- Begin VB.Form frmTicket1
- BorderStyle = 3 'Fixed Dialog
- Caption = "机票信息"
- ClientHeight = 5172
- ClientLeft = 48
- ClientTop = 336
- ClientWidth = 6384
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 5172
- ScaleWidth = 6384
- ShowInTaskbar = 0 'False
- StartUpPosition = 1 'CenterOwner
- Begin VB.TextBox ticketFsum
- Height = 270
- Left = 840
- TabIndex = 27
- TabStop = 0 'False
- Top = 4800
- Visible = 0 'False
- Width = 735
- End
- Begin VB.TextBox ticketMsum
- Height = 270
- Left = 840
- TabIndex = 26
- TabStop = 0 'False
- Top = 4440
- Visible = 0 'False
- Width = 735
- End
- Begin VB.TextBox ticketCsum
- Height = 270
- Left = 0
- TabIndex = 25
- TabStop = 0 'False
- Top = 4800
- Visible = 0 'False
- Width = 735
- End
- Begin VB.Frame Frame1
- Caption = "备注信息:"
- Height = 1212
- Index = 2
- Left = 120
- TabIndex = 19
- Top = 3120
- Width = 6132
- Begin VB.TextBox txtItem
- Height = 840
- Index = 1
- Left = 240
- MaxLength = 80
- MultiLine = -1 'True
- ScrollBars = 2 'Vertical
- TabIndex = 24
- Top = 240
- Width = 5532
- End
- End
- Begin VB.TextBox txtairline
- Height = 270
- Left = 5520
- TabIndex = 18
- TabStop = 0 'False
- Top = 4680
- Visible = 0 'False
- Width = 735
- End
- Begin VB.TextBox txtcustomer
- Height = 270
- Left = 4560
- TabIndex = 17
- TabStop = 0 'False
- Top = 4680
- Visible = 0 'False
- Width = 735
- End
- Begin VB.TextBox txtticket
- Height = 270
- Left = 0
- TabIndex = 16
- TabStop = 0 'False
- Top = 4440
- Visible = 0 'False
- Width = 735
- End
- Begin VB.Frame Frame1
- Caption = "客户信息:"
- Height = 1212
- Index = 1
- Left = 120
- TabIndex = 12
- Top = 1800
- Width = 6132
- Begin VB.ComboBox Combo1
- Height = 288
- Index = 6
- Left = 1560
- Style = 2 'Dropdown List
- TabIndex = 23
- Top = 720
- Width = 1212
- End
- Begin VB.ComboBox Combo1
- Height = 288
- Index = 5
- Left = 4560
- Style = 2 'Dropdown List
- TabIndex = 22
- Top = 360
- Width = 1212
- End
- Begin VB.ComboBox Combo1
- Height = 288
- Index = 4
- Left = 1560
- Style = 2 'Dropdown List
- TabIndex = 21
- Top = 360
- Width = 1212
- End
- Begin VB.Label Label2
- Caption = "客 户 类 型:"
- Height = 252
- Index = 15
- Left = 3360
- TabIndex = 15
- Top = 360
- Width = 1212
- End
- Begin VB.Label Label2
- Caption = "客 户 姓 名:"
- Height = 252
- Index = 14
- Left = 360
- TabIndex = 14
- Top = 360
- Width = 1212
- End
- Begin VB.Label Label2
- Caption = "折 扣 比 例:"
- Height = 252
- Index = 13
- Left = 360
- TabIndex = 13
- Top = 720
- Width = 1212
- End
- End
- Begin VB.Frame Frame1
- Caption = "航线信息:"
- Height = 1572
- Index = 0
- Left = 120
- TabIndex = 6
- Top = 120
- Width = 6132
- Begin VB.ComboBox Combo1
- Height = 288
- Index = 3
- Left = 1560
- Style = 2 'Dropdown List
- TabIndex = 20
- Top = 1080
- Width = 1212
- End
- Begin VB.ComboBox Combo1
- Height = 288
- Index = 2
- Left = 4560
- Style = 2 'Dropdown List
- TabIndex = 3
- Top = 720
- Width = 1212
- End
- Begin VB.ComboBox Combo1
- Height = 288
- Index = 1
- Left = 4560
- Style = 2 'Dropdown List
- TabIndex = 1
- Top = 360
- Width = 1212
- End
- Begin VB.ComboBox Combo1
- Height = 288
- Index = 0
- Left = 1560
- Style = 2 'Dropdown List
- TabIndex = 0
- Top = 360
- Width = 1212
- End
- Begin VB.TextBox txtItem
- Height = 270
- Index = 0
- Left = 1560
- MaxLength = 20
- TabIndex = 2
- Top = 720
- Width = 1212
- End
- Begin VB.Label Label2
- Caption = "票 价:"
- Height = 252
- Index = 7
- Left = 360
- TabIndex = 11
- Top = 1080
- Width = 1212
- End
- Begin VB.Label Label2
- Caption = "舱 位 类 型:"
- Height = 252
- Index = 6
- Left = 3360
- TabIndex = 10
- Top = 720
- Width = 1212
- End
- Begin VB.Label Label2
- Caption = "出 发 时 间:"
- Height = 252
- Index = 5
- Left = 360
- TabIndex = 9
- Top = 720
- Width = 1212
- End
- Begin VB.Label Label2
- Caption = "出 发 城 市:"
- Height = 252
- Index = 0
- Left = 360
- TabIndex = 8
- Top = 360
- Width = 1212
- End
- Begin VB.Label Label2
- Caption = "到 达 城 市:"
- Height = 252
- Index = 1
- Left = 3360
- TabIndex = 7
- Top = 360
- Width = 1212
- End
- End
- Begin VB.CommandButton cmdExit
- Caption = "返回 (&X)"
- Height = 375
- Left = 3120
- TabIndex = 5
- Top = 4560
- Width = 1215
- End
- Begin VB.CommandButton cmdSave
- Caption = "保存 (&S)"
- Height = 375
- Left = 1680
- TabIndex = 4
- Top = 4560
- Width = 1215
- End
- End
- Attribute VB_Name = "frmTicket1"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Option Explicit
- '是否改动过记录,ture为改过
- Dim mblChange As Boolean
- Dim mrc As ADODB.Recordset
- Public txtSQL As String
- Private Sub cmdExit_Click()
- If mblChange And cmdSave.Enabled Then
- If MsgBox("保存当前记录的变化吗?", vbOKCancel + vbExclamation, "警告") = vbOK Then
- '保存
- Call cmdSave_Click
- End If
- End If
- Unload Me
- 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
- 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
- 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
-
- txtSQL = "select * from planeInfo where planeNO = '" & Trim(ticketCsum) & "'"
- Set mrcc = ExecuteSQL(txtSQL, MsgText)
-
- If Not mrcc.EOF Then
- ticketCsum = mrcc.Fields(4)
- ticketMsum = mrcc.Fields(5)
- ticketFsum = mrcc.Fields(6)
- 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 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
- Private Sub Form_Unload(Cancel As Integer)
- gintKmode = 0
- End Sub
- Private Sub txtItem_Change(Index As Integer)
- '有变化设置gblchange
- mblChange = True
- End Sub
- Private Sub txtItem_GotFocus(Index As Integer)
- txtItem(Index).SelStart = 0
- txtItem(Index).SelLength = Len(txtItem(Index))
- End Sub
- Private Sub txtItem_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
- EnterToTab KeyCode
- End Sub