Partial Public Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Conexion.State = ConnectionState.Closed And Conexion.State = ConnectionState.Closed Then
            Conexion.ConnectionString = cadena
            Conexion.Open()
            con2.ConnectionString = con
            con2.Open()
        End If
    End Sub

    Protected Sub btnAceptar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAceptar.Click
        Dim rs As New ADODB.Recordset
        Dim strquery As String
        Dim bandera As Integer
        strquery = "Select * from conductor"
        bandera = 0

        If txtid.Text <> "" Then
            rs.Open(strquery, con2)
            While rs.EOF = False And bandera = 0
                If rs("Clave").Value = Val(txtid.Text) Then
                    bandera = 1
                End If
                rs.MoveNext()
            End While
            If bandera = 0 Then
                MsgBox("No existe Programación Activa para su ID, Intente de Nuevo", MsgBoxStyle.Critical, "Error de ID")
                txtid.Text = ""
            Else

                ID = Val(txtid.Text)
                fecha1 = Calendar1.SelectedDate
                fecha1 = FormatDateTime(fecha1, DateFormat.ShortDate)
                Dim query As String = "select * from [$hoja1] where  Fecha like '%" & fecha1 & "%' and clave=" & ID & " "
                Dim com As New OleDb.OleDbCommand(query, Conexion)
                com.ExecuteNonQuery()
                Dim ds As New DataSet
                Dim da As New OleDb.OleDbDataAdapter(com)
                da.Fill(ds)
                GridView1.DataSource = ds
                GridView1.DataBind()



            End If
        Else
            MsgBox("Favor de Ingresar su Id", MsgBoxStyle.Critical, "Falta Id de Operador")

        End If


    End Sub

    Protected Sub Calendar1_SelectionChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Calendar1.SelectionChanged

    End Sub
End Class