📄 formjiaban.vb
字号:
Imports System.Data.OleDb
Imports System.Data.SqlClient
Public Class FrmJb
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 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 Label3 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents label1 As System.Windows.Forms.Label
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents FrmJban As System.Windows.Forms.GroupBox
Friend WithEvents jbfl As System.Windows.Forms.TextBox
Friend WithEvents jbsj As System.Windows.Forms.TextBox
Friend WithEvents jbrq As System.Windows.Forms.TextBox
Friend WithEvents bmmc As System.Windows.Forms.TextBox
Friend WithEvents Ybm As System.Windows.Forms.ComboBox
Friend WithEvents ygmc As System.Windows.Forms.TextBox
Friend WithEvents ygbh As System.Windows.Forms.ComboBox
Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.FrmJban = New System.Windows.Forms.GroupBox
Me.ygbh = New System.Windows.Forms.ComboBox
Me.Ybm = New System.Windows.Forms.ComboBox
Me.jbfl = New System.Windows.Forms.TextBox
Me.Label11 = New System.Windows.Forms.Label
Me.jbsj = New System.Windows.Forms.TextBox
Me.Label12 = New System.Windows.Forms.Label
Me.jbrq = 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.ComboBox1 = New System.Windows.Forms.ComboBox
Me.FrmJban.SuspendLayout()
Me.SuspendLayout()
'
'FrmJban
'
Me.FrmJban.Controls.Add(Me.ygbh)
Me.FrmJban.Controls.Add(Me.Ybm)
Me.FrmJban.Controls.Add(Me.jbfl)
Me.FrmJban.Controls.Add(Me.Label11)
Me.FrmJban.Controls.Add(Me.jbsj)
Me.FrmJban.Controls.Add(Me.Label12)
Me.FrmJban.Controls.Add(Me.jbrq)
Me.FrmJban.Controls.Add(Me.Label13)
Me.FrmJban.Controls.Add(Me.Label4)
Me.FrmJban.Controls.Add(Me.ygmc)
Me.FrmJban.Controls.Add(Me.Label3)
Me.FrmJban.Controls.Add(Me.bmmc)
Me.FrmJban.Controls.Add(Me.Label2)
Me.FrmJban.Controls.Add(Me.label1)
Me.FrmJban.Controls.Add(Me.Button1)
Me.FrmJban.Controls.Add(Me.Button2)
Me.FrmJban.Location = New System.Drawing.Point(20, 16)
Me.FrmJban.Name = "FrmJban"
Me.FrmJban.Size = New System.Drawing.Size(356, 232)
Me.FrmJban.TabIndex = 5
Me.FrmJban.TabStop = False
Me.FrmJban.Text = "加班信息录入"
'
'ygbh
'
Me.ygbh.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
Me.ygbh.Location = New System.Drawing.Point(80, 80)
Me.ygbh.Name = "ygbh"
Me.ygbh.Size = New System.Drawing.Size(80, 20)
Me.ygbh.TabIndex = 39
'
'Ybm
'
Me.Ybm.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
Me.Ybm.Location = New System.Drawing.Point(80, 33)
Me.Ybm.Name = "Ybm"
Me.Ybm.Size = New System.Drawing.Size(80, 20)
Me.Ybm.TabIndex = 38
'
'jbfl
'
Me.jbfl.Location = New System.Drawing.Point(248, 80)
Me.jbfl.Name = "jbfl"
Me.jbfl.Size = New System.Drawing.Size(80, 21)
Me.jbfl.TabIndex = 19
Me.jbfl.Text = ""
'
'Label11
'
Me.Label11.Location = New System.Drawing.Point(168, 84)
Me.Label11.Name = "Label11"
Me.Label11.Size = New System.Drawing.Size(80, 16)
Me.Label11.TabIndex = 18
Me.Label11.Text = "加班费率:"
'
'jbsj
'
Me.jbsj.Location = New System.Drawing.Point(248, 56)
Me.jbsj.Name = "jbsj"
Me.jbsj.Size = New System.Drawing.Size(80, 21)
Me.jbsj.TabIndex = 17
Me.jbsj.Text = ""
'
'Label12
'
Me.Label12.Location = New System.Drawing.Point(168, 61)
Me.Label12.Name = "Label12"
Me.Label12.Size = New System.Drawing.Size(80, 16)
Me.Label12.TabIndex = 16
Me.Label12.Text = "加班时间:"
'
'jbrq
'
Me.jbrq.Location = New System.Drawing.Point(248, 32)
Me.jbrq.Name = "jbrq"
Me.jbrq.Size = New System.Drawing.Size(80, 21)
Me.jbrq.TabIndex = 15
Me.jbrq.Text = ""
'
'Label13
'
Me.Label13.Location = New System.Drawing.Point(168, 36)
Me.Label13.Name = "Label13"
Me.Label13.Size = New System.Drawing.Size(80, 16)
Me.Label13.TabIndex = 14
Me.Label13.Text = "加班日期:"
'
'Label4
'
Me.Label4.Location = New System.Drawing.Point(8, 109)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(64, 12)
Me.Label4.TabIndex = 6
Me.Label4.Text = "员工姓名:"
'
'ygmc
'
Me.ygmc.Location = New System.Drawing.Point(80, 104)
Me.ygmc.Name = "ygmc"
Me.ygmc.ReadOnly = True
Me.ygmc.Size = New System.Drawing.Size(80, 21)
Me.ygmc.TabIndex = 5
Me.ygmc.Text = ""
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(8, 83)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(64, 17)
Me.Label3.TabIndex = 4
Me.Label3.Text = "员工编号:"
'
'bmmc
'
Me.bmmc.Location = New System.Drawing.Point(80, 56)
Me.bmmc.Name = "bmmc"
Me.bmmc.ReadOnly = True
Me.bmmc.Size = New System.Drawing.Size(80, 21)
Me.bmmc.TabIndex = 3
Me.bmmc.Text = ""
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(8, 59)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(64, 14)
Me.Label2.TabIndex = 2
Me.Label2.Text = "部门名称:"
'
'label1
'
Me.label1.Location = New System.Drawing.Point(8, 36)
Me.label1.Name = "label1"
Me.label1.Size = New System.Drawing.Size(64, 11)
Me.label1.TabIndex = 0
Me.label1.Text = "部门编号:"
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(168, 192)
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(224, 192)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(56, 23)
Me.Button2.TabIndex = 5
Me.Button2.Text = "退出"
'
'ComboBox1
'
Me.ComboBox1.Location = New System.Drawing.Point(138, 130)
Me.ComboBox1.Name = "ComboBox1"
Me.ComboBox1.Size = New System.Drawing.Size(80, 20)
Me.ComboBox1.TabIndex = 0
'
'FrmJb
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(392, 270)
Me.Controls.Add(Me.FrmJban)
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "FrmJb"
Me.Text = "加班管理"
Me.FrmJban.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) & ",'" & jbrq.Text & "'," & _
CInt(jbsj.Text) & "," & CInt(jbfl.Text) & ")"
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 Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
Private Sub FrmJb_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
Cn.Dispose()
cmd.Dispose()
Dim NamePart As String
NamePart = CStr(DateTime.Now)
NamePart = Microsoft.VisualBasic.Left(NamePart, InStr(NamePart, " ") - 1)
jbrq.Text = NamePart
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
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -