📄 formchuqin.vb
字号:
Imports System.Data.OleDb
Imports System.Data.SqlClient
Public Class FrmChuQin
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 Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents ygbh As System.Windows.Forms.ComboBox
Friend WithEvents Ybm As System.Windows.Forms.ComboBox
Friend WithEvents Label11 As System.Windows.Forms.Label
Friend WithEvents Label12 As System.Windows.Forms.Label
Friend WithEvents Label13 As System.Windows.Forms.Label
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 qqsj As System.Windows.Forms.TextBox
Friend WithEvents qqrq As System.Windows.Forms.TextBox
Friend WithEvents qqlx As System.Windows.Forms.ComboBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.货物信息 = New System.Windows.Forms.GroupBox
Me.ygbh = New System.Windows.Forms.ComboBox
Me.Ybm = New System.Windows.Forms.ComboBox
Me.Label11 = New System.Windows.Forms.Label
Me.qqsj = New System.Windows.Forms.TextBox
Me.Label12 = New System.Windows.Forms.Label
Me.qqrq = New System.Windows.Forms.TextBox
Me.Label13 = New System.Windows.Forms.Label
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.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.qqlx = New System.Windows.Forms.ComboBox
Me.货物信息.SuspendLayout()
Me.SuspendLayout()
'
'货物信息
'
Me.货物信息.Controls.Add(Me.qqlx)
Me.货物信息.Controls.Add(Me.ygbh)
Me.货物信息.Controls.Add(Me.Ybm)
Me.货物信息.Controls.Add(Me.Label11)
Me.货物信息.Controls.Add(Me.qqsj)
Me.货物信息.Controls.Add(Me.Label12)
Me.货物信息.Controls.Add(Me.qqrq)
Me.货物信息.Controls.Add(Me.Label13)
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.货物信息.Controls.Add(Me.Button1)
Me.货物信息.Controls.Add(Me.Button2)
Me.货物信息.Location = New System.Drawing.Point(20, 16)
Me.货物信息.Name = "货物信息"
Me.货物信息.Size = New System.Drawing.Size(364, 232)
Me.货物信息.TabIndex = 5
Me.货物信息.TabStop = False
Me.货物信息.Text = "出勤信息录入"
'
'ygbh
'
Me.ygbh.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
Me.ygbh.Location = New System.Drawing.Point(88, 72)
Me.ygbh.Name = "ygbh"
Me.ygbh.Size = New System.Drawing.Size(80, 20)
Me.ygbh.TabIndex = 53
'
'Ybm
'
Me.Ybm.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
Me.Ybm.Location = New System.Drawing.Point(88, 24)
Me.Ybm.Name = "Ybm"
Me.Ybm.Size = New System.Drawing.Size(80, 20)
Me.Ybm.TabIndex = 52
'
'Label11
'
Me.Label11.Location = New System.Drawing.Point(176, 80)
Me.Label11.Name = "Label11"
Me.Label11.Size = New System.Drawing.Size(80, 16)
Me.Label11.TabIndex = 50
Me.Label11.Text = "缺勤类型:"
'
'qqsj
'
Me.qqsj.Location = New System.Drawing.Point(256, 48)
Me.qqsj.Name = "qqsj"
Me.qqsj.Size = New System.Drawing.Size(80, 21)
Me.qqsj.TabIndex = 49
Me.qqsj.Text = ""
'
'Label12
'
Me.Label12.Location = New System.Drawing.Point(176, 56)
Me.Label12.Name = "Label12"
Me.Label12.Size = New System.Drawing.Size(80, 16)
Me.Label12.TabIndex = 48
Me.Label12.Text = "缺勤时间:"
'
'qqrq
'
Me.qqrq.Location = New System.Drawing.Point(256, 24)
Me.qqrq.Name = "qqrq"
Me.qqrq.Size = New System.Drawing.Size(80, 21)
Me.qqrq.TabIndex = 47
Me.qqrq.Text = ""
'
'Label13
'
Me.Label13.Location = New System.Drawing.Point(176, 32)
Me.Label13.Name = "Label13"
Me.Label13.Size = New System.Drawing.Size(80, 16)
Me.Label13.TabIndex = 46
Me.Label13.Text = "缺勤日期:"
'
'Label4
'
Me.Label4.Location = New System.Drawing.Point(16, 104)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(64, 12)
Me.Label4.TabIndex = 45
Me.Label4.Text = "员工姓名:"
'
'ygmc
'
Me.ygmc.Location = New System.Drawing.Point(88, 96)
Me.ygmc.Name = "ygmc"
Me.ygmc.ReadOnly = True
Me.ygmc.Size = New System.Drawing.Size(80, 21)
Me.ygmc.TabIndex = 44
Me.ygmc.Text = ""
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(16, 80)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(64, 17)
Me.Label3.TabIndex = 43
Me.Label3.Text = "员工编号:"
'
'bmmc
'
Me.bmmc.Location = New System.Drawing.Point(88, 48)
Me.bmmc.Name = "bmmc"
Me.bmmc.ReadOnly = True
Me.bmmc.Size = New System.Drawing.Size(80, 21)
Me.bmmc.TabIndex = 42
Me.bmmc.Text = ""
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(16, 56)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(64, 14)
Me.Label2.TabIndex = 41
Me.Label2.Text = "部门名称:"
'
'label1
'
Me.label1.Location = New System.Drawing.Point(16, 32)
Me.label1.Name = "label1"
Me.label1.Size = New System.Drawing.Size(64, 11)
Me.label1.TabIndex = 40
Me.label1.Text = "部门编号:"
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(160, 184)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(56, 23)
Me.Button1.TabIndex = 4
Me.Button1.Text = "增加"
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(216, 184)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(56, 23)
Me.Button2.TabIndex = 5
Me.Button2.Text = "退出"
'
'qqlx
'
Me.qqlx.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
Me.qqlx.Location = New System.Drawing.Point(256, 72)
Me.qqlx.Name = "qqlx"
Me.qqlx.Size = New System.Drawing.Size(80, 20)
Me.qqlx.TabIndex = 54
'
'FrmChuQin
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(408, 278)
Me.Controls.Add(Me.货物信息)
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "FrmChuQin"
Me.Text = "出勤管理"
Me.货物信息.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
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 cmd As OleDbCommand
Dim SQLString As String
SQLString = "INSERT INTO 缺勤信息表 (员工编号,缺勤日期,缺勤时间,缺勤类型)" & _
" VALUES(" & CInt(ygbh.Text) & ",'" & qqrq.Text & "'," & _
CInt(qqsj.Text) & "," & CInt(qqlx.SelectedIndex) & ")"
Cn.ConnectionString = connstr
Cn.Open()
cmd = New OleDbCommand(SQLString, Cn)
Try
cmd.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.Message)
End Try
cmd.Dispose()
Cn.Dispose()
End Sub
Private Sub FrmChuQin_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()
Dim NamePart As String
NamePart = CStr(DateTime.Now)
NamePart = Microsoft.VisualBasic.Left(NamePart, InStr(NamePart, " ") - 1)
qqrq.Text = NamePart
qqlx.Items.Add("旷工")
qqlx.Items.Add("请假")
End Sub
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
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()
Catch ex As Exception
MsgBox(ex.Message)
End Try
Cn.Dispose()
cmd.Dispose()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -