Option Strict On Imports System.Data Imports Extensiones Partial Class GPS_CatRemisionesVehiculos Inherits ClsPaginas Private Property DTEquipos As DataTable Get Return CType(ViewState("DTEquipos"), DataTable) End Get Set(value As DataTable) ViewState("DTEquipos") = value End Set End Property Private Property Coordenada As String Get Return CType(ViewState("Coordenada"), String) End Get Set(value As String) ViewState("Coordenada") = value End Set End Property Private Property CveRemision As Integer Get Return CType(ViewState("Coordenada"), Integer) End Get Set(value As Integer) ViewState("Coordenada") = value End Set End Property Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then CargaDatos() End If End Sub Private Sub CargaDatos() Dim ObjTSoft As New ClsTSoft If ObjTSoft.GetRemisiones(UsuarioActual.CveCliente) Then GvRemisiones.DataSource = ObjTSoft.DtResultados Else GvRemisiones.DataSource = Nothing End If If ObjTSoft.GetEstatusRemisiones() Then DdlEstatus.DataSource = ObjTSoft.DtResultados End If ObjTSoft.Dispose() DdlEstatus.DataBind() GvRemisiones.DataBind() UPConsulta.Update() End Sub Protected Sub GvRemisiones_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvRemisiones.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then Coordenada = SQLToGmaps(e.Row.DBCampo("Posicion"), "POINT") e.Row.FCLinkButton("imgE").CommandArgument = e.Row.DBCampo("CveRemision").ToString e.Row.Attributes.Add("onClick", $"CreaMarcador({Coordenada}, '{e.Row.DBCampo("NoEconomico")}', ' ');") End If 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 = "" If CoordsPuntos.Length > 0 Then For Each coordenada As String In CoordsPuntos If coordenada Is CoordsPuntos.Last Then Dim latlng() As String = coordenada.Trim.Split(" "c) If coordenada IsNot Nothing AndAlso coordenada <> "" AndAlso latlng IsNot Nothing AndAlso latlng.Count > 1 Then Var = $"{Var}{{lat: {latlng(1)}, lng: {latlng(0)} }}" Else Dim latlng() As String = coordenada.Trim.Split(" "c) If coordenada IsNot Nothing AndAlso coordenada <> "" AndAlso latlng IsNot Nothing AndAlso latlng.Count > 1 Then Var = $"{Var}{{lat: {latlng(1)}, lng: {latlng(0)} }}," End If Next End If Return Var End Function Protected Sub imgE_Click(sender As Object, e As EventArgs) Dim Boton = CType(sender, LinkButton) CveRemision = Boton.CommandArgument.ToEntero Dim GvRow As GridViewRow = DirectCast(Boton.NamingContainer, GridViewRow) TxtNoRemolque.Text = GvRow.DataKey("NumeroRemolque").ToString TxtTracking.Text = GvRow.DataKey("TrackingNumber").ToString DdlEstatus.SelectedValueExist(GvRow.DataKey("CveEstatus")) RegistraScript("$('#C_BtnMostrarContrato').click();") UpContratos.Update() End Sub Protected Sub BtnActualizarEstatus_Click(sender As Object, e As EventArgs) Dim ObjSoft As New ClsTSoft Dim TrackingNo As String = If(TxtTracking.Text <> "", TxtTracking.Text, "-1") Dim NumRemolque As String = If(TxtNoRemolque.Text <> "", TxtNoRemolque.Text, "-1") If ObjSoft.UpdateEstatusRemisiones(CveRemision, DdlEstatus.SelectedValue.ToEntero, TrackingNo, NumRemolque) Then Alert("El estatus se actualizó correctamente") End If TxtNoRemolque.Text = "" TxtTracking.Text = "" ObjSoft.Dispose() CargaDatos() RegistraScript("$('#C_BtnCerrarContrato').click();") End Sub Protected Sub BtnCancelar_Click(sender As Object, e As EventArgs) RegistraScript("$('#C_BtnCerrarContrato').click();") End Sub Protected Sub imgHistorial_Click(sender As Object, e As EventArgs) Dim ObjSoft As New ClsTSoft Dim Boton = CType(sender, LinkButton) Dim GvRow As GridViewRow = DirectCast(Boton.NamingContainer, GridViewRow) CveRemision = Boton.CommandArgument.ToEntero If ObjSoft.GETRemisionesHistorial(GvRow.DataKey("FolioRemision").ToString, GvRow.DataKey("NoEconomico").ToString) Then GVHistorico.DataSource = ObjSoft.DtResultados End If ObjSoft.Dispose() H1.InnerText = $"Histórico Remisión: {GvRow.DataKey("FolioRemision").ToString} " GVHistorico.DataBind() UpHistorico.Update() RegistraScript("$('#dvHistorico').modal();") End Sub End Class