WS Kimberly Clark
This commit is contained in:
143
GPS/KimberlyClarkTracking.aspx.vb
Normal file
143
GPS/KimberlyClarkTracking.aspx.vb
Normal file
@@ -0,0 +1,143 @@
|
||||
Option Strict On
|
||||
Option Explicit On
|
||||
|
||||
Imports System.Data
|
||||
Imports System.IO
|
||||
Imports System.Net
|
||||
Imports Extensiones
|
||||
Imports Microsoft.Reporting.WebForms
|
||||
Imports Newtonsoft.Json.Linq
|
||||
Imports System.Linq
|
||||
Imports System.Net.Http
|
||||
|
||||
Partial Class GPS_KimberlyClarkTracking
|
||||
Inherits ClsPaginas
|
||||
|
||||
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()
|
||||
CargaDispositivos()
|
||||
CargaTracking()
|
||||
End Sub
|
||||
Public Sub CargaDispositivos()
|
||||
Dim DtDispositivos As DataTable = GlobalDTDispositivosUsuarios(UsuarioActual.CveCliente, UsuarioActual.CveUsuario).FiltraParametros("Estatus = 1")
|
||||
|
||||
DdlDispositivoFiltro.DataSource = DtDispositivos
|
||||
DdlDispositivoFiltro.DataBind()
|
||||
DdlDispositivoFiltro.Items.Insert(0, New ListItem("Todos", "-1"))
|
||||
|
||||
DdlDispositivo.DataSource = DtDispositivos
|
||||
DdlDispositivo.DataBind()
|
||||
DdlDispositivo.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
||||
|
||||
UpAgregar.Update()
|
||||
End Sub
|
||||
Private Sub CargaTracking()
|
||||
Dim FechaI As DateTime = If(IsDate(txtFechaI.Text), txtFechaI.Text.ToDateTime(), MinFecha)
|
||||
Dim FechaF As DateTime = If(IsDate(txtFechaF.Text), txtFechaF.Text.ToDateTime(), MaxFecha)
|
||||
|
||||
Dim ObjGPS As New ClsGPS
|
||||
If ObjGPS.GetKimberlyClarkTracking(-1, DdlDispositivoFiltro.SelectedValue.ToEntero(), DdlEstatus.SelectedValue.ToEntero(), UsuarioActual.CveCliente, UsuarioActual.CveEmpresa, FechaI, FechaF) Then
|
||||
GvDatos.DataSource = ObjGPS.DtResultados
|
||||
End If
|
||||
ObjGPS.Dispose()
|
||||
|
||||
GvDatos.DataBind()
|
||||
UpDatos.Update()
|
||||
End Sub
|
||||
Protected Sub LnkAgregarTracking_Click(sender As Object, e As EventArgs)
|
||||
RegistraScript("$('#DivAgregar').modal('show');")
|
||||
End Sub
|
||||
|
||||
Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs)
|
||||
CargaTracking()
|
||||
End Sub
|
||||
Protected Sub LnkCambiarEstatus_Click(sender As Object, e As EventArgs)
|
||||
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
||||
|
||||
Dim CveKimberlyClarkTracking As Integer = GvRow.DataKey("CveKimberlyClarkTracking").ToEntero()
|
||||
Dim Estatus As Boolean = CBool(GvRow.DataKey("CveEstatus").ToEntero())
|
||||
|
||||
Dim ObjGPS As New ClsGPS
|
||||
If ObjGPS.UpdateKimberlyClarkTrackingEstatus(CveKimberlyClarkTracking, Not Estatus, UsuarioActual.CveUsuario) Then
|
||||
Alert("El tracking fue desactivado correctamente")
|
||||
Else
|
||||
Alert("Ocurrió un error al actualizar el estatus", TipoMensaje.MsgError)
|
||||
End If
|
||||
ObjGPS.Dispose()
|
||||
|
||||
CargaDatos()
|
||||
End Sub
|
||||
Protected Sub GvDatos_RowDeleting(sender As Object, e As GridViewDeleteEventArgs)
|
||||
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
||||
|
||||
Dim CveKimberlyClarkTracking As Integer = GvRow.DataKey("CveKimberlyClarkTracking").ToEntero()
|
||||
|
||||
Dim ObjGPS As New ClsGPS
|
||||
If ObjGPS.RemoveKimberlyClarkTracking(CveKimberlyClarkTracking) Then
|
||||
Alert("El tracking fue eliminado")
|
||||
Else
|
||||
Alert("Ocurrió un error al actualizar el estatus", TipoMensaje.MsgError)
|
||||
End If
|
||||
ObjGPS.Dispose()
|
||||
|
||||
CargaDatos()
|
||||
End Sub
|
||||
|
||||
Protected Sub BtnAgregar_Click(sender As Object, e As EventArgs)
|
||||
Dim Dominio As String = TxtDominio.Text.Trim()
|
||||
Dim Codigo As String = TxtCodigo.Text.Trim()
|
||||
Dim Serie As String = TxtSerie.Text.Trim()
|
||||
Dim CveDispositivo As Integer = DdlDispositivo.SelectedValue.ToEntero()
|
||||
|
||||
Dim ObjGPS As New ClsGPS
|
||||
Dim CveKimberlyClarkTracking As Integer = ObjGPS.AddKimberlyClarkTracking(Dominio, Codigo, Serie, CveDispositivo, UsuarioActual.CveUsuario, UsuarioActual.CveCliente, UsuarioActual.CveEmpresa)
|
||||
If CveKimberlyClarkTracking > 0 Then
|
||||
Alert("El tracking fue agregado correctamente")
|
||||
Else
|
||||
Alert("Ocurrió un error el tracking", TipoMensaje.MsgError)
|
||||
End If
|
||||
ObjGPS.Dispose()
|
||||
|
||||
CargaDatos()
|
||||
RegistraScript("$('#DivAgregar').modal('hide');")
|
||||
End Sub
|
||||
Protected Sub LnkEnviarPosicion_Click(sender As Object, e As EventArgs)
|
||||
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
||||
|
||||
Dim CveDispositivo As Integer = GvRow.DataKey("CveDispositivo").ToEntero()
|
||||
Dim Dominio As String = GvRow.DataKey("Dominio")
|
||||
Dim Serie As String = GvRow.DataKey("Serie")
|
||||
Dim Codigo As String = GvRow.DataKey("Codigo")
|
||||
Dim Lat As Double = 0
|
||||
Dim Lng As Double = 0
|
||||
Dim Velocidad As Double = 0
|
||||
Dim FechaEvento As DateTime = Nothing
|
||||
|
||||
Using ObjGPS As New ClsGPS
|
||||
If ObjGPS.UltimaPosicionEquipoGet(CveDispositivo, MinFecha, MaxFecha) AndAlso ObjGPS.DtResultados.Rows.Count > 0 Then
|
||||
Lat = ObjGPS.DtResultados.Rows(0)("Lat").ToString().ToDouble()
|
||||
Lng = ObjGPS.DtResultados.Rows(0)("Lng").ToString().ToDouble()
|
||||
FechaEvento = ObjGPS.DtResultados.Rows(0)("FechaTrama").ToString().ToDateTime()
|
||||
Velocidad = ObjGPS.DtResultados.Rows(0)("SPD").ToString().ToDouble()
|
||||
End If
|
||||
End Using
|
||||
|
||||
Try
|
||||
Dim WS = New WSKimberlyClark.ServiceSoapClient()
|
||||
|
||||
Dim Retorno = WS.LoginYInsertarEvento("USUARIO", "CONTRASEÑA", Dominio, Serie, Codigo, Lat, Lng, 0, Velocidad, FechaEvento, FechaEvento)
|
||||
If Retorno > 0 Then
|
||||
Alert("El evento se envió correctamente")
|
||||
Else
|
||||
Alert("No se envió el evento", TipoMensaje.MsgAdvertencia)
|
||||
End If
|
||||
Catch ex As Exception
|
||||
OnError("Ocurrió un error al enviar la posición", ex)
|
||||
End Try
|
||||
|
||||
End Sub
|
||||
End Class
|
||||
Reference in New Issue
Block a user