📄 form1.vb
字号:
Me.Label7.Text = "This provides the ability to GET the time-in data of an employee. Employees shoul" & _
"d enter a valid password to save their time-in data into the database."
'
'Button2
'
Me.Button2.BackColor = System.Drawing.Color.Chocolate
Me.Button2.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.Button2.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Button2.ForeColor = System.Drawing.Color.Black
Me.Button2.Location = New System.Drawing.Point(272, 160)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(88, 24)
Me.Button2.TabIndex = 4
Me.Button2.Text = "&Clear"
'
'Timer1
'
Me.Timer1.Interval = 1000
'
'Button3
'
Me.Button3.BackColor = System.Drawing.Color.Chocolate
Me.Button3.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.Button3.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Button3.ForeColor = System.Drawing.Color.Black
Me.Button3.Location = New System.Drawing.Point(8, 296)
Me.Button3.Name = "Button3"
Me.Button3.Size = New System.Drawing.Size(352, 24)
Me.Button3.TabIndex = 5
Me.Button3.Text = "&System Administration"
'
'Button1
'
Me.Button1.BackColor = System.Drawing.Color.Chocolate
Me.Button1.Enabled = False
Me.Button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.Button1.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Button1.ForeColor = System.Drawing.Color.Black
Me.Button1.Location = New System.Drawing.Point(272, 128)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(88, 24)
Me.Button1.TabIndex = 3
Me.Button1.Text = "&Time In"
'
'GroupBox1
'
Me.GroupBox1.Controls.Add(Me.Label2)
Me.GroupBox1.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.GroupBox1.ForeColor = System.Drawing.SystemColors.ControlText
Me.GroupBox1.Location = New System.Drawing.Point(8, 56)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(352, 64)
Me.GroupBox1.TabIndex = 12
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = " Date and Time"
'
'Label2
'
Me.Label2.Font = New System.Drawing.Font("Arial", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label2.ForeColor = System.Drawing.Color.Brown
Me.Label2.Location = New System.Drawing.Point(8, 16)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(336, 40)
Me.Label2.TabIndex = 0
Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'Form1
'
Me.AcceptButton = Me.Button1
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.BackColor = System.Drawing.SystemColors.Control
Me.ClientSize = New System.Drawing.Size(368, 325)
Me.ControlBox = False
Me.Controls.Add(Me.GroupBox2)
Me.Controls.Add(Me.Label7)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button3)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.GroupBox1)
Me.Controls.Add(Me.GroupBox3)
Me.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.ForeColor = System.Drawing.Color.Black
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.Name = "Form1"
Me.ShowInTaskbar = False
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = " HRMS: Time-In/Time-Out"
Me.GroupBox3.ResumeLayout(False)
Me.GroupBox2.ResumeLayout(False)
Me.GroupBox1.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
#Region " Variable Declarations "
Public sConn As OleDbConnection
Dim eDS As DataSet = New DataSet
Dim eDA As OleDbDataAdapter = New OleDbDataAdapter
Dim eDR As DataRow
Dim dDS As DataSet = New DataSet
Dim dDA As OleDbDataAdapter = New OleDbDataAdapter
Dim dDR As DataRow
'Public bExitApplication As Boolean
#End Region
#Region " User-defined Procedures "
Private Sub Check_Info()
sConn.Open()
eDA.SelectCommand = New OleDbCommand("SELECT emp_fname,emp_lname,emp_mname FROM tblEmployee WHERE emp_idno='" & TextBox1.Text.ToString & "' and emp_pass='" & TextBox2.Text & "'", sConn)
eDS.Clear()
eDA.Fill(eDS)
If eDS.Tables(0).Rows.Count > 0 Then
eDR = eDS.Tables(0).Rows(0)
TextBox3.Text = eDR("emp_lname") & ", " & eDR("emp_fname") & " " & eDR("emp_mname")
dDA.SelectCommand = New OleDbCommand("SELECT * FROM tblDTR WHERE emp_idno='" & TextBox1.Text & "' AND date_timein=#" & Format(Now, "MM/d/yyyy") & "# AND time_timeout IS NULL", sConn)
dDS.Clear()
dDA.Fill(dDS)
If dDS.Tables(0).Rows.Count > 0 Then
dDR = dDS.Tables(0).Rows(0)
Button1.Enabled = True
Button1.Text = "&Time Out"
TextBox4.Text = Format(dDR("time_timein"), "h:mm:ss tt")
Else
Button1.Enabled = True
Button1.Text = "&Time In"
End If
dDR = Nothing
dDS.Dispose()
dDA.Dispose()
Else
TextBox3.Clear()
TextBox4.Clear()
TextBox5.Clear()
Button1.Enabled = False
End If
eDR = Nothing
eDS.Dispose()
eDA.Dispose()
sConn.Close()
End Sub
Private Sub ReturnFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox3.GotFocus, TextBox4.GotFocus, TextBox5.GotFocus
TextBox1.Focus()
End Sub
Private Sub TextboxChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged, TextBox2.TextChanged
If (TextBox1.Text <> "" And TextBox2.Text <> "") Then
Check_Info()
End If
End Sub
Private Sub LoginGotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.GotFocus, TextBox2.GotFocus
TextBox3.Clear()
TextBox4.Clear()
TextBox5.Clear()
End Sub
#End Region
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
sConn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "\EIS.mdb;Persist Security Info=False")
Label2.Text = Format(Now, "MMMM d, yyyy h:mm:ss tt")
Timer1.Enabled = True
TextBox1.Focus()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Label2.Text = Format(Now, "MMMM d, yyyy h:mm:ss tt")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' Time-in and Time-out button
Dim strSQL As String
sConn.Open()
If Button1.Text = "&Time In" Then
dDR = dDS.Tables(0).NewRow()
TextBox4.Text = Format(Now, "h:mm:ss tt")
strSQL = "INSERT INTO tblDTR (emp_idno, date_timein, time_timein) VALUES ('" & TextBox1.Text & "', #" & Format(Now, "MM/d/yyyy") & "#, #" & TextBox4.Text & "#)"
Button1.Text = "&Time Out"
Else
TextBox5.Text = Format(Now, "h:mm:ss tt")
strSQL = "UPDATE tblDTR SET time_timeout=#" & TextBox5.Text & "# WHERE emp_idno='" & TextBox1.Text & "' AND date_timein=#" & Format(Now, "MM/d/yyyy") & "# and time_timein=#" & TextBox4.Text & "#"
Button1.Text = "&Time In"
End If
Dim dCmd As OleDbCommand = New OleDbCommand(strSQL, sConn)
dCmd.ExecuteNonQuery()
dCmd.Dispose()
dDR = Nothing
dDS.Dispose()
dDA.Dispose()
sConn.Close()
Button1.Enabled = False
TextBox1.Clear()
TextBox2.Clear()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
' clear the form
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
TextBox4.Clear()
TextBox5.Clear()
Button1.Text = "&Time In"
Button1.Enabled = False
TextBox1.Focus()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
' System Administration
bExitApplication = True
Dim f As Form
f = New Form2
Me.Close()
f.Show()
End Sub
Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
If Not bExitApplication Then
MsgBox("You cannot close the system this way..." & vbCrLf & vbCrLf & "Please Quit the application in the System Administration Module.", MsgBoxStyle.Critical + MsgBoxStyle.OKOnly, "Error: No Administrative Privilage")
e.Cancel = True
End If
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -