108 lines
3.2 KiB
VB.net
108 lines
3.2 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
|
|
Imports Extensiones
|
|
|
|
Partial Class GPS_CatRutas
|
|
Inherits ClsPaginas
|
|
|
|
|
|
#Region "Propiedades"
|
|
Public Property CveRuta As Integer
|
|
Get
|
|
Return ViewState("CveRuta").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveRuta") = value
|
|
End Set
|
|
End Property
|
|
Public Property EsEditar As Integer
|
|
Get
|
|
Return ViewState("EsEditar").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("EsEditar") = value
|
|
End Set
|
|
End Property
|
|
|
|
#End Region
|
|
|
|
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
|
If Not Page.IsPostBack Then
|
|
CveRuta = -1
|
|
EsEditar = 0
|
|
CargaDatos()
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub CargaDatos()
|
|
Dim GPS As New ClsGPS
|
|
If GPS.GetRutas(-1, UsuarioActual.CveCliente) Then
|
|
GvRutas.DataSource = GPS.DtResultados
|
|
Else
|
|
GvRutas.DataSource = Nothing
|
|
End If
|
|
GPS.Dispose()
|
|
GvRutas.DataBind()
|
|
UpDatos.Update()
|
|
End Sub
|
|
|
|
Protected Sub imgE_Click(sender As Object, e As EventArgs)
|
|
Dim Boton = CType(sender, LinkButton)
|
|
|
|
Dim GvRow As GridViewRow = DirectCast(Boton.NamingContainer, GridViewRow)
|
|
CveRuta = GvRow.DataKey("CveRuta").ToEntero
|
|
TxtRuta.Text = GvRow.DataKey("Ruta").ToString
|
|
EsEditar = 1
|
|
BtnAgregarCatalogo.Text = "Actualizar"
|
|
UpAgregar.Update()
|
|
UpDatos.Update()
|
|
RegistraScript("$('#divAgregar').modal()")
|
|
End Sub
|
|
|
|
Protected Sub BtnAgregarCatalogo_Click(sender As Object, e As EventArgs) Handles BtnAgregarCatalogo.Click
|
|
Dim GPS As New ClsGPS
|
|
|
|
If EsEditar = 0 Then
|
|
If GPS.AddRuta(TxtRuta.Text, UsuarioActual.CveCliente) Then
|
|
Alert("La ruta se agregó correctamente", TipoMensaje.MsgInformacion)
|
|
End If
|
|
ElseIf EsEditar = 1 Then
|
|
If GPS.UpdateRuta(CveRuta, TxtRuta.Text, UsuarioActual.CveCliente) Then
|
|
Alert("La ruta se editó correctamente", TipoMensaje.MsgInformacion)
|
|
End If
|
|
EsEditar = 0
|
|
BtnAgregarCatalogo.Text = "Agregar"
|
|
End If
|
|
GPS.Dispose()
|
|
|
|
RegistraScript("$('#divAgregar').modal('hide')")
|
|
|
|
TxtRuta.Text = ""
|
|
CargaDatos()
|
|
UpDatos.Update()
|
|
UpAgregar.Update()
|
|
|
|
End Sub
|
|
|
|
Protected Sub GvDatos_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvRutas.RowDeleting
|
|
Dim GPS As New ClsGPS
|
|
Dim CveRuta As Integer = GvRutas.Rows(e.RowIndex).DataKey("CveRuta").ToEntero
|
|
If GPS.RemoveRuta(CveRuta) Then
|
|
Alert("La ruta se eliminó correctamente", TipoMensaje.MsgInformacion)
|
|
End If
|
|
GPS.Dispose()
|
|
CargaDatos()
|
|
UpDatos.Update()
|
|
End Sub
|
|
Protected Sub btnCancelar_Click(sender As Object, e As EventArgs) Handles BtnOpenDiv.Click
|
|
EsEditar = 0
|
|
RegistraScript("$('#divAgregar').modal()")
|
|
BtnAgregarCatalogo.Text = "Agregar"
|
|
TxtRuta.Text = ""
|
|
UpAgregar.Update()
|
|
End Sub
|
|
|
|
|
|
End Class
|