viewinf.vb
来自「是一个工资的管理系统 利用的是VB.NET和sql2000来完成的」· VB 代码 · 共 314 行
VB
314 行
Imports System.Data
Imports System.Data.SqlClient
Public Class viewinf
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 Label1 As System.Windows.Forms.Label
Friend WithEvents Txttime As System.Windows.Forms.TextBox
Friend WithEvents btviewall As System.Windows.Forms.Button
Friend WithEvents btviewlate As System.Windows.Forms.Button
Friend WithEvents btviewthismonth As System.Windows.Forms.Button
Friend WithEvents btdeletethismonth As System.Windows.Forms.Button
Friend WithEvents btall As System.Windows.Forms.Button
Friend WithEvents btexit As System.Windows.Forms.Button
Friend WithEvents CheckBox1 As System.Windows.Forms.CheckBox
Friend WithEvents Panel1 As System.Windows.Forms.Panel
Friend WithEvents DataGrid1 As System.Windows.Forms.DataGrid
Friend WithEvents SqlDataAdapter1 As System.Data.SqlClient.SqlDataAdapter
Friend WithEvents SqlSelectCommand1 As System.Data.SqlClient.SqlCommand
Friend WithEvents SqlConnection1 As System.Data.SqlClient.SqlConnection
Friend WithEvents DataSet1 As 员工上班情况.DataSet1
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(viewinf))
Me.Label1 = New System.Windows.Forms.Label
Me.Txttime = New System.Windows.Forms.TextBox
Me.btviewall = New System.Windows.Forms.Button
Me.btviewlate = New System.Windows.Forms.Button
Me.btviewthismonth = New System.Windows.Forms.Button
Me.btdeletethismonth = New System.Windows.Forms.Button
Me.btall = New System.Windows.Forms.Button
Me.btexit = New System.Windows.Forms.Button
Me.CheckBox1 = New System.Windows.Forms.CheckBox
Me.Panel1 = New System.Windows.Forms.Panel
Me.DataGrid1 = New System.Windows.Forms.DataGrid
Me.DataSet1 = New 员工上班情况.DataSet1
Me.SqlDataAdapter1 = New System.Data.SqlClient.SqlDataAdapter
Me.SqlSelectCommand1 = New System.Data.SqlClient.SqlCommand
Me.SqlConnection1 = New System.Data.SqlClient.SqlConnection
Me.Panel1.SuspendLayout()
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.DataSet1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(40, 80)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(104, 32)
Me.Label1.TabIndex = 0
Me.Label1.Text = "在这里输入的时间格式:00:00:00"
'
'Txttime
'
Me.Txttime.Location = New System.Drawing.Point(40, 136)
Me.Txttime.Name = "Txttime"
Me.Txttime.ReadOnly = True
Me.Txttime.Size = New System.Drawing.Size(104, 21)
Me.Txttime.TabIndex = 1
Me.Txttime.Text = "09:30:00"
Me.Txttime.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
'
'btviewall
'
Me.btviewall.FlatStyle = System.Windows.Forms.FlatStyle.Popup
Me.btviewall.Location = New System.Drawing.Point(192, 32)
Me.btviewall.Name = "btviewall"
Me.btviewall.Size = New System.Drawing.Size(88, 40)
Me.btviewall.TabIndex = 2
Me.btviewall.Text = "加载所有数据"
'
'btviewlate
'
Me.btviewlate.FlatStyle = System.Windows.Forms.FlatStyle.Popup
Me.btviewlate.Location = New System.Drawing.Point(320, 104)
Me.btviewlate.Name = "btviewlate"
Me.btviewlate.Size = New System.Drawing.Size(88, 40)
Me.btviewlate.TabIndex = 3
Me.btviewlate.Text = "查看本月迟到情况"
'
'btviewthismonth
'
Me.btviewthismonth.FlatStyle = System.Windows.Forms.FlatStyle.Popup
Me.btviewthismonth.Location = New System.Drawing.Point(192, 104)
Me.btviewthismonth.Name = "btviewthismonth"
Me.btviewthismonth.Size = New System.Drawing.Size(88, 40)
Me.btviewthismonth.TabIndex = 4
Me.btviewthismonth.Text = "查看本月上班记录"
'
'btdeletethismonth
'
Me.btdeletethismonth.FlatStyle = System.Windows.Forms.FlatStyle.Popup
Me.btdeletethismonth.Location = New System.Drawing.Point(320, 32)
Me.btdeletethismonth.Name = "btdeletethismonth"
Me.btdeletethismonth.Size = New System.Drawing.Size(88, 40)
Me.btdeletethismonth.TabIndex = 5
Me.btdeletethismonth.Text = "删除本月上班记录"
'
'btall
'
Me.btall.FlatStyle = System.Windows.Forms.FlatStyle.Popup
Me.btall.Location = New System.Drawing.Point(456, 32)
Me.btall.Name = "btall"
Me.btall.Size = New System.Drawing.Size(88, 40)
Me.btall.TabIndex = 6
Me.btall.Text = "删除所有"
'
'btexit
'
Me.btexit.FlatStyle = System.Windows.Forms.FlatStyle.Popup
Me.btexit.Location = New System.Drawing.Point(464, 104)
Me.btexit.Name = "btexit"
Me.btexit.Size = New System.Drawing.Size(88, 40)
Me.btexit.TabIndex = 7
Me.btexit.Text = "退出"
'
'CheckBox1
'
Me.CheckBox1.Location = New System.Drawing.Point(40, 24)
Me.CheckBox1.Name = "CheckBox1"
Me.CheckBox1.TabIndex = 8
Me.CheckBox1.Text = "改变上班时间"
'
'Panel1
'
Me.Panel1.Anchor = System.Windows.Forms.AnchorStyles.None
Me.Panel1.Controls.Add(Me.btexit)
Me.Panel1.Controls.Add(Me.btall)
Me.Panel1.Controls.Add(Me.btdeletethismonth)
Me.Panel1.Controls.Add(Me.btviewthismonth)
Me.Panel1.Controls.Add(Me.btviewlate)
Me.Panel1.Controls.Add(Me.btviewall)
Me.Panel1.Controls.Add(Me.Txttime)
Me.Panel1.Controls.Add(Me.Label1)
Me.Panel1.Controls.Add(Me.CheckBox1)
Me.Panel1.Location = New System.Drawing.Point(0, 208)
Me.Panel1.Name = "Panel1"
Me.Panel1.Size = New System.Drawing.Size(576, 168)
Me.Panel1.TabIndex = 9
'
'DataGrid1
'
Me.DataGrid1.Anchor = System.Windows.Forms.AnchorStyles.None
Me.DataGrid1.CaptionVisible = False
Me.DataGrid1.DataMember = "总表"
Me.DataGrid1.DataSource = Me.DataSet1
Me.DataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText
Me.DataGrid1.Location = New System.Drawing.Point(0, 0)
Me.DataGrid1.Name = "DataGrid1"
Me.DataGrid1.Size = New System.Drawing.Size(592, 208)
Me.DataGrid1.TabIndex = 10
'
'DataSet1
'
Me.DataSet1.DataSetName = "DataSet1"
Me.DataSet1.Locale = New System.Globalization.CultureInfo("zh-CN")
'
'SqlDataAdapter1
'
Me.SqlDataAdapter1.SelectCommand = Me.SqlSelectCommand1
Me.SqlDataAdapter1.TableMappings.AddRange(New System.Data.Common.DataTableMapping() {New System.Data.Common.DataTableMapping("Table", "总表", New System.Data.Common.DataColumnMapping() {New System.Data.Common.DataColumnMapping("工号", "工号"), New System.Data.Common.DataColumnMapping("姓名", "姓名"), New System.Data.Common.DataColumnMapping("性别", "性别"), New System.Data.Common.DataColumnMapping("职务", "职务"), New System.Data.Common.DataColumnMapping("上班日期", "上班日期"), New System.Data.Common.DataColumnMapping("上班时间", "上班时间")})})
'
'SqlSelectCommand1
'
Me.SqlSelectCommand1.CommandText = "SELECT 工号, 姓名, 性别, 职务, 上班日期, 上班时间 FROM 总表 ORDER BY 上班日期, 上班时间"
Me.SqlSelectCommand1.Connection = Me.SqlConnection1
'
'SqlConnection1
'
Me.SqlConnection1.ConnectionString = "workstation id=LYQAWM;packet size=4096;integrated security=SSPI;data source=""(loc" & _
"al)"";persist security info=False;initial catalog=员工上班情况"
'
'viewinf
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(592, 381)
Me.Controls.Add(Me.DataGrid1)
Me.Controls.Add(Me.Panel1)
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.Name = "viewinf"
Me.Text = "具体上班时间表"
Me.Panel1.ResumeLayout(False)
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.DataSet1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Checked = True Then
Txttime.ReadOnly = False
Else
Txttime.ReadOnly = True
End If
End Sub
Private Sub btviewall_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btviewall.Click
Try
DataSet1.Clear()
SqlDataAdapter1.SelectCommand.CommandText = "SELECT * FROM 总表 ORDER BY 上班日期,上班时间"
SqlDataAdapter1.Fill(DataSet1, "总表")
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Function getdate()
Dim datestr, yearstr, monthstr As String
yearstr = Year(DateString)
monthstr = Month(DateString)
If Len(monthstr) = 1 Then
monthstr = 0 & monthstr
End If
datestr = yearstr & "-" & monthstr & "-"
Return datestr
End Function
Private Sub BtViewThisMonth_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btviewthismonth.Click
Try
DataSet1.Clear()
SqlDataAdapter1.SelectCommand.CommandText = "SELECT * FROM 总表 WHERE 上班日期 Like'" & getdate() & "%'" & "ORDER BY 上班日期,上班时间"
SqlDataAdapter1.Fill(DataSet1, "总表")
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub BtViewLate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btviewlate.Click
Try
DataSet1.Clear()
SqlDataAdapter1.SelectCommand.CommandText = "SELECT * FROM 总表 WHERE 上班日期 Like'" & getdate() & "%'" & "ORDER BY 上班日期,上班时间"
SqlDataAdapter1.Fill(DataSet1, "总表")
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub BtDeleteThisMonth_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btdeletethismonth.Click
If MessageBox.Show("是否永久删除这些数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) = DialogResult.No Then
Exit Sub
End If
Try
Dim comstr As String = "delete 上班信息表 WHERE 上班日期 Like '" & getdate() & "&'"
Dim sqlcom As New SqlCommand(comstr, SqlConnection1)
SqlConnection1.Open()
sqlcom.ExecuteNonQuery()
Me.btviewall_Click(sender, e)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub BtAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btall.Click
If MessageBox.Show("是否永久删除所有的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) = DialogResult.No Then
Exit Sub
End If
Try
Dim comstr As String = "delete 上班信息表"
Dim sqlcom As New SqlCommand(comstr, SqlConnection1)
SqlConnection1.Open()
sqlcom.ExecuteNonQuery()
DataSet1.Clear()
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
SqlConnection1.Close()
End Try
End Sub
Private Sub BtExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btexit.Click
Me.Close()
End Sub
End Class
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?