0% found this document useful (0 votes)
52 views2 pages

Comunicación Usb: ' Variables Paraúsb

This document describes a USB communication class in Visual Basic for an employee attendance tracking system. It includes variables and methods for connecting to a SQL database, retrieving employee data, registering employee check-in and check-out times, and displaying the attendance records on a datagrid. On check-in, it inserts the employee name, date and time into the database table. On check-out, it updates the employee's checkout time field. It also includes methods for selecting the employee from a dropdown, displaying the current time, and refreshing the datagrid view of records.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views2 pages

Comunicación Usb: ' Variables Paraúsb

This document describes a USB communication class in Visual Basic for an employee attendance tracking system. It includes variables and methods for connecting to a SQL database, retrieving employee data, registering employee check-in and check-out times, and displaying the attendance records on a datagrid. On check-in, it inserts the employee name, date and time into the database table. On check-out, it updates the employee's checkout time field. It also includes methods for selecting the employee from a dropdown, displaying the current time, and refreshing the datagrid view of records.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

COMUNICACIN USB

Imports System.Data.Sql Public Class frmControlAsistencia Dim enviar As String Dim diaEntrada As Integer ' variables parasb Private Const VendorID As Short = 6017 Private Const ProductID As Short = 2009 Private Const BufferInSize As Short = 8 Private Const BufferOutSize As Short = 8 Dim BufferIn(0 To BufferInSize) As Byte Dim BufferOut(0 To BufferOutSize) As Byte Dim Prom_Tem As Double Dim n As Integer = 0 Dim Time As Integer = 0 'conexion con sql Dim cn As New SqlClient.SqlConnection("Data Source=Thoshiba-\SQLeXPRESS;Initial Catalog=DatosOB;Integrated Security=true") Private Sub frmControlAsistencia_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Timer1.Enabled = True Dim MiDataSet As New DataSet() cn.Open() Dim comando As New SqlClient.SqlDataAdapter("SELECT* FROM funcionario", cn) comando.Fill(MiDataSet, "USUARIO") Dim row cboUsuario.Items.Clear() For Each row In MiDataSet.Tables(0).Rows cboUsuario.Items.Add(row(0).ToString()) Next cn.Close() Dim fecha As Date fecha = Now diaEntrada = DatePart(DateInterval.Day, fecha) End Sub Private Sub rbtnEncender_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbtnEncender.CheckedChanged End Sub Private Sub rbtnApagar_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbtnApagar.CheckedChanged End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick BufferOut(2) = 23 'WriteSomeData()

txtRecibe.Text = cboUsuario.Text txtRecibe.Text = enviar lblHora.Text = TimeOfDay() Dim dtFecha As DateTime dtFecha = dtFecha.ToString("dd-MMMM-yyyy") End Sub Private Sub btnRegistrarEntrada_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRegistrarEntrada.Click Dim cmd As New SqlClient.SqlCommand("insert into controlAsistencia values('" & enviar & "','" &fecha.Value.ToString& "','" & fecha.Value.ToString & "')", cn) cn.Open() cmd.ExecuteNonQuery() MsgBox("Bienvenido,se registro su asistencia") cn.Close() Mostrar() End Sub Private Sub btnRegistrarSalida_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRegistrarSalida.Click Dim fecha1 As Date Dim diaSalida As Integer fecha1 = Now() diaSalida = DatePart(DateInterval.Day, fecha1) If (diaSalida = diaEntrada) Then Dim dr As SqlClient.SqlDataReader Dim cmd As New SqlClient.SqlCommand("update controlAsistencia SET HoraSalida='"&fecha.Value.ToString&"' where codigo = '"&enviar&"'",cn) cn.Open() dr = cmd.ExecuteReader() If (cboUsuario.Text = enviar) Then MsgBox("Hasta pronto,se registro su salida") End If dr.Close() cn.Close() Mostrar() Else MsgBox("No se registro su salida,no registro su ingreso") End If End Sub Sub Mostrar() Dim rs As New SqlClient.SqlDataAdapter("SELECT codigoC As CODIGO,HoraIngreso as [HORA DE INGRESO],HoraSalida as[HORA DE SALIDA]FROM controlAsistencia", cn) cn.Open() Dim rs1 As New DataSet rs.Fill(rs1, "controlAsistencia") DataGridView1.DataSource = rs1 DataGridView1.DataMember = "controlAsistencia" cn.Close() End Sub Private Sub cboUsuario_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboUsuario.SelectedIndexChanged enviar = cboUsuario.Text txtRecibe.Text = enviar End Sub Private Sub btnSalir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSalir.Click Me.Close() End Sub End Class

You might also like