Помогите мне с тайм-аут и тайм-аут, используя данные отпечатков пальцев VB.NET
' this is my main form for verifying of registered user for login and logout time ' my problem is everytime I log in and out the new row will display the last time out record Public Class BTAForm Private WithEvents verifyControl As DPFP.Gui.Verification.VerificationControl Private matcher As DPFP.Verification.Verification Private matchResult As DPFP.Verification.Verification.Result Private Sub CreateDPControl(ByRef control As DPFP.Gui.Verification.VerificationControl) Try control = New DPFP.Gui.Verification.VerificationControl() control.AutoSizeMode = Windows.Forms.AutoSizeMode.GrowAndShrink control.Name = "verifyControl" control.Location = New System.Drawing.Point(25, 1000) control.ReaderSerialNumber = "00000000-0000-0000-0000-000000000000" control.Visible = True control.Enabled = True control.BringToFront() Me.Controls.Add(control) Catch ex As Exception MessageBox.Show("exception") End Try End Sub Private Function ConnectString() As String Dim connectionString As String connectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Enrollment\BTA.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True" Return connectionString End Function Private Sub VerifyBiometric_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load matcher = New DPFP.Verification.Verification() matchResult = New DPFP.Verification.Verification.Result CreateDPControl(verifyControl) Me.verifyControl.Focus() refreshdata() End Sub Private Sub verifyControl_OnComplete(ByVal Control As Object, ByVal FeatureSet As DPFP.FeatureSet, ByRef EventHandlerStatus As DPFP.Gui.EventHandlerStatus) Handles verifyControl.OnComplete Dim dataSet As DataSet = New DataSet() Dim adapter As SqlDataAdapter = New SqlDataAdapter() Dim sqlCommand As SqlCommand = New SqlCommand() Dim cn As New SqlConnection(ConnectString()) Dim lrd As SqlDataReader Dim bytes As Byte() = Nothing Dim tpl8 As DPFP.Template = New DPFP.Template Try sqlCommand.CommandText = "Select * FROM FPRegistration" sqlCommand.CommandType = CommandType.Text sqlCommand.Connection = cn cn.Open() lrd = sqlCommand.ExecuteReader Do While (lrd.Read()) With Me .lblID.Text = lrd(1).ToString .emp_n.Text = lrd(2).ToString .Pos.Text = lrd(3).ToString .Dpt.Text = lrd(4).ToString bytes = lrd.Item("FP1") tpl8.DeSerialize(bytes) matcher.Verify(FeatureSet, tpl8, matchResult) End With If matchResult.Verified Then EventHandlerStatus = DPFP.Gui.EventHandlerStatus.Success Call employee() lblStat.Visible = True lblStat2.Visible = False emp_n.Visible = True Label5.Visible = True Label6.Visible = True Exit Do End If If Not matchResult.Verified Then EventHandlerStatus = DPFP.Gui.EventHandlerStatus.Failure lblStat2.Visible = True lblStat.Visible = False emp_n.Visible = False Label5.Visible = False Label6.Visible = False End If Loop Finally End Try cn.Close() End Sub Public Sub employee() Try Dim con As New SqlConnection() Dim com As SqlCommand = con.CreateCommand Dim reader As SqlClient.SqlDataReader con.ConnectionString = ("Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Enrollment\BTA.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True") con.Open() com.CommandText = "SELECT * from DTR WHERE Emp_Id='" & lblID.Text & "' AND TimeOut='Null' AND TimeIn='Null'" reader = com.ExecuteReader If reader.HasRows Then Call limit() Else call logout() End If If reader.HasRows Then Call limit() Else call login() End If Catch ex As Exception MessageBox.Show("Error in scanning", ex.Message) End Try End Sub Public Sub login() Dim myconnect As New SqlClient.SqlConnection myconnect.ConnectionString = ("Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Enrollment\BTA.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True") Dim mycommand As SqlClient.SqlCommand = New SqlClient.SqlCommand() mycommand.Connection = myconnect mycommand.CommandText = "INSERT INTO DTR (Emp_Id, Emp_Name, Position, Department, Date, TimeIn, TotalNoHours) VALUES (@Emp_Id,@Emp_Name,@Position,@Department,@Date,@TimeIn,@TotalNoHours)" Try myconnect.Open() mycommand.Parameters.AddWithValue("@Emp_Id", SqlDbType.VarChar).Value = lblID.Text mycommand.Parameters.AddWithValue("@Emp_Name", SqlDbType.VarChar).Value = emp_n.Text mycommand.Parameters.AddWithValue("@Department", SqlDbType.VarChar).Value = Dpt.Text mycommand.Parameters.AddWithValue("@Position", SqlDbType.VarChar).Value = Pos.Text mycommand.Parameters.AddWithValue("@Date", SqlDbType.VarChar).Value = Date.Today mycommand.Parameters.AddWithValue("@TimeIn", SqlDbType.VarChar).Value = TimeOfDay.ToString("HH:mm:ss tt") mycommand.Parameters.AddWithValue("@TotalNoHours", SqlDbType.VarChar).Value = lblTotal.Text mycommand.ExecuteNonQuery() Catch ex As System.Data.SqlClient.SqlException MsgBox(ex.Message) End Try myconnect.Close() End Sub Public Sub logout() Dim myconnect As New SqlClient.SqlConnection myconnect.ConnectionString = ("Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Enrollment\BTA.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True") Dim mycommand As SqlClient.SqlCommand = New SqlClient.SqlCommand() mycommand.Connection = myconnect mycommand.CommandText = "UPDATE DTR Set Date=@Date, TimeOut=@TimeOut,Emp_Id=@Emp_Id WHERE (Emp_Id= @Emp_Id AND Date=@Date)" Try myconnect.Open() mycommand.Parameters.AddWithValue("@Emp_Id", SqlDbType.VarChar).Value = lblID.Text mycommand.Parameters.AddWithValue("@Date", SqlDbType.VarChar).Value = Date.Today mycommand.Parameters.AddWithValue("@TimeOut", SqlDbType.VarChar).Value = TimeOfDay.ToString("HH:mm:ss tt") mycommand.ExecuteNonQuery() Catch ex As System.Data.SqlClient.SqlException MsgBox(ex.Message) End Try myconnect.Close() End Sub Public Sub limit() MsgBox("You already complete your attendance!") End Sub Private Sub refreshdata() Try Dim cn As New SqlConnection(ConnectString()) cn.Open() Dim query As String query = "SELECT * FROM DTR" Dim sqlcommand As SqlCommand = New SqlCommand Dim da As New SqlDataAdapter Dim dt As New DataTable sqlcommand = New SqlCommand(query, cn) da.SelectCommand = sqlcommand da.Fill(dt) DGV.DataSource = dt da.Update(dt) cn.Close() cn.Dispose() Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub End Class
Что я уже пробовал:
- Я пробовал это время от времени.
for each row as datagridiviewrow in dgv.rows 'time in if row.cells(1).value = nothing Call login() Else 'timeout if row.Cells(2).Value = Nothing Then Call logout() end if
Wendelius
Не могли бы Вы уточнить, в чем именно заключается этот вопрос?
Fitz Patrick Yanes
извините за мой плохой английский. Мой вопрос заключается в том, Можете ли вы помочь мне с тайм-аут и тайм-аут, используя данные отпечатков пальцев с помощью vb.net-что? спасибо что ответили на мой вопрос
Patrice T
опишите пронлем
Fitz Patrick Yanes
это мой первый раз, когда я разрабатываю систему учета рабочего времени с отпечатками пальцев. То, что я сделал на данный момент, захватывает отпечаток пальца, проверку и сохранение. Теперь я попробовал код, который я только что опубликовал для получения отпечатков пальцев одновременно время от времени.