Imports System.Data.SqlClient
Imports System.Data

Partial Class ETOZ_BuscarCarnet
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
        If Not IsPostBack Then
            btnInsertar.Visible = False
            panelResultado.Visible = False
        End If
    End Sub

    Protected Sub btnBuscarCarnet_Click(sender As Object, e As EventArgs)
        If txtCarnet.Text.Trim = "" Then
            btnInsertar.Visible = False
            panelResultado.Visible = False
            Exit Sub
        End If
        Dim dr As DataRow = RepVacunacion.ObtenerDatosVacunaPorCarnet(txtCarnet.Text.Trim)
        If dr IsNot Nothing Then
            txtNombreAnimal.Text = dr("NombreAnimal").ToString()
            txtEspecie.Text = dr("Especie").ToString()
            txtRaza.Text = dr("Raza").ToString()

            panelResultado.Visible = True
            btnInsertar.Visible = True   ' 👈 SOLO aquí se muestra
        Else
            panelResultado.Visible = False
            btnInsertar.Visible = False
        End If
    End Sub

    Protected Sub btnInsertar_Click(sender As Object, e As EventArgs)

        Dim carnet As String = txtCarnet.Text.Trim()

        If carnet = "" Then Exit Sub

        Dim script As String = "window.parent.CargarCarnetDesdePopup('" & carnet & "'); GetRadWindow().close();"

        ScriptManager.RegisterStartupScript(Me, Me.GetType(), "Cerrar", script, True)
    End Sub

End Class