113 lines
4.4 KiB
VB.net
113 lines
4.4 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
Imports Extensiones
|
|
|
|
Partial Class General_CatMarcas
|
|
Inherits ClsPaginas
|
|
|
|
#Region "PROPIEDADES"
|
|
Private Property CveMarca() As Integer
|
|
Get
|
|
Return If(IsNothing(ViewState("CveMarca")), -1, CInt(ViewState("CveMarca")))
|
|
End Get
|
|
Set
|
|
ViewState("CveMarca") = Value
|
|
End Set
|
|
End Property
|
|
Private Property Modalidad() As String
|
|
Get
|
|
Return If(IsNothing(ViewState("Modalidad")), "", (ViewState("Modalidad").ToString))
|
|
End Get
|
|
Set
|
|
ViewState("Modalidad") = Value
|
|
End Set
|
|
End Property
|
|
#End Region
|
|
|
|
Private Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
|
|
If Not IsPostBack Then
|
|
CargaDatos()
|
|
End If
|
|
End Sub
|
|
|
|
#Region "CARGAS"
|
|
Private Sub CargaDatos()
|
|
Dim ObjPS As New ClsProductosServicios
|
|
If ObjPS.GetMarcas(UsuarioActual.CveEmpresa) Then
|
|
GvMarcas.DataSource = ObjPS.DtResultados
|
|
End If
|
|
ObjPS.Dispose()
|
|
GvMarcas.DataBind()
|
|
UpGvMarcas.Update()
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "BOTONES"
|
|
|
|
Protected Sub LnkEditar_Click(sender As Object, e As EventArgs)
|
|
LimpiaModal()
|
|
Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow)
|
|
CveMarca = gvRow.DataKey("CveMarca").ToEntero()
|
|
TxtMarca.Text = gvRow.DataKey("Marca")
|
|
ChkEstatus.Checked = CBool(gvRow.DataKey("Estatus"))
|
|
Modalidad = "U"
|
|
BtnGuardar.Text = "Actualizar"
|
|
DivEstatus.Visible = True
|
|
RegistraScript("$('#DModalMarca').modal()")
|
|
UpModal.Update()
|
|
End Sub
|
|
Protected Sub LnkEliminar_Click(sender As Object, e As EventArgs)
|
|
Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow)
|
|
Dim ObjPS As New ClsProductosServicios
|
|
Dim CveMarca = gvRow.DataKey("CveMarca").ToEntero
|
|
If ObjPS.RemoveMarca(CveMarca) Then
|
|
Alert("Se borró correctamente de la base de Datos.", TipoMensaje.MsgInformacion)
|
|
Else
|
|
Alert("La marca esta siendo utilizada por un Producto", TipoMensaje.MsgError)
|
|
End If
|
|
ObjPS.Dispose()
|
|
CargaDatos()
|
|
End Sub
|
|
|
|
Protected Sub LnkAgregarMarca_Click(sender As Object, e As EventArgs)
|
|
LimpiaModal()
|
|
Modalidad = "A"
|
|
BtnGuardar.Text = "Agregar"
|
|
DivEstatus.Visible = False
|
|
UpModal.Update()
|
|
RegistraScript("$('#DModalMarca').modal()")
|
|
End Sub
|
|
Protected Sub BtnGuardar_Click(sender As Object, e As EventArgs)
|
|
Dim ObjPS As New ClsProductosServicios
|
|
If Modalidad = "A" Then
|
|
If ObjPS.AddMarcas(TxtMarca.Text, True, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
|
|
RegistraScript("$('#DModalMarca').modal('hide')")
|
|
Alert("La Marca se agregó correctamente.", TipoMensaje.MsgInformacion)
|
|
CargaDatos()
|
|
End If
|
|
ElseIf Modalidad = "U" Then
|
|
If ObjPS.UpdateMarca(TxtMarca.Text, CveMarca, ChkEstatus.Checked) Then
|
|
RegistraScript("$('#DModalMarca').modal('hide')")
|
|
Alert("La Marca se actualizo correctamente.", TipoMensaje.MsgInformacion)
|
|
CargaDatos()
|
|
End If
|
|
End If
|
|
ObjPS.Dispose()
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "LIMPIAR"
|
|
Protected Sub LimpiaModal()
|
|
TxtMarca.Text = ""
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "GRIDVIEW"
|
|
Protected Sub GvMarcas_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvMarcas.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
If e.Row.DBCampo("Estatus") = "True" Then
|
|
e.Row.Cells(1).ForeColor = Drawing.Color.Green
|
|
e.Row.Cells(1).Font.Bold = True
|
|
e.Row.Cells(1).Text = "Activo"
|
|
Else
|
|
e.Row.Cells(1).Text = "Inactivo"
|
|
e.Row.Cells(1).ForeColor = Drawing.Color.Red
|
|
e.Row.Cells(1).Font.Bold = True
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "IMPRESIONES"
|
|
Protected Sub LnkExportar_Click(sender As Object, e As EventArgs) Handles LnkExportar.Click
|
|
GvMarcas.ExportToExcel("CatMarcas_" & Now.ToShortDateString())
|
|
End Sub
|
|
#End Region
|
|
|
|
End Class
|