Option Strict On Imports Extensiones Imports System.Data Partial Class GPS_CatControlesGraficos Inherits ClsPaginas #Region "Propiedades" Public Property CveControladorGrafico As Integer Get Return ViewState("CveControladorGrafico").ToString.ToEntero End Get Set(value As Integer) ViewState("CveControladorGrafico") = 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 CveControladorGrafico = -1 EsEditar = 0 dvEstatus.Visible = False CargaDatos(-1) End If End Sub Private Sub CargaDatos(CveConductor As Integer) Dim GPS As New ClsGPS If GPS.ControladorGraficoGet(-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) CveControladorGrafico = Boton.CommandArgument.ToEntero Dim GvRow As GridViewRow = DirectCast(Boton.NamingContainer, GridViewRow) TxtControladorGrafico.Text = GvRow.DataKey("ControladorGrafico").ToString TxtUM.Text = GvRow.DataKey("UM").ToString chkEstatus.Checked = CBool(GvRow.DataKey("Estatus")) 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.ControladorGraficoAdd(TxtControladorGrafico.Text.Trim, TxtUM.Text.Trim) Then Alert("El Controlador Gráfico se agregó correctamente", TipoMensaje.MsgInformacion) End If ElseIf EsEditar = 1 Then If GPS.ControladorGraficoUpdate(TxtControladorGrafico.Text.Trim, TxtUM.Text.Trim, CveControladorGrafico, chkEstatus.Checked) Then Alert("El Controlador Gráfico se editó correctamente", TipoMensaje.MsgInformacion) End If EsEditar = 0 dvEstatus.Visible = False BtnAgregarCatalogo.Text = "Agregar" End If RegistraScript("$('#divAgregar').modal('hide')") GPS.Dispose() TxtControladorGrafico.Text = "" TxtUM.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 CveControladorGrafico As Integer = GvDatos.Rows(e.RowIndex).DataKey("CveControladorGrafico").ToEntero If GPS.ControladorGraficoDelete(CveControladorGrafico) Then Alert("El Controlador Gráfico 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("CveControladorGrafico").ToString If CBool(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 btnCancelar.Click EsEditar = 0 RegistraScript("$('#divAgregar').modal('hide')") BtnAgregarCatalogo.Text = "Agregar" TxtControladorGrafico.Text = "" TxtUM.Text = "" dvEstatus.Visible = False UpBodyEstatus.Update() UpFooter.Update() End Sub End Class