+
+
+
-
-
-
+
+
+
+
diff --git a/GPS/RepGeoReferencias.aspx.vb b/GPS/RepGeoReferencias.aspx.vb
index b322bcf74..3c4c9a164 100644
--- a/GPS/RepGeoReferencias.aspx.vb
+++ b/GPS/RepGeoReferencias.aspx.vb
@@ -12,6 +12,14 @@ Partial Class GPS_RepGeoReferencias
Set(value As Integer)
ViewState("CveGeoReferencia") = value
End Set
+ End Property
+ Private Property DtGeoReferencias As DataTable
+ Get
+ Return CType(ViewState("DtGeoReferencias"), DataTable)
+ End Get
+ Set(value As DataTable)
+ ViewState("DtGeoReferencias") = value
+ End Set
End Property
Private Property DtPosiciones As DataTable
Get
@@ -49,13 +57,27 @@ Partial Class GPS_RepGeoReferencias
Private Sub CargaGeoReferencias()
Dim Estatus = If(ChkEstatusGeocerca.Checked, 1, 0)
- Dim GPS As New ClsGPS
- If GPS.GeoReferenciaGet(-1, Estatus, "-1", UsuarioActual.CveCliente) Then
- GVGeoreferencias.DataSource = GPS.DtResultados
- Else
- GVGeoreferencias.DataSource = Nothing
+
+ Using GPS As New ClsGPS
+ If GPS.GeoReferenciaGet(-1, Estatus, "-1", UsuarioActual.CveCliente) Then
+ DtGeoReferencias = GPS.DtResultados.Copy()
+ End If
+ End Using
+
+ If DtGeoReferencias IsNot Nothing Then
+ Dim TotalRegistros As Integer = DtGeoReferencias.Rows.Count
+ Dim TotalRowsPage As Integer = GVGeoreferencias.PageSize
+ If TotalRegistros > TotalRowsPage Then
+ GVGeoreferencias.DataSource = DtGeoReferencias.FiltraPorIndices(0, TotalRowsPage - 1)
+ DivPaginacion.Visible = True
+ LblRegistros.Text = $"Distribución de datos desde 0 hasta {TotalRowsPage.ToString().ToDecimal().FormatoNumero(0)}. Total de registros: {TotalRegistros.ToString().ToDecimal().FormatoNumero(0)}"
+ Else
+ GVGeoreferencias.DataSource = DtGeoReferencias
+ End If
+ Else
+ GVGeoreferencias.DataSource = DtGeoReferencias
End If
- GPS.Dispose()
+
GVGeoreferencias.DataBind()
End Sub
Private Sub CargaDispositivos()
@@ -190,16 +212,11 @@ Partial Class GPS_RepGeoReferencias
TxtHoraF.Text = GvRow.DataKey("HoraFin").ToString.ToDateTime.ToString("HH:mm")
Using ObjGPS As New ClsGPS
- If ObjGPS.GetReferenciaDetalle(-1, CveGeoReferencia, -1, UsuarioActual.CveCliente) Then
- If ObjGPS.DtResultados.Rows.Count > 0 Then
- DtDetalle = ObjGPS.DtResultados
- GvEquiposDetalle.DataSource = DtDetalle
- Else
- DtDetalle = Nothing
- DtDetalleEliminar = Nothing
- GvEquiposDetalle.DataSource = Nothing
- End If
-
+ If ObjGPS.GetReferenciaDetalle(-1, CveGeoReferencia, -1, UsuarioActual.CveCliente) Then
+ DtDetalle = ObjGPS.DtResultados.Copy()
+ DtDetalleEliminar = ObjGPS.DtResultados.Copy()
+
+ GvEquiposDetalle.DataSource = DtDetalle
End If
End Using
GvEquiposDetalle.DataBind()
@@ -239,27 +256,22 @@ Partial Class GPS_RepGeoReferencias
Dim HoraF As Date = ($"{Date.Now.ToString("dd/MM/yyyy")} {TxtHoraF.Text}").ToDate
If ObjGPS.GeoReferenciaUpdate(CveGeoReferencia, TxtNombre.Text, -1, chkEstatus.Checked, txtFechaI.Text.ToDate, txtFechaF.Text.ToDate, chkLunes.Checked, chkMartes.Checked, chkMiercoles.Checked, chkJueves.Checked, chkViernes.Checked,
- chkSabado.Checked, chkDomingo.Checked, HoraI, HoraF, TxtTolerancia.Text.ToEntero, UsuarioActual.CveCliente) Then
-
- For Each Dr As DataRow In DtDetalle.Rows
- Dim CveGeoReferenciaDetalle = Dr("CveDispositivoGeoreferenciaDetalle").ToString.ToEntero
- If CveGeoReferenciaDetalle > 0 Then
- If Not ObjGPS.UpdateReferenciaDetalle(CveGeoReferenciaDetalle, CveGeoReferencia, Dr("CveDispositivo").ToString.ToEntero) Then
- TieneError = True
- Exit For
- End If
- Else
- If Not ObjGPS.AddGeoReferenciaDetalle(CveGeoReferencia, Dr("CveDispositivo").ToString.ToEntero) Then
- TieneError = True
- Exit For
- End If
- End If
- Next
+ chkSabado.Checked, chkDomingo.Checked, HoraI, HoraF, TxtTolerancia.Text.ToEntero, UsuarioActual.CveCliente) Then
If Not TieneError Then
For Each DrE As DataRow In DtDetalleEliminar.Rows
- TieneError = Not ObjGPS.RemoveferenciaDetalle(DrE("CveDispositivoGeoreferenciaDetalle").ToString.ToEntero)
+ If DrE("CveDispositivoGeoreferenciaDetalle").ToString.ToEntero > 0 Then
+ TieneError = Not ObjGPS.RemoveferenciaDetalle(DrE("CveDispositivoGeoreferenciaDetalle").ToString.ToEntero)
+ End If
Next
End If
+
+ For Each Dr As DataRow In DtDetalle.Rows
+ If Not ObjGPS.AddGeoReferenciaDetalle(CveGeoReferencia, Dr("CveDispositivo").ToString.ToEntero) Then
+ TieneError = True
+ Exit For
+ End If
+ Next
+
Else
TieneError = True
End If
@@ -336,14 +348,15 @@ Partial Class GPS_RepGeoReferencias
Dim Dr As DataRow = DtDetalle.Rows(e.RowIndex)
Dim CveGeoReferenciaDetalle = Dr("CveDispositivoGeoreferenciaDetalle").ToString.ToEntero
If CveGeoReferenciaDetalle > 0 Then
-
- Dim DrEliminar = DtDetalleEliminar.NewRow
- DrEliminar("CveDispositivoGeoreferenciaDetalle") = CveGeoReferenciaDetalle
- DrEliminar("CveDispositivo") = Dr("CveDispositivo").ToString.ToEntero
- DrEliminar("NoEconomico") = Dr("NoEconomico").ToString
- DtDetalleEliminar.Rows.Add(DrEliminar)
- DtDetalleEliminar.AcceptChanges()
-
+ If DtDetalleEliminar.COUNT("CveDispositivo", $"CveDispositivoGeoreferenciaDetalle={CveGeoReferenciaDetalle}") <= 0 Then
+ Dim DrEliminar = DtDetalleEliminar.NewRow
+ DrEliminar("CveDispositivoGeoreferenciaDetalle") = CveGeoReferenciaDetalle
+ DrEliminar("CveDispositivo") = Dr("CveDispositivo").ToString.ToEntero
+ DrEliminar("NoEconomico") = Dr("NoEconomico").ToString
+ DtDetalleEliminar.Rows.Add(DrEliminar)
+ DtDetalleEliminar.AcceptChanges()
+ End If
+
End If
DtDetalle.Rows.RemoveAt(e.RowIndex)
@@ -415,5 +428,63 @@ Partial Class GPS_RepGeoReferencias
Protected Sub ChkEstatusGeocerca_CheckedChanged(sender As Object, e As EventArgs)
CargaGeoReferencias()
+ End Sub
+
+ Protected Sub btnPagePrev_Click(sender As Object, e As EventArgs)
+ Dim TotalRegistros As Integer = DtGeoReferencias.Rows.Count
+ Dim TotalRowsPage As Integer = GVGeoreferencias.PageSize
+ Dim PrevIndex As Integer = HdnIndexPage.Value.ToEntero - 1
+ Dim CurrentIndex As Integer = PrevIndex + 1
+
+ Dim PrevIndexDT As Integer = (TotalRowsPage) * PrevIndex
+ Dim CurrentIndexDT As Integer = (TotalRowsPage) * CurrentIndex
+
+ HdnIndexPage.Value = PrevIndex.ToString
+
+ If Not btnPageNext.Enabled Then
+ btnPageNext.Enabled = True
+ End If
+
+ If PrevIndexDT <= 0 Then
+ btnPagePrev.Enabled = False
+ GVGeoreferencias.DataSource = DtGeoReferencias.FiltraPorIndices(0, CurrentIndexDT)
+ LblRegistros.Text = $"Distribución de datos desde 0 hasta {CurrentIndexDT.ToString.FormatoNumero(0)}. Total de registros: {DtGeoReferencias.Rows.Count.ToString.FormatoNumero(0)}"
+ Else
+ LblRegistros.Text = $"Distribución de datos desde {PrevIndexDT.ToString.FormatoNumero(0)} hasta {CurrentIndexDT.ToString.FormatoNumero(0)}. Total de registros: {DtGeoReferencias.Rows.Count.ToString.FormatoNumero(0)}"
+ GVGeoreferencias.DataSource = DtGeoReferencias.FiltraPorIndices(PrevIndexDT, CurrentIndexDT)
+ End If
+
+ GVGeoreferencias.DataBind()
+ UPGV.Update()
+
+ End Sub
+
+ Protected Sub btnPageNext_Click(sender As Object, e As EventArgs)
+ Dim TotalRegistros As Integer = DtGeoReferencias.Rows.Count
+ Dim TotalRowsPage As Integer = GVGeoreferencias.PageSize
+ Dim Index As Integer = HdnIndexPage.Value.ToEntero + 1
+ Dim NextIndex As Integer = Index + 1
+
+ Dim CurrentIndexDT As Integer = (TotalRowsPage) * Index
+ Dim NextIndexDT As Integer = (TotalRowsPage) * NextIndex
+
+ HdnIndexPage.Value = Index.ToString
+
+ If Not btnPagePrev.Enabled Then
+ btnPagePrev.Enabled = True
+ End If
+
+ If NextIndexDT >= TotalRegistros Then
+ btnPageNext.Enabled = False
+ GVGeoreferencias.DataSource = DtGeoReferencias.FiltraPorIndices(CurrentIndexDT, TotalRegistros - 1)
+ LblRegistros.Text = $"Distribución de datos desde {CurrentIndexDT.ToString.FormatoNumero(0)} hasta {DtGeoReferencias.Rows.Count.ToString.FormatoNumero(0)}. Total de registros: {DtGeoReferencias.Rows.Count.ToString.FormatoNumero(0)}"
+ Else
+ GVGeoreferencias.DataSource = DtGeoReferencias.FiltraPorIndices(CurrentIndexDT, NextIndexDT)
+ LblRegistros.Text = $"Distribución de datos desde {CurrentIndexDT.ToString.FormatoNumero(0)} hasta {NextIndexDT.ToString.FormatoNumero(0)}. Total de registros: {DtGeoReferencias.Rows.Count.ToString.FormatoNumero(0)}"
+ End If
+
+ GVGeoreferencias.DataBind()
+ UPGV.Update()
+
End Sub
End Class