From 0e34d5178865dac8c50a4839b44b5b433dda4ed8 Mon Sep 17 00:00:00 2001 From: rakcsle Date: Wed, 10 Apr 2024 12:50:17 -0700 Subject: [PATCH] Kardex siguiente siguiente PS con movimientos --- App_Code/ClsInventarios.vb | 38 +++++++++ Inventarios/Kardex.aspx.vb | 161 +++++++++++-------------------------- 2 files changed, 86 insertions(+), 113 deletions(-) diff --git a/App_Code/ClsInventarios.vb b/App_Code/ClsInventarios.vb index e5334119c..6e398afc5 100644 --- a/App_Code/ClsInventarios.vb +++ b/App_Code/ClsInventarios.vb @@ -1625,6 +1625,44 @@ Public Class ClsInventarios End Function + Public Function GetKardexPSNavegacion(Entrada As Boolean, Salida As Boolean, CvePS As Integer, FechaI As String, FechaF As String, CveAlmacen As Integer, CveTiposAlmacen As String, CveUnidadMedida As Integer, CveUsuario As Integer, CveEmpresa As Integer, Optional CveAlmacenes As String = "-1", Optional Siguiente As Boolean = True) As Boolean + + Dim Retorno As Boolean = False + + DataAdapter("PA_Inv_KardexPSNavegacionGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Entrada", SqlDbType.Bit).Value = Entrada + .Add("@Salida", SqlDbType.Bit).Value = Salida + .Add("@FechaI", SqlDbType.VarChar).Value = FechaI + .Add("@FechaF", SqlDbType.VarChar).Value = FechaF + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CveAlmacen", SqlDbType.Int).Value = CveAlmacen + .Add("@CveTiposAlmacen", SqlDbType.VarChar).Value = CveTiposAlmacen + .Add("@CveUnidadMedida", SqlDbType.Int).Value = CveUnidadMedida + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + + .Add("@CveAlmacenes", SqlDbType.VarChar).Value = CveAlmacenes + .Add("@Siguiente", SqlDbType.Bit).Value = Siguiente + + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + + Me.OnError("Ocurrió un error al obtener el kardex.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + + Catch ex As Exception + OnError("Ocurrió un error al obtener el kardex.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + + End Function + Public Function GetExistenciasProductoSerie(CvePS As Integer, CveUsuario As Integer, CveEmpresa As Integer, Fecha As DateTime, Optional CveAlmacenes As String = "-1") As Boolean Dim Retorno As Boolean = False diff --git a/Inventarios/Kardex.aspx.vb b/Inventarios/Kardex.aspx.vb index e12f8af7a..e51e12ce8 100644 --- a/Inventarios/Kardex.aspx.vb +++ b/Inventarios/Kardex.aspx.vb @@ -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