Imports Extensiones Partial Class Sistemas_CatPlataformas Inherits ClsPaginas #Region "Propiedades" Public Property CvePlataforma As Integer Get Return ViewState("CvePlataforma").ToString.ToEntero End Get Set(value As Integer) ViewState("CvePlataforma") = 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 CvePlataforma = -1 EsEditar = 0 CargaDatos(-1) End If End Sub Private Sub CargaDatos(CvePlataforma As Integer) Dim Plataforma As New ClsSisEmpresas If Plataforma.GetPlataforma(CvePlataforma, "-1") Then GvDatos.DataSource = Plataforma.DtResultados Else GvDatos.DataSource = Nothing End If Plataforma.Dispose() GvDatos.DataBind() End Sub Protected Sub imgE_Click(sender As Object, e As EventArgs) Dim Boton = CType(sender, LinkButton) CvePlataforma = Boton.CommandArgument.ToEntero Dim GvRow As GridViewRow = DirectCast(Boton.NamingContainer, GridViewRow) TxtPlataforma.Text = GvRow.DataKey("Plataforma").ToString EsEditar = 1 BtnAgregarPlataforma.Text = "Actualizar" UpBodyEstatus.Update() UpFooter.Update() RegistraScript("$('#divAgregar').modal()") End Sub Protected Sub BtnAgregarPlataforma_Click(sender As Object, e As EventArgs) Handles BtnAgregarPlataforma.Click Dim Plataforma As New ClsSisEmpresas If EsEditar = 0 Then If Plataforma.AddPlataforma(TxtPlataforma.Text.Trim) Then Alert("La plataforma se agregó correctamente", TipoMensaje.MsgInformacion) Else Alert("Ocurrió un error al agregar la plataforma", TipoMensaje.MsgError) End If ElseIf EsEditar = 1 Then If Plataforma.UpdatePlataforma(CvePlataforma, TxtPlataforma.Text) Then Alert("La plataforma se editó correctamente", TipoMensaje.MsgInformacion) Else Alert("Ocurrió un error al editar la plataforma", TipoMensaje.MsgError) End If EsEditar = 0 BtnAgregarPlataforma.Text = "Agregar" End If RegistraScript("$('#divAgregar').modal('hide')") Plataforma.Dispose() TxtPlataforma.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 Plataforma As New ClsSisEmpresas Dim CvePlataforma As Integer = GvDatos.Rows(e.RowIndex).DataKey("CvePlataforma").ToEntero If Plataforma.DeletePlataforma(CvePlataforma) Then Alert("La plataforma se eliminó correctamente", TipoMensaje.MsgInformacion) End If Plataforma.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("CvePlataforma").ToString End If End Sub Protected Sub btnCancelar_Click(sender As Object, e As EventArgs) Handles btnCancelar.Click EsEditar = 0 RegistraScript("$('#divAgregar').modal('hide')") BtnAgregarPlataforma.Text = "Agregar" UpBodyEstatus.Update() UpFooter.Update() End Sub End Class