122 lines
4.8 KiB
VB.net
122 lines
4.8 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
|
|
Imports System.Data
|
|
Imports System.Linq
|
|
Imports Extensiones
|
|
|
|
Partial Class General_CatCategorias
|
|
Inherits ClsPaginas
|
|
|
|
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 RecargaGlobal()
|
|
Dim ObjCategorias As New ClsGenerales
|
|
If ObjCategorias.GetCategorias(-1) Then
|
|
GlobalDTGralCategorias(-1) = ObjCategorias.DtResultados
|
|
End If
|
|
ObjCategorias.Dispose()
|
|
End Sub
|
|
|
|
Public Sub CargaDatos()
|
|
Dim ObjCategorias As New ClsGenerales
|
|
If ObjCategorias.GetCategorias(UsuarioActual.CveEmpresa) Then
|
|
GvDatos.DataSource = ObjCategorias.DtResultados
|
|
GvDatos.DataBind()
|
|
Else
|
|
GvDatos.DataSource = Nothing
|
|
End If
|
|
UpDatos.Update()
|
|
ObjCategorias.Dispose()
|
|
End Sub
|
|
|
|
Protected Sub LbAgregar_Click(sender As Object, e As System.EventArgs) Handles LbAgregar.Click
|
|
Dim ObjCategorias As New ClsGenerales
|
|
|
|
If HdnModalidadCategoria.Value = "A" Then
|
|
If ObjCategorias.AddCategorias(TxtCategoria.Text.Trim, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
|
|
TxtCategoria.Text = ""
|
|
Alert("El nueva Categoría se guardó correctamente.", TipoMensaje.MsgInformacion)
|
|
GlobalDTGralCategorias(UsuarioActual.CveEmpresa) = Nothing
|
|
End If
|
|
ElseIf HdnModalidadCategoria.Value = "U" Then
|
|
If ObjCategorias.UpdateCategoria(TxtCategoria.Text.Trim, ChkEstatus.Checked, HdnIDCategoria.Value.ToEntero) Then
|
|
TxtCategoria.Text = ""
|
|
ChkEstatus.Checked = True
|
|
Alert("La Categoría se actualizó correctamente.", TipoMensaje.MsgInformacion)
|
|
GlobalDTGralCategorias(UsuarioActual.CveEmpresa) = Nothing
|
|
End If
|
|
End If
|
|
|
|
CargaDatos()
|
|
RecargaGlobal()
|
|
UpModal.Update()
|
|
ObjCategorias.Dispose()
|
|
End Sub
|
|
|
|
#Region "G V D A T O S"
|
|
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(100)
|
|
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(65)
|
|
End If
|
|
e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Left
|
|
e.Row.Cells(1).HorizontalAlign = HorizontalAlign.Center
|
|
e.Row.Cells(2).HorizontalAlign = HorizontalAlign.Center
|
|
e.Row.Cells(3).HorizontalAlign = HorizontalAlign.Center
|
|
e.Row.Cells(4).HorizontalAlign = HorizontalAlign.Center
|
|
e.Row.Cells(5).HorizontalAlign = HorizontalAlign.Center
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub GvDatos_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvDatos.RowDeleting
|
|
Dim ObjCategorias As New ClsGenerales
|
|
If ObjCategorias.RemoveCategorias(GvDatos.DataKeys(e.RowIndex).Value.ToString.ToEntero) Then
|
|
GvDatos.EditIndex = -1
|
|
CargaDatos()
|
|
RecargaGlobal()
|
|
Alert("La Categoría se eliminó correctamente.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
ObjCategorias.Dispose()
|
|
End Sub
|
|
|
|
|
|
Private Sub HlAgregarCategorias(sender As Object, e As EventArgs) Handles HlAgregarCategoria.Click
|
|
TxtCategoria.Text = ""
|
|
LtlTituloModal.Text = "Agregar Categoría"
|
|
LbAgregar.Text = "Agregar"
|
|
HdnModalidadCategoria.Value = "A"
|
|
UpModal.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal();", "ModalCategorias"))
|
|
End Sub
|
|
|
|
Public Sub ActualizaCategoria(sender As Object, e As EventArgs)
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
Dim CveCategoria As String = GvRow.DataKey("CveCategoria").ToString
|
|
Dim Categoria As String = GvRow.DataKey("Categoria").ToString
|
|
Dim Estatus As String = GvRow.DataKey("Estatus").ToString
|
|
|
|
If Estatus = "Activo" Then ChkEstatus.Checked = True Else ChkEstatus.Checked = False
|
|
TxtCategoria.Text = Categoria
|
|
HdnIDCategoria.Value = CveCategoria
|
|
HdnModalidadCategoria.Value = "U"
|
|
LtlTituloModal.Text = "Actualizar Categoría"
|
|
LbAgregar.Text = "Actualizar"
|
|
UpModal.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal();", "ModalCategorias"))
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
End Class
|