Files
SIG/GPS/CatEventosTipos.aspx.vb
JORGE LUIS CAUDILLO ESPARZA c35cf91883 Commit inicial Ventas Productivo
2019-08-14 16:40:54 -07:00

131 lines
4.6 KiB
VB.net

Imports Extensiones
Partial Class GPS_CatEventosTipos
Inherits ClsPaginas
#Region "Propiedades"
Public Property CveEventoTipo As Integer
Get
Return ViewState("CveEventoTipo").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("CveEventoTipo") = 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
CveEventoTipo = -1
EsEditar = 0
dvEstatus.Visible = False
CargaDatos(-1)
End If
End Sub
Private Sub CargaDatos(CveEventoTipo As Integer)
Dim GPS As New ClsGPS
If GPS.EventosTiposGet(CveEventoTipo, -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)
CveEventoTipo = Boton.CommandArgument.ToEntero
Dim GvRow As GridViewRow = DirectCast(Boton.NamingContainer, GridViewRow)
TxtTipoEvento.Text = GvRow.DataKey("EventoTipo").ToString
EsEditar = 1
chkEstatus.Checked = CBool(GvRow.DataKey("Estatus").ToString)
myModalLabel.InnerHtml = "Actualizar Tipo de Evento"
BtnAgregarCatalogo.Text = "Actualizar"
dvEstatus.Visible = True
UpBodyEstatus.Update()
UpAgregar.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.EventoTipoAdd(TxtTipoEvento.Text.Trim, True, UsuarioActual.CveUsuario) Then
Alert("El Tipo De Evento se agregó correctamente", TipoMensaje.MsgInformacion)
Else
Alert("Ocurrió un error al agregar el tipo de evento", TipoMensaje.MsgError)
End If
ElseIf EsEditar = 1 Then
If GPS.EventosTiposUpdate(CveEventoTipo, TxtTipoEvento.Text, If(chkEstatus.Checked, 1, 0)) Then
Alert("El Tipo De Evento se editó correctamente", TipoMensaje.MsgInformacion)
Else
Alert("Ocurrió un error al editar el Tipo De Eventor", TipoMensaje.MsgError)
End If
EsEditar = 0
dvEstatus.Visible = True
BtnAgregarCatalogo.Text = "Agregar"
End If
RegistraScript("$('#divAgregar').modal('hide')")
GPS.Dispose()
TxtTipoEvento.Text = ""
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 CveEventoTipo As Integer = GvDatos.Rows(e.RowIndex).DataKey("CveEventoTipo").ToEntero
If GPS.EventoTipoDelete(CveEventoTipo) Then
Alert("El conductor 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("CveEventoTipo").ToString
If e.Row.DBCampo("Estatus") = True 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 BtnOpenDiv.Click
EsEditar = 0
RegistraScript("$('#divAgregar').modal()")
BtnAgregarCatalogo.Text = "Agregar"
myModalLabel.InnerHtml = "Agregar Tipo de Evento"
TxtTipoEvento.Text = ""
dvEstatus.Visible = False
UpBodyEstatus.Update()
UpFooter.Update()
End Sub
End Class