Kardex siguiente siguiente PS con movimientos

This commit is contained in:
rakcsle
2024-04-10 12:50:17 -07:00
parent c1d75cc8f1
commit 0e34d51788
2 changed files with 86 additions and 113 deletions

View File

@@ -2,6 +2,7 @@
Option Explicit On
Imports System.Data
Imports ADSNetLibrary.SIGAPI.Models.CGame
Imports Extensiones
Imports Microsoft.Reporting.WebForms
@@ -26,56 +27,12 @@ Partial Class Inventarios_Kardex
End Set
End Property
Private Property IndiceNavegacionActual As Integer
Get
If ViewState("IndiceNavegacionActual") Is Nothing Then
ViewState("IndiceNavegacionActual") = 0
End If
Return ViewState("IndiceNavegacionActual").ToString.ToEntero
End Get
Set
ViewState("IndiceNavegacionActual") = Value
End Set
End Property
Private Property DTPSNavegacion As DataTable
Get
If ViewState("DTPSNavegacion") Is Nothing Then
ViewState("DTPSNavegacion") = New DataTable
End If
Return DirectCast(ViewState("DTPSNavegacion"), DataTable)
End Get
Set(value As DataTable)
ViewState("DTPSNavegacion") = value
End Set
End Property
Private Property NavegacionTieneDatos As Boolean
Get
If ViewState("NavegacionTieneDatos") Is Nothing Then
ViewState("NavegacionTieneDatos") = False
End If
Return Boolean.Parse(ViewState("NavegacionTieneDatos").ToString)
End Get
Set(value As Boolean)
ViewState("NavegacionTieneDatos") = value
End Set
End Property
#End Region
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not IsPostBack Then
If UsuarioActual.CveRol = 1 Then
CreaDTPSNavegacion()
DVNavegar.Visible = True
End If
@@ -250,7 +207,7 @@ Partial Class Inventarios_Kardex
#Region " CARGA DATOS "
Protected Sub btConsultar_Click(sender As Object, e As EventArgs) Handles btConsultar.Click
CargaDatos(True)
CargaDatos()
Dim almacenes As String = ddlAlmacen.GetSelectedValues()
If almacenes = "" Then
almacenes = "-1"
@@ -258,22 +215,15 @@ Partial Class Inventarios_Kardex
ImprimirQR.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=Etiqueta2&CvePS={0}&PS={1}&CveAlmacen={2}&Modalidad={3}", ddlProducto2.SelectedValue.ToEntero, ddlProducto2.SelectedText.ToString, almacenes, "Individual")))
End Sub
Private Sub CargaDatos(Optional validaInidiceActual As Boolean = False)
Private Sub CargaDatos()
NavegacionTieneDatos = False
Dim CveProducto As Integer = ddlProducto2.SelectedValue.ToEntero
If validaInidiceActual Then
EstablecerIndiceActaual(CveProducto)
End If
If CveProducto > 0 Then
Dim DtTemp = CargarKardex(CveProducto)
If DtTemp IsNot Nothing AndAlso DtTemp.Rows.Count > 1 Then
NavegacionTieneDatos = True
End If
If DtTemp IsNot Nothing AndAlso DtTemp.Rows.Count > 0 Then
@@ -598,81 +548,66 @@ Partial Class Inventarios_Kardex
End Sub
#End Region
Private Sub EstablecerIndiceActaual(CveProducto As Integer)
IndiceNavegacionActual = 0
For Each drow As DataRow In DTPSNavegacion.Rows
If drow("CvePS").ToString.ToEntero = CveProducto Then
Exit Sub
End If
IndiceNavegacionActual = IndiceNavegacionActual + 1
Next
End Sub
Private Sub CreaDTPSNavegacion()
DTPSNavegacion = GlobalDTPS(UsuarioActual.CveEmpresa).FiltraParametros("", "Codigo", {"CvePS", "CodigoPS", "Codigo"})
End Sub
Protected Sub LnkPSAntyerior_Click(sender As Object, e As EventArgs)
NavegacionTieneDatos = False
For x As Integer = IndiceNavegacionActual - 1 To 0 Step -1
If x <= 0 Or NavegacionTieneDatos Then
IndiceNavegacionActual = x
UPFiltros.Update()
End If
ddlProducto2.SelectedValue = DTPSNavegacion.Rows(x)("CvePS").ToString
ddlProducto2.SelectedText = DTPSNavegacion.Rows(x)("CodigoPS").ToString
ddlProducto2.txtValue.Value = DTPSNavegacion.Rows(x)("CvePS").ToString
ddlProducto2.txtText.Value = DTPSNavegacion.Rows(x)("CodigoPS").ToString
CargaDatos()
If x <= 0 Or NavegacionTieneDatos Then
IndiceNavegacionActual = x
UPFiltros.Update()
UPDatos.Update()
Exit Sub
End If
Next
NavegacionPS(Siguiente:=False)
End Sub
Protected Sub LnkPSSiguiente_Click(sender As Object, e As EventArgs)
NavegacionPS(Siguiente:=True)
End Sub
Private Sub NavegacionPS(Siguiente As Boolean)
Dim CvePS As Integer = ddlProducto2.SelectedValue.ToEntero
NavegacionTieneDatos = False
If Not CvePS > 0 Then
Exit Sub
End If
For x As Integer = IndiceNavegacionActual + 1 To DTPSNavegacion.Rows.Count - 1 Step 1
Dim dt As DataTable = New DataTable
Dim Entrada As Boolean = cbEntrada.Checked
Dim Salida As Boolean = cbSalida.Checked
If x >= DTPSNavegacion.Rows.Count - 1 Or NavegacionTieneDatos Then
IndiceNavegacionActual = x
UPFiltros.Update()
End If
ddlProducto2.SelectedValue = DTPSNavegacion.Rows(x)("CvePS").ToString
ddlProducto2.SelectedText = DTPSNavegacion.Rows(x)("CodigoPS").ToString
ddlProducto2.txtValue.Value = DTPSNavegacion.Rows(x)("CvePS").ToString
ddlProducto2.txtText.Value = DTPSNavegacion.Rows(x)("CodigoPS").ToString
CargaDatos()
If x >= DTPSNavegacion.Rows.Count - 1 Or NavegacionTieneDatos Then
IndiceNavegacionActual = x
UPFiltros.Update()
UPDatos.Update()
Exit Sub
Dim FechaI As String = If(TxtFechaI.Text <> "" AndAlso TxtFechaI.Text <> "__/__/____", TxtFechaI.Text, "-1")
Dim FechaF As String = If(TxtFechaF.Text <> "" AndAlso TxtFechaF.Text <> "__/__/____", TxtFechaF.Text, "-1")
Dim CveAlmacen As Integer = If(ddlAlmacen.SelectedValue.ToEntero = 0, -1, ddlAlmacen.SelectedValue.ToEntero)
Dim CveAlmacenes As String = ddlAlmacen.GetSelectedValues()
If CveAlmacenes.Contains(",") Then
CveAlmacen = -1
End If
If CvePS > 0 Then
Dim dr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("")
If dr IsNot Nothing Then
ddlProducto2.SelectedText = dr("PSCodigo").ToString
ddlProducto2.SelectedValue = CvePS.ToString
End If
End If
Dim CveTiposAlmacen As String = ""
For Each item As ListItem In CBLTiposAlmacen.Items
CveTiposAlmacen += If(item.Selected, $"{item.Value},", "")
Next
Dim ObjInventarios As New ClsInventarios
If ObjInventarios.GetKardexPSNavegacion(Entrada, Salida, CvePS, FechaI, FechaF, CveAlmacen, CveTiposAlmacen.Substring(0, CveTiposAlmacen.Length - 1), DdlUnidadMedida.SelectedValue.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveAlmacenes, Siguiente:=Siguiente) Then
dt = ObjInventarios.DtResultados.Copy
End If
ObjInventarios.Dispose()
If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
ddlProducto2.SelectedValue = dt.Rows(0)("CvePS").ToString
ddlProducto2.SelectedText = dt.Rows(0)("CodigoPS").ToString
ddlProducto2.txtValue.Value = dt.Rows(0)("CvePS").ToString
ddlProducto2.txtText.Value = dt.Rows(0)("CodigoPS").ToString
CargaDatos()
UPFiltros.Update()
UPDatos.Update()
End If
End Sub
End Class