145 lines
5.0 KiB
VB.net
145 lines
5.0 KiB
VB.net
Imports Extensiones
|
|
Imports System.Data
|
|
|
|
Partial Class Sistemas_CatDistribuidores
|
|
Inherits ClsPaginas
|
|
|
|
|
|
#Region "Propiedades"
|
|
Public Property CveDistribuidor As Integer
|
|
Get
|
|
Return ViewState("CveDistribuidor").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveDistribuidor") = value
|
|
End Set
|
|
End Property
|
|
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
|
|
CveDistribuidor = -1
|
|
CvePlataforma = -1
|
|
EsEditar = 0
|
|
CargaCombos()
|
|
CargaDatos(-1)
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub CargaCombos()
|
|
Dim Plataforma As New ClsSisEmpresas
|
|
If Plataforma.GetPlataforma(CvePlataforma, "-1") Then
|
|
DdlPlataforma.DataSource = Plataforma.DtResultados
|
|
Else
|
|
DdlPlataforma.DataSource = Nothing
|
|
End If
|
|
|
|
Plataforma.Dispose()
|
|
DdlPlataforma.DataBind()
|
|
DdlPlataforma.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
DdlPlataforma.SelectedValue = "-1"
|
|
End Sub
|
|
|
|
Private Sub CargaDatos(CvePlataforma As Integer)
|
|
|
|
Dim Plataforma As New ClsSisEmpresas
|
|
|
|
|
|
If Plataforma.GetDistribuidor(-1, "-1", -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)
|
|
CveDistribuidor = Boton.CommandArgument.ToEntero
|
|
Dim GvRow As GridViewRow = DirectCast(Boton.NamingContainer, GridViewRow)
|
|
TxtDistribuidor.Text = GvRow.DataKey("Distribuidor").ToString
|
|
DdlPlataforma.SelectedValueExist(GvRow.DataKey("CvePlataforma").ToString)
|
|
EsEditar = 1
|
|
BtnAgregarDistribuidor.Text = "Actualizar"
|
|
UpBodyEstatus.Update()
|
|
UpFooter.Update()
|
|
RegistraScript("$('#divAgregar').modal()")
|
|
End Sub
|
|
|
|
Protected Sub BtnAgregarDistribuidor_Click(sender As Object, e As EventArgs) Handles BtnAgregarDistribuidor.Click
|
|
Dim Plataforma As New ClsSisEmpresas
|
|
|
|
If EsEditar = 0 Then
|
|
If Plataforma.AddDistribuidor(TxtDistribuidor.Text.Trim, DdlPlataforma.SelectedValue.ToEntero) Then
|
|
Alert("El distribuidor se agregó correctamente", TipoMensaje.MsgInformacion)
|
|
Else
|
|
Alert("Ocurrió un error al agregar el distribuidor", TipoMensaje.MsgError)
|
|
End If
|
|
ElseIf EsEditar = 1 Then
|
|
If Plataforma.UpdateDistribuidor(CveDistribuidor, DdlPlataforma.SelectedValue.ToEntero, TxtDistribuidor.Text) Then
|
|
Alert("el distribuidor se editó correctamente", TipoMensaje.MsgInformacion)
|
|
Else
|
|
Alert("Ocurrió un error al editar el distribuidor", TipoMensaje.MsgError)
|
|
End If
|
|
EsEditar = 0
|
|
BtnAgregarDistribuidor.Text = "Agregar"
|
|
End If
|
|
RegistraScript("$('#divAgregar').modal('hide')")
|
|
Plataforma.Dispose()
|
|
TxtDistribuidor.Text = ""
|
|
DdlPlataforma.SelectedValue = "-1"
|
|
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 CveDistribuidor As Integer = GvDatos.Rows(e.RowIndex).DataKey("CveDistribuidor").ToEntero
|
|
If Plataforma.DeleteDistribuidor(CveDistribuidor) 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("CveDistribuidor").ToString
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub btnCancelar_Click(sender As Object, e As EventArgs) Handles btnCancelar.Click
|
|
EsEditar = 0
|
|
TxtDistribuidor.Text = ""
|
|
DdlPlataforma.SelectedValue = "-1"
|
|
RegistraScript("$('#divAgregar').modal('hide')")
|
|
BtnAgregarDistribuidor.Text = "Agregar"
|
|
UpBodyEstatus.Update()
|
|
UpFooter.Update()
|
|
End Sub
|
|
|
|
End Class
|