133 lines
4.6 KiB
VB.net
133 lines
4.6 KiB
VB.net
|
|
Imports Extensiones
|
|
Imports System.Data
|
|
|
|
Partial Class GPS_CatDispositivos
|
|
Inherits System.Web.UI.Page
|
|
|
|
#Region "Propiedades"
|
|
Public Property CveDispositivo As Integer
|
|
Get
|
|
Return ViewState("CveDispositivo").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveDispositivo") = 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
|
|
|
|
CveDispositivo = -1
|
|
EsEditar = 0
|
|
dvEstatus.Visible = False
|
|
CargaDatos(-1)
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub CargaDatos(CveDispositivo As Integer)
|
|
Dim GPS As New ClsGPS
|
|
If GPS.DispositivosGet(CveDispositivo, -1, -1) Then
|
|
GvDatos.DataSource = GPS.DtResultados
|
|
Else
|
|
GvDatos.DataSource = Nothing
|
|
End If
|
|
|
|
GPS.Dispose()
|
|
GvDatos.DataBind()
|
|
|
|
End Sub
|
|
|
|
Protected Sub imgE_Click(sender As Object, e As EventArgs)
|
|
Dim Boton = CType(sender, LinkButton)
|
|
CveDispositivo = Boton.CommandArgument.ToEntero
|
|
Dim GvRow As GridViewRow = DirectCast(Boton.NamingContainer, GridViewRow)
|
|
'TxtConductor.Text = GvRow.DataKey("Conductor").ToString
|
|
EsEditar = 1
|
|
BtnAgregarCatalogo.Text = "Actualizar"
|
|
dvEstatus.Visible = True
|
|
UpBodyEstatus.Update()
|
|
UpFooter.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.DispositivoAdd(DdlModelo.SelectedValue.ToEntero, DdlCuentas.SelectedValue.ToEntero, 4, TxtIMEI.Text, TxtSerie.Text, 1) Then
|
|
' Alert("El Dispositivo se agregó correctamente", TipoMensaje.MsgInformacion)
|
|
' Else
|
|
' Alert("Ocurrió un error al agregar el Dispositivo", TipoMensaje.MsgError)
|
|
' End If
|
|
'ElseIf EsEditar = 1 Then
|
|
' If GPS.DispositivosUpdate(CveDispositivo, DdlModelo.SelectedValue.ToEntero, DdlCuentas.SelectedValue.ToEntero, 4, TxtIMEI.Text, TxtSerie.Text, DdlEstatus.SelectedValue) Then
|
|
' Alert("El Dispositivo se editó correctamente", TipoMensaje.MsgInformacion)
|
|
' Else
|
|
' Alert("Ocurrió un error al editar el dispositivo", TipoMensaje.MsgError)
|
|
' End If
|
|
' EsEditar = 0
|
|
' dvEstatus.Visible = True
|
|
' BtnAgregarCatalogo.Text = "Agregar"
|
|
'End If
|
|
'RegistraScript("$('#divAgregar').modal('hide')")
|
|
'GPS.Dispose()
|
|
'CargaDatos(-1)
|
|
'UpDatos.Update()
|
|
'UpBodyEstatus.Update()
|
|
End Sub
|
|
|
|
Protected Sub GvDatos_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvDatos.RowDeleting
|
|
Dim GPS As New ClsGPS
|
|
Dim CveDispositivo As Integer = GvDatos.Rows(e.RowIndex).DataKey("CveDispositivo").ToEntero
|
|
If GPS.DispositivosDelete(CveDispositivo) Then
|
|
Alert("El Dispositivo se eliminó correctamente", TipoMensaje.MsgInformacion)
|
|
End If
|
|
GPS.Dispose()
|
|
CargaDatos(-1)
|
|
UpDatos.Update()
|
|
End Sub
|
|
|
|
Protected Sub GvDatos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvDatos.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
e.Row.VerticalAlign = VerticalAlign.Middle
|
|
' e.Row.FCLinkButton("ImgE").CommandArgument = e.Row.DataKey("CveDispositivo").ToString
|
|
|
|
If e.Row.DBCampo("CveEstatus") = 1 Then
|
|
e.Row.FCLabel("LblEstatus").Text = "Activo"
|
|
e.Row.FCLabel("LblEstatus").ForeColor = Drawing.Color.Green
|
|
|
|
Else
|
|
e.Row.FCLabel("LblEstatus").Text = "Inactivo"
|
|
e.Row.FCLabel("LblEstatus").ForeColor = Drawing.Color.Red
|
|
End If
|
|
|
|
End If
|
|
End Sub
|
|
|
|
|
|
'Protected Sub btnCancelar_Click(sender As Object, e As EventArgs) Handles btnCancelar.Click
|
|
' EsEditar = 0
|
|
' RegistraScript("$('#divAgregar').modal('hide')")
|
|
' BtnAgregarCatalogo.Text = "Agregar"
|
|
' 'TxtConductor.Text = ""
|
|
' dvEstatus.Visible = False
|
|
' UpBodyEstatus.Update()
|
|
' UpFooter.Update()
|
|
'End Sub
|
|
|
|
|
|
End Class
|
|
|