Option Explicit On Option Strict On Imports System.Data Imports Extensiones Partial Class ZDG_CapturaManual Inherits ClsPaginas #Region " PROPIEDADES " Private Property TempDT As DataTable Get TempDT = CType(ViewState("TempDT"), DataTable) End Get Set(value As DataTable) ViewState("TempDT") = value End Set End Property #End Region Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not IsPostBack Then CreaDT() End If End Sub Private Sub CreaDT() TempDT = New DataTable TempDT.Columns.Add("Consecutivo", GetType(Integer)) TempDT.Columns.Add("Hora", GetType(DateTime)) TempDT.Columns.Add("Resultado", GetType(Boolean)) End Sub Protected Sub BtnRegistrarVoto_Click(sender As Object, e As EventArgs) Dim ObjDG As New ClsDG Dim Dr = TempDT.NewRow Dr("Consecutivo") = TxtConsecutivo.Text.ToEntero Dr("Hora") = DateTime.Now Dr("Resultado") = False If ObjDG.RegistrarVoto(TxtConsecutivo.Text.ToEntero) Then If ObjDG.RegistrosAfectados = 1 Then Dr("Resultado") = True End If ObjDG.Dispose() TempDT.Rows.Add(Dr) TempDT.AcceptChanges() If TempDT.Rows.Count > 20 Then TempDT.Rows.RemoveAt(0) End If CargaRegistros() Else ObjDG.Dispose() Alert("Ocurrió un error al registar el voto. Por favor vuelva a intentar.", TipoMensaje.MsgError) End If TxtConsecutivo.Text = "" TxtConsecutivo.Focus() End Sub #Region " GV DATOS " Private Sub CargaRegistros() GvDatos.DataSource = TempDT.FiltraParametros("", "Hora DESC") GvDatos.DataBind() UPDatos.Update() End Sub Protected Sub GvDatos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvDatos.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then If e.Row.DBCampo("Resultado") = "True" Then e.Row.Cells(0).ForeColor = Drawing.Color.Green Else e.Row.Cells(0).ForeColor = Drawing.Color.Red End If End If End Sub #End Region End Class