diff --git a/Inventarios/EntregaAlmacen.aspx.vb b/Inventarios/EntregaAlmacen.aspx.vb
index 757984d7c..dc91c7c49 100644
--- a/Inventarios/EntregaAlmacen.aspx.vb
+++ b/Inventarios/EntregaAlmacen.aspx.vb
@@ -1,2435 +1,2562 @@
-Option Strict On
-Option Explicit On
-
-Imports System.Data
+Option Strict On
+Option Explicit On
+
+Imports System.Data
Imports System.IO
-Imports Extensiones
-
-Imports Microsoft.Reporting.WebForms
-
-Partial Class Inventarios_EntregaAlmacen
+Imports Extensiones
+
+Imports Microsoft.Reporting.WebForms
+
+Partial Class Inventarios_EntregaAlmacen
Inherits ClsPaginas
-#Region "PROPIEDADES"
- Private Property CveVentaAD As Integer
- Get
- Return CType(ViewState("CveVentaAD"), Integer)
- End Get
- Set(value As Integer)
- ViewState("CveVentaAD") = value
- End Set
- End Property
- Private Property DtDatos As DataTable
- Get
- Return CType(ViewState("DtDatos"), DataTable)
- End Get
- Set(value As DataTable)
- ViewState("DtDatos") = value
- End Set
- End Property
- Private Property DtDatosDetalle As DataTable
- Get
- Return CType(ViewState("DtDatosDetalle"), DataTable)
- End Get
- Set(value As DataTable)
- ViewState("DtDatosDetalle") = value
- End Set
- End Property
- Private Property DtDatosSugerencias As DataTable
- Get
- Return CType(ViewState("DtDatosSugerencias"), DataTable)
- End Get
- Set(value As DataTable)
- ViewState("DtDatosSugerencias") = value
- End Set
- End Property
- Private Property DtDatosDetalleLote As DataTable
- Get
- Return CType(ViewState("DtDatosDetalleLote"), DataTable)
- End Get
- Set(value As DataTable)
- ViewState("DtDatosDetalleLote") = value
- End Set
- End Property
- Private Property PSSerie As String
- Get
- Return CType(ViewState("PSSerie"), String)
- End Get
- Set(value As String)
- ViewState("PSSerie") = value
- End Set
- End Property
- Private Property CveConsecSerie As Integer
- Get
- Return CType(ViewState("CveConsecSerie"), Integer)
- End Get
- Set(value As Integer)
- ViewState("CveConsecSerie") = value
- End Set
- End Property
- Private Property CvePSSerie As Integer
- Get
- Return CType(ViewState("CvePSSerie"), Integer)
- End Get
- Set(value As Integer)
- ViewState("CvePSSerie") = value
- End Set
- End Property
- Private Property CveUMSerie As Integer
- Get
- Return CType(ViewState("CveUMSerie"), Integer)
- End Get
- Set(value As Integer)
- ViewState("CveUMSerie") = value
- End Set
- End Property
- Private Property EsInterno As Boolean
- Get
- Return CBool(If(ViewState("EsInterno") Is Nothing, 0, ViewState("EsInterno")))
- End Get
- Set(value As Boolean)
- ViewState("EsInterno") = value
- End Set
- End Property
- Private Property CveMetodoInventario As Integer
- Get
- Return CType(ViewState("CveMetodoInventario"), Integer)
- End Get
- Set(value As Integer)
- ViewState("CveMetodoInventario") = value
- End Set
- End Property
- Private Property CveVentaSurtir As Integer
- Get
- Return CType(ViewState("CveVentaSurtir"), Integer)
- End Get
- Set(value As Integer)
- ViewState("CveVentaSurtir") = value
- End Set
- End Property
- Private Property TipoEstatus As Integer
- Get
- Return CType(ViewState("TipoEstatus"), Integer)
- End Get
- Set(value As Integer)
- ViewState("TipoEstatus") = value
- End Set
- End Property
- Private Property CveContrato As Integer
- Get
- Return CType(ViewState("CveContrato"), Integer)
- End Get
- Set(value As Integer)
- ViewState("CveContrato") = value
- End Set
- End Property
- Private Property CveAlmacenTraspasoOrigen As Integer
- Get
- Return CType(ViewState("CveAlmacenTraspasoOrigen"), Integer)
- End Get
- Set(value As Integer)
- ViewState("CveAlmacenTraspasoOrigen") = value
- End Set
- End Property
- Private Property CveAlmacenTraspasoDestino As Integer
- Get
- Return CType(ViewState("CveAlmacenTraspasoDestino"), Integer)
- End Get
- Set(value As Integer)
- ViewState("CveAlmacenTraspasoDestino") = value
- End Set
- End Property
- Private Property TipoMovimiento As Integer
- Get
- Return CType(ViewState("TipoMovimiento"), Integer)
- End Get
- Set(value As Integer)
- ViewState("TipoMovimiento") = value
- End Set
- End Property
- Private Property TipoDocto As String
- Get
- Return CType(ViewState("TipoDocto"), String)
- End Get
- Set(value As String)
- ViewState("TipoDocto") = value
- End Set
- End Property
- Private Property DtExistencias As DataTable
- Get
- Return CType(ViewState("DtExistencias"), DataTable)
- End Get
- Set(value As DataTable)
- ViewState("DtExistencias") = value
- End Set
- End Property
- Private Property RowIndexCantidadEspecial As Integer
- Get
- Return CType(ViewState("RowIndexCantidadEspecial"), Integer)
- End Get
- Set(value As Integer)
- ViewState("RowIndexCantidadEspecial") = value
- End Set
- End Property
- Private Property CantidadEspecialTemp As Decimal
- Get
- Return CType(ViewState("CantidadEspecialTemp"), Decimal)
- End Get
- Set(value As Decimal)
- ViewState("CantidadEspecialTemp") = value
- End Set
- End Property
- Private Property EsDevolucionVenta As Integer
- Get
- Return CType(ViewState("EsDevolucionVenta"), Integer)
- End Get
- Set(value As Integer)
- ViewState("EsDevolucionVenta") = value
- End Set
- End Property
- Private Property CveVendedor As Integer
- Get
- Return CType(ViewState("CveVendedor"), Integer)
- End Get
- Set(value As Integer)
- ViewState("CveVendedor") = value
- End Set
- End Property
- Private Property CveSubProyecto As Integer
- Get
- Return CType(ViewState("CveSubProyecto"), Integer)
- End Get
- Set(value As Integer)
- ViewState("CveSubProyecto") = value
- End Set
- End Property
- Private Property CveCliente As Integer
- Get
- Return CType(ViewState("CveCliente"), Integer)
- End Get
- Set(value As Integer)
- ViewState("CveCliente") = value
- End Set
- End Property
- Private Property CveMovimiento As Integer
- Get
- Return CType(ViewState("CveMovimiento"), Integer)
- End Get
- Set(value As Integer)
- ViewState("CveMovimiento") = value
- End Set
- End Property
- Private Property CveTraspasoSurtir As Integer
- Get
- Return CType(ViewState("CveTraspasoSurtir"), Integer)
- End Get
- Set(value As Integer)
- ViewState("CveTraspasoSurtir") = value
- End Set
- End Property
- Private Property TipoEntrega As Integer
- Get
- Return CType(ViewState("TipoEntrega"), Integer)
- End Get
- Set(value As Integer)
- ViewState("TipoEntrega") = value
- End Set
- End Property
-
- Private Property EsDevolucionDirecta As Boolean
- Get
- Return CBool(If(ViewState("EsDevolucionDirecta") Is Nothing, 0, ViewState("EsDevolucionDirecta")))
- End Get
- Set(value As Boolean)
- ViewState("EsDevolucionDirecta") = value
- End Set
+#Region "PROPIEDADES"
+ Private Property CveVentaAD As Integer
+ Get
+ Return CType(ViewState("CveVentaAD"), Integer)
+ End Get
+ Set(value As Integer)
+ ViewState("CveVentaAD") = value
+ End Set
+ End Property
+ Private Property DtDatos As DataTable
+ Get
+ Return CType(ViewState("DtDatos"), DataTable)
+ End Get
+ Set(value As DataTable)
+ ViewState("DtDatos") = value
+ End Set
+ End Property
+ Private Property DtDatosDetalle As DataTable
+ Get
+ Return CType(ViewState("DtDatosDetalle"), DataTable)
+ End Get
+ Set(value As DataTable)
+ ViewState("DtDatosDetalle") = value
+ End Set
+ End Property
+ Private Property DtDatosSugerencias As DataTable
+ Get
+ Return CType(ViewState("DtDatosSugerencias"), DataTable)
+ End Get
+ Set(value As DataTable)
+ ViewState("DtDatosSugerencias") = value
+ End Set
+ End Property
+ Private Property DtDatosDetalleLote As DataTable
+ Get
+ Return CType(ViewState("DtDatosDetalleLote"), DataTable)
+ End Get
+ Set(value As DataTable)
+ ViewState("DtDatosDetalleLote") = value
+ End Set
+ End Property
+ Private Property PSSerie As String
+ Get
+ Return CType(ViewState("PSSerie"), String)
+ End Get
+ Set(value As String)
+ ViewState("PSSerie") = value
+ End Set
+ End Property
+ Private Property CveConsecSerie As Integer
+ Get
+ Return CType(ViewState("CveConsecSerie"), Integer)
+ End Get
+ Set(value As Integer)
+ ViewState("CveConsecSerie") = value
+ End Set
+ End Property
+ Private Property CvePSSerie As Integer
+ Get
+ Return CType(ViewState("CvePSSerie"), Integer)
+ End Get
+ Set(value As Integer)
+ ViewState("CvePSSerie") = value
+ End Set
+ End Property
+ Private Property CveUMSerie As Integer
+ Get
+ Return CType(ViewState("CveUMSerie"), Integer)
+ End Get
+ Set(value As Integer)
+ ViewState("CveUMSerie") = value
+ End Set
+ End Property
+ Private Property EsInterno As Boolean
+ Get
+ Return CBool(If(ViewState("EsInterno") Is Nothing, 0, ViewState("EsInterno")))
+ End Get
+ Set(value As Boolean)
+ ViewState("EsInterno") = value
+ End Set
+ End Property
+ Private Property CveMetodoInventario As Integer
+ Get
+ Return CType(ViewState("CveMetodoInventario"), Integer)
+ End Get
+ Set(value As Integer)
+ ViewState("CveMetodoInventario") = value
+ End Set
+ End Property
+ Private Property CveVentaSurtir As Integer
+ Get
+ Return CType(ViewState("CveVentaSurtir"), Integer)
+ End Get
+ Set(value As Integer)
+ ViewState("CveVentaSurtir") = value
+ End Set
+ End Property
+ Private Property TipoEstatus As Integer
+ Get
+ Return CType(ViewState("TipoEstatus"), Integer)
+ End Get
+ Set(value As Integer)
+ ViewState("TipoEstatus") = value
+ End Set
+ End Property
+ Private Property CveContrato As Integer
+ Get
+ Return CType(ViewState("CveContrato"), Integer)
+ End Get
+ Set(value As Integer)
+ ViewState("CveContrato") = value
+ End Set
+ End Property
+ Private Property CveAlmacenTraspasoOrigen As Integer
+ Get
+ Return CType(ViewState("CveAlmacenTraspasoOrigen"), Integer)
+ End Get
+ Set(value As Integer)
+ ViewState("CveAlmacenTraspasoOrigen") = value
+ End Set
+ End Property
+ Private Property CveAlmacenTraspasoDestino As Integer
+ Get
+ Return CType(ViewState("CveAlmacenTraspasoDestino"), Integer)
+ End Get
+ Set(value As Integer)
+ ViewState("CveAlmacenTraspasoDestino") = value
+ End Set
+ End Property
+ Private Property TipoMovimiento As Integer
+ Get
+ Return CType(ViewState("TipoMovimiento"), Integer)
+ End Get
+ Set(value As Integer)
+ ViewState("TipoMovimiento") = value
+ End Set
+ End Property
+ Private Property TipoDocto As String
+ Get
+ Return CType(ViewState("TipoDocto"), String)
+ End Get
+ Set(value As String)
+ ViewState("TipoDocto") = value
+ End Set
+ End Property
+ Private Property DtExistencias As DataTable
+ Get
+ Return CType(ViewState("DtExistencias"), DataTable)
+ End Get
+ Set(value As DataTable)
+ ViewState("DtExistencias") = value
+ End Set
+ End Property
+ Private Property RowIndexCantidadEspecial As Integer
+ Get
+ Return CType(ViewState("RowIndexCantidadEspecial"), Integer)
+ End Get
+ Set(value As Integer)
+ ViewState("RowIndexCantidadEspecial") = value
+ End Set
+ End Property
+ Private Property CantidadEspecialTemp As Decimal
+ Get
+ Return CType(ViewState("CantidadEspecialTemp"), Decimal)
+ End Get
+ Set(value As Decimal)
+ ViewState("CantidadEspecialTemp") = value
+ End Set
+ End Property
+ Private Property EsDevolucionVenta As Integer
+ Get
+ Return CType(ViewState("EsDevolucionVenta"), Integer)
+ End Get
+ Set(value As Integer)
+ ViewState("EsDevolucionVenta") = value
+ End Set
+ End Property
+ Private Property CveVendedor As Integer
+ Get
+ Return CType(ViewState("CveVendedor"), Integer)
+ End Get
+ Set(value As Integer)
+ ViewState("CveVendedor") = value
+ End Set
+ End Property
+ Private Property CveSubProyecto As Integer
+ Get
+ Return CType(ViewState("CveSubProyecto"), Integer)
+ End Get
+ Set(value As Integer)
+ ViewState("CveSubProyecto") = value
+ End Set
+ End Property
+ Private Property CveCliente As Integer
+ Get
+ Return CType(ViewState("CveCliente"), Integer)
+ End Get
+ Set(value As Integer)
+ ViewState("CveCliente") = value
+ End Set
+ End Property
+ Private Property CveMovimiento As Integer
+ Get
+ Return CType(ViewState("CveMovimiento"), Integer)
+ End Get
+ Set(value As Integer)
+ ViewState("CveMovimiento") = value
+ End Set
+ End Property
+ Private Property CveTraspasoSurtir As Integer
+ Get
+ Return CType(ViewState("CveTraspasoSurtir"), Integer)
+ End Get
+ Set(value As Integer)
+ ViewState("CveTraspasoSurtir") = value
+ End Set
+ End Property
+ Private Property TipoEntrega As Integer
+ Get
+ Return CType(ViewState("TipoEntrega"), Integer)
+ End Get
+ Set(value As Integer)
+ ViewState("TipoEntrega") = value
+ End Set
End Property
-#End Region
+ Private Property EsDevolucionDirecta As Boolean
+ Get
+ Return CBool(If(ViewState("EsDevolucionDirecta") Is Nothing, 0, ViewState("EsDevolucionDirecta")))
+ End Get
+ Set(value As Boolean)
+ ViewState("EsDevolucionDirecta") = value
+ End Set
+ End Property
- Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
- If Not IsPostBack Then
-
- InicializaValores()
- CargaParametrosAD()
- If UsuarioActual.CveEmpresa.Contiene(72, 80) Then DdlAlmacen.AutoPostBack = True
- End If
+#End Region
+
+ Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
+ If Not IsPostBack Then
+
+ InicializaValores()
+ CargaParametrosAD()
+ If UsuarioActual.CveEmpresa.Contiene(72, 80) Then DdlAlmacen.AutoPostBack = True
+ End If
End Sub
-#Region " INICIALIZA VALORES "
- Private Sub InicializaValores()
- TipoEstatus = -1
- CveVendedor = -1
- CveCliente = -1
- CveSubProyecto = -1
-
- DtDatosSugerencias = New DataTable
-
- Dim StrAlmacenes As String = "CveTipoAlmacen IN (1,2)"
-
- If (UsuarioActual.Empresa.Funcionalidad(105) = "1" Or UsuarioActual.Empresa.Funcionalidad(141) = "1") Then
- DdlClientes.setEsWebService(True)
- DdlClientes.Attributes.Add("data-metodo", "getcliente")
- DdlClientes.SelectedText = "Todos"
- DdlClientes.SelectedValue = "-1"
- Else
- DdlClientes.setEsWebService(False)
- DdlClientes.ddl.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa)
- DdlClientes.ddl.DataBind()
- DdlClientes.ddl.Items.Insert(0, New ListItem("Todos", "-1"))
- End If
-
- If UsuarioActual.CveSubProyecto = 8804 Then
- StrAlmacenes = "CveTipoAlmacen IN (1,2,12)"
- End If
-
- DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros(StrAlmacenes) 'GlobalDTAlmacen(UsuarioActual.CveEmpresa)
- DdlAlmacen.Items.Insert(0, New ListItem(" Seleccione ", "-1"))
- DdlAlmacen.SelectedValue = "-1"
- DdlAlmacen.DataBind()
- DdlAlmacen.SelectedValueExist(UsuarioActual.CveAlmacen)
-
- DdlAlmacenTransitorio.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 3)
- DdlAlmacenTransitorio.DataBind()
- DdlAlmacenTransitorio.Items.Insert(0, New ListItem("Seleccione", "-1"))
-
- DdlFolio.Items.Insert(0, New ListItem("Seleccione", "-1"))
-
- TxtFechaPendientes.Text = Now.ToShortDateString
- 'TxtFechaCaducidad.Text = Now.ToShortDateString
- TxtFecha.Text = Now.ToShortDateString
- RVFecha.MaximumValue = MaxFecha.ToShortDateString
- If UsuarioActual.CveEmpresa.Contiene(119) Then RVFecha.MinimumValue = Now.ToShortDateString : CEFecha.StartDate = Now Else RVFecha.MinimumValue = MinFecha.ToShortDateString
-
- If Not UsuarioActual.TienePermisoProceso(190) Then
- 'CARGA SOLO LAS SUCURSALES DE LOS ALMCENES QUE TIENE ASIGNADO EL USUARIO
- Dim ObjInventarios As New ClsInventarios
- If ObjInventarios.GetSucursalesAlmacenUsuario(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
- DdlSubProyectos.DataSource = ObjInventarios.DtResultados
- End If
- ObjInventarios.Dispose()
- Else
- DdlSubProyectos.DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa)
- End If
- DdlSubProyectos.DataBind()
- DdlSubProyectos.SelectedValueExist(UsuarioActual.CveSubProyecto.ToString)
-
- If UsuarioActual.TienePermisoProceso(152) Then DdlSubProyectos.Enabled = False
- If UsuarioActual.Empresa.Funcionalidad(280) = "1" Then PnlEntrega.Visible = True
-
- CreaDtDetalle()
- CreaDtDetalleLote()
- CargaPendientes()
-
-
- LimpiaCampos()
+#Region " INICIALIZA VALORES "
+ Private Sub InicializaValores()
+ TipoEstatus = -1
+ CveVendedor = -1
+ CveCliente = -1
+ CveSubProyecto = -1
+
+ DtDatosSugerencias = New DataTable
+
+ Dim StrAlmacenes As String = "CveTipoAlmacen IN (1,2)"
+
+ If (UsuarioActual.Empresa.Funcionalidad(105) = "1" Or UsuarioActual.Empresa.Funcionalidad(141) = "1") Then
+ DdlClientes.setEsWebService(True)
+ DdlClientes.Attributes.Add("data-metodo", "getcliente")
+ DdlClientes.SelectedText = "Todos"
+ DdlClientes.SelectedValue = "-1"
+ Else
+ DdlClientes.setEsWebService(False)
+ DdlClientes.ddl.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa)
+ DdlClientes.ddl.DataBind()
+ DdlClientes.ddl.Items.Insert(0, New ListItem("Todos", "-1"))
+ End If
+
+ If UsuarioActual.CveSubProyecto = 8804 Then
+ StrAlmacenes = "CveTipoAlmacen IN (1,2,12)"
+ End If
+
+ DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros(StrAlmacenes) 'GlobalDTAlmacen(UsuarioActual.CveEmpresa)
+ DdlAlmacen.Items.Insert(0, New ListItem(" Seleccione ", "-1"))
+ DdlAlmacen.SelectedValue = "-1"
+ DdlAlmacen.DataBind()
+ DdlAlmacen.SelectedValueExist(UsuarioActual.CveAlmacen)
+
+ DdlAlmacenTransitorio.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 3)
+ DdlAlmacenTransitorio.DataBind()
+ DdlAlmacenTransitorio.Items.Insert(0, New ListItem("Seleccione", "-1"))
+
+ DdlFolio.Items.Insert(0, New ListItem("Seleccione", "-1"))
+
+ TxtFechaPendientes.Text = Now.ToShortDateString
+ 'TxtFechaCaducidad.Text = Now.ToShortDateString
+ TxtFecha.Text = Now.ToShortDateString
+ RVFecha.MaximumValue = MaxFecha.ToShortDateString
+ If UsuarioActual.CveEmpresa.Contiene(119) Then RVFecha.MinimumValue = Now.ToShortDateString : CEFecha.StartDate = Now Else RVFecha.MinimumValue = MinFecha.ToShortDateString
+
+ If Not UsuarioActual.TienePermisoProceso(190) Then
+ 'CARGA SOLO LAS SUCURSALES DE LOS ALMCENES QUE TIENE ASIGNADO EL USUARIO
+ Dim ObjInventarios As New ClsInventarios
+ If ObjInventarios.GetSucursalesAlmacenUsuario(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
+ DdlSubProyectos.DataSource = ObjInventarios.DtResultados
+ End If
+ ObjInventarios.Dispose()
+ Else
+ DdlSubProyectos.DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa)
+ End If
+ DdlSubProyectos.DataBind()
+ DdlSubProyectos.SelectedValueExist(UsuarioActual.CveSubProyecto.ToString)
+
+ If UsuarioActual.TienePermisoProceso(152) Then DdlSubProyectos.Enabled = False
+ If UsuarioActual.Empresa.Funcionalidad(280) = "1" Then PnlEntrega.Visible = True
+
+ CreaDtDetalle()
+ CreaDtDetalleLote()
+ CargaPendientes()
+
+
+ LimpiaCampos()
End Sub
-#End Region
+#End Region
-#Region " CARGA PARAMETROS - EXCLUSIVO USO AD "
- Private Sub CargaParametrosAD()
-
- CveVentaAD = -1
-
- If UsuarioActual.CveUsuario <> 100 Then
- Exit Sub
- End If
-
- If Not IsNothing(Request("CveVenta")) AndAlso IsNumeric(Request("CveVenta")) Then
- CveVentaAD = Request("CveVenta").ToEntero
- CargaVentaPorSurtir(Request("CveVenta").ToEntero)
- LbSurtida.Visible = True
- LbSurtida.Text = "SOLO MODO VISUAL"
- BtnGuardar.Visible = False
- End If
-
+#Region " CARGA PARAMETROS - EXCLUSIVO USO AD "
+ Private Sub CargaParametrosAD()
+
+ CveVentaAD = -1
+
+ If UsuarioActual.CveUsuario <> 100 Then
+ Exit Sub
+ End If
+
+ If Not IsNothing(Request("CveVenta")) AndAlso IsNumeric(Request("CveVenta")) Then
+ CveVentaAD = Request("CveVenta").ToEntero
+ CargaVentaPorSurtir(Request("CveVenta").ToEntero)
+ LbSurtida.Visible = True
+ LbSurtida.Text = "SOLO MODO VISUAL"
+ BtnGuardar.Visible = False
+ End If
+
End Sub
-#End Region
+#End Region
-#Region " CARGA PENDIENTES POR SURTIR "
- Protected Sub DdlCliente_SelectedIndexChanged(sender As Object, e As EventArgs)
- CargaFolios()
- End Sub
- Private Sub CargaFolios()
- Dim ObjInventarios As New ClsInventarios
-
- DdlFolio.Items.Clear()
-
- If DdlClientes.SelectedValue.ToEntero > 0 Then
- If ObjInventarios.VentasPendientesAlmacenGet(DdlClientes.SelectedValue.ToEntero, MinFecha, DdlSubProyectos.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario) Then
- DdlFolio.DataSource = ObjInventarios.DtResultados
- Else
- Alert("Ocurrió un error al obtener las Compras pendientes de recibir del proveedor. Por favor vuelva a intentar", TipoMensaje.MsgError)
- End If
- End If
-
- ObjInventarios.Dispose()
-
- DdlFolio.DataBind()
- DdlFolio.Items.Insert(0, New ListItem("Seleccione", "-1"))
- UpFiltros.Update()
- End Sub
- Protected Sub TimmerRefresh_Tick(sender As Object, e As EventArgs)
- CargaPendientes()
- End Sub
- Protected Sub BtnConsultarPendientes_Click(sender As Object, e As EventArgs)
- CargaPendientes()
- End Sub
- Private Sub CargaPendientes()
- DivTipoCambioAdvertencia.Visible = False
-
- Dim ObjInventarios As New ClsInventarios
- Dim DtPendientes As New DataTable
-
- If ObjInventarios.VentasPendientesAlmacenGet(-1, TxtFechaPendientes.Text.ToDate, DdlSubProyectos.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario) Then
-
-
- If UsuarioActual.TienePermisoProceso(266) AndAlso UsuarioActual.TienePermisoProceso(267) Then
- DtPendientes = ObjInventarios.DtResultados.FiltraParametros("TipoDocto IN ('Ing','Dev','Rem','Traspaso','Ped','PDev','DPe','Ant')")
- ElseIf UsuarioActual.TienePermisoProceso(266) AndAlso Not UsuarioActual.TienePermisoProceso(267) Then
- DtPendientes = ObjInventarios.DtResultados.FiltraParametros("TipoDocto IN ('Ing','Dev','Rem','Traspaso','Ant')")
- ElseIf UsuarioActual.TienePermisoProceso(267) AndAlso Not UsuarioActual.TienePermisoProceso(266) Then
- DtPendientes = ObjInventarios.DtResultados.FiltraParametros("TipoDocto IN ('Ped','PDev','DPe')")
- Else
- DtPendientes = ObjInventarios.DtResultados
- End If
- Else
- DtPendientes = Nothing
- Alert("Ocurrió un error al obtener las Compras pendientes de recibir del proveedor. Por favor vuelva a intentar", TipoMensaje.MsgError)
- End If
-
- If UsuarioActual.Empresa.Funcionalidad(540) = "1" Then
- BtnGuardar.Enabled = False
- Dim FI As Date = Now.AddDays(-1)
- Dim FF As Date = Now.AddDays(-7)
- If ObjInventarios.RepNotasSinAlmacen(1, -1, FI, FF, "-1", -1, UsuarioActual.Empresa.CveEmpresa) Then
- If ObjInventarios.DtResultados IsNot Nothing AndAlso ObjInventarios.DtResultados.Rows.Count > 1 Then
- BtnGuardar.Enabled = False
- Alert("No se podrá realizar entrega de mercancía si no se les da salida a los documentos pendientes. Para más información ver el Reporte de notas sin entrada en la sección Ventas.", TipoMensaje.MsgAdvertencia)
- Else
- BtnGuardar.Enabled = True
-
- End If
- End If
- End If
-
- ObjInventarios.Dispose()
-
- If DtPendientes IsNot Nothing Then
- GVPendientes.DataSource = DtPendientes
-
- End If
-
- LtActualizado.Text = String.Format("Actualizado: {0}", Now.ToString("H:mm"))
-
- GVPendientes.DataBind()
- UpPendientes.Update()
- If DtPendientes IsNot Nothing Then DtPendientes.Dispose()
-
- End Sub
- Protected Sub GVPendientes_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GVPendientes.RowDataBound
- If e.Row.RowType = DataControlRowType.DataRow Then
- e.Row.FCLinkButton("BtnSurtir").CommandArgument = If(e.Row.DBCampo("TipoEntrega") = "1", e.Row.DBCampo("CveVenta"), e.Row.DBCampo("CveTraspasoSolicitud"))
-
-
-
- Select Case e.Row.DBCampo("TipoEntrega").ToString.ToEntero
- Case 1
- If UsuarioActual.TienePermisoProceso(201) Then
- Dim Css = "Texto"
- Dim Liga = $"/Ventas/Ventas.aspx?&CveVenta={e.Row.DBCampo("CveVenta")}"
- e.Row.FCLabel("LblFolio").Text = "" + e.Row.FCLabel("LblFolio").Text + ""
- End If
-
- If UsuarioActual.CveEmpresa.Contiene(72, 80) Then
- GVPendientes.Columns(4).Visible = True
- e.Row.FCHyperLink("HplDownPDF").Visible = True
- e.Row.FCHyperLink("HplDownPDF").NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=VTA&CVEVENTA={0}", e.Row.DBCampo("CveVenta"))))
- End If
-
- If e.Row.DBCampo("TipoDocto").ToString.Contiene({"Rem", "Ing", "Ped", "PeC", "Ant"}) And e.Row.DBCampo("EsDevolucionVenta").ToString.ToEntero = 0 Then
- e.Row.FCLinkButton("BtnSurtir").CssClass = "btn btn-primary btn-sm"
- e.Row.FCLinkButton("BtnSurtir").Text = " Surtir "
- Else
- e.Row.FCLinkButton("BtnSurtir").CssClass = "btn yellow-gold btn-sm"
- e.Row.FCLinkButton("BtnSurtir").Text = " Recibir"
- End If
- Case 2
- Dim Css = "Texto"
- Dim Liga = $"/Inventarios/TrasladoSolicitud.aspx?&CveTraspasoSolicitud={e.Row.DBCampo("CveTraspasoSolicitud")}"
- e.Row.FCLabel("LblFolio").Text = "" + e.Row.FCLabel("LblFolio").Text + ""
- e.Row.FCLinkButton("BtnSurtir").CssClass = "btn btn-primary btn-sm"
- e.Row.FCLinkButton("BtnSurtir").Text = " Traspasar "
- End Select
- UpPendientes.Update()
- End If
+#Region " CARGA PENDIENTES POR SURTIR "
+ Protected Sub DdlCliente_SelectedIndexChanged(sender As Object, e As EventArgs)
+ CargaFolios()
+ End Sub
+ Private Sub CargaFolios()
+ Dim ObjInventarios As New ClsInventarios
+
+ DdlFolio.Items.Clear()
+
+ If DdlClientes.SelectedValue.ToEntero > 0 Then
+ If ObjInventarios.VentasPendientesAlmacenGet(DdlClientes.SelectedValue.ToEntero, MinFecha, DdlSubProyectos.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario) Then
+ DdlFolio.DataSource = ObjInventarios.DtResultados
+ Else
+ Alert("Ocurrió un error al obtener las Compras pendientes de recibir del proveedor. Por favor vuelva a intentar", TipoMensaje.MsgError)
+ End If
+ End If
+
+ ObjInventarios.Dispose()
+
+ DdlFolio.DataBind()
+ DdlFolio.Items.Insert(0, New ListItem("Seleccione", "-1"))
+ UpFiltros.Update()
+ End Sub
+ Protected Sub TimmerRefresh_Tick(sender As Object, e As EventArgs)
+ CargaPendientes()
+ End Sub
+ Protected Sub BtnConsultarPendientes_Click(sender As Object, e As EventArgs)
+ CargaPendientes()
+ End Sub
+ Private Sub CargaPendientes()
+ DivTipoCambioAdvertencia.Visible = False
+
+ Dim ObjInventarios As New ClsInventarios
+ Dim DtPendientes As New DataTable
+
+ If ObjInventarios.VentasPendientesAlmacenGet(-1, TxtFechaPendientes.Text.ToDate, DdlSubProyectos.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario) Then
+
+
+ If UsuarioActual.TienePermisoProceso(266) AndAlso UsuarioActual.TienePermisoProceso(267) Then
+ DtPendientes = ObjInventarios.DtResultados.FiltraParametros("TipoDocto IN ('Ing','Dev','Rem','Traspaso','Ped','PDev','DPe','Ant')")
+ ElseIf UsuarioActual.TienePermisoProceso(266) AndAlso Not UsuarioActual.TienePermisoProceso(267) Then
+ DtPendientes = ObjInventarios.DtResultados.FiltraParametros("TipoDocto IN ('Ing','Dev','Rem','Traspaso','Ant')")
+ ElseIf UsuarioActual.TienePermisoProceso(267) AndAlso Not UsuarioActual.TienePermisoProceso(266) Then
+ DtPendientes = ObjInventarios.DtResultados.FiltraParametros("TipoDocto IN ('Ped','PDev','DPe')")
+ Else
+ DtPendientes = ObjInventarios.DtResultados
+ End If
+ Else
+ DtPendientes = Nothing
+ Alert("Ocurrió un error al obtener las Compras pendientes de recibir del proveedor. Por favor vuelva a intentar", TipoMensaje.MsgError)
+ End If
+
+ If UsuarioActual.Empresa.Funcionalidad(540) = "1" Then
+ BtnGuardar.Enabled = False
+ Dim FI As Date = Now.AddDays(-1)
+ Dim FF As Date = Now.AddDays(-7)
+ If ObjInventarios.RepNotasSinAlmacen(1, -1, FI, FF, "-1", -1, UsuarioActual.Empresa.CveEmpresa) Then
+ If ObjInventarios.DtResultados IsNot Nothing AndAlso ObjInventarios.DtResultados.Rows.Count > 1 Then
+ BtnGuardar.Enabled = False
+ Alert("No se podrá realizar entrega de mercancía si no se les da salida a los documentos pendientes. Para más información ver el Reporte de notas sin entrada en la sección Ventas.", TipoMensaje.MsgAdvertencia)
+ Else
+ BtnGuardar.Enabled = True
+
+ End If
+ End If
+ End If
+
+ ObjInventarios.Dispose()
+
+ If DtPendientes IsNot Nothing Then
+ GVPendientes.DataSource = DtPendientes
+
+ End If
+
+ LtActualizado.Text = String.Format("Actualizado: {0}", Now.ToString("H:mm"))
+
+ GVPendientes.DataBind()
+ UpPendientes.Update()
+ If DtPendientes IsNot Nothing Then DtPendientes.Dispose()
+
+ End Sub
+ Protected Sub GVPendientes_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GVPendientes.RowDataBound
+ If e.Row.RowType = DataControlRowType.DataRow Then
+ e.Row.FCLinkButton("BtnSurtir").CommandArgument = If(e.Row.DBCampo("TipoEntrega") = "1", e.Row.DBCampo("CveVenta"), e.Row.DBCampo("CveTraspasoSolicitud"))
+
+
+
+ Select Case e.Row.DBCampo("TipoEntrega").ToString.ToEntero
+ Case 1
+ If UsuarioActual.TienePermisoProceso(201) Then
+ Dim Css = "Texto"
+ Dim Liga = $"/Ventas/Ventas.aspx?&CveVenta={e.Row.DBCampo("CveVenta")}"
+ e.Row.FCLabel("LblFolio").Text = "" + e.Row.FCLabel("LblFolio").Text + ""
+ End If
+
+ If UsuarioActual.CveEmpresa.Contiene(72, 80) Then
+ GVPendientes.Columns(4).Visible = True
+ e.Row.FCHyperLink("HplDownPDF").Visible = True
+ e.Row.FCHyperLink("HplDownPDF").NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=VTA&CVEVENTA={0}", e.Row.DBCampo("CveVenta"))))
+ End If
+
+ If e.Row.DBCampo("TipoDocto").ToString.Contiene({"Rem", "Ing", "Ped", "PeC", "Ant"}) And e.Row.DBCampo("EsDevolucionVenta").ToString.ToEntero = 0 Then
+ e.Row.FCLinkButton("BtnSurtir").CssClass = "btn btn-primary btn-sm"
+ e.Row.FCLinkButton("BtnSurtir").Text = " Surtir "
+ Else
+ e.Row.FCLinkButton("BtnSurtir").CssClass = "btn yellow-gold btn-sm"
+ e.Row.FCLinkButton("BtnSurtir").Text = " Recibir"
+ End If
+ Case 2
+ Dim Css = "Texto"
+ Dim Liga = $"/Inventarios/TrasladoSolicitud.aspx?&CveTraspasoSolicitud={e.Row.DBCampo("CveTraspasoSolicitud")}"
+ e.Row.FCLabel("LblFolio").Text = "" + e.Row.FCLabel("LblFolio").Text + ""
+ e.Row.FCLinkButton("BtnSurtir").CssClass = "btn btn-primary btn-sm"
+ e.Row.FCLinkButton("BtnSurtir").Text = " Traspasar "
+ End Select
+ UpPendientes.Update()
+ End If
End Sub
-#End Region
+#End Region
-#Region " CARGA VENTA POR SURTIR "
- Protected Sub BtnSurtir_Click(sender As Object, e As EventArgs)
-
- Dim Boton = CType(sender, LinkButton)
- CveVentaAD = -1
-
- If Boton.CommandArgument.ToEntero > 0 Then
- TimmerRefresh.Enabled = False
-
- DivTransitorio1.Visible = False
- ChkTransitorio.Checked = False
- TxtResponsable.Text = ""
- DivTransitorio2.Visible = False
-
-
- Select Case CType(Boton.NamingContainer, GridViewRow).DataKey("TipoEntrega").ToEntero
- Case 1 ' VENTA
- CargaVentaPorSurtir(CType(sender, LinkButton).CommandArgument.ToEntero)
- Case 2 ' TRASPASO
- DivTransitorio1.Visible = True
- CargaTraspasoPorSurtir(CType(Boton.NamingContainer, GridViewRow).DataKey("CveTraspasoSolicitud").ToEntero)
- End Select
-
- End If
-
- End Sub
- Protected Sub BtnBuscar_Click(sender As Object, e As EventArgs)
- CveVentaAD = -2
- CargaVentaPorSurtir(DdlFolio.SelectedValue.ToEntero)
- End Sub
- Private Sub CargaVentaPorSurtir(CveVenta As Integer)
- LbSurtida.Visible = False
- CveContrato = -1
- CveSubProyecto = -1
- DtDatos = Nothing
- TipoEntrega = 1
- BtnGuardar.Visible = True
-
- Dim StrAlmacenes As String = "CveTipoAlmacen IN (1,2)"
-
- If UsuarioActual.CveSubProyecto = 8804 Then
- StrAlmacenes = "CveTipoAlmacen IN (1,2,12)"
- End If
-
- Dim ObjInventario As New ClsInventarios
-
- If ObjInventario.EntregaAlmacenGet(CveVenta) Then
- If ObjInventario.DtResultados IsNot Nothing AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then
-
-
- DtDatos = ObjInventario.DtResultados
- DtDatos.Columns.Add("Consec", GetType(Integer))
- DtDatos.Columns.Add("CantidadGV", GetType(Double))
- DtDatos.Columns.Add("CantidadTraspaso", GetType(Double))
- Dim Index = 1
- For Each Dr As DataRow In DtDatos.Rows
- Dr("Consec") = Index
- Index += 1
- Next
-
- DtDatosDetalle = Nothing
- CreaDtDetalle()
-
- DtDatosDetalleLote = Nothing
- CreaDtDetalleLote()
-
- If DtDatos.Rows(0) IsNot Nothing Then
- EsDevolucionVenta = DtDatos.Rows(0)("EsDevolucionVenta").ToString.ToEntero
- TipoDocto = DtDatos.Rows(0)("TipoDocto").ToString
- TipoMovimiento = If(TipoDocto.Contiene({"Rem", "Ing", "Ped", "PeC", "Ant"}) And (EsDevolucionVenta = 0 Or CveVentaAD > 0), 1, 2)
-
- LbCliente.Text = DtDatos.Rows(0)("Nombre").ToString
- 'LbFolio.Text = DtDatos.Rows(0)("SerieFolio").ToString
- HLFolio.Text = DtDatos.Rows(0)("SerieFolio").ToString
- If UsuarioActual.TienePermisoProceso(201) Then
- HLFolio.NavigateUrl = $"/Ventas/Ventas.aspx?CveVenta={CveVenta}"
- End If
-
- LbObservaciones.Text = DtDatos.Rows(0)("Observaciones").ToString
- LbObservacionesAlmacen.Text = DtDatos.Rows(0)("ObservacionesAlmacen").ToString
- CveVentaSurtir = CveVenta
- CveAlmacenTraspasoDestino = DtDatos.Rows(0)(If(EsDevolucionVenta = 1 And TipoDocto <> "Rem", "CveAlmacenTraspasoOrigen", "CveAlmacenTraspasoDestino")).ToString.ToEntero
- CveAlmacenTraspasoOrigen = DtDatos.Rows(0)(If(EsDevolucionVenta = 1 And TipoDocto <> "Rem", "CveAlmacenTraspasoDestino", "CveAlmacenTraspasoOrigen")).ToString.ToEntero
- CveContrato = DtDatos.Rows(0)("CveContrato").ToString.ToEntero
- CveVendedor = DtDatos.Rows(0)("CveVendedor").ToString.ToEntero
- CveCliente = DtDatos.Rows(0)("CveCliente").ToString.ToEntero
- CveSubProyecto = DtDatos.Rows(0)("CveSubProyecto").ToString.ToEntero
- EsInterno = CBool(DtDatos.Rows(0)("EsInterno").ToString)
-
- If DtDatos.SUM("CantidadS") <= 0 Then
- GvDatos.CssClass = "table table-striped table-hover Widthall ScrollAD gvInventario gvEscondeColumna"
- Else
- GvDatos.CssClass = "table table-striped table-hover Widthall ScrollAD gvInventario"
- End If
-
- If CveAlmacenTraspasoDestino > 0 And Not (TipoMovimiento = 2 And TipoDocto = "Rem") Then
- DivTipoCambioAdvertencia.Visible = True
- LtTipoCambioAdvertencia.Text = $"Los productos seran Trasladados al Almacen: {GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Almacen", $"CveAlmacen = {CveAlmacenTraspasoDestino}")}"
- Else
- DivTipoCambioAdvertencia.Visible = False
- End If
-
- 'DEVOLUCION REMISION
- If TipoMovimiento = 2 And TipoDocto = "Rem" And Not CveAlmacenTraspasoDestino > 0 Then
- Alert("La remisión que se intenta devolver presenta inconsistencias. Comuniquese con servicio tecnico SIG.", TipoMensaje.MsgError)
- BtnGuardar.Visible = False
- End If
-
- DdlAlmacen.Items.Clear()
- If CveAlmacenTraspasoOrigen > 0 Then 'Not (EsDevolucionVenta = 1 And DtDatos.Rows(0)("TipoDocto").ToString = "Rem" And UsuarioActual.Empresa.Funcionalidad(145) = "1") - ESTO ES PARA CUANDO SEA REMISION DE ENTREGA POR ADELANTADO FUNCIONA LA DEVOLUCION
- DdlAlmacen.Items.Insert(0, New ListItem(GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Almacen", $"CveAlmacen = {CveAlmacenTraspasoOrigen}"), CveAlmacenTraspasoOrigen.ToString))
- Else
- '[IPP] PARCHE - Debe hacerse permiso proceso - 17Enero2018
- Dim RestriccionAlmacenSubProyecto = If(UsuarioActual.CveEmpresa.Contiene(72, 80), $" AND CveSubProyecto = {CveSubProyecto}", "")
- DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros($"{StrAlmacenes} {RestriccionAlmacenSubProyecto}")
- End If
- DdlAlmacen.Items.Insert(0, New ListItem(" Seleccione ", "-1"))
- DdlAlmacen.SelectedValue = "-1"
- DdlAlmacen.DataBind()
- DdlAlmacen.SelectedValueExist(UsuarioActual.CveAlmacen)
- If CveAlmacenTraspasoOrigen > 0 Then
- DdlAlmacen.SelectedValueExist(CveAlmacenTraspasoOrigen)
- End If
-
- If Not DtDatos.Columns.Contains("Serie") Then
- DtDatos.Columns.Add("Serie", GetType(String))
- End If
- If Not DtDatos.Columns.Contains("Lote") Then
- DtDatos.Columns.Add("Lote", GetType(String))
- End If
- If Not DtDatos.Columns.Contains("CveSeccion") Then
- DtDatos.Columns.Add("CveSeccion", GetType(Integer))
- End If
- If Not DtDatos.Columns.Contains("FechaCaducidad") Then
- DtDatos.Columns.Add("FechaCaducidad", GetType(Date))
- End If
- If Not DtDatos.Columns.Contains("Seleccionado") Then
- DtDatos.Columns.Add("Seleccionado", GetType(Boolean))
- End If
- If Not DtDatos.Columns.Contains("CantidadSeleccionada") Then
- DtDatos.Columns.Add("CantidadSeleccionada", GetType(Double))
- End If
-
-
- 'TxtFecha.Text = If(EsDevolucionVenta = 1, Now.ToShortDateString, DtDatos.Rows(0)("Fecha").ToString)
- End If
-
- If UsuarioActual.Empresa.Funcionalidad(132) = "1" Then
- DivCodigoSeriePS.Visible = True
- Else
- DivCodigoSeriePS.Visible = False
- End If
-
- If TipoMovimiento = 2 Then ' cuando es cancelación
- Dim Filtro As String '= If(ObjInventario.DtResultados.Rows(0)("TipoDocto").ToString.Contiene({"Ing", "Dev", "Ped"}), "CveConcepto = 3", "CveConcepto = 9")
- Select Case ObjInventario.DtResultados.Rows(0)("TipoDocto").ToString
- Case "Ing", "Ped"
- Filtro = "CveConcepto IN (3,40)"
- Case "Dev"
- 'cuand es devolucionventa=1, es cancelación de la devolución
- If EsDevolucionVenta = 1 Then Filtro = "CveConcepto = 18" Else Filtro = "CveConcepto IN (3,40)"
- Case Else
- Filtro = "CveConcepto = 9"
- End Select
- If ObjInventario.GetInv_Mov(ObjInventario.DtResultados.Rows(0)("CveVentaPadre").ToString.ToEntero, UsuarioActual.CveEmpresa) Then
- DtExistencias = ObjInventario.DtResultados.FiltraParametros($"CvePS Is Not NULL AND {Filtro}")
-
- If Not DtExistencias.Rows.Count > 0 Then
- Alert("La Venta original de la Devolución no tiene salida de Almacén.", TipoMensaje.MsgAdvertencia)
- End If
-
- If TipoDocto.Contiene("Ing") AndAlso TipoMovimiento = 2 Then
- Dim DtMov As DataTable = DtExistencias.FiltraParametros("CveConcepto = 40", "", {"CveAlmacen"})
- If DtMov.Rows.Count > 0 Then
- Dim CveAlmacenDev As Integer = DtMov.Rows(0)("CveAlmacen").ToString().ToEntero()
- DdlAlmacen.Items.Clear()
- DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros($"CveAlmacen = {CveAlmacenDev}")
- DdlAlmacen.DataBind()
-
- DdlAlmacen.SelectedValueExist(CveAlmacenDev)
- EsDevolucionDirecta = True
- End If
- End If
-
- Else
- Alert("Ocurrió un error al cargar los datos de devolución. Por favor vuelva a intentar.", TipoMensaje.MsgError)
- End If
- End If
- If UsuarioActual.Empresa.FacturaProduccion Then
- CargaDocumentos(CveVenta)
- End If
- Else
- Alert("No se encontraron productos pendientes por surtir. Por favor verifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
- End If
- Else
- DtDatos = Nothing
- End If
-
- ObjInventario.Dispose()
- UpGenerales.Update()
- CargaGvDatos()
-
- End Sub
- Private Sub CargaTraspasoPorSurtir(CveTraspaso As Integer)
- LbSurtida.Visible = False
- CveContrato = -1
- CveSubProyecto = -1
- DtDatos = Nothing
- TipoEntrega = 2
-
- Dim ObjInventario As New ClsInventarios
-
- If ObjInventario.EntregaAlmacenTraspasosGet(CveTraspaso) Then
- If ObjInventario.DtResultados IsNot Nothing AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then
- CveTraspasoSurtir = CveTraspaso
- TipoMovimiento = 1
-
- DtDatos = ObjInventario.DtResultados
- DtDatos.Columns.Add("Consec", GetType(Integer))
- DtDatos.Columns.Add("CantidadGV", GetType(Double))
- DtDatos.Columns.Add("CantidadTraspaso", GetType(Double))
-
- LbCliente.Text = DtDatos.Rows(0)("Nombre").ToString
- HLFolio.Text = DtDatos.Rows(0)("SerieFolio").ToString
- If UsuarioActual.TienePermisoProceso(201) Then
- HLFolio.NavigateUrl = $"/Inventarios/TrasladoSolicitud.aspx?CveTraspasoSolicitud={CveTraspasoSurtir}"
- End If
- LbObservaciones.Text = DtDatos.Rows(0)("Observaciones").ToString
-
- Dim Index = 1
- For Each Dr As DataRow In DtDatos.Rows
- Dr("Consec") = Index
- Index += 1
- Next
-
- DtDatosDetalle = Nothing
- CreaDtDetalle()
-
- DtDatosDetalleLote = Nothing
- CreaDtDetalleLote()
-
- CveAlmacenTraspasoDestino = DtDatos.Rows(0)("CveAlmacenDestino").ToString.ToEntero
- CveAlmacenTraspasoOrigen = DtDatos.Rows(0)("CveAlmacenOrigen").ToString.ToEntero
- CveSubProyecto = DtDatos.Rows(0)("CveSubProyecto").ToString.ToEntero
- EsInterno = CBool(DtDatos.Rows(0)("EsInterno").ToString)
-
- If DtDatos.SUM("CantidadS") <= 0 Then
- GvDatos.CssClass = "table table-striped table-hover Widthall ScrollAD gvInventario gvEscondeColumna"
- Else
- GvDatos.CssClass = "table table-striped table-hover Widthall ScrollAD gvInventario"
- End If
-
- If CveAlmacenTraspasoDestino > 0 Then
- DivTipoCambioAdvertencia.Visible = True
- LtTipoCambioAdvertencia.Text = $"Los productos seran Trasladados al Almacen: {GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Almacen", $"CveAlmacen = {CveAlmacenTraspasoDestino}")}"
- Else
- DivTipoCambioAdvertencia.Visible = False
- End If
-
- 'If DtDatos.Rows.Cast(Of DataRow).Any(Function(Row) Row("CveTamaño").ToString().ToEntero() > 0) Then
-
- 'End If
-
-
- DdlAlmacen.Items.Clear()
- If CveAlmacenTraspasoOrigen > 0 Then
- DdlAlmacen.Items.Insert(0, New ListItem(GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Almacen", $"CveAlmacen = {CveAlmacenTraspasoOrigen}"), CveAlmacenTraspasoOrigen.ToString))
- End If
-
- DdlAlmacen.Items.Insert(0, New ListItem(" Seleccione ", "-1"))
- DdlAlmacen.SelectedValue = "-1"
- DdlAlmacen.DataBind()
- DdlAlmacen.SelectedValueExist(UsuarioActual.CveAlmacen)
- If CveAlmacenTraspasoOrigen > 0 Then
- DdlAlmacen.SelectedValueExist(CveAlmacenTraspasoOrigen)
- End If
-
- If Not DtDatos.Columns.Contains("CveSeccion") Then
- DtDatos.Columns.Add("CveSeccion", GetType(Integer))
+#Region " CARGA VENTA POR SURTIR "
+ Protected Sub BtnSurtir_Click(sender As Object, e As EventArgs)
+
+ Dim Boton = CType(sender, LinkButton)
+ CveVentaAD = -1
+
+ If Boton.CommandArgument.ToEntero > 0 Then
+ TimmerRefresh.Enabled = False
+
+ DivTransitorio1.Visible = False
+ ChkTransitorio.Checked = False
+ TxtResponsable.Text = ""
+ DivTransitorio2.Visible = False
+
+
+ Select Case CType(Boton.NamingContainer, GridViewRow).DataKey("TipoEntrega").ToEntero
+ Case 1 ' VENTA
+ CargaVentaPorSurtir(CType(sender, LinkButton).CommandArgument.ToEntero)
+ Case 2 ' TRASPASO
+ DivTransitorio1.Visible = True
+ CargaTraspasoPorSurtir(CType(Boton.NamingContainer, GridViewRow).DataKey("CveTraspasoSolicitud").ToEntero)
+ End Select
+
+ End If
+
+ End Sub
+ Protected Sub BtnBuscar_Click(sender As Object, e As EventArgs)
+ CveVentaAD = -2
+ CargaVentaPorSurtir(DdlFolio.SelectedValue.ToEntero)
+ End Sub
+ Private Sub CargaVentaPorSurtir(CveVenta As Integer)
+ LbSurtida.Visible = False
+ CveContrato = -1
+ CveSubProyecto = -1
+ DtDatos = Nothing
+ TipoEntrega = 1
+ BtnGuardar.Visible = True
+
+ Dim StrAlmacenes As String = "CveTipoAlmacen IN (1,2)"
+
+ If UsuarioActual.CveSubProyecto = 8804 Then
+ StrAlmacenes = "CveTipoAlmacen IN (1,2,12)"
+ End If
+
+ Dim ObjInventario As New ClsInventarios
+
+ If ObjInventario.EntregaAlmacenGet(CveVenta) Then
+ If ObjInventario.DtResultados IsNot Nothing AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then
+
+
+ DtDatos = ObjInventario.DtResultados
+ DtDatos.Columns.Add("Consec", GetType(Integer))
+ DtDatos.Columns.Add("CantidadGV", GetType(Double))
+ DtDatos.Columns.Add("CantidadTraspaso", GetType(Double))
+ Dim Index = 1
+ For Each Dr As DataRow In DtDatos.Rows
+ Dr("Consec") = Index
+ Index += 1
+ Next
+
+ DtDatosDetalle = Nothing
+ CreaDtDetalle()
+
+ DtDatosDetalleLote = Nothing
+ CreaDtDetalleLote()
+
+ If DtDatos.Rows(0) IsNot Nothing Then
+ EsDevolucionVenta = DtDatos.Rows(0)("EsDevolucionVenta").ToString.ToEntero
+ TipoDocto = DtDatos.Rows(0)("TipoDocto").ToString
+ TipoMovimiento = If(TipoDocto.Contiene({"Rem", "Ing", "Ped", "PeC", "Ant"}) And (EsDevolucionVenta = 0 Or CveVentaAD > 0), 1, 2)
+
+ LbCliente.Text = DtDatos.Rows(0)("Nombre").ToString
+ 'LbFolio.Text = DtDatos.Rows(0)("SerieFolio").ToString
+ HLFolio.Text = DtDatos.Rows(0)("SerieFolio").ToString
+ If UsuarioActual.TienePermisoProceso(201) Then
+ HLFolio.NavigateUrl = $"/Ventas/Ventas.aspx?CveVenta={CveVenta}"
+ End If
+
+ LbObservaciones.Text = DtDatos.Rows(0)("Observaciones").ToString
+ LbObservacionesAlmacen.Text = DtDatos.Rows(0)("ObservacionesAlmacen").ToString
+ CveVentaSurtir = CveVenta
+ CveAlmacenTraspasoDestino = DtDatos.Rows(0)(If(EsDevolucionVenta = 1 And TipoDocto <> "Rem", "CveAlmacenTraspasoOrigen", "CveAlmacenTraspasoDestino")).ToString.ToEntero
+ CveAlmacenTraspasoOrigen = DtDatos.Rows(0)(If(EsDevolucionVenta = 1 And TipoDocto <> "Rem", "CveAlmacenTraspasoDestino", "CveAlmacenTraspasoOrigen")).ToString.ToEntero
+ CveContrato = DtDatos.Rows(0)("CveContrato").ToString.ToEntero
+ CveVendedor = DtDatos.Rows(0)("CveVendedor").ToString.ToEntero
+ CveCliente = DtDatos.Rows(0)("CveCliente").ToString.ToEntero
+ CveSubProyecto = DtDatos.Rows(0)("CveSubProyecto").ToString.ToEntero
+ EsInterno = CBool(DtDatos.Rows(0)("EsInterno").ToString)
+
+ If DtDatos.SUM("CantidadS") <= 0 Then
+ GvDatos.CssClass = "table table-striped table-hover Widthall ScrollAD gvInventario gvEscondeColumna"
+ Else
+ GvDatos.CssClass = "table table-striped table-hover Widthall ScrollAD gvInventario"
+ End If
+
+ If CveAlmacenTraspasoDestino > 0 And Not (TipoMovimiento = 2 And TipoDocto = "Rem") Then
+ DivTipoCambioAdvertencia.Visible = True
+ LtTipoCambioAdvertencia.Text = $"Los productos seran Trasladados al Almacen: {GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Almacen", $"CveAlmacen = {CveAlmacenTraspasoDestino}")}"
+ Else
+ DivTipoCambioAdvertencia.Visible = False
+ End If
+
+ 'DEVOLUCION REMISION
+ If TipoMovimiento = 2 And TipoDocto = "Rem" And Not CveAlmacenTraspasoDestino > 0 Then
+ Alert("La remisión que se intenta devolver presenta inconsistencias. Comuniquese con servicio tecnico SIG.", TipoMensaje.MsgError)
+ BtnGuardar.Visible = False
+ End If
+
+ DdlAlmacen.Items.Clear()
+ If CveAlmacenTraspasoOrigen > 0 Then 'Not (EsDevolucionVenta = 1 And DtDatos.Rows(0)("TipoDocto").ToString = "Rem" And UsuarioActual.Empresa.Funcionalidad(145) = "1") - ESTO ES PARA CUANDO SEA REMISION DE ENTREGA POR ADELANTADO FUNCIONA LA DEVOLUCION
+ DdlAlmacen.Items.Insert(0, New ListItem(GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Almacen", $"CveAlmacen = {CveAlmacenTraspasoOrigen}"), CveAlmacenTraspasoOrigen.ToString))
+ Else
+ '[IPP] PARCHE - Debe hacerse permiso proceso - 17Enero2018
+ Dim RestriccionAlmacenSubProyecto = If(UsuarioActual.CveEmpresa.Contiene(72, 80), $" AND CveSubProyecto = {CveSubProyecto}", "")
+ DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros($"{StrAlmacenes} {RestriccionAlmacenSubProyecto}")
+ End If
+ DdlAlmacen.Items.Insert(0, New ListItem(" Seleccione ", "-1"))
+ DdlAlmacen.SelectedValue = "-1"
+ DdlAlmacen.DataBind()
+ DdlAlmacen.SelectedValueExist(UsuarioActual.CveAlmacen)
+ If CveAlmacenTraspasoOrigen > 0 Then
+ DdlAlmacen.SelectedValueExist(CveAlmacenTraspasoOrigen)
+ End If
+
+ If Not DtDatos.Columns.Contains("Serie") Then
+ DtDatos.Columns.Add("Serie", GetType(String))
+ End If
+ If Not DtDatos.Columns.Contains("Lote") Then
+ DtDatos.Columns.Add("Lote", GetType(String))
+ End If
+ If Not DtDatos.Columns.Contains("CveSeccion") Then
+ DtDatos.Columns.Add("CveSeccion", GetType(Integer))
+ End If
+ If Not DtDatos.Columns.Contains("FechaCaducidad") Then
+ DtDatos.Columns.Add("FechaCaducidad", GetType(Date))
+ End If
+ If Not DtDatos.Columns.Contains("Seleccionado") Then
+ DtDatos.Columns.Add("Seleccionado", GetType(Boolean))
+ End If
+ If Not DtDatos.Columns.Contains("CantidadSeleccionada") Then
+ DtDatos.Columns.Add("CantidadSeleccionada", GetType(Double))
+ End If
+
+
+ 'TxtFecha.Text = If(EsDevolucionVenta = 1, Now.ToShortDateString, DtDatos.Rows(0)("Fecha").ToString)
End If
- If Not DtDatos.Columns.Contains("Lote") Then
- DtDatos.Columns.Add("Lote", GetType(String))
- End If
-
- If Not DtDatos.Columns.Contains("FechaCaducidad") Then
- DtDatos.Columns.Add("FechaCaducidad", GetType(Date))
- End If
- If Not DtDatos.Columns.Contains("Seleccionado") Then
- DtDatos.Columns.Add("Seleccionado", GetType(Boolean))
- End If
- If Not DtDatos.Columns.Contains("CantidadSeleccionada") Then
- DtDatos.Columns.Add("CantidadSeleccionada", GetType(Double))
- End If
-
- If UsuarioActual.Empresa.Funcionalidad(132) = "1" Then
- DivCodigoSeriePS.Visible = True
- Else
- DivCodigoSeriePS.Visible = False
- End If
-
- Else
- Alert("No se encontraron productos pendientes por surtir. Por favor verifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
- End If
- Else
- DtDatos = Nothing
- End If
-
- ObjInventario.Dispose()
- UpGenerales.Update()
- CargaGvDatos()
-
- End Sub
- Private Sub CargaGvDatos()
-
- If DtDatos IsNot Nothing Then
-
-
- Dim AplicaSeccion, AplicaLote, AplicaCaducidad, AplicaSerie As Boolean
- If DtDatos IsNot Nothing AndAlso DtDatos.Rows.Count > 0 Then
- AplicaSerie = CBool(DtDatos.MAX("AplicaSerie"))
- AplicaSeccion = CBool(DtDatos.MAX("AplicaSeccion"))
- AplicaLote = CBool(DtDatos.MAX("AplicaLote"))
- AplicaCaducidad = CBool(DtDatos.MAX("AplicaCaducidad"))
- End If
-
- If AplicaSeccion Then GvDatos.Columns(7).Visible = True
- If AplicaLote Then GvDatos.Columns(8).Visible = True
- If AplicaCaducidad Then GvDatos.Columns(9).Visible = True
-
- GvDatos.DataSource = DtDatos
- End If
-
-
- GvDatos.DataBind()
- UpDatos.Update()
- UpVenta.Update()
-
- 'CARGA LO PRECARGADO CON SERIE
- Dim Contador = 0
- For Each Gvr As GridViewRow In GvDatos.Rows
- If Gvr.DataKey("CvePS").ToEntero = CvePSSerie AndAlso DtDatosDetalle IsNot Nothing Then
- Contador = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Gvr.DataKey("Consec"))).Rows.Count
- Gvr.FCCheckBox("cbInv").Enabled = False
- Gvr.FCCheckBox("cbInv").Checked = True
- Gvr.FCTextBox("TbCantidadF").Text = Contador.ToString
- End If
- Next
-
- End Sub
-
- Protected Sub GvDatos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDatos.RowDataBound
- If e.Row.RowType = DataControlRowType.DataRow Then
-
- If CBool(e.Row.DBCampo("AplicaSerie")) Then
- e.Row.FCButton("BtnSerie").Visible = True
- e.Row.FCButton("BtnSerie").Text = If(e.Row.DBCampo("Inv_CveMetodoInventario").ToString = "5", "Serie", "Lote-Batch")
- e.Row.FCButton("BtnSerie").CommandArgument = String.Format("{0}°{1}°{2}°{3}°{4}°{5}", e.Row.DBCampo("CvePS"), e.Row.DBCampo("CveUM"), e.Row.DBCampo("PS"), e.Row.DBCampo("CantidadF"), e.Row.DBCampo("Consec"), e.Row.DBCampo("Inv_CveMetodoInventario"))
- e.Row.FCTextBox("TbCantidadF").Enabled = False
- e.Row.FCCheckBox("cbInv").Enabled = False
- If e.Row.DBCampo("Consec") <> "" AndAlso DtDatosDetalle IsNot Nothing Then
- Dim Contador = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", e.Row.DBCampo("Consec"))).Rows.Count
- e.Row.FCTextBox("TbCantidadF").Text = Contador.ToString
- Else
- e.Row.FCTextBox("TbCantidadF").Text = "0"
- End If
-
-
- If TipoDocto = "DPe" Then
- CveConsecSerie = e.Row.DBCampo("Consec").ToString.ToEntero
- PSSerie = e.Row.DBCampo("PS").ToString
- CvePSSerie = e.Row.DBCampo("CvePS").ToEntero
- CveUMSerie = e.Row.DBCampo("CveUM").ToEntero
- LbCantidad.Text = e.Row.DBCampo("CantidadF")
- LbCantidad2.Text = e.Row.DBCampo("CantidadF")
- AgregaSerie(e.Row.DBCampo("ObservacionesDetalle"), 3)
- End If
-
- Else
- e.Row.FCButton("BtnSerie").Visible = False
- e.Row.FCTextBox("TbCantidadF").Enabled = True
- e.Row.FCTextBox("TbCantidadF").Attributes.Add("onblur", String.Format("ValidarCantidad(this, {0})", e.Row.DBCampo("CantidadF")))
- End If
-
-
- If CBool(e.Row.DBCampo("AplicaSeccion")) Then
- e.Row.FCDropDownList("DdlSeccionAlmacen").Visible = True
- If DdlAlmacen.SelectedValue.ToEntero > 0 Then
- e.Row.FCDropDownList("DdlSeccionAlmacen").DataSource = GlobalDTInvPSSeccionesAlmacen(UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, e.Row.DBCampo("CvePS").ToEntero)
- e.Row.FCDropDownList("DdlSeccionAlmacen").DataBind()
- e.Row.FCDropDownList("DdlSeccionAlmacen").Items.Insert(0, New ListItem("Seleccione", "-1"))
- End If
-
- Else
- e.Row.FCDropDownList("DdlSeccionAlmacen").Visible = False
- End If
-
- If CBool(e.Row.DBCampo("AplicaCaducidad")) Then
- e.Row.FCTextBox("TxtCaducidad").Visible = True
- e.Row.FCLinkButton("LnkCaducidad").Visible = True
-
- Else
- e.Row.FCTextBox("TxtCaducidad").Visible = False
- e.Row.FCLinkButton("LnkCaducidad").Visible = False
- End If
-
- If CBool(e.Row.DBCampo("AplicaLote")) Then
- e.Row.FCTextBox("TxtLote").Visible = True
- Else
- e.Row.FCTextBox("TxtLote").Visible = False
- End If
-
- e.Row.FCButton("BtnDividir").Attributes.Add("onclick", String.Format("Dividir('{0}');", e.Row.FCTextBox("TxtDividir").ClientID))
- e.Row.FCButton("BtnDividir").CommandArgument = e.Row.RowIndex.ToString
- e.Row.FCTextBox("TxtDividir").Attributes.Add("onkeyup", String.Format("LimitaCantidad({0},this,'{1}');", e.Row.DBCampo("CantidadF"), e.Row.FCButton("BtnDividir").ClientID))
-
-
- 'FUNCIONALIDAD PISTOLA DE CODIGOS
- If UsuarioActual.Empresa.Funcionalidad(132) = "1" And e.Row.DBCampo("CodigoBarras").Trim <> "" Then
- e.Row.FCTextBox("TbCantidadF").Text = "0"
- 'NO BLOQUEA PARA ROL AD
- If UsuarioActual.CveRol = 1 Then
- If e.Row.DBCampo("Inv_CveMetodoInventario").Contiene("5", "6") Then
- e.Row.FCTextBox("TbCantidadF").Enabled = False
- Else
- e.Row.FCTextBox("TbCantidadF").Text = e.Row.DBCampo("CantidadF").FormatoNumero()
- End If
- End If
-
- If Not UsuarioActual.CveRol = 1 Then
- e.Row.FCTextBox("TbCantidadF").Enabled = False
- End If
- End If
-
- 'SI ES TRASPASO OBLIGATORIO SURTIR TODO
- If TipoEntrega = 2 Then
- e.Row.FCCheckBox("cbInv").Enabled = False
- End If
-
-
- End If
- End Sub
-
- Private Sub CargaDocumentos(tCveVenta As Integer)
- Dim objInv As New ClsEdocumentacion
-
- If objInv.DocumentacionElectronicaGet(-1, -1, -1, UsuarioActual.CveEmpresa, -1, tCveVenta) Then
- GvDocs.DataSource = objInv.DtResultados.FiltraParametros("Adjunto <> ''")
- End If
- objInv.Dispose()
- GvDocs.DataBind()
+ If UsuarioActual.Empresa.Funcionalidad(132) = "1" Then
+ DivCodigoSeriePS.Visible = True
+ Else
+ DivCodigoSeriePS.Visible = False
+ End If
+
+ If TipoMovimiento = 2 Then ' cuando es cancelación
+ Dim Filtro As String '= If(ObjInventario.DtResultados.Rows(0)("TipoDocto").ToString.Contiene({"Ing", "Dev", "Ped"}), "CveConcepto = 3", "CveConcepto = 9")
+ Select Case ObjInventario.DtResultados.Rows(0)("TipoDocto").ToString
+ Case "Ing", "Ped"
+ Filtro = "CveConcepto IN (3,40)"
+ Case "Dev"
+ 'cuand es devolucionventa=1, es cancelación de la devolución
+ If EsDevolucionVenta = 1 Then Filtro = "CveConcepto = 18" Else Filtro = "CveConcepto IN (3,40)"
+ Case Else
+ Filtro = "CveConcepto = 9"
+ End Select
+ If ObjInventario.GetInv_Mov(ObjInventario.DtResultados.Rows(0)("CveVentaPadre").ToString.ToEntero, UsuarioActual.CveEmpresa) Then
+ DtExistencias = ObjInventario.DtResultados.FiltraParametros($"CvePS Is Not NULL AND {Filtro}")
+
+ If Not DtExistencias.Rows.Count > 0 Then
+ Alert("La Venta original de la Devolución no tiene salida de Almacén.", TipoMensaje.MsgAdvertencia)
+ End If
+
+ If TipoDocto.Contiene("Ing") AndAlso TipoMovimiento = 2 Then
+ Dim DtMov As DataTable = DtExistencias.FiltraParametros("CveConcepto = 40", "", {"CveAlmacen"})
+ If DtMov.Rows.Count > 0 Then
+ Dim CveAlmacenDev As Integer = DtMov.Rows(0)("CveAlmacen").ToString().ToEntero()
+ DdlAlmacen.Items.Clear()
+ DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros($"CveAlmacen = {CveAlmacenDev}")
+ DdlAlmacen.DataBind()
+
+ DdlAlmacen.SelectedValueExist(CveAlmacenDev)
+ EsDevolucionDirecta = True
+ End If
+ End If
+
+ Else
+ Alert("Ocurrió un error al cargar los datos de devolución. Por favor vuelva a intentar.", TipoMensaje.MsgError)
+ End If
+ End If
+ If UsuarioActual.Empresa.FacturaProduccion Then
+ CargaDocumentos(CveVenta)
+ End If
+ Else
+ Alert("No se encontraron productos pendientes por surtir. Por favor verifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
+ End If
+ Else
+ DtDatos = Nothing
+ End If
+
+ ObjInventario.Dispose()
+ UpGenerales.Update()
+ CargaGvDatos()
+
+ End Sub
+ Private Sub CargaTraspasoPorSurtir(CveTraspaso As Integer)
+ LbSurtida.Visible = False
+ CveContrato = -1
+ CveSubProyecto = -1
+ DtDatos = Nothing
+ TipoEntrega = 2
+
+ Dim ObjInventario As New ClsInventarios
+
+ If ObjInventario.EntregaAlmacenTraspasosGet(CveTraspaso) Then
+ If ObjInventario.DtResultados IsNot Nothing AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then
+ CveTraspasoSurtir = CveTraspaso
+ TipoMovimiento = 1
+
+ DtDatos = ObjInventario.DtResultados
+ DtDatos.Columns.Add("Consec", GetType(Integer))
+ DtDatos.Columns.Add("CantidadGV", GetType(Double))
+ DtDatos.Columns.Add("CantidadTraspaso", GetType(Double))
+
+ LbCliente.Text = DtDatos.Rows(0)("Nombre").ToString
+ HLFolio.Text = DtDatos.Rows(0)("SerieFolio").ToString
+ If UsuarioActual.TienePermisoProceso(201) Then
+ HLFolio.NavigateUrl = $"/Inventarios/TrasladoSolicitud.aspx?CveTraspasoSolicitud={CveTraspasoSurtir}"
+ End If
+ LbObservaciones.Text = DtDatos.Rows(0)("Observaciones").ToString
+
+ Dim Index = 1
+ For Each Dr As DataRow In DtDatos.Rows
+ Dr("Consec") = Index
+ Index += 1
+ Next
+
+ DtDatosDetalle = Nothing
+ CreaDtDetalle()
+
+ DtDatosDetalleLote = Nothing
+ CreaDtDetalleLote()
+
+ CveAlmacenTraspasoDestino = DtDatos.Rows(0)("CveAlmacenDestino").ToString.ToEntero
+ CveAlmacenTraspasoOrigen = DtDatos.Rows(0)("CveAlmacenOrigen").ToString.ToEntero
+
+ If DtDatos.SUM("CantidadS") <= 0 Then
+ GvDatos.CssClass = "table table-striped table-hover Widthall ScrollAD gvInventario gvEscondeColumna"
+ Else
+ GvDatos.CssClass = "table table-striped table-hover Widthall ScrollAD gvInventario"
+ End If
+
+ If CveAlmacenTraspasoDestino > 0 Then
+ DivTipoCambioAdvertencia.Visible = True
+ LtTipoCambioAdvertencia.Text = $"Los productos seran Trasladados al Almacen: {GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Almacen", $"CveAlmacen = {CveAlmacenTraspasoDestino}")}"
+ Else
+ DivTipoCambioAdvertencia.Visible = False
+ End If
+
+ 'If DtDatos.Rows.Cast(Of DataRow).Any(Function(Row) Row("CveTamaño").ToString().ToEntero() > 0) Then
+
+ 'End If
+
+
+ DdlAlmacen.Items.Clear()
+ If CveAlmacenTraspasoOrigen > 0 Then
+ DdlAlmacen.Items.Insert(0, New ListItem(GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Almacen", $"CveAlmacen = {CveAlmacenTraspasoOrigen}"), CveAlmacenTraspasoOrigen.ToString))
+ End If
+
+ DdlAlmacen.Items.Insert(0, New ListItem(" Seleccione ", "-1"))
+ DdlAlmacen.SelectedValue = "-1"
+ DdlAlmacen.DataBind()
+ DdlAlmacen.SelectedValueExist(UsuarioActual.CveAlmacen)
+ If CveAlmacenTraspasoOrigen > 0 Then
+ DdlAlmacen.SelectedValueExist(CveAlmacenTraspasoOrigen)
+ End If
+
+ If Not DtDatos.Columns.Contains("CveSeccion") Then
+ DtDatos.Columns.Add("CveSeccion", GetType(Integer))
+ End If
+
+ If Not DtDatos.Columns.Contains("FechaCaducidad") Then
+ DtDatos.Columns.Add("FechaCaducidad", GetType(Date))
+ End If
+ If Not DtDatos.Columns.Contains("Seleccionado") Then
+ DtDatos.Columns.Add("Seleccionado", GetType(Boolean))
+ End If
+ If Not DtDatos.Columns.Contains("CantidadSeleccionada") Then
+ DtDatos.Columns.Add("CantidadSeleccionada", GetType(Double))
+ End If
+
+ If UsuarioActual.Empresa.Funcionalidad(132) = "1" Then
+ DivCodigoSeriePS.Visible = True
+ Else
+ DivCodigoSeriePS.Visible = False
+ End If
+
+ Else
+ Alert("No se encontraron productos pendientes por surtir. Por favor verifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
+ End If
+ Else
+ DtDatos = Nothing
+ End If
+
+ ObjInventario.Dispose()
+ UpGenerales.Update()
+ CargaGvDatos()
+
+ End Sub
+ Private Sub CargaGvDatos()
+
+ If DtDatos IsNot Nothing Then
+
+
+ Dim AplicaSeccion, AplicaLote, AplicaCaducidad, AplicaSerie As Boolean
+ If DtDatos IsNot Nothing AndAlso DtDatos.Rows.Count > 0 Then
+ AplicaSerie = CBool(DtDatos.MAX("AplicaSerie"))
+ AplicaSeccion = CBool(DtDatos.MAX("AplicaSeccion"))
+ AplicaLote = CBool(DtDatos.MAX("AplicaLote"))
+ AplicaCaducidad = CBool(DtDatos.MAX("AplicaCaducidad"))
+ End If
+
+ If AplicaSeccion Then GvDatos.Columns(7).Visible = True
+ If AplicaLote Then GvDatos.Columns(8).Visible = True
+ If AplicaCaducidad Then GvDatos.Columns(9).Visible = True
+
+ GvDatos.DataSource = DtDatos
+ End If
+
+
+ GvDatos.DataBind()
+ UpDatos.Update()
+ UpVenta.Update()
+
+ 'CARGA LO PRECARGADO CON SERIE
+ Dim Contador = 0
+ For Each Gvr As GridViewRow In GvDatos.Rows
+ If Gvr.DataKey("CvePS").ToEntero = CvePSSerie AndAlso DtDatosDetalle IsNot Nothing Then
+ Contador = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Gvr.DataKey("Consec"))).Rows.Count
+ Gvr.FCCheckBox("cbInv").Enabled = False
+ Gvr.FCCheckBox("cbInv").Checked = True
+ Gvr.FCTextBox("TbCantidadF").Text = Contador.ToString
+ End If
+ Next
+
+ End Sub
+
+ Protected Sub GvDatos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDatos.RowDataBound
+ If e.Row.RowType = DataControlRowType.DataRow Then
+
+ If CBool(e.Row.DBCampo("AplicaSerie")) Then
+ e.Row.FCButton("BtnSerie").Visible = True
+ e.Row.FCButton("BtnSerie").Text = If(e.Row.DBCampo("Inv_CveMetodoInventario").ToString = "5", "Serie", "Lote-Batch")
+ e.Row.FCButton("BtnSerie").CommandArgument = String.Format("{0}°{1}°{2}°{3}°{4}°{5}", e.Row.DBCampo("CvePS"), e.Row.DBCampo("CveUM"), e.Row.DBCampo("PS"), e.Row.DBCampo("CantidadF"), e.Row.DBCampo("Consec"), e.Row.DBCampo("Inv_CveMetodoInventario"))
+ e.Row.FCTextBox("TbCantidadF").Enabled = False
+ e.Row.FCCheckBox("cbInv").Enabled = False
+ If e.Row.DBCampo("Consec") <> "" AndAlso DtDatosDetalle IsNot Nothing Then
+ Dim Contador = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", e.Row.DBCampo("Consec"))).Rows.Count
+ e.Row.FCTextBox("TbCantidadF").Text = Contador.ToString
+ Else
+ e.Row.FCTextBox("TbCantidadF").Text = "0"
+ End If
+
+
+ If TipoDocto = "DPe" Then
+ CveConsecSerie = e.Row.DBCampo("Consec").ToString.ToEntero
+ PSSerie = e.Row.DBCampo("PS").ToString
+ CvePSSerie = e.Row.DBCampo("CvePS").ToEntero
+ CveUMSerie = e.Row.DBCampo("CveUM").ToEntero
+ LbCantidad.Text = e.Row.DBCampo("CantidadF")
+ LbCantidad2.Text = e.Row.DBCampo("CantidadF")
+ AgregaSerie(e.Row.DBCampo("ObservacionesDetalle"), 3)
+ End If
+
+ Else
+ e.Row.FCButton("BtnSerie").Visible = False
+ e.Row.FCTextBox("TbCantidadF").Enabled = True
+ e.Row.FCTextBox("TbCantidadF").Attributes.Add("onblur", String.Format("ValidarCantidad(this, {0})", e.Row.DBCampo("CantidadF")))
+ End If
+
+
+ If CBool(e.Row.DBCampo("AplicaSeccion")) Then
+ e.Row.FCDropDownList("DdlSeccionAlmacen").Visible = True
+ If DdlAlmacen.SelectedValue.ToEntero > 0 Then
+ e.Row.FCDropDownList("DdlSeccionAlmacen").DataSource = GlobalDTInvPSSeccionesAlmacen(UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, e.Row.DBCampo("CvePS").ToEntero)
+ e.Row.FCDropDownList("DdlSeccionAlmacen").DataBind()
+ e.Row.FCDropDownList("DdlSeccionAlmacen").Items.Insert(0, New ListItem("Seleccione", "-1"))
+ End If
+
+ Else
+ e.Row.FCDropDownList("DdlSeccionAlmacen").Visible = False
+ End If
+
+ If CBool(e.Row.DBCampo("AplicaCaducidad")) Then
+ e.Row.FCTextBox("TxtCaducidad").Visible = True
+ e.Row.FCLinkButton("LnkCaducidad").Visible = True
+
+ Else
+ e.Row.FCTextBox("TxtCaducidad").Visible = False
+ e.Row.FCLinkButton("LnkCaducidad").Visible = False
+ End If
+
+ If CBool(e.Row.DBCampo("AplicaLote")) Then
+ e.Row.FCTextBox("TxtLote").Visible = True
+ Else
+ e.Row.FCTextBox("TxtLote").Visible = False
+ End If
+
+ e.Row.FCButton("BtnDividir").Attributes.Add("onclick", String.Format("Dividir('{0}');", e.Row.FCTextBox("TxtDividir").ClientID))
+ e.Row.FCButton("BtnDividir").CommandArgument = e.Row.RowIndex.ToString
+ e.Row.FCTextBox("TxtDividir").Attributes.Add("onkeyup", String.Format("LimitaCantidad({0},this,'{1}');", e.Row.DBCampo("CantidadF"), e.Row.FCButton("BtnDividir").ClientID))
+
+
+ 'FUNCIONALIDAD PISTOLA DE CODIGOS
+ If UsuarioActual.Empresa.Funcionalidad(132) = "1" And e.Row.DBCampo("CodigoBarras").Trim <> "" Then
+ e.Row.FCTextBox("TbCantidadF").Text = "0"
+ 'NO BLOQUEA PARA ROL AD
+ If UsuarioActual.CveRol = 1 Then
+ If e.Row.DBCampo("Inv_CveMetodoInventario").Contiene("5", "6") Then
+ e.Row.FCTextBox("TbCantidadF").Enabled = False
+ Else
+ e.Row.FCTextBox("TbCantidadF").Text = e.Row.DBCampo("CantidadF").FormatoNumero()
+ End If
+ End If
+
+ If Not UsuarioActual.CveRol = 1 Then
+ e.Row.FCTextBox("TbCantidadF").Enabled = False
+ End If
+ End If
+
+ 'SI ES TRASPASO OBLIGATORIO SURTIR TODO
+ If TipoEntrega = 2 Then
+ e.Row.FCCheckBox("cbInv").Enabled = False
+ End If
+
+
+ End If
+ End Sub
+
+ Private Sub CargaDocumentos(tCveVenta As Integer)
+ Dim objInv As New ClsEdocumentacion
+
+ If objInv.DocumentacionElectronicaGet(-1, -1, -1, UsuarioActual.CveEmpresa, -1, tCveVenta) Then
+ GvDocs.DataSource = objInv.DtResultados.FiltraParametros("Adjunto <> ''")
+ End If
+ objInv.Dispose()
+ GvDocs.DataBind()
End Sub
-#End Region
+#End Region
-#Region " AGREGAR "
+#Region " AGREGAR "
+
+ Protected Sub BtnSerie_Click(sender As Object, e As EventArgs)
+
+ Dim Argumentos = CType(sender, Button).CommandArgument.Split("°"c)
+
+ LbProducto.Text = Argumentos(2)
+ LbCantidad.Text = Argumentos(3)
+
+ LbProducto2.Text = Argumentos(2)
+ LbCantidad2.Text = Argumentos(3)
+
+ CvePSSerie = Argumentos(0).ToEntero
+ CveUMSerie = Argumentos(1).ToEntero
+ PSSerie = Argumentos(2).ToString
+ CveConsecSerie = Argumentos(4).ToEntero
+ CveMetodoInventario = Argumentos(5).ToEntero
+
+ If CveMetodoInventario = 5 Then
+ RegistraScript("$('#DivSerie').modal('show')")
+ CargaSerie()
+ UpSerie.Update()
+ ElseIf CveMetodoInventario = 6 Then
+ RegistraScript("$('#DivLote').modal('show')")
+ CargaLote()
+ UpLoteBatch.Update()
+ End If
- Protected Sub BtnSerie_Click(sender As Object, e As EventArgs)
-
- Dim Argumentos = CType(sender, Button).CommandArgument.Split("°"c)
-
- LbProducto.Text = Argumentos(2)
- LbCantidad.Text = Argumentos(3)
-
- LbProducto2.Text = Argumentos(2)
- LbCantidad2.Text = Argumentos(3)
-
- CvePSSerie = Argumentos(0).ToEntero
- CveUMSerie = Argumentos(1).ToEntero
- PSSerie = Argumentos(2).ToString
- CveConsecSerie = Argumentos(4).ToEntero
- CveMetodoInventario = Argumentos(5).ToEntero
-
- If CveMetodoInventario = 5 Then
- RegistraScript("$('#DivSerie').modal('show')")
- CargaSerie()
- UpSerie.Update()
- ElseIf CveMetodoInventario = 6 Then
- RegistraScript("$('#DivLote').modal('show')")
- CargaLote()
- UpLoteBatch.Update()
- End If
-
End Sub
-#Region " AGREGA POR SERIE/LOTE "
+#Region " AGREGA POR SERIE/LOTE "
- Private Sub CreaDtDetalle()
- If DtDatosDetalle Is Nothing Then
- DtDatosDetalle = New DataTable
- DtDatosDetalle.Columns.Add("CveVentaDetalle", GetType(Integer))
- DtDatosDetalle.Columns.Add("Consec", GetType(Integer))
- DtDatosDetalle.Columns.Add("ConsecId", GetType(Integer))
- DtDatosDetalle.Columns.Add("CvePS", GetType(Integer))
- DtDatosDetalle.Columns.Add("PS", GetType(String))
- DtDatosDetalle.Columns.Add("CveUM", GetType(Integer))
- DtDatosDetalle.Columns.Add("Serie", GetType(String))
- DtDatosDetalle.Columns.Add("Lote", GetType(String))
- DtDatosDetalle.Columns.Add("FechaCaducidad", GetType(Date))
- DtDatosDetalle.Columns.Add("FueTraspaso", GetType(Integer))
- End If
- End Sub
- Private Sub CargaSerie(Optional CerrarCompletado As Boolean = False)
- RegistraScript("$('#DivSerie').modal('show')", "show")
-
-
- Dim AplicaCaducidad = False
- If GlobalDTPS(UsuarioActual.CveEmpresa, ).FiltraParametros("").Rows(0) IsNot Nothing Then
- AplicaCaducidad = If(GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePSSerie).FiltraParametros("").Rows(0)("AplicaCaducidad").ToString = "True", True, False)
- End If
-
- If AplicaCaducidad Then
- GvSerie.Columns(1).Visible = True
- TdCaducidad1.Visible = True
- TdCaducidad2.Visible = True
- Else
- GvSerie.Columns(1).Visible = False
- TdCaducidad1.Visible = False
- TdCaducidad2.Visible = False
- End If
-
- GvSerie.DataSource = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", CveConsecSerie), "Consec DESC")
- GvSerie.DataBind()
-
- 'SERIE LOTE RECOMENDADO
- Dim DtSerie As New DataTable
- If TipoMovimiento = 1 Then
- Dim ObjInventarios As New ClsInventarios
- If ObjInventarios.SerieRecomendadoGet(CvePSSerie, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, CveSubProyecto:=CveSubProyecto) Then
- DtSerie = ObjInventarios.DtResultados
- End If
- ObjInventarios.Dispose()
- Else
- DtSerie = DtExistencias.FiltraParametros("Serie <> ''")
- End If
- 'SERIE LOTE RECOMENDADO - QUITA YA COMPLETADOS EN EL CLIENTE
- If DtSerie.Rows.Count > 0 Then
- 'CALCULA YA COMPLETADOS
- Dim DrsRemove As New List(Of DataRow)
- DtSerie.Columns.Add("CantidadSeleccionada", GetType(Integer))
- For Each dr As DataRow In DtSerie.Rows
- dr("CantidadSeleccionada") = DtDatosDetalle.FiltraParametros(String.Format("Consec = {0} AND Serie = '{1}'", CveConsecSerie, dr("Serie").ToString.Replace("'", "''"))).Rows.Count
- If dr("CantidadSeleccionada").ToString.ToDecimal = dr("Existencia").ToString.ToDecimal Then
- DrsRemove.Add(dr)
- End If
- Next
-
- 'ELIMINA YA COMPLETADOS EN PAGINA
- For Each dr As DataRow In DrsRemove
- DtSerie.Rows.Remove(dr)
- Next
-
- If DtSerie.Rows.Count > 0 Then
- Dim Mensaje As New StringBuilder
- Mensaje.AppendFormat("Serie Recomendado: {0}", DtSerie.Rows(0)("Serie"))
- If AplicaCaducidad Then Mensaje.AppendFormat(", Caducicdad: {0}", DtSerie.Rows(0)("FechaCaducidad").ToString.ToDate.ToShortDateString)
- LbSerieRecomendado.Text = Mensaje.ToString 'String.Format("Serie / Lote Recomendado: {0}, Caducicdad: {1}", ObjInventarios.DtResultados.Rows(0)("SerieLote"), ObjInventarios.DtResultados.Rows(0)("FechaCaducidad").ToString.ToDate.ToShortDateString)
- Else
- LbSerieRecomendado.Text = "No se encontro ningun Serie/Lote."
- End If
- Else
- LbSerieRecomendado.Text = "No se encontro ningun Serie/Lote."
- End If
-
- 'SI TIENE SALIDA POR SERIE LOTE, BLOQUEAMOS CHECK Y TXTCANTIDAD
- Dim Contador = 0
- For Each Gvr As GridViewRow In GvDatos.Rows
- If Gvr.DataKey("AplicaSerieLote") = "True" Then
- Contador = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Gvr.DataKey("Consec"))).Rows.Count
- Gvr.FCCheckBox("cbInv").Enabled = False
- Gvr.FCCheckBox("cbInv").Checked = True
- Gvr.FCTextBox("TbCantidadF").Text = Contador.ToString
- End If
- Next
- UpDatos.Update()
-
- 'VALIDA QUE SIGA AGREGANDO
- If DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", CveConsecSerie)).Rows.Count = LbCantidad.Text.ToEntero Then
- BtnAgregarPS.Enabled = False
- If CerrarCompletado Then
- RegistraScript("$('#DivSerie').modal('hide')", "hide")
- End If
- UpSerie.Update()
- Exit Sub
- Else
- BtnAgregarPS.Enabled = True
- UpSerie.Update()
- End If
-
- End Sub
-
- Protected Sub BtnAgregarPS_Click(sender As Object, e As EventArgs)
- If TxtSerie.Text.Trim.Length >= 2 AndAlso TxtSerie.Text.Trim.StartsWith("*") AndAlso TxtSerie.Text.Trim.EndsWith("*") Then
- Dim ArraySeries() As String = Nothing
- Dim Series As String = Nothing
-
- Series = TxtSerie.Text.Trim
- Series = Series.Remove(0, 1)
- Series = Series.Remove(Series.Length - 1, 1)
- ArraySeries = Series.Trim.Split(","c)
-
- For i As Integer = 0 To ArraySeries.Length - 1
- If ArraySeries(i).Trim.Length > 1 Then AgregaSerie(ArraySeries(i).Trim, 1)
- Next
- Else
- AgregaSerie(TxtSerie.Text.Trim, 1)
- End If
- End Sub
-
- Private Sub AgregaSerie(Serie As String, Tipo As Integer)
-
- If Serie.Trim = "" Then
- Alert("El campo Serie es obligatorio. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
- Exit Sub
- End If
-
- If DtDatosDetalle.FiltraParametros($"CvePS = {CvePSSerie} AND Serie = '{Serie}'").Rows.Count > 0 Then
- Alert("La Serie indicada ya esta registrada. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
- RegistraScript("playsonidito('142608__autistic-lucario__error.wav')", "Error1")
- TxtSerie.Text = ""
- Exit Sub
- End If
-
- Dim AplicaCaducidad = False
- If GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePSSerie).FiltraParametros("").Rows(0) IsNot Nothing Then
- AplicaCaducidad = If(GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePSSerie).FiltraParametros("").Rows(0)("AplicaCaducidad").ToString = "True", True, False)
- End If
-
-
- 'Valida Existencia
- If TipoMovimiento = 1 Then
- Dim ObjInventarios As New ClsInventarios
- Dim Existencia = ObjInventarios.GetExistenciasPS(CvePSSerie, CveUMSerie, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), Serie:=Serie, CveVendedor:=CveVendedor, CveSubProyecto:=CveSubProyecto, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeApartados:=If(TipoEntrega = 2, 1, -1))
- If Existencia < 1 Then
- Alert($"No hay existencia suficiente del producto ""{PSSerie}"" con la Serie definida ""{Serie}"". Por favor rectifique y vuelva a intentar", TipoMensaje.MsgAdvertencia, If(Tipo = 2, "window.setTimeout(Focus,200);", ""))
- RegistraScript("playsonidito('142608__autistic-lucario__error.wav')", "Error2")
- ObjInventarios.Dispose()
- Exit Sub
- End If
- Else
- If DtExistencias IsNot Nothing Then
- Dim Existencia = DtExistencias.SUM("Cantidad", $"CvePS = {CvePSSerie} AND CveUM = {CveUMSerie} AND Serie = '{Serie}'")
- If Existencia < 1 Then
- Alert($"No hay existencia suficiente del producto ""{PSSerie}"" con la Serie definida ""{Serie}"". Por favor rectifique y vuelva a intentar", TipoMensaje.MsgAdvertencia, If(Tipo = 2, "window.setTimeout(Focus,200);", ""))
- RegistraScript("playsonidito('142608__autistic-lucario__error.wav')", "Error3")
- Exit Sub
- End If
- End If
- End If
-
-
- Dim Row = DtDatosDetalle.NewRow
-
- Row("ConsecId") = CveConsecSerie
- Row("Consec") = DtDatosDetalle.Rows.Count + 1
- Row("PS") = PSSerie
- Row("CvePS") = CvePSSerie
- Row("CveUM") = CveUMSerie
- Row("Serie") = Serie
- Row("FechaCaducidad") = If(AplicaCaducidad, TxtFechaCaducidad.Text, MinFecha.ToShortDateString)
-
- DtDatosDetalle.Rows.Add(Row)
- RegistraScript("playsonidito('beep-07.wav')", "Sonidito")
-
- If Tipo = 1 Then
- TxtSerie.Text = ""
- TxtFechaCaducidad.Text = ""
- End If
-
- If Tipo < 3 Then
- CargaSerie(True)
- End If
-
- End Sub
-
- Protected Sub GvSerie_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvSerie.RowDeleting
-
- Dim keySerie As String = e.Keys("Serie").ToString
- Try
- For Each dr As DataRow In DtDatosDetalle.Rows
- If dr("Serie").ToString = keySerie Then
- dr.Delete()
- End If
- Next
- Catch ex As Exception
-
- End Try
-
- DtDatosDetalle.AcceptChanges()
- CargaSerie()
-
+ Private Sub CreaDtDetalle()
+ If DtDatosDetalle Is Nothing Then
+ DtDatosDetalle = New DataTable
+ DtDatosDetalle.Columns.Add("CveVentaDetalle", GetType(Integer))
+ DtDatosDetalle.Columns.Add("Consec", GetType(Integer))
+ DtDatosDetalle.Columns.Add("ConsecId", GetType(Integer))
+ DtDatosDetalle.Columns.Add("CvePS", GetType(Integer))
+ DtDatosDetalle.Columns.Add("PS", GetType(String))
+ DtDatosDetalle.Columns.Add("CveUM", GetType(Integer))
+ DtDatosDetalle.Columns.Add("Serie", GetType(String))
+ DtDatosDetalle.Columns.Add("Lote", GetType(String))
+ DtDatosDetalle.Columns.Add("FechaCaducidad", GetType(Date))
+ DtDatosDetalle.Columns.Add("FueTraspaso", GetType(Integer))
+ End If
End Sub
-#End Region
+ Private Sub CargaSerie(Optional CerrarCompletado As Boolean = False)
+ RegistraScript("$('#DivSerie').modal('show')", "show")
-#Region " AGREGA CON LOTE BATCH "
- Private Sub CreaDtDetalleLote()
- If DtDatosDetalleLote Is Nothing Then
- DtDatosDetalleLote = New DataTable
- DtDatosDetalleLote.Columns.Add("CveVentaDetalle", GetType(Integer))
- DtDatosDetalleLote.Columns.Add("Consec", GetType(Integer))
- DtDatosDetalleLote.Columns.Add("ConsecId", GetType(Integer))
- DtDatosDetalleLote.Columns.Add("Cantidad", GetType(Double))
- DtDatosDetalleLote.Columns.Add("CvePS", GetType(Integer))
- DtDatosDetalleLote.Columns.Add("PS", GetType(String))
- DtDatosDetalleLote.Columns.Add("CveUM", GetType(Integer))
- DtDatosDetalleLote.Columns.Add("Lote", GetType(String))
- DtDatosDetalleLote.Columns.Add("FechaCaducidad", GetType(String))
- DtDatosDetalleLote.Columns.Add("FueTraspaso", GetType(Integer))
- End If
- End Sub
- Private Sub CargaLote(Optional CerrarCompletado As Boolean = False)
-
- RegistraScript("$('#DivLote').modal('show')")
- GvLote.DataSource = DtDatosDetalleLote.FiltraParametros(String.Format("ConsecId = {0}", CveConsecSerie), "Consec DESC")
- GvLote.DataBind()
-
- 'VALIDA QUE SIGA AGREGANDO
- If DtDatosDetalleLote.SUM("Cantidad", String.Format("ConsecId = {0}", CveConsecSerie)) = LbCantidad2.Text.ToDecimal Then
- BtnLote.Enabled = False
- If CerrarCompletado Then
- RegistraScript("$('#DivLote').modal('hide')", "hide")
- End If
- Else
- BtnLote.Enabled = True
- End If
-
- 'LOTE RECOMENDADO
- Dim DtLotes As New DataTable
- If TipoMovimiento = 1 Then
- Dim ObjInventarios As New ClsInventarios
- If ObjInventarios.LoteRecomendadoGet(CvePSSerie, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero) Then
- DtLotes = ObjInventarios.DtResultados
- End If
- ObjInventarios.Dispose()
- Else
- DtLotes = DtExistencias.FiltraParametros("Lote <> ''")
- End If
-
- Dim DrsRemove As New List(Of DataRow)
-
- If DtLotes.Rows.Count > 0 Then
- 'CALCULA YA COMPLETADOS
- DtLotes.Columns.Add("CantidadSeleccionada", GetType(Integer))
- For Each dr As DataRow In DtLotes.Rows
- dr("CantidadSeleccionada") = DtDatosDetalleLote.SUM("Cantidad", String.Format("Consec = {0} AND Lote = '{1}'", CveConsecSerie, dr("Lote")))
- If dr("CantidadSeleccionada").ToString.ToDecimal = dr("Existencia").ToString.ToDecimal Then
- DrsRemove.Add(dr)
- End If
- Next
-
- 'ELIMINA YA COMPLETADOS EN PAGINA
- For Each dr As DataRow In DrsRemove
- DtLotes.Rows.Remove(dr)
- Next
-
- If DtLotes.Rows.Count > 0 Then
- Dim Mensaje As New StringBuilder
- Mensaje.AppendFormat("Recomendado: Existencia: {0} Lote: {1} Fecha Caducidad: {2} ", DtLotes.Rows(0)("Existencia").ToString.FormatoNumero, DtLotes.Rows(0)("Lote"), DtLotes.Rows(0)("FechaCaducidad").ToString.ToDate.ToShortDateString)
- LbLoteRecomendado.Text = Mensaje.ToString
- Else
- LbLoteRecomendado.Text = "No se encontro ningún Lote recomendado."
- End If
- Else
- LbLoteRecomendado.Text = "No se encontro ningún Lote recomendado."
- End If
-
-
- 'SI TIENE SALIDA POR LOTE, BLOQUEAMOS CHECK Y TXTCANTIDAD
- Dim Contador As Decimal = 0
- For Each Gvr As GridViewRow In GvDatos.Rows
- If Gvr.DataKey("CvePS").ToEntero = CvePSSerie Then
- Contador = DtDatosDetalleLote.SUM("Cantidad", String.Format("ConsecId = {0}", Gvr.DataKey("Consec"))).ToDecimal
- Gvr.FCCheckBox("cbInv").Enabled = False
- Gvr.FCCheckBox("cbInv").Checked = True
- Gvr.FCTextBox("TbCantidadF").Text = Contador.ToString.FormatoNumero
- End If
- Next
-
- RVCantidadLote.MaximumValue = (If((LbCantidad2.Text.ToDecimal - Contador) = 0, 0.02, LbCantidad2.Text.ToDecimal - Contador)).ToString.FormatoNumero
-
- TxtCantidadLote.Text = "1"
- TxtLote.Text = ""
- TxtBatch.Text = ""
- TxtLote.Focus()
-
- UpLoteBatch.Update()
- UpDatos.Update()
-
- End Sub
-
- Protected Sub BtnAgregarPS2_Click(sender As Object, e As EventArgs)
- AgregaLote(TxtLote.Text.Trim, TxtBatch.Text.Trim, 1)
- End Sub
- Private Sub AgregaLote(Lote As String, Batch As String, Tipo As Integer)
-
- If Lote = "" Then
- Alert("El campo Lote es obligatorio. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
- Exit Sub
- End If
-
- 'VALIDACION DE SERIES DUPLICADAS
- Dim MensajeAlert As New StringBuilder
- Dim DtDuplicado As New DataTable
- Dim DtSeriesNuevas As New DataTable
- DtSeriesNuevas.Columns.Add("Serie", GetType(String))
-
- DtDuplicado = DtDatosDetalleLote.FiltraParametros($"ConsecId = {CveConsecSerie} AND Lote = '{Lote}' AND Batch = '{Batch}'")
- If DtDuplicado IsNot Nothing AndAlso DtDuplicado.Rows.Count > 0 Then
- Alert($"
El numero de Lote ""{Lote}"" y Batch = '{Batch}' proporcionado ya se encuentra ingresado.", TipoMensaje.MsgAdvertencia)
- RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
- Exit Sub
- End If
-
- Dim Row = DtDatosDetalleLote.NewRow
- Dim CantidadLote = TxtCantidadLote.Text.ToDecimal
-
- Dim MensajeSinExistencias As New StringBuilder
- Dim ObjInventarios As New ClsInventarios
-
- 'VERIFICA EXISTENCIAS
- If TipoMovimiento = 1 Then
- Dim Existencia = ObjInventarios.GetExistenciasPS(CvePSSerie, CveUMSerie, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), CveVendedor:=CveVendedor, CveSubProyecto:=CveSubProyecto, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), Lote:=Lote, ExcluyeApartados:=If(TipoEntrega = 2, 1, -1))
- If Existencia < CantidadLote Then
- Alert($"No hay existencia suficiente del producto ""{PSSerie}"" con el lote definido ""{Lote}"" y el batch ""{Batch}"". Por favor rectifique y vuelva a intentar", TipoMensaje.MsgAdvertencia)
- RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
- ObjInventarios.Dispose()
- Exit Sub
- End If
- Else
- If DtExistencias IsNot Nothing Then
- Dim Existencia = DtExistencias.SUM("Cantidad", $"CvePS = {CvePSSerie} AND CveUM = {CveUMSerie} AND Lote = '{Lote}' AND Batch = '{Batch}'")
- If Existencia < CantidadLote Then
- Alert($"No hay existencia suficiente del producto ""{PSSerie}"" con el lote definido ""{Lote}"" y el batch ""{Batch}"". Por favor rectifique y vuelva a intentar", TipoMensaje.MsgAdvertencia)
- RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
- ObjInventarios.Dispose()
- Exit Sub
- End If
- End If
- End If
-
- Dim FechaCaducidad = ""
- If ObjInventarios.LoteRecomendadoGet(CvePSSerie, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero) AndAlso ObjInventarios.DtResultados.Rows.Count > 0 Then
- FechaCaducidad = ObjInventarios.DtResultados.Rows(0)("FechaCaducidad").ToString.ToDate.ToShortDateString
- End If
-
- Row("ConsecId") = CveConsecSerie
- Row("Consec") = DtDatosDetalle.Rows.Count + 1
- Row("Cantidad") = CantidadLote
- Row("CvePS") = CvePSSerie
- Row("PS") = PSSerie
- Row("CveUM") = CveUMSerie
- Row("Lote") = Lote
- Row("Batch") = Batch
- Row("FechaCaducidad") = FechaCaducidad
-
- DtDatosDetalleLote.Rows.Add(Row)
- ObjInventarios.Dispose()
-
- If Tipo = 1 Then
- TxtCantidadLote.Text = "1"
- TxtLote.Text = ""
- TxtBatch.Text = ""
- End If
-
- CargaLote(True)
-
- End Sub
-
- Protected Sub GvLote_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvLote.RowDeleting
-
- Dim keyLote As String = e.Keys("Lote").ToString
- Try
- For Each dr As DataRow In DtDatosDetalleLote.Rows
- If dr("Lote").ToString = keyLote Then
- dr.Delete()
- End If
- Next
- Catch ex As Exception
-
- End Try
- DtDatosDetalleLote.AcceptChanges()
- CargaLote()
+ Dim AplicaCaducidad = False
+ If GlobalDTPS(UsuarioActual.CveEmpresa, ).FiltraParametros("").Rows(0) IsNot Nothing Then
+ AplicaCaducidad = If(GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePSSerie).FiltraParametros("").Rows(0)("AplicaCaducidad").ToString = "True", True, False)
+ End If
+
+ If AplicaCaducidad Then
+ GvSerie.Columns(1).Visible = True
+ TdCaducidad1.Visible = True
+ TdCaducidad2.Visible = True
+ Else
+ GvSerie.Columns(1).Visible = False
+ TdCaducidad1.Visible = False
+ TdCaducidad2.Visible = False
+ End If
+
+ GvSerie.DataSource = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", CveConsecSerie), "Consec DESC")
+ GvSerie.DataBind()
+
+ 'SERIE LOTE RECOMENDADO
+ Dim DtSerie As New DataTable
+ If TipoMovimiento = 1 Then
+ Dim ObjInventarios As New ClsInventarios
+ If ObjInventarios.SerieRecomendadoGet(CvePSSerie, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, CveSubProyecto:=CveSubProyecto) Then
+ DtSerie = ObjInventarios.DtResultados
+ End If
+ ObjInventarios.Dispose()
+ Else
+ DtSerie = DtExistencias.FiltraParametros("Serie <> ''")
+ End If
+ 'SERIE LOTE RECOMENDADO - QUITA YA COMPLETADOS EN EL CLIENTE
+ If DtSerie.Rows.Count > 0 Then
+ 'CALCULA YA COMPLETADOS
+ Dim DrsRemove As New List(Of DataRow)
+ DtSerie.Columns.Add("CantidadSeleccionada", GetType(Integer))
+ For Each dr As DataRow In DtSerie.Rows
+ dr("CantidadSeleccionada") = DtDatosDetalle.FiltraParametros(String.Format("Consec = {0} AND Serie = '{1}'", CveConsecSerie, dr("Serie").ToString.Replace("'", "''"))).Rows.Count
+ If dr("CantidadSeleccionada").ToString.ToDecimal = dr("Existencia").ToString.ToDecimal Then
+ DrsRemove.Add(dr)
+ End If
+ Next
+
+ 'ELIMINA YA COMPLETADOS EN PAGINA
+ For Each dr As DataRow In DrsRemove
+ DtSerie.Rows.Remove(dr)
+ Next
+
+ If DtSerie.Rows.Count > 0 Then
+ Dim Mensaje As New StringBuilder
+ Mensaje.AppendFormat("Serie Recomendado: {0}", DtSerie.Rows(0)("Serie"))
+ If AplicaCaducidad Then Mensaje.AppendFormat(", Caducicdad: {0}", DtSerie.Rows(0)("FechaCaducidad").ToString.ToDate.ToShortDateString)
+ LbSerieRecomendado.Text = Mensaje.ToString 'String.Format("Serie / Lote Recomendado: {0}, Caducicdad: {1}", ObjInventarios.DtResultados.Rows(0)("SerieLote"), ObjInventarios.DtResultados.Rows(0)("FechaCaducidad").ToString.ToDate.ToShortDateString)
+ Else
+ LbSerieRecomendado.Text = "No se encontro ningun Serie/Lote."
+ End If
+ Else
+ LbSerieRecomendado.Text = "No se encontro ningun Serie/Lote."
+ End If
+
+ 'SI TIENE SALIDA POR SERIE LOTE, BLOQUEAMOS CHECK Y TXTCANTIDAD
+ Dim Contador = 0
+ For Each Gvr As GridViewRow In GvDatos.Rows
+ If Gvr.DataKey("AplicaSerieLote") = "True" Then
+ Contador = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Gvr.DataKey("Consec"))).Rows.Count
+ Gvr.FCCheckBox("cbInv").Enabled = False
+ Gvr.FCCheckBox("cbInv").Checked = True
+ Gvr.FCTextBox("TbCantidadF").Text = Contador.ToString
+ End If
+ Next
+ UpDatos.Update()
+
+ 'VALIDA QUE SIGA AGREGANDO
+ If DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", CveConsecSerie)).Rows.Count = LbCantidad.Text.ToEntero Then
+ BtnAgregarPS.Enabled = False
+ If CerrarCompletado Then
+ RegistraScript("$('#DivSerie').modal('hide')", "hide")
+ End If
+ UpSerie.Update()
+ Exit Sub
+ Else
+ BtnAgregarPS.Enabled = True
+ UpSerie.Update()
+ End If
+
End Sub
-#End Region
-#Region " AGREGA CON TXT | CODIGO - SERIE "
- Protected Sub BtnCodigoPS_Click(sender As Object, e As EventArgs)
-
- If TxtCodigoPS.Text = "" Then
- Exit Sub
- End If
-
- TdSeriePS.Visible = False
- Dim Existe = False
- Dim PSTemp = ""
-
- For Each Gvr As GridViewRow In GvDatos.Rows
- If Gvr.DataKey("CodigoBarras") = TxtCodigoPS.Text.Trim Then
- Dim TxtCantidad = GvDatos.Rows(Gvr.RowIndex).FCTextBox("TbCantidadF")
- If Gvr.DataKey("CantidadF").ToDecimal - TxtCantidad.Text.ToDecimal - 1 >= 0 Then
-
- ''VALIDA EXISTENCIA
- If Not TipoDocto.Contiene("Dev") Then
- If TipoMovimiento = 1 Then
- Dim ObjInventario As New ClsInventarios
- Dim Existencia = ObjInventario.GetExistenciasPS(Gvr.DataKey("CvePS").ToString.ToEntero, Gvr.DataKey("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), CveVendedor:=CveVendedor, CveSubProyecto:=CveSubProyecto, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeApartados:=If(TipoEntrega = 2, 1, -1))
- ObjInventario.Dispose()
- If Not Existencia >= TxtCantidad.Text.ToDecimal + 1 Then
- TxtCodigoPS.Text = ""
- Alert($"No hay existencias suficientes del producto:
""{Gvr.DataKey("Codigo")}-{Gvr.DataKey("PS")}"".
Solo hay disponibles {Existencia.FormatoNumero} en Almacen. Por favor Verifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus,200);")
- RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
- Exit Sub
- End If
- Else
- If DtExistencias IsNot Nothing Then
- Dim Existencia = DtExistencias.SUM("Cantidad", $"CvePS = {Gvr.DataKey("CvePS")} AND CveUM = {Gvr.DataKey("CveUM").ToString.ToEntero}")
- If Not Existencia >= TxtCantidad.Text.ToDecimal + 1 Then
- TxtCodigoPS.Text = ""
- Alert($"No hay existencias suficientes del producto:
""{Gvr.DataKey("Codigo")}-{Gvr.DataKey("PS")}"".
Solo hay disponibles {Existencia.FormatoNumero} en Almacen. Por favor Verifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus,200);")
- RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
- Exit Sub
- End If
- End If
- End If
- End If
-
-
- If Gvr.DataKey("AplicaSerieLote") = "True" Then
- TdSeriePS.Visible = True
- TxtSeriePS.Focus()
-
- CveConsecSerie = Gvr.DataKey("Consec").ToString.ToEntero
- PSSerie = Gvr.DataKey("PS").ToString
- CvePSSerie = Gvr.DataKey("CvePS").ToEntero
- CveUMSerie = Gvr.DataKey("CveUM").ToEntero
- Exit Sub
- End If
-
-
- Dim CantidadEspecial = Gvr.DataKey("CveClasificacion").ToString.ToEntero.Contiene(17601, 17881) OrElse Gvr.DataKey("CvePS").ToString.ToEntero.Contiene(343032, 343033)
-
- If CantidadEspecial Then
- RegistraScript("CantidadEspecial();window.setTimeout(FocusCantidadEspecial,200);")
- LtlProductoCantidad.Text = $"{Gvr.DataKey("Codigo")}"
- RowIndexCantidadEspecial = Gvr.RowIndex
- CantidadEspecialTemp = Gvr.DataKey("CantidadF").ToDecimal
- TxtCodigoPS.Text = ""
- Exit Sub
- Else
- TxtCantidad.Text = (TxtCantidad.Text.ToDecimal + 1).ToString.FormatoNumero
- TxtCodigoPS.Text = ""
- UpDatos.Update()
- Exit Sub
- End If
-
- VerificaVentaSurtida()
- Exit Sub
- End If
-
- Existe = True
- PSTemp = Gvr.DataKey("PS").ToString
- 'Alert($"Ya se ha cargado la totalidad del Producto ""{Gvr.DataKey("PS").ToString}"" con el Codigo ""{TxtCodigoPS.Text}"".", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus,200);")
- 'VerificaVentaSurtida()
- 'Exit Sub
- End If
- Next
-
- VerificaVentaSurtida()
- If Existe Then
- Alert($"Ya se ha cargado la totalidad del Producto ""{PSTemp}"" con el Codigo ""{TxtCodigoPS.Text}"".", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus,200);")
- Else
- Alert($"No se ha encontrado un producto para surtir con el Codigo ""{TxtCodigoPS.Text}"". ", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus,200);")
- End If
- RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
- TxtCodigoPS.Text = ""
-
- End Sub
- Private Sub VerificaVentaSurtida()
- Dim Surtida = True
-
- For Each Gvr As GridViewRow In GvDatos.Rows
- If Gvr.DataKey("CantidadF").ToDecimal <> Gvr.FCTextBox("TbCantidadF").Text.ToDecimal Then
- Surtida = False
- Exit Sub
- End If
- Next
-
- If Surtida Then
- LbSurtida.Visible = True
- End If
- End Sub
- Protected Sub BtnSeriePS_Click(sender As Object, e As EventArgs)
- AgregaSerie(TxtSeriePS.Text.Trim, 2)
-
- TdSeriePS.Visible = False
- TxtSeriePS.Text = ""
- TxtCodigoPS.Text = ""
- TxtCodigoPS.Focus()
- VerificaVentaSurtida()
-
- End Sub
- Protected Sub BtnGuardarCantidadEspecial_Click(sender As Object, e As EventArgs)
- AgregaCantidadEspecial()
- End Sub
- Private Sub AgregaCantidadEspecial()
- Dim TxtCantidad = GvDatos.Rows(RowIndexCantidadEspecial).FCTextBox("TbCantidadF")
- If CantidadEspecialTemp - TxtCantidadEspecialDiv.Text.ToDecimal - TxtCantidad.Text.ToDecimal >= 0 Then
- TxtCantidad.Text = (TxtCantidad.Text.ToDecimal + TxtCantidadEspecialDiv.Text.ToDecimal).ToString.FormatoNumero
- 'RegistraScript("$('#ModalCantidad').modal('hide');")
- RegistraScript("$('#DivCantidadEspecial').hide(200);")
- UpDatos.Update()
- TxtCodigoPS.Focus()
- Else
- Alert("La cantidad excede la pendiente por surtir. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus,200);")
- RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
- End If
-
- TxtCantidadEspecialDiv.Text = "1"
+ Protected Sub BtnAgregarPS_Click(sender As Object, e As EventArgs)
+ If TxtSerie.Text.Trim.Length >= 2 AndAlso TxtSerie.Text.Trim.StartsWith("*") AndAlso TxtSerie.Text.Trim.EndsWith("*") Then
+ Dim ArraySeries() As String = Nothing
+ Dim Series As String = Nothing
+
+ Series = TxtSerie.Text.Trim
+ Series = Series.Remove(0, 1)
+ Series = Series.Remove(Series.Length - 1, 1)
+ ArraySeries = Series.Trim.Split(","c)
+
+ For i As Integer = 0 To ArraySeries.Length - 1
+ If ArraySeries(i).Trim.Length > 1 Then AgregaSerie(ArraySeries(i).Trim, 1)
+ Next
+ Else
+ AgregaSerie(TxtSerie.Text.Trim, 1)
+ End If
End Sub
-#End Region
-#End Region
+ Private Sub AgregaSerie(Serie As String, Tipo As Integer)
+
+ If Serie.Trim = "" Then
+ Alert("El campo Serie es obligatorio. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
+
+ If DtDatosDetalle.FiltraParametros($"CvePS = {CvePSSerie} AND Serie = '{Serie}'").Rows.Count > 0 Then
+ Alert("La Serie indicada ya esta registrada. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
+ RegistraScript("playsonidito('142608__autistic-lucario__error.wav')", "Error1")
+ TxtSerie.Text = ""
+ Exit Sub
+ End If
+
+ Dim AplicaCaducidad = False
+ If GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePSSerie).FiltraParametros("").Rows(0) IsNot Nothing Then
+ AplicaCaducidad = If(GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePSSerie).FiltraParametros("").Rows(0)("AplicaCaducidad").ToString = "True", True, False)
+ End If
-#Region " GUARDAR "
- Protected Sub BtnGuardar_Click(sender As Object, e As EventArgs)
-
- Select Case TipoEntrega
- Case 1
- GuardaVenta()
- Case 2
- GuardaTraspaso()
- End Select
-
- End Sub
-
- Private Sub GuardaVenta()
-
-
- '' INICIA: VALIDACIONES
-
- 'Valida el estatus de la Venta, si es = 5 O DevolucionVenta = 2, NO SE SURTE!
- Dim ObjVentaInv As New ClsInventarios
- If ObjVentaInv.GetEstatusVentaPorSurtir(CveVentaSurtir) Then
- TipoEstatus = ObjVentaInv.TipoEstatus
- EsDevolucionVenta = ObjVentaInv.EsDevolucionVenta
- End If
- ObjVentaInv.Dispose()
-
- If TipoEstatus = 5 Or EsDevolucionVenta.Contiene(2, 3) Then
- Alert("No se puede surtir esta venta, verifique que no esté cancelada o ya registrado su movimiento en almacen", TipoMensaje.MsgAdvertencia)
- Exit Sub
- End If
-
- Dim ValidaSeccion As Boolean = False : Dim ValidaCaducidad As Boolean = False : Dim ValidaLote As Boolean = False
- 'VALIDA CANTIDAD DE SALIDA
- Dim Cantidad As Decimal = 0.0D
- For Each Gvr As GridViewRow In GvDatos.Rows
- If CBool(Gvr.DataKey("AplicaSeccion")) AndAlso Gvr.FCDropDownList("DdlSeccionAlmacen").SelectedValue.ToEntero <= 0 Then
- ValidaSeccion = True
- End If
- If CBool(Gvr.DataKey("AplicaCaducidad")) AndAlso Gvr.FCTextBox("TxtCaducidad").Text.Trim = "" Then
- ValidaCaducidad = True
- End If
- If CBool(Gvr.DataKey("AplicaLote")) AndAlso Gvr.FCTextBox("TxtLote").Text.Trim = "" Then
- ValidaLote = True
- End If
-
- If Gvr.FCCheckBox("cbInv").Checked AndAlso Gvr.FCTextBox("TbCantidadF").Text.ToDecimal > 0 Then
- Cantidad = Gvr.FCTextBox("TbCantidadF").Text.ToDecimal
- Exit For
- End If
-
- Next
-
- If ValidaSeccion Then
- Alert("La sección de almacen no ha sido especificada en todos los productos.", TipoMensaje.MsgAdvertencia)
- Exit Sub
- End If
- If ValidaCaducidad Then
- Alert("La caducidad no ha sido especificada en todos los productos.", TipoMensaje.MsgAdvertencia)
- Exit Sub
- End If
- If ValidaLote Then
- Alert("El lote de almacen no ha sido especificada en todos los productos.", TipoMensaje.MsgAdvertencia)
- Exit Sub
- End If
-
-
- If Not Cantidad > 0 Then
- Alert("No se detecto ningun movimiento por hacer. Por favor verifique e intente nuevamente.", TipoMensaje.MsgAdvertencia)
- Exit Sub
- End If
-
- 'PROCESO , si tiene proceso "176" no lo valida
- If Not UsuarioActual.TienePermisoProceso(176) Then
- For Each Gvr As GridViewRow In GvDatos.Rows
- If Gvr.DataKey("CantidadF").ToDecimal <> Gvr.FCTextBox("TbCantidadF").Text.ToDecimal Then
- Alert("En la factura no se han especificado todos los productos a entregar, favor de especificarlos para poder dar salida.", TipoMensaje.MsgAdvertencia)
- Exit Sub
- End If
- Next
- End If
-
- If EsDevolucionVenta = 1 Or TipoDocto.Contiene({"Ped"}) Then
- For Each Gvr As GridViewRow In GvDatos.Rows
- If Not Gvr.FCCheckBox("cbInv").Checked Or (Gvr.FCCheckBox("cbInv").Checked AndAlso Gvr.FCTextBox("TbCantidadF").Text.ToDecimal <> Gvr.DataKey("CantidadC").ToString.ToDecimal) Then
- Alert("Es necesario surtir todos los productos. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
- RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
- Exit Sub
- End If
- Next
- End If
-
-
- Dim EsInterno As Integer = -1
- If TipoDocto = "Ped" Then
- EsInterno = If(Me.EsInterno, 1, 0)
- End If
-
- Dim ObjInventario As New ClsInventarios
- Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL())
- Dim ObjVentas As New ClsVentas(ObjInventario.IniciaTransacSQL())
- Dim ObjEventos As New ClsOIEventos(ObjInventario.IniciaTransacSQL())
- Dim ObjAcumuladores As New ClsAcumuladores(ObjInventario.IniciaTransacSQL())
- Dim ObjGeneral As New ClsGenerales(ObjInventario.IniciaTransacSQL())
- Dim CveMovimiento As Integer
- Dim Folio As Integer
- Dim ErrorMovInv As Boolean
- Dim DtDetalle As New DataTable
- Dim DtDetalleLote As New DataTable
- Dim TextoError As New StringBuilder
-
- Dim CveMovimientoGarantia As Integer = -1
- Dim FolioGarantia As Integer = -1
-
- Dim CveMovimientoVirtual As Integer = -1
- Dim FolioVirtual As Integer = -1
-
- 'PASA DATOS DEL GV A DATATABLE PARA MANEJOR CON FOR EACH
- Dim Index = 0
- For Each gvr As GridViewRow In GvDatos.Rows
- If gvr.FCCheckBox("cbInv").Checked AndAlso gvr.FCTextBox("TbCantidadF").Text.ToDecimal > 0 Then
- DtDatos.Rows(Index)("CantidadGV") = gvr.FCTextBox("TbCantidadF").Text.ToDecimal
- DtDatos.Rows(Index)("CveSeccion") = gvr.FCDropDownList("DdlSeccionAlmacen").SelectedValue.ToEntero
- DtDatos.Rows(Index)("FechaCaducidad") = gvr.FCTextBox("TxtCaducidad").Text.ToDate
- DtDatos.Rows(Index)("Lote") = gvr.FCTextBox("TxtLote").Text
- End If
- Index += 1
- Next
-
- 'VALIDA SI HUBO CAMBIOS EN LA EXISTENCIA
- Dim DtDatosVenta As New DataTable
- If ObjInventario.EntregaAlmacenGet(CveVentaSurtir) Then
- DtDatosVenta = ObjInventario.DtResultados
- End If
- Dim CantidadGV = GvDatos.Rows.Cast(Of GridViewRow)().Sum(Function(gvr) gvr.DataKey("CantidadF").ToDecimal)
- If CantidadGV <> DtDatosVenta.SUM("CantidadF").ToDecimal Then
- ObjInventario.RollBack()
- ObjInventario.Dispose()
- ObjConta.Dispose()
- ObjVentas.Dispose()
- ObjEventos.Dispose()
- CargaVentaPorSurtir(CveVentaSurtir)
- CargaPendientes()
- Alert("Ha sido cambiada la informacion de existencias de la venta actual, se han recargado la información.", TipoMensaje.MsgAdvertencia)
- Exit Sub
- End If
-
- If Not ObjVentas.UpdateVentasDevolucionAlmacen(3, CveVentaSurtir) Then
- ObjInventario.RollBack()
- ObjInventario.Dispose()
- ObjConta.Dispose()
- ObjVentas.Dispose()
- ObjEventos.Dispose()
- Exit Sub
- End If
-
- Dim DtTraspasos As New DataTable
- DtTraspasos.Columns.Add("CveAlmacen", GetType(Integer))
- DtTraspasos.Columns.Add("Almacen", GetType(String))
- DtTraspasos.Columns.Add("CveMovimientoSalida", GetType(Integer))
- DtTraspasos.Columns.Add("FolioSalida", GetType(Integer))
- DtTraspasos.Columns.Add("CveMovimientoEntrada", GetType(Integer))
- DtTraspasos.Columns.Add("FolioEntrada", GetType(Integer))
-
- Dim CveMovimientoSalida = -1, FolioSalida = -1, CveMovimientoEntrada = -1, CveMovimientoEntradaApartado = -1, FolioEntrada = -1, CveMovimientoSalidaDevRem = -1, FolioMovimientoSalidaDevRem = -1, CveMovimientoEntradaDevRem = -1, FolioMovimientoEntradaDevRem = -1
-
- Try
- 'VALIDA EXISTENCIA 2
- If TipoMovimiento = 1 Then
- Dim StrXML As New StringBuilder
- StrXML.Append("")
- Dim FechaCaducidad As Date
- Dim Lote As String = ""
-
- For Each Dr As DataRow In DtDatos.Rows
- FechaCaducidad = If(CBool(Dr("AplicaCaducidad")) AndAlso Dr("FechaCaducidad").ToString <> "", Dr("FechaCaducidad").ToString.ToDate, MinFecha)
- Lote = If(CBool(Dr("AplicaLote")), Dr("Lote").ToString, "-1")
-
- If Dr("CantidadGV").ToString.ToDecimal > 0 Then
- If CBool(Dr("AplicaSerie")) Then
- DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Dr("Consec")))
- For Each Dr1 As DataRow In DtDetalle.Rows
- StrXML.AppendFormat("", Dr1("CvePS"), Dr1("CveUM"), 1, IfNull(Dr("CveSeccion"), -1), Dr1("Serie"), Lote, FechaCaducidad.ToString("yyyy/MM/dd"))
- Next
- Else
- StrXML.AppendFormat("", Dr("CvePS"), Dr("CveUM"), Dr("CantidadGV"), IfNull(Dr("CveSeccion"), -1), "-1", Lote, FechaCaducidad.ToString("yyyy/MM/dd"))
- End If
- End If
- Next
- StrXML.Append("")
-
- Dim TieneErrorExistencia = False
- If ObjInventario.GetExistenciasPSXML(StrXML.ToString(), DdlAlmacen.SelectedValue.ToEntero, TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), CveSubProyecto, CveVendedor, If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), If(TipoEntrega = 2, 1, -1), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
- If ObjInventario.DtResultados.Rows.Count > 0 Then
- TieneErrorExistencia = True
- For Each Dr As DataRow In ObjInventario.DtResultados.Rows
- TextoError.AppendFormat(" - {0} Existencia: {1:#,##0.##}
", Dr("CodigoPS"), Dr("Existencia"))
- Next
- End If
- Else
- TieneErrorExistencia = True
- End If
-
- If TieneErrorExistencia Then
- ObjInventario.RollBack()
- ObjInventario.Dispose()
- ObjConta.Dispose()
- ObjVentas.Dispose()
- ObjEventos.Dispose()
- If TextoError.Length > 0 Then
- Alert($" Lo(s) siguiente(s) Productos no tienen existencia suficiente:
{TextoError}", TipoMensaje.MsgAdvertencia)
- End If
- RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
- Exit Sub
- End If
-
- End If
-
- '' TERMINA: VALIDACIONES
-
-
- '' COMIENZA: APARTADOS
- Dim CantidadPendiente As Decimal = 0
- Dim CantidadSaldo As Decimal = 0
-
-
- If CveVendedor > 0 AndAlso (UsuarioActual.Empresa.Funcionalidad(146) = "1" Or CveCliente > 0) Then 'no debe considerar cuando es pedido de contrato
- If TipoMovimiento = 1 Then ' SI ES DEVOLUCION NO APLICA APARTADO
- ' SALIDA POR TRASPASO DE LOS ALMACENES DE APARTADO
- For Each Dr As DataRow In DtDatos.Rows
- If Dr("CantidadGV").ToString.ToDecimal > 0 Then
-
- If CBool(Dr("AplicaSerie")) Then
-
- DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Dr("Consec")))
- For Each Dr1 As DataRow In DtDetalle.Rows
- If ObjInventario.GetExistenciasProducto(Dr1("CvePS").ToString.ToEntero, Dr1("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, -1, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), Serie:=Dr1("Serie").ToString, CveTipoAlmacen:=9, CveVendedor:=CveVendedor, CveSubProyecto:=CveSubProyecto, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeApartados:=-1, Caducidad:=If(CBool(Dr("AplicaCaducidad")), Dr("FechaCaducidad").ToString.ToDate, MinFecha), Lote:=If(CBool(Dr("AplicaLote")), Dr("Lote").ToString, "-1"), CveSeccionAlmacen:=If(CBool(Dr("AplicaSeccion")), Dr("CveSeccion").ToString.ToEntero, -1)) Then
- For Each Dr2 As DataRow In ObjInventario.DtResultados.FiltraParametros("CveAlmacen > 0 AND ExistenciaFinal > 0").Rows
-
- 'BUSCA SI EXISTE YA UN TRASPASO DEL ALMACEN DE APARTADO
- CveMovimientoSalida = DtTraspasos.FiltroPrimeroValor("CveMovimientoSalida", $"CveAlmacen = {Dr2("CveAlmacen")}").ToEntero
-
- If Not CveMovimientoSalida > 0 Then
- CveMovimientoSalida = ObjInventario.AddMovimiento(Dr2("CveAlmacen").ToString.ToEntero, 8, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1,
- Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveVendedor:=CveVendedor, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente),
- CveAlmacenDestino:=DdlAlmacen.SelectedValue.ToEntero, Modulo:="RE/G1")
- FolioSalida = ObjInventario.Folio
-
- If Not CveMovimientoSalida > 0 Then
- ErrorMovInv = True
- TextoError.AppendFormat("Ocurrió un error al procesar los movimientos de traspaso de apartado. Por favor vuelva a intentar.")
- Exit For
- End If
-
- Dim DrMovto = DtTraspasos.NewRow
- DrMovto("Almacen") = Dr2("Almacen").ToString.ToEntero
- DrMovto("CveAlmacen") = Dr2("CveAlmacen").ToString.ToEntero
- DrMovto("CveMovimientoSalida") = CveMovimientoSalida
- DrMovto("FolioSalida") = FolioSalida
- DtTraspasos.Rows.Add(DrMovto)
- End If
-
-
- CantidadPendiente = 1
-
- If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, CantidadPendiente.ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0, Serie:=Dr1("Serie").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, FechaCaducidad:=If(CBool(Dr("AplicaCaducidad")), Dr("FechaCaducidad").ToString.ToDate, MinFecha), Lote:=If(CBool(Dr("AplicaLote")), Dr("Lote").ToString, "-1"), CveSeccionAlmacen:=If(CBool(Dr("AplicaSeccion")), Dr("CveSeccion").ToString.ToEntero, -1)) Then
- ErrorMovInv = True
- TextoError.AppendFormat("Ocurrió un Error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar.")
- Exit For
- End If
-
- DtDatosDetalle.Select($"Consec = {Dr1("Consec")}")(0)("FueTraspaso") = 1
- DtDatosDetalle.Select($"Consec = {Dr1("Consec")}")(0)("CveVentaDetalle") = Dr("CveVentaDetalle")
- Dr("CantidadTraspaso") = Dr("CantidadTraspaso").ToString.ToDecimal + CantidadPendiente
- Exit For
- Next
- End If
- If ErrorMovInv Then Exit For
- Next
-
- ElseIf CBool(Dr("AplicaLote")) Then
-
- DtDetalle = DtDatosDetalleLote.FiltraParametros(String.Format("ConsecId = {0}", Dr("Consec")))
- For Each Dr1 As DataRow In DtDetalle.Rows
- If ObjInventario.GetExistenciasProducto(Dr1("CvePS").ToString.ToEntero, Dr1("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, -1, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), Lote:=Dr1("Lote").ToString, CveTipoAlmacen:=9, CveVendedor:=CveVendedor, CveSubProyecto:=CveSubProyecto, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeApartados:=-1, Caducidad:=If(CBool(Dr("AplicaCaducidad")), Dr("FechaCaducidad").ToString.ToDate, MinFecha), CveSeccionAlmacen:=If(CBool(Dr("AplicaSeccion")), Dr("CveSeccion").ToString.ToEntero, -1)) Then
-
- CantidadSaldo = Dr("CantidadGV").ToString.ToDecimal
-
- For Each Dr2 As DataRow In ObjInventario.DtResultados.FiltraParametros("CveAlmacen > 0 AND ExistenciaFinal > 0").Rows
-
- 'BUSCA SI EXISTE YA UN TRASPASO DEL ALMACEN DE APARTADO
- CveMovimientoSalida = DtTraspasos.FiltroPrimeroValor("CveMovimientoSalida", $"CveAlmacen = {Dr2("CveAlmacen")}").ToEntero
-
- If Not CveMovimientoSalida > 0 Then
- CveMovimientoSalida = ObjInventario.AddMovimiento(Dr2("CveAlmacen").ToString.ToEntero, 8, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim,
- Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveVendedor:=CveVendedor, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente),
- CveAlmacenDestino:=DdlAlmacen.SelectedValue.ToEntero, Modulo:="RE/G2")
- FolioSalida = ObjInventario.Folio
-
- If Not CveMovimientoSalida > 0 Then
- ErrorMovInv = True
- TextoError.AppendFormat("Ocurrió un error al procesar los movimientos de traspaso de apartado. Por favor vuelva a intentar.")
- Exit For
- End If
-
- Dim DrMovto = DtTraspasos.NewRow
- DrMovto("Almacen") = Dr2("Almacen").ToString.ToEntero
- DrMovto("CveAlmacen") = Dr2("CveAlmacen").ToString.ToEntero
- DrMovto("CveMovimientoSalida") = CveMovimientoSalida
- DrMovto("FolioSalida") = FolioSalida
- DtTraspasos.Rows.Add(DrMovto)
- End If
-
- CantidadPendiente = If(Dr1("Cantidad").ToString.ToDecimal > CantidadSaldo, CantidadSaldo, Dr1("Cantidad").ToString.ToDecimal)
-
- If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, CantidadPendiente.ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0, Lote:=Dr1("Lote").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, FechaCaducidad:=If(CBool(Dr("AplicaCaducidad")), Dr("FechaCaducidad").ToString.ToDate, MinFecha), CveSeccionAlmacen:=If(CBool(Dr("AplicaSeccion")), Dr("CveSeccion").ToString.ToEntero, -1)) Then
- ErrorMovInv = True
- TextoError.AppendFormat("Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar.")
- Exit For
- End If
-
- DtDatosDetalle.Select($"Consec = {Dr1("Consec")}")(0)("FueTraspaso") = 1
- DtDatosDetalle.Select($"Consec = {Dr1("Consec")}")(0)("CveVentaDetalle") = Dr("CveVentaDetalle")
-
- CantidadSaldo -= CantidadPendiente
- Dr("CantidadTraspaso") = Dr("CantidadTraspaso").ToString.ToDecimal + CantidadPendiente
- If CantidadSaldo <= 0 Then Exit For
- Next
- End If
- Next
-
- Else
-
- If ObjInventario.GetExistenciasProducto(Dr("CvePS").ToString.ToEntero, Dr("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, -1, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), CveTipoAlmacen:=9, CveVendedor:=CveVendedor, CveSubProyecto:=CveSubProyecto, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeApartados:=-1, Caducidad:=If(CBool(Dr("AplicaCaducidad")), Dr("FechaCaducidad").ToString.ToDate, MinFecha), Lote:=If(CBool(Dr("AplicaLote")), Dr("Lote").ToString, "-1"), CveSeccionAlmacen:=If(CBool(Dr("AplicaSeccion")), Dr("CveSeccion").ToString.ToEntero, -1)) Then
-
- CantidadSaldo = Dr("CantidadGV").ToString.ToDecimal
-
- For Each Dr1 As DataRow In ObjInventario.DtResultados.FiltraParametros("CveAlmacen > 0 AND ExistenciaFinal > 0").Rows
-
- 'BUSCA SI EXISTE YA UN TRASPASO DEL ALMACEN DE APARTADO
- CveMovimientoSalida = DtTraspasos.FiltroPrimeroValor("CveMovimientoSalida", $"CveAlmacen = {Dr1("CveAlmacen")}").ToEntero
-
- If Not CveMovimientoSalida > 0 Then
- CveMovimientoSalida = ObjInventario.AddMovimiento(Dr1("CveAlmacen").ToString.ToEntero, 8, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1,
- Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveVendedor:=CveVendedor,
- CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), CveAlmacenDestino:=DdlAlmacen.SelectedValue.ToEntero, Modulo:="RE/G3")
- FolioSalida = ObjInventario.Folio
-
- If Not CveMovimientoSalida > 0 Then
- ErrorMovInv = True
- TextoError.AppendFormat("Ocurrió un error al procesar los movimientos de traspaso de apartado. Por favor vuelva a intentar.")
- Exit For
- End If
-
- Dim DrMovto = DtTraspasos.NewRow
- DrMovto("Almacen") = Dr1("Almacen").ToString.ToEntero
- DrMovto("CveAlmacen") = Dr1("CveAlmacen").ToString.ToEntero
- DrMovto("CveMovimientoSalida") = CveMovimientoSalida
- DrMovto("FolioSalida") = FolioSalida
- DtTraspasos.Rows.Add(DrMovto)
- End If
-
-
- CantidadPendiente = If(Dr1("ExistenciaFinal").ToString.ToDecimal > CantidadSaldo, CantidadSaldo, Dr1("ExistenciaFinal").ToString.ToDecimal)
-
- If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, CantidadPendiente.ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0,
- Serie:=Dr("Serie").ToString,
- CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero,
- FechaCaducidad:=If(CBool(Dr("AplicaCaducidad")), Dr("FechaCaducidad").ToString.ToDate, MinFecha),
- Lote:=If(CBool(Dr("AplicaLote")), Dr("Lote").ToString, "-1"),
- CveSeccionAlmacen:=If(CBool(Dr("AplicaSeccion")), Dr("CveSeccion").ToString.ToEntero, -1)) Then
- ErrorMovInv = True
- TextoError.AppendFormat("Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar.")
- Exit For
- End If
-
- CantidadSaldo -= CantidadPendiente
- Dr("CantidadTraspaso") = Dr("CantidadTraspaso").ToString.ToDecimal + CantidadPendiente
- If CantidadSaldo <= 0 Then Exit For
- Next
-
- If ErrorMovInv Then Exit For
- Else
- ErrorMovInv = True
- End If
-
- End If
- If ErrorMovInv Then Exit For
-
- End If
-
- Next
-
- 'ENTRADA POR TRASPASO AL ALMACEN GENERAL
- If Not ErrorMovInv Then
- For Each Dr1 As DataRow In DtTraspasos.Rows
- CveMovimientoSalida = Dr1("CveMovimientoSalida").ToString.ToEntero
-
- CveMovimientoEntradaApartado = ObjInventario.AddMovimiento(DdlAlmacen.SelectedValue.ToEntero, 9, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1,
- Observaciones:=TxtObservaciones.Text.Trim, CveAlmacenDestino:=DdlAlmacen.SelectedValue.ToEntero, CveMovimientoRelacionado:=CveMovimientoSalida,
- Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveVendedor:=CveVendedor, CveCliente:=CveCliente, Modulo:="RE/G4")
- FolioEntrada = ObjInventario.Folio
-
- If Not CveMovimientoEntradaApartado > 0 Then
- ErrorMovInv = True
- TextoError.AppendFormat("Ocurrió un error al procesar los movimientos de traspaso de apartado. Por favor vuelva a intentar.")
- Exit For
- End If
-
- Dr1("CveMovimientoEntrada") = CveMovimientoEntradaApartado
- Dr1("FolioEntrada") = FolioEntrada
-
- If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then
- For Each Dr As DataRow In ObjInventario.DtResultados.Rows
- If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntradaApartado, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, CveAF:=Dr("CveAF").ToString.ToEntero, Serie:=Dr("Serie").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, FechaCaducidad:=If(CBool(Dr("AplicaCaducidad")), Dr("FechaCaducidad").ToString.ToDate, MinFecha), Lote:=If(CBool(Dr("AplicaLote")), Dr("Lote").ToString, "-1"), CveSeccionAlmacen:=If(CBool(Dr("AplicaSeccion")), Dr("CveSeccion").ToString.ToEntero, -1)) Then
- ErrorMovInv = True
- TextoError.AppendFormat("Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar.")
- Exit For
- End If
- Next
- End If
-
- If ErrorMovInv Then Exit For
-
- Next
- End If
- End If
- End If
- '' TERMINA: APARTADOS
-
- ' COMIENZA: GARANTIAS
- If TipoDocto.Contiene("Ing", "Rem") AndAlso UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso TipoMovimiento = 1 Then
-
- Dim CveAlmacenGarantia As Integer = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 6).FiltroPrimeroValor("CveAlmacen", $"CveSubProyecto={CveSubProyecto}").ToEntero()
- Dim DtGarantias As DataTable = Nothing
-
- If ObjAcumuladores.GetGarantiasDetalle(CveVentaSurtir) Then
- DtGarantias = ObjAcumuladores.DtResultados.Copy()
- End If
-
- If DtGarantias IsNot Nothing AndAlso DtGarantias.Rows.Count > 0 AndAlso CveAlmacenGarantia > 0 Then
- CveMovimientoGarantia = ObjInventario.AddMovimiento(CveAlmacenGarantia, 2, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, Modulo:="RE/G5")
- FolioGarantia = ObjInventario.Folio
-
- For Each RowGarantia As DataRow In DtGarantias.Rows
- Dim CvePS = RowGarantia("CvePS").ToString().ToEntero()
- Dim CveTamaño As Integer = RowGarantia("CveTamaño").ToString().ToEntero()
- Dim CveUM As Integer = RowGarantia("CveUnidadMedida").ToString().ToEntero()
- Dim PU As Decimal = RowGarantia("Importe").ToString().ToDecimal() ' / RowGarantia("Cantidad").ToString().ToDouble()
-
- If Not ObjInventario.AddMovimientoDetalle(CveMovimientoGarantia, RowGarantia("Cantidad").ToString().ToDouble(), CveUM, CvePS, PU) Then
- ErrorMovInv = True
- TextoError.AppendFormat("Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar.")
- Exit For
- End If
- Next
- End If
- End If
- ' TERMINA: GARANTIAS
-
-
-
- If Not ErrorMovInv Then
- Dim ConceptoMovimiento = 3
- ConceptoMovimiento = If(TipoMovimiento = 1, ConceptoMovimiento, 18)
- ConceptoMovimiento = If(CveAlmacenTraspasoDestino > 0, 8, ConceptoMovimiento)
-
- Dim Almacen1 = DdlAlmacen.SelectedValue.ToEntero
-
- If TipoDocto = "Rem" AndAlso CveAlmacenTraspasoDestino = 0 Then
- ErrorMovInv = True
- TextoError.AppendFormat("Ocurrió un error. no se tiene definido el almacen destino")
- End If
-
- 'DEVOLUCION REMISION
- If TipoMovimiento = 2 And TipoDocto = "Rem" Then
- ConceptoMovimiento = 8
- Almacen1 = CveAlmacenTraspasoDestino
- CveAlmacenTraspasoDestino = DdlAlmacen.SelectedValue.ToEntero
- End If
-
- 'CANCELACION DE DEVOLUCION
- If TipoMovimiento = 2 And TipoDocto = "Dev" And EsDevolucionVenta = 1 Then
- ConceptoMovimiento = 3
- Almacen1 = DdlAlmacen.SelectedValue.ToEntero
- CveAlmacenTraspasoDestino = DdlAlmacen.SelectedValue.ToEntero
- End If
-
- 'DEVOLUCION DIRECTA A ENTREGA POR ADELANTADO
- If TipoMovimiento = 2 And ConceptoMovimiento = 18 AndAlso EsDevolucionDirecta Then
- ConceptoMovimiento = 41
- End If
-
- CveMovimiento = ObjInventario.AddMovimiento(Almacen1, ConceptoMovimiento, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text,
- CveContrato:=CveContrato, CveAlmacenDestino:=CveAlmacenTraspasoDestino, Modulo:="RE/G7")
- Folio = ObjInventario.Folio
-
- 'SALIDA DE ALMACEN - SALIDA POR TRASPASO CUANDO ES REMISION - DEVOLUCION (SI ES TRASPASO Y TIENE CONTRATO NO HACE DEVOLUCIóN)
- 'If Not (CveContrato > 0 And CveAlmacenTraspasoDestino > 0) Then
- If CveMovimiento > 0 Then
-
- 'SACA LO DE TRASPASOS - APARTADO
- For Each Dr1 As DataRow In DtTraspasos.Rows
- CveMovimientoSalida = Dr1("CveMovimientoEntrada").ToString.ToEntero
- If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then
- If ObjInventario.DtResultados.Rows.Count = 0 Then
- ErrorMovInv = True
- TextoError.AppendFormat("Ocurrió un error, no se tienen registros que ingresar")
- Exit Sub
- End If
-
- For Each Dr As DataRow In ObjInventario.DtResultados.Rows
- If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, CveAF:=Dr("CveAF").ToString.ToEntero, Serie:=Dr("Serie").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, FechaCaducidad:=If(CBool(Dr("AplicaCaducidad")), Dr("FechaCaducidad").ToString.ToDate, MinFecha), Lote:=If(CBool(Dr("AplicaLote")), Dr("Lote").ToString, "-1"), CveSeccionAlmacen:=If(CBool(Dr("AplicaSeccion")), Dr("CveSeccion").ToString.ToEntero, -1), EsInterno:=EsInterno) Then
- ErrorMovInv = True
- TextoError.AppendFormat("Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar.")
- Exit For
- End If
- Next
- Else
- ErrorMovInv = True
- TextoError.AppendFormat("Ocurrió un error al obtener los registros")
- End If
- If ErrorMovInv Then Exit For
- Next
-
- 'ES EL MOVIMIENTO PRINCIPAL
- CantidadPendiente = 0
- Dim Cont As Integer = 0
- For Each Dr As DataRow In DtDatos.Rows
- CantidadPendiente = Dr("CantidadGV").ToString.ToDecimal - Dr("CantidadTraspaso").ToString.ToDecimal
- If CantidadPendiente > 0 Then
- Dim PU As Decimal = 0
-
- 'SI FUE POR SERIE
- DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0} AND FueTraspaso IS NULL", Dr("Consec")))
- DtDetalleLote = DtDatosDetalleLote.FiltraParametros(String.Format("ConsecId = {0} AND FueTraspaso IS NULL", Dr("Consec")))
- If DtDetalle.Rows.Count > 0 Then
- For Each Dr1 As DataRow In DtDetalle.Rows
- If TipoMovimiento = 2 AndAlso DtExistencias IsNot Nothing Then
- PU = DtExistencias.FiltroPrimeroValor("PU", $"CvePS = {Dr("CvePS")} AND CveUM = {Dr("CveUM").ToString.ToEntero} AND Serie = '{Dr1("Serie").ToString}'").ToString.ToDecimal
- End If
-
- If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, 1, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, PU, Serie:=Dr1("Serie").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, FechaCaducidad:=If(CBool(Dr("AplicaCaducidad")), Dr("FechaCaducidad").ToString.ToDate, MinFecha), Lote:=If(CBool(Dr("AplicaLote")), Dr("Lote").ToString, "-1"), CveSeccionAlmacen:=If(CBool(Dr("AplicaSeccion")), Dr("CveSeccion").ToString.ToEntero, -1)) Then
- ErrorMovInv = True
- TextoError.AppendFormat("Ocurrió un error al procesar los conceptos con serie. Por favor vuelva a intentar.")
- Exit For
- End If
- Next
- ElseIf DtDetalleLote.Rows.Count > 0 Then
- For Each Dr1 As DataRow In DtDetalleLote.Rows
- If TipoMovimiento = 2 AndAlso DtExistencias IsNot Nothing Then
- PU = DtExistencias.FiltroPrimeroValor("PU", $"CvePS = {Dr("CvePS")} AND CveUM = {Dr("CveUM").ToString.ToEntero} AND Serie = '{Dr1("Serie").ToString}'").ToString.ToDecimal
- End If
-
- If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr1("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, PU, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, FechaCaducidad:=If(CBool(Dr("AplicaCaducidad")), Dr("FechaCaducidad").ToString.ToDate, MinFecha), Lote:=If(CBool(Dr("AplicaLote")), Dr("Lote").ToString, "-1"), CveSeccionAlmacen:=If(CBool(Dr("AplicaSeccion")), Dr("CveSeccion").ToString.ToEntero, -1)) Then
- ErrorMovInv = True
- TextoError.AppendFormat("Ocurrió un error al procesar los conceptos con serie. Por favor vuelva a intentar.")
- Exit For
- End If
- Next
- Else
- If TipoMovimiento = 2 AndAlso DtExistencias IsNot Nothing Then
- PU = DtExistencias.FiltroPrimeroValor("PU", $"CvePS = {Dr("CvePS")} AND CveUM = {Dr("CveUM").ToString.ToEntero}").ToString.ToDecimal
- End If
-
- If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, CantidadPendiente, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, PU, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, FechaCaducidad:=If(CBool(Dr("AplicaCaducidad")), Dr("FechaCaducidad").ToString.ToDate, MinFecha), Lote:=If(CBool(Dr("AplicaLote")), Dr("Lote").ToString, "-1"), CveSeccionAlmacen:=If(CBool(Dr("AplicaSeccion")), Dr("CveSeccion").ToString.ToEntero, -1)) Then
- ErrorMovInv = True
- TextoError.AppendFormat("Ocurrió un error al procesar los conceptos de salida. Por favor vuelva a intentar.")
- Exit For
- End If
- End If
- 'If ObjInventario.CveMovimientoDetalle > 0 AndAlso DtSeccionAlmacen.Rows.Count > 0 Then
- ' For Each Dr2 As DataRow In DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {Cont}").Rows
- ' If Not ObjInventario.AddMovimientosDetalleSeccionesAlmacen(ObjInventario.CveMovimientoDetalle, Dr2("CveSeccionAlmacen").ToString.ToEntero, -Dr2("CantidadSeccionAlmacen").ToString.ToDecimal) Then
- ' ErrorMovInv = True
- ' TextoError = "Ocurrió un error al procesar las secciones de almacen. Por favor vuelva a intentar."
- ' Exit For
- ' End If
- ' Next
- 'End If
- Cont += 1
- End If
- Next
- Else
- ErrorMovInv = True
- End If
- End If
- 'End If
-
-
- 'ENTRADA POR TRASPASO CUANDO ES REMISION
- If Not ErrorMovInv Then
- If CveAlmacenTraspasoDestino > 0 AndAlso Not (TipoMovimiento = 2 And TipoDocto = "Dev" And EsDevolucionVenta = 1) Then ' TRASPASO CUANDO ES REMISION
- CveMovimientoEntrada = ObjInventario.AddMovimiento(CveAlmacenTraspasoDestino, 9, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, CveContrato:=CveContrato,
- CveMovimientoRelacionado:=CveMovimiento, CveAlmacenDestino:=DdlAlmacen.SelectedValue.ToEntero, Modulo:="RE/G8")
- FolioEntrada = ObjInventario.Folio
-
- If CveMovimientoEntrada <= 0 Then
- TextoError.AppendFormat("No se pudo generar el movimiento de entrada correctamente")
- ErrorMovInv = True
- Else
- If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then
- For Each Dr As DataRow In ObjInventario.DtResultados.Rows
- If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, CveAF:=Dr("CveAF").ToString.ToEntero, CveSeccionAlmacen:=Dr("CveSeccionAlmacen").ToString.ToEntero, Serie:=Dr("Serie").ToString, Lote:=Dr("Lote").ToString, FechaCaducidad:=Dr("FechaCaducidad").ToString.ToDate, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, EsInterno:=EsInterno, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero()) Then
- ErrorMovInv = True
- TextoError.AppendFormat("Ocurrió un error al guardar los movimientos de entrada")
- Exit For
- End If
- Next
- Else
- ErrorMovInv = True
- TextoError.AppendFormat("Ocurrió un error al guardar los movimientos de entrada")
- End If
- End If
-
- Else 'REGISTRO LA PREPOLIZA DE COSTO VS ALMACEN - SALIDA ALMACEN
- Dim DtCostos As DataTable = Nothing
- Dim ValorInventario As Decimal = 0
- If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then
- DtCostos = ObjInventario.DtResultados
-
- Dim tmpCostos As DataTable = DtCostos.FiltraParametros("", "", {"CveClasificacion"})
- Dim IdCtaContableAlmacen As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", $"CveAlmacen = {DdlAlmacen.SelectedValue}").ToEntero
- Dim CveCuentaAlmacen As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContableSIG", $"CveAlmacen = {DdlAlmacen.SelectedValue}").ToEntero
- Dim IdCtaContable As Integer = 0
- Dim CveCuenta As Integer = 0
- If tmpCostos.Rows.Count > 0 Then
-
-
- If ObjVentas.GetVenta(CveVentaSurtir, UsuarioActual.CveEmpresa) Then
- Dim Fecha As Date = TxtFecha.Text.ToDate ' If(TipoMovimiento <> 1, TxtFecha.Text.ToDate, ObjVentas.DtResultados(0)("Fecha").ToString.ToDate)
- Dim CveCliente As Integer = ObjVentas.DtResultados(0)("CveCliente").ToString.ToEntero
- Dim ClienteNombre As String = ObjVentas.DtResultados(0)("ClienteNombre").ToString
- Dim Serie As String = ObjVentas.DtResultados(0)("Serie").ToString
- Dim TotalCosto As Decimal = DtCostos.SUMD("Total").RoundSQL()
- Dim TotalCostoAcumulado As Decimal = 0
- Dim cont As Integer = 1
-
- Dim ValorMultiplicador = 1
-
- If TipoMovimiento = 1 Then
- ValorMultiplicador = 1
- ElseIf TipoMovimiento = 2 Then
- ValorMultiplicador = -1
- ElseIf TipoMovimiento = 2 AndAlso TipoDocto.Contiene({"Dev"}) And (EsDevolucionVenta = 1) Then
- ValorMultiplicador = 1
- End If
-
- Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Inventario/RecepcionEntrega", 4, TotalCosto, TotalCosto, 1, Fecha, ClienteNombre, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
- 'Se agrega movimiento separado por la cuenta de ventas (ER)
-
- If CvePrePoliza > 0 Then
-
- For Each RowInv As DataRow In tmpCostos.Rows
- ValorInventario = DtCostos.SUMD("Total", $"CveClasificacion = {RowInv("CveClasificacion")}").RoundSQL()
- TotalCostoAcumulado += ValorInventario
-
- 'cuando es el último movimiento y hay diferencias en los importes
- If cont = DtCostos.FiltraParametros("", "", {"CveClasificacion"}).Rows.Count AndAlso TotalCosto <> TotalCostoAcumulado Then
- ValorInventario = ValorInventario + (TotalCosto - TotalCostoAcumulado)
- End If
-
- 'Concepto = String.Format("{0} - {1}", Row2("Clasificacion").ToString, Row2("SubProyecto").ToString)
- IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaCostos", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero
- CveCuenta = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaCostosSIG", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero
-
- If Not ErrorMovInv Then
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ValorMultiplicador * ValorInventario, Serie, 69, Serie, Fecha, IdCtaContable, -1, CveVenta:=CveVentaSurtir, CveCliente:=CveCliente, CveMovimientoAlmacen:=CveMovimiento, CveSubProyecto:=CveSubProyecto, ImporteMX:=ValorMultiplicador * ValorInventario, CveCuenta:=CveCuenta, CveClasificacion:=RowInv("CveClasificacion").ToString.ToEntero) Then
- ErrorMovInv = True
- End If
- End If
-
- cont += 1
- Next
-
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ValorMultiplicador * TotalCosto, Serie, 68, Serie, Fecha, IdCtaContableAlmacen, -1, CveVenta:=CveVentaSurtir, CveCliente:=CveCliente, CveMovimientoAlmacen:=CveMovimiento, CveSubProyecto:=CveSubProyecto, ImporteMX:=ValorMultiplicador * TotalCosto, CveCuenta:=CveCuentaAlmacen) Then
- ErrorMovInv = True
- End If
-
- 'AutoConta - El movimiento 1 es el de Venta
- Dim AutoConta As Boolean = UsuarioActual.Empresa.Funcionalidad(200) = "1"
-
- If AutoConta And Not ErrorMovInv Then
- Dim ObjContPaq = New ClsContPAQi(UsuarioActual.Empresa)
-
- If IdCtaContable > 0 Then
- If Not ObjConta.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa, ObjConta:=ObjContPaq) Then
- Alert("Ocurrio un Error al contabilizar, pongase en contacto con Soporte Técnico")
- ErrorMovInv = True
- TextoError.AppendFormat("Ocurrio un Error al contabilizar, pongase en contacto con Soporte Técnico")
- End If
- Else
- Alert(String.Format("No se puede contabilizar ya que falta asignación de las cuentas contables"), TipoMensaje.MsgAdvertencia)
- End If
-
- ObjContPaq.Dispose()
- End If
- Else
- ErrorMovInv = True
- TextoError.AppendFormat("Ocurrió un Error al ingresar la prepoliza.1")
- End If
- Else
- ErrorMovInv = True
- TextoError.AppendFormat("Ocurrió un Error al ingresar las prepolizas.2")
- End If
- Else
- ErrorMovInv = True
- TextoError.AppendFormat("Ocurrió un Error al ingresar las prepolizas.3")
- End If
- Else
- ErrorMovInv = True
- TextoError.AppendFormat("Ocurrió un Error al ingresar las prepolizas.4")
- End If
- End If
-
- End If
-
- 'DEVOLUCION APARTADOS
- If Not ErrorMovInv Then
- If TipoMovimiento = 2 Then
- If ObjInventario.VentasAlmacenApartadosGet(CveVentaSurtir) Then
-
- Dim DtTempApartados = ObjInventario.DtResultados.FiltraParametros("CveTipoAlmacen = 9", "CveAlmacen")
- Dim CveMovimientoSalidaApartado = -1
- Dim CveAlmacenApartado = -1
- Dim CveAlmacenOrigen = If(CveAlmacenTraspasoDestino > 0, CveAlmacenTraspasoDestino, DdlAlmacen.SelectedValue.ToEntero)
-
- For Each Dr As DataRow In DtTempApartados.Rows
-
- If CveMovimientoSalidaApartado = -1 Or CveAlmacenApartado <> Dr("CveAlmacen").ToString.ToEntero Then
- CveMovimientoSalidaApartado = ObjInventario.AddMovimiento(CveAlmacenOrigen, 8, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1,
- Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveVendedor:=CveVendedor, CveCliente:=CveCliente,
- CveAlmacenDestino:=Dr("CveAlmacen").ToString.ToEntero, Modulo:="RE/G9")
- FolioSalida = ObjInventario.Folio
- CveAlmacenApartado = Dr("CveAlmacen").ToString.ToEntero
-
- Dim DrMovto = DtTraspasos.NewRow
- DrMovto("Almacen") = Dr("Almacen").ToString.ToEntero
- DrMovto("CveAlmacen") = Dr("CveAlmacen").ToString.ToEntero
- DrMovto("CveMovimientoSalida") = CveMovimientoSalidaApartado
- DrMovto("FolioSalida") = FolioSalida
- DtTraspasos.Rows.Add(DrMovto)
- End If
-
- If Not CveMovimientoSalidaApartado > 0 Then
- ErrorMovInv = True
- TextoError.AppendFormat("Ocurrió un error al guardar los movimientos de control de apartados")
- Exit For
- End If
-
- If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalidaApartado, Dr("Cantidad").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, CveAF:=Dr("CveAF").ToString.ToEntero, Serie:=Dr("Serie").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, Lote:=Dr("Lote").ToString) Then
- ErrorMovInv = True
- TextoError.AppendFormat("Ocurrió un error al guardar los movimientos de control de apartados")
- Exit For
- End If
- Next
-
- If Not ErrorMovInv Then
- For Each Dr1 As DataRow In DtTraspasos.Rows
- CveMovimientoSalida = Dr1("CveMovimientoSalida").ToString.ToEntero
-
- CveMovimientoEntradaApartado = ObjInventario.AddMovimiento(Dr1("CveAlmacen").ToString.ToEntero, 9, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa,
- -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, CveAlmacenDestino:=DdlAlmacen.SelectedValue.ToEntero,
- CveMovimientoRelacionado:=CveMovimientoSalida, Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveVendedor:=CveVendedor,
- CveCliente:=CveCliente, Modulo:="RE/G10")
- FolioEntrada = ObjInventario.Folio
-
- If Not CveMovimientoEntradaApartado > 0 Then
- ErrorMovInv = True
- TextoError.AppendFormat("Ocurrió un error al procesar los movimientos de traspaso de apartado. Por favor vuelva a intentar.")
- Exit For
- End If
-
- Dr1("CveMovimientoEntrada") = CveMovimientoEntradaApartado
- Dr1("FolioEntrada") = FolioEntrada
-
- If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then
- For Each Dr As DataRow In ObjInventario.DtResultados.Rows
- If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntradaApartado, Dr("Cantidad").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, CveAF:=Dr("CveAF").ToString.ToEntero, Serie:=Dr("Serie").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, Lote:=Dr("Lote").ToString) Then
- ErrorMovInv = True
- TextoError.AppendFormat("Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar.")
- Exit For
- End If
- Next
- End If
-
- If ErrorMovInv Then Exit For
-
- Next
- End If
-
- End If
- End If
- End If
-
- 'QUEMAR REMISIONES
- If Not ErrorMovInv And EsDevolucionVenta = 1 And TipoDocto = "Ing" Then
- Dim DtDevRem As New DataTable
-
- 'CARGA REMISIONES DE LA VENTA DEVUELTA
- If ObjInventario.GetDevolucionRemisionesFacturadas(CveVentaSurtir) Then
- DtDevRem = ObjInventario.DtResultados.FiltraParametros("CantidadAlmacen = 0")
- Else
- ErrorMovInv = True
- End If
-
- If Not ErrorMovInv Then
- If DtDevRem.Rows.Count > 0 Then
- For Each DrMovtos As DataRow In DtDevRem.FiltraParametros("", "CveRem", {"CveRem"}).Rows
- If Not ObjInventario.ActualizarEsDevolucionVenta(DrMovtos("CveRem").ToString.ToEntero, 2) Then
- TextoError.AppendFormat("Ocurrió un error al hacer la devolución hacia la remision. Por favor vuelva a intentar.")
- ErrorMovInv = True
- Exit For
- End If
- Next
- End If
- Else
- TextoError.AppendFormat("Ocurrió un error al hacer la devolucion a remisión. Por favor vuelva a intentar.")
- ErrorMovInv = True
- End If
-
- End If
-
- 'QUEMA DEVOLUCION | QUEMA = LA QUITA DE PENDIENTE POR RECIBIR (DEVOLVER)
- If Not ErrorMovInv And EsDevolucionVenta = 1 Then
- If Not ObjVentas.UpdateVentasDevolucionAlmacen(2, CveVentaSurtir) Then
- TextoError.AppendFormat("Ocurrió un error al hacer la devolución. Por favor vuelva a intentar.")
- ErrorMovInv = True
- End If
- End If
-
- If Not ErrorMovInv And EsDevolucionVenta = 0 Then
- If Not ObjVentas.UpdateVentasDevolucionAlmacen(0, CveVentaSurtir) Then
- TextoError.AppendFormat("Ocurrió un error al hacer la devolucion. Por favor vuelva a intentar.")
- ErrorMovInv = True
- End If
- End If
-
- ' COMIENZA: VIRTUAL
- If Not ErrorMovInv AndAlso TipoDocto.Contiene("Ing", "Dev") AndAlso UsuarioActual.Empresa.Funcionalidad(573) = "1" AndAlso CveMovimiento > 0 Then
- Dim DtPSVirtual As New DataTable("DtTamanios")
-
- If ObjInventario.GetMovimientosDetalleVirtual(CveMovimiento, UsuarioActual.CveEmpresa) Then
- DtPSVirtual = ObjInventario.DtResultados
- End If
-
- '
- 'DtPSVirtual.Columns.Add(New DataColumn("CvePS", GetType(Integer)))
- 'DtPSVirtual.Columns.Add(New DataColumn("Cantidad", GetType(Decimal)))
- 'DtPSVirtual.Columns.Add(New DataColumn("PU", GetType(Decimal)))
- 'DtPSVirtual.Columns.Add(New DataColumn("CveUM", GetType(Integer)))
-
- 'Dim DtTamanios As DataTable = Nothing
-
- 'If ObjAcumuladores.TamañoGet(-1, UsuarioActual.CveEmpresa) Then
- ' DtTamanios = ObjAcumuladores.DtResultados.Copy()
- 'End If
-
- Dim CveConceptoMovimientoVirtual As Integer = -1
- Dim CveAlmacenVirtual As Integer = -1
- Dim CveMovimientoRelacionadoVirtual As Integer = CveMovimiento
- Dim ValidaVirtual As Boolean = False
- CveAlmacenVirtual = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 24).FiltroPrimeroValor("CveAlmacen", $"CveSubProyecto={CveSubProyecto}").ToEntero()
-
- If TipoMovimiento = 1 Then
- CveConceptoMovimientoVirtual = 37
-
- ElseIf TipoMovimiento = 2 Then
- ValidaVirtual = True
- CveConceptoMovimientoVirtual = 36
- End If
-
- If DtPSVirtual IsNot Nothing AndAlso DtPSVirtual.Rows.Count > 0 AndAlso CveAlmacenVirtual > 0 AndAlso CveConceptoMovimientoVirtual > 0 Then
- CveMovimientoVirtual = ObjInventario.AddMovimiento(CveAlmacenVirtual, CveConceptoMovimientoVirtual, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1,
- Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, CveMovimientoRelacionado:=CveMovimientoRelacionadoVirtual, Modulo:="RE/G6")
- FolioVirtual = ObjInventario.Folio
-
- If CveMovimientoVirtual > 0 Then
- For Each RowUsado As DataRow In DtPSVirtual.Rows
- Dim CvePS = RowUsado("CvePS").ToString().ToEntero()
- Dim CantidadUsado As Double = RowUsado("Cantidad").ToString().ToDouble()
- Dim PU As Decimal = RowUsado("PU").ToString().ToDecimal()
- Dim CveUM As Integer = RowUsado("CveUM").ToString().ToEntero()
-
- If Not ObjInventario.AddMovimientoDetalle(CveMovimientoVirtual, CantidadUsado, CveUM, CvePS, PU) Then
- ErrorMovInv = True
- TextoError.AppendFormat("Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar.")
- Exit For
- End If
- Next
- Else
- ErrorMovInv = True
- End If
-
- Else
- If ValidaVirtual Then
- ErrorMovInv = True
- TextoError.AppendFormat("Ocurrió un error al procesar el movimiento en almacen virtual. Por favor vuelva a intentar.")
-
- End If
- End If
-
- If DtPSVirtual.Rows.Count = 0 AndAlso ValidaVirtual = True Then
- ErrorMovInv = True
- TextoError.AppendFormat("No se tienen productos para el almacen virtual.")
- End If
- End If
-
- ' TERMINA: VIRTUAL
-
-
- 'AGREGA BITACORA A VENTA
- If Not ErrorMovInv Then
- Dim MensajeBitacora = If(TipoMovimiento = 1, "Surtida", "Devuelta")
- If Not ObjEventos.AddEventoBitacora(String.Format("Venta {2} en Folio: {1}", CveMovimiento, Folio, MensajeBitacora), "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveVenta:=CveVentaSurtir) Then
- ErrorMovInv = True
- End If
- End If
-
- Catch ex As Exception
- ErrorMovInv = True
- OnError("Ocurrió un error al guardar", ex)
- End Try
-
- 'Paqueterias guias
- If RbEntregaInterna.Checked AndAlso Not ErrorMovInv Then
- Dim CveEstatus As Integer = DdlEstatus.SelectedValue.ToEntero()
- Dim Fecha As String = TxtFechaPaqInterna.Text
- Dim FechaEstimada As String = If(TxtFechaEstimada.Text = "", "-1", TxtFechaEstimada.Text)
- Dim NoCajas As Integer = TxtNoCajas.Text.ToEntero()
- Dim Observaciones As String = TxtObservacionesPaqInterna.Text
- Dim CvePaqueteria As Integer = GlobalDTPaqueterias().FiltroPrimeroValor("CvePaqueteria", String.Format("CveEmpresa={0} AND TipoPaqueteria = 0", UsuarioActual.CveEmpresa)).ToEntero
-
- If CveSubProyecto > 0 Then
+ 'Valida Existencia
+ If TipoMovimiento = 1 Then
+ Dim ObjInventarios As New ClsInventarios
+ Dim Existencia = ObjInventarios.GetExistenciasPS(CvePSSerie, CveUMSerie, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), Serie:=Serie, CveVendedor:=CveVendedor, CveSubProyecto:=CveSubProyecto, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeApartados:=If(TipoEntrega = 2, 1, -1))
+ If Existencia < 1 Then
+ Alert($"No hay existencia suficiente del producto ""{PSSerie}"" con la Serie definida ""{Serie}"". Por favor rectifique y vuelva a intentar", TipoMensaje.MsgAdvertencia, If(Tipo = 2, "window.setTimeout(Focus,200);", ""))
+ RegistraScript("playsonidito('142608__autistic-lucario__error.wav')", "Error2")
+ ObjInventarios.Dispose()
+ Exit Sub
+ End If
+ Else
+ If DtExistencias IsNot Nothing Then
+ Dim Existencia = DtExistencias.SUM("Cantidad", $"CvePS = {CvePSSerie} AND CveUM = {CveUMSerie} AND Serie = '{Serie}'")
+ If Existencia < 1 Then
+ Alert($"No hay existencia suficiente del producto ""{PSSerie}"" con la Serie definida ""{Serie}"". Por favor rectifique y vuelva a intentar", TipoMensaje.MsgAdvertencia, If(Tipo = 2, "window.setTimeout(Focus,200);", ""))
+ RegistraScript("playsonidito('142608__autistic-lucario__error.wav')", "Error3")
+ Exit Sub
+ End If
+ End If
+ End If
+
+
+ Dim Row = DtDatosDetalle.NewRow
+
+ Row("ConsecId") = CveConsecSerie
+ Row("Consec") = DtDatosDetalle.Rows.Count + 1
+ Row("PS") = PSSerie
+ Row("CvePS") = CvePSSerie
+ Row("CveUM") = CveUMSerie
+ Row("Serie") = Serie
+ Row("FechaCaducidad") = If(AplicaCaducidad, TxtFechaCaducidad.Text, MinFecha.ToShortDateString)
+
+ DtDatosDetalle.Rows.Add(Row)
+ RegistraScript("playsonidito('beep-07.wav')", "Sonidito")
+
+ If Tipo = 1 Then
+ TxtSerie.Text = ""
+ TxtFechaCaducidad.Text = ""
+ End If
+
+ If Tipo < 3 Then
+ CargaSerie(True)
+ End If
+
+ End Sub
+
+ Protected Sub GvSerie_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvSerie.RowDeleting
+
+ Dim keySerie As String = e.Keys("Serie").ToString
+ Try
+ For Each dr As DataRow In DtDatosDetalle.Rows
+ If dr("Serie").ToString = keySerie Then
+ dr.Delete()
+ End If
+ Next
+ Catch ex As Exception
+
+ End Try
+
+ DtDatosDetalle.AcceptChanges()
+ CargaSerie()
+
+ End Sub
+#End Region
+
+#Region " AGREGA CON LOTE BATCH "
+
+ Private Sub CreaDtDetalleLote()
+ If DtDatosDetalleLote Is Nothing Then
+ DtDatosDetalleLote = New DataTable
+ DtDatosDetalleLote.Columns.Add("CveVentaDetalle", GetType(Integer))
+ DtDatosDetalleLote.Columns.Add("Consec", GetType(Integer))
+ DtDatosDetalleLote.Columns.Add("ConsecId", GetType(Integer))
+ DtDatosDetalleLote.Columns.Add("Cantidad", GetType(Double))
+ DtDatosDetalleLote.Columns.Add("CvePS", GetType(Integer))
+ DtDatosDetalleLote.Columns.Add("PS", GetType(String))
+ DtDatosDetalleLote.Columns.Add("CveUM", GetType(Integer))
+ DtDatosDetalleLote.Columns.Add("Lote", GetType(String))
+ DtDatosDetalleLote.Columns.Add("FechaCaducidad", GetType(String))
+ DtDatosDetalleLote.Columns.Add("FueTraspaso", GetType(Integer))
+ End If
+ End Sub
+ Private Sub CargaLote(Optional CerrarCompletado As Boolean = False)
+
+ RegistraScript("$('#DivLote').modal('show')")
+ GvLote.DataSource = DtDatosDetalleLote.FiltraParametros(String.Format("ConsecId = {0}", CveConsecSerie), "Consec DESC")
+ GvLote.DataBind()
+
+ 'VALIDA QUE SIGA AGREGANDO
+ If DtDatosDetalleLote.SUM("Cantidad", String.Format("ConsecId = {0}", CveConsecSerie)) = LbCantidad2.Text.ToDecimal Then
+ BtnLote.Enabled = False
+ If CerrarCompletado Then
+ RegistraScript("$('#DivLote').modal('hide')", "hide")
+ End If
+ Else
+ BtnLote.Enabled = True
+ End If
+
+ 'LOTE RECOMENDADO
+ Dim DtLotes As New DataTable
+ If TipoMovimiento = 1 Then
+ Dim ObjInventarios As New ClsInventarios
+ If ObjInventarios.LoteRecomendadoGet(CvePSSerie, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero) Then
+ DtLotes = ObjInventarios.DtResultados
+ End If
+ ObjInventarios.Dispose()
+ Else
+ DtLotes = DtExistencias.FiltraParametros("Lote <> ''")
+ End If
+
+ Dim DrsRemove As New List(Of DataRow)
+
+ If DtLotes.Rows.Count > 0 Then
+ 'CALCULA YA COMPLETADOS
+ DtLotes.Columns.Add("CantidadSeleccionada", GetType(Integer))
+ For Each dr As DataRow In DtLotes.Rows
+ dr("CantidadSeleccionada") = DtDatosDetalleLote.SUM("Cantidad", String.Format("Consec = {0} AND Lote = '{1}'", CveConsecSerie, dr("Lote")))
+ If dr("CantidadSeleccionada").ToString.ToDecimal = dr("Existencia").ToString.ToDecimal Then
+ DrsRemove.Add(dr)
+ End If
+ Next
+
+ 'ELIMINA YA COMPLETADOS EN PAGINA
+ For Each dr As DataRow In DrsRemove
+ DtLotes.Rows.Remove(dr)
+ Next
+
+ If DtLotes.Rows.Count > 0 Then
+ Dim Mensaje As New StringBuilder
+ Mensaje.AppendFormat("Recomendado: Existencia: {0} Lote: {1} Fecha Caducidad: {2} ", DtLotes.Rows(0)("Existencia").ToString.FormatoNumero, DtLotes.Rows(0)("Lote"), DtLotes.Rows(0)("FechaCaducidad").ToString.ToDate.ToShortDateString)
+ LbLoteRecomendado.Text = Mensaje.ToString
+ Else
+ LbLoteRecomendado.Text = "No se encontro ningún Lote recomendado."
+ End If
+ Else
+ LbLoteRecomendado.Text = "No se encontro ningún Lote recomendado."
+ End If
+
+
+ 'SI TIENE SALIDA POR LOTE, BLOQUEAMOS CHECK Y TXTCANTIDAD
+ Dim Contador As Decimal = 0
+ For Each Gvr As GridViewRow In GvDatos.Rows
+ If Gvr.DataKey("CvePS").ToEntero = CvePSSerie Then
+ Contador = DtDatosDetalleLote.SUM("Cantidad", String.Format("ConsecId = {0}", Gvr.DataKey("Consec"))).ToDecimal
+ Gvr.FCCheckBox("cbInv").Enabled = False
+ Gvr.FCCheckBox("cbInv").Checked = True
+ Gvr.FCTextBox("TbCantidadF").Text = Contador.ToString.FormatoNumero
+ End If
+ Next
+
+ RVCantidadLote.MaximumValue = (If((LbCantidad2.Text.ToDecimal - Contador) = 0, 0.02, LbCantidad2.Text.ToDecimal - Contador)).ToString.FormatoNumero
+
+ TxtCantidadLote.Text = "1"
+ TxtLote.Text = ""
+ TxtBatch.Text = ""
+ TxtLote.Focus()
+
+ UpLoteBatch.Update()
+ UpDatos.Update()
+
+ End Sub
+
+ Protected Sub BtnAgregarPS2_Click(sender As Object, e As EventArgs)
+ AgregaLote(TxtLote.Text.Trim, TxtBatch.Text.Trim, 1)
+ End Sub
+ Private Sub AgregaLote(Lote As String, Batch As String, Tipo As Integer)
+
+ If Lote = "" Then
+ Alert("El campo Lote es obligatorio. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
+
+ 'VALIDACION DE SERIES DUPLICADAS
+ Dim MensajeAlert As New StringBuilder
+ Dim DtDuplicado As New DataTable
+ Dim DtSeriesNuevas As New DataTable
+ DtSeriesNuevas.Columns.Add("Serie", GetType(String))
+
+ DtDuplicado = DtDatosDetalleLote.FiltraParametros($"ConsecId = {CveConsecSerie} AND Lote = '{Lote}' AND Batch = '{Batch}'")
+ If DtDuplicado IsNot Nothing AndAlso DtDuplicado.Rows.Count > 0 Then
+ Alert($"
El numero de Lote ""{Lote}"" y Batch = '{Batch}' proporcionado ya se encuentra ingresado.", TipoMensaje.MsgAdvertencia)
+ RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
+ Exit Sub
+ End If
+
+ Dim Row = DtDatosDetalleLote.NewRow
+ Dim CantidadLote = TxtCantidadLote.Text.ToDecimal
+
+ Dim MensajeSinExistencias As New StringBuilder
+ Dim ObjInventarios As New ClsInventarios
+
+ 'VERIFICA EXISTENCIAS
+ If TipoMovimiento = 1 Then
+ Dim Existencia = ObjInventarios.GetExistenciasPS(CvePSSerie, CveUMSerie, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), CveVendedor:=CveVendedor, CveSubProyecto:=CveSubProyecto, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), Lote:=Lote, ExcluyeApartados:=If(TipoEntrega = 2, 1, -1))
+ If Existencia < CantidadLote Then
+ Alert($"No hay existencia suficiente del producto ""{PSSerie}"" con el lote definido ""{Lote}"" y el batch ""{Batch}"". Por favor rectifique y vuelva a intentar", TipoMensaje.MsgAdvertencia)
+ RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
+ ObjInventarios.Dispose()
+ Exit Sub
+ End If
+ Else
+ If DtExistencias IsNot Nothing Then
+ Dim Existencia = DtExistencias.SUM("Cantidad", $"CvePS = {CvePSSerie} AND CveUM = {CveUMSerie} AND Lote = '{Lote}' AND Batch = '{Batch}'")
+ If Existencia < CantidadLote Then
+ Alert($"No hay existencia suficiente del producto ""{PSSerie}"" con el lote definido ""{Lote}"" y el batch ""{Batch}"". Por favor rectifique y vuelva a intentar", TipoMensaje.MsgAdvertencia)
+ RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
+ ObjInventarios.Dispose()
+ Exit Sub
+ End If
+ End If
+ End If
+
+ Dim FechaCaducidad = ""
+ If ObjInventarios.LoteRecomendadoGet(CvePSSerie, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero) AndAlso ObjInventarios.DtResultados.Rows.Count > 0 Then
+ FechaCaducidad = ObjInventarios.DtResultados.Rows(0)("FechaCaducidad").ToString.ToDate.ToShortDateString
+ End If
+
+ Row("ConsecId") = CveConsecSerie
+ Row("Consec") = DtDatosDetalle.Rows.Count + 1
+ Row("Cantidad") = CantidadLote
+ Row("CvePS") = CvePSSerie
+ Row("PS") = PSSerie
+ Row("CveUM") = CveUMSerie
+ Row("Lote") = Lote
+ Row("Batch") = Batch
+ Row("FechaCaducidad") = FechaCaducidad
+
+ DtDatosDetalleLote.Rows.Add(Row)
+ ObjInventarios.Dispose()
+
+ If Tipo = 1 Then
+ TxtCantidadLote.Text = "1"
+ TxtLote.Text = ""
+ TxtBatch.Text = ""
+ End If
+
+ CargaLote(True)
+
+ End Sub
+
+ Protected Sub GvLote_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvLote.RowDeleting
+
+ Dim keyLote As String = e.Keys("Lote").ToString
+ Try
+ For Each dr As DataRow In DtDatosDetalleLote.Rows
+ If dr("Lote").ToString = keyLote Then
+ dr.Delete()
+ End If
+ Next
+ Catch ex As Exception
+
+ End Try
+ DtDatosDetalleLote.AcceptChanges()
+ CargaLote()
+ End Sub
+#End Region
+
+#Region " AGREGA CON TXT | CODIGO - SERIE "
+ Protected Sub BtnCodigoPS_Click(sender As Object, e As EventArgs)
+
+ If TxtCodigoPS.Text = "" Then
+ Exit Sub
+ End If
+
+ TdSeriePS.Visible = False
+ Dim Existe = False
+ Dim PSTemp = ""
+
+ For Each Gvr As GridViewRow In GvDatos.Rows
+ If Gvr.DataKey("CodigoBarras") = TxtCodigoPS.Text.Trim Then
+ Dim TxtCantidad = GvDatos.Rows(Gvr.RowIndex).FCTextBox("TbCantidadF")
+ If Gvr.DataKey("CantidadF").ToDecimal - TxtCantidad.Text.ToDecimal - 1 >= 0 Then
+
+ ''VALIDA EXISTENCIA
+ If Not TipoDocto.Contiene("Dev") Then
+ If TipoMovimiento = 1 Then
+ Dim ObjInventario As New ClsInventarios
+ Dim Existencia = ObjInventario.GetExistenciasPS(Gvr.DataKey("CvePS").ToString.ToEntero, Gvr.DataKey("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), CveVendedor:=CveVendedor, CveSubProyecto:=CveSubProyecto, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeApartados:=If(TipoEntrega = 2, 1, -1))
+ ObjInventario.Dispose()
+ If Not Existencia >= TxtCantidad.Text.ToDecimal + 1 Then
+ TxtCodigoPS.Text = ""
+ Alert($"No hay existencias suficientes del producto:
""{Gvr.DataKey("Codigo")}-{Gvr.DataKey("PS")}"".
Solo hay disponibles {Existencia.FormatoNumero} en Almacen. Por favor Verifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus,200);")
+ RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
+ Exit Sub
+ End If
+ Else
+ If DtExistencias IsNot Nothing Then
+ Dim Existencia = DtExistencias.SUM("Cantidad", $"CvePS = {Gvr.DataKey("CvePS")} AND CveUM = {Gvr.DataKey("CveUM").ToString.ToEntero}")
+ If Not Existencia >= TxtCantidad.Text.ToDecimal + 1 Then
+ TxtCodigoPS.Text = ""
+ Alert($"No hay existencias suficientes del producto:
""{Gvr.DataKey("Codigo")}-{Gvr.DataKey("PS")}"".
Solo hay disponibles {Existencia.FormatoNumero} en Almacen. Por favor Verifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus,200);")
+ RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
+ Exit Sub
+ End If
+ End If
+ End If
+ End If
+
+
+ If Gvr.DataKey("AplicaSerieLote") = "True" Then
+ TdSeriePS.Visible = True
+ TxtSeriePS.Focus()
+
+ CveConsecSerie = Gvr.DataKey("Consec").ToString.ToEntero
+ PSSerie = Gvr.DataKey("PS").ToString
+ CvePSSerie = Gvr.DataKey("CvePS").ToEntero
+ CveUMSerie = Gvr.DataKey("CveUM").ToEntero
+ Exit Sub
+ End If
+
+
+ Dim CantidadEspecial = Gvr.DataKey("CveClasificacion").ToString.ToEntero.Contiene(17601, 17881) OrElse Gvr.DataKey("CvePS").ToString.ToEntero.Contiene(343032, 343033)
+
+ If CantidadEspecial Then
+ RegistraScript("CantidadEspecial();window.setTimeout(FocusCantidadEspecial,200);")
+ LtlProductoCantidad.Text = $"{Gvr.DataKey("Codigo")}"
+ RowIndexCantidadEspecial = Gvr.RowIndex
+ CantidadEspecialTemp = Gvr.DataKey("CantidadF").ToDecimal
+ TxtCodigoPS.Text = ""
+ Exit Sub
+ Else
+ TxtCantidad.Text = (TxtCantidad.Text.ToDecimal + 1).ToString.FormatoNumero
+ TxtCodigoPS.Text = ""
+ UpDatos.Update()
+ Exit Sub
+ End If
+
+ VerificaVentaSurtida()
+ Exit Sub
+ End If
+
+ Existe = True
+ PSTemp = Gvr.DataKey("PS").ToString
+ 'Alert($"Ya se ha cargado la totalidad del Producto ""{Gvr.DataKey("PS").ToString}"" con el Codigo ""{TxtCodigoPS.Text}"".", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus,200);")
+ 'VerificaVentaSurtida()
+ 'Exit Sub
+ End If
+ Next
+
+ VerificaVentaSurtida()
+ If Existe Then
+ Alert($"Ya se ha cargado la totalidad del Producto ""{PSTemp}"" con el Codigo ""{TxtCodigoPS.Text}"".", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus,200);")
+ Else
+ Alert($"No se ha encontrado un producto para surtir con el Codigo ""{TxtCodigoPS.Text}"". ", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus,200);")
+ End If
+ RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
+ TxtCodigoPS.Text = ""
+
+ End Sub
+ Private Sub VerificaVentaSurtida()
+ Dim Surtida = True
+
+ For Each Gvr As GridViewRow In GvDatos.Rows
+ If Gvr.DataKey("CantidadF").ToDecimal <> Gvr.FCTextBox("TbCantidadF").Text.ToDecimal Then
+ Surtida = False
+ Exit Sub
+ End If
+ Next
+
+ If Surtida Then
+ LbSurtida.Visible = True
+ End If
+ End Sub
+ Protected Sub BtnSeriePS_Click(sender As Object, e As EventArgs)
+ AgregaSerie(TxtSeriePS.Text.Trim, 2)
+
+ TdSeriePS.Visible = False
+ TxtSeriePS.Text = ""
+ TxtCodigoPS.Text = ""
+ TxtCodigoPS.Focus()
+ VerificaVentaSurtida()
+
+ End Sub
+ Protected Sub BtnGuardarCantidadEspecial_Click(sender As Object, e As EventArgs)
+ AgregaCantidadEspecial()
+ End Sub
+ Private Sub AgregaCantidadEspecial()
+ Dim TxtCantidad = GvDatos.Rows(RowIndexCantidadEspecial).FCTextBox("TbCantidadF")
+ If CantidadEspecialTemp - TxtCantidadEspecialDiv.Text.ToDecimal - TxtCantidad.Text.ToDecimal >= 0 Then
+ TxtCantidad.Text = (TxtCantidad.Text.ToDecimal + TxtCantidadEspecialDiv.Text.ToDecimal).ToString.FormatoNumero
+ 'RegistraScript("$('#ModalCantidad').modal('hide');")
+ RegistraScript("$('#DivCantidadEspecial').hide(200);")
+ UpDatos.Update()
+ TxtCodigoPS.Focus()
+ Else
+ Alert("La cantidad excede la pendiente por surtir. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus,200);")
+ RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
+ End If
+
+ TxtCantidadEspecialDiv.Text = "1"
+ End Sub
+#End Region
+
+#End Region
+
+
+#Region " GUARDAR "
+ Protected Sub BtnGuardar_Click(sender As Object, e As EventArgs)
+
+ Select Case TipoEntrega
+ Case 1
+ GuardaVenta()
+ Case 2
+ GuardaTraspaso()
+ End Select
+
+ End Sub
+
+ Private Sub GuardaVenta()
+
+
+ '' INICIA: VALIDACIONES
+
+ 'Valida el estatus de la Venta, si es = 5 O DevolucionVenta = 2, NO SE SURTE!
+ Dim ObjVentaInv As New ClsInventarios
+ If ObjVentaInv.GetEstatusVentaPorSurtir(CveVentaSurtir) Then
+ TipoEstatus = ObjVentaInv.TipoEstatus
+ EsDevolucionVenta = ObjVentaInv.EsDevolucionVenta
+ End If
+ ObjVentaInv.Dispose()
+
+ If TipoEstatus = 5 Or EsDevolucionVenta.Contiene(2, 3) Then
+ Alert("No se puede surtir esta venta, verifique que no esté cancelada o ya registrado su movimiento en almacen", TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
+
+ Dim ValidaSeccion As Boolean = False : Dim ValidaCaducidad As Boolean = False : Dim ValidaLote As Boolean = False
+ 'VALIDA CANTIDAD DE SALIDA
+ Dim Cantidad As Decimal = 0.0D
+ For Each Gvr As GridViewRow In GvDatos.Rows
+ If CBool(Gvr.DataKey("AplicaSeccion")) AndAlso Gvr.FCDropDownList("DdlSeccionAlmacen").SelectedValue.ToEntero <= 0 Then
+ ValidaSeccion = True
+ End If
+ If CBool(Gvr.DataKey("AplicaCaducidad")) AndAlso Gvr.FCTextBox("TxtCaducidad").Text.Trim = "" Then
+ ValidaCaducidad = True
+ End If
+ If CBool(Gvr.DataKey("AplicaLote")) AndAlso Gvr.FCTextBox("TxtLote").Text.Trim = "" Then
+ ValidaLote = True
+ End If
+
+ If Gvr.FCCheckBox("cbInv").Checked AndAlso Gvr.FCTextBox("TbCantidadF").Text.ToDecimal > 0 Then
+ Cantidad = Gvr.FCTextBox("TbCantidadF").Text.ToDecimal
+ Exit For
+ End If
+
+ Next
+
+ If ValidaSeccion Then
+ Alert("La sección de almacen no ha sido especificada en todos los productos.", TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
+ If ValidaCaducidad Then
+ Alert("La caducidad no ha sido especificada en todos los productos.", TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
+ If ValidaLote Then
+ Alert("El lote de almacen no ha sido especificada en todos los productos.", TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
+
+
+ If Not Cantidad > 0 Then
+ Alert("No se detecto ningun movimiento por hacer. Por favor verifique e intente nuevamente.", TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
+
+ 'PROCESO , si tiene proceso "176" no lo valida
+ If Not UsuarioActual.TienePermisoProceso(176) Then
+ For Each Gvr As GridViewRow In GvDatos.Rows
+ If Gvr.DataKey("CantidadF").ToDecimal <> Gvr.FCTextBox("TbCantidadF").Text.ToDecimal Then
+ Alert("En la factura no se han especificado todos los productos a entregar, favor de especificarlos para poder dar salida.", TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
+ Next
+ End If
+
+ If EsDevolucionVenta = 1 Or TipoDocto.Contiene({"Ped"}) Then
+ For Each Gvr As GridViewRow In GvDatos.Rows
+ If Not Gvr.FCCheckBox("cbInv").Checked Or (Gvr.FCCheckBox("cbInv").Checked AndAlso Gvr.FCTextBox("TbCantidadF").Text.ToDecimal <> Gvr.DataKey("CantidadC").ToString.ToDecimal) Then
+ Alert("Es necesario surtir todos los productos. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
+ RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
+ Exit Sub
+ End If
+ Next
+ End If
+
+
+ Dim EsInterno As Integer = -1
+ If TipoDocto = "Ped" Then
+ EsInterno = If(Me.EsInterno, 1, 0)
+ End If
+
+ Dim ObjInventario As New ClsInventarios
+ Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL())
+ Dim ObjVentas As New ClsVentas(ObjInventario.IniciaTransacSQL())
+ Dim ObjEventos As New ClsOIEventos(ObjInventario.IniciaTransacSQL())
+ Dim ObjAcumuladores As New ClsAcumuladores(ObjInventario.IniciaTransacSQL())
+ Dim ObjGeneral As New ClsGenerales(ObjInventario.IniciaTransacSQL())
+ Dim CveMovimiento As Integer
+ Dim Folio As Integer
+ Dim ErrorMovInv As Boolean
+ Dim DtDetalle As New DataTable
+ Dim DtDetalleLote As New DataTable
+ Dim TextoError As New StringBuilder
+
+ Dim CveMovimientoGarantia As Integer = -1
+ Dim FolioGarantia As Integer = -1
+
+ Dim CveMovimientoVirtual As Integer = -1
+ Dim FolioVirtual As Integer = -1
+
+ 'PASA DATOS DEL GV A DATATABLE PARA MANEJOR CON FOR EACH
+ Dim Index = 0
+ For Each gvr As GridViewRow In GvDatos.Rows
+ If gvr.FCCheckBox("cbInv").Checked AndAlso gvr.FCTextBox("TbCantidadF").Text.ToDecimal > 0 Then
+ DtDatos.Rows(Index)("CantidadGV") = gvr.FCTextBox("TbCantidadF").Text.ToDecimal
+ DtDatos.Rows(Index)("CveSeccion") = gvr.FCDropDownList("DdlSeccionAlmacen").SelectedValue.ToEntero
+ DtDatos.Rows(Index)("FechaCaducidad") = gvr.FCTextBox("TxtCaducidad").Text.ToDate
+ DtDatos.Rows(Index)("Lote") = gvr.FCTextBox("TxtLote").Text
+ End If
+ Index += 1
+ Next
+
+ 'VALIDA SI HUBO CAMBIOS EN LA EXISTENCIA
+ Dim DtDatosVenta As New DataTable
+ If ObjInventario.EntregaAlmacenGet(CveVentaSurtir) Then
+ DtDatosVenta = ObjInventario.DtResultados
+ End If
+ Dim CantidadGV = GvDatos.Rows.Cast(Of GridViewRow)().Sum(Function(gvr) gvr.DataKey("CantidadF").ToDecimal)
+ If CantidadGV <> DtDatosVenta.SUM("CantidadF").ToDecimal Then
+ ObjInventario.RollBack()
+ ObjInventario.Dispose()
+ ObjConta.Dispose()
+ ObjVentas.Dispose()
+ ObjEventos.Dispose()
+ CargaVentaPorSurtir(CveVentaSurtir)
+ CargaPendientes()
+ Alert("Ha sido cambiada la informacion de existencias de la venta actual, se han recargado la información.", TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
+
+ If Not ObjVentas.UpdateVentasDevolucionAlmacen(3, CveVentaSurtir) Then
+ ObjInventario.RollBack()
+ ObjInventario.Dispose()
+ ObjConta.Dispose()
+ ObjVentas.Dispose()
+ ObjEventos.Dispose()
+ Exit Sub
+ End If
+
+ Dim DtTraspasos As New DataTable
+ DtTraspasos.Columns.Add("CveAlmacen", GetType(Integer))
+ DtTraspasos.Columns.Add("Almacen", GetType(String))
+ DtTraspasos.Columns.Add("CveMovimientoSalida", GetType(Integer))
+ DtTraspasos.Columns.Add("FolioSalida", GetType(Integer))
+ DtTraspasos.Columns.Add("CveMovimientoEntrada", GetType(Integer))
+ DtTraspasos.Columns.Add("FolioEntrada", GetType(Integer))
+ DtTraspasos.Columns.Add("CveTipoAlmacen", GetType(Integer))
+ DtTraspasos.Columns.Add("CveConceptoMovimientoSalida", GetType(Integer))
+
+ Dim CveMovimientoSalida = -1, FolioSalida = -1, CveMovimientoEntrada = -1, CveMovimientoEntradaApartado = -1, FolioEntrada = -1, CveMovimientoSalidaDevRem = -1, FolioMovimientoSalidaDevRem = -1, CveMovimientoEntradaDevRem = -1, FolioMovimientoEntradaDevRem = -1
+
+ Try
+ 'VALIDA EXISTENCIA 2
+ If TipoMovimiento = 1 Then
+ Dim StrXML As New StringBuilder
+ StrXML.Append("")
+ Dim FechaCaducidad As Date
+ Dim Lote As String = ""
+
+ For Each Dr As DataRow In DtDatos.Rows
+ FechaCaducidad = If(CBool(Dr("AplicaCaducidad")) AndAlso Dr("FechaCaducidad").ToString <> "", Dr("FechaCaducidad").ToString.ToDate, MinFecha)
+ Lote = If(CBool(Dr("AplicaLote")), Dr("Lote").ToString, "-1")
+
+ If Dr("CantidadGV").ToString.ToDecimal > 0 Then
+ If CBool(Dr("AplicaSerie")) Then
+ DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Dr("Consec")))
+ For Each Dr1 As DataRow In DtDetalle.Rows
+ StrXML.AppendFormat("", Dr1("CvePS"), Dr1("CveUM"), 1, IfNull(Dr("CveSeccion"), -1), Dr1("Serie"), Lote, FechaCaducidad.ToString("yyyy/MM/dd"))
+ Next
+ Else
+ StrXML.AppendFormat("", Dr("CvePS"), Dr("CveUM"), Dr("CantidadGV"), IfNull(Dr("CveSeccion"), -1), "-1", Lote, FechaCaducidad.ToString("yyyy/MM/dd"))
+ End If
+ End If
+ Next
+ StrXML.Append("")
+
+ Dim TieneErrorExistencia = False
+ If ObjInventario.GetExistenciasPSXML(StrXML.ToString(), DdlAlmacen.SelectedValue.ToEntero, TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), CveSubProyecto, CveVendedor, If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), If(TipoEntrega = 2, 1, -1), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
+ If ObjInventario.DtResultados.Rows.Count > 0 Then
+ TieneErrorExistencia = True
+ For Each Dr As DataRow In ObjInventario.DtResultados.Rows
+ TextoError.AppendFormat(" - {0} Existencia: {1:#,##0.##}
", Dr("CodigoPS"), Dr("Existencia"))
+ Next
+ End If
+ Else
+ TieneErrorExistencia = True
+ End If
+
+ If TieneErrorExistencia Then
+ ObjInventario.RollBack()
+ ObjInventario.Dispose()
+ ObjConta.Dispose()
+ ObjVentas.Dispose()
+ ObjEventos.Dispose()
+ If TextoError.Length > 0 Then
+ Alert($" Lo(s) siguiente(s) Productos no tienen existencia suficiente:
{TextoError}", TipoMensaje.MsgAdvertencia)
+ End If
+ RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
+ Exit Sub
+ End If
+
+ End If
+
+ '' TERMINA: VALIDACIONES
+
+ Dim CantidadPendienteSinCosto As Decimal = 0
+ Dim CantidadSaldoSinCosto As Decimal = 0
+
+ Dim CantidadSalidaSinCosto As Decimal = 0
+
+ '' COMIENZA: SIN COSTO
+ If TipoDocto.Contiene("Ing", "Rem") AndAlso UsuarioActual.Empresa.Funcionalidad(587) = "1" AndAlso TipoMovimiento = 1 Then
+
+ Dim CveConceptoSalidaSinCosto As Integer = If(TipoDocto.Contiene("Rem"), 8, 40)
+
+ For Each Dr As DataRow In DtDatos.Rows
+ If Dr("CantidadGV").ToString.ToDecimal > 0 Then
+ If CBool(Dr("AplicaSerie")) Then
+ DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Dr("Consec")))
+ For Each Dr1 As DataRow In DtDetalle.Rows
+ If ObjInventario.GetExistenciasProducto(Dr1("CvePS").ToString.ToEntero, Dr1("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, -1, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), Serie:=Dr1("Serie").ToString, CveTipoAlmacen:=26, CveSubProyecto:=CveSubProyecto, Caducidad:=If(CBool(Dr("AplicaCaducidad")), Dr("FechaCaducidad").ToString.ToDate, MinFecha), Lote:=If(CBool(Dr("AplicaLote")), Dr("Lote").ToString, "-1"), CveSeccionAlmacen:=If(CBool(Dr("AplicaSeccion")), Dr("CveSeccion").ToString.ToEntero, -1)) Then
+ For Each Dr2 As DataRow In ObjInventario.DtResultados.FiltraParametros("CveAlmacen > 0 AND ExistenciaFinal > 0").Rows
+
+ 'BUSCA SI EXISTE YA UN TRASPASO DEL ALMACEN DE APARTADO
+ CveMovimientoSalida = DtTraspasos.FiltroPrimeroValor("CveMovimientoSalida", $"CveAlmacen = {Dr2("CveAlmacen")}").ToEntero
+
+ If Not CveMovimientoSalida > 0 Then
+
+
+
+ CveMovimientoSalida = ObjInventario.AddMovimiento(Dr2("CveAlmacen").ToString.ToEntero, CveConceptoSalidaSinCosto, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1,
+ Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, CveContrato:=CveContrato, Modulo:="RE/GSC1")
+ FolioSalida = ObjInventario.Folio
+
+ If Not CveMovimientoSalida > 0 Then
+ ErrorMovInv = True
+ TextoError.AppendFormat("Ocurrió un error al procesar los movimientos de traspaso de apartado. Por favor vuelva a intentar.")
+ Exit For
+ End If
+
+ Dim DrMovto = DtTraspasos.NewRow
+ DrMovto("Almacen") = Dr2("Almacen").ToString.ToEntero
+ DrMovto("CveAlmacen") = Dr2("CveAlmacen").ToString.ToEntero
+ DrMovto("CveMovimientoSalida") = CveMovimientoSalida
+ DrMovto("FolioSalida") = FolioSalida
+ DrMovto("CveTipoAlmacen") = 26
+ DrMovto("CveConceptoMovimientoSalida") = CveConceptoSalidaSinCosto
+ DtTraspasos.Rows.Add(DrMovto)
+ End If
+
+
+ CantidadPendienteSinCosto = 1
+
+ If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, CantidadPendienteSinCosto, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0, Serie:=Dr1("Serie").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, FechaCaducidad:=If(CBool(Dr("AplicaCaducidad")), Dr("FechaCaducidad").ToString.ToDate, MinFecha), Lote:=If(CBool(Dr("AplicaLote")), Dr("Lote").ToString, "-1"), CveSeccionAlmacen:=If(CBool(Dr("AplicaSeccion")), Dr("CveSeccion").ToString.ToEntero, -1)) Then
+ ErrorMovInv = True
+ TextoError.AppendFormat("Ocurrió un Error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar.")
+ Exit For
+ End If
+
+ DtDatosDetalle.Select($"Consec = {Dr1("Consec")}")(0)("FueTraspaso") = 1
+ DtDatosDetalle.Select($"Consec = {Dr1("Consec")}")(0)("CveVentaDetalle") = Dr("CveVentaDetalle")
+ Dr("CantidadTraspaso") = Dr("CantidadTraspaso").ToString.ToDecimal + CantidadPendienteSinCosto
+ Exit For
+ Next
+ End If
+ If ErrorMovInv Then Exit For
+ Next
+
+ ElseIf CBool(Dr("AplicaLote")) Then
+
+ DtDetalle = DtDatosDetalleLote.FiltraParametros(String.Format("ConsecId = {0}", Dr("Consec")))
+ For Each Dr1 As DataRow In DtDetalle.Rows
+ If ObjInventario.GetExistenciasProducto(Dr1("CvePS").ToString.ToEntero, Dr1("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, -1, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), Lote:=Dr1("Lote").ToString, CveTipoAlmacen:=26, CveSubProyecto:=CveSubProyecto, Caducidad:=If(CBool(Dr("AplicaCaducidad")), Dr("FechaCaducidad").ToString.ToDate, MinFecha), CveSeccionAlmacen:=If(CBool(Dr("AplicaSeccion")), Dr("CveSeccion").ToString.ToEntero, -1)) Then
+
+ CantidadSaldoSinCosto = Dr("CantidadGV").ToString.ToDecimal
+
+ For Each Dr2 As DataRow In ObjInventario.DtResultados.FiltraParametros("CveAlmacen > 0 AND ExistenciaFinal > 0").Rows
+
+ 'BUSCA SI EXISTE YA UN TRASPASO DEL ALMACEN DE APARTADO
+ CveMovimientoSalida = DtTraspasos.FiltroPrimeroValor("CveMovimientoSalida", $"CveAlmacen = {Dr2("CveAlmacen")}").ToEntero
+
+ If Not CveMovimientoSalida > 0 Then
+ CveMovimientoSalida = ObjInventario.AddMovimiento(Dr2("CveAlmacen").ToString.ToEntero, CveConceptoSalidaSinCosto, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim,
+ Guia:=TxtGuia.Text, CveContrato:=CveContrato, Modulo:="RE/GSC2")
+ FolioSalida = ObjInventario.Folio
+
+ If Not CveMovimientoSalida > 0 Then
+ ErrorMovInv = True
+ TextoError.AppendFormat("Ocurrió un error al procesar los movimientos de traspaso de apartado. Por favor vuelva a intentar.")
+ Exit For
+ End If
+
+ Dim DrMovto = DtTraspasos.NewRow
+ DrMovto("Almacen") = Dr2("Almacen").ToString.ToEntero
+ DrMovto("CveAlmacen") = Dr2("CveAlmacen").ToString.ToEntero
+ DrMovto("CveMovimientoSalida") = CveMovimientoSalida
+ DrMovto("FolioSalida") = FolioSalida
+ DrMovto("CveTipoAlmacen") = 26
+ DrMovto("CveConceptoMovimientoSalida") = CveConceptoSalidaSinCosto
+ DtTraspasos.Rows.Add(DrMovto)
+ End If
+
+ CantidadPendienteSinCosto = If(Dr1("Cantidad").ToString.ToDecimal > CantidadSaldoSinCosto, CantidadSaldoSinCosto, Dr1("Cantidad").ToString.ToDecimal)
+
+ If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, CantidadPendienteSinCosto.ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0, Lote:=Dr1("Lote").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, FechaCaducidad:=If(CBool(Dr("AplicaCaducidad")), Dr("FechaCaducidad").ToString.ToDate, MinFecha), CveSeccionAlmacen:=If(CBool(Dr("AplicaSeccion")), Dr("CveSeccion").ToString.ToEntero, -1)) Then
+ ErrorMovInv = True
+ TextoError.AppendFormat("Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar.")
+ Exit For
+ End If
+
+ DtDatosDetalle.Select($"Consec = {Dr1("Consec")}")(0)("FueTraspaso") = 1
+ DtDatosDetalle.Select($"Consec = {Dr1("Consec")}")(0)("CveVentaDetalle") = Dr("CveVentaDetalle")
+
+ CantidadSaldoSinCosto -= CantidadPendienteSinCosto
+ Dr("CantidadTraspaso") = Dr("CantidadTraspaso").ToString.ToDecimal + CantidadPendienteSinCosto
+ If CantidadSaldoSinCosto <= 0 Then Exit For
+ Next
+ End If
+ Next
+
+ Else
+
+ If ObjInventario.GetExistenciasProducto(Dr("CvePS").ToString.ToEntero, Dr("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, -1, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), CveTipoAlmacen:=26, CveSubProyecto:=CveSubProyecto, Caducidad:=If(CBool(Dr("AplicaCaducidad")), Dr("FechaCaducidad").ToString.ToDate, MinFecha), Lote:=If(CBool(Dr("AplicaLote")), Dr("Lote").ToString, "-1"), CveSeccionAlmacen:=If(CBool(Dr("AplicaSeccion")), Dr("CveSeccion").ToString.ToEntero, -1)) Then
+
+ CantidadSaldoSinCosto = Dr("CantidadGV").ToString.ToDecimal
+
+ For Each Dr1 As DataRow In ObjInventario.DtResultados.FiltraParametros("CveAlmacen > 0 AND ExistenciaFinal > 0").Rows
+
+ 'BUSCA SI EXISTE YA UN TRASPASO DEL ALMACEN DE APARTADO
+ CveMovimientoSalida = DtTraspasos.FiltroPrimeroValor("CveMovimientoSalida", $"CveAlmacen = {Dr1("CveAlmacen")}").ToEntero
+
+ If Not CveMovimientoSalida > 0 Then
+ CveMovimientoSalida = ObjInventario.AddMovimiento(Dr1("CveAlmacen").ToString.ToEntero, CveConceptoSalidaSinCosto, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1,
+ Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, CveContrato:=CveContrato, Modulo:="RE/GSC3")
+ FolioSalida = ObjInventario.Folio
+
+ If Not CveMovimientoSalida > 0 Then
+ ErrorMovInv = True
+ TextoError.AppendFormat("Ocurrió un error al procesar los movimientos de traspaso de apartado. Por favor vuelva a intentar.")
+ Exit For
+ End If
+
+ Dim DrMovto = DtTraspasos.NewRow
+ DrMovto("Almacen") = Dr1("Almacen").ToString.ToEntero
+ DrMovto("CveAlmacen") = Dr1("CveAlmacen").ToString.ToEntero
+ DrMovto("CveMovimientoSalida") = CveMovimientoSalida
+ DrMovto("FolioSalida") = FolioSalida
+ DrMovto("CveTipoAlmacen") = 26
+ DrMovto("CveConceptoMovimientoSalida") = CveConceptoSalidaSinCosto
+ DtTraspasos.Rows.Add(DrMovto)
+ End If
+
+
+ CantidadPendienteSinCosto = If(Dr1("ExistenciaFinal").ToString.ToDecimal > CantidadSaldoSinCosto, CantidadSaldoSinCosto, Dr1("ExistenciaFinal").ToString.ToDecimal)
+
+ If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, CantidadPendienteSinCosto.ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0,
+ Serie:=Dr("Serie").ToString,
+ CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero,
+ FechaCaducidad:=If(CBool(Dr("AplicaCaducidad")), Dr("FechaCaducidad").ToString.ToDate, MinFecha),
+ Lote:=If(CBool(Dr("AplicaLote")), Dr("Lote").ToString, "-1"),
+ CveSeccionAlmacen:=If(CBool(Dr("AplicaSeccion")), Dr("CveSeccion").ToString.ToEntero, -1)) Then
+ ErrorMovInv = True
+ TextoError.AppendFormat("Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar.")
+ Exit For
+ End If
+
+ CantidadSaldoSinCosto -= CantidadPendienteSinCosto
+ Dr("CantidadTraspaso") = Dr("CantidadTraspaso").ToString.ToDecimal + CantidadPendienteSinCosto
+ If CantidadSaldoSinCosto <= 0 Then Exit For
+ Next
+
+ If ErrorMovInv Then Exit For
+ Else
+ ErrorMovInv = True
+ End If
+
+ End If
+
+ CantidadSalidaSinCosto += Dr("CantidadTraspaso").ToString().ToDecimal()
+ If ErrorMovInv Then Exit For
+
+ End If
+
+ Next
+
+ 'ENTRADA POR TRASPASO A ENTREGA POR ADELANTADO
+ If TipoDocto = "Rem" AndAlso Not ErrorMovInv Then
+ For Each Dr1 As DataRow In DtTraspasos.Select("CveTipoAlmacen = 26")
+ CveMovimientoSalida = Dr1("CveMovimientoSalida").ToString.ToEntero
+
+ Dim CveAlmacenExA As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveTipoAlmacen:=10).FiltroPrimeroValor("CveAlmacen", $"CveSubProyecto={CveSubProyecto}").ToEntero()
+
+ CveMovimientoEntradaApartado = ObjInventario.AddMovimiento(CveAlmacenExA, 9, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1,
+ Observaciones:=TxtObservaciones.Text.Trim, CveAlmacenDestino:=DdlAlmacen.SelectedValue.ToEntero, CveMovimientoRelacionado:=CveMovimientoSalida,
+ Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveVendedor:=CveVendedor, CveCliente:=CveCliente, Modulo:="RE/G4")
+ FolioEntrada = ObjInventario.Folio
+
+ If Not CveMovimientoEntradaApartado > 0 Then
+ ErrorMovInv = True
+ TextoError.AppendFormat("Ocurrió un error al procesar los movimientos de traspaso de apartado. Por favor vuelva a intentar.")
+ Exit For
+ End If
+
+ Dr1("CveMovimientoEntrada") = CveMovimientoEntradaApartado
+ Dr1("FolioEntrada") = FolioEntrada
+
+ If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then
+ For Each Dr As DataRow In ObjInventario.DtResultados.Rows
+ If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntradaApartado, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, CveAF:=Dr("CveAF").ToString.ToEntero, Serie:=Dr("Serie").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, FechaCaducidad:=If(CBool(Dr("AplicaCaducidad")), Dr("FechaCaducidad").ToString.ToDate, MinFecha), Lote:=If(CBool(Dr("AplicaLote")), Dr("Lote").ToString, "-1"), CveSeccionAlmacen:=If(CBool(Dr("AplicaSeccion")), Dr("CveSeccion").ToString.ToEntero, -1)) Then
+ ErrorMovInv = True
+ TextoError.AppendFormat("Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar.")
+ Exit For
+ End If
+ Next
+ End If
+
+ If ErrorMovInv Then Exit For
+
+ Next
+ End If
+ End If
+
+ If Not ErrorMovInv Then
+ For Each DrMovto As DataRow In DtTraspasos.FiltraParametros("CveConceptoMovimientoSalida = 40").Rows
+ ErrorMovInv = Not GenerarPrePoliza(ObjInventario, ObjVentas, ObjConta, DrMovto("CveMovimientoSalida").ToString().ToEntero(), TextoError)
+ If ErrorMovInv Then
+ Exit For
+ End If
+ Next
+ End If
+
+ ''TERMINA: SIN COSTO
+
+ '' COMIENZA: APARTADOS
+ Dim CantidadPendiente As Decimal = 0
+ Dim CantidadSaldo As Decimal = 0
+
+
+ If Not ErrorMovInv AndAlso CveVendedor > 0 AndAlso (UsuarioActual.Empresa.Funcionalidad(146) = "1" Or CveCliente > 0) Then 'no debe considerar cuando es pedido de contrato
+ If TipoMovimiento = 1 Then ' SI ES DEVOLUCION NO APLICA APARTADO
+ ' SALIDA POR TRASPASO DE LOS ALMACENES DE APARTADO
+ For Each Dr As DataRow In DtDatos.Rows
+ If Dr("CantidadGV").ToString.ToDecimal > 0 Then
+
+ If CBool(Dr("AplicaSerie")) Then
+
+ DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Dr("Consec")))
+ For Each Dr1 As DataRow In DtDetalle.Rows
+ If ObjInventario.GetExistenciasProducto(Dr1("CvePS").ToString.ToEntero, Dr1("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, -1, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), Serie:=Dr1("Serie").ToString, CveTipoAlmacen:=9, CveVendedor:=CveVendedor, CveSubProyecto:=CveSubProyecto, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeApartados:=-1, Caducidad:=If(CBool(Dr("AplicaCaducidad")), Dr("FechaCaducidad").ToString.ToDate, MinFecha), Lote:=If(CBool(Dr("AplicaLote")), Dr("Lote").ToString, "-1"), CveSeccionAlmacen:=If(CBool(Dr("AplicaSeccion")), Dr("CveSeccion").ToString.ToEntero, -1)) Then
+ For Each Dr2 As DataRow In ObjInventario.DtResultados.FiltraParametros("CveAlmacen > 0 AND ExistenciaFinal > 0").Rows
+
+ 'BUSCA SI EXISTE YA UN TRASPASO DEL ALMACEN DE APARTADO
+ CveMovimientoSalida = DtTraspasos.FiltroPrimeroValor("CveMovimientoSalida", $"CveAlmacen = {Dr2("CveAlmacen")}").ToEntero
+
+ If Not CveMovimientoSalida > 0 Then
+ CveMovimientoSalida = ObjInventario.AddMovimiento(Dr2("CveAlmacen").ToString.ToEntero, 8, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1,
+ Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveVendedor:=CveVendedor, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente),
+ CveAlmacenDestino:=DdlAlmacen.SelectedValue.ToEntero, Modulo:="RE/G1")
+ FolioSalida = ObjInventario.Folio
+
+ If Not CveMovimientoSalida > 0 Then
+ ErrorMovInv = True
+ TextoError.AppendFormat("Ocurrió un error al procesar los movimientos de traspaso de apartado. Por favor vuelva a intentar.")
+ Exit For
+ End If
+
+ Dim DrMovto = DtTraspasos.NewRow
+ DrMovto("Almacen") = Dr2("Almacen").ToString.ToEntero
+ DrMovto("CveAlmacen") = Dr2("CveAlmacen").ToString.ToEntero
+ DrMovto("CveMovimientoSalida") = CveMovimientoSalida
+ DrMovto("FolioSalida") = FolioSalida
+ DrMovto("CveTipoAlmacen") = 9
+ DrMovto("CveConceptoMovimientoSalida") = 8
+ DtTraspasos.Rows.Add(DrMovto)
+ End If
+
+
+ CantidadPendiente = 1
+
+ If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, CantidadPendiente.ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0, Serie:=Dr1("Serie").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, FechaCaducidad:=If(CBool(Dr("AplicaCaducidad")), Dr("FechaCaducidad").ToString.ToDate, MinFecha), Lote:=If(CBool(Dr("AplicaLote")), Dr("Lote").ToString, "-1"), CveSeccionAlmacen:=If(CBool(Dr("AplicaSeccion")), Dr("CveSeccion").ToString.ToEntero, -1)) Then
+ ErrorMovInv = True
+ TextoError.AppendFormat("Ocurrió un Error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar.")
+ Exit For
+ End If
+
+ DtDatosDetalle.Select($"Consec = {Dr1("Consec")}")(0)("FueTraspaso") = 1
+ DtDatosDetalle.Select($"Consec = {Dr1("Consec")}")(0)("CveVentaDetalle") = Dr("CveVentaDetalle")
+ Dr("CantidadTraspaso") = Dr("CantidadTraspaso").ToString.ToDecimal + CantidadPendiente
+ Exit For
+ Next
+ End If
+ If ErrorMovInv Then Exit For
+ Next
+
+ ElseIf CBool(Dr("AplicaLote")) Then
+
+ DtDetalle = DtDatosDetalleLote.FiltraParametros(String.Format("ConsecId = {0}", Dr("Consec")))
+ For Each Dr1 As DataRow In DtDetalle.Rows
+ If ObjInventario.GetExistenciasProducto(Dr1("CvePS").ToString.ToEntero, Dr1("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, -1, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), Lote:=Dr1("Lote").ToString, CveTipoAlmacen:=9, CveVendedor:=CveVendedor, CveSubProyecto:=CveSubProyecto, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeApartados:=-1, Caducidad:=If(CBool(Dr("AplicaCaducidad")), Dr("FechaCaducidad").ToString.ToDate, MinFecha), CveSeccionAlmacen:=If(CBool(Dr("AplicaSeccion")), Dr("CveSeccion").ToString.ToEntero, -1)) Then
+
+ CantidadSaldo = Dr("CantidadGV").ToString.ToDecimal
+
+ For Each Dr2 As DataRow In ObjInventario.DtResultados.FiltraParametros("CveAlmacen > 0 AND ExistenciaFinal > 0").Rows
+
+ 'BUSCA SI EXISTE YA UN TRASPASO DEL ALMACEN DE APARTADO
+ CveMovimientoSalida = DtTraspasos.FiltroPrimeroValor("CveMovimientoSalida", $"CveAlmacen = {Dr2("CveAlmacen")}").ToEntero
+
+ If Not CveMovimientoSalida > 0 Then
+ CveMovimientoSalida = ObjInventario.AddMovimiento(Dr2("CveAlmacen").ToString.ToEntero, 8, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim,
+ Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveVendedor:=CveVendedor, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente),
+ CveAlmacenDestino:=DdlAlmacen.SelectedValue.ToEntero, Modulo:="RE/G2")
+ FolioSalida = ObjInventario.Folio
+
+ If Not CveMovimientoSalida > 0 Then
+ ErrorMovInv = True
+ TextoError.AppendFormat("Ocurrió un error al procesar los movimientos de traspaso de apartado. Por favor vuelva a intentar.")
+ Exit For
+ End If
+
+ Dim DrMovto = DtTraspasos.NewRow
+ DrMovto("Almacen") = Dr2("Almacen").ToString.ToEntero
+ DrMovto("CveAlmacen") = Dr2("CveAlmacen").ToString.ToEntero
+ DrMovto("CveMovimientoSalida") = CveMovimientoSalida
+ DrMovto("FolioSalida") = FolioSalida
+ DrMovto("CveTipoAlmacen") = 9
+ DrMovto("CveConceptoMovimientoSalida") = 8
+ DtTraspasos.Rows.Add(DrMovto)
+ End If
+
+ CantidadPendiente = If(Dr1("Cantidad").ToString.ToDecimal > CantidadSaldo, CantidadSaldo, Dr1("Cantidad").ToString.ToDecimal)
+
+ If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, CantidadPendiente.ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0, Lote:=Dr1("Lote").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, FechaCaducidad:=If(CBool(Dr("AplicaCaducidad")), Dr("FechaCaducidad").ToString.ToDate, MinFecha), CveSeccionAlmacen:=If(CBool(Dr("AplicaSeccion")), Dr("CveSeccion").ToString.ToEntero, -1)) Then
+ ErrorMovInv = True
+ TextoError.AppendFormat("Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar.")
+ Exit For
+ End If
+
+ DtDatosDetalle.Select($"Consec = {Dr1("Consec")}")(0)("FueTraspaso") = 1
+ DtDatosDetalle.Select($"Consec = {Dr1("Consec")}")(0)("CveVentaDetalle") = Dr("CveVentaDetalle")
+
+ CantidadSaldo -= CantidadPendiente
+ Dr("CantidadTraspaso") = Dr("CantidadTraspaso").ToString.ToDecimal + CantidadPendiente
+ If CantidadSaldo <= 0 Then Exit For
+ Next
+ End If
+ Next
+
+ Else
+
+ If ObjInventario.GetExistenciasProducto(Dr("CvePS").ToString.ToEntero, Dr("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, -1, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), CveTipoAlmacen:=9, CveVendedor:=CveVendedor, CveSubProyecto:=CveSubProyecto, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeApartados:=-1, Caducidad:=If(CBool(Dr("AplicaCaducidad")), Dr("FechaCaducidad").ToString.ToDate, MinFecha), Lote:=If(CBool(Dr("AplicaLote")), Dr("Lote").ToString, "-1"), CveSeccionAlmacen:=If(CBool(Dr("AplicaSeccion")), Dr("CveSeccion").ToString.ToEntero, -1)) Then
+
+ CantidadSaldo = Dr("CantidadGV").ToString.ToDecimal
+
+ For Each Dr1 As DataRow In ObjInventario.DtResultados.FiltraParametros("CveAlmacen > 0 AND ExistenciaFinal > 0").Rows
+
+ 'BUSCA SI EXISTE YA UN TRASPASO DEL ALMACEN DE APARTADO
+ CveMovimientoSalida = DtTraspasos.FiltroPrimeroValor("CveMovimientoSalida", $"CveAlmacen = {Dr1("CveAlmacen")}").ToEntero
+
+ If Not CveMovimientoSalida > 0 Then
+ CveMovimientoSalida = ObjInventario.AddMovimiento(Dr1("CveAlmacen").ToString.ToEntero, 8, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1,
+ Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveVendedor:=CveVendedor,
+ CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), CveAlmacenDestino:=DdlAlmacen.SelectedValue.ToEntero, Modulo:="RE/G3")
+ FolioSalida = ObjInventario.Folio
+
+ If Not CveMovimientoSalida > 0 Then
+ ErrorMovInv = True
+ TextoError.AppendFormat("Ocurrió un error al procesar los movimientos de traspaso de apartado. Por favor vuelva a intentar.")
+ Exit For
+ End If
+
+ Dim DrMovto = DtTraspasos.NewRow
+ DrMovto("Almacen") = Dr1("Almacen").ToString.ToEntero
+ DrMovto("CveAlmacen") = Dr1("CveAlmacen").ToString.ToEntero
+ DrMovto("CveMovimientoSalida") = CveMovimientoSalida
+ DrMovto("FolioSalida") = FolioSalida
+ DrMovto("CveTipoAlmacen") = 9
+ DrMovto("CveConceptoMovimientoSalida") = 8
+ DtTraspasos.Rows.Add(DrMovto)
+ End If
+
+
+ CantidadPendiente = If(Dr1("ExistenciaFinal").ToString.ToDecimal > CantidadSaldo, CantidadSaldo, Dr1("ExistenciaFinal").ToString.ToDecimal)
+
+ If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, CantidadPendiente.ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0,
+ Serie:=Dr("Serie").ToString,
+ CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero,
+ FechaCaducidad:=If(CBool(Dr("AplicaCaducidad")), Dr("FechaCaducidad").ToString.ToDate, MinFecha),
+ Lote:=If(CBool(Dr("AplicaLote")), Dr("Lote").ToString, "-1"),
+ CveSeccionAlmacen:=If(CBool(Dr("AplicaSeccion")), Dr("CveSeccion").ToString.ToEntero, -1)) Then
+ ErrorMovInv = True
+ TextoError.AppendFormat("Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar.")
+ Exit For
+ End If
+
+ CantidadSaldo -= CantidadPendiente
+ Dr("CantidadTraspaso") = Dr("CantidadTraspaso").ToString.ToDecimal + CantidadPendiente
+ If CantidadSaldo <= 0 Then Exit For
+ Next
+
+ If ErrorMovInv Then Exit For
+ Else
+ ErrorMovInv = True
+ End If
+
+ End If
+ If ErrorMovInv Then Exit For
+
+ End If
+
+ Next
+
+ 'ENTRADA POR TRASPASO AL ALMACEN GENERAL
+ If Not ErrorMovInv Then
+ For Each Dr1 As DataRow In DtTraspasos.Select("CveTipoAlmacen = 9")
+ CveMovimientoSalida = Dr1("CveMovimientoSalida").ToString.ToEntero
+
+ CveMovimientoEntradaApartado = ObjInventario.AddMovimiento(DdlAlmacen.SelectedValue.ToEntero, 9, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1,
+ Observaciones:=TxtObservaciones.Text.Trim, CveAlmacenDestino:=DdlAlmacen.SelectedValue.ToEntero, CveMovimientoRelacionado:=CveMovimientoSalida,
+ Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveVendedor:=CveVendedor, CveCliente:=CveCliente, Modulo:="RE/G4")
+ FolioEntrada = ObjInventario.Folio
+
+ If Not CveMovimientoEntradaApartado > 0 Then
+ ErrorMovInv = True
+ TextoError.AppendFormat("Ocurrió un error al procesar los movimientos de traspaso de apartado. Por favor vuelva a intentar.")
+ Exit For
+ End If
+
+ Dr1("CveMovimientoEntrada") = CveMovimientoEntradaApartado
+ Dr1("FolioEntrada") = FolioEntrada
+
+ If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then
+ For Each Dr As DataRow In ObjInventario.DtResultados.Rows
+ If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntradaApartado, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, CveAF:=Dr("CveAF").ToString.ToEntero, Serie:=Dr("Serie").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, FechaCaducidad:=If(CBool(Dr("AplicaCaducidad")), Dr("FechaCaducidad").ToString.ToDate, MinFecha), Lote:=If(CBool(Dr("AplicaLote")), Dr("Lote").ToString, "-1"), CveSeccionAlmacen:=If(CBool(Dr("AplicaSeccion")), Dr("CveSeccion").ToString.ToEntero, -1)) Then
+ ErrorMovInv = True
+ TextoError.AppendFormat("Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar.")
+ Exit For
+ End If
+ Next
+ End If
+
+ If ErrorMovInv Then Exit For
+
+ Next
+ End If
+ End If
+ End If
+ '' TERMINA: APARTADOS
+
+ ' COMIENZA: GARANTIAS
+ If Not ErrorMovInv AndAlso TipoDocto.Contiene("Ing", "Rem") AndAlso UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso TipoMovimiento = 1 Then
+
+ Dim CveAlmacenGarantia As Integer = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 6).FiltroPrimeroValor("CveAlmacen", $"CveSubProyecto={CveSubProyecto}").ToEntero()
+ Dim DtGarantias As DataTable = Nothing
+
+ If ObjAcumuladores.GetGarantiasDetalle(CveVentaSurtir) Then
+ DtGarantias = ObjAcumuladores.DtResultados.Copy()
+ End If
+
+ If DtGarantias IsNot Nothing AndAlso DtGarantias.Rows.Count > 0 AndAlso CveAlmacenGarantia > 0 Then
+ CveMovimientoGarantia = ObjInventario.AddMovimiento(CveAlmacenGarantia, 2, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, Modulo:="RE/G5")
+ FolioGarantia = ObjInventario.Folio
+
+ For Each RowGarantia As DataRow In DtGarantias.Rows
+ Dim CvePS = RowGarantia("CvePS").ToString().ToEntero()
+ Dim CveTamaño As Integer = RowGarantia("CveTamaño").ToString().ToEntero()
+ Dim CveUM As Integer = RowGarantia("CveUnidadMedida").ToString().ToEntero()
+ Dim PU As Decimal = RowGarantia("Importe").ToString().ToDecimal() ' / RowGarantia("Cantidad").ToString().ToDouble()
+
+ If Not ObjInventario.AddMovimientoDetalle(CveMovimientoGarantia, RowGarantia("Cantidad").ToString().ToDouble(), CveUM, CvePS, PU) Then
+ ErrorMovInv = True
+ TextoError.AppendFormat("Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar.")
+ Exit For
+ End If
+ Next
+ End If
+ End If
+ ' TERMINA: GARANTIAS
+
+ Dim CantidadPendientePorSalir As Decimal = DtDatos.SUM("CantidadGV").ToDecimal() - CantidadSalidaSinCosto
+
+ If Not ErrorMovInv AndAlso CantidadPendientePorSalir > 0 Then
+ Dim ConceptoMovimiento = 3
+ ConceptoMovimiento = If(TipoMovimiento = 1, ConceptoMovimiento, 18)
+ ConceptoMovimiento = If(CveAlmacenTraspasoDestino > 0, 8, ConceptoMovimiento)
+
+ Dim Almacen1 = DdlAlmacen.SelectedValue.ToEntero
+
+ If TipoDocto = "Rem" AndAlso CveAlmacenTraspasoDestino = 0 Then
+ ErrorMovInv = True
+ TextoError.AppendFormat("Ocurrió un error. no se tiene definido el almacen destino")
+ End If
+
+ 'DEVOLUCION REMISION
+ If TipoMovimiento = 2 And TipoDocto = "Rem" Then
+ ConceptoMovimiento = 8
+ Almacen1 = CveAlmacenTraspasoDestino
+ CveAlmacenTraspasoDestino = DdlAlmacen.SelectedValue.ToEntero
+ End If
+
+ 'CANCELACION DE DEVOLUCION
+ If TipoMovimiento = 2 And TipoDocto = "Dev" And EsDevolucionVenta = 1 Then
+ ConceptoMovimiento = 3
+ Almacen1 = DdlAlmacen.SelectedValue.ToEntero
+ CveAlmacenTraspasoDestino = DdlAlmacen.SelectedValue.ToEntero
+ End If
+
+ 'DEVOLUCION DIRECTA A ENTREGA POR ADELANTADO
+ If TipoMovimiento = 2 And ConceptoMovimiento = 18 AndAlso EsDevolucionDirecta Then
+ ConceptoMovimiento = 41
+ End If
+
+ CveMovimiento = ObjInventario.AddMovimiento(Almacen1, ConceptoMovimiento, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text,
+ CveContrato:=CveContrato, CveAlmacenDestino:=CveAlmacenTraspasoDestino, Modulo:="RE/G7")
+ Folio = ObjInventario.Folio
+
+ 'SALIDA DE ALMACEN - SALIDA POR TRASPASO CUANDO ES REMISION - DEVOLUCION (SI ES TRASPASO Y TIENE CONTRATO NO HACE DEVOLUCIóN)
+ 'If Not (CveContrato > 0 And CveAlmacenTraspasoDestino > 0) Then
+ If CveMovimiento > 0 Then
+
+ 'SACA LO DE TRASPASOS - APARTADO
+ For Each Dr1 As DataRow In DtTraspasos.Select("CveTipoAlmacen = 9")
+ CveMovimientoSalida = Dr1("CveMovimientoEntrada").ToString.ToEntero
+ If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then
+ If ObjInventario.DtResultados.Rows.Count = 0 Then
+ ErrorMovInv = True
+ TextoError.AppendFormat("Ocurrió un error, no se tienen registros que ingresar")
+ Exit Sub
+ End If
+
+ For Each Dr As DataRow In ObjInventario.DtResultados.Rows
+ If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, CveAF:=Dr("CveAF").ToString.ToEntero, Serie:=Dr("Serie").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, FechaCaducidad:=If(CBool(Dr("AplicaCaducidad")), Dr("FechaCaducidad").ToString.ToDate, MinFecha), Lote:=If(CBool(Dr("AplicaLote")), Dr("Lote").ToString, "-1"), CveSeccionAlmacen:=If(CBool(Dr("AplicaSeccion")), Dr("CveSeccion").ToString.ToEntero, -1), EsInterno:=EsInterno) Then
+ ErrorMovInv = True
+ TextoError.AppendFormat("Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar.")
+ Exit For
+ End If
+ Next
+ Else
+ ErrorMovInv = True
+ TextoError.AppendFormat("Ocurrió un error al obtener los registros")
+ End If
+ If ErrorMovInv Then Exit For
+ Next
+
+ 'ES EL MOVIMIENTO PRINCIPAL
+ CantidadPendiente = 0
+ Dim Cont As Integer = 0
+ For Each Dr As DataRow In DtDatos.Rows
+ CantidadPendiente = Dr("CantidadGV").ToString.ToDecimal - Dr("CantidadTraspaso").ToString.ToDecimal
+ If CantidadPendiente > 0 Then
+ Dim PU As Decimal = 0
+
+ 'SI FUE POR SERIE
+ DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0} AND FueTraspaso IS NULL", Dr("Consec")))
+ DtDetalleLote = DtDatosDetalleLote.FiltraParametros(String.Format("ConsecId = {0} AND FueTraspaso IS NULL", Dr("Consec")))
+ If DtDetalle.Rows.Count > 0 Then
+ For Each Dr1 As DataRow In DtDetalle.Rows
+ If TipoMovimiento = 2 AndAlso DtExistencias IsNot Nothing Then
+ PU = DtExistencias.FiltroPrimeroValor("PU", $"CvePS = {Dr("CvePS")} AND CveUM = {Dr("CveUM").ToString.ToEntero} AND Serie = '{Dr1("Serie").ToString}'").ToString.ToDecimal
+ End If
+
+ If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, 1, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, PU, Serie:=Dr1("Serie").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, FechaCaducidad:=If(CBool(Dr("AplicaCaducidad")), Dr("FechaCaducidad").ToString.ToDate, MinFecha), Lote:=If(CBool(Dr("AplicaLote")), Dr("Lote").ToString, "-1"), CveSeccionAlmacen:=If(CBool(Dr("AplicaSeccion")), Dr("CveSeccion").ToString.ToEntero, -1)) Then
+ ErrorMovInv = True
+ TextoError.AppendFormat("Ocurrió un error al procesar los conceptos con serie. Por favor vuelva a intentar.")
+ Exit For
+ End If
+ Next
+ ElseIf DtDetalleLote.Rows.Count > 0 Then
+ For Each Dr1 As DataRow In DtDetalleLote.Rows
+ If TipoMovimiento = 2 AndAlso DtExistencias IsNot Nothing Then
+ PU = DtExistencias.FiltroPrimeroValor("PU", $"CvePS = {Dr("CvePS")} AND CveUM = {Dr("CveUM").ToString.ToEntero} AND Serie = '{Dr1("Serie").ToString}'").ToString.ToDecimal
+ End If
+
+ If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr1("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, PU, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, FechaCaducidad:=If(CBool(Dr("AplicaCaducidad")), Dr("FechaCaducidad").ToString.ToDate, MinFecha), Lote:=If(CBool(Dr("AplicaLote")), Dr("Lote").ToString, "-1"), CveSeccionAlmacen:=If(CBool(Dr("AplicaSeccion")), Dr("CveSeccion").ToString.ToEntero, -1)) Then
+ ErrorMovInv = True
+ TextoError.AppendFormat("Ocurrió un error al procesar los conceptos con serie. Por favor vuelva a intentar.")
+ Exit For
+ End If
+ Next
+ Else
+ If TipoMovimiento = 2 AndAlso DtExistencias IsNot Nothing Then
+ PU = DtExistencias.FiltroPrimeroValor("PU", $"CvePS = {Dr("CvePS")} AND CveUM = {Dr("CveUM").ToString.ToEntero}").ToString.ToDecimal
+ End If
+
+ If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, CantidadPendiente, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, PU, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, FechaCaducidad:=If(CBool(Dr("AplicaCaducidad")), Dr("FechaCaducidad").ToString.ToDate, MinFecha), Lote:=If(CBool(Dr("AplicaLote")), Dr("Lote").ToString, "-1"), CveSeccionAlmacen:=If(CBool(Dr("AplicaSeccion")), Dr("CveSeccion").ToString.ToEntero, -1)) Then
+ ErrorMovInv = True
+ TextoError.AppendFormat("Ocurrió un error al procesar los conceptos de salida. Por favor vuelva a intentar.")
+ Exit For
+ End If
+ End If
+ 'If ObjInventario.CveMovimientoDetalle > 0 AndAlso DtSeccionAlmacen.Rows.Count > 0 Then
+ ' For Each Dr2 As DataRow In DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {Cont}").Rows
+ ' If Not ObjInventario.AddMovimientosDetalleSeccionesAlmacen(ObjInventario.CveMovimientoDetalle, Dr2("CveSeccionAlmacen").ToString.ToEntero, -Dr2("CantidadSeccionAlmacen").ToString.ToDecimal) Then
+ ' ErrorMovInv = True
+ ' TextoError = "Ocurrió un error al procesar las secciones de almacen. Por favor vuelva a intentar."
+ ' Exit For
+ ' End If
+ ' Next
+ 'End If
+ Cont += 1
+ End If
+ Next
+ Else
+ ErrorMovInv = True
+ End If
+
+ 'ENTRADA POR TRASPASO CUANDO ES REMISION
+ If Not ErrorMovInv Then
+ If CveAlmacenTraspasoDestino > 0 AndAlso Not (TipoMovimiento = 2 And TipoDocto = "Dev" And EsDevolucionVenta = 1) Then ' TRASPASO CUANDO ES REMISION
+ CveMovimientoEntrada = ObjInventario.AddMovimiento(CveAlmacenTraspasoDestino, 9, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, CveContrato:=CveContrato,
+ CveMovimientoRelacionado:=CveMovimiento, CveAlmacenDestino:=DdlAlmacen.SelectedValue.ToEntero, Modulo:="RE/G8")
+ FolioEntrada = ObjInventario.Folio
+
+ If CveMovimientoEntrada <= 0 Then
+ TextoError.AppendFormat("No se pudo generar el movimiento de entrada correctamente")
+ ErrorMovInv = True
+ Else
+ If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then
+ For Each Dr As DataRow In ObjInventario.DtResultados.Rows
+ If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, CveAF:=Dr("CveAF").ToString.ToEntero, CveSeccionAlmacen:=Dr("CveSeccionAlmacen").ToString.ToEntero, Serie:=Dr("Serie").ToString, Lote:=Dr("Lote").ToString, FechaCaducidad:=Dr("FechaCaducidad").ToString.ToDate, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, EsInterno:=EsInterno, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero()) Then
+ ErrorMovInv = True
+ TextoError.AppendFormat("Ocurrió un error al guardar los movimientos de entrada")
+ Exit For
+ End If
+ Next
+ Else
+ ErrorMovInv = True
+ TextoError.AppendFormat("Ocurrió un error al guardar los movimientos de entrada")
+ End If
+ End If
+
+ Else 'REGISTRO LA PREPOLIZA DE COSTO VS ALMACEN - SALIDA ALMACEN
+ ErrorMovInv = Not GenerarPrePoliza(ObjInventario, ObjVentas, ObjConta, CveMovimiento, TextoError)
+ End If
+
+ End If
+
+ End If
+
+
+ 'DEVOLUCION APARTADOS
+ If Not ErrorMovInv Then
+ If TipoMovimiento = 2 Then
+ If ObjInventario.VentasAlmacenApartadosGet(CveVentaSurtir) Then
+
+ Dim DtTempApartados = ObjInventario.DtResultados.FiltraParametros("CveTipoAlmacen = 9", "CveAlmacen")
+ Dim CveMovimientoSalidaApartado = -1
+ Dim CveAlmacenApartado = -1
+ Dim CveAlmacenOrigen = If(CveAlmacenTraspasoDestino > 0, CveAlmacenTraspasoDestino, DdlAlmacen.SelectedValue.ToEntero)
+
+ For Each Dr As DataRow In DtTempApartados.Rows
+
+ If CveMovimientoSalidaApartado = -1 Or CveAlmacenApartado <> Dr("CveAlmacen").ToString.ToEntero Then
+ CveMovimientoSalidaApartado = ObjInventario.AddMovimiento(CveAlmacenOrigen, 8, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1,
+ Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveVendedor:=CveVendedor, CveCliente:=CveCliente,
+ CveAlmacenDestino:=Dr("CveAlmacen").ToString.ToEntero, Modulo:="RE/G9")
+ FolioSalida = ObjInventario.Folio
+ CveAlmacenApartado = Dr("CveAlmacen").ToString.ToEntero
+
+ Dim DrMovto = DtTraspasos.NewRow
+ DrMovto("Almacen") = Dr("Almacen").ToString.ToEntero
+ DrMovto("CveAlmacen") = Dr("CveAlmacen").ToString.ToEntero
+ DrMovto("CveMovimientoSalida") = CveMovimientoSalidaApartado
+ DrMovto("FolioSalida") = FolioSalida
+ DtTraspasos.Rows.Add(DrMovto)
+ End If
+
+ If Not CveMovimientoSalidaApartado > 0 Then
+ ErrorMovInv = True
+ TextoError.AppendFormat("Ocurrió un error al guardar los movimientos de control de apartados")
+ Exit For
+ End If
+
+ If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalidaApartado, Dr("Cantidad").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, CveAF:=Dr("CveAF").ToString.ToEntero, Serie:=Dr("Serie").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, Lote:=Dr("Lote").ToString) Then
+ ErrorMovInv = True
+ TextoError.AppendFormat("Ocurrió un error al guardar los movimientos de control de apartados")
+ Exit For
+ End If
+ Next
+
+ If Not ErrorMovInv Then
+ For Each Dr1 As DataRow In DtTraspasos.Rows
+ CveMovimientoSalida = Dr1("CveMovimientoSalida").ToString.ToEntero
+
+ CveMovimientoEntradaApartado = ObjInventario.AddMovimiento(Dr1("CveAlmacen").ToString.ToEntero, 9, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa,
+ -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, CveAlmacenDestino:=DdlAlmacen.SelectedValue.ToEntero,
+ CveMovimientoRelacionado:=CveMovimientoSalida, Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveVendedor:=CveVendedor,
+ CveCliente:=CveCliente, Modulo:="RE/G10")
+ FolioEntrada = ObjInventario.Folio
+
+ If Not CveMovimientoEntradaApartado > 0 Then
+ ErrorMovInv = True
+ TextoError.AppendFormat("Ocurrió un error al procesar los movimientos de traspaso de apartado. Por favor vuelva a intentar.")
+ Exit For
+ End If
+
+ Dr1("CveMovimientoEntrada") = CveMovimientoEntradaApartado
+ Dr1("FolioEntrada") = FolioEntrada
+
+ If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then
+ For Each Dr As DataRow In ObjInventario.DtResultados.Rows
+ If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntradaApartado, Dr("Cantidad").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, CveAF:=Dr("CveAF").ToString.ToEntero, Serie:=Dr("Serie").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, Lote:=Dr("Lote").ToString) Then
+ ErrorMovInv = True
+ TextoError.AppendFormat("Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar.")
+ Exit For
+ End If
+ Next
+ End If
+
+ If ErrorMovInv Then Exit For
+
+ Next
+ End If
+
+ End If
+ End If
+ End If
+
+ 'QUEMAR REMISIONES
+ If Not ErrorMovInv And EsDevolucionVenta = 1 And TipoDocto = "Ing" Then
+ Dim DtDevRem As New DataTable
+
+ 'CARGA REMISIONES DE LA VENTA DEVUELTA
+ If ObjInventario.GetDevolucionRemisionesFacturadas(CveVentaSurtir) Then
+ DtDevRem = ObjInventario.DtResultados.FiltraParametros("CantidadAlmacen = 0")
+ Else
+ ErrorMovInv = True
+ End If
+
+ If Not ErrorMovInv Then
+ If DtDevRem.Rows.Count > 0 Then
+ For Each DrMovtos As DataRow In DtDevRem.FiltraParametros("", "CveRem", {"CveRem"}).Rows
+ If Not ObjInventario.ActualizarEsDevolucionVenta(DrMovtos("CveRem").ToString.ToEntero, 2) Then
+ TextoError.AppendFormat("Ocurrió un error al hacer la devolución hacia la remision. Por favor vuelva a intentar.")
+ ErrorMovInv = True
+ Exit For
+ End If
+ Next
+ End If
+ Else
+ TextoError.AppendFormat("Ocurrió un error al hacer la devolucion a remisión. Por favor vuelva a intentar.")
+ ErrorMovInv = True
+ End If
+
+ End If
+
+ 'QUEMA DEVOLUCION | QUEMA = LA QUITA DE PENDIENTE POR RECIBIR (DEVOLVER)
+ If Not ErrorMovInv And EsDevolucionVenta = 1 Then
+ If Not ObjVentas.UpdateVentasDevolucionAlmacen(2, CveVentaSurtir) Then
+ TextoError.AppendFormat("Ocurrió un error al hacer la devolución. Por favor vuelva a intentar.")
+ ErrorMovInv = True
+ End If
+ End If
+
+ If Not ErrorMovInv And EsDevolucionVenta = 0 Then
+ If Not ObjVentas.UpdateVentasDevolucionAlmacen(0, CveVentaSurtir) Then
+ TextoError.AppendFormat("Ocurrió un error al hacer la devolucion. Por favor vuelva a intentar.")
+ ErrorMovInv = True
+ End If
+ End If
+
+ ' COMIENZA: VIRTUAL
+ If Not ErrorMovInv AndAlso TipoDocto.Contiene("Ing", "Dev") AndAlso UsuarioActual.Empresa.Funcionalidad(573) = "1" AndAlso CveMovimiento > 0 Then
+ Dim DtPSVirtual As New DataTable("DtTamanios")
+
+ If ObjInventario.GetMovimientosDetalleVirtual(CveMovimiento, UsuarioActual.CveEmpresa) Then
+ DtPSVirtual = ObjInventario.DtResultados
+ End If
+
+ '
+ 'DtPSVirtual.Columns.Add(New DataColumn("CvePS", GetType(Integer)))
+ 'DtPSVirtual.Columns.Add(New DataColumn("Cantidad", GetType(Decimal)))
+ 'DtPSVirtual.Columns.Add(New DataColumn("PU", GetType(Decimal)))
+ 'DtPSVirtual.Columns.Add(New DataColumn("CveUM", GetType(Integer)))
+
+ 'Dim DtTamanios As DataTable = Nothing
+
+ 'If ObjAcumuladores.TamañoGet(-1, UsuarioActual.CveEmpresa) Then
+ ' DtTamanios = ObjAcumuladores.DtResultados.Copy()
+ 'End If
+
+ Dim CveConceptoMovimientoVirtual As Integer = -1
+ Dim CveAlmacenVirtual As Integer = -1
+ Dim CveMovimientoRelacionadoVirtual As Integer = CveMovimiento
+ Dim ValidaVirtual As Boolean = False
+ CveAlmacenVirtual = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 24).FiltroPrimeroValor("CveAlmacen", $"CveSubProyecto={CveSubProyecto}").ToEntero()
+
+ If TipoMovimiento = 1 Then
+ CveConceptoMovimientoVirtual = 37
+
+ ElseIf TipoMovimiento = 2 Then
+ ValidaVirtual = True
+ CveConceptoMovimientoVirtual = 36
+ End If
+
+ If DtPSVirtual IsNot Nothing AndAlso DtPSVirtual.Rows.Count > 0 AndAlso CveAlmacenVirtual > 0 AndAlso CveConceptoMovimientoVirtual > 0 Then
+ CveMovimientoVirtual = ObjInventario.AddMovimiento(CveAlmacenVirtual, CveConceptoMovimientoVirtual, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1,
+ Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, CveMovimientoRelacionado:=CveMovimientoRelacionadoVirtual, Modulo:="RE/G6")
+ FolioVirtual = ObjInventario.Folio
+
+ If CveMovimientoVirtual > 0 Then
+ For Each RowUsado As DataRow In DtPSVirtual.Rows
+ Dim CvePS = RowUsado("CvePS").ToString().ToEntero()
+ Dim CantidadUsado As Double = RowUsado("Cantidad").ToString().ToDouble()
+ Dim PU As Decimal = RowUsado("PU").ToString().ToDecimal()
+ Dim CveUM As Integer = RowUsado("CveUM").ToString().ToEntero()
+
+ If Not ObjInventario.AddMovimientoDetalle(CveMovimientoVirtual, CantidadUsado, CveUM, CvePS, PU) Then
+ ErrorMovInv = True
+ TextoError.AppendFormat("Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar.")
+ Exit For
+ End If
+ Next
+ Else
+ ErrorMovInv = True
+ End If
+
+ Else
+ If ValidaVirtual Then
+ ErrorMovInv = True
+ TextoError.AppendFormat("Ocurrió un error al procesar el movimiento en almacen virtual. Por favor vuelva a intentar.")
+
+ End If
+ End If
+
+ If DtPSVirtual.Rows.Count = 0 AndAlso ValidaVirtual = True Then
+ ErrorMovInv = True
+ TextoError.AppendFormat("No se tienen productos para el almacen virtual.")
+ End If
+ End If
+
+ ' TERMINA: VIRTUAL
+
+
+ 'AGREGA BITACORA A VENTA
+ If Not ErrorMovInv Then
+ Dim MensajeBitacora = If(TipoMovimiento = 1, "Surtida", "Devuelta")
+ If Not ObjEventos.AddEventoBitacora(String.Format("Venta {2} en Folio: {1}", CveMovimiento, Folio, MensajeBitacora), "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveVenta:=CveVentaSurtir) Then
+ ErrorMovInv = True
+ End If
+ End If
+
+ 'Paqueterias guias
+ If RbEntregaInterna.Checked AndAlso Not ErrorMovInv Then
+ Dim CveEstatus As Integer = DdlEstatus.SelectedValue.ToEntero()
+ Dim Fecha As String = TxtFechaPaqInterna.Text
+ Dim FechaEstimada As String = If(TxtFechaEstimada.Text = "", "-1", TxtFechaEstimada.Text)
+ Dim NoCajas As Integer = TxtNoCajas.Text.ToEntero()
+ Dim Observaciones As String = TxtObservacionesPaqInterna.Text
+ Dim CvePaqueteria As Integer = GlobalDTPaqueterias().FiltroPrimeroValor("CvePaqueteria", String.Format("CveEmpresa={0} AND TipoPaqueteria = 0", UsuarioActual.CveEmpresa)).ToEntero
+
Dim CvePaqueteriaGuia As Integer = ObjGeneral.AddPaqueteriasGuias(CvePaqueteria, 9, CveEstatus, CveSubProyecto, Fecha, "", "", NoCajas, 0.00, "-1", FechaEstimada, Observaciones, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, EsEntregaInterna:=True)
If CvePaqueteriaGuia > 0 Then
@@ -2449,381 +2576,443 @@ Partial Class Inventarios_EntregaAlmacen
ErrorMovInv = True
Alert("Error en el paqueteria guia", TipoMensaje.MsgError)
End If
- Else
- Alert("Hace falta indicar un Sub Proyecto", TipoMensaje.MsgAdvertencia)
- ErrorMovInv = True
- End If
- End If
-
- If Not ErrorMovInv Then
-
- ObjInventario.Commit()
- ObjGeneral.Dispose()
- RegistraScript("playsonidito('beep-07.wav')")
- Dim Msg As New StringBuilder
-
- Msg.AppendFormat("Movimiento {2}: {1}", CveMovimiento, Folio, If(TipoMovimiento = 1, "Salida", "Entrada"))
- Msg.AppendFormat("
Imprimir Movimiento ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimiento)))
-
- If CveMovimientoEntrada > 0 Then
- Msg.AppendFormat("
Movimiento Entrada (Traspaso): {1}", CveMovimientoEntrada, FolioEntrada)
- Msg.AppendFormat("
Imprimir Movimiento ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoEntrada)))
- End If
-
- If DtTraspasos.Rows.Count > 0 Then
- Msg.AppendFormat("
Movimientos de Control (Apartados):")
- For Each Dr As DataRow In DtTraspasos.Rows
- Msg.AppendFormat("
Almacén {0} | Salida por Traspaso: {2} | Entrada por Traspaso: {4} ", Dr("Almacen"), Dr("CveMovimientoSalida"), Dr("FolioSalida"), Dr("CveMovimientoEntrada"), Dr("FolioEntrada"))
- Next
- End If
-
- If CveMovimientoGarantia > 0 Then
- Msg.AppendFormat("
Movimiento de Entrada (garantías): {1}", CveMovimientoGarantia, FolioGarantia)
- Msg.AppendFormat("
Imprimir Movimiento ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoGarantia)))
- End If
-
- If CveMovimientoVirtual > 0 Then
- Msg.AppendFormat("
{0} Almacen Virtual: ", If(TipoMovimiento = 1, "Salida", "Entrada"))
- Msg.AppendFormat("{1}", CveMovimientoVirtual, FolioVirtual)
- Msg.AppendFormat("
Imprimir Movimiento ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoVirtual)))
- End If
-
- If RbEntregaInterna.Checked Then
- Msg.AppendFormat("
Se agregó una guía de paquetería interna")
- End If
-
- Alert(Msg.ToString, TipoMensaje.MsgInformacion)
-
- Limpia()
- CargaPendientes()
- LimpiaCampos()
- Else
- ObjInventario.RollBack()
- Alert(TextoError.ToString, TipoMensaje.MsgError)
- RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
- End If
-
- ObjAcumuladores.Dispose()
- ObjInventario.Dispose()
- ObjConta.Dispose()
- ObjVentas.Dispose()
- ObjEventos.Dispose()
-
- End Sub
-
- Private Sub GuardaTraspaso()
-
- 'OBLIGA A SURTIR TODO
- For Each Gvr As GridViewRow In GvDatos.Rows
- If Not Gvr.FCCheckBox("cbInv").Checked Or (Gvr.FCCheckBox("cbInv").Checked AndAlso Gvr.FCTextBox("TbCantidadF").Text.ToDecimal <> Gvr.DataKey("CantidadC").ToString.ToDecimal) Then
- Alert("Es necesario surtir todos los productos. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
- RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
- Exit Sub
- End If
- Next
+ End If
- Dim ValidaSeccion As Boolean = False : Dim ValidaCaducidad As Boolean = False : Dim ValidaLote As Boolean = False
- 'VALIDA CANTIDAD DE SALIDA
- Dim Cantidad As Decimal = 0.0D
- For Each Gvr As GridViewRow In GvDatos.Rows
- If CBool(Gvr.DataKey("AplicaSeccion")) AndAlso Gvr.FCDropDownList("DdlSeccionAlmacen").SelectedValue.ToEntero <= 0 Then
- ValidaSeccion = True
- End If
- If CBool(Gvr.DataKey("AplicaCaducidad")) AndAlso Gvr.FCTextBox("TxtCaducidad").Text.Trim = "" Then
- ValidaCaducidad = True
- End If
- If CBool(Gvr.DataKey("AplicaLote")) AndAlso Gvr.FCTextBox("TxtLote").Text.Trim = "" Then
- ValidaLote = True
- End If
-
- If Gvr.FCCheckBox("cbInv").Checked AndAlso Gvr.FCTextBox("TbCantidadF").Text.ToDecimal > 0 Then
- Cantidad = Gvr.FCTextBox("TbCantidadF").Text.ToDecimal
- Exit For
- End If
-
- Next
-
- If ValidaSeccion Then
- Alert("La sección de almacen no ha sido especificada en todos los productos.", TipoMensaje.MsgAdvertencia)
- Exit Sub
- End If
- If ValidaCaducidad Then
- Alert("La caducidad no ha sido especificada en todos los productos.", TipoMensaje.MsgAdvertencia)
- Exit Sub
- End If
- If ValidaLote Then
- Alert("El lote de almacen no ha sido especificada en todos los productos.", TipoMensaje.MsgAdvertencia)
- Exit Sub
- End If
-
- 'VALIDA TRANSITORIO
- If ChkTransitorio.Checked Then
- If TxtResponsable.Text.Trim = "" Then
- Alert("Debe seleccionar un responsable para el traspaso transitorio.", TipoMensaje.MsgAdvertencia)
- RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')")
- If ChkTransitorio.Checked Then RegistraScript("$('#DivTransitorio').show(200);")
- Exit Sub
- End If
-
- If DdlAlmacenTransitorio.SelectedValue.ToEntero <= 0 Then
- Alert("Debe seleccionar un almacen transitorio.", TipoMensaje.MsgAdvertencia)
- RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')")
- If ChkTransitorio.Checked Then RegistraScript("$('#DivTransitorio').show(200);")
- Exit Sub
- End If
- End If
-
- Dim ObjInventario As New ClsInventarios : ObjInventario.IniciaTransacSQL()
- Dim ObjGeneral As New ClsGenerales(ObjInventario.IniciaTransacSQL())
- Dim CveMovimientoSalida As Integer
- Dim ConceptoMovimiento = 0
- Dim FolioSalida As Integer
- Dim CveMovimientoEntrada As Integer
- Dim FolioEntrada As Integer
- Dim ErrorMovInv As Boolean
- Dim DtDetalle As New DataTable
- Dim DtDetalleLote As New DataTable
- Dim TextoError = ""
-
- 'PASA DATOS DEL GV A DATATABLE PARA MANEJOR CON FOR EACH
- Dim Index = 0
- For Each gvr As GridViewRow In GvDatos.Rows
- If gvr.FCCheckBox("cbInv").Checked AndAlso gvr.FCTextBox("TbCantidadF").Text.ToDecimal > 0 Then
- DtDatos.Rows(Index)("CantidadGV") = gvr.FCTextBox("TbCantidadF").Text.ToDecimal
- DtDatos.Rows(Index)("CveSeccion") = gvr.FCDropDownList("DdlSeccionAlmacen").SelectedValue.ToEntero
- DtDatos.Rows(Index)("FechaCaducidad") = gvr.FCTextBox("TxtCaducidad").Text.ToDate
- DtDatos.Rows(Index)("Lote") = gvr.FCTextBox("TxtLote").Text
- End If
- Index += 1
- Next
-
- 'VALIDA SI HUBO CAMBIOS EN LA EXISTENCIA
- Dim DtDatosTraspaso As New DataTable
- If ObjInventario.EntregaAlmacenTraspasosGet(CveTraspasoSurtir) Then
- DtDatosTraspaso = ObjInventario.DtResultados
- End If
- Dim CantidadGV = GvDatos.Rows.Cast(Of GridViewRow)().Sum(Function(gvr) gvr.DataKey("CantidadF").ToDecimal)
- If DtDatos.SUM("CantidadF") <> DtDatosTraspaso.SUM("CantidadF") Then
- ObjInventario.RollBack()
- ObjInventario.Dispose()
- CargaTraspasoPorSurtir(CveTraspasoSurtir)
- CargaPendientes()
- Alert("Ha sido cambiada la informacion de existencias del traspaso actual. Por favor verifique.", TipoMensaje.MsgAdvertencia)
- Exit Sub
- End If
-
- 'VALIDA QUE EL TRASPASO SIGA VIGENTE
- If ObjInventario.AddTrasladoSolicitudGet(CveTraspasoSurtir, UsuarioActual.CveEmpresa) AndAlso ObjInventario.DtResultados.Rows.Count > 0 AndAlso ObjInventario.DtResultados.Rows(0)("CveTrasladoEstatus").ToString = "2" Then
- ObjInventario.RollBack()
- ObjInventario.Dispose()
- CargaTraspasoPorSurtir(CveTraspasoSurtir)
- CargaPendientes()
- Alert("Ha sido cambiada la informacion del traspaso actual. Por favor verifique.", TipoMensaje.MsgAdvertencia)
- Exit Sub
- End If
-
- 'VALIDA ALMACENES
- Dim Almacen1 = DdlAlmacen.SelectedValue.ToEntero
- Dim Almacen2 = CveAlmacenTraspasoDestino
- If Almacen1 <= 0 Or Almacen2 <= 0 Then
- Alert("Ocurrió un error al obtener los almacenes del movimiento. Por favor recargue y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
- ObjInventario.RollBack()
- ObjInventario.Dispose()
- Exit Sub
- End If
-
- 'VERIFICAR EXISTENCIA
- Dim StrXML As New StringBuilder
- Dim Lote As String = ""
- Dim FechaCaducidad As Date
- StrXML.Append("")
- For Each Dr As DataRow In DtDatos.Rows
- FechaCaducidad = If(CBool(Dr("AplicaCaducidad")) AndAlso Dr("FechaCaducidad").ToString <> "", Dr("FechaCaducidad").ToString.ToDate, MinFecha)
- Lote = If(CBool(Dr("AplicaLote")), Dr("Lote").ToString, "-1")
-
- If Dr("CantidadGV").ToString.ToDecimal > 0 Then
- If CBool(Dr("AplicaSerie")) Then
- DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Dr("Consec")))
- For Each Dr1 As DataRow In DtDetalle.Rows
- StrXML.AppendFormat("", Dr1("CvePS"), Dr1("CveUM"), 1, IfNull(Dr("CveSeccion"), -1), Dr1("Serie"), Lote, FechaCaducidad.ToString("yyyy/MM/dd"))
- Next
- Else
- StrXML.AppendFormat("", Dr("CvePS"), Dr("CveUM"), Dr("CantidadGV"), IfNull(Dr("CveSeccion"), -1), "-1", Lote, FechaCaducidad.ToString("yyyy/MM/dd"))
- End If
- End If
- Next
- StrXML.Append("")
-
- Dim TieneErrorExistencia = False
- If ObjInventario.GetExistenciasPSXML(StrXML.ToString(), DdlAlmacen.SelectedValue.ToEntero, TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), CveSubProyecto, CveVendedor, If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), If(TipoEntrega = 2, 1, -1), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
- If ObjInventario.DtResultados.Rows.Count > 0 Then
- TieneErrorExistencia = True
- For Each Dr As DataRow In ObjInventario.DtResultados.Rows
- TextoError += $" - {Dr("CodigoPS")} Existencia: {Dr("Existencia").ToString.ToDecimal.ToString("#,##0.##")}
"
- Next
- End If
- Else
- TieneErrorExistencia = True
- End If
-
- If TieneErrorExistencia Then
- ObjInventario.RollBack()
- ObjInventario.Dispose()
- If TextoError.Length > 0 Then
- Alert($" Lo(s) siguiente(s) Productos no tienen existencia suficiente:
{TextoError}", TipoMensaje.MsgAdvertencia)
- End If
- RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
- Exit Sub
- End If
-
- 'SALIDA POR TRASPASO
- If Not ErrorMovInv Then
- ConceptoMovimiento = 26
- CveMovimientoSalida = ObjInventario.AddMovimiento(Almacen1, ConceptoMovimiento, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Guia:="",
- CveContrato:=-1, CveAlmacenDestino:=CveAlmacenTraspasoDestino, Recibio:=If(ChkTransitorio.Checked, TxtResponsable.Text.Trim, ""), Modulo:="RE/GT")
- FolioSalida = ObjInventario.Folio
- If CveMovimientoSalida > 0 Then
- Dim CantidadPendiente As Decimal = 0
- Dim CveSeccionAlmacen As Integer = -1
-
- For Each Dr As DataRow In DtDatos.Rows
- FechaCaducidad = If(CBool(Dr("AplicaCaducidad")) AndAlso Dr("FechaCaducidad").ToString <> "", Dr("FechaCaducidad").ToString.ToDate, MinFecha)
- Lote = If(CBool(Dr("AplicaLote")), Dr("Lote").ToString, "-1")
- CveSeccionAlmacen = If(CBool(Dr("AplicaSeccion")), Dr("CveSeccion").ToString.ToEntero, -1)
-
- DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0} AND FueTraspaso IS NULL", Dr("Consec")))
- DtDetalleLote = DtDatosDetalleLote.FiltraParametros(String.Format("ConsecId = {0} AND FueTraspaso IS NULL", Dr("Consec")))
- If DtDetalle.Rows.Count > 0 Then 'SI FUE POR SERIE
- For Each Dr1 As DataRow In DtDetalle.Rows
- If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, 1, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0, Serie:=Dr1("Serie").ToString, Lote:=Lote, FechaCaducidad:=FechaCaducidad, CveSeccionAlmacen:=CveSeccionAlmacen, CveVentaDetalle:=-1, CveContratoDetalle:=Dr("CveContratoDetalle").ToString.ToEntero) Then
- ErrorMovInv = True
- TextoError = "Ocurrió un error al procesar los conceptos con serie. Por favor vuelva a intentar."
- Exit For
- End If
- Next
- ElseIf DtDetalleLote.Rows.Count > 0 Then 'SI FUE POR LOTE BATCH
- For Each Dr1 As DataRow In DtDetalleLote.Rows
- If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Dr1("Cantidad").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0, Serie:="", Lote:=Dr1("Lote").ToString, FechaCaducidad:=FechaCaducidad, CveSeccionAlmacen:=CveSeccionAlmacen, CveVentaDetalle:=-1, CveContratoDetalle:=Dr("CveContratoDetalle").ToString.ToEntero) Then
- ErrorMovInv = True
- TextoError = "Ocurrió un error al procesar los conceptos con serie. Por favor vuelva a intentar."
- Exit For
- End If
- Next
- Else 'NORMAL
- If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Dr("CantidadGV").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0, -1, FechaCaducidad:=FechaCaducidad, CveSeccionAlmacen:=CveSeccionAlmacen, CveContratoDetalle:=Dr("CveContratoDetalle").ToString.ToEntero) Then
- ErrorMovInv = True
- TextoError = "Ocurrió un error al procesar los conceptos de salida. Por favor vuelva a intentar."
- Exit For
- End If
- End If
- Next
- Else
- TextoError = "Ocurrió un error al generar el movimiento de salida."
- ErrorMovInv = True
- End If
- End If
-
- 'ENTRADA POR TRASPASO
- If Not ErrorMovInv Then
- 'sino es transitorio, los transitorios, ya no se hace otro movimiento
- If Not ChkTransitorio.Checked Then
- ConceptoMovimiento = 27 ' If(ChkTransitorio.Checked, 2, 27)
- Almacen2 = If(ChkTransitorio.Checked, DdlAlmacenTransitorio.SelectedValue.ToEntero, CveAlmacenTraspasoDestino)
- CveMovimientoEntrada = ObjInventario.AddMovimiento(Almacen2, ConceptoMovimiento, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservaciones.Text.Trim,
- Guia:="", CveContrato:=CveContrato, CveMovimientoRelacionado:=CveMovimientoSalida, CveAlmacenDestino:=CveAlmacenTraspasoDestino,
- Recibio:=If(ChkTransitorio.Checked, TxtResponsable.Text.Trim, ""), Modulo:="RE/GT1")
- FolioEntrada = ObjInventario.Folio
- If CveMovimientoEntrada > 0 Then
- If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then
- Dim CveSeccionAlmacen As Integer = -1
- For Each Dr As DataRow In ObjInventario.DtResultados.Rows
- If CBool(Dr("AplicaSeccion")) Then
- CveSeccionAlmacen = GlobalDTInvPSSeccionesAlmacen(UsuarioActual.CveEmpresa, Almacen2, Dr("CvePS").ToString.ToEntero).FiltroPrimeroValor("CveSeccionAlmacen").ToEntero
- Else
- CveSeccionAlmacen = -1
+ Catch ex As Exception
+ ErrorMovInv = True
+ OnError("Ocurrió un error al guardar", ex)
+ End Try
+
+ If Not ErrorMovInv Then
+
+ ObjInventario.Commit()
+ ObjGeneral.Dispose()
+ RegistraScript("playsonidito('beep-07.wav')")
+ Dim Msg As New StringBuilder
+
+ Msg.AppendFormat("Movimiento {2}: {1}", CveMovimiento, Folio, If(TipoMovimiento = 1, "Salida", "Entrada"))
+ Msg.AppendFormat("
Imprimir Movimiento ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimiento)))
+
+ If CveMovimientoEntrada > 0 Then
+ Msg.AppendFormat("
Movimiento Entrada (Traspaso): {1}", CveMovimientoEntrada, FolioEntrada)
+ Msg.AppendFormat("
Imprimir Movimiento ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoEntrada)))
+ End If
+
+ If DtTraspasos.FiltraParametros("CveTipoAlmacen=9").Rows.Count > 0 Then
+ Msg.AppendFormat("
Movimientos de Control (Apartados):")
+ For Each Dr As DataRow In DtTraspasos.Rows
+ Msg.AppendFormat("
Almacén {0} | Salida por Traspaso: {2} | Entrada por Traspaso: {4} ", Dr("Almacen"), Dr("CveMovimientoSalida"), Dr("FolioSalida"), Dr("CveMovimientoEntrada"), Dr("FolioEntrada"))
+ Next
+ End If
+
+ If DtTraspasos.FiltraParametros("CveTipoAlmacen=26").Rows.Count > 0 Then
+ Msg.AppendFormat("
Movimientos de Control (Sin Costo):")
+ For Each Dr As DataRow In DtTraspasos.FiltraParametros("CveConceptoMovimientoSalida=40").Rows
+ Msg.AppendFormat("
Almacén {0} | Salida directa de almacen: {2} ", Dr("Almacen"), Dr("CveMovimientoSalida"), Dr("FolioSalida"), Dr("CveMovimientoEntrada"), Dr("FolioEntrada"))
+ Next
+ For Each Dr As DataRow In DtTraspasos.FiltraParametros("CveConceptoMovimientoSalida=8").Rows
+ Msg.AppendFormat("
Almacén {0} | Salida por Traspaso: {2} ", Dr("Almacen"), Dr("CveMovimientoSalida"), Dr("FolioSalida"), Dr("CveMovimientoEntrada"), Dr("FolioEntrada"))
+ Next
+ End If
+
+ If CveMovimientoGarantia > 0 Then
+ Msg.AppendFormat("
Movimiento de Entrada (garantías): {1}", CveMovimientoGarantia, FolioGarantia)
+ Msg.AppendFormat("
Imprimir Movimiento ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoGarantia)))
+ End If
+
+ If CveMovimientoVirtual > 0 Then
+ Msg.AppendFormat("
{0} Almacen Virtual: ", If(TipoMovimiento = 1, "Salida", "Entrada"))
+ Msg.AppendFormat("{1}", CveMovimientoVirtual, FolioVirtual)
+ Msg.AppendFormat("
Imprimir Movimiento ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoVirtual)))
+ End If
+
+ If RbEntregaInterna.Checked Then
+ Msg.AppendFormat("
Se agregó una guía de paquetería interna")
+ End If
+
+ Alert(Msg.ToString, TipoMensaje.MsgInformacion)
+
+ Limpia()
+ CargaPendientes()
+ LimpiaCampos()
+ Else
+ ObjInventario.RollBack()
+ Alert(TextoError.ToString, TipoMensaje.MsgError)
+ RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
+ End If
+
+ ObjAcumuladores.Dispose()
+ ObjInventario.Dispose()
+ ObjConta.Dispose()
+ ObjVentas.Dispose()
+ ObjEventos.Dispose()
+
+ End Sub
+
+ Private Function GenerarPrePoliza(ByRef ObjInventario As ClsInventarios, ByRef ObjVentas As ClsVentas, ByRef ObjConta As ClsContabilidad, CveMovimiento As Integer, ByRef TextoError As StringBuilder) As Boolean
+ Dim ErrorMovInv As Boolean = False
+ Dim DtCostos As DataTable = Nothing
+ Dim ValorInventario As Decimal = 0
+ If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then
+ DtCostos = ObjInventario.DtResultados
+
+ Dim tmpCostos As DataTable = DtCostos.FiltraParametros("", "", {"CveClasificacion"})
+ Dim IdCtaContableAlmacen As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", $"CveAlmacen = {DdlAlmacen.SelectedValue}").ToEntero
+ Dim CveCuentaAlmacen As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContableSIG", $"CveAlmacen = {DdlAlmacen.SelectedValue}").ToEntero
+ Dim IdCtaContable As Integer = 0
+ Dim CveCuenta As Integer = 0
+ If tmpCostos.Rows.Count > 0 Then
+
+
+ If ObjVentas.GetVenta(CveVentaSurtir, UsuarioActual.CveEmpresa) Then
+ Dim Fecha As Date = TxtFecha.Text.ToDate ' If(TipoMovimiento <> 1, TxtFecha.Text.ToDate, ObjVentas.DtResultados(0)("Fecha").ToString.ToDate)
+ Dim CveCliente As Integer = ObjVentas.DtResultados(0)("CveCliente").ToString.ToEntero
+ Dim ClienteNombre As String = ObjVentas.DtResultados(0)("ClienteNombre").ToString
+ Dim Serie As String = ObjVentas.DtResultados(0)("Serie").ToString
+ Dim TotalCosto As Decimal = DtCostos.SUMD("Total").RoundSQL()
+ Dim TotalCostoAcumulado As Decimal = 0
+ Dim cont As Integer = 1
+
+ Dim ValorMultiplicador = 1
+
+ If TipoMovimiento = 1 Then
+ ValorMultiplicador = 1
+ ElseIf TipoMovimiento = 2 Then
+ ValorMultiplicador = -1
+ ElseIf TipoMovimiento = 2 AndAlso TipoDocto.Contiene({"Dev"}) And (EsDevolucionVenta = 1) Then
+ ValorMultiplicador = 1
+ End If
+
+ Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Inventario/RecepcionEntrega", 4, TotalCosto, TotalCosto, 1, Fecha, ClienteNombre, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
+ 'Se agrega movimiento separado por la cuenta de ventas (ER)
+
+ If CvePrePoliza > 0 Then
+
+ For Each RowInv As DataRow In tmpCostos.Rows
+ ValorInventario = DtCostos.SUMD("Total", $"CveClasificacion = {RowInv("CveClasificacion")}").RoundSQL()
+ TotalCostoAcumulado += ValorInventario
+
+ 'cuando es el último movimiento y hay diferencias en los importes
+ If cont = DtCostos.FiltraParametros("", "", {"CveClasificacion"}).Rows.Count AndAlso TotalCosto <> TotalCostoAcumulado Then
+ ValorInventario = ValorInventario + (TotalCosto - TotalCostoAcumulado)
End If
- If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Dr("Cantidad").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, CveAF:=Dr("CveAF").ToString.ToEntero, CveSeccionAlmacen:=CveSeccionAlmacen, Serie:=Dr("Serie").ToString, Lote:=Dr("Lote").ToString, FechaCaducidad:=Dr("FechaCaducidad").ToString.ToDate, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then
- ErrorMovInv = True
- TextoError = "Ocurrió un error al guardar los movimientos de entrada"
- Exit For
- End If
- Next
- End If
- Else
- TextoError = "Ocurrió un error al generar el movimiento de entrada"
- ErrorMovInv = True
- End If
- End If
-
- End If
-
- 'MARCA SOLICITUD CON EL MOVIMIENTO GENERADO
- If Not ErrorMovInv Then
- If Not ObjInventario.UpdateTraspasoSolicitudMovimiento(CveTraspasoSurtir, CveMovimientoSalida) Then
- TextoError = "Ocurrió un error al vincular los movimientos con la solicitud de traspaso. Por favor verifique y vuelva a intentar"
- ErrorMovInv = True
- End If
- End If
-
- 'Paqueterias Guias
- If RbEntregaInterna.Checked AndAlso Not ErrorMovInv Then
- Dim CveEstatus As Integer = DdlEstatus.SelectedValue.ToEntero()
- Dim Fecha As String = TxtFechaPaqInterna.Text
- Dim FechaEstimada As String = If(TxtFechaEstimada.Text = "", "-1", TxtFechaEstimada.Text)
- Dim NoCajas As Integer = TxtNoCajas.Text.ToEntero()
- Dim Observaciones As String = TxtObservacionesPaqInterna.Text
- Dim CvePaqueteria As Integer = GlobalDTPaqueterias().FiltroPrimeroValor("CvePaqueteria", String.Format("CveEmpresa={0} AND TipoPaqueteria = 0", UsuarioActual.CveEmpresa)).ToEntero
-
- Dim CvePaqueteriaGuia As Integer = ObjGeneral.AddPaqueteriasGuias(CvePaqueteria, 9, CveEstatus, CveSubProyecto, Fecha, "-1", "-1", NoCajas, 0.00, "-1", FechaEstimada, Observaciones, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, EsEntregaInterna:=True)
-
- If CvePaqueteriaGuia > 0 Then
-
- If CveVentaSurtir > 0 OrElse CveSubProyecto > 0 Then
- ErrorMovInv = Not ObjGeneral.AddPaqueteriasGuiasDetalles(CvePaqueteriaGuia, CveVentaSurtir, -1, CveMovimiento, -1)
- End If
-
- If ErrorMovInv Then
- Alert("Error en el paqueteria guia detalle", TipoMensaje.MsgError)
- End If
- Else
- ErrorMovInv = True
- Alert("Error en el paqueteria guia", TipoMensaje.MsgError)
- End If
- End If
-
- If Not ErrorMovInv Then
- ObjInventario.Commit()
- ObjGeneral.Dispose()
- RegistraScript("playsonidito('beep-07.wav')")
-
- Dim Msg As New StringBuilder
- Msg.AppendFormat("Movimiento Salida: {1}", CveMovimientoSalida, FolioSalida)
- Msg.AppendFormat("
Imprimir Movimiento ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoSalida)))
-
- Msg.AppendFormat("
Movimiento Entrada (Traspaso): {1}", CveMovimientoEntrada, FolioEntrada)
- Msg.AppendFormat("
Imprimir Movimiento ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoEntrada)))
-
- If RbEntregaInterna.Checked Then
- Msg.AppendFormat("
Se agregó una guía de paquetería interna")
- End If
-
- Alert(Msg.ToString, TipoMensaje.MsgInformacion)
-
- Limpia()
- LimpiaCampos()
- CargaPendientes()
- Else
- Alert(TextoError, TipoMensaje.MsgError)
- RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
- ObjInventario.RollBack()
- End If
-
- ObjInventario.Dispose()
-
- End Sub
-
-
+ 'Concepto = String.Format("{0} - {1}", Row2("Clasificacion").ToString, Row2("SubProyecto").ToString)
+ IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaCostos", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero
+ CveCuenta = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaCostosSIG", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero
+
+ If Not ErrorMovInv Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ValorMultiplicador * ValorInventario, Serie, 69, Serie, Fecha, IdCtaContable, -1, CveVenta:=CveVentaSurtir, CveCliente:=CveCliente, CveMovimientoAlmacen:=CveMovimiento, CveSubProyecto:=CveSubProyecto, ImporteMX:=ValorMultiplicador * ValorInventario, CveCuenta:=CveCuenta, CveClasificacion:=RowInv("CveClasificacion").ToString.ToEntero) Then
+ ErrorMovInv = True
+ End If
+ End If
+
+ cont += 1
+ Next
+
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ValorMultiplicador * TotalCosto, Serie, 68, Serie, Fecha, IdCtaContableAlmacen, -1, CveVenta:=CveVentaSurtir, CveCliente:=CveCliente, CveMovimientoAlmacen:=CveMovimiento, CveSubProyecto:=CveSubProyecto, ImporteMX:=ValorMultiplicador * TotalCosto, CveCuenta:=CveCuentaAlmacen) Then
+ ErrorMovInv = True
+ End If
+
+ 'AutoConta - El movimiento 1 es el de Venta
+ Dim AutoConta As Boolean = UsuarioActual.Empresa.Funcionalidad(200) = "1"
+
+ If AutoConta And Not ErrorMovInv Then
+ Dim ObjContPaq = New ClsContPAQi(UsuarioActual.Empresa)
+
+ If IdCtaContable > 0 Then
+ If Not ObjConta.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa, ObjConta:=ObjContPaq) Then
+ Alert("Ocurrio un Error al contabilizar, pongase en contacto con Soporte Técnico")
+ ErrorMovInv = True
+ TextoError.AppendFormat("Ocurrio un Error al contabilizar, pongase en contacto con Soporte Técnico")
+ End If
+ Else
+ Alert(String.Format("No se puede contabilizar ya que falta asignación de las cuentas contables"), TipoMensaje.MsgAdvertencia)
+ End If
+
+ ObjContPaq.Dispose()
+ End If
+ Else
+ ErrorMovInv = True
+ TextoError.AppendFormat("Ocurrió un Error al ingresar la prepoliza.1")
+ End If
+ Else
+ ErrorMovInv = True
+ TextoError.AppendFormat("Ocurrió un Error al ingresar las prepolizas.2")
+ End If
+ Else
+ ErrorMovInv = True
+ TextoError.AppendFormat("Ocurrió un Error al ingresar las prepolizas.3")
+ End If
+ Else
+ ErrorMovInv = True
+ TextoError.AppendFormat("Ocurrió un Error al ingresar las prepolizas.4")
+ End If
+
+ Return Not ErrorMovInv
+ End Function
+
+ Private Sub GuardaTraspaso()
+
+ 'OBLIGA A SURTIR TODO
+ For Each Gvr As GridViewRow In GvDatos.Rows
+ If Not Gvr.FCCheckBox("cbInv").Checked Or (Gvr.FCCheckBox("cbInv").Checked AndAlso Gvr.FCTextBox("TbCantidadF").Text.ToDecimal <> Gvr.DataKey("CantidadC").ToString.ToDecimal) Then
+ Alert("Es necesario surtir todos los productos. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
+ RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
+ Exit Sub
+ End If
+ Next
+
+ 'VALIDA TRANSITORIO
+ If ChkTransitorio.Checked Then
+ If TxtResponsable.Text.Trim = "" Then
+ Alert("Debe seleccionar un responsable para el traspaso transitorio.", TipoMensaje.MsgAdvertencia)
+ RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')")
+ If ChkTransitorio.Checked Then RegistraScript("$('#DivTransitorio').show(200);")
+ Exit Sub
+ End If
+
+ If DdlAlmacenTransitorio.SelectedValue.ToEntero <= 0 Then
+ Alert("Debe seleccionar un almacen transitorio.", TipoMensaje.MsgAdvertencia)
+ RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')")
+ If ChkTransitorio.Checked Then RegistraScript("$('#DivTransitorio').show(200);")
+ Exit Sub
+ End If
+ End If
+
+ Dim ObjInventario As New ClsInventarios : ObjInventario.IniciaTransacSQL()
+ Dim ObjGeneral As New ClsGenerales(ObjInventario.IniciaTransacSQL())
+ Dim CveMovimientoSalida As Integer
+ Dim ConceptoMovimiento = 0
+ Dim FolioSalida As Integer
+ Dim CveMovimientoEntrada As Integer
+ Dim FolioEntrada As Integer
+ Dim ErrorMovInv As Boolean
+ Dim DtDetalle As New DataTable
+ Dim DtDetalleLote As New DataTable
+ Dim TextoError = ""
+
+ 'PASA DATOS DEL GV A DATATABLE PARA MANEJOR CON FOR EACH
+ Dim Index = 0
+ For Each gvr As GridViewRow In GvDatos.Rows
+ If gvr.FCCheckBox("cbInv").Checked AndAlso gvr.FCTextBox("TbCantidadF").Text.ToDecimal > 0 Then
+ DtDatos.Rows(Index)("CantidadGV") = gvr.FCTextBox("TbCantidadF").Text.ToDecimal
+ End If
+ Index += 1
+ Next
+
+ 'VALIDA SI HUBO CAMBIOS EN LA EXISTENCIA
+ Dim DtDatosTraspaso As New DataTable
+ If ObjInventario.EntregaAlmacenTraspasosGet(CveTraspasoSurtir) Then
+ DtDatosTraspaso = ObjInventario.DtResultados
+ End If
+ Dim CantidadGV = GvDatos.Rows.Cast(Of GridViewRow)().Sum(Function(gvr) gvr.DataKey("CantidadF").ToDecimal)
+ If DtDatos.SUM("CantidadF") <> DtDatosTraspaso.SUM("CantidadF") Then
+ ObjInventario.RollBack()
+ ObjInventario.Dispose()
+ CargaTraspasoPorSurtir(CveTraspasoSurtir)
+ CargaPendientes()
+ Alert("Ha sido cambiada la informacion de existencias del traspaso actual. Por favor verifique.", TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
+
+ 'VALIDA QUE EL TRASPASO SIGA VIGENTE
+ If ObjInventario.AddTrasladoSolicitudGet(CveTraspasoSurtir, UsuarioActual.CveEmpresa) AndAlso ObjInventario.DtResultados.Rows.Count > 0 AndAlso ObjInventario.DtResultados.Rows(0)("CveTrasladoEstatus").ToString = "2" Then
+ ObjInventario.RollBack()
+ ObjInventario.Dispose()
+ CargaTraspasoPorSurtir(CveTraspasoSurtir)
+ CargaPendientes()
+ Alert("Ha sido cambiada la informacion del traspaso actual. Por favor verifique.", TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
+
+ 'VALIDA ALMACENES
+ Dim Almacen1 = DdlAlmacen.SelectedValue.ToEntero
+ Dim Almacen2 = CveAlmacenTraspasoDestino
+ If Almacen1 <= 0 Or Almacen2 <= 0 Then
+ Alert("Ocurrió un error al obtener los almacenes del movimiento. Por favor recargue y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
+ ObjInventario.RollBack()
+ ObjInventario.Dispose()
+ Exit Sub
+ End If
+
+ 'VERIFICAR EXISTENCIA
+ Dim StrXML As New StringBuilder
+ Dim Lote As String = ""
+ Dim FechaCaducidad As Date
+ StrXML.Append("")
+ For Each Dr As DataRow In DtDatos.Rows
+ FechaCaducidad = If(CBool(Dr("AplicaCaducidad")) AndAlso Dr("FechaCaducidad").ToString <> "", Dr("FechaCaducidad").ToString.ToDate, MinFecha)
+ Lote = If(CBool(Dr("AplicaLote")), Dr("Lote").ToString, "-1")
+
+ If Dr("CantidadGV").ToString.ToDecimal > 0 Then
+ If CBool(Dr("AplicaSerie")) Then
+ DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Dr("Consec")))
+ For Each Dr1 As DataRow In DtDetalle.Rows
+ StrXML.AppendFormat("", Dr1("CvePS"), Dr1("CveUM"), 1, IfNull(Dr("CveSeccion"), -1), Dr1("Serie"), Lote, FechaCaducidad.ToString("yyyy/MM/dd"))
+ Next
+ Else
+ StrXML.AppendFormat("", Dr("CvePS"), Dr("CveUM"), Dr("CantidadGV"), IfNull(Dr("CveSeccion"), -1), "-1", Lote, FechaCaducidad.ToString("yyyy/MM/dd"))
+ End If
+ End If
+ Next
+ StrXML.Append("")
+
+ Dim TieneErrorExistencia = False
+ If ObjInventario.GetExistenciasPSXML(StrXML.ToString(), DdlAlmacen.SelectedValue.ToEntero, TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), CveSubProyecto, CveVendedor, If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), If(TipoEntrega = 2, 1, -1), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
+ If ObjInventario.DtResultados.Rows.Count > 0 Then
+ TieneErrorExistencia = True
+ For Each Dr As DataRow In ObjInventario.DtResultados.Rows
+ TextoError += $" - {Dr("CodigoPS")} Existencia: {Dr("Existencia").ToString.ToDecimal.ToString("#,##0.##")}
"
+ Next
+ End If
+ Else
+ TieneErrorExistencia = True
+ End If
+
+ If TieneErrorExistencia Then
+ ObjInventario.RollBack()
+ ObjInventario.Dispose()
+ If TextoError.Length > 0 Then
+ Alert($" Lo(s) siguiente(s) Productos no tienen existencia suficiente:
{TextoError}", TipoMensaje.MsgAdvertencia)
+ End If
+ RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
+ Exit Sub
+ End If
+
+ 'SALIDA POR TRASPASO
+ If Not ErrorMovInv Then
+ ConceptoMovimiento = 26
+ CveMovimientoSalida = ObjInventario.AddMovimiento(Almacen1, ConceptoMovimiento, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Guia:="",
+ CveContrato:=-1, CveAlmacenDestino:=CveAlmacenTraspasoDestino, Recibio:=If(ChkTransitorio.Checked, TxtResponsable.Text.Trim, ""), Modulo:="RE/GT")
+ FolioSalida = ObjInventario.Folio
+ If CveMovimientoSalida > 0 Then
+ Dim CantidadPendiente As Decimal = 0
+
+ For Each Dr As DataRow In DtDatos.Rows
+ DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0} AND FueTraspaso IS NULL", Dr("Consec")))
+ DtDetalleLote = DtDatosDetalleLote.FiltraParametros(String.Format("ConsecId = {0} AND FueTraspaso IS NULL", Dr("Consec")))
+ If DtDetalle.Rows.Count > 0 Then 'SI FUE POR SERIE
+ For Each Dr1 As DataRow In DtDetalle.Rows
+ If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, 1, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0, Serie:=Dr1("Serie").ToString, CveVentaDetalle:=-1, CveContratoDetalle:=Dr("CveContratoDetalle").ToString.ToEntero) Then
+ ErrorMovInv = True
+ TextoError = "Ocurrió un error al procesar los conceptos con serie. Por favor vuelva a intentar."
+ Exit For
+ End If
+ Next
+ ElseIf DtDetalleLote.Rows.Count > 0 Then 'SI FUE POR LOTE BATCH
+ For Each Dr1 As DataRow In DtDetalleLote.Rows
+ If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Dr1("Cantidad").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0, -1, Lote:=Dr1("Lote").ToString, CveVentaDetalle:=-1, CveContratoDetalle:=Dr("CveContratoDetalle").ToString.ToEntero) Then
+ ErrorMovInv = True
+ TextoError = "Ocurrió un error al procesar los conceptos con serie. Por favor vuelva a intentar."
+ Exit For
+ End If
+ Next
+ Else 'NORMAL
+ If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Dr("CantidadGV").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0, -1, -1, CveContratoDetalle:=Dr("CveContratoDetalle").ToString.ToEntero) Then
+ ErrorMovInv = True
+ TextoError = "Ocurrió un error al procesar los conceptos de salida. Por favor vuelva a intentar."
+ Exit For
+ End If
+ End If
+ Next
+ Else
+ TextoError = "Ocurrió un error al generar el movimiento de salida."
+ ErrorMovInv = True
+ End If
+ End If
+
+ 'ENTRADA POR TRASPASO
+ If Not ErrorMovInv Then
+ 'sino es transitorio, los transitorios, ya no se hace otro movimiento
+ If Not ChkTransitorio.Checked Then
+ ConceptoMovimiento = 27 ' If(ChkTransitorio.Checked, 2, 27)
+ Almacen2 = If(ChkTransitorio.Checked, DdlAlmacenTransitorio.SelectedValue.ToEntero, CveAlmacenTraspasoDestino)
+ CveMovimientoEntrada = ObjInventario.AddMovimiento(Almacen2, ConceptoMovimiento, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservaciones.Text.Trim,
+ Guia:="", CveContrato:=CveContrato, CveMovimientoRelacionado:=CveMovimientoSalida, CveAlmacenDestino:=CveAlmacenTraspasoDestino,
+ Recibio:=If(ChkTransitorio.Checked, TxtResponsable.Text.Trim, ""), Modulo:="RE/GT1")
+ FolioEntrada = ObjInventario.Folio
+ If CveMovimientoEntrada > 0 Then
+ If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then
+ For Each Dr As DataRow In ObjInventario.DtResultados.Rows
+ If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Dr("Cantidad").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, CveAF:=Dr("CveAF").ToString.ToEntero, Serie:=Dr("Serie").ToString, Lote:=Dr("Lote").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then
+ ErrorMovInv = True
+ TextoError = "Ocurrió un error al guardar los movimientos de entrada"
+ Exit For
+ End If
+ Next
+ End If
+ Else
+ TextoError = "Ocurrió un error al generar el movimiento de entrada"
+ ErrorMovInv = True
+ End If
+ End If
+
+ End If
+
+ 'MARCA SOLICITUD CON EL MOVIMIENTO GENERADO
+ If Not ErrorMovInv Then
+ If Not ObjInventario.UpdateTraspasoSolicitudMovimiento(CveTraspasoSurtir, CveMovimientoSalida) Then
+ TextoError = "Ocurrió un error al vincular los movimientos con la solicitud de traspaso. Por favor verifique y vuelva a intentar"
+ ErrorMovInv = True
+ End If
+ End If
+
+ 'Paqueterias Guias
+ If RbEntregaInterna.Checked AndAlso Not ErrorMovInv Then
+ Dim CveEstatus As Integer = DdlEstatus.SelectedValue.ToEntero()
+ Dim Fecha As String = TxtFechaPaqInterna.Text
+ Dim FechaEstimada As String = If(TxtFechaEstimada.Text = "", "-1", TxtFechaEstimada.Text)
+ Dim NoCajas As Integer = TxtNoCajas.Text.ToEntero()
+ Dim Observaciones As String = TxtObservacionesPaqInterna.Text
+ Dim CvePaqueteriaGuia As Integer = ObjGeneral.AddPaqueteriasGuias(-1, -1, CveEstatus, CveSubProyecto, Fecha, "-1", "-1", NoCajas, 0.00, "-1", FechaEstimada, Observaciones, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, EsEntregaInterna:=True)
+
+ If CvePaqueteriaGuia > 0 Then
+
+ If CveVentaSurtir > 0 OrElse CveSubProyecto > 0 Then
+ ErrorMovInv = Not ObjGeneral.AddPaqueteriasGuiasDetalles(CvePaqueteriaGuia, CveVentaSurtir, -1, CveMovimiento, -1)
+ End If
+ If ErrorMovInv Then
+ Alert("Error en el paqueteria guia detalle", TipoMensaje.MsgError)
+ End If
+ Else
+ ErrorMovInv = True
+ Alert("Error en el paqueteria guia", TipoMensaje.MsgError)
+ End If
+ End If
+
+ If Not ErrorMovInv Then
+ ObjInventario.Commit()
+ ObjGeneral.Dispose()
+ RegistraScript("playsonidito('beep-07.wav')")
+
+ Dim Msg As New StringBuilder
+ Msg.AppendFormat("Movimiento Salida: {1}", CveMovimientoSalida, FolioSalida)
+ Msg.AppendFormat("
Imprimir Movimiento ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoSalida)))
+
+ Msg.AppendFormat("
Movimiento Entrada (Traspaso): {1}", CveMovimientoEntrada, FolioEntrada)
+ Msg.AppendFormat("
Imprimir Movimiento ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoEntrada)))
+
+ If RbEntregaInterna.Checked Then
+ Msg.AppendFormat("
Se agregó una guía de paquetería interna")
+ End If
+
+ Alert(Msg.ToString, TipoMensaje.MsgInformacion)
+
+ Limpia()
+ LimpiaCampos()
+ CargaPendientes()
+ Else
+ Alert(TextoError, TipoMensaje.MsgError)
+ RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
+ ObjInventario.RollBack()
+ End If
+
+ ObjInventario.Dispose()
+
+ End Sub
+
+
Private Sub MandaCorreoEntrega(tCveVenta As Integer)
Dim Correo As New ClsSisMail()
Dim SerieFolio As String = ""
@@ -2869,443 +3058,443 @@ Partial Class Inventarios_EntregaAlmacen
MensajeEnviado = Correo.SendMail(UsuarioActual.Empresa, Destinatario, Asunto, Cuerpo.ToString())
- End Sub
- Private Sub Limpia()
-
- 'DATOS DE LA VENTA
- LbCantidad.Text = ""
- LbCliente.Text = ""
- LbObservaciones.Text = ""
- 'LbFolio.Text = ""
- HLFolio.Text = ""
-
- 'DATOS DEL MOVIMINETO
- TxtObservaciones.Text = ""
- TxtFecha.Text = Now.ToShortDateString
- DdlAlmacen.SelectedValueExist(-1)
- CargaFolios()
-
- 'VARIABLES GENERALES
- CveVentaSurtir = -1
- DtDatosDetalle = Nothing
- DtDatosDetalleLote = Nothing
- DtDatos = Nothing
-
- DivTipoCambioAdvertencia.Visible = False
-
- 'TRASPASO
- DivTransitorio1.Visible = False
- ChkTransitorio.Checked = False
- TxtResponsable.Text = ""
- DivTransitorio2.Visible = False
-
- LbSurtida.Visible = False
- TimmerRefresh.Enabled = True
- UpGenerales.Update()
- CargaGvDatos()
- End Sub
-
-#End Region
-
-#Region " TRASPASO - TRANSITORIO "
- Protected Sub ChkTransitorio_CheckedChanged(sender As Object, e As EventArgs)
-
- TxtResponsable.Text = ""
- DivTransitorio2.Visible = ChkTransitorio.Checked
-
- End Sub
-#End Region
-
-#Region "SECCION ALMACEN"
- 'Private Sub CreaDtSeccionAlmacen()
- ' DtSeccionAlmacen = New DataTable
- ' DtSeccionAlmacen.Columns.Add("CantidadSeccionAlmacen", GetType(Decimal))
- ' DtSeccionAlmacen.Columns.Add("IndexSeccionAlmacen", GetType(Integer))
- ' DtSeccionAlmacen.Columns.Add("CveSeccionAlmacen", GetType(Integer))
- ' DtSeccionAlmacen.Columns.Add("CvePS", GetType(Integer))
- ' DtSeccionAlmacen.Columns.Add("SeccionAlmacen", GetType(String))
- ' DtSeccionAlmacen.Columns.Add("Consec", GetType(Integer))
- 'End Sub
- 'Private Sub CargaDdlAlmacen()
- ' DdlSeccionAlmacen.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa, -1)
- ' DdlSeccionAlmacen.Items.Insert(0, New ListItem("Seleccione", "-1"))
- ' DdlSeccionAlmacen.DataBind()
- 'End Sub
- 'Protected Sub LnkSeccionAlmacen_Click(sender As Object, e As EventArgs)
- ' Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow)
-
- ' If Not DdlAlmacen.SelectedValue.ToEntero > 0 Then
- ' Alert("Tiene que tener seleccionado un almacen para registrar seccion almacen.", TipoMensaje.MsgAdvertencia)
- ' Exit Sub
- ' End If
-
- ' CantidadTotal = gvRow.FCTextBox("TbCantidadF").Text.ToDecimal
- ' IndexSeccionAlmacen = gvRow.RowIndex
- ' CvePS = gvRow.DataKey("CvePS").ToEntero
- ' CargaSeccionAlmacen()
- ' RegistraScript("$('#DModalSeccionAlmacen').modal()")
- 'End Sub
-
- 'Private Sub CargaSeccionAlmacen()
- ' Dim CantidadTotalSeccion As Decimal = DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {IndexSeccionAlmacen}").SUMD("CantidadSeccionAlmacen")
- ' GvSeccion.DataSource = DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {IndexSeccionAlmacen}")
- ' GvSeccion.DataBind()
-
- ' TxtCantidadSeccion.Text = ""
- ' DdlSeccionAlmacen.SelectedIndex = 0
- ' Dim CantidadRestante As Decimal = CantidadTotal - CantidadTotalSeccion
- ' If CantidadRestante = 0 Then
- ' RVTxtCantidad.MaximumValue = "1"
- ' TxtCantidadSeccion.Enabled = False
- ' Else
- ' RVTxtCantidad.MaximumValue = CantidadRestante.ToString
- ' TxtCantidadSeccion.Enabled = True
- ' End If
-
- ' If CantidadTotalSeccion > 0 Then
- ' GvDatos.Rows(IndexSeccionAlmacen).FCTextBox("TbCantidadF").Enabled = False
- ' GvDatos.Rows(IndexSeccionAlmacen).FCTextBox("TbCantidadF").ToolTip = "Cuenta con sección almacen"
-
- ' Else
- ' GvDatos.Rows(IndexSeccionAlmacen).FCTextBox("TbCantidadF").Enabled = True
- ' GvDatos.Rows(IndexSeccionAlmacen).FCTextBox("TbCantidadF").ToolTip = ""
-
- ' End If
-
- ' If DtSeccionAlmacen.SUMD("CantidadSeccionAlmacen") > 0 Then
- ' DdlAlmacen.Enabled = False
- ' DdlAlmacen.ToolTip = "Cuenta con sección almacen"
- ' Else
- ' DdlAlmacen.Enabled = True
- ' DdlAlmacen.ToolTip = ""
- ' End If
-
- ' UpModalSeccionAlmacen.Update()
- ' UpDatos.Update()
- ' UpGenerales.Update()
- 'End Sub
-
- 'Protected Sub LnkAddSeccionAlmacen_Click(sender As Object, e As EventArgs)
-
- ' Dim ObjInv As New ClsInventarios
- ' Dim CantidadDisponible As Decimal = 0
- ' If ObjInv.GetMovimientosDetalleSeccionesAlmacen(DdlSeccionAlmacen.SelectedValue.ToEntero, DdlAlmacen.SelectedValue.ToEntero,
- ' CvePS, UsuarioActual.CveEmpresa) Then
- ' If ObjInv.DtResultados.Rows.Count > 0 Then
- ' CantidadDisponible = ObjInv.DtResultados.Rows(0)("CantidadRestante").ToString.ToDecimal
- ' End If
- ' End If
- ' ObjInv.Dispose()
-
- ' CantidadDisponible -= DtSeccionAlmacen.FiltraParametros($"CvePS = {CvePS} AND CveSeccionAlmacen = {DdlSeccionAlmacen.SelectedValue}").SUMD("CantidadSeccionAlmacen")
-
- ' If TxtCantidadSeccion.Text.ToDecimal > CantidadDisponible Then
- ' Alert($"No tiene cantidad de producto suficiente en esta seccion de almacen, su cantidad restante es: {CantidadDisponible}", TipoMensaje.MsgAdvertencia)
- ' Exit Sub
- ' End If
-
- ' Dim Row As DataRow = Nothing
- ' DtSeccionAlmacen.AcceptChanges()
- ' Row = DtSeccionAlmacen.NewRow
- ' Row("CantidadSeccionAlmacen") = TxtCantidadSeccion.Text.ToDecimal
- ' Row("IndexSeccionAlmacen") = IndexSeccionAlmacen
- ' Row("CveSeccionAlmacen") = DdlSeccionAlmacen.SelectedValue.ToEntero
- ' Row("SeccionAlmacen") = DdlSeccionAlmacen.SelectedItem.Text
- ' Row("CvePS") = CvePS
- ' Row("Consec") = DtSeccionAlmacen.Rows.Count + 1
- ' DtSeccionAlmacen.Rows.Add(Row)
- ' DtSeccionAlmacen.AcceptChanges()
- ' CargaSeccionAlmacen()
- 'End Sub
-
- 'Protected Sub LnkEliminarSeccion_Click(sender As Object, e As EventArgs)
- ' Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow)
- ' Dim Index As Integer = 0
- ' For Each Dr As DataRow In DtSeccionAlmacen.Rows
- ' If Dr("Consec").ToString.ToEntero = gvRow.DataKey("Consec").ToEntero() Then
- ' Exit For
- ' End If
- ' Index += 1
- ' Next
- ' DtSeccionAlmacen.Rows.RemoveAt(Index)
- ' DtSeccionAlmacen.AcceptChanges()
- ' CargaSeccionAlmacen()
- 'End Sub
-
- 'Protected Sub LnkVerSecciones_Click(sender As Object, e As EventArgs)
- ' If Not CveVentaSurtir > 0 Then
- ' Alert("Tiene que seleccionar la venta a surtir", TipoMensaje.MsgAdvertencia)
- ' Exit Sub
- ' End If
-
- ' If Not DdlAlmacen.SelectedValue.ToEntero > 0 Then
- ' Alert("Tiene que seleccionar el almacen", TipoMensaje.MsgAdvertencia)
- ' Exit Sub
- ' End If
-
- ' Dim ObjInv As New ClsInventarios
- ' If ObjInv.GetExistenciaSeccionAlmacen(CveVentaSurtir, DdlAlmacen.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then
- ' GvVerSeccionesAlmacen.DataSource = ObjInv.DtResultados
- ' End If
- ' ObjInv.Dispose()
- ' GvVerSeccionesAlmacen.DataBind()
- ' UpVerSeccionesAlmacen.Update()
- ' RegistraScript("$('#ModalVerSeccionesAlmacen').modal()")
- 'End Sub
-
-#End Region
-
-#Region "DIVIDIR"
-
- Protected Sub Dividir(sender As Object, e As EventArgs)
- Dim index2 As Integer = 0
-
- For Each Row As DataRow In DtDatos.Rows
- Row("Seleccionado") = GvDatos.Rows(index2).FCCheckBox("cbInv").Checked
- If GvDatos.Rows(index2).FCTextBox("TbCantidadF").Text <> "" Then
- Row("CantidadSeleccionada") = GvDatos.Rows(index2).FCTextBox("TbCantidadF").Text
- End If
- If GvDatos.Rows(index2).FCTextBox("TxtLote").Text <> "" Then
- Row("Lote") = GvDatos.Rows(index2).FCTextBox("TxtLote").Text
- End If
- If GvDatos.Rows(index2).FCDropDownList("DdlSeccionAlmacen").SelectedValue <> "-1" Then
- Row("CveSeccion") = GvDatos.Rows(index2).FCDropDownList("DdlSeccionAlmacen").SelectedValue.ToEntero
- End If
- If GvDatos.Rows(index2).FCTextBox("TxtCaducidad").Text <> "" Then
- Row("FechaCaducidad") = GvDatos.Rows(index2).FCTextBox("TxtCaducidad").Text.ToDate
- End If
- index2 += 1
- Next
- DtDatos.AcceptChanges()
-
- Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, Button)).NamingContainer, GridViewRow)
- Dim Index As Integer = gvRow.RowIndex
- Dim Cantidad As String = HdnCantidadMovimiento.Value
- Dim dr1 As DataRow = DtDatos.Rows(Index)
- Dim dr As DataRow = DtDatos.NewRow
- dr.ItemArray = dr1.ItemArray
- dr1("CantidadC") = (dr1("CantidadC").ToString.ToDouble - Cantidad.ToDouble)
- Dim CantidadFOriginal As Double = dr1("CantidadF").ToString.ToDouble
- dr1("CantidadF") = (dr1("CantidadF").ToString.ToDouble - Cantidad.ToDouble)
- Dim CantidadSOriginal As Double = dr1("CantidadS").ToString.ToDouble
- dr1("CantidadS") = (CantidadSOriginal * dr1("CantidadF").ToString.ToDouble) / CantidadFOriginal
- Dim CantidadSeleccionadaOriginal As Double = dr1("CantidadSeleccionada").ToString.ToDouble
- dr1("CantidadSeleccionada") = If(CantidadSeleccionadaOriginal > dr1("CantidadF").ToString.ToDouble, dr1("CantidadF").ToString.ToDouble, CantidadSeleccionadaOriginal)
- CantidadSeleccionadaOriginal = CantidadSeleccionadaOriginal - dr1("CantidadF").ToString.ToDouble
-
- 'Dim CostoIndirectoOriginal As Double = dr1("CostoIndirecto").ToString.ToDouble
- 'dr1("CostoIndirecto") = (CostoIndirectoOriginal * dr1("CantidadF").ToString.ToDouble) / CantidadFOriginal
- 'Dim CostoIndirectoExtranjeroOriginal As Double = dr1("CostoIndirectoExtranjero").ToString.ToDouble
- 'dr1("CostoIndirectoExtranjero") = (CostoIndirectoExtranjeroOriginal * dr1("CantidadF").ToString.ToDouble) / CantidadFOriginal
-
- DtDatos.AcceptChanges()
-
- dr("CantidadC") = Cantidad.ToDouble
- dr("CantidadF") = Cantidad.ToDouble
- dr("CantidadS") = (CantidadSOriginal * dr("CantidadF").ToString.ToDouble) / CantidadFOriginal
- dr("CantidadSeleccionada") = If(CantidadSeleccionadaOriginal > 0, CantidadSeleccionadaOriginal, 0)
- dr("Seleccionado") = If(CantidadSeleccionadaOriginal > 0, True, False)
- 'dr("CostoIndirecto") = (CostoIndirectoOriginal * dr("CantidadF").ToString.ToDouble) / CantidadFOriginal
- 'dr("CostoIndirectoExtranjero") = (CostoIndirectoExtranjeroOriginal * dr("CantidadF").ToString.ToDouble) / CantidadFOriginal
- DtDatos.Rows.InsertAt(dr, Index)
- DtDatos.AcceptChanges()
-
- index2 = 1
- For Each Row As DataRow In DtDatos.Rows
- Row("Consec") = index2
- index2 += 1
- Next
- DtDatos.AcceptChanges()
-
- CargaGvDatos()
-
- index2 = 0
- For Each Row As DataRow In DtDatos.Rows
- GvDatos.Rows(index2).FCCheckBox("cbInv").Checked = CBool(Row("Seleccionado"))
- If Row("CantidadSeleccionada").ToString <> "" Then
- GvDatos.Rows(index2).FCTextBox("TbCantidadF").Text = Row("CantidadSeleccionada").ToString
- End If
- If Row("Lote").ToString <> "" Then
- GvDatos.Rows(index2).FCTextBox("TxtLote").Text = Row("Lote").ToString
- End If
- If Row("CveSeccion").ToString <> "" Then
- GvDatos.Rows(index2).FCDropDownList("DdlSeccionAlmacen").SelectedValue = Row("CveSeccion").ToString
- End If
- If Row("FechaCaducidad").ToString <> "" Then
- GvDatos.Rows(index2).FCTextBox("TxtCaducidad").Text = Row("FechaCaducidad").ToString.ToDate.ToShortDateString
- End If
- index2 += 1
- Next
-
- End Sub
-
-
-#End Region
-
-#Region " GUIAS - SABE QUE ES PORQUE NO VEO QUE SE UTILIZE EN ALGUNA PARTE - EN MIRAS DE ELIMINAR - IPP 24 AGOSTO 2017 "
- Private Sub BtnNumeroGuia_Click(sender As Object, e As EventArgs) Handles BtnNumeroGuia.Click
- Dim Objeto As New ClsInventarios
- If Objeto.UpdateMovimientoGuia(TxtGuia.Text, CveMovimiento, UsuarioActual.CveEmpresa) Then
- Alert("Se ha guardado correctamente la póliza", TipoMensaje.MsgConfirmacion)
- End If
- Objeto.Dispose()
- End Sub
-
- Private Sub GvDocs_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDocs.RowDataBound
-
- If e.Row.RowType = DataControlRowType.DataRow Then
-
- Dim ImgDownLoad As Literal = e.Row.FCLiteral("HplDown")
- Dim Adjunto As String = e.Row.DBCampo("Adjunto").ToString
- Dim ArchivoRuta As String = ""
-
- If Adjunto.Trim.Length > 0 Then
- ArchivoRuta = UsuarioActual.Empresa.Ruta & "Documentacion\Ventas\" & Adjunto
- Dim fi As New FileInfo(ArchivoRuta)
- Dim linkDescarga As String = ""
- If fi.Exists() Then
- linkDescarga = $"/Empresas/{UsuarioActual.CveEmpresa}/Documentacion/ventas/{fi.Name}"
- ImgDownLoad.Visible = True
- ImgDownLoad.Text = String.Format(" ", linkDescarga)
-
-
- End If
-
- End If
-
- End If
-
- End Sub
-#End Region
-
-#Region "SUGERENCIAS"
-
- Protected Sub BtnVerSugerencias_Click(sender As Object, e As EventArgs)
- If Not CveVentaSurtir > 0 Then
- Alert("Tiene que seleccionar la venta a surtir", TipoMensaje.MsgAdvertencia)
- Exit Sub
- End If
-
- If Not DdlAlmacen.SelectedValue.ToEntero > 0 Then
- Alert("Tiene que seleccionar el almacen", TipoMensaje.MsgAdvertencia)
- Exit Sub
- End If
-
- Dim ObjInv As New ClsInventarios
- If ObjInv.GetSugerenciasSalidaAlmacen(CveVentaSurtir, DdlAlmacen.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then
- GvSugerencias.DataSource = ObjInv.DtResultados
-
-
- DtDatosSugerencias = ObjInv.DtResultados
-
- DtDatosSugerencias.Columns.Add("Consec", GetType(Integer))
- DtDatosSugerencias.Columns.Add("CantidadGV", GetType(Double))
- DtDatosSugerencias.Columns.Add("CantidadTraspaso", GetType(Double))
-
- If Not DtDatosSugerencias.Columns.Contains("Lote") Then
- DtDatosSugerencias.Columns.Add("Lote", GetType(String))
- End If
- If Not DtDatosSugerencias.Columns.Contains("CveSeccion") Then
- DtDatosSugerencias.Columns.Add("CveSeccion", GetType(Integer))
- End If
-
- If Not DtDatosSugerencias.Columns.Contains("Seleccionado") Then
- DtDatosSugerencias.Columns.Add("Seleccionado", GetType(Boolean))
- End If
- If Not DtDatosSugerencias.Columns.Contains("CantidadSeleccionada") Then
- DtDatosSugerencias.Columns.Add("CantidadSeleccionada", GetType(Double))
- End If
-
- Dim Index = 1
- For Each Dr As DataRow In DtDatosSugerencias.Rows
- Dr("Consec") = Index
-
- Index += 1
- Next
-
- DtDatosSugerencias.AcceptChanges()
-
- If DtDatosSugerencias IsNot Nothing AndAlso DtDatosSugerencias.Rows.Count > 0 Then
- GvSugerencias.Columns(2).Visible = DtDatosSugerencias.MAX("Seccion") <> ""
- GvSugerencias.Columns(3).Visible = DtDatosSugerencias.MAX("Serie") <> ""
- GvSugerencias.Columns(4).Visible = DtDatosSugerencias.MAX("Lote") <> ""
- GvSugerencias.Columns(5).Visible = DtDatosSugerencias.MAX("FechaCaducidad") <> ""
- End If
-
-
- End If
- ObjInv.Dispose()
- GvSugerencias.DataBind()
-
- UpVerSugerencias.Update()
-
- RegistraScript("$('#ModalVerSugerencias').modal()")
- End Sub
- Protected Sub BtnAplicarSugerencias_Click(sender As Object, e As EventArgs)
-
- DtDatos = Nothing
- DtDatos = New DataTable
- DtDatos = DtDatosSugerencias
-
- DtDatosDetalle = Nothing
- CreaDtDetalle()
-
- DtDatosDetalleLote = Nothing
- CreaDtDetalleLote()
-
- CargaGvDatos()
-
- RegistraScript("$('#ModalVerSugerencias').modal('hide')")
- End Sub
-
- Protected Sub DdlAlmacen_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlAlmacen.SelectedIndexChanged
- If DdlAlmacen.SelectedValue <> "-1" Then
- CargaGvDatos()
- End If
- End Sub
-
- Protected Sub BtnImprimirSugerencias_Click(sender As Object, e As EventArgs)
- Dim LogoRutaFisica As String = String.Format("Empresas\{0}\Logo.png", UsuarioActual.CveEmpresa)
- Dim logouri = String.Format("{0}://{1}:{2}/ashx/sigfiles.ashx?P={3}", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, Encripta(LogoRutaFisica))
- Dim Imagen As New System.IO.FileInfo(String.Format("{0}Logo.png", UsuarioActual.Empresa.Ruta))
-
- Dim params As New List(Of ReportParameter)
- If Imagen.Exists Then
- params.Add(New ReportParameter("LogoPath", logouri))
- Else
- params.Add(New ReportParameter("LogoPath", ""))
- End If
- params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
- params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Usuario))
-
- ImprimirPDF("Empresas/Grales/Formatos/RepEntregaAlmacenSugerencia.rdlc", DtDatosSugerencias, params, "Equipo GPS")
- End Sub
-
-#End Region
-
-#Region "TipoEntrega"
-
- Protected Sub EntregaRadioGroup_Click(sender As Object, e As EventArgs)
- If RbEntregaExterna.Checked Then
- RegistraScript("AbrirVentana('/General/PopUpPaqueteriasGuias.aspx',800,547,'N')")
- ElseIf RbEntregaInterna.Checked Then
- RegistraScript("$('#ModalPaqueteriaInterna').modal('show')")
- 'RegistraScript($"AbrirVentana('/General/PopUpPaqueteriasGuiasInternas.aspx?CveVenta={CveVentaSurtir}&CveSubProyecto={CveSubProyecto}',800,547,'N')")
- 'CveVentaSurtir
- ElseIf RbSinEntrega.Checked Then
- LimpiaCampos()
- End If
- End Sub
-
- Protected Sub LimpiaCampos()
- DdlEstatus.SelectedValue = "1"
- TxtFechaPaqInterna.Text = ""
- TxtFechaEstimada.Text = ""
- TxtNoCajas.Text = ""
- TxtObservacionesPaqInterna.Text = ""
- UpPaqInterna.Update()
- End Sub
-#End Region
-
-
-End Class
+ End Sub
+ Private Sub Limpia()
+
+ 'DATOS DE LA VENTA
+ LbCantidad.Text = ""
+ LbCliente.Text = ""
+ LbObservaciones.Text = ""
+ 'LbFolio.Text = ""
+ HLFolio.Text = ""
+
+ 'DATOS DEL MOVIMINETO
+ TxtObservaciones.Text = ""
+ TxtFecha.Text = Now.ToShortDateString
+ DdlAlmacen.SelectedValueExist(-1)
+ CargaFolios()
+
+ 'VARIABLES GENERALES
+ CveVentaSurtir = -1
+ DtDatosDetalle = Nothing
+ DtDatosDetalleLote = Nothing
+ DtDatos = Nothing
+
+ DivTipoCambioAdvertencia.Visible = False
+
+ 'TRASPASO
+ DivTransitorio1.Visible = False
+ ChkTransitorio.Checked = False
+ TxtResponsable.Text = ""
+ DivTransitorio2.Visible = False
+
+ LbSurtida.Visible = False
+ TimmerRefresh.Enabled = True
+ UpGenerales.Update()
+ CargaGvDatos()
+ End Sub
+
+#End Region
+
+#Region " TRASPASO - TRANSITORIO "
+ Protected Sub ChkTransitorio_CheckedChanged(sender As Object, e As EventArgs)
+
+ TxtResponsable.Text = ""
+ DivTransitorio2.Visible = ChkTransitorio.Checked
+
+ End Sub
+#End Region
+
+#Region "SECCION ALMACEN"
+ 'Private Sub CreaDtSeccionAlmacen()
+ ' DtSeccionAlmacen = New DataTable
+ ' DtSeccionAlmacen.Columns.Add("CantidadSeccionAlmacen", GetType(Decimal))
+ ' DtSeccionAlmacen.Columns.Add("IndexSeccionAlmacen", GetType(Integer))
+ ' DtSeccionAlmacen.Columns.Add("CveSeccionAlmacen", GetType(Integer))
+ ' DtSeccionAlmacen.Columns.Add("CvePS", GetType(Integer))
+ ' DtSeccionAlmacen.Columns.Add("SeccionAlmacen", GetType(String))
+ ' DtSeccionAlmacen.Columns.Add("Consec", GetType(Integer))
+ 'End Sub
+ 'Private Sub CargaDdlAlmacen()
+ ' DdlSeccionAlmacen.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa, -1)
+ ' DdlSeccionAlmacen.Items.Insert(0, New ListItem("Seleccione", "-1"))
+ ' DdlSeccionAlmacen.DataBind()
+ 'End Sub
+ 'Protected Sub LnkSeccionAlmacen_Click(sender As Object, e As EventArgs)
+ ' Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow)
+
+ ' If Not DdlAlmacen.SelectedValue.ToEntero > 0 Then
+ ' Alert("Tiene que tener seleccionado un almacen para registrar seccion almacen.", TipoMensaje.MsgAdvertencia)
+ ' Exit Sub
+ ' End If
+
+ ' CantidadTotal = gvRow.FCTextBox("TbCantidadF").Text.ToDecimal
+ ' IndexSeccionAlmacen = gvRow.RowIndex
+ ' CvePS = gvRow.DataKey("CvePS").ToEntero
+ ' CargaSeccionAlmacen()
+ ' RegistraScript("$('#DModalSeccionAlmacen').modal()")
+ 'End Sub
+
+ 'Private Sub CargaSeccionAlmacen()
+ ' Dim CantidadTotalSeccion As Decimal = DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {IndexSeccionAlmacen}").SUMD("CantidadSeccionAlmacen")
+ ' GvSeccion.DataSource = DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {IndexSeccionAlmacen}")
+ ' GvSeccion.DataBind()
+
+ ' TxtCantidadSeccion.Text = ""
+ ' DdlSeccionAlmacen.SelectedIndex = 0
+ ' Dim CantidadRestante As Decimal = CantidadTotal - CantidadTotalSeccion
+ ' If CantidadRestante = 0 Then
+ ' RVTxtCantidad.MaximumValue = "1"
+ ' TxtCantidadSeccion.Enabled = False
+ ' Else
+ ' RVTxtCantidad.MaximumValue = CantidadRestante.ToString
+ ' TxtCantidadSeccion.Enabled = True
+ ' End If
+
+ ' If CantidadTotalSeccion > 0 Then
+ ' GvDatos.Rows(IndexSeccionAlmacen).FCTextBox("TbCantidadF").Enabled = False
+ ' GvDatos.Rows(IndexSeccionAlmacen).FCTextBox("TbCantidadF").ToolTip = "Cuenta con sección almacen"
+
+ ' Else
+ ' GvDatos.Rows(IndexSeccionAlmacen).FCTextBox("TbCantidadF").Enabled = True
+ ' GvDatos.Rows(IndexSeccionAlmacen).FCTextBox("TbCantidadF").ToolTip = ""
+
+ ' End If
+
+ ' If DtSeccionAlmacen.SUMD("CantidadSeccionAlmacen") > 0 Then
+ ' DdlAlmacen.Enabled = False
+ ' DdlAlmacen.ToolTip = "Cuenta con sección almacen"
+ ' Else
+ ' DdlAlmacen.Enabled = True
+ ' DdlAlmacen.ToolTip = ""
+ ' End If
+
+ ' UpModalSeccionAlmacen.Update()
+ ' UpDatos.Update()
+ ' UpGenerales.Update()
+ 'End Sub
+
+ 'Protected Sub LnkAddSeccionAlmacen_Click(sender As Object, e As EventArgs)
+
+ ' Dim ObjInv As New ClsInventarios
+ ' Dim CantidadDisponible As Decimal = 0
+ ' If ObjInv.GetMovimientosDetalleSeccionesAlmacen(DdlSeccionAlmacen.SelectedValue.ToEntero, DdlAlmacen.SelectedValue.ToEntero,
+ ' CvePS, UsuarioActual.CveEmpresa) Then
+ ' If ObjInv.DtResultados.Rows.Count > 0 Then
+ ' CantidadDisponible = ObjInv.DtResultados.Rows(0)("CantidadRestante").ToString.ToDecimal
+ ' End If
+ ' End If
+ ' ObjInv.Dispose()
+
+ ' CantidadDisponible -= DtSeccionAlmacen.FiltraParametros($"CvePS = {CvePS} AND CveSeccionAlmacen = {DdlSeccionAlmacen.SelectedValue}").SUMD("CantidadSeccionAlmacen")
+
+ ' If TxtCantidadSeccion.Text.ToDecimal > CantidadDisponible Then
+ ' Alert($"No tiene cantidad de producto suficiente en esta seccion de almacen, su cantidad restante es: {CantidadDisponible}", TipoMensaje.MsgAdvertencia)
+ ' Exit Sub
+ ' End If
+
+ ' Dim Row As DataRow = Nothing
+ ' DtSeccionAlmacen.AcceptChanges()
+ ' Row = DtSeccionAlmacen.NewRow
+ ' Row("CantidadSeccionAlmacen") = TxtCantidadSeccion.Text.ToDecimal
+ ' Row("IndexSeccionAlmacen") = IndexSeccionAlmacen
+ ' Row("CveSeccionAlmacen") = DdlSeccionAlmacen.SelectedValue.ToEntero
+ ' Row("SeccionAlmacen") = DdlSeccionAlmacen.SelectedItem.Text
+ ' Row("CvePS") = CvePS
+ ' Row("Consec") = DtSeccionAlmacen.Rows.Count + 1
+ ' DtSeccionAlmacen.Rows.Add(Row)
+ ' DtSeccionAlmacen.AcceptChanges()
+ ' CargaSeccionAlmacen()
+ 'End Sub
+
+ 'Protected Sub LnkEliminarSeccion_Click(sender As Object, e As EventArgs)
+ ' Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow)
+ ' Dim Index As Integer = 0
+ ' For Each Dr As DataRow In DtSeccionAlmacen.Rows
+ ' If Dr("Consec").ToString.ToEntero = gvRow.DataKey("Consec").ToEntero() Then
+ ' Exit For
+ ' End If
+ ' Index += 1
+ ' Next
+ ' DtSeccionAlmacen.Rows.RemoveAt(Index)
+ ' DtSeccionAlmacen.AcceptChanges()
+ ' CargaSeccionAlmacen()
+ 'End Sub
+
+ 'Protected Sub LnkVerSecciones_Click(sender As Object, e As EventArgs)
+ ' If Not CveVentaSurtir > 0 Then
+ ' Alert("Tiene que seleccionar la venta a surtir", TipoMensaje.MsgAdvertencia)
+ ' Exit Sub
+ ' End If
+
+ ' If Not DdlAlmacen.SelectedValue.ToEntero > 0 Then
+ ' Alert("Tiene que seleccionar el almacen", TipoMensaje.MsgAdvertencia)
+ ' Exit Sub
+ ' End If
+
+ ' Dim ObjInv As New ClsInventarios
+ ' If ObjInv.GetExistenciaSeccionAlmacen(CveVentaSurtir, DdlAlmacen.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then
+ ' GvVerSeccionesAlmacen.DataSource = ObjInv.DtResultados
+ ' End If
+ ' ObjInv.Dispose()
+ ' GvVerSeccionesAlmacen.DataBind()
+ ' UpVerSeccionesAlmacen.Update()
+ ' RegistraScript("$('#ModalVerSeccionesAlmacen').modal()")
+ 'End Sub
+
+#End Region
+
+#Region "DIVIDIR"
+
+ Protected Sub Dividir(sender As Object, e As EventArgs)
+ Dim index2 As Integer = 0
+
+ For Each Row As DataRow In DtDatos.Rows
+ Row("Seleccionado") = GvDatos.Rows(index2).FCCheckBox("cbInv").Checked
+ If GvDatos.Rows(index2).FCTextBox("TbCantidadF").Text <> "" Then
+ Row("CantidadSeleccionada") = GvDatos.Rows(index2).FCTextBox("TbCantidadF").Text
+ End If
+ If GvDatos.Rows(index2).FCTextBox("TxtLote").Text <> "" Then
+ Row("Lote") = GvDatos.Rows(index2).FCTextBox("TxtLote").Text
+ End If
+ If GvDatos.Rows(index2).FCDropDownList("DdlSeccionAlmacen").SelectedValue <> "-1" Then
+ Row("CveSeccion") = GvDatos.Rows(index2).FCDropDownList("DdlSeccionAlmacen").SelectedValue.ToEntero
+ End If
+ If GvDatos.Rows(index2).FCTextBox("TxtCaducidad").Text <> "" Then
+ Row("FechaCaducidad") = GvDatos.Rows(index2).FCTextBox("TxtCaducidad").Text.ToDate
+ End If
+ index2 += 1
+ Next
+ DtDatos.AcceptChanges()
+
+ Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, Button)).NamingContainer, GridViewRow)
+ Dim Index As Integer = gvRow.RowIndex
+ Dim Cantidad As String = HdnCantidadMovimiento.Value
+ Dim dr1 As DataRow = DtDatos.Rows(Index)
+ Dim dr As DataRow = DtDatos.NewRow
+ dr.ItemArray = dr1.ItemArray
+ dr1("CantidadC") = (dr1("CantidadC").ToString.ToDouble - Cantidad.ToDouble)
+ Dim CantidadFOriginal As Double = dr1("CantidadF").ToString.ToDouble
+ dr1("CantidadF") = (dr1("CantidadF").ToString.ToDouble - Cantidad.ToDouble)
+ Dim CantidadSOriginal As Double = dr1("CantidadS").ToString.ToDouble
+ dr1("CantidadS") = (CantidadSOriginal * dr1("CantidadF").ToString.ToDouble) / CantidadFOriginal
+ Dim CantidadSeleccionadaOriginal As Double = dr1("CantidadSeleccionada").ToString.ToDouble
+ dr1("CantidadSeleccionada") = If(CantidadSeleccionadaOriginal > dr1("CantidadF").ToString.ToDouble, dr1("CantidadF").ToString.ToDouble, CantidadSeleccionadaOriginal)
+ CantidadSeleccionadaOriginal = CantidadSeleccionadaOriginal - dr1("CantidadF").ToString.ToDouble
+
+ 'Dim CostoIndirectoOriginal As Double = dr1("CostoIndirecto").ToString.ToDouble
+ 'dr1("CostoIndirecto") = (CostoIndirectoOriginal * dr1("CantidadF").ToString.ToDouble) / CantidadFOriginal
+ 'Dim CostoIndirectoExtranjeroOriginal As Double = dr1("CostoIndirectoExtranjero").ToString.ToDouble
+ 'dr1("CostoIndirectoExtranjero") = (CostoIndirectoExtranjeroOriginal * dr1("CantidadF").ToString.ToDouble) / CantidadFOriginal
+
+ DtDatos.AcceptChanges()
+
+ dr("CantidadC") = Cantidad.ToDouble
+ dr("CantidadF") = Cantidad.ToDouble
+ dr("CantidadS") = (CantidadSOriginal * dr("CantidadF").ToString.ToDouble) / CantidadFOriginal
+ dr("CantidadSeleccionada") = If(CantidadSeleccionadaOriginal > 0, CantidadSeleccionadaOriginal, 0)
+ dr("Seleccionado") = If(CantidadSeleccionadaOriginal > 0, True, False)
+ 'dr("CostoIndirecto") = (CostoIndirectoOriginal * dr("CantidadF").ToString.ToDouble) / CantidadFOriginal
+ 'dr("CostoIndirectoExtranjero") = (CostoIndirectoExtranjeroOriginal * dr("CantidadF").ToString.ToDouble) / CantidadFOriginal
+ DtDatos.Rows.InsertAt(dr, Index)
+ DtDatos.AcceptChanges()
+
+ index2 = 1
+ For Each Row As DataRow In DtDatos.Rows
+ Row("Consec") = index2
+ index2 += 1
+ Next
+ DtDatos.AcceptChanges()
+
+ CargaGvDatos()
+
+ index2 = 0
+ For Each Row As DataRow In DtDatos.Rows
+ GvDatos.Rows(index2).FCCheckBox("cbInv").Checked = CBool(Row("Seleccionado"))
+ If Row("CantidadSeleccionada").ToString <> "" Then
+ GvDatos.Rows(index2).FCTextBox("TbCantidadF").Text = Row("CantidadSeleccionada").ToString
+ End If
+ If Row("Lote").ToString <> "" Then
+ GvDatos.Rows(index2).FCTextBox("TxtLote").Text = Row("Lote").ToString
+ End If
+ If Row("CveSeccion").ToString <> "" Then
+ GvDatos.Rows(index2).FCDropDownList("DdlSeccionAlmacen").SelectedValue = Row("CveSeccion").ToString
+ End If
+ If Row("FechaCaducidad").ToString <> "" Then
+ GvDatos.Rows(index2).FCTextBox("TxtCaducidad").Text = Row("FechaCaducidad").ToString.ToDate.ToShortDateString
+ End If
+ index2 += 1
+ Next
+
+ End Sub
+
+
+#End Region
+
+#Region " GUIAS - SABE QUE ES PORQUE NO VEO QUE SE UTILIZE EN ALGUNA PARTE - EN MIRAS DE ELIMINAR - IPP 24 AGOSTO 2017 "
+ Private Sub BtnNumeroGuia_Click(sender As Object, e As EventArgs) Handles BtnNumeroGuia.Click
+ Dim Objeto As New ClsInventarios
+ If Objeto.UpdateMovimientoGuia(TxtGuia.Text, CveMovimiento, UsuarioActual.CveEmpresa) Then
+ Alert("Se ha guardado correctamente la póliza", TipoMensaje.MsgConfirmacion)
+ End If
+ Objeto.Dispose()
+ End Sub
+
+ Private Sub GvDocs_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDocs.RowDataBound
+
+ If e.Row.RowType = DataControlRowType.DataRow Then
+
+ Dim ImgDownLoad As Literal = e.Row.FCLiteral("HplDown")
+ Dim Adjunto As String = e.Row.DBCampo("Adjunto").ToString
+ Dim ArchivoRuta As String = ""
+
+ If Adjunto.Trim.Length > 0 Then
+ ArchivoRuta = UsuarioActual.Empresa.Ruta & "Documentacion\Ventas\" & Adjunto
+ Dim fi As New FileInfo(ArchivoRuta)
+ Dim linkDescarga As String = ""
+ If fi.Exists() Then
+ linkDescarga = $"/Empresas/{UsuarioActual.CveEmpresa}/Documentacion/ventas/{fi.Name}"
+ ImgDownLoad.Visible = True
+ ImgDownLoad.Text = String.Format(" ", linkDescarga)
+
+
+ End If
+
+ End If
+
+ End If
+
+ End Sub
+#End Region
+
+#Region "SUGERENCIAS"
+
+ Protected Sub BtnVerSugerencias_Click(sender As Object, e As EventArgs)
+ If Not CveVentaSurtir > 0 Then
+ Alert("Tiene que seleccionar la venta a surtir", TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
+
+ If Not DdlAlmacen.SelectedValue.ToEntero > 0 Then
+ Alert("Tiene que seleccionar el almacen", TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
+
+ Dim ObjInv As New ClsInventarios
+ If ObjInv.GetSugerenciasSalidaAlmacen(CveVentaSurtir, DdlAlmacen.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then
+ GvSugerencias.DataSource = ObjInv.DtResultados
+
+
+ DtDatosSugerencias = ObjInv.DtResultados
+
+ DtDatosSugerencias.Columns.Add("Consec", GetType(Integer))
+ DtDatosSugerencias.Columns.Add("CantidadGV", GetType(Double))
+ DtDatosSugerencias.Columns.Add("CantidadTraspaso", GetType(Double))
+
+ If Not DtDatosSugerencias.Columns.Contains("Lote") Then
+ DtDatosSugerencias.Columns.Add("Lote", GetType(String))
+ End If
+ If Not DtDatosSugerencias.Columns.Contains("CveSeccion") Then
+ DtDatosSugerencias.Columns.Add("CveSeccion", GetType(Integer))
+ End If
+
+ If Not DtDatosSugerencias.Columns.Contains("Seleccionado") Then
+ DtDatosSugerencias.Columns.Add("Seleccionado", GetType(Boolean))
+ End If
+ If Not DtDatosSugerencias.Columns.Contains("CantidadSeleccionada") Then
+ DtDatosSugerencias.Columns.Add("CantidadSeleccionada", GetType(Double))
+ End If
+
+ Dim Index = 1
+ For Each Dr As DataRow In DtDatosSugerencias.Rows
+ Dr("Consec") = Index
+
+ Index += 1
+ Next
+
+ DtDatosSugerencias.AcceptChanges()
+
+ If DtDatosSugerencias IsNot Nothing AndAlso DtDatosSugerencias.Rows.Count > 0 Then
+ GvSugerencias.Columns(2).Visible = DtDatosSugerencias.MAX("Seccion") <> ""
+ GvSugerencias.Columns(3).Visible = DtDatosSugerencias.MAX("Serie") <> ""
+ GvSugerencias.Columns(4).Visible = DtDatosSugerencias.MAX("Lote") <> ""
+ GvSugerencias.Columns(5).Visible = DtDatosSugerencias.MAX("FechaCaducidad") <> ""
+ End If
+
+
+ End If
+ ObjInv.Dispose()
+ GvSugerencias.DataBind()
+
+ UpVerSugerencias.Update()
+
+ RegistraScript("$('#ModalVerSugerencias').modal()")
+ End Sub
+ Protected Sub BtnAplicarSugerencias_Click(sender As Object, e As EventArgs)
+
+ DtDatos = Nothing
+ DtDatos = New DataTable
+ DtDatos = DtDatosSugerencias
+
+ DtDatosDetalle = Nothing
+ CreaDtDetalle()
+
+ DtDatosDetalleLote = Nothing
+ CreaDtDetalleLote()
+
+ CargaGvDatos()
+
+ RegistraScript("$('#ModalVerSugerencias').modal('hide')")
+ End Sub
+
+ Protected Sub DdlAlmacen_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlAlmacen.SelectedIndexChanged
+ If DdlAlmacen.SelectedValue <> "-1" Then
+ CargaGvDatos()
+ End If
+ End Sub
+
+ Protected Sub BtnImprimirSugerencias_Click(sender As Object, e As EventArgs)
+ Dim LogoRutaFisica As String = String.Format("Empresas\{0}\Logo.png", UsuarioActual.CveEmpresa)
+ Dim logouri = String.Format("{0}://{1}:{2}/ashx/sigfiles.ashx?P={3}", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, Encripta(LogoRutaFisica))
+ Dim Imagen As New System.IO.FileInfo(String.Format("{0}Logo.png", UsuarioActual.Empresa.Ruta))
+
+ Dim params As New List(Of ReportParameter)
+ If Imagen.Exists Then
+ params.Add(New ReportParameter("LogoPath", logouri))
+ Else
+ params.Add(New ReportParameter("LogoPath", ""))
+ End If
+ params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
+ params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Usuario))
+
+ ImprimirPDF("Empresas/Grales/Formatos/RepEntregaAlmacenSugerencia.rdlc", DtDatosSugerencias, params, "Equipo GPS")
+ End Sub
+
+#End Region
+
+#Region "TipoEntrega"
+
+ Protected Sub EntregaRadioGroup_Click(sender As Object, e As EventArgs)
+ If RbEntregaExterna.Checked Then
+ RegistraScript("AbrirVentana('/General/PopUpPaqueteriasGuias.aspx',800,547,'N')")
+ ElseIf RbEntregaInterna.Checked Then
+ RegistraScript("$('#ModalPaqueteriaInterna').modal('show')")
+ 'RegistraScript($"AbrirVentana('/General/PopUpPaqueteriasGuiasInternas.aspx?CveVenta={CveVentaSurtir}&CveSubProyecto={CveSubProyecto}',800,547,'N')")
+ 'CveVentaSurtir
+ ElseIf RbSinEntrega.Checked Then
+ LimpiaCampos()
+ End If
+ End Sub
+
+ Protected Sub LimpiaCampos()
+ DdlEstatus.SelectedValue = "1"
+ TxtFechaPaqInterna.Text = ""
+ TxtFechaEstimada.Text = ""
+ TxtNoCajas.Text = ""
+ TxtObservacionesPaqInterna.Text = ""
+ UpPaqInterna.Update()
+ End Sub
+#End Region
+
+
+End Class
diff --git a/Inventarios/TraspasoAlmacen.aspx.vb b/Inventarios/TraspasoAlmacen.aspx.vb
index 752c30d04..b7bfeeb5c 100644
--- a/Inventarios/TraspasoAlmacen.aspx.vb
+++ b/Inventarios/TraspasoAlmacen.aspx.vb
@@ -532,7 +532,7 @@ Partial Class Inventarios_TraspasoAlmacen
End If
Inv.Dispose()
- If Existencia - Cantidad - CantidadEnGrid < 0 ORELSE ExistenciaEspecificada - Cantidad - CantidadEnGrid < 0 Then
+ If Existencia - Cantidad - CantidadEnGrid < 0 OrElse ExistenciaEspecificada - Cantidad - CantidadEnGrid < 0 Then
If Existencia < 0 OrElse ExistenciaEspecificada < 0 Then
Alert("No hay existencia del producto", TipoMensaje.MsgAdvertencia)
RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')")
@@ -659,7 +659,7 @@ Partial Class Inventarios_TraspasoAlmacen
Dim CveSucursalOrigen = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveSubProyecto", $"CveAlmacen = {DdlAlmacenOrigen.SelectedValue.ToEntero}")
Dim CveSucursalDestino = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveSubProyecto", $"CveAlmacen = {DdlAlmacenDestino.SelectedValue.ToEntero}")
- If GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveTipoAlmacen", $"CveAlmacen = {DdlAlmacenDestino.SelectedValue.ToEntero}").ToEntero <> 21 Then 'NO SE VALIDA CUANDO EL TIPO DE ALMACEN DESTINO ES DE DEVOLUCION
+ If Not GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveTipoAlmacen", $"CveAlmacen = {DdlAlmacenDestino.SelectedValue.ToEntero}").Contiene("21", "26") Then 'NO SE VALIDA CUANDO EL TIPO DE ALMACEN DESTINO ES DE DEVOLUCION
If CveSucursalOrigen <> CveSucursalDestino Then
Alert("Por ser un traspaso entre sucursales es necesario indicar que el traspaso es transitorio.", TipoMensaje.MsgAdvertencia)
RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'');", "SonidoError")
@@ -844,6 +844,9 @@ Partial Class Inventarios_TraspasoAlmacen
If Not ErrorMovInv Then
Dim TipoMovimientoEntrada = 27
AlmacenEntrada = If(ChkTransitorio.Checked, DdlAlmacenTransitorio.SelectedValue.ToEntero, DdlAlmacenDestino.SelectedValue.ToEntero)
+
+ Dim TipoAlmacenEntrada As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveTipoAlmacen", $"CveAlmacen = {AlmacenEntrada}").ToEntero()
+
CveMovimientoEntrada = ObjInventario.AddMovimiento(AlmacenEntrada, TipoMovimientoEntrada, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, -1, -1,
Observaciones:=TxtObservaciones.Text.Trim, Recibio:=If(ChkTransitorio.Checked, TxtResponsable.Text.Trim, "-1"),
CveAlmacenDestino:=If(ChkTransitorio.Checked, DdlAlmacenDestino.SelectedValue.ToEntero, -1), CveMovimientoRelacionado:=CveMovimientoSalida, Modulo:="TA/G3")
@@ -855,7 +858,8 @@ Partial Class Inventarios_TraspasoAlmacen
If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then
Dim Cont As Integer = 0
For Each Dr As DataRow In ObjInventario.DtResultados.Rows
- If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, CveAF:=Dr("CveAF").ToString.ToEntero, CveSeccionAlmacen:=-1, Serie:=Dr("Serie").ToString, Lote:=Dr("Lote").ToString, FechaCaducidad:=Dr("FechaCaducidad").ToString.ToDate, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, Observaciones:=Dr("Observaciones").ToString) Then
+ Dim CostoEntrada As Decimal = If(TipoAlmacenEntrada = 26, 0, Dr("PU").ToString.ToDecimal())
+ If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, CostoEntrada, CveAF:=Dr("CveAF").ToString.ToEntero, CveSeccionAlmacen:=-1, Serie:=Dr("Serie").ToString, Lote:=Dr("Lote").ToString, FechaCaducidad:=Dr("FechaCaducidad").ToString.ToDate, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, Observaciones:=Dr("Observaciones").ToString) Then
ErrorMovInv = True
TextoError = "Ocurrió un error al guardar los movimientos de entrada"
Exit For
@@ -1274,7 +1278,7 @@ Partial Class Inventarios_TraspasoAlmacen
Protected Sub GvDatos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDatos.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
- If e.Row.DBCampo("EstatusExistencia").ToEntero <0 Then
+ If e.Row.DBCampo("EstatusExistencia").ToEntero < 0 Then
e.Row.Cells(0).BackColor = Drawing.Color.Red
End If
@@ -1718,8 +1722,12 @@ Partial Class Inventarios_TraspasoAlmacen
ObjInventario.IniciaTransacSQL() 'Inicia la transacción
Dim Fecha As Date = TxtFechaRecepcion.Text.ToDate
+ Dim CveAlmacenEntrada As Integer = GvDatosRecepcion.Rows(0).DataKey("CveAlmacenDestino").ToEntero
+
+ Dim TipoAlmacenDestino As Integer = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveTipoAlmacen", $"CveAlmacen = {CveAlmacenEntrada}").ToEntero()
+
'AGREGAMOS LA ENTRADA
- CveMovimientoSalida = ObjInventario.AddMovimiento(GvDatosRecepcion.Rows(0).DataKey("CveAlmacenDestino").ToEntero, 27, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1,
+ CveMovimientoSalida = ObjInventario.AddMovimiento(CveAlmacenEntrada, 27, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1,
Observaciones:=TxtObservacionesRecepcion.Text.Trim, CveAlmacenDestino:=GvDatosRecepcion.Rows(0).DataKey("CveAlmacenSalida").ToEntero, CveMovimientoRelacionado:=CveMovimientoSalida, Modulo:="TA/G1")
Folio = ObjInventario.Folio
@@ -1751,8 +1759,8 @@ Partial Class Inventarios_TraspasoAlmacen
TextoError = "Ocurrió un error al guardar los movimientos de salida"
Exit For
End If
-
- If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, gvr.FCTextBox("TxtCantidad").Text.ToString.ToDecimal, gvr.DataKey("CveUM").ToString.ToEntero, gvr.DataKey("CvePS").ToString.ToEntero, gvr.DataKey("PU").ToString.ToDecimal, CveAF:=gvr.DataKey("CveAF").ToString.ToEntero, CveSeccionAlmacen:=gvr.FCDropDownList("DdlSeccionAlmacen").SelectedValue.ToEntero, Serie:=gvr.DataKey("Serie").ToString, Lote:=gvr.DataKey("Lote").ToString, FechaCaducidad:=gvr.DataKey("FechaCaducidad").ToDate, CveMovimientoDetalleEntrada:=CveMovimientoDetalleEntrada) Then
+ Dim PrecioEntrada As Decimal = If(TipoAlmacenDestino = 26, 0, gvr.DataKey("PU").ToString.ToDecimal)
+ If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, gvr.FCTextBox("TxtCantidad").Text.ToString.ToDecimal, gvr.DataKey("CveUM").ToString.ToEntero, gvr.DataKey("CvePS").ToString.ToEntero, PrecioEntrada, CveAF:=gvr.DataKey("CveAF").ToString.ToEntero, CveSeccionAlmacen:=gvr.FCDropDownList("DdlSeccionAlmacen").SelectedValue.ToEntero, Serie:=gvr.DataKey("Serie").ToString, Lote:=gvr.DataKey("Lote").ToString, FechaCaducidad:=gvr.DataKey("FechaCaducidad").ToDate, CveMovimientoDetalleEntrada:=CveMovimientoDetalleEntrada) Then
ErrorMovInv = True
TextoError = "Ocurrió un error al guardar los movimientos de salida"
Exit For