From 1d87768d8618d11cf99c64a9956940d55274acd5 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Wed, 10 Feb 2021 12:53:42 -0700 Subject: [PATCH] Reporte de puntos de interes --- GPS/RepPuntosDeInteres.aspx | 374 ++++++++++++++++++++++++++++++++- GPS/RepPuntosDeInteres.aspx.vb | 144 +++++++++---- 2 files changed, 471 insertions(+), 47 deletions(-) diff --git a/GPS/RepPuntosDeInteres.aspx b/GPS/RepPuntosDeInteres.aspx index 5aed250b6..adbe38c9f 100644 --- a/GPS/RepPuntosDeInteres.aspx +++ b/GPS/RepPuntosDeInteres.aspx @@ -3,6 +3,7 @@ + @@ -66,8 +199,11 @@ + + + - + @@ -83,8 +219,11 @@ + + + - + @@ -148,6 +287,43 @@ + +
  • @@ -158,18 +334,36 @@ - + + + diff --git a/GPS/RepPuntosDeInteres.aspx.vb b/GPS/RepPuntosDeInteres.aspx.vb index 0886eacb8..3b818619e 100644 --- a/GPS/RepPuntosDeInteres.aspx.vb +++ b/GPS/RepPuntosDeInteres.aspx.vb @@ -2,9 +2,11 @@ Imports Extensiones Imports System.Data +Imports Microsoft.Reporting.WebForms + Partial Class GPS_RepPuntosDeInteres - Inherits ClsPaginas - + Inherits ClsPaginas + #Region "P R O P I E D A D E S " Private Property DispositivosLista As List(Of String) Get @@ -13,29 +15,34 @@ Partial Class GPS_RepPuntosDeInteres Set(value As List(Of String)) ViewState("DispositivosLista") = value End Set - End Property + End Property + Private Property DtDatosReporte As DataTable + Get + Return If(IsNothing(ViewState("DtDatosReporte")), Nothing, CType(ViewState("DtDatosReporte"), DataTable)) + End Get + Set(value As DataTable) + ViewState("DtDatosReporte") = value + End Set + End Property #End Region - + Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load If Not Page.IsPostBack Then CargaDatos() End If End Sub Private Sub CargaDatos() + txtFechaF.Text = Now.ToString("dd/MM/yyyy") + txtFechaI.Text = Now.AddDays(-7).ToString("dd/MM/yyyy") + CargaDispositivos() - Dim gps As New ClsGPS - 'If gps.PuntoDeInteresGrupoGet(-1, 1) Then - ' GvGrupos.DataSource = gps.DtResultados - 'Else - ' GvGrupos.DataSource = Nothing - 'End If - If gps.PuntoDeInteresGet(-1, UsuarioActual.CveCliente, 1, -1) Then - GvPuntos.DataSource = gps.DtResultados + Dim ObjGPS As New ClsGPS + If ObjGPS.PuntoDeInteresGet(-1, UsuarioActual.CveCliente, 1, -1) Then + GvPuntos.DataSource = ObjGPS.DtResultados Else GvPuntos.DataSource = Nothing End If - gps.Dispose() - 'GvGrupos.DataBind() + ObjGPS.Dispose() GvPuntos.DataBind() End Sub @@ -58,8 +65,8 @@ Partial Class GPS_RepPuntosDeInteres RegistraScript("$('#dvConsulta').modal('hide');", "00") End Sub - Private Sub ReportePuntos(Dispositivos As String) - Dim GPS As New ClsGPS + Private Sub ReportePuntos(Dispositivos As String) + Dim FechaI, FechaF As Date Dim SBBody As New StringBuilder Dim CoordsPoligono = "" @@ -70,35 +77,48 @@ Partial Class GPS_RepPuntosDeInteres Dim GeoCercas = "" Dim Color = "" FechaI = If(txtFechaI.Text.Trim = "", MinFecha, txtFechaI.Text.Trim.ToDate) - FechaF = If(txtFechaF.Text.Trim = "", MaxFecha, txtFechaF.Text.Trim.ToDate) - For Each row As GridViewRow In GvPuntos.Rows - SBBody.Clear() - If row.FCCheckBox("chkGR").Checked Then - If GPS.RepPuntosGet(row.DataKey("CvePuntoDeInteres").ToEntero, Dispositivos, txtFechaI.Text.ToDateTime, txtFechaF.Text.ToDateTime, UsuarioActual.CveCliente) Then - Coords = SQLToGmaps(row.DataKey("Punto").ToString, "POINT") - SBBody.Append($"
    ") - SBBody.Append($"
    Punto: {row.DataKey("PuntoDeInteres")}
    ") + FechaF = If(txtFechaF.Text.Trim = "", MaxFecha, txtFechaF.Text.Trim.ToDate) + + Dim ObjGPS As New ClsGPS + Try + For Each row As GridViewRow In GvPuntos.Rows + SBBody.Clear() + If row.FCCheckBox("chkGR").Checked Then + If ObjGPS.RepPuntosGet(row.DataKey("CvePuntoDeInteres").ToEntero, Dispositivos, txtFechaI.Text.ToDateTime, txtFechaF.Text.ToDateTime, UsuarioActual.CveCliente) Then + + DtDatosReporte = ObjGPS.DtResultados.Copy() + GvBarra.DataSource = DtDatosReporte + + Coords = SQLToGmaps(row.DataKey("Punto").ToString, "POINT") + SBBody.Append($"
    ") + SBBody.Append($"
    Punto: {row.DataKey("PuntoDeInteres")}
    ") + + If ObjGPS.DtResultados.Rows.Count > 0 Then + Color = "#26C281" + SBBody.Append($"
    ") + For Each Cve As String In DispositivosLista + If ObjGPS.DtResultados.FiltraParametros($"CveDispositivo = {Cve} ").Rows.Count > 0 Then + SBBody.Append($"") + SBBody.Append($"") + End If + Next + SBBody.Append($"
    {ObjGPS.DtResultados.FiltroPrimeroValor("Vehiculo", $"CveDispositivo = {Cve}")}: {ObjGPS.DtResultados.FiltroPrimeroValor("Visitas", $"CveDispositivo = {Cve}")} visitas
    Última Visita: {ObjGPS.DtResultados.FiltroPrimeroValor("UltimaVisita", $"CveDispositivo = {Cve}")}
    ") + Else + Color = "#e82929" + SBBody.Append($"Este punto de interés no fue visitado en las fechas seleccionadas.") + End If + SBBody.Append($"
    ") + RegistraScript($"CreaCirculo({Coords},'{Color}');CreaMarcador({Coords},'{row.DataKey("PuntoDeInteres")}','{SBBody.ToString}');", row.DataKey("CvePuntoDeInteres")) + End If + End If + Next + Catch ex As Exception + OnError("Ocurrió un error al consultar los puntos de interes", ex) + End Try - If GPS.DtResultados.Rows.Count > 0 Then - Color = "#26C281" - SBBody.Append($"
    ") - For Each Cve As String In DispositivosLista - If GPS.DtResultados.FiltraParametros($"CveDispositivo = {Cve} ").Rows.Count > 0 Then - SBBody.Append($"") - SBBody.Append($"") - End If - Next - SBBody.Append($"
    {GPS.DtResultados.FiltroPrimeroValor("Vehiculo", $"CveDispositivo = {Cve}")}: {GPS.DtResultados.FiltroPrimeroValor("Visitas", $"CveDispositivo = {Cve}")} visitas
    Última Visita: {GPS.DtResultados.FiltroPrimeroValor("UltimaVisita", $"CveDispositivo = {Cve}")}
    ") - Else - Color = "#e82929" - SBBody.Append($"Este punto de interés no fue visitado en las fechas seleccionadas.") - End If - SBBody.Append($"
    ") - RegistraScript($"CreaCirculo({Coords},'{Color}');CreaMarcador({Coords},'{row.DataKey("PuntoDeInteres")}','{SBBody.ToString}');", row.DataKey("CvePuntoDeInteres")) - End If - End If - Next - GPS.Dispose() + ObjGPS.Dispose() + GvBarra.DataBind() + UPGV.Update() End Sub 'If GPS.GeoReferenciasEntradasSalidas(GVRow.DataKey("CveDispositivo").ToString.ToEntero, row.DataKey("CveGeoReferencia").ToString.ToEntero, FechaI, FechaF) Then @@ -152,5 +172,41 @@ Partial Class GPS_RepPuntosDeInteres GVHistorico.DataBind() UpdatePanel3.Update() RegistraScript("$('#dvHistorico').modal()") + End Sub + + 'Protected Sub GvBarra_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvBarra.RowDataBound + ' If e.Row.RowType = DataControlRowType.DataRow Then + ' Dim RowID As String = $"row{e.Row.RowIndex}" + ' e.Row.Attributes("id") = RowID + ' Dim IndexGvBarra As Integer = If(String.IsNullOrEmpty(HdnIndexGvBarra.Value), -1, HdnIndexGvBarra.Value.ToEntero) + + ' RegistraScript($"GetDireccionesGV({e.Row.DBCampo("Posicion").ToString}, {e.Row.RowIndex}, 1);", $"{RowID}") + + ' End If + 'End Sub + + Protected Sub btnImprimir_Click(sender As Object, e As EventArgs) + Dim Btn As Button = CType(sender, Button) + Dim Format = Btn.CommandArgument + EnviarReporteProgramado(Format) + + End Sub + Public Sub EnviarReporteProgramado(Format As String) + Dim RutaReporte = "Empresas/Grales/ReportesProgramados/RPTPuntosInteres.rdlc" + Dim NombreReporte = "ReportePuntosInteres" + + Try + Dim RptParametro As New List(Of ReportParameter) + RptParametro.Add(New ReportParameter("FechaInicio", txtFechaI.Text)) + RptParametro.Add(New ReportParameter("FechaFin", txtFechaF.Text)) + RptParametro.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Usuario)) + RptParametro.Add(New ReportParameter("FechaImpresion", DateTime.Now.ToShortDateString)) + + Dim retorno = StreamPDF(RutaReporte, DtDatosReporte, RptParametro, $"{NombreReporte}{Date.Now.ToShortDateString}", Format, MR:=Nothing, RDSName:="DsOC") + + ImprimirbytesPDF(retorno, $"{NombreReporte}{Date.Now.ToShortDateString}", Format) + Catch ex As Exception + GuardaLog(String.Format("Ocurrio un error al generar el reporte RLDC {0}", ex)) + End Try End Sub End Class