📄 frmemployeeview.vb
字号:
Public Class wquery
Inherits System.Windows.Forms.Form
#Region " Windows 窗体设计器生成的代码 "
Public Sub New()
MyBase.New()
'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()
'在 InitializeComponent() 调用之后添加任何初始化
Dim myResult As Short
myResult = OpenDb()
Dim Mysql As String
Mysql = "select * from employees"
Myrec = Mydb.OpenRecordset(Mysql, DAO.RecordsetTypeEnum.dbOpenDynaset)
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 Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents Txtname As System.Windows.Forms.TextBox
Friend WithEvents Txtno As System.Windows.Forms.TextBox
Friend WithEvents Txttitle As System.Windows.Forms.TextBox
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents Cmbsearch As System.Windows.Forms.ComboBox
Friend WithEvents Txtsearch As System.Windows.Forms.TextBox
Friend WithEvents Btsearch As System.Windows.Forms.Button
Friend WithEvents Btpre As System.Windows.Forms.Button
Friend WithEvents Btnext As System.Windows.Forms.Button
Friend WithEvents Btfirst As System.Windows.Forms.Button
Friend WithEvents Btlast As System.Windows.Forms.Button
Friend WithEvents Btexit As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.Label3 = New System.Windows.Forms.Label
Me.Btpre = New System.Windows.Forms.Button
Me.Btnext = New System.Windows.Forms.Button
Me.Btfirst = New System.Windows.Forms.Button
Me.Btlast = New System.Windows.Forms.Button
Me.Txtname = New System.Windows.Forms.TextBox
Me.Txtno = New System.Windows.Forms.TextBox
Me.Txttitle = New System.Windows.Forms.TextBox
Me.Label4 = New System.Windows.Forms.Label
Me.Cmbsearch = New System.Windows.Forms.ComboBox
Me.Txtsearch = New System.Windows.Forms.TextBox
Me.Btsearch = New System.Windows.Forms.Button
Me.Btexit = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(24, 32)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(88, 24)
Me.Label1.TabIndex = 0
Me.Label1.Text = "姓名"
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(16, 80)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(96, 24)
Me.Label2.TabIndex = 1
Me.Label2.Text = "工号"
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(16, 120)
Me.Label3.Name = "Label3"
Me.Label3.TabIndex = 2
Me.Label3.Text = "职称"
'
'Btpre
'
Me.Btpre.Location = New System.Drawing.Point(32, 176)
Me.Btpre.Name = "Btpre"
Me.Btpre.TabIndex = 3
Me.Btpre.Text = "上一条"
'
'Btnext
'
Me.Btnext.Location = New System.Drawing.Point(160, 176)
Me.Btnext.Name = "Btnext"
Me.Btnext.TabIndex = 4
Me.Btnext.Text = "下一条"
'
'Btfirst
'
Me.Btfirst.Location = New System.Drawing.Point(32, 208)
Me.Btfirst.Name = "Btfirst"
Me.Btfirst.TabIndex = 5
Me.Btfirst.Text = "第一条"
'
'Btlast
'
Me.Btlast.Location = New System.Drawing.Point(160, 208)
Me.Btlast.Name = "Btlast"
Me.Btlast.TabIndex = 6
Me.Btlast.Text = "最未条"
'
'Txtname
'
Me.Txtname.Location = New System.Drawing.Point(136, 40)
Me.Txtname.Name = "Txtname"
Me.Txtname.Size = New System.Drawing.Size(136, 21)
Me.Txtname.TabIndex = 7
Me.Txtname.Text = ""
'
'Txtno
'
Me.Txtno.Location = New System.Drawing.Point(136, 80)
Me.Txtno.Name = "Txtno"
Me.Txtno.Size = New System.Drawing.Size(136, 21)
Me.Txtno.TabIndex = 8
Me.Txtno.Text = ""
'
'Txttitle
'
Me.Txttitle.Location = New System.Drawing.Point(136, 120)
Me.Txttitle.Name = "Txttitle"
Me.Txttitle.Size = New System.Drawing.Size(136, 21)
Me.Txttitle.TabIndex = 9
Me.Txttitle.Text = ""
'
'Label4
'
Me.Label4.Location = New System.Drawing.Point(8, 256)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(72, 23)
Me.Label4.TabIndex = 10
Me.Label4.Text = "查询条件"
'
'Cmbsearch
'
Me.Cmbsearch.Items.AddRange(New Object() {"姓名", "职工号"})
Me.Cmbsearch.Location = New System.Drawing.Point(88, 256)
Me.Cmbsearch.Name = "Cmbsearch"
Me.Cmbsearch.Size = New System.Drawing.Size(88, 20)
Me.Cmbsearch.TabIndex = 11
'
'Txtsearch
'
Me.Txtsearch.Location = New System.Drawing.Point(192, 256)
Me.Txtsearch.Name = "Txtsearch"
Me.Txtsearch.Size = New System.Drawing.Size(72, 21)
Me.Txtsearch.TabIndex = 12
Me.Txtsearch.Text = ""
'
'Btsearch
'
Me.Btsearch.Location = New System.Drawing.Point(280, 256)
Me.Btsearch.Name = "Btsearch"
Me.Btsearch.Size = New System.Drawing.Size(72, 24)
Me.Btsearch.TabIndex = 13
Me.Btsearch.Text = "查询"
'
'Btexit
'
Me.Btexit.Location = New System.Drawing.Point(280, 208)
Me.Btexit.Name = "Btexit"
Me.Btexit.Size = New System.Drawing.Size(72, 24)
Me.Btexit.TabIndex = 14
Me.Btexit.Text = "退出"
'
'wquery
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(376, 326)
Me.Controls.Add(Me.Btexit)
Me.Controls.Add(Me.Btsearch)
Me.Controls.Add(Me.Txtsearch)
Me.Controls.Add(Me.Cmbsearch)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.Txttitle)
Me.Controls.Add(Me.Txtno)
Me.Controls.Add(Me.Txtname)
Me.Controls.Add(Me.Btlast)
Me.Controls.Add(Me.Btfirst)
Me.Controls.Add(Me.Btnext)
Me.Controls.Add(Me.Btpre)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Name = "wquery"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "员工查询"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub wquery_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Activated
Txtname.Text = Myrec.Fields(1).Value
Txtno.Text = Myrec.Fields(0).Value
Txttitle.Text = Myrec.Fields(3).Value
End Sub
Private Sub Btpre_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btpre.Click
If Myrec.BOF = True Then
MsgBox("已是第一条记录")
Exit Sub
Else
Myrec.MovePrevious()
If Myrec.BOF = True Then
MsgBox("已是第一条记录")
Exit Sub
End If
End If
Txtname.Text = Myrec.Fields(1).Value
Txtno.Text = Myrec.Fields(0).Value
Txttitle.Text = Myrec.Fields(3).Value
End Sub
Private Sub Btnext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnext.Click
If Myrec.EOF Then
MsgBox("已经是最后一条记录")
Exit Sub
Else
Myrec.MoveNext()
If Myrec.EOF = True Then
MsgBox("已经是最后一条记录")
Exit Sub
End If
End If
Txtname.Text = Myrec.Fields(1).Value
Txtno.Text = Myrec.Fields(0).Value
Txttitle.Text = Myrec.Fields(3).Value
End Sub
Private Sub Btfirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btfirst.Click
Myrec.MoveFirst()
Txtname.Text = Myrec.Fields(1).Value
Txtno.Text = Myrec.Fields(0).Value
Txttitle.Text = Myrec.Fields(3).Value
End Sub
Private Sub Btlast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btlast.Click
Myrec.MoveLast()
Txtname.Text = Myrec.Fields(1).Value
Txtno.Text = Myrec.Fields(0).Value
Txttitle.Text = Myrec.Fields(3).Value
End Sub
Private Sub Btexit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btexit.Click
Me.Close()
End Sub
Private Sub Btsearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btsearch.Click
Dim strstem As String
Dim dbstr As String
strstem = Txtsearch.Text
If Cmbsearch.Text = "姓名" Then
dbstr = "select * from employees where LastName='" & strstem & "'"
MsgBox(dbstr)
ElseIf Cmbsearch.Text = "职工号" Then
dbstr = "select * from employees where EmployeeID=" & strstem & ""
ElseIf Cmbsearch.Text = "" Then
MsgBox("请先选择查询条件")
End If
Myrec = Mydb.OpenRecordset(dbstr, DAO.RecordsetTypeEnum.dbOpenDynaset)
If Myrec.EOF = True Then
If Cmbsearch.Text = "姓名" Then
MsgBox("没有查询到该职工信息,您的查询条件是姓名,您输入的是" & strstem & "")
ElseIf Cmbsearch.Text = "职工号" Then
MsgBox("没有查询到该职工信息,您的查询条件是职工号,您输入的是" & strstem & "")
End If
Else
Txtname.Text = Myrec.Fields(1).Value
Txtno.Text = Myrec.Fields(0).Value
Txttitle.Text = Myrec.Fields(3).Value
End If
Myrec.Close()
Myrec = Nothing
Call OpenDb()
End Sub
Private Sub wquery_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -