Option Strict On Imports System.Data Imports System.Collections.Generic Imports System.Linq Imports System.Web Imports System.Web.UI.WebControls Imports Extensiones Partial Class CATEstatus Inherits ClsPaginas #Region "Propiedades" Property CveEstatus As Integer Get If Not ViewState("CveEstatus") Is Nothing Then Return ViewState("CveEstatus").ToString.ToEntero Else Return -1 End If End Get Set(value As Integer) ViewState("CveEstatus") = value End Set End Property #End Region Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load If Not IsPostBack Then CargaEstatus() End If End Sub Protected Sub CargaEstatus() Dim ObjEsta As New ClsCGame() If ObjEsta.GetEstatus(UsuarioActual.CveEmpresa) Then GVEstatus.DataSource = ObjEsta.DtResultados GVEstatus.DataBind() End If ObjEsta.Dispose() upDatosEsta.Update() End Sub Protected Sub LimpiaEstatus() TxtEstaestatus.Text = "" UPModalEsta.Update() End Sub Protected Sub LnkEditarEsta_Click(sender As Object, e As EventArgs) LimpiaEstatus() Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) CveEstatus = gvRow.DataKey("CveEstatus").ToEntero() Dim estatus As String = gvRow.DataKey("Estatus") Dim estado As Boolean = CBool(gvRow.DataKey("Estado")) Dim fechaIng As DateTime = gvRow.DataKey("FechaIng").ToDateTime() Dim cveUsuario As Int32 = gvRow.DataKey("CveUsuario").ToEntero() Dim cveEmpresa As Int32 = gvRow.DataKey("CveEmpresa").ToEntero() TxtEstaestatus.Text = gvRow.DataKey("Estatus") ChkEstaestado.Checked = CBool(gvRow.DataKey("Estado")) RegistraScript("$('#DModalEstatus').modal()") BtnEstaADD.Visible = False BtnEstaEdit.Visible = True DivEstado.Visible = True UPModalEsta.Update() End Sub Protected Sub LnkAgregarEsta_Click(sender As Object, e As EventArgs) RegistraScript("$('#DModalEstatus').modal()") LimpiaEstatus() BtnEstaADD.Visible = True BtnEstaEdit.Visible = False DivEstado.Visible = False UPModalEsta.Update() End Sub Protected Sub BtnEstaADD_Click(sender As Object, e As EventArgs) Dim ObjEsta As New ClsCGame() Dim Continuar As Boolean = ObjEsta.AddEstatus(TxtEstaestatus.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) ObjEsta.Dispose() If (Continuar) Then RegistraScript("$('#DModalEstatus').modal('hide')") LimpiaEstatus() UPModalEsta.Update() Alert("El Estatus se ha agregado") CargaEstatus() End If End Sub Protected Sub BtnEstaEdit_Click(sender As Object, e As EventArgs) Dim ObjEsta As New ClsCGame() Dim Continuar As Boolean = ObjEsta.UpdateEstatus(CveEstatus, TxtEstaestatus.Text, ChkEstaestado.Checked, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) ObjEsta.Dispose() If (Continuar) Then RegistraScript("$('#DModalEstatus').modal('hide')") LimpiaEstatus() UPModalEsta.Update() Alert("El Estatus se ha actualizado") CargaEstatus() End If End Sub Protected Sub LnkEliminarEsta_Click(sender As Object, e As EventArgs) Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) CveEstatus = gvRow.DataKey("CveEstatus").ToEntero() Dim ObjEsta As New ClsCGame() Dim Continuar As Boolean = ObjEsta.RemoveEstatus(CveEstatus) ObjEsta.Dispose() If (Continuar) Then Alert("El Estatus se ha eliminado") CargaEstatus() End If End Sub Private Sub GVEstatus_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GVEstatus.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then If CBool(e.Row.DBCampo("Estado")) = True Then e.Row.FCLabel("lblestado").Text = "Activo" e.Row.FCLabel("lblestado").ForeColor = Drawing.Color.Green Else e.Row.FCLabel("lblestado").Text = "Inactivo" e.Row.FCLabel("lblestado").ForeColor = Drawing.Color.Red End If End If End Sub End Class