186 lines
8.0 KiB
VB.net
186 lines
8.0 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
|
|
Imports System.Data
|
|
Imports Extensiones
|
|
|
|
|
|
Partial Class Inventarios_CatSeccionesAlmacenes
|
|
Inherits ClsPaginas
|
|
|
|
Private Property CveSeccionAEditar() As Integer 'Guardamos el ID de registro para saber cual registro Editar
|
|
Get
|
|
Return If(IsNothing(ViewState("CveSeccionAEditar")), -1, CInt(ViewState("CveSeccionAEditar")))
|
|
End Get
|
|
Set
|
|
ViewState("CveSeccionAEditar") = Value
|
|
End Set
|
|
End Property
|
|
|
|
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
|
|
If Not Page.IsPostBack Then
|
|
ViewState("Orden") = ""
|
|
DdlAlmacen.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa)
|
|
DdlAlmacen.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
DdlAlmacen.DataBind()
|
|
CargaDatos()
|
|
End If
|
|
End Sub
|
|
|
|
Public Sub CargaDatos()
|
|
Dim ObjSeccion As New ClsInventarios
|
|
If ObjSeccion.GetSeccionesAlmacenes(-1) Then
|
|
ViewState("DTSeccionesAlmacenes") = ObjSeccion.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
|
GlobalDTSeccionAlmacen(-1) = ObjSeccion.DtResultados
|
|
Else
|
|
GvDatos.DataSource = Nothing
|
|
End If
|
|
ObjSeccion.Dispose()
|
|
If ViewState("Orden").ToString() <> String.Empty Then
|
|
CargaGrid(ViewState("Orden").ToString())
|
|
Else
|
|
CargaGrid("")
|
|
End If
|
|
End Sub
|
|
Protected Sub BtnAgregarMotivo_Click(sender As Object, e As EventArgs) Handles BtnAgregarMotivoD.Click 'Hacemos aparecer la ventana modal con los campos limpios
|
|
BtnEditarTiposDModal.Visible = False
|
|
BtnAgregarTiposDModal.Visible = True
|
|
CheckActiveSection.Visible = False
|
|
saltoDeLinea.Visible = False
|
|
SeccionTxt.Text = ""
|
|
DdlAlmacen.SelectedIndex = 0
|
|
UpModalTiposD.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarTiposD"))
|
|
|
|
End Sub
|
|
|
|
Protected Sub LbAgregar_Click(ByVal sender As Object, ByVal e As EventArgs) Handles BtnAgregarTiposDModal.Click 'esta funcion es la que agrega un nuevo motivo de baja se activa con el boton "Agregar" de la ventana modal"
|
|
Dim ObjSeccion As New ClsInventarios
|
|
If ObjSeccion.AddSeccion(SeccionTxt.Text.Trim, DdlAlmacen.SelectedValue.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
|
|
SeccionTxt.Text = ""
|
|
DdlAlmacen.SelectedIndex = 0
|
|
Alert("La Seccion se guardó correctamente.", TipoMensaje.MsgInformacion)
|
|
|
|
ViewState("DTSeccionesAlmacenes") = ObjSeccion.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
|
GlobalDTSeccionAlmacen(-1) = ObjSeccion.DtResultados
|
|
|
|
If ViewState("Orden").ToString() <> String.Empty Then
|
|
CargaGrid(ViewState("Orden").ToString())
|
|
Else
|
|
CargaGrid("")
|
|
End If
|
|
End If
|
|
ObjSeccion.Dispose()
|
|
End Sub
|
|
|
|
Public Sub imgE_Click(ByVal sender As Object, ByVal e As EventArgs) 'Este metodo muestra la pantalla modal con la información del renglon ya puesta en los campos del formulario
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) 'obtenemos el renglon que acabamos de seleccionar
|
|
BtnAgregarTiposDModal.Visible = False
|
|
BtnEditarTiposDModal.Visible = True
|
|
CheckActiveSection.Visible = True
|
|
saltoDeLinea.Visible = True
|
|
|
|
SeccionTxt.Text = GvRow.DataKey("Seccion")
|
|
ChkEstatus.Checked = ChkEstatus.Checked
|
|
CveSeccionAEditar = Convert.ToInt32(GvRow.DataKey("CveSeccion")) 'Guardamos en una propiedad el id del registro del cual haremos cambios, se guarda y se utiliza en el metodo "GvDatos_RowUpdating"
|
|
DdlAlmacen.SelectedValueExist(GvRow.DataKey("CveAlmacen"))
|
|
|
|
UpDatos.Update()
|
|
If ViewState("Orden").ToString() <> String.Empty Then
|
|
CargaGrid(ViewState("Orden").ToString())
|
|
Else
|
|
CargaGrid("")
|
|
End If
|
|
RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarTiposD"))
|
|
End Sub
|
|
|
|
Protected Sub BtnEditarTiposDModal_Click(ByVal sender As Object, ByVal e As EventArgs) Handles BtnEditarTiposDModal.Click
|
|
Dim ObjSeccion As New ClsInventarios
|
|
Dim Seccion As String = ""
|
|
Dim CveSeccion As Integer = 0
|
|
Dim Estatus As Boolean = False
|
|
Seccion = SeccionTxt.Text.Trim
|
|
Estatus = ChkEstatus.Checked
|
|
CveSeccion = CveSeccionAEditar
|
|
|
|
If ObjSeccion.UpdateSeccion(Seccion, DdlAlmacen.SelectedValue.ToEntero, Estatus, CveSeccion) Then
|
|
SeccionTxt.Text = ""
|
|
DdlAlmacen.SelectedIndex = 0
|
|
Alert("La Seccion se actualizo correctamente.", TipoMensaje.MsgInformacion)
|
|
ViewState("DTSeccionesAlmacenes") = ObjSeccion.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
|
GlobalDTSeccionAlmacen(-1) = ObjSeccion.DtResultados
|
|
End If
|
|
|
|
ObjSeccion.Dispose()
|
|
|
|
If ViewState("Orden").ToString() <> String.Empty Then
|
|
CargaGrid(ViewState("Orden").ToString())
|
|
Else
|
|
CargaGrid("")
|
|
End If
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarTiposD"))
|
|
End Sub
|
|
|
|
#Region "G V D A T O S"
|
|
Protected Sub GvDatos_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles GvDatos.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
|
|
End If
|
|
End Sub
|
|
|
|
Public Sub imgD_Click(ByVal sender As Object, ByVal e As EventArgs)
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
Dim ObjSeccion As New ClsInventarios
|
|
If ObjSeccion.RemoveSeccion(GvRow.DataKey("CveSeccion").ToString.ToEntero) Then
|
|
Alert("La Seccion se elimino correctamente.", TipoMensaje.MsgInformacion)
|
|
ViewState("DTSeccionesAlmacenes") = ObjSeccion.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
|
GlobalDTSeccionAlmacen(-1) = ObjSeccion.DtResultados
|
|
End If
|
|
ObjSeccion.Dispose()
|
|
If ViewState("Orden").ToString() <> String.Empty Then
|
|
CargaGrid(ViewState("Orden").ToString())
|
|
Else
|
|
CargaGrid("")
|
|
End If
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "O R D E N A M I E N T O"
|
|
Protected Sub LbOrden_Click(ByVal sender As Object, ByVal e As EventArgs)
|
|
Dim Orden As String = ""
|
|
Dim Campo As String = ""
|
|
Dim Literal As Literal = Nothing
|
|
Const OrdenInicial As String = ""
|
|
Dim Arg(2) As String
|
|
|
|
Arg = CType(sender, LinkButton).CommandArgument().ToString.Split(";"c)
|
|
Campo = Arg(0)
|
|
Literal = CType(CType(sender, LinkButton).NamingContainer.FindControl("Img" & Campo.Replace(",", "_")), Literal)
|
|
|
|
If ViewState(String.Format("O{0}", Campo)) IsNot Nothing AndAlso ViewState(String.Format("O{0}", Campo)).ToString = String.Format("{0} DESC", Campo) Then
|
|
ViewState(String.Format("O{0}", Campo)) = String.Format("{0} ASC", Campo)
|
|
Literal.Text = String.Format("<i class='fa fa-sort-asc' style='color:#999' ></i>")
|
|
Else
|
|
ViewState(String.Format("O{0}", Campo)) = String.Format("{0} DESC", Campo)
|
|
Literal.Text = String.Format("<i class='fa fa-sort-desc' style='color:#999' ></i>")
|
|
End If
|
|
Orden = OrdenInicial & ViewState(String.Format("O{0}", Campo)).ToString
|
|
ViewState("Orden") = Orden
|
|
CargaGrid(Orden)
|
|
End Sub
|
|
|
|
Private Sub CargaGrid(ByVal Orden As String)
|
|
If Orden <> String.Empty Then
|
|
Dim DV As New DataView(CType(ViewState("DTSeccionesAlmacenes"), DataTable), "", Orden, DataViewRowState.CurrentRows)
|
|
GvDatos.DataSource = DV.ToTable()
|
|
DV.Dispose()
|
|
Else
|
|
GvDatos.DataSource = CType(ViewState("DTSeccionesAlmacenes"), DataTable)
|
|
End If
|
|
|
|
GvDatos.DataBind()
|
|
UpDatos.Update()
|
|
End Sub
|
|
#End Region
|
|
End Class |