📄 航线信息查询.vb
字号:
Public Class 航线信息查询
Inherits System.Windows.Forms.Form
#Region " Windows 窗体设计器生成的代码 "
Public Sub New()
MyBase.New()
'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()
'在 InitializeComponent() 调用之后添加任何初始化
End Sub
'窗体重写 dispose 以清理组件列表。
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Windows 窗体设计器所必需的
Private components As System.ComponentModel.IContainer
'注意: 以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改此过程。
'不要使用代码编辑器修改它。
Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents ComboBox2 As System.Windows.Forms.ComboBox
Friend WithEvents RadioButton1 As System.Windows.Forms.RadioButton
Friend WithEvents RadioButton2 As System.Windows.Forms.RadioButton
Friend WithEvents Button3 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.ComboBox1 = New System.Windows.Forms.ComboBox
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.ComboBox2 = New System.Windows.Forms.ComboBox
Me.RadioButton1 = New System.Windows.Forms.RadioButton
Me.RadioButton2 = New System.Windows.Forms.RadioButton
Me.Button3 = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'ComboBox1
'
Me.ComboBox1.Location = New System.Drawing.Point(216, 40)
Me.ComboBox1.Name = "ComboBox1"
Me.ComboBox1.Size = New System.Drawing.Size(128, 20)
Me.ComboBox1.TabIndex = 2
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(24, 168)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(120, 48)
Me.Button1.TabIndex = 4
Me.Button1.Text = "确定(&o)"
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(168, 168)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(128, 48)
Me.Button2.TabIndex = 5
Me.Button2.Text = "取消(&x)"
'
'ComboBox2
'
Me.ComboBox2.Location = New System.Drawing.Point(216, 88)
Me.ComboBox2.Name = "ComboBox2"
Me.ComboBox2.Size = New System.Drawing.Size(128, 20)
Me.ComboBox2.TabIndex = 6
'
'RadioButton1
'
Me.RadioButton1.Checked = True
Me.RadioButton1.Location = New System.Drawing.Point(80, 40)
Me.RadioButton1.Name = "RadioButton1"
Me.RadioButton1.TabIndex = 7
Me.RadioButton1.TabStop = True
Me.RadioButton1.Text = "出发城市"
'
'RadioButton2
'
Me.RadioButton2.Location = New System.Drawing.Point(80, 88)
Me.RadioButton2.Name = "RadioButton2"
Me.RadioButton2.TabIndex = 8
Me.RadioButton2.Text = "到达城市"
'
'Button3
'
Me.Button3.Location = New System.Drawing.Point(328, 168)
Me.Button3.Name = "Button3"
Me.Button3.Size = New System.Drawing.Size(128, 48)
Me.Button3.TabIndex = 9
Me.Button3.Text = "重新查询"
'
'航线信息查询
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(488, 254)
Me.Controls.Add(Me.Button3)
Me.Controls.Add(Me.RadioButton2)
Me.Controls.Add(Me.RadioButton1)
Me.Controls.Add(Me.ComboBox2)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.ComboBox1)
Me.Name = "航线信息查询"
Me.Text = "航线信息查询"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub 航线信息查询_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
my_class.init()
Dim ds As DataSet
Dim con As String
Dim count, i As Integer
con = "select * from airlineinfo"
ds = my_class.query(con)
count = ds.Tables(0).Rows.Count
For i = 0 To count - 1
my_class.dr = ds.Tables(0).Rows(i)
ComboBox1.Items.Add(Trim(CStr(my_class.dr(1))))
ComboBox2.Items.Add(Trim(CStr(my_class.dr(2))))
Next
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ds As DataSet
Dim con As String
Dim str As String
Dim count, i As Integer
If RadioButton1.Checked = True Then
str = ComboBox1.Text
con = "select * from airlineinfo where departcity='" + str + "'"
ds = my_class.query(con)
count = ds.Tables(0).Rows.Count
'''''''''''''''''''''''''''''''''''''''''''''''''
If (count > 0) Then
Try
my_class.dr = ds.Tables(0).Rows(0)
Catch ex As Exception
MsgBox("选择错误!")
Exit Try
End Try
ComboBox2.Text = ""
ComboBox2.Items.Clear()
ComboBox2.Text = Trim(CStr(my_class.dr("arrivalcity")))
For i = 1 To count - 1
my_class.dr = ds.Tables(0).Rows(i)
ComboBox2.Items.Add(Trim(CStr(my_class.dr("arrivalcity"))))
Next
Else
MsgBox("出发地中所选城市有误,请重新选择!")
ComboBox1.Items.Clear()
ComboBox2.Items.Clear()
End If
''''''''''''''''''''''''''''''''''''''''''''''''''
ElseIf RadioButton2.Checked = True Then
str = ComboBox2.Text
con = "select * from airlineinfo where arrivalcity='" + str + "'"
ds = my_class.query(con)
count = ds.Tables(0).Rows.Count
If (count > 0) Then
Try
my_class.dr = ds.Tables(0).Rows(0)
Catch ex As Exception
MsgBox("选择错误!")
Exit Try
End Try
ComboBox1.Text = ""
ComboBox1.Items.Clear()
ComboBox1.Text = Trim(CStr(my_class.dr("departcity")))
For i = 0 To count - 1
my_class.dr = ds.Tables(0).Rows(i)
ComboBox1.Items.Add(Trim(CStr(my_class.dr("departcity"))))
Next
Else
MsgBox("目的地中所选城市有误,请重新选择!")
ComboBox1.Items.Clear()
ComboBox2.Items.Clear()
End If
ElseIf (RadioButton1.Checked = True And ComboBox1.Text = "") Or (RadioButton2.Checked = True And ComboBox2.Text = "") Then
MsgBox("单选框选择有错误,请重新选择!")
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
ComboBox1.Text = ""
ComboBox2.Text = ""
ComboBox1.Items.Clear()
ComboBox2.Items.Clear()
Dim ds As DataSet
Dim con As String
Dim count, i As Integer
con = "select * from airlineinfo"
ds = my_class.query(con)
count = ds.Tables(0).Rows.Count
For i = 0 To count - 1
my_class.dr = ds.Tables(0).Rows(i)
ComboBox1.Items.Add(CStr(my_class.dr(1)))
ComboBox2.Items.Add(CStr(my_class.dr(2)))
Next
End Sub
Private Sub 航线信息查询_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Activated
Dim mdifrm As New MDIForm1
mdifrm = Me.MdiParent
mdifrm.StatusBar1.Panels(0).Text = Me.Text
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -