231 lines
9.1 KiB
VB.net
231 lines
9.1 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
|
|
Imports System.Data
|
|
Imports System.Linq
|
|
Imports Extensiones
|
|
|
|
Partial Class AF_CatTiposEventos
|
|
Inherits ClsPaginas
|
|
|
|
Public Property PuedeEditar As Boolean
|
|
Get
|
|
Return CBool(ViewState("PuedeEditar"))
|
|
End Get
|
|
Set(value As Boolean)
|
|
ViewState("PuedeEditar") = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property PuedeEliminar As Boolean
|
|
Get
|
|
Return CBool(ViewState("PuedeEditar"))
|
|
End Get
|
|
Set(value As Boolean)
|
|
ViewState("PuedeEditar") = value
|
|
End Set
|
|
End Property
|
|
|
|
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
|
If Not Page.IsPostBack Then
|
|
ViewState("Orden") = ""
|
|
ViewState("OTipo") = "Tipo DESC"
|
|
ViewState("OTipoReferencia") = "TipoReferencia DESC"
|
|
ViewState("OEstado") = "Estado DESC"
|
|
ViewState("OFechaIng") = "FechaIng DESC"
|
|
ViewState("OUsuario") = "Usuario DESC"
|
|
CargaDatos()
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub CargaDatos()
|
|
Dim ObjTiposEventos As New ClsTiposEventos()
|
|
|
|
'CARGA TIPOS EVENTOS
|
|
If ObjTiposEventos.GetTiposEventos() Then
|
|
ViewState("DTTiposEventos") = ObjTiposEventos.DtResultados
|
|
GlobalDTTiposEventos = ObjTiposEventos.DtResultados
|
|
Else
|
|
Me.GvDatos.DataSource = Nothing
|
|
End If
|
|
|
|
ObjTiposEventos.Dispose()
|
|
|
|
If ViewState("Orden").ToString() <> String.Empty Then
|
|
CargaGrid(ViewState("Orden").ToString())
|
|
Else
|
|
CargaGrid("")
|
|
End If
|
|
|
|
ObjTiposEventos.Dispose()
|
|
End Sub
|
|
|
|
Private Sub CargaGrid(Orden As String)
|
|
If Orden <> String.Empty Then
|
|
Dim DV As New DataView(CType(ViewState("DTTiposEventos"), DataTable), "", Orden, DataViewRowState.CurrentRows)
|
|
GvDatos.DataSource = DV.ToTable()
|
|
DV.Dispose()
|
|
Else
|
|
GvDatos.DataSource = CType(ViewState("DTTiposEventos"), DataTable)
|
|
End If
|
|
GvDatos.DataBind()
|
|
UpDatos.Update()
|
|
End Sub
|
|
|
|
Protected Sub LbUsuario_Click(sender As Object, e As System.EventArgs) Handles LbUsuario.Click, ImgUsuario.Click
|
|
If ViewState("OUsuario").ToString() = "Usuario DESC" Then
|
|
ViewState("OUsuario") = "Usuario ASC"
|
|
ImgUsuario.ImageUrl = "/Imagenes/FlechasArriba.gif"
|
|
Else
|
|
ViewState("OUsuario") = "Usuario DESC"
|
|
ImgUsuario.ImageUrl = "/Imagenes/FlechasAbajo.gif"
|
|
End If
|
|
ViewState("Orden") = ViewState("OUsuario")
|
|
CargaGrid(ViewState("Orden").ToString())
|
|
End Sub
|
|
|
|
Protected Sub LbTipoReferencia_Click(sender As Object, e As System.EventArgs) Handles LbTipoReferencia.Click, ImgTipoReferencia.Click
|
|
If ViewState("OTipoReferencia").ToString() = "TipoReferencia DESC" Then
|
|
ViewState("OTipoReferencia") = "TipoReferencia ASC"
|
|
ImgTipoReferencia.ImageUrl = "/Imagenes/FlechasArriba.gif"
|
|
Else
|
|
ViewState("OTipoReferencia") = "TipoReferencia DESC"
|
|
ImgTipoReferencia.ImageUrl = "/Imagenes/FlechasAbajo.gif"
|
|
End If
|
|
ViewState("Orden") = ViewState("OTipoReferencia")
|
|
CargaGrid(ViewState("Orden").ToString())
|
|
End Sub
|
|
|
|
Protected Sub LbEstadoEvento_Click(sender As Object, e As System.EventArgs) Handles LbEstadoEvento.Click, ImgEstadoEvento.Click
|
|
If ViewState("OEstadoEvento").ToString() = "EstadoEvento DESC" Then
|
|
ViewState("OEstadoEvento") = "EstadoEvento ASC"
|
|
ImgEstadoEvento.ImageUrl = "/Imagenes/FlechasArriba.gif"
|
|
Else
|
|
ViewState("OEstadoEvento") = "EstadoEvento DESC"
|
|
ImgEstadoEvento.ImageUrl = "/Imagenes/FlechasAbajo.gif"
|
|
End If
|
|
ViewState("Orden") = ViewState("OEstadoEvento")
|
|
CargaGrid(ViewState("Orden").ToString())
|
|
End Sub
|
|
|
|
Protected Sub LbTipo_Click(sender As Object, e As System.EventArgs) Handles LbTipo.Click, ImgTipo.Click
|
|
If ViewState("OTipo").ToString() = "Tipo DESC" Then
|
|
ViewState("OTipo") = "Tipo ASC"
|
|
ImgTipo.ImageUrl = "/Imagenes/FlechasArriba.gif"
|
|
Else
|
|
ViewState("OTipo") = "Tipo DESC"
|
|
ImgTipo.ImageUrl = "/Imagenes/FlechasAbajo.gif"
|
|
End If
|
|
ViewState("Orden") = ViewState("OTipo")
|
|
CargaGrid(ViewState("Orden").ToString())
|
|
End Sub
|
|
|
|
Protected Sub LbFechaIng_Click(sender As Object, e As System.EventArgs) Handles LbFechaIng.Click, ImgFechaIng.Click
|
|
If ViewState("OFechaIng").ToString() = "FechaIng DESC" Then
|
|
ViewState("OFechaIng") = "FechaIng ASC"
|
|
ImgFechaIng.ImageUrl = "/Imagenes/FlechasArriba.gif"
|
|
Else
|
|
ViewState("OFechaIng") = "FechaIng DESC"
|
|
ImgFechaIng.ImageUrl = "/Imagenes/FlechasAbajo.gif"
|
|
End If
|
|
ViewState("Orden") = ViewState("OFechaIng")
|
|
CargaGrid(ViewState("Orden").ToString())
|
|
End Sub
|
|
|
|
Protected Sub GvDatos_RowEditing(sender As Object, e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GvDatos.RowEditing
|
|
GvDatos.EditIndex = e.NewEditIndex
|
|
|
|
If ViewState("Orden").ToString() <> String.Empty Then
|
|
CargaGrid(ViewState("Orden").ToString())
|
|
Else
|
|
CargaGrid("")
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub GvDatos_RowCancelingEdit(sender As Object, e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles GvDatos.RowCancelingEdit
|
|
GvDatos.EditIndex = -1
|
|
If ViewState("Orden").ToString() <> String.Empty Then
|
|
CargaGrid(ViewState("Orden").ToString())
|
|
Else
|
|
CargaGrid("")
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub GvDatos_RowUpdating(sender As Object, e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GvDatos.RowUpdating
|
|
|
|
Dim ObjTiposEventos As New ClsTiposEventos
|
|
|
|
Dim Tipo As String = DirectCast(GvDatos.Rows(e.RowIndex).FindControl("TxtTipo"), TextBox).Text.Trim
|
|
Dim TipoReferencia As String = DirectCast(GvDatos.Rows(e.RowIndex).FindControl("TxtTipoReferencia"), TextBox).Text.Trim
|
|
Dim Estado As Boolean = GvDatos.Rows(e.RowIndex).FCCheckBox("ChkEstado").Checked
|
|
Dim CveTipoEvento As Integer = GvDatos.DataKeys(e.RowIndex).Value.ToString.ToEntero
|
|
|
|
If ObjTiposEventos.UpdateTiposEventos(Tipo, TipoReferencia, Estado, CveTipoEvento) Then
|
|
GvDatos.EditIndex = -1
|
|
ViewState("DTTiposEventos") = ObjTiposEventos.DtResultados
|
|
GlobalDTTiposEventos = ObjTiposEventos.DtResultados
|
|
Alert("Los cambios se guardaron correctamente.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
|
|
ObjTiposEventos.Dispose()
|
|
|
|
If ViewState("Orden").ToString() <> String.Empty Then
|
|
CargaGrid(ViewState("Orden").ToString())
|
|
Else
|
|
CargaGrid("")
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Protected Sub GvDatos_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvDatos.RowDeleting
|
|
Dim ObjTiposEventos As New ClsTiposEventos
|
|
If ObjTiposEventos.RemoveTiposEventos(GvDatos.DataKeys(e.RowIndex).Value.ToString.ToEntero) Then
|
|
GvDatos.EditIndex = -1
|
|
ViewState("DTTiposEventos") = ObjTiposEventos.DtResultados
|
|
GlobalDTTiposEventos = ObjTiposEventos.DtResultados
|
|
Alert("El Registro se eliminó correctamente.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
|
|
ObjTiposEventos.Dispose()
|
|
|
|
If ViewState("Orden").ToString() <> String.Empty Then
|
|
CargaGrid(ViewState("Orden").ToString())
|
|
Else
|
|
CargaGrid("")
|
|
End If
|
|
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
|
|
If e.Row.RowIndex = 0 Then
|
|
e.Row.Cells(0).Width = Unit.Pixel(250)
|
|
e.Row.Cells(1).Width = Unit.Pixel(250)
|
|
e.Row.Cells(2).Width = Unit.Pixel(100)
|
|
e.Row.Cells(3).Width = Unit.Pixel(100)
|
|
e.Row.Cells(4).Width = Unit.Pixel(100)
|
|
e.Row.Cells(5).Width = Unit.Pixel(50)
|
|
e.Row.Cells(6).Width = Unit.Pixel(50)
|
|
End If
|
|
e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Left
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub LbAgregar_Click(sender As Object, e As System.EventArgs) Handles LbAgregar.Click
|
|
Dim ObjTiposEventos As New ClsTiposEventos
|
|
If ObjTiposEventos.AddTiposEventos(TxtTipo.Text.Trim, TxtTipoReferencia.Text.Trim, UsuarioActual.CveUsuario) Then
|
|
TxtTipo.Text = ""
|
|
Alert("El nuevo Departamento se guardó correctamente.", TipoMensaje.MsgInformacion)
|
|
UpTitulos.Update()
|
|
ViewState("DTTiposEventos") = ObjTiposEventos.DtResultados
|
|
GlobalDTTiposEventos = ObjTiposEventos.DtResultados
|
|
|
|
If ViewState("Orden").ToString() <> String.Empty Then
|
|
CargaGrid(ViewState("Orden").ToString())
|
|
Else
|
|
CargaGrid("")
|
|
End If
|
|
End If
|
|
ObjTiposEventos.Dispose()
|
|
End Sub
|
|
End Class
|