Reporte de puntos de interes

This commit is contained in:
2021-02-10 12:53:42 -07:00
parent 2e6d6ee9d3
commit 1d87768d86
2 changed files with 471 additions and 47 deletions

View File

@@ -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($"<div>")
SBBody.Append($"<div><h5><b> Punto: {row.DataKey("PuntoDeInteres")}</b></h5></div>")
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($"<div>")
SBBody.Append($"<div><h5><b> Punto: {row.DataKey("PuntoDeInteres")}</b></h5></div>")
If ObjGPS.DtResultados.Rows.Count > 0 Then
Color = "#26C281"
SBBody.Append($"<div><table>")
For Each Cve As String In DispositivosLista
If ObjGPS.DtResultados.FiltraParametros($"CveDispositivo = {Cve} ").Rows.Count > 0 Then
SBBody.Append($"<tr><td><b>{ObjGPS.DtResultados.FiltroPrimeroValor("Vehiculo", $"CveDispositivo = {Cve}")}:</b> <a onclick=""CargaGV({Cve}, {row.DataKey("CvePuntoDeInteres")} )"">{ObjGPS.DtResultados.FiltroPrimeroValor("Visitas", $"CveDispositivo = {Cve}")} visitas<a></td></tr>")
SBBody.Append($"<tr><td>Última Visita: {ObjGPS.DtResultados.FiltroPrimeroValor("UltimaVisita", $"CveDispositivo = {Cve}")}</td></tr>")
End If
Next
SBBody.Append($"</table></div>")
Else
Color = "#e82929"
SBBody.Append($"<tr><td><b>Este punto de interés no fue visitado en las fechas seleccionadas.</b></td></tr>")
End If
SBBody.Append($"</div>")
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($"<div><table>")
For Each Cve As String In DispositivosLista
If GPS.DtResultados.FiltraParametros($"CveDispositivo = {Cve} ").Rows.Count > 0 Then
SBBody.Append($"<tr><td><b>{GPS.DtResultados.FiltroPrimeroValor("Vehiculo", $"CveDispositivo = {Cve}")}:</b> <a onclick=""CargaGV({Cve}, {row.DataKey("CvePuntoDeInteres")} )"">{GPS.DtResultados.FiltroPrimeroValor("Visitas", $"CveDispositivo = {Cve}")} visitas<a></td></tr>")
SBBody.Append($"<tr><td>Última Visita: {GPS.DtResultados.FiltroPrimeroValor("UltimaVisita", $"CveDispositivo = {Cve}")}</td></tr>")
End If
Next
SBBody.Append($"</table></div>")
Else
Color = "#e82929"
SBBody.Append($"<tr><td><b>Este punto de interés no fue visitado en las fechas seleccionadas.</b></td></tr>")
End If
SBBody.Append($"</div>")
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