121 lines
4.9 KiB
VB.net
121 lines
4.9 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
Imports Extensiones
|
|
Partial Class General_CatModelos
|
|
Inherits ClsPaginas
|
|
|
|
#Region "PROPIEDADES"
|
|
Private Property CveModelo() As Integer
|
|
Get
|
|
Return If(IsNothing(ViewState("CveModelo")), -1, CInt(ViewState("CveModelo")))
|
|
End Get
|
|
Set
|
|
ViewState("CveModelo") = 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
|
|
CargaCombos()
|
|
CargaDatos()
|
|
End If
|
|
End Sub
|
|
|
|
#Region "CARGAS"
|
|
Private Sub CargaCombos()
|
|
Dim ObjPS As New ClsProductosServicios()
|
|
If ObjPS.GetMarcas(UsuarioActual.CveEmpresa) Then
|
|
DdlMarca.DataSource = ObjPS.DtResultados
|
|
End If
|
|
ObjPS.Dispose()
|
|
DdlMarca.DataBind()
|
|
UpModal.Update()
|
|
End Sub
|
|
Private Sub CargaDatos()
|
|
Dim ObjGral As New ClsGenerales
|
|
If ObjGral.GetModelos(UsuarioActual.CveEmpresa) Then
|
|
GvDatos.DataSource = ObjGral.DtResultados
|
|
End If
|
|
ObjGral.Dispose()
|
|
GvDatos.DataBind()
|
|
UpDatos.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)
|
|
CveModelo = gvRow.DataKey("CveModelo").ToEntero()
|
|
TxtModelo.Text = gvRow.DataKey("Modelo")
|
|
TxtCodigo.Text = gvRow.DataKey("Codigo")
|
|
DdlMarca.SelectedValueExist(gvRow.DataKey("CveMarca"))
|
|
ChkEstatus.Checked = CBool(gvRow.DataKey("Estatus"))
|
|
Modalidad = "U"
|
|
BtnGuardar.Text = "Actualizar"
|
|
ltlMotititulo.Text = "Actualizar Modelo"
|
|
DivEstatus.Visible = True
|
|
RegistraScript("$('#DModal').modal('show')")
|
|
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 ClsGenerales
|
|
Dim CveMarca = gvRow.DataKey("CveModelo").ToEntero
|
|
If ObjPS.RemoveModelos(CveMarca) Then
|
|
Alert("El modelo se eliminó correctamente.", TipoMensaje.MsgInformacion)
|
|
Else
|
|
Alert("El modelo esta siendo utilizada por un Producto", TipoMensaje.MsgError)
|
|
End If
|
|
ObjPS.Dispose()
|
|
CargaDatos()
|
|
End Sub
|
|
|
|
Protected Sub LnkAgregar_Click(sender As Object, e As EventArgs)
|
|
LimpiaModal()
|
|
Modalidad = "A"
|
|
BtnGuardar.Text = "Agregar"
|
|
ltlMotititulo.Text = "Agregar Modelo"
|
|
DivEstatus.Visible = False
|
|
UpModal.Update()
|
|
RegistraScript("$('#DModal').modal()")
|
|
End Sub
|
|
Protected Sub BtnGuardar_Click(sender As Object, e As EventArgs)
|
|
Dim ObjPS As New ClsGenerales
|
|
If Modalidad = "A" Then
|
|
If ObjPS.AddModelos(DdlMarca.SelectedValue.ToEntero(), TxtCodigo.Text.Trim(), TxtModelo.Text.Trim(), True, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
|
|
RegistraScript("$('#DModal').modal('hide')")
|
|
Alert("El modelo se agregó correctamente.", TipoMensaje.MsgInformacion)
|
|
|
|
End If
|
|
ElseIf Modalidad = "U" Then
|
|
If ObjPS.UpdateModelos(CveModelo, DdlMarca.SelectedValue.ToEntero(), TxtCodigo.Text.Trim(), TxtModelo.Text.Trim(), ChkEstatus.Checked, UsuarioActual.CveUsuario) Then
|
|
RegistraScript("$('#DModal').modal('hide')")
|
|
Alert("El modelo se actualizo correctamente.", TipoMensaje.MsgInformacion)
|
|
|
|
End If
|
|
End If
|
|
ObjPS.Dispose()
|
|
CargaDatos()
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "LIMPIAR"
|
|
Protected Sub LimpiaModal()
|
|
TxtModelo.Text = ""
|
|
TxtCodigo.Text = ""
|
|
DdlMarca.SelectedValueExist("-1")
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "GRIDVIEW"
|
|
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.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
|
|
End Class
|