Option Explicit On Option Strict On Imports Extensiones Partial Class Ventas_CatSelectivas Inherits ClsPaginas Private Property CveSelectiva As Integer Get Return (IfNull(ViewState("CveSelectiva"), "-1", ViewState("CveSelectiva"))).ToString().ToEntero() End Get Set(value As Integer) ViewState("CveSelectiva") = value End Set End Property Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then CargaDatos() End If End Sub Private Sub CargaDatos() LimpiaDatos() Dim ObjGral As New ClsProductosServicios() If ObjGral.GetSelectiva(-1, UsuarioActual.CveEmpresa) Then GvDatos.DataSource = ObjGral.DtResultados.Copy() End If ObjGral.Dispose() GvDatos.DataBind() UpDatos.Update() End Sub Protected Sub GvDatos_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) Dim GvRow As GridViewRow = GvDatos.Rows(e.RowIndex) CveSelectiva = GvRow.DataKey("CveSelectiva").ToEntero() Using ObjVentas As New ClsProductosServicios If ObjVentas.RemoveSelectiva(CveSelectiva, UsuarioActual.CveEmpresa) Then Alert("Se eliminó correctamente") End If End Using CargaDatos() End Sub Protected Sub imgE_Click(sender As Object, e As EventArgs) Dim GvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) CveSelectiva = GvRow.DataKey("CveSelectiva").ToEntero() TxtSelectiva.Text = GvRow.DataKey("Selectiva") UpModal.Update() RegistraScript("$('#DivDatos').modal('show');") End Sub Private Sub LimpiaDatos() CveSelectiva = -1 TxtSelectiva.Text = "" End Sub Protected Sub BtnGuardar_Click(sender As Object, e As EventArgs) Dim ObjVentas As New ClsProductosServicios If CveSelectiva = -1 Then If ObjVentas.AddSelectiva(TxtSelectiva.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then Alert("La selectiva se agrego correctamente") End If Else If ObjVentas.UpdateSelectiva(CveSelectiva, TxtSelectiva.Text, UsuarioActual.CveEmpresa) Then Alert("La selectiva se actualizó correctamente") End If End If ObjVentas.Dispose() RegistraScript("$('#DivDatos').modal('hide');") CargaDatos() End Sub Protected Sub LnkAgregar_Click(sender As Object, e As EventArgs) LimpiaDatos() RegistraScript("$('#DivDatos').modal('show');") End Sub End Class