📄 客户信息查询.vb
字号:
Imports System.Data
Imports System.Data.SqlClient
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 ComboBox2 As System.Windows.Forms.ComboBox
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
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.ComboBox2 = New System.Windows.Forms.ComboBox
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
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(264, 40)
Me.ComboBox1.Name = "ComboBox1"
Me.ComboBox1.Size = New System.Drawing.Size(121, 20)
Me.ComboBox1.TabIndex = 2
'
'ComboBox2
'
Me.ComboBox2.Location = New System.Drawing.Point(264, 112)
Me.ComboBox2.Name = "ComboBox2"
Me.ComboBox2.Size = New System.Drawing.Size(121, 20)
Me.ComboBox2.TabIndex = 3
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(32, 184)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(120, 40)
Me.Button1.TabIndex = 4
Me.Button1.Text = "确定(&o)"
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(176, 184)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(120, 40)
Me.Button2.TabIndex = 5
Me.Button2.Text = "取消(&x)"
'
'RadioButton1
'
Me.RadioButton1.Checked = True
Me.RadioButton1.Location = New System.Drawing.Point(112, 40)
Me.RadioButton1.Name = "RadioButton1"
Me.RadioButton1.TabIndex = 6
Me.RadioButton1.TabStop = True
Me.RadioButton1.Text = "客户姓名"
'
'RadioButton2
'
Me.RadioButton2.Location = New System.Drawing.Point(112, 115)
Me.RadioButton2.Name = "RadioButton2"
Me.RadioButton2.TabIndex = 7
Me.RadioButton2.Text = "客户类型"
'
'Button3
'
Me.Button3.Location = New System.Drawing.Point(328, 184)
Me.Button3.Name = "Button3"
Me.Button3.Size = New System.Drawing.Size(120, 40)
Me.Button3.TabIndex = 8
Me.Button3.Text = "重新查询 "
'
'客户信息查询
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(480, 254)
Me.Controls.Add(Me.Button3)
Me.Controls.Add(Me.RadioButton2)
Me.Controls.Add(Me.RadioButton1)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.ComboBox2)
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
ct = 51
my_class.init()
Dim ds As DataSet
Dim con As String
Dim count, i As Integer
con = "select * from customerinfo"
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("customername"))))
ComboBox2.Items.Add(Trim(CStr(my_class.dr("customertype"))))
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 And ComboBox1.Text <> "") Then
ComboBox2.Text = ""
ComboBox2.Enabled = False
str = ComboBox1.Text
con = "select * from customerinfo where customername='" + 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.Enabled = True
ComboBox2.Text = CStr(my_class.dr("customertype"))
ComboBox2.Items.Clear()
For i = 0 To count - 1
my_class.dr = ds.Tables(0).Rows(i)
ComboBox2.Items.Add(Trim(CStr(my_class.dr("customertype"))))
Next
Else
MsgBox("不存在该客户姓名,请重新选择!")
ComboBox1.SelectAll()
End If
ElseIf (RadioButton2.Checked = True And ComboBox2.Text <> "") Then
str = ComboBox2.Text
con = "select * from customerinfo where customertype='" + 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("customername")))
For i = 1 To count - 1
my_class.dr = ds.Tables(0).Rows(i)
ComboBox1.Items.Add(Trim(CStr(my_class.dr("customername"))))
Next
Else
MsgBox("不存在该客户类型,请重新选择!")
ComboBox2.SelectAll()
End If
Else
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 customerinfo"
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("customername"))))
ComboBox2.Items.Add(Trim(CStr(my_class.dr("customertype"))))
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 + -