frmAirline1.frm
上传用户:darkchong
上传日期:2007-06-21
资源大小:44k
文件大小:14k
- VERSION 5.00
- Begin VB.Form frmAirline1
- BorderStyle = 3 'Fixed Dialog
- Caption = "航线信息"
- ClientHeight = 4200
- ClientLeft = 48
- ClientTop = 336
- ClientWidth = 6396
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 4200
- ScaleWidth = 6396
- ShowInTaskbar = 0 'False
- StartUpPosition = 1 'CenterOwner
- Begin VB.ComboBox Combo1
- Height = 288
- Index = 1
- Left = 4680
- Style = 2 'Dropdown List
- TabIndex = 5
- Top = 1200
- Width = 1212
- End
- Begin VB.TextBox txtNo
- Height = 270
- Left = 1080
- TabIndex = 21
- TabStop = 0 'False
- Top = 3720
- Visible = 0 'False
- Width = 735
- End
- Begin VB.Frame Frame1
- Caption = "航线信息:"
- Height = 3372
- Left = 120
- TabIndex = 12
- Top = 120
- Width = 6132
- Begin VB.TextBox txtItem
- Height = 1080
- Index = 7
- Left = 1560
- MaxLength = 80
- MultiLine = -1 'True
- ScrollBars = 2 'Vertical
- TabIndex = 9
- Top = 2160
- Width = 4212
- End
- Begin VB.TextBox txtItem
- Height = 270
- Index = 6
- Left = 1560
- MaxLength = 20
- TabIndex = 8
- Top = 1800
- Width = 1212
- End
- Begin VB.TextBox txtItem
- Height = 270
- Index = 5
- Left = 4560
- MaxLength = 20
- TabIndex = 7
- Top = 1440
- Width = 1212
- End
- Begin VB.TextBox txtItem
- Height = 270
- Index = 4
- Left = 1560
- MaxLength = 20
- TabIndex = 6
- Top = 1440
- Width = 1212
- End
- Begin VB.TextBox txtItem
- Height = 270
- Index = 3
- Left = 1560
- MaxLength = 20
- TabIndex = 4
- Top = 1080
- Width = 1212
- End
- Begin VB.TextBox txtItem
- Height = 270
- Index = 2
- Left = 4560
- MaxLength = 20
- TabIndex = 3
- Top = 720
- Width = 1212
- End
- Begin VB.ComboBox Combo1
- Height = 288
- Index = 0
- Left = 1560
- Style = 2 'Dropdown List
- TabIndex = 2
- Top = 720
- Width = 1212
- End
- Begin VB.TextBox txtItem
- Height = 270
- Index = 0
- Left = 1560
- MaxLength = 8
- TabIndex = 0
- Top = 360
- Width = 1212
- End
- Begin VB.TextBox txtItem
- Height = 270
- Index = 1
- Left = 4560
- MaxLength = 20
- TabIndex = 1
- Top = 360
- Width = 1212
- End
- Begin VB.Label Label2
- Caption = "头等舱价格:"
- Height = 252
- Index = 4
- Left = 360
- TabIndex = 23
- Top = 1800
- Width = 1212
- End
- Begin VB.Label Label2
- Caption = "公务舱价格:"
- Height = 252
- Index = 3
- Left = 3360
- TabIndex = 22
- Top = 1440
- Width = 1212
- End
- Begin VB.Label Label2
- Caption = "备 注 信 息:"
- Height = 252
- Index = 10
- Left = 360
- TabIndex = 20
- Top = 2160
- Width = 1212
- End
- Begin VB.Label Label2
- Caption = "经济舱价格:"
- Height = 252
- Index = 2
- Left = 360
- TabIndex = 19
- Top = 1440
- Width = 1212
- End
- Begin VB.Label Label2
- Caption = "客 机 编 号:"
- Height = 252
- Index = 8
- Left = 3360
- TabIndex = 18
- Top = 1080
- Width = 1212
- End
- Begin VB.Label Label2
- Caption = " 到 达 时 间:"
- Height = 252
- Index = 7
- Left = 360
- TabIndex = 17
- Top = 1080
- Width = 1212
- End
- Begin VB.Label Label2
- Caption = "出 发 时 间:"
- Height = 252
- Index = 6
- Left = 3360
- TabIndex = 16
- Top = 720
- Width = 1212
- End
- Begin VB.Label Label2
- Caption = " 航 班 日 期:"
- Height = 252
- Index = 5
- Left = 360
- TabIndex = 15
- Top = 720
- Width = 1212
- End
- Begin VB.Label Label2
- Caption = " 出 发 城 市:"
- Height = 252
- Index = 0
- Left = 360
- TabIndex = 14
- Top = 360
- Width = 1212
- End
- Begin VB.Label Label2
- Caption = "到 达 城 市:"
- Height = 252
- Index = 1
- Left = 3360
- TabIndex = 13
- Top = 360
- Width = 1212
- End
- End
- Begin VB.CommandButton cmdExit
- Caption = "返回 (&X)"
- Height = 375
- Left = 3600
- TabIndex = 11
- Top = 3720
- Width = 1215
- End
- Begin VB.CommandButton cmdSave
- Caption = "保存 (&S)"
- Height = 375
- Left = 2160
- TabIndex = 10
- Top = 3720
- Width = 1215
- End
- End
- Attribute VB_Name = "frmAirline1"
- 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(txtItem(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, "警告"
- txtItem(intCount).SetFocus
- Exit Sub
- End If
- Next intCount
-
- 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
-
-
-
- For intCount = 4 To 6
- If Not IsNumeric(Trim(txtItem(intCount))) Then
- sMeg = "客票价格"
- sMeg = sMeg & "请输入数字!"
- MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
- txtItem(intCount).SetFocus
- End If
- Next intCount
-
-
- For intCount = 2 To 3
- If IsDate(txtItem(intCount)) Then
- txtItem(intCount) = Format(txtItem(intCount), "hh:mm")
- Else
- MsgBox "时间应输入(hh:mm)!", vbOKOnly + vbExclamation, "警告"
- txtItem(intCount).SetFocus
- Exit Sub
- End If
- Next intCount
-
-
-
- '判断是否有相同内容的记录
- txtSQL = "select * from airlineInfo where airlineNO <> '" & Trim(txtNo) & "' and departCity = '" & Trim(txtItem(0)) & "' and arrivalCity = '" & Trim(txtItem(1)) & "' and departDate = '" & Trim(Combo1(0)) & " ' and departTime = '" & Trim(txtItem(2)) & "' and planeNO = '" & Trim(Combo1(1)) & "'"
- Set mrc = ExecuteSQL(txtSQL, MsgText)
- If mrc.EOF = False Then
- MsgBox "已经存在相同航线的记录!", vbOKOnly + vbExclamation, "警告"
- txtItem(0).SetFocus
- Exit Sub
- End If
-
- '先删除已有记录
- txtSQL = "delete from airlineInfo where airlineNO='" & Trim(txtNo) & "'"
- Set mrc = ExecuteSQL(txtSQL, MsgText)
-
-
- '再加入新记录
- txtSQL = "select * from airlineInfo"
- Set mrc = ExecuteSQL(txtSQL, MsgText)
- mrc.AddNew
-
- mrc.Fields(0) = txtNo
-
- For intCount = 0 To 1
- mrc.Fields(intCount + 1) = Trim(txtItem(intCount))
- Next intCount
-
- mrc.Fields(3) = Trim(Combo1(0))
-
- For intCount = 2 To 3
- mrc.Fields(intCount + 2) = Trim(txtItem(intCount))
- Next intCount
-
- mrc.Fields(6) = Trim(Combo1(1))
-
- For intCount = 4 To 7
- mrc.Fields(intCount + 3) = Trim(txtItem(intCount))
- Next intCount
-
- mrc.Update
- mrc.Close
-
- If gintAmode = 1 Then
- MsgBox "添加记录成功!", vbOKOnly + vbExclamation, "添加记录"
- For intCount = 0 To 7
- txtItem(intCount) = ""
- Next intCount
-
- mblChange = False
- Unload frmAirline
- frmAirline.txtSQL = "select * from airlineInfo"
- frmAirline.Show
-
- ElseIf gintAmode = 2 Then
- Unload Me
- Unload frmAirline
-
- frmAirline.txtSQL = "select * from airlineInfo"
- frmAirline.Show
- 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 gintAmode = 1 Then
- Me.Caption = Me.Caption & "添加"
- txtNo = GetRkno()
-
- ElseIf gintAmode = 2 Then
- Set mrc = ExecuteSQL(txtSQL, MsgText)
-
- If mrc.EOF = False Then
- With mrc
-
- txtNo = .Fields(0)
-
- For intCount = 0 To 1
- txtItem(intCount) = .Fields(intCount + 1)
- Next intCount
-
- For intCount = 2 To 3
- txtItem(intCount) = .Fields(intCount + 2)
- Next intCount
-
- For intCount = 4 To 7
- txtItem(intCount) = .Fields(intCount + 3)
- Next intCount
- End With
-
- End If
-
- Me.Caption = Me.Caption & "修改"
- End If
-
- Combo1(0).Clear
-
- With Combo1(0)
- .AddItem "星期一"
- .AddItem "星期二"
- .AddItem "星期三"
- .AddItem "星期四"
- .AddItem "星期五"
- .AddItem "星期六"
- .AddItem "星期日"
- End With
-
- Combo1(1).Clear
-
- txtSQL = "select DISTINCT planeNO from planeInfo"
- Set mrcc = ExecuteSQL(txtSQL, MsgText)
-
- If mrcc.EOF = False Then
- Do While Not mrcc.EOF
- Combo1(1).AddItem mrcc.Fields(0)
- mrcc.MoveNext
- Loop
- Else
- MsgBox "请首先设置客机信息!", vbOKOnly + vbExclamation, "警告"
- Exit Sub
- End If
-
- mrcc.Close
-
- mblChange = False
- End Sub
- Private Sub Form_Unload(Cancel As Integer)
- gintAmode = 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