📄 formchaxun.vb
字号:
Imports System.Data.OleDb
Imports System.Data.SqlClient
Public Class FrmChaXun
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.GroupBox
Friend WithEvents ygbh As System.Windows.Forms.ComboBox
Friend WithEvents Ybm As System.Windows.Forms.ComboBox
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents ygmc As System.Windows.Forms.TextBox
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents bmmc As System.Windows.Forms.TextBox
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents label1 As System.Windows.Forms.Label
Friend WithEvents DataGrid1 As System.Windows.Forms.DataGrid
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.货物信息 = New System.Windows.Forms.GroupBox
Me.DataGrid1 = New System.Windows.Forms.DataGrid
Me.ygbh = New System.Windows.Forms.ComboBox
Me.Ybm = New System.Windows.Forms.ComboBox
Me.Label4 = New System.Windows.Forms.Label
Me.ygmc = New System.Windows.Forms.TextBox
Me.Label3 = New System.Windows.Forms.Label
Me.bmmc = New System.Windows.Forms.TextBox
Me.Label2 = New System.Windows.Forms.Label
Me.label1 = New System.Windows.Forms.Label
Me.货物信息.SuspendLayout()
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'货物信息
'
Me.货物信息.Controls.Add(Me.DataGrid1)
Me.货物信息.Controls.Add(Me.ygbh)
Me.货物信息.Controls.Add(Me.Ybm)
Me.货物信息.Controls.Add(Me.Label4)
Me.货物信息.Controls.Add(Me.ygmc)
Me.货物信息.Controls.Add(Me.Label3)
Me.货物信息.Controls.Add(Me.bmmc)
Me.货物信息.Controls.Add(Me.Label2)
Me.货物信息.Controls.Add(Me.label1)
Me.货物信息.Location = New System.Drawing.Point(20, 16)
Me.货物信息.Name = "货物信息"
Me.货物信息.Size = New System.Drawing.Size(508, 232)
Me.货物信息.TabIndex = 5
Me.货物信息.TabStop = False
Me.货物信息.Text = "个人工资情况"
'
'DataGrid1
'
Me.DataGrid1.DataMember = ""
Me.DataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText
Me.DataGrid1.Location = New System.Drawing.Point(16, 80)
Me.DataGrid1.Name = "DataGrid1"
Me.DataGrid1.ReadOnly = True
Me.DataGrid1.Size = New System.Drawing.Size(472, 144)
Me.DataGrid1.TabIndex = 62
'
'ygbh
'
Me.ygbh.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
Me.ygbh.Location = New System.Drawing.Point(84, 41)
Me.ygbh.Name = "ygbh"
Me.ygbh.Size = New System.Drawing.Size(80, 20)
Me.ygbh.TabIndex = 61
'
'Ybm
'
Me.Ybm.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
Me.Ybm.Location = New System.Drawing.Point(84, 20)
Me.Ybm.Name = "Ybm"
Me.Ybm.Size = New System.Drawing.Size(80, 20)
Me.Ybm.TabIndex = 60
'
'Label4
'
Me.Label4.Location = New System.Drawing.Point(176, 44)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(64, 12)
Me.Label4.TabIndex = 59
Me.Label4.Text = "员工姓名:"
'
'ygmc
'
Me.ygmc.Location = New System.Drawing.Point(248, 43)
Me.ygmc.Name = "ygmc"
Me.ygmc.ReadOnly = True
Me.ygmc.Size = New System.Drawing.Size(80, 21)
Me.ygmc.TabIndex = 58
Me.ygmc.Text = ""
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(16, 45)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(64, 17)
Me.Label3.TabIndex = 57
Me.Label3.Text = "员工编号:"
'
'bmmc
'
Me.bmmc.Location = New System.Drawing.Point(248, 21)
Me.bmmc.Name = "bmmc"
Me.bmmc.ReadOnly = True
Me.bmmc.Size = New System.Drawing.Size(80, 21)
Me.bmmc.TabIndex = 56
Me.bmmc.Text = ""
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(176, 24)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(64, 14)
Me.Label2.TabIndex = 55
Me.Label2.Text = "部门名称:"
'
'label1
'
Me.label1.Location = New System.Drawing.Point(16, 24)
Me.label1.Name = "label1"
Me.label1.Size = New System.Drawing.Size(64, 11)
Me.label1.TabIndex = 54
Me.label1.Text = "部门编号:"
'
'FrmChaXun
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(552, 270)
Me.Controls.Add(Me.货物信息)
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "FrmChaXun"
Me.Text = "工资查询"
Me.货物信息.ResumeLayout(False)
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Ybm_SelectionChangeCommitted(ByVal sender As Object, ByVal e As System.EventArgs) Handles Ybm.SelectionChangeCommitted
Dim connstr As New String("provider=SQLOLEDB.1;User ID=sa;PassWord=110;Persist Security Info=false;Initial Catalog=wage;Data Source=.;")
Dim Cn As New OleDbConnection
Dim searchSql As String
Dim cmd As OleDbCommand
Dim dr As OleDbDataReader
searchSql = "select 部门名称 from 部门信息表 where 部门编号=" & CInt(Ybm.SelectedItem)
Try
Cn.ConnectionString = connstr
Cn.Open()
cmd = New OleDbCommand(searchSql, Cn)
dr = cmd.ExecuteReader()
Do While dr.Read()
Me.bmmc.Text = dr.GetString(0)
Loop
dr.Close()
searchSql = "select 员工编号 from 员工信息表 where 部门编号=" & CInt(Ybm.SelectedItem)
cmd = New OleDbCommand(searchSql, Cn)
dr = cmd.ExecuteReader()
ygbh.Items.Clear()
Do While dr.Read()
Me.ygbh.Items.Add(dr.GetValue(0))
Loop
dr.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
Cn.Dispose()
cmd.Dispose()
End Sub
Private Sub ygbh_SelectionChangeCommitted(ByVal sender As Object, ByVal e As System.EventArgs) Handles ygbh.SelectionChangeCommitted
Dim connstr As New String("provider=SQLOLEDB.1;User ID=sa;PassWord=110;Persist Security Info=false;Initial Catalog=wage;Data Source=.;")
Dim Cn As New OleDbConnection
Dim searchSql As String
Dim cmd As OleDbCommand
Dim dr As OleDbDataReader
Dim da As New OleDbDataAdapter
Dim dsDataBase As New DataSet
searchSql = "select 员工姓名 from 员工信息表 where 员工编号=" & CInt(ygbh.SelectedItem)
Try
Cn.ConnectionString = connstr
Cn.Open()
cmd = New OleDbCommand(searchSql, Cn)
dr = cmd.ExecuteReader()
Dim i As Integer = 0
Do While dr.Read()
Me.ygmc.Text = dr.GetString(0)
Loop
dr.Close()
searchSql = "select * from 工资福利表 where 员工编号=" & CInt(ygbh.SelectedItem)
da.SelectCommand = New OleDbCommand(searchSql, Cn)
da.Fill(dsDataBase)
Me.DataGrid1.DataSource = dsDataBase.Tables(0)
Catch ex As Exception
MsgBox(ex.Message)
End Try
Cn.Dispose()
cmd.Dispose()
End Sub
Private Sub FrmChaXun_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim connstr As New String("provider=SQLOLEDB.1;User ID=sa;PassWord=110;Persist Security Info=false;Initial Catalog=wage;Data Source=.;")
Dim Cn As New OleDbConnection
Dim searchSql As String
Dim cmd As OleDbCommand
Dim dr As OleDbDataReader
searchSql = "select 部门编号 from 部门信息表"
Try
Cn.ConnectionString = connstr
Cn.Open()
cmd = New OleDbCommand(searchSql, Cn)
dr = cmd.ExecuteReader()
Dim i As Integer = 0
Do While dr.Read()
Me.Ybm.Items.Add(dr.GetInt32(0))
Loop
dr.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
cmd.Dispose()
Cn.Dispose()
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -