Commit inicial Ventas Productivo
This commit is contained in:
246
GPS/RepCombustible2.aspx.vb
Normal file
246
GPS/RepCombustible2.aspx.vb
Normal file
@@ -0,0 +1,246 @@
|
||||
Imports Extensiones
|
||||
Imports System.Data
|
||||
Imports Microsoft.Reporting.WebForms
|
||||
|
||||
Partial Class GPS_RepCombustible2
|
||||
Inherits Page
|
||||
|
||||
ReadOnly Property UsuarioActual() As Usuario
|
||||
Get
|
||||
Try
|
||||
'UsuarioActual = DirectCast(Session("UsuarioSIG"), Usuario)
|
||||
UsuarioActual = CType(Context.Session("UsuarioSIG"), Usuario)
|
||||
Catch ex As Exception
|
||||
UsuarioActual = Nothing
|
||||
FormsAuthentication.SignOut()
|
||||
Session("UsuarioSIG") = Nothing
|
||||
HttpContext.Current.Response.Redirect(String.Format("/LogIn.aspx?ReturnUrl={0}", HttpContext.Current.Request.Url))
|
||||
End Try
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Sub RegistraScript(Script As String, Optional valuetick As String = "")
|
||||
Dim Rdm As Random = New Random()
|
||||
ScriptManager.RegisterStartupScript(Page, Me.GetType(), String.Format("{0}{1}{2}", (DateTime.Now.Ticks + 1), Rdm.Next(), valuetick), String.Format("<script type='text/javascript' language='javascript'>{0}</script>", Script), False)
|
||||
End Sub
|
||||
Property DTCargasDescargas As DataTable
|
||||
Get
|
||||
If ViewState("DTCargasDescargas") Is Nothing Then
|
||||
Return New DataTable
|
||||
Else
|
||||
Return DirectCast(ViewState("DTCargasDescargas"), DataTable)
|
||||
End If
|
||||
|
||||
End Get
|
||||
Set(value As DataTable)
|
||||
ViewState("DTCargasDescargas") = value
|
||||
End Set
|
||||
End Property
|
||||
Property DTDatos As DataTable
|
||||
Get
|
||||
If ViewState("DTDatos") Is Nothing Then
|
||||
Return New DataTable
|
||||
Else
|
||||
Return DirectCast(ViewState("DTDatos"), DataTable)
|
||||
End If
|
||||
|
||||
End Get
|
||||
Set(value As DataTable)
|
||||
ViewState("DTDatos") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private Property CveDispositivo As Integer
|
||||
Get
|
||||
Return CType(ViewState("CveDispositivo"), Integer)
|
||||
End Get
|
||||
Set(value As Integer)
|
||||
ViewState("CveDispositivo") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private Property FechaI As DateTime
|
||||
Get
|
||||
Return CType(ViewState("FechaI"), DateTime)
|
||||
End Get
|
||||
Set(value As DateTime)
|
||||
ViewState("FechaI") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private Property FechaF As DateTime
|
||||
Get
|
||||
Return CType(ViewState("FechaF"), DateTime)
|
||||
End Get
|
||||
Set(value As DateTime)
|
||||
ViewState("FechaF") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
|
||||
|
||||
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
|
||||
If Not Page.IsPostBack Then
|
||||
CargaDispositivos()
|
||||
txtFechaI.Text = Now.FirstDayOfMonth.ToShortDateString
|
||||
txtFechaF.Text = Now.LastDayOfMonth.ToShortDateString
|
||||
End If
|
||||
End Sub
|
||||
|
||||
'Private Sub CargaDatos()
|
||||
' Dim ObjAF As New ClsAF
|
||||
' Dim Finicial As String = ""
|
||||
' Dim FFinal As String = ""
|
||||
' Try
|
||||
' Finicial = txtFechaI.Text.ToDate.ToString("yyyy/MM/dd")
|
||||
' FFinal = txtFechaF.Text.ToDate.ToString("yyyy/MM/dd")
|
||||
' Catch ex As Exception
|
||||
' Alert("Ocurrio un error con las fechas")
|
||||
' End Try
|
||||
|
||||
' If ObjAF.GetIncidentesRep(-1, -1, -1, Finicial, FFinal, DdlDispositivo.SelectedValue.ToEntero, UsuarioActual.CveCliente) Then
|
||||
' DTDatos = ObjAF.DtResultados
|
||||
' Else
|
||||
' DTDatos = Nothing
|
||||
' End If
|
||||
' ObjAF.Dispose()
|
||||
'End Sub
|
||||
|
||||
#Region "C O M B O S"
|
||||
Private Sub CargaDispositivos()
|
||||
Dim GPS As New ClsGPS
|
||||
|
||||
If GPS.DispositivosGet(-1, -1, UsuarioActual.CveCliente) AndAlso GPS.DtResultados.Rows.Count > 0 Then
|
||||
DdlDispositivo.DataSource = GPS.DtResultados.FiltraParametros("TieneCombustible = 1")
|
||||
End If
|
||||
GPS.Dispose()
|
||||
DdlDispositivo.DataBind()
|
||||
DdlDispositivo.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
||||
End Sub
|
||||
|
||||
Private Sub CargaDatos()
|
||||
LtlUnidad.Text = DdlDispositivo.SelectedItem.Text
|
||||
CveDispositivo = DdlDispositivo.SelectedValue.ToEntero
|
||||
FechaI = txtFechaI.Text.ToDateTime
|
||||
FechaF = txtFechaF.Text.ToDateTime
|
||||
'UpReportes.Update()
|
||||
Dim GPS As New ClsGPS
|
||||
CargaHistorico(GPS)
|
||||
If GPS.RepCombustibleGet2(DdlDispositivo.SelectedValue.ToEntero, FechaI, FechaF) AndAlso GPS.DtSetResultados.Tables.Count > 1 Then
|
||||
Dim DTDatos As DataTable = GPS.DtSetResultados.Tables(1) '$("{DTDatos.Rows(0)("")}")
|
||||
DTCargasDescargas = GPS.DtSetResultados.Tables(0)
|
||||
If DTDatos.Rows.Count > 0 Then
|
||||
LtlDistancia.Text = $"{DTDatos.Rows(0)("KmRecorridos")}"
|
||||
lblVelocidad.Text = $"{DTDatos.Rows(0)("SPD")}"
|
||||
lblRendBruto.Text = $"{DTDatos.Rows(0)("KmRecorridos") / DTDatos.Rows(0)("CombustibleConsumido"):N2}"
|
||||
LtlCombustibleInicial.Text = $"{DTDatos.Rows(0)("CombustibleInicial")}"
|
||||
LtlCombustibleFinal.Text = $"{DTDatos.Rows(0)("CombustibleFinal")}"
|
||||
LtlNoCargas.Text = $"{DTDatos.Rows(0)("CCargas")}"
|
||||
LtlNoDescargas.Text = $"{DTDatos.Rows(0)("CDescargas")}"
|
||||
SumaCargas.Text = $"{DTDatos.Rows(0)("Cargas")}"
|
||||
LtlCostoCargas.Text = ""
|
||||
SumaDescargas.Text = $"{DTDatos.Rows(0)("Descargas")}"
|
||||
LtlCostoDescargas.Text = ""
|
||||
LtlDistanciaR.Text = $"{DTDatos.Rows(0)("KmRecorridos")}"
|
||||
LtlCombustibleConsumido.Text = $"{DTDatos.Rows(0)("CombustibleConsumido")}"
|
||||
LtlCostoConsumo.Text = ""
|
||||
LtlCostoCombustibleF.Text = ""
|
||||
LtlCostoInicial.Text = ""
|
||||
lCombustibleConsumido.Text = $"{DTDatos.Rows(0)("Recorrido")}"
|
||||
End If
|
||||
|
||||
End If
|
||||
If GPS.RepCombustibleGet(DdlDispositivo.SelectedValue.ToEntero, FechaI, FechaF) AndAlso GPS.DtResultados.Rows.Count > 0 Then
|
||||
' Dim TotalKilometros As Decimal = (GPS.DtResultados.Rows(0)("Distancia").ToString.ToDecimal) / 1000
|
||||
' Dim CombustibleConsumido As Decimal = (GPS.DtResultados.Rows(0)("CombustibleInicial").ToString.ToDecimal + GPS.DtResultados.Rows(0)("SumaCargas").ToString.ToDecimal) - (GPS.DtResultados.Rows(0)("CombustibleFinal").ToString.ToDecimal + GPS.DtResultados.Rows(0)("SumaDescargas").ToString.ToDecimal)
|
||||
' Dim RendBruto As Decimal = TotalKilometros / CombustibleConsumido
|
||||
' Dim CostoCombustible As Decimal = GlobalDTDispositivos(-1).FiltroPrimeroValor("CostoCombustible", $"CveDispositivo = {DdlDispositivo.SelectedValue}").ToDecimal
|
||||
' LtlDistancia.Text = TotalKilometros.ToString.FormatoNumero
|
||||
' lblVelocidad.Text = $"{GPS.DtResultados.Rows(0)("VelocidadMaxima").ToString.FormatoNumero}"
|
||||
' lblRendBruto.Text = $"{RendBruto.ToString.FormatoNumero}"
|
||||
' LtlCombustibleInicial.Text = GPS.DtResultados.Rows(0)("CombustibleInicial").ToString.FormatoNumero
|
||||
' LtlCombustibleFinal.Text = GPS.DtResultados.Rows(0)("CombustibleFinal").ToString.FormatoNumero
|
||||
' LtlNoCargas.Text = GPS.DtResultados.Rows(0)("Cargas").ToString
|
||||
' LtlNoDescargas.Text = GPS.DtResultados.Rows(0)("Descargas").ToString
|
||||
' SumaCargas.Text = GPS.DtResultados.Rows(0)("SumaCargas").ToString.FormatoNumero
|
||||
' LtlCostoCargas.Text = $"${(GPS.DtResultados.Rows(0)("SumaCargas").ToString.ToDecimal * CostoCombustible).ToString.FormatoNumero}"
|
||||
' SumaDescargas.Text = GPS.DtResultados.Rows(0)("SumaDescargas").ToString.FormatoNumero
|
||||
' LtlCostoDescargas.Text = $"${(GPS.DtResultados.Rows(0)("SumaDescargas").ToString.ToDecimal * CostoCombustible).ToString.FormatoNumero}"
|
||||
' LtlDistanciaR.Text = TotalKilometros.ToString.FormatoNumero
|
||||
' LtlCombustibleConsumido.Text = CombustibleConsumido.ToString.FormatoNumero
|
||||
' LtlCostoConsumo.Text = $"${(CombustibleConsumido * CostoCombustible).ToString.FormatoNumero}"
|
||||
' LtlCostoCombustibleF.Text = $"${(GPS.DtResultados.Rows(0)("CombustibleFinal").ToString.ToDecimal * CostoCombustible).ToString.FormatoNumero}"
|
||||
' LtlCostoInicial.Text = $"${(GPS.DtResultados.Rows(0)("CombustibleInicial").ToString.ToDecimal * CostoCombustible).ToString.FormatoNumero}"
|
||||
' lCombustibleConsumido.Text = CombustibleConsumido.ToString.FormatoNumero
|
||||
lblMuerto.Text = $"{((DateDiff(DateInterval.Minute, txtFechaI.Text.ToDateTime, txtFechaF.Text.ToDateTime).ToString - GPS.DtResultados.Rows(0)("Horas").ToString.ToLong) / 60).ToString.FormatoNumero} Hrs."
|
||||
lblMovimiento.Text = $"{(GPS.DtResultados.Rows(0)("Horas").ToString.ToDecimal / 60).ToString.FormatoNumero} Hrs"
|
||||
LtlRalenti.Text = $"{GPS.DtResultados.Rows(0)("TiempoRalentiHoras").ToString.FormatoNumero} Hrs. ({GPS.DtResultados.Rows(0)("TiempoRalentiMinutos").ToString} Minutos)"
|
||||
|
||||
' 'lblRendEfectivo.Text = $"{(RendBruto + 1).ToString.FormatoNumero} KM/L"
|
||||
End If
|
||||
GPS.Dispose()
|
||||
DvReporte.Visible = True
|
||||
UpReporte.Update()
|
||||
UpDash.Update()
|
||||
UPTabla.Update()
|
||||
' bodyreportes.Visible = True
|
||||
' UpReportes.Update()
|
||||
End Sub
|
||||
Private Sub CargaHistorico(ByRef GPS As ClsGPS)
|
||||
If GPS.GetCombustibleHistorico(DdlDispositivo.SelectedValue.ToEntero, txtFechaI.Text.ToDateTime, txtFechaF.Text.ToDateTime) Then
|
||||
Dim query = From s In GPS.DtResultados
|
||||
Select New With {.date = s.Field(Of DateTime)("FechaTrama").ToString("yyyy-MM-dd HH:mm:ss"), .value = s("Valor").ToString().ToDecimal(), .value2 = s("Valor2").ToString().ToDecimal(), .Tanque1 = s("Tanque1").ToString().ToDecimal(), .Tanque2 = s("Tanque2").ToString().ToDecimal(), .cvetrama = s("CveTrama")} ',,
|
||||
Dim json = Newtonsoft.Json.JsonConvert.SerializeObject(query)
|
||||
|
||||
HdfGrafica.Value = json
|
||||
RegistraScript($"CargaHistorico(JSON.parse($(""#{HdfGrafica.ClientID}"").val()))")
|
||||
End If
|
||||
End Sub
|
||||
Private Sub BtnConsultar_Click(sender As Object, e As EventArgs) Handles BtnConsultar.Click
|
||||
CargaDatos()
|
||||
End Sub
|
||||
Protected Sub lbCargas_Click(sender As Object, e As EventArgs)
|
||||
LtlTituloCD.Text = $"Desglose de cargas de combustible: {LtlUnidad.Text}"
|
||||
Dim GPS As New ClsGPS
|
||||
GVHistorico.DataSource = DTCargasDescargas.FiltraParametros("TipoEvento=2")
|
||||
'If GPS.GetCargasDescargas(CveDispositivo, FechaI, FechaF, 48) Then
|
||||
' GVHistorico.DataSource = GPS.DtResultados
|
||||
'Else
|
||||
' GVHistorico.DataSource = Nothing
|
||||
'End If
|
||||
GPS.Dispose()
|
||||
GVHistorico.DataBind()
|
||||
UpdatePanel3.Update()
|
||||
UpHistorico.Update()
|
||||
RegistraScript("$('#dvHistorico').modal()")
|
||||
End Sub
|
||||
|
||||
Protected Sub lbDesCargas_Click(sender As Object, e As EventArgs) Handles lbDescargas.Click
|
||||
LtlTituloCD.Text = $"Desglose de descargas de combustible: {LtlUnidad.Text}"
|
||||
Dim GPS As New ClsGPS
|
||||
GVHistorico.DataSource = DTCargasDescargas.FiltraParametros("TipoEvento=1")
|
||||
'If GPS.GetCargasDescargas(CveDispositivo, FechaI, FechaF, 43) Then
|
||||
' GVHistorico.DataSource = GPS.DtResultados
|
||||
'Else
|
||||
' GVHistorico.DataSource = Nothing
|
||||
'End If
|
||||
GPS.Dispose()
|
||||
GVHistorico.DataBind()
|
||||
UpdatePanel3.Update()
|
||||
UpHistorico.Update()
|
||||
RegistraScript("$('#dvHistorico').modal()")
|
||||
End Sub
|
||||
|
||||
Protected Sub GVHistorico_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GVHistorico.RowDataBound
|
||||
If e.Row.RowType = DataControlRowType.DataRow Then
|
||||
Dim RowID As String = $"row{e.Row.RowIndex}"
|
||||
e.Row.Attributes("id") = RowID
|
||||
RegistraScript($"GetDireccionesGV({{ lat: {e.Row.DBCampo("Lat").ToString}, lng: {e.Row.DBCampo("Lon").ToString }}}, '#{RowID}', {e.Row.RowIndex});", $"{RowID}")
|
||||
End If
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user