Commit inicial Ventas Productivo
This commit is contained in:
245
GPS/Conductores.aspx.vb
Normal file
245
GPS/Conductores.aspx.vb
Normal file
@@ -0,0 +1,245 @@
|
||||
Option Strict On
|
||||
Option Explicit On
|
||||
|
||||
Imports Extensiones
|
||||
Imports System.Data
|
||||
Imports Newtonsoft.Json.Linq
|
||||
Partial Class GPS_Conductores
|
||||
Inherits ClsPaginas
|
||||
|
||||
#Region "Propiedades"
|
||||
Public Property CveConductor As Integer
|
||||
Get
|
||||
Return ViewState("CveConductor").ToString.ToEntero
|
||||
End Get
|
||||
Set(value As Integer)
|
||||
ViewState("CveConductor") = value
|
||||
End Set
|
||||
End Property
|
||||
Public Property CveDispositivo As Integer
|
||||
Get
|
||||
Return ViewState("CveDispositivo").ToString.ToEntero
|
||||
End Get
|
||||
Set(value As Integer)
|
||||
ViewState("CveDispositivo") = 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
|
||||
CargaFechas()
|
||||
If Request("CveConductor") IsNot Nothing AndAlso Request("CveConductor").ToString.ToEntero > 0 Then
|
||||
CveConductor = Request("CveConductor").ToString.ToEntero
|
||||
CargaPonderacion()
|
||||
CargaGraficas()
|
||||
CargaConductor(CveConductor)
|
||||
UpDatos.Update()
|
||||
CargaMapa()
|
||||
End If
|
||||
If Request("CveDispositivo") IsNot Nothing AndAlso Request("CveDispositivo").ToString.ToEntero > 0 Then
|
||||
CveDispositivo = Request("CveDispositivo").ToString.ToEntero
|
||||
CveConductor = -1
|
||||
|
||||
DdlGrupo.SelectedValueExist("2")
|
||||
CargaGrupos()
|
||||
DdlNombre.SelectedValueExist(CveDispositivo)
|
||||
CargaPonderacion()
|
||||
CargaGraficas()
|
||||
CargaVehiculo(CveDispositivo)
|
||||
DvContenido.Visible = True
|
||||
UpDatos.Update()
|
||||
CargaMapa()
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
Private Sub CargaFechas()
|
||||
txtFechaI.Text = $"01/{Now.Month}/{Now.Year} 00:00"
|
||||
txtFechaF.Text = DateTime.Now.ToString("dd/MM/yyyy") + " 23:59"
|
||||
End Sub
|
||||
#Region "Conductores"
|
||||
|
||||
Private Sub CargaPonderacion()
|
||||
Dim ObjGps As New ClsGPS
|
||||
Dim Ponderacion As Integer = 100
|
||||
Dim Riesgo As String = "0"
|
||||
Dim Desgaste As String = "0"
|
||||
Dim TotalEventos As String = "0"
|
||||
|
||||
If CveConductor <= 0 AndAlso CveDispositivo > 0 Then
|
||||
If ObjGps.ConductoresGet(-1, "-1", -1, UsuarioActual.CveCliente) AndAlso ObjGps.DtResultados.Rows.Count > 0 Then
|
||||
CveConductor = ObjGps.DtResultados.FiltroPrimeroValor("CveConductor", $"CveDispositivo = {CveDispositivo}").ToString.ToEntero
|
||||
End If
|
||||
End If
|
||||
|
||||
If ObjGps.GetEventosPonderacionCliente(UsuarioActual.CveCliente, CveConductor, txtFechaI.Text.ToDateTime(), txtFechaF.Text.ToDateTime()) AndAlso ObjGps.DtResultados.Rows.Count > 0 Then
|
||||
Ponderacion = 100 - ObjGps.DtResultados(0)("Total").ToString.ToEntero
|
||||
Riesgo = ObjGps.DtResultados(0)("Riesgo").ToString
|
||||
Desgaste = ObjGps.DtResultados(0)("Desgaste").ToString
|
||||
TotalEventos = ObjGps.DtResultados(0)("TotalEventos").ToString
|
||||
End If
|
||||
|
||||
LblPonderacion.Text = Ponderacion.ToString
|
||||
LblRiesgo.Text = Riesgo
|
||||
LblDesgaste.Text = Desgaste
|
||||
LblTotalEventos.Text = TotalEventos
|
||||
|
||||
If Ponderacion >= 70 Then
|
||||
DivTituloPonderacion.Attributes("class") = "toplistaVerde verde"
|
||||
DivCirculoPonderacion.Attributes("class") = "circuloVerde verde"
|
||||
ElseIf Ponderacion >= 50 Then
|
||||
DivTituloPonderacion.Attributes("class") = "toplistaAmarillo amarillo"
|
||||
DivCirculoPonderacion.Attributes("class") = "circuloAmarillo amarillo"
|
||||
Else
|
||||
DivTituloPonderacion.Attributes("class") = "toplistaRojo rojo"
|
||||
DivCirculoPonderacion.Attributes("class") = "circuloRojo rojo"
|
||||
End If
|
||||
|
||||
ObjGps.Dispose()
|
||||
End Sub
|
||||
|
||||
Private Sub CargaConductor(CveConductor As Integer)
|
||||
Dim ObjGps As New ClsGPS
|
||||
If ObjGps.ConductoresGet(CveConductor, "-1", -1, UsuarioActual.CveCliente) AndAlso ObjGps.DtResultados.Rows.Count > 0 Then
|
||||
LblConductor.Text = ObjGps.DtResultados(0)("Conductor").ToString
|
||||
LblFechaNacimiento.Text = ObjGps.DtResultados(0)("FechaNacimiento").ToString.ToDateTime.ToShortDateString
|
||||
LblSerieLicencia.Text = ObjGps.DtResultados(0)("SerieLicencia").ToString
|
||||
LblVigencia.Text = ObjGps.DtResultados(0)("VencimientoLicencia").ToString.ToDateTime.ToShortDateString
|
||||
LblEstatus.Text = ObjGps.DtResultados(0)("EstatusT").ToString
|
||||
|
||||
If ObjGps.DtResultados(0)("Estatus").ToString = "True" Then
|
||||
LblEstatus.ForeColor = Drawing.Color.Green
|
||||
Else
|
||||
LblEstatus.ForeColor = Drawing.Color.Red
|
||||
End If
|
||||
End If
|
||||
ObjGps.Dispose()
|
||||
TbConductor.Visible = True
|
||||
TbVehiculo.Visible = False
|
||||
UpInfo.Update()
|
||||
End Sub
|
||||
Private Sub CargaVehiculo(CveDispositivo As Integer)
|
||||
Dim DrVehiculo = GlobalDTDispositivosUsuarios(UsuarioActual.CveCliente, UsuarioActual.CveUsuario).FiltroPrimero($"CveDispositivo = {CveDispositivo}")
|
||||
If DrVehiculo IsNot Nothing Then
|
||||
LblVehiculo.Text = DrVehiculo("NombreVehiculo").ToString
|
||||
LblNoEconomicos.Text = DrVehiculo("NoEconomico").ToString
|
||||
LblModelo.Text = DrVehiculo("Modelo").ToString
|
||||
LblAnio.Text = DrVehiculo("AñoVehiculo").ToString
|
||||
LblVelocidad.Text = DrVehiculo("VelocidadMaxima").ToString
|
||||
End If
|
||||
TbConductor.Visible = False
|
||||
TbVehiculo.Visible = True
|
||||
UpInfo.Update()
|
||||
End Sub
|
||||
|
||||
Private Sub CargaMapa()
|
||||
Dim ObjGps As New ClsGPS
|
||||
|
||||
If ObjGps.UltimaPosicionEquipoGet(CveDispositivo, txtFechaI.Text.ToDateTime(), txtFechaF.Text.ToDateTime()) AndAlso ObjGps.DtResultados.Rows.Count > 0 Then
|
||||
Dim Coord As String = SQLToGmaps(ObjGps.DtResultados.Rows(0)("Posicion").ToString, "POINT")
|
||||
RegistraScript($"DeleteMarkers();CreaMarcador({Coord},'{ObjGps.DtResultados.Rows(0)("NombreVehiculo")}');")
|
||||
End If
|
||||
|
||||
ObjGps.Dispose()
|
||||
End Sub
|
||||
Private Sub CargaGraficas()
|
||||
Dim ObjGps As New ClsGPS
|
||||
|
||||
Dim Velocidad As String = "0"
|
||||
Dim VelocidadMaxima As String = "0"
|
||||
|
||||
If ObjGps.GetConductoresVelocidades(CveConductor) AndAlso ObjGps.DtResultados.Rows.Count > 0 Then
|
||||
Velocidad = ObjGps.DtResultados(0)("Velocidad").ToString
|
||||
VelocidadMaxima = ObjGps.DtResultados(0)("VelocidadMaxima").ToString
|
||||
CveDispositivo = ObjGps.DtResultados(0)("CveDispositivo").ToString.ToEntero
|
||||
End If
|
||||
|
||||
|
||||
If ObjGps.GetConductoresEventos(CveConductor) Then
|
||||
Dim Random = New Random()
|
||||
Dim JsonArray As New JArray(
|
||||
From dr In ObjGps.DtResultados
|
||||
Let color = String.Format("#{0:X6}", Random.Next(&H1000000))
|
||||
Select New JObject(
|
||||
New JProperty("evento", dr("Evento").ToString),
|
||||
New JProperty("value", dr("Total").ToString),
|
||||
New JProperty("color", color)
|
||||
)
|
||||
)
|
||||
HdnValoresPastel.Value = JsonArray.ToString
|
||||
End If
|
||||
ObjGps.Dispose()
|
||||
RegistraScript($"EstablecerValoresTacometro(""{VelocidadMaxima}"",""{Velocidad}"");", "1")
|
||||
RegistraScript($"EstablecerValoresPastel();", "2")
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
Private Function SQLToGmaps(CoordsSQL As String, Tipo As String) As String
|
||||
Dim CoordsPoligono As String = CoordsSQL.Replace($"{Tipo}", "").Replace(")", "").Replace("(", "")
|
||||
Dim CoordsPuntos() As String = CoordsPoligono.Split(","c)
|
||||
Dim Var As String = ""
|
||||
For Each coordenada As String In CoordsPuntos
|
||||
If coordenada Is CoordsPuntos.Last Then
|
||||
Dim latlng() As String = coordenada.Trim.Split(" "c)
|
||||
Var = $"{Var}{{lat: {latlng(1)}, lng: {latlng(0)} }}"
|
||||
Else
|
||||
Dim latlng() As String = coordenada.Trim.Split(" "c)
|
||||
Var = $"{Var}{{lat: {latlng(1)}, lng: {latlng(0)} }},"
|
||||
End If
|
||||
Next
|
||||
Return Var
|
||||
End Function
|
||||
|
||||
#End Region
|
||||
#Region "Lista Conductores"
|
||||
Private Sub CargaGrupos()
|
||||
DdlNombre.Items.Clear()
|
||||
|
||||
Dim ObjGps As New ClsGPS
|
||||
Select Case DdlGrupo.SelectedValue
|
||||
Case "1" 'CONDUCTOR
|
||||
If ObjGps.ConductoresGet(-1, "-1", -1, UsuarioActual.CveCliente) Then
|
||||
Dim Query = From d In ObjGps.DtResultados
|
||||
Select Cve = d("CveConductor").ToString.ToEntero, Nombre = d("Conductor").ToString
|
||||
DdlNombre.DataSource = Query
|
||||
LtlNombre.Text = "Conductor:"
|
||||
End If
|
||||
Case "2" 'VEHICULOS
|
||||
Dim Query = From d In GlobalDTDispositivosUsuarios(UsuarioActual.CveCliente, UsuarioActual.CveUsuario)
|
||||
Select Cve = d("CveDispositivo").ToString.ToEntero, Nombre = d("NoEconomico").ToString
|
||||
DdlNombre.DataSource = Query
|
||||
LtlNombre.Text = "Vehículo:"
|
||||
End Select
|
||||
ObjGps.Dispose()
|
||||
DdlNombre.DataBind()
|
||||
DdlNombre.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
||||
UPFiltros.Update()
|
||||
|
||||
End Sub
|
||||
#End Region
|
||||
Protected Sub DdlGrupo_SelectedIndexChanged(sender As Object, e As EventArgs)
|
||||
CargaGrupos()
|
||||
End Sub
|
||||
Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs)
|
||||
|
||||
Select Case DdlGrupo.SelectedValue
|
||||
Case "1" 'CONDUCTOR
|
||||
CveConductor = DdlNombre.SelectedValue.ToEntero
|
||||
CargaPonderacion()
|
||||
CargaGraficas()
|
||||
CargaConductor(CveConductor)
|
||||
|
||||
Case "2" 'VEHICULOS
|
||||
CveDispositivo = DdlNombre.SelectedValue.ToEntero
|
||||
CveConductor = -1
|
||||
CargaPonderacion()
|
||||
CargaGraficas()
|
||||
CargaVehiculo(CveDispositivo)
|
||||
End Select
|
||||
DvContenido.Visible = True
|
||||
UpDatos.Update()
|
||||
CargaMapa()
|
||||
End Sub
|
||||
End Class
|
||||
Reference in New Issue
Block a user