-- Recolecciones de usados

This commit is contained in:
2024-02-08 09:09:32 -07:00
parent 6294ac302e
commit 596a7a7791
2 changed files with 115 additions and 29 deletions

View File

@@ -178,8 +178,25 @@
<div class="row"> <div class="row">
<div class=" col-md-12"> <div class=" col-md-12">
<asp:Literal runat="server" ID="LblProductosCargados">P</asp:Literal> <asp:Literal runat="server" ID="LblProductosCargados">P</asp:Literal>
<asp:HiddenField ID="HdnPSRecoleccion" runat="server" />
<asp:HiddenField ID="HdnCantidadRecoleccion" runat="server" />
</div> </div>
</div> </div>
<hr />
<div class="row">
<div class="col-md-2">
A. Origen
</div>
<div class="col-md-4">
<asp:DropDownList ID="DdlAlmacenOrigen" CssClass="form-control input-sm select2me" DataTextField="Almacen" Width="100%" DataValueField="CveAlmacen" runat="server"></asp:DropDownList>
</div>
<div class="col-md-2">
A. Destino
</div>
<div class="col-md-4">
<asp:DropDownList ID="DdlAlmacenDestino" CssClass="form-control input-sm select2me" DataTextField="Almacen" Width="100%" DataValueField="CveAlmacen" runat="server"></asp:DropDownList>
</div>
</div>
<hr /> <hr />
<div class="row"> <div class="row">
<div class=" col-md-2"> <div class=" col-md-2">
@@ -246,6 +263,7 @@
</asp:GridView> </asp:GridView>
</div> </div>
</div> </div>

View File

@@ -1,6 +1,7 @@
Imports System.Data Imports System.Data
Imports CrystalDecisions.Shared.Json Imports CrystalDecisions.Shared.Json
Imports Extensiones Imports Extensiones
Imports Modelos
Partial Class Acumuladores_RepRecolecciones Partial Class Acumuladores_RepRecolecciones
@@ -62,22 +63,24 @@ Partial Class Acumuladores_RepRecolecciones
TxtFechaI.Text = NowADS().AddDays(-1).ToShortDateString TxtFechaI.Text = NowADS().AddDays(-1).ToShortDateString
TxtFechaF.Text = NowADS().AddDays(3).ToShortDateString TxtFechaF.Text = NowADS().AddDays(3).ToShortDateString
CargarCentrosDeCosto(Nothing, DdlSubProyecto, Nothing, LblSubProyecto) CargarCentrosDeCosto(Nothing, DdlSubProyecto, Nothing, LblSubProyecto)
DdlAlmacenOrigen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen IN (4)")
DdlAlmacenOrigen.DataBind()
DdlAlmacenDestino.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen IN (21) and Almacen like '%sado%'")
DdlAlmacenDestino.DataBind()
End Sub End Sub
Private Sub CargaDatos() Private Sub CargaDatos()
Dim ObjGeneral As New ClsGenerales Dim ObjGeneral As New ClsGenerales
If (ObjGeneral.GetInvEntregaAlmacenRuta(-1, Now.AddMonths(-1), Now.AddMonths(1), UsuarioActual.CveEmpresa, 2, -1)) Then If (ObjGeneral.GetInvEntregaAlmacenRuta(-1, Now.AddMonths(-1), Now.AddMonths(1), UsuarioActual.CveEmpresa, 2, -1)) Then
GvR.DataSource = ObjGeneral.DtResultados GvR.DataSource = ObjGeneral.DtResultados
End If End If
ObjGeneral.Dispose() ObjGeneral.Dispose()
UPGv.DataBind() UPGv.DataBind()
UpGral.Update() UpGral.Update()
End Sub End Sub
Protected Sub gvR_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Protected Sub gvR_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
@@ -128,16 +131,18 @@ Partial Class Acumuladores_RepRecolecciones
Private Sub CargaDatosRecoleccionDetallePS() Private Sub CargaDatosRecoleccionDetallePS()
Dim ObjGenerales As New ClsGenerales() Dim ObjGenerales As New ClsGenerales()
Dim Str As New StringBuilder Dim Str As New StringBuilder
Str.Append("Productos Definidos <br/>") Str.Append("Productos Definidos <br/>")
If ObjGenerales.GetEntregaAlmacenRutaDetalle(CveEntregaAlmacen) Then If ObjGenerales.GetEntregaAlmacenRutaDetalle(CveEntregaAlmacen) Then
For Each dr As DataRow In ObjGenerales.DtResultados.Rows For Each dr As DataRow In ObjGenerales.DtResultados.Rows
Str.AppendFormat(" {0} - {1}<br/>", dr("Cantidad"), dr("CodigoPS")) Str.AppendFormat(" {0} - {1}<br/>", dr("Cantidad"), dr("CodigoPS"))
Next HdnPSRecoleccion.Value = dr("CvePS").ToString
LblProductosCargados.Text = Str.ToString HdnCantidadRecoleccion.Value = dr("Cantidad").ToString
End If Next
LblProductosCargados.Text = Str.ToString
End If
ObjGenerales.Dispose() ObjGenerales.Dispose()
GvModalPSRecoleccion.DataSource = DTRecoleccion GvModalPSRecoleccion.DataSource = DTRecoleccion
GvModalPSRecoleccion.DataBind() GvModalPSRecoleccion.DataBind()
@@ -158,43 +163,38 @@ Partial Class Acumuladores_RepRecolecciones
End Function End Function
Private Sub CargaPS() Private Sub CargaPS()
Dim ObjAcum As New ClsAcumuladores
Dim lista As New List(Of String) Dim lista As New List(Of String)
Dim Filtro As String = "" Dim Filtro As String = ""
For Each drow As DataRow In GlobalDTAcumTamaños(UsuarioActual.CveEmpresa).Rows For Each drow As DataRow In GlobalDTAcumTamaños(UsuarioActual.CveEmpresa).Rows
If drow("CvePSCargo").ToString.ToEntero > 0 Then If drow("CvePSCargo").ToString.ToEntero > 0 Then
lista.Add(drow("CvePSCargo").ToString) lista.Add(drow("CvePSCargo").ToString)
End If End If
Next Next
If lista.Count > 0 Then If lista.Count > 0 Then
Filtro = "CvePS in(" & String.Join(",", lista) & ")" Filtro = "CvePS in(" & String.Join(",", lista) & ")"
DdlProducto2.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa).FiltraParametros(Filtro) DdlProducto2.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa).FiltraParametros(Filtro)
DdlProducto2.DataBind() DdlProducto2.DataBind()
DdlProducto2.Items.Insert(0, New ListItem("Seleccione", "-1")) DdlProducto2.Items.Insert(0, New ListItem("Seleccione", "-1"))
End If End If
ObjAcum.Dispose()
End Sub End Sub
Protected Sub LnkModalAgregarPS_Click(ByVal sender As Object, ByVal e As EventArgs) Protected Sub LnkModalAgregarPS_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim dRow As DataRow = DTRecoleccion.NewRow() Dim dRow As DataRow = DTRecoleccion.NewRow()
dRow("CveEntregaAlmacenDetalle") = -1 dRow("CveEntregaAlmacenDetalle") = -1
dRow("CveEntregaAlmacen") = CveEntregaAlmacen dRow("CveEntregaAlmacen") = CveEntregaAlmacen
dRow("CvePS") = DdlProducto2.SelectedValue.ToEntero() dRow("CvePS") = DdlProducto2.SelectedValue.ToEntero()
dRow("Cantidad") = TxtModalRecoleccionCantidad.Text.ToEntero() dRow("Cantidad") = TxtModalRecoleccionCantidad.Text.ToEntero()
dRow("CveUnidadMedida") = DdlModalRecoleccionUnidad.SelectedValue.ToEntero() dRow("CveUnidadMedida") = DdlModalRecoleccionUnidad.SelectedValue.ToEntero()
dRow("CveUsuario") = UsuarioActual.CveUsuario dRow("CveUsuario") = UsuarioActual.CveUsuario
dRow("FechaIng") = NowADS() dRow("FechaIng") = NowADS()
dRow("CodigoPS") = DdlProducto2.SelectedItem.Text dRow("CodigoPS") = DdlProducto2.SelectedItem.Text
dRow("Abreviatura") = DdlModalRecoleccionUnidad.SelectedItem.Text dRow("Abreviatura") = DdlModalRecoleccionUnidad.SelectedItem.Text
DTRecoleccion.Rows.Add(dRow) DTRecoleccion.Rows.Add(dRow)
LimpiarControlesPS() LimpiarControlesPS()
CargaDatosRecoleccionDetallePS() CargaDatosRecoleccionDetallePS()
@@ -208,5 +208,73 @@ Partial Class Acumuladores_RepRecolecciones
UpModalRecoleccion.Update() UpModalRecoleccion.Update()
End Sub End Sub
Private Sub BtnModalRecoleccionGuardar_Click(sender As Object, e As EventArgs) Handles BtnModalRecoleccionGuardar.Click
Dim ObjInventario As New ClsInventarios
Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL)
Dim ErrorMovInv As Boolean = False
Dim Fecha As DateTime = NowADS()
Dim Concepto As String = "Traspaso Recolección"
Dim CveMovimientoSalida As Integer = ObjInventario.AddMovimiento(DdlAlmacenOrigen.SelectedValue.ToEntero, 26, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1)
Dim FolioSalida As Integer = ObjInventario.Folio
Dim CveMovimientoEntrada As Integer = ObjInventario.AddMovimiento(DdlAlmacenDestino.SelectedValue.ToEntero, 27, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, CveMovimientoRelacionado:=CveMovimientoSalida)
Dim CveUM As Integer = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CvePS:=HdnPSRecoleccion.Value.ToEntero).FiltroPrimeroValor("CveUnidadMedida", "").ToEntero
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, HdnCantidadRecoleccion.Value.ToDecimal, CveUM, HdnPSRecoleccion.Value.ToEntero, 0) Then
ErrorMovInv = True
End If
'HdnPSRecoleccion
For Each gvr As GridViewRow In GvModalPSRecoleccion.Rows
Dim CveMovtoDetalle As Integer
If ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, gvr.DataKey("Cantidad").ToDecimal, gvr.DataKey("CveUnidadMedida").ToEntero, gvr.DataKey("CvePS").ToEntero, 0) Then
CveMovtoDetalle = ObjInventario.CveMovimientoDetalle
Else
ErrorMovInv = True
End If
Next
If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then
Dim Cont As Integer = 0
Dim dttSalida As DataTable = ObjInventario.DtResultados
If Not ErrorMovInv Then
Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Inventario/TraspasoAlmacen", 53, 0, 0, 1, Fecha, Concepto, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
Dim importe As Decimal = dttSalida.SUMD("Total").RoundSQL
Dim Contabilizable As Boolean = False
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importe, importe, 68, Concepto, Concepto, CveMovimientoAlmacen:=CveMovimientoSalida, Contabilizable:=Contabilizable) Then
ErrorMovInv = True
End If
If Not ErrorMovInv AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importe, importe, 68, Concepto, Concepto, CveMovimientoAlmacen:=CveMovimientoEntrada, Contabilizable:=Contabilizable) Then
ErrorMovInv = True
End If
If Not ErrorMovInv Then
If ObjConta.ValidacionesPrePoliza(CvePrePoliza, UsuarioActual) Then
If ObjConta.ValorPolizaDescuadre > 0 Then
'MsgError = ObjMov.MensajePolizaDescuadre
ErrorMovInv = True
'GuardaLogAD($"Bancos/Transferencias | Error:{ObjMov.MensajePolizaDescuadre} Diferencia:{ObjMov.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas")
End If
Else
ErrorMovInv = True
End If
End If
End If
End If
If Not ErrorMovInv Then
ObjInventario.Commit()
Dim MensajeAlert As New StringBuilder
MensajeAlert.Append("Se realizó con éxito el traspaso.")
MensajeAlert.AppendFormat("<br/> Folio de Salida: <b><a href=""/Inventarios/EntradasSalidas.aspx?CveMovimiento={1}"" class='Texto' target=""_blank"">{0}</a></b>", FolioSalida, CveMovimientoSalida)
'MensajeAlert.AppendFormat("<br/><a target='_blank' class='Texto' href='/Compras/PopUpVerFactura.aspx?P={0}'>Imprimir Reporte</a>", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoSalida)))
Alert(MensajeAlert.ToString)
Else
ObjInventario.RollBack()
End If
End Sub
End Class End Class