📄 formfindemployee.vb
字号:
Imports CommonDB
Public Class FormFindEmployee
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 部门 As System.Windows.Forms.Label
Friend WithEvents 员工姓名 As System.Windows.Forms.Label
Friend WithEvents 员工编号 As System.Windows.Forms.Label
Friend WithEvents cmbDempartment As System.Windows.Forms.ComboBox
Friend WithEvents txtNumber As System.Windows.Forms.TextBox
Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
Friend WithEvents cmbName As System.Windows.Forms.ComboBox
Friend WithEvents Panel1 As System.Windows.Forms.Panel
Friend WithEvents btnQuery As System.Windows.Forms.Button
Friend WithEvents btnReset As System.Windows.Forms.Button
Friend WithEvents btnView As System.Windows.Forms.Button
Friend WithEvents btnDescription As System.Windows.Forms.Button
Friend WithEvents btnExit As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.GroupBox1 = New System.Windows.Forms.GroupBox
Me.txtNumber = New System.Windows.Forms.TextBox
Me.cmbDempartment = New System.Windows.Forms.ComboBox
Me.员工编号 = New System.Windows.Forms.Label
Me.员工姓名 = New System.Windows.Forms.Label
Me.部门 = New System.Windows.Forms.Label
Me.cmbName = New System.Windows.Forms.ComboBox
Me.Panel1 = New System.Windows.Forms.Panel
Me.btnView = New System.Windows.Forms.Button
Me.btnReset = New System.Windows.Forms.Button
Me.btnQuery = New System.Windows.Forms.Button
Me.btnDescription = New System.Windows.Forms.Button
Me.btnExit = New System.Windows.Forms.Button
Me.GroupBox1.SuspendLayout()
Me.Panel1.SuspendLayout()
Me.SuspendLayout()
'
'GroupBox1
'
Me.GroupBox1.Controls.Add(Me.txtNumber)
Me.GroupBox1.Controls.Add(Me.cmbDempartment)
Me.GroupBox1.Controls.Add(Me.员工编号)
Me.GroupBox1.Controls.Add(Me.员工姓名)
Me.GroupBox1.Controls.Add(Me.部门)
Me.GroupBox1.Controls.Add(Me.cmbName)
Me.GroupBox1.Location = New System.Drawing.Point(8, 8)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(272, 120)
Me.GroupBox1.TabIndex = 0
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "输入查询条件"
'
'txtNumber
'
Me.txtNumber.HideSelection = False
Me.txtNumber.Location = New System.Drawing.Point(112, 88)
Me.txtNumber.Name = "txtNumber"
Me.txtNumber.TabIndex = 5
Me.txtNumber.Text = ""
'
'cmbDempartment
'
Me.cmbDempartment.DisplayMember = "name"
Me.cmbDempartment.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
Me.cmbDempartment.Location = New System.Drawing.Point(112, 24)
Me.cmbDempartment.Name = "cmbDempartment"
Me.cmbDempartment.Size = New System.Drawing.Size(100, 20)
Me.cmbDempartment.TabIndex = 3
Me.cmbDempartment.ValueMember = "number"
'
'员工编号
'
Me.员工编号.Location = New System.Drawing.Point(8, 88)
Me.员工编号.Name = "员工编号"
Me.员工编号.TabIndex = 2
Me.员工编号.Text = "编号"
'
'员工姓名
'
Me.员工姓名.Location = New System.Drawing.Point(8, 56)
Me.员工姓名.Name = "员工姓名"
Me.员工姓名.TabIndex = 1
Me.员工姓名.Text = "姓名"
'
'部门
'
Me.部门.Location = New System.Drawing.Point(8, 24)
Me.部门.Name = "部门"
Me.部门.TabIndex = 0
Me.部门.Text = "部门"
'
'cmbName
'
Me.cmbName.DisplayMember = "name"
Me.cmbName.Location = New System.Drawing.Point(112, 56)
Me.cmbName.Name = "cmbName"
Me.cmbName.Size = New System.Drawing.Size(100, 20)
Me.cmbName.TabIndex = 3
Me.cmbName.ValueMember = "number"
'
'Panel1
'
Me.Panel1.Controls.Add(Me.btnExit)
Me.Panel1.Controls.Add(Me.btnDescription)
Me.Panel1.Controls.Add(Me.btnView)
Me.Panel1.Controls.Add(Me.btnReset)
Me.Panel1.Controls.Add(Me.btnQuery)
Me.Panel1.Location = New System.Drawing.Point(8, 136)
Me.Panel1.Name = "Panel1"
Me.Panel1.Size = New System.Drawing.Size(272, 80)
Me.Panel1.TabIndex = 1
'
'btnView
'
Me.btnView.Location = New System.Drawing.Point(184, 8)
Me.btnView.Name = "btnView"
Me.btnView.TabIndex = 2
Me.btnView.Text = "查看"
'
'btnReset
'
Me.btnReset.Location = New System.Drawing.Point(96, 8)
Me.btnReset.Name = "btnReset"
Me.btnReset.TabIndex = 1
Me.btnReset.Text = "重置"
'
'btnQuery
'
Me.btnQuery.Location = New System.Drawing.Point(8, 8)
Me.btnQuery.Name = "btnQuery"
Me.btnQuery.TabIndex = 0
Me.btnQuery.Text = "查询"
'
'btnDescription
'
Me.btnDescription.Location = New System.Drawing.Point(8, 48)
Me.btnDescription.Name = "btnDescription"
Me.btnDescription.Size = New System.Drawing.Size(120, 23)
Me.btnDescription.TabIndex = 3
Me.btnDescription.Text = "查询说明"
'
'btnExit
'
Me.btnExit.Location = New System.Drawing.Point(144, 48)
Me.btnExit.Name = "btnExit"
Me.btnExit.Size = New System.Drawing.Size(112, 23)
Me.btnExit.TabIndex = 4
Me.btnExit.Text = "退 出"
'
'FormFindEmployee
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(292, 270)
Me.Controls.Add(Me.Panel1)
Me.Controls.Add(Me.GroupBox1)
Me.Name = "FormFindEmployee"
Me.Text = "查询员工"
Me.GroupBox1.ResumeLayout(False)
Me.Panel1.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub InitialData()
cmbDempartment.DataSource = Nothing
cmbDempartment.Items.Clear()
cmbDempartment.DataSource = DbBase.DataInterface().Execute4DS("select number,name from department order by number").Tables(0).DefaultView
cmbDempartment.DisplayMember = "name"
cmbDempartment.ValueMember = "number"
cmbDempartment.Text = "请选择部门"
FilterData()
End Sub
Private Sub FilterData(Optional ByVal sDepartNumber As String = "")
Dim sSql As String
If sDepartNumber = "" Then
sSql = "select number,name from v_employee order by name"
Else
sSql = "select number,name from v_employee where department_number = '" & sDepartNumber & "' order by name"
End If
cmbName.DataSource = Nothing
cmbName.Items.Clear()
cmbName.DataSource = DbBase.DataInterface().Execute4DS(sSql).Tables(0).DefaultView
cmbName.DisplayMember = "name"
cmbName.ValueMember = "number"
cmbName.Text = "请选择姓名"
End Sub
Private Sub FormFindEmployee_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
InitialData()
End Sub
Private Sub cmbDempartment_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles cmbDempartment.SelectedIndexChanged
FilterData(cmbDempartment.SelectedValue)
End Sub
Private Sub cmbName_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles cmbName.SelectedIndexChanged
txtNumber.Text = cmbName.SelectedValue
End Sub
Private Sub btnQuery_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnQuery.Click
Try
txtNumber.Text = DbBase.DataInterface().Execute4Object("select number from v_employee where name like '%" & cmbName.Text & "%' and department_number = '" & cmbDempartment.SelectedValue & "'")
Catch ex As Exception
If ex.Message = "value unavailable!" Then
MessageBox.Show("没有找到该员工!")
End If
End Try
btnView.Focus()
txtNumber.SelectAll()
End Sub
Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReset.Click
InitialData()
End Sub
Private Sub btnView_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnView.Click
If txtNumber.Text <> "" Then
Dim oForm As New FormEmployee
oForm.SelectedEmployee = New Employee(txtNumber.Text)
oForm.Show()
Else
MessageBox.Show("请输入员工编号!")
End If
End Sub
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub
Private Sub btnDescription_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDescription.Click
MessageBox.Show("1.首先选择一个部门,在姓名下拉框内可以显示该部门的所有员工姓名;然后可以选择员工姓名,在编号文本框中显示员工编号;再单击""查看""按钮即可查看员工详细信息" & _
Chr(13) & "2.可以选择一个部门,然后输入员工姓名,单击""查询""按钮,在""编号""文本框显示查询到员工编号,然后单击""查看""按钮即可" _
, "查询说明")
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -