From 2e80d4cb9d2faf4100acd2c6a9c59e622c6b76de Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Mon, 6 Apr 2020 14:55:14 -0700 Subject: [PATCH 1/6] Ir al punto de venta si es remision en bdh --- Ventas/PopUpBuscarFolio.aspx | 3 +++ Ventas/PopUpBuscarFolio.aspx.vb | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/Ventas/PopUpBuscarFolio.aspx b/Ventas/PopUpBuscarFolio.aspx index e05a1490b..a725c5285 100644 --- a/Ventas/PopUpBuscarFolio.aspx +++ b/Ventas/PopUpBuscarFolio.aspx @@ -269,6 +269,9 @@ function Ir(v) { gotourl('/Ventas/Ventas.aspx?CveVenta=' + v); } + function IrPV(v) { + gotourl('/Ventas/PV.aspx?CveVenta=' + v); + } Sys.Application.add_load(function (s, e) { }); diff --git a/Ventas/PopUpBuscarFolio.aspx.vb b/Ventas/PopUpBuscarFolio.aspx.vb index 744463516..04777e43d 100644 --- a/Ventas/PopUpBuscarFolio.aspx.vb +++ b/Ventas/PopUpBuscarFolio.aspx.vb @@ -159,6 +159,10 @@ Partial Class PopUpBuscarFolio e.Row.Cells(4).HorizontalAlign = HorizontalAlign.Right Dim Liga As String = String.Format("", e.Row.DBCampo("CveVenta")) + If UsuarioActual.CveEmpresa = 140 AndAlso e.Row.DBCampo("TipoDocto").Contiene("Rem") Then + Liga = String.Format("", e.Row.DBCampo("CveVenta")) + End If + e.Row.FCLiteral("LtlTipo").Text = String.Format("
{0}{1}
", Liga, e.Row.DBCampo("TipoDocto")) e.Row.FCLiteral("LtlFolio").Text = String.Format("
{0}{1}
", Liga, e.Row.DBCampo("Folio")) e.Row.FCLiteral("LtlFecha").Text = String.Format("
{0}{1}
", Liga, e.Row.DBCampo("Fecha").ToDate.ToShortDateString) From edb6ee294b4461c6ca001c3a6847979d68143a37 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Mon, 6 Apr 2020 18:02:57 -0700 Subject: [PATCH 2/6] Factura para econo con rpt --- App_Code/DtDatos.xsd | 16 ++++++++++++++++ App_Code/DtDatos.xss | 25 +++++++++++++------------ 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/App_Code/DtDatos.xsd b/App_Code/DtDatos.xsd index 50aca8dd6..2d4df0230 100644 --- a/App_Code/DtDatos.xsd +++ b/App_Code/DtDatos.xsd @@ -261,6 +261,22 @@ + + + + + + + + + + + + + + + + diff --git a/App_Code/DtDatos.xss b/App_Code/DtDatos.xss index daabedb14..d278af616 100644 --- a/App_Code/DtDatos.xss +++ b/App_Code/DtDatos.xss @@ -6,18 +6,19 @@ --> - - - - - - - - - - - - + + + + + + + + + + + + + \ No newline at end of file From 2c891fec85a21801fbd27ad1e578caff6ad0a56c Mon Sep 17 00:00:00 2001 From: rrene Date: Mon, 6 Apr 2020 23:12:13 -0700 Subject: [PATCH 3/6] - cambio de mov almacen, PU a decimal --- App_Code/ClsInventarios.vb | 10 +- App_Code/ClsPaginas.vb | 2 +- App_Code/Modelos.vb | 14556 +++++++++--------- Compras/Compras.aspx.vb | 40 +- Inventarios/Apartados.aspx.vb | 6 +- Inventarios/Consignaciones.aspx.vb | 12 +- Inventarios/EntradasSalidas.aspx.vb | 8194 +++++----- Inventarios/KardexSeccionAlmacen.aspx.vb | 665 +- Inventarios/PaquetesArmadoDesarmado.aspx.vb | 10 +- Inventarios/RecepcionAlmacen.aspx.vb | 5740 +++---- Inventarios/RecepcionEntrega.aspx.vb | 10 +- Inventarios/RecepcionUsados.aspx.vb | 446 +- Inventarios/Remanufactura.aspx.vb | 2 +- Inventarios/TraspasoAlmacen.aspx.vb | 4804 +++--- Ventas/ClientesAbonar.aspx.vb | 4 +- Ventas/Ventas.aspx.vb | 8 +- 16 files changed, 17259 insertions(+), 17250 deletions(-) diff --git a/App_Code/ClsInventarios.vb b/App_Code/ClsInventarios.vb index 4cacc834a..4bc6ba35a 100644 --- a/App_Code/ClsInventarios.vb +++ b/App_Code/ClsInventarios.vb @@ -1259,9 +1259,9 @@ Public Class ClsInventarios Return Retorno End Function - Public Function AddMovimientoDetalle(CveMovimiento As Integer, Cantidad As Double, CveUM As Integer, CvePS As Integer, PU As Double, CveAF As Integer, Optional CveSeccionAlmacen As Integer = -1, Optional SerieLote As String = "", - Optional Observaciones As String = "", Optional CveMovimientoDetalleEntrada As Integer = -1, Optional PUTC As Double = -1, Optional FechaCaducidad As Date = MinFecha, - Optional CostoIndirecto As Double = 0, Optional CveCompraDetalle As Integer = -1, Optional CveOrdenCompraDetalle As Integer = -1, Optional CveVentaDetalle As Integer = -1, + Public Function AddMovimientoDetalle(CveMovimiento As Integer, Cantidad As Double, CveUM As Integer, CvePS As Integer, PU As Decimal, CveAF As Integer, Optional CveSeccionAlmacen As Integer = -1, Optional SerieLote As String = "", + Optional Observaciones As String = "", Optional CveMovimientoDetalleEntrada As Integer = -1, Optional PUTC As Decimal = -1, Optional FechaCaducidad As Date = MinFecha, + Optional CostoIndirecto As Decimal = 0, Optional CveCompraDetalle As Integer = -1, Optional CveOrdenCompraDetalle As Integer = -1, Optional CveVentaDetalle As Integer = -1, Optional Lote As String = "", Optional Batch As String = "", Optional CveContratoDetalle As Integer = -1, Optional CveUsuarioModifico As Integer = -1, Optional EsInterno As Integer = -1) As Boolean Dim Retorno As Boolean = False @@ -1271,7 +1271,7 @@ Public Class ClsInventarios .Add("@CveMovimiento", SqlDbType.Int).Value = CveMovimiento .Add("@CveUM", SqlDbType.Int).Value = CveUM .Add("@Cantidad", SqlDbType.Money).Value = Cantidad - .Add("@PU", SqlDbType.Float).Value = PU + .Add("@PU", SqlDbType.Decimal).Value = PU .Add("@PUTC", SqlDbType.Money).Value = PUTC .Add("@CveSeccionAlmacen", SqlDbType.Int).Value = CveSeccionAlmacen .Add("@CvePS", SqlDbType.Int).Value = CvePS @@ -1282,7 +1282,7 @@ Public Class ClsInventarios .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones .Add("@CveMovimientoDetalleEntrada", SqlDbType.Int).Value = CveMovimientoDetalleEntrada .Add("@FechaCaducidad", SqlDbType.Date).Value = FechaCaducidad - .Add("@CostoIndirecto", SqlDbType.Float).Value = CostoIndirecto + .Add("@CostoIndirecto", SqlDbType.Decimal).Value = CostoIndirecto .Add("@CveCompraDetalle", SqlDbType.Int).Value = CveCompraDetalle .Add("@CveOrdenCompraDetalle", SqlDbType.Int).Value = CveOrdenCompraDetalle .Add("@CveVentaDetalle", SqlDbType.Int).Value = CveVentaDetalle diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index 081440aab..f70562de6 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -5191,7 +5191,7 @@ Public Class ClsPaginas If fllreport IsNot Nothing Then fllreport.liberarecursos() sw.Stop() - If sw.Elapsed.TotalSeconds > 10 Then + If sw.Elapsed.TotalSeconds > 1 Then GuardaLog($"Reporte:{RutaReporte} | Tiempo Renderizado Milisegundos: {sw.ElapsedMilliseconds},Total Segundos: {sw.Elapsed.TotalSeconds} ") End If diff --git a/App_Code/Modelos.vb b/App_Code/Modelos.vb index d45920d09..ba138a872 100644 --- a/App_Code/Modelos.vb +++ b/App_Code/Modelos.vb @@ -1,452 +1,452 @@ -Option Explicit On -Option Strict On - -Imports Extensiones -Imports Microsoft.VisualBasic -Imports System.Data -Imports System.IO -Imports System.Xml -Imports Microsoft.Reporting.WebForms -Imports System.Security.Cryptography.X509Certificates -Imports System.Globalization -Imports System -Imports System.Net -Imports System.IO.Compression -Imports System.Text +Option Explicit On +Option Strict On + +Imports Extensiones +Imports Microsoft.VisualBasic +Imports System.Data +Imports System.IO +Imports System.Xml +Imports Microsoft.Reporting.WebForms +Imports System.Security.Cryptography.X509Certificates +Imports System.Globalization +Imports System +Imports System.Net +Imports System.IO.Compression +Imports System.Text Imports System.Net.Http Imports System.Collections.Generic -Namespace Modelos - - - Public Class PlantillasPolizas - Public Property CvePlantillaPoliza As Integer - Public Property PlantillaPoliza As String - Public Property TipoPoliza As Integer - Public Property Orden As Integer - Public Property TipoPlantilla As Integer - Public Property CveTipoPlantillaPoliza As Integer - Public Property Estatus As Integer - Public Property TipoPlantillaTexto As String - Public Property TipoPolizaTexto As String - Public Property FechaIng As DateTime - Public Property CveUsuario As Integer - Public Property Usuario As String - Public Property CveEmpresa As Integer - - End Class - - Public Class Evento - Public Sub New() - CveEvento = -1 - CveTipoEvento = -1 - CveAgendaTipo = -1 - Asunto = "-1" - Descripcion = "-1" - Prioridad = "-1" - CveUsuarioDe = -1 - CveUsuarioPara = -1 - CveEventoEstatus = -1 - CveRevision = -1 - CveEventoPadre = -1 - Acuerdos = "-1" - CveActivoFijo = -1 - CveIE = -1 - CveProspecto = -1 - CveCliente = -1 - CveOS = -1 - CveOC = -1 - CvePersonal = -1 - CveProveedor = -1 - CveCompra = -1 - CveVenta = -1 - CveUsuario = -1 - CveUsuarioIng = -1 - 'CveUsuarioConsulta = -1 - CveEmpresa = -1 - CveContrato = -1 - End Sub - - Public Property CveEvento As Integer - Public Property CveTipoEvento As Integer - Public Property CveAgendaTipo As Integer - Public Property Folio As Integer - Public Property Asunto As String - Public Property Descripcion As String - Public Property Prioridad As String - Public Property CveUsuarioDe As Integer - Public Property CveUsuarioPara As Integer - Public Property UsuarioDe As String - Public Property UsuarioPara As String - Public Property CveEventoEstatus As Integer - Public Property FechaInicio As DateTime - Public Property FechaFin As DateTime - Public Property FechaRealTermino As DateTime - Public Property CveEventoPadre As Integer - Public Property Orden As Double - Public Property CveRevision As Integer - Public Property Acuerdos As String - Public Property Archivo As String - Public Property CveEventoComentario As Integer - Public Property Geom As String - Public Property CveActivoFijo As Integer - Public Property CveIE As Integer - Public Property CveProspecto As Integer - Public Property CveCliente As Integer - Public Property CveOS As Integer - Public Property CveOC As Integer - Public Property CvePersonal As Integer - Public Property CveProveedor As Integer - Public Property CveCompra As Integer - Public Property CveVenta As Integer - Public Property CveContrato As Integer - Public Property CveUsuario As Integer - Public Property Imagen1 As String - Public Property Imagen2 As String - Public Property Imagen3 As String - Public Property BackGroundColor As String - Public Property RecurrenciaTipo As String - Public Property Frecuencia As String - Public Property DiasSemana As String - Public Property Dia As String - Public Property Mes As String - Public Property RecurrenciaFin As String - Public Property FechaFinRecurrencia As DateTime - Public Property FechaIng As DateTime - Public Property CveUsuarioIng As Integer - Public Property UsuarioIng As String - Public Property CveEmpresa As Integer - Public Property Modificado As Integer - Public Property CveUsuarioModifico As Integer - Public Property Avance As Double - Public Tick As DateTime - End Class - - Public Class EventoEstatus - Public Property CveEventoEstatus As Integer - Public Property EventoEstatus As String - Public Property Tick As DateTime - End Class - - Public Class OrdenCompra - Public Sub New() - CveOrdenCompra = -1 - Folio = -1 - Tipo = "-1" - CveVendedor = -1 - CveCliente = -1 - Guia = "-1" - End Sub - - Public Property CveOrdenCompra As Integer - Public Property CveEstatus As Integer - Public Property Folio As Integer - Public Property Descripcion As String - Public Property Justificacion As String - Public Property Prioridad As Integer - Public Property PrioridadObservacion As String - Public Property FechaEstimadaEntrega As DateTime - Public Property CveProyecto As Integer - Public Property Proyecto As String - Public Property CveSubProyecto As Integer - Public Property SubProyecto As String - Public Property Fecha As DateTime - Public Property FechaIng As DateTime - Public Property CveUsuario As Integer - Public Property CveVendedor As Integer - Public Property CveCliente As Integer - Public Property Tipo As String - Public Property CveUsuarioModifico As Integer - Public Property Cancelacion As String - Public Property RequiereCotizacion As Integer - Public Property CveProveedor As Integer - Public Property PorcentajeIVA As Decimal - Public Property IVA As Decimal - Public Property RetIVA As Decimal - Public Property RetISR As Integer - Public Property IEPS As Integer - Public Property LugarEntrega As String - Public Property Guia As String - Public Property CveMoneda As Integer - Public Property CveUsuarioAsignado As Integer - Public Property CvePresupuestoEgreso As Integer - Public Property IDCuentaPolizaAC As Integer - Public Property CveCotizacion As Integer - Public Property CveCompra As Integer - Public Property CveEmpresa As Integer - Public Tick As DateTime - Public Property UsuarioSolicito As String - End Class - - Public Class WSOrdenCompra - Public Sub New() - CveOrdenCompra = -1 - Folio = -1 - Tipo = "-1" - CveVendedor = -1 - CveCliente = -1 - Guia = "-1" - End Sub - - Public Property CveOrdenCompra As Integer - Public Property CveEstatus As Integer - Public Property Folio As Integer - Public Property FolioAdicional As String - Public Property Descripcion As String - Public Property Justificacion As String - Public Property Prioridad As Integer - Public Property PrioridadObservacion As String - Public Property FechaEstimadaEntrega As DateTime - Public Property CveProyecto As Integer - Public Property Proyecto As String - Public Property CveSubProyecto As Integer - Public Property SubProyecto As String - Public Property Fecha As DateTime - Public Property FechaIng As DateTime - Public Property CveUsuario As Integer - Public Property CveVendedor As Integer - Public Property CveCliente As Integer - Public Property Tipo As String - Public Property CveUsuarioModifico As Integer - Public Property Cancelacion As String - Public Property RequiereCotizacion As Boolean - Public Property CveProveedor As Integer - Public Property CveProveedorSucursal As Integer - Public Property PorcentajeIVA As Decimal - Public Property IVA As Decimal - Public Property RetIVA As Decimal - Public Property RetISR As Integer - Public Property IEPS As Decimal - Public Property LugarEntrega As String - Public Property Guia As String - Public Property CveMoneda As Integer - Public Property CveUsuarioAsignado As Integer - Public Property CvePresupuestoEgreso As Integer - Public Property IDCuentaPolizaAC As Integer - Public Property CveCotizacion As Integer - Public Property CveCompra As Integer - Public Property CveEmpresa As Integer - Public Property EntregaDirecta As Integer - Public Property CveDireccionEnvio As Integer - Public Tick As DateTime - Public Property UsuarioSolicito As String - End Class - - Public Class OrdenCompraDetalle - Public Property CveOrdenCompraDetalle As Integer - Public Property CveOrdenCompra As Integer - Public Property FolioOC As String - Public Property Cantidad As Decimal - Public Property CveUnidadMedida As Integer - Public Property Abreviatura As String - Public Property CveUM As Integer - Public Property UM As String - Public Property CvePS As Integer - Public Property PS As String - Public Property PorcentajeIVA As Decimal - Public Property IVA As Decimal - Public Property RetIVA As Decimal - Public Property RetISR As Decimal - Public Property IEPS As Decimal - Public Property Descripcion As String - Public Property Importe As Decimal - Public Property Descuento As Decimal - Public Property Total As Decimal - Public Property TotalDescuento As Decimal - Public Property CveOrdenCompraPadre As Integer - Public Property Producto As String - Public Property CodigoPS As String - Public Property CveTipoPS As Integer - Public Property CveClasificacion As Integer - Public Property Clasificacion As String - Public Property CveActivoFijo As Integer - Public Property Observacion As String - Public Property Codigo As String - Public Property CodigoAF As String - Public Property TipoDato As String - Public Property Obs As String - Public Property CveProyecto As Integer - Public Property Proyecto As String - Public Property SubProyecto As String - Public Property CveSubProyecto As Integer - Public Property FolioOrdenCompraPadre As String - Public Property CveOrdenCompraHija As Integer - Public Property FolioOrdenCompraHija As String - Public Property CvePresupuestoEgreso As Integer - Public Property CveProgramaOperativo As Integer - Public Property CveUnidadAdministrativa As Integer - Public Property CveFuenteFinanciamiento As Integer - Public Property CveTipoGasto As Integer - Public Property CveClasificacionOG As Integer - Public Property IdCuentaPorEjercer As Integer - Public Property IdCuentaComprometido As Integer - Public Property CantidadDisponible As Integer - Public Property CveCompra As Integer - Public Property FolioCompra As String - Public Property ProductoOC As String - Public Property CveProveedor As Integer - Public Property CveMoneda As Integer - +Namespace Modelos + + + Public Class PlantillasPolizas + Public Property CvePlantillaPoliza As Integer + Public Property PlantillaPoliza As String + Public Property TipoPoliza As Integer + Public Property Orden As Integer + Public Property TipoPlantilla As Integer + Public Property CveTipoPlantillaPoliza As Integer + Public Property Estatus As Integer + Public Property TipoPlantillaTexto As String + Public Property TipoPolizaTexto As String + Public Property FechaIng As DateTime + Public Property CveUsuario As Integer + Public Property Usuario As String + Public Property CveEmpresa As Integer + + End Class + + Public Class Evento + Public Sub New() + CveEvento = -1 + CveTipoEvento = -1 + CveAgendaTipo = -1 + Asunto = "-1" + Descripcion = "-1" + Prioridad = "-1" + CveUsuarioDe = -1 + CveUsuarioPara = -1 + CveEventoEstatus = -1 + CveRevision = -1 + CveEventoPadre = -1 + Acuerdos = "-1" + CveActivoFijo = -1 + CveIE = -1 + CveProspecto = -1 + CveCliente = -1 + CveOS = -1 + CveOC = -1 + CvePersonal = -1 + CveProveedor = -1 + CveCompra = -1 + CveVenta = -1 + CveUsuario = -1 + CveUsuarioIng = -1 + 'CveUsuarioConsulta = -1 + CveEmpresa = -1 + CveContrato = -1 + End Sub + + Public Property CveEvento As Integer + Public Property CveTipoEvento As Integer + Public Property CveAgendaTipo As Integer + Public Property Folio As Integer + Public Property Asunto As String + Public Property Descripcion As String + Public Property Prioridad As String + Public Property CveUsuarioDe As Integer + Public Property CveUsuarioPara As Integer + Public Property UsuarioDe As String + Public Property UsuarioPara As String + Public Property CveEventoEstatus As Integer + Public Property FechaInicio As DateTime + Public Property FechaFin As DateTime + Public Property FechaRealTermino As DateTime + Public Property CveEventoPadre As Integer + Public Property Orden As Double + Public Property CveRevision As Integer + Public Property Acuerdos As String + Public Property Archivo As String + Public Property CveEventoComentario As Integer + Public Property Geom As String + Public Property CveActivoFijo As Integer + Public Property CveIE As Integer + Public Property CveProspecto As Integer + Public Property CveCliente As Integer + Public Property CveOS As Integer + Public Property CveOC As Integer + Public Property CvePersonal As Integer + Public Property CveProveedor As Integer + Public Property CveCompra As Integer + Public Property CveVenta As Integer + Public Property CveContrato As Integer + Public Property CveUsuario As Integer + Public Property Imagen1 As String + Public Property Imagen2 As String + Public Property Imagen3 As String + Public Property BackGroundColor As String + Public Property RecurrenciaTipo As String + Public Property Frecuencia As String + Public Property DiasSemana As String + Public Property Dia As String + Public Property Mes As String + Public Property RecurrenciaFin As String + Public Property FechaFinRecurrencia As DateTime + Public Property FechaIng As DateTime + Public Property CveUsuarioIng As Integer + Public Property UsuarioIng As String + Public Property CveEmpresa As Integer + Public Property Modificado As Integer + Public Property CveUsuarioModifico As Integer + Public Property Avance As Double + Public Tick As DateTime + End Class + + Public Class EventoEstatus + Public Property CveEventoEstatus As Integer + Public Property EventoEstatus As String + Public Property Tick As DateTime + End Class + + Public Class OrdenCompra + Public Sub New() + CveOrdenCompra = -1 + Folio = -1 + Tipo = "-1" + CveVendedor = -1 + CveCliente = -1 + Guia = "-1" + End Sub + + Public Property CveOrdenCompra As Integer + Public Property CveEstatus As Integer + Public Property Folio As Integer + Public Property Descripcion As String + Public Property Justificacion As String + Public Property Prioridad As Integer + Public Property PrioridadObservacion As String + Public Property FechaEstimadaEntrega As DateTime + Public Property CveProyecto As Integer + Public Property Proyecto As String + Public Property CveSubProyecto As Integer + Public Property SubProyecto As String + Public Property Fecha As DateTime + Public Property FechaIng As DateTime + Public Property CveUsuario As Integer + Public Property CveVendedor As Integer + Public Property CveCliente As Integer + Public Property Tipo As String + Public Property CveUsuarioModifico As Integer + Public Property Cancelacion As String + Public Property RequiereCotizacion As Integer + Public Property CveProveedor As Integer + Public Property PorcentajeIVA As Decimal + Public Property IVA As Decimal + Public Property RetIVA As Decimal + Public Property RetISR As Integer + Public Property IEPS As Integer + Public Property LugarEntrega As String + Public Property Guia As String + Public Property CveMoneda As Integer + Public Property CveUsuarioAsignado As Integer + Public Property CvePresupuestoEgreso As Integer + Public Property IDCuentaPolizaAC As Integer + Public Property CveCotizacion As Integer + Public Property CveCompra As Integer + Public Property CveEmpresa As Integer + Public Tick As DateTime + Public Property UsuarioSolicito As String + End Class + + Public Class WSOrdenCompra + Public Sub New() + CveOrdenCompra = -1 + Folio = -1 + Tipo = "-1" + CveVendedor = -1 + CveCliente = -1 + Guia = "-1" + End Sub + + Public Property CveOrdenCompra As Integer + Public Property CveEstatus As Integer + Public Property Folio As Integer + Public Property FolioAdicional As String + Public Property Descripcion As String + Public Property Justificacion As String + Public Property Prioridad As Integer + Public Property PrioridadObservacion As String + Public Property FechaEstimadaEntrega As DateTime + Public Property CveProyecto As Integer + Public Property Proyecto As String + Public Property CveSubProyecto As Integer + Public Property SubProyecto As String + Public Property Fecha As DateTime + Public Property FechaIng As DateTime + Public Property CveUsuario As Integer + Public Property CveVendedor As Integer + Public Property CveCliente As Integer + Public Property Tipo As String + Public Property CveUsuarioModifico As Integer + Public Property Cancelacion As String + Public Property RequiereCotizacion As Boolean + Public Property CveProveedor As Integer + Public Property CveProveedorSucursal As Integer + Public Property PorcentajeIVA As Decimal + Public Property IVA As Decimal + Public Property RetIVA As Decimal + Public Property RetISR As Integer + Public Property IEPS As Decimal + Public Property LugarEntrega As String + Public Property Guia As String + Public Property CveMoneda As Integer + Public Property CveUsuarioAsignado As Integer + Public Property CvePresupuestoEgreso As Integer + Public Property IDCuentaPolizaAC As Integer + Public Property CveCotizacion As Integer + Public Property CveCompra As Integer + Public Property CveEmpresa As Integer + Public Property EntregaDirecta As Integer + Public Property CveDireccionEnvio As Integer + Public Tick As DateTime + Public Property UsuarioSolicito As String + End Class + + Public Class OrdenCompraDetalle + Public Property CveOrdenCompraDetalle As Integer + Public Property CveOrdenCompra As Integer + Public Property FolioOC As String + Public Property Cantidad As Decimal + Public Property CveUnidadMedida As Integer + Public Property Abreviatura As String + Public Property CveUM As Integer + Public Property UM As String + Public Property CvePS As Integer + Public Property PS As String + Public Property PorcentajeIVA As Decimal + Public Property IVA As Decimal + Public Property RetIVA As Decimal + Public Property RetISR As Decimal + Public Property IEPS As Decimal + Public Property Descripcion As String + Public Property Importe As Decimal + Public Property Descuento As Decimal + Public Property Total As Decimal + Public Property TotalDescuento As Decimal + Public Property CveOrdenCompraPadre As Integer + Public Property Producto As String + Public Property CodigoPS As String + Public Property CveTipoPS As Integer + Public Property CveClasificacion As Integer + Public Property Clasificacion As String + Public Property CveActivoFijo As Integer + Public Property Observacion As String + Public Property Codigo As String + Public Property CodigoAF As String + Public Property TipoDato As String + Public Property Obs As String + Public Property CveProyecto As Integer + Public Property Proyecto As String + Public Property SubProyecto As String + Public Property CveSubProyecto As Integer + Public Property FolioOrdenCompraPadre As String + Public Property CveOrdenCompraHija As Integer + Public Property FolioOrdenCompraHija As String + Public Property CvePresupuestoEgreso As Integer + Public Property CveProgramaOperativo As Integer + Public Property CveUnidadAdministrativa As Integer + Public Property CveFuenteFinanciamiento As Integer + Public Property CveTipoGasto As Integer + Public Property CveClasificacionOG As Integer + Public Property IdCuentaPorEjercer As Integer + Public Property IdCuentaComprometido As Integer + Public Property CantidadDisponible As Integer + Public Property CveCompra As Integer + Public Property FolioCompra As String + Public Property ProductoOC As String + Public Property CveProveedor As Integer + Public Property CveMoneda As Integer + End Class -#Region " OBJETOS Ventas" - Public Enum TipoMensajeRespuesta - TextoLimpio = 0 - HTML = 1 - End Enum - - Public Class Factura - Inherits Modelos.EntityModel - Implements IDisposable - Public ReadOnly Property UrlSitio As String - Get - If IsNothing(System.Configuration.ConfigurationManager.AppSettings("UrlSitio")) Then - Return "" - Else - Return System.Configuration.ConfigurationManager.AppSettings("UrlSitio").ToString() - End If - End Get - End Property - Public Property UsuarioActual As Usuario - Public Property ListaMensajes As List(Of String) - Public Property TipoMensajeRespuesta As TipoMensajeRespuesta = TipoMensajeRespuesta.HTML - Public Sub New() - Timbre = New CFDITimbre - IniciaValores() - End Sub - - Public Sub New(ObjsClsPaginas As ClsPaginas, Optional Row As Data.DataRow = Nothing) - If Row IsNot Nothing Then - setValues(Row) - Else - IniciaValores() - End If - SetMetodoPago(ObjsClsPaginas) - Timbre = New CFDITimbre - DirectorioServidor = ObjsClsPaginas.Server.MapPath("/") - End Sub - - Public Sub New(ObjsClsPaginas As ClsPaginas, CveVenta As Integer, CveEmpresa As Integer) - Me.CveEmpresa = CveEmpresa - Dim ObjVentas As New ClsVentas() - If ObjVentas.GetVenta(CveVenta, CveEmpresa) Then - If ObjVentas.DtResultados IsNot Nothing AndAlso ObjVentas.DtResultados.Rows.Count > 0 Then - setValues(ObjVentas.DtResultados.Rows(0)) - SetMetodoPago(ObjsClsPaginas) - SetMoneda(ObjsClsPaginas) - End If - End If - ObjVentas.Dispose() - DirectorioServidor = ObjsClsPaginas.Server.MapPath("/") - End Sub - Public Sub New(ObjsClsPaginas As ClsPaginas, UsuarioActual As Usuario, Optional Row As Data.DataRow = Nothing) - Me.UsuarioActual = UsuarioActual - Me.ErrorList = New List(Of String) - Me.RemisionesLista = New List(Of Integer) - Me.ListaMensajes = New List(Of String) - If Row IsNot Nothing Then - setValues(Row) - Else - IniciaValores() - End If - SetMetodoPago(ObjsClsPaginas) - SetMoneda(ObjsClsPaginas) - SetSubProyecto(ObjsClsPaginas) - SetSubProyectoMatriz(ObjsClsPaginas) - Timbre = New CFDITimbre - DirectorioServidor = ObjsClsPaginas.Server.MapPath("/") - End Sub - Public Sub New(UsuarioActual As Usuario, Optional Row As Data.DataRow = Nothing) - Me.UsuarioActual = UsuarioActual - Me.ErrorList = New List(Of String) - Me.RemisionesLista = New List(Of Integer) - Me.ListaMensajes = New List(Of String) - If Row IsNot Nothing Then - setValues(Row) - Else - IniciaValores() - End If - Timbre = New CFDITimbre - End Sub - Public Sub New(UsuarioActual As Usuario, CveVenta As Integer, CveEmpresa As Integer, Optional DirectorioServidor As String = "", Optional EsCancelacion As Boolean = False) - Me.UsuarioActual = UsuarioActual - Me.CveVenta = CveVenta - Me.CveEmpresa = CveEmpresa - Me.ErrorList = New List(Of String) - Me.RemisionesLista = New List(Of Integer) - Me.ListaMensajes = New List(Of String) - Me.FolioFiscal = "" - Me.GenerarPDFFactura = False - IniciaValores() - Dim ObjVentas As New ClsVentas() - If ObjVentas.GetVenta(CveVenta, CveEmpresa) Then - If ObjVentas.DtResultados IsNot Nothing AndAlso ObjVentas.DtResultados.Rows.Count > 0 Then - setValues(ObjVentas.DtResultados.Rows(0)) - SetMetodoPago() - SetMoneda() - SetSubProyecto() - SetSubProyectoMatriz() - SetCliente() - End If - End If - If ObjVentas.GetVentaDetalle(CveVenta) Then - Me.DtDetalle = ObjVentas.DtResultados.Copy() - End If +#Region " OBJETOS Ventas" + Public Enum TipoMensajeRespuesta + TextoLimpio = 0 + HTML = 1 + End Enum + + Public Class Factura + Inherits Modelos.EntityModel + Implements IDisposable + Public ReadOnly Property UrlSitio As String + Get + If IsNothing(System.Configuration.ConfigurationManager.AppSettings("UrlSitio")) Then + Return "" + Else + Return System.Configuration.ConfigurationManager.AppSettings("UrlSitio").ToString() + End If + End Get + End Property + Public Property UsuarioActual As Usuario + Public Property ListaMensajes As List(Of String) + Public Property TipoMensajeRespuesta As TipoMensajeRespuesta = TipoMensajeRespuesta.HTML + Public Sub New() + Timbre = New CFDITimbre + IniciaValores() + End Sub + + Public Sub New(ObjsClsPaginas As ClsPaginas, Optional Row As Data.DataRow = Nothing) + If Row IsNot Nothing Then + setValues(Row) + Else + IniciaValores() + End If + SetMetodoPago(ObjsClsPaginas) + Timbre = New CFDITimbre + DirectorioServidor = ObjsClsPaginas.Server.MapPath("/") + End Sub + + Public Sub New(ObjsClsPaginas As ClsPaginas, CveVenta As Integer, CveEmpresa As Integer) + Me.CveEmpresa = CveEmpresa + Dim ObjVentas As New ClsVentas() + If ObjVentas.GetVenta(CveVenta, CveEmpresa) Then + If ObjVentas.DtResultados IsNot Nothing AndAlso ObjVentas.DtResultados.Rows.Count > 0 Then + setValues(ObjVentas.DtResultados.Rows(0)) + SetMetodoPago(ObjsClsPaginas) + SetMoneda(ObjsClsPaginas) + End If + End If ObjVentas.Dispose() - IniciaValoresVentas(EsCancelacion) + DirectorioServidor = ObjsClsPaginas.Server.MapPath("/") + End Sub + Public Sub New(ObjsClsPaginas As ClsPaginas, UsuarioActual As Usuario, Optional Row As Data.DataRow = Nothing) + Me.UsuarioActual = UsuarioActual + Me.ErrorList = New List(Of String) + Me.RemisionesLista = New List(Of Integer) + Me.ListaMensajes = New List(Of String) + If Row IsNot Nothing Then + setValues(Row) + Else + IniciaValores() + End If + SetMetodoPago(ObjsClsPaginas) + SetMoneda(ObjsClsPaginas) + SetSubProyecto(ObjsClsPaginas) + SetSubProyectoMatriz(ObjsClsPaginas) + Timbre = New CFDITimbre + DirectorioServidor = ObjsClsPaginas.Server.MapPath("/") + End Sub + Public Sub New(UsuarioActual As Usuario, Optional Row As Data.DataRow = Nothing) + Me.UsuarioActual = UsuarioActual + Me.ErrorList = New List(Of String) + Me.RemisionesLista = New List(Of Integer) + Me.ListaMensajes = New List(Of String) + If Row IsNot Nothing Then + setValues(Row) + Else + IniciaValores() + End If + Timbre = New CFDITimbre + End Sub + Public Sub New(UsuarioActual As Usuario, CveVenta As Integer, CveEmpresa As Integer, Optional DirectorioServidor As String = "", Optional EsCancelacion As Boolean = False) + Me.UsuarioActual = UsuarioActual + Me.CveVenta = CveVenta + Me.CveEmpresa = CveEmpresa + Me.ErrorList = New List(Of String) + Me.RemisionesLista = New List(Of Integer) + Me.ListaMensajes = New List(Of String) + Me.FolioFiscal = "" + Me.GenerarPDFFactura = False + IniciaValores() + Dim ObjVentas As New ClsVentas() + If ObjVentas.GetVenta(CveVenta, CveEmpresa) Then + If ObjVentas.DtResultados IsNot Nothing AndAlso ObjVentas.DtResultados.Rows.Count > 0 Then + setValues(ObjVentas.DtResultados.Rows(0)) + SetMetodoPago() + SetMoneda() + SetSubProyecto() + SetSubProyectoMatriz() + SetCliente() + End If + End If + If ObjVentas.GetVentaDetalle(CveVenta) Then + Me.DtDetalle = ObjVentas.DtResultados.Copy() + End If + ObjVentas.Dispose() + IniciaValoresVentas(EsCancelacion) If String.IsNullOrEmpty(DirectorioServidor) Then DirectorioServidor = HttpContext.Current.Server.MapPath("/") - End If - Me.DirectorioServidor = DirectorioServidor - Timbre = New CFDITimbre - End Sub - Private Sub IniciaValores() - Me.FolioFiscal = "" - Me.CveContratoSecciones = "" - Me.Version = "3.3" - If UsuarioActual IsNot Nothing Then - Me.CveUsuario = UsuarioActual.CveUsuario - Me.CveEmpresa = UsuarioActual.CveEmpresa - Me.UsuarioCreo = UsuarioActual.Usuario - End If - Me.TipoCambio = 0 - Me.ConvertirPesos = False - Me.CveMoneda = 1 - Me.Moneda = GlobalDTMonedas.FiltroPrimeroValor("Moneda", $"CveMoneda = {CveMoneda} ") - Me.MonedaSAT = GlobalDTMonedas.FiltroPrimeroValor("AbreviaturaSAT", $"CveMoneda = {CveMoneda} ") - Me.RefDocto = "" - Me.CveMesa = -1 - Me.Fecha = Now - Me.CvePrePoliza = -1 - Me.FechaPago = Now - Me.MotivoDescuento = "" - Me.Observaciones = "" - Me.FechaEjecucion = Now - Me.CveCondicionEntrega = -1 - Me.CondicionEntrega = "" - Me.NumeroCuenta = "" - Me.CondicionesPago = 0 - Me.FormaPago = 0 - Me.PedidoContrato = "" - Me.NumeroContrato = "" - Me.DescripcionContrato = "" - Me.CveCorte = -1 - Me.Alfa1 = "" - Me.Alfa2 = "" - Me.Alfa3 = "" - Me.Descuento = 0 - Me.Amortizacion = 0 - Me.CveContrato = 0 - Me.SubTotal = 0 - Me.Descuento = 0 - Me.Amortizacion = 0 - Me.IVA = IVA - Me.RetIVA = 0 - Me.RetISR = 0 - Me.IEPS = 0 - Me.CveAlmacenTraspasoOrigen = 0 - End Sub + End If + Me.DirectorioServidor = DirectorioServidor + Timbre = New CFDITimbre + End Sub + Private Sub IniciaValores() + Me.FolioFiscal = "" + Me.CveContratoSecciones = "" + Me.Version = "3.3" + If UsuarioActual IsNot Nothing Then + Me.CveUsuario = UsuarioActual.CveUsuario + Me.CveEmpresa = UsuarioActual.CveEmpresa + Me.UsuarioCreo = UsuarioActual.Usuario + End If + Me.TipoCambio = 0 + Me.ConvertirPesos = False + Me.CveMoneda = 1 + Me.Moneda = GlobalDTMonedas.FiltroPrimeroValor("Moneda", $"CveMoneda = {CveMoneda} ") + Me.MonedaSAT = GlobalDTMonedas.FiltroPrimeroValor("AbreviaturaSAT", $"CveMoneda = {CveMoneda} ") + Me.RefDocto = "" + Me.CveMesa = -1 + Me.Fecha = Now + Me.CvePrePoliza = -1 + Me.FechaPago = Now + Me.MotivoDescuento = "" + Me.Observaciones = "" + Me.FechaEjecucion = Now + Me.CveCondicionEntrega = -1 + Me.CondicionEntrega = "" + Me.NumeroCuenta = "" + Me.CondicionesPago = 0 + Me.FormaPago = 0 + Me.PedidoContrato = "" + Me.NumeroContrato = "" + Me.DescripcionContrato = "" + Me.CveCorte = -1 + Me.Alfa1 = "" + Me.Alfa2 = "" + Me.Alfa3 = "" + Me.Descuento = 0 + Me.Amortizacion = 0 + Me.CveContrato = 0 + Me.SubTotal = 0 + Me.Descuento = 0 + Me.Amortizacion = 0 + Me.IVA = IVA + Me.RetIVA = 0 + Me.RetISR = 0 + Me.IEPS = 0 + Me.CveAlmacenTraspasoOrigen = 0 + End Sub Private Sub IniciaValoresVentas(Optional EsCancelacion As Boolean = False) If CveVenta > 0 AndAlso CveEmpresa > 0 Then Me.DtAnticipos = New DataTable() @@ -523,32 +523,32 @@ Namespace Modelos End If End If - End Sub - Public Class MMensajeFactura - Sub New() - CveVenta = -1 - LigaCliente = "" - LigaPV = "" - LigaVenta = "" - LigaPDF = "" - SerieFolio = "" - Mensajes = New List(Of String) - TieneError = True - End Sub - Public Property Mensajes As New List(Of String) - Public Property TieneError As Boolean - Public Property CveVenta As Integer - Public Property LigaCliente As String - Public Property LigaPV As String - Public Property LigaVenta As String - Public Property LigaCRM As String - Public Property LigaPDF As String - Public Property SerieFolio As String - Public Property SeTimbro As Boolean - Public Property SeTimbroNotaCredito As Boolean - Public Property CveEstatus As Integer - - End Class + End Sub + Public Class MMensajeFactura + Sub New() + CveVenta = -1 + LigaCliente = "" + LigaPV = "" + LigaVenta = "" + LigaPDF = "" + SerieFolio = "" + Mensajes = New List(Of String) + TieneError = True + End Sub + Public Property Mensajes As New List(Of String) + Public Property TieneError As Boolean + Public Property CveVenta As Integer + Public Property LigaCliente As String + Public Property LigaPV As String + Public Property LigaVenta As String + Public Property LigaCRM As String + Public Property LigaPDF As String + Public Property SerieFolio As String + Public Property SeTimbro As Boolean + Public Property SeTimbroNotaCredito As Boolean + Public Property CveEstatus As Integer + + End Class Public Function RegenerarPrePolizas(Optional TransaccionCompartida As SqlClient.SqlTransaction = Nothing, Optional ObjACTransac As ClsContPAQi = Nothing) As Boolean Dim ErrorPrePolizas As Boolean = False @@ -606,263 +606,263 @@ Namespace Modelos If Not ErrorPrePolizas Then ErrorPrePolizas = GuardarVentaImpuestosLocales(ObjFactura, ObjVentas, ObjConta, 1) Return Not ErrorPrePolizas - End Function - Public Function EmitirFactura(Optional Timbrar As Boolean = True, Optional Transac As SqlClient.SqlTransaction = Nothing, Optional ObjContPaqTransac As ClsContPAQi = Nothing) As MMensajeFactura - Dim Retorno As New MMensajeFactura() - - If Me.Version = "3.3" AndAlso Not Me.TipoDocto.Contiene("Ped", "PeC") Then - Dim dttsat As DataTable = DtDetalle.FiltraParametros("ISNULL(SATClaveProdServ,'') = '' OR ISNULL(SATClaveUM,'') = '' ") - If dttsat IsNot Nothing AndAlso dttsat.Rows.Count > 0 Then - Dim str As New StringBuilder - str.Append("Los siguientes productos no tiene asignado la clave Producto SAT o Unidad Medida SAT

") - For Each drt As DataRow In dttsat.Rows - str.AppendFormat("{0}
", drt("CodigoPS")) - Next - ErrorList.Add(str.ToString) - dttsat.Dispose() - Retorno.Mensajes = ErrorList - Return Retorno - End If - dttsat.Dispose() - End If - - If Not Me.TipoDocto.Contiene("Ped", "Ant", "DPe") Then - If UsuarioActual.CveEmpresa.Contiene(72, 80) Then - If Me.SubTotal <= 0 Then - ErrorList.Add("Es necesario especificar el importe en los conceptos. Por favor rectifique y vuelva a intentar.") - Retorno.Mensajes = ErrorList - Return Retorno - End If - End If - End If - - 'VALIDA CUENTAS CONTABLES DE AC - If UsuarioActual.Empresa.UsaAC Then - If Me.Cliente.IdCtaContClientes <= 0 Then - ErrorList.Add("El Cliente no tiene registrado la cuenta contable") - Retorno.Mensajes = ErrorList - Return Retorno - End If - - If Me.SubTotal <= 0 Then - ErrorList.Add("Es necesario especificar el importe en los conceptos. Por favor rectifique y vuelva a intentar.") - Retorno.Mensajes = ErrorList - Return Retorno - End If - End If - - If Me.CveCliente > 0 Or Me.CveEmpresaCRM > 0 Then + End Function + Public Function EmitirFactura(Optional Timbrar As Boolean = True, Optional Transac As SqlClient.SqlTransaction = Nothing, Optional ObjContPaqTransac As ClsContPAQi = Nothing) As MMensajeFactura + Dim Retorno As New MMensajeFactura() + + If Me.Version = "3.3" AndAlso Not Me.TipoDocto.Contiene("Ped", "PeC") Then + Dim dttsat As DataTable = DtDetalle.FiltraParametros("ISNULL(SATClaveProdServ,'') = '' OR ISNULL(SATClaveUM,'') = '' ") + If dttsat IsNot Nothing AndAlso dttsat.Rows.Count > 0 Then + Dim str As New StringBuilder + str.Append("Los siguientes productos no tiene asignado la clave Producto SAT o Unidad Medida SAT

") + For Each drt As DataRow In dttsat.Rows + str.AppendFormat("{0}
", drt("CodigoPS")) + Next + ErrorList.Add(str.ToString) + dttsat.Dispose() + Retorno.Mensajes = ErrorList + Return Retorno + End If + dttsat.Dispose() + End If + + If Not Me.TipoDocto.Contiene("Ped", "Ant", "DPe") Then + If UsuarioActual.CveEmpresa.Contiene(72, 80) Then + If Me.SubTotal <= 0 Then + ErrorList.Add("Es necesario especificar el importe en los conceptos. Por favor rectifique y vuelva a intentar.") + Retorno.Mensajes = ErrorList + Return Retorno + End If + End If + End If + + 'VALIDA CUENTAS CONTABLES DE AC + If UsuarioActual.Empresa.UsaAC Then + If Me.Cliente.IdCtaContClientes <= 0 Then + ErrorList.Add("El Cliente no tiene registrado la cuenta contable") + Retorno.Mensajes = ErrorList + Return Retorno + End If + + If Me.SubTotal <= 0 Then + ErrorList.Add("Es necesario especificar el importe en los conceptos. Por favor rectifique y vuelva a intentar.") + Retorno.Mensajes = ErrorList + Return Retorno + End If + End If + + If Me.CveCliente > 0 Or Me.CveEmpresaCRM > 0 Then If DtDetalle.Rows.Count > 0 Then - Dim ObjVentas As ClsVentas = Nothing + Dim ObjVentas As ClsVentas = Nothing If Transac IsNot Nothing Then ObjVentas = New ClsVentas(Transac) Else ObjVentas = New ClsVentas() ObjVentas.IniciaTransacSQL() - End If - - Dim ObjConta As New ClsContabilidad(ObjVentas.IniciaTransacSQL()) - Dim ObjInventario As New ClsInventarios(ObjVentas.IniciaTransacSQL()) - Dim ObjContr As New ClsContratos(ObjVentas.IniciaTransacSQL()) - Dim ObjOS As New ClsOS(ObjVentas.IniciaTransacSQL()) - Dim ObjBancos As New ClsBancos(ObjVentas.IniciaTransacSQL()) - Dim ObjClientes As New ClsClientes(ObjVentas.IniciaTransacSQL()) - Dim ObjEventos As New ClsOIEventos(ObjVentas.IniciaTransacSQL()) - Dim ObjCGame As New ClsCGame(ObjVentas.IniciaTransacSQL()) - Dim ObjDocCliente As New ClsEdocumentacion(ObjVentas.IniciaTransacSQL()) - Dim ObjAcum As New ClsAcumuladores(ObjVentas.IniciaTransacSQL()) - Dim ObjContPaq As ClsContPAQi = Nothing - Dim MensajeAlert = New StringBuilder - - Try - 'CONTABILIDAD AUTOMATICA Y AC + End If + + Dim ObjConta As New ClsContabilidad(ObjVentas.IniciaTransacSQL()) + Dim ObjInventario As New ClsInventarios(ObjVentas.IniciaTransacSQL()) + Dim ObjContr As New ClsContratos(ObjVentas.IniciaTransacSQL()) + Dim ObjOS As New ClsOS(ObjVentas.IniciaTransacSQL()) + Dim ObjBancos As New ClsBancos(ObjVentas.IniciaTransacSQL()) + Dim ObjClientes As New ClsClientes(ObjVentas.IniciaTransacSQL()) + Dim ObjEventos As New ClsOIEventos(ObjVentas.IniciaTransacSQL()) + Dim ObjCGame As New ClsCGame(ObjVentas.IniciaTransacSQL()) + Dim ObjDocCliente As New ClsEdocumentacion(ObjVentas.IniciaTransacSQL()) + Dim ObjAcum As New ClsAcumuladores(ObjVentas.IniciaTransacSQL()) + Dim ObjContPaq As ClsContPAQi = Nothing + Dim MensajeAlert = New StringBuilder + + Try + 'CONTABILIDAD AUTOMATICA Y AC If ObjContPaqTransac IsNot Nothing Then ObjContPaq = ObjContPaqTransac Else If UsuarioActual.Empresa.UsaAC OrElse UsuarioActual.Empresa.Funcionalidad(200) = "1" Then ObjContPaq = New ClsContPAQi(UsuarioActual.Empresa) End If - End If - - - 'GUARDA VENTA - Dim TieneAnticipo As Boolean = False - Dim CveAnticipoPadre As Integer = 0 ' vinculación con anticipo - Dim FolioFiscalRelacionado As String = "" - If DtAnticipos IsNot Nothing AndAlso DtAnticipos.Rows.Count > 0 Then - Dim actualindex As Integer = 0 - For Each row2 As DataRow In DtAnticipos.Rows - TieneAnticipo = True - CveAnticipoPadre = row2("CveVenta").ToString().ToEntero() - Me.CveVentaRelacion = CveAnticipoPadre 'relaciona al anticipo - Me.ImporteRelacion = row2("Importe").ToString().ToDecimal() - FolioFiscalRelacionado = row2("FolioFiscal").ToString() - Me.CveVentaPadre = row2("CveVenta").ToString().ToEntero() - actualindex = actualindex + 1 - Next - End If - - GuardarVenta(Me, ObjVentas, ObjConta, ObjInventario, ObjContr, DtDetalle, Me.CveNCaVincular, ObjContPaq, ObjBancos, ObjOS, ObjEventos, ObjCGame, ObjClientes, ObjAcum:=ObjAcum) - - 'SI ES REFACTURACION - Dim ObjNC As List(Of Object) = Nothing - If ErrorList.Count = 0 Then - If NuevaFactura = 1 AndAlso FacturaDevolucion IsNot Nothing Then - - ObjNC = GeneraNC(ObjVentas, ObjConta, ObjInventario, ObjContr, ObjContPaq, FacturaDevolucion, ObjBancos, ObjEventos) - - If ObjNC Is Nothing Then - ErrorList.Add("No se pudo Cancelar la Factura") - End If - - 'Esquema viejo, evitamos que aparezca por surtir - If ErrorList.Count = 0 Then - If Not ObjInventario.ActualizarEsDevolucionVenta(CveVenta, 2) Then - ErrorList.Add("No se pudo Cancelar el movimiento de almacen de la Factura") - End If - End If - - End If - End If - - 'SI ES amortizacion 3.3 - Dim Obj2 As New List(Of Object) - - If ErrorList.Count = 0 Then - ' cambiar la condicion para saber si hay seleccionado - If TieneAnticipo AndAlso Me.CveTipoAmortizacionAnticipo = 2 Then - - If TieneAnticipo Then - Try - 'DESCOMENTAR - If RegistrarNCAmortizacion(ObjVentas, ObjConta, ObjInventario, ObjContr, ObjContPaq, FacturaDevolucion, ObjBancos, Nothing, Nothing) Then - Obj2.Add(FacturaDevolucion) - End If - Catch ex As Exception - ErrorList.Add("No se pudo generarse la nota de crédito de amortización") - End Try - - - End If - - If Obj2 Is Nothing AndAlso Obj2.Count = 0 Then - ErrorList.Add("No se pudo generarse la nota de crédito de amortización") - End If - End If - End If - - 'MARCA PARA NO SURTIR VENTA DE COTNRATO DE CONSIGNACION DE VENTA | [IPP] : PARCHE - If ErrorList.Count = 0 Then - If Me.CveVenta > 0 And Me.CveAlmacenExistenciasContrato > 0 And Me.TipoDocto = "Ing" Then - If Not ObjInventario.ActualizarEsDevolucionVenta(Me.CveVenta, 2) Then - ErrorList.Add("No se pudo cancelar el movimiento de almacen de la Factura de consignación") - End If - End If - End If - - If ErrorList.Count = 0 Then - If Me.CveVenta > 0 And CveAlmacenExistenciasContrato > 0 And Me.TipoDocto = "Ing" Then - If Not RegistraAlmacenConsignacionVenta(ObjInventario) Then - ErrorList.Add("Ocurrió un error al registrar los movimientos de almacén del contrato de consignación") - End If - End If - End If - - If Me.CveVenta > 0 AndAlso ErrorList.Count = 0 Then - 'ACTUALIZA VENTA COTIZACIÓN - If EraCotizacion = 1 Then - If Not ObjVentas.UpdateVentaCotizacion(Me.CveVenta, Me.CveCotizacion) Then - ErrorList.Add("Ocurrió un error al actualizar la cotización") - End If - End If - - 'ACTUALIZA VENTAPADRE PEDIDO - If DevPed > 0 AndAlso ErrorList.Count = 0 Then - If Not ObjVentas.UpdateVentaCotizacion(DevPed, Me.CveVenta) Then - ErrorList.Add("Ocurrió un error al actualizar la devolución de pedido") - End If - End If - - 'ACTUALIZA LA COLUMNA CveVentaFacturada - If (CveRemision > 0) AndAlso ErrorList.Count = 0 Then - If Not ObjVentas.UpdateVentaRemision(CveRemision, Me.CveVenta) Then - ErrorList.Add("Ocurrió un error al actualizar la remision") - End If - End If - - 'Agregamos las OCs a la tabla - If DTOrdenesCompraPS IsNot Nothing AndAlso DTOrdenesCompraPS.Rows.Count > 0 AndAlso ErrorList.Count = 0 Then - Dim CveVentaDetalle As Integer = 0 - Dim CveOrdenCompraDetalle As Integer = 0 - Dim Cantidad As Decimal = 0 - - - For Each row As DataRow In DtDetalle.Rows - Cantidad = row("Cantidad").ToString.ToDecimal - CveVentaDetalle = row("CveVentaDetalle").ToString.ToEntero - CveOrdenCompraDetalle = row("CveOrdenCompraDetalle").ToString.ToEntero - If Not ObjVentas.AgregarVentaOCDetalle(CveVentaDetalle, CveOrdenCompraDetalle, Cantidad) Then - ErrorList.Add("Ocurrió un Error al agregar el detalle de la Remision") - End If - Next - - End If - - 'Agregamos las Cotizaciones a la tabla - If DtCotizacionesPS IsNot Nothing AndAlso DtCotizacionesPS.Rows.Count > 0 AndAlso ErrorList.Count = 0 Then - Dim CveVentaDetalle As Integer = 0 - Dim CveVentaDetallePadre As Integer = 0 - Dim Cantidad As Decimal = 0 - Dim CvePS As Integer = 0 - Dim PU As Decimal = 0 - - For Each row As DataRow In DtCotizacionesPS.Rows - Cantidad = DtDetalle.FiltroPrimeroValor("Cantidad", $"CveVentaDetalleCotizacion={row("CveVentaDetalle")}").ToDecimal - CvePS = DtDetalle.FiltroPrimeroValor("CvePS", $"CveVentaDetalleCotizacion={row("CveVentaDetalle")}").ToEntero - PU = DtDetalle.FiltroPrimeroValor("PU", $"CveVentaDetalleCotizacion={row("CveVentaDetalle")}").ToDecimal - CveVentaDetalle = DtDetalle.FiltroPrimeroValor("CveVentaDetalle", $"CveVentaDetalleCotizacion={row("CveVentaDetalle")}").ToEntero - CveVentaDetallePadre = row("CveVentaDetalle").ToString.ToEntero - - If Not ObjVentas.AgregaCotizacionDetalle(CveVentaDetalle, CveVentaDetallePadre, Cantidad) Then - ErrorList.Add("Ocurrió un Error al agregar el detalle de la Cotización.") - End If - Next - End If - - - 'Marcamos las ventas anteriores a febrero como surtidas - Ajuste Compu - If ErrorList.Count = 0 Then - If Not ObjVentas.MarcarRemisionesSinSurtir(Me.CveVenta) Then - ErrorList.Add("Ocurrió un Error al marcar la factura") - End If - End If - - If Me.CveOS > 0 And FacturaMateriales = 1 AndAlso ErrorList.Count = 0 Then - If SalidaAlmacenMateriales(ObjInventario, CveOS, ObjConta, True, 3) Then - ErrorList.Add("Ocurrió un Error al dar salida de materiales de almacen") - End If - End If - - If Me.CveFactura > 0 AndAlso ErrorList.Count = 0 Then - If Not ObjVentas.UpdateVentaFacturas(Me.CveFactura, ObjVentas.CveVenta, UsuarioActual.CveEmpresa) Then - ErrorList.Add("No se pudo actualizar la Factura") - End If - End If - - If CveCicloComercial > 0 AndAlso ErrorList.Count = 0 Then - If Not ObjContr.CicloComercialUpdate(Me.CveCicloComercial, True, UsuarioActual.CveEmpresa) Then - ErrorList.Add("No se pudo actualizar ") - End If - End If - - If ErrorList.Count = 0 AndAlso Me.CveVenta > 0 AndAlso DtDocumentacionCliente IsNot Nothing Then - ' si se cargó algun documento - If DtDocumentacionCliente.FiltraParametros("RutaArchivo <> ''").Rows.Count > 0 Then - GuardaVentaDocumentosCliente(Me.CveVenta, ObjDocCliente) - End If - End If - + End If + + + 'GUARDA VENTA + Dim TieneAnticipo As Boolean = False + Dim CveAnticipoPadre As Integer = 0 ' vinculación con anticipo + Dim FolioFiscalRelacionado As String = "" + If DtAnticipos IsNot Nothing AndAlso DtAnticipos.Rows.Count > 0 Then + Dim actualindex As Integer = 0 + For Each row2 As DataRow In DtAnticipos.Rows + TieneAnticipo = True + CveAnticipoPadre = row2("CveVenta").ToString().ToEntero() + Me.CveVentaRelacion = CveAnticipoPadre 'relaciona al anticipo + Me.ImporteRelacion = row2("Importe").ToString().ToDecimal() + FolioFiscalRelacionado = row2("FolioFiscal").ToString() + Me.CveVentaPadre = row2("CveVenta").ToString().ToEntero() + actualindex = actualindex + 1 + Next + End If + + GuardarVenta(Me, ObjVentas, ObjConta, ObjInventario, ObjContr, DtDetalle, Me.CveNCaVincular, ObjContPaq, ObjBancos, ObjOS, ObjEventos, ObjCGame, ObjClientes, ObjAcum:=ObjAcum) + + 'SI ES REFACTURACION + Dim ObjNC As List(Of Object) = Nothing + If ErrorList.Count = 0 Then + If NuevaFactura = 1 AndAlso FacturaDevolucion IsNot Nothing Then + + ObjNC = GeneraNC(ObjVentas, ObjConta, ObjInventario, ObjContr, ObjContPaq, FacturaDevolucion, ObjBancos, ObjEventos) + + If ObjNC Is Nothing Then + ErrorList.Add("No se pudo Cancelar la Factura") + End If + + 'Esquema viejo, evitamos que aparezca por surtir + If ErrorList.Count = 0 Then + If Not ObjInventario.ActualizarEsDevolucionVenta(CveVenta, 2) Then + ErrorList.Add("No se pudo Cancelar el movimiento de almacen de la Factura") + End If + End If + + End If + End If + + 'SI ES amortizacion 3.3 + Dim Obj2 As New List(Of Object) + + If ErrorList.Count = 0 Then + ' cambiar la condicion para saber si hay seleccionado + If TieneAnticipo AndAlso Me.CveTipoAmortizacionAnticipo = 2 Then + + If TieneAnticipo Then + Try + 'DESCOMENTAR + If RegistrarNCAmortizacion(ObjVentas, ObjConta, ObjInventario, ObjContr, ObjContPaq, FacturaDevolucion, ObjBancos, Nothing, Nothing) Then + Obj2.Add(FacturaDevolucion) + End If + Catch ex As Exception + ErrorList.Add("No se pudo generarse la nota de crédito de amortización") + End Try + + + End If + + If Obj2 Is Nothing AndAlso Obj2.Count = 0 Then + ErrorList.Add("No se pudo generarse la nota de crédito de amortización") + End If + End If + End If + + 'MARCA PARA NO SURTIR VENTA DE COTNRATO DE CONSIGNACION DE VENTA | [IPP] : PARCHE + If ErrorList.Count = 0 Then + If Me.CveVenta > 0 And Me.CveAlmacenExistenciasContrato > 0 And Me.TipoDocto = "Ing" Then + If Not ObjInventario.ActualizarEsDevolucionVenta(Me.CveVenta, 2) Then + ErrorList.Add("No se pudo cancelar el movimiento de almacen de la Factura de consignación") + End If + End If + End If + + If ErrorList.Count = 0 Then + If Me.CveVenta > 0 And CveAlmacenExistenciasContrato > 0 And Me.TipoDocto = "Ing" Then + If Not RegistraAlmacenConsignacionVenta(ObjInventario) Then + ErrorList.Add("Ocurrió un error al registrar los movimientos de almacén del contrato de consignación") + End If + End If + End If + + If Me.CveVenta > 0 AndAlso ErrorList.Count = 0 Then + 'ACTUALIZA VENTA COTIZACIÓN + If EraCotizacion = 1 Then + If Not ObjVentas.UpdateVentaCotizacion(Me.CveVenta, Me.CveCotizacion) Then + ErrorList.Add("Ocurrió un error al actualizar la cotización") + End If + End If + + 'ACTUALIZA VENTAPADRE PEDIDO + If DevPed > 0 AndAlso ErrorList.Count = 0 Then + If Not ObjVentas.UpdateVentaCotizacion(DevPed, Me.CveVenta) Then + ErrorList.Add("Ocurrió un error al actualizar la devolución de pedido") + End If + End If + + 'ACTUALIZA LA COLUMNA CveVentaFacturada + If (CveRemision > 0) AndAlso ErrorList.Count = 0 Then + If Not ObjVentas.UpdateVentaRemision(CveRemision, Me.CveVenta) Then + ErrorList.Add("Ocurrió un error al actualizar la remision") + End If + End If + + 'Agregamos las OCs a la tabla + If DTOrdenesCompraPS IsNot Nothing AndAlso DTOrdenesCompraPS.Rows.Count > 0 AndAlso ErrorList.Count = 0 Then + Dim CveVentaDetalle As Integer = 0 + Dim CveOrdenCompraDetalle As Integer = 0 + Dim Cantidad As Decimal = 0 + + + For Each row As DataRow In DtDetalle.Rows + Cantidad = row("Cantidad").ToString.ToDecimal + CveVentaDetalle = row("CveVentaDetalle").ToString.ToEntero + CveOrdenCompraDetalle = row("CveOrdenCompraDetalle").ToString.ToEntero + If Not ObjVentas.AgregarVentaOCDetalle(CveVentaDetalle, CveOrdenCompraDetalle, Cantidad) Then + ErrorList.Add("Ocurrió un Error al agregar el detalle de la Remision") + End If + Next + + End If + + 'Agregamos las Cotizaciones a la tabla + If DtCotizacionesPS IsNot Nothing AndAlso DtCotizacionesPS.Rows.Count > 0 AndAlso ErrorList.Count = 0 Then + Dim CveVentaDetalle As Integer = 0 + Dim CveVentaDetallePadre As Integer = 0 + Dim Cantidad As Decimal = 0 + Dim CvePS As Integer = 0 + Dim PU As Decimal = 0 + + For Each row As DataRow In DtCotizacionesPS.Rows + Cantidad = DtDetalle.FiltroPrimeroValor("Cantidad", $"CveVentaDetalleCotizacion={row("CveVentaDetalle")}").ToDecimal + CvePS = DtDetalle.FiltroPrimeroValor("CvePS", $"CveVentaDetalleCotizacion={row("CveVentaDetalle")}").ToEntero + PU = DtDetalle.FiltroPrimeroValor("PU", $"CveVentaDetalleCotizacion={row("CveVentaDetalle")}").ToDecimal + CveVentaDetalle = DtDetalle.FiltroPrimeroValor("CveVentaDetalle", $"CveVentaDetalleCotizacion={row("CveVentaDetalle")}").ToEntero + CveVentaDetallePadre = row("CveVentaDetalle").ToString.ToEntero + + If Not ObjVentas.AgregaCotizacionDetalle(CveVentaDetalle, CveVentaDetallePadre, Cantidad) Then + ErrorList.Add("Ocurrió un Error al agregar el detalle de la Cotización.") + End If + Next + End If + + + 'Marcamos las ventas anteriores a febrero como surtidas - Ajuste Compu + If ErrorList.Count = 0 Then + If Not ObjVentas.MarcarRemisionesSinSurtir(Me.CveVenta) Then + ErrorList.Add("Ocurrió un Error al marcar la factura") + End If + End If + + If Me.CveOS > 0 And FacturaMateriales = 1 AndAlso ErrorList.Count = 0 Then + If SalidaAlmacenMateriales(ObjInventario, CveOS, ObjConta, True, 3) Then + ErrorList.Add("Ocurrió un Error al dar salida de materiales de almacen") + End If + End If + + If Me.CveFactura > 0 AndAlso ErrorList.Count = 0 Then + If Not ObjVentas.UpdateVentaFacturas(Me.CveFactura, ObjVentas.CveVenta, UsuarioActual.CveEmpresa) Then + ErrorList.Add("No se pudo actualizar la Factura") + End If + End If + + If CveCicloComercial > 0 AndAlso ErrorList.Count = 0 Then + If Not ObjContr.CicloComercialUpdate(Me.CveCicloComercial, True, UsuarioActual.CveEmpresa) Then + ErrorList.Add("No se pudo actualizar ") + End If + End If + + If ErrorList.Count = 0 AndAlso Me.CveVenta > 0 AndAlso DtDocumentacionCliente IsNot Nothing Then + ' si se cargó algun documento + If DtDocumentacionCliente.FiltraParametros("RutaArchivo <> ''").Rows.Count > 0 Then + GuardaVentaDocumentosCliente(Me.CveVenta, ObjDocCliente) + End If + End If + If Me.CveVenta > 0 AndAlso ErrorList.Count = 0 AndAlso (SeGuardoPrePoliza Or Me.TipoDocto.Contiene("Ped", "Cot", "DPe", "PeC", "PA", "Pd2")) Then If Transac Is Nothing Then @@ -871,116 +871,116 @@ Namespace Modelos If ObjContPaqTransac Is Nothing Then If ObjContPaq IsNot Nothing Then ObjContPaq.Commit() End If - - Try - If Not String.IsNullOrEmpty(DirectorioServidor) Then - Dim DirectoriArchivoXML As String = System.IO.Path.Combine(DirectorioServidor, "Empresas", UsuarioActual.CveEmpresa.ToString, Me.TipoDocto) - If Not Directory.Exists(DirectoriArchivoXML) Then - Directory.CreateDirectory(DirectoriArchivoXML) - End If - End If - - Dim SeTimbro As Boolean = False - Dim SeTimbroNC As Boolean = False - Dim EstatusSMS = 0 - - 'TIMBRADO Y CASO ESPECIAL NOTA DE CREDITO - If (TipoDoctoDevolucion = "" OrElse Not TipoDoctoDevolucion.Contiene("Rem", "Cot", "Ped", "DPe", "PA", "Pd2")) Then - - Dim DebeTimbrar As Boolean = Timbrar - If UsuarioActual.CveEmpresa.Contiene(1, 72, 80) Then - 'si tiene anticipos seleccionados y el total es cero, que no se timbre(previo empresa72) - If Me.Amortizacion > 0 And Me.Total <= 0 Then - DebeTimbrar = False - End If - End If - - If Me.TipoDocto.Contiene("Ing", "Egs", "Ant", "Dev") Then - If UsuarioActual.Empresa.TipoFacturacion = "CFDi" Then - - If Me.FemsaFactura IsNot Nothing Then - - 'FACTURA INGRESO/EGRESO - Dim ObjTimbrado As New Timbrado - 'DOCUMENTO ACTUAL - If DebeTimbrar Then - SeTimbro = ObjTimbrado.TimbrarFactura(UsuarioActual, Me) - - 'NOTA DE CREDITO - REFACTURADA - CASO ESPECIAL, TIMBRADO E IMPRESION - If Not IsNothing(Obj2) AndAlso Obj2.Count > 0 Then - Dim ofa As Modelos.Factura = CType(Obj2(0), Modelos.Factura) - 'asigna el foliofiscal del ingreso que se acaba de timbrar, cuando es amortización de anticipo con NC - If TieneAnticipo AndAlso CveTipoAmortizacionAnticipo = 2 Then - ofa.Timbre.CFDIRelacionados.UUID.Clear() - ofa.Timbre.CFDIRelacionados.UUID.Add(ObjTimbrado.UUID) - End If - ObjTimbrado.TimbrarFactura(UsuarioActual, ofa) - End If - - If SeTimbro AndAlso Me.TipoDocto.Contiene("Ing") Then - EstatusSMS = EnviarSMSTimbrado(ObjEventos) - End If - - If Not SeTimbro Then - ErrorList.Add(ObjTimbrado.MensajeErrorCFDI) - End If - - End If - - 'NOTA DE CREDITO DE REFACTURACION - If RefacturacionGeneroNC Then - If Not IsNothing(ObjNC) AndAlso ObjNC.Count > 0 Then - Dim ofa As Modelos.Factura = CType(ObjNC(0), Modelos.Factura) - SeTimbroNC = ObjTimbrado.TimbrarFactura(UsuarioActual, ofa) - End If - End If - End If - End If - End If - End If - - 'VERIFICAR 100% AVANCE A IMPORTE Y CANTIDAD - If Me.TipoDocto.Contiene("Ing", "Ant") AndAlso CveContrato > 0 Then - If ObjContr.GetContratos(CveContrato, UsuarioActual.CveEmpresa) Then - - If ObjContr.DtResultados.Rows.Count > 0 Then - ' si es flexible que notifique el monto maximo, si no lo es que notifique el porcentaje alcanzado... flexible = 2, no flexible = 1 - Dim PorcentajeAvance As Double = ObjContr.DtResultados.Rows(0)("ContratoAvance").ToString.ToDouble - - If ObjContr.DtResultados.Rows(0)("ModalidadDetalle").ToString() = "1" Then - - If PorcentajeAvance >= 100 Then - EnviarNotificacionAvance(ObjContr.DtResultados.Rows(0)("NumeroContrato").ToString(), ObjContr.DtResultados.Rows(0)("DescripcionContrato").ToString(), ObjContr.DtResultados.Rows(0)("ContratoTipo").ToString(), ObjContr.DtResultados.Rows(0)("NombreComercial").ToString(), ObjContr.DtResultados.Rows(0)("CorreoVendedor").ToString()) - End If - Else - Dim MontoMaximo As Double = ObjContr.DtResultados.Rows(0)("ImporteMax").ToString.ToDouble - - If PorcentajeAvance >= 100 And MontoMaximo > 0 Then - EnviarNotificacionAvance(ObjContr.DtResultados.Rows(0)("NumeroContrato").ToString(), ObjContr.DtResultados.Rows(0)("DescripcionContrato").ToString(), ObjContr.DtResultados.Rows(0)("ContratoTipo").ToString(), ObjContr.DtResultados.Rows(0)("NombreComercial").ToString(), ObjContr.DtResultados.Rows(0)("CorreoVendedor").ToString(), MontoMaximo) - End If - End If - - End If - End If - End If - - 'MENSAJE PRINCIPAL - MensajeAlert.AppendFormat(String.Format("
La {0}: {1} se generó correctamente.

", Me.TipoDocumento, Me.SerieFolio)) - - - ' DESCARGA XML - SI SE TIMBRA MANDA CORREO CON FACTURA - If SeTimbro Then - Dim ArchivoXML = String.Format("{0}/XML/{1}/{2}.xml", UsuarioActual.Empresa.Ruta, Me.TipoDocto, Me.SerieFolio) - If File.Exists(ArchivoXML) Then - MensajeAlert.AppendFormat("", Encripta(String.Format("OP=FactVta&CVEVENTA={0}&EXT={1}&SERIEFOLIO={2}&TIPODOCTO={3}", CveVenta, "XML", Me.SerieFolio, Me.TipoDocto))) - End If - - End If - - 'DESCARGA PDF - If Me.TipoDocto.Contiene("Ing", "Rem", "Ant", "Egs", "Dev", "Pd2") Then - 'If Not ImprimeAlert Then - + + Try + If Not String.IsNullOrEmpty(DirectorioServidor) Then + Dim DirectoriArchivoXML As String = System.IO.Path.Combine(DirectorioServidor, "Empresas", UsuarioActual.CveEmpresa.ToString, Me.TipoDocto) + If Not Directory.Exists(DirectoriArchivoXML) Then + Directory.CreateDirectory(DirectoriArchivoXML) + End If + End If + + Dim SeTimbro As Boolean = False + Dim SeTimbroNC As Boolean = False + Dim EstatusSMS = 0 + + 'TIMBRADO Y CASO ESPECIAL NOTA DE CREDITO + If (TipoDoctoDevolucion = "" OrElse Not TipoDoctoDevolucion.Contiene("Rem", "Cot", "Ped", "DPe", "PA", "Pd2")) Then + + Dim DebeTimbrar As Boolean = Timbrar + If UsuarioActual.CveEmpresa.Contiene(1, 72, 80) Then + 'si tiene anticipos seleccionados y el total es cero, que no se timbre(previo empresa72) + If Me.Amortizacion > 0 And Me.Total <= 0 Then + DebeTimbrar = False + End If + End If + + If Me.TipoDocto.Contiene("Ing", "Egs", "Ant", "Dev") Then + If UsuarioActual.Empresa.TipoFacturacion = "CFDi" Then + + If Me.FemsaFactura IsNot Nothing Then + + 'FACTURA INGRESO/EGRESO + Dim ObjTimbrado As New Timbrado + 'DOCUMENTO ACTUAL + If DebeTimbrar Then + SeTimbro = ObjTimbrado.TimbrarFactura(UsuarioActual, Me) + + 'NOTA DE CREDITO - REFACTURADA - CASO ESPECIAL, TIMBRADO E IMPRESION + If Not IsNothing(Obj2) AndAlso Obj2.Count > 0 Then + Dim ofa As Modelos.Factura = CType(Obj2(0), Modelos.Factura) + 'asigna el foliofiscal del ingreso que se acaba de timbrar, cuando es amortización de anticipo con NC + If TieneAnticipo AndAlso CveTipoAmortizacionAnticipo = 2 Then + ofa.Timbre.CFDIRelacionados.UUID.Clear() + ofa.Timbre.CFDIRelacionados.UUID.Add(ObjTimbrado.UUID) + End If + ObjTimbrado.TimbrarFactura(UsuarioActual, ofa) + End If + + If SeTimbro AndAlso Me.TipoDocto.Contiene("Ing") Then + EstatusSMS = EnviarSMSTimbrado(ObjEventos) + End If + + If Not SeTimbro Then + ErrorList.Add(ObjTimbrado.MensajeErrorCFDI) + End If + + End If + + 'NOTA DE CREDITO DE REFACTURACION + If RefacturacionGeneroNC Then + If Not IsNothing(ObjNC) AndAlso ObjNC.Count > 0 Then + Dim ofa As Modelos.Factura = CType(ObjNC(0), Modelos.Factura) + SeTimbroNC = ObjTimbrado.TimbrarFactura(UsuarioActual, ofa) + End If + End If + End If + End If + End If + End If + + 'VERIFICAR 100% AVANCE A IMPORTE Y CANTIDAD + If Me.TipoDocto.Contiene("Ing", "Ant") AndAlso CveContrato > 0 Then + If ObjContr.GetContratos(CveContrato, UsuarioActual.CveEmpresa) Then + + If ObjContr.DtResultados.Rows.Count > 0 Then + ' si es flexible que notifique el monto maximo, si no lo es que notifique el porcentaje alcanzado... flexible = 2, no flexible = 1 + Dim PorcentajeAvance As Double = ObjContr.DtResultados.Rows(0)("ContratoAvance").ToString.ToDouble + + If ObjContr.DtResultados.Rows(0)("ModalidadDetalle").ToString() = "1" Then + + If PorcentajeAvance >= 100 Then + EnviarNotificacionAvance(ObjContr.DtResultados.Rows(0)("NumeroContrato").ToString(), ObjContr.DtResultados.Rows(0)("DescripcionContrato").ToString(), ObjContr.DtResultados.Rows(0)("ContratoTipo").ToString(), ObjContr.DtResultados.Rows(0)("NombreComercial").ToString(), ObjContr.DtResultados.Rows(0)("CorreoVendedor").ToString()) + End If + Else + Dim MontoMaximo As Double = ObjContr.DtResultados.Rows(0)("ImporteMax").ToString.ToDouble + + If PorcentajeAvance >= 100 And MontoMaximo > 0 Then + EnviarNotificacionAvance(ObjContr.DtResultados.Rows(0)("NumeroContrato").ToString(), ObjContr.DtResultados.Rows(0)("DescripcionContrato").ToString(), ObjContr.DtResultados.Rows(0)("ContratoTipo").ToString(), ObjContr.DtResultados.Rows(0)("NombreComercial").ToString(), ObjContr.DtResultados.Rows(0)("CorreoVendedor").ToString(), MontoMaximo) + End If + End If + + End If + End If + End If + + 'MENSAJE PRINCIPAL + MensajeAlert.AppendFormat(String.Format("
La {0}: {1} se generó correctamente.

", Me.TipoDocumento, Me.SerieFolio)) + + + ' DESCARGA XML - SI SE TIMBRA MANDA CORREO CON FACTURA + If SeTimbro Then + Dim ArchivoXML = String.Format("{0}/XML/{1}/{2}.xml", UsuarioActual.Empresa.Ruta, Me.TipoDocto, Me.SerieFolio) + If File.Exists(ArchivoXML) Then + MensajeAlert.AppendFormat("", Encripta(String.Format("OP=FactVta&CVEVENTA={0}&EXT={1}&SERIEFOLIO={2}&TIPODOCTO={3}", CveVenta, "XML", Me.SerieFolio, Me.TipoDocto))) + End If + + End If + + 'DESCARGA PDF + If Me.TipoDocto.Contiene("Ing", "Rem", "Ant", "Egs", "Dev", "Pd2") Then + 'If Not ImprimeAlert Then + If Me.GenerarPDFFactura Then DescargarFactura(CveVenta, CveEmpresa, False) @@ -994,116 +994,116 @@ Namespace Modelos Else MensajeAlert.Append("Ocurrió un error al generar el PDF. Por favor vuelva a entrar a la factura para imprimir el PDF. ") End If - End If - - End If - - 'ERROR DE NO TIMBRADO - If Not SeTimbro And (Me.TipoDocto = "Ing" Or Me.TipoDocto.Contiene("Egs", "Dev") Or Me.TipoDocto = "Ant") Then - MensajeAlert.AppendFormat("La factura no se pudo timbrar. Por favor intentelo de nuevo a traves del boton Emitir.") - End If - - 'ERROR DE NO TIMBRADO NC - If Not IsNothing(ObjNC) AndAlso ObjNC.Count > 0 AndAlso Not SeTimbroNC Then - MensajeAlert.AppendFormat("
La NC #{0} no se pudo timbrar. Por favor intentelo de nuevo a traves del boton Emitir.", CType(ObjNC(0), Modelos.Factura).SerieFolio) - End If - - 'NOTIFICACION DE SMS - Select Case EstatusSMS - Case 1 - MensajeAlert.AppendFormat("
Notificación SMS: enviado con éxito al cliente al celular: {0}", Me.Cliente.CobranzaTelefono) - Case 2 - MensajeAlert.AppendFormat("
Notificación SMS: sin enviar. Ocurrió un error en el envío, por favor verifique la información del cliente.") - Case 3 - MensajeAlert.AppendFormat("
Notificación SMS: sin enviar. No se pudo cargar el celular del cliente, por favor verifique la información del cliente.") - End Select - - Retorno.LigaPDF = $"{UrlSitio}Compras/PopUpVerFactura.aspx?P={Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1", CveVenta))}" - - If Me.TipoDocto = "Cot" Then - - If Not CveEmpresaCRM > 0 Then - If Me.CveVenta > 0 Then MensajeAlert = New StringBuilder - Dim ArchivoCotizacion As New System.IO.FileInfo(String.Format("{0}Formatos/Cotizacion.rdlc", UsuarioActual.Empresa.Ruta)) - - If ArchivoCotizacion.Exists Then - MensajeAlert.AppendFormat("
", Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=0", CveVenta))) - Else - MensajeAlert.Append("Ocurrió un error al generar el PDF. Por favor vuelva a entrar a la factura para imprimir el PDF. ") - End If - End If - - End If - - 'MOVIMIENTO DE ALMACEN - If Me.Inv_CveMovimiento > 0 Then - MensajeAlert.AppendFormat("

Movimiento de Almacén
", Me.Inv_CveMovimiento) - End If - - If TieneAnticipo AndAlso CveTipoAmortizacionAnticipo = 2 Then - MensajeAlert.AppendFormat("

Se generó una Nota de crédito Folio: {0} amortizando el anticipo
", FacturaDevolucion.Folio) - End If - - If TipoMensajeRespuesta = TipoMensajeRespuesta.HTML Then - ListaMensajes.Add(MensajeAlert.ToString) - Retorno.LigaCliente = $"document.location.href=""/Ventas/Clientes.aspx?CveCliente={Me.CveCliente}&Opt=3"";" - Retorno.LigaVenta = "document.location.href=""/Ventas/Ventas.aspx?CveVenta=-1"";" - Retorno.LigaPV = "document.location.href=""/Ventas/PV.aspx"";" - Retorno.LigaCRM = $"document.location.href=""/CRM/EmpresaCRM.aspx?CveEmpresaCRM={Me.CveEmpresaCRM}"";" - ElseIf TipoMensajeRespuesta = TipoMensajeRespuesta.TextoLimpio Then - ListaMensajes.Add(String.Format("El {0} se generó correctamente", Me.TipoDocumento)) - Retorno.LigaCliente = $"{UrlSitio}Ventas/Clientes.aspx?CveCliente={Me.CveCliente}&Opt=3" - Retorno.LigaVenta = $"{UrlSitio}Ventas/Ventas.aspx?CveVenta={Me.CveVenta}" - Retorno.LigaCRM = $"{UrlSitio}CRM/EmpresaCRM.aspx?CveEmpresaCRM={Me.CveEmpresaCRM}" - End If - - Retorno.CveVenta = Me.CveVenta - Retorno.SerieFolio = Me.SerieFolio - Retorno.SeTimbro = SeTimbro - Retorno.SeTimbroNotaCredito = SeTimbroNC - Retorno.Mensajes = ListaMensajes - Retorno.TieneError = False - Catch ex As Exception - ListaMensajes.Add(ex.ToString()) - Retorno.Mensajes = ListaMensajes - End Try - Else + End If + + End If + + 'ERROR DE NO TIMBRADO + If Not SeTimbro And (Me.TipoDocto = "Ing" Or Me.TipoDocto.Contiene("Egs", "Dev") Or Me.TipoDocto = "Ant") Then + MensajeAlert.AppendFormat("La factura no se pudo timbrar. Por favor intentelo de nuevo a traves del boton Emitir.") + End If + + 'ERROR DE NO TIMBRADO NC + If Not IsNothing(ObjNC) AndAlso ObjNC.Count > 0 AndAlso Not SeTimbroNC Then + MensajeAlert.AppendFormat("
La NC #{0} no se pudo timbrar. Por favor intentelo de nuevo a traves del boton Emitir.", CType(ObjNC(0), Modelos.Factura).SerieFolio) + End If + + 'NOTIFICACION DE SMS + Select Case EstatusSMS + Case 1 + MensajeAlert.AppendFormat("
Notificación SMS: enviado con éxito al cliente al celular: {0}", Me.Cliente.CobranzaTelefono) + Case 2 + MensajeAlert.AppendFormat("
Notificación SMS: sin enviar. Ocurrió un error en el envío, por favor verifique la información del cliente.") + Case 3 + MensajeAlert.AppendFormat("
Notificación SMS: sin enviar. No se pudo cargar el celular del cliente, por favor verifique la información del cliente.") + End Select + + Retorno.LigaPDF = $"{UrlSitio}Compras/PopUpVerFactura.aspx?P={Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1", CveVenta))}" + + If Me.TipoDocto = "Cot" Then + + If Not CveEmpresaCRM > 0 Then + If Me.CveVenta > 0 Then MensajeAlert = New StringBuilder + Dim ArchivoCotizacion As New System.IO.FileInfo(String.Format("{0}Formatos/Cotizacion.rdlc", UsuarioActual.Empresa.Ruta)) + + If ArchivoCotizacion.Exists Then + MensajeAlert.AppendFormat("
", Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=0", CveVenta))) + Else + MensajeAlert.Append("Ocurrió un error al generar el PDF. Por favor vuelva a entrar a la factura para imprimir el PDF. ") + End If + End If + + End If + + 'MOVIMIENTO DE ALMACEN + If Me.Inv_CveMovimiento > 0 Then + MensajeAlert.AppendFormat("

Movimiento de Almacén
", Me.Inv_CveMovimiento) + End If + + If TieneAnticipo AndAlso CveTipoAmortizacionAnticipo = 2 Then + MensajeAlert.AppendFormat("

Se generó una Nota de crédito Folio: {0} amortizando el anticipo
", FacturaDevolucion.Folio) + End If + + If TipoMensajeRespuesta = TipoMensajeRespuesta.HTML Then + ListaMensajes.Add(MensajeAlert.ToString) + Retorno.LigaCliente = $"document.location.href=""/Ventas/Clientes.aspx?CveCliente={Me.CveCliente}&Opt=3"";" + Retorno.LigaVenta = "document.location.href=""/Ventas/Ventas.aspx?CveVenta=-1"";" + Retorno.LigaPV = "document.location.href=""/Ventas/PV.aspx"";" + Retorno.LigaCRM = $"document.location.href=""/CRM/EmpresaCRM.aspx?CveEmpresaCRM={Me.CveEmpresaCRM}"";" + ElseIf TipoMensajeRespuesta = TipoMensajeRespuesta.TextoLimpio Then + ListaMensajes.Add(String.Format("El {0} se generó correctamente", Me.TipoDocumento)) + Retorno.LigaCliente = $"{UrlSitio}Ventas/Clientes.aspx?CveCliente={Me.CveCliente}&Opt=3" + Retorno.LigaVenta = $"{UrlSitio}Ventas/Ventas.aspx?CveVenta={Me.CveVenta}" + Retorno.LigaCRM = $"{UrlSitio}CRM/EmpresaCRM.aspx?CveEmpresaCRM={Me.CveEmpresaCRM}" + End If + + Retorno.CveVenta = Me.CveVenta + Retorno.SerieFolio = Me.SerieFolio + Retorno.SeTimbro = SeTimbro + Retorno.SeTimbroNotaCredito = SeTimbroNC + Retorno.Mensajes = ListaMensajes + Retorno.TieneError = False + Catch ex As Exception + ListaMensajes.Add(ex.ToString()) + Retorno.Mensajes = ListaMensajes + End Try + Else If Transac Is Nothing Then ObjVentas.RollBack() - End If + End If If ObjContPaqTransac Is Nothing Then If ObjContPaq IsNot Nothing Then ObjContPaq.RollBack() - End If - Retorno.Mensajes = ErrorList - Retorno.TieneError = True - End If - - Else + End If + Retorno.Mensajes = ErrorList + Retorno.TieneError = True + End If + + Else If Transac Is Nothing Then ObjVentas.RollBack() End If If ObjContPaqTransac Is Nothing Then If ObjContPaq IsNot Nothing Then ObjContPaq.RollBack() - End If - - ErrorList.Add("Ocurrió un error al procesar los datos. Por favor rectifique y vuelta a intentar.") - Retorno.Mensajes = ErrorList - Retorno.TieneError = True - End If - Catch ex As Exception - Me.ErrorList.Add(ex.ToString()) - + End If + + ErrorList.Add("Ocurrió un error al procesar los datos. Por favor rectifique y vuelta a intentar.") + Retorno.Mensajes = ErrorList + Retorno.TieneError = True + End If + Catch ex As Exception + Me.ErrorList.Add(ex.ToString()) + If Transac Is Nothing Then ObjVentas.RollBack() End If If ObjContPaqTransac Is Nothing Then If ObjContPaq IsNot Nothing Then ObjContPaq.RollBack() - End If - - Retorno.Mensajes = ErrorList - Retorno.TieneError = True - Finally + End If + + Retorno.Mensajes = ErrorList + Retorno.TieneError = True + Finally If Transac Is Nothing Then ObjVentas.Dispose() ObjConta.Dispose() @@ -1116,14 +1116,14 @@ Namespace Modelos End If If ObjContPaqTransac Is Nothing Then If ObjContPaq IsNot Nothing Then ObjContPaq.RollBack() - End If - End Try - Else - Retorno.Mensajes.Add("No se han agregado productos/servicios") - End If - End If - - Return Retorno + End If + End Try + Else + Retorno.Mensajes.Add("No se han agregado productos/servicios") + End If + End If + + Return Retorno End Function Private Function DescargarFactura(CveVenta As Integer, CveEmpresa As Integer, Optional GetBytes As Boolean = True) As Byte() @@ -1148,764 +1148,764 @@ Namespace Modelos Return File End Function -#Region " GUARDAR - VENTA, PREPOLIZAS, INV, NC , ESTIMACIONES, AC, NOTA DE CRÉDITO " - Private Function RegistrarNCAmortizacion(ObjVentas As ClsVentas, ObjConta As ClsContabilidad, ObjInventario As ClsInventarios, ObjContr As ClsContratos, ObjContPaq As ClsContPAQi, ByVal factura As Modelos.Factura, ObjBancos As ClsBancos, TmpDTconceptos As DataTable, ByRef ObjEventos As ClsOIEventos) As Boolean - Dim ProcesoCorrecto As Boolean = True - - 'Generamos el nuevo folio - Dim ObjFolios As New ClsGralFolios(ObjVentas.IniciaTransacSQL()) - - If ObjFolios.GetFolios(factura.TipoDocto, UsuarioActual.CveEmpresa) Then - Dim DT As DataTable = ObjFolios.DtResultados.FiltraParametros(String.Format(" CveSubProyecto = {0} And Estado = 'Activo'", Me.CveSubProyecto)) - If DT.Rows.Count > 0 Then - factura.Folio = DT.Rows(0)("FActual").ToString.ToEntero - Else - ProcesoCorrecto = False - End If - DT.Dispose() - End If - - '** genero los datos de la NC - Dim tmpcon As DataTable = DtDetalle.Clone - tmpcon.Clear() - - Dim drpss As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, SATClavePS:="84111506").FiltroPrimero("SATClavePS = '84111506'") - - If drpss IsNot Nothing Then - Dim ii As Integer = 1 - Dim CveVentaP As Integer = 0 - For Each gvrt As DataRow In DtAnticipos.Rows - Dim CveSub As Integer = DtDetalle.FiltroPrimeroValor("CveSubProyecto").ToEntero - Dim dr As DataRow = tmpcon.NewRow - Dim Cantidad As Decimal = 1 - Dim PU As Decimal = gvrt("Importe").ToString().ToDecimal() - Dim TotalCalculableImpuestos As Decimal = (Cantidad * (PU)) - dr("CvePS") = drpss("CvePS") - dr("PS") = drpss("PS") - dr("OBS") = drpss("PS") - dr("PU") = PU - dr("Cantidad") = Cantidad - dr("CveUM") = drpss("CveUnidadMedida") - dr("SATClaveProdServ") = "84111506" - dr("SATClaveUM") = "ACT" - dr("Consec") = ii - - If drpss("IVA").ToString = "-1" Then - dr("PorcentajeIVA") = SubProyectoPorcentajeIVA ' GlobalDTSubProyectos(-1,cves DrPS("IVA") - Else - dr("PorcentajeIVA") = drpss("IVA") - End If - - dr("IVA") = dr("PorcentajeIVA") - dr("ImporteIVA") = Math.Round(dr("PorcentajeIVA").ToString.ToDecimal * TotalCalculableImpuestos, 2) - - dr("ImporteRetIVA") = Math.Round(Me.Cliente.RetIVA * TotalCalculableImpuestos, 2) - dr("ImporteRetISR") = Math.Round(Me.Cliente.RetIVA * TotalCalculableImpuestos, 2) - dr("PorcentajeRetIVA") = Me.Cliente.RetIVA - dr("PorcentajeRetISR") = Me.Cliente.RetISR - dr("PorcentajeIEPS") = 0 ' DrPS("IEPSPorcentaje") - dr("ImporteIEPS") = 0 'Math.Round(DrPS("IEPSPorcentaje").ToString.ToDecimal * TotalCalculableImpuestos, NumeroDecimales) - dr("IEPS") = dr("ImporteIEPS") - dr("Descuento") = Math.Round(0, 2) - dr("TipoDescuento") = TipoDescuento - dr("Total") = (Cantidad * PU) - dr("CveClasificacion") = drpss("CveClasificacion") - dr("CveSubProyecto") = CveSub - dr("TotalImporte") = Math.Round(Cantidad * PU, 2) - CveVentaP = gvrt("CveVenta").ToString().ToEntero() - tmpcon.Rows.Add(dr) - ii += 1 - - Next - - '**** impuestos locales - - - factura.DtDetalle = tmpcon - Dim TotalSubTotal As Decimal = tmpcon.SUM("TotalImporte").ToDecimal - Dim TotalDescuentos As Decimal = tmpcon.SUM("Descuento").ToDecimal - - Dim TotalIVA As Decimal = tmpcon.SUM("ImporteIVA").ToDecimal - Dim TotalIEPS As Decimal = tmpcon.SUM("ImporteIEPS").ToDecimal - Dim TotalRetIVA As Decimal = tmpcon.SUM("ImporteRetIVA").ToDecimal - Dim TotalRetISR As Decimal = tmpcon.SUM("ImporteRetISR").ToDecimal - Dim Total As Decimal = 0 - Dim TotalImpuestosLocales As Decimal = 0 - Total = (TotalSubTotal - TotalDescuentos + TotalIVA + TotalIEPS - TotalRetIVA - TotalRetISR - TotalImpuestosLocales) - - factura.SubTotal = TotalSubTotal - factura.Descuento = 0 - factura.IVA = TotalIVA - factura.IEPS = TotalIEPS - factura.RetIVA = TotalRetIVA - factura.RetISR = TotalRetISR - factura.Total = Total - factura.CveVentaPadre = CveVentaP - - 'Registramos la venta - GuardarVenta(factura, ObjVentas, ObjConta, ObjInventario, ObjContr, tmpcon, -1, ObjContPaq, ObjBancos) - - ''Timbramos - Else - ErrorList.Add("No se encontró un producto para generar la nota de crédito") - End If - - - Return ProcesoCorrecto - End Function - Private Sub EnviarNotificacionAvance(NumeroContrato As String, DescripcionContrato As String, ContratoTipo As String, Cliente As String, CorreoVendedor As String, Optional MontoMaximo As Double = 0) - - Dim ObjMail As New ClsSisMail() - - Dim CorreoLicitacion As String = "" - - Dim Para As String = String.Format("{0};{1}", CorreoVendedor, CorreoLicitacion) - Dim Asunto As String = "NOTIFICACION DE 100% DE AVANCE DE CONTRATO" - Dim Cuerpo As String = "" - - If MontoMaximo > 0 Then - Cuerpo = String.Format("El Contrato {0} - {1} ({2}) con cliente {4} ha alcanzado el monto máximo de {3}.", NumeroContrato, DescripcionContrato, ContratoTipo, MontoMaximo.ToString("C2"), Cliente) - Else - Cuerpo = String.Format("El Contrato {0} - {1} ({2}) con cliente {3} ha llegado al 100% de Avance.", NumeroContrato, DescripcionContrato, ContratoTipo, Cliente) - End If - - ObjMail.SendMail(ClsPaginas.EmpresaNotificaciones, Para, Asunto, Cuerpo) - - End Sub - Private Function EnviarSMSTimbrado(ByRef ObjEventos As ClsOIEventos) As Integer - Dim Mensaje = UsuarioActual.Empresa.Funcionalidad(152) - If Mensaje = "" Then Return 0 - - Dim Celular = Me.Cliente.CobranzaTelefono - If Celular.Length <> 10 Then Return 3 - - 'ARMA MENSAJE - '4: VSH Monitoreo aviso de: Factura pendiente {SerieFolio} del {Fecha} por ${Importe} fecha limite de pago {FechaPago} Bancomer 0171426931-{ClienteNombreCorto} - Mensaje = Mensaje.Replace("{SerieFolio}", Me.SerieFolio) - Mensaje = Mensaje.Replace("{Fecha}", Me.Fecha.ToString("dd-MMM-yyyy").Replace(".", "")) - Mensaje = Mensaje.Replace("{Importe}", Me.Total.FormatoNumero) - Mensaje = Mensaje.Replace("{FechaPago}", Me.FechaPago.ToString("dd-MMM-yyyy").Replace(".", "")) - Mensaje = Mensaje.Replace("{ClienteNombreCorto}", Me.Cliente.NombreCorto) - If Mensaje = "" Then Return 2 - - Dim ObjMensaje As New ClsTecnoMovil - If ObjMensaje.EnviarMensajeWS(Celular, Mensaje) Then - If ObjEventos.AddEventoBitacora($"Notificación al cliente via SMS. Mensaje: {Mensaje}", "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCliente:=Me.CveCliente, CveVenta:=Me.CveVenta) Then - End If - Return 1 - Else - Return 2 - End If - End Function - Private Sub GuardaVentaDocumentosCliente(tCveVenta As Integer, ByRef objDocumentacion As ClsEdocumentacion) - If tCveVenta > 0 Then - - For Each DRow As DataRow In DtDocumentacionCliente.FiltraParametros("RutaArchivo <> '' ").Rows - Dim CveDocumentacion As Integer = DRow("CveDocumentacion").ToString.ToEntero - Dim Estatus As Integer = DRow("Estatus").ToString.ToEntero - Dim Adjunto As String = DRow("Adjunto").ToString - Dim NombreArchivo As String = "" - Dim ArchivoRuta As String = DRow("RutaArchivo").ToString - If ArchivoRuta.Length > 0 Then Adjunto = ArchivoRuta - Dim Extension As String = Path.GetExtension(Adjunto) - - Dim CveDocumentacionElectronica As Integer = objDocumentacion.DocumentacionElectronicaAdd(CveDocumentacion, -1, -1, -1, 1, DRow("Observacion").ToString, Extension, UsuarioActual.CveUsuario, New Date(1900, 1, 1), CveVenta:=tCveVenta) - - If CveDocumentacionElectronica <= 0 Then ErrorList.Add("No se pudo registrar el documento ") - NombreArchivo = $"{CveDocumentacionElectronica}{Extension}" - - If ArchivoRuta.Length > 0 And NombreArchivo.Length > 0 Then - If Not Directory.Exists($"{UsuarioActual.Empresa.Ruta}Documentacion\Ventas\") Then - Directory.CreateDirectory($"{UsuarioActual.Empresa.Ruta}Documentacion\Ventas\") - End If - - Dim ArchivoExistenteRuta As String = $"{UsuarioActual.Empresa.Ruta}Documentacion\Ventas\{NombreArchivo}" - - If File.Exists(ArchivoExistenteRuta) Then File.Delete(ArchivoExistenteRuta) - - Try - - File.Move(ArchivoRuta, ArchivoExistenteRuta) - Catch ex As Exception - ErrorList.Add("No se pudo guardar el documento de la venta") - Exit For - End Try - - End If - Next - - End If - - End Sub - Public Sub GuardarVenta(ByRef factura As Modelos.Factura, ByRef ObjVentas As ClsVentas, ByRef ObjConta As ClsContabilidad, ByRef ObjInventario As ClsInventarios, ByRef ObjContr As ClsContratos, ByRef TmpDTDetalle As DataTable, CveNCaVincular As Integer, ByRef objContPaqi As ClsContPAQi, Optional ByRef ObjBancos As ClsBancos = Nothing, Optional ByRef ObjOS As ClsOS = Nothing, ByRef Optional ObjEventos As ClsOIEventos = Nothing, ByRef Optional ObjCGame As ClsCGame = Nothing, ByRef Optional ObjCliente As ClsClientes = Nothing, Optional EsNotaCredito As Boolean = False, Optional ObjAcum As ClsAcumuladores = Nothing) - Dim Msgok As New StringBuilder - - factura.CvePrePoliza = ObjConta.AddPrePolizas("Ventas/GuardarVenta", factura.CvePlantillaPoliza, factura.TotalTC, factura.TotalTC, factura.CveMoneda, factura.Fecha, If(factura.CveEmpresaCRM > 0, factura.EmpresaCRM, factura.Cliente.Nombre), factura.CveUsuario, factura.CveEmpresa) - - If Not ObjVentas.AddVenta(factura.TipoDocto, factura.Folio, factura.CveCliente, factura.CveClienteSucursal, factura.SubTotalTC, factura.DescuentoTC, - factura.AmortizacionTC, factura.IVATC, factura.RetIVATC, factura.RetISRTC, - factura.TotalTC, factura.CveMoneda, factura.TipoCambio, factura.CveMetodoPago, factura.CondicionesPago, factura.FormaPago, factura.FechaPago, factura.Fecha, factura.MotivoDescuento, - factura.Observaciones, factura.FechaEjecucion, factura.CveVendedor, - factura.Alfa1, factura.Alfa2, factura.Alfa3, factura.Num1, factura.Num2, factura.Num3, - factura.Fech1, factura.Fech2, factura.Fech3, factura.CveCorte, factura.CveMesa, factura.NumeroPersonas, factura.CvePrePoliza, factura.CveUsuario, factura.CveEmpresa, - AtencionA:=factura.AtencionA, TelefonoGenerico:=factura.TelefonoGenerico, CveContrato:=factura.CveContrato, - CveVentaPadre:=If(AplicaDevolucion, CveVentaDevolucion, factura.CveVentaPadre), Det_FechaOrdenCompra:=factura.Det_FechaOrdenCompra, Det_OrdenCompra:=factura.Det_OrdenCompra, otros:=factura.Otros, - Entrega:=factura.Entrega, Vigencia:=If(factura.TipoDocto = "Cot", FechaVencimiento, MinFecha), - CveAlmacenTraspasoDestino:=CveAlmacenTraspasoDestino, CveAlmacenTraspasoOrigen:=CveAlmacenTraspasoOrigen, - CveDireccionEnvio:=factura.CveDireccionEnvio, CveOC:=factura.CveOC, IEPS:=factura.IEPSTC, Serie:=factura.Serie, CveCondicionEntrega:=factura.CveCondicionEntrega, - PedidoContrato:=factura.PedidoContrato, ObservacionesAlmacen:=factura.ObservacionesAlmacen, CveSubProyecto:=factura.CveSubProyecto, CveSubProyectoCobranza:=factura.CveSubProyectoCobranza, CveSubProyectoEjecucion:=factura.CveSubProyectoEjecucion, CveFormaPago33:=factura.CveFormaPago33, - CveMetodoPago33:=factura.CveMetodoPago33, CveUsoCFDI:=factura.CveUsoCFDI, OrdenCompra:=factura.OrdenCompra, CveCuentaTerminal:=factura.CveCuentaTerminal, CveTipoRelacion:=factura.CveTipoRelacion, ImpuestoLocal:=TotalImpuestoLocal, - CveVentaRelacion:=(If(factura.CveVentaRelacion.ToEntero > 0, factura.CveVentaRelacion, -1)), ImporteRelacion:=(If(factura.ImporteRelacion <> Nothing, factura.ImporteRelacion, -1)), - CveTipoAmortizacionAnticipo:=factura.CveTipoAmortizacionAnticipo, CveEmpresaCRM:=CveEmpresaCRM, EsInterno:=EsInterno) Then - - ErrorList.Add("Ocurrió un error al Generar la Venta.
Revise su factura y cualquier detalle comuníquese a Soporte Técnico") - - End If - - If Not GuardarUsados(ObjVentas.IniciaTransacSQL, ObjVentas.CveVenta, ObjVentas, factura.TipoDocto) Then - ErrorList.Add("Error al guardar usados") - End If - - - If ErrorList.Count = 0 AndAlso ObjVentas.CveVenta > 0 Then - - factura.CveVenta = ObjVentas.CveVenta - factura.Serie = ObjVentas.Serie - factura.Folio = ObjVentas.Folio - factura.Timbre.Comprobante.Serie = ObjVentas.Serie - factura.Timbre.Comprobante.Folio = ObjVentas.Folio.ToString - - If factura.TipoDocto = "Egs" AndAlso NuevaFactura = 1 Then - If DtVentasNC Is Nothing Then - InicializaDTVentasNC() - End If - CargaNCDT(factura.CveVentaPadre, factura.Total, NuevaFactura:=NuevaFactura, ObjVentas:=ObjVentas) - End If - - 'Se agregan los PS - For Each Row As DataRow In TmpDTDetalle.Rows - If Not ObjVentas.AddVentaDetalle(ObjVentas.CveVenta, Row("CvePS").ToString.ToEntero, Row("Cantidad").ToString.ToDouble, Row("CveUM").ToString.ToEntero, - Row("PU").ToString.ToDouble(If(factura.ConvertirPesos, factura.TipoCambio, 1)), Row("ImporteIVA").ToString.ToDouble(If(factura.ConvertirPesos, factura.TipoCambio, 1)), Math.Round((Row("Total").ToString.ToDouble(If(factura.ConvertirPesos, factura.TipoCambio, 1)) * (1 + Row("PorcentajeIVA").ToString.ToDouble(If(factura.ConvertirPesos, factura.TipoCambio, 1)))), 6), - Row("Obs").ToString, Row("Descuento").ToString.ToDouble(If(factura.ConvertirPesos, factura.TipoCambio, 1)), Row("TipoDescuento").ToString.ToEntero, Row("CveSubProyecto").ToString.ToEntero, Row("CvePresupuestoIngreso").ToString.ToEntero, - TiempoEntrega:=Row("TiempoEntrega").ToString, CveVentaDetallePadre:=Row("CveVentaDetalle").ToString.ToEntero, CveContratoDetalle:=Row("CveContratoDetalle").ToString.ToEntero, - CvePromocionDetalle:=If(DtPromociones IsNot Nothing, DtPromociones.FiltroPrimeroValor("CvePromocionDetalle", $"CvePS={Row("CvePS").ToString}").ToEntero, -1), - IEPS:=Row("ImporteIEPS").ToString.ToDouble, CveMovimientoDetallePedido:=Row("CveMovimientoDetallePedido").ToString.ToEntero, - ImporteRetIVA:=Row("ImporteRetIVA").ToString.ToDouble, ImporteRetISR:=Row("ImporteRetISR").ToString.ToDouble, - PorcentajeIEPS:=Row("PorcentajeIEPS").ToString.ToDouble, PorcentajeRetIVA:=Row("PorcentajeRetIVA").ToString.ToDouble, PorcentajeRetISR:=Row("PorcentajeRetISR").ToString.ToDouble, CuentaPredial:=Row("CuentaPredial").ToString, - PorcentajeIVA:=Row("PorcentajeIVA").ToString.ToDecimal) Then - ErrorList.Add("Ocurrió un error al agregar un Producto o Servicio a la factura.
Revise su factura y cualquier detalle comuníquese a Soporte Técnico") - Exit For - Else - Row("CveVenta") = factura.CveVenta - Row("CveVentaDetalle") = ObjVentas.CveVentaDetalle - - If DtInventario IsNot Nothing Then - If DtInventario.Select($"CvePS={Row("CvePS").ToString.ToEntero}").Length > 0 Then - Dim rowInv As DataRow = DtInventario.Select($"CvePS={Row("CvePS").ToString.ToEntero}")(0) - rowInv("CveVentaDetalle") = ObjVentas.CveVentaDetalle - End If - End If - - If DtRecepcionUsados IsNot Nothing Then - If DtRecepcionUsados.Select($"CvePS={Row("CvePS").ToString.ToEntero}").Length > 0 Then - Dim rowInv As DataRow = DtRecepcionUsados.Select($"CvePS={Row("CvePS").ToString.ToEntero}")(0) - rowInv("CveVentaDetalle") = ObjVentas.CveVentaDetalle - End If +#Region " GUARDAR - VENTA, PREPOLIZAS, INV, NC , ESTIMACIONES, AC, NOTA DE CRÉDITO " + Private Function RegistrarNCAmortizacion(ObjVentas As ClsVentas, ObjConta As ClsContabilidad, ObjInventario As ClsInventarios, ObjContr As ClsContratos, ObjContPaq As ClsContPAQi, ByVal factura As Modelos.Factura, ObjBancos As ClsBancos, TmpDTconceptos As DataTable, ByRef ObjEventos As ClsOIEventos) As Boolean + Dim ProcesoCorrecto As Boolean = True + + 'Generamos el nuevo folio + Dim ObjFolios As New ClsGralFolios(ObjVentas.IniciaTransacSQL()) + + If ObjFolios.GetFolios(factura.TipoDocto, UsuarioActual.CveEmpresa) Then + Dim DT As DataTable = ObjFolios.DtResultados.FiltraParametros(String.Format(" CveSubProyecto = {0} And Estado = 'Activo'", Me.CveSubProyecto)) + If DT.Rows.Count > 0 Then + factura.Folio = DT.Rows(0)("FActual").ToString.ToEntero + Else + ProcesoCorrecto = False + End If + DT.Dispose() + End If + + '** genero los datos de la NC + Dim tmpcon As DataTable = DtDetalle.Clone + tmpcon.Clear() + + Dim drpss As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, SATClavePS:="84111506").FiltroPrimero("SATClavePS = '84111506'") + + If drpss IsNot Nothing Then + Dim ii As Integer = 1 + Dim CveVentaP As Integer = 0 + For Each gvrt As DataRow In DtAnticipos.Rows + Dim CveSub As Integer = DtDetalle.FiltroPrimeroValor("CveSubProyecto").ToEntero + Dim dr As DataRow = tmpcon.NewRow + Dim Cantidad As Decimal = 1 + Dim PU As Decimal = gvrt("Importe").ToString().ToDecimal() + Dim TotalCalculableImpuestos As Decimal = (Cantidad * (PU)) + dr("CvePS") = drpss("CvePS") + dr("PS") = drpss("PS") + dr("OBS") = drpss("PS") + dr("PU") = PU + dr("Cantidad") = Cantidad + dr("CveUM") = drpss("CveUnidadMedida") + dr("SATClaveProdServ") = "84111506" + dr("SATClaveUM") = "ACT" + dr("Consec") = ii + + If drpss("IVA").ToString = "-1" Then + dr("PorcentajeIVA") = SubProyectoPorcentajeIVA ' GlobalDTSubProyectos(-1,cves DrPS("IVA") + Else + dr("PorcentajeIVA") = drpss("IVA") + End If + + dr("IVA") = dr("PorcentajeIVA") + dr("ImporteIVA") = Math.Round(dr("PorcentajeIVA").ToString.ToDecimal * TotalCalculableImpuestos, 2) + + dr("ImporteRetIVA") = Math.Round(Me.Cliente.RetIVA * TotalCalculableImpuestos, 2) + dr("ImporteRetISR") = Math.Round(Me.Cliente.RetIVA * TotalCalculableImpuestos, 2) + dr("PorcentajeRetIVA") = Me.Cliente.RetIVA + dr("PorcentajeRetISR") = Me.Cliente.RetISR + dr("PorcentajeIEPS") = 0 ' DrPS("IEPSPorcentaje") + dr("ImporteIEPS") = 0 'Math.Round(DrPS("IEPSPorcentaje").ToString.ToDecimal * TotalCalculableImpuestos, NumeroDecimales) + dr("IEPS") = dr("ImporteIEPS") + dr("Descuento") = Math.Round(0, 2) + dr("TipoDescuento") = TipoDescuento + dr("Total") = (Cantidad * PU) + dr("CveClasificacion") = drpss("CveClasificacion") + dr("CveSubProyecto") = CveSub + dr("TotalImporte") = Math.Round(Cantidad * PU, 2) + CveVentaP = gvrt("CveVenta").ToString().ToEntero() + tmpcon.Rows.Add(dr) + ii += 1 + + Next + + '**** impuestos locales + + + factura.DtDetalle = tmpcon + Dim TotalSubTotal As Decimal = tmpcon.SUM("TotalImporte").ToDecimal + Dim TotalDescuentos As Decimal = tmpcon.SUM("Descuento").ToDecimal + + Dim TotalIVA As Decimal = tmpcon.SUM("ImporteIVA").ToDecimal + Dim TotalIEPS As Decimal = tmpcon.SUM("ImporteIEPS").ToDecimal + Dim TotalRetIVA As Decimal = tmpcon.SUM("ImporteRetIVA").ToDecimal + Dim TotalRetISR As Decimal = tmpcon.SUM("ImporteRetISR").ToDecimal + Dim Total As Decimal = 0 + Dim TotalImpuestosLocales As Decimal = 0 + Total = (TotalSubTotal - TotalDescuentos + TotalIVA + TotalIEPS - TotalRetIVA - TotalRetISR - TotalImpuestosLocales) + + factura.SubTotal = TotalSubTotal + factura.Descuento = 0 + factura.IVA = TotalIVA + factura.IEPS = TotalIEPS + factura.RetIVA = TotalRetIVA + factura.RetISR = TotalRetISR + factura.Total = Total + factura.CveVentaPadre = CveVentaP + + 'Registramos la venta + GuardarVenta(factura, ObjVentas, ObjConta, ObjInventario, ObjContr, tmpcon, -1, ObjContPaq, ObjBancos) + + ''Timbramos + Else + ErrorList.Add("No se encontró un producto para generar la nota de crédito") + End If + + + Return ProcesoCorrecto + End Function + Private Sub EnviarNotificacionAvance(NumeroContrato As String, DescripcionContrato As String, ContratoTipo As String, Cliente As String, CorreoVendedor As String, Optional MontoMaximo As Double = 0) + + Dim ObjMail As New ClsSisMail() + + Dim CorreoLicitacion As String = "" + + Dim Para As String = String.Format("{0};{1}", CorreoVendedor, CorreoLicitacion) + Dim Asunto As String = "NOTIFICACION DE 100% DE AVANCE DE CONTRATO" + Dim Cuerpo As String = "" + + If MontoMaximo > 0 Then + Cuerpo = String.Format("El Contrato {0} - {1} ({2}) con cliente {4} ha alcanzado el monto máximo de {3}.", NumeroContrato, DescripcionContrato, ContratoTipo, MontoMaximo.ToString("C2"), Cliente) + Else + Cuerpo = String.Format("El Contrato {0} - {1} ({2}) con cliente {3} ha llegado al 100% de Avance.", NumeroContrato, DescripcionContrato, ContratoTipo, Cliente) + End If + + ObjMail.SendMail(ClsPaginas.EmpresaNotificaciones, Para, Asunto, Cuerpo) + + End Sub + Private Function EnviarSMSTimbrado(ByRef ObjEventos As ClsOIEventos) As Integer + Dim Mensaje = UsuarioActual.Empresa.Funcionalidad(152) + If Mensaje = "" Then Return 0 + + Dim Celular = Me.Cliente.CobranzaTelefono + If Celular.Length <> 10 Then Return 3 + + 'ARMA MENSAJE + '4: VSH Monitoreo aviso de: Factura pendiente {SerieFolio} del {Fecha} por ${Importe} fecha limite de pago {FechaPago} Bancomer 0171426931-{ClienteNombreCorto} + Mensaje = Mensaje.Replace("{SerieFolio}", Me.SerieFolio) + Mensaje = Mensaje.Replace("{Fecha}", Me.Fecha.ToString("dd-MMM-yyyy").Replace(".", "")) + Mensaje = Mensaje.Replace("{Importe}", Me.Total.FormatoNumero) + Mensaje = Mensaje.Replace("{FechaPago}", Me.FechaPago.ToString("dd-MMM-yyyy").Replace(".", "")) + Mensaje = Mensaje.Replace("{ClienteNombreCorto}", Me.Cliente.NombreCorto) + If Mensaje = "" Then Return 2 + + Dim ObjMensaje As New ClsTecnoMovil + If ObjMensaje.EnviarMensajeWS(Celular, Mensaje) Then + If ObjEventos.AddEventoBitacora($"Notificación al cliente via SMS. Mensaje: {Mensaje}", "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCliente:=Me.CveCliente, CveVenta:=Me.CveVenta) Then + End If + Return 1 + Else + Return 2 + End If + End Function + Private Sub GuardaVentaDocumentosCliente(tCveVenta As Integer, ByRef objDocumentacion As ClsEdocumentacion) + If tCveVenta > 0 Then + + For Each DRow As DataRow In DtDocumentacionCliente.FiltraParametros("RutaArchivo <> '' ").Rows + Dim CveDocumentacion As Integer = DRow("CveDocumentacion").ToString.ToEntero + Dim Estatus As Integer = DRow("Estatus").ToString.ToEntero + Dim Adjunto As String = DRow("Adjunto").ToString + Dim NombreArchivo As String = "" + Dim ArchivoRuta As String = DRow("RutaArchivo").ToString + If ArchivoRuta.Length > 0 Then Adjunto = ArchivoRuta + Dim Extension As String = Path.GetExtension(Adjunto) + + Dim CveDocumentacionElectronica As Integer = objDocumentacion.DocumentacionElectronicaAdd(CveDocumentacion, -1, -1, -1, 1, DRow("Observacion").ToString, Extension, UsuarioActual.CveUsuario, New Date(1900, 1, 1), CveVenta:=tCveVenta) + + If CveDocumentacionElectronica <= 0 Then ErrorList.Add("No se pudo registrar el documento ") + NombreArchivo = $"{CveDocumentacionElectronica}{Extension}" + + If ArchivoRuta.Length > 0 And NombreArchivo.Length > 0 Then + If Not Directory.Exists($"{UsuarioActual.Empresa.Ruta}Documentacion\Ventas\") Then + Directory.CreateDirectory($"{UsuarioActual.Empresa.Ruta}Documentacion\Ventas\") End If - If DtPolizasVirtuales IsNot Nothing Then - If DtPolizasVirtuales.Select($"CvePS={Row("CvePS").ToString.ToEntero}").Length > 0 Then - Dim RowPoliza As DataRow = DtPolizasVirtuales.Select($"CvePS={Row("CvePS").ToString.ToEntero}")(0) - RowPoliza("CveVentaDetalle") = ObjVentas.CveVentaDetalle - End If - End If - - 'Agregamos el gasto de contrato - If factura.CveContrato > 0 AndAlso factura.TipoDocto = "Rem" AndAlso AplicaGastoContrato Then - Dim ObjContrato As New ClsContratos - If Not ObjContrato.AddContratoGasto(factura.CveContrato, Row("PS").ToString, Row("Cantidad").ToString.ToDecimal * Row("PU").ToString.ToDecimal, factura.Fecha, UsuarioActual.CveUsuario, CveVenta:=ObjVentas.CveVenta) Then - ErrorList.Add("Ocurrió un error al agregar el gasto de la factura.") - Exit For - End If - ObjContrato.Dispose() - End If - - 'Si es devolucion se agregan a la tabla de Vta_VentasDetalleDevolucion - If AplicaDevolucion Then - If Not ObjVentas.AddVentaDetalleDevolucion(Row("CveVentaDetalle").ToString.ToEntero, ObjVentas.CveVentaDetalle, Row("Cantidad").ToString.ToDouble()) Then - ErrorList.Add("Ocurrió un error al agregar la venta detalle devolucion.") - End If - End If - - If DtAjustes IsNot Nothing AndAlso DtAjustes.Rows.Count > 0 Then - If DtAjustes.Select($"ConsecutivoVenta={Row("Consec").ToString.ToEntero}").Length > 0 Then - Dim DrAju As DataRow = DtAjustes.Select($"ConsecutivoVenta={Row("Consec").ToString.ToEntero}")(0) - DrAju("CveVentaDetalle") = ObjVentas.CveVentaDetalle - End If - End If - - End If - Next - - 'BONIFICACION USADOS - If UsadosBonificacion IsNot Nothing AndAlso UsadosBonificacion.Count > 0 AndAlso TipoBonificacion > 0 Then - For Each CveMovto In UsadosBonificacion - If Not ObjAcum.DistribuidorActualizarFacturados(CveMovto, UsuarioActual.CveEmpresa, TipoBonificacion, CveVenta) Then - ErrorList.Add("Ocurrió un error al actualizar el distribuidor.") - End If - Next - End If - - 'AJUSTES' - If DtAjustes IsNot Nothing AndAlso DtAjustes.Rows.Count > 0 Then - For Each Dr As DataRow In DtAjustes.Rows - If Not ObjAcum.AddGarantiasDetalle(Dr("CveVentaDetalle").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("CveFolioGarantia").ToString.ToEntero, Dr("CveTipoUso").ToString.ToEntero, - Dr("CodigoEnsamble").ToString, Dr("CodigoLinea").ToString, Dr("CodigoInspeccion").ToString, Dr("CveTipoDefecto").ToString.ToEntero, - Dr("NumPoliza").ToString, Dr("Importe").ToString.ToDouble, Dr("Consecutivo").ToString, Dr("FechaAjuste").ToString.ToDateTime()) Then - ErrorList.Add("Ocurrió un error al agregar la garantia detalle.") - End If - Next - End If - - 'POLIZA VIRTUAL + Dim ArchivoExistenteRuta As String = $"{UsuarioActual.Empresa.Ruta}Documentacion\Ventas\{NombreArchivo}" + + If File.Exists(ArchivoExistenteRuta) Then File.Delete(ArchivoExistenteRuta) + + Try + + File.Move(ArchivoRuta, ArchivoExistenteRuta) + Catch ex As Exception + ErrorList.Add("No se pudo guardar el documento de la venta") + Exit For + End Try + + End If + Next + + End If + + End Sub + Public Sub GuardarVenta(ByRef factura As Modelos.Factura, ByRef ObjVentas As ClsVentas, ByRef ObjConta As ClsContabilidad, ByRef ObjInventario As ClsInventarios, ByRef ObjContr As ClsContratos, ByRef TmpDTDetalle As DataTable, CveNCaVincular As Integer, ByRef objContPaqi As ClsContPAQi, Optional ByRef ObjBancos As ClsBancos = Nothing, Optional ByRef ObjOS As ClsOS = Nothing, ByRef Optional ObjEventos As ClsOIEventos = Nothing, ByRef Optional ObjCGame As ClsCGame = Nothing, ByRef Optional ObjCliente As ClsClientes = Nothing, Optional EsNotaCredito As Boolean = False, Optional ObjAcum As ClsAcumuladores = Nothing) + Dim Msgok As New StringBuilder + + factura.CvePrePoliza = ObjConta.AddPrePolizas("Ventas/GuardarVenta", factura.CvePlantillaPoliza, factura.TotalTC, factura.TotalTC, factura.CveMoneda, factura.Fecha, If(factura.CveEmpresaCRM > 0, factura.EmpresaCRM, factura.Cliente.Nombre), factura.CveUsuario, factura.CveEmpresa) + + If Not ObjVentas.AddVenta(factura.TipoDocto, factura.Folio, factura.CveCliente, factura.CveClienteSucursal, factura.SubTotalTC, factura.DescuentoTC, + factura.AmortizacionTC, factura.IVATC, factura.RetIVATC, factura.RetISRTC, + factura.TotalTC, factura.CveMoneda, factura.TipoCambio, factura.CveMetodoPago, factura.CondicionesPago, factura.FormaPago, factura.FechaPago, factura.Fecha, factura.MotivoDescuento, + factura.Observaciones, factura.FechaEjecucion, factura.CveVendedor, + factura.Alfa1, factura.Alfa2, factura.Alfa3, factura.Num1, factura.Num2, factura.Num3, + factura.Fech1, factura.Fech2, factura.Fech3, factura.CveCorte, factura.CveMesa, factura.NumeroPersonas, factura.CvePrePoliza, factura.CveUsuario, factura.CveEmpresa, + AtencionA:=factura.AtencionA, TelefonoGenerico:=factura.TelefonoGenerico, CveContrato:=factura.CveContrato, + CveVentaPadre:=If(AplicaDevolucion, CveVentaDevolucion, factura.CveVentaPadre), Det_FechaOrdenCompra:=factura.Det_FechaOrdenCompra, Det_OrdenCompra:=factura.Det_OrdenCompra, otros:=factura.Otros, + Entrega:=factura.Entrega, Vigencia:=If(factura.TipoDocto = "Cot", FechaVencimiento, MinFecha), + CveAlmacenTraspasoDestino:=CveAlmacenTraspasoDestino, CveAlmacenTraspasoOrigen:=CveAlmacenTraspasoOrigen, + CveDireccionEnvio:=factura.CveDireccionEnvio, CveOC:=factura.CveOC, IEPS:=factura.IEPSTC, Serie:=factura.Serie, CveCondicionEntrega:=factura.CveCondicionEntrega, + PedidoContrato:=factura.PedidoContrato, ObservacionesAlmacen:=factura.ObservacionesAlmacen, CveSubProyecto:=factura.CveSubProyecto, CveSubProyectoCobranza:=factura.CveSubProyectoCobranza, CveSubProyectoEjecucion:=factura.CveSubProyectoEjecucion, CveFormaPago33:=factura.CveFormaPago33, + CveMetodoPago33:=factura.CveMetodoPago33, CveUsoCFDI:=factura.CveUsoCFDI, OrdenCompra:=factura.OrdenCompra, CveCuentaTerminal:=factura.CveCuentaTerminal, CveTipoRelacion:=factura.CveTipoRelacion, ImpuestoLocal:=TotalImpuestoLocal, + CveVentaRelacion:=(If(factura.CveVentaRelacion.ToEntero > 0, factura.CveVentaRelacion, -1)), ImporteRelacion:=(If(factura.ImporteRelacion <> Nothing, factura.ImporteRelacion, -1)), + CveTipoAmortizacionAnticipo:=factura.CveTipoAmortizacionAnticipo, CveEmpresaCRM:=CveEmpresaCRM, EsInterno:=EsInterno) Then + + ErrorList.Add("Ocurrió un error al Generar la Venta.
Revise su factura y cualquier detalle comuníquese a Soporte Técnico") + + End If + + If Not GuardarUsados(ObjVentas.IniciaTransacSQL, ObjVentas.CveVenta, ObjVentas, factura.TipoDocto) Then + ErrorList.Add("Error al guardar usados") + End If + + + If ErrorList.Count = 0 AndAlso ObjVentas.CveVenta > 0 Then + + factura.CveVenta = ObjVentas.CveVenta + factura.Serie = ObjVentas.Serie + factura.Folio = ObjVentas.Folio + factura.Timbre.Comprobante.Serie = ObjVentas.Serie + factura.Timbre.Comprobante.Folio = ObjVentas.Folio.ToString + + If factura.TipoDocto = "Egs" AndAlso NuevaFactura = 1 Then + If DtVentasNC Is Nothing Then + InicializaDTVentasNC() + End If + CargaNCDT(factura.CveVentaPadre, factura.Total, NuevaFactura:=NuevaFactura, ObjVentas:=ObjVentas) + End If + + 'Se agregan los PS + For Each Row As DataRow In TmpDTDetalle.Rows + If Not ObjVentas.AddVentaDetalle(ObjVentas.CveVenta, Row("CvePS").ToString.ToEntero, Row("Cantidad").ToString.ToDouble, Row("CveUM").ToString.ToEntero, + Row("PU").ToString.ToDouble(If(factura.ConvertirPesos, factura.TipoCambio, 1)), Row("ImporteIVA").ToString.ToDouble(If(factura.ConvertirPesos, factura.TipoCambio, 1)), Math.Round((Row("Total").ToString.ToDouble(If(factura.ConvertirPesos, factura.TipoCambio, 1)) * (1 + Row("PorcentajeIVA").ToString.ToDouble(If(factura.ConvertirPesos, factura.TipoCambio, 1)))), 6), + Row("Obs").ToString, Row("Descuento").ToString.ToDouble(If(factura.ConvertirPesos, factura.TipoCambio, 1)), Row("TipoDescuento").ToString.ToEntero, Row("CveSubProyecto").ToString.ToEntero, Row("CvePresupuestoIngreso").ToString.ToEntero, + TiempoEntrega:=Row("TiempoEntrega").ToString, CveVentaDetallePadre:=Row("CveVentaDetalle").ToString.ToEntero, CveContratoDetalle:=Row("CveContratoDetalle").ToString.ToEntero, + CvePromocionDetalle:=If(DtPromociones IsNot Nothing, DtPromociones.FiltroPrimeroValor("CvePromocionDetalle", $"CvePS={Row("CvePS").ToString}").ToEntero, -1), + IEPS:=Row("ImporteIEPS").ToString.ToDouble, CveMovimientoDetallePedido:=Row("CveMovimientoDetallePedido").ToString.ToEntero, + ImporteRetIVA:=Row("ImporteRetIVA").ToString.ToDouble, ImporteRetISR:=Row("ImporteRetISR").ToString.ToDouble, + PorcentajeIEPS:=Row("PorcentajeIEPS").ToString.ToDouble, PorcentajeRetIVA:=Row("PorcentajeRetIVA").ToString.ToDouble, PorcentajeRetISR:=Row("PorcentajeRetISR").ToString.ToDouble, CuentaPredial:=Row("CuentaPredial").ToString, + PorcentajeIVA:=Row("PorcentajeIVA").ToString.ToDecimal) Then + ErrorList.Add("Ocurrió un error al agregar un Producto o Servicio a la factura.
Revise su factura y cualquier detalle comuníquese a Soporte Técnico") + Exit For + Else + Row("CveVenta") = factura.CveVenta + Row("CveVentaDetalle") = ObjVentas.CveVentaDetalle + + If DtInventario IsNot Nothing Then + If DtInventario.Select($"CvePS={Row("CvePS").ToString.ToEntero}").Length > 0 Then + Dim rowInv As DataRow = DtInventario.Select($"CvePS={Row("CvePS").ToString.ToEntero}")(0) + rowInv("CveVentaDetalle") = ObjVentas.CveVentaDetalle + End If + End If + + If DtRecepcionUsados IsNot Nothing Then + If DtRecepcionUsados.Select($"CvePS={Row("CvePS").ToString.ToEntero}").Length > 0 Then + Dim rowInv As DataRow = DtRecepcionUsados.Select($"CvePS={Row("CvePS").ToString.ToEntero}")(0) + rowInv("CveVentaDetalle") = ObjVentas.CveVentaDetalle + End If + End If + + If DtPolizasVirtuales IsNot Nothing Then + If DtPolizasVirtuales.Select($"CvePS={Row("CvePS").ToString.ToEntero}").Length > 0 Then + Dim RowPoliza As DataRow = DtPolizasVirtuales.Select($"CvePS={Row("CvePS").ToString.ToEntero}")(0) + RowPoliza("CveVentaDetalle") = ObjVentas.CveVentaDetalle + End If + End If + + 'Agregamos el gasto de contrato + If factura.CveContrato > 0 AndAlso factura.TipoDocto = "Rem" AndAlso AplicaGastoContrato Then + Dim ObjContrato As New ClsContratos + If Not ObjContrato.AddContratoGasto(factura.CveContrato, Row("PS").ToString, Row("Cantidad").ToString.ToDecimal * Row("PU").ToString.ToDecimal, factura.Fecha, UsuarioActual.CveUsuario, CveVenta:=ObjVentas.CveVenta) Then + ErrorList.Add("Ocurrió un error al agregar el gasto de la factura.") + Exit For + End If + ObjContrato.Dispose() + End If + + 'Si es devolucion se agregan a la tabla de Vta_VentasDetalleDevolucion + If AplicaDevolucion Then + If Not ObjVentas.AddVentaDetalleDevolucion(Row("CveVentaDetalle").ToString.ToEntero, ObjVentas.CveVentaDetalle, Row("Cantidad").ToString.ToDouble()) Then + ErrorList.Add("Ocurrió un error al agregar la venta detalle devolucion.") + End If + End If + + If DtAjustes IsNot Nothing AndAlso DtAjustes.Rows.Count > 0 Then + If DtAjustes.Select($"ConsecutivoVenta={Row("Consec").ToString.ToEntero}").Length > 0 Then + Dim DrAju As DataRow = DtAjustes.Select($"ConsecutivoVenta={Row("Consec").ToString.ToEntero}")(0) + DrAju("CveVentaDetalle") = ObjVentas.CveVentaDetalle + End If + End If + + End If + Next + + 'BONIFICACION USADOS + If UsadosBonificacion IsNot Nothing AndAlso UsadosBonificacion.Count > 0 AndAlso TipoBonificacion > 0 Then + For Each CveMovto In UsadosBonificacion + If Not ObjAcum.DistribuidorActualizarFacturados(CveMovto, UsuarioActual.CveEmpresa, TipoBonificacion, CveVenta) Then + ErrorList.Add("Ocurrió un error al actualizar el distribuidor.") + End If + Next + End If + + 'AJUSTES' + If DtAjustes IsNot Nothing AndAlso DtAjustes.Rows.Count > 0 Then + For Each Dr As DataRow In DtAjustes.Rows + If Not ObjAcum.AddGarantiasDetalle(Dr("CveVentaDetalle").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("CveFolioGarantia").ToString.ToEntero, Dr("CveTipoUso").ToString.ToEntero, + Dr("CodigoEnsamble").ToString, Dr("CodigoLinea").ToString, Dr("CodigoInspeccion").ToString, Dr("CveTipoDefecto").ToString.ToEntero, + Dr("NumPoliza").ToString, Dr("Importe").ToString.ToDouble, Dr("Consecutivo").ToString, Dr("FechaAjuste").ToString.ToDateTime()) Then + ErrorList.Add("Ocurrió un error al agregar la garantia detalle.") + End If + Next + End If + + 'POLIZA VIRTUAL If factura.DtPolizasVirtuales IsNot Nothing AndAlso factura.DtPolizasVirtuales.Rows.Count > 0 Then If Not GuardarPolizasVirtuales(ObjVentas.IniciaTransacSQL(), ObjFactura:=factura) Then ErrorList.Add("Ocurrió un error al actualizar el distribuidor.") End If - End If - - 'ORDEN PRODUCCION' - If UsuarioActual.CveEmpresa.Contiene(126) Then - If ObjVentas.CveVenta > 0 And factura.CveOrdenProduccion > 0 Then - If Not ObjCGame.UpdateOrdenProduccionVenta(factura.CveOrdenProduccion, ObjVentas.CveVenta) Then - ErrorList.Add("Ocurrió un error al actualizar la orden de producción") - End If - End If - End If - - 'PedidoA' - If ObjVentas.CveVenta > 0 And factura.CvePedidoA > 0 And factura.TipoDocto.Contiene("Rem") Then - If Not ObjCliente.UpdateEstatusPedido(factura.CvePedidoA, 18, -1, UsuarioActual.CveUsuario) Then - ErrorList.Add("Ocurrió un error al actualizar el estatus del pedidoA") - End If - End If - - 'Pedido2' - If ObjVentas.CveVenta > 0 And factura.CvePedido2 > 0 And factura.TipoDocto.Contiene("Rem", "PA") Then - If Not ObjCliente.UpdateEstatusPedido(factura.CvePedido2, 21, -1, UsuarioActual.CveUsuario) Then - ErrorList.Add("Ocurrió un error al actualizar el estatus del pedido2") - End If - End If - - 'Si viene de OS, Se guarda CveVenta en OS - If CveOS > 0 Then - If Not ObjOS.UpdateVentaOS(factura.CveVenta, CveOS) Then - ErrorList.Add("Ocurrió un error al guardar la venta en Ordenes de Servicio") - End If - End If - - 'Contratos - If factura.CveContrato > 0 AndAlso factura.TipoDocto.Contiene("Ing") Then - GuardarContratoAvanceEstimaciones(factura, ObjContr, ErrorList, 1) - 'CUANDO ES NOTA DE CRÉDITO, NO DEBE DE CONSIDERAR AVANCE, CUANDO ES NOTA DE CRÉDITO POR AMORTIZACIÓN - ElseIf factura.CveContrato > 0 AndAlso factura.TipoDocto.Contiene("Egs", "Dev") AndAlso Not factura.EsNCAmortizacion Then - GuardarContratoAvanceEstimaciones(factura, ObjContr, ErrorList, -1) - End If - - 'Impuestos Locales - If DtImpuestosLocales IsNot Nothing Then - For Each gvr As DataRow In DtImpuestosLocales.Rows - If Not ObjVentas.AddVentaImpuestoLocales(factura.CveVenta, gvr("CveImpuestoLocal").ToString.ToEntero(), gvr("Importe").ToString().ToDouble()) Then - ErrorList.Add("Ocurrió un error al Guardar Impuestos Locales") - End If - Next - End If - - - If DtFirmas IsNot Nothing AndAlso DtFirmas.Rows.Count > 0 Then - For Each Row As DataRow In DtFirmas.Rows - If Not ObjVentas.AddVentasFirmas(factura.CveVenta, Row("Titulo").ToString, Row("Nombre").ToString, Row("Puesto").ToString, Row("Lado").ToString.ToEntero) Then - ErrorList.Add("Ocurrio un error al Guardar Firmas") - End If - Next - End If - - 'registro los metodos de pago, cuando hay corte. - If factura.CveCorte > 0 Then - 'cuando es contado - If Pago = 2 AndAlso DtPagos IsNot Nothing AndAlso DtPagos.Rows.Count > 0 Then - For Each DrPago As DataRow In DtPagos.Rows - If Not ObjVentas.AddVta_VentaPago(factura.CveVenta, DrPago("CveMetodoPago").ToString.ToEntero, DrPago("Importe").ToString.ToDouble) Then - ErrorList.Add("Ocurrio un error al guardar los metodos de pago") - End If - Next - Else - 'cuando es crédito o terminal - If Not ObjVentas.AddVta_VentaPago(factura.CveVenta, 7, factura.Total) Then - ErrorList.Add("Ocurrio un error al guardar los metodos de pago") - End If - End If - - End If - - 'INE COMPLEMENTOS - If factura.ComplementoINE IsNot Nothing Then - If Not ObjVentas.UpdateVentasComplementos(factura.CveVenta, factura.ComplementoINE.INETipoProceso, factura.ComplementoINE.INETipoComite, factura.ComplementoINE.INEIdContabilidad.ToString) Then - ErrorList.Add("Ocurrio un error al guardar los complementos") - End If - End If - - If ErrorList.Count = 0 AndAlso factura.TipoDocto.Contiene("Ing", "Ant") Then - 'Agregamos las remisiones a la tabla - If factura.DtRemisionesPS IsNot Nothing AndAlso factura.DtRemisionesPS.Rows.Count > 0 AndAlso ErrorList.Count = 0 Then - Dim CveVentaDetalle As Integer = 0 - Dim CveVentaDetallePadre As Integer = 0 - Dim Cantidad As Decimal = 0 - - - For Each row As DataRow In factura.DtRemisionesPS.Rows - Cantidad = factura.DtDetalle.FiltroPrimeroValor("Cantidad", $"CveVentaDetalleRemision={row("CveVentaDetalle")}").ToDecimal() - CveVentaDetallePadre = row("CveVentaDetalle").ToString.ToEntero - CveVentaDetalle = factura.DtDetalle.FiltroPrimeroValor("CveVentaDetalle", $"CveVentaDetalleRemision={CveVentaDetallePadre}").ToEntero - - - If Not ObjVentas.AgregarRemisionDetalle(CveVentaDetalle, CveVentaDetallePadre, Cantidad) Then - ErrorList.Add("Ocurrió un error al agregar el detalle de la Remision") - End If - Next - - End If - - If factura.DtRemisiones IsNot Nothing AndAlso factura.DtRemisiones.Rows.Count > 0 AndAlso ErrorList.Count = 0 Then - For Each row As DataRow In factura.DtRemisiones.Rows - If Not ObjVentas.UpdateVentaRemision(row("CveVenta").ToString.ToEntero, factura.CveVenta) Then - ErrorList.Add("Ocurrió un error al actualizar la remisión") - End If - Next - End If - End If - - If ErrorList.Count = 0 Then - 'Agregamos los pedidos2 a la tabla - If DtPedidos2PS IsNot Nothing AndAlso DtPedidos2PS.Rows.Count > 0 AndAlso ErrorList.Count = 0 Then - Dim CveVentaDetalle As Integer = 0 - Dim CveVentaDetallePadre As Integer = 0 - Dim Cantidad As Decimal = 0 - Dim CvePS As Integer = 0 - Dim PU As Decimal = 0 - - For Each row As DataRow In DtDetalle.Rows - Cantidad = DtDetalle.FiltroPrimeroValor("Cantidad", $"CveVentaDetallePedido2={row("CveVentaDetalle")}").ToDecimal - CvePS = DtDetalle.FiltroPrimeroValor("CvePS", $"CveVentaDetallePedido2={row("CveVentaDetalle")}").ToEntero - PU = DtDetalle.FiltroPrimeroValor("PU", $"CveVentaDetallePedido2={row("CveVentaDetalle")}").ToDecimal - CveVentaDetalle = DtDetalle.FiltroPrimeroValor("CveVentaDetalle", $"CveVentaDetallePedido2={row("CveVentaDetalle")}").ToEntero - CveVentaDetallePadre = row("CveVentaDetalle").ToString.ToEntero - - If Not ObjVentas.AddVentaDetallePedido2(CveVentaDetalle, CveVentaDetallePadre, Cantidad) Then - ErrorList.Add("Ocurrió un error al agregar el detalle del Pedido2") - End If - Next - End If - - If DtPedidos2 IsNot Nothing AndAlso DtPedidos2.Rows.Count > 0 AndAlso ErrorList.Count = 0 Then - Dim dt As DataTable = DtPedidos2.FiltraParametros("Aplicado = True") - If dt.Rows.Count > 0 Then - For Each row As DataRow In dt.Rows - If Not ObjVentas.UpdateVentaPedido2(row("CveVenta").ToString.ToEntero, factura.CveVenta) Then - ErrorList.Add("Ocurrió un error al actualizar el Pedido2") - End If - Next - End If - End If - End If - - - If ErrorList.Count = 0 Then - 'prepoliza - GuardarVentaPrePolizas(factura, ObjConta, TmpDTDetalle, CveNCaVincular, objContPaqi, ObjBancos, ObjVentas, ObjEventos:=ObjEventos) - If ErrorList.Count = 0 Then - 'inventarios - GuardarVentaInventarios(factura, ObjInventario, ObjConta) - - 'GuardaRecepcionUsados(factura, ObjInventario, ObjConta) - - If ErrorList.Count = 0 Then - 'estimaciones - GuardarVentaEstimaciones(factura, ObjContr) - If ErrorList.Count = 0 Then - 'armonizaccionContable - GuardarVentaAC(factura, ObjVentas, Msgok, objContPaqi) - If ErrorList.Count = 0 Then - 'Impuestos Locales - If GuardarVentaImpuestosLocales(factura, ObjVentas, ObjConta) Then - ErrorList.Add("Ocurrio un error al Guardar Impuestos Locales") - End If - End If - End If - End If - End If - End If - - End If - End Sub - Private Function SalidaAlmacenMateriales(ByRef ObjInventario As ClsInventarios, CveOS As Integer, ByRef ObjConta As ClsContabilidad, ConSalida As Boolean, ConceptoMovimiento As Integer) As Boolean - Dim TieneError As Boolean = False - Dim CveMovimientoSalida = 0 - Dim CveMovimientoEntrada = 0 - - Dim CveMovimientoSalida2 = 0 - Dim CveMovimientoEntrada2 = 0 - - Dim CveMovimientoSalida3 = 0 - Dim CveMovimientoEntrada3 = 0 - - Dim AlmacenEntrada = -1 - Dim FolioSalida = 0 - Dim FolioEntrada = 0 - - Dim TextoError = "" - Dim TextoExistencia As StringBuilder = New StringBuilder - - 'Obtenemos los movimientos detalle - If ObjInventario.GetMovimientosOS(9, CveOS, UsuarioActual.CveEmpresa) Then - If ObjInventario.DtResultados.Rows.Count > 0 Then - Dim CveMovimiento As Integer = ObjInventario.DtResultados(0)("CveMovimiento").ToString.ToEntero - Dim CveAlmacenOrigen As Integer = ObjInventario.DtResultados(0)("CveAlmacen").ToString.ToEntero - Dim CveAlmacenDestino As Integer = ObjInventario.DtResultados(0)("AlmacenDestino2").ToString.ToEntero - Dim CveMoneda As Integer = ObjInventario.DtResultados(0)("CveMoneda").ToString.ToEntero - Dim CveTipoAlmacen As Integer = ObjInventario.DtResultados(0)("CveTipoAlmacen").ToString.ToEntero - - 'AGREGAMOS LA ENTRADA Movto 1 - If Not TieneError Then - AlmacenEntrada = CveAlmacenOrigen - + End If + + 'ORDEN PRODUCCION' + If UsuarioActual.CveEmpresa.Contiene(126) Then + If ObjVentas.CveVenta > 0 And factura.CveOrdenProduccion > 0 Then + If Not ObjCGame.UpdateOrdenProduccionVenta(factura.CveOrdenProduccion, ObjVentas.CveVenta) Then + ErrorList.Add("Ocurrió un error al actualizar la orden de producción") + End If + End If + End If + + 'PedidoA' + If ObjVentas.CveVenta > 0 And factura.CvePedidoA > 0 And factura.TipoDocto.Contiene("Rem") Then + If Not ObjCliente.UpdateEstatusPedido(factura.CvePedidoA, 18, -1, UsuarioActual.CveUsuario) Then + ErrorList.Add("Ocurrió un error al actualizar el estatus del pedidoA") + End If + End If + + 'Pedido2' + If ObjVentas.CveVenta > 0 And factura.CvePedido2 > 0 And factura.TipoDocto.Contiene("Rem", "PA") Then + If Not ObjCliente.UpdateEstatusPedido(factura.CvePedido2, 21, -1, UsuarioActual.CveUsuario) Then + ErrorList.Add("Ocurrió un error al actualizar el estatus del pedido2") + End If + End If + + 'Si viene de OS, Se guarda CveVenta en OS + If CveOS > 0 Then + If Not ObjOS.UpdateVentaOS(factura.CveVenta, CveOS) Then + ErrorList.Add("Ocurrió un error al guardar la venta en Ordenes de Servicio") + End If + End If + + 'Contratos + If factura.CveContrato > 0 AndAlso factura.TipoDocto.Contiene("Ing") Then + GuardarContratoAvanceEstimaciones(factura, ObjContr, ErrorList, 1) + 'CUANDO ES NOTA DE CRÉDITO, NO DEBE DE CONSIDERAR AVANCE, CUANDO ES NOTA DE CRÉDITO POR AMORTIZACIÓN + ElseIf factura.CveContrato > 0 AndAlso factura.TipoDocto.Contiene("Egs", "Dev") AndAlso Not factura.EsNCAmortizacion Then + GuardarContratoAvanceEstimaciones(factura, ObjContr, ErrorList, -1) + End If + + 'Impuestos Locales + If DtImpuestosLocales IsNot Nothing Then + For Each gvr As DataRow In DtImpuestosLocales.Rows + If Not ObjVentas.AddVentaImpuestoLocales(factura.CveVenta, gvr("CveImpuestoLocal").ToString.ToEntero(), gvr("Importe").ToString().ToDouble()) Then + ErrorList.Add("Ocurrió un error al Guardar Impuestos Locales") + End If + Next + End If + + + If DtFirmas IsNot Nothing AndAlso DtFirmas.Rows.Count > 0 Then + For Each Row As DataRow In DtFirmas.Rows + If Not ObjVentas.AddVentasFirmas(factura.CveVenta, Row("Titulo").ToString, Row("Nombre").ToString, Row("Puesto").ToString, Row("Lado").ToString.ToEntero) Then + ErrorList.Add("Ocurrio un error al Guardar Firmas") + End If + Next + End If + + 'registro los metodos de pago, cuando hay corte. + If factura.CveCorte > 0 Then + 'cuando es contado + If Pago = 2 AndAlso DtPagos IsNot Nothing AndAlso DtPagos.Rows.Count > 0 Then + For Each DrPago As DataRow In DtPagos.Rows + If Not ObjVentas.AddVta_VentaPago(factura.CveVenta, DrPago("CveMetodoPago").ToString.ToEntero, DrPago("Importe").ToString.ToDouble) Then + ErrorList.Add("Ocurrio un error al guardar los metodos de pago") + End If + Next + Else + 'cuando es crédito o terminal + If Not ObjVentas.AddVta_VentaPago(factura.CveVenta, 7, factura.Total) Then + ErrorList.Add("Ocurrio un error al guardar los metodos de pago") + End If + End If + + End If + + 'INE COMPLEMENTOS + If factura.ComplementoINE IsNot Nothing Then + If Not ObjVentas.UpdateVentasComplementos(factura.CveVenta, factura.ComplementoINE.INETipoProceso, factura.ComplementoINE.INETipoComite, factura.ComplementoINE.INEIdContabilidad.ToString) Then + ErrorList.Add("Ocurrio un error al guardar los complementos") + End If + End If + + If ErrorList.Count = 0 AndAlso factura.TipoDocto.Contiene("Ing", "Ant") Then + 'Agregamos las remisiones a la tabla + If factura.DtRemisionesPS IsNot Nothing AndAlso factura.DtRemisionesPS.Rows.Count > 0 AndAlso ErrorList.Count = 0 Then + Dim CveVentaDetalle As Integer = 0 + Dim CveVentaDetallePadre As Integer = 0 + Dim Cantidad As Decimal = 0 + + + For Each row As DataRow In factura.DtRemisionesPS.Rows + Cantidad = factura.DtDetalle.FiltroPrimeroValor("Cantidad", $"CveVentaDetalleRemision={row("CveVentaDetalle")}").ToDecimal() + CveVentaDetallePadre = row("CveVentaDetalle").ToString.ToEntero + CveVentaDetalle = factura.DtDetalle.FiltroPrimeroValor("CveVentaDetalle", $"CveVentaDetalleRemision={CveVentaDetallePadre}").ToEntero + + + If Not ObjVentas.AgregarRemisionDetalle(CveVentaDetalle, CveVentaDetallePadre, Cantidad) Then + ErrorList.Add("Ocurrió un error al agregar el detalle de la Remision") + End If + Next + + End If + + If factura.DtRemisiones IsNot Nothing AndAlso factura.DtRemisiones.Rows.Count > 0 AndAlso ErrorList.Count = 0 Then + For Each row As DataRow In factura.DtRemisiones.Rows + If Not ObjVentas.UpdateVentaRemision(row("CveVenta").ToString.ToEntero, factura.CveVenta) Then + ErrorList.Add("Ocurrió un error al actualizar la remisión") + End If + Next + End If + End If + + If ErrorList.Count = 0 Then + 'Agregamos los pedidos2 a la tabla + If DtPedidos2PS IsNot Nothing AndAlso DtPedidos2PS.Rows.Count > 0 AndAlso ErrorList.Count = 0 Then + Dim CveVentaDetalle As Integer = 0 + Dim CveVentaDetallePadre As Integer = 0 + Dim Cantidad As Decimal = 0 + Dim CvePS As Integer = 0 + Dim PU As Decimal = 0 + + For Each row As DataRow In DtDetalle.Rows + Cantidad = DtDetalle.FiltroPrimeroValor("Cantidad", $"CveVentaDetallePedido2={row("CveVentaDetalle")}").ToDecimal + CvePS = DtDetalle.FiltroPrimeroValor("CvePS", $"CveVentaDetallePedido2={row("CveVentaDetalle")}").ToEntero + PU = DtDetalle.FiltroPrimeroValor("PU", $"CveVentaDetallePedido2={row("CveVentaDetalle")}").ToDecimal + CveVentaDetalle = DtDetalle.FiltroPrimeroValor("CveVentaDetalle", $"CveVentaDetallePedido2={row("CveVentaDetalle")}").ToEntero + CveVentaDetallePadre = row("CveVentaDetalle").ToString.ToEntero + + If Not ObjVentas.AddVentaDetallePedido2(CveVentaDetalle, CveVentaDetallePadre, Cantidad) Then + ErrorList.Add("Ocurrió un error al agregar el detalle del Pedido2") + End If + Next + End If + + If DtPedidos2 IsNot Nothing AndAlso DtPedidos2.Rows.Count > 0 AndAlso ErrorList.Count = 0 Then + Dim dt As DataTable = DtPedidos2.FiltraParametros("Aplicado = True") + If dt.Rows.Count > 0 Then + For Each row As DataRow In dt.Rows + If Not ObjVentas.UpdateVentaPedido2(row("CveVenta").ToString.ToEntero, factura.CveVenta) Then + ErrorList.Add("Ocurrió un error al actualizar el Pedido2") + End If + Next + End If + End If + End If + + + If ErrorList.Count = 0 Then + 'prepoliza + GuardarVentaPrePolizas(factura, ObjConta, TmpDTDetalle, CveNCaVincular, objContPaqi, ObjBancos, ObjVentas, ObjEventos:=ObjEventos) + If ErrorList.Count = 0 Then + 'inventarios + GuardarVentaInventarios(factura, ObjInventario, ObjConta) + + 'GuardaRecepcionUsados(factura, ObjInventario, ObjConta) + + If ErrorList.Count = 0 Then + 'estimaciones + GuardarVentaEstimaciones(factura, ObjContr) + If ErrorList.Count = 0 Then + 'armonizaccionContable + GuardarVentaAC(factura, ObjVentas, Msgok, objContPaqi) + If ErrorList.Count = 0 Then + 'Impuestos Locales + If GuardarVentaImpuestosLocales(factura, ObjVentas, ObjConta) Then + ErrorList.Add("Ocurrio un error al Guardar Impuestos Locales") + End If + End If + End If + End If + End If + End If + + End If + End Sub + Private Function SalidaAlmacenMateriales(ByRef ObjInventario As ClsInventarios, CveOS As Integer, ByRef ObjConta As ClsContabilidad, ConSalida As Boolean, ConceptoMovimiento As Integer) As Boolean + Dim TieneError As Boolean = False + Dim CveMovimientoSalida = 0 + Dim CveMovimientoEntrada = 0 + + Dim CveMovimientoSalida2 = 0 + Dim CveMovimientoEntrada2 = 0 + + Dim CveMovimientoSalida3 = 0 + Dim CveMovimientoEntrada3 = 0 + + Dim AlmacenEntrada = -1 + Dim FolioSalida = 0 + Dim FolioEntrada = 0 + + Dim TextoError = "" + Dim TextoExistencia As StringBuilder = New StringBuilder + + 'Obtenemos los movimientos detalle + If ObjInventario.GetMovimientosOS(9, CveOS, UsuarioActual.CveEmpresa) Then + If ObjInventario.DtResultados.Rows.Count > 0 Then + Dim CveMovimiento As Integer = ObjInventario.DtResultados(0)("CveMovimiento").ToString.ToEntero + Dim CveAlmacenOrigen As Integer = ObjInventario.DtResultados(0)("CveAlmacen").ToString.ToEntero + Dim CveAlmacenDestino As Integer = ObjInventario.DtResultados(0)("AlmacenDestino2").ToString.ToEntero + Dim CveMoneda As Integer = ObjInventario.DtResultados(0)("CveMoneda").ToString.ToEntero + Dim CveTipoAlmacen As Integer = ObjInventario.DtResultados(0)("CveTipoAlmacen").ToString.ToEntero + + 'AGREGAMOS LA ENTRADA Movto 1 + If Not TieneError Then + AlmacenEntrada = CveAlmacenOrigen + CveMovimientoEntrada = ObjInventario.AddMovimiento(AlmacenEntrada, 8, 1, Me.Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, - CveAlmacenDestino:=-1, CveMovimientoRelacionado:=CveMovimientoSalida, CveOS:=CveOS, Modulo:="Mod/OS") - FolioEntrada = ObjInventario.Folio - - If CveMovimientoEntrada <= 0 Then - TextoError = "No se pudo generar el movimiento de entrada correctamente" - TieneError = True - Else - - If ObjInventario.GetMovimientosDetalle(CveMovimiento, 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, -1, -1) Then - TieneError = True - TextoError = "Ocurrió un Error al guardar los movimientos de entrada" - Exit For - End If - Next - - End If - - End If - End If - - 'AGREGAMOS LA ENTRADA Movto 2 - If Not TieneError Then - AlmacenEntrada = CveAlmacenDestino - - CveMovimientoEntrada2 = ObjInventario.AddMovimiento(AlmacenEntrada, 9, 1, Me.Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, CveAlmacenDestino:=-1, - CveMovimientoRelacionado:=CveMovimientoSalida2, CveOS:=CveOS, Modulo:="Mod/OS") - FolioEntrada = ObjInventario.Folio - - If CveMovimientoEntrada2 <= 0 Then - TextoError = "No se pudo generar el movimiento de entrada correctamente" - TieneError = True - Else - - If ObjInventario.GetMovimientosDetalle(CveMovimientoEntrada, UsuarioActual.CveEmpresa) Then - - For Each Dr As DataRow In ObjInventario.DtResultados.Rows - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada2, Dr("Cantidad").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, -1, -1) Then - TieneError = True - TextoError = "Ocurrió un Error al guardar los movimientos de entrada" - Exit For - End If - Next - - End If - - End If - End If - - 'AGREGAMOS LA ENTRADA Movto 3 - If Not TieneError Then - AlmacenEntrada = CveAlmacenDestino - + CveAlmacenDestino:=-1, CveMovimientoRelacionado:=CveMovimientoSalida, CveOS:=CveOS, Modulo:="Mod/OS") + FolioEntrada = ObjInventario.Folio + + If CveMovimientoEntrada <= 0 Then + TextoError = "No se pudo generar el movimiento de entrada correctamente" + TieneError = True + Else + + If ObjInventario.GetMovimientosDetalle(CveMovimiento, 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, -1, -1) Then + TieneError = True + TextoError = "Ocurrió un Error al guardar los movimientos de entrada" + Exit For + End If + Next + + End If + + End If + End If + + 'AGREGAMOS LA ENTRADA Movto 2 + If Not TieneError Then + AlmacenEntrada = CveAlmacenDestino + + CveMovimientoEntrada2 = ObjInventario.AddMovimiento(AlmacenEntrada, 9, 1, Me.Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, CveAlmacenDestino:=-1, + CveMovimientoRelacionado:=CveMovimientoSalida2, CveOS:=CveOS, Modulo:="Mod/OS") + FolioEntrada = ObjInventario.Folio + + If CveMovimientoEntrada2 <= 0 Then + TextoError = "No se pudo generar el movimiento de entrada correctamente" + TieneError = True + Else + + If ObjInventario.GetMovimientosDetalle(CveMovimientoEntrada, UsuarioActual.CveEmpresa) Then + + For Each Dr As DataRow In ObjInventario.DtResultados.Rows + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada2, Dr("Cantidad").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, -1, -1) Then + TieneError = True + TextoError = "Ocurrió un Error al guardar los movimientos de entrada" + Exit For + End If + Next + + End If + + End If + End If + + 'AGREGAMOS LA ENTRADA Movto 3 + If Not TieneError Then + AlmacenEntrada = CveAlmacenDestino + CveMovimientoEntrada3 = ObjInventario.AddMovimiento(AlmacenEntrada, 3, 1, Me.Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, CveAlmacenDestino:=-1, - CveMovimientoRelacionado:=CveMovimientoSalida3, CveOS:=CveOS, Modulo:="Mod/OS") - FolioEntrada = ObjInventario.Folio - - If CveMovimientoEntrada3 <= 0 Then - TextoError = "No se pudo generar el movimiento de entrada correctamente" - TieneError = True - Else - - If ObjInventario.GetMovimientosDetalle(CveMovimientoEntrada2, UsuarioActual.CveEmpresa) Then - - For Each Dr As DataRow In ObjInventario.DtResultados.Rows - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada3, Dr("Cantidad").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, -1, -1) Then - TieneError = True - TextoError = "Ocurrió un Error al guardar los movimientos de entrada" - Exit For - End If - Next - - End If - - End If - End If - - End If - End If - - Return TieneError - End Function - Function RegistraAlmacenConsignacionVenta(ByRef ObjInventario As ClsInventarios) As Boolean - If Not (UsuarioActual.Empresa.UsaInventarios AndAlso CveAlmacenExistenciasContrato > 0) Then - Return True - End If - - Dim CveMovimientoSalidaConsignacion = -1 - Dim CveMovimientoEntradaGeneral = -1 - Dim CveMovimientoSalidaGeneral = -1 - - - 'MOVIMIENTO DE SALIDA POR TRASPASO DEL ALMACEN DE CONSIGNACION - CveMovimientoSalidaConsignacion = ObjInventario.AddMovimiento(CveAlmacenExistenciasContrato, 8, 1, Me.Fecha, -1, Me.CveUsuario, Me.CveEmpresa, -1, Me.CveVenta, -1, -1, Modulo:="Mod/E") - If CveMovimientoSalidaConsignacion > 0 Then - Dim CveProducto As Integer - Dim CveUnidad As Integer - Dim Cantidad As Double - Dim Existencia As Double - For Each Dr As DataRow In DtDetalle.Rows - CveProducto = Dr("CvePS").ToString.ToEntero - CveUnidad = Dr("CveUM").ToString.ToEntero - Cantidad = Dr("Cantidad").ToString.ToDouble - - If Not CveProducto > 0 Then - Return False - End If - - If Dr("CveTipoInvPS").ToString.ToEntero = 5 Then - For Each Dr2 As DataRow In DtContratosSerieDetalle.FiltraParametros($"ConsecId = {Dr("CveContratoDetalle")}").Rows - Existencia = ObjInventario.GetExistenciasPS(CveProducto, CveUnidad, Me.CveEmpresa, CveAlmacenExistenciasContrato, SerieLote:=Dr2("Serie").ToString, FechaMovto:=DateTime.Today.AddDays(1).ToString("yyyy/MM/dd HH:mm"), CveSubProyecto:=Me.CveSubProyecto, ExcluyeAdelantado:=1, RestringirAlmacenes:=1, ExcluyeApartados:=1) - If Existencia < 1 Then - Return False - End If - - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalidaConsignacion, 1, CveUnidad, CveProducto, 0, -1, SerieLote:=Dr2("Serie").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then - Return False - End If - Next - Else - Existencia = ObjInventario.GetExistenciasPS(CveProducto, CveUnidad, Me.CveEmpresa, CveAlmacenExistenciasContrato, FechaMovto:=DateTime.Today.AddDays(1).ToString("yyyy/MM/dd HH:mm"), CveSubProyecto:=Me.CveSubProyecto, ExcluyeAdelantado:=1, RestringirAlmacenes:=1, ExcluyeApartados:=1) - If Existencia < Cantidad Then - Return False - End If - - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalidaConsignacion, Cantidad, CveUnidad, CveProducto, 0, -1, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then - Return False - End If - End If - Next - Else - Return False - End If - - - 'ENTRADA POR TRASPASO A GENERAL - CveMovimientoEntradaGeneral = ObjInventario.AddMovimiento(Me.CveAlmacenOrigenContrato, 9, 1, Me.Fecha, -1, Me.CveUsuario, Me.CveEmpresa, -1, Me.CveVenta, -1, -1, CveMovimientoRelacionado:=CveMovimientoSalidaConsignacion, Modulo:="Mod/E") - If CveMovimientoEntradaGeneral > 0 Then - If ObjInventario.GetMovimientosDetalle(CveMovimientoSalidaConsignacion, UsuarioActual.CveEmpresa) Then - For Each Dr As DataRow In ObjInventario.DtResultados.Rows - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntradaGeneral, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDouble, Dr("CveAF").ToString.ToEntero, Dr("CveSeccionAlmacen").ToString.ToEntero, Dr("SerieLote").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then - Return False - End If - Next - End If - Else - Return False - End If - - 'SALIDA GENERAL - CveMovimientoEntradaGeneral = ObjInventario.AddMovimiento(Me.CveAlmacenOrigenContrato, 3, 1, Me.Fecha, -1, Me.CveUsuario, Me.CveEmpresa, -1, Me.CveVenta, -1, -1, Modulo:="Mod/E") - If CveMovimientoEntradaGeneral > 0 Then - If ObjInventario.GetMovimientosDetalle(CveMovimientoSalidaConsignacion, UsuarioActual.CveEmpresa) Then - For Each Dr As DataRow In ObjInventario.DtResultados.Rows - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntradaGeneral, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDouble, Dr("CveAF").ToString.ToEntero, Dr("CveSeccionAlmacen").ToString.ToEntero, Dr("SerieLote").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then - Return False - End If - Next - End If - Else - Return False - End If - - - Return True - End Function - Private Sub GuardarContratoAvanceEstimaciones(ObjFactura As Modelos.Factura, ObjContrato As ClsContratos, ErrorList As List(Of String), Multiplicador As Integer, Optional CrearAvance As Boolean = False) - - If ObjFactura.CveContrato > 0 Then - - Dim CveEstimacion As Integer = -1 - - If ObjContrato.AddEstimaciones(ObjFactura.CveContrato, ObjFactura.Fecha, -1, ObjFactura.CveVenta, "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then - CveEstimacion = ObjContrato.DtResultados(0)("CveEstimacion").ToString.ToEntero - - For Each row As DataRow In ObjFactura.DtDetalle.Rows - If row("CveContratoDetalle").ToString.ToEntero > 0 Then - If Not ObjContrato.AddContratosAvance(row("CveContratoDetalle").ToString.ToEntero, row("Cantidad").ToString.ToEntero * Multiplicador, ObjFactura.Fecha, UsuarioActual.CveUsuario, CveEstimacion:=CveEstimacion) Then - ErrorList.Add("Ocurrió un error al agregar los avances") - End If - End If - Next - - Else - ErrorList.Add("Ocurrió un error al agregar las estimaciones") - End If - End If - - End Sub - Private Sub InicializaDTVentasNC() - DtVentasNC = New DataTable - DtVentasNC.Columns.Add("CveVenta", GetType(Integer)) - DtVentasNC.Columns.Add("Importe", GetType(Decimal)) - DtVentasNC.Columns.Add("FolioFiscal", GetType(String)) - End Sub - Private Sub CargaNCDT(pCveVenta As Integer, Importe As Decimal, Optional FolioFiscal As String = "", Optional NuevaFactura As Integer = -1, Optional ByRef ObjVentas As ClsVentas = Nothing) - If (pCveVenta > 0 AndAlso Me.TipoDocto.Contiene("Egs")) OrElse (pCveVenta > 0 AndAlso NuevaFactura = 1) Then - If FolioFiscal = "" Then - - Dim ObjVentasAplicar As ClsVentas - If ObjVentas IsNot Nothing Then - ObjVentasAplicar = ObjVentas - Else - ObjVentasAplicar = New ClsVentas - End If - - If ObjVentasAplicar.GetVenta(pCveVenta, UsuarioActual.CveEmpresa) AndAlso ObjVentasAplicar.DtResultados.Rows.Count > 0 Then - FolioFiscal = ObjVentasAplicar.DtResultados.FiltroPrimeroValor("FolioFiscal").ToString - End If - - If ObjVentas Is Nothing Then - ObjVentasAplicar.Dispose() - End If - - End If - - Dim Dr = DtVentasNC.NewRow - Dr("CveVenta") = pCveVenta - Dr("Importe") = Importe - Dr("FolioFiscal") = FolioFiscal - DtVentasNC.Rows.Add(Dr) - End If - End Sub - Private Function GuardarUsados(SqlTransaccion As SqlClient.SqlTransaction, CveVenta As Integer, ByRef ObjVentas As ClsVentas, TipoDocto As String) As Boolean + CveMovimientoRelacionado:=CveMovimientoSalida3, CveOS:=CveOS, Modulo:="Mod/OS") + FolioEntrada = ObjInventario.Folio + + If CveMovimientoEntrada3 <= 0 Then + TextoError = "No se pudo generar el movimiento de entrada correctamente" + TieneError = True + Else + + If ObjInventario.GetMovimientosDetalle(CveMovimientoEntrada2, UsuarioActual.CveEmpresa) Then + + For Each Dr As DataRow In ObjInventario.DtResultados.Rows + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada3, Dr("Cantidad").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, -1, -1) Then + TieneError = True + TextoError = "Ocurrió un Error al guardar los movimientos de entrada" + Exit For + End If + Next + + End If + + End If + End If + + End If + End If + + Return TieneError + End Function + Function RegistraAlmacenConsignacionVenta(ByRef ObjInventario As ClsInventarios) As Boolean + If Not (UsuarioActual.Empresa.UsaInventarios AndAlso CveAlmacenExistenciasContrato > 0) Then + Return True + End If + + Dim CveMovimientoSalidaConsignacion = -1 + Dim CveMovimientoEntradaGeneral = -1 + Dim CveMovimientoSalidaGeneral = -1 + + + 'MOVIMIENTO DE SALIDA POR TRASPASO DEL ALMACEN DE CONSIGNACION + CveMovimientoSalidaConsignacion = ObjInventario.AddMovimiento(CveAlmacenExistenciasContrato, 8, 1, Me.Fecha, -1, Me.CveUsuario, Me.CveEmpresa, -1, Me.CveVenta, -1, -1, Modulo:="Mod/E") + If CveMovimientoSalidaConsignacion > 0 Then + Dim CveProducto As Integer + Dim CveUnidad As Integer + Dim Cantidad As Double + Dim Existencia As Double + For Each Dr As DataRow In DtDetalle.Rows + CveProducto = Dr("CvePS").ToString.ToEntero + CveUnidad = Dr("CveUM").ToString.ToEntero + Cantidad = Dr("Cantidad").ToString.ToDouble + + If Not CveProducto > 0 Then + Return False + End If + + If Dr("CveTipoInvPS").ToString.ToEntero = 5 Then + For Each Dr2 As DataRow In DtContratosSerieDetalle.FiltraParametros($"ConsecId = {Dr("CveContratoDetalle")}").Rows + Existencia = ObjInventario.GetExistenciasPS(CveProducto, CveUnidad, Me.CveEmpresa, CveAlmacenExistenciasContrato, SerieLote:=Dr2("Serie").ToString, FechaMovto:=DateTime.Today.AddDays(1).ToString("yyyy/MM/dd HH:mm"), CveSubProyecto:=Me.CveSubProyecto, ExcluyeAdelantado:=1, RestringirAlmacenes:=1, ExcluyeApartados:=1) + If Existencia < 1 Then + Return False + End If + + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalidaConsignacion, 1, CveUnidad, CveProducto, 0, -1, SerieLote:=Dr2("Serie").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then + Return False + End If + Next + Else + Existencia = ObjInventario.GetExistenciasPS(CveProducto, CveUnidad, Me.CveEmpresa, CveAlmacenExistenciasContrato, FechaMovto:=DateTime.Today.AddDays(1).ToString("yyyy/MM/dd HH:mm"), CveSubProyecto:=Me.CveSubProyecto, ExcluyeAdelantado:=1, RestringirAlmacenes:=1, ExcluyeApartados:=1) + If Existencia < Cantidad Then + Return False + End If + + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalidaConsignacion, Cantidad, CveUnidad, CveProducto, 0, -1, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then + Return False + End If + End If + Next + Else + Return False + End If + + + 'ENTRADA POR TRASPASO A GENERAL + CveMovimientoEntradaGeneral = ObjInventario.AddMovimiento(Me.CveAlmacenOrigenContrato, 9, 1, Me.Fecha, -1, Me.CveUsuario, Me.CveEmpresa, -1, Me.CveVenta, -1, -1, CveMovimientoRelacionado:=CveMovimientoSalidaConsignacion, Modulo:="Mod/E") + If CveMovimientoEntradaGeneral > 0 Then + If ObjInventario.GetMovimientosDetalle(CveMovimientoSalidaConsignacion, UsuarioActual.CveEmpresa) Then + For Each Dr As DataRow In ObjInventario.DtResultados.Rows + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntradaGeneral, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero, Dr("CveSeccionAlmacen").ToString.ToEntero, Dr("SerieLote").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then + Return False + End If + Next + End If + Else + Return False + End If + + 'SALIDA GENERAL + CveMovimientoEntradaGeneral = ObjInventario.AddMovimiento(Me.CveAlmacenOrigenContrato, 3, 1, Me.Fecha, -1, Me.CveUsuario, Me.CveEmpresa, -1, Me.CveVenta, -1, -1, Modulo:="Mod/E") + If CveMovimientoEntradaGeneral > 0 Then + If ObjInventario.GetMovimientosDetalle(CveMovimientoSalidaConsignacion, UsuarioActual.CveEmpresa) Then + For Each Dr As DataRow In ObjInventario.DtResultados.Rows + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntradaGeneral, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero, Dr("CveSeccionAlmacen").ToString.ToEntero, Dr("SerieLote").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then + Return False + End If + Next + End If + Else + Return False + End If + + + Return True + End Function + Private Sub GuardarContratoAvanceEstimaciones(ObjFactura As Modelos.Factura, ObjContrato As ClsContratos, ErrorList As List(Of String), Multiplicador As Integer, Optional CrearAvance As Boolean = False) + + If ObjFactura.CveContrato > 0 Then + + Dim CveEstimacion As Integer = -1 + + If ObjContrato.AddEstimaciones(ObjFactura.CveContrato, ObjFactura.Fecha, -1, ObjFactura.CveVenta, "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then + CveEstimacion = ObjContrato.DtResultados(0)("CveEstimacion").ToString.ToEntero + + For Each row As DataRow In ObjFactura.DtDetalle.Rows + If row("CveContratoDetalle").ToString.ToEntero > 0 Then + If Not ObjContrato.AddContratosAvance(row("CveContratoDetalle").ToString.ToEntero, row("Cantidad").ToString.ToEntero * Multiplicador, ObjFactura.Fecha, UsuarioActual.CveUsuario, CveEstimacion:=CveEstimacion) Then + ErrorList.Add("Ocurrió un error al agregar los avances") + End If + End If + Next + + Else + ErrorList.Add("Ocurrió un error al agregar las estimaciones") + End If + End If + + End Sub + Private Sub InicializaDTVentasNC() + DtVentasNC = New DataTable + DtVentasNC.Columns.Add("CveVenta", GetType(Integer)) + DtVentasNC.Columns.Add("Importe", GetType(Decimal)) + DtVentasNC.Columns.Add("FolioFiscal", GetType(String)) + End Sub + Private Sub CargaNCDT(pCveVenta As Integer, Importe As Decimal, Optional FolioFiscal As String = "", Optional NuevaFactura As Integer = -1, Optional ByRef ObjVentas As ClsVentas = Nothing) + If (pCveVenta > 0 AndAlso Me.TipoDocto.Contiene("Egs")) OrElse (pCveVenta > 0 AndAlso NuevaFactura = 1) Then + If FolioFiscal = "" Then + + Dim ObjVentasAplicar As ClsVentas + If ObjVentas IsNot Nothing Then + ObjVentasAplicar = ObjVentas + Else + ObjVentasAplicar = New ClsVentas + End If + + If ObjVentasAplicar.GetVenta(pCveVenta, UsuarioActual.CveEmpresa) AndAlso ObjVentasAplicar.DtResultados.Rows.Count > 0 Then + FolioFiscal = ObjVentasAplicar.DtResultados.FiltroPrimeroValor("FolioFiscal").ToString + End If + + If ObjVentas Is Nothing Then + ObjVentasAplicar.Dispose() + End If + + End If + + Dim Dr = DtVentasNC.NewRow + Dr("CveVenta") = pCveVenta + Dr("Importe") = Importe + Dr("FolioFiscal") = FolioFiscal + DtVentasNC.Rows.Add(Dr) + End If + End Sub + Private Function GuardarUsados(SqlTransaccion As SqlClient.SqlTransaction, CveVenta As Integer, ByRef ObjVentas As ClsVentas, TipoDocto As String) As Boolean Dim Resultado As Boolean = True If UsuarioActual.Empresa.Funcionalidad(533).ToEntero > 0 AndAlso TipoDocto.Contiene("Ing", "Ant", "Rem") Then @@ -1938,10 +1938,10 @@ Namespace Modelos End If End If - Return Resultado - + Return Resultado + End Function - Private Function GuardarPolizasVirtuales(SqlTransaccion As SqlClient.SqlTransaction, ObjFactura As Modelos.Factura) As Boolean + Private Function GuardarPolizasVirtuales(SqlTransaccion As SqlClient.SqlTransaction, ObjFactura As Modelos.Factura) As Boolean Dim Resultado As Boolean = True If UsuarioActual.Empresa.Funcionalidad(531).ToEntero > 0 AndAlso ObjFactura.TipoDocto.Contiene("Rem") Then @@ -1959,88 +1959,88 @@ Namespace Modelos Next End If - Return Resultado - - End Function - Private Sub GuardarVentaPrePolizas(ByRef factura As Modelos.Factura, ByRef ObjConta As ClsContabilidad, TmpDTDetalleMovimientos As DataTable, CveNCaVincular As Integer, ByRef objContPaqi As ClsContPAQi, Optional ByRef ObjBancos As ClsBancos = Nothing, ByRef Optional ObjVentas As ClsVentas = Nothing, ByRef Optional ObjEventos As ClsOIEventos = Nothing) - - Dim CveIE As Integer = -1 - Dim DT As DataTable = Nothing - - - Dim CveConceptoAfectacion As Integer = 1 'Cliente - Dim CveConceptoAntCli As Integer = 3 'Anticipo Cliente - Dim CveConceptoVenta As Integer = 4 'Venta - Dim CveConceptoCanAnt As Integer = 11 'Cancelacion Anticipos - Dim CveConceptoDSV As Integer = 12 ' DSV - Dim CveConceptoIVA As Integer = 13 'IVA Trasladado - Dim CveConceptoRetIVA As Integer = 8 'Ret IVA - Dim CveConceptoRetISR As Integer = 9 'Ret ISR - - 'P R E P O L I Z A S - If Me.TipoDocto <> "Cot" Then - If Me.CvePrePoliza > 0 Then - If ProcesoPrepolizas(factura, ObjConta, CveIE, TmpDTDetalleMovimientos, objContPaqi, 1, ObjBancos, ObjVentas, ObjEventos:=ObjEventos) Then - ErrorList.Add("Ocurrió un error al agregar los Movimientos de la prepoliza.
Revise su factura y cualquier detalle comuníquese a Soporte Técnico") - End If - Else - ErrorList.Add("Ocurrió un error al agregar los Movimientos de la prepoliza.
Revise su factura y cualquier detalle comuníquese a Soporte Técnico") - End If - End If - End Sub - Private Function ProcesoPrepolizas(ObjFactura As Factura, ByRef ObjConta As ClsContabilidad, CveIE As Integer, TmpDTDetalle As DataTable, ByRef objContPaqi As ClsContPAQi, - Optional ValorMultiplicador As Integer = 1, ByRef Optional ObjBancos As ClsBancos = Nothing, ByRef Optional ObjVentas As ClsVentas = Nothing, ByRef Optional ObjEventos As ClsOIEventos = Nothing, - Optional ByRef DtRemisionesRelacionadas As DataTable = Nothing, Optional SeCancelaRemisionProceso As Boolean = False, Optional CancelarRemisiones As Boolean = False, Optional ListaRemisionesCancelar As List(Of Integer) = Nothing, - Optional CveEstatusRefacturacion As Integer = 0) As Boolean - Dim ErrorPrepoliza As Boolean = False - Try - Dim DT As DataTable - Dim CvePlantilaPoliza As Integer - Dim PorcentajeAmortizacion As Decimal = 0 - Dim sumaAmorticaciones As Decimal = 0 - Dim alertaContabilizacion As String = "Se enviaron correctamente las siguientes pólizas:

" - Dim idCuentaContabilizacion As Integer = 1 - Dim CveCuentaContabilizacion As Integer = 1 - Dim tipoCambio As Decimal - Dim CuentasContablesInvalidas As New StringBuilder - Dim CuentasContablesInvalidasSIG As New StringBuilder - - If ObjFactura.TipoDocto = "Ing" Or ObjFactura.TipoDocto = "Ant" Or ObjFactura.TipoDocto = "Com" Then - CvePlantilaPoliza = 4 - ElseIf ObjFactura.TipoDocto.Contiene("Egs", "Dev") Then - CvePlantilaPoliza = 7 - ElseIf ObjFactura.TipoDocto.Contiene("Rem", "RNC") Then - CvePlantilaPoliza = 4 - End If - - If ObjFactura.CveMoneda = 2 AndAlso ObjFactura.TipoCambio > 0 Then - tipoCambio = ObjFactura.TipoCambio - ElseIf ObjFactura.CveMoneda = 2 AndAlso ObjFactura.TipoCambio <= 1 Then - tipoCambio = GlobalTipoCambio(ObjFactura.Fecha).ToString.ToDecimal - Else - tipoCambio = 1 - End If - - Dim ConceptoContable As Integer - Dim TipoMovimiento As Boolean - Dim importeMovimiento As Decimal - Dim FechaMovimiento As Date = ObjFactura.Fecha - Dim IdCtaContable As Integer - Dim CveCuenta As Integer - Dim IdCtaContableCliente As Integer - Dim CveCuentaCliente As Integer - Dim Concepto As String = ObjFactura.SerieFolio - Dim Referencia As String = ObjFactura.SerieFolio - Dim Fecha = ObjFactura.Fecha - - Dim importeMX As Decimal - Dim Multiplicador As Integer - Dim CveIEPago As Integer - Dim FolioIE As Long - Dim CveIEAnticipo As Integer - Dim CveSubProyectoVenta = ObjFactura.CveSubProyecto - Dim CveSubProyectoContabilizar As Integer - Dim IdCtaIVAXTrasladar As Integer = 0 + Return Resultado + + End Function + Private Sub GuardarVentaPrePolizas(ByRef factura As Modelos.Factura, ByRef ObjConta As ClsContabilidad, TmpDTDetalleMovimientos As DataTable, CveNCaVincular As Integer, ByRef objContPaqi As ClsContPAQi, Optional ByRef ObjBancos As ClsBancos = Nothing, ByRef Optional ObjVentas As ClsVentas = Nothing, ByRef Optional ObjEventos As ClsOIEventos = Nothing) + + Dim CveIE As Integer = -1 + Dim DT As DataTable = Nothing + + + Dim CveConceptoAfectacion As Integer = 1 'Cliente + Dim CveConceptoAntCli As Integer = 3 'Anticipo Cliente + Dim CveConceptoVenta As Integer = 4 'Venta + Dim CveConceptoCanAnt As Integer = 11 'Cancelacion Anticipos + Dim CveConceptoDSV As Integer = 12 ' DSV + Dim CveConceptoIVA As Integer = 13 'IVA Trasladado + Dim CveConceptoRetIVA As Integer = 8 'Ret IVA + Dim CveConceptoRetISR As Integer = 9 'Ret ISR + + 'P R E P O L I Z A S + If Me.TipoDocto <> "Cot" Then + If Me.CvePrePoliza > 0 Then + If ProcesoPrepolizas(factura, ObjConta, CveIE, TmpDTDetalleMovimientos, objContPaqi, 1, ObjBancos, ObjVentas, ObjEventos:=ObjEventos) Then + ErrorList.Add("Ocurrió un error al agregar los Movimientos de la prepoliza.
Revise su factura y cualquier detalle comuníquese a Soporte Técnico") + End If + Else + ErrorList.Add("Ocurrió un error al agregar los Movimientos de la prepoliza.
Revise su factura y cualquier detalle comuníquese a Soporte Técnico") + End If + End If + End Sub + Private Function ProcesoPrepolizas(ObjFactura As Factura, ByRef ObjConta As ClsContabilidad, CveIE As Integer, TmpDTDetalle As DataTable, ByRef objContPaqi As ClsContPAQi, + Optional ValorMultiplicador As Integer = 1, ByRef Optional ObjBancos As ClsBancos = Nothing, ByRef Optional ObjVentas As ClsVentas = Nothing, ByRef Optional ObjEventos As ClsOIEventos = Nothing, + Optional ByRef DtRemisionesRelacionadas As DataTable = Nothing, Optional SeCancelaRemisionProceso As Boolean = False, Optional CancelarRemisiones As Boolean = False, Optional ListaRemisionesCancelar As List(Of Integer) = Nothing, + Optional CveEstatusRefacturacion As Integer = 0) As Boolean + Dim ErrorPrepoliza As Boolean = False + Try + Dim DT As DataTable + Dim CvePlantilaPoliza As Integer + Dim PorcentajeAmortizacion As Decimal = 0 + Dim sumaAmorticaciones As Decimal = 0 + Dim alertaContabilizacion As String = "Se enviaron correctamente las siguientes pólizas:

" + Dim idCuentaContabilizacion As Integer = 1 + Dim CveCuentaContabilizacion As Integer = 1 + Dim tipoCambio As Decimal + Dim CuentasContablesInvalidas As New StringBuilder + Dim CuentasContablesInvalidasSIG As New StringBuilder + + If ObjFactura.TipoDocto = "Ing" Or ObjFactura.TipoDocto = "Ant" Or ObjFactura.TipoDocto = "Com" Then + CvePlantilaPoliza = 4 + ElseIf ObjFactura.TipoDocto.Contiene("Egs", "Dev") Then + CvePlantilaPoliza = 7 + ElseIf ObjFactura.TipoDocto.Contiene("Rem", "RNC") Then + CvePlantilaPoliza = 4 + End If + + If ObjFactura.CveMoneda = 2 AndAlso ObjFactura.TipoCambio > 0 Then + tipoCambio = ObjFactura.TipoCambio + ElseIf ObjFactura.CveMoneda = 2 AndAlso ObjFactura.TipoCambio <= 1 Then + tipoCambio = GlobalTipoCambio(ObjFactura.Fecha).ToString.ToDecimal + Else + tipoCambio = 1 + End If + + Dim ConceptoContable As Integer + Dim TipoMovimiento As Boolean + Dim importeMovimiento As Decimal + Dim FechaMovimiento As Date = ObjFactura.Fecha + Dim IdCtaContable As Integer + Dim CveCuenta As Integer + Dim IdCtaContableCliente As Integer + Dim CveCuentaCliente As Integer + Dim Concepto As String = ObjFactura.SerieFolio + Dim Referencia As String = ObjFactura.SerieFolio + Dim Fecha = ObjFactura.Fecha + + Dim importeMX As Decimal + Dim Multiplicador As Integer + Dim CveIEPago As Integer + Dim FolioIE As Long + Dim CveIEAnticipo As Integer + Dim CveSubProyectoVenta = ObjFactura.CveSubProyecto + Dim CveSubProyectoContabilizar As Integer + Dim IdCtaIVAXTrasladar As Integer = 0 Dim IdCtaIVATrasladado As Integer = 0 Dim CveCuentaIVAxTrasladar As Integer = 0 Dim CveCuentaIVATrasladado As Integer = 0 @@ -2048,35 +2048,35 @@ Namespace Modelos If (UsuarioActual.Empresa.Funcionalidad(343) = "1" AndAlso ObjFactura.TipoDocto = "Ant") Then SeContabiliza = False - End If - + End If + If GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=ObjFactura.DtDetalle.MAX("PorcentajeIVA").ToDouble).Rows.Count > 0 Then IdCtaIVAXTrasladar = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=DtDetalle.MAX("PorcentajeIVA").ToDouble).Rows(0)("IdCtaIVAXTrasladar").ToString.ToEntero CveCuentaIVAxTrasladar = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=DtDetalle.MAX("PorcentajeIVA").ToDouble).Rows(0)("CveCuentaIVAXTrasladar").ToString.ToEntero IdCtaIVATrasladado = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=DtDetalle.MAX("PorcentajeIVA").ToDouble).Rows(0)("IdCtaIVATrasladado").ToString.ToEntero - CveCuentaIVATrasladado = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=DtDetalle.MAX("PorcentajeIVA").ToDouble).Rows(0)("CveCuentaIVATrasladado").ToString.ToEntero - End If - - Dim UsaComplementariaClientes As Boolean = False - If UsuarioActual.CveEmpresa.Contiene(1, 119) Then UsaComplementariaClientes = True - + CveCuentaIVATrasladado = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=DtDetalle.MAX("PorcentajeIVA").ToDouble).Rows(0)("CveCuentaIVATrasladado").ToString.ToEntero + End If + + Dim UsaComplementariaClientes As Boolean = False + If UsuarioActual.CveEmpresa.Contiene(1, 119) Then UsaComplementariaClientes = True + If ObjConta.GetPlantillaConceptos(ObjFactura.CveEmpresa, CvePlantilaPoliza) Then Dim dtt As DataTable = ObjConta.DtResultados If ValorMultiplicador = -1 Then dtt = ObjConta.DtResultados.FiltraParametros("", "Orden DESC") ' se ordena contrario al registro para llevar los saldos correctos For Each Row As DataRow In dtt.Rows - ConceptoContable = Row("CveConcepto").ToString.ToEntero - TipoMovimiento = If(Row("TipoMovto").ToString = "True", True, False) - importeMovimiento = 0 - IdCtaContable = 0 - CveCuenta = 0 - CveSubProyectoContabilizar = 0 - Multiplicador = (Row("Multiplicador").ToString.ToEntero) - Concepto = ObjConta.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, ConceptoContable, ObjFactura.Cliente.Nombre, $"{ObjFactura.Serie}-{ObjFactura.Folio}", "") - Dim PorcentajeImpuesto As Decimal = 0 - - - Select Case ConceptoContable + ConceptoContable = Row("CveConcepto").ToString.ToEntero + TipoMovimiento = If(Row("TipoMovto").ToString = "True", True, False) + importeMovimiento = 0 + IdCtaContable = 0 + CveCuenta = 0 + CveSubProyectoContabilizar = 0 + Multiplicador = (Row("Multiplicador").ToString.ToEntero) + Concepto = ObjConta.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, ConceptoContable, ObjFactura.Cliente.Nombre, $"{ObjFactura.Serie}-{ObjFactura.Folio}", "") + Dim PorcentajeImpuesto As Decimal = 0 + + + Select Case ConceptoContable Case 1 'Cliente If Not ObjFactura.TipoDocto.Contiene("Egs", "Rem", "RNC") Then importeMovimiento = (ObjFactura.Total - TotalOtrosConceptos) * ValorMultiplicador @@ -2107,8 +2107,8 @@ Namespace Modelos End If IdCtaContableCliente = IdCtaContable CveCuentaCliente = CveCuenta - End If - + End If + Case 3 'Cliente If ObjFactura.TipoDocto = "Ant" Then @@ -2120,10 +2120,10 @@ Namespace Modelos CveCuenta = ObjFactura.Cliente.CveCuentaAnticipos CveSubProyectoContabilizar = CveSubProyectoVenta If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}" - End If - - Case 190 'Remisión del cliente - + End If + + Case 190 'Remisión del cliente + If ObjFactura.TipoDocto = "Rem" Then importeMovimiento = (ObjFactura.Total - TotalOtrosConceptos) * ValorMultiplicador importeMX = importeMovimiento * tipoCambio * Multiplicador @@ -2149,11 +2149,11 @@ Namespace Modelos ErrorPrepoliza = True End If - importeMovimiento = 0 - ObjFactura.SeGuardoPrePoliza = True - End If - Case 277 'Remisión del cliente - + importeMovimiento = 0 + ObjFactura.SeGuardoPrePoliza = True + End If + Case 277 'Remisión del cliente + If ObjFactura.TipoDocto = "RNC" Then importeMovimiento = (ObjFactura.Total - TotalOtrosConceptos) * ValorMultiplicador importeMX = importeMovimiento * tipoCambio * Multiplicador @@ -2179,12 +2179,12 @@ Namespace Modelos ErrorPrepoliza = True End If - importeMovimiento = 0 - ObjFactura.SeGuardoPrePoliza = True - End If - - - Case 12 'Nota de Credito + importeMovimiento = 0 + ObjFactura.SeGuardoPrePoliza = True + End If + + + Case 12 'Nota de Credito If ObjFactura.TipoDocto.Contiene("Egs", "Dev") Then importeMovimiento = ObjFactura.Total * ValorMultiplicador importeMX = (importeMovimiento * tipoCambio * Multiplicador).RoundSQL @@ -2228,143 +2228,143 @@ Namespace Modelos ObjFactura.SeGuardoPrePoliza = True End If End If - importeMovimiento = 0 - - If ValorMultiplicador = 1 Then - Dim IdCtaContableClienteComplementaria As Integer = ObjFactura.Cliente.IdCtaContComplementaria - Dim TipoCambioNC As Decimal = 1 - If tipoCambio > 1 Then - TipoCambioNC = tipoCambio - Else - TipoCambioNC = GlobalTipoCambio(ObjFactura.Fecha).ToDecimal - End If - 'APLICA NC SALDOS DIRECTOS - If DtVentasNC IsNot Nothing AndAlso DtVentasNC.Rows.Count > 0 Then - For Each Dr As DataRow In DtVentasNC.Rows - Dim Importe91 As Decimal = 0 - Dim ImporteMN91 As Decimal = 0 - Dim Importe251 As Decimal = 0 - - If ObjFactura.CveMoneda = 1 AndAlso Not Dr("TCCambioValuacion").ToString.ToDecimal > 1 Then - Importe251 = Dr("Importe").ToString.ToDecimal - Importe91 = Dr("Importe").ToString.ToDecimal - ImporteMN91 = Dr("Importe").ToString.ToDecimal - TipoCambioNC = 1 - ElseIf ObjFactura.CveMoneda = 2 AndAlso Not Dr("TCCambioValuacion").ToString.ToDecimal > 1 Then - Importe251 = Dr("Importe").ToString.ToDecimal * TipoCambioNC - Importe91 = Dr("Importe").ToString.ToDecimal - ImporteMN91 = Dr("Importe").ToString.ToDecimal * TipoCambioNC - ElseIf ObjFactura.CveMoneda = 2 AndAlso Dr("TCCambioValuacion").ToString.ToDecimal > 1 Then - Importe251 = Dr("Importe").ToString.ToDecimal - Importe91 = Dr("Importe").ToString.ToDecimal - ImporteMN91 = Dr("Importe").ToString.ToDecimal * TipoCambioNC - ElseIf ObjFactura.CveMoneda = 1 AndAlso Dr("TCCambioValuacion").ToString.ToDecimal > 1 Then - Importe251 = Dr("Importe").ToString.ToDecimal / TipoCambioNC - Importe91 = Dr("Importe").ToString.ToDecimal - ImporteMN91 = Dr("Importe").ToString.ToDecimal - End If - - Importe251 = (Importe251 * Multiplicador).RoundSQL - - Importe91 = (Importe91 * ValorMultiplicador).RoundSQL - ImporteMN91 = (ImporteMN91 * Multiplicador).RoundSQL - If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${Importe91.FormatoNumero(2)}" - - CveUltimaVenta = Dr("CveVenta").ToString.ToEntero - - Dim ImporteComplementarioIngreso As Decimal = 0 - If UsaComplementariaClientes = True AndAlso tipoCambio > 1 Then - ImporteMN91 = Importe91 - ImporteComplementarioIngreso = ((Importe91 * tipoCambio) - Importe91).RoundSQL - If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, False, Importe91, Referencia, 203, Concepto, FechaMovimiento, IdCtaContableClienteComplementaria, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveVentaAmortizacion:=Dr("CveVenta").ToString.ToEntero, ImporteMX:=ImporteComplementarioIngreso, ImporteME:=If(tipoCambio = 1, 0, Importe91), CveSubProyecto:=CveSubProyectoContabilizar, TipoCambio:=tipoCambio, TipoCambioPago:=Dr("TCCambioValuacion").ToString.ToDecimal) Then - ErrorPrepoliza = True - Exit For - End If - End If - If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, False, Importe91, Referencia, 91, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveVentaAmortizacion:=Dr("CveVenta").ToString.ToEntero, ImporteMX:=ImporteMN91, ImporteME:=If(tipoCambio = 1, 0, Importe91), CveSubProyecto:=CveSubProyectoContabilizar, TipoCambio:=tipoCambio) Then - ErrorPrepoliza = True - Exit For - End If - ImporteAcumulado91 += (ImporteMN91).RoundSQL - - If UsaComplementariaClientes = True AndAlso Dr("TCCambioValuacion").ToString.ToDecimal > 1 Then - Dim ImporteComplementarioNC As Decimal = ((Importe251 * Dr("TCCambioValuacion").ToString.ToDecimal) - Importe251).RoundSQL - If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, True, Importe251, Referencia, 207, Concepto, FechaMovimiento, IdCtaContableClienteComplementaria, -1, CveVenta:=Dr("CveVenta").ToString.ToEntero, CveCliente:=ObjFactura.CveCliente, ImporteMX:=ImporteComplementarioNC, ImporteME:=If(Dr("TCCambioValuacion").ToString.ToDecimal = 1, 0, Importe251), CveSubProyecto:=CveSubProyectoContabilizar, CveVentaAmortizacion:=ObjFactura.CveVenta, TipoCambio:=Dr("TCCambioValuacion").ToString.ToDecimal) Then - ErrorPrepoliza = True - Exit For - End If - End If - If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, True, Importe251, Referencia, 251, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=Dr("CveVenta").ToString.ToEntero, CveCliente:=ObjFactura.CveCliente, ImporteMX:=Importe251, ImporteME:=If(Dr("TCCambioValuacion").ToString.ToDecimal = 1, 0, Importe251), CveSubProyecto:=CveSubProyectoContabilizar, CveVentaAmortizacion:=ObjFactura.CveVenta, TipoCambio:=Dr("TCCambioValuacion").ToString.ToDecimal, TipoCambioPago:=tipoCambio) Then - ErrorPrepoliza = True - Exit For - End If - - - 'considero fluctuación. - - Dim TCFluctuacion As Decimal = Dr("TCCambioValuacion").ToString.ToDecimal - If TCFluctuacion = 1 AndAlso TipoCambioNC > 1 Then - TCFluctuacion = GlobalTipoCambio(ObjFactura.Fecha).ToDecimal - End If - If TipoCambioNC <> TCFluctuacion AndAlso TCFluctuacion > 1 AndAlso TipoCambioNC > 1 Then - Dim difFluctuacion As Decimal = TipoCambioNC - TCFluctuacion - Dim CveConceptoFluctua As Integer = 64 '64.ganacia, 65.perdida - Dim TipoMovtoFluctua As Boolean = True - Dim IdCtaContableFluctua As Integer - If difFluctuacion < 0 Then - CveConceptoFluctua = 65 - TipoMovtoFluctua = False - IdCtaContableFluctua = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria - CveCuenta = UsuarioActual.Empresa.CveCuentaPerdidaCambiaria - Else - CveConceptoFluctua = 64 - TipoMovtoFluctua = True - IdCtaContableFluctua = UsuarioActual.Empresa.IdCuentaGananciaCambiaria - CveCuenta = UsuarioActual.Empresa.CveCuentaGananciaCambiaria - End If - Dim ImporteFluctuacion As Decimal = Math.Abs((Importe251 * difFluctuacion).RoundSQL) * ValorMultiplicador - - If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovtoFluctua, ImporteFluctuacion, Referencia, CveConceptoFluctua, Concepto, FechaMovimiento, IdCtaContableFluctua, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveVentaAmortizacion:=Dr("CveVenta").ToString.ToEntero, ImporteMX:=ImporteFluctuacion, ImporteME:=ImporteFluctuacion, CveSubProyecto:=CveSubProyectoContabilizar, TipoCambio:=TipoCambioNC, TipoCambioPago:=Dr("TCCambioValuacion").ToString.ToDecimal, CveCuenta:=CveCuenta) Then - ErrorPrepoliza = True - Exit For - End If - End If - - Next - - If ImporteConcepto12 < ImporteAcumulado91 Then - Dim ImporteOtrosIngresos As Decimal = ImporteConcepto12 - ImporteAcumulado91 - If ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, False, ImporteOtrosIngresos, Referencia, 91, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveVentaAmortizacion:=CveUltimaVenta, ImporteMX:=ImporteOtrosIngresos, ImporteME:=0, CveSubProyecto:=CveSubProyectoContabilizar, TipoCambio:=tipoCambio) Then - If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, True, ImporteOtrosIngresos, Referencia, 211, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, ImporteME:=0, ImporteMX:=ImporteOtrosIngresos, CveSubProyecto:=CveSubProyectoContabilizar) Then - ErrorPrepoliza = True - End If - Else - ErrorPrepoliza = True - End If - End If - - If ObjConta.ValidacionPrePolizaCuadre(ObjFactura.CvePrePoliza, 5) Then - If ObjConta.ValorPolizaDescuadre > 0 Then - ErrorPrepoliza = True - GuardaLogAD($"Ventas/Ventas-ProcesoPrePolizas | Error:{ObjConta.MensajePolizaDescuadre} Diferencia:{ObjConta.ValorDiferencia} | CvePrePoliza:{ObjFactura.CvePrePoliza}", "LogPrePolizas") - - 'SIRVE PARA VER LA PREPOLIZA QUE SE VALIDA - 'If ObjConta.GetPrePolizasDetalle(ObjFactura.CvePrePoliza) Then - ' Dim DtTest = ObjConta.DtResultados - 'End If - End If - End If - - - If ErrorPrepoliza Then - Exit For - End If - End If - - 'APLICA DEVOLUCION SALDOS DIRECTOS - If ObjFactura.AplicaDevolucion Then - Dim TipoCambioFactura = ObjFactura.TipoCambio - Dim importeMovimientoDev = ObjFactura.Total + importeMovimiento = 0 + + If ValorMultiplicador = 1 Then + Dim IdCtaContableClienteComplementaria As Integer = ObjFactura.Cliente.IdCtaContComplementaria + Dim TipoCambioNC As Decimal = 1 + If tipoCambio > 1 Then + TipoCambioNC = tipoCambio + Else + TipoCambioNC = GlobalTipoCambio(ObjFactura.Fecha).ToDecimal + End If + 'APLICA NC SALDOS DIRECTOS + If DtVentasNC IsNot Nothing AndAlso DtVentasNC.Rows.Count > 0 Then + For Each Dr As DataRow In DtVentasNC.Rows + Dim Importe91 As Decimal = 0 + Dim ImporteMN91 As Decimal = 0 + Dim Importe251 As Decimal = 0 + + If ObjFactura.CveMoneda = 1 AndAlso Not Dr("TCCambioValuacion").ToString.ToDecimal > 1 Then + Importe251 = Dr("Importe").ToString.ToDecimal + Importe91 = Dr("Importe").ToString.ToDecimal + ImporteMN91 = Dr("Importe").ToString.ToDecimal + TipoCambioNC = 1 + ElseIf ObjFactura.CveMoneda = 2 AndAlso Not Dr("TCCambioValuacion").ToString.ToDecimal > 1 Then + Importe251 = Dr("Importe").ToString.ToDecimal * TipoCambioNC + Importe91 = Dr("Importe").ToString.ToDecimal + ImporteMN91 = Dr("Importe").ToString.ToDecimal * TipoCambioNC + ElseIf ObjFactura.CveMoneda = 2 AndAlso Dr("TCCambioValuacion").ToString.ToDecimal > 1 Then + Importe251 = Dr("Importe").ToString.ToDecimal + Importe91 = Dr("Importe").ToString.ToDecimal + ImporteMN91 = Dr("Importe").ToString.ToDecimal * TipoCambioNC + ElseIf ObjFactura.CveMoneda = 1 AndAlso Dr("TCCambioValuacion").ToString.ToDecimal > 1 Then + Importe251 = Dr("Importe").ToString.ToDecimal / TipoCambioNC + Importe91 = Dr("Importe").ToString.ToDecimal + ImporteMN91 = Dr("Importe").ToString.ToDecimal + End If + + Importe251 = (Importe251 * Multiplicador).RoundSQL + + Importe91 = (Importe91 * ValorMultiplicador).RoundSQL + ImporteMN91 = (ImporteMN91 * Multiplicador).RoundSQL + If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${Importe91.FormatoNumero(2)}" + + CveUltimaVenta = Dr("CveVenta").ToString.ToEntero + + Dim ImporteComplementarioIngreso As Decimal = 0 + If UsaComplementariaClientes = True AndAlso tipoCambio > 1 Then + ImporteMN91 = Importe91 + ImporteComplementarioIngreso = ((Importe91 * tipoCambio) - Importe91).RoundSQL + If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, False, Importe91, Referencia, 203, Concepto, FechaMovimiento, IdCtaContableClienteComplementaria, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveVentaAmortizacion:=Dr("CveVenta").ToString.ToEntero, ImporteMX:=ImporteComplementarioIngreso, ImporteME:=If(tipoCambio = 1, 0, Importe91), CveSubProyecto:=CveSubProyectoContabilizar, TipoCambio:=tipoCambio, TipoCambioPago:=Dr("TCCambioValuacion").ToString.ToDecimal) Then + ErrorPrepoliza = True + Exit For + End If + End If + If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, False, Importe91, Referencia, 91, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveVentaAmortizacion:=Dr("CveVenta").ToString.ToEntero, ImporteMX:=ImporteMN91, ImporteME:=If(tipoCambio = 1, 0, Importe91), CveSubProyecto:=CveSubProyectoContabilizar, TipoCambio:=tipoCambio) Then + ErrorPrepoliza = True + Exit For + End If + ImporteAcumulado91 += (ImporteMN91).RoundSQL + + If UsaComplementariaClientes = True AndAlso Dr("TCCambioValuacion").ToString.ToDecimal > 1 Then + Dim ImporteComplementarioNC As Decimal = ((Importe251 * Dr("TCCambioValuacion").ToString.ToDecimal) - Importe251).RoundSQL + If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, True, Importe251, Referencia, 207, Concepto, FechaMovimiento, IdCtaContableClienteComplementaria, -1, CveVenta:=Dr("CveVenta").ToString.ToEntero, CveCliente:=ObjFactura.CveCliente, ImporteMX:=ImporteComplementarioNC, ImporteME:=If(Dr("TCCambioValuacion").ToString.ToDecimal = 1, 0, Importe251), CveSubProyecto:=CveSubProyectoContabilizar, CveVentaAmortizacion:=ObjFactura.CveVenta, TipoCambio:=Dr("TCCambioValuacion").ToString.ToDecimal) Then + ErrorPrepoliza = True + Exit For + End If + End If + If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, True, Importe251, Referencia, 251, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=Dr("CveVenta").ToString.ToEntero, CveCliente:=ObjFactura.CveCliente, ImporteMX:=Importe251, ImporteME:=If(Dr("TCCambioValuacion").ToString.ToDecimal = 1, 0, Importe251), CveSubProyecto:=CveSubProyectoContabilizar, CveVentaAmortizacion:=ObjFactura.CveVenta, TipoCambio:=Dr("TCCambioValuacion").ToString.ToDecimal, TipoCambioPago:=tipoCambio) Then + ErrorPrepoliza = True + Exit For + End If + + + 'considero fluctuación. + + Dim TCFluctuacion As Decimal = Dr("TCCambioValuacion").ToString.ToDecimal + If TCFluctuacion = 1 AndAlso TipoCambioNC > 1 Then + TCFluctuacion = GlobalTipoCambio(ObjFactura.Fecha).ToDecimal + End If + If TipoCambioNC <> TCFluctuacion AndAlso TCFluctuacion > 1 AndAlso TipoCambioNC > 1 Then + Dim difFluctuacion As Decimal = TipoCambioNC - TCFluctuacion + Dim CveConceptoFluctua As Integer = 64 '64.ganacia, 65.perdida + Dim TipoMovtoFluctua As Boolean = True + Dim IdCtaContableFluctua As Integer + If difFluctuacion < 0 Then + CveConceptoFluctua = 65 + TipoMovtoFluctua = False + IdCtaContableFluctua = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria + CveCuenta = UsuarioActual.Empresa.CveCuentaPerdidaCambiaria + Else + CveConceptoFluctua = 64 + TipoMovtoFluctua = True + IdCtaContableFluctua = UsuarioActual.Empresa.IdCuentaGananciaCambiaria + CveCuenta = UsuarioActual.Empresa.CveCuentaGananciaCambiaria + End If + Dim ImporteFluctuacion As Decimal = Math.Abs((Importe251 * difFluctuacion).RoundSQL) * ValorMultiplicador + + If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovtoFluctua, ImporteFluctuacion, Referencia, CveConceptoFluctua, Concepto, FechaMovimiento, IdCtaContableFluctua, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveVentaAmortizacion:=Dr("CveVenta").ToString.ToEntero, ImporteMX:=ImporteFluctuacion, ImporteME:=ImporteFluctuacion, CveSubProyecto:=CveSubProyectoContabilizar, TipoCambio:=TipoCambioNC, TipoCambioPago:=Dr("TCCambioValuacion").ToString.ToDecimal, CveCuenta:=CveCuenta) Then + ErrorPrepoliza = True + Exit For + End If + End If + + Next + + If ImporteConcepto12 < ImporteAcumulado91 Then + Dim ImporteOtrosIngresos As Decimal = ImporteConcepto12 - ImporteAcumulado91 + If ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, False, ImporteOtrosIngresos, Referencia, 91, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveVentaAmortizacion:=CveUltimaVenta, ImporteMX:=ImporteOtrosIngresos, ImporteME:=0, CveSubProyecto:=CveSubProyectoContabilizar, TipoCambio:=tipoCambio) Then + If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, True, ImporteOtrosIngresos, Referencia, 211, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, ImporteME:=0, ImporteMX:=ImporteOtrosIngresos, CveSubProyecto:=CveSubProyectoContabilizar) Then + ErrorPrepoliza = True + End If + Else + ErrorPrepoliza = True + End If + End If + + If ObjConta.ValidacionPrePolizaCuadre(ObjFactura.CvePrePoliza, 5) Then + If ObjConta.ValorPolizaDescuadre > 0 Then + ErrorPrepoliza = True + GuardaLogAD($"Ventas/Ventas-ProcesoPrePolizas | Error:{ObjConta.MensajePolizaDescuadre} Diferencia:{ObjConta.ValorDiferencia} | CvePrePoliza:{ObjFactura.CvePrePoliza}", "LogPrePolizas") + + 'SIRVE PARA VER LA PREPOLIZA QUE SE VALIDA + 'If ObjConta.GetPrePolizasDetalle(ObjFactura.CvePrePoliza) Then + ' Dim DtTest = ObjConta.DtResultados + 'End If + End If + End If + + + If ErrorPrepoliza Then + Exit For + End If + End If + + 'APLICA DEVOLUCION SALDOS DIRECTOS + If ObjFactura.AplicaDevolucion Then + Dim TipoCambioFactura = ObjFactura.TipoCambio + Dim importeMovimientoDev = ObjFactura.Total importeMovimientoDev = If(ObjFactura.SaldoVentaDevolucion < importeMovimientoDev, ObjFactura.SaldoVentaDevolucion, importeMovimientoDev) If importeMovimientoDev > 0 Then Dim importeMXDev = importeMovimientoDev * tipoCambio * Multiplicador @@ -2430,48 +2430,48 @@ Namespace Modelos End If End If - End If - End If - End If - - End If - - Case 136 'Otros Conceptos Dinamicos - If ObjFactura.DtOtrosConceptos IsNot Nothing Then - For Each row2 As DataRow In ObjFactura.DtOtrosConceptos.Rows - If row2("Importe").ToString().ToDecimal > 0 Then - - importeMovimiento = (row2("Importe").ToString().ToDecimal * ValorMultiplicador) - CveSubProyectoContabilizar = CveSubProyectoVenta - If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}" - - If row2("IdCtaContable").ToString().ToEntero > 0 Then - IdCtaContable = row2("IdCtaContable").ToString().ToEntero - Else - If ObjConta.GetRetCuenta(row2("CveConceptoContable").ToString().ToEntero, ObjFactura.CveCliente) Then - If ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCtaContFondoGarantia").ToString.ToEntero - End If - End If - End If - - If importeMovimiento <> 0 Then - If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, If(row2("TipoMovto").ToString = "True", True, False), importeMovimiento, Referencia, row2("CveConceptoContable").ToString().ToEntero, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, ImporteMX:=importeMovimiento * tipoCambio, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveSubProyecto:=CveSubProyectoContabilizar) Then - ErrorPrepoliza = True - End If - End If - - End If - Next - End If - - importeMovimiento = 0 - - Case 11 'Anticipo - - '[IPP] SI ES REFACTURACION LOS ANTICIPOS NO LOS DEBE APLICAR EN EL INGRESO REFACTURADO (VIEJO) - If NuevaFactura = 1 And ObjFactura.CveVenta = CveDevolucion Then - Exit Select + End If + End If + End If + + End If + + Case 136 'Otros Conceptos Dinamicos + If ObjFactura.DtOtrosConceptos IsNot Nothing Then + For Each row2 As DataRow In ObjFactura.DtOtrosConceptos.Rows + If row2("Importe").ToString().ToDecimal > 0 Then + + importeMovimiento = (row2("Importe").ToString().ToDecimal * ValorMultiplicador) + CveSubProyectoContabilizar = CveSubProyectoVenta + If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}" + + If row2("IdCtaContable").ToString().ToEntero > 0 Then + IdCtaContable = row2("IdCtaContable").ToString().ToEntero + Else + If ObjConta.GetRetCuenta(row2("CveConceptoContable").ToString().ToEntero, ObjFactura.CveCliente) Then + If ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCtaContFondoGarantia").ToString.ToEntero + End If + End If + End If + + If importeMovimiento <> 0 Then + If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, If(row2("TipoMovto").ToString = "True", True, False), importeMovimiento, Referencia, row2("CveConceptoContable").ToString().ToEntero, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, ImporteMX:=importeMovimiento * tipoCambio, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveSubProyecto:=CveSubProyectoContabilizar) Then + ErrorPrepoliza = True + End If + End If + + End If + Next + End If + + importeMovimiento = 0 + + Case 11 'Anticipo + + '[IPP] SI ES REFACTURACION LOS ANTICIPOS NO LOS DEBE APLICAR EN EL INGRESO REFACTURADO (VIEJO) + If NuevaFactura = 1 And ObjFactura.CveVenta = CveDevolucion Then + Exit Select End If If ObjFactura.TipoDocto.Contiene("Ing", "Egs", "Ant") AndAlso ValorMultiplicador = -1 Then @@ -2513,8 +2513,8 @@ Namespace Modelos End If Next - End If - + End If + If ValorMultiplicador = 1 Then 'cuando es anticipo ' cuando es amortización de nota de crédito, y es la nc @@ -2547,60 +2547,60 @@ Namespace Modelos End If Next End If - End If - - 'Cuando la funcionalidad de amortizacion en PS esta activa - If Not ErrorPrepoliza Then - DT = TmpDTDetalle.FiltraParametros($"CvePS = {ObjFactura.CvePSAmortizacion}") - If DT.Rows.Count > 0 Then - For Each Row2 As DataRow In DT.Rows - importeMovimiento = Math.Abs(Row2("PU").ToString.ToDecimal) - IdCtaContable = ObjFactura.Cliente.IdCtaContAnticipos - CveCuenta = ObjFactura.Cliente.CveCuentaAnticipos - CveSubProyectoContabilizar = CveSubProyectoVenta - If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}" - - If importeMovimiento <> 0 Then - If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, - ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, - CveVenta:=ObjFactura.CveVenta, CveVentaAmortizacion:=ObjFactura.CveVenta, - CveCliente:=ObjFactura.CveCliente, ImporteMX:=importeMovimiento * tipoCambio, - ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, - CveSubProyecto:=CveSubProyectoContabilizar) Then - ErrorPrepoliza = True - Else - ObjFactura.SeGuardoPrePoliza = True - End If - End If - Next - End If - End If - - 'PorcentajeAmortizacion = sumaAmorticaciones / TxtTotal.Text.ToDecimal - importeMovimiento = 0 - - Case 91 'Amortizacion Nota de Credito - Dim Contabilizable = If(UsuarioActual.CveEmpresa = 119, False, True) - - If ValorMultiplicador = -1 Then - 'cuando es cancelación - If ObjFactura.DtNCVinculadas IsNot Nothing Then - For Each row2 As DataRow In ObjFactura.DtNCVinculadas.Rows - - If row2("CveConceptoContable").ToString().ToEntero = 91 Then - - importeMovimiento = (row2("Importe").ToString().ToDecimal * ValorMultiplicador) - sumaAmorticaciones += importeMovimiento - If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}" - - 'CTACONTABLE - 'IdCtaContable = IdCtaContAnticipos - 'CveCuenta = CveCuentaAnticipos - IdCtaContable = ObjFactura.Cliente.IdCtaContClientes - CveCuenta = ObjFactura.Cliente.CveCuentaClientes - - CveSubProyectoContabilizar = CveSubProyectoVenta - + End If + + 'Cuando la funcionalidad de amortizacion en PS esta activa + If Not ErrorPrepoliza Then + DT = TmpDTDetalle.FiltraParametros($"CvePS = {ObjFactura.CvePSAmortizacion}") + If DT.Rows.Count > 0 Then + For Each Row2 As DataRow In DT.Rows + importeMovimiento = Math.Abs(Row2("PU").ToString.ToDecimal) + IdCtaContable = ObjFactura.Cliente.IdCtaContAnticipos + CveCuenta = ObjFactura.Cliente.CveCuentaAnticipos + CveSubProyectoContabilizar = CveSubProyectoVenta + If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}" + + If importeMovimiento <> 0 Then + If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, + ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, + CveVenta:=ObjFactura.CveVenta, CveVentaAmortizacion:=ObjFactura.CveVenta, + CveCliente:=ObjFactura.CveCliente, ImporteMX:=importeMovimiento * tipoCambio, + ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, + CveSubProyecto:=CveSubProyectoContabilizar) Then + ErrorPrepoliza = True + Else + ObjFactura.SeGuardoPrePoliza = True + End If + End If + Next + End If + End If + + 'PorcentajeAmortizacion = sumaAmorticaciones / TxtTotal.Text.ToDecimal + importeMovimiento = 0 + + Case 91 'Amortizacion Nota de Credito + Dim Contabilizable = If(UsuarioActual.CveEmpresa = 119, False, True) + + If ValorMultiplicador = -1 Then + 'cuando es cancelación + If ObjFactura.DtNCVinculadas IsNot Nothing Then + For Each row2 As DataRow In ObjFactura.DtNCVinculadas.Rows + + If row2("CveConceptoContable").ToString().ToEntero = 91 Then + + importeMovimiento = (row2("Importe").ToString().ToDecimal * ValorMultiplicador) + sumaAmorticaciones += importeMovimiento + If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}" + + 'CTACONTABLE + 'IdCtaContable = IdCtaContAnticipos + 'CveCuenta = CveCuentaAnticipos + IdCtaContable = ObjFactura.Cliente.IdCtaContClientes + CveCuenta = ObjFactura.Cliente.CveCuentaClientes + + CveSubProyectoContabilizar = CveSubProyectoVenta + If importeMovimiento <> 0 Then Dim Importe91 As Decimal = 0 @@ -2707,270 +2707,270 @@ Namespace Modelos ErrorPrepoliza = True Exit For End If - End If - - End If - End If - Next - End If - Else - If ObjFactura.DtAnticipos IsNot Nothing Then - For Each row2 As DataRow In ObjFactura.DtAnticipos.Rows - - If row2("CveConceptoContable").ToString().ToEntero = 12 Then - importeMovimiento = row2("Importe").ToString().ToDecimal() - sumaAmorticaciones += importeMovimiento - If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}" - IdCtaContable = ObjFactura.Cliente.IdCtaContAnticipos - CveCuenta = ObjFactura.Cliente.CveCuentaAnticipos - CveSubProyectoContabilizar = CveSubProyectoVenta - - If importeMovimiento <> 0 Then - - If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, - ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, - CveVenta:=row2("CveVenta").ToString.ToEntero, CveCliente:=ObjFactura.CveCliente, - CveVentaAmortizacion:=ObjFactura.CveVenta, ImporteMX:=importeMovimiento * tipoCambio, - ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, - CveSubProyecto:=CveSubProyectoContabilizar, Contabilizable:=Contabilizable) Then - ErrorPrepoliza = True - End If - End If - - End If - - Next - End If - If sumaAmorticaciones <> 0 Then - If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, True, sumaAmorticaciones, Referencia, 251, Concepto, FechaMovimiento, - ObjFactura.Cliente.IdCtaContClientes, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, ImporteMX:=sumaAmorticaciones * tipoCambio, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=CveCuentaCliente, CveSubProyecto:=CveSubProyectoContabilizar, Contabilizable:=Contabilizable) Then - ErrorPrepoliza = True - Else - ObjFactura.SeGuardoPrePoliza = True - End If - End If - - End If - importeMovimiento = 0 - - Case 4 'Venta Clasificacion - If Not ObjFactura.TipoDocto.Contiene("Rem", "Ant", "Egs", "Dev", "RNC") Then - - Dim ConceptoContableAplicar = 4 - Dim CveVentaAplicar = ObjFactura.CveVenta - Dim CveVentaAmortizacionAplicar = -1 - - If ObjFactura.TipoDocto.Contiene("Egs") And ObjFactura.TipoDocto = "Ant" And CveDevolucion > 0 And NuevaFactura = 1 Then - ConceptoContableAplicar = 11 - CveVentaAplicar = CveDevolucion - CveVentaAmortizacionAplicar = ObjFactura.CveVenta - End If - - 'código fijo en base el porcentaje iva, que se afecten las clasificaciones - For i = 0 To TmpDTDetalle.Rows.Count - 1 - - 'se excluyen las clasificaciones anteriores para que se asignen las de ingreso - If Not TmpDTDetalle(i)("CveClasificacion").ToString.Contiene("19958", "19933") Then - - 'reclasifica la clasificación del producto, por la del ingreso correspondiente a su iva - If ObjFactura.GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=TmpDTDetalle(i)("PorcentajeIVA").ToString.ToDecimal).Rows.Count > 0 Then - TmpDTDetalle(i)("CveClasificacion") = ObjFactura.GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=TmpDTDetalle(i)("PorcentajeIVA").ToString.ToDecimal).Rows(0)("CveClasificacion").ToString - End If - - End If - - Next - - DT = TmpDTDetalle.FiltraParametros($"CvePS <> {ObjFactura.CvePSAmortizacion}", "", {"CveClasificacion", "CveSubProyecto"}) - - If DT.Rows.Count > 0 Then - 'Se agrega movimiento separado por la cuenta de ventas (ER) - For Each Row2 As DataRow In DT.Rows - importeMovimiento = ((TmpDTDetalle.SUM("TotalImporte", String.Format("CveClasificacion = {0} And CveSubProyecto = {1}", Row2("CveClasificacion"), Row2("CveSubProyecto"))).ToString.ToDecimal) * ValorMultiplicador) - importeMX = importeMovimiento * tipoCambio * Multiplicador - FechaMovimiento = ObjFactura.FechaPago - Concepto = $"{ObjFactura.SerieFolio} {If(Row2("CveClasificacion").ToString.ToEntero > 0, GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Clasificacion", $"CveClasificacion = {Row2("CveClasificacion").ToString}"), "")} - {If(Row2("CveSubProyecto").ToString.ToEntero > 0, GlobalDTSubProyectos(-1, -1, UsuarioActual.CveEmpresa).FiltroPrimeroValor("SubProyecto", $"CveSubProyecto = {Row2("CveSubProyecto").ToString}"), "Sin SubProyecto Asignado")}" - - If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}" - 'Nota cuando es Nota de crédiot, debe de tomar el devoluciones y rebajas - If ObjFactura.TipoDocto.Contiene("Egs") Then - IdCtaContable = GlobalDTClasificaciones(ObjFactura.CveEmpresa).FiltroPrimeroValor("IdCuentaGasto", String.Format("CveClasificacion = {0}", Row2("CveClasificacion"))).ToEntero - Else - IdCtaContable = GlobalDTClasificaciones(ObjFactura.CveEmpresa).FiltroPrimeroValor("IdCuentaIngresos", String.Format("CveClasificacion = {0}", Row2("CveClasificacion"))).ToEntero - End If - - - CveCuenta = GlobalDTClasificaciones(ObjFactura.CveEmpresa).FiltroPrimeroValor("IdCuentaIngresosSIG", String.Format("CveClasificacion = {0}", Row2("CveClasificacion"))).ToEntero - - If importeMovimiento <> 0 Then - - If IdCtaContable <= 0 Then - CuentasContablesInvalidas.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString + GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Clasificacion", $"CveClasificacion = {Row2("CveClasificacion").ToString}")) - idCuentaContabilizacion = 0 - End If - - If CveCuenta <= 0 Then - CuentasContablesInvalidasSIG.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString + GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Clasificacion", $"CveClasificacion = {Row2("CveClasificacion").ToString}")) - CveCuentaContabilizacion = 0 - End If - - If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, ConceptoContableAplicar, Concepto, ObjFactura.Fecha, IdCtaContable, -1, CveVenta:=CveVentaAplicar, CveVentaAmortizacion:=CveVentaAmortizacionAplicar, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, CveClasificacion:=Row2("CveClasificacion").ToString.ToEntero, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero, ImporteMX:=importeMX, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), TipoCambio:=tipoCambio, CveCuenta:=CveCuenta) Then - ErrorPrepoliza = True - Else - ObjFactura.SeGuardoPrePoliza = True - End If - End If - Next - End If - End If - - importeMovimiento = 0 - Case 150 'Descuento sobre ventas - If ObjFactura.TipoDocto.Contiene("Egs", "Dev") AndAlso Not EsNCAmortizacion Then - - Dim ConceptoContableAplicar = 150 - Dim CveVentaAplicar = ObjFactura.CveVenta - Dim CveVentaAmortizacionAplicar = -1 - - If ObjFactura.TipoDocto.Contiene("Egs") And ObjFactura.CveAnticipo > 0 Then - ConceptoContableAplicar = 11 - CveVentaAplicar = ObjFactura.CveAnticipo - CveVentaAmortizacionAplicar = ObjFactura.CveVenta - End If - - If UsuarioActual.CveEmpresa = 119 Then - - 'código fijo en base el porcentaje iva, que se afecten las clasificaciones - For i = 0 To TmpDTDetalle.Rows.Count - 1 - - 'se excluyen las clasificaciones anteriores para que se asignen las de ingreso - If Not TmpDTDetalle(i)("CveClasificacion").ToString.Contiene("19958", "19933", "20242") Then - - If GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=TmpDTDetalle.MAX("PorcentajeIVA").ToDouble).Rows.Count > 0 Then - TmpDTDetalle(i)("CveClasificacion") = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=TmpDTDetalle.MAX("PorcentajeIVA").ToDouble).Rows(0)("CveClasificacion").ToString - End If - - End If - - Next - - End If - - DT = TmpDTDetalle.FiltraParametros($"CvePS <> {ObjFactura.CvePSAmortizacion}", "", {"CveClasificacion", "CveSubProyecto"}) - - If DT.Rows.Count > 0 Then - 'Se agrega movimiento separado por la cuenta de ventas (ER) - For Each Row2 As DataRow In DT.Rows - importeMovimiento = ((TmpDTDetalle.SUM("TotalImporte", String.Format("CveClasificacion = {0} And CveSubProyecto = {1}", Row2("CveClasificacion"), Row2("CveSubProyecto"))).ToString.ToDecimal) * ValorMultiplicador) - importeMX = importeMovimiento * tipoCambio * Multiplicador - FechaMovimiento = ObjFactura.FechaPago - Concepto = $"{ObjFactura.SerieFolio} {If(Row2("CveClasificacion").ToString.ToEntero > 0, GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Clasificacion", $"CveClasificacion = {Row2("CveClasificacion").ToString}"), "")} - {If(Row2("CveSubProyecto").ToString.ToEntero > 0, GlobalDTSubProyectos(-1, -1, UsuarioActual.CveEmpresa).FiltroPrimeroValor("SubProyecto", $"CveSubProyecto = {Row2("CveSubProyecto").ToString}"), "Sin SubProyecto Asignado")}" - - If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}" - 'Nota cuando es Nota de crédiot, debe de tomar el devoluciones y rebajas - If ObjFactura.TipoDocto.Contiene("Egs", "Dev") Then - IdCtaContable = GlobalDTClasificaciones(ObjFactura.CveEmpresa).FiltroPrimeroValor("IdCuentaGasto", String.Format("CveClasificacion = {0}", Row2("CveClasificacion"))).ToEntero - Else - IdCtaContable = GlobalDTClasificaciones(ObjFactura.CveEmpresa).FiltroPrimeroValor("IdCuentaIngresos", String.Format("CveClasificacion = {0}", Row2("CveClasificacion"))).ToEntero - End If - - If UsuarioActual.CveEmpresa = 119 Then - If Row2("CveClasificacion").ToString = "19930" Then IdCtaContable = 1141 - If Row2("CveClasificacion").ToString = "19929" Then IdCtaContable = 1142 - End If - - CveCuenta = GlobalDTClasificaciones(ObjFactura.CveEmpresa).FiltroPrimeroValor("IdCuentaIngresosSIG", String.Format("CveClasificacion = {0}", Row2("CveClasificacion"))).ToEntero - - If importeMovimiento <> 0 Then - - If IdCtaContable <= 0 Then - CuentasContablesInvalidas.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString + GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Clasificacion", $"CveClasificacion = {Row2("CveClasificacion").ToString}")) - idCuentaContabilizacion = 0 - End If - - If CveCuenta <= 0 Then - CuentasContablesInvalidasSIG.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString + GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Clasificacion", $"CveClasificacion = {Row2("CveClasificacion").ToString}")) - CveCuentaContabilizacion = 0 - End If - - If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, ConceptoContableAplicar, Concepto, ObjFactura.Fecha, IdCtaContable, -1, CveVenta:=CveVentaAplicar, CveVentaAmortizacion:=CveVentaAmortizacionAplicar, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, CveClasificacion:=Row2("CveClasificacion").ToString.ToEntero, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero, ImporteMX:=importeMX, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), TipoCambio:=tipoCambio, CveCuenta:=CveCuenta) Then - ErrorPrepoliza = True - Else - ObjFactura.SeGuardoPrePoliza = True - End If - End If - Next - End If - End If - - importeMovimiento = 0 - Case 103 'Descuento - If Not ObjFactura.TipoDocto.Contiene("Rem", "RNC") AndAlso ObjFactura.CveTipoAmortizacionAnticipo = -1 Then - - importeMovimiento = (ObjFactura.Descuento * ValorMultiplicador) - importeMX = Math.Round(importeMovimiento, 2) * tipoCambio * Multiplicador - FechaMovimiento = ObjFactura.FechaPago - CveSubProyectoContabilizar = CveSubProyectoVenta - - If importeMovimiento <> 0 AndAlso ObjConta.GetRetCuenta(ConceptoContable, ObjFactura.CveEmpresa) Then - If ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("Conta_IdCuentaDescuentoVenta").ToString.ToEntero - 'CveCuenta = ObjConta.DtResultados.Rows(0)("Conta_IdCuentaDescuentoVenta").ToString.ToEntero - End If - End If - If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}" - If importeMovimiento > 0 AndAlso UsuarioActual.CveEmpresa = 119 Then - 'código fijo en base el porcentaje iva, que se afecten las clasificaciones - For i = 0 To TmpDTDetalle.Rows.Count - 1 - - If GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=TmpDTDetalle.MAX("PorcentajeIVA").ToDouble).Rows.Count > 0 Then - TmpDTDetalle(i)("CveClasificacion") = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=TmpDTDetalle.MAX("PorcentajeIVA").ToDouble).Rows(0)("CveClasificacion").ToString - End If - Next - - End If - - End If - - Case 103 'Descuento - 'si se amortiza anticipo por concepto de descuento, no debe de registrar esta partida. - If ObjFactura.CveTipoAmortizacionAnticipo <> 1 Then - importeMovimiento = (ObjFactura.Descuento * ValorMultiplicador) - importeMX = Math.Round(importeMovimiento, 2) * tipoCambio * Multiplicador - FechaMovimiento = ObjFactura.FechaPago - If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}" - IdCtaContable = 0 - End If - - Case 8 'Ret IVA por Trasladar + End If + + End If + End If + Next + End If + Else + If ObjFactura.DtAnticipos IsNot Nothing Then + For Each row2 As DataRow In ObjFactura.DtAnticipos.Rows + + If row2("CveConceptoContable").ToString().ToEntero = 12 Then + importeMovimiento = row2("Importe").ToString().ToDecimal() + sumaAmorticaciones += importeMovimiento + If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}" + IdCtaContable = ObjFactura.Cliente.IdCtaContAnticipos + CveCuenta = ObjFactura.Cliente.CveCuentaAnticipos + CveSubProyectoContabilizar = CveSubProyectoVenta + + If importeMovimiento <> 0 Then + + If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, + ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, + CveVenta:=row2("CveVenta").ToString.ToEntero, CveCliente:=ObjFactura.CveCliente, + CveVentaAmortizacion:=ObjFactura.CveVenta, ImporteMX:=importeMovimiento * tipoCambio, + ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, + CveSubProyecto:=CveSubProyectoContabilizar, Contabilizable:=Contabilizable) Then + ErrorPrepoliza = True + End If + End If + + End If + + Next + End If + If sumaAmorticaciones <> 0 Then + If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, True, sumaAmorticaciones, Referencia, 251, Concepto, FechaMovimiento, + ObjFactura.Cliente.IdCtaContClientes, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, ImporteMX:=sumaAmorticaciones * tipoCambio, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=CveCuentaCliente, CveSubProyecto:=CveSubProyectoContabilizar, Contabilizable:=Contabilizable) Then + ErrorPrepoliza = True + Else + ObjFactura.SeGuardoPrePoliza = True + End If + End If + + End If + importeMovimiento = 0 + + Case 4 'Venta Clasificacion + If Not ObjFactura.TipoDocto.Contiene("Rem", "Ant", "Egs", "Dev", "RNC") Then + + Dim ConceptoContableAplicar = 4 + Dim CveVentaAplicar = ObjFactura.CveVenta + Dim CveVentaAmortizacionAplicar = -1 + + If ObjFactura.TipoDocto.Contiene("Egs") And ObjFactura.TipoDocto = "Ant" And CveDevolucion > 0 And NuevaFactura = 1 Then + ConceptoContableAplicar = 11 + CveVentaAplicar = CveDevolucion + CveVentaAmortizacionAplicar = ObjFactura.CveVenta + End If + + 'código fijo en base el porcentaje iva, que se afecten las clasificaciones + For i = 0 To TmpDTDetalle.Rows.Count - 1 + + 'se excluyen las clasificaciones anteriores para que se asignen las de ingreso + If Not TmpDTDetalle(i)("CveClasificacion").ToString.Contiene("19958", "19933") Then + + 'reclasifica la clasificación del producto, por la del ingreso correspondiente a su iva + If ObjFactura.GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=TmpDTDetalle(i)("PorcentajeIVA").ToString.ToDecimal).Rows.Count > 0 Then + TmpDTDetalle(i)("CveClasificacion") = ObjFactura.GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=TmpDTDetalle(i)("PorcentajeIVA").ToString.ToDecimal).Rows(0)("CveClasificacion").ToString + End If + + End If + + Next + + DT = TmpDTDetalle.FiltraParametros($"CvePS <> {ObjFactura.CvePSAmortizacion}", "", {"CveClasificacion", "CveSubProyecto"}) + + If DT.Rows.Count > 0 Then + 'Se agrega movimiento separado por la cuenta de ventas (ER) + For Each Row2 As DataRow In DT.Rows + importeMovimiento = ((TmpDTDetalle.SUM("TotalImporte", String.Format("CveClasificacion = {0} And CveSubProyecto = {1}", Row2("CveClasificacion"), Row2("CveSubProyecto"))).ToString.ToDecimal) * ValorMultiplicador) + importeMX = importeMovimiento * tipoCambio * Multiplicador + FechaMovimiento = ObjFactura.FechaPago + Concepto = $"{ObjFactura.SerieFolio} {If(Row2("CveClasificacion").ToString.ToEntero > 0, GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Clasificacion", $"CveClasificacion = {Row2("CveClasificacion").ToString}"), "")} - {If(Row2("CveSubProyecto").ToString.ToEntero > 0, GlobalDTSubProyectos(-1, -1, UsuarioActual.CveEmpresa).FiltroPrimeroValor("SubProyecto", $"CveSubProyecto = {Row2("CveSubProyecto").ToString}"), "Sin SubProyecto Asignado")}" + + If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}" + 'Nota cuando es Nota de crédiot, debe de tomar el devoluciones y rebajas + If ObjFactura.TipoDocto.Contiene("Egs") Then + IdCtaContable = GlobalDTClasificaciones(ObjFactura.CveEmpresa).FiltroPrimeroValor("IdCuentaGasto", String.Format("CveClasificacion = {0}", Row2("CveClasificacion"))).ToEntero + Else + IdCtaContable = GlobalDTClasificaciones(ObjFactura.CveEmpresa).FiltroPrimeroValor("IdCuentaIngresos", String.Format("CveClasificacion = {0}", Row2("CveClasificacion"))).ToEntero + End If + + + CveCuenta = GlobalDTClasificaciones(ObjFactura.CveEmpresa).FiltroPrimeroValor("IdCuentaIngresosSIG", String.Format("CveClasificacion = {0}", Row2("CveClasificacion"))).ToEntero + + If importeMovimiento <> 0 Then + + If IdCtaContable <= 0 Then + CuentasContablesInvalidas.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString + GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Clasificacion", $"CveClasificacion = {Row2("CveClasificacion").ToString}")) + idCuentaContabilizacion = 0 + End If + + If CveCuenta <= 0 Then + CuentasContablesInvalidasSIG.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString + GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Clasificacion", $"CveClasificacion = {Row2("CveClasificacion").ToString}")) + CveCuentaContabilizacion = 0 + End If + + If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, ConceptoContableAplicar, Concepto, ObjFactura.Fecha, IdCtaContable, -1, CveVenta:=CveVentaAplicar, CveVentaAmortizacion:=CveVentaAmortizacionAplicar, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, CveClasificacion:=Row2("CveClasificacion").ToString.ToEntero, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero, ImporteMX:=importeMX, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), TipoCambio:=tipoCambio, CveCuenta:=CveCuenta) Then + ErrorPrepoliza = True + Else + ObjFactura.SeGuardoPrePoliza = True + End If + End If + Next + End If + End If + + importeMovimiento = 0 + Case 150 'Descuento sobre ventas + If ObjFactura.TipoDocto.Contiene("Egs", "Dev") AndAlso Not EsNCAmortizacion Then + + Dim ConceptoContableAplicar = 150 + Dim CveVentaAplicar = ObjFactura.CveVenta + Dim CveVentaAmortizacionAplicar = -1 + + If ObjFactura.TipoDocto.Contiene("Egs") And ObjFactura.CveAnticipo > 0 Then + ConceptoContableAplicar = 11 + CveVentaAplicar = ObjFactura.CveAnticipo + CveVentaAmortizacionAplicar = ObjFactura.CveVenta + End If + + If UsuarioActual.CveEmpresa = 119 Then + + 'código fijo en base el porcentaje iva, que se afecten las clasificaciones + For i = 0 To TmpDTDetalle.Rows.Count - 1 + + 'se excluyen las clasificaciones anteriores para que se asignen las de ingreso + If Not TmpDTDetalle(i)("CveClasificacion").ToString.Contiene("19958", "19933", "20242") Then + + If GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=TmpDTDetalle.MAX("PorcentajeIVA").ToDouble).Rows.Count > 0 Then + TmpDTDetalle(i)("CveClasificacion") = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=TmpDTDetalle.MAX("PorcentajeIVA").ToDouble).Rows(0)("CveClasificacion").ToString + End If + + End If + + Next + + End If + + DT = TmpDTDetalle.FiltraParametros($"CvePS <> {ObjFactura.CvePSAmortizacion}", "", {"CveClasificacion", "CveSubProyecto"}) + + If DT.Rows.Count > 0 Then + 'Se agrega movimiento separado por la cuenta de ventas (ER) + For Each Row2 As DataRow In DT.Rows + importeMovimiento = ((TmpDTDetalle.SUM("TotalImporte", String.Format("CveClasificacion = {0} And CveSubProyecto = {1}", Row2("CveClasificacion"), Row2("CveSubProyecto"))).ToString.ToDecimal) * ValorMultiplicador) + importeMX = importeMovimiento * tipoCambio * Multiplicador + FechaMovimiento = ObjFactura.FechaPago + Concepto = $"{ObjFactura.SerieFolio} {If(Row2("CveClasificacion").ToString.ToEntero > 0, GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Clasificacion", $"CveClasificacion = {Row2("CveClasificacion").ToString}"), "")} - {If(Row2("CveSubProyecto").ToString.ToEntero > 0, GlobalDTSubProyectos(-1, -1, UsuarioActual.CveEmpresa).FiltroPrimeroValor("SubProyecto", $"CveSubProyecto = {Row2("CveSubProyecto").ToString}"), "Sin SubProyecto Asignado")}" + + If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}" + 'Nota cuando es Nota de crédiot, debe de tomar el devoluciones y rebajas + If ObjFactura.TipoDocto.Contiene("Egs", "Dev") Then + IdCtaContable = GlobalDTClasificaciones(ObjFactura.CveEmpresa).FiltroPrimeroValor("IdCuentaGasto", String.Format("CveClasificacion = {0}", Row2("CveClasificacion"))).ToEntero + Else + IdCtaContable = GlobalDTClasificaciones(ObjFactura.CveEmpresa).FiltroPrimeroValor("IdCuentaIngresos", String.Format("CveClasificacion = {0}", Row2("CveClasificacion"))).ToEntero + End If + + If UsuarioActual.CveEmpresa = 119 Then + If Row2("CveClasificacion").ToString = "19930" Then IdCtaContable = 1141 + If Row2("CveClasificacion").ToString = "19929" Then IdCtaContable = 1142 + End If + + CveCuenta = GlobalDTClasificaciones(ObjFactura.CveEmpresa).FiltroPrimeroValor("IdCuentaIngresosSIG", String.Format("CveClasificacion = {0}", Row2("CveClasificacion"))).ToEntero + + If importeMovimiento <> 0 Then + + If IdCtaContable <= 0 Then + CuentasContablesInvalidas.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString + GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Clasificacion", $"CveClasificacion = {Row2("CveClasificacion").ToString}")) + idCuentaContabilizacion = 0 + End If + + If CveCuenta <= 0 Then + CuentasContablesInvalidasSIG.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString + GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Clasificacion", $"CveClasificacion = {Row2("CveClasificacion").ToString}")) + CveCuentaContabilizacion = 0 + End If + + If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, ConceptoContableAplicar, Concepto, ObjFactura.Fecha, IdCtaContable, -1, CveVenta:=CveVentaAplicar, CveVentaAmortizacion:=CveVentaAmortizacionAplicar, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, CveClasificacion:=Row2("CveClasificacion").ToString.ToEntero, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero, ImporteMX:=importeMX, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), TipoCambio:=tipoCambio, CveCuenta:=CveCuenta) Then + ErrorPrepoliza = True + Else + ObjFactura.SeGuardoPrePoliza = True + End If + End If + Next + End If + End If + + importeMovimiento = 0 + Case 103 'Descuento + If Not ObjFactura.TipoDocto.Contiene("Rem", "RNC") AndAlso ObjFactura.CveTipoAmortizacionAnticipo = -1 Then + + importeMovimiento = (ObjFactura.Descuento * ValorMultiplicador) + importeMX = Math.Round(importeMovimiento, 2) * tipoCambio * Multiplicador + FechaMovimiento = ObjFactura.FechaPago + CveSubProyectoContabilizar = CveSubProyectoVenta + + If importeMovimiento <> 0 AndAlso ObjConta.GetRetCuenta(ConceptoContable, ObjFactura.CveEmpresa) Then + If ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("Conta_IdCuentaDescuentoVenta").ToString.ToEntero + 'CveCuenta = ObjConta.DtResultados.Rows(0)("Conta_IdCuentaDescuentoVenta").ToString.ToEntero + End If + End If + If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}" + If importeMovimiento > 0 AndAlso UsuarioActual.CveEmpresa = 119 Then + 'código fijo en base el porcentaje iva, que se afecten las clasificaciones + For i = 0 To TmpDTDetalle.Rows.Count - 1 + + If GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=TmpDTDetalle.MAX("PorcentajeIVA").ToDouble).Rows.Count > 0 Then + TmpDTDetalle(i)("CveClasificacion") = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=TmpDTDetalle.MAX("PorcentajeIVA").ToDouble).Rows(0)("CveClasificacion").ToString + End If + Next + + End If + + End If + + Case 103 'Descuento + 'si se amortiza anticipo por concepto de descuento, no debe de registrar esta partida. + If ObjFactura.CveTipoAmortizacionAnticipo <> 1 Then + importeMovimiento = (ObjFactura.Descuento * ValorMultiplicador) + importeMX = Math.Round(importeMovimiento, 2) * tipoCambio * Multiplicador + FechaMovimiento = ObjFactura.FechaPago + If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}" + IdCtaContable = 0 + End If + + Case 8 'Ret IVA por Trasladar If Not ObjFactura.TipoDocto.Contiene("Rem", "RNC") AndAlso ObjFactura.CveTipoRetencion <> 4 Then 'SI NO ES RETENCION DE IVA DE SERVICIOS - importeMovimiento = (ObjFactura.RetIVA * ValorMultiplicador) - importeMX = Math.Round(importeMovimiento, 2) * tipoCambio * Multiplicador - FechaMovimiento = ObjFactura.FechaPago - CveSubProyectoContabilizar = CveSubProyectoVenta - If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}" - - 'Contabilidad ContPAQ - If ObjFactura.Cliente.IdCtaContRetIVA > 0 Then - IdCtaContable = ObjFactura.Cliente.IdCtaContRetIVA - Else - If ObjConta.GetRetCuenta(ConceptoContable, ObjFactura.CveEmpresa) Then - If ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero - End If - End If - End If - - 'Contabilidad SIG - If ObjFactura.Cliente.CveCuentaRetIVA > 0 Then - CveCuenta = ObjFactura.Cliente.CveCuentaRetIVA - Else - If importeMovimiento <> 0 AndAlso ObjConta.GetRetCuenta(ConceptoContable, ObjFactura.CveEmpresa) Then - If ObjConta.DtResultados.Rows.Count > 0 Then - CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero - End If - End If - End If + importeMovimiento = (ObjFactura.RetIVA * ValorMultiplicador) + importeMX = Math.Round(importeMovimiento, 2) * tipoCambio * Multiplicador + FechaMovimiento = ObjFactura.FechaPago + CveSubProyectoContabilizar = CveSubProyectoVenta + If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}" + + 'Contabilidad ContPAQ + If ObjFactura.Cliente.IdCtaContRetIVA > 0 Then + IdCtaContable = ObjFactura.Cliente.IdCtaContRetIVA + Else + If ObjConta.GetRetCuenta(ConceptoContable, ObjFactura.CveEmpresa) Then + If ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero + End If + End If + End If + + 'Contabilidad SIG + If ObjFactura.Cliente.CveCuentaRetIVA > 0 Then + CveCuenta = ObjFactura.Cliente.CveCuentaRetIVA + Else + If importeMovimiento <> 0 AndAlso ObjConta.GetRetCuenta(ConceptoContable, ObjFactura.CveEmpresa) Then + If ObjConta.DtResultados.Rows.Count > 0 Then + CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero + End If + End If + End If End If Case 313 'Ret Iva Servicios @@ -2989,67 +2989,67 @@ Namespace Modelos End If End If - End If - - Case 9 'Ret ISR por Trasladar - If Not ObjFactura.TipoDocto.Contiene("Rem", "RNC") Then - importeMovimiento = (ObjFactura.RetISR * ValorMultiplicador) - importeMX = importeMovimiento * tipoCambio * Multiplicador - FechaMovimiento = ObjFactura.FechaPago - CveSubProyectoContabilizar = CveSubProyectoVenta - If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}" - - 'Contabilidad ContPAQ - If ObjFactura.Cliente.IdCtaContRetISR > 0 Then - IdCtaContable = ObjFactura.Cliente.IdCtaContRetISR - Else - If importeMovimiento <> 0 AndAlso ObjConta.GetRetCuenta(ConceptoContable, ObjFactura.CveEmpresa) Then - If ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetISRCirculacion").ToString.ToEntero - End If - End If - End If - - 'Contabilidad SIG - If ObjFactura.Cliente.CveCuentaRetISR > 0 Then - CveCuenta = ObjFactura.Cliente.CveCuentaRetISR - Else - If ObjConta.GetRetCuenta(ConceptoContable, ObjFactura.CveEmpresa) Then - If ObjConta.DtResultados.Rows.Count > 0 Then - CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetISRCirculacionSIG").ToString.ToEntero - End If - End If - End If - End If - Case 13 'Iva por Trasladar - If Not ObjFactura.TipoDocto.Contiene("Rem", "RNC") Then - importeMovimiento = (ObjFactura.IVA * ValorMultiplicador) - importeMX = Math.Round(importeMovimiento * tipoCambio * Multiplicador, 2) - FechaMovimiento = ObjFactura.FechaPago - PorcentajeImpuesto = TmpDTDetalle.MAX("PorcentajeIVA").ToDecimal - IdCtaContable = If(IdCtaIVAXTrasladar > 0, IdCtaIVAXTrasladar, UsuarioActual.Empresa.IdCuentaIVAxTrasladar) - CveCuenta = UsuarioActual.Empresa.CveCuentaIVAxTrasladar - CveSubProyectoContabilizar = CveSubProyectoVenta - If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}" - End If - - - Case 38 'IEPS por Trasladar - If Not ObjFactura.TipoDocto.Contiene("Rem", "RNC") Then - importeMovimiento = (ObjFactura.IEPS * ValorMultiplicador) - importeMX = Math.Round(importeMovimiento * tipoCambio * Multiplicador, 2) - FechaMovimiento = ObjFactura.Fecha - CveSubProyectoContabilizar = CveSubProyectoVenta - If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}" - If importeMovimiento <> 0 AndAlso ObjConta.GetRetCuenta(ConceptoContable, ObjFactura.CveEmpresa) Then - If ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaIEPSxTrasladar").ToString.ToEntero - CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaIEPSxTrasladarSIG").ToString.ToEntero - End If - End If - End If - - + End If + + Case 9 'Ret ISR por Trasladar + If Not ObjFactura.TipoDocto.Contiene("Rem", "RNC") Then + importeMovimiento = (ObjFactura.RetISR * ValorMultiplicador) + importeMX = importeMovimiento * tipoCambio * Multiplicador + FechaMovimiento = ObjFactura.FechaPago + CveSubProyectoContabilizar = CveSubProyectoVenta + If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}" + + 'Contabilidad ContPAQ + If ObjFactura.Cliente.IdCtaContRetISR > 0 Then + IdCtaContable = ObjFactura.Cliente.IdCtaContRetISR + Else + If importeMovimiento <> 0 AndAlso ObjConta.GetRetCuenta(ConceptoContable, ObjFactura.CveEmpresa) Then + If ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetISRCirculacion").ToString.ToEntero + End If + End If + End If + + 'Contabilidad SIG + If ObjFactura.Cliente.CveCuentaRetISR > 0 Then + CveCuenta = ObjFactura.Cliente.CveCuentaRetISR + Else + If ObjConta.GetRetCuenta(ConceptoContable, ObjFactura.CveEmpresa) Then + If ObjConta.DtResultados.Rows.Count > 0 Then + CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetISRCirculacionSIG").ToString.ToEntero + End If + End If + End If + End If + Case 13 'Iva por Trasladar + If Not ObjFactura.TipoDocto.Contiene("Rem", "RNC") Then + importeMovimiento = (ObjFactura.IVA * ValorMultiplicador) + importeMX = Math.Round(importeMovimiento * tipoCambio * Multiplicador, 2) + FechaMovimiento = ObjFactura.FechaPago + PorcentajeImpuesto = TmpDTDetalle.MAX("PorcentajeIVA").ToDecimal + IdCtaContable = If(IdCtaIVAXTrasladar > 0, IdCtaIVAXTrasladar, UsuarioActual.Empresa.IdCuentaIVAxTrasladar) + CveCuenta = UsuarioActual.Empresa.CveCuentaIVAxTrasladar + CveSubProyectoContabilizar = CveSubProyectoVenta + If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}" + End If + + + Case 38 'IEPS por Trasladar + If Not ObjFactura.TipoDocto.Contiene("Rem", "RNC") Then + importeMovimiento = (ObjFactura.IEPS * ValorMultiplicador) + importeMX = Math.Round(importeMovimiento * tipoCambio * Multiplicador, 2) + FechaMovimiento = ObjFactura.Fecha + CveSubProyectoContabilizar = CveSubProyectoVenta + If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}" + If importeMovimiento <> 0 AndAlso ObjConta.GetRetCuenta(ConceptoContable, ObjFactura.CveEmpresa) Then + If ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaIEPSxTrasladar").ToString.ToEntero + CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaIEPSxTrasladarSIG").ToString.ToEntero + End If + End If + End If + + Case 30 'PAGO - BANCOS If ObjFactura.DtPagos IsNot Nothing AndAlso ObjFactura.DtPagos.Rows.Count > 0 Then @@ -3144,45 +3144,45 @@ Namespace Modelos Next importeMovimiento = 0 - End If - - End Select - - If importeMovimiento <> 0 And Not ErrorPrepoliza Then - - If IdCtaContable <= 0 Then - CuentasContablesInvalidas.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString) - idCuentaContabilizacion = 0 - End If - - If CveCuenta <= 0 Then - CuentasContablesInvalidasSIG.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString) - CveCuentaContabilizacion = 0 - End If - - If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, ImporteMX:=importeMX, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, CveSubProyecto:=CveSubProyectoContabilizar, PorcentajeImpuesto:=PorcentajeImpuesto, TipoCambio:=tipoCambio, Contabilizable:=SeContabiliza) Then - ErrorPrepoliza = True - Else - ObjFactura.SeGuardoPrePoliza = True - End If - - End If - - If ErrorPrepoliza Then - Exit For - End If - - Next - + End If + + End Select + + If importeMovimiento <> 0 And Not ErrorPrepoliza Then + + If IdCtaContable <= 0 Then + CuentasContablesInvalidas.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString) + idCuentaContabilizacion = 0 + End If + + If CveCuenta <= 0 Then + CuentasContablesInvalidasSIG.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString) + CveCuentaContabilizacion = 0 + End If + + If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, ImporteMX:=importeMX, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, CveSubProyecto:=CveSubProyectoContabilizar, PorcentajeImpuesto:=PorcentajeImpuesto, TipoCambio:=tipoCambio, Contabilizable:=SeContabiliza) Then + ErrorPrepoliza = True + Else + ObjFactura.SeGuardoPrePoliza = True + End If + + End If + + If ErrorPrepoliza Then + Exit For + End If + + Next + End If If ObjFactura.RemisionesLista.Count = 0 AndAlso (DtRemisionesRelacionadas IsNot Nothing AndAlso DtRemisionesRelacionadas.Rows.Count > 0) Then For Each Row As DataRow In DtRemisionesRelacionadas.Rows ObjFactura.RemisionesLista.Add(Row("CveVenta").ToString().ToEntero()) Next - End If - - 'Si es Facturacion de una remision cancelamos, traspasamos saldos y agregamos evento a la bitacora + End If + + 'Si es Facturacion de una remision cancelamos, traspasamos saldos y agregamos evento a la bitacora If (DtRemisionesRelacionadas IsNot Nothing AndAlso DtRemisionesRelacionadas.Rows.Count > 0) OrElse ObjFactura.RemisionesLista.Count > 0 Then If Not ObjFactura.TipoDocto.Contiene("Ing", "Ant") Then @@ -3210,7 +3210,7 @@ Namespace Modelos End If Next End If - End If + End If End If If DtRemisionesRelacionadas Is Nothing Then @@ -3266,681 +3266,681 @@ Namespace Modelos If AutoConta Then If idCuentaContabilizacion > 0 Then If Not ObjConta.ContabilizarPrePoliza(ObjFactura.CvePrePoliza, ObjFactura.CveUsuario, UsuarioActual.Empresa, ObjConta:=objContPaqi) Then - ErrorList.Add("Ocurrio un Error al contabilizar, pongase en contacto con Soporte Técnico") + ErrorList.Add("Ocurrio un Error al contabilizar, pongase en contacto con Soporte Técnico") 'ErrorPrepoliza = True End If Else - ErrorList.Add(String.Format("Falta asignación de las siguientes cuentas contables: {0}", CuentasContablesInvalidas)) + ErrorList.Add(String.Format("Falta asignación de las siguientes cuentas contables: {0}", CuentasContablesInvalidas)) 'ErrorPrepoliza = True End If - End If - - Catch ex As Exception - GuardaLog(ex.ToString()) - ErrorPrepoliza = True - End Try - Return ErrorPrepoliza - End Function - - Private Function GuardaRecepcionUsados(ByRef factura As Modelos.Factura, ObjInventario As ClsInventarios, ObjConta As ClsContabilidad) As Boolean - Dim OcurrioError As Boolean = False - If UsuarioActual.Empresa.UsaInventarios AndAlso factura.TipoDocto.Contiene("Ing", "Egs", "Rem") AndAlso (DtRecepcionUsados IsNot Nothing Or DtAjustes IsNot Nothing) Then - If factura.CveAlmacenRecepcionUsados > 0 Then - Dim CveMovimientoInventario As Integer = ObjInventario.AddMovimiento(factura.CveAlmacenRecepcionUsados, 2, factura.CveMoneda, factura.Fecha, -1, factura.CveUsuario, factura.CveEmpresa, -1, factura.CveVenta, -1, -1, Modulo:="Mod/E") - - Dim DtTemporal As DataTable = Nothing - Dim DtTemporalMovimientosDetalle As DataTable = Nothing - Dim EsUsado As Boolean = False - If DtRecepcionUsados IsNot Nothing AndAlso DtRecepcionUsados.Rows.Count > 0 Then - DtTemporal = DtRecepcionUsados.Copy - EsUsado = True - ElseIf DtAjustes IsNot Nothing AndAlso DtAjustes.Rows.Count > 0 Then - DtTemporal = DtAjustes.Copy - If factura.Inv_CveMovimiento > 0 Then - If ObjInventario.GetMovimientosDetalle(factura.Inv_CveMovimiento, UsuarioActual.CveEmpresa) Then - DtTemporalMovimientosDetalle = ObjInventario.DtResultados - End If - End If - End If - - If DtTemporal IsNot Nothing Then - For Each Dr As DataRow In DtTemporal.Rows - Dim CveProducto As Integer = Dr("CvePS").ToString.ToEntero - Dim CveUnidad As Integer = Dr("CveUM").ToString.ToEntero - Dim Cantidad As Double = Dr("Cantidad").ToString.ToDouble - Dim PU As Double = 0 - If CveProducto > 0 Then - - If EsUsado Then - PU = Dr("PU").ToString.ToDouble - Else - If DtTemporalMovimientosDetalle IsNot Nothing AndAlso DtTemporalMovimientosDetalle.FiltraParametros($"CvePS = {CveProducto}").Rows.Count > 0 Then - PU = DtTemporalMovimientosDetalle.FiltraParametros($"CvePS = {CveProducto}").Rows(0)("PU").ToString.ToDouble - End If - End If - - - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoInventario, Cantidad, CveUnidad, CveProducto, PU, -1, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then - OcurrioError = True - ErrorList.Add("Ocurrió un error al agregar los Movimientos de entrada al Inventario.
") - Exit For - End If - Else - OcurrioError = True - ErrorList.Add("Ocurrió un error al agregar los Movimientos de entrada al Inventario.
") - Exit For - End If - - Next - End If - End If - End If - Return OcurrioError - End Function - - Private Function GuardarVentaInventarios(ByRef factura As Modelos.Factura, ObjInventario As ClsInventarios, ObjConta As ClsContabilidad) As Boolean - Dim OcurrioError As Boolean = False - - If UsuarioActual.Empresa.UsaInventarios AndAlso factura.TipoDocto.Contiene("Ing", "Egs", "Rem") Then - If factura.CveAlmacen > 0 AndAlso DtInventario.Rows.Count > 0 Then - Dim CveMovimientoInventario As Integer = ObjInventario.AddMovimiento(factura.CveAlmacen, 3, factura.CveMoneda, factura.Fecha, -1, factura.CveUsuario, factura.CveEmpresa, -1, factura.CveVenta, -1, -1, Modulo:="Mod/E") - - If CveMovimientoInventario <= 0 Then - OcurrioError = True - ErrorList.Add("Ocurrió un error al agregar los Movimientos de salida al Inventario.
Revise su factura y cualquier detalle comuníquese a Soporte Técnico") - Else - Dim Mensaje As String = "" - Dim i As Integer = 0 - Dim Cantidad As Double - Dim CveUnidad As Integer - Dim CveProducto As Integer - Dim Existencia As Double - 'Dim Pu As Double - 'DtInv.Clone() - - Dim DtEquivalencias As DataTable - For Each Dr As DataRow In DtInventario.Rows - CveProducto = Dr("CvePS").ToString.ToEntero - CveUnidad = Dr("CveUM").ToString.ToEntero - Cantidad = Dr("Cantidad").ToString.ToDouble - - If Dr("CveTipoInvPS").ToString.ToEntero = 5 And Dr("SerieLote").ToString = "" Then - OcurrioError = True - ErrorList.Add("Se deben especificar las Series de los productos de almacén") - Exit For - End If - - If UsuarioActual.CveEmpresa.Contiene({72, 80, 119}) AndAlso factura.TipoDocto.Contiene("Rem", "Ing") Then - Existencia = ObjInventario.GetExistenciasPS(CveProducto, CveUnidad, UsuarioActual.CveEmpresa, CveAlmacen, FechaMovto:=DateTime.Today.AddDays(1).ToString("yyyy/MM/dd HH:mm"), CveSubProyecto:=factura.CveSubProyecto, CveVendedor:=factura.CveVendedor, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeAdelantado:=1, RestringirAlmacenes:=1, ExcluyeApartados:=1) - If Existencia < Cantidad Then - OcurrioError = True - ErrorList.Add($"No cuenta con la cantidad suficiente en inventario del producto {Dr("CodigoPS")} .Cuenta con {Existencia.FormatoNumero(2)}.") - Exit For - End If - End If - - If UsuarioActual.CveEmpresa = 1 Then - DtEquivalencias = New DataTable - DtEquivalencias = GlobalDTProductosServiciosEquivalencias(CveProducto, -1, UsuarioActual.CveEmpresa) - Dim CveUnidadBase As Integer = DtEquivalencias.FiltroPrimeroValor("CveUM", "UnidadBase = 'True'").ToEntero - Dim drUMBase As DataRow = DtEquivalencias.FiltroPrimero("UnidadBase = 'True'") - - 'SI LA UNIDAD ACTUAL NO ES LA BASE SACA PROPORCION (EQUIVALENTE) - If CveUnidadBase <> CveUnidad Then - ' LO QUE PUSE LO QUE VALE UNIDAD BASE LO QUE VALE UNIDAD SELECCIONADA - Cantidad = Dr("Cantidad").ToString.ToDouble * drUMBase("Cantidad").ToString.ToDouble / DtEquivalencias.FiltraParametros(String.Format("CveUM = {0}", CveUnidad)).Rows(0)("Cantidad").ToString.ToDouble - CveUnidad = CveUnidadBase - End If - End If - - If CveProducto > 0 Then - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoInventario, Cantidad, CveUnidad, CveProducto, 0, -1, SerieLote:=Dr("SerieLote").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then - OcurrioError = True - ErrorList.Add("Ocurrió un error al agregar los Movimientos de salida al Inventario.
") - Exit For - End If - Else - OcurrioError = True - ErrorList.Add("Ocurrió un error al agregar los Movimientos de salida al Inventario.
") - Exit For - End If - - - i = i + 1 - Next - - 'REGISTRO LA PREPOLIZA DE COSTO VS ALMACEN - If Not OcurrioError Then - Dim DtCostos As DataTable = Nothing - Dim ValorInventario As Decimal = 0 - Dim TotalCosto As Decimal = 0 - If ObjInventario.GetMovimientosDetalle(CveMovimientoInventario, UsuarioActual.CveEmpresa) Then - DtCostos = ObjInventario.DtResultados - TotalCosto = DtCostos.SUMD("Total").RoundSQL() - Dim tmpCostos As DataTable = DtCostos.FiltraParametros("", "", {"CveClasificacion"}) - Dim IdCtaContable As Integer = 0 - Dim CveCuenta As Integer = 0 - If tmpCostos.Rows.Count > 0 Then - Dim TotalCostoAcumulado As Decimal = 0 - Dim cont As Integer = 1 - 'Se agrega movimiento separado por la cuenta de ventas (ER) - 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.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(factura.CveEmpresa).FiltroPrimeroValor("IdCuentaCostos", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero - CveCuenta = GlobalDTClasificaciones(factura.CveEmpresa).FiltroPrimeroValor("IdCuentaGastoSIG", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero - If ValorInventario <> 0 Then - - If Not ObjConta.AddPrePolizasDetalle(factura.CvePrePoliza, False, ValorInventario, factura.SerieFolio, 69, factura.SerieFolio, factura.Fecha, IdCtaContable, -1, CveVenta:=factura.CveVenta, CveCliente:=factura.CveCliente, CveSubProyecto:=factura.CveSubProyecto, CveClasificacion:=RowInv("CveClasificacion").ToString.ToEntero, CveMovimientoAlmacen:=CveMovimientoInventario, ImporteMX:=ValorInventario, CveCuenta:=CveCuenta) Then - OcurrioError = True - End If - End If - cont += 1 - Next - End If - IdCtaContable = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", String.Format("CveAlmacen = {0}", CveAlmacen)).ToEntero - - If TotalCosto <> 0 Then - If Not ObjConta.AddPrePolizasDetalle(factura.CvePrePoliza, True, TotalCosto, factura.SerieFolio, 68, factura.SerieFolio, factura.Fecha, IdCtaContable, -1, CveVenta:=factura.CveVenta, CveCliente:=factura.CveCliente, CveMovimientoAlmacen:=CveMovimientoInventario, ImporteMX:=TotalCosto, CveCuenta:=CveCuenta, CveSubProyecto:=factura.CveSubProyecto) Then - OcurrioError = True - End If - End If - - factura.Inv_CveMovimiento = CveMovimientoInventario - factura.Inv_ValorInventario = ValorInventario - - End If - End If - - - End If - - If RemisionesLista.Count > 0 Then - For Each CveRemision As Integer In RemisionesLista - 'El almacen general es el Primer Almacen de Material en la Sucursal - If Not TraspasoAlmacen(ObjInventario, CveRemision, ObjConta, True, 9) Then - OcurrioError = True - Exit For - End If - Next - End If - End If - - End If - - Return OcurrioError - End Function - Private Function CuadrarFacturaMovimientos(MovDetalle As DataTable) As DataTable - Dim MovDTCuadrados As New DataTable - MovDTCuadrados = MovDetalle.Clone - MovDTCuadrados.Clear() - - 'Llenamos el DT solo si es primera llamada - If DtRemConceptosSurtidos Is Nothing Then - DtRemConceptosSurtidos = New DataTable - DtRemConceptosSurtidos.Columns.Add("CveVentaDetalle", GetType(Integer)) - DtRemConceptosSurtidos.Columns.Add("Cantidad", GetType(Decimal)) - DtRemConceptosSurtidos.Columns.Add("Surtido", GetType(Decimal)) - - For Each dr As DataRow In DtRemisiones.Rows - Dim dtr As DataRow = DtRemConceptosSurtidos.NewRow - dtr("CveVentaDetalle") = dr("CveVentaDetalle") - dtr("Cantidad") = dr("Cantidad") - dtr("Surtido") = 0 - DtRemConceptosSurtidos.Rows.Add(dtr) - Next - End If - - For Each dr As DataRow In MovDetalle.Rows - Dim rowSurtidos As DataRow = DtRemConceptosSurtidos.FiltroPrimero($"CveVentaDetalle={dr("CveVentaDetalle")}") - Dim rowSurtidosP As DataRow = DtRemConceptosSurtidos.Select($"CveVentaDetalle={dr("CveVentaDetalle")}").FirstOrDefault() - Dim Indice As Integer = DtRemConceptosSurtidos.Rows.IndexOf(rowSurtidosP) - - 'Si no se ha terminado de surtir agregamos el movimiento - If Indice >= 0 Then - ' rowSurtidos("Surtido").ToString.ToDouble < rowSurtidos("Cantidad").ToString.ToDouble AndAlso (dr("CantidadDisponible").ToString.ToDouble - rowSurtidos("Surtido").ToString.ToDouble > 0 Or dr("SerieLote").ToString <> "") - If rowSurtidos("Surtido").ToString.ToDecimal < rowSurtidos("Cantidad").ToString.ToDecimal Then - Dim CantidadSurtida As Double = If(dr("CantidadDisponible").ToString.ToDecimal < rowSurtidos("Cantidad").ToString.ToDouble, dr("CantidadDisponible").ToString.ToDecimal, rowSurtidos("Cantidad").ToString.ToDecimal) - MovDTCuadrados.ImportRow(dr) - MovDTCuadrados(MovDTCuadrados.Rows.Count - 1)("Cantidad") = CantidadSurtida - DtRemConceptosSurtidos(Indice)("Surtido") = rowSurtidos("Surtido").ToString.ToDecimal + CantidadSurtida - End If - Else - ErrorList.Add("Ocurrió un error al traspasar el inventario de la remisión") - Exit For - End If - Next - - Return MovDTCuadrados - End Function - Private Function TraspasoAlmacen(ByRef ObjInventario As ClsInventarios, CveRemision As Integer, ByRef ObjConta As ClsContabilidad, ConSalida As Boolean, ConceptoMovimiento As Integer) As Boolean - Dim OcurrioError As Boolean = False - Dim DtMovimientos As DataTable - Dim DtMovimientosDetalles As DataTable - DtRemConceptosSurtidos = Nothing - - 'Obtenemos los movimientos detalle - If ObjInventario.GetInv_Mov(CveRemision, UsuarioActual.CveEmpresa) Then - - If ObjInventario.DtResultados.Rows.Count > 0 Then - - DtMovimientos = ObjInventario.DtResultados.FiltraParametros("", DistinctColumns:={"CveMovimiento"}) - - 'Si estamos facturando remisiones ajustamos por ventadetalle - If RemisionesLista.Count > 0 Then - Dim resultados = From DtRemisiones In DtRemisiones - Join DtMovDet In ObjInventario.DtResultados.FiltraParametros("CvePS > 0") On DtRemisiones("CveVentaDetalleRemision").ToString.ToEntero Equals DtMovDet("CveVentaDetalle").ToString.ToEntero - Select DtMovDet - Try - DtMovimientosDetalles = resultados.CopyToDataTable - Catch ex As Exception - GuardaLog($"LOG IPP: Ventas LN: 10033. - DtRemisionesTmpDT.Rows.Count: {DtRemisiones.Rows.Count} - ObjInventario.DtResultados.FiltraParametros('CvePS > 0').Rows.Count: {ObjInventario.DtResultados.FiltraParametros("CvePS > 0").Rows.Count}") - DtMovimientosDetalles = New DataTable - End Try - Else - DtMovimientosDetalles = ObjInventario.DtResultados.FiltraParametros("CvePS > 0") - End If - - For Each dr As DataRow In DtMovimientos.Rows - 'Obtenemos los Movimientos de salida - If ObjInventario.GetMovimientos(dr("CveMovimiento").ToString.ToEntero, ConceptoMovimiento, -1, UsuarioActual.CveEmpresa) Then - - If ObjInventario.DtResultados.Rows.Count > 0 AndAlso DtMovimientosDetalles.Rows.Count > 0 Then - - Dim CveAlmacenSalida As Integer = ObjInventario.DtResultados(0)("CveAlmacen").ToString.ToEntero - Dim CveAlmacenEntrada As Integer = ObjInventario.DtResultados(0)("CveAlmacenRelacionado").ToString.ToEntero - Dim CveMoneda As Integer = ObjInventario.DtResultados(0)("CveMoneda").ToString.ToEntero - Dim CveTipoAlmacen As Integer = ObjInventario.DtResultados(0)("CveTipoAlmacen").ToString.ToEntero - - If (CveAlmacenEntrada > 0 AndAlso CveTipoAlmacen <> 1) Or RemisionesLista.Count = 0 Then 'Con remisiones parciales ignoramos las surtidas ya realizadas - - Dim MovDetalle As New DataTable - If RemisionesLista.Count > 0 Then - MovDetalle = CuadrarFacturaMovimientos(DtMovimientosDetalles.FiltraParametros($"CveMovimiento = {dr("CveMovimiento")} AND TieneSalidaxFactura IS NULL")) - Else - MovDetalle = DtMovimientosDetalles.FiltraParametros($"CveMovimiento = {dr("CveMovimiento")}") - End If - - If ErrorList.Count = 0 Then - If MovDetalle.Rows.Count > 0 Then - Dim CveMovimientoSalidaPorTraspaso = -1 - - 'Le damos salida de apartado por traspaso - CveMovimientoSalidaPorTraspaso = GenerarMovimientoAlmacen(ObjInventario, MovDetalle, CveAlmacenSalida, 8, CveMoneda, CveRemision) - If Not CveMovimientoSalidaPorTraspaso > 0 Then - OcurrioError = True - Exit For - End If - - 'Le damos entrada al general por traspaso - If Not OcurrioError Then - If Not GenerarMovimientoAlmacen(ObjInventario, MovDetalle, CveAlmacenEntrada, 9, CveMoneda, CveRemision, CveMovimientoRelacionado:=CveMovimientoSalidaPorTraspaso) > 0 Then - OcurrioError = True - Exit For - End If - End If - - If Not OcurrioError Then - If ConSalida Then - 'Le damos salida normal - If Not GenerarMovimientoAlmacen(ObjInventario, MovDetalle, CveAlmacenEntrada, 3, CveMoneda, Me.CveVenta, MovimientoPrePoliza:=True, ObjConta:=ObjConta) > 0 Then - OcurrioError = True - Exit For - End If - End If - End If - End If - Else - OcurrioError = True - End If - - MovDetalle.Dispose() - End If - - End If - - ElseIf ObjInventario.GetMovimientos(dr("CveMovimiento").ToString.ToEntero, 3, -1, UsuarioActual.CveEmpresa) Then - - 'Esquema viejo, evitamos que aparezca por surtir - If Not ObjInventario.ActualizarEsDevolucionVenta(Me.CveVenta, 2) Then - OcurrioError = True - Exit For - End If - - End If - Next - - End If - - End If - - Return Not OcurrioError - End Function - Private Function GenerarMovimientoAlmacen(ByRef ObjInventario As ClsInventarios, DtMovDetalle As DataTable, CveAlmacen As Integer, ConceptoEntrada As Integer, CveMoneda As Integer, CveVenta As Integer, Optional MovimientoPrePoliza As Boolean = False, Optional ByRef ObjConta As ClsContabilidad = Nothing, Optional CveMovimientoRelacionado As Integer = -1) As Integer - Dim OcurrioError As Boolean = False - Dim ContadorMovtosDetalles = 0 - - 'Creamos el movimiento - Dim CveMovimientoInventario As Integer = ObjInventario.AddMovimiento(CveAlmacen, ConceptoEntrada, CveMoneda, Now, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVenta, -1, -1, CveMovimientoRelacionado:=CveMovimientoRelacionado) - - If CveMovimientoInventario > 0 Then - - 'Agregamos los detalles - For Each MovDet As DataRow In DtMovDetalle.Rows - - Dim Cantidad = 0.0 - Dim CantidadRemision = DtRemisiones.FiltroPrimeroValor("Cantidad", $"CveVentaDetalleRemision={MovDet("CveVentaDetalle").ToString}").ToDouble - Dim CantidadInventario = MovDet("Cantidad").ToString.ToDecimal - - If RemisionesLista.Count > 0 AndAlso CantidadInventario >= CantidadRemision Then - Cantidad = CantidadRemision - Else - Cantidad = CantidadInventario - End If - - Dim CveUnidad As Integer = MovDet("CveUM").ToString.ToEntero - Dim PU As Decimal = MovDet("PU").ToString.ToDecimal - Dim CveProducto As Integer = MovDet("CvePS").ToString.ToEntero - Dim SerieLote As String = MovDet("SerieLote").ToString - Dim Consec As Integer = DtRemisiones.FiltroPrimeroValor("Consec", $"CveVentaDetalle = {MovDet("CveVentaDetalle").ToString}").ToEntero - - 'COMIENZA: VENTADETALLE - 'CUANDO SEA SALIDA VA POR LA VENTA DETALLE DE LA FACTURA DE LA REMISION - OJO!! SOLO FUNCIONA HASTA ORITA QUE SE HACE SALIDA SOLO CUANDO SE FACTURA LA REMISION - Dim CveVentaDetalle = If(ConceptoEntrada.Contiene(3, 40), DtDetalle.FiltroPrimeroValor("CveVentaDetalle", $"Consec={Consec}").ToEntero, MovDet("CveVentaDetalle").ToString.ToEntero) - 'CUANDO LA VENTADETALLE NO TENGA VALOR DEBE MARCAR ERROR, NUEVA RESTRICCION DE ALMACEN - If CveVentaDetalle < 0 Then - OcurrioError = True - Exit For - End If - 'TERMINA: VENTADETALLE - - If Cantidad < 0 Then - ErrorList.Add("Ocurrió un Error al generar los movimientos de almacén. Por favor comuniquese con atención SIG.") - OcurrioError = True - Exit For - End If - - If ObjInventario.AddMovimientoDetalle(CveMovimientoInventario, Cantidad, CveUnidad, CveProducto, PU, -1, SerieLote:=SerieLote, CveVentaDetalle:=CveVentaDetalle) Then - ContadorMovtosDetalles += 1 - Else - OcurrioError = True - Exit For - End If - Next - - 'Agregamos las PrePolizas - If Not OcurrioError Then - If MovimientoPrePoliza AndAlso CveMovimientoInventario > 0 Then - If ObjInventario.GetMovimientosDetalle(CveMovimientoInventario, UsuarioActual.CveEmpresa) AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then - Dim DtCostos = ObjInventario.DtResultados.Copy - Dim DtCostosDistinct As DataTable = ObjInventario.DtResultados.FiltraParametros("", "", {"CveClasificacion"}) - Dim IdCtaContable As Integer = 0 - Dim CveCuenta As Integer = 0 - Dim ValorInventario As Decimal - - For Each RowInv As DataRow In DtCostosDistinct.Rows - ValorInventario = DtCostos.SUM("Total", String.Format("CveClasificacion = {0}", RowInv("CveClasificacion"))).ToString.ToDecimal - IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaCostos", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero - CveCuenta = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaGastoSIG", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero - Try - If ValorInventario <> 0 Then - If Not ObjConta.AddPrePolizasDetalle(Me.CvePrePoliza, False, ValorInventario, Me.SerieFolio, 69, Me.SerieFolio, Me.Fecha, IdCtaContable, -1, CveVenta:=CveVenta, CveCliente:=Me.CveCliente, CveClasificacion:=RowInv("CveClasificacion").ToString.ToEntero, CveMovimientoAlmacen:=CveMovimientoInventario, ImporteMX:=ValorInventario, CveCuenta:=CveCuenta, CveSubProyecto:=Me.CveSubProyecto) Then - OcurrioError = True - Exit For - End If - End If - Catch ex As Exception - OcurrioError = True - End Try - Next - - If Not OcurrioError Then - IdCtaContable = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", String.Format("CveAlmacen = {0}", CveAlmacen)).ToEntero - ValorInventario = Math.Round(DtCostos.SUM("Total", "").ToDecimal, 2, MidpointRounding.AwayFromZero) - If Not ObjConta.AddPrePolizasDetalle(Me.CvePrePoliza, True, ValorInventario, Me.SerieFolio, 68, Me.SerieFolio, Me.Fecha, IdCtaContable, -1, CveVenta:=CveVenta, CveCliente:=Me.CveCliente, CveMovimientoAlmacen:=CveMovimientoInventario, ImporteMX:=ValorInventario, CveCuenta:=CveCuenta, CveSubProyecto:=Me.CveSubProyecto) Then - OcurrioError = True - End If - End If - Else - OcurrioError = True - End If - End If - End If - - - 'VALIDA QUE SE HALLAN AGREGADO DETALLES AL MOVIMIENTO - If ContadorMovtosDetalles = 0 Then - OcurrioError = True - End If - - Else - OcurrioError = True - End If - - - - If OcurrioError Then - Return -1 - Else - Return CveMovimientoInventario - End If - 'Return Not OcurrioError - - End Function - Private Sub GuardarVentaEstimaciones(ByRef factura As Modelos.Factura, ObjContr As ClsContratos) - 'debe de ser por contrato el movimiento - If factura.CveContratoSecciones.Length > 0 Then - If Not ObjContr.AddEstimaciones(CveContrato, factura.Fecha, -1, factura.CveVenta, CveContratoSecciones, factura.CveUsuario, factura.CveEmpresa) Then - ErrorList.Add("Ocurrió un error al agregar la estimación a la Factura.
Revise su factura y cualquier detalle comuníquese a Soporte Técnico") - End If - End If - End Sub - Private Sub GuardarVentaAC(ByRef factura As Modelos.Factura, ObjVentas As ClsVentas, Msgok As StringBuilder, ObjAC As ClsContPAQi) - If UsuarioActual.Empresa.UsaAC Then - - If factura.TipoDocto.Contiene("Ing", "Egs", "OP", "Com") Then - - 'Dim ObjAC As New ClsContPAQi(UsuarioActual.Empresa) : ObjAC.IniciaTransacSQL() - Dim IDPoliza As Integer = GenerarPolizaAC(factura, ObjAC) - - If IDPoliza > 0 Then - - If ObjVentas.UpdateVentaPrePoliza(IDPoliza, factura.CvePrePoliza, factura.CveVenta, factura.CveEmpresa) Then - - 'Si se facturó la cotización hay que vincular la venta - Msgok.AppendFormat("Abono Registrado Correctamente.

Ver Poliza", IDPoliza) - End If - Else - ErrorList.Add("Ocurrió un error al generar A.C. en la Factura.
Revise su factura y cualquier detalle comuníquese a Soporte Técnico") - End If - - Else - Msgok.Append("Movimiento Registrado Correctamente.

") - End If - - End If - End Sub - Private Function GuardarVentaImpuestosLocales(factura As Modelos.Factura, ObjVentas As ClsVentas, ObjConta As ClsContabilidad, Optional ValorMultiplicador As Integer = 1) As Boolean - Dim ErrorPrepoliza As Boolean = False - - If factura.DtImpuestosLocales IsNot Nothing AndAlso factura.CvePrePoliza > 0 AndAlso Not factura.TipoDocto.Contiene("Cot", "Rem") Then - - Dim Importe As Decimal - Dim IdCtaContable, CveCuenta As Integer - Dim Concepto As String - Dim tipoCambio As Decimal - Dim CveSubProyectoContabilizar As Integer = factura.CveSubProyecto - - For Each RowIL As DataRow In factura.DtImpuestosLocales.Rows - If RowIL("TipoImpuesto").ToString.ToEntero > 0 Then - - Importe = RowIL("Importe").ToString.ToDecimal * ValorMultiplicador - IdCtaContable = RowIL("IdCtaContable").ToString.ToEntero - CveCuenta = RowIL("IdCtaContable").ToString.ToEntero - Concepto = factura.SerieFolio - - If factura.CveMoneda = 2 AndAlso factura.TipoCambio > 0 Then - tipoCambio = factura.TipoCambio - ElseIf factura.CveMoneda = 2 AndAlso factura.TipoCambio <= 1 Then - tipoCambio = GlobalTipoCambio(factura.Fecha).ToString.ToDecimal - Else - tipoCambio = 1 - End If - - Select Case RowIL("TipoImpuesto").ToString - Case "1" - If Not ObjConta.AddPrePolizasDetalle(factura.CvePrePoliza, False, Importe, Concepto, 27, Concepto, factura.Fecha, IdCtaContable:=IdCtaContable, IdSegmentoNegocio:=-1, CveVenta:=factura.CveVenta, CveCliente:=factura.CveCliente, ImporteMX:=Importe * tipoCambio, CveCuenta:=CveCuenta, CveSubProyecto:=CveSubProyectoContabilizar) Then - ErrorPrepoliza = True - End If - - Case "3" - If Not ObjConta.AddPrePolizasDetalle(factura.CvePrePoliza, False, Importe, Concepto, 116, Concepto, factura.Fecha, IdCtaContable:=IdCtaContable, IdSegmentoNegocio:=-1, CveVenta:=factura.CveVenta, CveCliente:=factura.CveCliente, ImporteMX:=Importe * tipoCambio, CveCuenta:=CveCuenta, CveSubProyecto:=CveSubProyectoContabilizar) Then - ErrorPrepoliza = True - End If - Case "4" - If Not ObjConta.AddPrePolizasDetalle(factura.CvePrePoliza, False, Importe, Concepto, 58, Concepto, factura.Fecha, IdCtaContable:=IdCtaContable, IdSegmentoNegocio:=-1, CveVenta:=factura.CveVenta, CveCliente:=factura.CveCliente, ImporteMX:=Importe * tipoCambio, CveCuenta:=CveCuenta, CveSubProyecto:=CveSubProyectoContabilizar) Then - ErrorPrepoliza = True - End If - Case "5" - If Not ObjConta.AddPrePolizasDetalle(factura.CvePrePoliza, True, Importe, Concepto, 27, Concepto, factura.Fecha, IdCtaContable:=IdCtaContable, IdSegmentoNegocio:=-1, CveVenta:=factura.CveVenta, CveCliente:=factura.CveCliente, ImporteMX:=Importe * tipoCambio, CveCuenta:=CveCuenta, CveSubProyecto:=CveSubProyectoContabilizar) Then - ErrorPrepoliza = True - End If - End Select - End If - Next - - End If - - Return ErrorPrepoliza - End Function - Private Function GeneraNC(ByRef ObjVentas As ClsVentas, ByRef ObjConta As ClsContabilidad, ByRef ObjInventario As ClsInventarios, ByRef ObjContr As ClsContratos, ByRef ObjContPaq As ClsContPAQi, ByVal factura As Modelos.Factura, ByRef ObjBancos As ClsBancos, ByRef ObjEventos As ClsOIEventos) As List(Of Object) - Dim Obj As New List(Of Object) - Dim CveVentaNueva As Integer = ObjVentas.CveVenta - Dim BanderaGeneraNC As Boolean = False - If UsuarioActual.CveEmpresa.Contiene(1, 119) Then BanderaGeneraNC = True - Dim CveEstatus As Integer = -1 - - If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa) Then - If ObjVentas.DtResultados IsNot Nothing AndAlso ObjVentas.DtResultados.Rows.Count > 0 Then - Dim drv As DataRow = ObjVentas.DtResultados.Rows(0) - Dim TmpDTconceptos As DataTable = Nothing - Dim CveNCaVincular As Integer = factura.CveNCaVincular - 'CargaCliente - Dim CveCliente As Integer = drv("CveCliente").ToString.ToEntero - If UsuarioActual.CveEmpresa = 2 AndAlso UsuarioActual.CveUsuario = 77 AndAlso Not CveCliente.Contiene(10450, 10460, 10458) Then - Return Nothing - ElseIf UsuarioActual.CveEmpresa = 2 AndAlso UsuarioActual.CveUsuario = 21 AndAlso Not CveCliente.Contiene(27448) Then - Return Nothing - End If - factura.TipoDocto = drv("TipoDocto").ToString - factura.Serie = drv("Serie").ToString - factura.FechaEjecucion = drv("FechaEjecucion").ToString.ToDateTime - factura.Fecha = drv("Fecha").ToString.ToDateTime - factura.CveSubProyectoEjecucion = drv("CveSubProyectoEjecucion").ToString.ToEntero - factura.CveSubProyectoCobranza = drv("CveSubProyectoCobranza").ToString.ToEntero - factura.CveClienteSucursal = drv("CveClienteSucursal").ToString.ToEntero - factura.CveSubProyecto = drv("CveSubProyecto").ToString.ToEntero - - 'CargaDetalle - If ObjVentas.GetVentaDetalle(CveVenta) Then - TmpDTconceptos = ObjVentas.DtResultados - TmpDTconceptos.Columns.Add("CveMovimientoDetallePedido", GetType(Integer)) - End If - - 'Carga Totales - factura.SubTotal = drv("SubTotal").ToString.ToDecimal - factura.Descuento = drv("Descuento").ToString.ToDecimal - factura.Amortizacion = drv("Amortizacion").ToString.ToDecimal - factura.IVA = drv("IVA").ToString.ToDecimal - factura.RetIVA = drv("RetIVA").ToString.ToDecimal - factura.RetISR = drv("RetISR").ToString.ToDecimal - factura.Total = drv("Total").ToString.ToDecimal - factura.MotivoDescuento = drv("MotivoDescuento").ToString - factura.Observaciones = drv("Observaciones").ToString - factura.CveMoneda = drv("CveMoneda").ToString.ToEntero - factura.TipoCambio = drv("TipoCambio").ToString.ToDecimal - factura.CveVendedor = drv("CveVendedor").ToString.ToEntero - factura.RefDocto = drv("Ref").ToString - - If factura.CveCliente > 0 Then - If Not IsNothing(TmpDTconceptos) AndAlso TmpDTconceptos.Rows.Count > 0 Then - - If Not drv("Total").ToString.ToDecimal = factura.Total Then - Return Nothing - End If - - If FolioFiscal = "" Then - CveEstatus = 4 - Else - CveEstatus = 5 - End If - - '[IPP] - CANCELA INVENTARIO DE VENTA NUEVA Y NO TRASPASA MOVTOS DE ALMACEN - 'If UsuarioActual.CveEmpresa.Contiene(1) Then - 'QUEMA DOCUMENTO NUEVO - If Not ObjInventario.ActualizarEsDevolucionVenta(CveVentaNueva, 2) Then - Return Nothing - End If - - 'CANCELA PAGOS - If FacturaDevolucion.TipoDocto.Contiene("Ing", "Ant") Then - If Not ObjConta.PrePolizasCancelarPagos(CveDevolucion, Me.CvePrePoliza) Then - Return Nothing - End If - End If - - 'CANCELA FACTURA - If Month(factura.Fecha) = Month(Now) OrElse BanderaGeneraNC = True Then - If CancelarFactura(ObjVentas, ObjConta, ObjContPaq, ObjBancos) Then - Obj.Add(factura) - Else - Return Nothing - End If - Else - FacturaDevolucion.TipoDocto = "Egs" - FacturaDevolucion.Fecha = Now - If RegistrarNC(ObjVentas, ObjConta, ObjInventario, ObjContr, ObjContPaq, FacturaDevolucion, ObjBancos, TmpDTconceptos, ObjEventos) Then - Obj.Add(FacturaDevolucion) - Else - Return Nothing - End If - End If - - 'TRASPASA PAGADO - If Not ObjConta.TraspasarSaldosPrePolizas(Me.CveDevolucion, Me.CveVenta, Me.CvePrePoliza) Then - Return Nothing - End If - - If Not ObjInventario.TraspasaEntregaDirectaOCInv(Me.CveVenta, UsuarioActual.CveEmpresa) Then - Return Nothing - End If - - End If - End If - End If - End If - - If Obj.Count > 0 Then - Return Obj - Else - Return Nothing - End If - - End Function - Private Shared Function DecodeBase64(ByVal strXMLCodificado As String) As String - Try - Dim decbuff As Byte() = Convert.FromBase64String(strXMLCodificado) - Return System.Text.Encoding.UTF8.GetString(decbuff) - Catch - Return "" - End Try + End If + + Catch ex As Exception + GuardaLog(ex.ToString()) + ErrorPrepoliza = True + End Try + Return ErrorPrepoliza + End Function + + Private Function GuardaRecepcionUsados(ByRef factura As Modelos.Factura, ObjInventario As ClsInventarios, ObjConta As ClsContabilidad) As Boolean + Dim OcurrioError As Boolean = False + If UsuarioActual.Empresa.UsaInventarios AndAlso factura.TipoDocto.Contiene("Ing", "Egs", "Rem") AndAlso (DtRecepcionUsados IsNot Nothing Or DtAjustes IsNot Nothing) Then + If factura.CveAlmacenRecepcionUsados > 0 Then + Dim CveMovimientoInventario As Integer = ObjInventario.AddMovimiento(factura.CveAlmacenRecepcionUsados, 2, factura.CveMoneda, factura.Fecha, -1, factura.CveUsuario, factura.CveEmpresa, -1, factura.CveVenta, -1, -1, Modulo:="Mod/E") + + Dim DtTemporal As DataTable = Nothing + Dim DtTemporalMovimientosDetalle As DataTable = Nothing + Dim EsUsado As Boolean = False + If DtRecepcionUsados IsNot Nothing AndAlso DtRecepcionUsados.Rows.Count > 0 Then + DtTemporal = DtRecepcionUsados.Copy + EsUsado = True + ElseIf DtAjustes IsNot Nothing AndAlso DtAjustes.Rows.Count > 0 Then + DtTemporal = DtAjustes.Copy + If factura.Inv_CveMovimiento > 0 Then + If ObjInventario.GetMovimientosDetalle(factura.Inv_CveMovimiento, UsuarioActual.CveEmpresa) Then + DtTemporalMovimientosDetalle = ObjInventario.DtResultados + End If + End If + End If + + If DtTemporal IsNot Nothing Then + For Each Dr As DataRow In DtTemporal.Rows + Dim CveProducto As Integer = Dr("CvePS").ToString.ToEntero + Dim CveUnidad As Integer = Dr("CveUM").ToString.ToEntero + Dim Cantidad As Double = Dr("Cantidad").ToString.ToDouble + Dim PU As Decimal = 0 + If CveProducto > 0 Then + + If EsUsado Then + PU = Dr("PU").ToString.ToDecimal + Else + If DtTemporalMovimientosDetalle IsNot Nothing AndAlso DtTemporalMovimientosDetalle.FiltraParametros($"CvePS = {CveProducto}").Rows.Count > 0 Then + PU = DtTemporalMovimientosDetalle.FiltraParametros($"CvePS = {CveProducto}").Rows(0)("PU").ToString.ToDecimal + End If + End If + + + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoInventario, Cantidad, CveUnidad, CveProducto, PU, -1, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then + OcurrioError = True + ErrorList.Add("Ocurrió un error al agregar los Movimientos de entrada al Inventario.
") + Exit For + End If + Else + OcurrioError = True + ErrorList.Add("Ocurrió un error al agregar los Movimientos de entrada al Inventario.
") + Exit For + End If + + Next + End If + End If + End If + Return OcurrioError + End Function + + Private Function GuardarVentaInventarios(ByRef factura As Modelos.Factura, ObjInventario As ClsInventarios, ObjConta As ClsContabilidad) As Boolean + Dim OcurrioError As Boolean = False + + If UsuarioActual.Empresa.UsaInventarios AndAlso factura.TipoDocto.Contiene("Ing", "Egs", "Rem") Then + If factura.CveAlmacen > 0 AndAlso DtInventario.Rows.Count > 0 Then + Dim CveMovimientoInventario As Integer = ObjInventario.AddMovimiento(factura.CveAlmacen, 3, factura.CveMoneda, factura.Fecha, -1, factura.CveUsuario, factura.CveEmpresa, -1, factura.CveVenta, -1, -1, Modulo:="Mod/E") + + If CveMovimientoInventario <= 0 Then + OcurrioError = True + ErrorList.Add("Ocurrió un error al agregar los Movimientos de salida al Inventario.
Revise su factura y cualquier detalle comuníquese a Soporte Técnico") + Else + Dim Mensaje As String = "" + Dim i As Integer = 0 + Dim Cantidad As Double + Dim CveUnidad As Integer + Dim CveProducto As Integer + Dim Existencia As Double + 'Dim Pu As Double + 'DtInv.Clone() + + Dim DtEquivalencias As DataTable + For Each Dr As DataRow In DtInventario.Rows + CveProducto = Dr("CvePS").ToString.ToEntero + CveUnidad = Dr("CveUM").ToString.ToEntero + Cantidad = Dr("Cantidad").ToString.ToDouble + + If Dr("CveTipoInvPS").ToString.ToEntero = 5 And Dr("SerieLote").ToString = "" Then + OcurrioError = True + ErrorList.Add("Se deben especificar las Series de los productos de almacén") + Exit For + End If + + If UsuarioActual.CveEmpresa.Contiene({72, 80, 119}) AndAlso factura.TipoDocto.Contiene("Rem", "Ing") Then + Existencia = ObjInventario.GetExistenciasPS(CveProducto, CveUnidad, UsuarioActual.CveEmpresa, CveAlmacen, FechaMovto:=DateTime.Today.AddDays(1).ToString("yyyy/MM/dd HH:mm"), CveSubProyecto:=factura.CveSubProyecto, CveVendedor:=factura.CveVendedor, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeAdelantado:=1, RestringirAlmacenes:=1, ExcluyeApartados:=1) + If Existencia < Cantidad Then + OcurrioError = True + ErrorList.Add($"No cuenta con la cantidad suficiente en inventario del producto {Dr("CodigoPS")} .Cuenta con {Existencia.FormatoNumero(2)}.") + Exit For + End If + End If + + If UsuarioActual.CveEmpresa = 1 Then + DtEquivalencias = New DataTable + DtEquivalencias = GlobalDTProductosServiciosEquivalencias(CveProducto, -1, UsuarioActual.CveEmpresa) + Dim CveUnidadBase As Integer = DtEquivalencias.FiltroPrimeroValor("CveUM", "UnidadBase = 'True'").ToEntero + Dim drUMBase As DataRow = DtEquivalencias.FiltroPrimero("UnidadBase = 'True'") + + 'SI LA UNIDAD ACTUAL NO ES LA BASE SACA PROPORCION (EQUIVALENTE) + If CveUnidadBase <> CveUnidad Then + ' LO QUE PUSE LO QUE VALE UNIDAD BASE LO QUE VALE UNIDAD SELECCIONADA + Cantidad = Dr("Cantidad").ToString.ToDouble * drUMBase("Cantidad").ToString.ToDouble / DtEquivalencias.FiltraParametros(String.Format("CveUM = {0}", CveUnidad)).Rows(0)("Cantidad").ToString.ToDouble + CveUnidad = CveUnidadBase + End If + End If + + If CveProducto > 0 Then + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoInventario, Cantidad, CveUnidad, CveProducto, 0, -1, SerieLote:=Dr("SerieLote").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then + OcurrioError = True + ErrorList.Add("Ocurrió un error al agregar los Movimientos de salida al Inventario.
") + Exit For + End If + Else + OcurrioError = True + ErrorList.Add("Ocurrió un error al agregar los Movimientos de salida al Inventario.
") + Exit For + End If + + + i = i + 1 + Next + + 'REGISTRO LA PREPOLIZA DE COSTO VS ALMACEN + If Not OcurrioError Then + Dim DtCostos As DataTable = Nothing + Dim ValorInventario As Decimal = 0 + Dim TotalCosto As Decimal = 0 + If ObjInventario.GetMovimientosDetalle(CveMovimientoInventario, UsuarioActual.CveEmpresa) Then + DtCostos = ObjInventario.DtResultados + TotalCosto = DtCostos.SUMD("Total").RoundSQL() + Dim tmpCostos As DataTable = DtCostos.FiltraParametros("", "", {"CveClasificacion"}) + Dim IdCtaContable As Integer = 0 + Dim CveCuenta As Integer = 0 + If tmpCostos.Rows.Count > 0 Then + Dim TotalCostoAcumulado As Decimal = 0 + Dim cont As Integer = 1 + 'Se agrega movimiento separado por la cuenta de ventas (ER) + 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.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(factura.CveEmpresa).FiltroPrimeroValor("IdCuentaCostos", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero + CveCuenta = GlobalDTClasificaciones(factura.CveEmpresa).FiltroPrimeroValor("IdCuentaGastoSIG", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero + If ValorInventario <> 0 Then + + If Not ObjConta.AddPrePolizasDetalle(factura.CvePrePoliza, False, ValorInventario, factura.SerieFolio, 69, factura.SerieFolio, factura.Fecha, IdCtaContable, -1, CveVenta:=factura.CveVenta, CveCliente:=factura.CveCliente, CveSubProyecto:=factura.CveSubProyecto, CveClasificacion:=RowInv("CveClasificacion").ToString.ToEntero, CveMovimientoAlmacen:=CveMovimientoInventario, ImporteMX:=ValorInventario, CveCuenta:=CveCuenta) Then + OcurrioError = True + End If + End If + cont += 1 + Next + End If + IdCtaContable = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", String.Format("CveAlmacen = {0}", CveAlmacen)).ToEntero + + If TotalCosto <> 0 Then + If Not ObjConta.AddPrePolizasDetalle(factura.CvePrePoliza, True, TotalCosto, factura.SerieFolio, 68, factura.SerieFolio, factura.Fecha, IdCtaContable, -1, CveVenta:=factura.CveVenta, CveCliente:=factura.CveCliente, CveMovimientoAlmacen:=CveMovimientoInventario, ImporteMX:=TotalCosto, CveCuenta:=CveCuenta, CveSubProyecto:=factura.CveSubProyecto) Then + OcurrioError = True + End If + End If + + factura.Inv_CveMovimiento = CveMovimientoInventario + factura.Inv_ValorInventario = ValorInventario + + End If + End If + + + End If + + If RemisionesLista.Count > 0 Then + For Each CveRemision As Integer In RemisionesLista + 'El almacen general es el Primer Almacen de Material en la Sucursal + If Not TraspasoAlmacen(ObjInventario, CveRemision, ObjConta, True, 9) Then + OcurrioError = True + Exit For + End If + Next + End If + End If + + End If + + Return OcurrioError + End Function + Private Function CuadrarFacturaMovimientos(MovDetalle As DataTable) As DataTable + Dim MovDTCuadrados As New DataTable + MovDTCuadrados = MovDetalle.Clone + MovDTCuadrados.Clear() + + 'Llenamos el DT solo si es primera llamada + If DtRemConceptosSurtidos Is Nothing Then + DtRemConceptosSurtidos = New DataTable + DtRemConceptosSurtidos.Columns.Add("CveVentaDetalle", GetType(Integer)) + DtRemConceptosSurtidos.Columns.Add("Cantidad", GetType(Decimal)) + DtRemConceptosSurtidos.Columns.Add("Surtido", GetType(Decimal)) + + For Each dr As DataRow In DtRemisiones.Rows + Dim dtr As DataRow = DtRemConceptosSurtidos.NewRow + dtr("CveVentaDetalle") = dr("CveVentaDetalle") + dtr("Cantidad") = dr("Cantidad") + dtr("Surtido") = 0 + DtRemConceptosSurtidos.Rows.Add(dtr) + Next + End If + + For Each dr As DataRow In MovDetalle.Rows + Dim rowSurtidos As DataRow = DtRemConceptosSurtidos.FiltroPrimero($"CveVentaDetalle={dr("CveVentaDetalle")}") + Dim rowSurtidosP As DataRow = DtRemConceptosSurtidos.Select($"CveVentaDetalle={dr("CveVentaDetalle")}").FirstOrDefault() + Dim Indice As Integer = DtRemConceptosSurtidos.Rows.IndexOf(rowSurtidosP) + + 'Si no se ha terminado de surtir agregamos el movimiento + If Indice >= 0 Then + ' rowSurtidos("Surtido").ToString.ToDouble < rowSurtidos("Cantidad").ToString.ToDouble AndAlso (dr("CantidadDisponible").ToString.ToDouble - rowSurtidos("Surtido").ToString.ToDouble > 0 Or dr("SerieLote").ToString <> "") + If rowSurtidos("Surtido").ToString.ToDecimal < rowSurtidos("Cantidad").ToString.ToDecimal Then + Dim CantidadSurtida As Double = If(dr("CantidadDisponible").ToString.ToDecimal < rowSurtidos("Cantidad").ToString.ToDouble, dr("CantidadDisponible").ToString.ToDecimal, rowSurtidos("Cantidad").ToString.ToDecimal) + MovDTCuadrados.ImportRow(dr) + MovDTCuadrados(MovDTCuadrados.Rows.Count - 1)("Cantidad") = CantidadSurtida + DtRemConceptosSurtidos(Indice)("Surtido") = rowSurtidos("Surtido").ToString.ToDecimal + CantidadSurtida + End If + Else + ErrorList.Add("Ocurrió un error al traspasar el inventario de la remisión") + Exit For + End If + Next + + Return MovDTCuadrados + End Function + Private Function TraspasoAlmacen(ByRef ObjInventario As ClsInventarios, CveRemision As Integer, ByRef ObjConta As ClsContabilidad, ConSalida As Boolean, ConceptoMovimiento As Integer) As Boolean + Dim OcurrioError As Boolean = False + Dim DtMovimientos As DataTable + Dim DtMovimientosDetalles As DataTable + DtRemConceptosSurtidos = Nothing + + 'Obtenemos los movimientos detalle + If ObjInventario.GetInv_Mov(CveRemision, UsuarioActual.CveEmpresa) Then + + If ObjInventario.DtResultados.Rows.Count > 0 Then + + DtMovimientos = ObjInventario.DtResultados.FiltraParametros("", DistinctColumns:={"CveMovimiento"}) + + 'Si estamos facturando remisiones ajustamos por ventadetalle + If RemisionesLista.Count > 0 Then + Dim resultados = From DtRemisiones In DtRemisiones + Join DtMovDet In ObjInventario.DtResultados.FiltraParametros("CvePS > 0") On DtRemisiones("CveVentaDetalleRemision").ToString.ToEntero Equals DtMovDet("CveVentaDetalle").ToString.ToEntero + Select DtMovDet + Try + DtMovimientosDetalles = resultados.CopyToDataTable + Catch ex As Exception + GuardaLog($"LOG IPP: Ventas LN: 10033. - DtRemisionesTmpDT.Rows.Count: {DtRemisiones.Rows.Count} - ObjInventario.DtResultados.FiltraParametros('CvePS > 0').Rows.Count: {ObjInventario.DtResultados.FiltraParametros("CvePS > 0").Rows.Count}") + DtMovimientosDetalles = New DataTable + End Try + Else + DtMovimientosDetalles = ObjInventario.DtResultados.FiltraParametros("CvePS > 0") + End If + + For Each dr As DataRow In DtMovimientos.Rows + 'Obtenemos los Movimientos de salida + If ObjInventario.GetMovimientos(dr("CveMovimiento").ToString.ToEntero, ConceptoMovimiento, -1, UsuarioActual.CveEmpresa) Then + + If ObjInventario.DtResultados.Rows.Count > 0 AndAlso DtMovimientosDetalles.Rows.Count > 0 Then + + Dim CveAlmacenSalida As Integer = ObjInventario.DtResultados(0)("CveAlmacen").ToString.ToEntero + Dim CveAlmacenEntrada As Integer = ObjInventario.DtResultados(0)("CveAlmacenRelacionado").ToString.ToEntero + Dim CveMoneda As Integer = ObjInventario.DtResultados(0)("CveMoneda").ToString.ToEntero + Dim CveTipoAlmacen As Integer = ObjInventario.DtResultados(0)("CveTipoAlmacen").ToString.ToEntero + + If (CveAlmacenEntrada > 0 AndAlso CveTipoAlmacen <> 1) Or RemisionesLista.Count = 0 Then 'Con remisiones parciales ignoramos las surtidas ya realizadas + + Dim MovDetalle As New DataTable + If RemisionesLista.Count > 0 Then + MovDetalle = CuadrarFacturaMovimientos(DtMovimientosDetalles.FiltraParametros($"CveMovimiento = {dr("CveMovimiento")} AND TieneSalidaxFactura IS NULL")) + Else + MovDetalle = DtMovimientosDetalles.FiltraParametros($"CveMovimiento = {dr("CveMovimiento")}") + End If + + If ErrorList.Count = 0 Then + If MovDetalle.Rows.Count > 0 Then + Dim CveMovimientoSalidaPorTraspaso = -1 + + 'Le damos salida de apartado por traspaso + CveMovimientoSalidaPorTraspaso = GenerarMovimientoAlmacen(ObjInventario, MovDetalle, CveAlmacenSalida, 8, CveMoneda, CveRemision) + If Not CveMovimientoSalidaPorTraspaso > 0 Then + OcurrioError = True + Exit For + End If + + 'Le damos entrada al general por traspaso + If Not OcurrioError Then + If Not GenerarMovimientoAlmacen(ObjInventario, MovDetalle, CveAlmacenEntrada, 9, CveMoneda, CveRemision, CveMovimientoRelacionado:=CveMovimientoSalidaPorTraspaso) > 0 Then + OcurrioError = True + Exit For + End If + End If + + If Not OcurrioError Then + If ConSalida Then + 'Le damos salida normal + If Not GenerarMovimientoAlmacen(ObjInventario, MovDetalle, CveAlmacenEntrada, 3, CveMoneda, Me.CveVenta, MovimientoPrePoliza:=True, ObjConta:=ObjConta) > 0 Then + OcurrioError = True + Exit For + End If + End If + End If + End If + Else + OcurrioError = True + End If + + MovDetalle.Dispose() + End If + + End If + + ElseIf ObjInventario.GetMovimientos(dr("CveMovimiento").ToString.ToEntero, 3, -1, UsuarioActual.CveEmpresa) Then + + 'Esquema viejo, evitamos que aparezca por surtir + If Not ObjInventario.ActualizarEsDevolucionVenta(Me.CveVenta, 2) Then + OcurrioError = True + Exit For + End If + + End If + Next + + End If + + End If + + Return Not OcurrioError + End Function + Private Function GenerarMovimientoAlmacen(ByRef ObjInventario As ClsInventarios, DtMovDetalle As DataTable, CveAlmacen As Integer, ConceptoEntrada As Integer, CveMoneda As Integer, CveVenta As Integer, Optional MovimientoPrePoliza As Boolean = False, Optional ByRef ObjConta As ClsContabilidad = Nothing, Optional CveMovimientoRelacionado As Integer = -1) As Integer + Dim OcurrioError As Boolean = False + Dim ContadorMovtosDetalles = 0 + + 'Creamos el movimiento + Dim CveMovimientoInventario As Integer = ObjInventario.AddMovimiento(CveAlmacen, ConceptoEntrada, CveMoneda, Now, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVenta, -1, -1, CveMovimientoRelacionado:=CveMovimientoRelacionado) + + If CveMovimientoInventario > 0 Then + + 'Agregamos los detalles + For Each MovDet As DataRow In DtMovDetalle.Rows + + Dim Cantidad = 0.0 + Dim CantidadRemision = DtRemisiones.FiltroPrimeroValor("Cantidad", $"CveVentaDetalleRemision={MovDet("CveVentaDetalle").ToString}").ToDouble + Dim CantidadInventario = MovDet("Cantidad").ToString.ToDecimal + + If RemisionesLista.Count > 0 AndAlso CantidadInventario >= CantidadRemision Then + Cantidad = CantidadRemision + Else + Cantidad = CantidadInventario + End If + + Dim CveUnidad As Integer = MovDet("CveUM").ToString.ToEntero + Dim PU As Decimal = MovDet("PU").ToString.ToDecimal + Dim CveProducto As Integer = MovDet("CvePS").ToString.ToEntero + Dim SerieLote As String = MovDet("SerieLote").ToString + Dim Consec As Integer = DtRemisiones.FiltroPrimeroValor("Consec", $"CveVentaDetalle = {MovDet("CveVentaDetalle").ToString}").ToEntero + + 'COMIENZA: VENTADETALLE + 'CUANDO SEA SALIDA VA POR LA VENTA DETALLE DE LA FACTURA DE LA REMISION - OJO!! SOLO FUNCIONA HASTA ORITA QUE SE HACE SALIDA SOLO CUANDO SE FACTURA LA REMISION + Dim CveVentaDetalle = If(ConceptoEntrada.Contiene(3, 40), DtDetalle.FiltroPrimeroValor("CveVentaDetalle", $"Consec={Consec}").ToEntero, MovDet("CveVentaDetalle").ToString.ToEntero) + 'CUANDO LA VENTADETALLE NO TENGA VALOR DEBE MARCAR ERROR, NUEVA RESTRICCION DE ALMACEN + If CveVentaDetalle < 0 Then + OcurrioError = True + Exit For + End If + 'TERMINA: VENTADETALLE + + If Cantidad < 0 Then + ErrorList.Add("Ocurrió un Error al generar los movimientos de almacén. Por favor comuniquese con atención SIG.") + OcurrioError = True + Exit For + End If + + If ObjInventario.AddMovimientoDetalle(CveMovimientoInventario, Cantidad, CveUnidad, CveProducto, PU, -1, SerieLote:=SerieLote, CveVentaDetalle:=CveVentaDetalle) Then + ContadorMovtosDetalles += 1 + Else + OcurrioError = True + Exit For + End If + Next + + 'Agregamos las PrePolizas + If Not OcurrioError Then + If MovimientoPrePoliza AndAlso CveMovimientoInventario > 0 Then + If ObjInventario.GetMovimientosDetalle(CveMovimientoInventario, UsuarioActual.CveEmpresa) AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then + Dim DtCostos = ObjInventario.DtResultados.Copy + Dim DtCostosDistinct As DataTable = ObjInventario.DtResultados.FiltraParametros("", "", {"CveClasificacion"}) + Dim IdCtaContable As Integer = 0 + Dim CveCuenta As Integer = 0 + Dim ValorInventario As Decimal + + For Each RowInv As DataRow In DtCostosDistinct.Rows + ValorInventario = DtCostos.SUM("Total", String.Format("CveClasificacion = {0}", RowInv("CveClasificacion"))).ToString.ToDecimal + IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaCostos", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero + CveCuenta = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaGastoSIG", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero + Try + If ValorInventario <> 0 Then + If Not ObjConta.AddPrePolizasDetalle(Me.CvePrePoliza, False, ValorInventario, Me.SerieFolio, 69, Me.SerieFolio, Me.Fecha, IdCtaContable, -1, CveVenta:=CveVenta, CveCliente:=Me.CveCliente, CveClasificacion:=RowInv("CveClasificacion").ToString.ToEntero, CveMovimientoAlmacen:=CveMovimientoInventario, ImporteMX:=ValorInventario, CveCuenta:=CveCuenta, CveSubProyecto:=Me.CveSubProyecto) Then + OcurrioError = True + Exit For + End If + End If + Catch ex As Exception + OcurrioError = True + End Try + Next + + If Not OcurrioError Then + IdCtaContable = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", String.Format("CveAlmacen = {0}", CveAlmacen)).ToEntero + ValorInventario = Math.Round(DtCostos.SUM("Total", "").ToDecimal, 2, MidpointRounding.AwayFromZero) + If Not ObjConta.AddPrePolizasDetalle(Me.CvePrePoliza, True, ValorInventario, Me.SerieFolio, 68, Me.SerieFolio, Me.Fecha, IdCtaContable, -1, CveVenta:=CveVenta, CveCliente:=Me.CveCliente, CveMovimientoAlmacen:=CveMovimientoInventario, ImporteMX:=ValorInventario, CveCuenta:=CveCuenta, CveSubProyecto:=Me.CveSubProyecto) Then + OcurrioError = True + End If + End If + Else + OcurrioError = True + End If + End If + End If + + + 'VALIDA QUE SE HALLAN AGREGADO DETALLES AL MOVIMIENTO + If ContadorMovtosDetalles = 0 Then + OcurrioError = True + End If + + Else + OcurrioError = True + End If + + + + If OcurrioError Then + Return -1 + Else + Return CveMovimientoInventario + End If + 'Return Not OcurrioError + + End Function + Private Sub GuardarVentaEstimaciones(ByRef factura As Modelos.Factura, ObjContr As ClsContratos) + 'debe de ser por contrato el movimiento + If factura.CveContratoSecciones.Length > 0 Then + If Not ObjContr.AddEstimaciones(CveContrato, factura.Fecha, -1, factura.CveVenta, CveContratoSecciones, factura.CveUsuario, factura.CveEmpresa) Then + ErrorList.Add("Ocurrió un error al agregar la estimación a la Factura.
Revise su factura y cualquier detalle comuníquese a Soporte Técnico") + End If + End If + End Sub + Private Sub GuardarVentaAC(ByRef factura As Modelos.Factura, ObjVentas As ClsVentas, Msgok As StringBuilder, ObjAC As ClsContPAQi) + If UsuarioActual.Empresa.UsaAC Then + + If factura.TipoDocto.Contiene("Ing", "Egs", "OP", "Com") Then + + 'Dim ObjAC As New ClsContPAQi(UsuarioActual.Empresa) : ObjAC.IniciaTransacSQL() + Dim IDPoliza As Integer = GenerarPolizaAC(factura, ObjAC) + + If IDPoliza > 0 Then + + If ObjVentas.UpdateVentaPrePoliza(IDPoliza, factura.CvePrePoliza, factura.CveVenta, factura.CveEmpresa) Then + + 'Si se facturó la cotización hay que vincular la venta + Msgok.AppendFormat("Abono Registrado Correctamente.

Ver Poliza", IDPoliza) + End If + Else + ErrorList.Add("Ocurrió un error al generar A.C. en la Factura.
Revise su factura y cualquier detalle comuníquese a Soporte Técnico") + End If + + Else + Msgok.Append("Movimiento Registrado Correctamente.

") + End If + + End If + End Sub + Private Function GuardarVentaImpuestosLocales(factura As Modelos.Factura, ObjVentas As ClsVentas, ObjConta As ClsContabilidad, Optional ValorMultiplicador As Integer = 1) As Boolean + Dim ErrorPrepoliza As Boolean = False + + If factura.DtImpuestosLocales IsNot Nothing AndAlso factura.CvePrePoliza > 0 AndAlso Not factura.TipoDocto.Contiene("Cot", "Rem") Then + + Dim Importe As Decimal + Dim IdCtaContable, CveCuenta As Integer + Dim Concepto As String + Dim tipoCambio As Decimal + Dim CveSubProyectoContabilizar As Integer = factura.CveSubProyecto + + For Each RowIL As DataRow In factura.DtImpuestosLocales.Rows + If RowIL("TipoImpuesto").ToString.ToEntero > 0 Then + + Importe = RowIL("Importe").ToString.ToDecimal * ValorMultiplicador + IdCtaContable = RowIL("IdCtaContable").ToString.ToEntero + CveCuenta = RowIL("IdCtaContable").ToString.ToEntero + Concepto = factura.SerieFolio + + If factura.CveMoneda = 2 AndAlso factura.TipoCambio > 0 Then + tipoCambio = factura.TipoCambio + ElseIf factura.CveMoneda = 2 AndAlso factura.TipoCambio <= 1 Then + tipoCambio = GlobalTipoCambio(factura.Fecha).ToString.ToDecimal + Else + tipoCambio = 1 + End If + + Select Case RowIL("TipoImpuesto").ToString + Case "1" + If Not ObjConta.AddPrePolizasDetalle(factura.CvePrePoliza, False, Importe, Concepto, 27, Concepto, factura.Fecha, IdCtaContable:=IdCtaContable, IdSegmentoNegocio:=-1, CveVenta:=factura.CveVenta, CveCliente:=factura.CveCliente, ImporteMX:=Importe * tipoCambio, CveCuenta:=CveCuenta, CveSubProyecto:=CveSubProyectoContabilizar) Then + ErrorPrepoliza = True + End If + + Case "3" + If Not ObjConta.AddPrePolizasDetalle(factura.CvePrePoliza, False, Importe, Concepto, 116, Concepto, factura.Fecha, IdCtaContable:=IdCtaContable, IdSegmentoNegocio:=-1, CveVenta:=factura.CveVenta, CveCliente:=factura.CveCliente, ImporteMX:=Importe * tipoCambio, CveCuenta:=CveCuenta, CveSubProyecto:=CveSubProyectoContabilizar) Then + ErrorPrepoliza = True + End If + Case "4" + If Not ObjConta.AddPrePolizasDetalle(factura.CvePrePoliza, False, Importe, Concepto, 58, Concepto, factura.Fecha, IdCtaContable:=IdCtaContable, IdSegmentoNegocio:=-1, CveVenta:=factura.CveVenta, CveCliente:=factura.CveCliente, ImporteMX:=Importe * tipoCambio, CveCuenta:=CveCuenta, CveSubProyecto:=CveSubProyectoContabilizar) Then + ErrorPrepoliza = True + End If + Case "5" + If Not ObjConta.AddPrePolizasDetalle(factura.CvePrePoliza, True, Importe, Concepto, 27, Concepto, factura.Fecha, IdCtaContable:=IdCtaContable, IdSegmentoNegocio:=-1, CveVenta:=factura.CveVenta, CveCliente:=factura.CveCliente, ImporteMX:=Importe * tipoCambio, CveCuenta:=CveCuenta, CveSubProyecto:=CveSubProyectoContabilizar) Then + ErrorPrepoliza = True + End If + End Select + End If + Next + + End If + + Return ErrorPrepoliza + End Function + Private Function GeneraNC(ByRef ObjVentas As ClsVentas, ByRef ObjConta As ClsContabilidad, ByRef ObjInventario As ClsInventarios, ByRef ObjContr As ClsContratos, ByRef ObjContPaq As ClsContPAQi, ByVal factura As Modelos.Factura, ByRef ObjBancos As ClsBancos, ByRef ObjEventos As ClsOIEventos) As List(Of Object) + Dim Obj As New List(Of Object) + Dim CveVentaNueva As Integer = ObjVentas.CveVenta + Dim BanderaGeneraNC As Boolean = False + If UsuarioActual.CveEmpresa.Contiene(1, 119) Then BanderaGeneraNC = True + Dim CveEstatus As Integer = -1 + + If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa) Then + If ObjVentas.DtResultados IsNot Nothing AndAlso ObjVentas.DtResultados.Rows.Count > 0 Then + Dim drv As DataRow = ObjVentas.DtResultados.Rows(0) + Dim TmpDTconceptos As DataTable = Nothing + Dim CveNCaVincular As Integer = factura.CveNCaVincular + 'CargaCliente + Dim CveCliente As Integer = drv("CveCliente").ToString.ToEntero + If UsuarioActual.CveEmpresa = 2 AndAlso UsuarioActual.CveUsuario = 77 AndAlso Not CveCliente.Contiene(10450, 10460, 10458) Then + Return Nothing + ElseIf UsuarioActual.CveEmpresa = 2 AndAlso UsuarioActual.CveUsuario = 21 AndAlso Not CveCliente.Contiene(27448) Then + Return Nothing + End If + factura.TipoDocto = drv("TipoDocto").ToString + factura.Serie = drv("Serie").ToString + factura.FechaEjecucion = drv("FechaEjecucion").ToString.ToDateTime + factura.Fecha = drv("Fecha").ToString.ToDateTime + factura.CveSubProyectoEjecucion = drv("CveSubProyectoEjecucion").ToString.ToEntero + factura.CveSubProyectoCobranza = drv("CveSubProyectoCobranza").ToString.ToEntero + factura.CveClienteSucursal = drv("CveClienteSucursal").ToString.ToEntero + factura.CveSubProyecto = drv("CveSubProyecto").ToString.ToEntero + + 'CargaDetalle + If ObjVentas.GetVentaDetalle(CveVenta) Then + TmpDTconceptos = ObjVentas.DtResultados + TmpDTconceptos.Columns.Add("CveMovimientoDetallePedido", GetType(Integer)) + End If + + 'Carga Totales + factura.SubTotal = drv("SubTotal").ToString.ToDecimal + factura.Descuento = drv("Descuento").ToString.ToDecimal + factura.Amortizacion = drv("Amortizacion").ToString.ToDecimal + factura.IVA = drv("IVA").ToString.ToDecimal + factura.RetIVA = drv("RetIVA").ToString.ToDecimal + factura.RetISR = drv("RetISR").ToString.ToDecimal + factura.Total = drv("Total").ToString.ToDecimal + factura.MotivoDescuento = drv("MotivoDescuento").ToString + factura.Observaciones = drv("Observaciones").ToString + factura.CveMoneda = drv("CveMoneda").ToString.ToEntero + factura.TipoCambio = drv("TipoCambio").ToString.ToDecimal + factura.CveVendedor = drv("CveVendedor").ToString.ToEntero + factura.RefDocto = drv("Ref").ToString + + If factura.CveCliente > 0 Then + If Not IsNothing(TmpDTconceptos) AndAlso TmpDTconceptos.Rows.Count > 0 Then + + If Not drv("Total").ToString.ToDecimal = factura.Total Then + Return Nothing + End If + + If FolioFiscal = "" Then + CveEstatus = 4 + Else + CveEstatus = 5 + End If + + '[IPP] - CANCELA INVENTARIO DE VENTA NUEVA Y NO TRASPASA MOVTOS DE ALMACEN + 'If UsuarioActual.CveEmpresa.Contiene(1) Then + 'QUEMA DOCUMENTO NUEVO + If Not ObjInventario.ActualizarEsDevolucionVenta(CveVentaNueva, 2) Then + Return Nothing + End If + + 'CANCELA PAGOS + If FacturaDevolucion.TipoDocto.Contiene("Ing", "Ant") Then + If Not ObjConta.PrePolizasCancelarPagos(CveDevolucion, Me.CvePrePoliza) Then + Return Nothing + End If + End If + + 'CANCELA FACTURA + If Month(factura.Fecha) = Month(Now) OrElse BanderaGeneraNC = True Then + If CancelarFactura(ObjVentas, ObjConta, ObjContPaq, ObjBancos) Then + Obj.Add(factura) + Else + Return Nothing + End If + Else + FacturaDevolucion.TipoDocto = "Egs" + FacturaDevolucion.Fecha = Now + If RegistrarNC(ObjVentas, ObjConta, ObjInventario, ObjContr, ObjContPaq, FacturaDevolucion, ObjBancos, TmpDTconceptos, ObjEventos) Then + Obj.Add(FacturaDevolucion) + Else + Return Nothing + End If + End If + + 'TRASPASA PAGADO + If Not ObjConta.TraspasarSaldosPrePolizas(Me.CveDevolucion, Me.CveVenta, Me.CvePrePoliza) Then + Return Nothing + End If + + If Not ObjInventario.TraspasaEntregaDirectaOCInv(Me.CveVenta, UsuarioActual.CveEmpresa) Then + Return Nothing + End If + + End If + End If + End If + End If + + If Obj.Count > 0 Then + Return Obj + Else + Return Nothing + End If + + End Function + Private Shared Function DecodeBase64(ByVal strXMLCodificado As String) As String + Try + Dim decbuff As Byte() = Convert.FromBase64String(strXMLCodificado) + Return System.Text.Encoding.UTF8.GetString(decbuff) + Catch + Return "" + End Try End Function Public Class MCancelacionVentaMensaje Public Property HuboError As Boolean = False @@ -4803,7 +4803,7 @@ Namespace Modelos For Each RowUsado As DataRow In DtMovtosDev.Rows Dim CvePS = RowUsado("CvePS").ToString().ToEntero() Dim CantidadUsado As Double = RowUsado("Cantidad").ToString().ToDouble() - Dim PU As Double = RowUsado("PU").ToString().ToDouble() + Dim PU As Decimal = RowUsado("PU").ToString().ToDecimal() Dim CveUM As Integer = RowUsado("CveUM").ToString().ToEntero() If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, CantidadUsado, CveUM, CvePS, PU, -1, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then @@ -4895,7 +4895,7 @@ Namespace Modelos End If For Each Dr As DataRow In DtMovtosDev.FiltraParametros($"CveVentaDetalle = {DrRem("CveVentaDetalle").ToString.ToEntero}").Rows - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalidaDevRem, Dr("Cantidad").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDouble, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, CveVentaDetalle:=CveVentaDetalleRem, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString) Then + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalidaDevRem, Dr("Cantidad").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, CveVentaDetalle:=CveVentaDetalleRem, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString) Then ErrorCancelar = True Exit For End If @@ -5034,109 +5034,109 @@ Namespace Modelos CancelarVenta(Me, UsuarioActual) Return Retorno - End Function - Protected Function CancelarFactura(ByRef ObjVentas As ClsVentas, ByRef ObjConta As ClsContabilidad, ByRef ObjAC As ClsContPAQi, ByRef ObjBancos As ClsBancos) As Boolean - - Dim IDPoliza As Integer = -1 - Dim CvePrePoliza As Integer - Dim CvePlantillaPoliza As Integer - - Dim ErrorCancelar As Boolean = False - Dim Mensaje As String = "" - - FacturaDevolucion.TipoDocto = Me.TipoDocto - - If FacturaDevolucion.TipoDocto.Contiene("Egs", "Dev") Then - CvePlantillaPoliza = 7 - ElseIf FacturaDevolucion.TipoDocto.Contiene("Ing", "Rem", "Ant") Then - CvePlantillaPoliza = 4 - End If - - - CvePrePoliza = ObjConta.AddPrePolizas("Ventas/GuardaEstatus", CvePlantillaPoliza, Me.Total, Me.Total, Me.CveMoneda, Now, Me.Cliente.NombreComercial, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - FacturaDevolucion.CveVenta = CveVenta - FacturaDevolucion.CvePrePoliza = CvePrePoliza - - - If NuevaFactura = 1 AndAlso UsuarioActual.TienePermisoProceso(222) Then - If ObjVentas.GetVentaDetalle(FacturaDevolucion.CveVenta) Then - DtDetalle = ObjVentas.DtResultados - End If - ErrorCancelar = ProcesoPrepolizas(FacturaDevolucion, ObjConta, -1, DtDetalle, ObjAC, -1, ObjBancos, ObjVentas) - Else - ErrorCancelar = ProcesoPrepolizas(FacturaDevolucion, ObjConta, -1, DtDetalle, ObjAC, -1, ObjBancos, ObjVentas) - End If - - If Not ErrorCancelar Then - ErrorCancelar = GuardarVentaImpuestosLocales(FacturaDevolucion, ObjVentas, ObjConta, -1) - End If - - If CveEstatus = 4 Then - - If ObjVentas.UpdateEstatusFactura(CveEstatus, FolioFiscal, "", Now, CveVenta, IDPoliza) Then - Mensaje = "El nuevo estatus se guardó correctamente" - Else - ErrorCancelar = True - End If - - 'Si se está mandando a Cancelada SAT - ElseIf CveEstatus = 5 Then - - Dim DT As DataTable = Nothing - - If FolioFiscal = "" Then - Dim XmlDoc As New XmlDocument - XmlDoc.Load(Me.DirectorioServidor & UsuarioActual.Empresa.Ruta & "XML\" & Me.TipoDocto & "\" & Me.SerieFolio & ".xml") - FacturaDevolucion.FolioFiscal = XmlDoc.DocumentElement("cfdi:Complemento").FirstChild.Attributes("UUID").InnerText - End If - - Dim ObjCancelacion As New Timbrado - - Dim Total As Decimal = Me.Total - Dim RFCReceptor As String = Me.Cliente.RFC - - If Not ObjVentas.UpdateEstatusFactura(13, FolioFiscal, "", Now, CveVenta, IDPoliza) Then 'Marcamos la factura como refacturada, si no se cancelo en el SAT el estatus nos dejara cancelarla despues - ErrorCancelar = True - End If - - If ObjCancelacion.CFDICancelar(UsuarioActual.Empresa, FolioFiscal, Total, RFCReceptor, UsuarioActual.Empresa.RFC) Then - 'falta verificar traer el acuse y reenviarlo - If UsuarioActual.Empresa.UsaAC Then - IDPoliza = GenerarPolizaAC(Me, ObjAC, True) - If IDPoliza <= 0 Then - Mensaje = "No se pudo generar la poliza" - ErrorCancelar = True - End If - End If - - If Not ErrorCancelar Then - If ObjVentas.UpdateEstatusFactura(CveEstatus, FolioFiscal, ObjCancelacion.CancelacionAcuse, Now, CveVenta, IDPoliza, CvePAC:=UsuarioActual.Empresa.CvePAC) Then - Mensaje = "El nuevo estatus se guardó correctamente" - Else - ErrorCancelar = True - End If - End If - End If - - ObjCancelacion = Nothing - - End If - - Return Not ErrorCancelar - End Function - Private Function RegistrarNC(ObjVentas As ClsVentas, ObjConta As ClsContabilidad, ObjInventario As ClsInventarios, ObjContr As ClsContratos, ObjContPaq As ClsContPAQi, ByVal factura As Modelos.Factura, ObjBancos As ClsBancos, TmpDTconceptos As DataTable, ByRef ObjEventos As ClsOIEventos) As Boolean - Dim ProcesoCorrecto As Boolean = True - RefacturacionGeneroNC = True - factura.Folio = -1 - - 'Registramos la venta - GuardarVenta(factura, ObjVentas, ObjConta, ObjInventario, ObjContr, TmpDTconceptos, -1, ObjContPaq, ObjBancos) - - If ErrorList.Count > 0 Then - ProcesoCorrecto = False - End If - - Return ProcesoCorrecto + End Function + Protected Function CancelarFactura(ByRef ObjVentas As ClsVentas, ByRef ObjConta As ClsContabilidad, ByRef ObjAC As ClsContPAQi, ByRef ObjBancos As ClsBancos) As Boolean + + Dim IDPoliza As Integer = -1 + Dim CvePrePoliza As Integer + Dim CvePlantillaPoliza As Integer + + Dim ErrorCancelar As Boolean = False + Dim Mensaje As String = "" + + FacturaDevolucion.TipoDocto = Me.TipoDocto + + If FacturaDevolucion.TipoDocto.Contiene("Egs", "Dev") Then + CvePlantillaPoliza = 7 + ElseIf FacturaDevolucion.TipoDocto.Contiene("Ing", "Rem", "Ant") Then + CvePlantillaPoliza = 4 + End If + + + CvePrePoliza = ObjConta.AddPrePolizas("Ventas/GuardaEstatus", CvePlantillaPoliza, Me.Total, Me.Total, Me.CveMoneda, Now, Me.Cliente.NombreComercial, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + FacturaDevolucion.CveVenta = CveVenta + FacturaDevolucion.CvePrePoliza = CvePrePoliza + + + If NuevaFactura = 1 AndAlso UsuarioActual.TienePermisoProceso(222) Then + If ObjVentas.GetVentaDetalle(FacturaDevolucion.CveVenta) Then + DtDetalle = ObjVentas.DtResultados + End If + ErrorCancelar = ProcesoPrepolizas(FacturaDevolucion, ObjConta, -1, DtDetalle, ObjAC, -1, ObjBancos, ObjVentas) + Else + ErrorCancelar = ProcesoPrepolizas(FacturaDevolucion, ObjConta, -1, DtDetalle, ObjAC, -1, ObjBancos, ObjVentas) + End If + + If Not ErrorCancelar Then + ErrorCancelar = GuardarVentaImpuestosLocales(FacturaDevolucion, ObjVentas, ObjConta, -1) + End If + + If CveEstatus = 4 Then + + If ObjVentas.UpdateEstatusFactura(CveEstatus, FolioFiscal, "", Now, CveVenta, IDPoliza) Then + Mensaje = "El nuevo estatus se guardó correctamente" + Else + ErrorCancelar = True + End If + + 'Si se está mandando a Cancelada SAT + ElseIf CveEstatus = 5 Then + + Dim DT As DataTable = Nothing + + If FolioFiscal = "" Then + Dim XmlDoc As New XmlDocument + XmlDoc.Load(Me.DirectorioServidor & UsuarioActual.Empresa.Ruta & "XML\" & Me.TipoDocto & "\" & Me.SerieFolio & ".xml") + FacturaDevolucion.FolioFiscal = XmlDoc.DocumentElement("cfdi:Complemento").FirstChild.Attributes("UUID").InnerText + End If + + Dim ObjCancelacion As New Timbrado + + Dim Total As Decimal = Me.Total + Dim RFCReceptor As String = Me.Cliente.RFC + + If Not ObjVentas.UpdateEstatusFactura(13, FolioFiscal, "", Now, CveVenta, IDPoliza) Then 'Marcamos la factura como refacturada, si no se cancelo en el SAT el estatus nos dejara cancelarla despues + ErrorCancelar = True + End If + + If ObjCancelacion.CFDICancelar(UsuarioActual.Empresa, FolioFiscal, Total, RFCReceptor, UsuarioActual.Empresa.RFC) Then + 'falta verificar traer el acuse y reenviarlo + If UsuarioActual.Empresa.UsaAC Then + IDPoliza = GenerarPolizaAC(Me, ObjAC, True) + If IDPoliza <= 0 Then + Mensaje = "No se pudo generar la poliza" + ErrorCancelar = True + End If + End If + + If Not ErrorCancelar Then + If ObjVentas.UpdateEstatusFactura(CveEstatus, FolioFiscal, ObjCancelacion.CancelacionAcuse, Now, CveVenta, IDPoliza, CvePAC:=UsuarioActual.Empresa.CvePAC) Then + Mensaje = "El nuevo estatus se guardó correctamente" + Else + ErrorCancelar = True + End If + End If + End If + + ObjCancelacion = Nothing + + End If + + Return Not ErrorCancelar + End Function + Private Function RegistrarNC(ObjVentas As ClsVentas, ObjConta As ClsContabilidad, ObjInventario As ClsInventarios, ObjContr As ClsContratos, ObjContPaq As ClsContPAQi, ByVal factura As Modelos.Factura, ObjBancos As ClsBancos, TmpDTconceptos As DataTable, ByRef ObjEventos As ClsOIEventos) As Boolean + Dim ProcesoCorrecto As Boolean = True + RefacturacionGeneroNC = True + factura.Folio = -1 + + 'Registramos la venta + GuardarVenta(factura, ObjVentas, ObjConta, ObjInventario, ObjContr, TmpDTconceptos, -1, ObjContPaq, ObjBancos) + + If ErrorList.Count > 0 Then + ProcesoCorrecto = False + End If + + Return ProcesoCorrecto End Function Private Function GenerarPolizaAC(ObjFactura As Modelos.Factura, ObjAC As ClsContPAQi, Optional CancelacionIngreso As Boolean = False) As Integer Dim Retorno As Integer = 0 @@ -5243,132 +5243,132 @@ Namespace Modelos End Function -#End Region +#End Region #Region "P R O P I E D A D E S" Public Property CveEstatusRefacturacion As Integer = 0 - Public Property NuevaFactura As Integer - Public Property EnviarCorreo As Boolean = False - Public Property ErrorList As List(Of String) - Public Property TipoContrato As Integer - Public Property CvePedido As Integer = -1 - Public Property CvePedidoA As Integer = -1 - Public Property CvePedido2 As Integer = -1 - Public Property CveAlmacenTraspasoOrigen As Integer = -1 - Public Property CveAlmacenTraspasoDestino As Integer = -1 - Public Property EsDevolucionVenta As Integer = -1 - Public Property EsInterno As Integer = -1 - Public Property CveEmpresaCRM As Integer = -1 - Public Property EmpresaCRM As String = "" - Public Property TotalImpuestoLocal As Decimal = 0 - Public Property AplicaDevolucion As Boolean - Public Property CveVentaDevolucion As Integer - Public Property ObservacionesAlmacen As String - Public Property CveOC As Integer = -1 - Public Property CveCuentaTerminal As Integer = -1 - Public Property ClienteEsDistribuidor As Boolean = False - Public Property AplicaGastoContrato As Boolean = False - Public Property FacturaDevolucion As Modelos.Factura - Public Property CveOrdenProduccion As Integer = -1 - Public Property Pago As Integer - Public Property TipoAmortizacionAnticipo As Integer - Public Property CveAlmacenExistenciasContrato As Integer - Public Property EraCotizacion As Integer - Public Property CveRemision As Integer = -1 - Public Property CveCotizacion As Integer = -1 - Public Property DevPed As Integer = -1 - Public Property CveFactura As Integer - Public Property CveCicloComercial As Integer - Public Property TipoDoctoDevolucion As String - Public Property SeGuardoPrePoliza As Boolean - Public Property DirectorioServidor As String - Public Property FacturaMateriales As Integer - Public Property TipoDescuento As Integer - Public Property SubProyectoPorcentajeIVA As Double - Public Property CveAlmacenOrigenContrato As Integer - Public Property CveDevolucion As Integer - Public Property TotalOtrosConceptos As Decimal - Public Property CvePSAmortizacion As Integer - Public Property SaldoVentaDevolucion As Decimal - Public Property Saldo As Decimal - Public Property SaldoAlmacen As Decimal - Public Property SaldoAnticipo As Decimal - Public Property SaldoAmortizado As Decimal - Public Property CvePAC As Integer - Public Property CveAnticipo As Integer - Public Property RemisionesLista As List(Of Integer) - Public Property CveAlmacen As Integer + Public Property NuevaFactura As Integer + Public Property EnviarCorreo As Boolean = False + Public Property ErrorList As List(Of String) + Public Property TipoContrato As Integer + Public Property CvePedido As Integer = -1 + Public Property CvePedidoA As Integer = -1 + Public Property CvePedido2 As Integer = -1 + Public Property CveAlmacenTraspasoOrigen As Integer = -1 + Public Property CveAlmacenTraspasoDestino As Integer = -1 + Public Property EsDevolucionVenta As Integer = -1 + Public Property EsInterno As Integer = -1 + Public Property CveEmpresaCRM As Integer = -1 + Public Property EmpresaCRM As String = "" + Public Property TotalImpuestoLocal As Decimal = 0 + Public Property AplicaDevolucion As Boolean + Public Property CveVentaDevolucion As Integer + Public Property ObservacionesAlmacen As String + Public Property CveOC As Integer = -1 + Public Property CveCuentaTerminal As Integer = -1 + Public Property ClienteEsDistribuidor As Boolean = False + Public Property AplicaGastoContrato As Boolean = False + Public Property FacturaDevolucion As Modelos.Factura + Public Property CveOrdenProduccion As Integer = -1 + Public Property Pago As Integer + Public Property TipoAmortizacionAnticipo As Integer + Public Property CveAlmacenExistenciasContrato As Integer + Public Property EraCotizacion As Integer + Public Property CveRemision As Integer = -1 + Public Property CveCotizacion As Integer = -1 + Public Property DevPed As Integer = -1 + Public Property CveFactura As Integer + Public Property CveCicloComercial As Integer + Public Property TipoDoctoDevolucion As String + Public Property SeGuardoPrePoliza As Boolean + Public Property DirectorioServidor As String + Public Property FacturaMateriales As Integer + Public Property TipoDescuento As Integer + Public Property SubProyectoPorcentajeIVA As Double + Public Property CveAlmacenOrigenContrato As Integer + Public Property CveDevolucion As Integer + Public Property TotalOtrosConceptos As Decimal + Public Property CvePSAmortizacion As Integer + Public Property SaldoVentaDevolucion As Decimal + Public Property Saldo As Decimal + Public Property SaldoAlmacen As Decimal + Public Property SaldoAnticipo As Decimal + Public Property SaldoAmortizado As Decimal + Public Property CvePAC As Integer + Public Property CveAnticipo As Integer + Public Property RemisionesLista As List(Of Integer) + Public Property CveAlmacen As Integer Public Property CveAlmacenDevolucion As Integer - Public Property CveVenta As Integer - Public Property CveEmpresa As Integer - Public Property CveSucursal As Integer 'sucursal de la empresa que factura - Public Property CveSubProyecto As Integer - Public Property CveAlmacenRecepcionUsados As Integer = -1 - Public Property CveDireccionEnvio As Integer - Public Property RefacturacionGeneroNC As Boolean = False + Public Property CveVenta As Integer + Public Property CveEmpresa As Integer + Public Property CveSucursal As Integer 'sucursal de la empresa que factura + Public Property CveSubProyecto As Integer + Public Property CveAlmacenRecepcionUsados As Integer = -1 + Public Property CveDireccionEnvio As Integer + Public Property RefacturacionGeneroNC As Boolean = False Public Property Pagado As Decimal - Public Property DescuentoProntoPago As Decimal - 'Public Property Sucursal As SucursalModel - Public Property SubProyecto As Modelos.SubProyectoModel - - Public Property DtDetalle As Data.DataTable - Public Property DtDetalleAC As Data.DataTable - Public Property DtAjustes As Data.DataTable + Public Property DescuentoProntoPago As Decimal + 'Public Property Sucursal As SucursalModel + Public Property SubProyecto As Modelos.SubProyectoModel + + Public Property DtDetalle As Data.DataTable + Public Property DtDetalleAC As Data.DataTable + Public Property DtAjustes As Data.DataTable Public Property DtRecepcionUsados As Data.DataTable - Public Property DtPolizasVirtuales As Data.DataTable - Public Property DtVentasNC As Data.DataTable - Public Property DtDeduccion As Data.DataTable - Public Property DtFirmas As Data.DataTable - Public Property DtDesgloseImpuestos As Data.DataTable + Public Property DtPolizasVirtuales As Data.DataTable + Public Property DtVentasNC As Data.DataTable + Public Property DtDeduccion As Data.DataTable + Public Property DtFirmas As Data.DataTable + Public Property DtDesgloseImpuestos As Data.DataTable Public Property DtDocumentosRelacionados As Data.DataTable - Public Property DtNCVinculadas As Data.DataTable - - Public Property DtAnticipos As Data.DataTable - Public Property DtPromociones As Data.DataTable - Public Property DtImpuestosLocales As Data.DataTable - Public Property DtPagos As Data.DataTable - Public Property DtRemisionesPS As Data.DataTable - Public Property DtRemisiones As Data.DataTable - Public Property DtPedidos2 As Data.DataTable - Public Property DtPedidos2PS As Data.DataTable - Public Property DTOrdenesCompraPS As Data.DataTable - Public Property DtCotizacionesPS As Data.DataTable - Public Property DtDocumentacionCliente As Data.DataTable - Public Property DtContratosSerieDetalle As Data.DataTable - Public Property DtOtrosConceptos As Data.DataTable - Public Property DtInventario As Data.DataTable + Public Property DtNCVinculadas As Data.DataTable + + Public Property DtAnticipos As Data.DataTable + Public Property DtPromociones As Data.DataTable + Public Property DtImpuestosLocales As Data.DataTable + Public Property DtPagos As Data.DataTable + Public Property DtRemisionesPS As Data.DataTable + Public Property DtRemisiones As Data.DataTable + Public Property DtPedidos2 As Data.DataTable + Public Property DtPedidos2PS As Data.DataTable + Public Property DTOrdenesCompraPS As Data.DataTable + Public Property DtCotizacionesPS As Data.DataTable + Public Property DtDocumentacionCliente As Data.DataTable + Public Property DtContratosSerieDetalle As Data.DataTable + Public Property DtOtrosConceptos As Data.DataTable + Public Property DtInventario As Data.DataTable 'Public Property DtAnticipoAmortizacion As Data.DataTable - Public Property DtRemConceptosSurtidos As Data.DataTable - Public Property UsadosBonificacion As List(Of Integer) - Public Property TipoBonificacion As Integer = 0 - Public Property Timbre As CFDITimbre - Public Property CveCliente As Integer - Public Property Cliente As Modelos.ClienteModel - Public Property SubProyectoMatriz As Modelos.SubProyectoModel - 'CFDi - - Public Property Version As String - Public Property Serie As String = "" - Public Property Folio As Integer - - Public ReadOnly Property SerieFolio As String - Get - If Not IsNothing(Serie) AndAlso Serie.Trim <> String.Empty Then - Return String.Format("{0}-{1}", Serie, Folio) - Else - Return Folio.ToString - End If - End Get - End Property - - Public Property Inv_CveMovimiento As Integer - Public Property Inv_CveEstatusEntrega As Integer - Public Property Inv_EstatusEntrega As String - Public Property Inv_ValorInventario As Decimal + Public Property DtRemConceptosSurtidos As Data.DataTable + Public Property UsadosBonificacion As List(Of Integer) + Public Property TipoBonificacion As Integer = 0 + Public Property Timbre As CFDITimbre + Public Property CveCliente As Integer + Public Property Cliente As Modelos.ClienteModel + Public Property SubProyectoMatriz As Modelos.SubProyectoModel + 'CFDi + + Public Property Version As String + Public Property Serie As String = "" + Public Property Folio As Integer + + Public ReadOnly Property SerieFolio As String + Get + If Not IsNothing(Serie) AndAlso Serie.Trim <> String.Empty Then + Return String.Format("{0}-{1}", Serie, Folio) + Else + Return Folio.ToString + End If + End Get + End Property + + Public Property Inv_CveMovimiento As Integer + Public Property Inv_CveEstatusEntrega As Integer + Public Property Inv_EstatusEntrega As String + Public Property Inv_ValorInventario As Decimal Public Property Fecha As DateTime - Public ReadOnly Property FechaCP As DateTime + Public ReadOnly Property FechaCP As DateTime Get If Me.SubProyecto IsNot Nothing Then If Now.EsHorarioVerano Then @@ -5378,410 +5378,410 @@ Namespace Modelos End If Else Return Fecha - End If - End Get - End Property - Public Property FechaVencimiento As DateTime - Public Property EstatusFactura As String - Public Property SeTimbro As String - Public Property TipoDocto As String - Public Property RefDocto As String - Public Property RealizarDevolucionAlmacen As Boolean - Public Property CveAlmacenDevolucionVenta As Integer - - Public Property TipoDocumento As String - - - - - Public ReadOnly Property TipodeComprobante As String - Get - Select Case TipoDocto - Case "Ing" - Return "Ingresos" - Case "Egs" - Return "Egresos" - Case "Dev" - Return "Devolucion" - Case "Ped" - Return "Pedido" - Case "Cot" - Return "Cotización" - Case "Rem" - Return "Remisión" - Case "Nom" - Return "Nom" - Case "Ant" - Return "Anticipos" - Case Else - Return "No Identificado" - End Select - End Get - End Property - Public ReadOnly Property CvePlantillaPoliza As Integer - Get - Select Case TipoDocto - Case "Ing" - Return 4 - Case "Egs" - Return 7 - Case "Dev" - Return 7 - Case "Rem" - Return 4 - Case "Ant" - Return 12 - Case Else - Return -1 - End Select - End Get - End Property - Public ReadOnly Property TipodeComprobanteSAT As ClbNegBICFDv3_2.TipoDeComprobante - Get - Select Case TipoDocto - Case "Ing" - Return ClbNegBICFDv3_2.TipoDeComprobante.ingreso - Case "Egs" - Return ClbNegBICFDv3_2.TipoDeComprobante.egreso - Case "Dev" - Return ClbNegBICFDv3_2.TipoDeComprobante.egreso - Case "Cot" - Return Nothing - Case "Rem" - Return Nothing - Case "Nom" - Return Nothing - Case "Ant" - Return ClbNegBICFDv3_2.TipoDeComprobante.ingreso - Case Else - Return Nothing - End Select - End Get - End Property - Public ReadOnly Property ClaseDoctoSat As Integer - Get - Select Case TipoDocto - Case "Ing" - Return 1 - Case "Egs" - Return 9 - Case "Dev" - Return 9 - Case "Cot" - Return 0 - Case "Rem" - Return 0 - Case "Nom" - Return 0 - Case "Ant" - Return 0 - Case Else - Return 0 - End Select - End Get - End Property - Public Property CveUsuario As Integer - Public Property SerieFolioPadre As String - Public Property CveMoneda As Integer - Public Property Moneda As String - Public Property MonedaSAT As String - Public Property UsuarioCreo As String - Public Property MonedaAbreviatura As String - Public Property TipoCambio As Decimal - Public Property TipoCambioDolares As Decimal - Public Property ConvertirPesos As Boolean - Public Property ConvertirDolares As Boolean - Public Property FormaPago As Integer - - Public ReadOnly Property FormaPagoText As String - Get - Dim retorno = "" - Select Case FormaPago - Case 0 - retorno = "PAGO EN UNA SOLA EXHIBICIÓN" - Case 1 - retorno = "PAGO EN PARCIALIDADES" - End Select - Return retorno - End Get - End Property - - Public Property CondicionesPago As Integer - - Public ReadOnly Property CondicionesPagoText As String - Get - Dim retorno = "" - Select Case CondicionesPago - Case 0 - retorno = "contado" - Case 1 - retorno = "crédito" - End Select - Return retorno - End Get - End Property - + End If + End Get + End Property + Public Property FechaVencimiento As DateTime + Public Property EstatusFactura As String + Public Property SeTimbro As String + Public Property TipoDocto As String + Public Property RefDocto As String + Public Property RealizarDevolucionAlmacen As Boolean + Public Property CveAlmacenDevolucionVenta As Integer + + Public Property TipoDocumento As String + + + + + Public ReadOnly Property TipodeComprobante As String + Get + Select Case TipoDocto + Case "Ing" + Return "Ingresos" + Case "Egs" + Return "Egresos" + Case "Dev" + Return "Devolucion" + Case "Ped" + Return "Pedido" + Case "Cot" + Return "Cotización" + Case "Rem" + Return "Remisión" + Case "Nom" + Return "Nom" + Case "Ant" + Return "Anticipos" + Case Else + Return "No Identificado" + End Select + End Get + End Property + Public ReadOnly Property CvePlantillaPoliza As Integer + Get + Select Case TipoDocto + Case "Ing" + Return 4 + Case "Egs" + Return 7 + Case "Dev" + Return 7 + Case "Rem" + Return 4 + Case "Ant" + Return 12 + Case Else + Return -1 + End Select + End Get + End Property + Public ReadOnly Property TipodeComprobanteSAT As ClbNegBICFDv3_2.TipoDeComprobante + Get + Select Case TipoDocto + Case "Ing" + Return ClbNegBICFDv3_2.TipoDeComprobante.ingreso + Case "Egs" + Return ClbNegBICFDv3_2.TipoDeComprobante.egreso + Case "Dev" + Return ClbNegBICFDv3_2.TipoDeComprobante.egreso + Case "Cot" + Return Nothing + Case "Rem" + Return Nothing + Case "Nom" + Return Nothing + Case "Ant" + Return ClbNegBICFDv3_2.TipoDeComprobante.ingreso + Case Else + Return Nothing + End Select + End Get + End Property + Public ReadOnly Property ClaseDoctoSat As Integer + Get + Select Case TipoDocto + Case "Ing" + Return 1 + Case "Egs" + Return 9 + Case "Dev" + Return 9 + Case "Cot" + Return 0 + Case "Rem" + Return 0 + Case "Nom" + Return 0 + Case "Ant" + Return 0 + Case Else + Return 0 + End Select + End Get + End Property + Public Property CveUsuario As Integer + Public Property SerieFolioPadre As String + Public Property CveMoneda As Integer + Public Property Moneda As String + Public Property MonedaSAT As String + Public Property UsuarioCreo As String + Public Property MonedaAbreviatura As String + Public Property TipoCambio As Decimal + Public Property TipoCambioDolares As Decimal + Public Property ConvertirPesos As Boolean + Public Property ConvertirDolares As Boolean + Public Property FormaPago As Integer + + Public ReadOnly Property FormaPagoText As String + Get + Dim retorno = "" + Select Case FormaPago + Case 0 + retorno = "PAGO EN UNA SOLA EXHIBICIÓN" + Case 1 + retorno = "PAGO EN PARCIALIDADES" + End Select + Return retorno + End Get + End Property + + Public Property CondicionesPago As Integer + + Public ReadOnly Property CondicionesPagoText As String + Get + Dim retorno = "" + Select Case CondicionesPago + Case 0 + retorno = "contado" + Case 1 + retorno = "crédito" + End Select + Return retorno + End Get + End Property + Public Property MotivoDescuento As String -#Region "Totales" - Public Property SubTotal As Decimal - Public Property Descuento As Decimal - Public Property Amortizacion As Decimal - - 'IVA - Public Property RetIVA As Decimal - Public Property RetISR As Decimal - Public Property IVA As Decimal - Public Property IEPS As Decimal - - Public Property Total As Decimal +#Region "Totales" + Public Property SubTotal As Decimal + Public Property Descuento As Decimal + Public Property Amortizacion As Decimal + + 'IVA + Public Property RetIVA As Decimal + Public Property RetISR As Decimal + Public Property IVA As Decimal + Public Property IEPS As Decimal + + Public Property Total As Decimal Public Property Otros As Decimal Public Property TotalRemNCAplicado As Decimal -#Region "Totales por Tipo de cambio" +#Region "Totales por Tipo de cambio" - Public ReadOnly Property SubTotalTC As Decimal - Get - If ConvertirPesos Then - Return SubTotal * TipoCambio - Else - Return SubTotal - End If - End Get - End Property - Public ReadOnly Property DescuentoTC As Decimal - Get - If ConvertirPesos Then - Return Descuento * TipoCambio - Else - Return Descuento - End If - End Get - End Property - Public ReadOnly Property AmortizacionTC As Decimal - Get - If ConvertirPesos Then - Return Amortizacion * TipoCambio - Else - Return Amortizacion - End If - End Get - End Property - 'IVA - Public ReadOnly Property RetIVATC As Decimal - Get - If ConvertirPesos Then - Return RetIVA * TipoCambio - Else - Return RetIVA - End If - End Get - End Property - Public ReadOnly Property RetISRTC As Decimal - Get - If ConvertirPesos Then - Return RetISR * TipoCambio - Else - Return RetISR - End If - End Get - End Property - Public ReadOnly Property IVATC As Decimal - Get - If ConvertirPesos Then - Return IVA * TipoCambio - Else - Return IVA - End If - End Get - End Property - Public ReadOnly Property IEPSTC As Decimal - Get - If ConvertirPesos Then - Return IEPS * TipoCambio - Else - Return IEPS - End If - End Get - End Property - Public ReadOnly Property TotalTC As Decimal - Get - If ConvertirPesos Then - Return Total * TipoCambio - Else - Return Total - End If - End Get - End Property - Public ReadOnly Property OtrosTC As Decimal - Get - If ConvertirPesos Then - Return Otros * TipoCambio - Else - Return Otros - End If - End Get + Public ReadOnly Property SubTotalTC As Decimal + Get + If ConvertirPesos Then + Return SubTotal * TipoCambio + Else + Return SubTotal + End If + End Get End Property -#End Region -#End Region - Public Property AtencionA As String - Public Property AtnA As String - Public Property TelefonoGenerico As String - Public Property Det_OrdenCompra As String - Public Property Det_FechaOrdenCompra As String - Public Property Det_ContraRecibo As String - Public Property Observaciones As String - - Public Property Alfa1 As String - Public Property Alfa2 As String - Public Property Alfa3 As String - - Public Property Fech1 As Date - Public Property Fech2 As Date - Public Property Fech3 As Date - - Public Property Num1 As Double - Public Property Num2 As Double - Public Property Num3 As Double - - Public Property DiasCredito As Integer - Public Property EsDiasCreditoFijo As Boolean - - Public Property CveCorte As Integer - Public Property CveMesa As Integer - Public Property NumeroPersonas As Integer - - - Public Property FechaPago As Date - - Public Property CveNCaVincular As Integer - Public Property FolioFiscal As String - Public Property NoSerieCertificado As String - Public Property SelloCFDi As String - Public Property SelloSAT As String - Public Property FechaEmision As Date - Public Property FechaCertificacion As Date - Public Property NoSerieCertificadoContribuyente As String - Public Property NumeroCuenta As String - Public Property CveTipoAmortizacionAnticipo As Integer = -1 - Public Property DescripcionContrato As String - Public Property NumeroDescripcionContrato As String - Public Property CveComplementoTimbrado As Integer = 0 - Public Property ComplementoINE As Modelos.ComplementoINE - Public Property FordGSDB As String = "" - Public Property FordASN As String = "" + Public ReadOnly Property DescuentoTC As Decimal + Get + If ConvertirPesos Then + Return Descuento * TipoCambio + Else + Return Descuento + End If + End Get + End Property + Public ReadOnly Property AmortizacionTC As Decimal + Get + If ConvertirPesos Then + Return Amortizacion * TipoCambio + Else + Return Amortizacion + End If + End Get + End Property + 'IVA + Public ReadOnly Property RetIVATC As Decimal + Get + If ConvertirPesos Then + Return RetIVA * TipoCambio + Else + Return RetIVA + End If + End Get + End Property + Public ReadOnly Property RetISRTC As Decimal + Get + If ConvertirPesos Then + Return RetISR * TipoCambio + Else + Return RetISR + End If + End Get + End Property + Public ReadOnly Property IVATC As Decimal + Get + If ConvertirPesos Then + Return IVA * TipoCambio + Else + Return IVA + End If + End Get + End Property + Public ReadOnly Property IEPSTC As Decimal + Get + If ConvertirPesos Then + Return IEPS * TipoCambio + Else + Return IEPS + End If + End Get + End Property + Public ReadOnly Property TotalTC As Decimal + Get + If ConvertirPesos Then + Return Total * TipoCambio + Else + Return Total + End If + End Get + End Property + Public ReadOnly Property OtrosTC As Decimal + Get + If ConvertirPesos Then + Return Otros * TipoCambio + Else + Return Otros + End If + End Get + End Property +#End Region +#End Region + Public Property AtencionA As String + Public Property AtnA As String + Public Property TelefonoGenerico As String + Public Property Det_OrdenCompra As String + Public Property Det_FechaOrdenCompra As String + Public Property Det_ContraRecibo As String + Public Property Observaciones As String + + Public Property Alfa1 As String + Public Property Alfa2 As String + Public Property Alfa3 As String + + Public Property Fech1 As Date + Public Property Fech2 As Date + Public Property Fech3 As Date + + Public Property Num1 As Double + Public Property Num2 As Double + Public Property Num3 As Double + + Public Property DiasCredito As Integer + Public Property EsDiasCreditoFijo As Boolean + + Public Property CveCorte As Integer + Public Property CveMesa As Integer + Public Property NumeroPersonas As Integer + + + Public Property FechaPago As Date + + Public Property CveNCaVincular As Integer + Public Property FolioFiscal As String + Public Property NoSerieCertificado As String + Public Property SelloCFDi As String + Public Property SelloSAT As String + Public Property FechaEmision As Date + Public Property FechaCertificacion As Date + Public Property NoSerieCertificadoContribuyente As String + Public Property NumeroCuenta As String + Public Property CveTipoAmortizacionAnticipo As Integer = -1 + Public Property DescripcionContrato As String + Public Property NumeroDescripcionContrato As String + Public Property CveComplementoTimbrado As Integer = 0 + Public Property ComplementoINE As Modelos.ComplementoINE + Public Property FordGSDB As String = "" + Public Property FordASN As String = "" Public Property FemsaFactura As Modelos.FemsaFactura - Public Sub SetSubProyecto() - If CveSubProyecto > 0 Then - SubProyecto = New Modelos.SubProyectoModel(GlobalDTSubProyectos(-1).FiltroPrimero($"CveSubProyecto = {CveSubProyecto}")) - End If - End Sub - Public Sub SetSubProyectoMatriz() - Dim Row As Data.DataRow = GlobalDTSubProyectos(-1, CveSubProyecto:=-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero("TipoSucursal=1") - If Not IsNothing(Row) Then - SubProyectoMatriz = New Modelos.SubProyectoModel(Row) - End If - End Sub - Public Sub SetCliente() - If CveCliente > 0 Then - Cliente = New Modelos.ClienteModel(CveCliente, CveEmpresa) - End If - End Sub - Public Sub SetMoneda() - If CveMoneda > 0 Then - Dim dr As DataRow = GlobalDTMonedas.FiltroPrimero(String.Format("CveMoneda ={0}", CveMoneda)) - If Not IsNothing(dr) Then - Moneda = dr("Moneda").ToString() - MonedaSAT = dr("AbreviaturaSAT").ToString() - MonedaAbreviatura = dr("Abreviatura").ToString() - End If - End If - End Sub - Public Sub SetMetodoPago() - If CveMetodoPago > 0 AndAlso Not IsNothing(GlobalDTMetodosPago.FiltroPrimero(String.Format(" CveMetodoPago ={0}", CveMetodoPago))) Then - MetodoPago = GlobalDTMetodosPago.FiltroPrimero(String.Format(" CveMetodoPago ={0}", CveMetodoPago))("MetodoPago").ToString() - ClaveMetodoPagoSAT = GlobalDTMetodosPago.FiltroPrimero(String.Format(" CveMetodoPago ={0}", CveMetodoPago))("ClaveSAT").ToString() - End If - End Sub - Public Sub SetMoneda(ObjClsPaginas As ClsPaginas) - If Not IsNothing(ObjClsPaginas) Then - Dim dr As DataRow = ObjClsPaginas.GlobalDTMonedas.FiltroPrimero(String.Format("CveMoneda ={0}", CveMoneda)) - If Not IsNothing(dr) Then - Moneda = dr("Moneda").ToString() - MonedaSAT = dr("AbreviaturaSAT").ToString() - MonedaAbreviatura = dr("Abreviatura").ToString() - End If - End If - End Sub - Public Sub SetMetodoPago(ObjClsPaginas As ClsPaginas) - If Not IsNothing(ObjClsPaginas) Then - If Not IsNothing(ObjClsPaginas.GlobalDTMetodosPago.FiltroPrimero(String.Format(" CveMetodoPago ={0}", CveMetodoPago))) Then - MetodoPago = ObjClsPaginas.GlobalDTMetodosPago.FiltroPrimero(String.Format(" CveMetodoPago ={0}", CveMetodoPago))("MetodoPago").ToString() - ClaveMetodoPagoSAT = ObjClsPaginas.GlobalDTMetodosPago.FiltroPrimero(String.Format(" CveMetodoPago ={0}", CveMetodoPago))("ClaveSAT").ToString() - End If - End If - End Sub - Public Sub SetSubProyecto(obj As ClsPaginas) - If CveSubProyecto > 0 AndAlso Not IsNothing(obj) Then - SubProyecto = New Modelos.SubProyectoModel(GlobalDTSubProyectos(-1).FiltroPrimero($"CveSubProyecto = {CveSubProyecto}")) - End If - End Sub - Public Sub SetSubProyectoMatriz(obj As ClsPaginas) - If Not IsNothing(obj) Then - Dim Row As Data.DataRow = GlobalDTSubProyectos(-1, CveSubProyecto:=-1, CveEmpresa:=obj.UsuarioActual.CveEmpresa).FiltroPrimero("TipoSucursal=1") - If Not IsNothing(Row) Then - SubProyectoMatriz = New Modelos.SubProyectoModel(Row) - End If - End If - End Sub - - Public Property CveClienteSucursal As Integer - Public Property ClienteSucursal As Modelos.SucursalModel - Public Property EnviarA As Modelos.EnviarAModel - Public Property NumeroContrato As String - Public Property PedidoContrato As String - Public Property OrdenCompra As String = "-1" - Public Property CveMetodoPago As Integer - Public Property MetodoPago As String - Public Property ClaveMetodoPagoSAT As String - Public Property CveMetodoPago33 As Integer - Public Property MetodoPago33 As String - Public Property CveFormaPago33 As Integer - Public Property MetodoPagoSAT33 As String - Public Property FormaPago33 As String - Public Property FormaPagoSAT33 As String - Public Property UsoCFDI As String = "" - Public Property CveUsoCFDI As Integer - Public Property ClaveUsoCFDI As String = "" - Public Property CveTipoRelacion As Integer = -1 - Public Property CveEstatusFactura As Integer - Public Property CveVendedor As Integer - Public Property VendedorCodigo As String - Public Property CveSucursalEjecucion As Integer - Public Property FechaEjecucion As Date - Public Property CveSucursalCobranza As Integer - - Public Property CveSubProyectoCobranza As Integer - Public Property CveSubProyectoEjecucion As Integer - Public Property CveOS As Integer - Public Property CveContrato As Integer - Public Property CveVentaPadre As Integer - Public Property CvePrePoliza As Integer - Public Property Entrega As String - Public Property TiempoEntrega As String - Public Property Vigencia As Date - Public Property TipoEstatus As Integer - Public Property CveCondicionEntrega As Integer - Public Property CondicionEntrega As String - - Public Property TipoRelacion As String - Public Property UUIDRelacionados As List(Of String) - - - Public Property CveVentaRelacion As Integer = -1 + Public Sub SetSubProyecto() + If CveSubProyecto > 0 Then + SubProyecto = New Modelos.SubProyectoModel(GlobalDTSubProyectos(-1).FiltroPrimero($"CveSubProyecto = {CveSubProyecto}")) + End If + End Sub + Public Sub SetSubProyectoMatriz() + Dim Row As Data.DataRow = GlobalDTSubProyectos(-1, CveSubProyecto:=-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero("TipoSucursal=1") + If Not IsNothing(Row) Then + SubProyectoMatriz = New Modelos.SubProyectoModel(Row) + End If + End Sub + Public Sub SetCliente() + If CveCliente > 0 Then + Cliente = New Modelos.ClienteModel(CveCliente, CveEmpresa) + End If + End Sub + Public Sub SetMoneda() + If CveMoneda > 0 Then + Dim dr As DataRow = GlobalDTMonedas.FiltroPrimero(String.Format("CveMoneda ={0}", CveMoneda)) + If Not IsNothing(dr) Then + Moneda = dr("Moneda").ToString() + MonedaSAT = dr("AbreviaturaSAT").ToString() + MonedaAbreviatura = dr("Abreviatura").ToString() + End If + End If + End Sub + Public Sub SetMetodoPago() + If CveMetodoPago > 0 AndAlso Not IsNothing(GlobalDTMetodosPago.FiltroPrimero(String.Format(" CveMetodoPago ={0}", CveMetodoPago))) Then + MetodoPago = GlobalDTMetodosPago.FiltroPrimero(String.Format(" CveMetodoPago ={0}", CveMetodoPago))("MetodoPago").ToString() + ClaveMetodoPagoSAT = GlobalDTMetodosPago.FiltroPrimero(String.Format(" CveMetodoPago ={0}", CveMetodoPago))("ClaveSAT").ToString() + End If + End Sub + Public Sub SetMoneda(ObjClsPaginas As ClsPaginas) + If Not IsNothing(ObjClsPaginas) Then + Dim dr As DataRow = ObjClsPaginas.GlobalDTMonedas.FiltroPrimero(String.Format("CveMoneda ={0}", CveMoneda)) + If Not IsNothing(dr) Then + Moneda = dr("Moneda").ToString() + MonedaSAT = dr("AbreviaturaSAT").ToString() + MonedaAbreviatura = dr("Abreviatura").ToString() + End If + End If + End Sub + Public Sub SetMetodoPago(ObjClsPaginas As ClsPaginas) + If Not IsNothing(ObjClsPaginas) Then + If Not IsNothing(ObjClsPaginas.GlobalDTMetodosPago.FiltroPrimero(String.Format(" CveMetodoPago ={0}", CveMetodoPago))) Then + MetodoPago = ObjClsPaginas.GlobalDTMetodosPago.FiltroPrimero(String.Format(" CveMetodoPago ={0}", CveMetodoPago))("MetodoPago").ToString() + ClaveMetodoPagoSAT = ObjClsPaginas.GlobalDTMetodosPago.FiltroPrimero(String.Format(" CveMetodoPago ={0}", CveMetodoPago))("ClaveSAT").ToString() + End If + End If + End Sub + Public Sub SetSubProyecto(obj As ClsPaginas) + If CveSubProyecto > 0 AndAlso Not IsNothing(obj) Then + SubProyecto = New Modelos.SubProyectoModel(GlobalDTSubProyectos(-1).FiltroPrimero($"CveSubProyecto = {CveSubProyecto}")) + End If + End Sub + Public Sub SetSubProyectoMatriz(obj As ClsPaginas) + If Not IsNothing(obj) Then + Dim Row As Data.DataRow = GlobalDTSubProyectos(-1, CveSubProyecto:=-1, CveEmpresa:=obj.UsuarioActual.CveEmpresa).FiltroPrimero("TipoSucursal=1") + If Not IsNothing(Row) Then + SubProyectoMatriz = New Modelos.SubProyectoModel(Row) + End If + End If + End Sub + + Public Property CveClienteSucursal As Integer + Public Property ClienteSucursal As Modelos.SucursalModel + Public Property EnviarA As Modelos.EnviarAModel + Public Property NumeroContrato As String + Public Property PedidoContrato As String + Public Property OrdenCompra As String = "-1" + Public Property CveMetodoPago As Integer + Public Property MetodoPago As String + Public Property ClaveMetodoPagoSAT As String + Public Property CveMetodoPago33 As Integer + Public Property MetodoPago33 As String + Public Property CveFormaPago33 As Integer + Public Property MetodoPagoSAT33 As String + Public Property FormaPago33 As String + Public Property FormaPagoSAT33 As String + Public Property UsoCFDI As String = "" + Public Property CveUsoCFDI As Integer + Public Property ClaveUsoCFDI As String = "" + Public Property CveTipoRelacion As Integer = -1 + Public Property CveEstatusFactura As Integer + Public Property CveVendedor As Integer + Public Property VendedorCodigo As String + Public Property CveSucursalEjecucion As Integer + Public Property FechaEjecucion As Date + Public Property CveSucursalCobranza As Integer + + Public Property CveSubProyectoCobranza As Integer + Public Property CveSubProyectoEjecucion As Integer + Public Property CveOS As Integer + Public Property CveContrato As Integer + Public Property CveVentaPadre As Integer + Public Property CvePrePoliza As Integer + Public Property Entrega As String + Public Property TiempoEntrega As String + Public Property Vigencia As Date + Public Property TipoEstatus As Integer + Public Property CveCondicionEntrega As Integer + Public Property CondicionEntrega As String + + Public Property TipoRelacion As String + Public Property UUIDRelacionados As List(Of String) + + + Public Property CveVentaRelacion As Integer = -1 Public Property ImporteRelacion As Decimal Public Property EsNCAmortizacion As Boolean @@ -5792,385 +5792,385 @@ Namespace Modelos #End Region -#Region "IDisposable Support" +#Region "IDisposable Support" 'Atributos de la clase - Private disposedValue As Boolean = False - - ' IDisposable - Protected Overridable Sub Dispose(disposing As Boolean) - If Not Me.disposedValue Then - If disposing Then - '' TODO: dispose managed state (managed objects). - If Not DtDetalle Is Nothing Then DtDetalle.Dispose() - If Not DtAjustes Is Nothing Then DtAjustes.Dispose() - If Not DtAnticipos Is Nothing Then DtAnticipos.Dispose() - If Not DtContratosSerieDetalle Is Nothing Then DtContratosSerieDetalle.Dispose() - If Not DtCotizacionesPS Is Nothing Then DtCotizacionesPS.Dispose() - If Not DtDeduccion Is Nothing Then DtDeduccion.Dispose() - If Not DtDesgloseImpuestos Is Nothing Then DtDesgloseImpuestos.Dispose() - If Not DtDocumentacionCliente Is Nothing Then DtDocumentacionCliente.Dispose() - If Not DtDocumentosRelacionados Is Nothing Then DtDocumentosRelacionados.Dispose() - If Not DtFirmas Is Nothing Then DtFirmas.Dispose() - If Not DtImpuestosLocales Is Nothing Then DtImpuestosLocales.Dispose() - If Not DtInventario Is Nothing Then DtInventario.Dispose() - If Not DtNCVinculadas Is Nothing Then DtNCVinculadas.Dispose() - If Not DTOrdenesCompraPS Is Nothing Then DTOrdenesCompraPS.Dispose() - If Not DtOtrosConceptos Is Nothing Then DtOtrosConceptos.Dispose() - If Not DtPagos Is Nothing Then DtPagos.Dispose() - If Not DtPedidos2 Is Nothing Then DtPedidos2.Dispose() - If Not DtPedidos2PS Is Nothing Then DtPedidos2PS.Dispose() - If Not DtPromociones Is Nothing Then DtPromociones.Dispose() - If Not DtRecepcionUsados Is Nothing Then DtRecepcionUsados.Dispose() - If Not DtRemConceptosSurtidos Is Nothing Then DtRemConceptosSurtidos.Dispose() - If Not DtRemisiones Is Nothing Then DtRemisiones.Dispose() - If Not DtRemisionesPS Is Nothing Then DtRemisionesPS.Dispose() - If Not DtVentasNC Is Nothing Then DtVentasNC.Dispose() - End If - End If - Me.disposedValue = True - End Sub - ' This code added by Visual Basic to correctly implement the disposable pattern. - Public Sub Dispose() Implements IDisposable.Dispose - ' Do not change this code. Put cleanup code in Dispose(disposing As Boolean) above. - Dispose(True) - GC.SuppressFinalize(Me) + Private disposedValue As Boolean = False + + ' IDisposable + Protected Overridable Sub Dispose(disposing As Boolean) + If Not Me.disposedValue Then + If disposing Then + '' TODO: dispose managed state (managed objects). + If Not DtDetalle Is Nothing Then DtDetalle.Dispose() + If Not DtAjustes Is Nothing Then DtAjustes.Dispose() + If Not DtAnticipos Is Nothing Then DtAnticipos.Dispose() + If Not DtContratosSerieDetalle Is Nothing Then DtContratosSerieDetalle.Dispose() + If Not DtCotizacionesPS Is Nothing Then DtCotizacionesPS.Dispose() + If Not DtDeduccion Is Nothing Then DtDeduccion.Dispose() + If Not DtDesgloseImpuestos Is Nothing Then DtDesgloseImpuestos.Dispose() + If Not DtDocumentacionCliente Is Nothing Then DtDocumentacionCliente.Dispose() + If Not DtDocumentosRelacionados Is Nothing Then DtDocumentosRelacionados.Dispose() + If Not DtFirmas Is Nothing Then DtFirmas.Dispose() + If Not DtImpuestosLocales Is Nothing Then DtImpuestosLocales.Dispose() + If Not DtInventario Is Nothing Then DtInventario.Dispose() + If Not DtNCVinculadas Is Nothing Then DtNCVinculadas.Dispose() + If Not DTOrdenesCompraPS Is Nothing Then DTOrdenesCompraPS.Dispose() + If Not DtOtrosConceptos Is Nothing Then DtOtrosConceptos.Dispose() + If Not DtPagos Is Nothing Then DtPagos.Dispose() + If Not DtPedidos2 Is Nothing Then DtPedidos2.Dispose() + If Not DtPedidos2PS Is Nothing Then DtPedidos2PS.Dispose() + If Not DtPromociones Is Nothing Then DtPromociones.Dispose() + If Not DtRecepcionUsados Is Nothing Then DtRecepcionUsados.Dispose() + If Not DtRemConceptosSurtidos Is Nothing Then DtRemConceptosSurtidos.Dispose() + If Not DtRemisiones Is Nothing Then DtRemisiones.Dispose() + If Not DtRemisionesPS Is Nothing Then DtRemisionesPS.Dispose() + If Not DtVentasNC Is Nothing Then DtVentasNC.Dispose() + End If + End If + Me.disposedValue = True End Sub -#End Region + ' This code added by Visual Basic to correctly implement the disposable pattern. + Public Sub Dispose() Implements IDisposable.Dispose + ' Do not change this code. Put cleanup code in Dispose(disposing As Boolean) above. + Dispose(True) + GC.SuppressFinalize(Me) + End Sub +#End Region -#Region "G L O B A L - D T" - Public Property GlobalTipoCambio(Optional Fecha As Date = MinFecha) As Double - Get - If GlobalTipoCambio <= 0 Then - 'sino tiene dato lo recargo por si ya esta insertado - If Fecha = MinFecha Then Fecha = Now - - Dim ObjGral As New ClsGenerales - If ObjGral.GetTipoCambio(-1, Fecha) AndAlso ObjGral.DtResultados.Rows.Count > 0 Then - - HttpContext.Current.Application("GlobalTipoCambio") = ObjGral.DtResultados.Rows(0)("TipoCambio").ToString.ToDouble - Else - HttpContext.Current.Application("GlobalTipoCambio") = 0 - End If - ObjGral.Dispose() - - End If - - Return HttpContext.Current.Application("GlobalTipoCambio").ToString.ToDouble - End Get - Set(value As Double) - HttpContext.Current.Application("GlobalTipoCambio") = value - End Set - - End Property - Public Property GlobalTipoCambioEuro(Optional Fecha As Date = MinFecha) As Double - Get - If GlobalTipoCambioEuro <= 0 Then - 'sino tiene dato lo recargo por si ya esta insertado - If Fecha = MinFecha Then Fecha = Now - - Dim ObjGral As New ClsGenerales - If ObjGral.GetTipoCambio(-1, Fecha) AndAlso ObjGral.DtResultados.Rows.Count > 0 Then - - HttpContext.Current.Application("GlobalTipoCambioEuro") = ObjGral.DtResultados.Rows(0)("TipoCambioEuro").ToString.ToDouble - Else - HttpContext.Current.Application("GlobalTipoCambioEuro") = 0 - End If - ObjGral.Dispose() - - End If - - Return HttpContext.Current.Application("GlobalTipoCambioEuro").ToString.ToDouble - End Get - Set(value As Double) - HttpContext.Current.Application("GlobalTipoCambioEuro") = value - End Set - - End Property - 'Property GlobalValidarCFDI As Boolean - ' Get - ' GlobalValidarCFDI = CBool(HttpContext.Current.Application("GlobalValidarCFDI")) - ' End Get - ' Set(value As Boolean) - ' HttpContext.Current.Application("GlobalValidarCFDI") = value - ' End Set - 'End Property - Property GlobalDTUsuarios(Optional CveUsuario As Integer = -1, Optional CveEmpresa As Integer = -1, Optional CveCliente As Integer = -1, Optional CveProveedor As Integer = -1) As DataTable - Get - Dim Str As New StringBuilder - If CveUsuario <> -1 Then Str.AppendFormat("CveUsuario = {0}", CveUsuario) - If CveEmpresa <> -1 Then Str.AppendFormat(" {0} CveEmpresa = {1}", If(Str.Length > 0, "AND", ""), CveEmpresa) - If CveCliente <> -1 Then Str.AppendFormat(" {0} CveCliente = {1}", If(Str.Length > 0, "AND", ""), CveCliente) - If CveProveedor <> -1 Then Str.AppendFormat(" {0} CveProveedor = {1}", If(Str.Length > 0, "AND", ""), CveProveedor) - - If CveUsuario <> -1 OrElse CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTUsuarios"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) - GlobalDTUsuarios = Dv.ToTable - Dv.Dispose() - Else - GlobalDTUsuarios = DirectCast(HttpContext.Current.Application("GlobalDTUsuarios"), DataTable) - End If - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTUsuarios") = value - End Set - End Property - Property GlobalDTNomConceptos(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTNomConceptos"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTNomConceptos = Dv.ToTable - Dv.Dispose() - Else - GlobalDTNomConceptos = DirectCast(HttpContext.Current.Application("GlobalDTNomConceptos"), DataTable) - End If - - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTNomConceptos") = value - End Set - End Property - Property GlobalDTTiposGastos(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTTiposGastos"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTTiposGastos = Dv.ToTable - Dv.Dispose() - Else - GlobalDTTiposGastos = DirectCast(HttpContext.Current.Application("GlobalDTTiposGastos"), DataTable) - End If - - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTTiposGastos") = value - End Set - End Property - Property GlobalDTMFActividad(CveEmpresa As Integer, Optional Estatus As Integer = -1, Optional CveActividad As Integer = -1) As DataTable - Get - - Dim dt As DataTable = Nothing - Dim ObjMF As New ClsMF - - If ObjMF.GetActividad(CveActividad, CveEmpresa, Estatus) Then - dt = ObjMF.DtResultados - End If - - ObjMF.Dispose() - GlobalDTMFActividad = dt - - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTActividad") = value - End Set - End Property - Property GlobalDTMFOperador(CveEmpresa As Integer, Optional Estatus As Integer = -1, Optional CveOperador As Integer = -1) As DataTable - Get - - Dim dt As DataTable = Nothing - Dim ObjMF As New ClsMF - - If ObjMF.GetOperador(CveOperador, CveEmpresa, Estatus) Then - dt = ObjMF.DtResultados - End If - - ObjMF.Dispose() - GlobalDTMFOperador = dt - - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTOperador") = value - End Set - End Property - Property GlobalDTMFEstatus(CveEmpresa As Integer, Optional Estatus As Integer = -1, Optional CveEstatus As Integer = -1) As DataTable - Get - - Dim dt As DataTable = Nothing - Dim ObjMF As New ClsMF - - If ObjMF.GetEstatus(CveEstatus, Estatus, CveEmpresa) Then - dt = ObjMF.DtResultados - End If - - ObjMF.Dispose() - GlobalDTMFEstatus = dt - - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTEstatus") = value - End Set - End Property - Property DtFacturaDefault() As DataTable - Get - DtFacturaDefault = DirectCast(HttpContext.Current.Application("DtFacturaDefault"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("DtFacturaDefault") = value - End Set - End Property - Property Directorio() As String - Get - Directorio = DirectCast(HttpContext.Current.Application("Directorio"), String) - End Get - Set(value As String) - HttpContext.Current.Application("Directorio") = value - End Set - End Property - Property GlobalDTPSATPS() As DataTable - Get - GlobalDTPSATPS = DirectCast(HttpContext.Current.Application("GlobalDTPSATPS"), EnumerableRowCollection(Of DataRow)).CopyToDataTable - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTPSATPS") = value - End Set +#Region "G L O B A L - D T" + Public Property GlobalTipoCambio(Optional Fecha As Date = MinFecha) As Double + Get + If GlobalTipoCambio <= 0 Then + 'sino tiene dato lo recargo por si ya esta insertado + If Fecha = MinFecha Then Fecha = Now + + Dim ObjGral As New ClsGenerales + If ObjGral.GetTipoCambio(-1, Fecha) AndAlso ObjGral.DtResultados.Rows.Count > 0 Then + + HttpContext.Current.Application("GlobalTipoCambio") = ObjGral.DtResultados.Rows(0)("TipoCambio").ToString.ToDouble + Else + HttpContext.Current.Application("GlobalTipoCambio") = 0 + End If + ObjGral.Dispose() + + End If + + Return HttpContext.Current.Application("GlobalTipoCambio").ToString.ToDouble + End Get + Set(value As Double) + HttpContext.Current.Application("GlobalTipoCambio") = value + End Set + + End Property + Public Property GlobalTipoCambioEuro(Optional Fecha As Date = MinFecha) As Double + Get + If GlobalTipoCambioEuro <= 0 Then + 'sino tiene dato lo recargo por si ya esta insertado + If Fecha = MinFecha Then Fecha = Now + + Dim ObjGral As New ClsGenerales + If ObjGral.GetTipoCambio(-1, Fecha) AndAlso ObjGral.DtResultados.Rows.Count > 0 Then + + HttpContext.Current.Application("GlobalTipoCambioEuro") = ObjGral.DtResultados.Rows(0)("TipoCambioEuro").ToString.ToDouble + Else + HttpContext.Current.Application("GlobalTipoCambioEuro") = 0 + End If + ObjGral.Dispose() + + End If + + Return HttpContext.Current.Application("GlobalTipoCambioEuro").ToString.ToDouble + End Get + Set(value As Double) + HttpContext.Current.Application("GlobalTipoCambioEuro") = value + End Set + + End Property + 'Property GlobalValidarCFDI As Boolean + ' Get + ' GlobalValidarCFDI = CBool(HttpContext.Current.Application("GlobalValidarCFDI")) + ' End Get + ' Set(value As Boolean) + ' HttpContext.Current.Application("GlobalValidarCFDI") = value + ' End Set + 'End Property + Property GlobalDTUsuarios(Optional CveUsuario As Integer = -1, Optional CveEmpresa As Integer = -1, Optional CveCliente As Integer = -1, Optional CveProveedor As Integer = -1) As DataTable + Get + Dim Str As New StringBuilder + If CveUsuario <> -1 Then Str.AppendFormat("CveUsuario = {0}", CveUsuario) + If CveEmpresa <> -1 Then Str.AppendFormat(" {0} CveEmpresa = {1}", If(Str.Length > 0, "AND", ""), CveEmpresa) + If CveCliente <> -1 Then Str.AppendFormat(" {0} CveCliente = {1}", If(Str.Length > 0, "AND", ""), CveCliente) + If CveProveedor <> -1 Then Str.AppendFormat(" {0} CveProveedor = {1}", If(Str.Length > 0, "AND", ""), CveProveedor) + + If CveUsuario <> -1 OrElse CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTUsuarios"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) + GlobalDTUsuarios = Dv.ToTable + Dv.Dispose() + Else + GlobalDTUsuarios = DirectCast(HttpContext.Current.Application("GlobalDTUsuarios"), DataTable) + End If + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTUsuarios") = value + End Set + End Property + Property GlobalDTNomConceptos(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTNomConceptos"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTNomConceptos = Dv.ToTable + Dv.Dispose() + Else + GlobalDTNomConceptos = DirectCast(HttpContext.Current.Application("GlobalDTNomConceptos"), DataTable) + End If + + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTNomConceptos") = value + End Set + End Property + Property GlobalDTTiposGastos(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTTiposGastos"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTTiposGastos = Dv.ToTable + Dv.Dispose() + Else + GlobalDTTiposGastos = DirectCast(HttpContext.Current.Application("GlobalDTTiposGastos"), DataTable) + End If + + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTTiposGastos") = value + End Set + End Property + Property GlobalDTMFActividad(CveEmpresa As Integer, Optional Estatus As Integer = -1, Optional CveActividad As Integer = -1) As DataTable + Get + + Dim dt As DataTable = Nothing + Dim ObjMF As New ClsMF + + If ObjMF.GetActividad(CveActividad, CveEmpresa, Estatus) Then + dt = ObjMF.DtResultados + End If + + ObjMF.Dispose() + GlobalDTMFActividad = dt + + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTActividad") = value + End Set + End Property + Property GlobalDTMFOperador(CveEmpresa As Integer, Optional Estatus As Integer = -1, Optional CveOperador As Integer = -1) As DataTable + Get + + Dim dt As DataTable = Nothing + Dim ObjMF As New ClsMF + + If ObjMF.GetOperador(CveOperador, CveEmpresa, Estatus) Then + dt = ObjMF.DtResultados + End If + + ObjMF.Dispose() + GlobalDTMFOperador = dt + + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTOperador") = value + End Set + End Property + Property GlobalDTMFEstatus(CveEmpresa As Integer, Optional Estatus As Integer = -1, Optional CveEstatus As Integer = -1) As DataTable + Get + + Dim dt As DataTable = Nothing + Dim ObjMF As New ClsMF + + If ObjMF.GetEstatus(CveEstatus, Estatus, CveEmpresa) Then + dt = ObjMF.DtResultados + End If + + ObjMF.Dispose() + GlobalDTMFEstatus = dt + + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTEstatus") = value + End Set + End Property + Property DtFacturaDefault() As DataTable + Get + DtFacturaDefault = DirectCast(HttpContext.Current.Application("DtFacturaDefault"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("DtFacturaDefault") = value + End Set + End Property + Property Directorio() As String + Get + Directorio = DirectCast(HttpContext.Current.Application("Directorio"), String) + End Get + Set(value As String) + HttpContext.Current.Application("Directorio") = value + End Set + End Property + Property GlobalDTPSATPS() As DataTable + Get + GlobalDTPSATPS = DirectCast(HttpContext.Current.Application("GlobalDTPSATPS"), EnumerableRowCollection(Of DataRow)).CopyToDataTable + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTPSATPS") = value + End Set End Property -#Region "GLOBALES DE SAT COMERCIO EXTERIOR" +#Region "GLOBALES DE SAT COMERCIO EXTERIOR" - Property GlobalDTClavePedimento() As DataTable - Get - GlobalDTClavePedimento = DirectCast(HttpContext.Current.Application("GlobalDTClavePedimento"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTClavePedimento") = value - End Set - End Property - - Property GlobalDTFraccionArancelaria() As DataTable - Get - GlobalDTFraccionArancelaria = DirectCast(HttpContext.Current.Application("GlobalDTFraccionArancelaria"), EnumerableRowCollection(Of DataRow)).CopyToDataTable - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTFraccionArancelaria") = value - End Set - End Property - - Property GlobalDTIncoterm() As DataTable - Get - GlobalDTIncoterm = DirectCast(HttpContext.Current.Application("GlobalDTIncoterm"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTIncoterm") = value - End Set - End Property - - Property GlobalDTTipoOperacion() As DataTable - Get - GlobalDTTipoOperacion = DirectCast(HttpContext.Current.Application("GlobalDTTipoOperacion"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTTipoOperacion") = value - End Set - End Property - - Property GlobalDTSATMotivoTraslado() As DataTable - Get - GlobalDTSATMotivoTraslado = DirectCast(HttpContext.Current.Application("GlobalDTSATMotivoTraslado"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTSATMotivoTraslado") = value - End Set - End Property - - Property GlobalDTUnidadAduana() As DataTable - Get - GlobalDTUnidadAduana = DirectCast(HttpContext.Current.Application("GlobalDTUnidadAduana"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTUnidadAduana") = value - End Set - End Property - - Property GlobalDTPais() As DataTable - Get - GlobalDTPais = DirectCast(HttpContext.Current.Application("GlobalDTPais"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTPais") = value - End Set - End Property - - Property GlobalDTEstado(ClaveSATPais As String) As DataTable - Get - If ClaveSATPais <> "-1" Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTEstado"), DataTable), String.Format("ClaveSATPais = '{0}'", ClaveSATPais), "", DataViewRowState.CurrentRows) - GlobalDTEstado = Dv.ToTable - Dv.Dispose() - Else - GlobalDTEstado = DirectCast(HttpContext.Current.Application("GlobalDTEstado"), DataTable) - End If - - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTEstado") = value - End Set - End Property - - Property GlobalDTMunicipio(ClaveSATEstado As String) As DataTable - Get - If ClaveSATEstado <> "-1" Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTMunicipio"), DataTable), String.Format("ClaveSATEstado = '{0}'", ClaveSATEstado), "", DataViewRowState.CurrentRows) - GlobalDTMunicipio = Dv.ToTable - Dv.Dispose() - Else - GlobalDTMunicipio = DirectCast(HttpContext.Current.Application("GlobalDTMunicipio"), DataTable) - End If - - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTMunicipio") = value - End Set - End Property - - Property GlobalDTColonia(ClaveSATMunicipio As String) As DataTable - Get - If ClaveSATMunicipio <> "-1" Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTColonia"), DataTable), String.Format("ClaveSATMunicipio = '{0}'", ClaveSATMunicipio), "", DataViewRowState.CurrentRows) - GlobalDTColonia = Dv.ToTable - Dv.Dispose() - Else - GlobalDTColonia = DirectCast(HttpContext.Current.Application("GlobalDTColonia"), DataTable) - End If - - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTColonia") = value - End Set + Property GlobalDTClavePedimento() As DataTable + Get + GlobalDTClavePedimento = DirectCast(HttpContext.Current.Application("GlobalDTClavePedimento"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTClavePedimento") = value + End Set End Property -#End Region + Property GlobalDTFraccionArancelaria() As DataTable + Get + GlobalDTFraccionArancelaria = DirectCast(HttpContext.Current.Application("GlobalDTFraccionArancelaria"), EnumerableRowCollection(Of DataRow)).CopyToDataTable + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTFraccionArancelaria") = value + End Set + End Property + + Property GlobalDTIncoterm() As DataTable + Get + GlobalDTIncoterm = DirectCast(HttpContext.Current.Application("GlobalDTIncoterm"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTIncoterm") = value + End Set + End Property + + Property GlobalDTTipoOperacion() As DataTable + Get + GlobalDTTipoOperacion = DirectCast(HttpContext.Current.Application("GlobalDTTipoOperacion"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTTipoOperacion") = value + End Set + End Property + + Property GlobalDTSATMotivoTraslado() As DataTable + Get + GlobalDTSATMotivoTraslado = DirectCast(HttpContext.Current.Application("GlobalDTSATMotivoTraslado"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTSATMotivoTraslado") = value + End Set + End Property + + Property GlobalDTUnidadAduana() As DataTable + Get + GlobalDTUnidadAduana = DirectCast(HttpContext.Current.Application("GlobalDTUnidadAduana"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTUnidadAduana") = value + End Set + End Property + + Property GlobalDTPais() As DataTable + Get + GlobalDTPais = DirectCast(HttpContext.Current.Application("GlobalDTPais"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTPais") = value + End Set + End Property + + Property GlobalDTEstado(ClaveSATPais As String) As DataTable + Get + If ClaveSATPais <> "-1" Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTEstado"), DataTable), String.Format("ClaveSATPais = '{0}'", ClaveSATPais), "", DataViewRowState.CurrentRows) + GlobalDTEstado = Dv.ToTable + Dv.Dispose() + Else + GlobalDTEstado = DirectCast(HttpContext.Current.Application("GlobalDTEstado"), DataTable) + End If + + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTEstado") = value + End Set + End Property + + Property GlobalDTMunicipio(ClaveSATEstado As String) As DataTable + Get + If ClaveSATEstado <> "-1" Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTMunicipio"), DataTable), String.Format("ClaveSATEstado = '{0}'", ClaveSATEstado), "", DataViewRowState.CurrentRows) + GlobalDTMunicipio = Dv.ToTable + Dv.Dispose() + Else + GlobalDTMunicipio = DirectCast(HttpContext.Current.Application("GlobalDTMunicipio"), DataTable) + End If + + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTMunicipio") = value + End Set + End Property + + Property GlobalDTColonia(ClaveSATMunicipio As String) As DataTable + Get + If ClaveSATMunicipio <> "-1" Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTColonia"), DataTable), String.Format("ClaveSATMunicipio = '{0}'", ClaveSATMunicipio), "", DataViewRowState.CurrentRows) + GlobalDTColonia = Dv.ToTable + Dv.Dispose() + Else + GlobalDTColonia = DirectCast(HttpContext.Current.Application("GlobalDTColonia"), DataTable) + End If + + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTColonia") = value + End Set + End Property + +#End Region + + Property GlobalDTPSATUM() As DataTable + Get + GlobalDTPSATUM = DirectCast(HttpContext.Current.Application("GlobalDTPSATUM"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTPSATUM") = value + End Set + End Property + Property GlobalDTNomConceptosFunciones() As DataTable + Get + GlobalDTNomConceptosFunciones = DirectCast(HttpContext.Current.Application("GlobalDTNomConceptosFunciones"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTNomConceptosFunciones") = value + End Set + End Property + Property GlobalDTUsuarioResponsable() As DataTable + Get + GlobalDTUsuarioResponsable = DirectCast(HttpContext.Current.Application("GlobalDTUsuarioResponsable"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTUsuarioResponsable") = value + End Set + End Property + Property GlobalDTProveedoresCuentas(CveProveedor As Integer, Estatus As Boolean) As DataTable + Get + GlobalDTProveedoresCuentas = DirectCast(HttpContext.Current.Application("GlobalDTProveedoresCuentas"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTProveedoresCuentas") = value + End Set + End Property - Property GlobalDTPSATUM() As DataTable - Get - GlobalDTPSATUM = DirectCast(HttpContext.Current.Application("GlobalDTPSATUM"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTPSATUM") = value - End Set - End Property - Property GlobalDTNomConceptosFunciones() As DataTable - Get - GlobalDTNomConceptosFunciones = DirectCast(HttpContext.Current.Application("GlobalDTNomConceptosFunciones"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTNomConceptosFunciones") = value - End Set - End Property - Property GlobalDTUsuarioResponsable() As DataTable - Get - GlobalDTUsuarioResponsable = DirectCast(HttpContext.Current.Application("GlobalDTUsuarioResponsable"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTUsuarioResponsable") = value - End Set - End Property - Property GlobalDTProveedoresCuentas(CveProveedor As Integer, Estatus As Boolean) As DataTable - Get - GlobalDTProveedoresCuentas = DirectCast(HttpContext.Current.Application("GlobalDTProveedoresCuentas"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTProveedoresCuentas") = value - End Set - End Property - Public ReadOnly Property GlobalDTProductosServiciosEquivalencias(CvePS As Integer, CveUM As Integer, CveEmpresa As Integer) As DataTable Get Dim AppNombre As String = String.Format("GlobalDTProductosServiciosEquivalencias-{0}", CveEmpresa) @@ -6190,409 +6190,409 @@ Namespace Modelos End If End Get - End Property - Property GlobalDTProveedorClasificacion(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTProveedorClasificacion"), DataTable), String.Format("CveEmpresa ={0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTProveedorClasificacion = Dv.ToTable - Dv.Dispose() - Else - GlobalDTProveedorClasificacion = DirectCast(HttpContext.Current.Application("GlobalDTProveedorClasificacion"), DataTable) - End If - - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTProveedorClasificacion") = value - End Set - End Property - Property GlobalDTProveedorSucursales(CveProveedor As Integer) As DataTable - Get - If CveProveedor <> -1 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTProveedorSucursales"), DataTable), String.Format("CveProveedor = {0}", CveProveedor), "", DataViewRowState.CurrentRows) - GlobalDTProveedorSucursales = Dv.ToTable - Dv.Dispose() - Else - GlobalDTProveedorSucursales = DirectCast(HttpContext.Current.Application("GlobalDTProveedorSucursales"), DataTable) - End If - - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTProveedorSucursales") = value - End Set - End Property - Property GlobalDTRoles(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTRoles"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTRoles = Dv.ToTable - Dv.Dispose() - Else - GlobalDTRoles = DirectCast(HttpContext.Current.Application("GlobalDTRoles"), DataTable) - End If - - End Get - Set(ByVal value As DataTable) - HttpContext.Current.Application("GlobalDTRoles") = value - End Set - End Property - Property GlobalDTNomSatBancos() As DataTable - Get - GlobalDTNomSatBancos = DirectCast(HttpContext.Current.Application("GlobalDTNomSatBancos"), DataTable) - End Get - Set(ByVal value As DataTable) - HttpContext.Current.Application("GlobalDTNomSatBancos") = value - End Set - End Property - Property GlobalDTNomSatConceptos() As DataTable - Get - GlobalDTNomSatConceptos = DirectCast(HttpContext.Current.Application("GlobalDTNomSatConceptos"), DataTable) - End Get - Set(ByVal value As DataTable) - HttpContext.Current.Application("GlobalDTNomSatConceptos") = value - End Set - End Property - Property GlobalDTNomSatRegimenContratacion() As DataTable - Get - GlobalDTNomSatRegimenContratacion = DirectCast(HttpContext.Current.Application("GlobalDTNomSatRegimenContratacion"), DataTable) - End Get - Set(ByVal value As DataTable) - HttpContext.Current.Application("GlobalDTNomSatRegimenContratacion") = value - End Set - End Property - Property GlobalDTNomSatRiesgoPuesto() As DataTable - Get - GlobalDTNomSatRiesgoPuesto = DirectCast(HttpContext.Current.Application("GlobalDTNomSatRiesgoPuesto"), DataTable) - End Get - Set(ByVal value As DataTable) - HttpContext.Current.Application("GlobalDTNomSatRiesgoPuesto") = value - End Set - End Property - Property GlobalDTNomSatTipoIncapacidad() As DataTable - Get - GlobalDTNomSatTipoIncapacidad = DirectCast(HttpContext.Current.Application("GlobalDTNomSatTipoIncapacidad"), DataTable) - End Get - Set(ByVal value As DataTable) - HttpContext.Current.Application("GlobalDTNomSatTipoIncapacidad") = value - End Set - End Property - Property GlobalDTEmpresas(Optional CveEmpresa As Integer = -1) As DataTable - Get - - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTEmpresas"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTEmpresas = Dv.ToTable - Dv.Dispose() - Else - GlobalDTEmpresas = DirectCast(HttpContext.Current.Application("GlobalDTEmpresas"), DataTable) - End If - End Get - Set(ByVal value As DataTable) - HttpContext.Current.Application("GlobalDTEmpresas") = value - End Set - End Property - Property GlobalDTClasificaciones(Optional CveEmpresa As Integer = -1, Optional CveCategoria As Integer = -1, Optional UsoClasificacion As Integer = -1) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Str As New StringBuilder - Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) - If CveCategoria <> -1 Then Str.AppendFormat(" AND CveCategoria = {0}", CveCategoria) - If UsoClasificacion <> -1 Then Str.AppendFormat(" AND UsoClasificacion IN ({0},3) ", UsoClasificacion) - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTClasificaciones"), DataTable), Str.ToString(), "", DataViewRowState.CurrentRows) - GlobalDTClasificaciones = Dv.ToTable - Dv.Dispose() - Else - GlobalDTClasificaciones = DirectCast(HttpContext.Current.Application("GlobalDTClasificaciones"), DataTable) - End If - - - - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTClasificaciones") = value - End Set - End Property - Property GlobalDTClasificaciones2(Optional CveEmpresa As Integer = -1, Optional CveCategoria As Integer = -1) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Str As New StringBuilder - Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) - If CveCategoria <> -1 Then Str.AppendFormat(" AND CveCategoria = {0}", CveCategoria) - - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTClasificaciones2"), DataTable), Str.ToString(), "", DataViewRowState.CurrentRows) - GlobalDTClasificaciones2 = Dv.ToTable - Dv.Dispose() - Else - GlobalDTClasificaciones2 = DirectCast(HttpContext.Current.Application("GlobalDTClasificaciones2"), DataTable) - End If - - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTClasificaciones2") = value - End Set - End Property - Property GlobalDTClasificacionesSubProyectos(Optional CveClasificacion As Integer = -1, Optional CveEmpresa As Integer = -1) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Str As New StringBuilder - Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) - - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTClasificacionesSubProyecto"), DataTable), Str.ToString(), "", DataViewRowState.CurrentRows) - GlobalDTClasificacionesSubProyectos = Dv.ToTable - Dv.Dispose() - Else - GlobalDTClasificacionesSubProyectos = DirectCast(HttpContext.Current.Application("GlobalDTClasificacionesSubProyecto"), DataTable) - End If - - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTClasificacionesSubProyecto") = value - End Set - End Property - Property GlobalDTACClasificadorObjetoGasto(Optional CveEmpresa As Integer = -1, Optional CveCategoria As Integer = -1) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Str As New StringBuilder - Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) - If CveCategoria <> -1 Then Str.AppendFormat(" AND CveCategoria = {0}", CveCategoria) - - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTACClasificadorObjetoGasto"), DataTable), Str.ToString(), "", DataViewRowState.CurrentRows) - GlobalDTACClasificadorObjetoGasto = Dv.ToTable - Dv.Dispose() - Else - GlobalDTACClasificadorObjetoGasto = DirectCast(HttpContext.Current.Application("GlobalDTACClasificadorObjetoGasto"), DataTable) - End If - - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTACClasificadorObjetoGasto") = value - End Set - End Property - Property GlobalDTClasificacionesDetalle(Optional CveEmpresa As Integer = -1, Optional CveClasificacion As Integer = -1) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Str As New StringBuilder - Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) - If CveClasificacion <> -1 Then Str.AppendFormat(" AND CveClasificacion = {0}", CveClasificacion) - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTClasificacionesDetalle"), DataTable), Str.ToString(), "", DataViewRowState.CurrentRows) - GlobalDTClasificacionesDetalle = Dv.ToTable - Dv.Dispose() - Else - GlobalDTClasificacionesDetalle = DirectCast(HttpContext.Current.Application("GlobalDTClasificacionesDetalle"), DataTable) - End If - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTClasificacionesDetalle") = value - End Set - End Property - Property GlobalDTSubFamilias(Optional CveEmpresa As Integer = -1, Optional CveCategoria As Integer = -1) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Str As New StringBuilder - Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) - If CveCategoria <> -1 Then Str.AppendFormat(" AND CveCategoria = {0}", CveCategoria) - - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTSubFamilias"), DataTable), Str.ToString(), "", DataViewRowState.CurrentRows) - GlobalDTSubFamilias = Dv.ToTable - Dv.Dispose() - - Else - GlobalDTSubFamilias = DirectCast(HttpContext.Current.Application("GlobalDTSubFamilias"), DataTable) - End If - - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTSubFamilias") = value - End Set - End Property - Property GlobalDTFamilias(Optional CveEmpresa As Integer = -1) As DataTable - Get - If CveEmpresa <> -1 Then - - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTFamilias"), DataTable), String.Format("CveEmpresa = {0} ", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTFamilias = Dv.ToTable - Dv.Dispose() - Else - GlobalDTFamilias = DirectCast(HttpContext.Current.Application("GlobalDTFamilias"), DataTable) - End If - - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTFamilias") = value - End Set - End Property - Property GlobalDTClasificacionesPresupuestos(Optional CveEmpresa As Integer = -1) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTClasificacionesPresupuestos"), DataTable), String.Format("CveEmpresa = {0} ", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTClasificacionesPresupuestos = Dv.ToTable - Dv.Dispose() - Else - GlobalDTClasificacionesPresupuestos = DirectCast(HttpContext.Current.Application("GlobalDTClasificacionesPresupuestos"), DataTable) - End If - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTClasificacionesPresupuestos") = value - End Set - End Property - Property GlobalDTMetodosPago() As DataTable - Get - GlobalDTMetodosPago = DirectCast(HttpContext.Current.Application("GlobalDTMetodosPago"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTMetodosPago") = value - End Set - End Property - Property GlobalDTModulos() As DataTable - Get - GlobalDTModulos = DirectCast(HttpContext.Current.Application("GlobalDTModulos"), DataTable) - End Get - Set(ByVal value As DataTable) - HttpContext.Current.Application("GlobalDTModulos") = value - End Set - End Property - Property GlobalDTMonedas() As DataTable - Get - GlobalDTMonedas = DirectCast(HttpContext.Current.Application("GlobalDTMonedas"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTMonedas") = value - End Set - End Property - Property GlobalDTMonedasAlias() As DataTable - Get - GlobalDTMonedasAlias = DirectCast(HttpContext.Current.Application("GlobalDTMonedasAlias"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTMonedasAlias") = value - End Set - End Property - Property GlobalDTSucursales(Optional CveEmpresa As Integer = -1) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTSucursales"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), " Sucursal", DataViewRowState.CurrentRows) - GlobalDTSucursales = Dv.ToTable - Dv.Dispose() - Else - GlobalDTSucursales = DirectCast(HttpContext.Current.Application("GlobalDTSucursales"), DataTable) - End If - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTSucursales") = value - End Set - End Property - Property GlobalDTSATUsosCFDI(Optional EsPersonaFisica As Integer = -1) As DataTable - Get - If EsPersonaFisica <> -1 Then - Dim Tipo As String = "" - If EsPersonaFisica = 1 Then Tipo = "AplicaPersonaFisica = 1" Else Tipo = "AplicaPersonaMoral = 1" - - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTSATUsosCFDI"), DataTable), Tipo, " UsoCFDIDescripcion", DataViewRowState.CurrentRows) - GlobalDTSATUsosCFDI = Dv.ToTable - Dv.Dispose() - Else - GlobalDTSATUsosCFDI = DirectCast(HttpContext.Current.Application("GlobalDTSATUsosCFDI"), DataTable) - End If - - End Get - Set(ByVal value As DataTable) - HttpContext.Current.Application("GlobalDTSATUsosCFDI") = value - End Set - End Property - 'Property GlobalDTUnidadesMedida(Optional CveEmpresa As Integer = -1) As DataTable - ' Get - ' If CveEmpresa <> -1 Then - ' Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTUnidadesMedida"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), " UnidadMedida", DataViewRowState.CurrentRows) - ' GlobalDTUnidadesMedida = Dv.ToTable - ' Dv.Dispose() - ' Else - ' GlobalDTUnidadesMedida = DirectCast(HttpContext.Current.Application("GlobalDTUnidadesMedida"), DataTable) - ' End If - ' End Get - ' Set(value As DataTable) - ' HttpContext.Current.Application("GlobalDTUnidadesMedida") = value - ' End Set - 'End Property - 'Property GlobalDTUnidadesMedidaAlias(Optional CveEmpresa As Integer = -1) As DataTable - ' Get - ' If CveEmpresa <> -1 Then - ' Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTUnidadesMedidaAlias"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - ' GlobalDTUnidadesMedidaAlias = Dv.ToTable - ' Dv.Dispose() - ' Else - ' GlobalDTUnidadesMedidaAlias = DirectCast(HttpContext.Current.Application("GlobalDTUnidadesMedidaAlias"), DataTable) - ' End If - ' End Get - ' Set(value As DataTable) - ' HttpContext.Current.Application("GlobalDTUnidadesMedidaAlias") = value - ' End Set - 'End Property - Property GlobalDTEstatusOrdenCompra() As DataTable - Get - GlobalDTEstatusOrdenCompra = DirectCast(HttpContext.Current.Application("GlobalDTEstatusOrdenCompra"), DataTable) - End Get - Set(ByVal value As DataTable) - HttpContext.Current.Application("GlobalDTEstatusOrdenCompra") = value - End Set - End Property - Property GlobalDTLeyendasFiscales() As DataTable - Get - GlobalDTLeyendasFiscales = DirectCast(HttpContext.Current.Application("GlobalDTLeyendasFiscales"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTLeyendasFiscales") = value - End Set - End Property - Property GlobalDTFolios() As DataTable - Get - GlobalDTFolios = DirectCast(HttpContext.Current.Application("GlobalDTFolios"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTFolios") = value - End Set - End Property - Property GlobalDTEstatusFactura() As DataTable - Get - GlobalDTEstatusFactura = DirectCast(HttpContext.Current.Application("GlobalDTEstatusFactura"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTEstatusFactura") = value - End Set - End Property - Property GlobalDTProyectos(CveEmpresa As Integer, Optional Estatus As Integer = -1) As DataTable - Get - - If DirectCast(HttpContext.Current.Application("GlobalDTProyectos"), DataTable) Is Nothing Or (DirectCast(HttpContext.Current.Application("GlobalDTProyectos"), DataTable) IsNot Nothing AndAlso DirectCast(HttpContext.Current.Application("GlobalDTProyectos"), DataTable).Rows.Count = 0) Then - Dim P As New ClsProyectos - If P.GetProyectos Then - HttpContext.Current.Application("GlobalDTProyectos") = P.DtResultados - End If - P.Dispose() - - End If - - If CveEmpresa <> -1 OrElse Estatus <> -1 Then 'OrElse CveProyecto <> -1 - - Dim StrSQL As New StringBuilder - If CveEmpresa <> -1 Then StrSQL.AppendFormat("CveEmpresa = {0}", CveEmpresa) - ' If CveProyecto <> -1 Then StrSQL.AppendFormat(" {0} CveProyecto = {1}", If(StrSQL.Length > 0, "AND", ""), CveProyecto) - If Estatus <> -1 Then StrSQL.AppendFormat(" {0} CveEstatus = {1}", If(StrSQL.Length > 0, "AND", ""), Estatus) - - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTProyectos"), DataTable), StrSQL.ToString, "", DataViewRowState.CurrentRows) - GlobalDTProyectos = Dv.ToTable - Dv.Dispose() - - Else - GlobalDTProyectos = DirectCast(HttpContext.Current.Application("GlobalDTProyectos"), DataTable) - End If - - End Get - Set(ByVal value As DataTable) - If value Is Nothing OrElse value.Rows.Count = 0 Then - - End If - HttpContext.Current.Application("GlobalDTProyectos") = value - End Set + End Property + Property GlobalDTProveedorClasificacion(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTProveedorClasificacion"), DataTable), String.Format("CveEmpresa ={0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTProveedorClasificacion = Dv.ToTable + Dv.Dispose() + Else + GlobalDTProveedorClasificacion = DirectCast(HttpContext.Current.Application("GlobalDTProveedorClasificacion"), DataTable) + End If + + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTProveedorClasificacion") = value + End Set + End Property + Property GlobalDTProveedorSucursales(CveProveedor As Integer) As DataTable + Get + If CveProveedor <> -1 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTProveedorSucursales"), DataTable), String.Format("CveProveedor = {0}", CveProveedor), "", DataViewRowState.CurrentRows) + GlobalDTProveedorSucursales = Dv.ToTable + Dv.Dispose() + Else + GlobalDTProveedorSucursales = DirectCast(HttpContext.Current.Application("GlobalDTProveedorSucursales"), DataTable) + End If + + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTProveedorSucursales") = value + End Set + End Property + Property GlobalDTRoles(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTRoles"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTRoles = Dv.ToTable + Dv.Dispose() + Else + GlobalDTRoles = DirectCast(HttpContext.Current.Application("GlobalDTRoles"), DataTable) + End If + + End Get + Set(ByVal value As DataTable) + HttpContext.Current.Application("GlobalDTRoles") = value + End Set + End Property + Property GlobalDTNomSatBancos() As DataTable + Get + GlobalDTNomSatBancos = DirectCast(HttpContext.Current.Application("GlobalDTNomSatBancos"), DataTable) + End Get + Set(ByVal value As DataTable) + HttpContext.Current.Application("GlobalDTNomSatBancos") = value + End Set + End Property + Property GlobalDTNomSatConceptos() As DataTable + Get + GlobalDTNomSatConceptos = DirectCast(HttpContext.Current.Application("GlobalDTNomSatConceptos"), DataTable) + End Get + Set(ByVal value As DataTable) + HttpContext.Current.Application("GlobalDTNomSatConceptos") = value + End Set + End Property + Property GlobalDTNomSatRegimenContratacion() As DataTable + Get + GlobalDTNomSatRegimenContratacion = DirectCast(HttpContext.Current.Application("GlobalDTNomSatRegimenContratacion"), DataTable) + End Get + Set(ByVal value As DataTable) + HttpContext.Current.Application("GlobalDTNomSatRegimenContratacion") = value + End Set + End Property + Property GlobalDTNomSatRiesgoPuesto() As DataTable + Get + GlobalDTNomSatRiesgoPuesto = DirectCast(HttpContext.Current.Application("GlobalDTNomSatRiesgoPuesto"), DataTable) + End Get + Set(ByVal value As DataTable) + HttpContext.Current.Application("GlobalDTNomSatRiesgoPuesto") = value + End Set + End Property + Property GlobalDTNomSatTipoIncapacidad() As DataTable + Get + GlobalDTNomSatTipoIncapacidad = DirectCast(HttpContext.Current.Application("GlobalDTNomSatTipoIncapacidad"), DataTable) + End Get + Set(ByVal value As DataTable) + HttpContext.Current.Application("GlobalDTNomSatTipoIncapacidad") = value + End Set + End Property + Property GlobalDTEmpresas(Optional CveEmpresa As Integer = -1) As DataTable + Get + + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTEmpresas"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTEmpresas = Dv.ToTable + Dv.Dispose() + Else + GlobalDTEmpresas = DirectCast(HttpContext.Current.Application("GlobalDTEmpresas"), DataTable) + End If + End Get + Set(ByVal value As DataTable) + HttpContext.Current.Application("GlobalDTEmpresas") = value + End Set + End Property + Property GlobalDTClasificaciones(Optional CveEmpresa As Integer = -1, Optional CveCategoria As Integer = -1, Optional UsoClasificacion As Integer = -1) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Str As New StringBuilder + Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) + If CveCategoria <> -1 Then Str.AppendFormat(" AND CveCategoria = {0}", CveCategoria) + If UsoClasificacion <> -1 Then Str.AppendFormat(" AND UsoClasificacion IN ({0},3) ", UsoClasificacion) + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTClasificaciones"), DataTable), Str.ToString(), "", DataViewRowState.CurrentRows) + GlobalDTClasificaciones = Dv.ToTable + Dv.Dispose() + Else + GlobalDTClasificaciones = DirectCast(HttpContext.Current.Application("GlobalDTClasificaciones"), DataTable) + End If + + + + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTClasificaciones") = value + End Set + End Property + Property GlobalDTClasificaciones2(Optional CveEmpresa As Integer = -1, Optional CveCategoria As Integer = -1) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Str As New StringBuilder + Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) + If CveCategoria <> -1 Then Str.AppendFormat(" AND CveCategoria = {0}", CveCategoria) + + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTClasificaciones2"), DataTable), Str.ToString(), "", DataViewRowState.CurrentRows) + GlobalDTClasificaciones2 = Dv.ToTable + Dv.Dispose() + Else + GlobalDTClasificaciones2 = DirectCast(HttpContext.Current.Application("GlobalDTClasificaciones2"), DataTable) + End If + + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTClasificaciones2") = value + End Set + End Property + Property GlobalDTClasificacionesSubProyectos(Optional CveClasificacion As Integer = -1, Optional CveEmpresa As Integer = -1) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Str As New StringBuilder + Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) + + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTClasificacionesSubProyecto"), DataTable), Str.ToString(), "", DataViewRowState.CurrentRows) + GlobalDTClasificacionesSubProyectos = Dv.ToTable + Dv.Dispose() + Else + GlobalDTClasificacionesSubProyectos = DirectCast(HttpContext.Current.Application("GlobalDTClasificacionesSubProyecto"), DataTable) + End If + + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTClasificacionesSubProyecto") = value + End Set + End Property + Property GlobalDTACClasificadorObjetoGasto(Optional CveEmpresa As Integer = -1, Optional CveCategoria As Integer = -1) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Str As New StringBuilder + Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) + If CveCategoria <> -1 Then Str.AppendFormat(" AND CveCategoria = {0}", CveCategoria) + + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTACClasificadorObjetoGasto"), DataTable), Str.ToString(), "", DataViewRowState.CurrentRows) + GlobalDTACClasificadorObjetoGasto = Dv.ToTable + Dv.Dispose() + Else + GlobalDTACClasificadorObjetoGasto = DirectCast(HttpContext.Current.Application("GlobalDTACClasificadorObjetoGasto"), DataTable) + End If + + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTACClasificadorObjetoGasto") = value + End Set + End Property + Property GlobalDTClasificacionesDetalle(Optional CveEmpresa As Integer = -1, Optional CveClasificacion As Integer = -1) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Str As New StringBuilder + Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) + If CveClasificacion <> -1 Then Str.AppendFormat(" AND CveClasificacion = {0}", CveClasificacion) + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTClasificacionesDetalle"), DataTable), Str.ToString(), "", DataViewRowState.CurrentRows) + GlobalDTClasificacionesDetalle = Dv.ToTable + Dv.Dispose() + Else + GlobalDTClasificacionesDetalle = DirectCast(HttpContext.Current.Application("GlobalDTClasificacionesDetalle"), DataTable) + End If + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTClasificacionesDetalle") = value + End Set + End Property + Property GlobalDTSubFamilias(Optional CveEmpresa As Integer = -1, Optional CveCategoria As Integer = -1) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Str As New StringBuilder + Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) + If CveCategoria <> -1 Then Str.AppendFormat(" AND CveCategoria = {0}", CveCategoria) + + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTSubFamilias"), DataTable), Str.ToString(), "", DataViewRowState.CurrentRows) + GlobalDTSubFamilias = Dv.ToTable + Dv.Dispose() + + Else + GlobalDTSubFamilias = DirectCast(HttpContext.Current.Application("GlobalDTSubFamilias"), DataTable) + End If + + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTSubFamilias") = value + End Set + End Property + Property GlobalDTFamilias(Optional CveEmpresa As Integer = -1) As DataTable + Get + If CveEmpresa <> -1 Then + + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTFamilias"), DataTable), String.Format("CveEmpresa = {0} ", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTFamilias = Dv.ToTable + Dv.Dispose() + Else + GlobalDTFamilias = DirectCast(HttpContext.Current.Application("GlobalDTFamilias"), DataTable) + End If + + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTFamilias") = value + End Set + End Property + Property GlobalDTClasificacionesPresupuestos(Optional CveEmpresa As Integer = -1) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTClasificacionesPresupuestos"), DataTable), String.Format("CveEmpresa = {0} ", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTClasificacionesPresupuestos = Dv.ToTable + Dv.Dispose() + Else + GlobalDTClasificacionesPresupuestos = DirectCast(HttpContext.Current.Application("GlobalDTClasificacionesPresupuestos"), DataTable) + End If + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTClasificacionesPresupuestos") = value + End Set + End Property + Property GlobalDTMetodosPago() As DataTable + Get + GlobalDTMetodosPago = DirectCast(HttpContext.Current.Application("GlobalDTMetodosPago"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTMetodosPago") = value + End Set + End Property + Property GlobalDTModulos() As DataTable + Get + GlobalDTModulos = DirectCast(HttpContext.Current.Application("GlobalDTModulos"), DataTable) + End Get + Set(ByVal value As DataTable) + HttpContext.Current.Application("GlobalDTModulos") = value + End Set + End Property + Property GlobalDTMonedas() As DataTable + Get + GlobalDTMonedas = DirectCast(HttpContext.Current.Application("GlobalDTMonedas"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTMonedas") = value + End Set + End Property + Property GlobalDTMonedasAlias() As DataTable + Get + GlobalDTMonedasAlias = DirectCast(HttpContext.Current.Application("GlobalDTMonedasAlias"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTMonedasAlias") = value + End Set + End Property + Property GlobalDTSucursales(Optional CveEmpresa As Integer = -1) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTSucursales"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), " Sucursal", DataViewRowState.CurrentRows) + GlobalDTSucursales = Dv.ToTable + Dv.Dispose() + Else + GlobalDTSucursales = DirectCast(HttpContext.Current.Application("GlobalDTSucursales"), DataTable) + End If + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTSucursales") = value + End Set + End Property + Property GlobalDTSATUsosCFDI(Optional EsPersonaFisica As Integer = -1) As DataTable + Get + If EsPersonaFisica <> -1 Then + Dim Tipo As String = "" + If EsPersonaFisica = 1 Then Tipo = "AplicaPersonaFisica = 1" Else Tipo = "AplicaPersonaMoral = 1" + + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTSATUsosCFDI"), DataTable), Tipo, " UsoCFDIDescripcion", DataViewRowState.CurrentRows) + GlobalDTSATUsosCFDI = Dv.ToTable + Dv.Dispose() + Else + GlobalDTSATUsosCFDI = DirectCast(HttpContext.Current.Application("GlobalDTSATUsosCFDI"), DataTable) + End If + + End Get + Set(ByVal value As DataTable) + HttpContext.Current.Application("GlobalDTSATUsosCFDI") = value + End Set + End Property + 'Property GlobalDTUnidadesMedida(Optional CveEmpresa As Integer = -1) As DataTable + ' Get + ' If CveEmpresa <> -1 Then + ' Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTUnidadesMedida"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), " UnidadMedida", DataViewRowState.CurrentRows) + ' GlobalDTUnidadesMedida = Dv.ToTable + ' Dv.Dispose() + ' Else + ' GlobalDTUnidadesMedida = DirectCast(HttpContext.Current.Application("GlobalDTUnidadesMedida"), DataTable) + ' End If + ' End Get + ' Set(value As DataTable) + ' HttpContext.Current.Application("GlobalDTUnidadesMedida") = value + ' End Set + 'End Property + 'Property GlobalDTUnidadesMedidaAlias(Optional CveEmpresa As Integer = -1) As DataTable + ' Get + ' If CveEmpresa <> -1 Then + ' Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTUnidadesMedidaAlias"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + ' GlobalDTUnidadesMedidaAlias = Dv.ToTable + ' Dv.Dispose() + ' Else + ' GlobalDTUnidadesMedidaAlias = DirectCast(HttpContext.Current.Application("GlobalDTUnidadesMedidaAlias"), DataTable) + ' End If + ' End Get + ' Set(value As DataTable) + ' HttpContext.Current.Application("GlobalDTUnidadesMedidaAlias") = value + ' End Set + 'End Property + Property GlobalDTEstatusOrdenCompra() As DataTable + Get + GlobalDTEstatusOrdenCompra = DirectCast(HttpContext.Current.Application("GlobalDTEstatusOrdenCompra"), DataTable) + End Get + Set(ByVal value As DataTable) + HttpContext.Current.Application("GlobalDTEstatusOrdenCompra") = value + End Set + End Property + Property GlobalDTLeyendasFiscales() As DataTable + Get + GlobalDTLeyendasFiscales = DirectCast(HttpContext.Current.Application("GlobalDTLeyendasFiscales"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTLeyendasFiscales") = value + End Set + End Property + Property GlobalDTFolios() As DataTable + Get + GlobalDTFolios = DirectCast(HttpContext.Current.Application("GlobalDTFolios"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTFolios") = value + End Set + End Property + Property GlobalDTEstatusFactura() As DataTable + Get + GlobalDTEstatusFactura = DirectCast(HttpContext.Current.Application("GlobalDTEstatusFactura"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTEstatusFactura") = value + End Set + End Property + Property GlobalDTProyectos(CveEmpresa As Integer, Optional Estatus As Integer = -1) As DataTable + Get + + If DirectCast(HttpContext.Current.Application("GlobalDTProyectos"), DataTable) Is Nothing Or (DirectCast(HttpContext.Current.Application("GlobalDTProyectos"), DataTable) IsNot Nothing AndAlso DirectCast(HttpContext.Current.Application("GlobalDTProyectos"), DataTable).Rows.Count = 0) Then + Dim P As New ClsProyectos + If P.GetProyectos Then + HttpContext.Current.Application("GlobalDTProyectos") = P.DtResultados + End If + P.Dispose() + + End If + + If CveEmpresa <> -1 OrElse Estatus <> -1 Then 'OrElse CveProyecto <> -1 + + Dim StrSQL As New StringBuilder + If CveEmpresa <> -1 Then StrSQL.AppendFormat("CveEmpresa = {0}", CveEmpresa) + ' If CveProyecto <> -1 Then StrSQL.AppendFormat(" {0} CveProyecto = {1}", If(StrSQL.Length > 0, "AND", ""), CveProyecto) + If Estatus <> -1 Then StrSQL.AppendFormat(" {0} CveEstatus = {1}", If(StrSQL.Length > 0, "AND", ""), Estatus) + + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTProyectos"), DataTable), StrSQL.ToString, "", DataViewRowState.CurrentRows) + GlobalDTProyectos = Dv.ToTable + Dv.Dispose() + + Else + GlobalDTProyectos = DirectCast(HttpContext.Current.Application("GlobalDTProyectos"), DataTable) + End If + + End Get + Set(ByVal value As DataTable) + If value Is Nothing OrElse value.Rows.Count = 0 Then + + End If + HttpContext.Current.Application("GlobalDTProyectos") = value + End Set End Property Public Property GlobalDTSubProyectos(CveProyecto As Integer, Optional CveSubProyecto As Integer = -1, Optional CveEmpresa As Integer = -1, Optional Estatus As Integer = 1) As DataTable @@ -6634,363 +6634,363 @@ Namespace Modelos End Set End Property - Property GlobalDTSubProyectosUsuarios(CveUsuario As Integer, CveProyecto As Integer, CveEmpresa As Integer, Optional CveSubProyecto As Integer = -1, Optional CveEstatus As Integer = -1) As DataTable - Get - - If HttpContext.Current.Application("GlobalDTSubProyectosUsuarios") Is Nothing Then - Dim ObjSubProyectos As New ClsSubProyectos() - If ObjSubProyectos.GetSubProyectosUsuarios Then HttpContext.Current.Application("GlobalDTSubProyectosUsuarios") = ObjSubProyectos.DtResultados Else Alert("Ocurrió un error al cargar los SubProyectos. Por favor comuniquese con sistemas.", TipoMensaje.MsgError) - ObjSubProyectos.Dispose() - End If - - If CveUsuario <> -1 OrElse CveProyecto <> -1 OrElse CveSubProyecto <> -1 OrElse CveEmpresa <> -1 OrElse CveEstatus <> -1 Then - Dim StrSQL As New StringBuilder - If CveProyecto <> -1 Then StrSQL.AppendFormat(" AND CveProyecto = {0}", CveProyecto) - If CveSubProyecto <> -1 Then StrSQL.AppendFormat(" AND CveSubProyecto = {0}", CveSubProyecto) - If CveEmpresa <> -1 Then StrSQL.AppendFormat(" AND CveEmpresa = {0}", CveEmpresa) - If CveUsuario <> -1 Then StrSQL.AppendFormat(" AND CveUsuario = {0}", CveUsuario) - If CveEstatus <> -1 Then StrSQL.AppendFormat(" AND CveEstatus = {0}", CveEstatus) - - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTSubProyectosUsuarios"), DataTable), StrSQL.ToString.Trim.TrimStart("A"c, "N"c, "D"c), "", DataViewRowState.CurrentRows) - GlobalDTSubProyectosUsuarios = Dv.ToTable - Dv.Dispose() - - Dim ObjSubProyectos As New ClsSubProyectos() - If ObjSubProyectos.GetSubProyectosUsuarios(CveUsuario:=CveUsuario, CveProyecto:=CveProyecto, CveSubProyecto:=CveSubProyecto, CveEstatus:=CveEstatus, CveEmpresa:=CveEmpresa) Then - GlobalDTSubProyectosUsuarios = ObjSubProyectos.DtResultados - Else - GlobalDTSubProyectosUsuarios = Nothing - End If - ObjSubProyectos.Dispose() - - Else - GlobalDTSubProyectosUsuarios = DirectCast(HttpContext.Current.Application("GlobalDTSubProyectosUsuarios"), DataTable) - End If - - End Get - Set(ByVal value As DataTable) - If value Is Nothing OrElse value.Rows.Count = 0 Then - - - End If - HttpContext.Current.Application("GlobalDTSubProyectosUsuarios") = value - End Set - End Property - Property GlobalDTProyectosUsuarios(CveUsuario As Integer, CveProyecto As Integer, CveEmpresa As Integer, CveEstatus As Integer) As DataTable - Get - - If HttpContext.Current.Application("GlobalDTProyectosUsuarios") Is Nothing AndAlso DirectCast(HttpContext.Current.Application("GlobalDTProyectosUsuarios"), DataTable).Rows.Count = 0 Then - Dim ObjSubProyectos As New ClsSubProyectos() - If ObjSubProyectos.GetSubProyectosUsuarios Then HttpContext.Current.Application("GlobalDTProyectosUsuarios") = ObjSubProyectos.DtResultados.FiltraParametros("", "", {"Proyecto", "CveProyecto", "CveUsuario", "CveEmpresa", "CveEstatusProyecto"}) Else Alert("Ocurrió un error al cargar los Proyectos. Por favor comuniquese con sistemas.", TipoMensaje.MsgError) - ObjSubProyectos.Dispose() - GuardaLog("Se Cargo GlobalDTProyectosUsuarios") - End If - - If CveUsuario <> -1 OrElse CveProyecto <> -1 OrElse CveEmpresa <> -1 OrElse CveEstatus <> -1 Then - Dim StrSQL As New StringBuilder - If CveProyecto <> -1 Then StrSQL.AppendFormat(" AND CveProyecto = {0}", CveProyecto) - If CveEmpresa <> -1 Then StrSQL.AppendFormat(" AND CveEmpresa = {0}", CveEmpresa) - If CveUsuario <> -1 Then StrSQL.AppendFormat(" AND CveUsuario = {0}", CveUsuario) - If CveEstatus <> -1 Then StrSQL.AppendFormat(" AND CveEstatusProyecto = {0}", CveEstatus) - - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTProyectosUsuarios"), DataTable), StrSQL.ToString.Trim.TrimStart("A"c, "N"c, "D"c), "", DataViewRowState.CurrentRows) - GlobalDTProyectosUsuarios = Dv.ToTable - Dv.Dispose() - - Else - GlobalDTProyectosUsuarios = DirectCast(HttpContext.Current.Application("GlobalDTProyectosUsuarios"), DataTable) - End If - - End Get - Set(ByVal value As DataTable) - If value Is Nothing OrElse value.Rows.Count = 0 Then - - End If - HttpContext.Current.Application("GlobalDTProyectosUsuarios") = value - End Set - End Property - Property GlobalDTPrecioListas(CveEmpresa As Integer) As DataTable - Get - GlobalDTPrecioListas = DirectCast(HttpContext.Current.Application("GlobalDTPrecioListas"), DataTable).FiltraParametros(String.Format("CveEmpresa = {0}", CveEmpresa)) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTPrecioListas") = value - End Set - End Property - Property GlobalDTMesas() As DataTable - Get - GlobalDTMesas = DirectCast(HttpContext.Current.Application("GlobalDTMesas"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTMesas") = value - End Set - End Property - Property GlobalDTTipoOrdenServicios(CveEmpresa As Integer) As DataTable - Get - GlobalDTTipoOrdenServicios = DirectCast(HttpContext.Current.Application("GlobalDTTipoOrdenServicios"), DataTable).FiltraParametros(String.Format("CveEmpresa = {0}", CveEmpresa)) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTTipoOrdenServicios") = value - End Set - End Property - Property GlobalDTSubTipoOrdenServicios() As DataTable - Get - GlobalDTSubTipoOrdenServicios = DirectCast(HttpContext.Current.Application("GlobalDTSubTipoOrdenServicios"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTSubTipoOrdenServicios") = value - End Set - End Property - Property GlobalDTCaracteristicasOrdenServicios() As DataTable - Get - GlobalDTCaracteristicasOrdenServicios = DirectCast(HttpContext.Current.Application("GlobalDTCaracteristicasOrdenServicios"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTCaracteristicasOrdenServicios") = value - End Set - End Property - Property GlobalDTOrdenesServiciosCaracteristicas() As DataTable - Get - GlobalDTOrdenesServiciosCaracteristicas = DirectCast(HttpContext.Current.Application("GlobalDTOrdenesServiciosCaracteristicas"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTOrdenesServiciosCaracteristicas") = value - End Set - End Property - Property GlobalDTCaracteristicasOpciones() As DataTable - Get - GlobalDTCaracteristicasOpciones = DirectCast(HttpContext.Current.Application("GlobalDTCaracteristicasOpciones"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTCaracteristicasOpciones") = value - End Set - End Property - Property GlobalDTTipoCuentasEquipos(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTTipoCuentasEquipos"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTTipoCuentasEquipos = Dv.ToTable - Dv.Dispose() - Else - GlobalDTTipoCuentasEquipos = DirectCast(HttpContext.Current.Application("GlobalDTTipoCuentasEquipos"), DataTable) - End If - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTTipoCuentasEquipos") = value - End Set - End Property - Property GlobalDTTipoCuentasEquiposCaracteristicas(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTTipoCuentasEquiposCaracteristicas"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTTipoCuentasEquiposCaracteristicas = Dv.ToTable - Dv.Dispose() - Else - GlobalDTTipoCuentasEquiposCaracteristicas = DirectCast(HttpContext.Current.Application("GlobalDTTipoCuentasEquiposCaracteristicas"), DataTable) - End If - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTTipoCuentasEquiposCaracteristicas") = value - End Set - End Property - Property GlobalDTTipoCuentasEquiposOpciones(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTTipoCuentasEquiposOpciones"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTTipoCuentasEquiposOpciones = Dv.ToTable - Dv.Dispose() - Else - GlobalDTTipoCuentasEquiposOpciones = DirectCast(HttpContext.Current.Application("GlobalDTTipoCuentasEquiposOpciones"), DataTable) - End If - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTTipoCuentasEquiposOpciones") = value - End Set - End Property - ReadOnly Property GlobalDTPS(CveEmpresa As Integer, Optional CvePS As Integer = -1, Optional SATClavePS As String = "-1", Optional AplicaParaVenta As Integer = -1) As DataTable - Get - Dim ObjPS As New ClsProductosServicios - - If ObjPS.GetPS(CvePS, -1, CveEmpresa, SATClavePS:=SATClavePS, pAplicaParaVenta:=AplicaParaVenta) Then - GlobalDTPS = ObjPS.DtResultados - Else - GlobalDTPS = Nothing - End If - - ObjPS.Dispose() - End Get + Property GlobalDTSubProyectosUsuarios(CveUsuario As Integer, CveProyecto As Integer, CveEmpresa As Integer, Optional CveSubProyecto As Integer = -1, Optional CveEstatus As Integer = -1) As DataTable + Get + + If HttpContext.Current.Application("GlobalDTSubProyectosUsuarios") Is Nothing Then + Dim ObjSubProyectos As New ClsSubProyectos() + If ObjSubProyectos.GetSubProyectosUsuarios Then HttpContext.Current.Application("GlobalDTSubProyectosUsuarios") = ObjSubProyectos.DtResultados Else Alert("Ocurrió un error al cargar los SubProyectos. Por favor comuniquese con sistemas.", TipoMensaje.MsgError) + ObjSubProyectos.Dispose() + End If + + If CveUsuario <> -1 OrElse CveProyecto <> -1 OrElse CveSubProyecto <> -1 OrElse CveEmpresa <> -1 OrElse CveEstatus <> -1 Then + Dim StrSQL As New StringBuilder + If CveProyecto <> -1 Then StrSQL.AppendFormat(" AND CveProyecto = {0}", CveProyecto) + If CveSubProyecto <> -1 Then StrSQL.AppendFormat(" AND CveSubProyecto = {0}", CveSubProyecto) + If CveEmpresa <> -1 Then StrSQL.AppendFormat(" AND CveEmpresa = {0}", CveEmpresa) + If CveUsuario <> -1 Then StrSQL.AppendFormat(" AND CveUsuario = {0}", CveUsuario) + If CveEstatus <> -1 Then StrSQL.AppendFormat(" AND CveEstatus = {0}", CveEstatus) + + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTSubProyectosUsuarios"), DataTable), StrSQL.ToString.Trim.TrimStart("A"c, "N"c, "D"c), "", DataViewRowState.CurrentRows) + GlobalDTSubProyectosUsuarios = Dv.ToTable + Dv.Dispose() + + Dim ObjSubProyectos As New ClsSubProyectos() + If ObjSubProyectos.GetSubProyectosUsuarios(CveUsuario:=CveUsuario, CveProyecto:=CveProyecto, CveSubProyecto:=CveSubProyecto, CveEstatus:=CveEstatus, CveEmpresa:=CveEmpresa) Then + GlobalDTSubProyectosUsuarios = ObjSubProyectos.DtResultados + Else + GlobalDTSubProyectosUsuarios = Nothing + End If + ObjSubProyectos.Dispose() + + Else + GlobalDTSubProyectosUsuarios = DirectCast(HttpContext.Current.Application("GlobalDTSubProyectosUsuarios"), DataTable) + End If + + End Get + Set(ByVal value As DataTable) + If value Is Nothing OrElse value.Rows.Count = 0 Then + + + End If + HttpContext.Current.Application("GlobalDTSubProyectosUsuarios") = value + End Set + End Property + Property GlobalDTProyectosUsuarios(CveUsuario As Integer, CveProyecto As Integer, CveEmpresa As Integer, CveEstatus As Integer) As DataTable + Get + + If HttpContext.Current.Application("GlobalDTProyectosUsuarios") Is Nothing AndAlso DirectCast(HttpContext.Current.Application("GlobalDTProyectosUsuarios"), DataTable).Rows.Count = 0 Then + Dim ObjSubProyectos As New ClsSubProyectos() + If ObjSubProyectos.GetSubProyectosUsuarios Then HttpContext.Current.Application("GlobalDTProyectosUsuarios") = ObjSubProyectos.DtResultados.FiltraParametros("", "", {"Proyecto", "CveProyecto", "CveUsuario", "CveEmpresa", "CveEstatusProyecto"}) Else Alert("Ocurrió un error al cargar los Proyectos. Por favor comuniquese con sistemas.", TipoMensaje.MsgError) + ObjSubProyectos.Dispose() + GuardaLog("Se Cargo GlobalDTProyectosUsuarios") + End If + + If CveUsuario <> -1 OrElse CveProyecto <> -1 OrElse CveEmpresa <> -1 OrElse CveEstatus <> -1 Then + Dim StrSQL As New StringBuilder + If CveProyecto <> -1 Then StrSQL.AppendFormat(" AND CveProyecto = {0}", CveProyecto) + If CveEmpresa <> -1 Then StrSQL.AppendFormat(" AND CveEmpresa = {0}", CveEmpresa) + If CveUsuario <> -1 Then StrSQL.AppendFormat(" AND CveUsuario = {0}", CveUsuario) + If CveEstatus <> -1 Then StrSQL.AppendFormat(" AND CveEstatusProyecto = {0}", CveEstatus) + + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTProyectosUsuarios"), DataTable), StrSQL.ToString.Trim.TrimStart("A"c, "N"c, "D"c), "", DataViewRowState.CurrentRows) + GlobalDTProyectosUsuarios = Dv.ToTable + Dv.Dispose() + + Else + GlobalDTProyectosUsuarios = DirectCast(HttpContext.Current.Application("GlobalDTProyectosUsuarios"), DataTable) + End If + + End Get + Set(ByVal value As DataTable) + If value Is Nothing OrElse value.Rows.Count = 0 Then + + End If + HttpContext.Current.Application("GlobalDTProyectosUsuarios") = value + End Set + End Property + Property GlobalDTPrecioListas(CveEmpresa As Integer) As DataTable + Get + GlobalDTPrecioListas = DirectCast(HttpContext.Current.Application("GlobalDTPrecioListas"), DataTable).FiltraParametros(String.Format("CveEmpresa = {0}", CveEmpresa)) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTPrecioListas") = value + End Set + End Property + Property GlobalDTMesas() As DataTable + Get + GlobalDTMesas = DirectCast(HttpContext.Current.Application("GlobalDTMesas"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTMesas") = value + End Set + End Property + Property GlobalDTTipoOrdenServicios(CveEmpresa As Integer) As DataTable + Get + GlobalDTTipoOrdenServicios = DirectCast(HttpContext.Current.Application("GlobalDTTipoOrdenServicios"), DataTable).FiltraParametros(String.Format("CveEmpresa = {0}", CveEmpresa)) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTTipoOrdenServicios") = value + End Set + End Property + Property GlobalDTSubTipoOrdenServicios() As DataTable + Get + GlobalDTSubTipoOrdenServicios = DirectCast(HttpContext.Current.Application("GlobalDTSubTipoOrdenServicios"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTSubTipoOrdenServicios") = value + End Set + End Property + Property GlobalDTCaracteristicasOrdenServicios() As DataTable + Get + GlobalDTCaracteristicasOrdenServicios = DirectCast(HttpContext.Current.Application("GlobalDTCaracteristicasOrdenServicios"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTCaracteristicasOrdenServicios") = value + End Set + End Property + Property GlobalDTOrdenesServiciosCaracteristicas() As DataTable + Get + GlobalDTOrdenesServiciosCaracteristicas = DirectCast(HttpContext.Current.Application("GlobalDTOrdenesServiciosCaracteristicas"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTOrdenesServiciosCaracteristicas") = value + End Set + End Property + Property GlobalDTCaracteristicasOpciones() As DataTable + Get + GlobalDTCaracteristicasOpciones = DirectCast(HttpContext.Current.Application("GlobalDTCaracteristicasOpciones"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTCaracteristicasOpciones") = value + End Set + End Property + Property GlobalDTTipoCuentasEquipos(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTTipoCuentasEquipos"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTTipoCuentasEquipos = Dv.ToTable + Dv.Dispose() + Else + GlobalDTTipoCuentasEquipos = DirectCast(HttpContext.Current.Application("GlobalDTTipoCuentasEquipos"), DataTable) + End If + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTTipoCuentasEquipos") = value + End Set + End Property + Property GlobalDTTipoCuentasEquiposCaracteristicas(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTTipoCuentasEquiposCaracteristicas"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTTipoCuentasEquiposCaracteristicas = Dv.ToTable + Dv.Dispose() + Else + GlobalDTTipoCuentasEquiposCaracteristicas = DirectCast(HttpContext.Current.Application("GlobalDTTipoCuentasEquiposCaracteristicas"), DataTable) + End If + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTTipoCuentasEquiposCaracteristicas") = value + End Set + End Property + Property GlobalDTTipoCuentasEquiposOpciones(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTTipoCuentasEquiposOpciones"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTTipoCuentasEquiposOpciones = Dv.ToTable + Dv.Dispose() + Else + GlobalDTTipoCuentasEquiposOpciones = DirectCast(HttpContext.Current.Application("GlobalDTTipoCuentasEquiposOpciones"), DataTable) + End If + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTTipoCuentasEquiposOpciones") = value + End Set + End Property + ReadOnly Property GlobalDTPS(CveEmpresa As Integer, Optional CvePS As Integer = -1, Optional SATClavePS As String = "-1", Optional AplicaParaVenta As Integer = -1) As DataTable + Get + Dim ObjPS As New ClsProductosServicios + + If ObjPS.GetPS(CvePS, -1, CveEmpresa, SATClavePS:=SATClavePS, pAplicaParaVenta:=AplicaParaVenta) Then + GlobalDTPS = ObjPS.DtResultados + Else + GlobalDTPS = Nothing + End If + + ObjPS.Dispose() + End Get End Property - Property GlobalDTInvMetodosInventario() As DataTable - Get - GlobalDTInvMetodosInventario = DirectCast(HttpContext.Current.Application("GlobalDTInvMetodosInventario"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTInvMetodosInventario") = value - End Set - End Property - Property GlobalDTAFCaracteristicasOpciones() As DataTable - Get - GlobalDTAFCaracteristicasOpciones = DirectCast(HttpContext.Current.Application("GlobalDTAFCaracteristicasOpciones"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTAFCaracteristicasOpciones") = value - End Set - End Property - Property GlobalDTAFCaracteristicas() As DataTable - Get - GlobalDTAFCaracteristicas = DirectCast(HttpContext.Current.Application("GlobalDTAFCaracteristicas"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTAFCaracteristicas") = value - End Set - End Property - Property GlobalDTAFCaracteristicasClasificaciones() As DataTable - Get - GlobalDTAFCaracteristicasClasificaciones = DirectCast(HttpContext.Current.Application("GlobalDTAFCaracteristicasClasificaciones"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTAFCaracteristicasClasificaciones") = value - End Set - End Property - Property GlobalDTImpuestosLocales(CvePS As Integer, CveEmpresa As Integer) As DataTable - Get - Dim Str As New StringBuilder - If CvePS > 0 Then Str.AppendFormat("CvePS = {0}", CvePS) - If CveEmpresa > 0 Then Str.AppendFormat("{0} CveEmpresa = {1}", If(CvePS > 0, " AND ", ""), CveEmpresa) - - If CvePS > 0 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTImpuestosLocales"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) - GlobalDTImpuestosLocales = Dv.ToTable - Dv.Dispose() - Else - GlobalDTImpuestosLocales = DirectCast(HttpContext.Current.Application("GlobalDTImpuestosLocales"), DataTable) - End If - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTImpuestosLocales") = value - End Set - End Property - 'Bancos - Property GlobalDTBancos() As DataTable - Get - GlobalDTBancos = DirectCast(HttpContext.Current.Application("GlobalDTBancos"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTBancos") = value - End Set - End Property - 'Property GlobalDTBancosCuentas(CveUsuario As Integer) As DataTable - ' Get - ' Dim Str As String = String.Format("CveEmpresa = {0} ", UsuarioActual.CveEmpresa) - ' If CveUsuario > -1 Then Str = String.Format("{0} AND CveUsuario ={1}", Str, CveUsuario) - - ' Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTBancosCuentas"), DataTable), Str, "", DataViewRowState.CurrentRows) - ' GlobalDTBancosCuentas = Dv.ToTable - ' Dv.Dispose() - - ' End Get - ' Set(value As DataTable) - ' HttpContext.Current.Application("GlobalDTBancosCuentas") = value - ' End Set - 'End Property - Property GlobalDTBancosCuentas(CveUsuario As Integer, Optional CveCuenta As Integer = -1, Optional Estatus As Integer = 1) As DataTable - Get - - Dim Str As String = String.Format("CveEmpresa = {0} ", UsuarioActual.CveEmpresa) - If CveUsuario > -1 Then Str = String.Format("{0} AND CveUsuario = {1}", Str, CveUsuario) - If CveCuenta > -1 Then Str = String.Format("{0} AND CveCuenta = {1}", Str, CveCuenta) - If Estatus > -1 Then Str = String.Format("{0} AND Estatus = '{1}'", Str, If(Estatus = 1, "Activo", "Inactivo")) - - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTBancosCuentas"), DataTable), Str, "", DataViewRowState.CurrentRows) - GlobalDTBancosCuentas = Dv.ToTable - Dv.Dispose() - 'GlobalDTBancosCuentas = DirectCast(HttpContext.Current.Application("GlobalDTBancosCuentas"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTBancosCuentas") = value - End Set - End Property - Property GlobalDTTipoTransacciones() As DataTable - Get - If UsuarioActual.CveEmpresa = 66 Then - GlobalDTTipoTransacciones = DirectCast(HttpContext.Current.Application("GlobalDTTipoTransacciones"), DataTable).FiltraParametros("Estatus = 1") - Else - GlobalDTTipoTransacciones = DirectCast(HttpContext.Current.Application("GlobalDTTipoTransacciones"), DataTable) - End If - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTTipoTransacciones") = value - End Set - End Property - Property GlobalDTEstatusIE() As DataTable - Get - GlobalDTEstatusIE = DirectCast(HttpContext.Current.Application("GlobalDTEstatusIE"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTEstatusIE") = value - End Set - End Property - Property GlobalDTBancosIE() As DataTable - Get - GlobalDTBancosIE = DirectCast(HttpContext.Current.Application("GlobalDTBancosIE"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTBancosIE") = value - End Set - End Property - Property GlobalDTTipoCuenta() As DataTable - Get - GlobalDTTipoCuenta = DirectCast(HttpContext.Current.Application("GlobalDTTipoCuenta"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTTipoCuenta") = value - End Set - End Property - 'Fin Bancos - - 'Fin EstadoCIvil - 'TipoPerioso - Property GlobalDTTipoPeriodo() As DataTable - Get - GlobalDTTipoPeriodo = DirectCast(HttpContext.Current.Application("GlobalDTTipoPeriodo"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTTipoPeriodo") = value - End Set - End Property - 'Fin TipoPeriodo - - 'Periodos - Property GlobalDTNominasPeriodos(CveTipoPeriodo As Integer, CvePeriodo As Integer, CveEmpresa As Integer) As DataTable - Get - Dim Str As New StringBuilder - If CveEmpresa <> -1 Then Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) - If CveTipoPeriodo <> -1 Then Str.AppendFormat(" {0} CveTipoPeriodo = {1}", If(Str.Length > 0, "AND", ""), CveTipoPeriodo) - If CvePeriodo <> -1 Then Str.AppendFormat(" {0} CvePeriodo = {1}", If(Str.Length > 0, "AND", ""), CvePeriodo) - If Str.Length > 0 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTNominasPeriodos"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) - GlobalDTNominasPeriodos = Dv.ToTable - Dv.Dispose() - - Else - GlobalDTNominasPeriodos = DirectCast(HttpContext.Current.Application("GlobalDTNominasPeriodos"), DataTable) - End If - - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTNominasPeriodos") = value - End Set - End Property - 'Fin Periodos - - 'Fin Ruta - 'Cliente + Property GlobalDTInvMetodosInventario() As DataTable + Get + GlobalDTInvMetodosInventario = DirectCast(HttpContext.Current.Application("GlobalDTInvMetodosInventario"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTInvMetodosInventario") = value + End Set + End Property + Property GlobalDTAFCaracteristicasOpciones() As DataTable + Get + GlobalDTAFCaracteristicasOpciones = DirectCast(HttpContext.Current.Application("GlobalDTAFCaracteristicasOpciones"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTAFCaracteristicasOpciones") = value + End Set + End Property + Property GlobalDTAFCaracteristicas() As DataTable + Get + GlobalDTAFCaracteristicas = DirectCast(HttpContext.Current.Application("GlobalDTAFCaracteristicas"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTAFCaracteristicas") = value + End Set + End Property + Property GlobalDTAFCaracteristicasClasificaciones() As DataTable + Get + GlobalDTAFCaracteristicasClasificaciones = DirectCast(HttpContext.Current.Application("GlobalDTAFCaracteristicasClasificaciones"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTAFCaracteristicasClasificaciones") = value + End Set + End Property + Property GlobalDTImpuestosLocales(CvePS As Integer, CveEmpresa As Integer) As DataTable + Get + Dim Str As New StringBuilder + If CvePS > 0 Then Str.AppendFormat("CvePS = {0}", CvePS) + If CveEmpresa > 0 Then Str.AppendFormat("{0} CveEmpresa = {1}", If(CvePS > 0, " AND ", ""), CveEmpresa) + + If CvePS > 0 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTImpuestosLocales"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) + GlobalDTImpuestosLocales = Dv.ToTable + Dv.Dispose() + Else + GlobalDTImpuestosLocales = DirectCast(HttpContext.Current.Application("GlobalDTImpuestosLocales"), DataTable) + End If + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTImpuestosLocales") = value + End Set + End Property + 'Bancos + Property GlobalDTBancos() As DataTable + Get + GlobalDTBancos = DirectCast(HttpContext.Current.Application("GlobalDTBancos"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTBancos") = value + End Set + End Property + 'Property GlobalDTBancosCuentas(CveUsuario As Integer) As DataTable + ' Get + ' Dim Str As String = String.Format("CveEmpresa = {0} ", UsuarioActual.CveEmpresa) + ' If CveUsuario > -1 Then Str = String.Format("{0} AND CveUsuario ={1}", Str, CveUsuario) + + ' Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTBancosCuentas"), DataTable), Str, "", DataViewRowState.CurrentRows) + ' GlobalDTBancosCuentas = Dv.ToTable + ' Dv.Dispose() + + ' End Get + ' Set(value As DataTable) + ' HttpContext.Current.Application("GlobalDTBancosCuentas") = value + ' End Set + 'End Property + Property GlobalDTBancosCuentas(CveUsuario As Integer, Optional CveCuenta As Integer = -1, Optional Estatus As Integer = 1) As DataTable + Get + + Dim Str As String = String.Format("CveEmpresa = {0} ", UsuarioActual.CveEmpresa) + If CveUsuario > -1 Then Str = String.Format("{0} AND CveUsuario = {1}", Str, CveUsuario) + If CveCuenta > -1 Then Str = String.Format("{0} AND CveCuenta = {1}", Str, CveCuenta) + If Estatus > -1 Then Str = String.Format("{0} AND Estatus = '{1}'", Str, If(Estatus = 1, "Activo", "Inactivo")) + + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTBancosCuentas"), DataTable), Str, "", DataViewRowState.CurrentRows) + GlobalDTBancosCuentas = Dv.ToTable + Dv.Dispose() + 'GlobalDTBancosCuentas = DirectCast(HttpContext.Current.Application("GlobalDTBancosCuentas"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTBancosCuentas") = value + End Set + End Property + Property GlobalDTTipoTransacciones() As DataTable + Get + If UsuarioActual.CveEmpresa = 66 Then + GlobalDTTipoTransacciones = DirectCast(HttpContext.Current.Application("GlobalDTTipoTransacciones"), DataTable).FiltraParametros("Estatus = 1") + Else + GlobalDTTipoTransacciones = DirectCast(HttpContext.Current.Application("GlobalDTTipoTransacciones"), DataTable) + End If + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTTipoTransacciones") = value + End Set + End Property + Property GlobalDTEstatusIE() As DataTable + Get + GlobalDTEstatusIE = DirectCast(HttpContext.Current.Application("GlobalDTEstatusIE"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTEstatusIE") = value + End Set + End Property + Property GlobalDTBancosIE() As DataTable + Get + GlobalDTBancosIE = DirectCast(HttpContext.Current.Application("GlobalDTBancosIE"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTBancosIE") = value + End Set + End Property + Property GlobalDTTipoCuenta() As DataTable + Get + GlobalDTTipoCuenta = DirectCast(HttpContext.Current.Application("GlobalDTTipoCuenta"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTTipoCuenta") = value + End Set + End Property + 'Fin Bancos + + 'Fin EstadoCIvil + 'TipoPerioso + Property GlobalDTTipoPeriodo() As DataTable + Get + GlobalDTTipoPeriodo = DirectCast(HttpContext.Current.Application("GlobalDTTipoPeriodo"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTTipoPeriodo") = value + End Set + End Property + 'Fin TipoPeriodo + + 'Periodos + Property GlobalDTNominasPeriodos(CveTipoPeriodo As Integer, CvePeriodo As Integer, CveEmpresa As Integer) As DataTable + Get + Dim Str As New StringBuilder + If CveEmpresa <> -1 Then Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) + If CveTipoPeriodo <> -1 Then Str.AppendFormat(" {0} CveTipoPeriodo = {1}", If(Str.Length > 0, "AND", ""), CveTipoPeriodo) + If CvePeriodo <> -1 Then Str.AppendFormat(" {0} CvePeriodo = {1}", If(Str.Length > 0, "AND", ""), CvePeriodo) + If Str.Length > 0 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTNominasPeriodos"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) + GlobalDTNominasPeriodos = Dv.ToTable + Dv.Dispose() + + Else + GlobalDTNominasPeriodos = DirectCast(HttpContext.Current.Application("GlobalDTNominasPeriodos"), DataTable) + End If + + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTNominasPeriodos") = value + End Set + End Property + 'Fin Periodos + + 'Fin Ruta + 'Cliente Property GlobalDTCliente(CveEmpresa As Integer, Optional Estatus As Integer = 1) As DataTable Get Dim AppNombre As String = String.Format("GlobalDTCliente-{0}", CveEmpresa) @@ -7008,8 +7008,8 @@ Namespace Modelos StrSQL.AppendFormat("CveEmpresa = {0}", CveEmpresa) If Estatus >= 0 Then StrSQL.AppendFormat(" AND EstatusBool = {0} ", Estatus) - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application(AppNombre), DataTable), StrSQL.ToString, "", DataViewRowState.CurrentRows) - GlobalDTCliente = Dv.ToTable + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application(AppNombre), DataTable), StrSQL.ToString, "", DataViewRowState.CurrentRows) + GlobalDTCliente = Dv.ToTable Dv.Dispose() Else @@ -7049,1583 +7049,1583 @@ Namespace Modelos 'If ObjClientes.GetClienteClasificacion(CveEmpresa) Then Application(AppNombre) = ObjClientes.DtResultados 'ObjClientes.Dispose() End Set - End Property - Property GlobalDTEstatusOrdenServicios(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTEstatusOrdenServicios"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTEstatusOrdenServicios = Dv.ToTable - Dv.Dispose() - Else - GlobalDTEstatusOrdenServicios = DirectCast(HttpContext.Current.Application("GlobalDTEstatusOrdenServicios"), DataTable) - End If - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTEstatusOrdenServicios") = value - End Set - End Property - 'Variables para Ventas - Property GlobalDTVendedores(CveEmpresa As Integer, Optional Estatus As Boolean = True, Optional VendedorTipo As Integer = 1) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTVendedores"), DataTable), String.Format("CveEmpresa = {0} AND CveEstatus = {1} AND VendedorTipo = {2}", CveEmpresa, If(Estatus, 1, 0), VendedorTipo), "", DataViewRowState.CurrentRows) - GlobalDTVendedores = Dv.ToTable - Dv.Dispose() - Else - GlobalDTVendedores = DirectCast(HttpContext.Current.Application("GlobalDTVendedores"), DataTable) - End If - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTVendedores") = value - End Set - End Property - Property GlobalDTClientesCorporativo(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTClientesCorporativo"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTClientesCorporativo = Dv.ToTable - Dv.Dispose() - Else - GlobalDTClientesCorporativo = DirectCast(HttpContext.Current.Application("GlobalDTClientesCorporativo"), DataTable) - End If - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTClientesCorporativo") = value - End Set - End Property - Property GlobalDTCompProveedores(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTCompProveedores"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTCompProveedores = Dv.ToTable - Dv.Dispose() - Else - GlobalDTCompProveedores = DirectCast(HttpContext.Current.Application("GlobalDTCompProveedores"), DataTable) - End If - - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTCompProveedores") = value - End Set - End Property - 'EstatusFactura - Property GlobalDTCompEstatusFactura() As DataTable - Get - GlobalDTCompEstatusFactura = DirectCast(HttpContext.Current.Application("GlobalDTCompEstatusFactura"), DataTable).FiltraParametros("Estatus = 'Activo'") - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTCompEstatusFactura") = value - End Set - End Property - Property GlobalDTContratosSecciones() As DataTable - Get - GlobalDTContratosSecciones = DirectCast(HttpContext.Current.Application("GlobalDTContratosSecciones"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTContratosSecciones") = value - End Set - End Property - Property GlobalDTContratos() As DataTable - Get - GlobalDTContratos = DirectCast(HttpContext.Current.Application("GlobalDTContratos"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTContratos") = value - End Set - End Property - Property GlobalDTContratosTipos() As DataTable - Get - GlobalDTContratosTipos = DirectCast(HttpContext.Current.Application("GlobalDTContratosTipos"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTContratosTipos") = value - End Set - End Property - Property GlobalDTTipoAlmacen(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTTipoAlmacen"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTTipoAlmacen = Dv.ToTable - Dv.Dispose() - Else - GlobalDTTipoAlmacen = DirectCast(HttpContext.Current.Application("GlobalDTTipoAlmacen"), DataTable) - End If - - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTTipoAlmacen") = value - End Set - End Property - Property GlobalDTInvConceptos() As DataTable - Get - - Return DirectCast(HttpContext.Current.Application("GlobalDTInvConceptos"), DataTable) - - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTInvConceptos") = value - End Set - End Property - Property GlobalDTSeccionAlmacen(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTSeccionAlmacen"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTSeccionAlmacen = Dv.ToTable - Dv.Dispose() - Else - GlobalDTSeccionAlmacen = DirectCast(HttpContext.Current.Application("GlobalDTSeccionAlmacen"), DataTable) - End If - - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTSeccionAlmacen") = value - End Set - End Property - Property GlobalDTAlmacen(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTAlmacen"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTAlmacen = Dv.ToTable - Dv.Dispose() - Else - GlobalDTAlmacen = DirectCast(HttpContext.Current.Application("GlobalDTAlmacen"), DataTable) - End If - - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTAlmacen") = value - End Set - End Property - Property GlobalDTAlmacenUsuarios(CveUsuario As Integer, CveEmpresa As Integer, Optional CveTipoAlmacen As Integer = 1) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Str As New StringBuilder - Str.AppendFormat("CveUsuario = {0} AND CveEmpresa = {1} ", CveUsuario, CveEmpresa) - If CveTipoAlmacen > 0 Then Str.AppendFormat("AND CveTipoAlmacen = {0}", CveTipoAlmacen) - - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTAlmacenUsuarios"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) - GlobalDTAlmacenUsuarios = Dv.ToTable - Dv.Dispose() - Else - GlobalDTAlmacenUsuarios = DirectCast(HttpContext.Current.Application("GlobalDTAlmacenUsuarios"), DataTable) - End If - - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTAlmacenUsuarios") = value - End Set - End Property - Property GlobalDTNom_Periodos() As DataTable - Get - GlobalDTNom_Periodos = DirectCast(HttpContext.Current.Application("GlobalDTNom_Periodos"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTNom_Periodos") = value - End Set - End Property - Property GlobalDTVtaFormaPago() As DataTable - Get - GlobalDTVtaFormaPago = DirectCast(HttpContext.Current.Application("GlobalDTVtaFormaPago"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTVtaFormaPago") = value - End Set - End Property - Property GlobalDTVtaMetodoPago() As DataTable - Get - GlobalDTVtaMetodoPago = DirectCast(HttpContext.Current.Application("GlobalDTVtaMetodoPago"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTVtaMetodoPago") = value - End Set - End Property - Property GlobalDTVtaTiposRelacion() As DataTable - Get - GlobalDTVtaTiposRelacion = DirectCast(HttpContext.Current.Application("GlobalDTVtaTiposRelacion"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTVtaTiposRelacion") = value - End Set - End Property - Property GlobalDTTiposDocumentos() As DataTable - Get - GlobalDTTiposDocumentos = DirectCast(HttpContext.Current.Application("GlobalDTTiposDocumentos"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTTiposDocumentos") = value - End Set - End Property - Property GlobalDTCobranzaEstatus(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTVtaCobranzaEstatus"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTCobranzaEstatus = Dv.ToTable - Dv.Dispose() - Else - GlobalDTCobranzaEstatus = DirectCast(HttpContext.Current.Application("GlobalDTVtaCobranzaEstatus"), DataTable) - End If - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTVtaCobranzaEstatus") = value - End Set + End Property + Property GlobalDTEstatusOrdenServicios(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTEstatusOrdenServicios"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTEstatusOrdenServicios = Dv.ToTable + Dv.Dispose() + Else + GlobalDTEstatusOrdenServicios = DirectCast(HttpContext.Current.Application("GlobalDTEstatusOrdenServicios"), DataTable) + End If + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTEstatusOrdenServicios") = value + End Set + End Property + 'Variables para Ventas + Property GlobalDTVendedores(CveEmpresa As Integer, Optional Estatus As Boolean = True, Optional VendedorTipo As Integer = 1) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTVendedores"), DataTable), String.Format("CveEmpresa = {0} AND CveEstatus = {1} AND VendedorTipo = {2}", CveEmpresa, If(Estatus, 1, 0), VendedorTipo), "", DataViewRowState.CurrentRows) + GlobalDTVendedores = Dv.ToTable + Dv.Dispose() + Else + GlobalDTVendedores = DirectCast(HttpContext.Current.Application("GlobalDTVendedores"), DataTable) + End If + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTVendedores") = value + End Set + End Property + Property GlobalDTClientesCorporativo(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTClientesCorporativo"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTClientesCorporativo = Dv.ToTable + Dv.Dispose() + Else + GlobalDTClientesCorporativo = DirectCast(HttpContext.Current.Application("GlobalDTClientesCorporativo"), DataTable) + End If + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTClientesCorporativo") = value + End Set + End Property + Property GlobalDTCompProveedores(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTCompProveedores"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTCompProveedores = Dv.ToTable + Dv.Dispose() + Else + GlobalDTCompProveedores = DirectCast(HttpContext.Current.Application("GlobalDTCompProveedores"), DataTable) + End If + + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTCompProveedores") = value + End Set + End Property + 'EstatusFactura + Property GlobalDTCompEstatusFactura() As DataTable + Get + GlobalDTCompEstatusFactura = DirectCast(HttpContext.Current.Application("GlobalDTCompEstatusFactura"), DataTable).FiltraParametros("Estatus = 'Activo'") + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTCompEstatusFactura") = value + End Set + End Property + Property GlobalDTContratosSecciones() As DataTable + Get + GlobalDTContratosSecciones = DirectCast(HttpContext.Current.Application("GlobalDTContratosSecciones"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTContratosSecciones") = value + End Set + End Property + Property GlobalDTContratos() As DataTable + Get + GlobalDTContratos = DirectCast(HttpContext.Current.Application("GlobalDTContratos"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTContratos") = value + End Set + End Property + Property GlobalDTContratosTipos() As DataTable + Get + GlobalDTContratosTipos = DirectCast(HttpContext.Current.Application("GlobalDTContratosTipos"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTContratosTipos") = value + End Set + End Property + Property GlobalDTTipoAlmacen(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTTipoAlmacen"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTTipoAlmacen = Dv.ToTable + Dv.Dispose() + Else + GlobalDTTipoAlmacen = DirectCast(HttpContext.Current.Application("GlobalDTTipoAlmacen"), DataTable) + End If + + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTTipoAlmacen") = value + End Set + End Property + Property GlobalDTInvConceptos() As DataTable + Get + + Return DirectCast(HttpContext.Current.Application("GlobalDTInvConceptos"), DataTable) + + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTInvConceptos") = value + End Set + End Property + Property GlobalDTSeccionAlmacen(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTSeccionAlmacen"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTSeccionAlmacen = Dv.ToTable + Dv.Dispose() + Else + GlobalDTSeccionAlmacen = DirectCast(HttpContext.Current.Application("GlobalDTSeccionAlmacen"), DataTable) + End If + + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTSeccionAlmacen") = value + End Set + End Property + Property GlobalDTAlmacen(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTAlmacen"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTAlmacen = Dv.ToTable + Dv.Dispose() + Else + GlobalDTAlmacen = DirectCast(HttpContext.Current.Application("GlobalDTAlmacen"), DataTable) + End If + + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTAlmacen") = value + End Set + End Property + Property GlobalDTAlmacenUsuarios(CveUsuario As Integer, CveEmpresa As Integer, Optional CveTipoAlmacen As Integer = 1) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Str As New StringBuilder + Str.AppendFormat("CveUsuario = {0} AND CveEmpresa = {1} ", CveUsuario, CveEmpresa) + If CveTipoAlmacen > 0 Then Str.AppendFormat("AND CveTipoAlmacen = {0}", CveTipoAlmacen) + + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTAlmacenUsuarios"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) + GlobalDTAlmacenUsuarios = Dv.ToTable + Dv.Dispose() + Else + GlobalDTAlmacenUsuarios = DirectCast(HttpContext.Current.Application("GlobalDTAlmacenUsuarios"), DataTable) + End If + + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTAlmacenUsuarios") = value + End Set + End Property + Property GlobalDTNom_Periodos() As DataTable + Get + GlobalDTNom_Periodos = DirectCast(HttpContext.Current.Application("GlobalDTNom_Periodos"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTNom_Periodos") = value + End Set + End Property + Property GlobalDTVtaFormaPago() As DataTable + Get + GlobalDTVtaFormaPago = DirectCast(HttpContext.Current.Application("GlobalDTVtaFormaPago"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTVtaFormaPago") = value + End Set + End Property + Property GlobalDTVtaMetodoPago() As DataTable + Get + GlobalDTVtaMetodoPago = DirectCast(HttpContext.Current.Application("GlobalDTVtaMetodoPago"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTVtaMetodoPago") = value + End Set + End Property + Property GlobalDTVtaTiposRelacion() As DataTable + Get + GlobalDTVtaTiposRelacion = DirectCast(HttpContext.Current.Application("GlobalDTVtaTiposRelacion"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTVtaTiposRelacion") = value + End Set + End Property + Property GlobalDTTiposDocumentos() As DataTable + Get + GlobalDTTiposDocumentos = DirectCast(HttpContext.Current.Application("GlobalDTTiposDocumentos"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTTiposDocumentos") = value + End Set + End Property + Property GlobalDTCobranzaEstatus(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTVtaCobranzaEstatus"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTCobranzaEstatus = Dv.ToTable + Dv.Dispose() + Else + GlobalDTCobranzaEstatus = DirectCast(HttpContext.Current.Application("GlobalDTVtaCobranzaEstatus"), DataTable) + End If + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTVtaCobranzaEstatus") = value + End Set End Property -#Region "***********************************************************************DT EVENTOS****************************************************************************************" - Property GlobalDTTiposEventos() As DataTable - Get - GlobalDTTiposEventos = DirectCast(HttpContext.Current.Application("GlobalDTTiposEventos"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTTiposEventos") = value - End Set - End Property - - Property GlobalDTEventos() As DataTable - Get - GlobalDTEventos = DirectCast(HttpContext.Current.Application("GlobalDTEventos"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTEventos") = value - End Set - End Property - - Property GlobalDTOIEventoTarea() As DataTable - Get - GlobalDTOIEventoTarea = DirectCast(HttpContext.Current.Application("GlobalDTOIEventoTarea"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTOIEventoTarea") = value - End Set - End Property - - Property GlobalDTOIEstatusEventos() As DataTable - Get - GlobalDTOIEstatusEventos = DirectCast(HttpContext.Current.Application("GlobalDTOIEstatusEventos"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTOIEstatusEventos") = value - End Set - End Property -#End Region - -#Region " **********************************************************************DT PROSPECTOS*************************************************************************************" - Property GlobalDTProspectosCaracteristicasClasificaciones() As DataTable - Get - GlobalDTProspectosCaracteristicasClasificaciones = DirectCast(HttpContext.Current.Application("GlobalDTProspectosCaracteristicasClasificaciones"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTProspectosCaracteristicasClasificaciones") = value - End Set - End Property - Property GlobalDTProspectosTiposCaracteristicas() As DataTable - Get - GlobalDTProspectosTiposCaracteristicas = DirectCast(HttpContext.Current.Application("GlobalDTProspectosTiposCaracteristicas"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTProspectosTiposCaracteristicas") = value - End Set - End Property - Property GlobalDTProspectosCaracteristicas(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTProspectosCaracteristicas"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTProspectosCaracteristicas = Dv.ToTable - Dv.Dispose() - Else - GlobalDTProspectosCaracteristicas = DirectCast(HttpContext.Current.Application("GlobalDTProspectosCaracteristicas"), DataTable) - End If - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTProspectosCaracteristicas") = value - End Set - End Property - - Property GlobalDTProspectosCaracteristicasOpciones() As DataTable - Get - GlobalDTProspectosCaracteristicasOpciones = DirectCast(HttpContext.Current.Application("GlobalDTProspectosCaracteristicasOpciones"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTProspectosCaracteristicasOpciones") = value - End Set - End Property -#End Region - -#Region "***********************************************************************DT ACTIVOS FIJOS**********************************************************************************" - Property GlobalDTActivoFijos(CveEmpresa As Integer, Optional CveSubTipoActivoFijo As Integer = -1, Optional CveActivoFijo As Integer = -1) As DataTable - Get - Dim dt As DataTable = Nothing - 'Dim Str As New StringBuilder - 'Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) - 'If CveSubTipoActivoFijo <> -1 Then Str.AppendFormat(" AND CveSubTipoActivoFijo = {0}", CveSubTipoActivoFijo) - - Dim ObjAF As New ClsAF - 'If ObjAF.GetActivosFijos(CveActivoFijo, UsuarioActual.CveEmpresa, "-1", "-1", -1, -1, -1, "-1", -1, -1, -1, -1, -1) Then - If ObjAF.GetActivosFijos(CveActivoFijo, CveEmpresa, "-1", "-1", -1, CveSubTipoActivoFijo, "-1", -1, -1, -1, -1, -1, "", -1) Then - dt = ObjAF.DtResultados - End If - - ObjAF.Dispose() - GlobalDTActivoFijos = dt - - End Get - Set(ByVal value As DataTable) - HttpContext.Current.Application("GlobalDTActivoFijos") = value - End Set - End Property - Property GlobalDTEstadoActivoFijo() As DataTable - Get - GlobalDTEstadoActivoFijo = DirectCast(HttpContext.Current.Application("GlobalDTEstadoActivoFijo"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTEstadoActivoFijo") = value - End Set - End Property - Property GlobalDTMarcaActivoFijo(CveEmpresa As Integer) As DataTable - Get - Dim dt As DataTable = Nothing - - Dim ObjAF As New ClsAF - - If ObjAF.GetMarcasActivosFijos(CveEmpresa) Then - dt = ObjAF.DtResultados - End If - - ObjAF.Dispose() - GlobalDTMarcaActivoFijo = dt - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTMarcaActivoFijo") = value - End Set - End Property - Property GlobalDTModeloActivoFijo(CveEmpresa As Integer, CveMarca As Integer) As DataTable - Get - Dim dt As DataTable = Nothing - - Dim ObjAF As New ClsAF - - If ObjAF.GetModelosActivosFijos(CveEmpresa, CveMarca) Then - dt = ObjAF.DtResultados - End If - - ObjAF.Dispose() - GlobalDTModeloActivoFijo = dt - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTModeloActivoFijo") = value - End Set - End Property - - Property GlobalDTSubTipoActivoFijo(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTSubTipoActivoFijo"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTSubTipoActivoFijo = Dv.ToTable - Dv.Dispose() - Else - GlobalDTSubTipoActivoFijo = DirectCast(HttpContext.Current.Application("GlobalDTSubTipoActivoFijo"), DataTable) - End If - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTSubTipoActivoFijo") = value - End Set - End Property - Property GlobalDTTipoActivoFijo(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTTipoActivoFijo"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTTipoActivoFijo = Dv.ToTable - Dv.Dispose() - Else - GlobalDTTipoActivoFijo = DirectCast(HttpContext.Current.Application("GlobalDTTipoActivoFijo"), DataTable) - End If - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTTipoActivoFijo") = value - End Set +#Region "***********************************************************************DT EVENTOS****************************************************************************************" + Property GlobalDTTiposEventos() As DataTable + Get + GlobalDTTiposEventos = DirectCast(HttpContext.Current.Application("GlobalDTTiposEventos"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTTiposEventos") = value + End Set End Property -#End Region - -#Region "***********************************************************************DT GENERALES**************************************************************************************" - Property GlobalDTGralPaises() As DataTable - Get - GlobalDTGralPaises = DirectCast(HttpContext.Current.Application("GlobalDTGralPaises"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTGralPaises") = value - End Set - End Property - Property GlobalDTGralEstados(CvePais As Integer) As DataTable - Get - GlobalDTGralEstados = DirectCast(HttpContext.Current.Application("GlobalDTGralEstados"), DataTable).FiltraParametros(String.Format("CvePais ={0}", CvePais)) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTGralEstados") = value - End Set - End Property - Property GlobalDTGralMunicipios(CveEstado As Integer) As DataTable - Get - GlobalDTGralMunicipios = DirectCast(HttpContext.Current.Application("GlobalDTGralMunicipios"), DataTable).FiltraParametros(String.Format("CveEstado ={0}", CveEstado)) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTGralMunicipios") = value - End Set - End Property - - Property GlobalDTGralPoblaciones() As DataTable - Get - GlobalDTGralPoblaciones = DirectCast(HttpContext.Current.Application("GlobalDTGralPoblaciones"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTGralPoblaciones") = value - End Set - End Property - Property GlobalDTGralCategorias(CveEmpresa As Integer) As DataTable - - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTGralCategorias"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTGralCategorias = Dv.ToTable - Dv.Dispose() - Else - GlobalDTGralCategorias = DirectCast(HttpContext.Current.Application("GlobalDTGralCategorias"), DataTable) - End If - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTGralCategorias") = value - End Set - End Property - Property GlobalDTGralCategorias2(CveEmpresa As Integer) As DataTable - - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTCategorias2"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTGralCategorias2 = Dv.ToTable - Dv.Dispose() - Else - GlobalDTGralCategorias2 = DirectCast(HttpContext.Current.Application("GlobalDTCategorias2"), DataTable) - End If - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTCategorias2") = value - End Set - End Property - - Property GlobalDTGralEscolaridades() As DataTable - Get - GlobalDTGralEscolaridades = DirectCast(HttpContext.Current.Application("GlobalDTGralEscolaridades"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTGralEscolaridades") = value - End Set - End Property - - Property GlobalDTGralColectivas(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTGralColectivas"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTGralColectivas = Dv.ToTable - Dv.Dispose() - Else - GlobalDTGralColectivas = DirectCast(HttpContext.Current.Application("GlobalDTGralColectivas"), DataTable) - End If - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTGralColectivas") = value - End Set + Property GlobalDTEventos() As DataTable + Get + GlobalDTEventos = DirectCast(HttpContext.Current.Application("GlobalDTEventos"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTEventos") = value + End Set End Property -#End Region - -#Region "***********************************************************************DT PROSPECTOS*************************************************************************************" - Property GlobalDTProspectosSupervisores(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTProspectosSupervisores"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTProspectosSupervisores = Dv.ToTable - Dv.Dispose() - Else - GlobalDTProspectosSupervisores = DirectCast(HttpContext.Current.Application("GlobalDTProspectosSupervisores"), DataTable) - End If - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTProspectosSupervisores") = value - End Set - End Property - Property GlobalDTProspectosCoordinadores(CveSupervisor As Integer, CveEmpresa As Integer) As DataTable - Get - Dim Str As New StringBuilder - If CveEmpresa <> -1 Then Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) - If CveSupervisor <> -1 Then Str.AppendFormat(" {0} CveSupervisor = {1}", If(Str.Length > 0, "AND", ""), CveSupervisor) - If Str.Length > 0 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTProspectosCoordinadores"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) - GlobalDTProspectosCoordinadores = Dv.ToTable - Dv.Dispose() - - Else - GlobalDTProspectosCoordinadores = DirectCast(HttpContext.Current.Application("GlobalDTProspectosCoordinadores"), DataTable) - End If - End Get - - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTProspectosCoordinadores") = value - End Set - End Property - Property GlobalDTProspectosApoyos(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTProspectosApoyos"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTProspectosApoyos = Dv.ToTable - Dv.Dispose() - Else - GlobalDTProspectosApoyos = DirectCast(HttpContext.Current.Application("GlobalDTProspectosApoyos"), DataTable) - End If - End Get - - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTProspectosApoyos") = value - End Set - End Property - Property GlobalDTProspectosClasificaciones(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTProspectosClasificaciones"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTProspectosClasificaciones = Dv.ToTable - Dv.Dispose() - Else - GlobalDTProspectosClasificaciones = DirectCast(HttpContext.Current.Application("GlobalDTProspectosClasificaciones"), DataTable) - End If - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTProspectosClasificaciones") = value - End Set - End Property - Property GlobalDTProspectosEventosTipo(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTProspectosEventosTipo"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTProspectosEventosTipo = Dv.ToTable - Dv.Dispose() - Else - GlobalDTProspectosEventosTipo = DirectCast(HttpContext.Current.Application("GlobalDTProspectosEventosTipo"), DataTable) - End If - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTProspectosEventosTipo") = value - End Set - End Property - Property GlobalDTProspectosEvento(CveEventoTipo As Integer, CveEmpresa As Integer) As DataTable - Get - Dim Str As New StringBuilder - If CveEmpresa <> -1 Then Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) - If CveEventoTipo <> -1 Then Str.AppendFormat(" {0} CveEventoTipo = {1}", If(Str.Length > 0, "AND", ""), CveEventoTipo) - If Str.Length > 0 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTProspectosEvento"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) - GlobalDTProspectosEvento = Dv.ToTable - Dv.Dispose() - Else - GlobalDTProspectosEvento = DirectCast(HttpContext.Current.Application("GlobalDTProspectosEvento"), DataTable) - End If - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTProspectosEvento") = value - End Set - End Property - Property GlobalDTProspectosEstatus(CveEmpresa As Integer) As DataTable - Get - Dim Str As New StringBuilder - If CveEmpresa <> -1 Then Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) - If Str.Length > 0 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTProspectosEstatus"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) - GlobalDTProspectosEstatus = Dv.ToTable - Dv.Dispose() - Else - GlobalDTProspectosEstatus = DirectCast(HttpContext.Current.Application("GlobalDTProspectosEstatus"), DataTable) - End If - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTProspectosEstatus") = value - End Set - End Property - Property GlobalDTProspectosApoyosTipos(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTProspectosApoyosTipos"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTProspectosApoyosTipos = Dv.ToTable - Dv.Dispose() - Else - GlobalDTProspectosApoyosTipos = DirectCast(HttpContext.Current.Application("GlobalDTProspectosApoyosTipos"), DataTable) - End If - End Get - - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTProspectosApoyosTipos") = value - End Set - End Property - Property GlobalDTProspectosApoyosTipos() As DataTable - Get - GlobalDTProspectosApoyosTipos = DirectCast(HttpContext.Current.Application("GlobalDTProspectosApoyosTipos"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTProspectosApoyosTipos") = value - End Set - End Property - Property GlobalDTProspectosEncuestas(CveEmpresa As Integer) As DataTable - Get - Dim Str As New StringBuilder - If CveEmpresa <> -1 Then Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) - - If Str.Length > 0 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTProspectosEncuestas"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) - GlobalDTProspectosEncuestas = Dv.ToTable - Dv.Dispose() - - Else - GlobalDTProspectosEncuestas = DirectCast(HttpContext.Current.Application("GlobalDTProspectosEncuestas"), DataTable) - End If - End Get - - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTProspectosEncuestas") = value - End Set - End Property - Property GlobalDTProspectosEncuestasPreguntas(CveEncuesta As Integer, CveEmpresa As Integer) As DataTable - Get - Dim Str As New StringBuilder - If CveEmpresa <> -1 Then Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) - If CveEncuesta <> -1 Then Str.AppendFormat(" {0} CveEncuesta = {1}", If(Str.Length > 0, "AND", ""), CveEncuesta) - - - If Str.Length > 0 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTProspectosEncuestasPreguntas"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) - GlobalDTProspectosEncuestasPreguntas = Dv.ToTable - Dv.Dispose() - - Else - GlobalDTProspectosEncuestasPreguntas = DirectCast(HttpContext.Current.Application("GlobalDTProspectosEncuestasPreguntas"), DataTable) - End If - End Get - - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTProspectosEncuestasPreguntas") = value - End Set - End Property - Property GlobalDTProspectosEncuestasRespuestas(CvePregunta As Integer, CveEncuesta As Integer, CveEmpresa As Integer) As DataTable - Get - Dim Str As New StringBuilder - If CveEmpresa <> -1 Then Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) - If CveEncuesta <> -1 Then Str.AppendFormat(" {0} CveEncuesta = {1}", If(Str.Length > 0, "AND", ""), CveEncuesta) - If CvePregunta <> -1 Then Str.AppendFormat(" {0} CvePregunta = {1}", If(Str.Length > 0, "AND", ""), CvePregunta) - - - If Str.Length > 0 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTProspectosEncuestasRespuestas"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) - GlobalDTProspectosEncuestasRespuestas = Dv.ToTable - Dv.Dispose() - - Else - GlobalDTProspectosEncuestasRespuestas = DirectCast(HttpContext.Current.Application("GlobalDTProspectosEncuestasRespuestas"), DataTable) - End If - End Get - - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTProspectosEncuestasRespuestas") = value - End Set - End Property - Property GlobalDTProspectosTipos(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTProspectosTipos"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTProspectosTipos = Dv.ToTable - Dv.Dispose() - Else - GlobalDTProspectosTipos = DirectCast(HttpContext.Current.Application("GlobalDTProspectosTipos"), DataTable) - End If - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTProspectosTipos") = value - End Set + Property GlobalDTOIEventoTarea() As DataTable + Get + GlobalDTOIEventoTarea = DirectCast(HttpContext.Current.Application("GlobalDTOIEventoTarea"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTOIEventoTarea") = value + End Set End Property -#Region " DT PROSPECTOS SOLICITUDES" - Property GlobalDTProspectosSolicitudes(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTProspectosSolicitudes"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTProspectosSolicitudes = Dv.ToTable - Dv.Dispose() - Else - GlobalDTProspectosSolicitudes = DirectCast(HttpContext.Current.Application("GlobalDTProspectosSolicitudes"), DataTable) - End If - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTProspectosSolicitudes") = value - End Set - End Property - Property GlobalDTProspectosSolicitudesEstatus(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTProspectosSolicitudesEstatus"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTProspectosSolicitudesEstatus = Dv.ToTable - Dv.Dispose() - Else - GlobalDTProspectosSolicitudesEstatus = DirectCast(HttpContext.Current.Application("GlobalDTProspectosSolicitudesEstatus"), DataTable) - End If - End Get - - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTProspectosSolicitudesEstatus") = value - End Set - End Property - Property GlobalDTProspectosSolicitudesTipos(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTProspectosSolicitudesTipos"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTProspectosSolicitudesTipos = Dv.ToTable - Dv.Dispose() - Else - GlobalDTProspectosSolicitudesTipos = DirectCast(HttpContext.Current.Application("GlobalDTProspectosSolicitudesTipos"), DataTable) - End If - End Get - - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTProspectosSolicitudesTipos") = value - End Set - End Property - 'Property GlobalDTProspectosSolicitudesTipos() As DataTable - ' Get - ' GlobalDTProspectosSolicitudesTipos = DirectCast(HttpContext.Current.Application("GlobalDTProspectosSolicitudesTipos"), DataTable) - ' End Get - ' Set(value As DataTable) - ' HttpContext.Current.Application("GlobalDTProspectosSolicitudesTipos") = value - ' End Set - 'End Property - Property GlobalDTProspectosSolicitudesApoyos(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTProspectosSolicitudesApoyos"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTProspectosSolicitudesApoyos = Dv.ToTable - Dv.Dispose() - Else - GlobalDTProspectosSolicitudesApoyos = DirectCast(HttpContext.Current.Application("GlobalDTProspectosSolicitudesApoyos"), DataTable) - End If - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTProspectosSolicitudesApoyos") = value - End Set + Property GlobalDTOIEstatusEventos() As DataTable + Get + GlobalDTOIEstatusEventos = DirectCast(HttpContext.Current.Application("GlobalDTOIEstatusEventos"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTOIEstatusEventos") = value + End Set + End Property +#End Region + +#Region " **********************************************************************DT PROSPECTOS*************************************************************************************" + Property GlobalDTProspectosCaracteristicasClasificaciones() As DataTable + Get + GlobalDTProspectosCaracteristicasClasificaciones = DirectCast(HttpContext.Current.Application("GlobalDTProspectosCaracteristicasClasificaciones"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTProspectosCaracteristicasClasificaciones") = value + End Set + End Property + Property GlobalDTProspectosTiposCaracteristicas() As DataTable + Get + GlobalDTProspectosTiposCaracteristicas = DirectCast(HttpContext.Current.Application("GlobalDTProspectosTiposCaracteristicas"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTProspectosTiposCaracteristicas") = value + End Set + End Property + Property GlobalDTProspectosCaracteristicas(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTProspectosCaracteristicas"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTProspectosCaracteristicas = Dv.ToTable + Dv.Dispose() + Else + GlobalDTProspectosCaracteristicas = DirectCast(HttpContext.Current.Application("GlobalDTProspectosCaracteristicas"), DataTable) + End If + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTProspectosCaracteristicas") = value + End Set End Property -#End Region -#End Region + Property GlobalDTProspectosCaracteristicasOpciones() As DataTable + Get + GlobalDTProspectosCaracteristicasOpciones = DirectCast(HttpContext.Current.Application("GlobalDTProspectosCaracteristicasOpciones"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTProspectosCaracteristicasOpciones") = value + End Set + End Property +#End Region -#Region "**********************************************DT AMORTIZACIÓN CONTABLE PLAN DE DESARROLLO********************************************************************************" +#Region "***********************************************************************DT ACTIVOS FIJOS**********************************************************************************" + Property GlobalDTActivoFijos(CveEmpresa As Integer, Optional CveSubTipoActivoFijo As Integer = -1, Optional CveActivoFijo As Integer = -1) As DataTable + Get + Dim dt As DataTable = Nothing + 'Dim Str As New StringBuilder + 'Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) + 'If CveSubTipoActivoFijo <> -1 Then Str.AppendFormat(" AND CveSubTipoActivoFijo = {0}", CveSubTipoActivoFijo) -#Region "***********************************************************************DT AMORTIZACIÓN CONTABLE*********************************************************************************************" + Dim ObjAF As New ClsAF + 'If ObjAF.GetActivosFijos(CveActivoFijo, UsuarioActual.CveEmpresa, "-1", "-1", -1, -1, -1, "-1", -1, -1, -1, -1, -1) Then + If ObjAF.GetActivosFijos(CveActivoFijo, CveEmpresa, "-1", "-1", -1, CveSubTipoActivoFijo, "-1", -1, -1, -1, -1, -1, "", -1) Then + dt = ObjAF.DtResultados + End If - Property GlobalDTAC_RubrosIngreso() As DataTable - Get - GlobalDTAC_RubrosIngreso = DirectCast(HttpContext.Current.Application("GlobalDTAC_RubrosIngreso"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTAC_RubrosIngreso") = value - End Set - End Property - Property GlobalDTAC_FuentesRecaudacion(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim StrSQL As String = String.Format("CveEmpresa = {0}", CveEmpresa) - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTAC_FuentesRecaudacion"), DataTable), StrSQL, "", DataViewRowState.CurrentRows) - GlobalDTAC_FuentesRecaudacion = Dv.ToTable - Dv.Dispose() - Else - GlobalDTAC_FuentesRecaudacion = DirectCast(HttpContext.Current.Application("GlobalDTAC_FuentesRecaudacion"), DataTable) - End If - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTAC_FuentesRecaudacion") = value - End Set - End Property - - Property GlobalDTAC_FuentesFinanciamiento() As DataTable - Get - GlobalDTAC_FuentesFinanciamiento = DirectCast(HttpContext.Current.Application("GlobalDTAC_FuentesFinanciamiento"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTAC_FuentesFinanciamiento") = value - End Set - End Property - Property GlobalDTAC_OG() As DataTable - Get - GlobalDTAC_OG = DirectCast(HttpContext.Current.Application("GlobalDTAC_OG"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTAC_OG") = value - End Set - End Property - 'Property GlobalDTAC_ClasificadorOG(CveEmpresa As Integer) As DataTable - ' Get - ' If CveEmpresa <> -1 Then - ' Dim StrSQL As String = String.Format("CveEmpresa = {0}", CveEmpresa) - ' Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTAC_ClasificadorOG"), DataTable), StrSQL, "", DataViewRowState.CurrentRows) - ' GlobalDTAC_ClasificadorOG = Dv.ToTable - ' Dv.Dispose() - ' Else - ' GlobalDTAC_ClasificadorOG = DirectCast(HttpContext.Current.Application("GlobalDTAC_ClasificadorOG"), DataTable) - ' End If - ' End Get - ' Set(value As DataTable) - ' HttpContext.Current.Application("GlobalDTAC_ClasificadorOG") = value - ' End Set - 'End Property - Property GlobalDTAC_Ubicaciones() As DataTable - Get - GlobalDTAC_Ubicaciones = DirectCast(HttpContext.Current.Application("GlobalDTAC_Ubicaciones"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTAC_Ubicaciones") = value - End Set - End Property - Property GlobalDTAC_UnidadesAdministrativas(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim StrSQL As String = String.Format("CveEmpresa = {0}", CveEmpresa) - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTAC_UnidadesAdministrativas"), DataTable), StrSQL, "", DataViewRowState.CurrentRows) - GlobalDTAC_UnidadesAdministrativas = Dv.ToTable - Dv.Dispose() - Else - GlobalDTAC_UnidadesAdministrativas = DirectCast(HttpContext.Current.Application("GlobalDTAC_UnidadesAdministrativas"), DataTable) - End If - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTAC_UnidadesAdministrativas") = value - End Set - End Property - Property GlobalDTAC_ClasificacionFuncional(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTAC_ClasificacionFuncional"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTAC_ClasificacionFuncional = Dv.ToTable - Dv.Dispose() - Else - GlobalDTAC_ClasificacionFuncional = DirectCast(HttpContext.Current.Application("GlobalDTAC_ClasificacionFuncional"), DataTable) - End If - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTAC_ClasificacionFuncional") = value - End Set - End Property - Property GlobalDTAC_ClasificacionGeografica(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTAC_ClasificacionGeografica"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTAC_ClasificacionGeografica = Dv.ToTable - Dv.Dispose() - Else - GlobalDTAC_ClasificacionGeografica = DirectCast(HttpContext.Current.Application("GlobalDTAC_ClasificacionGeografica"), DataTable) - End If - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTAC_ClasificacionGeografica") = value - End Set - End Property - Property GlobalDTAC_Cuentas() As DataTable - Get - GlobalDTAC_Cuentas = DirectCast(HttpContext.Current.Application("GlobalDTAC_Cuentas"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTAC_Cuentas") = value - End Set - End Property - Property GlobalDTAC_Finalidad() As DataTable - Get - GlobalDTAC_Finalidad = DirectCast(HttpContext.Current.Application("GlobalDTAC_Finalidad"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTAC_Finalidad") = value - End Set - End Property - 'Property GlobalDTAC_FuenteFinanciamiento() As DataTable - ' Get - ' GlobalDTAC_FuenteFinanciamiento = DirectCast(HttpContext.Current.Application("GlobalDTAC_FuenteFinanciamiento"), DataTable) - ' End Get - ' Set(value As DataTable) - ' HttpContext.Current.Application("GlobalDTAC_FuenteFinanciamiento") = value - ' End Set - 'End Property - Property GlobalDTAC_FuentesFinanciamiento(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim StrSQL As String = String.Format("CveEmpresa = {0}", CveEmpresa) - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTAC_FuentesFinanciamiento"), DataTable), StrSQL, "", DataViewRowState.CurrentRows) - GlobalDTAC_FuentesFinanciamiento = Dv.ToTable - Dv.Dispose() - Else - GlobalDTAC_FuentesFinanciamiento = DirectCast(HttpContext.Current.Application("GlobalDTAC_FuentesFinanciamiento"), DataTable) - End If - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTAC_FuentesFinanciamiento") = value - End Set - End Property - Property GlobalDTAC_FuentesFinanciamientoCONAC() As DataTable - Get - GlobalDTAC_FuentesFinanciamientoCONAC = DirectCast(HttpContext.Current.Application("GlobalDTAC_FuentesFinanciamientoCONAC"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTAC_FuentesFinanciamientoCONAC") = value - End Set - End Property - Property GlobalDTAC_Funcion() As DataTable - Get - GlobalDTAC_Funcion = DirectCast(HttpContext.Current.Application("GlobalDTAC_Funcion"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTAC_Funcion") = value - End Set - End Property - Property GlobalDTAC_Programas() As DataTable - Get - GlobalDTAC_Programas = DirectCast(HttpContext.Current.Application("GlobalDTAC_Programas"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTAC_Programas") = value - End Set - End Property - Property GlobalDTAC_ProgramasCONAC() As DataTable - Get - GlobalDTAC_ProgramasCONAC = DirectCast(HttpContext.Current.Application("GlobalDTAC_ProgramasCONAC"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTAC_ProgramasCONAC") = value - End Set - End Property - Property GlobalDTAC_ProyectosProceso() As DataTable - Get - GlobalDTAC_ProyectosProceso = DirectCast(HttpContext.Current.Application("GlobalDTAC_ProyectosProceso"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTAC_ProyectosProceso") = value - End Set - End Property - Property GlobalDTAC_SubFuncion() As DataTable - Get - GlobalDTAC_SubFuncion = DirectCast(HttpContext.Current.Application("GlobalDTAC_SubFuncion"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTAC_SubFuncion") = value - End Set - End Property - Property GlobalDTAC_SubProgramas() As DataTable - Get - GlobalDTAC_SubProgramas = DirectCast(HttpContext.Current.Application("GlobalDTAC_SubProgramas"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTAC_SubProgramas") = value - End Set - End Property - Property GlobalDTAC_ClasificacionAdministrativa(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTAC_ClasificacionAdministrativa"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTAC_ClasificacionAdministrativa = Dv.ToTable - Dv.Dispose() - Else - GlobalDTAC_ClasificacionAdministrativa = DirectCast(HttpContext.Current.Application("GlobalDTAC_ClasificacionAdministrativa"), DataTable) - End If - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTAC_ClasificacionAdministrativa") = value - End Set - End Property - Property GlobalDTAC_TipoGasto() As DataTable - Get - GlobalDTAC_TipoGasto = DirectCast(HttpContext.Current.Application("GlobalDTAC_TipoGasto"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTAC_TipoGasto") = value - End Set - End Property - - Property GlobalDTAC_ProgramaOperativo(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTAC_ProgramaOperativo"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTAC_ProgramaOperativo = Dv.ToTable - Dv.Dispose() - Else - GlobalDTAC_ProgramaOperativo = DirectCast(HttpContext.Current.Application("GlobalDTAC_ProgramaOperativo"), DataTable) - End If - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTAC_ProgramaOperativo") = value - End Set - End Property - - Property GlobalDTAC_MatrizIngresos() As DataTable - Get - GlobalDTAC_MatrizIngresos = DirectCast(HttpContext.Current.Application("GlobalDTAC_MatrizIngresos"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTAC_MatrizIngresos") = value - End Set - End Property - - Property GlobalDTAC_MatrizEgresos() As DataTable - Get - GlobalDTAC_MatrizEgresos = DirectCast(HttpContext.Current.Application("GlobalDTAC_MatrizEgresos"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTAC_MatrizEgresos") = value - End Set + ObjAF.Dispose() + GlobalDTActivoFijos = dt + + End Get + Set(ByVal value As DataTable) + HttpContext.Current.Application("GlobalDTActivoFijos") = value + End Set + End Property + Property GlobalDTEstadoActivoFijo() As DataTable + Get + GlobalDTEstadoActivoFijo = DirectCast(HttpContext.Current.Application("GlobalDTEstadoActivoFijo"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTEstadoActivoFijo") = value + End Set + End Property + Property GlobalDTMarcaActivoFijo(CveEmpresa As Integer) As DataTable + Get + Dim dt As DataTable = Nothing + + Dim ObjAF As New ClsAF + + If ObjAF.GetMarcasActivosFijos(CveEmpresa) Then + dt = ObjAF.DtResultados + End If + + ObjAF.Dispose() + GlobalDTMarcaActivoFijo = dt + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTMarcaActivoFijo") = value + End Set + End Property + Property GlobalDTModeloActivoFijo(CveEmpresa As Integer, CveMarca As Integer) As DataTable + Get + Dim dt As DataTable = Nothing + + Dim ObjAF As New ClsAF + + If ObjAF.GetModelosActivosFijos(CveEmpresa, CveMarca) Then + dt = ObjAF.DtResultados + End If + + ObjAF.Dispose() + GlobalDTModeloActivoFijo = dt + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTModeloActivoFijo") = value + End Set + End Property + + Property GlobalDTSubTipoActivoFijo(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTSubTipoActivoFijo"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTSubTipoActivoFijo = Dv.ToTable + Dv.Dispose() + Else + GlobalDTSubTipoActivoFijo = DirectCast(HttpContext.Current.Application("GlobalDTSubTipoActivoFijo"), DataTable) + End If + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTSubTipoActivoFijo") = value + End Set + End Property + Property GlobalDTTipoActivoFijo(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTTipoActivoFijo"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTTipoActivoFijo = Dv.ToTable + Dv.Dispose() + Else + GlobalDTTipoActivoFijo = DirectCast(HttpContext.Current.Application("GlobalDTTipoActivoFijo"), DataTable) + End If + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTTipoActivoFijo") = value + End Set + End Property + +#End Region + +#Region "***********************************************************************DT GENERALES**************************************************************************************" + Property GlobalDTGralPaises() As DataTable + Get + GlobalDTGralPaises = DirectCast(HttpContext.Current.Application("GlobalDTGralPaises"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTGralPaises") = value + End Set + End Property + Property GlobalDTGralEstados(CvePais As Integer) As DataTable + Get + GlobalDTGralEstados = DirectCast(HttpContext.Current.Application("GlobalDTGralEstados"), DataTable).FiltraParametros(String.Format("CvePais ={0}", CvePais)) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTGralEstados") = value + End Set + End Property + Property GlobalDTGralMunicipios(CveEstado As Integer) As DataTable + Get + GlobalDTGralMunicipios = DirectCast(HttpContext.Current.Application("GlobalDTGralMunicipios"), DataTable).FiltraParametros(String.Format("CveEstado ={0}", CveEstado)) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTGralMunicipios") = value + End Set + End Property + + Property GlobalDTGralPoblaciones() As DataTable + Get + GlobalDTGralPoblaciones = DirectCast(HttpContext.Current.Application("GlobalDTGralPoblaciones"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTGralPoblaciones") = value + End Set + End Property + Property GlobalDTGralCategorias(CveEmpresa As Integer) As DataTable + + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTGralCategorias"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTGralCategorias = Dv.ToTable + Dv.Dispose() + Else + GlobalDTGralCategorias = DirectCast(HttpContext.Current.Application("GlobalDTGralCategorias"), DataTable) + End If + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTGralCategorias") = value + End Set + End Property + Property GlobalDTGralCategorias2(CveEmpresa As Integer) As DataTable + + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTCategorias2"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTGralCategorias2 = Dv.ToTable + Dv.Dispose() + Else + GlobalDTGralCategorias2 = DirectCast(HttpContext.Current.Application("GlobalDTCategorias2"), DataTable) + End If + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTCategorias2") = value + End Set + End Property + + Property GlobalDTGralEscolaridades() As DataTable + Get + GlobalDTGralEscolaridades = DirectCast(HttpContext.Current.Application("GlobalDTGralEscolaridades"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTGralEscolaridades") = value + End Set + End Property + + Property GlobalDTGralColectivas(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTGralColectivas"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTGralColectivas = Dv.ToTable + Dv.Dispose() + Else + GlobalDTGralColectivas = DirectCast(HttpContext.Current.Application("GlobalDTGralColectivas"), DataTable) + End If + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTGralColectivas") = value + End Set + End Property + +#End Region + +#Region "***********************************************************************DT PROSPECTOS*************************************************************************************" + Property GlobalDTProspectosSupervisores(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTProspectosSupervisores"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTProspectosSupervisores = Dv.ToTable + Dv.Dispose() + Else + GlobalDTProspectosSupervisores = DirectCast(HttpContext.Current.Application("GlobalDTProspectosSupervisores"), DataTable) + End If + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTProspectosSupervisores") = value + End Set + End Property + Property GlobalDTProspectosCoordinadores(CveSupervisor As Integer, CveEmpresa As Integer) As DataTable + Get + Dim Str As New StringBuilder + If CveEmpresa <> -1 Then Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) + If CveSupervisor <> -1 Then Str.AppendFormat(" {0} CveSupervisor = {1}", If(Str.Length > 0, "AND", ""), CveSupervisor) + If Str.Length > 0 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTProspectosCoordinadores"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) + GlobalDTProspectosCoordinadores = Dv.ToTable + Dv.Dispose() + + Else + GlobalDTProspectosCoordinadores = DirectCast(HttpContext.Current.Application("GlobalDTProspectosCoordinadores"), DataTable) + End If + End Get + + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTProspectosCoordinadores") = value + End Set + End Property + Property GlobalDTProspectosApoyos(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTProspectosApoyos"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTProspectosApoyos = Dv.ToTable + Dv.Dispose() + Else + GlobalDTProspectosApoyos = DirectCast(HttpContext.Current.Application("GlobalDTProspectosApoyos"), DataTable) + End If + End Get + + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTProspectosApoyos") = value + End Set + End Property + Property GlobalDTProspectosClasificaciones(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTProspectosClasificaciones"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTProspectosClasificaciones = Dv.ToTable + Dv.Dispose() + Else + GlobalDTProspectosClasificaciones = DirectCast(HttpContext.Current.Application("GlobalDTProspectosClasificaciones"), DataTable) + End If + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTProspectosClasificaciones") = value + End Set + End Property + Property GlobalDTProspectosEventosTipo(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTProspectosEventosTipo"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTProspectosEventosTipo = Dv.ToTable + Dv.Dispose() + Else + GlobalDTProspectosEventosTipo = DirectCast(HttpContext.Current.Application("GlobalDTProspectosEventosTipo"), DataTable) + End If + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTProspectosEventosTipo") = value + End Set + End Property + Property GlobalDTProspectosEvento(CveEventoTipo As Integer, CveEmpresa As Integer) As DataTable + Get + Dim Str As New StringBuilder + If CveEmpresa <> -1 Then Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) + If CveEventoTipo <> -1 Then Str.AppendFormat(" {0} CveEventoTipo = {1}", If(Str.Length > 0, "AND", ""), CveEventoTipo) + If Str.Length > 0 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTProspectosEvento"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) + GlobalDTProspectosEvento = Dv.ToTable + Dv.Dispose() + Else + GlobalDTProspectosEvento = DirectCast(HttpContext.Current.Application("GlobalDTProspectosEvento"), DataTable) + End If + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTProspectosEvento") = value + End Set + End Property + Property GlobalDTProspectosEstatus(CveEmpresa As Integer) As DataTable + Get + Dim Str As New StringBuilder + If CveEmpresa <> -1 Then Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) + If Str.Length > 0 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTProspectosEstatus"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) + GlobalDTProspectosEstatus = Dv.ToTable + Dv.Dispose() + Else + GlobalDTProspectosEstatus = DirectCast(HttpContext.Current.Application("GlobalDTProspectosEstatus"), DataTable) + End If + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTProspectosEstatus") = value + End Set + End Property + Property GlobalDTProspectosApoyosTipos(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTProspectosApoyosTipos"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTProspectosApoyosTipos = Dv.ToTable + Dv.Dispose() + Else + GlobalDTProspectosApoyosTipos = DirectCast(HttpContext.Current.Application("GlobalDTProspectosApoyosTipos"), DataTable) + End If + End Get + + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTProspectosApoyosTipos") = value + End Set + End Property + Property GlobalDTProspectosApoyosTipos() As DataTable + Get + GlobalDTProspectosApoyosTipos = DirectCast(HttpContext.Current.Application("GlobalDTProspectosApoyosTipos"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTProspectosApoyosTipos") = value + End Set + End Property + Property GlobalDTProspectosEncuestas(CveEmpresa As Integer) As DataTable + Get + Dim Str As New StringBuilder + If CveEmpresa <> -1 Then Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) + + If Str.Length > 0 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTProspectosEncuestas"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) + GlobalDTProspectosEncuestas = Dv.ToTable + Dv.Dispose() + + Else + GlobalDTProspectosEncuestas = DirectCast(HttpContext.Current.Application("GlobalDTProspectosEncuestas"), DataTable) + End If + End Get + + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTProspectosEncuestas") = value + End Set + End Property + Property GlobalDTProspectosEncuestasPreguntas(CveEncuesta As Integer, CveEmpresa As Integer) As DataTable + Get + Dim Str As New StringBuilder + If CveEmpresa <> -1 Then Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) + If CveEncuesta <> -1 Then Str.AppendFormat(" {0} CveEncuesta = {1}", If(Str.Length > 0, "AND", ""), CveEncuesta) + + + If Str.Length > 0 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTProspectosEncuestasPreguntas"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) + GlobalDTProspectosEncuestasPreguntas = Dv.ToTable + Dv.Dispose() + + Else + GlobalDTProspectosEncuestasPreguntas = DirectCast(HttpContext.Current.Application("GlobalDTProspectosEncuestasPreguntas"), DataTable) + End If + End Get + + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTProspectosEncuestasPreguntas") = value + End Set + End Property + Property GlobalDTProspectosEncuestasRespuestas(CvePregunta As Integer, CveEncuesta As Integer, CveEmpresa As Integer) As DataTable + Get + Dim Str As New StringBuilder + If CveEmpresa <> -1 Then Str.AppendFormat("CveEmpresa = {0}", CveEmpresa) + If CveEncuesta <> -1 Then Str.AppendFormat(" {0} CveEncuesta = {1}", If(Str.Length > 0, "AND", ""), CveEncuesta) + If CvePregunta <> -1 Then Str.AppendFormat(" {0} CvePregunta = {1}", If(Str.Length > 0, "AND", ""), CvePregunta) + + + If Str.Length > 0 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTProspectosEncuestasRespuestas"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows) + GlobalDTProspectosEncuestasRespuestas = Dv.ToTable + Dv.Dispose() + + Else + GlobalDTProspectosEncuestasRespuestas = DirectCast(HttpContext.Current.Application("GlobalDTProspectosEncuestasRespuestas"), DataTable) + End If + End Get + + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTProspectosEncuestasRespuestas") = value + End Set + End Property + Property GlobalDTProspectosTipos(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTProspectosTipos"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTProspectosTipos = Dv.ToTable + Dv.Dispose() + Else + GlobalDTProspectosTipos = DirectCast(HttpContext.Current.Application("GlobalDTProspectosTipos"), DataTable) + End If + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTProspectosTipos") = value + End Set + End Property + +#Region " DT PROSPECTOS SOLICITUDES" + Property GlobalDTProspectosSolicitudes(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTProspectosSolicitudes"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTProspectosSolicitudes = Dv.ToTable + Dv.Dispose() + Else + GlobalDTProspectosSolicitudes = DirectCast(HttpContext.Current.Application("GlobalDTProspectosSolicitudes"), DataTable) + End If + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTProspectosSolicitudes") = value + End Set + End Property + Property GlobalDTProspectosSolicitudesEstatus(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTProspectosSolicitudesEstatus"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTProspectosSolicitudesEstatus = Dv.ToTable + Dv.Dispose() + Else + GlobalDTProspectosSolicitudesEstatus = DirectCast(HttpContext.Current.Application("GlobalDTProspectosSolicitudesEstatus"), DataTable) + End If + End Get + + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTProspectosSolicitudesEstatus") = value + End Set + End Property + Property GlobalDTProspectosSolicitudesTipos(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTProspectosSolicitudesTipos"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTProspectosSolicitudesTipos = Dv.ToTable + Dv.Dispose() + Else + GlobalDTProspectosSolicitudesTipos = DirectCast(HttpContext.Current.Application("GlobalDTProspectosSolicitudesTipos"), DataTable) + End If + End Get + + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTProspectosSolicitudesTipos") = value + End Set + End Property + 'Property GlobalDTProspectosSolicitudesTipos() As DataTable + ' Get + ' GlobalDTProspectosSolicitudesTipos = DirectCast(HttpContext.Current.Application("GlobalDTProspectosSolicitudesTipos"), DataTable) + ' End Get + ' Set(value As DataTable) + ' HttpContext.Current.Application("GlobalDTProspectosSolicitudesTipos") = value + ' End Set + 'End Property + Property GlobalDTProspectosSolicitudesApoyos(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTProspectosSolicitudesApoyos"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTProspectosSolicitudesApoyos = Dv.ToTable + Dv.Dispose() + Else + GlobalDTProspectosSolicitudesApoyos = DirectCast(HttpContext.Current.Application("GlobalDTProspectosSolicitudesApoyos"), DataTable) + End If + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTProspectosSolicitudesApoyos") = value + End Set + End Property + +#End Region +#End Region + +#Region "**********************************************DT AMORTIZACIÓN CONTABLE PLAN DE DESARROLLO********************************************************************************" + +#Region "***********************************************************************DT AMORTIZACIÓN CONTABLE*********************************************************************************************" + + Property GlobalDTAC_RubrosIngreso() As DataTable + Get + GlobalDTAC_RubrosIngreso = DirectCast(HttpContext.Current.Application("GlobalDTAC_RubrosIngreso"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTAC_RubrosIngreso") = value + End Set + End Property + Property GlobalDTAC_FuentesRecaudacion(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim StrSQL As String = String.Format("CveEmpresa = {0}", CveEmpresa) + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTAC_FuentesRecaudacion"), DataTable), StrSQL, "", DataViewRowState.CurrentRows) + GlobalDTAC_FuentesRecaudacion = Dv.ToTable + Dv.Dispose() + Else + GlobalDTAC_FuentesRecaudacion = DirectCast(HttpContext.Current.Application("GlobalDTAC_FuentesRecaudacion"), DataTable) + End If + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTAC_FuentesRecaudacion") = value + End Set + End Property + + Property GlobalDTAC_FuentesFinanciamiento() As DataTable + Get + GlobalDTAC_FuentesFinanciamiento = DirectCast(HttpContext.Current.Application("GlobalDTAC_FuentesFinanciamiento"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTAC_FuentesFinanciamiento") = value + End Set + End Property + Property GlobalDTAC_OG() As DataTable + Get + GlobalDTAC_OG = DirectCast(HttpContext.Current.Application("GlobalDTAC_OG"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTAC_OG") = value + End Set + End Property + 'Property GlobalDTAC_ClasificadorOG(CveEmpresa As Integer) As DataTable + ' Get + ' If CveEmpresa <> -1 Then + ' Dim StrSQL As String = String.Format("CveEmpresa = {0}", CveEmpresa) + ' Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTAC_ClasificadorOG"), DataTable), StrSQL, "", DataViewRowState.CurrentRows) + ' GlobalDTAC_ClasificadorOG = Dv.ToTable + ' Dv.Dispose() + ' Else + ' GlobalDTAC_ClasificadorOG = DirectCast(HttpContext.Current.Application("GlobalDTAC_ClasificadorOG"), DataTable) + ' End If + ' End Get + ' Set(value As DataTable) + ' HttpContext.Current.Application("GlobalDTAC_ClasificadorOG") = value + ' End Set + 'End Property + Property GlobalDTAC_Ubicaciones() As DataTable + Get + GlobalDTAC_Ubicaciones = DirectCast(HttpContext.Current.Application("GlobalDTAC_Ubicaciones"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTAC_Ubicaciones") = value + End Set + End Property + Property GlobalDTAC_UnidadesAdministrativas(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim StrSQL As String = String.Format("CveEmpresa = {0}", CveEmpresa) + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTAC_UnidadesAdministrativas"), DataTable), StrSQL, "", DataViewRowState.CurrentRows) + GlobalDTAC_UnidadesAdministrativas = Dv.ToTable + Dv.Dispose() + Else + GlobalDTAC_UnidadesAdministrativas = DirectCast(HttpContext.Current.Application("GlobalDTAC_UnidadesAdministrativas"), DataTable) + End If + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTAC_UnidadesAdministrativas") = value + End Set + End Property + Property GlobalDTAC_ClasificacionFuncional(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTAC_ClasificacionFuncional"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTAC_ClasificacionFuncional = Dv.ToTable + Dv.Dispose() + Else + GlobalDTAC_ClasificacionFuncional = DirectCast(HttpContext.Current.Application("GlobalDTAC_ClasificacionFuncional"), DataTable) + End If + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTAC_ClasificacionFuncional") = value + End Set + End Property + Property GlobalDTAC_ClasificacionGeografica(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTAC_ClasificacionGeografica"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTAC_ClasificacionGeografica = Dv.ToTable + Dv.Dispose() + Else + GlobalDTAC_ClasificacionGeografica = DirectCast(HttpContext.Current.Application("GlobalDTAC_ClasificacionGeografica"), DataTable) + End If + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTAC_ClasificacionGeografica") = value + End Set + End Property + Property GlobalDTAC_Cuentas() As DataTable + Get + GlobalDTAC_Cuentas = DirectCast(HttpContext.Current.Application("GlobalDTAC_Cuentas"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTAC_Cuentas") = value + End Set + End Property + Property GlobalDTAC_Finalidad() As DataTable + Get + GlobalDTAC_Finalidad = DirectCast(HttpContext.Current.Application("GlobalDTAC_Finalidad"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTAC_Finalidad") = value + End Set + End Property + 'Property GlobalDTAC_FuenteFinanciamiento() As DataTable + ' Get + ' GlobalDTAC_FuenteFinanciamiento = DirectCast(HttpContext.Current.Application("GlobalDTAC_FuenteFinanciamiento"), DataTable) + ' End Get + ' Set(value As DataTable) + ' HttpContext.Current.Application("GlobalDTAC_FuenteFinanciamiento") = value + ' End Set + 'End Property + Property GlobalDTAC_FuentesFinanciamiento(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim StrSQL As String = String.Format("CveEmpresa = {0}", CveEmpresa) + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTAC_FuentesFinanciamiento"), DataTable), StrSQL, "", DataViewRowState.CurrentRows) + GlobalDTAC_FuentesFinanciamiento = Dv.ToTable + Dv.Dispose() + Else + GlobalDTAC_FuentesFinanciamiento = DirectCast(HttpContext.Current.Application("GlobalDTAC_FuentesFinanciamiento"), DataTable) + End If + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTAC_FuentesFinanciamiento") = value + End Set + End Property + Property GlobalDTAC_FuentesFinanciamientoCONAC() As DataTable + Get + GlobalDTAC_FuentesFinanciamientoCONAC = DirectCast(HttpContext.Current.Application("GlobalDTAC_FuentesFinanciamientoCONAC"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTAC_FuentesFinanciamientoCONAC") = value + End Set + End Property + Property GlobalDTAC_Funcion() As DataTable + Get + GlobalDTAC_Funcion = DirectCast(HttpContext.Current.Application("GlobalDTAC_Funcion"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTAC_Funcion") = value + End Set + End Property + Property GlobalDTAC_Programas() As DataTable + Get + GlobalDTAC_Programas = DirectCast(HttpContext.Current.Application("GlobalDTAC_Programas"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTAC_Programas") = value + End Set + End Property + Property GlobalDTAC_ProgramasCONAC() As DataTable + Get + GlobalDTAC_ProgramasCONAC = DirectCast(HttpContext.Current.Application("GlobalDTAC_ProgramasCONAC"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTAC_ProgramasCONAC") = value + End Set + End Property + Property GlobalDTAC_ProyectosProceso() As DataTable + Get + GlobalDTAC_ProyectosProceso = DirectCast(HttpContext.Current.Application("GlobalDTAC_ProyectosProceso"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTAC_ProyectosProceso") = value + End Set + End Property + Property GlobalDTAC_SubFuncion() As DataTable + Get + GlobalDTAC_SubFuncion = DirectCast(HttpContext.Current.Application("GlobalDTAC_SubFuncion"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTAC_SubFuncion") = value + End Set + End Property + Property GlobalDTAC_SubProgramas() As DataTable + Get + GlobalDTAC_SubProgramas = DirectCast(HttpContext.Current.Application("GlobalDTAC_SubProgramas"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTAC_SubProgramas") = value + End Set + End Property + Property GlobalDTAC_ClasificacionAdministrativa(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTAC_ClasificacionAdministrativa"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTAC_ClasificacionAdministrativa = Dv.ToTable + Dv.Dispose() + Else + GlobalDTAC_ClasificacionAdministrativa = DirectCast(HttpContext.Current.Application("GlobalDTAC_ClasificacionAdministrativa"), DataTable) + End If + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTAC_ClasificacionAdministrativa") = value + End Set + End Property + Property GlobalDTAC_TipoGasto() As DataTable + Get + GlobalDTAC_TipoGasto = DirectCast(HttpContext.Current.Application("GlobalDTAC_TipoGasto"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTAC_TipoGasto") = value + End Set + End Property + + Property GlobalDTAC_ProgramaOperativo(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTAC_ProgramaOperativo"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTAC_ProgramaOperativo = Dv.ToTable + Dv.Dispose() + Else + GlobalDTAC_ProgramaOperativo = DirectCast(HttpContext.Current.Application("GlobalDTAC_ProgramaOperativo"), DataTable) + End If + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTAC_ProgramaOperativo") = value + End Set + End Property + + Property GlobalDTAC_MatrizIngresos() As DataTable + Get + GlobalDTAC_MatrizIngresos = DirectCast(HttpContext.Current.Application("GlobalDTAC_MatrizIngresos"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTAC_MatrizIngresos") = value + End Set + End Property + + Property GlobalDTAC_MatrizEgresos() As DataTable + Get + GlobalDTAC_MatrizEgresos = DirectCast(HttpContext.Current.Application("GlobalDTAC_MatrizEgresos"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTAC_MatrizEgresos") = value + End Set End Property -#End Region +#End Region - Property GlobalDTAC_PD_EjeRector(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTAC_PD_EjeRector"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTAC_PD_EjeRector = Dv.ToTable - Dv.Dispose() - Else - GlobalDTAC_PD_EjeRector = DirectCast(HttpContext.Current.Application("GlobalDTAC_PD_EjeRector"), DataTable) - End If - - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTAC_PD_EjeRector") = value - End Set - End Property - - Property GlobalDTAC_PD_Programas(CveEjeRector As Integer) As DataTable - Get - If CveEjeRector <> -1 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTAC_PD_Programas"), DataTable), String.Format("CveEjeRector = {0}", CveEjeRector), "", DataViewRowState.CurrentRows) - GlobalDTAC_PD_Programas = Dv.ToTable - Dv.Dispose() - Else - GlobalDTAC_PD_Programas = DirectCast(HttpContext.Current.Application("GlobalDTAC_PD_Programas"), DataTable) - End If - - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTAC_PD_Programas") = value - End Set - End Property - - Property GlobalDTAC_PD_Estrategias(CveProgramas As Integer) As DataTable - Get - If CveProgramas <> -1 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTAC_PD_Estrategias"), DataTable), String.Format("CvePrograma = {0}", CveProgramas), "", DataViewRowState.CurrentRows) - GlobalDTAC_PD_Estrategias = Dv.ToTable - Dv.Dispose() - Else - GlobalDTAC_PD_Estrategias = DirectCast(HttpContext.Current.Application("GlobalDTAC_PD_Estrategias"), DataTable) - End If - - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTAC_PD_Estrategias") = value - End Set - End Property - - Property GlobalDTAC_PD_LineasAccion(CveEstrategias As Integer) As DataTable - Get - If CveEstrategias <> -1 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTAC_PD_LineasAccion"), DataTable), String.Format("CveEstrategia = {0}", CveEstrategias), "", DataViewRowState.CurrentRows) - GlobalDTAC_PD_LineasAccion = Dv.ToTable - Dv.Dispose() - Else - GlobalDTAC_PD_LineasAccion = DirectCast(HttpContext.Current.Application("GlobalDTAC_PD_LineasAccion"), DataTable) - End If - - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTAC_PD_LineasAccion") = value - End Set - End Property - - Property GlobalDTAC_PD_Metas(CveLineasAccion As Integer) As DataTable - Get - If CveLineasAccion <> -1 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTAC_PD_Metas"), DataTable), String.Format("CveLineaAccion = {0}", CveLineasAccion), "", DataViewRowState.CurrentRows) - GlobalDTAC_PD_Metas = Dv.ToTable - Dv.Dispose() - Else - GlobalDTAC_PD_Metas = DirectCast(HttpContext.Current.Application("GlobalDTAC_PD_Metas"), DataTable) - End If - - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTAC_PD_Metas") = value - End Set + Property GlobalDTAC_PD_EjeRector(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTAC_PD_EjeRector"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTAC_PD_EjeRector = Dv.ToTable + Dv.Dispose() + Else + GlobalDTAC_PD_EjeRector = DirectCast(HttpContext.Current.Application("GlobalDTAC_PD_EjeRector"), DataTable) + End If + + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTAC_PD_EjeRector") = value + End Set End Property -#End Region -#Region "***********************************************************************GLOBAL DT ORDENES DE COMPRA***********************************************************************" - Property GlobalDTOCEstatus(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTOCEstatus"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) - GlobalDTOCEstatus = Dv.ToTable - Dv.Dispose() - Else - GlobalDTOCEstatus = DirectCast(HttpContext.Current.Application("GlobalDTOCEstatus"), DataTable) - End If - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTOCEstatus") = value - End Set - End Property - Property GlobalDTOCEstatusUsuarios(CveEmpresa As Integer, Optional CveUsuario As Integer = -1, Optional Tipo As String = "") As DataTable - Get - If CveEmpresa <> -1 Then - Dim filtro As New StringBuilder - filtro.AppendFormat("CveEmpresa = {0} ", CveEmpresa) - If CveUsuario > 0 Then - filtro.AppendFormat(" AND CveUsuario={0} ", CveUsuario) - End If - If Tipo <> "" Then - filtro.AppendFormat(" AND Tipo='{0}'", Tipo) - End If - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTOCEstatusUsuarios"), DataTable), filtro.ToString, "", DataViewRowState.CurrentRows) - GlobalDTOCEstatusUsuarios = Dv.ToTable - Dv.Dispose() - Else - GlobalDTOCEstatusUsuarios = DirectCast(HttpContext.Current.Application("GlobalDTOCEstatusUsuarios"), DataTable) - End If - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTOCEstatusUsuarios") = value - End Set + Property GlobalDTAC_PD_Programas(CveEjeRector As Integer) As DataTable + Get + If CveEjeRector <> -1 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTAC_PD_Programas"), DataTable), String.Format("CveEjeRector = {0}", CveEjeRector), "", DataViewRowState.CurrentRows) + GlobalDTAC_PD_Programas = Dv.ToTable + Dv.Dispose() + Else + GlobalDTAC_PD_Programas = DirectCast(HttpContext.Current.Application("GlobalDTAC_PD_Programas"), DataTable) + End If + + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTAC_PD_Programas") = value + End Set + End Property + + Property GlobalDTAC_PD_Estrategias(CveProgramas As Integer) As DataTable + Get + If CveProgramas <> -1 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTAC_PD_Estrategias"), DataTable), String.Format("CvePrograma = {0}", CveProgramas), "", DataViewRowState.CurrentRows) + GlobalDTAC_PD_Estrategias = Dv.ToTable + Dv.Dispose() + Else + GlobalDTAC_PD_Estrategias = DirectCast(HttpContext.Current.Application("GlobalDTAC_PD_Estrategias"), DataTable) + End If + + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTAC_PD_Estrategias") = value + End Set + End Property + + Property GlobalDTAC_PD_LineasAccion(CveEstrategias As Integer) As DataTable + Get + If CveEstrategias <> -1 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTAC_PD_LineasAccion"), DataTable), String.Format("CveEstrategia = {0}", CveEstrategias), "", DataViewRowState.CurrentRows) + GlobalDTAC_PD_LineasAccion = Dv.ToTable + Dv.Dispose() + Else + GlobalDTAC_PD_LineasAccion = DirectCast(HttpContext.Current.Application("GlobalDTAC_PD_LineasAccion"), DataTable) + End If + + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTAC_PD_LineasAccion") = value + End Set + End Property + + Property GlobalDTAC_PD_Metas(CveLineasAccion As Integer) As DataTable + Get + If CveLineasAccion <> -1 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTAC_PD_Metas"), DataTable), String.Format("CveLineaAccion = {0}", CveLineasAccion), "", DataViewRowState.CurrentRows) + GlobalDTAC_PD_Metas = Dv.ToTable + Dv.Dispose() + Else + GlobalDTAC_PD_Metas = DirectCast(HttpContext.Current.Application("GlobalDTAC_PD_Metas"), DataTable) + End If + + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTAC_PD_Metas") = value + End Set + End Property +#End Region + +#Region "***********************************************************************GLOBAL DT ORDENES DE COMPRA***********************************************************************" + Property GlobalDTOCEstatus(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTOCEstatus"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows) + GlobalDTOCEstatus = Dv.ToTable + Dv.Dispose() + Else + GlobalDTOCEstatus = DirectCast(HttpContext.Current.Application("GlobalDTOCEstatus"), DataTable) + End If + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTOCEstatus") = value + End Set + End Property + Property GlobalDTOCEstatusUsuarios(CveEmpresa As Integer, Optional CveUsuario As Integer = -1, Optional Tipo As String = "") As DataTable + Get + If CveEmpresa <> -1 Then + Dim filtro As New StringBuilder + filtro.AppendFormat("CveEmpresa = {0} ", CveEmpresa) + If CveUsuario > 0 Then + filtro.AppendFormat(" AND CveUsuario={0} ", CveUsuario) + End If + If Tipo <> "" Then + filtro.AppendFormat(" AND Tipo='{0}'", Tipo) + End If + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTOCEstatusUsuarios"), DataTable), filtro.ToString, "", DataViewRowState.CurrentRows) + GlobalDTOCEstatusUsuarios = Dv.ToTable + Dv.Dispose() + Else + GlobalDTOCEstatusUsuarios = DirectCast(HttpContext.Current.Application("GlobalDTOCEstatusUsuarios"), DataTable) + End If + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTOCEstatusUsuarios") = value + End Set End Property -#End Region +#End Region -#Region "F I N A N Z A S " - Property GlobalDTFinan_RazonesFinancieras() As DataTable - Get - GlobalDTFinan_RazonesFinancieras = DirectCast(HttpContext.Current.Application("GlobalDTFinan_RazonesFinancieras"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTFinan_RazonesFinancieras") = value - End Set +#Region "F I N A N Z A S " + Property GlobalDTFinan_RazonesFinancieras() As DataTable + Get + GlobalDTFinan_RazonesFinancieras = DirectCast(HttpContext.Current.Application("GlobalDTFinan_RazonesFinancieras"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTFinan_RazonesFinancieras") = value + End Set End Property -#End Region +#End Region -#Region "***********************************************************************GLOBAL DT CONTABILIDAD****************************************************************************" - Property GlobalDTContaPlantillasPolizas(CveEmpresa As Integer, Optional TipoPlantilla As Integer = -1) As DataTable - Get - If CveEmpresa <> -1 Or TipoPlantilla <> -1 Then - Dim Str As New StringBuilder - If CveEmpresa <> -1 Then Str.AppendFormat(" AND CveEmpresa = {0}", CveEmpresa) - If TipoPlantilla <> -1 Then Str.AppendFormat(" AND TipoPlantilla = {0}", TipoPlantilla) - - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTContaPlantillasPolizas"), DataTable), Str.ToString.Substring(5), "", DataViewRowState.CurrentRows) - GlobalDTContaPlantillasPolizas = Dv.ToTable - Dv.Dispose() - Else - GlobalDTContaPlantillasPolizas = DirectCast(HttpContext.Current.Application("GlobalDTContaPlantillasPolizas"), DataTable) - End If - - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTContaPlantillasPolizas") = value - End Set - End Property - - Property GlobalDTContaPlantillasPolizasDetalle(CvePlantillaPoliza As Integer) As DataTable - Get - If CvePlantillaPoliza <> -1 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTContaPlantillasPolizasDetalle"), DataTable), String.Format("CvePlantillaPoliza = {0}", CvePlantillaPoliza), "", DataViewRowState.CurrentRows) - GlobalDTContaPlantillasPolizasDetalle = Dv.ToTable - Dv.Dispose() - Else - GlobalDTContaPlantillasPolizasDetalle = DirectCast(HttpContext.Current.Application("GlobalDTContaPlantillasPolizasDetalle"), DataTable) - End If - - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTContaPlantillasPolizasDetalle") = value - End Set - End Property - - - - Property GlobalDTContaConceptosContables(CvePlantillaPoliza As Integer) As DataTable - Get - If CvePlantillaPoliza <> -1 Then - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTContaConceptosContables"), DataTable), String.Format("CvePlantillaPoliza = {0}", CvePlantillaPoliza), "", DataViewRowState.CurrentRows) - GlobalDTContaConceptosContables = Dv.ToTable - Dv.Dispose() - Else - GlobalDTContaConceptosContables = DirectCast(HttpContext.Current.Application("GlobalDTContaConceptosContables"), DataTable) - End If - - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTContaConceptosContables") = value - End Set - End Property -#End Region +#Region "***********************************************************************GLOBAL DT CONTABILIDAD****************************************************************************" + Property GlobalDTContaPlantillasPolizas(CveEmpresa As Integer, Optional TipoPlantilla As Integer = -1) As DataTable + Get + If CveEmpresa <> -1 Or TipoPlantilla <> -1 Then + Dim Str As New StringBuilder + If CveEmpresa <> -1 Then Str.AppendFormat(" AND CveEmpresa = {0}", CveEmpresa) + If TipoPlantilla <> -1 Then Str.AppendFormat(" AND TipoPlantilla = {0}", TipoPlantilla) -#Region "**********************************************************************GLOBAL DT RH (RECURSOS HUMANOS)********************************************************************" - Property GlobalDTAsistenciaDetalle() As DataTable - Get - GlobalDTAsistenciaDetalle = DirectCast(HttpContext.Current.Application("GlobalDTAsistenciaDetalle"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTAsistenciaDetalle") = value - End Set - End Property - Property GlobalDTAsistenciasInasistencias() As DataTable - Get - GlobalDTAsistenciasInasistencias = DirectCast(HttpContext.Current.Application("GlobalDTAsistenciasInasistencias"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTAsistenciasInasistencias") = value - End Set - End Property - Property GlobalDTEstatusPersonal() As DataTable - Get - GlobalDTEstatusPersonal = DirectCast(HttpContext.Current.Application("GlobalDTEstatusPersonal"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTEstatusPersonal") = value - End Set - End Property - - Property GlobalDTRHPersonal(CveEmpresa As Integer) As DataTable - Get - Dim ObjPersonal As New ClsRH - ObjPersonal.GetPersonal(-1, CveEmpresa) - GlobalDTRHPersonal = ObjPersonal.DtResultados - ObjPersonal.Dispose() - - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTRHPersonal") = value - End Set - End Property - - - Property GlobalDTDepartamentos() As DataTable - Get - GlobalDTDepartamentos = DirectCast(HttpContext.Current.Application("GlobalDTDepartamentos"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTDepartamentos") = value - End Set - End Property - Property GlobalDTRHPuestos(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim StrSQL As String = String.Format("CveEmpresa = {0}", CveEmpresa) - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTRHPuestos"), DataTable), StrSQL, "", DataViewRowState.CurrentRows) - GlobalDTRHPuestos = Dv.ToTable - Dv.Dispose() - Else - GlobalDTRHPuestos = DirectCast(HttpContext.Current.Application("GlobalDTRHPuestos"), DataTable) - End If - - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTRHPuestos") = value - End Set - End Property - Property GlobalDTEscolaridad() As DataTable - Get - GlobalDTEscolaridad = DirectCast(HttpContext.Current.Application("GlobalDTEscolaridad"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTEscolaridad") = value - End Set - End Property - Property GlobalDTEstadoCivil() As DataTable - Get - GlobalDTEstadoCivil = DirectCast(HttpContext.Current.Application("GlobalDTEstadoCivil"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTEstadoCivil") = value - End Set - End Property - Property GlobalDTDocumentos() As DataTable - Get - GlobalDTDocumentos = DirectCast(HttpContext.Current.Application("GlobalDTDocumentos"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTDocumentos") = value - End Set - End Property - Property GlobalDTGenero() As DataTable - Get - GlobalDTGenero = DirectCast(HttpContext.Current.Application("GlobalDTGenero"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTGenero") = value - End Set - End Property - Property GlobalDTMotivoBaja() As DataTable - Get - GlobalDTMotivoBaja = DirectCast(HttpContext.Current.Application("GlobalDTMotivoBaja"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTMotivoBaja") = value - End Set - End Property - Property GlobalDTTiposContrato() As DataTable - Get - GlobalDTTiposContrato = DirectCast(HttpContext.Current.Application("GlobalDTTiposContrato"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTTiposContrato") = value - End Set - End Property - Property GlobalDTRutas() As DataTable - Get - GlobalDTRutas = DirectCast(HttpContext.Current.Application("GlobalDTRutas"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTRutas") = value - End Set - End Property - Property GlobalDTTurno() As DataTable - Get - GlobalDTTurno = DirectCast(HttpContext.Current.Application("GlobalDTTurno"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTTurno") = value - End Set - End Property - Property GlobalDTJornadas() As DataTable - Get - GlobalDTJornadas = DirectCast(HttpContext.Current.Application("GlobalDTJornadas"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTJornadas") = value - End Set - End Property - Property GlobalDTMotivosHorasExtras() As DataTable - Get - GlobalDTMotivosHorasExtras = DirectCast(HttpContext.Current.Application("GlobalDTMotivosHorasExtras"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTMotivosHorasExtras") = value - End Set - End Property - Property GlobalDTTipoBuzon() As DataTable - Get - GlobalDTTipoBuzon = DirectCast(HttpContext.Current.Application("GlobalDTTipoBuzon"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTTipoBuzon") = value - End Set - End Property -#End Region + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTContaPlantillasPolizas"), DataTable), Str.ToString.Substring(5), "", DataViewRowState.CurrentRows) + GlobalDTContaPlantillasPolizas = Dv.ToTable + Dv.Dispose() + Else + GlobalDTContaPlantillasPolizas = DirectCast(HttpContext.Current.Application("GlobalDTContaPlantillasPolizas"), DataTable) + End If -#Region "*********** D T - C O M B U S T I B L E S ***********" - - - - Property GlobalDTCombustibles(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim StrSQL As New StringBuilder - StrSQL.AppendFormat("CveEmpresa = {0}", CveEmpresa) - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTCombustibles"), DataTable), StrSQL.ToString, "", DataViewRowState.CurrentRows) - GlobalDTCombustibles = Dv.ToTable - Dv.Dispose() - - Else - GlobalDTCombustibles = DirectCast(HttpContext.Current.Application("GlobalDTCombustibles"), DataTable) - End If - - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTCombustibles") = value - End Set - End Property - - Property GlobalDTCombustiblesTipos(Optional CveCombustibleTipo As Integer = -1) As DataTable - Get - - If CveCombustibleTipo <> -1 Then - - Dim StrSQL As New StringBuilder - If CveCombustibleTipo <> -1 Then StrSQL.AppendFormat("CveCombustibleTipo = {0}", CveCombustibleTipo) - - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTCombustiblesTipos"), DataTable), StrSQL.ToString, "", DataViewRowState.CurrentRows) - GlobalDTCombustiblesTipos = Dv.ToTable - Dv.Dispose() - - Else - GlobalDTCombustiblesTipos = DirectCast(HttpContext.Current.Application("GlobalDTCombustiblesTipos"), DataTable) - End If - End Get - Set(ByVal value As DataTable) - HttpContext.Current.Application("GlobalDTCombustiblesTipos") = value - End Set - End Property -#End Region - -#Region "*********** D T - M A N T E N I M I E N T O S ***********" - - Property GlobalDTMantenimientosTipos() As DataTable - Get - GlobalDTMantenimientosTipos = DirectCast(HttpContext.Current.Application("GlobalDTMantenimientosTipos"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTMantenimientosTipos") = value - End Set - End Property - - Property GlobalDTMantenimientos() As DataTable - Get - GlobalDTMantenimientos = DirectCast(HttpContext.Current.Application("GlobalDTMantenimientos"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTMantenimientos") = value - End Set - End Property - - Property GlobalDTMantenimientosTipos(Optional CveMantenimientoTipo As Integer = -1) As DataTable - Get - - If CveMantenimientoTipo <> -1 Then - - Dim StrSQL As New StringBuilder - If CveMantenimientoTipo <> -1 Then StrSQL.AppendFormat("CveMantenimientoTipo = {0}", CveMantenimientoTipo) - - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTMantenimientosTipos"), DataTable), StrSQL.ToString, "", DataViewRowState.CurrentRows) - GlobalDTMantenimientosTipos = Dv.ToTable - Dv.Dispose() - - Else - GlobalDTMantenimientosTipos = DirectCast(HttpContext.Current.Application("GlobalDTMantenimientosTipos"), DataTable) - End If - End Get - Set(ByVal value As DataTable) - - HttpContext.Current.Application("GlobalDTMantenimientosTipos") = value - End Set + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTContaPlantillasPolizas") = value + End Set End Property -#End Region + Property GlobalDTContaPlantillasPolizasDetalle(CvePlantillaPoliza As Integer) As DataTable + Get + If CvePlantillaPoliza <> -1 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTContaPlantillasPolizasDetalle"), DataTable), String.Format("CvePlantillaPoliza = {0}", CvePlantillaPoliza), "", DataViewRowState.CurrentRows) + GlobalDTContaPlantillasPolizasDetalle = Dv.ToTable + Dv.Dispose() + Else + GlobalDTContaPlantillasPolizasDetalle = DirectCast(HttpContext.Current.Application("GlobalDTContaPlantillasPolizasDetalle"), DataTable) + End If - -#Region "*********** D T - T A L L E R E S ***********" - - Property GlobalDTTalleresTipos() As DataTable - Get - GlobalDTTalleresTipos = DirectCast(HttpContext.Current.Application("GlobalDTTalleresTipos"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTTalleresTipos") = value - End Set - End Property - - Property GlobalDTTalleres() As DataTable - Get - GlobalDTTalleres = DirectCast(HttpContext.Current.Application("GlobalDTTalleres"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTTalleres") = value - End Set + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTContaPlantillasPolizasDetalle") = value + End Set End Property -#End Region -#Region "*********** D T - D I S T R I B U I D O R E S ***********" - Property GlobalDTDistribuidoresTipos() As DataTable - Get - GlobalDTDistribuidoresTipos = DirectCast(HttpContext.Current.Application("GlobalDTDistribuidoresTipos"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTDistribuidoresTipos") = value - End Set - End Property - - Property GlobalDTDistribuidores() As DataTable - Get - GlobalDTDistribuidores = DirectCast(HttpContext.Current.Application("GlobalDTDistribuidores"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTDistribuidores") = value - End Set + Property GlobalDTContaConceptosContables(CvePlantillaPoliza As Integer) As DataTable + Get + If CvePlantillaPoliza <> -1 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTContaConceptosContables"), DataTable), String.Format("CvePlantillaPoliza = {0}", CvePlantillaPoliza), "", DataViewRowState.CurrentRows) + GlobalDTContaConceptosContables = Dv.ToTable + Dv.Dispose() + Else + GlobalDTContaConceptosContables = DirectCast(HttpContext.Current.Application("GlobalDTContaConceptosContables"), DataTable) + End If + + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTContaConceptosContables") = value + End Set + End Property +#End Region + +#Region "**********************************************************************GLOBAL DT RH (RECURSOS HUMANOS)********************************************************************" + Property GlobalDTAsistenciaDetalle() As DataTable + Get + GlobalDTAsistenciaDetalle = DirectCast(HttpContext.Current.Application("GlobalDTAsistenciaDetalle"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTAsistenciaDetalle") = value + End Set + End Property + Property GlobalDTAsistenciasInasistencias() As DataTable + Get + GlobalDTAsistenciasInasistencias = DirectCast(HttpContext.Current.Application("GlobalDTAsistenciasInasistencias"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTAsistenciasInasistencias") = value + End Set + End Property + Property GlobalDTEstatusPersonal() As DataTable + Get + GlobalDTEstatusPersonal = DirectCast(HttpContext.Current.Application("GlobalDTEstatusPersonal"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTEstatusPersonal") = value + End Set End Property -#End Region + Property GlobalDTRHPersonal(CveEmpresa As Integer) As DataTable + Get + Dim ObjPersonal As New ClsRH + ObjPersonal.GetPersonal(-1, CveEmpresa) + GlobalDTRHPersonal = ObjPersonal.DtResultados + ObjPersonal.Dispose() - - Property GlobalDTOIRevision(CveEmpresa As Integer) As DataTable - Get - If CveEmpresa <> -1 Then - Dim StrSQL As String = String.Format("CveEmpresa = {0}", CveEmpresa) - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTOIRevision"), DataTable), StrSQL, "", DataViewRowState.CurrentRows) - GlobalDTOIRevision = Dv.ToTable - Dv.Dispose() - Else - GlobalDTOIRevision = DirectCast(HttpContext.Current.Application("GlobalDTOIRevision"), DataTable) - End If - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTOIRevision") = value - End Set - End Property - Property GlobalDTOIAgendaTipo() As DataTable - Get - GlobalDTOIAgendaTipo = DirectCast(HttpContext.Current.Application("GlobalDTOIAgendaTipo"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTOIAgendaTipo") = value - End Set - End Property - Property GlobalDTOIAgenda() As DataTable - Get - GlobalDTOIAgenda = DirectCast(HttpContext.Current.Application("GlobalDTOIAgenda"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTOIAgenda") = value - End Set - End Property - Property GlobalDTVtaCondicionesEntrega(Optional CveEmpresa As Integer = -1) As DataTable - Get - If CveEmpresa <> -1 Then - Dim StrSQL As String = String.Format("CveEmpresa = {0}", CveEmpresa) - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTVtaCondicionesEntrega"), DataTable), StrSQL, "", DataViewRowState.CurrentRows) - GlobalDTVtaCondicionesEntrega = Dv.ToTable - Dv.Dispose() - Else - GlobalDTVtaCondicionesEntrega = DirectCast(HttpContext.Current.Application("GlobalDTVtaCondicionesEntrega"), DataTable) - End If - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTVtaCondicionesEntrega") = value - End Set - End Property - Property GlobalDTPaqueteriaGuiaTipos(CveEmpresa As Integer) As DataTable - - Get - If CveEmpresa <> -1 Then - Dim StrSQL As String = String.Format("CveEmpresa = {0}", CveEmpresa) - Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTPaqueteriaGuiaTipos"), DataTable), StrSQL, "", DataViewRowState.CurrentRows) - GlobalDTPaqueteriaGuiaTipos = Dv.ToTable - Dv.Dispose() - Else - GlobalDTPaqueteriaGuiaTipos = DirectCast(HttpContext.Current.Application("GlobalDTPaqueteriaGuiaTipos"), DataTable) - End If - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTPaqueteriaGuiaTipos") = value - End Set + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTRHPersonal") = value + End Set End Property - Property GlobalDTClasificacionPorcentaje(CveEmpresa As Integer, Optional CveClasicacionPorcentaje As Integer = -1, Optional CveClasicacion As Integer = -1, + + + Property GlobalDTDepartamentos() As DataTable + Get + GlobalDTDepartamentos = DirectCast(HttpContext.Current.Application("GlobalDTDepartamentos"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTDepartamentos") = value + End Set + End Property + Property GlobalDTRHPuestos(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim StrSQL As String = String.Format("CveEmpresa = {0}", CveEmpresa) + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTRHPuestos"), DataTable), StrSQL, "", DataViewRowState.CurrentRows) + GlobalDTRHPuestos = Dv.ToTable + Dv.Dispose() + Else + GlobalDTRHPuestos = DirectCast(HttpContext.Current.Application("GlobalDTRHPuestos"), DataTable) + End If + + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTRHPuestos") = value + End Set + End Property + Property GlobalDTEscolaridad() As DataTable + Get + GlobalDTEscolaridad = DirectCast(HttpContext.Current.Application("GlobalDTEscolaridad"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTEscolaridad") = value + End Set + End Property + Property GlobalDTEstadoCivil() As DataTable + Get + GlobalDTEstadoCivil = DirectCast(HttpContext.Current.Application("GlobalDTEstadoCivil"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTEstadoCivil") = value + End Set + End Property + Property GlobalDTDocumentos() As DataTable + Get + GlobalDTDocumentos = DirectCast(HttpContext.Current.Application("GlobalDTDocumentos"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTDocumentos") = value + End Set + End Property + Property GlobalDTGenero() As DataTable + Get + GlobalDTGenero = DirectCast(HttpContext.Current.Application("GlobalDTGenero"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTGenero") = value + End Set + End Property + Property GlobalDTMotivoBaja() As DataTable + Get + GlobalDTMotivoBaja = DirectCast(HttpContext.Current.Application("GlobalDTMotivoBaja"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTMotivoBaja") = value + End Set + End Property + Property GlobalDTTiposContrato() As DataTable + Get + GlobalDTTiposContrato = DirectCast(HttpContext.Current.Application("GlobalDTTiposContrato"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTTiposContrato") = value + End Set + End Property + Property GlobalDTRutas() As DataTable + Get + GlobalDTRutas = DirectCast(HttpContext.Current.Application("GlobalDTRutas"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTRutas") = value + End Set + End Property + Property GlobalDTTurno() As DataTable + Get + GlobalDTTurno = DirectCast(HttpContext.Current.Application("GlobalDTTurno"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTTurno") = value + End Set + End Property + Property GlobalDTJornadas() As DataTable + Get + GlobalDTJornadas = DirectCast(HttpContext.Current.Application("GlobalDTJornadas"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTJornadas") = value + End Set + End Property + Property GlobalDTMotivosHorasExtras() As DataTable + Get + GlobalDTMotivosHorasExtras = DirectCast(HttpContext.Current.Application("GlobalDTMotivosHorasExtras"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTMotivosHorasExtras") = value + End Set + End Property + Property GlobalDTTipoBuzon() As DataTable + Get + GlobalDTTipoBuzon = DirectCast(HttpContext.Current.Application("GlobalDTTipoBuzon"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTTipoBuzon") = value + End Set + End Property +#End Region + +#Region "*********** D T - C O M B U S T I B L E S ***********" + + + + Property GlobalDTCombustibles(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim StrSQL As New StringBuilder + StrSQL.AppendFormat("CveEmpresa = {0}", CveEmpresa) + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTCombustibles"), DataTable), StrSQL.ToString, "", DataViewRowState.CurrentRows) + GlobalDTCombustibles = Dv.ToTable + Dv.Dispose() + + Else + GlobalDTCombustibles = DirectCast(HttpContext.Current.Application("GlobalDTCombustibles"), DataTable) + End If + + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTCombustibles") = value + End Set + End Property + + Property GlobalDTCombustiblesTipos(Optional CveCombustibleTipo As Integer = -1) As DataTable + Get + + If CveCombustibleTipo <> -1 Then + + Dim StrSQL As New StringBuilder + If CveCombustibleTipo <> -1 Then StrSQL.AppendFormat("CveCombustibleTipo = {0}", CveCombustibleTipo) + + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTCombustiblesTipos"), DataTable), StrSQL.ToString, "", DataViewRowState.CurrentRows) + GlobalDTCombustiblesTipos = Dv.ToTable + Dv.Dispose() + + Else + GlobalDTCombustiblesTipos = DirectCast(HttpContext.Current.Application("GlobalDTCombustiblesTipos"), DataTable) + End If + End Get + Set(ByVal value As DataTable) + HttpContext.Current.Application("GlobalDTCombustiblesTipos") = value + End Set + End Property +#End Region + +#Region "*********** D T - M A N T E N I M I E N T O S ***********" + + Property GlobalDTMantenimientosTipos() As DataTable + Get + GlobalDTMantenimientosTipos = DirectCast(HttpContext.Current.Application("GlobalDTMantenimientosTipos"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTMantenimientosTipos") = value + End Set + End Property + + Property GlobalDTMantenimientos() As DataTable + Get + GlobalDTMantenimientos = DirectCast(HttpContext.Current.Application("GlobalDTMantenimientos"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTMantenimientos") = value + End Set + End Property + + Property GlobalDTMantenimientosTipos(Optional CveMantenimientoTipo As Integer = -1) As DataTable + Get + + If CveMantenimientoTipo <> -1 Then + + Dim StrSQL As New StringBuilder + If CveMantenimientoTipo <> -1 Then StrSQL.AppendFormat("CveMantenimientoTipo = {0}", CveMantenimientoTipo) + + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTMantenimientosTipos"), DataTable), StrSQL.ToString, "", DataViewRowState.CurrentRows) + GlobalDTMantenimientosTipos = Dv.ToTable + Dv.Dispose() + + Else + GlobalDTMantenimientosTipos = DirectCast(HttpContext.Current.Application("GlobalDTMantenimientosTipos"), DataTable) + End If + End Get + Set(ByVal value As DataTable) + + HttpContext.Current.Application("GlobalDTMantenimientosTipos") = value + End Set + End Property + +#End Region + + +#Region "*********** D T - T A L L E R E S ***********" + + Property GlobalDTTalleresTipos() As DataTable + Get + GlobalDTTalleresTipos = DirectCast(HttpContext.Current.Application("GlobalDTTalleresTipos"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTTalleresTipos") = value + End Set + End Property + + Property GlobalDTTalleres() As DataTable + Get + GlobalDTTalleres = DirectCast(HttpContext.Current.Application("GlobalDTTalleres"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTTalleres") = value + End Set + End Property + +#End Region + +#Region "*********** D T - D I S T R I B U I D O R E S ***********" + + Property GlobalDTDistribuidoresTipos() As DataTable + Get + GlobalDTDistribuidoresTipos = DirectCast(HttpContext.Current.Application("GlobalDTDistribuidoresTipos"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTDistribuidoresTipos") = value + End Set + End Property + + Property GlobalDTDistribuidores() As DataTable + Get + GlobalDTDistribuidores = DirectCast(HttpContext.Current.Application("GlobalDTDistribuidores"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTDistribuidores") = value + End Set + End Property + +#End Region + + + Property GlobalDTOIRevision(CveEmpresa As Integer) As DataTable + Get + If CveEmpresa <> -1 Then + Dim StrSQL As String = String.Format("CveEmpresa = {0}", CveEmpresa) + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTOIRevision"), DataTable), StrSQL, "", DataViewRowState.CurrentRows) + GlobalDTOIRevision = Dv.ToTable + Dv.Dispose() + Else + GlobalDTOIRevision = DirectCast(HttpContext.Current.Application("GlobalDTOIRevision"), DataTable) + End If + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTOIRevision") = value + End Set + End Property + Property GlobalDTOIAgendaTipo() As DataTable + Get + GlobalDTOIAgendaTipo = DirectCast(HttpContext.Current.Application("GlobalDTOIAgendaTipo"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTOIAgendaTipo") = value + End Set + End Property + Property GlobalDTOIAgenda() As DataTable + Get + GlobalDTOIAgenda = DirectCast(HttpContext.Current.Application("GlobalDTOIAgenda"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTOIAgenda") = value + End Set + End Property + Property GlobalDTVtaCondicionesEntrega(Optional CveEmpresa As Integer = -1) As DataTable + Get + If CveEmpresa <> -1 Then + Dim StrSQL As String = String.Format("CveEmpresa = {0}", CveEmpresa) + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTVtaCondicionesEntrega"), DataTable), StrSQL, "", DataViewRowState.CurrentRows) + GlobalDTVtaCondicionesEntrega = Dv.ToTable + Dv.Dispose() + Else + GlobalDTVtaCondicionesEntrega = DirectCast(HttpContext.Current.Application("GlobalDTVtaCondicionesEntrega"), DataTable) + End If + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTVtaCondicionesEntrega") = value + End Set + End Property + Property GlobalDTPaqueteriaGuiaTipos(CveEmpresa As Integer) As DataTable + + Get + If CveEmpresa <> -1 Then + Dim StrSQL As String = String.Format("CveEmpresa = {0}", CveEmpresa) + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTPaqueteriaGuiaTipos"), DataTable), StrSQL, "", DataViewRowState.CurrentRows) + GlobalDTPaqueteriaGuiaTipos = Dv.ToTable + Dv.Dispose() + Else + GlobalDTPaqueteriaGuiaTipos = DirectCast(HttpContext.Current.Application("GlobalDTPaqueteriaGuiaTipos"), DataTable) + End If + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTPaqueteriaGuiaTipos") = value + End Set + End Property + Property GlobalDTClasificacionPorcentaje(CveEmpresa As Integer, Optional CveClasicacionPorcentaje As Integer = -1, Optional CveClasicacion As Integer = -1, Optional PorcentajeIVA As Double = -1) As DataTable Get @@ -8645,655 +8645,655 @@ Namespace Modelos Set(value As DataTable) HttpContext.Current.Application("GlobalDTClasificacionPorcentaje") = value End Set - End Property - Property GlobalDTPaqueterias() As DataTable - Get - GlobalDTPaqueterias = DirectCast(HttpContext.Current.Application("GlobalDTPaqueterias"), DataTable) - End Get - Set(value As DataTable) - HttpContext.Current.Application("GlobalDTPaqueterias") = value - End Set - End Property - - Public Property CveContratoSecciones As String + End Property + Property GlobalDTPaqueterias() As DataTable + Get + GlobalDTPaqueterias = DirectCast(HttpContext.Current.Application("GlobalDTPaqueterias"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTPaqueterias") = value + End Set + End Property + + Public Property CveContratoSecciones As String Public Property CveEstatus As Integer Public Property GenerarPDFFactura As Boolean = False -#End Region +#End Region - End Class - - - Public Class ComplementoINE - Public Property INETipoProceso As String = "" - Public Property INETipoComite As String = "" - Public Property INEEntidad As String = "" - Public Property INEIdContabilidad As Integer = 0 - End Class - - - Public Class FemsaFactura - Inherits Modelos.EntityModel - Public Sub New() - MyBase.New() - End Sub - Public Sub New(Row As System.Data.DataRow) - setValues(Row) - End Sub - - Public Property AplicaFEMSA As Boolean = False 'AplicaFEMSA - Public Property FEMSA_NumSociedad As String 'TxtFEMSA_NumSociedad.Text.Trim, - Public Property FEMSA_NumProveedor As String 'TxtFEMSA_NumProveedor.Text.Trim, - Public Property FEMSA_Mail As String 'TxtFEMSA_Mail.Text.Trim - - - Public Property FEMSA_Version As Integer 'TxtFEMSA_Version.Text.ToEntero, ClaseDocto, - Public Property FEMSA_NumPedido As Long 'TxtFEMSA_NumPedido.Text.Trim.ToLong, - Public Property FEMSA_NumEntrada As String 'TxtFEMSA_NumEntrada.Text.Trim, - Public Property FEMSA_NumRemision As String 'TxtFEMSA_NumRemision.Text.Trim, - Public Property FEMSA_NumSocio As String 'TxtFEMSA_NumSocio.Text.Trim, - Public Property FEMSA_CentroCosto As String 'TxtFEMSA_CentroCosto.Text.Trim, - Public Property FEMSA_IPeriodoLiquidacion As String 'TxtFEMSA_IPeriodoLiquidacion.Text.Trim, - Public Property FEMSA_FPeriodoLiquidacion As String 'TxtFEMSA_FPeriodoLiquidacion.Text.Trim, - Public Property FEMSA_CodRetencion1 As String 'TxtFEMSA_CodRetencion1.Text.Trim, - Public Property FEMSA_CodRetencion2 As String 'TxtFEMSA_CodRetencion2.Text.Trim, - End Class - - - Public Class SucursalModel - Inherits Modelos.EntityModel - - Protected Overloads Sub SetDefaultValues() - Calle = "" - NoExt = "" - NoInt = "" - Colonia = "" - Localidad = "" - Municipio = "" - Estado = "" - Pais = "" - CP = "" - IVA = 0 - Serie = "" - TipoFormato = "" - FormatoFactura = "" - Sucursal = "" - CorreoSucursal = "" - End Sub - Public Sub New() - MyBase.New() - End Sub - Public Sub New(Row As System.Data.DataRow) - SetDefaultValues() - setValues(Row) - End Sub - - Public ReadOnly Property LugarExp As String - Get - Dim arr = {Calle, NoExt, NoInt, Colonia, Localidad, Municipio, Estado, Pais, CP} - Return String.Join(",", arr) - End Get - End Property - Public Property CveSucursal As Integer - Public Property Calle As String - Public Property Direccion As String - Public Property NoExt As String - Public Property NoInt As String - Public Property Colonia As String - Public Property Localidad As String - Public Property Municipio As String - Public Property Estado As String - Public Property Pais As String - Public Property CP As String - Public Property IVA As Decimal - Public Property Serie As String - Public Property TipoFormato As String - Public Property FormatoFactura As String - Public Property Sucursal As String - Public Property CorreoSucursal As String - Public Property TelefonoSucursal As String - Public Property ImprimeNombreSucursal As String - - End Class - - - Public Class SubProyectoModel - Inherits Modelos.EntityModel - - Protected Overloads Sub SetDefaultValues() - Calle = "" - NoExt = "" - NoInt = "" - Colonia = "" - Localidad = "" - Municipio = "" - Estado = "" - Pais = "" - CP = "" - IVA = 0 - Serie = "" - TipoFormato = "" - FormatoFactura = "" - SubProyecto = "" - Correo = "" - Telefono = "" - UTCOffsetVerano = -7 - UTCOffsetInvierno = -7 - End Sub - Public Sub New() - MyBase.New() - End Sub - Public Sub New(Row As System.Data.DataRow) - SetDefaultValues() - If Row IsNot Nothing Then - Me.setValues(Row) - End If - End Sub - - Public ReadOnly Property LugarExp As String - Get - Dim arr = {Calle, NoExt, NoInt, Colonia, Localidad, Municipio, Estado, Pais, CP, SubProyecto} - Return String.Join(",", arr) - End Get - End Property - Public Property CveSubProyecto As Integer - Public Property Calle As String - Public Property Direccion As String - Public Property NoExt As String - Public Property NoInt As String - Public Property Colonia As String - Public Property Localidad As String - Public Property Municipio As String - Public Property Estado As String - Public Property Pais As String - Public Property CP As String - Public Property IVA As Decimal - Public Property Serie As String - Public Property TipoFormato As String - Public Property FormatoFactura As String - Public Property SubProyecto As String - Public Property Correo As String - Public Property Telefono As String + End Class + + + Public Class ComplementoINE + Public Property INETipoProceso As String = "" + Public Property INETipoComite As String = "" + Public Property INEEntidad As String = "" + Public Property INEIdContabilidad As Integer = 0 + End Class + + + Public Class FemsaFactura + Inherits Modelos.EntityModel + Public Sub New() + MyBase.New() + End Sub + Public Sub New(Row As System.Data.DataRow) + setValues(Row) + End Sub + + Public Property AplicaFEMSA As Boolean = False 'AplicaFEMSA + Public Property FEMSA_NumSociedad As String 'TxtFEMSA_NumSociedad.Text.Trim, + Public Property FEMSA_NumProveedor As String 'TxtFEMSA_NumProveedor.Text.Trim, + Public Property FEMSA_Mail As String 'TxtFEMSA_Mail.Text.Trim + + + Public Property FEMSA_Version As Integer 'TxtFEMSA_Version.Text.ToEntero, ClaseDocto, + Public Property FEMSA_NumPedido As Long 'TxtFEMSA_NumPedido.Text.Trim.ToLong, + Public Property FEMSA_NumEntrada As String 'TxtFEMSA_NumEntrada.Text.Trim, + Public Property FEMSA_NumRemision As String 'TxtFEMSA_NumRemision.Text.Trim, + Public Property FEMSA_NumSocio As String 'TxtFEMSA_NumSocio.Text.Trim, + Public Property FEMSA_CentroCosto As String 'TxtFEMSA_CentroCosto.Text.Trim, + Public Property FEMSA_IPeriodoLiquidacion As String 'TxtFEMSA_IPeriodoLiquidacion.Text.Trim, + Public Property FEMSA_FPeriodoLiquidacion As String 'TxtFEMSA_FPeriodoLiquidacion.Text.Trim, + Public Property FEMSA_CodRetencion1 As String 'TxtFEMSA_CodRetencion1.Text.Trim, + Public Property FEMSA_CodRetencion2 As String 'TxtFEMSA_CodRetencion2.Text.Trim, + End Class + + + Public Class SucursalModel + Inherits Modelos.EntityModel + + Protected Overloads Sub SetDefaultValues() + Calle = "" + NoExt = "" + NoInt = "" + Colonia = "" + Localidad = "" + Municipio = "" + Estado = "" + Pais = "" + CP = "" + IVA = 0 + Serie = "" + TipoFormato = "" + FormatoFactura = "" + Sucursal = "" + CorreoSucursal = "" + End Sub + Public Sub New() + MyBase.New() + End Sub + Public Sub New(Row As System.Data.DataRow) + SetDefaultValues() + setValues(Row) + End Sub + + Public ReadOnly Property LugarExp As String + Get + Dim arr = {Calle, NoExt, NoInt, Colonia, Localidad, Municipio, Estado, Pais, CP} + Return String.Join(",", arr) + End Get + End Property + Public Property CveSucursal As Integer + Public Property Calle As String + Public Property Direccion As String + Public Property NoExt As String + Public Property NoInt As String + Public Property Colonia As String + Public Property Localidad As String + Public Property Municipio As String + Public Property Estado As String + Public Property Pais As String + Public Property CP As String + Public Property IVA As Decimal + Public Property Serie As String + Public Property TipoFormato As String + Public Property FormatoFactura As String + Public Property Sucursal As String + Public Property CorreoSucursal As String + Public Property TelefonoSucursal As String + Public Property ImprimeNombreSucursal As String + + End Class + + + Public Class SubProyectoModel + Inherits Modelos.EntityModel + + Protected Overloads Sub SetDefaultValues() + Calle = "" + NoExt = "" + NoInt = "" + Colonia = "" + Localidad = "" + Municipio = "" + Estado = "" + Pais = "" + CP = "" + IVA = 0 + Serie = "" + TipoFormato = "" + FormatoFactura = "" + SubProyecto = "" + Correo = "" + Telefono = "" + UTCOffsetVerano = -7 + UTCOffsetInvierno = -7 + End Sub + Public Sub New() + MyBase.New() + End Sub + Public Sub New(Row As System.Data.DataRow) + SetDefaultValues() + If Row IsNot Nothing Then + Me.setValues(Row) + End If + End Sub + + Public ReadOnly Property LugarExp As String + Get + Dim arr = {Calle, NoExt, NoInt, Colonia, Localidad, Municipio, Estado, Pais, CP, SubProyecto} + Return String.Join(",", arr) + End Get + End Property + Public Property CveSubProyecto As Integer + Public Property Calle As String + Public Property Direccion As String + Public Property NoExt As String + Public Property NoInt As String + Public Property Colonia As String + Public Property Localidad As String + Public Property Municipio As String + Public Property Estado As String + Public Property Pais As String + Public Property CP As String + Public Property IVA As Decimal + Public Property Serie As String + Public Property TipoFormato As String + Public Property FormatoFactura As String + Public Property SubProyecto As String + Public Property Correo As String + Public Property Telefono As String Public Property ImprimeNombre As String Public Property UTCOffsetVerano As Integer - Public Property UTCOffsetInvierno As Integer - - End Class - - - Public Class ClienteModel - Inherits Modelos.EntityModel - Protected Overloads Sub SetDefaultValues() - CveCliente = -1 - EnviarFactura = "Si" - Estatus = "Activo" - NoExt = "" - NoInt = "" - Direccion = "" - Colonia = "" - Localidad = "" - Ciudad = "" - Estado = "" - Pais = "" - CP = "" - Telefono = "" - AplicaFord = False - Ford_GSDB = "" - AplicaFEMSA = False - AplicaDetallista = False - AplicaComercioExterior = False - End Sub - Public Sub New() - MyBase.New() - End Sub - Public Sub New(Row As Data.DataRow) - SetDefaultValues() - setValues(Row) - End Sub - Public Sub New(CveCliente As Integer, CveEmpresa As Integer) - SetDefaultValues() - Dim ObjCliente As New ClsClientes() - If ObjCliente.GetClientes(CveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, CveEmpresa, -1, TipoCliente:=-1) AndAlso ObjCliente.DtResultados.Rows.Count > 0 Then - setValues(ObjCliente.DtResultados.Rows(0)) - End If - ObjCliente.Dispose() - End Sub - Public Property CveCliente As Integer - Public Property Nombre As String - Public Property NombreComercial As String - Public Property Codigo As String - Public Property Direccion As String - Public Property NoExt As String - Public Property NoInt As String - Public Property Colonia As String - Public Property Localidad As String - Public Property Ciudad As String - Public Property Estado As String - Public Property Pais As String - Public Property RFC As String - Public Property CP As String - Public Property Telefono As String - Public Property Contacto As String - Public Property Mail As String - Public Property MailCotizacion As String - Public Property NotificarA As String - Public Property Pagina As String - Public Property Giro As String - Public Property CvePrecioLista As Integer - Public Property EnviarFactura As String - Public Property CveSucursal As Integer - Public Property RetIVA As Decimal - Public Property RetISR As Decimal - Public Property IEPS As Decimal - Public Property RetIVAFletes As Boolean - Public Property Estatus As String - Public Property Fecha As DateTime - Public Property Usuario As String - Public Property NombreCorto As String - Public Property Vendedor As String - Public Property PlazoCobranza As Integer - Public Property Sucursal As String - Public Property RecepcionPagos As String - Public Property TipoPago As String - Public Property CuentaContable As String - Public Property IdCtaContClientes As Integer - Public Property IdCtaContMonedaExtranjera As Integer - Public Property IdCtaContComplementaria As Integer - Public Property IdCtaContAnticipos As Integer - Public Property IdCtaContRetIVA As Integer - Public Property IdCtaContRetISR As Integer - Public Property CveCuentaClientes As Integer - Public Property CveCuentaMonedaExtranjera As Integer - Public Property CveCuentaComplementaria As Integer - Public Property CveCuentaAnticipos As Integer - Public Property CveCuentaRetIVA As Integer - Public Property CveCuentaRetISR As Integer - Public Property ConvenioCIE As String - Public Property FormaFacturacion As String - Public Property LimiteCredito As Decimal - Public Property NumCtaPago As String - Public Property CveMetodoPago As Integer - Public Property AplicaFEMSA As Boolean - Public Property FEMSA_NumSociedad As String - Public Property FEMSA_NumProveedor As String - Public Property FEMSA_Mail As String - Public Property AplicaDetallista As Boolean - Public Property Detallista_GLNComprador As String - Public Property Detallista_Departamento As String - Public Property Detallista_GLNVendedor As String - Public Property Detallista_NumProveedor As String - Public Property SevenEleven_NumProveedor As String - Public Property Detallista_GLNEnvio As String = "envio num" - Public Property AplicaFord As Boolean - Public Property Ford_GSDB As String - Public Property ReferenciaFiscal As String - Public Property NumRegIdTrib As String - Public Property CobranzaTelefono As String - Public Property AplicaComercioExterior As Boolean - Public Property ClaveSATPais As String - Public Property ClaveSATEstado As String - Public Property ClaveSATMunicipio As String - Public Property ClaveSATColonia As String - Public Property ClaveSATCP As String - - End Class - - - Public Class EnviarAModel - Inherits Modelos.EntityModel - - Protected Overloads Sub SetDefaultValues() - EnvioDireccion = "" - EnvioNoExt = "" - EnvioNoInt = "" - EnvioColonia = "" - EnvioCiudad = "" - EnvioEstado = "" - EnvioContacto = "" - EnvioDepartamento = "" - EnvioPedidoContrato = "" - EnvioCP = "" - EnvioTel = "" - - End Sub - Public Sub New() - MyBase.New() - End Sub - Public Sub New(Row As System.Data.DataRow) - SetDefaultValues() - setValues(Row) - End Sub - - Public ReadOnly Property LugarExp As String - Get - Dim arr = {EnvioDireccion, EnvioColonia, EnvioCiudad, EnvioEstado, EnvioCP, EnvioTel} - Return String.Join(",", arr) - End Get - End Property - Public Property CveDireccionEnvio As Integer - Public Property EnvioDireccion As String - Public Property EnvioNoExt As String - Public Property EnvioNoInt As String - Public Property EnvioColonia As String - Public Property EnvioCiudad As String - Public Property EnvioEstado As String - Public Property EnvioContacto As String - Public Property EnvioDepartamento As String - Public Property EnvioPedidoContrato As String - Public Property EnvioCP As String - Public Property EnvioTel As String + Public Property UTCOffsetInvierno As Integer + End Class -#End Region + + Public Class ClienteModel + Inherits Modelos.EntityModel + Protected Overloads Sub SetDefaultValues() + CveCliente = -1 + EnviarFactura = "Si" + Estatus = "Activo" + NoExt = "" + NoInt = "" + Direccion = "" + Colonia = "" + Localidad = "" + Ciudad = "" + Estado = "" + Pais = "" + CP = "" + Telefono = "" + AplicaFord = False + Ford_GSDB = "" + AplicaFEMSA = False + AplicaDetallista = False + AplicaComercioExterior = False + End Sub + Public Sub New() + MyBase.New() + End Sub + Public Sub New(Row As Data.DataRow) + SetDefaultValues() + setValues(Row) + End Sub + Public Sub New(CveCliente As Integer, CveEmpresa As Integer) + SetDefaultValues() + Dim ObjCliente As New ClsClientes() + If ObjCliente.GetClientes(CveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, CveEmpresa, -1, TipoCliente:=-1) AndAlso ObjCliente.DtResultados.Rows.Count > 0 Then + setValues(ObjCliente.DtResultados.Rows(0)) + End If + ObjCliente.Dispose() + End Sub + Public Property CveCliente As Integer + Public Property Nombre As String + Public Property NombreComercial As String + Public Property Codigo As String + Public Property Direccion As String + Public Property NoExt As String + Public Property NoInt As String + Public Property Colonia As String + Public Property Localidad As String + Public Property Ciudad As String + Public Property Estado As String + Public Property Pais As String + Public Property RFC As String + Public Property CP As String + Public Property Telefono As String + Public Property Contacto As String + Public Property Mail As String + Public Property MailCotizacion As String + Public Property NotificarA As String + Public Property Pagina As String + Public Property Giro As String + Public Property CvePrecioLista As Integer + Public Property EnviarFactura As String + Public Property CveSucursal As Integer + Public Property RetIVA As Decimal + Public Property RetISR As Decimal + Public Property IEPS As Decimal + Public Property RetIVAFletes As Boolean + Public Property Estatus As String + Public Property Fecha As DateTime + Public Property Usuario As String + Public Property NombreCorto As String + Public Property Vendedor As String + Public Property PlazoCobranza As Integer + Public Property Sucursal As String + Public Property RecepcionPagos As String + Public Property TipoPago As String + Public Property CuentaContable As String + Public Property IdCtaContClientes As Integer + Public Property IdCtaContMonedaExtranjera As Integer + Public Property IdCtaContComplementaria As Integer + Public Property IdCtaContAnticipos As Integer + Public Property IdCtaContRetIVA As Integer + Public Property IdCtaContRetISR As Integer + Public Property CveCuentaClientes As Integer + Public Property CveCuentaMonedaExtranjera As Integer + Public Property CveCuentaComplementaria As Integer + Public Property CveCuentaAnticipos As Integer + Public Property CveCuentaRetIVA As Integer + Public Property CveCuentaRetISR As Integer + Public Property ConvenioCIE As String + Public Property FormaFacturacion As String + Public Property LimiteCredito As Decimal + Public Property NumCtaPago As String + Public Property CveMetodoPago As Integer + Public Property AplicaFEMSA As Boolean + Public Property FEMSA_NumSociedad As String + Public Property FEMSA_NumProveedor As String + Public Property FEMSA_Mail As String + Public Property AplicaDetallista As Boolean + Public Property Detallista_GLNComprador As String + Public Property Detallista_Departamento As String + Public Property Detallista_GLNVendedor As String + Public Property Detallista_NumProveedor As String + Public Property SevenEleven_NumProveedor As String + Public Property Detallista_GLNEnvio As String = "envio num" + Public Property AplicaFord As Boolean + Public Property Ford_GSDB As String + Public Property ReferenciaFiscal As String + Public Property NumRegIdTrib As String + Public Property CobranzaTelefono As String + Public Property AplicaComercioExterior As Boolean + Public Property ClaveSATPais As String + Public Property ClaveSATEstado As String + Public Property ClaveSATMunicipio As String + Public Property ClaveSATColonia As String + Public Property ClaveSATCP As String -#Region "Personal" + End Class - Public Class RH_PersonalRequerido - Public Sub New() - CveRequerimiento = -1 - CveProyecto = -1 - CveSubProyecto = -1 - CveTurno = -1 - CveUsuario = -1 - CveEmpresa = -1 - CveDepartamento = -1 - End Sub - Public Property CveRequerimiento As Integer - Public Property CveProyecto As Integer - Public Property Proyecto As String - Public Property CveSubProyecto As Integer - Public Property SubProyecto As String - Public Property CveTurno As Integer - Public Property Turno As String - Public Property Cantidad As Integer - Public Property FechaIngreso As DateTime - Public Property FechaActualizacion As DateTime - Public Property CveUsuario As Integer - Public Property Usuario As String + + Public Class EnviarAModel + Inherits Modelos.EntityModel + + Protected Overloads Sub SetDefaultValues() + EnvioDireccion = "" + EnvioNoExt = "" + EnvioNoInt = "" + EnvioColonia = "" + EnvioCiudad = "" + EnvioEstado = "" + EnvioContacto = "" + EnvioDepartamento = "" + EnvioPedidoContrato = "" + EnvioCP = "" + EnvioTel = "" + + End Sub + Public Sub New() + MyBase.New() + End Sub + Public Sub New(Row As System.Data.DataRow) + SetDefaultValues() + setValues(Row) + End Sub + + Public ReadOnly Property LugarExp As String + Get + Dim arr = {EnvioDireccion, EnvioColonia, EnvioCiudad, EnvioEstado, EnvioCP, EnvioTel} + Return String.Join(",", arr) + End Get + End Property + Public Property CveDireccionEnvio As Integer + Public Property EnvioDireccion As String + Public Property EnvioNoExt As String + Public Property EnvioNoInt As String + Public Property EnvioColonia As String + Public Property EnvioCiudad As String + Public Property EnvioEstado As String + Public Property EnvioContacto As String + Public Property EnvioDepartamento As String + Public Property EnvioPedidoContrato As String + Public Property EnvioCP As String + Public Property EnvioTel As String + End Class + +#End Region + +#Region "Personal" + + Public Class RH_PersonalRequerido + Public Sub New() + CveRequerimiento = -1 + CveProyecto = -1 + CveSubProyecto = -1 + CveTurno = -1 + CveUsuario = -1 + CveEmpresa = -1 + CveDepartamento = -1 + End Sub + Public Property CveRequerimiento As Integer + Public Property CveProyecto As Integer + Public Property Proyecto As String + Public Property CveSubProyecto As Integer + Public Property SubProyecto As String + Public Property CveTurno As Integer + Public Property Turno As String + Public Property Cantidad As Integer + Public Property FechaIngreso As DateTime + Public Property FechaActualizacion As DateTime + Public Property CveUsuario As Integer + Public Property Usuario As String Public Property CveEmpresa As Integer - Public Property CveDepartamento As Integer - - End Class -#End Region + Public Property CveDepartamento As Integer -#Region "E FACTURAS" + End Class +#End Region + +#Region "E FACTURAS" Public Class eFactura -#Region "Propiedades" - Public Property CveEmpresa() As Integer - Get - Return m_CveEmpresa - End Get - Set - m_CveEmpresa = Value - End Set - End Property - Private m_CveEmpresa As Integer - 'CFDi - Public Property Version() As String - Get - Return m_Version - End Get - Set - m_Version = Value - End Set - End Property - Private m_Version As String - Public Property Serie() As String - Get - Return m_Serie - End Get - Set - m_Serie = Value - End Set - End Property - Private m_Serie As String - Public Property Folio() As String - Get - Return m_Folio - End Get - Set - m_Folio = Value - End Set - End Property - Private m_Folio As String - Public Property Fecha() As String - Get - Return m_Fecha - End Get - Set - m_Fecha = Value - End Set - End Property - Private m_Fecha As String - Public Property subTotal() As Double - Get - Return m_subTotal - End Get - Set - m_subTotal = Value - End Set - End Property - Private m_subTotal As Double - Public Property Total() As Double - Get - Return m_Total - End Get - Set - m_Total = Value - End Set - End Property - Private m_Total As Double - Public Property Moneda() As String - Get - Return m_Moneda - End Get - Set - m_Moneda = Value - End Set - End Property - Private m_Moneda As String - Public Property TipodeComprobante() As String - Get - Return m_TipodeComprobante - End Get - Set - m_TipodeComprobante = Value - End Set - End Property - Private m_TipodeComprobante As String - Public Property Descuento() As Double - Get - Return m_Descuento - End Get - Set - m_Descuento = Value - End Set - End Property - Private m_Descuento As Double - Public Property TipoCambio() As Double - Get - Return m_TipoCambio - End Get - Set - m_TipoCambio = Value - End Set - End Property - Private m_TipoCambio As Double - Public Property MetododePago() As String - Get - Return m_MetododePago - End Get - Set - m_MetododePago = Value - End Set - End Property - Private m_MetododePago As String - - 'Emisor - Public Property EmisorRFC() As String - Get - Return m_EmisorRFC - End Get - Set - m_EmisorRFC = Value - End Set - End Property - Private m_EmisorRFC As String - Public Property EmisorNombre() As String - Get - Return m_EmisorNombre - End Get - Set - m_EmisorNombre = Value - End Set - End Property - Private m_EmisorNombre As String - - 'Receptor - Public Property ReceptorRFC() As String - Get - Return m_ReceptorRFC - End Get - Set - m_ReceptorRFC = Value - End Set - End Property - Private m_ReceptorRFC As String - - Public Property TotalRetenciones() As Double - Get - Return m_TotalRetenciones - End Get - Set - m_TotalRetenciones = Value - End Set - End Property - Private m_TotalRetenciones As Double - Public Property SumaTotalRetenciones() As Double - Get - Return m_SumaTotalRetenciones - End Get - Set - m_SumaTotalRetenciones = Value - End Set - End Property - Private m_SumaTotalRetenciones As Double - Public Property TotalTraslados() As Double - Get - Return m_TotalTraslados - End Get - Set - m_TotalTraslados = Value - End Set - End Property - Private m_TotalTraslados As Double - Public Property SumaTotalTraslados() As Double - Get - Return m_SumaTotalTraslados - End Get - Set - m_SumaTotalTraslados = Value - End Set - End Property - Private m_SumaTotalTraslados As Double - - 'IVA - Public Property TrasladoIVA() As Double - Get - Return m_TrasladoIVA - End Get - Set - m_TrasladoIVA = Value - End Set - End Property - Private m_TrasladoIVA As Double - Public Property TrasladoISR() As Double - Get - Return m_TrasladoISR - End Get - Set - m_TrasladoISR = Value - End Set - End Property - Private m_TrasladoISR As Double - Public Property RetencionIVA() As Double - Get - Return m_RetencionIVA - End Get - Set - m_RetencionIVA = Value - End Set - End Property - Private m_RetencionIVA As Double - - 'ISR - Public Property RetencionISR() As Double - Get - Return m_RetencionISR - End Get - Set - m_RetencionISR = Value - End Set - End Property - Private m_RetencionISR As Double - Public Property sUPPrefijo() As String - Get - Return m_sUPPrefijo - End Get - Set - m_sUPPrefijo = Value - End Set - End Property - Private m_sUPPrefijo As String - - 'TFD - Public Property TFDUUID() As String - Get - Return m_TFDUUID - End Get - Set - m_TFDUUID = Value - End Set - End Property - Private m_TFDUUID As String - Public Property Validada() As Integer - Get - Return m_Validada - End Get - Set - m_Validada = Value - End Set - End Property - Private m_Validada As Integer - - Public Property ArchivoXML() As String - Get - Return m_ArchivoXML - End Get - Set - m_ArchivoXML = Value - End Set - End Property - Private m_ArchivoXML As String - Public Property ArchivoPDF() As String - Get - Return m_ArchivoPDF - End Get - Set - m_ArchivoPDF = Value - End Set - End Property - Private m_ArchivoPDF As String - - Public Property DirectorioTemporal() As String - Get - Return m_DirectorioTemporal - End Get - Set - m_DirectorioTemporal = Value - End Set - End Property +#Region "Propiedades" + Public Property CveEmpresa() As Integer + Get + Return m_CveEmpresa + End Get + Set + m_CveEmpresa = Value + End Set + End Property + Private m_CveEmpresa As Integer + 'CFDi + Public Property Version() As String + Get + Return m_Version + End Get + Set + m_Version = Value + End Set + End Property + Private m_Version As String + Public Property Serie() As String + Get + Return m_Serie + End Get + Set + m_Serie = Value + End Set + End Property + Private m_Serie As String + Public Property Folio() As String + Get + Return m_Folio + End Get + Set + m_Folio = Value + End Set + End Property + Private m_Folio As String + Public Property Fecha() As String + Get + Return m_Fecha + End Get + Set + m_Fecha = Value + End Set + End Property + Private m_Fecha As String + Public Property subTotal() As Double + Get + Return m_subTotal + End Get + Set + m_subTotal = Value + End Set + End Property + Private m_subTotal As Double + Public Property Total() As Double + Get + Return m_Total + End Get + Set + m_Total = Value + End Set + End Property + Private m_Total As Double + Public Property Moneda() As String + Get + Return m_Moneda + End Get + Set + m_Moneda = Value + End Set + End Property + Private m_Moneda As String + Public Property TipodeComprobante() As String + Get + Return m_TipodeComprobante + End Get + Set + m_TipodeComprobante = Value + End Set + End Property + Private m_TipodeComprobante As String + Public Property Descuento() As Double + Get + Return m_Descuento + End Get + Set + m_Descuento = Value + End Set + End Property + Private m_Descuento As Double + Public Property TipoCambio() As Double + Get + Return m_TipoCambio + End Get + Set + m_TipoCambio = Value + End Set + End Property + Private m_TipoCambio As Double + Public Property MetododePago() As String + Get + Return m_MetododePago + End Get + Set + m_MetododePago = Value + End Set + End Property + Private m_MetododePago As String + + 'Emisor + Public Property EmisorRFC() As String + Get + Return m_EmisorRFC + End Get + Set + m_EmisorRFC = Value + End Set + End Property + Private m_EmisorRFC As String + Public Property EmisorNombre() As String + Get + Return m_EmisorNombre + End Get + Set + m_EmisorNombre = Value + End Set + End Property + Private m_EmisorNombre As String + + 'Receptor + Public Property ReceptorRFC() As String + Get + Return m_ReceptorRFC + End Get + Set + m_ReceptorRFC = Value + End Set + End Property + Private m_ReceptorRFC As String + + Public Property TotalRetenciones() As Double + Get + Return m_TotalRetenciones + End Get + Set + m_TotalRetenciones = Value + End Set + End Property + Private m_TotalRetenciones As Double + Public Property SumaTotalRetenciones() As Double + Get + Return m_SumaTotalRetenciones + End Get + Set + m_SumaTotalRetenciones = Value + End Set + End Property + Private m_SumaTotalRetenciones As Double + Public Property TotalTraslados() As Double + Get + Return m_TotalTraslados + End Get + Set + m_TotalTraslados = Value + End Set + End Property + Private m_TotalTraslados As Double + Public Property SumaTotalTraslados() As Double + Get + Return m_SumaTotalTraslados + End Get + Set + m_SumaTotalTraslados = Value + End Set + End Property + Private m_SumaTotalTraslados As Double + + 'IVA + Public Property TrasladoIVA() As Double + Get + Return m_TrasladoIVA + End Get + Set + m_TrasladoIVA = Value + End Set + End Property + Private m_TrasladoIVA As Double + Public Property TrasladoISR() As Double + Get + Return m_TrasladoISR + End Get + Set + m_TrasladoISR = Value + End Set + End Property + Private m_TrasladoISR As Double + Public Property RetencionIVA() As Double + Get + Return m_RetencionIVA + End Get + Set + m_RetencionIVA = Value + End Set + End Property + Private m_RetencionIVA As Double + + 'ISR + Public Property RetencionISR() As Double + Get + Return m_RetencionISR + End Get + Set + m_RetencionISR = Value + End Set + End Property + Private m_RetencionISR As Double + Public Property sUPPrefijo() As String + Get + Return m_sUPPrefijo + End Get + Set + m_sUPPrefijo = Value + End Set + End Property + Private m_sUPPrefijo As String + + 'TFD + Public Property TFDUUID() As String + Get + Return m_TFDUUID + End Get + Set + m_TFDUUID = Value + End Set + End Property + Private m_TFDUUID As String + Public Property Validada() As Integer + Get + Return m_Validada + End Get + Set + m_Validada = Value + End Set + End Property + Private m_Validada As Integer + + Public Property ArchivoXML() As String + Get + Return m_ArchivoXML + End Get + Set + m_ArchivoXML = Value + End Set + End Property + Private m_ArchivoXML As String + Public Property ArchivoPDF() As String + Get + Return m_ArchivoPDF + End Get + Set + m_ArchivoPDF = Value + End Set + End Property + Private m_ArchivoPDF As String + + Public Property DirectorioTemporal() As String + Get + Return m_DirectorioTemporal + End Get + Set + m_DirectorioTemporal = Value + End Set + End Property Private m_DirectorioTemporal As String -#End Region +#End Region End Class @@ -9608,315 +9608,315 @@ Namespace Modelos ' End Class -#End Region +#End Region -#Region "A P L I C A C I O N E S" +#Region "A P L I C A C I O N E S" - Public Class MCliente - Public Property CveCliente As Integer - Public Property Nombre As String - Public Property NombreComercial As String - Public Property Codigo As String - Public Property NombreCorto As String - Public Property SucursalTexto As String - Public Property Direccion As String - Public Property NoExt As String - Public Property NoInt As String - Public Property Colonia As String - Public Property Localidad As String - Public Property Ciudad As String - Public Property Estado As String - Public Property Pais As String - Public Property RFC As String - Public Property CP As String - Public Property Telefono As String - Public Property TelefonoExtension As String - Public Property TelefonoOtros As String - Public Property Contacto As String - Public Property Mail As String - Public Property MailCotizacion As String - Public Property NotificarA As String - Public Property Pagina As String - Public Property Giro As String - Public Property CvePrecioLista As Integer - Public Property EnviarFactura As String - Public Property CveSucursal As Integer? - Public Property Sucursal As String - Public Property RetIVA As Integer - Public Property RetISR As Integer - Public Property RetIVAFletes As Boolean - Public Property ConvenioCIE As String - Public Property CuentaContable As String - Public Property IdCtaContClientes As Integer - Public Property IdCtaContAnticipos As Integer - Public Property IdCtaContRetIVA As Integer - Public Property IdCtaContRetISR As Integer - Public Property IdCtaContFondoGarantia As Integer? - Public Property LimiteCredito As Integer - Public Property PlazoCobranza As Integer - Public Property PlazoCobranzaRemision As Integer - Public Property RecepcionPagos As String - Public Property TipoPago As String - Public Property CveVendedor As Integer? - Public Property FormaFacturacion As String - Public Property Estatus As String - Public Property Fecha As DateTime - Public Property Usuario As String - Public Property CveEmpresa As Integer - Public Property CveClienteClasificacion As Integer? - Public Property CveUsuarioResponsable As Integer? - Public Property CveCondicionEntrega As Integer? - Public Property NumCtaPago As String - Public Property CveMetodoPago As Integer - Public Property AplicaFEMSA As Boolean - Public Property FEMSA_NumSociedad As String - Public Property FEMSA_NumProveedor As String - Public Property FEMSA_Mail As String - Public Property AplicaDetallista As Boolean - Public Property Detallista_GLNVendedor As String - Public Property Detallista_Departamento As String - Public Property Detallista_NumProveedor As String - Public Property Detallista_GLNComprador As String - Public Property SevenEleven_NumProveedor As String - Public Property AplicaFord As Boolean - Public Property Ford_GSDB As String - Public Property IdCtaContMonedaExtranjera As Integer? - Public Property IdCtaContMonedaExtranjeraAnticipos As Integer? - Public Property IdCtaContComplementaria As Integer? - Public Property PermiteCredito As Boolean - Public Property CodigoNombre As String - Public Property IdCtaContCompClientes As Integer? - Public Property IdCtaContCompAnticipos As Integer? - Public Property TipoCliente As Integer - Public Property ImprimeNombreSucursal As Boolean - Public Property CveZonaHoraria As Integer? - Public Property CveSubProyecto As Integer? - Public Property SubProyecto As String - Public Property CobranzaContacto As String - Public Property CobranzaCorreo As String - Public Property CobranzaTelefono As String - Public Property CobranzaExt As String - Public Property Horario As String - Public Property PortalFacturacion As String - Public Property DiasPago As String - Public Property Documentacion As String - Public Property EstatusBool As Integer - Public Property UsuarioPortal As String - Public Property PasswordPortal As String - Public Property DiasRevision As String - Public Property ObservacionRevision As String - Public Property ReferenciaFiscal As String - Public Property Celular As String - Public Property ExtOtros As String - Public Property Vendedor As String - Public Property CveUsoCFDI As Integer? - Public Property CveFormaPago33 As Integer? - Public Property CveMetodoPago33 As Integer? - Public Property CveClienteCorporativo As Integer? - Public Property Descripcion As String - Public Property DesglosaIEPS As Boolean - Public Property AplicaComercioExterior As Boolean - Public Property CveTipoOperacion As Integer? - Public Property CvePedimento As Integer? - Public Property CveIncoterm As Integer? - Public Property CvePais As Integer - Public Property ClaveSATPais As String - Public Property ClaveSATPaisDescripcion As String - Public Property CveEstado As Integer? - Public Property ClaveSATEstado As String - Public Property ClaveSATEstadoNombreEstado As String - Public Property CveMunicipio As Integer? - Public Property ClaveSATMunicipio As String - Public Property ClaveSATMunicipioDescripcion As String - Public Property CveColonia As Integer? - Public Property ClaveSATCP As String - Public Property ClaveSATColonia As String - Public Property ClaveSATColoniaNombreAsentamiento As String - Public Property ClaveSATTipoOperacionDescripcion As String - Public Property ClaveSATPedimentoDescripcion As String - Public Property ClaveSATIncotermDescripcion As String - Public Property CveMotivoTraslado As Integer? - Public Property NumRegIdTrib As String - Public Property ComExtEstado As String - Public Property ComExtMunicipio As String - Public Property ComExtColonia As String - Public Property ApellidoPaterno As String - Public Property ApellidoMaterno As String - Public Property Nombres As String - Public Property RequiereOC As Boolean - Public Property LT As String - Public Property LG As String - End Class - Public Class MProductoServicio - Sub New() - CveClasificacionCosto = -1 - CveClasificacion = -1 - Codigo = "" - Codigo2 = "" - CodigoBarras = "" - CveMetodoInventario = -1 - CveTipoPS = -1 - CveClasificacionPresupuesto = -1 - TipoServicio = -1 - CveClasificacion2 = -1 - CveMarca = -1 - IEPSPorcentaje = 0 - CveCompuesto = -1 - CveSATPS = -1 - CveProveedorCompra = -1 - CveMoneda = -1 - CveTipoFactor = -1 - CveFraccionArancelaria = -1 - CveClasificacionDetalle = -1 - PrecioMinimo = 0 - - End Sub - Public Property CvePS As Integer - Public Property CveClasificacion As Integer? - Public Property Clasificacion As String - Public Property CveUM As Integer - Public Property CveUnidadMedida As Integer? - Public Property UnidadMedida As String - Public Property SATClaveUnidadMedida As String - Public Property Codigo As String - Public Property Codigo2 As String - Public Property CodigoBarras As String - Public Property PS As String - Public Property SATClavePS As String - Public Property Precio As Double? - Public Property CveTipoFactor As Integer? - Public Property Oferta As Integer? - Public Property CveSubFamilia As Integer? - Public Property SubFamilia As String - Public Property CostoPromedio As Double? - Public Property CveClasificacionPresupuesto As Integer? - Public Property ClasificacionPresupuesto As String - Public Property UsoClasificacion As Integer - Public Property CvePuesto As Integer? - Public Property Puesto As String - Public Property PSCodigo As String - Public Property PSCodigoCompuesto As String - Public Property IVA As Integer? - Public Property RetIVA As Integer? - Public Property MargenGanancia As Integer? - Public Property IdCtaContVentas As Integer? - Public Property IdCtaContCompras As Integer? - Public Property IdCtaContInventarios As Integer? - Public Property AsientoContableVentas As Integer? - Public Property AsientoContableCompras As Integer? - Public Property AplicaParaConcepto As Boolean - Public Property AplicaParaVenta As Boolean - Public Property EsPaquete As Boolean - Public Property Estado As String - Public Property CveEstado As Boolean? - Public Property Fecha As DateTime - Public Property Usuario As String - Public Property CveEmpresa As Integer - Public Property CveMoneda As Integer? - Public Property Abreviatura As String - Public Property Moneda As String - Public Property Inv_CveMetodoInventario As Integer? - Public Property CveTipoPS As Integer - Public Property FuePorXML As Boolean? - Public Property PendienteEnOC As Integer? - Public Property CveClasificacionCosto As Integer? - Public Property AplicaSerieLote As Boolean? - Public Property AplicaCaducidad As Boolean? - Public Property Estado2 As Integer? - Public Property CveClasificacion2 As Integer? - Public Property AplicaParaVentaP As String - Public Property Cantidad As Integer? - Public Property UnidadBase As Boolean? - Public Property CveMarca As Integer? - Public Property AlmacenSeccion As String - Public Property TipoPS As String - Public Property CvePSPaquete As Integer? - Public Property AplicaIEPS As Boolean? - Public Property IEPSGrabaIVA As Boolean? - Public Property IEPSPorcentaje As Double? - Public Property CveConceptoContable As Integer? - Public Property CveCompuesto As Integer? - Public Property CveSATPS As Integer? - Public Property SATClavePS1 As String - Public Property SATDescripcion As String - Public Property Descripcion As String - Public Property Inventariable As Boolean? - Public Property CveProveedorCompra As Integer? - Public Property ProveedorCompra As String - Public Property VentaMinima As Integer? - Public Property RetISR As Integer? - Public Property SATClaveProductoServicio As String - Public Property PrecioMinimo As Double? - Public Property CveFraccionArancelaria As Integer? - Public Property CveUnidadAduana As Integer? - Public Property ClaveSATFraccionArancelaria As Integer? - Public Property ClaveSATUnidadAduana As Integer? - Public Property ClaveSATFraccionArancelariaDescripcion As String - Public Property ClaveSATUnidadAduanaDescripcion As String - Public Property CveUsuarioModifico As Integer? - Public Property UsuarioModifico As String - Public Property FechaUltimaModificacion As DateTime? - Public Property CveClasificacionDetalle As Integer? - Public Property CostoPromedio1 As Integer? - Public Property UltimoCosto As Integer? - Public Property FechaUltimaCompra As String - Public Property CveUsuario As Integer - Public Property CveMetodoInventario As Integer? - Public Property TipoServicio As Integer? - Public Property CveTamaño As Integer? - End Class - Public Class MClasificacion - Sub New() - CveClasificacion = -1 - IdCuentaContable = -1 - IdCuentaCostos = -1 - IdCuentaIngresos = -1 - CveSATPS = -1 - End Sub - Public Property CveClasificacion As Integer - Public Property Clasificacion As String - Public Property Codigo As String - Public Property IdCuentaContable As Integer? - Public Property IdCuentaGasto As Integer? - Public Property CuentaGasto As String - Public Property IdCuentaCostos As Integer? - Public Property CuentaCostos As String - Public Property IdCuentaInventario As Integer? - Public Property CuentaInventario As String - Public Property IdCuentaIngresos As Integer? - Public Property CuentaIngresos As String - Public Property IdCuentaContableSIG As Integer? - Public Property IdCuentaCostosSIG As Integer? - Public Property IdCuentaGastoSIG As Integer? - Public Property IdCuentaIngresosSIG As Integer? - Public Property IdCuentaInventarioSIG As Integer? - Public Property IdCuentaRetIVASIG As Integer? - Public Property IdCuentaRetISRSIG As Integer? - Public Property Estado As Boolean - Public Property Estatus As String - Public Property RequiereSerieLote As Boolean? - Public Property Afectable As Boolean - Public Property TextoAfectable As String - Public Property CodigoClasificacion As String - Public Property NivelClasificacion As String - Public Property CveCategoria As Integer - Public Property Categoria As String - Public Property Tipo As Integer - Public Property EstatusCategoria As String - Public Property Fecha As DateTime - Public Property Usuario As String - Public Property CveEmpresa As Integer - Public Property CveUsuario As Integer? - Public Property UsoClasificacion As Integer - Public Property UsoClasif As String - Public Property CveSATPS As Integer - Public Property SATClaveProductoServicio As String - Public Property RequiereAFCompra As Boolean - Public Property RequiereAFInsumo As Boolean - Public Property RequierePersonal As Boolean - Public Property EsAcumulador As Boolean + Public Class MCliente + Public Property CveCliente As Integer + Public Property Nombre As String + Public Property NombreComercial As String + Public Property Codigo As String + Public Property NombreCorto As String + Public Property SucursalTexto As String + Public Property Direccion As String + Public Property NoExt As String + Public Property NoInt As String + Public Property Colonia As String + Public Property Localidad As String + Public Property Ciudad As String + Public Property Estado As String + Public Property Pais As String + Public Property RFC As String + Public Property CP As String + Public Property Telefono As String + Public Property TelefonoExtension As String + Public Property TelefonoOtros As String + Public Property Contacto As String + Public Property Mail As String + Public Property MailCotizacion As String + Public Property NotificarA As String + Public Property Pagina As String + Public Property Giro As String + Public Property CvePrecioLista As Integer + Public Property EnviarFactura As String + Public Property CveSucursal As Integer? + Public Property Sucursal As String + Public Property RetIVA As Integer + Public Property RetISR As Integer + Public Property RetIVAFletes As Boolean + Public Property ConvenioCIE As String + Public Property CuentaContable As String + Public Property IdCtaContClientes As Integer + Public Property IdCtaContAnticipos As Integer + Public Property IdCtaContRetIVA As Integer + Public Property IdCtaContRetISR As Integer + Public Property IdCtaContFondoGarantia As Integer? + Public Property LimiteCredito As Integer + Public Property PlazoCobranza As Integer + Public Property PlazoCobranzaRemision As Integer + Public Property RecepcionPagos As String + Public Property TipoPago As String + Public Property CveVendedor As Integer? + Public Property FormaFacturacion As String + Public Property Estatus As String + Public Property Fecha As DateTime + Public Property Usuario As String + Public Property CveEmpresa As Integer + Public Property CveClienteClasificacion As Integer? + Public Property CveUsuarioResponsable As Integer? + Public Property CveCondicionEntrega As Integer? + Public Property NumCtaPago As String + Public Property CveMetodoPago As Integer + Public Property AplicaFEMSA As Boolean + Public Property FEMSA_NumSociedad As String + Public Property FEMSA_NumProveedor As String + Public Property FEMSA_Mail As String + Public Property AplicaDetallista As Boolean + Public Property Detallista_GLNVendedor As String + Public Property Detallista_Departamento As String + Public Property Detallista_NumProveedor As String + Public Property Detallista_GLNComprador As String + Public Property SevenEleven_NumProveedor As String + Public Property AplicaFord As Boolean + Public Property Ford_GSDB As String + Public Property IdCtaContMonedaExtranjera As Integer? + Public Property IdCtaContMonedaExtranjeraAnticipos As Integer? + Public Property IdCtaContComplementaria As Integer? + Public Property PermiteCredito As Boolean + Public Property CodigoNombre As String + Public Property IdCtaContCompClientes As Integer? + Public Property IdCtaContCompAnticipos As Integer? + Public Property TipoCliente As Integer + Public Property ImprimeNombreSucursal As Boolean + Public Property CveZonaHoraria As Integer? + Public Property CveSubProyecto As Integer? + Public Property SubProyecto As String + Public Property CobranzaContacto As String + Public Property CobranzaCorreo As String + Public Property CobranzaTelefono As String + Public Property CobranzaExt As String + Public Property Horario As String + Public Property PortalFacturacion As String + Public Property DiasPago As String + Public Property Documentacion As String + Public Property EstatusBool As Integer + Public Property UsuarioPortal As String + Public Property PasswordPortal As String + Public Property DiasRevision As String + Public Property ObservacionRevision As String + Public Property ReferenciaFiscal As String + Public Property Celular As String + Public Property ExtOtros As String + Public Property Vendedor As String + Public Property CveUsoCFDI As Integer? + Public Property CveFormaPago33 As Integer? + Public Property CveMetodoPago33 As Integer? + Public Property CveClienteCorporativo As Integer? + Public Property Descripcion As String + Public Property DesglosaIEPS As Boolean + Public Property AplicaComercioExterior As Boolean + Public Property CveTipoOperacion As Integer? + Public Property CvePedimento As Integer? + Public Property CveIncoterm As Integer? + Public Property CvePais As Integer + Public Property ClaveSATPais As String + Public Property ClaveSATPaisDescripcion As String + Public Property CveEstado As Integer? + Public Property ClaveSATEstado As String + Public Property ClaveSATEstadoNombreEstado As String + Public Property CveMunicipio As Integer? + Public Property ClaveSATMunicipio As String + Public Property ClaveSATMunicipioDescripcion As String + Public Property CveColonia As Integer? + Public Property ClaveSATCP As String + Public Property ClaveSATColonia As String + Public Property ClaveSATColoniaNombreAsentamiento As String + Public Property ClaveSATTipoOperacionDescripcion As String + Public Property ClaveSATPedimentoDescripcion As String + Public Property ClaveSATIncotermDescripcion As String + Public Property CveMotivoTraslado As Integer? + Public Property NumRegIdTrib As String + Public Property ComExtEstado As String + Public Property ComExtMunicipio As String + Public Property ComExtColonia As String + Public Property ApellidoPaterno As String + Public Property ApellidoMaterno As String + Public Property Nombres As String + Public Property RequiereOC As Boolean + Public Property LT As String + Public Property LG As String End Class -#End Region + Public Class MProductoServicio + Sub New() + CveClasificacionCosto = -1 + CveClasificacion = -1 + Codigo = "" + Codigo2 = "" + CodigoBarras = "" + CveMetodoInventario = -1 + CveTipoPS = -1 + CveClasificacionPresupuesto = -1 + TipoServicio = -1 + CveClasificacion2 = -1 + CveMarca = -1 + IEPSPorcentaje = 0 + CveCompuesto = -1 + CveSATPS = -1 + CveProveedorCompra = -1 + CveMoneda = -1 + CveTipoFactor = -1 + CveFraccionArancelaria = -1 + CveClasificacionDetalle = -1 + PrecioMinimo = 0 + + End Sub + Public Property CvePS As Integer + Public Property CveClasificacion As Integer? + Public Property Clasificacion As String + Public Property CveUM As Integer + Public Property CveUnidadMedida As Integer? + Public Property UnidadMedida As String + Public Property SATClaveUnidadMedida As String + Public Property Codigo As String + Public Property Codigo2 As String + Public Property CodigoBarras As String + Public Property PS As String + Public Property SATClavePS As String + Public Property Precio As Double? + Public Property CveTipoFactor As Integer? + Public Property Oferta As Integer? + Public Property CveSubFamilia As Integer? + Public Property SubFamilia As String + Public Property CostoPromedio As Double? + Public Property CveClasificacionPresupuesto As Integer? + Public Property ClasificacionPresupuesto As String + Public Property UsoClasificacion As Integer + Public Property CvePuesto As Integer? + Public Property Puesto As String + Public Property PSCodigo As String + Public Property PSCodigoCompuesto As String + Public Property IVA As Integer? + Public Property RetIVA As Integer? + Public Property MargenGanancia As Integer? + Public Property IdCtaContVentas As Integer? + Public Property IdCtaContCompras As Integer? + Public Property IdCtaContInventarios As Integer? + Public Property AsientoContableVentas As Integer? + Public Property AsientoContableCompras As Integer? + Public Property AplicaParaConcepto As Boolean + Public Property AplicaParaVenta As Boolean + Public Property EsPaquete As Boolean + Public Property Estado As String + Public Property CveEstado As Boolean? + Public Property Fecha As DateTime + Public Property Usuario As String + Public Property CveEmpresa As Integer + Public Property CveMoneda As Integer? + Public Property Abreviatura As String + Public Property Moneda As String + Public Property Inv_CveMetodoInventario As Integer? + Public Property CveTipoPS As Integer + Public Property FuePorXML As Boolean? + Public Property PendienteEnOC As Integer? + Public Property CveClasificacionCosto As Integer? + Public Property AplicaSerieLote As Boolean? + Public Property AplicaCaducidad As Boolean? + Public Property Estado2 As Integer? + Public Property CveClasificacion2 As Integer? + Public Property AplicaParaVentaP As String + Public Property Cantidad As Integer? + Public Property UnidadBase As Boolean? + Public Property CveMarca As Integer? + Public Property AlmacenSeccion As String + Public Property TipoPS As String + Public Property CvePSPaquete As Integer? + Public Property AplicaIEPS As Boolean? + Public Property IEPSGrabaIVA As Boolean? + Public Property IEPSPorcentaje As Double? + Public Property CveConceptoContable As Integer? + Public Property CveCompuesto As Integer? + Public Property CveSATPS As Integer? + Public Property SATClavePS1 As String + Public Property SATDescripcion As String + Public Property Descripcion As String + Public Property Inventariable As Boolean? + Public Property CveProveedorCompra As Integer? + Public Property ProveedorCompra As String + Public Property VentaMinima As Integer? + Public Property RetISR As Integer? + Public Property SATClaveProductoServicio As String + Public Property PrecioMinimo As Double? + Public Property CveFraccionArancelaria As Integer? + Public Property CveUnidadAduana As Integer? + Public Property ClaveSATFraccionArancelaria As Integer? + Public Property ClaveSATUnidadAduana As Integer? + Public Property ClaveSATFraccionArancelariaDescripcion As String + Public Property ClaveSATUnidadAduanaDescripcion As String + Public Property CveUsuarioModifico As Integer? + Public Property UsuarioModifico As String + Public Property FechaUltimaModificacion As DateTime? + Public Property CveClasificacionDetalle As Integer? + Public Property CostoPromedio1 As Integer? + Public Property UltimoCosto As Integer? + Public Property FechaUltimaCompra As String + Public Property CveUsuario As Integer + Public Property CveMetodoInventario As Integer? + Public Property TipoServicio As Integer? + Public Property CveTamaño As Integer? + End Class + Public Class MClasificacion + Sub New() + CveClasificacion = -1 + IdCuentaContable = -1 + IdCuentaCostos = -1 + IdCuentaIngresos = -1 + CveSATPS = -1 + End Sub + Public Property CveClasificacion As Integer + Public Property Clasificacion As String + Public Property Codigo As String + Public Property IdCuentaContable As Integer? + Public Property IdCuentaGasto As Integer? + Public Property CuentaGasto As String + Public Property IdCuentaCostos As Integer? + Public Property CuentaCostos As String + Public Property IdCuentaInventario As Integer? + Public Property CuentaInventario As String + Public Property IdCuentaIngresos As Integer? + Public Property CuentaIngresos As String + Public Property IdCuentaContableSIG As Integer? + Public Property IdCuentaCostosSIG As Integer? + Public Property IdCuentaGastoSIG As Integer? + Public Property IdCuentaIngresosSIG As Integer? + Public Property IdCuentaInventarioSIG As Integer? + Public Property IdCuentaRetIVASIG As Integer? + Public Property IdCuentaRetISRSIG As Integer? + Public Property Estado As Boolean + Public Property Estatus As String + Public Property RequiereSerieLote As Boolean? + Public Property Afectable As Boolean + Public Property TextoAfectable As String + Public Property CodigoClasificacion As String + Public Property NivelClasificacion As String + Public Property CveCategoria As Integer + Public Property Categoria As String + Public Property Tipo As Integer + Public Property EstatusCategoria As String + Public Property Fecha As DateTime + Public Property Usuario As String + Public Property CveEmpresa As Integer + Public Property CveUsuario As Integer? + Public Property UsoClasificacion As Integer + Public Property UsoClasif As String + Public Property CveSATPS As Integer + Public Property SATClaveProductoServicio As String + Public Property RequiereAFCompra As Boolean + Public Property RequiereAFInsumo As Boolean + Public Property RequierePersonal As Boolean + Public Property EsAcumulador As Boolean + End Class +#End Region #Region "P O L I Z A - V I R T U A L" Public Class MPolizaVentaLTHWSD diff --git a/Compras/Compras.aspx.vb b/Compras/Compras.aspx.vb index 61a3ac5a1..412c2d84c 100644 --- a/Compras/Compras.aspx.vb +++ b/Compras/Compras.aspx.vb @@ -4312,7 +4312,7 @@ Partial Class Compras_Compras Dim ImporteCompra As Decimal = TxtTotal.Text.ToDecimal Dim MultiplicadorNC = If(DdlTipoComprobante.SelectedValue = "NC", -1, 1) Dim CveMovimientoInventario As Integer = -1 - Dim IVA = 1.16 + Dim IVA As Decimal = 1.16D Dim ListaMovimientosAlmacen As New List(Of Integer) Dim ErrorCreditoCapitalIntres As Boolean = False @@ -4326,9 +4326,9 @@ Partial Class Compras_Compras Dim ConceptoPoliza As String = String.Format("{0} - {1}{2} - {3}", NombreProveedor, TxtSerie.Text, TxtFolio.Text, TxtDescripcion.Text.Trim) 'TIPO CAMBIO MANUAL CON COMPRA NUEVA - Dim TipoCambioGuardar = 1.0 + Dim TipoCambioGuardar As Decimal = 1 If DdlMoneda.SelectedValue.ToEntero > 1 Then - TipoCambioGuardar = If(DivTC.Visible, TxtTC.Text.ToDouble, LblTC.Text.Substring(3).ToDouble) + TipoCambioGuardar = If(DivTC.Visible, TxtTC.Text.ToDecimal, LblTC.Text.Substring(3).ToDecimal) End If TipoCambio = If(DivTC.Visible, TipoCambioGuardar, TipoCambio) @@ -5041,7 +5041,7 @@ Partial Class Compras_Compras Dim folio = 0 Dim fecha As Date = TxtFecha.Text.ToDate Dim indice = 0 - Dim importeconcepto = 0.0 + Dim importeconcepto As Decimal = 0 Dim listalmacenes = (From cvealmacen In DtInv.AsEnumerable() Where cvealmacen.Field(Of Integer)("cvealmacen") > 0 Select cvealmacen.Field(Of Integer)("cvealmacen")).Distinct().ToList @@ -5086,8 +5086,8 @@ Partial Class Compras_Compras For Each dr As DataRow In DtInv.Rows If dr("cvealmacen").ToString.ToEntero = tcvealmacen Then 'hay que restarle descuento - importeconcepto = If(DdlMoneda.SelectedValue.ToEntero = 1, dr("pu").ToString.ToDouble, dr("pu").ToString.ToDouble * TipoCambioGuardar) - (If(DdlMoneda.SelectedValue.ToEntero = 1, dr("descuento").ToString.ToDouble, dr("descuento").ToString.ToDouble * TipoCambioGuardar) / dr("cantidad").ToString.ToDouble) - If Not ObjInventario.AddMovimientoDetalle(cvemovimientoentrada, dr("cantidad").ToString.ToDouble, dr("cveum").ToString.ToEntero, dr("cveps").ToString.ToEntero, importeconcepto, -1, PUTC:=If(DdlMoneda.SelectedValue.ToEntero = 1, -1, dr("pu").ToString.ToDouble), CveCompraDetalle:=dr("CveCompraDetalle").ToString.ToEntero) Then + importeconcepto = If(DdlMoneda.SelectedValue.ToEntero = 1, dr("pu").ToString.ToDecimal, dr("pu").ToString.ToDecimal * TipoCambioGuardar) - (If(DdlMoneda.SelectedValue.ToEntero = 1, dr("descuento").ToString.ToDecimal, dr("descuento").ToString.ToDecimal * TipoCambioGuardar) / dr("cantidad").ToString.ToDecimal) + If Not ObjInventario.AddMovimientoDetalle(cvemovimientoentrada, dr("cantidad").ToString.ToDouble, dr("cveum").ToString.ToEntero, dr("cveps").ToString.ToEntero, importeconcepto, -1, PUTC:=If(DdlMoneda.SelectedValue.ToEntero = 1, -1, dr("pu").ToString.ToDecimal), CveCompraDetalle:=dr("CveCompraDetalle").ToString.ToEntero) Then ErrorMovInv = True Exit For @@ -5145,7 +5145,7 @@ Partial Class Compras_Compras Dim i As Integer = 0 Dim ListAlmacenes = (From CveAlmacen In DtInv.AsEnumerable() Where CveAlmacen.Field(Of Integer)("CveAlmacen") > 0 Select CveAlmacen.Field(Of Integer)("CveAlmacen")).Distinct().ToList Dim indice = 0 - Dim ImporteConcepto = 0.0 + Dim ImporteConcepto As Decimal = 0 For Each tCveAlmacen As Integer In ListAlmacenes If GvInv.Rows(indice).FCDropDownList("DdlRecibirInv").SelectedValue = "1" Then @@ -5165,10 +5165,10 @@ Partial Class Compras_Compras Dim DtDetalle As New DataTable Dim DtEquivalencias As DataTable Dim CveProducto As Integer - Dim CantidadInv As Double - Dim PUInv As Double + Dim CantidadInv As Decimal + Dim PUInv As Decimal Dim CveUnidad As Integer - Dim CostoIndirecto As Double + Dim CostoIndirecto As Decimal Dim tDescuento As Decimal = 0 ListaMovimientosAlmacen.Add(CveMovimientoInventario) @@ -5178,17 +5178,17 @@ Partial Class Compras_Compras CveProducto = Dr("CvePS").ToString.ToEntero CveUnidad = Dr("CveUM").ToString.ToEntero - CantidadInv = Dr("Cantidad").ToString.ToDouble - PUInv = Dr("PU").ToString.ToDouble - tDescuento = Dr("Descuento").ToString.ToDecimal / CantidadInv.ToDecimal - CostoIndirecto = Dr("CostoIndirectoAlmacen").ToString.ToDouble + CantidadInv = Dr("Cantidad").ToString.ToDecimal + PUInv = Dr("PU").ToString.ToDecimal + tDescuento = Dr("Descuento").ToString.ToDecimal / CantidadInv + CostoIndirecto = Dr("CostoIndirectoAlmacen").ToString.ToDecimal If Dr("CveMetodoInventario").ToString.ToEntero = 5 Then 'SI FUE POR SERIE LOTE DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("CvePS = {0}", Dr("CvePS"))) If DtDetalle.Rows.Count > 0 Then For Each drr As DataRow In DtDetalle.Rows - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoInventario, 1, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDouble, -1, SerieLote:=drr("Serie").ToString, FechaCaducidad:=drr("FechaCaducidad").ToString.ToDate, CostoIndirecto:=Dr("CostoIndirectoAlmacen").ToString.ToDouble, CveCompraDetalle:=Dr("CveCompraDetalle").ToString.ToEntero, CveOrdenCompraDetalle:=Dr("CveOrdenCompraDetalle").ToString.ToEntero) Then + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoInventario, 1, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, -1, SerieLote:=drr("Serie").ToString, FechaCaducidad:=drr("FechaCaducidad").ToString.ToDate, CostoIndirecto:=Dr("CostoIndirectoAlmacen").ToString.ToDecimal, CveCompraDetalle:=Dr("CveCompraDetalle").ToString.ToEntero, CveOrdenCompraDetalle:=Dr("CveOrdenCompraDetalle").ToString.ToEntero) Then ErrorMovInv = True Exit For End If @@ -5207,9 +5207,9 @@ Partial Class Compras_Compras 'SI LA UNIDAD ACTUAL NO ES LA BASE SACA PROPORCION (EQUIVALENTE) If CveUnidadBase <> CveUnidad Then ' LO QUE PUSE LO QUE VALE UNIDAD BASE LO QUE VALE UNIDAD SELECCIONADA - CantidadInv = Dr("Cantidad").ToString.ToDouble * drUMBase("Cantidad").ToString.ToDouble / DtEquivalencias.FiltraParametros(String.Format("CveUM = {0}", CveUnidad)).Rows(0)("Cantidad").ToString.ToDouble - PUInv = PUInv * Dr("Cantidad").ToString.ToDouble / CantidadInv - CostoIndirecto = CostoIndirecto * Dr("Cantidad").ToString.ToDouble / CantidadInv + CantidadInv = Dr("Cantidad").ToString.ToDecimal * drUMBase("Cantidad").ToString.ToDecimal / DtEquivalencias.FiltraParametros(String.Format("CveUM = {0}", CveUnidad)).Rows(0)("Cantidad").ToString.ToDecimal + PUInv = PUInv * Dr("Cantidad").ToString.ToDecimal / CantidadInv + CostoIndirecto = CostoIndirecto * Dr("Cantidad").ToString.ToDecimal / CantidadInv CveUnidad = CveUnidadBase End If End If @@ -5218,7 +5218,7 @@ Partial Class Compras_Compras ImporteConcepto = If(DdlMoneda.SelectedValue.ToEntero = 1, PUInv, PUInv * TipoCambioGuardar) - If(DdlMoneda.SelectedValue.ToEntero = 1, tDescuento, tDescuento * TipoCambioGuardar) ImporteConcepto = If(UsuarioActual.Empresa.UsaAC, ImporteConcepto * IVA, ImporteConcepto) If Dr("CveAlmacen").ToString.ToEntero = tCveAlmacen Then - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoInventario, CantidadInv, CveUnidad, Dr("CvePS").ToString.ToEntero, ImporteConcepto, -1, PUTC:=If(DdlMoneda.SelectedValue.ToEntero = 1, -1, Dr("PU").ToString.ToDouble), CostoIndirecto:=CostoIndirecto, CveCompraDetalle:=Dr("CveCompraDetalle").ToString.ToEntero, CveOrdenCompraDetalle:=Dr("CveOrdenCompraDetalle").ToString.ToEntero) Then + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoInventario, CantidadInv, CveUnidad, Dr("CvePS").ToString.ToEntero, ImporteConcepto, -1, PUTC:=If(DdlMoneda.SelectedValue.ToEntero = 1, -1, Dr("PU").ToString.ToDecimal), CostoIndirecto:=CostoIndirecto, CveCompraDetalle:=Dr("CveCompraDetalle").ToString.ToEntero, CveOrdenCompraDetalle:=Dr("CveOrdenCompraDetalle").ToString.ToEntero) Then ErrorMovInv = True Exit For End If @@ -13802,7 +13802,7 @@ Partial Class Compras_Compras Else For Each Dr As GridViewRow In GVDevolucion.Rows If Dr.FCTextBox("TxtCantidad").Text.ToDouble > 0 Then - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Dr.FCTextBox("TxtCantidad").Text.ToDouble, Dr.DataKey("CveUM").ToString.ToEntero, Dr.DataKey("CvePS").ToString.ToEntero, Dr.DataKey("PU").ToString.ToDouble, -1, CveMovimientoDetalleEntrada:=Dr.DataKey("CveMovimientoDetalle").ToString.ToEntero) Then + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Dr.FCTextBox("TxtCantidad").Text.ToDouble, Dr.DataKey("CveUM").ToString.ToEntero, Dr.DataKey("CvePS").ToString.ToEntero, Dr.DataKey("PU").ToString.ToDecimal, -1, CveMovimientoDetalleEntrada:=Dr.DataKey("CveMovimientoDetalle").ToString.ToEntero) Then ErrorMovInv = True Exit For End If diff --git a/Inventarios/Apartados.aspx.vb b/Inventarios/Apartados.aspx.vb index 08456d654..ff8a3ed97 100644 --- a/Inventarios/Apartados.aspx.vb +++ b/Inventarios/Apartados.aspx.vb @@ -691,7 +691,7 @@ Partial Class Inventarios_Apartados Else If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) 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.ToDouble, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString) Then + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString) Then ErrorMovInv = True TextoError = "Ocurrió un error al guardar los movimientos de entrada" Exit For @@ -906,7 +906,7 @@ Partial Class Inventarios_Apartados Else For Each Gvr As GridViewRow In GvDatosDesapartado.Rows If Gvr.FCTextBox("TxtCantidad").Text.ToDouble > 0 Then - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Gvr.FCTextBox("TxtCantidad").Text.ToDouble, Gvr.DataKey("CveUM").ToString.ToEntero, Gvr.DataKey("CvePS").ToString.ToEntero, Gvr.DataKey("PU").ToString.ToDouble, -1, -1, Gvr.DataKey("SerieLote").ToString, CveMovimientoDetalleEntrada:=Gvr.DataKey("CveMovimientoDetalle").ToString.ToEntero) Then + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Gvr.FCTextBox("TxtCantidad").Text.ToDouble, Gvr.DataKey("CveUM").ToString.ToEntero, Gvr.DataKey("CvePS").ToString.ToEntero, Gvr.DataKey("PU").ToString.ToDecimal, -1, -1, Gvr.DataKey("SerieLote").ToString, CveMovimientoDetalleEntrada:=Gvr.DataKey("CveMovimientoDetalle").ToString.ToEntero) Then ErrorMovInv = True TextoError = "Ocurrió un error al guardar los movimientos de salida" Exit For @@ -938,7 +938,7 @@ Partial Class Inventarios_Apartados Else If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) 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.ToDouble, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString) Then + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString) Then ErrorMovInv = True TextoError = "Ocurrió un error al guardar los movimientos de entrada" Exit For diff --git a/Inventarios/Consignaciones.aspx.vb b/Inventarios/Consignaciones.aspx.vb index e39887743..e7d2271f7 100644 --- a/Inventarios/Consignaciones.aspx.vb +++ b/Inventarios/Consignaciones.aspx.vb @@ -696,7 +696,7 @@ Partial Class Inventarios_Consignaciones 'AGREGAMOS MOVTOS DETALLE If CveMovimiento > 0 Then For Each Dr As DataRow In DtMovimientos.Rows - If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDouble, Dr("CveAF").ToString.ToEntero, PUTC:=If(DdlMoneda.SelectedValue.ToEntero <> 1, Dr("PUExtranjero").ToString.ToDouble, -1)) Then + If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero, PUTC:=If(DdlMoneda.SelectedValue.ToEntero <> 1, Dr("PUExtranjero").ToString.ToDecimal, -1)) Then ErrorMovInv = True TextoError = "Ocurrió un error al guardar los movimientos" Exit For @@ -844,7 +844,7 @@ Partial Class Inventarios_Consignaciones End If 'AGREGAMOS MOVTOS DETALLE - If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Gvr.FCTextBox("TxtCantidadDevolucion").Text.ToString.ToDouble, Gvr.DataKey("CveUM").ToString.ToEntero, Gvr.DataKey("CvePS").ToString.ToEntero, Gvr.DataKey("PU").ToString.ToDouble, -1, -1, "", "") Then + If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Gvr.FCTextBox("TxtCantidadDevolucion").Text.ToString.ToDouble, Gvr.DataKey("CveUM").ToString.ToEntero, Gvr.DataKey("CvePS").ToString.ToEntero, Gvr.DataKey("PU").ToString.ToDecimal, -1, -1, "", "") Then ErrorMovInv = True TextoError = "Ocurrió un Error al guardar los movimientos" Exit For @@ -1001,7 +1001,7 @@ Partial Class Inventarios_Consignaciones End If 'AGREGAMOS MOVTOS DETALLE - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Gvr.FCTextBox("TxtCantidadDevolucion").Text.ToString.ToDouble, Gvr.DataKey("CveUM").ToString.ToEntero, Gvr.DataKey("CvePS").ToString.ToEntero, Gvr.DataKey("PU").ToString.ToDouble, -1, -1, "", "") Then + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Gvr.FCTextBox("TxtCantidadDevolucion").Text.ToString.ToDouble, Gvr.DataKey("CveUM").ToString.ToEntero, Gvr.DataKey("CvePS").ToString.ToEntero, Gvr.DataKey("PU").ToString.ToDecimal, -1, -1, "", "") Then ErrorMovInv = True TextoError = "Ocurrió un Error al guardar los movimientos detalle de la salida" Exit For @@ -1061,7 +1061,7 @@ Partial Class Inventarios_Consignaciones If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) 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.ToDouble, Dr("CveAF").ToString.ToEntero) Then + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero) Then ErrorMovInv = True TextoError = "Ocurrió un error al guardar los movimientos de entrada" Exit For @@ -1300,7 +1300,7 @@ Partial Class Inventarios_Consignaciones 'End Try CveMovimientoDetalleEntrada = gvr.DataKey("CveMovimientoDetalle").ToString.ToEntero - 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.ToDouble, gvr.DataKey("CveAF").ToString.ToEntero, CveMovimientoDetalleEntrada:=CveMovimientoDetalleEntrada) Then + 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, gvr.DataKey("CveAF").ToString.ToEntero, CveMovimientoDetalleEntrada:=CveMovimientoDetalleEntrada) Then ErrorMovInv = True TextoError = "Ocurrió un error al guardar los movimientos de salida" Exit For @@ -1325,7 +1325,7 @@ Partial Class Inventarios_Consignaciones If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) 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.ToDouble, Dr("CveAF").ToString.ToEntero) Then + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero) Then ErrorMovInv = True TextoError = "Ocurrió un error al guardar los movimientos de entrada" Exit For diff --git a/Inventarios/EntradasSalidas.aspx.vb b/Inventarios/EntradasSalidas.aspx.vb index ffcf00fcc..595bb902b 100644 --- a/Inventarios/EntradasSalidas.aspx.vb +++ b/Inventarios/EntradasSalidas.aspx.vb @@ -1,888 +1,888 @@ -Option Explicit On -Option Strict On - -Imports System.Data -Imports Extensiones -Imports System.IO -Imports Microsoft.Reporting.WebForms - -'Imports DocumentFormat.OpenXml.Wordprocessing - -Partial Class Inventarios_EntradasSalidas - Inherits ClsPaginas - -#Region "Propiedades" - - Private _dtDatos As DataTable - Private Property NumRow As Integer - - Public Property DtMovimientos() As DataTable - Get - Return CType(ViewState("DtMovimientos"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtMovimientos") = value - End Set - End Property - - Public Property DtMovimientosEntradaInvFisico() As DataTable - Get - Return CType(ViewState("DtMovimientosEntradaInvFisico"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtMovimientosEntradaInvFisico") = value - End Set - End Property - - Public Property DtMovimientosSalidaInvFisico() As DataTable - Get - Return CType(ViewState("DtMovimientosSalidaInvFisico"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtMovimientosSalidaInvFisico") = value - End Set - End Property - - Public Property CveMovimiento() As Integer - Get - Return ViewState("CveMovimiento").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("CveMovimiento") = value - End Set - End Property - Private Property DtMov As DataTable - Get - Return CType(ViewState("DtMov"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtMov") = value - End Set - End Property - Public Property CveCompra() As Integer - Get - Return ViewState("CveCompra").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("CveCompra") = value - End Set - End Property - Public Property CveConcepto() As Integer - Get - Return ViewState("CveConcepto").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("CveConcepto") = value - End Set - End Property - Public Property Folio() As Integer - Get - Return ViewState("Folio").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("Folio") = value - End Set - End Property - Public Property CveMovimientoRelacionado As Integer - Get - Return ViewState("CveMovimientoRelacionado").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("CveMovimientoRelacionado") = value - End Set - End Property - Public Property ConceptoRelacionado As String - Get - Return ViewState("ConceptoRelacionado").ToString - End Get - Set(value As String) - ViewState("ConceptoRelacionado") = value - End Set - End Property - Public Property FolioRelacionado As Integer - Get - Return ViewState("FolioRelacionado").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("FolioRelacionado") = value - End Set - End Property - Public Property TieneRelacionado As Integer - Get - Return ViewState("TieneRelacionado").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("TieneRelacionado") = value - End Set - End Property - Public Property EstatusAlmacenCompra As Integer - Get - Return ViewState("EstatusAlmacenCompra").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("EstatusAlmacenCompra") = value - End Set - End Property - Public Property TieneSalida As Boolean - Get - Return CBool(ViewState("TieneSalida").ToString) - End Get - Set(value As Boolean) - ViewState("TieneSalida") = value - End Set - End Property - Private Property DtBitacora As DataTable - Get - Return CType(ViewState("DtBitacora"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtBitacora") = value - End Set - End Property - Private Property CvePSSerieLote As Integer - Get - Return CType(ViewState("CvePSSerieLote"), Integer) - End Get - Set(value As Integer) - ViewState("CvePSSerieLote") = value - End Set - End Property - Private Property PSSerieLote As String - Get - Return CType(ViewState("PSSerieLote"), String) - End Get - Set(value As String) - ViewState("PSSerieLote") = value - End Set - End Property - Private Property CveUMSerieLote As Integer - Get - Return CType(ViewState("CveUMSerieLote"), Integer) - End Get - Set(value As Integer) - ViewState("CveUMSerieLote") = value - End Set - End Property - Private Property UMSerieLote As String - Get - Return CType(ViewState("UMSerieLote"), String) - End Get - Set(value As String) - ViewState("UMSerieLote") = value - End Set - End Property - Private Property CostoPromedioSerieLote As Double - Get - Return CType(ViewState("CostoPromedioSerieLote"), Double) - End Get - Set(value As Double) - ViewState("CostoPromedioSerieLote") = value - End Set - End Property - Public Property EsConsumoInterno As Boolean - Get - Return CBool(ViewState("EsConsumoInterno").ToString) - End Get - Set(value As Boolean) - ViewState("EsConsumoInterno") = value - End Set - End Property - Private Property FolioAsignado As Integer - Get - Return CType(ViewState("FolioAsignado"), Integer) - End Get - Set(value As Integer) - ViewState("FolioAsignado") = value - End Set - End Property - Public Property EsNuevoMov As Boolean - Get - Return CBool(ViewState("EsNuevoMov").ToString) - End Get - Set(value As Boolean) - ViewState("EsNuevoMov") = value - End Set - End Property - - Private Property DtSeccionAlmacen As DataTable - Get - Return CType(ViewState("DtSeccionAlmacen"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtSeccionAlmacen") = value - End Set - End Property - Private Property IndexSeccionAlmacen As Integer - Get - Return CType(ViewState("IndexSeccionAlmacen"), Integer) - End Get - Set(value As Integer) - ViewState("IndexSeccionAlmacen") = value - End Set - End Property - Private Property CantidadTotal As Decimal - Get - Return CType(ViewState("CantidadTotal"), Decimal) - End Get - Set(value As Decimal) - ViewState("CantidadTotal") = value - End Set - End Property - Private Property CvePS As Integer - Get - Return CType(ViewState("CvePS"), Integer) - End Get - Set(value As Integer) - ViewState("CvePS") = value - End Set - End Property - Private Property Tipo As Integer - Get - Return CType(ViewState("Tipo"), Integer) - End Get - Set(value As Integer) - ViewState("Tipo") = value - End Set - End Property - Private Property CvePrePoliza As Integer - Get - Return CType(ViewState("CvePrePoliza"), Integer) - End Get - Set(value As Integer) - ViewState("CvePrePoliza") = value - End Set - End Property - Private Property DescripcionDetalladaEliminar As String - Get - Return CType(ViewState("DescripcionDetalladaEliminar"), String) - End Get - Set(value As String) - ViewState("DescripcionDetalladaEliminar") = value - End Set +Option Explicit On +Option Strict On + +Imports System.Data +Imports Extensiones +Imports System.IO +Imports Microsoft.Reporting.WebForms + +'Imports DocumentFormat.OpenXml.Wordprocessing + +Partial Class Inventarios_EntradasSalidas + Inherits ClsPaginas + +#Region "Propiedades" + + Private _dtDatos As DataTable + Private Property NumRow As Integer + + Public Property DtMovimientos() As DataTable + Get + Return CType(ViewState("DtMovimientos"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtMovimientos") = value + End Set End Property -#End Region + Public Property DtMovimientosEntradaInvFisico() As DataTable + Get + Return CType(ViewState("DtMovimientosEntradaInvFisico"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtMovimientosEntradaInvFisico") = value + End Set + End Property - Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load - If Not IsPostBack Then - - CveMovimiento = -1 - CveMovimientoRelacionado = -1 - TieneRelacionado = -1 - TieneSalida = False - EstatusAlmacenCompra = -1 - EsConsumoInterno = False - EsNuevoMov = False - CvePrePoliza = -1 - - CreaDT() - CargaCombos() - TxtFecha.Text = Now.ToShortDateString - RVFecha.MaximumValue = Now.ToShortDateString - InicializaClientes() - - CantidadTotal = 0 - IndexSeccionAlmacen = 0 - Tipo = 0 - CreaDtSeccionAlmacen() - CargaDdlAlmacen() - - 'si viene una parámetro para cargar un movimiento lo hacemos dentro del procedimiento cargadatos - Select Case UsuarioActual.Empresa.Funcionalidad(103) - Case "1" - - Case "2" - divMonedaSeccion.Visible = True - divGuia.Visible = True - End Select - - - If Request("CveMovimiento") IsNot Nothing AndAlso Request("CveMovimiento").ToString.ToEntero > 0 Then - CargaDatos(Request("CveMovimiento").ToString.ToEntero) - 'CargaGvPaqueteria() - Else - AsignacionOpcion() - SiguienteFolio() - End If - - 'SI YA ES MOVIMIENTO REGISTRADO NO ESCONDE COLUMNA AF - If CveMovimiento > 0 Then - BloqueaEdicionEncabezado() - If UsuarioActual.CveEmpresa.Contiene(66, 13) Then - TrSubProyectoActivoFijo.Visible = True - VisualizaAF(True) - CargaSubProyectos() - End If - End If - - InicializaBitacoraTemporal() - - If UsuarioActual.Empresa.Funcionalidad(132) = "1" Then - DivCodigoSeriePS.Visible = True - End If - - If IfNull(Request("CI"), -1).ToString.ToEntero > 0 Then - ActivaConsumoInterno() - End If - - 'SECCION ALMACEN EXISTENCIAS - GvM.Columns(14).Visible = UsuarioActual.Empresa.Funcionalidad(563).ToString = "1" AndAlso Not CveMovimiento > 0 - - 'BLOQUEA PERMISOS - BtnGuardar.Enabled = PermiteGuardar() - BtnEliminar.Enabled = PermiteEliminar() - BtnContabilizar.Enabled = PermiteContabilizar() - BtnNuevo.Enabled = PermiteCrearNuevo() - - ActivaPermisoSeccionAlmacen() - If CveMovimiento > 0 Then - PermisoVerImportes() - End If - End If - End Sub - -#Region " PERMISOS PAGINAS " - Private Function PermiteGuardar() As Boolean - Return If(UsuarioActual.TienePermisoProceso(181) Or EsConsumoInterno, True, False) - End Function - ''' - ''' Este permiso solo habilita el Btn del GV. Debe ir en conjunto con el permiso 181 [PermiteGuardar] - ''' - Private Function PermiteGuardarObservacionDetalle() As Boolean - Return UsuarioActual.TienePermisoProceso(225) - End Function - Private Function PermiteEliminar() As Boolean - Return If(UsuarioActual.TienePermisoProceso(182), True, False) - End Function - Private Function PermiteContabilizar() As Boolean - Return If(UsuarioActual.TienePermisoProceso(183), True, False) - End Function - Private Function PermiteCrearNuevo() As Boolean - Return If(UsuarioActual.TienePermisoProceso(184) Or EsConsumoInterno, True, False) - End Function - Private Sub ActivaPermisoSeccionAlmacen() - GvM.Columns(12).Visible = UsuarioActual.Empresa.Funcionalidad(147) = "1" - TrSeccionAlmacen.Visible = UsuarioActual.Empresa.Funcionalidad(147) = "1" - TrSeccionAlmacen2.Visible = UsuarioActual.Empresa.Funcionalidad(147) = "1" - End Sub - Private Sub PermisoVerImportes() - Dim TienePermisoImportes As Boolean = UsuarioActual.TienePermisoProceso(201) - tdPU.Visible = TienePermisoImportes - tdTxtPU.Visible = TienePermisoImportes - GvM.Columns(4).Visible = TienePermisoImportes - - ThTotal.Visible = TienePermisoImportes - TdTotal.Visible = TienePermisoImportes - GvM.Columns(5).Visible = TienePermisoImportes - End Sub - - Private Sub CargaDdlPaqueteria() - 'DdlPaqueteria.DataSource = GlobalDTPaqueterias - 'DdlPaqueteria.DataBind() - 'DdlPaqueteria.Items.Insert(0, New ListItem("Seleccione uno", "-1")) - End Sub -#End Region - - Sub AsignacionOpcion() - DdlConcepto.SelectedValueExist("-1") - If UsuarioActual.CveEmpresa.Contiene(66, 13) Then - TrSubProyectoActivoFijo.Visible = True - VisualizaAF(True) - CargaSubProyectos() - End If - End Sub - - Private Function isWhitFamily() As Boolean - Return (UsuarioActual.CveEmpresa = 66) - End Function - -#Region " VALORES INICIALES " - Protected Sub CreaDT() - Dim dt As New DataTable - - Dim column As DataColumn = New DataColumn("No") - column.DataType = Type.GetType("System.Int32") - With column - .AutoIncrement = True - .AutoIncrementSeed = 1 - .AutoIncrementStep = 1 - End With - - 'dt.Columns.Add("No", Type.GetType("System.Int32")) - dt.Columns.Add(column) - dt.Columns.Add("CveMovimiento", Type.GetType("System.Int32")) - dt.Columns.Add("CveMovimientoDetalle", Type.GetType("System.Int32")) - dt.Columns.Add("Cantidad", Type.GetType("System.Double")) - dt.Columns.Add("CveUM", Type.GetType("System.Int32")) - dt.Columns.Add("UnidadMedida") - dt.Columns.Add("CvePS", Type.GetType("System.Int32")) - dt.Columns.Add("CodigoPS") - dt.Columns.Add("Codigo") - dt.Columns.Add("PS") - dt.Columns.Add("PU", Type.GetType("System.Double")) - dt.Columns.Add("PUExtranjero", Type.GetType("System.Double")) - dt.Columns.Add("Total", Type.GetType("System.Double")) - dt.Columns.Add("CveClasificacion", Type.GetType("System.Int32")) - dt.Columns.Add("CveSeccionAlmacen", Type.GetType("System.Int32")) - dt.Columns.Add("SeccionAlmacen") - dt.Columns.Add("Estatus") - - dt.Columns.Add("CostoIndirecto", Type.GetType("System.Double")) - dt.Columns.Add("CodigoAF") - dt.Columns.Add("CveAF") - dt.Columns.Add("SerieLote", Type.GetType("System.String")) - dt.Columns.Add("Lote", Type.GetType("System.String")) - dt.Columns.Add("Batch", Type.GetType("System.String")) - - dt.Columns.Add("Observaciones") - dt.Columns.Add("CountMovimientoEntradaDetalle") - dt.Columns.Add("TotalExtranjero", Type.GetType("System.Double")) - - CargaGVM(dt) - - DtMovimientos = dt.Clone - DtMovimientosEntradaInvFisico = dt.Clone - DtMovimientosSalidaInvFisico = dt.Clone - - End Sub - Private Sub CargaCombos() - 'Llenar el dropdownlist de Secciones - If UsuarioActual.CveEmpresa = 66 Then - DdlClasificacion.DataSource = GlobalDTSubFamilias(UsuarioActual.CveEmpresa).FiltraParametros("", Orderby:="Clasificacion") - Else - Dim ObjClasificaciones As New ClsClasificaciones - If ObjClasificaciones.GetClasificacionesExistencias(UsuarioActual.CveEmpresa) Then - DdlClasificacion.DataSource = ObjClasificaciones.DtResultados - End If - ObjClasificaciones.Dispose() - End If - DdlClasificacion.DataBind() - - DdlSeccion.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa) - DdlSeccion.Items.Insert(0, New ListItem("Seleccione", "-1")) - DdlSeccion.DataBind() - - DdlSeccionAlmacen.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa) - DdlSeccionAlmacen.DataBind() - - 'Llenar el dropdownlist de monedas - DdlMoneda.DataSource = GlobalDTMonedas - DdlMoneda.DataBind() - - 'MOVIMIENTO - DdlConcepto.DataSource = GlobalDTInvConceptos.FiltraParametros(IIf(UsuarioActual.CveEmpresa.Contiene(72, 80, 1), "CveConcepto NOT IN (4,5,10)", "CveConcepto NOT IN (1,2,4,5,8,9,10,12,26,27,29)").ToString) - DdlConcepto.DataBind() - - 'FILTRO - DdlCConcepto.DataSource = GlobalDTInvConceptos.FiltraParametros("CveConcepto NOT IN (4,5)") - DdlCConcepto.DataBind() - - 'Llenar el dropdownlist de almacén - If Not IfNull(Request("CI"), -1).ToString.ToEntero > 0 Then - DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen NOT IN (9,11)") 'GlobalDTAlmacen(UsuarioActual.CveEmpresa) - - End If - DdlAlmacenInventarioFisico.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen NOT IN (9,11)") 'GlobalDTAlmacen(UsuarioActual.CveEmpresa) - - DdlAlmacen.Items.Insert(0, New ListItem("Seleccione", "-1")) - DdlAlmacenInventarioFisico.Items.Insert(0, New ListItem("Seleccione", "-1")) - - DdlAlmacen.SelectedValue = "-1" - DdlAlmacenInventarioFisico.SelectedValue = "-1" - - DdlAlmacen.DataBind() - DdlAlmacenInventarioFisico.DataBind() - - If IsNothing(Request("CveMovimiento")) Then - DdlAlmacen.SelectedValueExist(UsuarioActual.CveAlmacen) - DdlAlmacen_SelectedIndexChanged(DdlAlmacen, EventArgs.Empty) - End If - - If DdlAlmacen.SelectedValue.ToEntero = -1 Then - DdlConcepto.Items.Clear() - DdlConcepto.Items.Insert(0, New ListItem("Seleccione", "-1")) - End If - - CargaPS() - - ' CargaDdlPaqueteria() - - End Sub - Private Sub CargaPS() - DdlProducto2.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1") - DdlPS.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1") - DdlPSSalida.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1") - - If UsuarioActual.CveEmpresa = 66 Then - DdlProducto2.ddlWS.Attributes.Add("data-pagina", "Inventarios") - End If - - If Not DdlProducto2.UsaWebService AndAlso CType(DdlProducto2.DataSource, DataTable) Is Nothing Then - DdlProducto2.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoPS = 2") - DdlPS.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoPS = 2") - DdlPSSalida.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoPS = 2") - - DdlProducto2.DataBind() - DdlPS.DataBind() - DdlPSSalida.DataBind() - - DdlProducto2.ddl.Items.Insert(0, New ListItem("Seleccione", "-1")) - DdlPS.ddl.Items.Insert(0, New ListItem("Seleccione", "-1")) - DdlPSSalida.ddl.Items.Insert(0, New ListItem("Seleccione", "-1")) - End If - - End Sub - Private Sub CargaSubProyectos() - DdlSubProyecto.DataSource = If(UsuarioActual.Empresa.Funcionalidad(102) = "1" AndAlso Not UsuarioActual.TienePermisoProceso(110), GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1), GlobalDTSubProyectos(-1, -1, UsuarioActual.CveEmpresa, 1)) - DdlSubProyecto.DataBind() - 'DdlSubProyecto.Items.Insert(0, New ListItem("Seleccione", "-1")) - End Sub - Private Sub CargaPersonal() - TrPersonal.Visible = True - Dim dt As DataTable = Nothing - - Dim RH As New ClsRH - - If RH.GetPersonal(-1, UsuarioActual.CveEmpresa) Then - dt = RH.DtResultados - End If - - RH.Dispose() - - DdlPersonal.DataSource = dt - DdlPersonal.DataBind() - 'DdlSubProyecto.Items.Insert(0, New ListItem("Seleccione", "-1")) - End Sub -#End Region - - -#Region " CARGA DATOS " - Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) Handles BtnConsultar.Click - GvM.EditIndex = -1 - LimpiarMovimiento() - CargaDatos(-1, DdlCConcepto.SelectedValue.ToEntero(), TxtCFolio.Text.ToEntero) - End Sub - Private Sub CargaDatos(tCveMovimiento As Integer, Optional pCveConcepto As Integer = -1, Optional pFolio As Integer = -1) - Dim Mov As New ClsInventarios - DtMovimientos.Clear() - TieneSalida = False - EstatusAlmacenCompra = -1 - - If UsuarioActual.CveEmpresa = 48 Then - GvM.Columns(8).Visible = False - End If - - - - If Mov.GetMovimientos(tCveMovimiento, pCveConcepto, pFolio, UsuarioActual.CveEmpresa) AndAlso Mov.DtResultados.Rows.Count = 1 Then - - CveMovimiento = Mov.CveMovimiento - DtMov = Mov.DtResultados - TxtFecha.Text = Mov.Fecha.ToShortDateString - TxtHoraInicio.SelectedTime = Mov.Fecha - EstatusAlmacenCompra = Mov.EstatusAlmacenCompra - Folio = Mov.Folio - - - If DtMov.Rows(0)("CveConcepto").ToString.ToEntero = 2 Then - HplTraspaso.Visible = True - HplTraspaso.NavigateUrl = $"/Inventarios/TraspasoAlmacen.aspx?CveEntrada={DtMov.Rows(0)("CveMovimiento").ToString}" - End If - 'DATOS DE REGISTRO - DivRegistro.Visible = True - LnkAgregarNuevoMov.Visible = True - LblUsuarioRegistro.Text = Mov.NombreCapturo - LblFechaRegistro.Text = Mov.FechaRegistro.ToShortDateString - - If DtMov.Rows(0)("CvePrePoliza").ToString.ToEntero > 0 Then - HplPrePoliza.Visible = True - HplPrePoliza.NavigateUrl = String.Format("/Contabilidad/RegPrePoliza.aspx?CvePrePoliza={0}", DtMov.Rows(0)("CvePrePoliza")) + Public Property DtMovimientosSalidaInvFisico() As DataTable + Get + Return CType(ViewState("DtMovimientosSalidaInvFisico"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtMovimientosSalidaInvFisico") = value + End Set + End Property + + Public Property CveMovimiento() As Integer + Get + Return ViewState("CveMovimiento").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveMovimiento") = value + End Set + End Property + Private Property DtMov As DataTable + Get + Return CType(ViewState("DtMov"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtMov") = value + End Set + End Property + Public Property CveCompra() As Integer + Get + Return ViewState("CveCompra").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveCompra") = value + End Set + End Property + Public Property CveConcepto() As Integer + Get + Return ViewState("CveConcepto").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveConcepto") = value + End Set + End Property + Public Property Folio() As Integer + Get + Return ViewState("Folio").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("Folio") = value + End Set + End Property + Public Property CveMovimientoRelacionado As Integer + Get + Return ViewState("CveMovimientoRelacionado").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveMovimientoRelacionado") = value + End Set + End Property + Public Property ConceptoRelacionado As String + Get + Return ViewState("ConceptoRelacionado").ToString + End Get + Set(value As String) + ViewState("ConceptoRelacionado") = value + End Set + End Property + Public Property FolioRelacionado As Integer + Get + Return ViewState("FolioRelacionado").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("FolioRelacionado") = value + End Set + End Property + Public Property TieneRelacionado As Integer + Get + Return ViewState("TieneRelacionado").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("TieneRelacionado") = value + End Set + End Property + Public Property EstatusAlmacenCompra As Integer + Get + Return ViewState("EstatusAlmacenCompra").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("EstatusAlmacenCompra") = value + End Set + End Property + Public Property TieneSalida As Boolean + Get + Return CBool(ViewState("TieneSalida").ToString) + End Get + Set(value As Boolean) + ViewState("TieneSalida") = value + End Set + End Property + Private Property DtBitacora As DataTable + Get + Return CType(ViewState("DtBitacora"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtBitacora") = value + End Set + End Property + Private Property CvePSSerieLote As Integer + Get + Return CType(ViewState("CvePSSerieLote"), Integer) + End Get + Set(value As Integer) + ViewState("CvePSSerieLote") = value + End Set + End Property + Private Property PSSerieLote As String + Get + Return CType(ViewState("PSSerieLote"), String) + End Get + Set(value As String) + ViewState("PSSerieLote") = value + End Set + End Property + Private Property CveUMSerieLote As Integer + Get + Return CType(ViewState("CveUMSerieLote"), Integer) + End Get + Set(value As Integer) + ViewState("CveUMSerieLote") = value + End Set + End Property + Private Property UMSerieLote As String + Get + Return CType(ViewState("UMSerieLote"), String) + End Get + Set(value As String) + ViewState("UMSerieLote") = value + End Set + End Property + Private Property CostoPromedioSerieLote As Decimal + Get + Return CType(ViewState("CostoPromedioSerieLote"), Decimal) + End Get + Set(value As Decimal) + ViewState("CostoPromedioSerieLote") = value + End Set + End Property + Public Property EsConsumoInterno As Boolean + Get + Return CBool(ViewState("EsConsumoInterno").ToString) + End Get + Set(value As Boolean) + ViewState("EsConsumoInterno") = value + End Set + End Property + Private Property FolioAsignado As Integer + Get + Return CType(ViewState("FolioAsignado"), Integer) + End Get + Set(value As Integer) + ViewState("FolioAsignado") = value + End Set + End Property + Public Property EsNuevoMov As Boolean + Get + Return CBool(ViewState("EsNuevoMov").ToString) + End Get + Set(value As Boolean) + ViewState("EsNuevoMov") = value + End Set + End Property + + Private Property DtSeccionAlmacen As DataTable + Get + Return CType(ViewState("DtSeccionAlmacen"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtSeccionAlmacen") = value + End Set + End Property + Private Property IndexSeccionAlmacen As Integer + Get + Return CType(ViewState("IndexSeccionAlmacen"), Integer) + End Get + Set(value As Integer) + ViewState("IndexSeccionAlmacen") = value + End Set + End Property + Private Property CantidadTotal As Decimal + Get + Return CType(ViewState("CantidadTotal"), Decimal) + End Get + Set(value As Decimal) + ViewState("CantidadTotal") = value + End Set + End Property + Private Property CvePS As Integer + Get + Return CType(ViewState("CvePS"), Integer) + End Get + Set(value As Integer) + ViewState("CvePS") = value + End Set + End Property + Private Property Tipo As Integer + Get + Return CType(ViewState("Tipo"), Integer) + End Get + Set(value As Integer) + ViewState("Tipo") = value + End Set + End Property + Private Property CvePrePoliza As Integer + Get + Return CType(ViewState("CvePrePoliza"), Integer) + End Get + Set(value As Integer) + ViewState("CvePrePoliza") = value + End Set + End Property + Private Property DescripcionDetalladaEliminar As String + Get + Return CType(ViewState("DescripcionDetalladaEliminar"), String) + End Get + Set(value As String) + ViewState("DescripcionDetalladaEliminar") = value + End Set + End Property + +#End Region + + Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load + If Not IsPostBack Then + + CveMovimiento = -1 + CveMovimientoRelacionado = -1 + TieneRelacionado = -1 + TieneSalida = False + EstatusAlmacenCompra = -1 + EsConsumoInterno = False + EsNuevoMov = False + CvePrePoliza = -1 + + CreaDT() + CargaCombos() + TxtFecha.Text = Now.ToShortDateString + RVFecha.MaximumValue = Now.ToShortDateString + InicializaClientes() + + CantidadTotal = 0 + IndexSeccionAlmacen = 0 + Tipo = 0 + CreaDtSeccionAlmacen() + CargaDdlAlmacen() + + 'si viene una parámetro para cargar un movimiento lo hacemos dentro del procedimiento cargadatos + Select Case UsuarioActual.Empresa.Funcionalidad(103) + Case "1" + + Case "2" + divMonedaSeccion.Visible = True + divGuia.Visible = True + End Select + + + If Request("CveMovimiento") IsNot Nothing AndAlso Request("CveMovimiento").ToString.ToEntero > 0 Then + CargaDatos(Request("CveMovimiento").ToString.ToEntero) + 'CargaGvPaqueteria() + Else + AsignacionOpcion() + SiguienteFolio() + End If + + 'SI YA ES MOVIMIENTO REGISTRADO NO ESCONDE COLUMNA AF + If CveMovimiento > 0 Then + BloqueaEdicionEncabezado() + If UsuarioActual.CveEmpresa.Contiene(66, 13) Then + TrSubProyectoActivoFijo.Visible = True + VisualizaAF(True) + CargaSubProyectos() + End If + End If + + InicializaBitacoraTemporal() + + If UsuarioActual.Empresa.Funcionalidad(132) = "1" Then + DivCodigoSeriePS.Visible = True + End If + + If IfNull(Request("CI"), -1).ToString.ToEntero > 0 Then + ActivaConsumoInterno() + End If + + 'SECCION ALMACEN EXISTENCIAS + GvM.Columns(14).Visible = UsuarioActual.Empresa.Funcionalidad(563).ToString = "1" AndAlso Not CveMovimiento > 0 + + 'BLOQUEA PERMISOS + BtnGuardar.Enabled = PermiteGuardar() + BtnEliminar.Enabled = PermiteEliminar() + BtnContabilizar.Enabled = PermiteContabilizar() + BtnNuevo.Enabled = PermiteCrearNuevo() + + ActivaPermisoSeccionAlmacen() + If CveMovimiento > 0 Then + PermisoVerImportes() + End If + End If + End Sub + +#Region " PERMISOS PAGINAS " + Private Function PermiteGuardar() As Boolean + Return If(UsuarioActual.TienePermisoProceso(181) Or EsConsumoInterno, True, False) + End Function + ''' + ''' Este permiso solo habilita el Btn del GV. Debe ir en conjunto con el permiso 181 [PermiteGuardar] + ''' + Private Function PermiteGuardarObservacionDetalle() As Boolean + Return UsuarioActual.TienePermisoProceso(225) + End Function + Private Function PermiteEliminar() As Boolean + Return If(UsuarioActual.TienePermisoProceso(182), True, False) + End Function + Private Function PermiteContabilizar() As Boolean + Return If(UsuarioActual.TienePermisoProceso(183), True, False) + End Function + Private Function PermiteCrearNuevo() As Boolean + Return If(UsuarioActual.TienePermisoProceso(184) Or EsConsumoInterno, True, False) + End Function + Private Sub ActivaPermisoSeccionAlmacen() + GvM.Columns(12).Visible = UsuarioActual.Empresa.Funcionalidad(147) = "1" + TrSeccionAlmacen.Visible = UsuarioActual.Empresa.Funcionalidad(147) = "1" + TrSeccionAlmacen2.Visible = UsuarioActual.Empresa.Funcionalidad(147) = "1" + End Sub + Private Sub PermisoVerImportes() + Dim TienePermisoImportes As Boolean = UsuarioActual.TienePermisoProceso(201) + tdPU.Visible = TienePermisoImportes + tdTxtPU.Visible = TienePermisoImportes + GvM.Columns(4).Visible = TienePermisoImportes + + ThTotal.Visible = TienePermisoImportes + TdTotal.Visible = TienePermisoImportes + GvM.Columns(5).Visible = TienePermisoImportes + End Sub + + Private Sub CargaDdlPaqueteria() + 'DdlPaqueteria.DataSource = GlobalDTPaqueterias + 'DdlPaqueteria.DataBind() + 'DdlPaqueteria.Items.Insert(0, New ListItem("Seleccione uno", "-1")) + End Sub +#End Region + + Sub AsignacionOpcion() + DdlConcepto.SelectedValueExist("-1") + If UsuarioActual.CveEmpresa.Contiene(66, 13) Then + TrSubProyectoActivoFijo.Visible = True + VisualizaAF(True) + CargaSubProyectos() + End If + End Sub + + Private Function isWhitFamily() As Boolean + Return (UsuarioActual.CveEmpresa = 66) + End Function + +#Region " VALORES INICIALES " + Protected Sub CreaDT() + Dim dt As New DataTable + + Dim column As DataColumn = New DataColumn("No") + column.DataType = Type.GetType("System.Int32") + With column + .AutoIncrement = True + .AutoIncrementSeed = 1 + .AutoIncrementStep = 1 + End With + + 'dt.Columns.Add("No", Type.GetType("System.Int32")) + dt.Columns.Add(column) + dt.Columns.Add("CveMovimiento", Type.GetType("System.Int32")) + dt.Columns.Add("CveMovimientoDetalle", Type.GetType("System.Int32")) + dt.Columns.Add("Cantidad", Type.GetType("System.Double")) + dt.Columns.Add("CveUM", Type.GetType("System.Int32")) + dt.Columns.Add("UnidadMedida") + dt.Columns.Add("CvePS", Type.GetType("System.Int32")) + dt.Columns.Add("CodigoPS") + dt.Columns.Add("Codigo") + dt.Columns.Add("PS") + dt.Columns.Add("PU", Type.GetType("System.Double")) + dt.Columns.Add("PUExtranjero", Type.GetType("System.Double")) + dt.Columns.Add("Total", Type.GetType("System.Double")) + dt.Columns.Add("CveClasificacion", Type.GetType("System.Int32")) + dt.Columns.Add("CveSeccionAlmacen", Type.GetType("System.Int32")) + dt.Columns.Add("SeccionAlmacen") + dt.Columns.Add("Estatus") + + dt.Columns.Add("CostoIndirecto", Type.GetType("System.Double")) + dt.Columns.Add("CodigoAF") + dt.Columns.Add("CveAF") + dt.Columns.Add("SerieLote", Type.GetType("System.String")) + dt.Columns.Add("Lote", Type.GetType("System.String")) + dt.Columns.Add("Batch", Type.GetType("System.String")) + + dt.Columns.Add("Observaciones") + dt.Columns.Add("CountMovimientoEntradaDetalle") + dt.Columns.Add("TotalExtranjero", Type.GetType("System.Double")) + + CargaGVM(dt) + + DtMovimientos = dt.Clone + DtMovimientosEntradaInvFisico = dt.Clone + DtMovimientosSalidaInvFisico = dt.Clone + + End Sub + Private Sub CargaCombos() + 'Llenar el dropdownlist de Secciones + If UsuarioActual.CveEmpresa = 66 Then + DdlClasificacion.DataSource = GlobalDTSubFamilias(UsuarioActual.CveEmpresa).FiltraParametros("", Orderby:="Clasificacion") + Else + Dim ObjClasificaciones As New ClsClasificaciones + If ObjClasificaciones.GetClasificacionesExistencias(UsuarioActual.CveEmpresa) Then + DdlClasificacion.DataSource = ObjClasificaciones.DtResultados + End If + ObjClasificaciones.Dispose() + End If + DdlClasificacion.DataBind() + + DdlSeccion.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa) + DdlSeccion.Items.Insert(0, New ListItem("Seleccione", "-1")) + DdlSeccion.DataBind() + + DdlSeccionAlmacen.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa) + DdlSeccionAlmacen.DataBind() + + 'Llenar el dropdownlist de monedas + DdlMoneda.DataSource = GlobalDTMonedas + DdlMoneda.DataBind() + + 'MOVIMIENTO + DdlConcepto.DataSource = GlobalDTInvConceptos.FiltraParametros(IIf(UsuarioActual.CveEmpresa.Contiene(72, 80, 1), "CveConcepto NOT IN (4,5,10)", "CveConcepto NOT IN (1,2,4,5,8,9,10,12,26,27,29)").ToString) + DdlConcepto.DataBind() + + 'FILTRO + DdlCConcepto.DataSource = GlobalDTInvConceptos.FiltraParametros("CveConcepto NOT IN (4,5)") + DdlCConcepto.DataBind() + + 'Llenar el dropdownlist de almacén + If Not IfNull(Request("CI"), -1).ToString.ToEntero > 0 Then + DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen NOT IN (9,11)") 'GlobalDTAlmacen(UsuarioActual.CveEmpresa) + + End If + DdlAlmacenInventarioFisico.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen NOT IN (9,11)") 'GlobalDTAlmacen(UsuarioActual.CveEmpresa) + + DdlAlmacen.Items.Insert(0, New ListItem("Seleccione", "-1")) + DdlAlmacenInventarioFisico.Items.Insert(0, New ListItem("Seleccione", "-1")) + + DdlAlmacen.SelectedValue = "-1" + DdlAlmacenInventarioFisico.SelectedValue = "-1" + + DdlAlmacen.DataBind() + DdlAlmacenInventarioFisico.DataBind() + + If IsNothing(Request("CveMovimiento")) Then + DdlAlmacen.SelectedValueExist(UsuarioActual.CveAlmacen) + DdlAlmacen_SelectedIndexChanged(DdlAlmacen, EventArgs.Empty) + End If + + If DdlAlmacen.SelectedValue.ToEntero = -1 Then + DdlConcepto.Items.Clear() + DdlConcepto.Items.Insert(0, New ListItem("Seleccione", "-1")) + End If + + CargaPS() + + ' CargaDdlPaqueteria() + + End Sub + Private Sub CargaPS() + DdlProducto2.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1") + DdlPS.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1") + DdlPSSalida.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1") + + If UsuarioActual.CveEmpresa = 66 Then + DdlProducto2.ddlWS.Attributes.Add("data-pagina", "Inventarios") + End If + + If Not DdlProducto2.UsaWebService AndAlso CType(DdlProducto2.DataSource, DataTable) Is Nothing Then + DdlProducto2.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoPS = 2") + DdlPS.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoPS = 2") + DdlPSSalida.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoPS = 2") + + DdlProducto2.DataBind() + DdlPS.DataBind() + DdlPSSalida.DataBind() + + DdlProducto2.ddl.Items.Insert(0, New ListItem("Seleccione", "-1")) + DdlPS.ddl.Items.Insert(0, New ListItem("Seleccione", "-1")) + DdlPSSalida.ddl.Items.Insert(0, New ListItem("Seleccione", "-1")) + End If + + End Sub + Private Sub CargaSubProyectos() + DdlSubProyecto.DataSource = If(UsuarioActual.Empresa.Funcionalidad(102) = "1" AndAlso Not UsuarioActual.TienePermisoProceso(110), GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1), GlobalDTSubProyectos(-1, -1, UsuarioActual.CveEmpresa, 1)) + DdlSubProyecto.DataBind() + 'DdlSubProyecto.Items.Insert(0, New ListItem("Seleccione", "-1")) + End Sub + Private Sub CargaPersonal() + TrPersonal.Visible = True + Dim dt As DataTable = Nothing + + Dim RH As New ClsRH + + If RH.GetPersonal(-1, UsuarioActual.CveEmpresa) Then + dt = RH.DtResultados + End If + + RH.Dispose() + + DdlPersonal.DataSource = dt + DdlPersonal.DataBind() + 'DdlSubProyecto.Items.Insert(0, New ListItem("Seleccione", "-1")) + End Sub +#End Region + + +#Region " CARGA DATOS " + Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) Handles BtnConsultar.Click + GvM.EditIndex = -1 + LimpiarMovimiento() + CargaDatos(-1, DdlCConcepto.SelectedValue.ToEntero(), TxtCFolio.Text.ToEntero) + End Sub + Private Sub CargaDatos(tCveMovimiento As Integer, Optional pCveConcepto As Integer = -1, Optional pFolio As Integer = -1) + Dim Mov As New ClsInventarios + DtMovimientos.Clear() + TieneSalida = False + EstatusAlmacenCompra = -1 + + If UsuarioActual.CveEmpresa = 48 Then + GvM.Columns(8).Visible = False + End If + + + + If Mov.GetMovimientos(tCveMovimiento, pCveConcepto, pFolio, UsuarioActual.CveEmpresa) AndAlso Mov.DtResultados.Rows.Count = 1 Then + + CveMovimiento = Mov.CveMovimiento + DtMov = Mov.DtResultados + TxtFecha.Text = Mov.Fecha.ToShortDateString + TxtHoraInicio.SelectedTime = Mov.Fecha + EstatusAlmacenCompra = Mov.EstatusAlmacenCompra + Folio = Mov.Folio + + + If DtMov.Rows(0)("CveConcepto").ToString.ToEntero = 2 Then + HplTraspaso.Visible = True + HplTraspaso.NavigateUrl = $"/Inventarios/TraspasoAlmacen.aspx?CveEntrada={DtMov.Rows(0)("CveMovimiento").ToString}" + End If + 'DATOS DE REGISTRO + DivRegistro.Visible = True + LnkAgregarNuevoMov.Visible = True + LblUsuarioRegistro.Text = Mov.NombreCapturo + LblFechaRegistro.Text = Mov.FechaRegistro.ToShortDateString + + If DtMov.Rows(0)("CvePrePoliza").ToString.ToEntero > 0 Then + HplPrePoliza.Visible = True + HplPrePoliza.NavigateUrl = String.Format("/Contabilidad/RegPrePoliza.aspx?CvePrePoliza={0}", DtMov.Rows(0)("CvePrePoliza")) CvePrePoliza = DtMov.Rows(0)("CvePrePoliza").ToString.ToEntero Else - If UsuarioActual.CveRol = 1 Then - BtnGeneraPrepoliza.Visible = True - End If - End If - - 'DATOS DE CONSIGNACION - If DtMov.Rows(0)("SerieFolio").ToString.Length > 0 Then - RowConsignacion.Visible = True - 'LbConsignacion.Text = DtMov.Rows(0)("SerieFolio").ToString - HLConsignacion.Text = DtMov.Rows(0)("SerieFolio").ToString - HLConsignacion.NavigateUrl = String.Format("/Inventarios/Consignaciones.aspx?CveConsignacion={0}", DtMov.Rows(0)("CveConsignacion").ToString) - End If - - 'TIPO CAMBIO - If DtMov.Rows(0)("TipoCambio").ToString.Length > 0 Then - RowTipoCambio.Visible = True - LbTipoCambio.Text = DtMov.Rows(0)("TipoCambio").ToString - End If - Dim TMDsTR = DtMov.Rows(0)("CveMtoRel").ToString - If DtMov.Rows(0)("CveMtoRel").ToString.Length > 0 Then - RowMtoRel.Visible = True - - lnkMtoRelaioando.NavigateUrl = "./EntradasSalidas.aspx?CveMovimiento=" & DtMov.Rows(0)("CveMtoRel").ToString - 'lnkMtoRelaioando.Attributes.Add("hreh", "./EntradasSalidas.aspx?CveMoviento=" & DtMov.Rows(0)("CveMtoRel").ToString) - 'lnkMtoRelaioando.Attributes.Add("target", "_blank") - Else - RowMtoRel.Visible = False - End If - - If (DdlAlmacen.Items.FindByValue(Mov.CveAlmacen.ToString()) Is Nothing) Then - Dim dr As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveEstatus:=-1).FiltroPrimero(String.Format("CveAlmacen = {0}", Mov.CveAlmacen)) - If dr IsNot Nothing Then - DdlAlmacen.Items.Insert(0, New ListItem(dr("Almacen").ToString, dr("CveAlmacen").ToString)) ' lo genera Obj.SelectedValue = Valor.ToString - DdlAlmacen.Enabled = False - End If - End If - - DdlAlmacen.SelectedValue = Mov.CveAlmacen.ToString - - DdlMoneda.SelectedValue = Mov.CveMoneda.ToString - - 'DATOS MONEDA EXTRANJERA - DdlMonedaTC.SelectedValue = Mov.CveMoneda.ToString - If DdlMonedaTC.SelectedValue.ToEntero = 2 Then - DivTipoCambio.Visible = True - TxtTipoCambio.Text = Mov.TipoCambio.ToString.FormatoNumero - DdlMonedaTC_SelectedIndexChanged(DdlMonedaTC, EventArgs.Empty) - - DdlMonedaTC.Enabled = False - TxtTipoCambio.Enabled = False - - VisualizaPUExtranjero(UsuarioActual.TienePermisoProceso(201)) - Else - DivTipoCambio.Visible = False - VisualizaPUExtranjero(False) - End If - - TxtGuia.Text = Mov.Guia - TxtObservaciones.Text = Mov.Observaciones - TxtResponsable.Text = Mov.Recibio - - If Mov.CveAlmacenDestino > 0 Then divDestino.Visible = True : LtlAlmacenDestino.Text = Mov.AlmacenDestino - - CveMovimientoRelacionado = Mov.CveMovimientoRelacionado - FolioRelacionado = Mov.FolioRelacionado - TieneRelacionado = Mov.TieneRelacionado - ConceptoRelacionado = Mov.ConceptoRelacionado - - 'sino existe el movimiento - If (DdlConcepto.Items.FindByValue(Mov.CveConcepto.ToString()) Is Nothing) Then - Dim dr As DataRow = GlobalDTInvConceptos.FiltroPrimero(String.Format("CveConcepto = {0}", Mov.CveConcepto)) - DdlConcepto.Items.Insert(0, New ListItem(dr("Concepto").ToString, dr("CveConcepto").ToString)) ' lo genera Obj.SelectedValue = Valor.ToString - End If - - DdlConcepto.SelectedValue = Mov.CveConcepto.ToString - ddlConcepto_SelectedIndexChanged(DdlConcepto, EventArgs.Empty) - - TxtFolio.Text = Mov.Folio.ToString - HdnIdPoliza.Value = Mov.IDPoliza.ToString - HplImprimir.Visible = True - HplImprimir.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimiento))) - CveCompra = Mov.CveCompra - CveConcepto = Mov.CveConcepto - - If DtMov.Rows(0)("CveEstatusTimbrado").ToString.ToEntero > 0 Then - HplDescargaXml.Visible = True - HplDescargaXml.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=DesXmlTra&CVEMOVIMIENTO={0}&EXT={1}&FOLIO={2}&TIPODOCTO={3}", CveMovimiento, "XML", $"Tra-{Folio}", "Tra"))) - HplDescargaPdf.Visible = True - HplDescargaPdf.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=DesPdfTra&CVEMOVIMIENTO={0}&EXT={1}&FOLIO={2}&TIPODOCTO={3}", CveMovimiento, "PDF", $"Tra-{Folio}", "Tra"))) - HplCartaPorte.Visible = True - HplCartaPorte.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=CARPO&CVEMOV={0}", CveMovimiento))) - End If - - - If CveConcepto.Contiene(3, 8) Then - LiLnkGuias.Visible = True - End If - - - If Mov.IDPoliza > 0 Then HplPoliza.Visible = True : HplPoliza.NavigateUrl = String.Format("/Contabilidad/RegPoliza.aspx?IdPoliza={0}", Mov.IDPoliza) - - If CveConcepto = 6 Or CveConcepto = 7 Then - If Mov.DtResultados(0)("Nombre").ToString() <> "" Then - LtTipo.Text = Mov.DtResultados(0)("Nombre").ToString() - LblTipo.InnerText = "Cliente:" - ElseIf Mov.DtResultados(0)("RazonSocial").ToString() <> "" Then - LtTipo.Text = Mov.DtResultados(0)("RazonSocial").ToString() - LblTipo.InnerText = "Proveedor:" - Else - LtTipo.Text = Mov.NombreCompleto - LblTipo.InnerText = "Personal" - End If - TrTipoCargado.Visible = True - TrPersonal.Visible = False - End If - - - - If Mov.CveSubProyecto > 0 Then - - 'verifico si existe - If (DdlSubProyecto.Items.FindByValue(Mov.CveSubProyecto.ToString()) Is Nothing) Then - Dim dr As DataRow = GlobalDTSubProyectos(-1, CveSubProyecto:=Mov.CveSubProyecto, Estatus:=-1).FiltroPrimero("") - DdlSubProyecto.Items.Insert(0, New ListItem(dr("SubProyecto").ToString, dr("CveSubProyecto").ToString)) ' lo genera Obj.SelectedValue = Valor.ToString - End If - - DdlSubProyecto.SelectedValue = Mov.CveSubProyecto.ToString - TrSubProyectoActivoFijo.Visible = True - End If - - 'LblCodigo.Text = If(Mov.CodigoAF = 0, "-1", Mov.CodigoAF.ToString) - 'HdnCveActivoFijo.Value = If(Mov.CveActivoFijo = 0, "-1", Mov.CveActivoFijo.ToString) - - If Mov.CveCompra > 0 Then - HplCompra.Visible = True - HplCompra.Text = DtMov.Rows(0)("SerieFolioCompra").ToString - If UsuarioActual.TienePermisoProceso(201) Then - HplCompra.NavigateUrl = String.Format("/Compras/Compras.aspx?CveCompra={0}", Mov.CveCompra) - End If - End If - - If Mov.CveVenta > 0 Then - HplVenta.Visible = True - HplVenta.Text = DtMov.Rows(0)("FolioVenta").ToString - If UsuarioActual.TienePermisoProceso(201) Then - HplVenta.NavigateUrl = String.Format("/Ventas/Ventas.aspx?CveVenta={0}", Mov.CveVenta) - End If - End If - - If Mov.CveOrdenCompraLiga > 0 Then - HplOrdenCompra.Visible = True - HdnCveOrdenCompra.Value = Mov.CveOrdenCompraLiga.ToString - HplOrdenCompra.Text = DtMov.Rows(0)("FolioOC").ToString - If UsuarioActual.TienePermisoProceso(201) Then - HplOrdenCompra.NavigateUrl = String.Format("/OC/OC.aspx?OC={0}", Mov.CveOrdenCompraLiga) - End If - End If - - If Mov.IDPoliza = 0 AndAlso UsuarioActual.Empresa.UsaAC Then - BtnContabilizar.Visible = PermiteContabilizar() - Else - BtnContabilizar.Visible = False - End If - - VisualizaPU(True) - - If DtMov.Rows(0)("Remision").ToString.Length > 0 Then - TxtRemision.Text = DtMov.Rows(0)("Remision").ToString - DivRemision.Visible = True - End If - - 'Carga Cliente y ClienteSucursal - If Mov.CveCliente > 0 Then - If DdlClientes.Items.FindByValue(Mov.CveCliente.ToString()) Is Nothing Then - Dim dr As DataRow = GlobalDTCliente(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveCliente = {0}", Mov.CveCliente)) - If dr IsNot Nothing Then - DdlClientes.Items.Insert(0, New ListItem(dr("NombreComercial").ToString, dr("CveCliente").ToString)) - End If - End If - DivCliente.Visible = True - DdlClientes.Enabled = False - DdlClientes.SelectedValueExist(Mov.CveCliente.ToString) - - End If - - If Mov.CveClienteSucursal > 0 Then - CambiaCliente() - - 'INSERTA SUCURSAL - If (DdlClientesSucursales.Items.FindByValue(Mov.CveClienteSucursal.ToString()) Is Nothing) Then - Dim ObjCliente As New ClsClientes - If ObjCliente.GetSucursales(Mov.CveCliente.ToString().ToEntero, Mov.CveClienteSucursal) Then - Dim dr As DataRow = ObjCliente.DtResultados.FiltroPrimero(String.Format("CveClienteSucursal = {0}", Mov.CveClienteSucursal)) - If dr IsNot Nothing Then - DdlClientesSucursales.Items.Insert(0, New ListItem(dr("SucursalCliente").ToString, dr("CveClienteSucursal").ToString)) - End If - End If - ObjCliente.Dispose() - End If - DdlClientesSucursales.Enabled = False - DdlClientesSucursales.SelectedValueExist(Mov.CveClienteSucursal.ToString) - End If - - - DivDepartamentoEntrega.Visible = True - TxtDepartamentoEntrega.Enabled = False - TxtDepartamentoEntrega.Text = Mov.DepartamentoEntrega - - TxtPedidoContrato.Enabled = False - TxtPedidoContrato.Text = Mov.PedidoContrato - - - 'cargar también los movimentos detalle - If Mov.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then - DdlSeccion.SelectedValueExist(Mov.CveSeccion.ToString) - DtMovimientos = Mov.DtResultados.FiltraParametros("", "CveMovimientoDetalle") - - DtMovimientos.Columns("No").AutoIncrement = True - DtMovimientos.Columns("No").AutoIncrementSeed = DtMovimientos.Rows.Count + 1 - DtMovimientos.Columns("No").AutoIncrementStep = 1 - - Dim keys(1) As DataColumn - keys(0) = DtMovimientos.Columns("No") - DtMovimientos.PrimaryKey = keys - - CargaGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' ")) - - End If - - PermisoVerImportes() - - If DtMov.Rows(0)("CveProveedor").ToString.ToEntero > 0 Then - DdlProveedor.DataSource = GlobalDTCompProveedores(UsuarioActual.CveEmpresa) - DdlProveedor.DataBind() - DdlProveedor.SelectedValueExist(DtMov.Rows(0)("CveProveedor").ToString) - DdlProveedor.Enabled = False - TrProveedor.Visible = True - End If - - Else - Alert("Movimiento No encontrado", TipoMensaje.MsgError) - - TxtObservaciones.Text = "" - TxtFolio.Text = "" - BtnGuardar.Visible = False - BtnEliminar.Visible = False - BtnContabilizar.Visible = False - - DivRegistro.Visible = False - DivTipoCambio.Visible = False - - CargaGVM(Nothing) - GvM.Columns(8).Visible = False - GvM.DataBind() - CveMovimiento = 0 - End If - - BtnGuardar.Visible = PermiteGuardar() - If UsuarioActual.TienePermisoProceso(182) Then - If TieneSalida Or TieneRelacionado > 0 Or EstatusAlmacenCompra = 2 Then - DivMensaje.Visible = True - BtnEliminar.Enabled = False - BtnEliminar.Visible = False - LtMensaje.Text = "El movimiento no se puede eliminar porque uno de sus conceptos ya tiene salida y/o el movimiento esta relacionado con otro." - Else - BtnEliminar.Visible = True - BtnEliminar.Enabled = True - If CveMovimientoRelacionado > 0 Then - BtnEliminar.ToolTip = $"El movimiento esta relacionado con el Folio de {ConceptoRelacionado} No. {FolioRelacionado}

¿Esta seguro de eliminar los dos movimientos?" - End If - LtMensaje.Text = "" - End If - Else - BtnEliminar.Visible = False - End If - - 'BLOQUEA FECHA CUANDO YA SE TIENE POLIZA - If HdnIdPoliza.Value.ToEntero > 0 And Not PermiteGuardar() Then - TxtFecha.Enabled = False - ImgFecha.Enabled = False - Else - TxtFecha.Enabled = True - ImgFecha.Enabled = True - TxtObservaciones.Enabled = True + If UsuarioActual.CveRol = 1 Then + BtnGeneraPrepoliza.Visible = True + End If + End If + + 'DATOS DE CONSIGNACION + If DtMov.Rows(0)("SerieFolio").ToString.Length > 0 Then + RowConsignacion.Visible = True + 'LbConsignacion.Text = DtMov.Rows(0)("SerieFolio").ToString + HLConsignacion.Text = DtMov.Rows(0)("SerieFolio").ToString + HLConsignacion.NavigateUrl = String.Format("/Inventarios/Consignaciones.aspx?CveConsignacion={0}", DtMov.Rows(0)("CveConsignacion").ToString) + End If + + 'TIPO CAMBIO + If DtMov.Rows(0)("TipoCambio").ToString.Length > 0 Then + RowTipoCambio.Visible = True + LbTipoCambio.Text = DtMov.Rows(0)("TipoCambio").ToString + End If + Dim TMDsTR = DtMov.Rows(0)("CveMtoRel").ToString + If DtMov.Rows(0)("CveMtoRel").ToString.Length > 0 Then + RowMtoRel.Visible = True + + lnkMtoRelaioando.NavigateUrl = "./EntradasSalidas.aspx?CveMovimiento=" & DtMov.Rows(0)("CveMtoRel").ToString + 'lnkMtoRelaioando.Attributes.Add("hreh", "./EntradasSalidas.aspx?CveMoviento=" & DtMov.Rows(0)("CveMtoRel").ToString) + 'lnkMtoRelaioando.Attributes.Add("target", "_blank") + Else + RowMtoRel.Visible = False + End If + + If (DdlAlmacen.Items.FindByValue(Mov.CveAlmacen.ToString()) Is Nothing) Then + Dim dr As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveEstatus:=-1).FiltroPrimero(String.Format("CveAlmacen = {0}", Mov.CveAlmacen)) + If dr IsNot Nothing Then + DdlAlmacen.Items.Insert(0, New ListItem(dr("Almacen").ToString, dr("CveAlmacen").ToString)) ' lo genera Obj.SelectedValue = Valor.ToString + DdlAlmacen.Enabled = False + End If + End If + + DdlAlmacen.SelectedValue = Mov.CveAlmacen.ToString + + DdlMoneda.SelectedValue = Mov.CveMoneda.ToString + + 'DATOS MONEDA EXTRANJERA + DdlMonedaTC.SelectedValue = Mov.CveMoneda.ToString + If DdlMonedaTC.SelectedValue.ToEntero = 2 Then + DivTipoCambio.Visible = True + TxtTipoCambio.Text = Mov.TipoCambio.ToString.FormatoNumero + DdlMonedaTC_SelectedIndexChanged(DdlMonedaTC, EventArgs.Empty) + + DdlMonedaTC.Enabled = False + TxtTipoCambio.Enabled = False + + VisualizaPUExtranjero(UsuarioActual.TienePermisoProceso(201)) + Else + DivTipoCambio.Visible = False + VisualizaPUExtranjero(False) + End If + + TxtGuia.Text = Mov.Guia + TxtObservaciones.Text = Mov.Observaciones + TxtResponsable.Text = Mov.Recibio + + If Mov.CveAlmacenDestino > 0 Then divDestino.Visible = True : LtlAlmacenDestino.Text = Mov.AlmacenDestino + + CveMovimientoRelacionado = Mov.CveMovimientoRelacionado + FolioRelacionado = Mov.FolioRelacionado + TieneRelacionado = Mov.TieneRelacionado + ConceptoRelacionado = Mov.ConceptoRelacionado + + 'sino existe el movimiento + If (DdlConcepto.Items.FindByValue(Mov.CveConcepto.ToString()) Is Nothing) Then + Dim dr As DataRow = GlobalDTInvConceptos.FiltroPrimero(String.Format("CveConcepto = {0}", Mov.CveConcepto)) + DdlConcepto.Items.Insert(0, New ListItem(dr("Concepto").ToString, dr("CveConcepto").ToString)) ' lo genera Obj.SelectedValue = Valor.ToString + End If + + DdlConcepto.SelectedValue = Mov.CveConcepto.ToString + ddlConcepto_SelectedIndexChanged(DdlConcepto, EventArgs.Empty) + + TxtFolio.Text = Mov.Folio.ToString + HdnIdPoliza.Value = Mov.IDPoliza.ToString + HplImprimir.Visible = True + HplImprimir.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimiento))) + CveCompra = Mov.CveCompra + CveConcepto = Mov.CveConcepto + + If DtMov.Rows(0)("CveEstatusTimbrado").ToString.ToEntero > 0 Then + HplDescargaXml.Visible = True + HplDescargaXml.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=DesXmlTra&CVEMOVIMIENTO={0}&EXT={1}&FOLIO={2}&TIPODOCTO={3}", CveMovimiento, "XML", $"Tra-{Folio}", "Tra"))) + HplDescargaPdf.Visible = True + HplDescargaPdf.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=DesPdfTra&CVEMOVIMIENTO={0}&EXT={1}&FOLIO={2}&TIPODOCTO={3}", CveMovimiento, "PDF", $"Tra-{Folio}", "Tra"))) + HplCartaPorte.Visible = True + HplCartaPorte.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=CARPO&CVEMOV={0}", CveMovimiento))) + End If + + + If CveConcepto.Contiene(3, 8) Then + LiLnkGuias.Visible = True + End If + + + If Mov.IDPoliza > 0 Then HplPoliza.Visible = True : HplPoliza.NavigateUrl = String.Format("/Contabilidad/RegPoliza.aspx?IdPoliza={0}", Mov.IDPoliza) + + If CveConcepto = 6 Or CveConcepto = 7 Then + If Mov.DtResultados(0)("Nombre").ToString() <> "" Then + LtTipo.Text = Mov.DtResultados(0)("Nombre").ToString() + LblTipo.InnerText = "Cliente:" + ElseIf Mov.DtResultados(0)("RazonSocial").ToString() <> "" Then + LtTipo.Text = Mov.DtResultados(0)("RazonSocial").ToString() + LblTipo.InnerText = "Proveedor:" + Else + LtTipo.Text = Mov.NombreCompleto + LblTipo.InnerText = "Personal" + End If + TrTipoCargado.Visible = True + TrPersonal.Visible = False + End If + + + + If Mov.CveSubProyecto > 0 Then + + 'verifico si existe + If (DdlSubProyecto.Items.FindByValue(Mov.CveSubProyecto.ToString()) Is Nothing) Then + Dim dr As DataRow = GlobalDTSubProyectos(-1, CveSubProyecto:=Mov.CveSubProyecto, Estatus:=-1).FiltroPrimero("") + DdlSubProyecto.Items.Insert(0, New ListItem(dr("SubProyecto").ToString, dr("CveSubProyecto").ToString)) ' lo genera Obj.SelectedValue = Valor.ToString + End If + + DdlSubProyecto.SelectedValue = Mov.CveSubProyecto.ToString + TrSubProyectoActivoFijo.Visible = True + End If + + 'LblCodigo.Text = If(Mov.CodigoAF = 0, "-1", Mov.CodigoAF.ToString) + 'HdnCveActivoFijo.Value = If(Mov.CveActivoFijo = 0, "-1", Mov.CveActivoFijo.ToString) + + If Mov.CveCompra > 0 Then + HplCompra.Visible = True + HplCompra.Text = DtMov.Rows(0)("SerieFolioCompra").ToString + If UsuarioActual.TienePermisoProceso(201) Then + HplCompra.NavigateUrl = String.Format("/Compras/Compras.aspx?CveCompra={0}", Mov.CveCompra) + End If + End If + + If Mov.CveVenta > 0 Then + HplVenta.Visible = True + HplVenta.Text = DtMov.Rows(0)("FolioVenta").ToString + If UsuarioActual.TienePermisoProceso(201) Then + HplVenta.NavigateUrl = String.Format("/Ventas/Ventas.aspx?CveVenta={0}", Mov.CveVenta) + End If + End If + + If Mov.CveOrdenCompraLiga > 0 Then + HplOrdenCompra.Visible = True + HdnCveOrdenCompra.Value = Mov.CveOrdenCompraLiga.ToString + HplOrdenCompra.Text = DtMov.Rows(0)("FolioOC").ToString + If UsuarioActual.TienePermisoProceso(201) Then + HplOrdenCompra.NavigateUrl = String.Format("/OC/OC.aspx?OC={0}", Mov.CveOrdenCompraLiga) + End If + End If + + If Mov.IDPoliza = 0 AndAlso UsuarioActual.Empresa.UsaAC Then + BtnContabilizar.Visible = PermiteContabilizar() + Else + BtnContabilizar.Visible = False + End If + + VisualizaPU(True) + + If DtMov.Rows(0)("Remision").ToString.Length > 0 Then + TxtRemision.Text = DtMov.Rows(0)("Remision").ToString + DivRemision.Visible = True + End If + + 'Carga Cliente y ClienteSucursal + If Mov.CveCliente > 0 Then + If DdlClientes.Items.FindByValue(Mov.CveCliente.ToString()) Is Nothing Then + Dim dr As DataRow = GlobalDTCliente(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveCliente = {0}", Mov.CveCliente)) + If dr IsNot Nothing Then + DdlClientes.Items.Insert(0, New ListItem(dr("NombreComercial").ToString, dr("CveCliente").ToString)) + End If + End If + DivCliente.Visible = True + DdlClientes.Enabled = False + DdlClientes.SelectedValueExist(Mov.CveCliente.ToString) + + End If + + If Mov.CveClienteSucursal > 0 Then + CambiaCliente() + + 'INSERTA SUCURSAL + If (DdlClientesSucursales.Items.FindByValue(Mov.CveClienteSucursal.ToString()) Is Nothing) Then + Dim ObjCliente As New ClsClientes + If ObjCliente.GetSucursales(Mov.CveCliente.ToString().ToEntero, Mov.CveClienteSucursal) Then + Dim dr As DataRow = ObjCliente.DtResultados.FiltroPrimero(String.Format("CveClienteSucursal = {0}", Mov.CveClienteSucursal)) + If dr IsNot Nothing Then + DdlClientesSucursales.Items.Insert(0, New ListItem(dr("SucursalCliente").ToString, dr("CveClienteSucursal").ToString)) + End If + End If + ObjCliente.Dispose() + End If + DdlClientesSucursales.Enabled = False + DdlClientesSucursales.SelectedValueExist(Mov.CveClienteSucursal.ToString) + End If + + + DivDepartamentoEntrega.Visible = True + TxtDepartamentoEntrega.Enabled = False + TxtDepartamentoEntrega.Text = Mov.DepartamentoEntrega + + TxtPedidoContrato.Enabled = False + TxtPedidoContrato.Text = Mov.PedidoContrato + + + 'cargar también los movimentos detalle + If Mov.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then + DdlSeccion.SelectedValueExist(Mov.CveSeccion.ToString) + DtMovimientos = Mov.DtResultados.FiltraParametros("", "CveMovimientoDetalle") + + DtMovimientos.Columns("No").AutoIncrement = True + DtMovimientos.Columns("No").AutoIncrementSeed = DtMovimientos.Rows.Count + 1 + DtMovimientos.Columns("No").AutoIncrementStep = 1 + + Dim keys(1) As DataColumn + keys(0) = DtMovimientos.Columns("No") + DtMovimientos.PrimaryKey = keys + + CargaGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' ")) + + End If + + PermisoVerImportes() + + If DtMov.Rows(0)("CveProveedor").ToString.ToEntero > 0 Then + DdlProveedor.DataSource = GlobalDTCompProveedores(UsuarioActual.CveEmpresa) + DdlProveedor.DataBind() + DdlProveedor.SelectedValueExist(DtMov.Rows(0)("CveProveedor").ToString) + DdlProveedor.Enabled = False + TrProveedor.Visible = True + End If + + Else + Alert("Movimiento No encontrado", TipoMensaje.MsgError) + + TxtObservaciones.Text = "" + TxtFolio.Text = "" + BtnGuardar.Visible = False + BtnEliminar.Visible = False + BtnContabilizar.Visible = False + + DivRegistro.Visible = False + DivTipoCambio.Visible = False + + CargaGVM(Nothing) + GvM.Columns(8).Visible = False + GvM.DataBind() + CveMovimiento = 0 + End If + + BtnGuardar.Visible = PermiteGuardar() + If UsuarioActual.TienePermisoProceso(182) Then + If TieneSalida Or TieneRelacionado > 0 Or EstatusAlmacenCompra = 2 Then + DivMensaje.Visible = True + BtnEliminar.Enabled = False + BtnEliminar.Visible = False + LtMensaje.Text = "El movimiento no se puede eliminar porque uno de sus conceptos ya tiene salida y/o el movimiento esta relacionado con otro." + Else + BtnEliminar.Visible = True + BtnEliminar.Enabled = True + If CveMovimientoRelacionado > 0 Then + BtnEliminar.ToolTip = $"El movimiento esta relacionado con el Folio de {ConceptoRelacionado} No. {FolioRelacionado}

¿Esta seguro de eliminar los dos movimientos?" + End If + LtMensaje.Text = "" + End If + Else + BtnEliminar.Visible = False + End If + + 'BLOQUEA FECHA CUANDO YA SE TIENE POLIZA + If HdnIdPoliza.Value.ToEntero > 0 And Not PermiteGuardar() Then + TxtFecha.Enabled = False + ImgFecha.Enabled = False + Else + TxtFecha.Enabled = True + ImgFecha.Enabled = True + TxtObservaciones.Enabled = True End If Dim ObjContabilidad As New ClsContabilidad @@ -894,289 +894,289 @@ Partial Class Inventarios_EntradasSalidas End If End If End If - ObjContabilidad.Dispose() - - 'SI TIENE PREPOLIZA NO SE DEBE PODER EDITAR - If Mov.TienePrePoliza > 0 Then - '[IPP] Se invalida por necesidad de JAM de modificar fechas para cuadrar con CIFRA - 19Abril2018 - 'BtnGuardar.Visible = False - End If - - BloqueaEdicionEncabezado() - Mov.Dispose() - UpGenerales.Update() - UPDatos.Update() - UppGrid.Update() - UPEncabezado.Update() - UpRegistroTipoCambio.Update() - - End Sub - - Private Sub BloqueaEdicionEncabezado() - - - DdlAlmacen.Enabled = True - DdlConcepto.Enabled = True - TxtFolio.Enabled = True - TxtFecha.Enabled = True - TxtResponsable.Enabled = True - TxtObservaciones.Enabled = True - DdlMoneda.Enabled = True - TxtGuia.Enabled = True - DdlSeccion.Enabled = True - - If CveMovimiento > 0 Then - DdlAlmacen.Enabled = False - DdlConcepto.Enabled = False - TxtFolio.Enabled = False - If Not PermiteGuardar() Then TxtFecha.Enabled = False - TxtResponsable.Enabled = False - TxtObservaciones.Enabled = False - DdlMoneda.Enabled = False - TxtGuia.Enabled = False - DdlSeccion.Enabled = False - End If - UppGrid.Update() - End Sub - - Private Sub CargaCodigoBarras() - If DdlCConcepto.SelectedValue.ToEntero = 1 Then - DivCodigoBarras.Visible = True - End If - End Sub -#End Region - - -#Region " BOTONES: ELIMINAR, NUEVO " - Protected Sub BtnNuevo_Click(sender As Object, e As EventArgs) Handles BtnNuevo.Click - 'Response.Redirect("EntradasSalidas.aspx") - - LimpiarMovimiento() - BloqueaEdicionEncabezado() - End Sub - Private Sub LimpiarMovimiento() - - CveMovimiento = -1 - SiguienteFolio() - - HplCompra.Visible = False - HplPoliza.Visible = False - HplVenta.Visible = False - HplOrdenCompra.Visible = False - - TrTipoCargado.Visible = False - TrPersonal.Visible = False - - DtMovimientos.Clear() - GvM.EditIndex = -1 - CargaGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' ")) - - BtnGuardar.Visible = PermiteGuardar() - BtnEliminar.Visible = False - - DivRegistro.Visible = False - DivTipoCambio.Visible = False - - If Not DdlAlmacen.Items.Contains(New ListItem("Seleccione", "-1")) Then - DdlAlmacen.Items.Add(New ListItem("Seleccione", "-1")) - End If - DdlAlmacen.SelectedValue = "-1" - If Not EsConsumoInterno Then - DdlAlmacen_SelectedIndexChanged(DdlAlmacen, EventArgs.Empty) - End If - DdlAlmacen.Enabled = True - - TxtResponsable.Text = "" - TxtObservaciones.Text = "" - TxtFecha.Text = Now.ToShortDateString - - LblUsuarioRegistro.Text = "" - LblFechaRegistro.Text = "" - HplCompra.Visible = False - HplVenta.Visible = False - HplPoliza.Visible = False - HplOrdenCompra.Visible = False - - LimpiarAgregar() - - InicializaBitacoraTemporal() - DtBitacora.Clear() - CargaEventoBitacoraTemp() - - TxtRemision.Text = "" - DivRemision.Visible = False - - UpRegistroTipoCambio.Update() - UPDatos.Update() - End Sub - - Private Sub LimpiarAgregar() - DdlClasificacion.SelectedValue = "-1" - txtCantidad.Text = "" - TxtnLote.Text = "" - TxtnBatch.Text = "" - TxtObservacionesdetalle.Text = "" - End Sub - - Protected Sub BtnEliminar_Click(sender As Object, e As EventArgs) Handles BtnEliminar.Click - - RegistraScript("$('#divDescripcion').modal()") - - Dim Description As String = String.Format("Movimiento con Concepto: {0}, Almacen: {1}, Fecha: {2}, Folio: {3}, Usuario: {4}, Observaciones adicionales: {5}, Productos Información:
", - DdlConcepto.SelectedItem, DdlAlmacen.SelectedItem, TxtFecha.Text, TxtFolio.Text, LblUsuarioRegistro.Text, TxtObservaciones.Text) + ObjContabilidad.Dispose() + + 'SI TIENE PREPOLIZA NO SE DEBE PODER EDITAR + If Mov.TienePrePoliza > 0 Then + '[IPP] Se invalida por necesidad de JAM de modificar fechas para cuadrar con CIFRA - 19Abril2018 + 'BtnGuardar.Visible = False + End If + + BloqueaEdicionEncabezado() + Mov.Dispose() + UpGenerales.Update() + UPDatos.Update() + UppGrid.Update() + UPEncabezado.Update() + UpRegistroTipoCambio.Update() + + End Sub + + Private Sub BloqueaEdicionEncabezado() + + + DdlAlmacen.Enabled = True + DdlConcepto.Enabled = True + TxtFolio.Enabled = True + TxtFecha.Enabled = True + TxtResponsable.Enabled = True + TxtObservaciones.Enabled = True + DdlMoneda.Enabled = True + TxtGuia.Enabled = True + DdlSeccion.Enabled = True + + If CveMovimiento > 0 Then + DdlAlmacen.Enabled = False + DdlConcepto.Enabled = False + TxtFolio.Enabled = False + If Not PermiteGuardar() Then TxtFecha.Enabled = False + TxtResponsable.Enabled = False + TxtObservaciones.Enabled = False + DdlMoneda.Enabled = False + TxtGuia.Enabled = False + DdlSeccion.Enabled = False + End If + UppGrid.Update() + End Sub + + Private Sub CargaCodigoBarras() + If DdlCConcepto.SelectedValue.ToEntero = 1 Then + DivCodigoBarras.Visible = True + End If + End Sub +#End Region + + +#Region " BOTONES: ELIMINAR, NUEVO " + Protected Sub BtnNuevo_Click(sender As Object, e As EventArgs) Handles BtnNuevo.Click + 'Response.Redirect("EntradasSalidas.aspx") + + LimpiarMovimiento() + BloqueaEdicionEncabezado() + End Sub + Private Sub LimpiarMovimiento() + + CveMovimiento = -1 + SiguienteFolio() + + HplCompra.Visible = False + HplPoliza.Visible = False + HplVenta.Visible = False + HplOrdenCompra.Visible = False + + TrTipoCargado.Visible = False + TrPersonal.Visible = False + + DtMovimientos.Clear() + GvM.EditIndex = -1 + CargaGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' ")) + + BtnGuardar.Visible = PermiteGuardar() + BtnEliminar.Visible = False + + DivRegistro.Visible = False + DivTipoCambio.Visible = False + + If Not DdlAlmacen.Items.Contains(New ListItem("Seleccione", "-1")) Then + DdlAlmacen.Items.Add(New ListItem("Seleccione", "-1")) + End If + DdlAlmacen.SelectedValue = "-1" + If Not EsConsumoInterno Then + DdlAlmacen_SelectedIndexChanged(DdlAlmacen, EventArgs.Empty) + End If + DdlAlmacen.Enabled = True + + TxtResponsable.Text = "" + TxtObservaciones.Text = "" + TxtFecha.Text = Now.ToShortDateString + + LblUsuarioRegistro.Text = "" + LblFechaRegistro.Text = "" + HplCompra.Visible = False + HplVenta.Visible = False + HplPoliza.Visible = False + HplOrdenCompra.Visible = False + + LimpiarAgregar() + + InicializaBitacoraTemporal() + DtBitacora.Clear() + CargaEventoBitacoraTemp() + + TxtRemision.Text = "" + DivRemision.Visible = False + + UpRegistroTipoCambio.Update() + UPDatos.Update() + End Sub + + Private Sub LimpiarAgregar() + DdlClasificacion.SelectedValue = "-1" + txtCantidad.Text = "" + TxtnLote.Text = "" + TxtnBatch.Text = "" + TxtObservacionesdetalle.Text = "" + End Sub + + Protected Sub BtnEliminar_Click(sender As Object, e As EventArgs) Handles BtnEliminar.Click + + RegistraScript("$('#divDescripcion').modal()") + + Dim Description As String = String.Format("Movimiento con Concepto: {0}, Almacen: {1}, Fecha: {2}, Folio: {3}, Usuario: {4}, Observaciones adicionales: {5}, Productos Información:
", + DdlConcepto.SelectedItem, DdlAlmacen.SelectedItem, TxtFecha.Text, TxtFolio.Text, LblUsuarioRegistro.Text, TxtObservaciones.Text) For Each dr As DataRow In DtMovimientos.Rows Dim detalleDescripcion As String = String.Format("- Cant: {0}, PS: {1}, PU: {2}, UM: {3}
", dr("Cantidad").ToString.ToEntero, dr("CodigoPS"), dr("PU"), dr("UnidadMedida")) Description = String.Format("{0}{1}", Description, detalleDescripcion) Next DescripcionDetalladaEliminar = Description - UpDescripcion.Update() - - 'Dim Inv As New ClsInventarios - 'Inv.IniciaTransacSQL() - - 'Dim TieneError = False - - 'Dim ObjConta As ClsContPAQi = Nothing - 'If UsuarioActual.Empresa.UsaContabilidad Or UsuarioActual.Empresa.UsaAC Then - ' ObjConta = New ClsContPAQi(UsuarioActual.Empresa) - ' ObjConta.IniciaTransacSQL() - 'End If - - - 'If Inv.MovimientoRemove(CveMovimiento, UsuarioActual.CveEmpresa) Then - ' If HdnIdPoliza.Value.ToEntero > 0 Then - ' If Not ObjConta.RemovePoliza(HdnIdPoliza.Value.ToEntero) Then - ' TieneError = True - ' End If - ' End If - 'Else - ' TieneError = True - 'End If - - 'If Not TieneError Then - ' If ObjConta IsNot Nothing Then ObjConta.Commit() - ' Inv.Commit() - - ' Alert("Movimientos Eliminado", TipoMensaje.MsgInformacion) - ' LimpiarMovimiento() - 'Else - ' If ObjConta IsNot Nothing Then ObjConta.RollBack() - ' Inv.RollBack() - - ' Alert("Ocurrió un error al eliminar el movimiento. Por favor vuelva a intetar.", TipoMensaje.MsgError) - 'End If - 'CveMovimiento = 0 - - 'If ObjConta IsNot Nothing Then ObjConta.Dispose() - 'Inv.Dispose() - End Sub - Private Sub BtnRemove_Click(sender As Object, e As EventArgs) Handles BtnRemove.Click - Dim Borrar As Boolean = False - If Not TxtDescripcion.Text = "" Then - - Dim Inv As New ClsInventarios - Dim Conta As New ClsContabilidad(Inv.IniciaTransacSQL()) - Dim ObjGral As New ClsGenerales(Inv.IniciaTransacSQL()) - - Dim TieneError = False - - Dim ObjConta As ClsContPAQi = Nothing - If UsuarioActual.Empresa.UsaContabilidad Or UsuarioActual.Empresa.UsaAC Then - ObjConta = New ClsContPAQi(UsuarioActual.Empresa) - ObjConta.IniciaTransacSQL() - End If - - If Not ObjGral.AddHistorialBitacora(Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, "", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 1, String.Format("{0}, Informacion = {1}", TxtDescripcion.Text, DescripcionDetalladaEliminar), "Inventarios", TxtFolio.Text + " / " + DdlConcepto.SelectedItem.Text) Then - TieneError = True - End If - - If Inv.MovimientoRemove(CveMovimiento, UsuarioActual.CveEmpresa) Then - If HdnIdPoliza.Value.ToEntero > 0 Then - If Not ObjConta.RemovePoliza(HdnIdPoliza.Value.ToEntero) Then - TieneError = True - End If - End If - Else - TieneError = True - End If - - If Not TieneError Then - If Not Conta.UpdatePrePolizasDetalleBloquear(CvePrePoliza, False) Then - TieneError = True - End If - End If - - If Not TieneError Then - If ObjConta IsNot Nothing Then ObjConta.Commit() - Inv.Commit() - - Alert("Movimientos Eliminado", TipoMensaje.MsgInformacion) - RegistraScript(String.Format("$('#{0}').modal('hide');", "divDescripcion")) - LimpiarMovimiento() - Else - If ObjConta IsNot Nothing Then ObjConta.RollBack() - Inv.RollBack() - - Alert("Ocurrió un error al eliminar el movimiento. Por favor vuelva a intentar.", TipoMensaje.MsgError) - End If - CveMovimiento = 0 - - If ObjConta IsNot Nothing Then ObjConta.Dispose() - Inv.Dispose() - ObjGral.Dispose() - Conta.Dispose() - End If - End Sub -#End Region - - -#Region " AGREGAR - GUARDAR " - Private Function GetExistencias(CvePS As Integer, CveUnidadMedida As Integer, CveEmpresa As Integer, CveAlmacen As Integer, Optional SerieLote As String = "-1", Optional Lote As String = "-1", Optional Batch As String = "-1") As Double - Dim Inv As New ClsInventarios - Dim Existencia As Double = Inv.GetExistenciasPS(CvePS, CveUnidadMedida, CveEmpresa, CveAlmacen, -1, FechaMovto:=String.Format("{0} {1}", TxtFecha.Text.ToDate.ToString("yyyy/MM/dd"), TxtHoraInicio.PostedTime), SerieLote:=SerieLote, Lote:=Lote, Batch:=Batch) - Inv.Dispose() - Return Existencia - End Function - - Protected Sub btnAgregar_Click(sender As Object, e As EventArgs) Handles LbAgregar.Click - AgregarPS() - End Sub - Protected Sub BtnSerieAddNew_Click(sender As Object, e As EventArgs) - AgregarPS() - End Sub - Private Sub AgregarPS() - If Not DdlProducto2.SelectedValue.ToEntero > 0 Then - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - Alert("Es necesario especificar el producto.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - AddNew(DdlProducto2.SelectedValue.ToEntero, DdlProducto2.SelectedText, DdlUnidad.SelectedValue.ToEntero, DdlUnidad.SelectedItem.Text, txtCantidad.Text.ToDouble, txtPrecio.Text.ToDouble, TxtnSerieLote.Text.Replace(" ", String.Empty), LblCodigo.Text, HdnCodigoAF.Value, HdnCveActivoFijo.Value, TxtObservacionesdetalle.Text, TxtnLote.Text.Trim, TxtnBatch.Text.Trim, DdlSeccionAlmacen.SelectedValue.ToEntero, DdlSeccionAlmacen.SelectedItem.Text) - LimpiarAgregar() - - txtCantidad.Text = "" - TxtnLote.Text = "" - TxtnBatch.Text = "" - LblCodigo.Text = "" - TxtnSerieLote.Text = "" - HdnCodigoAF.Value = "-1" - HdnCveActivoFijo.Value = "-1" - RegistraScript("CodigoAF = "";") - - If Not UsuarioActual.Empresa.Funcionalidad(105).ToString = "1" Then - DdlProducto2.SelectedValue = "-1" - Else - DdlProducto2.SelectedValue = "" - DdlProducto2.SelectedText = "" - End If - - txtCantidad.Focus() - End Sub - - - Protected Sub AddNew(CvePS As Integer, PS As String, CveUM As Integer, UM As String, Cantidad As Double, PU As Double, SerieLote As String, CodigoAF As String, Codigo As String, CveAF As String, Observaciones As String, Lote As String, Batch As String, CveSeccionAlmacen As Integer, SeccionAlmacen As String) - If DdlAlmacen.SelectedValue.ToEntero <= 0 Then Alert("Seleccione un almacen", TipoMensaje.MsgAdvertencia) : RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") : DdlProducto2.SelectedText = "" : Exit Sub - + UpDescripcion.Update() + + 'Dim Inv As New ClsInventarios + 'Inv.IniciaTransacSQL() + + 'Dim TieneError = False + + 'Dim ObjConta As ClsContPAQi = Nothing + 'If UsuarioActual.Empresa.UsaContabilidad Or UsuarioActual.Empresa.UsaAC Then + ' ObjConta = New ClsContPAQi(UsuarioActual.Empresa) + ' ObjConta.IniciaTransacSQL() + 'End If + + + 'If Inv.MovimientoRemove(CveMovimiento, UsuarioActual.CveEmpresa) Then + ' If HdnIdPoliza.Value.ToEntero > 0 Then + ' If Not ObjConta.RemovePoliza(HdnIdPoliza.Value.ToEntero) Then + ' TieneError = True + ' End If + ' End If + 'Else + ' TieneError = True + 'End If + + 'If Not TieneError Then + ' If ObjConta IsNot Nothing Then ObjConta.Commit() + ' Inv.Commit() + + ' Alert("Movimientos Eliminado", TipoMensaje.MsgInformacion) + ' LimpiarMovimiento() + 'Else + ' If ObjConta IsNot Nothing Then ObjConta.RollBack() + ' Inv.RollBack() + + ' Alert("Ocurrió un error al eliminar el movimiento. Por favor vuelva a intetar.", TipoMensaje.MsgError) + 'End If + 'CveMovimiento = 0 + + 'If ObjConta IsNot Nothing Then ObjConta.Dispose() + 'Inv.Dispose() + End Sub + Private Sub BtnRemove_Click(sender As Object, e As EventArgs) Handles BtnRemove.Click + Dim Borrar As Boolean = False + If Not TxtDescripcion.Text = "" Then + + Dim Inv As New ClsInventarios + Dim Conta As New ClsContabilidad(Inv.IniciaTransacSQL()) + Dim ObjGral As New ClsGenerales(Inv.IniciaTransacSQL()) + + Dim TieneError = False + + Dim ObjConta As ClsContPAQi = Nothing + If UsuarioActual.Empresa.UsaContabilidad Or UsuarioActual.Empresa.UsaAC Then + ObjConta = New ClsContPAQi(UsuarioActual.Empresa) + ObjConta.IniciaTransacSQL() + End If + + If Not ObjGral.AddHistorialBitacora(Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, "", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 1, String.Format("{0}, Informacion = {1}", TxtDescripcion.Text, DescripcionDetalladaEliminar), "Inventarios", TxtFolio.Text + " / " + DdlConcepto.SelectedItem.Text) Then + TieneError = True + End If + + If Inv.MovimientoRemove(CveMovimiento, UsuarioActual.CveEmpresa) Then + If HdnIdPoliza.Value.ToEntero > 0 Then + If Not ObjConta.RemovePoliza(HdnIdPoliza.Value.ToEntero) Then + TieneError = True + End If + End If + Else + TieneError = True + End If + + If Not TieneError Then + If Not Conta.UpdatePrePolizasDetalleBloquear(CvePrePoliza, False) Then + TieneError = True + End If + End If + + If Not TieneError Then + If ObjConta IsNot Nothing Then ObjConta.Commit() + Inv.Commit() + + Alert("Movimientos Eliminado", TipoMensaje.MsgInformacion) + RegistraScript(String.Format("$('#{0}').modal('hide');", "divDescripcion")) + LimpiarMovimiento() + Else + If ObjConta IsNot Nothing Then ObjConta.RollBack() + Inv.RollBack() + + Alert("Ocurrió un error al eliminar el movimiento. Por favor vuelva a intentar.", TipoMensaje.MsgError) + End If + CveMovimiento = 0 + + If ObjConta IsNot Nothing Then ObjConta.Dispose() + Inv.Dispose() + ObjGral.Dispose() + Conta.Dispose() + End If + End Sub +#End Region + + +#Region " AGREGAR - GUARDAR " + Private Function GetExistencias(CvePS As Integer, CveUnidadMedida As Integer, CveEmpresa As Integer, CveAlmacen As Integer, Optional SerieLote As String = "-1", Optional Lote As String = "-1", Optional Batch As String = "-1") As Double + Dim Inv As New ClsInventarios + Dim Existencia As Double = Inv.GetExistenciasPS(CvePS, CveUnidadMedida, CveEmpresa, CveAlmacen, -1, FechaMovto:=String.Format("{0} {1}", TxtFecha.Text.ToDate.ToString("yyyy/MM/dd"), TxtHoraInicio.PostedTime), SerieLote:=SerieLote, Lote:=Lote, Batch:=Batch) + Inv.Dispose() + Return Existencia + End Function + + Protected Sub btnAgregar_Click(sender As Object, e As EventArgs) Handles LbAgregar.Click + AgregarPS() + End Sub + Protected Sub BtnSerieAddNew_Click(sender As Object, e As EventArgs) + AgregarPS() + End Sub + Private Sub AgregarPS() + If Not DdlProducto2.SelectedValue.ToEntero > 0 Then + RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") + Alert("Es necesario especificar el producto.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + AddNew(DdlProducto2.SelectedValue.ToEntero, DdlProducto2.SelectedText, DdlUnidad.SelectedValue.ToEntero, DdlUnidad.SelectedItem.Text, txtCantidad.Text.ToDouble, txtPrecio.Text.ToDouble, TxtnSerieLote.Text.Replace(" ", String.Empty), LblCodigo.Text, HdnCodigoAF.Value, HdnCveActivoFijo.Value, TxtObservacionesdetalle.Text, TxtnLote.Text.Trim, TxtnBatch.Text.Trim, DdlSeccionAlmacen.SelectedValue.ToEntero, DdlSeccionAlmacen.SelectedItem.Text) + LimpiarAgregar() + + txtCantidad.Text = "" + TxtnLote.Text = "" + TxtnBatch.Text = "" + LblCodigo.Text = "" + TxtnSerieLote.Text = "" + HdnCodigoAF.Value = "-1" + HdnCveActivoFijo.Value = "-1" + RegistraScript("CodigoAF = "";") + + If Not UsuarioActual.Empresa.Funcionalidad(105).ToString = "1" Then + DdlProducto2.SelectedValue = "-1" + Else + DdlProducto2.SelectedValue = "" + DdlProducto2.SelectedText = "" + End If + + txtCantidad.Focus() + End Sub + + + Protected Sub AddNew(CvePS As Integer, PS As String, CveUM As Integer, UM As String, Cantidad As Double, PU As Double, SerieLote As String, CodigoAF As String, Codigo As String, CveAF As String, Observaciones As String, Lote As String, Batch As String, CveSeccionAlmacen As Integer, SeccionAlmacen As String) + If DdlAlmacen.SelectedValue.ToEntero <= 0 Then Alert("Seleccione un almacen", TipoMensaje.MsgAdvertencia) : RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") : DdlProducto2.SelectedText = "" : Exit Sub + Dim Valido As Boolean = True Dim RowPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS).Rows(0) @@ -1186,2207 +1186,2207 @@ Partial Class Inventarios_EntradasSalidas If CveMetodoInventario = 5 And (String.IsNullOrEmpty(SerieLote.Trim()) OrElse SerieLote = "-1") Then Valido = False Alert("El producto requiere Serie-Lote", TipoMensaje.MsgAdvertencia) - End If - - 'salida + End If + + 'salida If Valido AndAlso DdlConcepto.SelectedValue.Contiene({"3", "5", "7", "8", "11", "12", "13", "15", "16", "17", "20", "21", "30", "31"}) Then ' salida de almacen - - Dim Existencia As Double = GetExistencias(CvePS, CveUM, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, If(SerieLote = "", "-1", SerieLote), If(Lote = "", "-1", Lote), If(Batch = "", "-1", Batch)) - LbAgregar.ToolTip = Existencia.ToString - If Existencia - Cantidad - DtMovimientos.SUM("Cantidad", $"CvePS = {CvePS} AND CveUM = {CveUM} {If(SerieLote <> "", $" AND SerieLote = '{SerieLote}'", "")}") < 0 Then - If Existencia <= 0 Then - Alert("No hay existencia del producto", TipoMensaje.MsgAdvertencia) - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - Valido = False - Else - Alert(String.Format("Solo hay en existencia: {0}", Existencia), TipoMensaje.MsgAdvertencia) - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - If Not UsuarioActual.TienePermisoProceso(114) Then - Cantidad = Existencia - End If - End If - Valido = If(UsuarioActual.TienePermisoProceso(114), True, False) - End If - End If - - - If Valido Then - Dim CveClasificacion As Integer - Dim dr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS).FiltroPrimero("", "PS") - If dr IsNot Nothing Then CveClasificacion = dr("CveClasificacion").ToString.ToEntero - - 'VALIDA QUE LA SERIE NO SEA IGUAL AL CODIGO O CODIGOBARRAS - If SerieLote <> "" And (SerieLote.ToUpper = dr("Codigo").ToString.ToUpper Or SerieLote.ToUpper = dr("CodigoBarras").ToString.ToUpper) Then - Alert($"La serie indicada {SerieLote} coincide con el codigo o codigo de barras del producto. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - Dim registro As DataRow = DtMovimientos.NewRow - registro.Item("Cantidad") = Cantidad - registro.Item("CveUM") = CveUM - registro.Item("UnidadMedida") = UM - registro.Item("CvePS") = CvePS - registro.Item("CodigoPS") = PS - registro.Item("PS") = PS - registro.Item("PU") = PU - 'registro.Item("PUExtranjero") = PU - registro.Item("Total") = Cantidad * PU - registro.Item("CveClasificacion") = CveClasificacion - registro.Item("Estatus") = "" - registro.Item("CveSeccionAlmacen") = CveSeccionAlmacen - registro.Item("SeccionAlmacen") = SeccionAlmacen - - - registro.Item("CodigoAF") = CodigoAF - registro.Item("Codigo") = Codigo - registro.Item("CveAF") = CveAF - registro.Item("SerieLote") = If(SerieLote <> "", SerieLote, "") - registro.Item("Lote") = If(Lote <> "", Lote, "") - registro.Item("Batch") = If(Batch <> "", Batch, "") - registro.Item("Observaciones") = Observaciones - DtMovimientos.Rows.Add(registro) - CargaGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' ")) - RegistraScript("playsonidito('beep-07.wav')") - End If - - End Sub - Protected Sub BtnGuardar_Click(sender As Object, e As EventArgs) Handles BtnGuardar.Click - - If EsNuevoMov Then - CveMovimiento = 0 - End If - - If EsConsumoInterno And DdlPersonal.SelectedValue.ToEntero <= 0 Then - Alert("El personal es requerido. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - If GvM.Rows.Count > 0 Then - - 'Dim CveMovimiento As Integer - Dim ObjInventario As New ClsInventarios - Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL()) - Dim ObjContaAC As ClsContPAQi = Nothing - Dim ErrorMovInv As Boolean = False - Dim ErrorAC As Boolean = False - Dim IDPoliza As Integer = 0 - Dim ImporteConcepto = 0.0 - - Try - - 'Para Campos Nuevos AF y OC - Dim SubProyecto = -1 - Dim ActivoFijo = -1 - - If UsuarioActual.CveEmpresa = 66 AndAlso (DdlConcepto.SelectedValue.ToEntero = 3 Or DdlConcepto.SelectedValue.ToEntero = 11) Then - SubProyecto = DdlSubProyecto.SelectedValue.ToEntero - ActivoFijo = -1 'HdnCveActivoFijo.Value.ToEntero - ElseIf UsuarioActual.CveEmpresa = 66 AndAlso Not CveMovimiento > 0 Then - SubProyecto = -2 - ActivoFijo = -2 - End If - - 'ACTUALIZAR - If CveMovimiento > 0 Then - Dim Mensaje As String = "" - - 'Actualiza Movimiento - If Not ObjInventario.UpdateMovimiento(CveMovimiento, DdlAlmacen.SelectedValue.ToEntero, DdlConcepto.SelectedValue.ToEntero, 1, String.Format("{0} {1}", TxtFecha.Text.ToDate.ToString("yyyy/MM/dd"), TxtHoraInicio.PostedTime).ToDate, - TxtFolio.Text.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, SubProyecto, ActivoFijo, Guia:=TxtGuia.Text, Observaciones:=TxtObservaciones.Text) Then - Mensaje = "Error al Actualizar el Movimiento" - ErrorMovInv = True - End If - - If Not ErrorMovInv Then - - ' Actualizo los movimientos - For Each Dr As DataRow In DtMovimientos.Rows - - 'Determina PU dependiendo MONEDA - If DdlConcepto.SelectedValue.ToEntero = 2 AndAlso DdlMoneda.SelectedValue.ToEntero = 2 Then - ImporteConcepto = Dr("PU").ToString.ToDouble * GlobalTipoCambio(TxtFecha.Text.ToDate) - Else - ImporteConcepto = Dr("PU").ToString.ToDouble - End If - - 'Actualiza existentes - If Dr("CveMovimientoDetalle").ToString.ToEntero > 0 Then - 'cuando es normal - If Dr("Estatus").ToString = "E" Then - 'hay que eliminarlo - If Not ObjInventario.RemoveMovimientoDetalle(Dr("CveMovimientoDetalle").ToString.ToEntero, Dr("CveMovimiento").ToString.ToEntero) Then - ErrorMovInv = True - End If - ElseIf Dr("Estatus").ToString = "U" Then - - If Not ObjInventario.UpdateMovimientoDetalle(Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, ImporteConcepto, Dr("CveAF").ToString.ToEntero, Dr("CveMovimientoDetalle").ToString.ToEntero, Dr("CveSeccionAlmacen").ToString.ToEntero, Dr("SerieLote").ToString, Dr("Observaciones").ToString, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then - Mensaje = "Error al Actualizar los movimientos" - ErrorMovInv = True : Exit For - End If - - End If - - 'Agrega nuevos - Else - - If GlobalDTInvConceptos.FiltraParametros(String.Format("CveConcepto = {0}", DdlConcepto.SelectedValue.ToEntero)).Rows.Count > 0 AndAlso GlobalDTInvConceptos.FiltraParametros(String.Format("CveConcepto = {0}", DdlConcepto.SelectedValue.ToEntero)).Rows(0)("Origen").ToString.ToEntero < 0 Then - If ObjInventario.GetExistenciasPS(Dr("CvePS").ToString.ToEntero, Dr("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, CveAlmacen:=DdlAlmacen.SelectedValue.ToEntero, FechaMovto:=String.Format("{0} {1}", TxtFecha.Text.ToDate.ToString("yyyy/MM/dd"), TxtHoraInicio.PostedTime), SerieLote:=If(Dr("SerieLote").ToString = "", "-1", Dr("SerieLote").ToString), Lote:=If(Dr("Lote").ToString = "", "-1", Dr("Lote").ToString), Batch:=If(Dr("Batch").ToString = "", "-1", Dr("Batch").ToString)) >= Dr("Cantidad").ToString.ToDouble Then - If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, ImporteConcepto, Dr("CveAF").ToString.ToEntero, Dr("CveSeccionAlmacen").ToString.ToEntero, Dr("SerieLote").ToString, Dr("Observaciones").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then - Mensaje = "Error al Agregar los nuevos movimientos" - ErrorMovInv = True : Exit For - End If - Else - If UsuarioActual.TienePermisoProceso(114) Then - If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, ImporteConcepto, Dr("CveAF").ToString.ToEntero, Dr("CveSeccionAlmacen").ToString.ToEntero, Dr("SerieLote").ToString, Dr("Observaciones").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then - Mensaje = "Error al Agregar los nuevos movimientos" - ErrorMovInv = True : Exit For - End If - Else - Mensaje = String.Format("No hay existencias suficientes del producto: {0}", Dr("CodigoAF")) - ErrorMovInv = True : Exit For - End If - End If - Else - If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, ImporteConcepto, Dr("CveAF").ToString.ToEntero, Dr("CveSeccionAlmacen").ToString.ToEntero, Dr("SerieLote").ToString, Dr("Observaciones").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then - Mensaje = "Error al Agregar los nuevos movimientos" - ErrorMovInv = True : Exit For - End If - End If - - End If - Next - - If UsuarioActual.Empresa.UsaAC AndAlso Not ErrorMovInv Then - - 'cargar también los movimentos detalle - If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then - DtMovimientos = ObjInventario.DtResultados.FiltraParametros("", "CveMovimientoDetalle") - End If - - Dim Importe As Double = DtMovimientos.SUM("Total", "Estatus IN ('','U')") - IDPoliza = HdnIdPoliza.Value.ToEntero - - If Importe > 0 AndAlso IDPoliza > 0 Then - Dim CuentaAbonoAlmacen, CuentaCargoCOG As Integer - - ObjContaAC = New ClsContPAQi(UsuarioActual.Empresa) - ObjContaAC.IniciaTransacSQL() - ObjContaAC.RemoveAllMovimientos(IDPoliza) - - Dim drA As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveAlmacen = {0}", DdlAlmacen.SelectedValue)) - If drA IsNot Nothing Then CuentaAbonoAlmacen = drA("IdCtaContable").ToString.ToEntero - - If UsuarioActual.CveEmpresa = 48 Then ' APH - CuentaCargoCOG = 1386 - End If - - If CuentaCargoCOG > 0 AndAlso CuentaAbonoAlmacen > 0 Then - If ObjContaAC.AddMovimiento(IDPoliza, CuentaCargoCOG, False, Importe, "", "", 0, TxtFecha.Text.ToDate, "") Then - 'actualizo el idcuenta del presupuesto - If Not ObjContaAC.AddMovimiento(IDPoliza, CuentaAbonoAlmacen, True, Importe, "", "", 0, TxtFecha.Text.ToDate, "") Then - ErrorAC = True - End If - Else - ErrorAC = True - End If - - End If - - End If - End If - End If - - If Not ErrorAC AndAlso Not ErrorMovInv Then - Dim Msg As String = "Movimiento Actualizado" - If IDPoliza > 0 Then ObjContaAC.AjustaPoliza(IDPoliza) - ObjInventario.Commit() ' aplica los movimientos insertados - - 'recargo los datos para que esten actualizados, y no se duplique un rgistro nuevo - If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then - DtMovimientos = ObjInventario.DtResultados - End If - - If ObjContaAC IsNot Nothing Then ObjContaAC.Commit() - Alert(Msg, TipoMensaje.MsgInformacion, "document.location.href=""/Inventarios/EntradasSalidas.aspx?CveMovimiento=" & CveMovimiento & """;") - UPDatos.Update() - Else - ObjInventario.RollBack() - If ObjContaAC IsNot Nothing Then ObjContaAC.RollBack() - Alert(Mensaje, TipoMensaje.MsgError) - End If - - - 'GUARDAR - Else - Dim Fecha = String.Format("{0} {1}", TxtFecha.Text.ToDate.ToString("yyyy/MM/dd"), TxtHoraInicio.PostedTime).ToDate - Dim CveCliente As Integer = CInt(IIf((DdlClientes.SelectedValue.ToEntero <= 0), -1, DdlClientes.SelectedValue.ToEntero)) - Dim CveClienteSucursal As Integer = CInt(IIf((DdlClientesSucursales.SelectedValue.ToEntero <= 0), -1, DdlClientesSucursales.SelectedValue.ToEntero)) - - - 'cuando es APH - Dim tFolio As Integer = -1 - If UsuarioActual.CveEmpresa = 48 And EsConsumoInterno = False Then tFolio = TxtFolio.Text.ToEntero - If Not tFolio > 0 Then - tFolio = If(TxtFolio.Text.ToEntero <> FolioAsignado, TxtFolio.Text.ToEntero, -1) - End If - Dim tCveProveedor As Integer = -1 - If DdlProveedor.SelectedValue.ToEntero > 0 Then tCveProveedor = DdlProveedor.SelectedValue.ToEntero - Dim obs As String = TxtObservaciones.Text.Trim() - If obs = "" Then - obs = DdlConcepto.SelectedItem.Text - If DdlPersonal.SelectedValue.ToEntero > 0 Then obs = obs & " - " & DdlPersonal.SelectedItem.Text - End If - - Dim TotalCantidad As Double = DtMovimientos.SUMD("Cantidad") - If UsuarioActual.Empresa.Funcionalidad(563) = "1" Then - If TotalCantidad <> DtSeccionAlmacen.SUMD("CantidadSeccionAlmacen") Then - ObjInventario.RollBack() - Alert("La seccion de almacen no ha sido agregada completamente.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - End If - - Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Inv/ES", 53, 0, 0, 1, TxtFecha.Text.ToDate, obs, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoPoliza:=3) - CveMovimiento = ObjInventario.AddMovimiento(DdlAlmacen.SelectedValue.ToEntero, DdlConcepto.SelectedValue.ToEntero, 1, Fecha, tFolio, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, SubProyecto, ActivoFijo, Guia:=TxtGuia.Text, Observaciones:=TxtObservaciones.Text, CvePersonal:=DdlPersonal.SelectedValue.ToEntero, Recibio:=TxtResponsable.Text.Trim, CveCliente:=CveCliente, CveClienteSucursal:=CveClienteSucursal, DepartamentoEntrega:=TxtDepartamentoEntrega.Text, PedidoContrato:=TxtPedidoContrato.Text, CveProveedor:=tCveProveedor) - - - If CveMovimiento <= 0 OrElse CvePrePoliza <= 0 Then - Alert("No se pudo almacenar el movimiento correctamente", TipoMensaje.MsgError) - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - ObjInventario.RollBack() 'deshace lo insertado - Else - Dim Mensaje As String = "" - - ''VALIDA EXISTENCIAS - Dim Cont As Integer = 0 - If DdlConcepto.SelectedValue.Contiene({"3", "11", "13", "21", "30", "31"}) Then - For Each Dr As DataRow In DtMovimientos.Rows - If ObjInventario.GetExistenciasPS(Dr("CvePS").ToString.ToEntero, Dr("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, FechaMovto:=String.Format("{0} {1}", TxtFecha.Text.ToDate.ToString("yyyy/MM/dd"), TxtHoraInicio.PostedTime), SerieLote:=If(Dr("SerieLote").ToString = "", "-1", Dr("SerieLote").ToString), Lote:=If(Dr("Lote").ToString = "", "-1", Dr("Lote").ToString), Batch:=If(Dr("Batch").ToString = "", "-1", Dr("Batch").ToString)) >= Dr("Cantidad").ToString.ToDouble Then - - If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDouble, Dr("CveAF").ToString.ToEntero, Dr("CveSeccionAlmacen").ToString.ToEntero, Dr("SerieLote").ToString, Dr("Observaciones").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then - Mensaje = "Error al guardar los movimientos" - ErrorMovInv = True - Exit For - Else - 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 * Tipo) Then - ErrorMovInv = True - Mensaje = "Ocurrió un error al procesar las secciones de almacen. Por favor vuelva a intentar." - Exit For - End If - Next - End If - End If - Else - - If UsuarioActual.TienePermisoProceso(114) Then - If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDouble, Dr("CveAF").ToString.ToEntero, Dr("CveSeccionAlmacen").ToString.ToEntero, Dr("SerieLote").ToString, Dr("Observaciones").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then - Mensaje = "Error al guardar los movimientos" - ErrorMovInv = True - Exit For - Else - 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 * Tipo) Then - ErrorMovInv = True - Mensaje = "Ocurrió un error al procesar las secciones de almacen. Por favor vuelva a intentar." - Exit For - End If - Next - End If - End If - Else - Mensaje = String.Format("No hay existencias suficientes del producto: {0}", Dr("PS")) - Alert(Mensaje, TipoMensaje.MsgAdvertencia) - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - ErrorMovInv = True : Exit For - End If - - End If - Cont += 1 - Next - - Else - For Each Dr As DataRow In DtMovimientos.Rows - If DdlConcepto.SelectedValue.ToEntero = 2 AndAlso DdlMoneda.SelectedValue.ToEntero = 2 Then - ImporteConcepto = Dr("PU").ToString.ToDouble * GlobalTipoCambio(TxtFecha.Text.ToDate) - Else - ImporteConcepto = Dr("PU").ToString.ToDouble - End If - - If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, ImporteConcepto, Dr("CveAF").ToString.ToEntero, Dr("CveSeccionAlmacen").ToString.ToEntero, Dr("SerieLote").ToString, Dr("Observaciones").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then - Mensaje = "Error al guardar los movimientos" - ErrorMovInv = True - Exit For - Else - 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 * Tipo) Then - ErrorMovInv = True - Mensaje = "Ocurrió un error al procesar las secciones de almacen. Por favor vuelva a intentar." - Exit For - End If - Next - End If - End If - Cont += 1 - Next - End If - - - 'Registro la prepóliza - If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then - Dim tValorInventario As Decimal = ObjInventario.DtResultados.SUM("Total", "").ToDecimal.RoundSQL() - Dim tValorOtro As Decimal = tValorInventario - Dim idCtaContable As Integer = 0 - Dim IdCtaContableOtro As Integer = UsuarioActual.Empresa.IdCuentaOtrosIngresos - Dim TipoMovtoAlmacen As Boolean = False - Dim TipoMovtoOtro As Boolean = True - Dim tCveSubProyecto As Integer = -1 - - Dim drA2 As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveAlmacen = {0}", DdlAlmacen.SelectedValue)) - If drA2 IsNot Nothing Then - idCtaContable = drA2("IdCtaContable").ToString.ToEntero - tCveSubProyecto = drA2("CveSubProyecto").ToString.ToEntero - End If - - Dim OrigenMov As Integer = GlobalDTInvConceptos.FiltroPrimeroValor("Origen", "CveConcepto = " & DdlConcepto.SelectedValue).ToEntero - If OrigenMov = 1 Then TipoMovtoAlmacen = False Else TipoMovtoAlmacen = True - TipoMovtoOtro = Not TipoMovtoAlmacen - - Dim CveConceptoContable As Integer = 78 - Dim CveClasificacion As Integer = -1 - Select Case DdlConcepto.SelectedValue.ToEntero - Case 28, 31 - CveConceptoContable = 51 - - '[IPP] PARCHE CTA CONTABLE PARA SALIDA DE DEMOSTRACION - If DdlConcepto.SelectedValue.ToEntero = 31 Then - IdCtaContableOtro = 1319 - End If - - Case 30 - CveConceptoContable = 181 + + Dim Existencia As Double = GetExistencias(CvePS, CveUM, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, If(SerieLote = "", "-1", SerieLote), If(Lote = "", "-1", Lote), If(Batch = "", "-1", Batch)) + LbAgregar.ToolTip = Existencia.ToString + If Existencia - Cantidad - DtMovimientos.SUM("Cantidad", $"CvePS = {CvePS} AND CveUM = {CveUM} {If(SerieLote <> "", $" AND SerieLote = '{SerieLote}'", "")}") < 0 Then + If Existencia <= 0 Then + Alert("No hay existencia del producto", TipoMensaje.MsgAdvertencia) + RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") + Valido = False + Else + Alert(String.Format("Solo hay en existencia: {0}", Existencia), TipoMensaje.MsgAdvertencia) + RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") + If Not UsuarioActual.TienePermisoProceso(114) Then + Cantidad = Existencia + End If + End If + Valido = If(UsuarioActual.TienePermisoProceso(114), True, False) + End If + End If + + + If Valido Then + Dim CveClasificacion As Integer + Dim dr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS).FiltroPrimero("", "PS") + If dr IsNot Nothing Then CveClasificacion = dr("CveClasificacion").ToString.ToEntero + + 'VALIDA QUE LA SERIE NO SEA IGUAL AL CODIGO O CODIGOBARRAS + If SerieLote <> "" And (SerieLote.ToUpper = dr("Codigo").ToString.ToUpper Or SerieLote.ToUpper = dr("CodigoBarras").ToString.ToUpper) Then + Alert($"La serie indicada {SerieLote} coincide con el codigo o codigo de barras del producto. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + Dim registro As DataRow = DtMovimientos.NewRow + registro.Item("Cantidad") = Cantidad + registro.Item("CveUM") = CveUM + registro.Item("UnidadMedida") = UM + registro.Item("CvePS") = CvePS + registro.Item("CodigoPS") = PS + registro.Item("PS") = PS + registro.Item("PU") = PU + 'registro.Item("PUExtranjero") = PU + registro.Item("Total") = Cantidad * PU + registro.Item("CveClasificacion") = CveClasificacion + registro.Item("Estatus") = "" + registro.Item("CveSeccionAlmacen") = CveSeccionAlmacen + registro.Item("SeccionAlmacen") = SeccionAlmacen + + + registro.Item("CodigoAF") = CodigoAF + registro.Item("Codigo") = Codigo + registro.Item("CveAF") = CveAF + registro.Item("SerieLote") = If(SerieLote <> "", SerieLote, "") + registro.Item("Lote") = If(Lote <> "", Lote, "") + registro.Item("Batch") = If(Batch <> "", Batch, "") + registro.Item("Observaciones") = Observaciones + DtMovimientos.Rows.Add(registro) + CargaGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' ")) + RegistraScript("playsonidito('beep-07.wav')") + End If + + End Sub + Protected Sub BtnGuardar_Click(sender As Object, e As EventArgs) Handles BtnGuardar.Click + + If EsNuevoMov Then + CveMovimiento = 0 + End If + + If EsConsumoInterno And DdlPersonal.SelectedValue.ToEntero <= 0 Then + Alert("El personal es requerido. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If GvM.Rows.Count > 0 Then + + 'Dim CveMovimiento As Integer + Dim ObjInventario As New ClsInventarios + Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL()) + Dim ObjContaAC As ClsContPAQi = Nothing + Dim ErrorMovInv As Boolean = False + Dim ErrorAC As Boolean = False + Dim IDPoliza As Integer = 0 + Dim ImporteConcepto As Decimal = 0 + + Try + + 'Para Campos Nuevos AF y OC + Dim SubProyecto = -1 + Dim ActivoFijo = -1 + + If UsuarioActual.CveEmpresa = 66 AndAlso (DdlConcepto.SelectedValue.ToEntero = 3 Or DdlConcepto.SelectedValue.ToEntero = 11) Then + SubProyecto = DdlSubProyecto.SelectedValue.ToEntero + ActivoFijo = -1 'HdnCveActivoFijo.Value.ToEntero + ElseIf UsuarioActual.CveEmpresa = 66 AndAlso Not CveMovimiento > 0 Then + SubProyecto = -2 + ActivoFijo = -2 + End If + + 'ACTUALIZAR + If CveMovimiento > 0 Then + Dim Mensaje As String = "" + + 'Actualiza Movimiento + If Not ObjInventario.UpdateMovimiento(CveMovimiento, DdlAlmacen.SelectedValue.ToEntero, DdlConcepto.SelectedValue.ToEntero, 1, String.Format("{0} {1}", TxtFecha.Text.ToDate.ToString("yyyy/MM/dd"), TxtHoraInicio.PostedTime).ToDate, + TxtFolio.Text.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, SubProyecto, ActivoFijo, Guia:=TxtGuia.Text, Observaciones:=TxtObservaciones.Text) Then + Mensaje = "Error al Actualizar el Movimiento" + ErrorMovInv = True + End If + + If Not ErrorMovInv Then + + ' Actualizo los movimientos + For Each Dr As DataRow In DtMovimientos.Rows + + 'Determina PU dependiendo MONEDA + If DdlConcepto.SelectedValue.ToEntero = 2 AndAlso DdlMoneda.SelectedValue.ToEntero = 2 Then + ImporteConcepto = Dr("PU").ToString.ToDecimal * GlobalTipoCambio(TxtFecha.Text.ToDate).ToDecimal + Else + ImporteConcepto = Dr("PU").ToString.ToDecimal + End If + + 'Actualiza existentes + If Dr("CveMovimientoDetalle").ToString.ToEntero > 0 Then + 'cuando es normal + If Dr("Estatus").ToString = "E" Then + 'hay que eliminarlo + If Not ObjInventario.RemoveMovimientoDetalle(Dr("CveMovimientoDetalle").ToString.ToEntero, Dr("CveMovimiento").ToString.ToEntero) Then + ErrorMovInv = True + End If + ElseIf Dr("Estatus").ToString = "U" Then + + If Not ObjInventario.UpdateMovimientoDetalle(Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, ImporteConcepto, Dr("CveAF").ToString.ToEntero, Dr("CveMovimientoDetalle").ToString.ToEntero, Dr("CveSeccionAlmacen").ToString.ToEntero, Dr("SerieLote").ToString, Dr("Observaciones").ToString, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then + Mensaje = "Error al Actualizar los movimientos" + ErrorMovInv = True : Exit For + End If + + End If + + 'Agrega nuevos + Else + + If GlobalDTInvConceptos.FiltraParametros(String.Format("CveConcepto = {0}", DdlConcepto.SelectedValue.ToEntero)).Rows.Count > 0 AndAlso GlobalDTInvConceptos.FiltraParametros(String.Format("CveConcepto = {0}", DdlConcepto.SelectedValue.ToEntero)).Rows(0)("Origen").ToString.ToEntero < 0 Then + If ObjInventario.GetExistenciasPS(Dr("CvePS").ToString.ToEntero, Dr("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, CveAlmacen:=DdlAlmacen.SelectedValue.ToEntero, FechaMovto:=String.Format("{0} {1}", TxtFecha.Text.ToDate.ToString("yyyy/MM/dd"), TxtHoraInicio.PostedTime), SerieLote:=If(Dr("SerieLote").ToString = "", "-1", Dr("SerieLote").ToString), Lote:=If(Dr("Lote").ToString = "", "-1", Dr("Lote").ToString), Batch:=If(Dr("Batch").ToString = "", "-1", Dr("Batch").ToString)) >= Dr("Cantidad").ToString.ToDouble Then + If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, ImporteConcepto, Dr("CveAF").ToString.ToEntero, Dr("CveSeccionAlmacen").ToString.ToEntero, Dr("SerieLote").ToString, Dr("Observaciones").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then + Mensaje = "Error al Agregar los nuevos movimientos" + ErrorMovInv = True : Exit For + End If + Else + If UsuarioActual.TienePermisoProceso(114) Then + If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, ImporteConcepto, Dr("CveAF").ToString.ToEntero, Dr("CveSeccionAlmacen").ToString.ToEntero, Dr("SerieLote").ToString, Dr("Observaciones").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then + Mensaje = "Error al Agregar los nuevos movimientos" + ErrorMovInv = True : Exit For + End If + Else + Mensaje = String.Format("No hay existencias suficientes del producto: {0}", Dr("CodigoAF")) + ErrorMovInv = True : Exit For + End If + End If + Else + If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, ImporteConcepto, Dr("CveAF").ToString.ToEntero, Dr("CveSeccionAlmacen").ToString.ToEntero, Dr("SerieLote").ToString, Dr("Observaciones").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then + Mensaje = "Error al Agregar los nuevos movimientos" + ErrorMovInv = True : Exit For + End If + End If + + End If + Next + + If UsuarioActual.Empresa.UsaAC AndAlso Not ErrorMovInv Then + + 'cargar también los movimentos detalle + If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then + DtMovimientos = ObjInventario.DtResultados.FiltraParametros("", "CveMovimientoDetalle") + End If + + Dim Importe As Double = DtMovimientos.SUM("Total", "Estatus IN ('','U')") + IDPoliza = HdnIdPoliza.Value.ToEntero + + If Importe > 0 AndAlso IDPoliza > 0 Then + Dim CuentaAbonoAlmacen, CuentaCargoCOG As Integer + + ObjContaAC = New ClsContPAQi(UsuarioActual.Empresa) + ObjContaAC.IniciaTransacSQL() + ObjContaAC.RemoveAllMovimientos(IDPoliza) + + Dim drA As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveAlmacen = {0}", DdlAlmacen.SelectedValue)) + If drA IsNot Nothing Then CuentaAbonoAlmacen = drA("IdCtaContable").ToString.ToEntero + + If UsuarioActual.CveEmpresa = 48 Then ' APH + CuentaCargoCOG = 1386 + End If + + If CuentaCargoCOG > 0 AndAlso CuentaAbonoAlmacen > 0 Then + If ObjContaAC.AddMovimiento(IDPoliza, CuentaCargoCOG, False, Importe, "", "", 0, TxtFecha.Text.ToDate, "") Then + 'actualizo el idcuenta del presupuesto + If Not ObjContaAC.AddMovimiento(IDPoliza, CuentaAbonoAlmacen, True, Importe, "", "", 0, TxtFecha.Text.ToDate, "") Then + ErrorAC = True + End If + Else + ErrorAC = True + End If + + End If + + End If + End If + End If + + If Not ErrorAC AndAlso Not ErrorMovInv Then + Dim Msg As String = "Movimiento Actualizado" + If IDPoliza > 0 Then ObjContaAC.AjustaPoliza(IDPoliza) + ObjInventario.Commit() ' aplica los movimientos insertados + + 'recargo los datos para que esten actualizados, y no se duplique un rgistro nuevo + If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then + DtMovimientos = ObjInventario.DtResultados + End If + + If ObjContaAC IsNot Nothing Then ObjContaAC.Commit() + Alert(Msg, TipoMensaje.MsgInformacion, "document.location.href=""/Inventarios/EntradasSalidas.aspx?CveMovimiento=" & CveMovimiento & """;") + UPDatos.Update() + Else + ObjInventario.RollBack() + If ObjContaAC IsNot Nothing Then ObjContaAC.RollBack() + Alert(Mensaje, TipoMensaje.MsgError) + End If + + + 'GUARDAR + Else + Dim Fecha = String.Format("{0} {1}", TxtFecha.Text.ToDate.ToString("yyyy/MM/dd"), TxtHoraInicio.PostedTime).ToDate + Dim CveCliente As Integer = CInt(IIf((DdlClientes.SelectedValue.ToEntero <= 0), -1, DdlClientes.SelectedValue.ToEntero)) + Dim CveClienteSucursal As Integer = CInt(IIf((DdlClientesSucursales.SelectedValue.ToEntero <= 0), -1, DdlClientesSucursales.SelectedValue.ToEntero)) + + + 'cuando es APH + Dim tFolio As Integer = -1 + If UsuarioActual.CveEmpresa = 48 And EsConsumoInterno = False Then tFolio = TxtFolio.Text.ToEntero + If Not tFolio > 0 Then + tFolio = If(TxtFolio.Text.ToEntero <> FolioAsignado, TxtFolio.Text.ToEntero, -1) + End If + Dim tCveProveedor As Integer = -1 + If DdlProveedor.SelectedValue.ToEntero > 0 Then tCveProveedor = DdlProveedor.SelectedValue.ToEntero + Dim obs As String = TxtObservaciones.Text.Trim() + If obs = "" Then + obs = DdlConcepto.SelectedItem.Text + If DdlPersonal.SelectedValue.ToEntero > 0 Then obs = obs & " - " & DdlPersonal.SelectedItem.Text + End If + + Dim TotalCantidad As Double = DtMovimientos.SUMD("Cantidad") + If UsuarioActual.Empresa.Funcionalidad(563) = "1" Then + If TotalCantidad <> DtSeccionAlmacen.SUMD("CantidadSeccionAlmacen") Then + ObjInventario.RollBack() + Alert("La seccion de almacen no ha sido agregada completamente.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + End If + + Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Inv/ES", 53, 0, 0, 1, TxtFecha.Text.ToDate, obs, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoPoliza:=3) + CveMovimiento = ObjInventario.AddMovimiento(DdlAlmacen.SelectedValue.ToEntero, DdlConcepto.SelectedValue.ToEntero, 1, Fecha, tFolio, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, SubProyecto, ActivoFijo, Guia:=TxtGuia.Text, Observaciones:=TxtObservaciones.Text, CvePersonal:=DdlPersonal.SelectedValue.ToEntero, Recibio:=TxtResponsable.Text.Trim, CveCliente:=CveCliente, CveClienteSucursal:=CveClienteSucursal, DepartamentoEntrega:=TxtDepartamentoEntrega.Text, PedidoContrato:=TxtPedidoContrato.Text, CveProveedor:=tCveProveedor) + + + If CveMovimiento <= 0 OrElse CvePrePoliza <= 0 Then + Alert("No se pudo almacenar el movimiento correctamente", TipoMensaje.MsgError) + RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") + ObjInventario.RollBack() 'deshace lo insertado + Else + Dim Mensaje As String = "" + + ''VALIDA EXISTENCIAS + Dim Cont As Integer = 0 + If DdlConcepto.SelectedValue.Contiene({"3", "11", "13", "21", "30", "31"}) Then + For Each Dr As DataRow In DtMovimientos.Rows + If ObjInventario.GetExistenciasPS(Dr("CvePS").ToString.ToEntero, Dr("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, FechaMovto:=String.Format("{0} {1}", TxtFecha.Text.ToDate.ToString("yyyy/MM/dd"), TxtHoraInicio.PostedTime), SerieLote:=If(Dr("SerieLote").ToString = "", "-1", Dr("SerieLote").ToString), Lote:=If(Dr("Lote").ToString = "", "-1", Dr("Lote").ToString), Batch:=If(Dr("Batch").ToString = "", "-1", Dr("Batch").ToString)) >= Dr("Cantidad").ToString.ToDouble Then + + If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero, Dr("CveSeccionAlmacen").ToString.ToEntero, Dr("SerieLote").ToString, Dr("Observaciones").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then + Mensaje = "Error al guardar los movimientos" + ErrorMovInv = True + Exit For + Else + 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 * Tipo) Then + ErrorMovInv = True + Mensaje = "Ocurrió un error al procesar las secciones de almacen. Por favor vuelva a intentar." + Exit For + End If + Next + End If + End If + Else + + If UsuarioActual.TienePermisoProceso(114) Then + If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero, Dr("CveSeccionAlmacen").ToString.ToEntero, Dr("SerieLote").ToString, Dr("Observaciones").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then + Mensaje = "Error al guardar los movimientos" + ErrorMovInv = True + Exit For + Else + 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 * Tipo) Then + ErrorMovInv = True + Mensaje = "Ocurrió un error al procesar las secciones de almacen. Por favor vuelva a intentar." + Exit For + End If + Next + End If + End If + Else + Mensaje = String.Format("No hay existencias suficientes del producto: {0}", Dr("PS")) + Alert(Mensaje, TipoMensaje.MsgAdvertencia) + RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") + ErrorMovInv = True : Exit For + End If + + End If + Cont += 1 + Next + + Else + For Each Dr As DataRow In DtMovimientos.Rows + If DdlConcepto.SelectedValue.ToEntero = 2 AndAlso DdlMoneda.SelectedValue.ToEntero = 2 Then + ImporteConcepto = Dr("PU").ToString.ToDecimal * GlobalTipoCambio(TxtFecha.Text.ToDate).ToDecimal + Else + ImporteConcepto = Dr("PU").ToString.ToDecimal + End If + + If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, ImporteConcepto, Dr("CveAF").ToString.ToEntero, Dr("CveSeccionAlmacen").ToString.ToEntero, Dr("SerieLote").ToString, Dr("Observaciones").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then + Mensaje = "Error al guardar los movimientos" + ErrorMovInv = True + Exit For + Else + 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 * Tipo) Then + ErrorMovInv = True + Mensaje = "Ocurrió un error al procesar las secciones de almacen. Por favor vuelva a intentar." + Exit For + End If + Next + End If + End If + Cont += 1 + Next + End If + + + 'Registro la prepóliza + If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then + Dim tValorInventario As Decimal = ObjInventario.DtResultados.SUM("Total", "").ToDecimal.RoundSQL() + Dim tValorOtro As Decimal = tValorInventario + Dim idCtaContable As Integer = 0 + Dim IdCtaContableOtro As Integer = UsuarioActual.Empresa.IdCuentaOtrosIngresos + Dim TipoMovtoAlmacen As Boolean = False + Dim TipoMovtoOtro As Boolean = True + Dim tCveSubProyecto As Integer = -1 + + Dim drA2 As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveAlmacen = {0}", DdlAlmacen.SelectedValue)) + If drA2 IsNot Nothing Then + idCtaContable = drA2("IdCtaContable").ToString.ToEntero + tCveSubProyecto = drA2("CveSubProyecto").ToString.ToEntero + End If + + Dim OrigenMov As Integer = GlobalDTInvConceptos.FiltroPrimeroValor("Origen", "CveConcepto = " & DdlConcepto.SelectedValue).ToEntero + If OrigenMov = 1 Then TipoMovtoAlmacen = False Else TipoMovtoAlmacen = True + TipoMovtoOtro = Not TipoMovtoAlmacen + + Dim CveConceptoContable As Integer = 78 + Dim CveClasificacion As Integer = -1 + Select Case DdlConcepto.SelectedValue.ToEntero + Case 28, 31 + CveConceptoContable = 51 + + '[IPP] PARCHE CTA CONTABLE PARA SALIDA DE DEMOSTRACION + If DdlConcepto.SelectedValue.ToEntero = 31 Then + IdCtaContableOtro = 1319 + End If + + Case 30 + CveConceptoContable = 181 TipoMovtoOtro = False - If UsuarioActual.Empresa.Funcionalidad(342).ToEntero > 0 Then - IdCtaContableOtro = UsuarioActual.Empresa.Funcionalidad(342).ToEntero - End If - Case 13, 29 - CveConceptoContable = 69 - TipoMovtoOtro = True - tValorOtro = -tValorOtro - Dim drr As DataRow = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimero("") - If drr IsNot Nothing Then - CveClasificacion = drr("CveClasificacion").ToString.ToEntero - IdCtaContableOtro = drr("IdCuentaCostos").ToString.ToEntero - End If - - - End Select - - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovtoAlmacen, tValorInventario, TxtObservaciones.Text.Trim, 68, TxtObservaciones.Text.Trim, TxtFecha.Text.ToDate, idCtaContable, -1, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=tValorInventario, CveClasificacion:=CveClasificacion) Then - ErrorMovInv = True - Else - 'Select Case DdlConcepto.SelectedValue.ToEntero - ' Case 30 - 'Dim Dt As DataTable = ObjInventario.DtResultados.FiltraParametros("", "", {"CveClasificacion"}).Copy - 'Dim IdCuentaGasto As Integer = 0 - 'Dim Total As Decimal = 0 - 'For Each Dr As DataRow In Dt.Rows - ' Total = ObjInventario.DtResultados.FiltraParametros($"CveClasificacion = {Dr("CveClasificacion").ToString}").SUM("Total").ToDecimal.RoundSQL() - ' IdCuentaGasto = ObjInventario.DtResultados.FiltraParametros($"CveClasificacion = {Dr("CveClasificacion").ToString}").Rows(0)("IdCuentaGasto").ToString.ToEntero - - ' If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovtoAlmacen, Total, TxtObservaciones.Text.Trim, CveConceptoContable, TxtObservaciones.Text.Trim, TxtFecha.Text.ToDate, IdCuentaGasto, -1, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=Total, CveClasificacion:=Dr("CveClasificacion").ToString.ToEntero, CveSubProyecto:=tCveSubProyecto) Then - ' ErrorMovInv = True - ' End If - 'Next - 'Case Else - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovtoOtro, tValorOtro, TxtObservaciones.Text.Trim, CveConceptoContable, TxtObservaciones.Text.Trim, TxtFecha.Text.ToDate, IdCtaContableOtro, -1, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=tValorOtro, CveSubProyecto:=tCveSubProyecto, CveClasificacion:=CveClasificacion) Then - ErrorMovInv = True - End If - 'End Select - End If - Else - ErrorMovInv = True - End If - - '------------------------------------------------ - If Not ErrorMovInv Then - 'DEVENGAR - Dim TotalPorDevengar As Double = 0 - - 'cuando tiene AC y es salida de almacen, se manda al gasto - If UsuarioActual.Empresa.UsaAC AndAlso (DdlConcepto.SelectedValue = "3") Then - Dim DtII As DataTable = Nothing - Dim TotalDetalle As Double = 0.0 - Dim Importe As Double = DtMovimientos.SUM("Total", "Estatus IN ('','U')") - 'NOTA. CUANDO ES SALIDA, EN AUTOMATICO NO TENEMOS LOS VALORES DE LA SALIDA TODAVIA, Y POR ESO IMPORTE ES CERO, ES RECARGAR CON LOS DATOS YA INSERTADOS - - If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then - DtII = ObjInventario.DtResultados - End If - - TotalPorDevengar += Importe ' GvInv.Rows.Cast(Of GridViewRow)().Sum(Function(Gvr) Math.Round(Gvr.DataKey("PU").ToString.ToDouble, 4) * Math.Round(Gvr.DataKey("CantidadF").ToString.ToDouble, 4)) - TotalPorDevengar = Math.Round(TotalPorDevengar, 4) - ObjContaAC = New ClsContPAQi(UsuarioActual.Empresa) - ObjContaAC.IniciaTransacSQL() - - Dim AC As New ClsAC - Dim DtPresupuestos As DataTable = Nothing - If AC.GetPresupuestoEgresos(-1, True, UsuarioActual.Empresa.EjercicioActual, UsuarioActual.CveEmpresa) Then - DtPresupuestos = AC.DtResultados.Copy - Else - Alert("Ocurrió un error al cargar los Presupuestos. Por favor vuelva a cargar la página", TipoMensaje.MsgError) - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - End If - AC.Dispose() - - IDPoliza = ObjContaAC.AddPoliza(3, "Salida de Almacen", TotalPorDevengar, TotalPorDevengar, UsuarioActual.CveUsuario, TxtFecha.Text.ToDate) - - If IDPoliza > 0 Then - Dim CuentaCargoCOG As Integer - Dim CuentaAbonoAlmacen As Integer = 0 - Dim drA As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveAlmacen = {0}", DdlAlmacen.SelectedValue)) - - If drA IsNot Nothing Then CuentaAbonoAlmacen = drA("IdCtaContable").ToString.ToEntero - - ''For Each gvr As GridViewRow In GvAC.Rows - 'For Each Dr As DataRow In DtII.Rows - ' Importe = Dr("Cantidad").ToString.ToDouble * Dr("PU").ToString.ToDouble ' gvr.FCTextBox("TxtImporte").Text.ToDouble - ' TotalDetalle += Importe - - - 'saco de que partida se va a descontar y se enviara a gasto - ' Dim drP As DataRow = DtPresupuestos.FiltroPrimero(String.Format("CveClasificacion = {0}", Dr("CveClasificacion"))) - ' If drP IsNot Nothing Then CuentaCargoCOG = drP("IdCuentaMatriz").ToString.ToEntero - - If UsuarioActual.CveEmpresa = 48 Then ' APH - CuentaCargoCOG = 1386 - End If - - Dim ConceptoRenglon As String = "Salida de Almacen" - - If IDPoliza > 0 Then - If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then - Dim DtMovtos = ObjInventario.DtResultados - Importe = DtMovtos.SUM("Total", "Estatus = ''") - - If Importe > 0 Then - If CuentaCargoCOG > 0 AndAlso CuentaAbonoAlmacen > 0 Then - If ObjContaAC.AddMovimiento(IDPoliza, CuentaCargoCOG, False, Importe, "", ConceptoRenglon, 0, TxtFecha.Text.ToDate, "") Then - 'actualizo el idcuenta del presupuesto - If Not ObjContaAC.AddMovimiento(IDPoliza, CuentaAbonoAlmacen, True, Importe, "", ConceptoRenglon, 0, TxtFecha.Text.ToDate, "") Then - ErrorAC = True - Mensaje = "No se pudo insertar movimiento en la poliza 2." - End If - Else - ErrorAC = True - Mensaje = "No se pudo insertar movimiento en la poliza 1." - End If - End If - End If - - - End If - End If - - If IDPoliza > 0 Then - ObjInventario.UpdateMovimientoPoliza(IDPoliza, CveMovimiento, UsuarioActual.CveEmpresa) - End If - - Else - ErrorAC = True - Mensaje = "No se pudo insertar la poliza" - End If - End If - 'TERMINA: DEVENGAR - - - ''PREPOLIZA - SE CAMBIO DE LUGAR EL USO DE ESTA PARTE - 'If EsConsumoInterno Then - ' If Not ErrorAC And Not ErrorMovInv Then - ' 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 IdCtaContable As Integer = 0 - - ' If tmpCostos.Rows.Count > 0 Then - ' Dim Concepto As String = $"Consumo Interno: {ObjInventario.Folio} - {TxtObservaciones.Text}" - ' Dim CvePrePoliza = ObjConta.AddPrePolizas("Inv/ConsumoInterno", 53, DtCostos.SUM("Total"), DtCostos.SUM("Total"), 1, TxtFecha.Text.ToDate, $"Consumo Interno: {TxtObservaciones.Text}", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - - ' For Each RowInv As DataRow In tmpCostos.Rows - ' ValorInventario = DtCostos.SUM("Total", $"CveClasificacion = {RowInv("CveClasificacion")}").ToString.ToDecimal - ' IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaGasto", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero - - ' If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ValorInventario, Concepto, 6, Concepto, TxtFecha.Text.ToDate, IdCtaContable, -1, CveClasificacion:=RowInv("CveClasificacion").ToString.ToEntero, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=ValorInventario) Then - ' ErrorMovInv = True - ' Exit For - ' End If - - ' Next - - ' IdCtaContable = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", $"CveAlmacen={DdlAlmacen.SelectedValue.ToEntero}").ToEntero - ' If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, DtCostos.SUM("Total"), Concepto, 68, Concepto, TxtFecha.Text.ToDate, IdCtaContable, -1, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=DtCostos.SUM("Total")) Then - ' ErrorMovInv = True - ' End If - ' End If - ' End If - - ' End If - 'End If - - - If Not ErrorAC And Not ErrorMovInv Then - Dim Msg As New StringBuilder - Msg.AppendFormat("
El Movimiento se registro con el Folio: {0}", ObjInventario.Folio) - Msg.AppendFormat("

Imprimir Movimiento ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimiento))) - - If ObjContaAC IsNot Nothing Then ObjContaAC.AjustaPoliza(IDPoliza) - If IDPoliza > 0 Then Msg = Msg.AppendFormat("

Ver Póliza", IDPoliza) - - ObjInventario.Commit() ' aplica los movimientos insertados - If ObjContaAC IsNot Nothing Then ObjContaAC.Commit() - - Alert(Msg.ToString, TipoMensaje.MsgInformacion) - - 'Limpia Valores cuando inserta de campos especiales - If UsuarioActual.CveEmpresa = 66 Then - DdlSubProyecto.SelectedValueExist("-1") - UPEncabezado.Update() - End If - - UPDatos.Update() - - - If UsuarioActual.TienePermisoProceso(139) Then - CargaDatos(CveMovimiento) - Else - LimpiarMovimiento() - End If - DtSeccionAlmacen.Rows.Clear() - RegistraScript("playsonidito('beep-07.wav')") - Else - ObjInventario.RollBack() - CveMovimiento = 0 - If ObjContaAC IsNot Nothing Then ObjContaAC.RollBack() - Alert(Mensaje, TipoMensaje.MsgError) - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - End If - - - Else - ObjInventario.RollBack() 'deshace lo insertado - CveMovimiento = 0 - If ObjContaAC IsNot Nothing Then ObjContaAC.RollBack() - Alert("ocurrió un Error al registrar los movimientos", TipoMensaje.MsgError) - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - End If - - End If - - CargaGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' ")) - - End If - - - Catch ex As Exception - Try 'por si ya le habian dado rollback o commit - ObjInventario.RollBack() 'deshace lo insertad - Catch exx As Exception - - End Try - CveMovimiento = 0 - If ObjContaAC IsNot Nothing Then ObjContaAC.RollBack() - Alert("Ocurrió un Error inesperado en el registro" & ex.Message, TipoMensaje.MsgError) - GuardaLog("Ocurrió un Error inesperado en el registro" & ex.ToString()) - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - End Try - - ObjInventario.Dispose() 'elimino la instancia - If ObjContaAC IsNot Nothing Then ObjContaAC.Dispose() - - Else - Alert("No hay ningun registro para generar el movimiento. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgError) - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - End If - - EsNuevoMov = False - End Sub - -#End Region - - -#Region " ADD INVENTARIO INICIAL " - Protected Sub BtnCodigoBarras_Click(sender As Object, e As EventArgs) - - If TxtCodigoBarras.Text = "" Then - Exit Sub - End If - - TdSeriePS.Visible = False - - Dim DrPS = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimero($"CodigoBarras= '{TxtCodigoBarras.Text}'") - If DrPS Is Nothing Then - Alert($"No se ha encontrado un producto del Codigo ""{TxtCodigoBarras.Text}"". ", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus,200);") - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - TxtCodigoBarras.Text = "" - Exit Sub - End If - - If DrPS("Inv_CveMetodoInventario").ToString.ToEntero = 5 Then - TdSeriePS.Visible = True - TxtCodigoSerie.Focus() - CvePSSerieLote = DrPS("CvePS").ToString.ToEntero - CveUMSerieLote = DrPS("CveUnidadMedida").ToString.ToEntero - CostoPromedioSerieLote = DrPS("CostoPromedio").ToString.ToDouble - Exit Sub - End If - - GuardaCodigoSerie(TxtCantidadProducto.Text.ToDouble, DrPS("CvePS").ToString.ToEntero, DrPS("CveUnidadMedida").ToString.ToEntero, DrPS("CostoPromedio").ToString.ToDouble) - - TxtCodigoBarras.Text = "" - TxtCodigoBarras.Focus() - End Sub - Protected Sub BtnSeriePS_Click(sender As Object, e As EventArgs) - If TxtCodigoSerie.Text.Trim = "" Then TxtCodigoSerie.Focus() : Exit Sub - - GuardaCodigoSerie(1, CvePSSerieLote, CveUMSerieLote, CostoPromedioSerieLote, TxtCodigoSerie.Text.Trim) - - TdSeriePS.Visible = False - End Sub - Public Sub BtnAddCodigo_Click(sender As Object, e As EventArgs) Handles BtnAddCodigo.Click - - If TxtCodigo.Text.Trim = "" And TxtCodigoBarras.Text.Trim = "" Then - Exit Sub - End If - - Dim DrP As DataRow = Nothing - - If TxtCodigo.Text.Trim <> String.Empty Then - DrP = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimero($" Codigo = '{TxtCodigo.Text.Trim}'") - ElseIf TxtCodigoBarras.Text.Trim <> String.Empty Then - DrP = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimero($" CodigoBarras = '{TxtCodigoBarras.Text.Trim}'") - End If - - - - Dim Costo As Double = TxtAltaCosto.Text.ToDouble - - If DrP IsNot Nothing AndAlso DrP("CvePS").ToString.ToEntero > 0 Then - GuardaCodigoSerie(TxtCantidadProducto.Text.ToDouble, DrP("CvePS").ToString.ToEntero, DrP("CveUnidadMedida").ToString.ToEntero, Costo) - Else - Alert("No se encontró el producto. Favor de verificar y volver a intentar.", TipoMensaje.MsgError, "window.setTimeout(Focus2,200);") - End If - - End Sub - - Private Sub GuardaCodigoSerie(Cantidad As Double, CvePS As Integer, CveUM As Integer, CostoPromedio As Double, Optional SerieLote As String = "-1") - Dim ObjInv As New ClsInventarios - - If CveMovimiento <= 0 Then - CveMovimiento = ObjInv.AddMovimiento(DdlAlmacen.SelectedValue.ToEntero, DdlConcepto.SelectedValue.ToEntero, 1, TxtFecha.Text.ToDate, TxtFolio.Text.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1) - End If - - ObjInv.AddMovimientoDetalle(CveMovimiento, Cantidad, CveUM, CvePS, CostoPromedio, -1, SerieLote:=SerieLote) - ObjInv.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) - DtMovimientos = ObjInv.DtResultados.FiltraParametros("", "CveMovimientoDetalle DESC").AsEnumerable.Take(25).CopyToDataTable - ObjInv.Dispose() - - CargaGVM(DtMovimientos) - - TxtCodigoBarras.Text = "" - TxtCodigo.Text = "" - TxtCodigoSerie.Text = "" - TxtCantidadProducto.Text = "1" - - txtCantidad.Text = "" - LblCodigo.Text = "" - HdnCodigoAF.Value = "-1" - HdnCveActivoFijo.Value = "-1" - - TxtCodigoBarras.Focus() - RegistraScript("beep-07.wav')") - End Sub -#End Region - - -#Region " DdlConcepto, DdlClasificacion, DdlAlmacen | Index CHANGED " - - Protected Sub DdlAlmacen_SelectedIndexChanged(sender As Object, e As EventArgs) - - If EsConsumoInterno Then - Exit Sub - End If - - DdlConcepto.Items.Clear() - - Dim filtro As String = "" - Dim CveTipoAlmacen = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltroPrimeroValor("CveTipoAlmacen", $"CveAlmacen = {DdlAlmacen.SelectedValue}").ToEntero - - filtro = If(UsuarioActual.TienePermisoProceso(144), "CveConcepto NOT IN (1,4,5,8,9,10,12,26,27)", "CveConcepto NOT IN (1,2,4,5,8,9,10,12,26,27)") - - If DdlAlmacen.SelectedValue = "-1" Then - filtro = IIf(UsuarioActual.CveEmpresa.Contiene(72, 1, 80), "CveConcepto NOT IN (4,5,10)", filtro).ToString - Else - filtro = String.Format("{0} AND CveTipoAlmacen = {1}", IIf(UsuarioActual.CveEmpresa.Contiene(72, 1, 80, 4, 7, 11, 12, 135), "CveConcepto NOT IN (4,5,10)", filtro).ToString, CveTipoAlmacen) - End If - - DdlConcepto.DataSource = GlobalDTInvConceptos.FiltraParametros(filtro) - DdlConcepto.DataBind() - - If IsNothing(Request("CveMovimiento")) Then - DdlConcepto.Items.Insert(0, New ListItem("Seleccione", "-1")) - End If - - If Not DdlConcepto.Items.Contains(New ListItem("Seleccione", "-1")) Then - DdlConcepto.Items.Insert(0, New ListItem("Seleccione", "-1")) - End If - - 'PRODUCTOS FINANCIEROS - If CveTipoAlmacen.Contiene(12, 15) Then - If DdlConcepto.Items.FindByValue("1") Is Nothing Then - DdlConcepto.Items.Insert(If(DdlConcepto.Items.Count >= 1, 1, 0), New ListItem(" Inventario Inicial ", "1")) - End If - End If - - 'ACTIVO FIJO - If CveTipoAlmacen = 15 Then - If DdlConcepto.Items.FindByValue("2") Is Nothing Then - DdlConcepto.Items.Insert(If(DdlConcepto.Items.Count >= 2, 2, DdlConcepto.Items.Count), New ListItem("Entrada Almacen ", "2")) - End If - If DdlConcepto.Items.FindByValue("3") Is Nothing Then - DdlConcepto.Items.Insert(If(DdlConcepto.Items.Count >= 3, 3, DdlConcepto.Items.Count), New ListItem("Salida de Almacen", "3")) - End If - End If - - 'cONSUMO INTERNO - If CveTipoAlmacen = 14 Then - If DdlConcepto.Items.FindByValue("2") Is Nothing Then - DdlConcepto.Items.Insert(If(DdlConcepto.Items.Count >= 2, 2, DdlConcepto.Items.Count), New ListItem("Entrada Almacen ", "2")) - End If - - End If - - '[IPP]: PARCHE PARA JAM - If UsuarioActual.CveEmpresa = 119 And CveTipoAlmacen.Contiene(4, 8, 16) Then - If DdlConcepto.Items.FindByValue("2") Is Nothing Then - DdlConcepto.Items.Insert(If(DdlConcepto.Items.Count >= 2, 2, DdlConcepto.Items.Count), New ListItem("Entrada Almacen ", "2")) - End If - If DdlConcepto.Items.FindByValue("3") Is Nothing Then - DdlConcepto.Items.Insert(If(DdlConcepto.Items.Count >= 3, 3, DdlConcepto.Items.Count), New ListItem("Salida de Almacen", "3")) - End If - - End If - - 'tIPO Devolución proveedor - If CveTipoAlmacen.Contiene(21) Then - DdlConcepto.Items.Insert(0, New ListItem("Entrada Almacen ", "2")) - If UsuarioActual.CveUsuario = 100 Then - DdlConcepto.Items.Insert(1, New ListItem("Devolución al Proveedor ", "13")) - End If - End If - - If CveTipoAlmacen.Contiene(22) Then - DdlConcepto.Items.Insert(0, New ListItem("Entrada Almacen ", "2")) - End If - - DdlConcepto.SelectedValue = "-1" - ddlConcepto_SelectedIndexChanged(DdlConcepto, EventArgs.Empty) - - End Sub - - Protected Sub ddlConcepto_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlConcepto.SelectedIndexChanged - - - If CveMovimiento > 0 And Not EsNuevoMov Then - Exit Sub - End If - - If CveMovimiento <= 0 Or EsNuevoMov Then SiguienteFolio() - Dim CveConcepto = DdlConcepto.SelectedValue - - DivCodigoBarras.Visible = False - TxtFecha.Enabled = True - TxtObservaciones.Enabled = True - - DivCliente.Visible = False - DivClienteSucursal.Visible = False - DivDepartamentoEntrega.Visible = False - TxtDepartamentoEntrega.Text = "" - TxtPedidoContrato.Text = "" - - Select Case CveConcepto - Case "1", "2", "22", "32", "33" ' ENTRADAS - DivCodigoBarras.Visible = True - TxtCodigoBarras.Focus() - - If CveMovimiento > 0 Then - TxtFecha.Text = Now.ToShortDateString - TxtFecha.Enabled = False - End If - - VisualizaPU(True) - TrPersonal.Visible = False - TrResponsable.Visible = True - If UsuarioActual.CveEmpresa.Contiene(66, 13) Then - TrSubProyectoActivoFijo.Visible = True - VisualizaAF(True) - CargaSubProyectos() - End If - If GvM.Rows.Count > 0 Then GvM.FooterRow.Visible = True - - Case "3", "11", "21", "31" - VisualizaPU(False) - TrPersonal.Visible = False - TrResponsable.Visible = True - If UsuarioActual.CveEmpresa.Contiene(66, 13) Then - TrSubProyectoActivoFijo.Visible = True - VisualizaAF(True) - CargaSubProyectos() - End If - If GvM.Rows.Count > 0 Then GvM.FooterRow.Visible = False - - If CveConcepto = "3" Then - ActivaClientes() - End If - - Case "7" - VisualizaPU(False) - TrSubProyectoActivoFijo.Visible = False - TrResponsable.Visible = False - CargaPersonal() - If GvM.Rows.Count > 0 Then GvM.FooterRow.Visible = False - Case "10" - VisualizaPU(True) - - Case "28" - TrProveedor.Visible = True - DdlProveedor.DataSource = GlobalDTCompProveedores(UsuarioActual.CveEmpresa) - DdlProveedor.DataBind() - - Case Else - DivCodigoBarras.Visible = False - TrSubProyectoActivoFijo.Visible = False - VisualizaAF(False) - If GvM.Rows.Count > 0 Then GvM.FooterRow.Visible = True - TrPersonal.Visible = False - TrResponsable.Visible = False - End Select - - UpCodigoBarras.Update() - UppGrid.Update() - UPDatos.Update() - End Sub - - Private Sub VisualizaPU(Opcion As Boolean) - tdPU.Visible = Opcion - tdTxtPU.Visible = Opcion - txtPrecio.Visible = Opcion - GvM.Columns(4).Visible = Opcion - - TdTotal.Visible = Opcion - ThTotal.Visible = Opcion - GvM.Columns(5).Visible = Opcion - End Sub - Private Sub VisualizaPUExtranjero(Opcion As Boolean) - tdPUExtranjero.Visible = Opcion - tdPUExtranjero2.Visible = Opcion - GvM.Columns(6).Visible = Opcion - End Sub - Private Sub VisualizaAF(Opcion As Boolean) - tdAF.Visible = Opcion - ThAF.Visible = Opcion - GvM.Columns(8).Visible = Opcion - End Sub - Private Sub SiguienteFolio() - Dim Inv As New ClsInventarios - Dim Folio As Integer = Inv.GetFolioSiguiente(DdlConcepto.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) - Inv.Dispose() - - TxtFolio.Text = Folio.ToString - FolioAsignado = Folio - UPEncabezado.Update() - End Sub - Protected Sub DdlClasificacion_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlClasificacion.SelectedIndexChanged - ChangeDdlProducto() - End Sub - Private Sub ChangeDdlProducto() - If UsuarioActual.Empresa.Funcionalidad(105) = "" Then - Dim filtro As String = "" - If Not (DdlClasificacion.SelectedValue = "-1") Then - - If isWhitFamily() Then - filtro = String.Format("CveSubFamilia={0}", DdlClasificacion.SelectedValue) - Else - filtro = String.Format("CveClasificacion={0}", DdlClasificacion.SelectedValue) - End If - End If - - DdlProducto2.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa).FiltraParametros($"{filtro} AND CveTipoPS = 2", "PSCodigo") - DdlProducto2.DataBind() - DdlProducto2.ddl.Items.Insert(0, New ListItem("Seleccione", "-1")) - Else - If isWhitFamily() Then - DdlProducto2.ddlWS.Attributes.Add("data-idSubFamilia", DdlClasificacion.SelectedValue) - Else - DdlProducto2.ddlWS.Attributes.Add("data-idClasificacion", DdlClasificacion.SelectedValue) - End If - End If - End Sub - - Protected Sub DdlProducto_ValueChanged(sender As Object, e As EventArgs) Handles DdlProducto2.selectedindexchange - ElProductoChange() - End Sub - Private Sub ElProductoChange() - TxtnSerieLote.Visible = False - TxtnLote.Visible = False - TxtnBatch.Visible = False - - EscondeColumnasGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' ")) - - If DdlProducto2.SelectedValue.ToEntero > 0 Then - Dim MetodoInventario As Integer = GlobalDTPS(UsuarioActual.CveEmpresa, DdlProducto2.SelectedValue.ToEntero).FiltroPrimeroValor("Inv_CveMetodoInventario", "").ToEntero ' ("Inv_CveMetodoInventario = 6", "PS") - If MetodoInventario = 5 Then - LblSerieLote.Visible = True - TxtnSerieLote.Visible = True - TrSerieLote.Visible = True - TrSerieLote2.Visible = True - GvM.Columns(9).Visible = True - End If - If MetodoInventario = 6 Then - TxtnLote.Visible = True - TrLote.Visible = True - TrLote2.Visible = True - GvM.Columns(10).Visible = True - - TxtnBatch.Visible = True - TrBatch.Visible = True - TrBatch2.Visible = True - GvM.Columns(11).Visible = True - End If - End If - - DdlUnidad.Items.Clear() - DdlUnidad.DataSource = GlobalDTProductosServiciosEquivalencias(DdlProducto2.SelectedValue.ToEntero, -1, UsuarioActual.CveEmpresa) - DdlUnidad.DataBind() - UPDatos.Update() - End Sub -#End Region - - -#Region " GVM " - Private Sub CargaGVM(DtTemp As DataTable) - GvM.DataSource = DtTemp - GvM.DataBind() - - EscondeColumnasGVM(DtTemp) - End Sub - Private Sub EscondeColumnasGVM(DtTemp As DataTable) - LblSerieLote.Visible = False - TxtnSerieLote.Visible = False - TrSerieLote.Visible = False - TrSerieLote2.Visible = False - - GvM.Columns(9).Visible = False - 'PERMISO SOLO PARA EDITAR SERIELOTE - If UsuarioActual.TienePermisoProceso(245) Then - GvM.Columns(9).Visible = True - End If - - TxtnLote.Visible = False - TrLote.Visible = False - TrLote2.Visible = False - GvM.Columns(10).Visible = False - - TxtnBatch.Visible = False - TrBatch.Visible = False - TrBatch2.Visible = False - GvM.Columns(11).Visible = False - - Dim TienePermisoImportes = UsuarioActual.TienePermisoProceso(201) - tdPUExtranjero.Visible = False - tdPUExtranjero2.Visible = False - GvM.Columns(6).Visible = False - - tdCI.Visible = False - tdCI2.Visible = False - GvM.Columns(7).Visible = False - - If DtTemp IsNot Nothing AndAlso DtTemp.Rows.Count > 0 Then - If DtTemp.MAX("SerieLote").ToString <> "" Then - LblSerieLote.Visible = True - TxtnSerieLote.Visible = True - TrSerieLote.Visible = True - TrSerieLote2.Visible = True - GvM.Columns(9).Visible = True - End If - - If DtTemp.MAX("Lote").ToString <> "" Then - TxtnLote.Visible = True - TrLote.Visible = True - TrLote2.Visible = True - GvM.Columns(10).Visible = True - - TxtnBatch.Visible = True - TrBatch.Visible = True - TrBatch2.Visible = True - GvM.Columns(11).Visible = True - End If - - If DtTemp.SUM("PUExtranjero") > 0 Then - tdPUExtranjero.Visible = TienePermisoImportes - tdPUExtranjero2.Visible = TienePermisoImportes - GvM.Columns(6).Visible = TienePermisoImportes - End If - - If DtTemp.SUM("CostoIndirecto") > 0 Then - tdCI.Visible = TienePermisoImportes - tdCI2.Visible = TienePermisoImportes - GvM.Columns(7).Visible = TienePermisoImportes - End If - End If - - End Sub - Protected Sub GvM_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvM.RowDataBound - Dim TienePermisoImportes As Boolean = UsuarioActual.TienePermisoProceso(201) - - If e.Row.RowType = DataControlRowType.Header Then - LbTotalMovimientos.Text = String.Format("Total de Movimientos: {0}", CType(GvM.DataSource, DataTable).Rows.Count.ToString) - End If - - - If e.Row.RowType = DataControlRowType.Footer Then - - e.Row.FCLiteral("lbTotProducto").Visible = TienePermisoImportes - e.Row.FCLiteral("lbTotPrecio").Visible = TienePermisoImportes - e.Row.FCLiteral("lbTotPrecioExtranjero").Visible = TienePermisoImportes - e.Row.FCLiteral("LtTotCI").Visible = TienePermisoImportes - - If TienePermisoImportes Then - e.Row.FCLiteral("lbTotPrecioExtranjero").Text = DtMovimientos.SUM("TotalExtranjero", "Estatus IN ('','U')").FormatoNumero - e.Row.FCLiteral("LtTotCI").Text = DtMovimientos.SUM("CostoIndirecto", "Estatus IN ('','U')").FormatoNumero - e.Row.FCLiteral("lbTotPrecio").Text = DtMovimientos.SUM("Total", "Estatus IN ('','U')").FormatoNumero - End If - End If - - If e.Row.RowType = DataControlRowType.DataRow Then - - If e.Row.RowState = DataControlRowState.Edit OrElse e.Row.RowState = 5 Then - e.Row.FCTextBox("LblEditCodigo").Attributes.Add("onkeyup", String.Format("EnterAFEdit(event,this,{0},{1});", e.Row.FCHiddenField("HdnCveActivoFijo").ClientID, e.Row.FCHiddenField("HdnCodigoAF").ClientID)) - e.Row.FCTextBox("LblEditCodigo").Attributes.Add("onblur", String.Format("AFBlurEdit(this,{0},{1});", e.Row.FCHiddenField("HdnCveActivoFijo").ClientID, e.Row.FCHiddenField("HdnCodigoAF").ClientID)) - e.Row.FCImage("ImgAF").Attributes.Add("onclick", String.Format("AbrirVentana('/AF/PopUpBuscarAF.aspx?OPCION=OCE&RI={0}',950,600,'N');", e.Row.RowIndex)) - - If UsuarioActual.Empresa.Funcionalidad(147) = "1" Then - e.Row.FCDropDownList("DdlSeccionAlmacen").DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa) - e.Row.FCDropDownList("DdlSeccionAlmacen").DataBind() - e.Row.FCDropDownList("DdlSeccionAlmacen").SelectedValueExist(e.Row.DBCampo("CveSeccionAlmacen")) - End If - - - 'PERMISO SOLO PARA EDITAR OBSERVACIONES - If PermiteGuardarObservacionDetalle() Then - e.Row.FCTextBox("txtPrecio").Enabled = False - e.Row.FCTextBox("LblEditCodigo").Enabled = False - e.Row.FCTextBox("TxtSerieLote").Enabled = False - e.Row.FCTextBox("TxtLote").Enabled = False - e.Row.FCTextBox("TxtBatch").Enabled = False - e.Row.FCDropDownList("DdlSeccionAlmacen").Enabled = False - End If - - 'PERMISO SOLO PARA EDITAR SERIELOTE - If UsuarioActual.TienePermisoProceso(245) Then - If (CveMovimiento > 0) Or (TieneRelacionado > 0 Or CveMovimientoRelacionado > 0) Then 'CveMovimiento > 0 And e.Row.DBCampo("TienePrePoliza").ToEntero > 0 - e.Row.FCTextBox("txtPrecio").Enabled = False - e.Row.FCTextBox("LblEditCodigo").Enabled = False - e.Row.FCTextBox("TxtSerieLote").Enabled = False - e.Row.FCTextBox("TxtLote").Enabled = False - e.Row.FCTextBox("TxtBatch").Enabled = False - e.Row.FCDropDownList("DdlSeccionAlmacen").Enabled = False - e.Row.FCTextBox("txtPrecio").Enabled = False - End If - e.Row.FCTextBox("TxtSerieLote").Enabled = True - End If - - If EsNuevoMov Then - e.Row.FCTextBox("TxtCantidad").Enabled = True - e.Row.FCTextBox("txtPrecio").Enabled = True - End If - - Else - If CveMovimiento > 0 Then - 'DEPENDE PERMISOS HABILITA - e.Row.FCLinkButton("lnkRemove").Visible = PermiteEliminar() - e.Row.FCLinkButton("imgE").Visible = PermiteGuardar() - - If e.Row.DBCampo("CountMovimientoEntradaDetalle").ToEntero > 0 Then - TieneSalida = True - e.Row.FCLinkButton("lnkRemove").Visible = False - e.Row.FCLinkButton("imgE").Visible = False - End If - - 'SI TIENE PREPOLIZAS NO PUEDE EDITAR NI ELIMINAR - If e.Row.DBCampo("TienePrePoliza").ToEntero > 0 Then - e.Row.FCLinkButton("lnkRemove").Visible = False - e.Row.FCLinkButton("imgE").Visible = False - End If - - 'APAGA TODO SI TIENE MOVIMIENTO RELACIONADO - If TieneRelacionado > 0 Or CveMovimientoRelacionado > 0 Then - e.Row.FCLinkButton("lnkRemove").Visible = False - e.Row.FCLinkButton("imgE").Visible = False - End If - - 'PERMISO SOLO PARA EDITAR OBSERVACIONES - If PermiteGuardarObservacionDetalle() Then - e.Row.FCLinkButton("imgE").Visible = True - End If - - 'PERMISO SOLO PARA EDITAR SERIELOTE - If UsuarioActual.TienePermisoProceso(245) Then - e.Row.FCLinkButton("imgE").Visible = True - End If - - If EsNuevoMov Then - e.Row.FCLinkButton("lnkRemove").Visible = True - End If - - End If - - Dim Cantidad = e.Row.FCLiteral("lbCantidad").Text.ToDecimal - If Not UsuarioActual.TienePermisoProceso(265) Or Cantidad <= 1 Or Cantidad Mod 1 <> 0 Then - e.Row.FCLinkButton("lnkDividir").Visible = False - End If - End If - - If DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {e.Row.RowIndex}").SUMD("CantidadSeccionAlmacen") > 0 Then - e.Row.FCLinkButton("imgE").Visible = False - e.Row.FCLinkButton("imgE").ToolTip = "Cuenta con sección almacen" - e.Row.FCLinkButton("lnkRemove").Visible = False - e.Row.FCLinkButton("lnkRemove").ToolTip = "Cuenta con sección almacen" - e.Row.FCLinkButton("lnkDividir").Visible = False - e.Row.FCLinkButton("lnkDividir").ToolTip = "Cuenta con sección almacen" - End If - - End If - End Sub - Protected Sub GvM_RowEditing(sender As Object, e As GridViewEditEventArgs) Handles GvM.RowEditing - GvM.EditIndex = e.NewEditIndex - - CargaGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' ")) - End Sub - Protected Sub GvM_RowCancelingEdit(sender As Object, e As GridViewCancelEditEventArgs) Handles GvM.RowCancelingEdit - GvM.EditIndex = -1 - - CargaGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' ")) - End Sub - Protected Sub GvM_RowUpdating(sender As Object, e As GridViewUpdateEventArgs) Handles GvM.RowUpdating - - Dim Precio As Double = GvM.Rows(e.RowIndex).FCTextBox("TxtPrecio").Text.ToDouble - Dim No As Integer = GvM.Rows(e.RowIndex).DataKey("No").ToEntero - Dim serielote As String = GvM.Rows(e.RowIndex).FCTextBox("TxtSerieLote").Text.Replace(" ", String.Empty) - Dim Observaciones As String = GvM.Rows(e.RowIndex).FCTextBox("TxtObservaciones").Text - Dim CveSeccionAlmacen As Integer = GvM.Rows(e.RowIndex).FCDropDownList("DdlSeccionAlmacen").SelectedValue.ToEntero - Dim SeccionAlmacen As String = GvM.Rows(e.RowIndex).FCDropDownList("DdlSeccionAlmacen").SelectedItem.Text - Dim Cantidad As Double = GvM.Rows(e.RowIndex).FCTextBox("TxtCantidad").Text.ToDouble - Dim Drs As DataRow() = DtMovimientos.Select(String.Format("No = {0}", No)) - - If Drs.Count > 0 Then - Drs(0)("Cantidad") = Cantidad - Drs(0)("PU") = Precio - Drs(0)("Total") = Drs(0)("Cantidad").ToString.ToDouble * Precio - Drs(0)("Estatus") = "U" - Drs(0)("SerieLote") = serielote - Drs(0)("Observaciones") = Observaciones - Drs(0)("CveSeccionAlmacen") = CveSeccionAlmacen - Drs(0)("SeccionAlmacen") = SeccionAlmacen - End If - - DtMovimientos.AcceptChanges() - GvM.EditIndex = -1 - - CargaGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' ")) - - End Sub - Protected Sub DeleteRow(ByVal sender As Object, ByVal e As EventArgs) - Dim lnkRemove As LinkButton = DirectCast(sender, LinkButton) - - - If DtMovimientos.Rows.Count > 0 And lnkRemove.CommandArgument.ToString.Length > 0 Then - Dim i As Integer - i = lnkRemove.CommandArgument.ToString.ToEntero - Dim Drs As DataRow() = DtMovimientos.Select(String.Format("No = {0}", i)) - If Drs.Count > 0 Then - If CveMovimiento > 0 AndAlso Drs(0)("CveMovimientoDetalle").ToString.ToEntero > 0 Then - Drs(0)("Estatus") = "E" - Else - Drs(0).Delete() - End If - - End If - DtMovimientos.AcceptChanges() - End If - - GvM.EditIndex = -1 - - CargaGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' ")) - - End Sub - Protected Sub DividirRow(ByVal sender As Object, ByVal e As EventArgs) - - Dim lnkRemove As LinkButton = DirectCast(sender, LinkButton) - - If DtMovimientos.Rows.Count > 0 And lnkRemove.CommandArgument.ToString.Length > 0 Then - Dim i As Integer - i = lnkRemove.CommandArgument.ToString.ToEntero - Dim Drs As DataRow() = DtMovimientos.Select(String.Format("No = {0}", i)) - If Drs.Count > 0 Then - Dim Cantidad As Integer = Drs(0)("Cantidad").ToString.ToEntero - - Dim CvePS = Drs(0)("CvePS") - Dim Producto = Drs(0)("CodigoPS") - Dim PU = Drs(0)("PU") - Dim CveSeccion = Drs(0)("CveSeccionAlmacen") - - Drs(0)("Cantidad") = "1" - Drs(0)("Total") = PU - Drs(0)("Estatus") = "U" - - For counter As Integer = 1 To Cantidad - 1 - - txtCantidad.Text = "1" - DdlProducto2.SelectedValue = CvePS.ToString - DdlProducto2.SelectedText = Producto.ToString - txtPrecio.Text = PU.ToString - If DdlSeccionAlmacen.Visible = True And CveSeccion.ToString <> "" Then - DdlSeccionAlmacen.SelectedValue = CveSeccion.ToString - End If - - ElProductoChange() - - AgregarPS() - txtPrecio.Text = "" - DdlUnidad.SelectedItem.Text = "" - - Next - - End If - DtMovimientos.AcceptChanges() - End If - - GvM.EditIndex = -1 - - CargaGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' ")) - End Sub -#End Region - - -#Region " CONTABILIZAR " - Protected Sub BtnContabilizar_Click(sender As Object, e As EventArgs) Handles BtnContabilizar.Click - Dim ObjContaAC As ClsContPAQi = Nothing - Dim ObjInventario As New ClsInventarios - ObjInventario.IniciaTransacSQL() 'Inicia la transacción - - 'DEVENGAR - Dim IDPoliza As Integer - Dim ErrorAC = False - Dim TotalPorDevengar As Double = 0 - Dim Folio As String = "" - Dim Fecha As Date = TxtFecha.Text.ToDate - - - 'cuando tiene AC y es salida de almacen, se manda al gasto - If UsuarioActual.Empresa.UsaAC AndAlso DdlConcepto.SelectedValue = "3" Then - - 'Dim Total As Double = 0 - - 'TotalPorDevengar += Total ' GvInv.Rows.Cast(Of GridViewRow)().Sum(Function(Gvr) Math.Round(Gvr.DataKey("PU").ToString.ToDouble, 4) * Math.Round(Gvr.DataKey("CantidadF").ToString.ToDouble, 4)) - - - TotalPorDevengar = Math.Round(TotalPorDevengar, 4) - ObjContaAC = New ClsContPAQi(UsuarioActual.Empresa) - ObjContaAC.IniciaTransacSQL() - - IDPoliza = ObjContaAC.AddPoliza(3, "Salida de Almacen", TotalPorDevengar, TotalPorDevengar, UsuarioActual.CveUsuario, Fecha) - If IDPoliza > 0 Then - - Dim CuentaCargoCOG As Integer - Dim CuentaAbonoAlmacen As Integer = 0 - Dim Importe As Double = DtMovimientos.SUM("Total", "Estatus = ''") - Folio = ObjContaAC.Folio.ToString - - Dim drA As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveAlmacen = {0}", DdlAlmacen.SelectedValue)) - If drA IsNot Nothing Then CuentaAbonoAlmacen = drA("IdCtaContable").ToString.ToEntero - - - If UsuarioActual.CveEmpresa = 48 Then ' APH - CuentaCargoCOG = 1386 - End If - - - If CuentaCargoCOG > 0 AndAlso CuentaAbonoAlmacen > 0 Then - If ObjContaAC.AddMovimiento(IDPoliza, CuentaCargoCOG, False, Importe, "", "", 0, Fecha, "") Then - 'actualizo el idcuenta del presupuesto - If Not ObjContaAC.AddMovimiento(IDPoliza, CuentaAbonoAlmacen, True, Importe, "", "", 0, Fecha, "") Then - ErrorAC = True - End If - Else - ErrorAC = True - End If - End If - - If IDPoliza > 0 Then - ObjInventario.UpdateMovimientoPoliza(IDPoliza, CveMovimiento, UsuarioActual.CveEmpresa) - End If - - Else - ErrorAC = True - End If - - - End If - 'TERMINA: DEVENGAR - - If Not ErrorAC Then - - ObjInventario.Commit() ' aplica los movimientos insertados - If ObjContaAC IsNot Nothing Then ObjContaAC.AjustaPoliza(IDPoliza) : ObjContaAC.Commit() - Alert(String.Format("Movimiento Registrado

Poliza {1}", IDPoliza, Folio), TipoMensaje.MsgInformacion) - UPDatos.Update() - BtnContabilizar.Visible = PermiteContabilizar() - Else - ObjInventario.RollBack() - If ObjContaAC IsNot Nothing Then ObjContaAC.RollBack() - Alert("Error", TipoMensaje.MsgError) - End If - - End Sub -#End Region - - -#Region " VinculaAF " - Protected Sub BtnVinculaAF_Click(sender As Object, e As EventArgs) - If HdnCveActivoFijo.Value.ToEntero = -2 Then - Dim ObjAF As New ClsAF - - If ObjAF.GetActivosFijos(-1, UsuarioActual.CveEmpresa, LblCodigo.Text, "-1", -1, -1, "-1", -1, -1, -1, -1, -1, "", -1) Then - If ObjAF.DtResultados.Rows.Count = 1 Then - HdnCodigoAF.Value = ObjAF.DtResultados.Rows(0)("Codigo").ToString - HdnCveActivoFijo.Value = ObjAF.DtResultados.Rows(0)("CveActivoFijo").ToString - - LblCodigo.Text = HdnCodigoAF.Value - Else - HdnCodigoAF.Value = "-1" - HdnCveActivoFijo.Value = "-1" - LblCodigo.Text = "" - Alert("No se encontró un Activo Fijo con el código proporcionado.", TipoMensaje.MsgAdvertencia) - End If - End If - - ObjAF.Dispose() - Else - LblCodigo.Text = HdnCodigoAF.Value - End If - - LbAgregar.Focus() - - UPDatos.Update() - End Sub - - Protected Sub BtnVinculaAFEdit_Click(sender As Object, e As EventArgs) - If HdnCodAFEdit.Value.Trim = "" Then Exit Sub - - Dim ObjAF As New ClsAF - - If ObjAF.GetActivosFijos(-1, UsuarioActual.CveEmpresa, HdnCodAFEdit.Value, "-1", -1, -1, "-1", -1, -1, -1, -1, -1, "", -1) Then - If ObjAF.DtResultados.Rows.Count = 1 Then - RegistraScript(String.Format("EnterAFEditOK('{0}','{1}');", ObjAF.DtResultados.Rows(0)("CveActivoFijo").ToString, ObjAF.DtResultados.Rows(0)("Codigo").ToString)) - Else - Alert("No se encontró un Activo Fijo con el código proporcionado.", TipoMensaje.MsgAdvertencia) - RegistraScript(String.Format("EnterAFEditOK({0},{1});", "-1", "-1")) - End If - End If - - ObjAF.Dispose() - End Sub -#End Region - - -#Region " TIPO DE CAMBIO " - Protected Sub DdlMonedaTC_SelectedIndexChanged(sender As Object, e As EventArgs) - Select Case DdlMonedaTC.SelectedValue.ToEntero - Case 1 - TrTC1.Visible = False - TrTC2.Visible = False - - For Each Dr As DataRow In DtMovimientos.Rows - Dr("PU") = Dr("PUExtranjero") - Dr("Total") = Dr("PU").ToString.ToDouble * Dr("Cantidad").ToString.ToDouble - Next - - CargaGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' ")) - - 'LtTotal.Text = DtMovimientos.SUM("Total", "").ToString.FormatoNumero - - UPDatos.Update() - - Case 2 - TrTC1.Visible = True - TrTC2.Visible = True - End Select - End Sub - Protected Sub BtnAplicarTC_Click(sender As Object, e As EventArgs) - For Each Dr As DataRow In DtMovimientos.Rows - Dr("PU") = Dr("PUExtranjero").ToString.ToDouble * TxtTipoCambio.Text.ToDouble - Dr("Total") = Dr("PU").ToString.ToDouble * Dr("Cantidad").ToString.ToDouble - Next - - CargaGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' ")) - - 'LtTotal.Text = DtMovimientos.SUM("Total", "").ToString.FormatoNumero - - UPDatos.Update() - End Sub - - - - -#End Region - - -#Region " BITACORA " - Private Sub InicializaBitacoraTemporal() - - DivBitacora.Visible = True - - - If CveMovimiento > 0 Then - CargaEventoBitacora() - Else - DtBitacora = New DataTable - DtBitacora.Columns.Add("FechaIng", GetType(String)) - DtBitacora.Columns.Add("FechaInicio", GetType(String)) - DtBitacora.Columns.Add("Usuario", GetType(String)) - DtBitacora.Columns.Add("CveUsuario", GetType(String)) - DtBitacora.Columns.Add("Descripcion", GetType(String)) - DtBitacora.Columns.Add("Prioridad", GetType(String)) - DtBitacora.Columns.Add("FileExtension", GetType(String)) - DtBitacora.Columns.Add("Archivo", GetType(String)) - DtBitacora.Columns.Add("CveOrdenCompra", GetType(String)) - DtBitacora.Columns.Add("CveEmpresa", GetType(String)) - End If - - End Sub - Private Sub CargaEventoBitacora() - Dim ObjEventoBitacora As New ClsOIEventos() - - If ObjEventoBitacora.GetAgendaBitacora(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveMovimientoAlmacen:=CveMovimiento) Then - 'If ObjEventoBitacora.DtResultados.FiltraParametros("CveTipoEvento IN (6,2) AND CvePrioridad=3").Rows.Count > 0 Then - ' DivEventoUrgente.Visible = True - 'End If - GvBitacora.DataSource = ObjEventoBitacora.DtResultados.FiltraParametros("CveTipoEvento IN (6,2)") - Else - GvBitacora.DataSource = Nothing - End If - - ObjEventoBitacora.Dispose() - - GvBitacora.DataBind() - UPEventoBitacora.Update() - End Sub - Protected Sub BtnGuardarEventoBitacora_Click(sender As Object, e As EventArgs) Handles BtnGuardarEventoBitacora.Click - If CveMovimiento > 0 Then - GuardaBitacora() - Else - AgregaBitacoraTemporal() - End If - End Sub - -#Region " GUARDA TEMPORAL " - Private Sub AgregaBitacoraTemporal() - Dim ObjEventoBitacora As New ClsOIEventos - - 'Archivo - Dim FileExtension As String = "" - Dim Filename As String = "" - Dim Filesgral As List(Of Archivo) = Anexo.getfiles().Archivos - - For Each fileItem As Archivo In Filesgral - FileExtension = IO.Path.GetExtension(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", "") - Filename = fileItem.filename - Next - - Dim Archivo As New System.IO.FileInfo(String.Format("{0}OI\Temp\OI{1}{2}.{3}", UsuarioActual.Empresa.Ruta, UsuarioActual.CveUsuario, Now.ToString("HH-mm"), FileExtension)) - If Archivo.Exists() Then - Archivo.Delete() - 'File.Delete(String.Format("\Empresas\{0}\OI\Temp\OI{1}{2}.{3}", CveEmpresaActual, UsuarioActual.CveUsuario, DtDetalle.Rows.Count, FileExtension)) - End If - - If Filename <> "" Then - Filename.FilesMove(String.Format("OI{0}{1}", UsuarioActual.CveUsuario, Now.ToString("HH-mm")), String.Format("Empresas\{0}\OI\Temp", UsuarioActual.CveEmpresa)) - End If - - - 'AGREGA - Dim Dr = DtBitacora.NewRow - Dr("FechaIng") = Now - Dr("FechaInicio") = "" - Dr("Usuario") = UsuarioActual.Usuario - Dr("CveUsuario") = UsuarioActual.CveUsuario - Dr("Descripcion") = TxtEventoDescripcion.Text.Trim - Dr("Prioridad") = 1 - Dr("Archivo") = If(FileExtension = "", "", $"{UsuarioActual.Empresa.Ruta}OI\Temp\OI{UsuarioActual.CveUsuario}{Now.ToString("HH-mm")}.{FileExtension}") - Dr("FileExtension") = String.Format(".{0}", FileExtension) - Dr("CveOrdenCompra") = -1 - Dr("CveEmpresa") = UsuarioActual.CveEmpresa - DtBitacora.Rows.Add(Dr) - - - 'LIMPIA - TxtEventoDescripcion.Text = "" - 'ChkEventoPrioridad.Checked = False - RegistraScript("$('#ModalBitacora').modal('hide')", "hidemodal") - - CargaEventoBitacoraTemp() - - - End Sub - Private Sub CargaEventoBitacoraTemp() - GvBitacora.DataSource = DtBitacora - GvBitacora.DataBind() - UPAddEventoBitacora.Update() - UPEventoBitacora.Update() - End Sub - Private Function GuardaBitacoraTemporal(ObjEventoBitacora As ClsOIEventos, CveMovimiento As Integer) As Boolean - Dim Retorno = False - Dim Archivo As System.IO.FileInfo = Nothing - - For Each Dr As DataRow In DtBitacora.Rows - If ObjEventoBitacora.AddEventoBitacora(Dr("Descripcion").ToString, Dr("FileExtension").ToString, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveMovimientoAlmacen:=CveMovimiento) Then - Try - If Dr("Archivo").ToString <> "" Then - Archivo = New System.IO.FileInfo(Dr("Archivo").ToString) - If Archivo.Exists() Then - File.Move(Archivo.ToString, String.Format("{0}OI\OI{1}{2}", UsuarioActual.Empresa.Ruta, ObjEventoBitacora.CveEvento.ToString, Archivo.Extension)) - End If - End If - Catch ex As Exception - Retorno = True - Alert("Ocurrió un error al guardar los datos adjuntos de la Bitácora.", TipoMensaje.MsgError) - Exit For - End Try - - Else - Retorno = True - Exit For - End If - Next - - Return Retorno - End Function -#End Region - - -#Region " GUARDA DIRECTO " - Private Sub GuardaBitacora() - Dim ObjEventoBitacora As New ClsOIEventos - - Dim FileExtension As String = "" - Dim Filesgral As List(Of Archivo) = Anexo.getfiles().Archivos - Dim Filename As String = "" - - For Each fileItem As Archivo In Filesgral - FileExtension = IO.Path.GetExtension(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)) '.Replace(".", "") - Filename = fileItem.filename - Next - - Dim descripcion As String = TxtEventoDescripcion.Text.Trim - 'Dim Prioridad As Integer = If(ChkEventoPrioridad.Checked, 3, 1) - - If ObjEventoBitacora.AddEventoBitacora(descripcion, String.Format("{0}", FileExtension), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveMovimientoAlmacen:=CveMovimiento) Then - - If Filename <> "" Then - Filename.FilesMove(String.Format("OI{0}", ObjEventoBitacora.CveEvento.ToString), String.Format("Empresas\{0}\OI", UsuarioActual.CveEmpresa)) - End If - - GvBitacora.DataSource = ObjEventoBitacora.DtResultados - TxtEventoDescripcion.Text = "" - Anexo.Text = "[]" - 'ChkEventoPrioridad.Checked = False - Alert("La bitácora/observación se guardó correctamente", TipoMensaje.MsgInformacion) - RegistraScript("$('#ModalBitacora').modal('hide')", "hidemodal") - - ''obtener el Evento de bitacora para enviar el correo - 'If ObjEventoBitacora.GetEvento(ObjEventoBitacora.CveEvento, UsuarioActual.CveUsuario, CveEmpresaActual) Then - ' If ObjEventoBitacora.DtResultados IsNot Nothing AndAlso ObjEventoBitacora.DtResultados.Rows.Count > 0 Then - ' Dim dr As DataRow = ObjEventoBitacora.DtResultados.Rows(0) - ' EnviarCorreoBitacora(String.Format("{0}, {1} comento: ""{2}""", dr("FechaIng"), dr("Usuario"), dr("Descripcion")), String.Format("http://sig.adsistemas.mx/Empresas/{0}/OI/{1}", CveEmpresaActual, ObjEventoBitacora.Archivo)) - ' End If - 'End If - - End If - - ObjEventoBitacora.Dispose() - GvBitacora.DataBind() - - UPEventoBitacora.Update() - CargaEventoBitacora() - UPAddEventoBitacora.Update() - End Sub - -#End Region - - Protected Sub GVEventoBitacora_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvBitacora.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - If e.Row.DBCampo("Archivo").ToString.Trim <> "" AndAlso CveMovimiento > 0 Then - e.Row.FCLinkButton("LinkArchivo").Visible = True - e.Row.FCLinkButton("LinkArchivo").CommandArgument = String.Format("OI\{0}", e.Row.DBCampo("Archivo").ToString) - ScriptManager.GetCurrent(Me).RegisterPostBackControl(e.Row.FCLinkButton("LinkArchivo")) 'Registro un evento Postbacktrigger, que recargue toda la pagina para que funcione - Else - e.Row.Cells(4).Text = "NO" - End If - End If - End Sub - Protected Sub DownloadFile(ByVal sender As Object, ByVal e As EventArgs) - Dim filePath As String = String.Format("{0}{1}", UsuarioActual.Empresa.Ruta, CType(sender, LinkButton).CommandArgument) - If IO.File.Exists(filePath) Then - Dim Archivo As New System.IO.FileInfo(filePath) - - HttpContext.Current.Response.Clear() - HttpContext.Current.Response.ClearContent() - HttpContext.Current.Response.ContentType = "application/octet-stream" - HttpContext.Current.Response.AppendHeader("Content-disposition", "attachment; filename=" + Path.GetFileName(filePath)) - HttpContext.Current.Response.AddHeader("Content-Length", Archivo.Length.ToString()) - HttpContext.Current.Response.TransmitFile(filePath) - HttpContext.Current.Response.Flush() - HttpContext.Current.Response.End() - - Archivo = Nothing - Else - UPEventoBitacora.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.Trim = "" Then - Exit Sub - End If - - TdSeriePS.Visible = False - - Dim Dr = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimero($"CodigoBarras= '{TxtCodigoPS.Text}'") - If Dr Is Nothing Then - Alert($"No se ha encontrado un producto con el Codigo ""{TxtCodigoPS.Text}"". ", TipoMensaje.MsgAdvertencia, "window.setTimeout(FocusAdd,200);") - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - TxtCodigoPS.Text = "" - Exit Sub - End If - - If Dr("Inv_CveMetodoInventario").ToString.ToEntero = 5 Then - TdSeriePSAdd.Visible = True - TxtSeriePS.Focus() - CvePSSerieLote = Dr("CvePS").ToString.ToEntero - PSSerieLote = Dr("PSCodigo").ToString - CveUMSerieLote = Dr("CveUM").ToString.ToEntero - UMSerieLote = Dr("UnidadMedida").ToString - Exit Sub - End If - - AddNew(Dr("CvePS").ToString.ToEntero, Dr("PSCodigo").ToString, Dr("CveUM").ToString.ToEntero, Dr("UnidadMedida").ToString, 1, Dr("CostoPromedio").ToString.ToDouble, "", "", "", "", "", "", "", -1, "") - - TxtCodigoPS.Text = "" - TxtCodigoPS.Focus() - - End Sub - Protected Sub BtnSeriePSAdd_Click(sender As Object, e As EventArgs) - - If TxtSeriePS.Text.Trim = "" Then - Exit Sub - End If - - AddNew(CvePSSerieLote, PSSerieLote, CveUMSerieLote, UMSerieLote, 1, 0, TxtSeriePS.Text.Trim, "", "", "", "", "", "", -1, "") - - TdSeriePSAdd.Visible = False - TxtSeriePS.Text = "" - TxtCodigoPS.Text = "" - TxtCodigoPS.Focus() - End Sub - -#End Region - - -#Region " CONSUMO INTERNO " - Private Sub ActivaConsumoInterno() - EsConsumoInterno = True - - Panel1.Visible = False - DdlConcepto.Items.Insert(0, New ListItem("Salida por Consumo Interno", "30")) - DdlConcepto.SelectedValue = "30" - DdlAlmacen.AutoPostBack = False - DivFolio1.Visible = False - DivFolio2.Visible = False - DivConcepto1.Visible = False - DivConcepto2.Visible = False - divMonedaSeccion.Visible = False - divGuia.Visible = False - TrResponsable.Visible = False - CargaPersonal() - LtlTitulo.Text = "Consumo Interno" - - 'RECARGA ALMACENES SOLO DE CONSUMO INTERNO - DdlAlmacen.Items.Clear() - DdlAlmacen.DataBind() - Dim dttA As DataTable = Nothing - dttA = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 14) - If UsuarioActual.CveEmpresa = 119 Then - dttA.Merge(GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 1)) - End If - DdlAlmacen.DataSource = dttA 'GlobalDTAlmacen(UsuarioActual.CveEmpresa) - DdlAlmacen.Items.Insert(0, New ListItem("Seleccione", "-1")) - ' DdlAlmacen.SelectedValue = "-1" - DdlAlmacen.DataBind() - If IsNothing(Request("CveMovimiento")) Then - DdlAlmacen.SelectedValueExist(UsuarioActual.CveAlmacen) - End If - - End Sub -#End Region - - -#Region "PAQUETERIA GUIA" - Protected Sub LnkAgregarGuia_Click(sender As Object, e As EventArgs) - RegistraScript(String.Format("AbrirVentana('/General/PopUpPaqueteriasGuias.aspx?CveMovimiento={0}',800,620);", CveMovimiento)) - End Sub - - Protected Sub BtnAgregarGuia_Click(sender As Object, e As EventArgs) - - 'Dim objInventario As New ClsInventarios - - 'If objInventario.AddPaqueteriaGuia(DdlPaqueteria.SelectedValue.ToEntero, CveMovimiento, TxtPaqueteriaGuia.Text.Trim, TxtPaqueteriaNumcajas.Text.ToEntero, TxtPaqueteriaPeso.Text.ToDecimal, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, - ' TxtRastreo.Text.Trim, TxtDimensiones.Text.Trim, TxtFechaEst.Text.Trim) Then - ' CargaGvPaqueteria() - ' LimpiacontrolesPaqueteria() - 'End If - - 'objInventario.Dispose() - - End Sub - - Protected Sub LnkRemovePaqueteriaGuia_Click(sender As Object, e As EventArgs) - - 'Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) - 'Dim CvePaqueteriaGuia As Integer = GvRow.DataKey("CvePaqueteriaGuia").ToString.ToEntero - 'Dim objInventario As New ClsInventarios - - 'If objInventario.RemovePaqueteriaGuia(CvePaqueteriaGuia, UsuarioActual.CveEmpresa) Then - ' CargaGvPaqueteria() - 'End If - - 'objInventario.Dispose() - - End Sub - - Private Sub CargaGvPaqueteria() - - 'Dim objInventario As New ClsInventarios - - 'If objInventario.GetPaqueteriaGuia(CveMovimiento, UsuarioActual.CveEmpresa) Then - ' GvPaqueriaGuias.DataSource = objInventario.DtResultados - - ' If objInventario.DtResultados.Rows.Count > 0 Then - ' BtnAgregarGuia.Attributes.Add("data-toggle", "confirmation") - ' BtnAgregarGuia.Attributes.Add("data-popout", "true") - ' BtnAgregarGuia.Attributes.Add("data-original-title", "¿Está seguro de registrar una nueva guia a la factura?") - ' BtnAgregarGuia.Attributes.Add("data-btn-ok-label", "si") - - ' Else - - ' BtnAgregarGuia.Attributes.Remove("data-toggle") - ' BtnAgregarGuia.Attributes.Remove("data-popout") - ' BtnAgregarGuia.Attributes.Remove("data-original-title") - ' BtnAgregarGuia.Attributes.Remove("data-btn-ok-label") - - - ' End If - - 'Else - ' GvPaqueriaGuias.DataSource = Nothing - 'End If - - 'objInventario.Dispose() - 'GvPaqueriaGuias.DataBind() - 'UpModalGuias.Update() - - End Sub - - Private Sub LimpiacontrolesPaqueteria() - - 'DdlPaqueteria.SelectedIndex = 0 - 'TxtPaqueteriaGuia.Text = "" - 'TxtPaqueteriaNumcajas.Text = "" - 'TxtPaqueteriaPeso.Text = "" - - 'TxtRastreo.Text = "" - 'TxtDimensiones.Text = "" - 'TxtFechaEst.Text = "" - - End Sub - - Protected Sub LnkGuiaPaqueteriaGuia_Click(sender As Object, e As EventArgs) - 'Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) - - 'Dim CvePaqueteriaGuia As Integer = GvRow.DataKey("CvePaqueteriaGuia").ToString.ToEntero - 'Dim NumCajas As String = GvRow.DataKey("NumCajas").ToString - 'Dim Guia As String = GvRow.DataKey("Guia").ToString - 'Dim Peso As String = GvRow.DataKey("Peso").ToString.ToDecimal.ToString("####.00") - 'Dim DTDatosClienteGuia As New DataTable - 'Dim DTMovimientosDetalle As New DataTable - 'Dim CvePaqueteria As Integer = GvRow.DataKey("CvePaqueteria").ToString.ToEntero - 'Dim RutaRdlc As String = Server.MapPath("~") & "\Empresas\Grales\Formatos\GuiasFormato" & CvePaqueteria & ".rdlc" - - 'Dim Rastreo As String = GvRow.DataKey("Rastreo") - 'Dim Dimensiones As String = GvRow.DataKey("Dimensiones") - 'Dim FechaEstimada As String = GvRow.DataKey("FechaEstimada") - 'Dim ValorStimado As Double = 0 - - 'If Not File.Exists(RutaRdlc) Then - ' RutaRdlc = Server.MapPath("~") & "\Empresas\Grales\Formatos\GuiasFormato0.rdlc" - 'End If - - 'RutaRdlc = RutaRdlc.Replace(Server.MapPath("~") & "\", "") - - 'Dim params As New List(Of ReportParameter) - 'Dim ObjInventario As New ClsInventarios - - 'If ObjInventario.GetPaqueteriaGuiasInfoFormato(CveMovimiento, UsuarioActual.CveEmpresa) Then - ' DTDatosClienteGuia = ObjInventario.DtResultados - 'Else - ' ObjInventario.Dispose() - ' Exit Sub - 'End If - - 'If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then - - ' DTMovimientosDetalle = ObjInventario.DtResultados - ' DTMovimientosDetalle.Columns.Add("Peso") - ' DTMovimientosDetalle.Columns.Add("Dimensiones") - ' DTMovimientosDetalle.AcceptChanges() - - ' For Each Drow As DataRow In DTMovimientosDetalle.Rows - ' Drow("Peso") = Peso - ' Drow("Dimensiones") = Dimensiones - ' DTMovimientosDetalle.AcceptChanges() - ' Next - - ' ValorStimado = DtMovimientos.SUM("PU") - ' ObjInventario.Dispose() - 'Else - ' ObjInventario.Dispose() - ' Exit Sub - 'End If - - 'If DTDatosClienteGuia.Rows.Count > 0 Then - ' params.Add(New ReportParameter("NombreComercial", DTDatosClienteGuia.Rows(0)("NombreComercial").ToString)) - ' params.Add(New ReportParameter("Direccion", DTDatosClienteGuia.Rows(0)("Direccion").ToString)) - ' params.Add(New ReportParameter("Colonia", DTDatosClienteGuia.Rows(0)("Colonia").ToString)) - ' params.Add(New ReportParameter("NoExt", DTDatosClienteGuia.Rows(0)("NoExt").ToString)) - ' params.Add(New ReportParameter("NoInt", DTDatosClienteGuia.Rows(0)("NoInt").ToString)) - ' params.Add(New ReportParameter("Localidad", DTDatosClienteGuia.Rows(0)("Localidad").ToString)) - ' params.Add(New ReportParameter("Telefono", DTDatosClienteGuia.Rows(0)("Telefono").ToString)) - ' params.Add(New ReportParameter("RFCCliente", DTDatosClienteGuia.Rows(0)("RFC").ToString)) - ' params.Add(New ReportParameter("CiudadCliente", DTDatosClienteGuia.Rows(0)("Ciudad").ToString)) - 'Else - ' Exit Sub - 'End If - - 'Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta)) - 'Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa) - - 'params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa)) - 'params.Add(New ReportParameter("EmpresaDireccion", UsuarioActual.Empresa.Direccion)) - 'params.Add(New ReportParameter("EmpresaTelefono", UsuarioActual.Empresa.Telefono)) - 'params.Add(New ReportParameter("EmpresaColonia", UsuarioActual.Empresa.Colonia)) - 'params.Add(New ReportParameter("EmpresaLocalidad", UsuarioActual.Empresa.Localidad)) - 'params.Add(New ReportParameter("RFCEmpresa", UsuarioActual.Empresa.RFC)) - 'params.Add(New ReportParameter("CiudadEmpresa", UsuarioActual.Empresa.Ciudad)) - - 'params.Add(New ReportParameter("EmpresaTelefono", UsuarioActual.Empresa.Telefono)) - 'params.Add(New ReportParameter("NumCajas", NumCajas)) - 'params.Add(New ReportParameter("Peso", Peso)) - 'params.Add(New ReportParameter("Guia", Guia)) - - 'params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre)) - 'params.Add(New ReportParameter("FechaImpresion", Now.ToDateTime.ToShortDateString)) - - 'params.Add(New ReportParameter("Anio", Now.Year.ToString)) - 'params.Add(New ReportParameter("Mes", Now.Month.ToString("00"))) - 'params.Add(New ReportParameter("Dia", Now.Day.ToString("00"))) - - 'params.Add(New ReportParameter("Rastreo", Rastreo)) - 'params.Add(New ReportParameter("Dimensiones", Dimensiones)) - 'params.Add(New ReportParameter("FechaEstimada", FechaEstimada)) - - 'If Imagen.Exists Then - ' params.Add(New ReportParameter("LogoPath", logouri)) - 'Else - ' params.Add(New ReportParameter("LogoPath", "")) - 'End If - - 'ImprimirPDF(RutaRdlc, DTMovimientosDetalle, params, $"ReporteGuia_{Now.ToString("yyyyMMddhhmmss")}") - - End Sub - - Private Sub GvPaqueriaGuias_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvPaqueriaGuias.RowDataBound - - 'If e.Row.RowType = DataControlRowType.DataRow Then - ' Dim Lnk As LinkButton = e.Row.FCLinkButton("LnkGuiaPaqueteriaGuia") - ' Dim Destinatario As String = e.Row.DataKey("Mail").ToString - - ' If Destinatario.Length = 0 Then - ' e.Row.FCLinkButton("LnkGuiaPaqueteriaMail").Visible = False - ' Else - ' e.Row.FCLinkButton("LnkGuiaPaqueteriaMail").Attributes.Add("title", "Enviar correo a: " & Destinatario) - ' End If - - ' ScriptManager.GetCurrent(Me).RegisterPostBackControl(Lnk) - 'End If - - End Sub - - Private Sub GvPaqueteriaCreaEnlaces() - - 'For Each GvRow As GridViewRow In GvPaqueriaGuias.Rows - - ' If GvRow.RowType = DataControlRowType.DataRow Then - ' Dim Lnk As LinkButton = GvRow.FCLinkButton("LnkGuiaPaqueteriaGuia") - ' ScriptManager.GetCurrent(Me).RegisterPostBackControl(Lnk) - ' End If - - 'Next - End Sub - - Protected Sub LnkGuiaPaqueteriaMail_Click(sender As Object, e As EventArgs) - - 'Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) - - - - 'Dim SerieFolio As String = GvRow.DataKey("SerieFolio").ToString - 'Dim NombreComercial As String = GvRow.DataKey("NombreComercial").ToString - 'Dim Destinatario As String = GvRow.DataKey("Mail").ToString - 'Dim Paqueteria As String = GvRow.DataKey("Paqueteria").ToString - 'Dim Guia As String = GvRow.DataKey("Guia").ToString - 'Dim Rastreo As String = GvRow.DataKey("Rastreo").ToString - 'Dim CveVenta As Integer = GvRow.DataKey("CveVenta").ToEntero - - 'EnviarCorreoNotificacion(SerieFolio, NombreComercial, Destinatario, Paqueteria, Guia, Rastreo, CveVenta) - - - End Sub - - Private Sub EnviarCorreoNotificacion(SerieFolio As String, NombreComercial As String, Destinatario As String, Paqueteria As String, Guia As String, Rastreo As String, CveVenta As Integer) - - 'Dim Correo As New ClsSisMail() - 'Dim Asunto As String = UsuarioActual.Empresa.NombreCorto & " Envio de pedido: " & SerieFolio - 'Dim Cuerpo As New StringBuilder - - 'Cuerpo.AppendLine($"Estimado {NombreComercial} le informamos que los productos de la factura {SerieFolio} han sido enviados mediante la paquetería {Paqueteria} con Guia {Guia} , Rastreo {Rastreo}.

") - - 'Cuerpo.AppendLine("") - 'Cuerpo.AppendLine("") - - 'For Each Drow As DataRow In DtMovimientos.Rows - ' Cuerpo.AppendLine($"") - 'Next - 'Cuerpo.AppendLine("
CantidadProducto
{Drow("Cantidad").ToString.ToEntero }{Drow("PS").ToString}
") - 'Cuerpo.AppendLine("

Dudas y aclaraciones departamento de ateción al cliente Tel. 2142200.") - - 'Destinatario = "rakcsle.rakcsle@gmail.com" - - 'If Correo.SendMail(UsuarioActual.Empresa, Destinatario, Asunto, Cuerpo.ToString) Then - ' GuardarBitacora(CveVenta, "", "Notificación de envío de productos al cliente") - ' Alert("Correo enviado existosamente a " & Destinatario) - 'Else - ' Alert("Se presento un error al enviar el correo a " & Destinatario) - 'End If - - - End Sub - -#End Region - - -#Region "DDL CLIENTE / CLIENTE SUCURSAL - SELECTED INDEX CHANGED" - Private Sub InicializaClientes() - If UsuarioActual.CveEmpresa.Contiene(72, 80) Then - DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa) - DdlClientes.DataBind() - - DdlClientes.Items.Insert(0, New ListItem("Seleccione", "-1")) - DdlClientes.SelectedValue = "-1" - End If - End Sub - Protected Sub ActivaClientes() - If UsuarioActual.CveEmpresa.Contiene(72, 80) Then - DivCliente.Visible = True - DivDepartamentoEntrega.Visible = True - 'TxtDepartamentoEntrega.Text = "" - End If - - 'If UsuarioActual.CveRol = 1 Then - ' RfvCliente.Enabled = False - 'End If - - End Sub - Protected Sub DdlClientes_SelectedIndexChanged(sender As Object, e As EventArgs) - CambiaCliente() - End Sub - Private Sub CambiaCliente() - DivClienteSucursal.Visible = False - DdlClientesSucursales.Items.Clear() - CargaSucursalesCliente() - End Sub - Protected Sub CargaSucursalesCliente() - DdlClientesSucursales.Enabled = True - Dim ObjCliente As New ClsClientes - If ObjCliente.GetSucursales(DdlClientes.SelectedValue.ToEntero) Then - If ObjCliente.DtResultados.Rows.Count > 0 Then - - DivClienteSucursal.Visible = True - UpGenerales.Update() - - DdlClientesSucursales.DataSource = ObjCliente.DtResultados - DdlClientesSucursales.DataBind() - - DdlClientesSucursales.Items.Insert(0, New ListItem("Seleccione", "-1")) - DdlClientesSucursales.SelectedValue = "-1" - - UpGenerales.Update() - End If - End If - ObjCliente.Dispose() - End Sub - - Private Sub BtnGeneraPrepoliza_Click(sender As Object, e As EventArgs) Handles BtnGeneraPrepoliza.Click - ''PREPOLIZA - SE CAMBIO DE LUGAR EL USO DE ESTA PARTE - Dim ObjInventario As New ClsInventarios - - Dim ErrorMovInv As Boolean = False - Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL()) - - - Dim DtCostos As DataTable = Nothing - Dim ValorInventario As Decimal = 0 - Dim ValorInventarioME As Decimal = 0 - + If UsuarioActual.Empresa.Funcionalidad(342).ToEntero > 0 Then + IdCtaContableOtro = UsuarioActual.Empresa.Funcionalidad(342).ToEntero + End If + Case 13, 29 + CveConceptoContable = 69 + TipoMovtoOtro = True + tValorOtro = -tValorOtro + Dim drr As DataRow = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimero("") + If drr IsNot Nothing Then + CveClasificacion = drr("CveClasificacion").ToString.ToEntero + IdCtaContableOtro = drr("IdCuentaCostos").ToString.ToEntero + End If + + + End Select + + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovtoAlmacen, tValorInventario, TxtObservaciones.Text.Trim, 68, TxtObservaciones.Text.Trim, TxtFecha.Text.ToDate, idCtaContable, -1, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=tValorInventario, CveClasificacion:=CveClasificacion) Then + ErrorMovInv = True + Else + 'Select Case DdlConcepto.SelectedValue.ToEntero + ' Case 30 + 'Dim Dt As DataTable = ObjInventario.DtResultados.FiltraParametros("", "", {"CveClasificacion"}).Copy + 'Dim IdCuentaGasto As Integer = 0 + 'Dim Total As Decimal = 0 + 'For Each Dr As DataRow In Dt.Rows + ' Total = ObjInventario.DtResultados.FiltraParametros($"CveClasificacion = {Dr("CveClasificacion").ToString}").SUM("Total").ToDecimal.RoundSQL() + ' IdCuentaGasto = ObjInventario.DtResultados.FiltraParametros($"CveClasificacion = {Dr("CveClasificacion").ToString}").Rows(0)("IdCuentaGasto").ToString.ToEntero + + ' If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovtoAlmacen, Total, TxtObservaciones.Text.Trim, CveConceptoContable, TxtObservaciones.Text.Trim, TxtFecha.Text.ToDate, IdCuentaGasto, -1, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=Total, CveClasificacion:=Dr("CveClasificacion").ToString.ToEntero, CveSubProyecto:=tCveSubProyecto) Then + ' ErrorMovInv = True + ' End If + 'Next + 'Case Else + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovtoOtro, tValorOtro, TxtObservaciones.Text.Trim, CveConceptoContable, TxtObservaciones.Text.Trim, TxtFecha.Text.ToDate, IdCtaContableOtro, -1, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=tValorOtro, CveSubProyecto:=tCveSubProyecto, CveClasificacion:=CveClasificacion) Then + ErrorMovInv = True + End If + 'End Select + End If + Else + ErrorMovInv = True + End If + + '------------------------------------------------ + If Not ErrorMovInv Then + 'DEVENGAR + Dim TotalPorDevengar As Double = 0 + + 'cuando tiene AC y es salida de almacen, se manda al gasto + If UsuarioActual.Empresa.UsaAC AndAlso (DdlConcepto.SelectedValue = "3") Then + Dim DtII As DataTable = Nothing + Dim TotalDetalle As Double = 0.0 + Dim Importe As Double = DtMovimientos.SUM("Total", "Estatus IN ('','U')") + 'NOTA. CUANDO ES SALIDA, EN AUTOMATICO NO TENEMOS LOS VALORES DE LA SALIDA TODAVIA, Y POR ESO IMPORTE ES CERO, ES RECARGAR CON LOS DATOS YA INSERTADOS + + If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then + DtII = ObjInventario.DtResultados + End If + + TotalPorDevengar += Importe ' GvInv.Rows.Cast(Of GridViewRow)().Sum(Function(Gvr) Math.Round(Gvr.DataKey("PU").ToString.ToDouble, 4) * Math.Round(Gvr.DataKey("CantidadF").ToString.ToDouble, 4)) + TotalPorDevengar = Math.Round(TotalPorDevengar, 4) + ObjContaAC = New ClsContPAQi(UsuarioActual.Empresa) + ObjContaAC.IniciaTransacSQL() + + Dim AC As New ClsAC + Dim DtPresupuestos As DataTable = Nothing + If AC.GetPresupuestoEgresos(-1, True, UsuarioActual.Empresa.EjercicioActual, UsuarioActual.CveEmpresa) Then + DtPresupuestos = AC.DtResultados.Copy + Else + Alert("Ocurrió un error al cargar los Presupuestos. Por favor vuelva a cargar la página", TipoMensaje.MsgError) + RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") + End If + AC.Dispose() + + IDPoliza = ObjContaAC.AddPoliza(3, "Salida de Almacen", TotalPorDevengar, TotalPorDevengar, UsuarioActual.CveUsuario, TxtFecha.Text.ToDate) + + If IDPoliza > 0 Then + Dim CuentaCargoCOG As Integer + Dim CuentaAbonoAlmacen As Integer = 0 + Dim drA As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveAlmacen = {0}", DdlAlmacen.SelectedValue)) + + If drA IsNot Nothing Then CuentaAbonoAlmacen = drA("IdCtaContable").ToString.ToEntero + + ''For Each gvr As GridViewRow In GvAC.Rows + 'For Each Dr As DataRow In DtII.Rows + ' Importe = Dr("Cantidad").ToString.ToDouble * Dr("PU").ToString.ToDouble ' gvr.FCTextBox("TxtImporte").Text.ToDouble + ' TotalDetalle += Importe + + + 'saco de que partida se va a descontar y se enviara a gasto + ' Dim drP As DataRow = DtPresupuestos.FiltroPrimero(String.Format("CveClasificacion = {0}", Dr("CveClasificacion"))) + ' If drP IsNot Nothing Then CuentaCargoCOG = drP("IdCuentaMatriz").ToString.ToEntero + + If UsuarioActual.CveEmpresa = 48 Then ' APH + CuentaCargoCOG = 1386 + End If + + Dim ConceptoRenglon As String = "Salida de Almacen" + + If IDPoliza > 0 Then + If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then + Dim DtMovtos = ObjInventario.DtResultados + Importe = DtMovtos.SUM("Total", "Estatus = ''") + + If Importe > 0 Then + If CuentaCargoCOG > 0 AndAlso CuentaAbonoAlmacen > 0 Then + If ObjContaAC.AddMovimiento(IDPoliza, CuentaCargoCOG, False, Importe, "", ConceptoRenglon, 0, TxtFecha.Text.ToDate, "") Then + 'actualizo el idcuenta del presupuesto + If Not ObjContaAC.AddMovimiento(IDPoliza, CuentaAbonoAlmacen, True, Importe, "", ConceptoRenglon, 0, TxtFecha.Text.ToDate, "") Then + ErrorAC = True + Mensaje = "No se pudo insertar movimiento en la poliza 2." + End If + Else + ErrorAC = True + Mensaje = "No se pudo insertar movimiento en la poliza 1." + End If + End If + End If + + + End If + End If + + If IDPoliza > 0 Then + ObjInventario.UpdateMovimientoPoliza(IDPoliza, CveMovimiento, UsuarioActual.CveEmpresa) + End If + + Else + ErrorAC = True + Mensaje = "No se pudo insertar la poliza" + End If + End If + 'TERMINA: DEVENGAR + + + ''PREPOLIZA - SE CAMBIO DE LUGAR EL USO DE ESTA PARTE + 'If EsConsumoInterno Then + ' If Not ErrorAC And Not ErrorMovInv Then + ' 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 IdCtaContable As Integer = 0 + + ' If tmpCostos.Rows.Count > 0 Then + ' Dim Concepto As String = $"Consumo Interno: {ObjInventario.Folio} - {TxtObservaciones.Text}" + ' Dim CvePrePoliza = ObjConta.AddPrePolizas("Inv/ConsumoInterno", 53, DtCostos.SUM("Total"), DtCostos.SUM("Total"), 1, TxtFecha.Text.ToDate, $"Consumo Interno: {TxtObservaciones.Text}", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + + ' For Each RowInv As DataRow In tmpCostos.Rows + ' ValorInventario = DtCostos.SUM("Total", $"CveClasificacion = {RowInv("CveClasificacion")}").ToString.ToDecimal + ' IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaGasto", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero + + ' If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ValorInventario, Concepto, 6, Concepto, TxtFecha.Text.ToDate, IdCtaContable, -1, CveClasificacion:=RowInv("CveClasificacion").ToString.ToEntero, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=ValorInventario) Then + ' ErrorMovInv = True + ' Exit For + ' End If + + ' Next + + ' IdCtaContable = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", $"CveAlmacen={DdlAlmacen.SelectedValue.ToEntero}").ToEntero + ' If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, DtCostos.SUM("Total"), Concepto, 68, Concepto, TxtFecha.Text.ToDate, IdCtaContable, -1, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=DtCostos.SUM("Total")) Then + ' ErrorMovInv = True + ' End If + ' End If + ' End If + + ' End If + 'End If + + + If Not ErrorAC And Not ErrorMovInv Then + Dim Msg As New StringBuilder + Msg.AppendFormat("
El Movimiento se registro con el Folio: {0}", ObjInventario.Folio) + Msg.AppendFormat("

Imprimir Movimiento ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimiento))) + + If ObjContaAC IsNot Nothing Then ObjContaAC.AjustaPoliza(IDPoliza) + If IDPoliza > 0 Then Msg = Msg.AppendFormat("

Ver Póliza", IDPoliza) + + ObjInventario.Commit() ' aplica los movimientos insertados + If ObjContaAC IsNot Nothing Then ObjContaAC.Commit() + + Alert(Msg.ToString, TipoMensaje.MsgInformacion) + + 'Limpia Valores cuando inserta de campos especiales + If UsuarioActual.CveEmpresa = 66 Then + DdlSubProyecto.SelectedValueExist("-1") + UPEncabezado.Update() + End If + + UPDatos.Update() + + + If UsuarioActual.TienePermisoProceso(139) Then + CargaDatos(CveMovimiento) + Else + LimpiarMovimiento() + End If + DtSeccionAlmacen.Rows.Clear() + RegistraScript("playsonidito('beep-07.wav')") + Else + ObjInventario.RollBack() + CveMovimiento = 0 + If ObjContaAC IsNot Nothing Then ObjContaAC.RollBack() + Alert(Mensaje, TipoMensaje.MsgError) + RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") + End If + + + Else + ObjInventario.RollBack() 'deshace lo insertado + CveMovimiento = 0 + If ObjContaAC IsNot Nothing Then ObjContaAC.RollBack() + Alert("ocurrió un Error al registrar los movimientos", TipoMensaje.MsgError) + RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") + End If + + End If + + CargaGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' ")) + + End If + + + Catch ex As Exception + Try 'por si ya le habian dado rollback o commit + ObjInventario.RollBack() 'deshace lo insertad + Catch exx As Exception + + End Try + CveMovimiento = 0 + If ObjContaAC IsNot Nothing Then ObjContaAC.RollBack() + Alert("Ocurrió un Error inesperado en el registro" & ex.Message, TipoMensaje.MsgError) + GuardaLog("Ocurrió un Error inesperado en el registro" & ex.ToString()) + RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") + End Try + + ObjInventario.Dispose() 'elimino la instancia + If ObjContaAC IsNot Nothing Then ObjContaAC.Dispose() + + Else + Alert("No hay ningun registro para generar el movimiento. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgError) + RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") + End If + + EsNuevoMov = False + End Sub + +#End Region + + +#Region " ADD INVENTARIO INICIAL " + Protected Sub BtnCodigoBarras_Click(sender As Object, e As EventArgs) + + If TxtCodigoBarras.Text = "" Then + Exit Sub + End If + + TdSeriePS.Visible = False + + Dim DrPS = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimero($"CodigoBarras= '{TxtCodigoBarras.Text}'") + If DrPS Is Nothing Then + Alert($"No se ha encontrado un producto del Codigo ""{TxtCodigoBarras.Text}"". ", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus,200);") + RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") + TxtCodigoBarras.Text = "" + Exit Sub + End If + + If DrPS("Inv_CveMetodoInventario").ToString.ToEntero = 5 Then + TdSeriePS.Visible = True + TxtCodigoSerie.Focus() + CvePSSerieLote = DrPS("CvePS").ToString.ToEntero + CveUMSerieLote = DrPS("CveUnidadMedida").ToString.ToEntero + CostoPromedioSerieLote = DrPS("CostoPromedio").ToString.ToDecimal + Exit Sub + End If + + GuardaCodigoSerie(TxtCantidadProducto.Text.ToDouble, DrPS("CvePS").ToString.ToEntero, DrPS("CveUnidadMedida").ToString.ToEntero, DrPS("CostoPromedio").ToString.ToDecimal) + + TxtCodigoBarras.Text = "" + TxtCodigoBarras.Focus() + End Sub + Protected Sub BtnSeriePS_Click(sender As Object, e As EventArgs) + If TxtCodigoSerie.Text.Trim = "" Then TxtCodigoSerie.Focus() : Exit Sub + + GuardaCodigoSerie(1, CvePSSerieLote, CveUMSerieLote, CostoPromedioSerieLote, TxtCodigoSerie.Text.Trim) + + TdSeriePS.Visible = False + End Sub + Public Sub BtnAddCodigo_Click(sender As Object, e As EventArgs) Handles BtnAddCodigo.Click + + If TxtCodigo.Text.Trim = "" And TxtCodigoBarras.Text.Trim = "" Then + Exit Sub + End If + + Dim DrP As DataRow = Nothing + + If TxtCodigo.Text.Trim <> String.Empty Then + DrP = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimero($" Codigo = '{TxtCodigo.Text.Trim}'") + ElseIf TxtCodigoBarras.Text.Trim <> String.Empty Then + DrP = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimero($" CodigoBarras = '{TxtCodigoBarras.Text.Trim}'") + End If + + + + Dim Costo As Decimal = TxtAltaCosto.Text.ToDecimal + + If DrP IsNot Nothing AndAlso DrP("CvePS").ToString.ToEntero > 0 Then + GuardaCodigoSerie(TxtCantidadProducto.Text.ToDouble, DrP("CvePS").ToString.ToEntero, DrP("CveUnidadMedida").ToString.ToEntero, Costo) + Else + Alert("No se encontró el producto. Favor de verificar y volver a intentar.", TipoMensaje.MsgError, "window.setTimeout(Focus2,200);") + End If + + End Sub + + Private Sub GuardaCodigoSerie(Cantidad As Double, CvePS As Integer, CveUM As Integer, CostoPromedio As Decimal, Optional SerieLote As String = "-1") + Dim ObjInv As New ClsInventarios + + If CveMovimiento <= 0 Then + CveMovimiento = ObjInv.AddMovimiento(DdlAlmacen.SelectedValue.ToEntero, DdlConcepto.SelectedValue.ToEntero, 1, TxtFecha.Text.ToDate, TxtFolio.Text.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1) + End If + + ObjInv.AddMovimientoDetalle(CveMovimiento, Cantidad, CveUM, CvePS, CostoPromedio, -1, SerieLote:=SerieLote) + ObjInv.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) + DtMovimientos = ObjInv.DtResultados.FiltraParametros("", "CveMovimientoDetalle DESC").AsEnumerable.Take(25).CopyToDataTable + ObjInv.Dispose() + + CargaGVM(DtMovimientos) + + TxtCodigoBarras.Text = "" + TxtCodigo.Text = "" + TxtCodigoSerie.Text = "" + TxtCantidadProducto.Text = "1" + + txtCantidad.Text = "" + LblCodigo.Text = "" + HdnCodigoAF.Value = "-1" + HdnCveActivoFijo.Value = "-1" + + TxtCodigoBarras.Focus() + RegistraScript("beep-07.wav')") + End Sub +#End Region + + +#Region " DdlConcepto, DdlClasificacion, DdlAlmacen | Index CHANGED " + + Protected Sub DdlAlmacen_SelectedIndexChanged(sender As Object, e As EventArgs) + + If EsConsumoInterno Then + Exit Sub + End If + + DdlConcepto.Items.Clear() + + Dim filtro As String = "" + Dim CveTipoAlmacen = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltroPrimeroValor("CveTipoAlmacen", $"CveAlmacen = {DdlAlmacen.SelectedValue}").ToEntero + + filtro = If(UsuarioActual.TienePermisoProceso(144), "CveConcepto NOT IN (1,4,5,8,9,10,12,26,27)", "CveConcepto NOT IN (1,2,4,5,8,9,10,12,26,27)") + + If DdlAlmacen.SelectedValue = "-1" Then + filtro = IIf(UsuarioActual.CveEmpresa.Contiene(72, 1, 80), "CveConcepto NOT IN (4,5,10)", filtro).ToString + Else + filtro = String.Format("{0} AND CveTipoAlmacen = {1}", IIf(UsuarioActual.CveEmpresa.Contiene(72, 1, 80, 4, 7, 11, 12, 135), "CveConcepto NOT IN (4,5,10)", filtro).ToString, CveTipoAlmacen) + End If + + DdlConcepto.DataSource = GlobalDTInvConceptos.FiltraParametros(filtro) + DdlConcepto.DataBind() + + If IsNothing(Request("CveMovimiento")) Then + DdlConcepto.Items.Insert(0, New ListItem("Seleccione", "-1")) + End If + + If Not DdlConcepto.Items.Contains(New ListItem("Seleccione", "-1")) Then + DdlConcepto.Items.Insert(0, New ListItem("Seleccione", "-1")) + End If + + 'PRODUCTOS FINANCIEROS + If CveTipoAlmacen.Contiene(12, 15) Then + If DdlConcepto.Items.FindByValue("1") Is Nothing Then + DdlConcepto.Items.Insert(If(DdlConcepto.Items.Count >= 1, 1, 0), New ListItem(" Inventario Inicial ", "1")) + End If + End If + + 'ACTIVO FIJO + If CveTipoAlmacen = 15 Then + If DdlConcepto.Items.FindByValue("2") Is Nothing Then + DdlConcepto.Items.Insert(If(DdlConcepto.Items.Count >= 2, 2, DdlConcepto.Items.Count), New ListItem("Entrada Almacen ", "2")) + End If + If DdlConcepto.Items.FindByValue("3") Is Nothing Then + DdlConcepto.Items.Insert(If(DdlConcepto.Items.Count >= 3, 3, DdlConcepto.Items.Count), New ListItem("Salida de Almacen", "3")) + End If + End If + + 'cONSUMO INTERNO + If CveTipoAlmacen = 14 Then + If DdlConcepto.Items.FindByValue("2") Is Nothing Then + DdlConcepto.Items.Insert(If(DdlConcepto.Items.Count >= 2, 2, DdlConcepto.Items.Count), New ListItem("Entrada Almacen ", "2")) + End If + + End If + + '[IPP]: PARCHE PARA JAM + If UsuarioActual.CveEmpresa = 119 And CveTipoAlmacen.Contiene(4, 8, 16) Then + If DdlConcepto.Items.FindByValue("2") Is Nothing Then + DdlConcepto.Items.Insert(If(DdlConcepto.Items.Count >= 2, 2, DdlConcepto.Items.Count), New ListItem("Entrada Almacen ", "2")) + End If + If DdlConcepto.Items.FindByValue("3") Is Nothing Then + DdlConcepto.Items.Insert(If(DdlConcepto.Items.Count >= 3, 3, DdlConcepto.Items.Count), New ListItem("Salida de Almacen", "3")) + End If + + End If + + 'tIPO Devolución proveedor + If CveTipoAlmacen.Contiene(21) Then + DdlConcepto.Items.Insert(0, New ListItem("Entrada Almacen ", "2")) + If UsuarioActual.CveUsuario = 100 Then + DdlConcepto.Items.Insert(1, New ListItem("Devolución al Proveedor ", "13")) + End If + End If + + If CveTipoAlmacen.Contiene(22) Then + DdlConcepto.Items.Insert(0, New ListItem("Entrada Almacen ", "2")) + End If + + DdlConcepto.SelectedValue = "-1" + ddlConcepto_SelectedIndexChanged(DdlConcepto, EventArgs.Empty) + + End Sub + + Protected Sub ddlConcepto_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlConcepto.SelectedIndexChanged + + + If CveMovimiento > 0 And Not EsNuevoMov Then + Exit Sub + End If + + If CveMovimiento <= 0 Or EsNuevoMov Then SiguienteFolio() + Dim CveConcepto = DdlConcepto.SelectedValue + + DivCodigoBarras.Visible = False + TxtFecha.Enabled = True + TxtObservaciones.Enabled = True + + DivCliente.Visible = False + DivClienteSucursal.Visible = False + DivDepartamentoEntrega.Visible = False + TxtDepartamentoEntrega.Text = "" + TxtPedidoContrato.Text = "" + + Select Case CveConcepto + Case "1", "2", "22", "32", "33" ' ENTRADAS + DivCodigoBarras.Visible = True + TxtCodigoBarras.Focus() + + If CveMovimiento > 0 Then + TxtFecha.Text = Now.ToShortDateString + TxtFecha.Enabled = False + End If + + VisualizaPU(True) + TrPersonal.Visible = False + TrResponsable.Visible = True + If UsuarioActual.CveEmpresa.Contiene(66, 13) Then + TrSubProyectoActivoFijo.Visible = True + VisualizaAF(True) + CargaSubProyectos() + End If + If GvM.Rows.Count > 0 Then GvM.FooterRow.Visible = True + + Case "3", "11", "21", "31" + VisualizaPU(False) + TrPersonal.Visible = False + TrResponsable.Visible = True + If UsuarioActual.CveEmpresa.Contiene(66, 13) Then + TrSubProyectoActivoFijo.Visible = True + VisualizaAF(True) + CargaSubProyectos() + End If + If GvM.Rows.Count > 0 Then GvM.FooterRow.Visible = False + + If CveConcepto = "3" Then + ActivaClientes() + End If + + Case "7" + VisualizaPU(False) + TrSubProyectoActivoFijo.Visible = False + TrResponsable.Visible = False + CargaPersonal() + If GvM.Rows.Count > 0 Then GvM.FooterRow.Visible = False + Case "10" + VisualizaPU(True) + + Case "28" + TrProveedor.Visible = True + DdlProveedor.DataSource = GlobalDTCompProveedores(UsuarioActual.CveEmpresa) + DdlProveedor.DataBind() + + Case Else + DivCodigoBarras.Visible = False + TrSubProyectoActivoFijo.Visible = False + VisualizaAF(False) + If GvM.Rows.Count > 0 Then GvM.FooterRow.Visible = True + TrPersonal.Visible = False + TrResponsable.Visible = False + End Select + + UpCodigoBarras.Update() + UppGrid.Update() + UPDatos.Update() + End Sub + + Private Sub VisualizaPU(Opcion As Boolean) + tdPU.Visible = Opcion + tdTxtPU.Visible = Opcion + txtPrecio.Visible = Opcion + GvM.Columns(4).Visible = Opcion + + TdTotal.Visible = Opcion + ThTotal.Visible = Opcion + GvM.Columns(5).Visible = Opcion + End Sub + Private Sub VisualizaPUExtranjero(Opcion As Boolean) + tdPUExtranjero.Visible = Opcion + tdPUExtranjero2.Visible = Opcion + GvM.Columns(6).Visible = Opcion + End Sub + Private Sub VisualizaAF(Opcion As Boolean) + tdAF.Visible = Opcion + ThAF.Visible = Opcion + GvM.Columns(8).Visible = Opcion + End Sub + Private Sub SiguienteFolio() + Dim Inv As New ClsInventarios + Dim Folio As Integer = Inv.GetFolioSiguiente(DdlConcepto.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) + Inv.Dispose() + + TxtFolio.Text = Folio.ToString + FolioAsignado = Folio + UPEncabezado.Update() + End Sub + Protected Sub DdlClasificacion_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlClasificacion.SelectedIndexChanged + ChangeDdlProducto() + End Sub + Private Sub ChangeDdlProducto() + If UsuarioActual.Empresa.Funcionalidad(105) = "" Then + Dim filtro As String = "" + If Not (DdlClasificacion.SelectedValue = "-1") Then + + If isWhitFamily() Then + filtro = String.Format("CveSubFamilia={0}", DdlClasificacion.SelectedValue) + Else + filtro = String.Format("CveClasificacion={0}", DdlClasificacion.SelectedValue) + End If + End If + + DdlProducto2.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa).FiltraParametros($"{filtro} AND CveTipoPS = 2", "PSCodigo") + DdlProducto2.DataBind() + DdlProducto2.ddl.Items.Insert(0, New ListItem("Seleccione", "-1")) + Else + If isWhitFamily() Then + DdlProducto2.ddlWS.Attributes.Add("data-idSubFamilia", DdlClasificacion.SelectedValue) + Else + DdlProducto2.ddlWS.Attributes.Add("data-idClasificacion", DdlClasificacion.SelectedValue) + End If + End If + End Sub + + Protected Sub DdlProducto_ValueChanged(sender As Object, e As EventArgs) Handles DdlProducto2.selectedindexchange + ElProductoChange() + End Sub + Private Sub ElProductoChange() + TxtnSerieLote.Visible = False + TxtnLote.Visible = False + TxtnBatch.Visible = False + + EscondeColumnasGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' ")) + + If DdlProducto2.SelectedValue.ToEntero > 0 Then + Dim MetodoInventario As Integer = GlobalDTPS(UsuarioActual.CveEmpresa, DdlProducto2.SelectedValue.ToEntero).FiltroPrimeroValor("Inv_CveMetodoInventario", "").ToEntero ' ("Inv_CveMetodoInventario = 6", "PS") + If MetodoInventario = 5 Then + LblSerieLote.Visible = True + TxtnSerieLote.Visible = True + TrSerieLote.Visible = True + TrSerieLote2.Visible = True + GvM.Columns(9).Visible = True + End If + If MetodoInventario = 6 Then + TxtnLote.Visible = True + TrLote.Visible = True + TrLote2.Visible = True + GvM.Columns(10).Visible = True + + TxtnBatch.Visible = True + TrBatch.Visible = True + TrBatch2.Visible = True + GvM.Columns(11).Visible = True + End If + End If + + DdlUnidad.Items.Clear() + DdlUnidad.DataSource = GlobalDTProductosServiciosEquivalencias(DdlProducto2.SelectedValue.ToEntero, -1, UsuarioActual.CveEmpresa) + DdlUnidad.DataBind() + UPDatos.Update() + End Sub +#End Region + + +#Region " GVM " + Private Sub CargaGVM(DtTemp As DataTable) + GvM.DataSource = DtTemp + GvM.DataBind() + + EscondeColumnasGVM(DtTemp) + End Sub + Private Sub EscondeColumnasGVM(DtTemp As DataTable) + LblSerieLote.Visible = False + TxtnSerieLote.Visible = False + TrSerieLote.Visible = False + TrSerieLote2.Visible = False + + GvM.Columns(9).Visible = False + 'PERMISO SOLO PARA EDITAR SERIELOTE + If UsuarioActual.TienePermisoProceso(245) Then + GvM.Columns(9).Visible = True + End If + + TxtnLote.Visible = False + TrLote.Visible = False + TrLote2.Visible = False + GvM.Columns(10).Visible = False + + TxtnBatch.Visible = False + TrBatch.Visible = False + TrBatch2.Visible = False + GvM.Columns(11).Visible = False + + Dim TienePermisoImportes = UsuarioActual.TienePermisoProceso(201) + tdPUExtranjero.Visible = False + tdPUExtranjero2.Visible = False + GvM.Columns(6).Visible = False + + tdCI.Visible = False + tdCI2.Visible = False + GvM.Columns(7).Visible = False + + If DtTemp IsNot Nothing AndAlso DtTemp.Rows.Count > 0 Then + If DtTemp.MAX("SerieLote").ToString <> "" Then + LblSerieLote.Visible = True + TxtnSerieLote.Visible = True + TrSerieLote.Visible = True + TrSerieLote2.Visible = True + GvM.Columns(9).Visible = True + End If + + If DtTemp.MAX("Lote").ToString <> "" Then + TxtnLote.Visible = True + TrLote.Visible = True + TrLote2.Visible = True + GvM.Columns(10).Visible = True + + TxtnBatch.Visible = True + TrBatch.Visible = True + TrBatch2.Visible = True + GvM.Columns(11).Visible = True + End If + + If DtTemp.SUM("PUExtranjero") > 0 Then + tdPUExtranjero.Visible = TienePermisoImportes + tdPUExtranjero2.Visible = TienePermisoImportes + GvM.Columns(6).Visible = TienePermisoImportes + End If + + If DtTemp.SUM("CostoIndirecto") > 0 Then + tdCI.Visible = TienePermisoImportes + tdCI2.Visible = TienePermisoImportes + GvM.Columns(7).Visible = TienePermisoImportes + End If + End If + + End Sub + Protected Sub GvM_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvM.RowDataBound + Dim TienePermisoImportes As Boolean = UsuarioActual.TienePermisoProceso(201) + + If e.Row.RowType = DataControlRowType.Header Then + LbTotalMovimientos.Text = String.Format("Total de Movimientos: {0}", CType(GvM.DataSource, DataTable).Rows.Count.ToString) + End If + + + If e.Row.RowType = DataControlRowType.Footer Then + + e.Row.FCLiteral("lbTotProducto").Visible = TienePermisoImportes + e.Row.FCLiteral("lbTotPrecio").Visible = TienePermisoImportes + e.Row.FCLiteral("lbTotPrecioExtranjero").Visible = TienePermisoImportes + e.Row.FCLiteral("LtTotCI").Visible = TienePermisoImportes + + If TienePermisoImportes Then + e.Row.FCLiteral("lbTotPrecioExtranjero").Text = DtMovimientos.SUM("TotalExtranjero", "Estatus IN ('','U')").FormatoNumero + e.Row.FCLiteral("LtTotCI").Text = DtMovimientos.SUM("CostoIndirecto", "Estatus IN ('','U')").FormatoNumero + e.Row.FCLiteral("lbTotPrecio").Text = DtMovimientos.SUM("Total", "Estatus IN ('','U')").FormatoNumero + End If + End If + + If e.Row.RowType = DataControlRowType.DataRow Then + + If e.Row.RowState = DataControlRowState.Edit OrElse e.Row.RowState = 5 Then + e.Row.FCTextBox("LblEditCodigo").Attributes.Add("onkeyup", String.Format("EnterAFEdit(event,this,{0},{1});", e.Row.FCHiddenField("HdnCveActivoFijo").ClientID, e.Row.FCHiddenField("HdnCodigoAF").ClientID)) + e.Row.FCTextBox("LblEditCodigo").Attributes.Add("onblur", String.Format("AFBlurEdit(this,{0},{1});", e.Row.FCHiddenField("HdnCveActivoFijo").ClientID, e.Row.FCHiddenField("HdnCodigoAF").ClientID)) + e.Row.FCImage("ImgAF").Attributes.Add("onclick", String.Format("AbrirVentana('/AF/PopUpBuscarAF.aspx?OPCION=OCE&RI={0}',950,600,'N');", e.Row.RowIndex)) + + If UsuarioActual.Empresa.Funcionalidad(147) = "1" Then + e.Row.FCDropDownList("DdlSeccionAlmacen").DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa) + e.Row.FCDropDownList("DdlSeccionAlmacen").DataBind() + e.Row.FCDropDownList("DdlSeccionAlmacen").SelectedValueExist(e.Row.DBCampo("CveSeccionAlmacen")) + End If + + + 'PERMISO SOLO PARA EDITAR OBSERVACIONES + If PermiteGuardarObservacionDetalle() Then + e.Row.FCTextBox("txtPrecio").Enabled = False + e.Row.FCTextBox("LblEditCodigo").Enabled = False + e.Row.FCTextBox("TxtSerieLote").Enabled = False + e.Row.FCTextBox("TxtLote").Enabled = False + e.Row.FCTextBox("TxtBatch").Enabled = False + e.Row.FCDropDownList("DdlSeccionAlmacen").Enabled = False + End If + + 'PERMISO SOLO PARA EDITAR SERIELOTE + If UsuarioActual.TienePermisoProceso(245) Then + If (CveMovimiento > 0) Or (TieneRelacionado > 0 Or CveMovimientoRelacionado > 0) Then 'CveMovimiento > 0 And e.Row.DBCampo("TienePrePoliza").ToEntero > 0 + e.Row.FCTextBox("txtPrecio").Enabled = False + e.Row.FCTextBox("LblEditCodigo").Enabled = False + e.Row.FCTextBox("TxtSerieLote").Enabled = False + e.Row.FCTextBox("TxtLote").Enabled = False + e.Row.FCTextBox("TxtBatch").Enabled = False + e.Row.FCDropDownList("DdlSeccionAlmacen").Enabled = False + e.Row.FCTextBox("txtPrecio").Enabled = False + End If + e.Row.FCTextBox("TxtSerieLote").Enabled = True + End If + + If EsNuevoMov Then + e.Row.FCTextBox("TxtCantidad").Enabled = True + e.Row.FCTextBox("txtPrecio").Enabled = True + End If + + Else + If CveMovimiento > 0 Then + 'DEPENDE PERMISOS HABILITA + e.Row.FCLinkButton("lnkRemove").Visible = PermiteEliminar() + e.Row.FCLinkButton("imgE").Visible = PermiteGuardar() + + If e.Row.DBCampo("CountMovimientoEntradaDetalle").ToEntero > 0 Then + TieneSalida = True + e.Row.FCLinkButton("lnkRemove").Visible = False + e.Row.FCLinkButton("imgE").Visible = False + End If + + 'SI TIENE PREPOLIZAS NO PUEDE EDITAR NI ELIMINAR + If e.Row.DBCampo("TienePrePoliza").ToEntero > 0 Then + e.Row.FCLinkButton("lnkRemove").Visible = False + e.Row.FCLinkButton("imgE").Visible = False + End If + + 'APAGA TODO SI TIENE MOVIMIENTO RELACIONADO + If TieneRelacionado > 0 Or CveMovimientoRelacionado > 0 Then + e.Row.FCLinkButton("lnkRemove").Visible = False + e.Row.FCLinkButton("imgE").Visible = False + End If + + 'PERMISO SOLO PARA EDITAR OBSERVACIONES + If PermiteGuardarObservacionDetalle() Then + e.Row.FCLinkButton("imgE").Visible = True + End If + + 'PERMISO SOLO PARA EDITAR SERIELOTE + If UsuarioActual.TienePermisoProceso(245) Then + e.Row.FCLinkButton("imgE").Visible = True + End If + + If EsNuevoMov Then + e.Row.FCLinkButton("lnkRemove").Visible = True + End If + + End If + + Dim Cantidad = e.Row.FCLiteral("lbCantidad").Text.ToDecimal + If Not UsuarioActual.TienePermisoProceso(265) Or Cantidad <= 1 Or Cantidad Mod 1 <> 0 Then + e.Row.FCLinkButton("lnkDividir").Visible = False + End If + End If + + If DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {e.Row.RowIndex}").SUMD("CantidadSeccionAlmacen") > 0 Then + e.Row.FCLinkButton("imgE").Visible = False + e.Row.FCLinkButton("imgE").ToolTip = "Cuenta con sección almacen" + e.Row.FCLinkButton("lnkRemove").Visible = False + e.Row.FCLinkButton("lnkRemove").ToolTip = "Cuenta con sección almacen" + e.Row.FCLinkButton("lnkDividir").Visible = False + e.Row.FCLinkButton("lnkDividir").ToolTip = "Cuenta con sección almacen" + End If + + End If + End Sub + Protected Sub GvM_RowEditing(sender As Object, e As GridViewEditEventArgs) Handles GvM.RowEditing + GvM.EditIndex = e.NewEditIndex + + CargaGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' ")) + End Sub + Protected Sub GvM_RowCancelingEdit(sender As Object, e As GridViewCancelEditEventArgs) Handles GvM.RowCancelingEdit + GvM.EditIndex = -1 + + CargaGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' ")) + End Sub + Protected Sub GvM_RowUpdating(sender As Object, e As GridViewUpdateEventArgs) Handles GvM.RowUpdating + + Dim Precio As Double = GvM.Rows(e.RowIndex).FCTextBox("TxtPrecio").Text.ToDouble + Dim No As Integer = GvM.Rows(e.RowIndex).DataKey("No").ToEntero + Dim serielote As String = GvM.Rows(e.RowIndex).FCTextBox("TxtSerieLote").Text.Replace(" ", String.Empty) + Dim Observaciones As String = GvM.Rows(e.RowIndex).FCTextBox("TxtObservaciones").Text + Dim CveSeccionAlmacen As Integer = GvM.Rows(e.RowIndex).FCDropDownList("DdlSeccionAlmacen").SelectedValue.ToEntero + Dim SeccionAlmacen As String = GvM.Rows(e.RowIndex).FCDropDownList("DdlSeccionAlmacen").SelectedItem.Text + Dim Cantidad As Double = GvM.Rows(e.RowIndex).FCTextBox("TxtCantidad").Text.ToDouble + Dim Drs As DataRow() = DtMovimientos.Select(String.Format("No = {0}", No)) + + If Drs.Count > 0 Then + Drs(0)("Cantidad") = Cantidad + Drs(0)("PU") = Precio + Drs(0)("Total") = Drs(0)("Cantidad").ToString.ToDouble * Precio + Drs(0)("Estatus") = "U" + Drs(0)("SerieLote") = serielote + Drs(0)("Observaciones") = Observaciones + Drs(0)("CveSeccionAlmacen") = CveSeccionAlmacen + Drs(0)("SeccionAlmacen") = SeccionAlmacen + End If + + DtMovimientos.AcceptChanges() + GvM.EditIndex = -1 + + CargaGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' ")) + + End Sub + Protected Sub DeleteRow(ByVal sender As Object, ByVal e As EventArgs) + Dim lnkRemove As LinkButton = DirectCast(sender, LinkButton) + + + If DtMovimientos.Rows.Count > 0 And lnkRemove.CommandArgument.ToString.Length > 0 Then + Dim i As Integer + i = lnkRemove.CommandArgument.ToString.ToEntero + Dim Drs As DataRow() = DtMovimientos.Select(String.Format("No = {0}", i)) + If Drs.Count > 0 Then + If CveMovimiento > 0 AndAlso Drs(0)("CveMovimientoDetalle").ToString.ToEntero > 0 Then + Drs(0)("Estatus") = "E" + Else + Drs(0).Delete() + End If + + End If + DtMovimientos.AcceptChanges() + End If + + GvM.EditIndex = -1 + + CargaGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' ")) + + End Sub + Protected Sub DividirRow(ByVal sender As Object, ByVal e As EventArgs) + + Dim lnkRemove As LinkButton = DirectCast(sender, LinkButton) + + If DtMovimientos.Rows.Count > 0 And lnkRemove.CommandArgument.ToString.Length > 0 Then + Dim i As Integer + i = lnkRemove.CommandArgument.ToString.ToEntero + Dim Drs As DataRow() = DtMovimientos.Select(String.Format("No = {0}", i)) + If Drs.Count > 0 Then + Dim Cantidad As Integer = Drs(0)("Cantidad").ToString.ToEntero + + Dim CvePS = Drs(0)("CvePS") + Dim Producto = Drs(0)("CodigoPS") + Dim PU = Drs(0)("PU") + Dim CveSeccion = Drs(0)("CveSeccionAlmacen") + + Drs(0)("Cantidad") = "1" + Drs(0)("Total") = PU + Drs(0)("Estatus") = "U" + + For counter As Integer = 1 To Cantidad - 1 + + txtCantidad.Text = "1" + DdlProducto2.SelectedValue = CvePS.ToString + DdlProducto2.SelectedText = Producto.ToString + txtPrecio.Text = PU.ToString + If DdlSeccionAlmacen.Visible = True And CveSeccion.ToString <> "" Then + DdlSeccionAlmacen.SelectedValue = CveSeccion.ToString + End If + + ElProductoChange() + + AgregarPS() + txtPrecio.Text = "" + DdlUnidad.SelectedItem.Text = "" + + Next + + End If + DtMovimientos.AcceptChanges() + End If + + GvM.EditIndex = -1 + + CargaGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' ")) + End Sub +#End Region + + +#Region " CONTABILIZAR " + Protected Sub BtnContabilizar_Click(sender As Object, e As EventArgs) Handles BtnContabilizar.Click + Dim ObjContaAC As ClsContPAQi = Nothing + Dim ObjInventario As New ClsInventarios + ObjInventario.IniciaTransacSQL() 'Inicia la transacción + + 'DEVENGAR + Dim IDPoliza As Integer + Dim ErrorAC = False + Dim TotalPorDevengar As Double = 0 + Dim Folio As String = "" + Dim Fecha As Date = TxtFecha.Text.ToDate + + + 'cuando tiene AC y es salida de almacen, se manda al gasto + If UsuarioActual.Empresa.UsaAC AndAlso DdlConcepto.SelectedValue = "3" Then + + 'Dim Total As Double = 0 + + 'TotalPorDevengar += Total ' GvInv.Rows.Cast(Of GridViewRow)().Sum(Function(Gvr) Math.Round(Gvr.DataKey("PU").ToString.ToDouble, 4) * Math.Round(Gvr.DataKey("CantidadF").ToString.ToDouble, 4)) + + + TotalPorDevengar = Math.Round(TotalPorDevengar, 4) + ObjContaAC = New ClsContPAQi(UsuarioActual.Empresa) + ObjContaAC.IniciaTransacSQL() + + IDPoliza = ObjContaAC.AddPoliza(3, "Salida de Almacen", TotalPorDevengar, TotalPorDevengar, UsuarioActual.CveUsuario, Fecha) + If IDPoliza > 0 Then + + Dim CuentaCargoCOG As Integer + Dim CuentaAbonoAlmacen As Integer = 0 + Dim Importe As Double = DtMovimientos.SUM("Total", "Estatus = ''") + Folio = ObjContaAC.Folio.ToString + + Dim drA As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveAlmacen = {0}", DdlAlmacen.SelectedValue)) + If drA IsNot Nothing Then CuentaAbonoAlmacen = drA("IdCtaContable").ToString.ToEntero + + + If UsuarioActual.CveEmpresa = 48 Then ' APH + CuentaCargoCOG = 1386 + End If + + + If CuentaCargoCOG > 0 AndAlso CuentaAbonoAlmacen > 0 Then + If ObjContaAC.AddMovimiento(IDPoliza, CuentaCargoCOG, False, Importe, "", "", 0, Fecha, "") Then + 'actualizo el idcuenta del presupuesto + If Not ObjContaAC.AddMovimiento(IDPoliza, CuentaAbonoAlmacen, True, Importe, "", "", 0, Fecha, "") Then + ErrorAC = True + End If + Else + ErrorAC = True + End If + End If + + If IDPoliza > 0 Then + ObjInventario.UpdateMovimientoPoliza(IDPoliza, CveMovimiento, UsuarioActual.CveEmpresa) + End If + + Else + ErrorAC = True + End If + + + End If + 'TERMINA: DEVENGAR + + If Not ErrorAC Then + + ObjInventario.Commit() ' aplica los movimientos insertados + If ObjContaAC IsNot Nothing Then ObjContaAC.AjustaPoliza(IDPoliza) : ObjContaAC.Commit() + Alert(String.Format("Movimiento Registrado

Poliza {1}", IDPoliza, Folio), TipoMensaje.MsgInformacion) + UPDatos.Update() + BtnContabilizar.Visible = PermiteContabilizar() + Else + ObjInventario.RollBack() + If ObjContaAC IsNot Nothing Then ObjContaAC.RollBack() + Alert("Error", TipoMensaje.MsgError) + End If + + End Sub +#End Region + + +#Region " VinculaAF " + Protected Sub BtnVinculaAF_Click(sender As Object, e As EventArgs) + If HdnCveActivoFijo.Value.ToEntero = -2 Then + Dim ObjAF As New ClsAF + + If ObjAF.GetActivosFijos(-1, UsuarioActual.CveEmpresa, LblCodigo.Text, "-1", -1, -1, "-1", -1, -1, -1, -1, -1, "", -1) Then + If ObjAF.DtResultados.Rows.Count = 1 Then + HdnCodigoAF.Value = ObjAF.DtResultados.Rows(0)("Codigo").ToString + HdnCveActivoFijo.Value = ObjAF.DtResultados.Rows(0)("CveActivoFijo").ToString + + LblCodigo.Text = HdnCodigoAF.Value + Else + HdnCodigoAF.Value = "-1" + HdnCveActivoFijo.Value = "-1" + LblCodigo.Text = "" + Alert("No se encontró un Activo Fijo con el código proporcionado.", TipoMensaje.MsgAdvertencia) + End If + End If + + ObjAF.Dispose() + Else + LblCodigo.Text = HdnCodigoAF.Value + End If + + LbAgregar.Focus() + + UPDatos.Update() + End Sub + + Protected Sub BtnVinculaAFEdit_Click(sender As Object, e As EventArgs) + If HdnCodAFEdit.Value.Trim = "" Then Exit Sub + + Dim ObjAF As New ClsAF + + If ObjAF.GetActivosFijos(-1, UsuarioActual.CveEmpresa, HdnCodAFEdit.Value, "-1", -1, -1, "-1", -1, -1, -1, -1, -1, "", -1) Then + If ObjAF.DtResultados.Rows.Count = 1 Then + RegistraScript(String.Format("EnterAFEditOK('{0}','{1}');", ObjAF.DtResultados.Rows(0)("CveActivoFijo").ToString, ObjAF.DtResultados.Rows(0)("Codigo").ToString)) + Else + Alert("No se encontró un Activo Fijo con el código proporcionado.", TipoMensaje.MsgAdvertencia) + RegistraScript(String.Format("EnterAFEditOK({0},{1});", "-1", "-1")) + End If + End If + + ObjAF.Dispose() + End Sub +#End Region + + +#Region " TIPO DE CAMBIO " + Protected Sub DdlMonedaTC_SelectedIndexChanged(sender As Object, e As EventArgs) + Select Case DdlMonedaTC.SelectedValue.ToEntero + Case 1 + TrTC1.Visible = False + TrTC2.Visible = False + + For Each Dr As DataRow In DtMovimientos.Rows + Dr("PU") = Dr("PUExtranjero") + Dr("Total") = Dr("PU").ToString.ToDouble * Dr("Cantidad").ToString.ToDouble + Next + + CargaGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' ")) + + 'LtTotal.Text = DtMovimientos.SUM("Total", "").ToString.FormatoNumero + + UPDatos.Update() + + Case 2 + TrTC1.Visible = True + TrTC2.Visible = True + End Select + End Sub + Protected Sub BtnAplicarTC_Click(sender As Object, e As EventArgs) + For Each Dr As DataRow In DtMovimientos.Rows + Dr("PU") = Dr("PUExtranjero").ToString.ToDouble * TxtTipoCambio.Text.ToDouble + Dr("Total") = Dr("PU").ToString.ToDouble * Dr("Cantidad").ToString.ToDouble + Next + + CargaGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' ")) + + 'LtTotal.Text = DtMovimientos.SUM("Total", "").ToString.FormatoNumero + + UPDatos.Update() + End Sub + + + + +#End Region + + +#Region " BITACORA " + Private Sub InicializaBitacoraTemporal() + + DivBitacora.Visible = True + + + If CveMovimiento > 0 Then + CargaEventoBitacora() + Else + DtBitacora = New DataTable + DtBitacora.Columns.Add("FechaIng", GetType(String)) + DtBitacora.Columns.Add("FechaInicio", GetType(String)) + DtBitacora.Columns.Add("Usuario", GetType(String)) + DtBitacora.Columns.Add("CveUsuario", GetType(String)) + DtBitacora.Columns.Add("Descripcion", GetType(String)) + DtBitacora.Columns.Add("Prioridad", GetType(String)) + DtBitacora.Columns.Add("FileExtension", GetType(String)) + DtBitacora.Columns.Add("Archivo", GetType(String)) + DtBitacora.Columns.Add("CveOrdenCompra", GetType(String)) + DtBitacora.Columns.Add("CveEmpresa", GetType(String)) + End If + + End Sub + Private Sub CargaEventoBitacora() + Dim ObjEventoBitacora As New ClsOIEventos() + + If ObjEventoBitacora.GetAgendaBitacora(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveMovimientoAlmacen:=CveMovimiento) Then + 'If ObjEventoBitacora.DtResultados.FiltraParametros("CveTipoEvento IN (6,2) AND CvePrioridad=3").Rows.Count > 0 Then + ' DivEventoUrgente.Visible = True + 'End If + GvBitacora.DataSource = ObjEventoBitacora.DtResultados.FiltraParametros("CveTipoEvento IN (6,2)") + Else + GvBitacora.DataSource = Nothing + End If + + ObjEventoBitacora.Dispose() + + GvBitacora.DataBind() + UPEventoBitacora.Update() + End Sub + Protected Sub BtnGuardarEventoBitacora_Click(sender As Object, e As EventArgs) Handles BtnGuardarEventoBitacora.Click + If CveMovimiento > 0 Then + GuardaBitacora() + Else + AgregaBitacoraTemporal() + End If + End Sub + +#Region " GUARDA TEMPORAL " + Private Sub AgregaBitacoraTemporal() + Dim ObjEventoBitacora As New ClsOIEventos + + 'Archivo + Dim FileExtension As String = "" + Dim Filename As String = "" + Dim Filesgral As List(Of Archivo) = Anexo.getfiles().Archivos + + For Each fileItem As Archivo In Filesgral + FileExtension = IO.Path.GetExtension(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", "") + Filename = fileItem.filename + Next + + Dim Archivo As New System.IO.FileInfo(String.Format("{0}OI\Temp\OI{1}{2}.{3}", UsuarioActual.Empresa.Ruta, UsuarioActual.CveUsuario, Now.ToString("HH-mm"), FileExtension)) + If Archivo.Exists() Then + Archivo.Delete() + 'File.Delete(String.Format("\Empresas\{0}\OI\Temp\OI{1}{2}.{3}", CveEmpresaActual, UsuarioActual.CveUsuario, DtDetalle.Rows.Count, FileExtension)) + End If + + If Filename <> "" Then + Filename.FilesMove(String.Format("OI{0}{1}", UsuarioActual.CveUsuario, Now.ToString("HH-mm")), String.Format("Empresas\{0}\OI\Temp", UsuarioActual.CveEmpresa)) + End If + + + 'AGREGA + Dim Dr = DtBitacora.NewRow + Dr("FechaIng") = Now + Dr("FechaInicio") = "" + Dr("Usuario") = UsuarioActual.Usuario + Dr("CveUsuario") = UsuarioActual.CveUsuario + Dr("Descripcion") = TxtEventoDescripcion.Text.Trim + Dr("Prioridad") = 1 + Dr("Archivo") = If(FileExtension = "", "", $"{UsuarioActual.Empresa.Ruta}OI\Temp\OI{UsuarioActual.CveUsuario}{Now.ToString("HH-mm")}.{FileExtension}") + Dr("FileExtension") = String.Format(".{0}", FileExtension) + Dr("CveOrdenCompra") = -1 + Dr("CveEmpresa") = UsuarioActual.CveEmpresa + DtBitacora.Rows.Add(Dr) + + + 'LIMPIA + TxtEventoDescripcion.Text = "" + 'ChkEventoPrioridad.Checked = False + RegistraScript("$('#ModalBitacora').modal('hide')", "hidemodal") + + CargaEventoBitacoraTemp() + + + End Sub + Private Sub CargaEventoBitacoraTemp() + GvBitacora.DataSource = DtBitacora + GvBitacora.DataBind() + UPAddEventoBitacora.Update() + UPEventoBitacora.Update() + End Sub + Private Function GuardaBitacoraTemporal(ObjEventoBitacora As ClsOIEventos, CveMovimiento As Integer) As Boolean + Dim Retorno = False + Dim Archivo As System.IO.FileInfo = Nothing + + For Each Dr As DataRow In DtBitacora.Rows + If ObjEventoBitacora.AddEventoBitacora(Dr("Descripcion").ToString, Dr("FileExtension").ToString, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveMovimientoAlmacen:=CveMovimiento) Then + Try + If Dr("Archivo").ToString <> "" Then + Archivo = New System.IO.FileInfo(Dr("Archivo").ToString) + If Archivo.Exists() Then + File.Move(Archivo.ToString, String.Format("{0}OI\OI{1}{2}", UsuarioActual.Empresa.Ruta, ObjEventoBitacora.CveEvento.ToString, Archivo.Extension)) + End If + End If + Catch ex As Exception + Retorno = True + Alert("Ocurrió un error al guardar los datos adjuntos de la Bitácora.", TipoMensaje.MsgError) + Exit For + End Try + + Else + Retorno = True + Exit For + End If + Next + + Return Retorno + End Function +#End Region + + +#Region " GUARDA DIRECTO " + Private Sub GuardaBitacora() + Dim ObjEventoBitacora As New ClsOIEventos + + Dim FileExtension As String = "" + Dim Filesgral As List(Of Archivo) = Anexo.getfiles().Archivos + Dim Filename As String = "" + + For Each fileItem As Archivo In Filesgral + FileExtension = IO.Path.GetExtension(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)) '.Replace(".", "") + Filename = fileItem.filename + Next + + Dim descripcion As String = TxtEventoDescripcion.Text.Trim + 'Dim Prioridad As Integer = If(ChkEventoPrioridad.Checked, 3, 1) + + If ObjEventoBitacora.AddEventoBitacora(descripcion, String.Format("{0}", FileExtension), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveMovimientoAlmacen:=CveMovimiento) Then + + If Filename <> "" Then + Filename.FilesMove(String.Format("OI{0}", ObjEventoBitacora.CveEvento.ToString), String.Format("Empresas\{0}\OI", UsuarioActual.CveEmpresa)) + End If + + GvBitacora.DataSource = ObjEventoBitacora.DtResultados + TxtEventoDescripcion.Text = "" + Anexo.Text = "[]" + 'ChkEventoPrioridad.Checked = False + Alert("La bitácora/observación se guardó correctamente", TipoMensaje.MsgInformacion) + RegistraScript("$('#ModalBitacora').modal('hide')", "hidemodal") + + ''obtener el Evento de bitacora para enviar el correo + 'If ObjEventoBitacora.GetEvento(ObjEventoBitacora.CveEvento, UsuarioActual.CveUsuario, CveEmpresaActual) Then + ' If ObjEventoBitacora.DtResultados IsNot Nothing AndAlso ObjEventoBitacora.DtResultados.Rows.Count > 0 Then + ' Dim dr As DataRow = ObjEventoBitacora.DtResultados.Rows(0) + ' EnviarCorreoBitacora(String.Format("{0}, {1} comento: ""{2}""", dr("FechaIng"), dr("Usuario"), dr("Descripcion")), String.Format("http://sig.adsistemas.mx/Empresas/{0}/OI/{1}", CveEmpresaActual, ObjEventoBitacora.Archivo)) + ' End If + 'End If + + End If + + ObjEventoBitacora.Dispose() + GvBitacora.DataBind() + + UPEventoBitacora.Update() + CargaEventoBitacora() + UPAddEventoBitacora.Update() + End Sub + +#End Region + + Protected Sub GVEventoBitacora_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvBitacora.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + If e.Row.DBCampo("Archivo").ToString.Trim <> "" AndAlso CveMovimiento > 0 Then + e.Row.FCLinkButton("LinkArchivo").Visible = True + e.Row.FCLinkButton("LinkArchivo").CommandArgument = String.Format("OI\{0}", e.Row.DBCampo("Archivo").ToString) + ScriptManager.GetCurrent(Me).RegisterPostBackControl(e.Row.FCLinkButton("LinkArchivo")) 'Registro un evento Postbacktrigger, que recargue toda la pagina para que funcione + Else + e.Row.Cells(4).Text = "NO" + End If + End If + End Sub + Protected Sub DownloadFile(ByVal sender As Object, ByVal e As EventArgs) + Dim filePath As String = String.Format("{0}{1}", UsuarioActual.Empresa.Ruta, CType(sender, LinkButton).CommandArgument) + If IO.File.Exists(filePath) Then + Dim Archivo As New System.IO.FileInfo(filePath) + + HttpContext.Current.Response.Clear() + HttpContext.Current.Response.ClearContent() + HttpContext.Current.Response.ContentType = "application/octet-stream" + HttpContext.Current.Response.AppendHeader("Content-disposition", "attachment; filename=" + Path.GetFileName(filePath)) + HttpContext.Current.Response.AddHeader("Content-Length", Archivo.Length.ToString()) + HttpContext.Current.Response.TransmitFile(filePath) + HttpContext.Current.Response.Flush() + HttpContext.Current.Response.End() + + Archivo = Nothing + Else + UPEventoBitacora.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.Trim = "" Then + Exit Sub + End If + + TdSeriePS.Visible = False + + Dim Dr = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimero($"CodigoBarras= '{TxtCodigoPS.Text}'") + If Dr Is Nothing Then + Alert($"No se ha encontrado un producto con el Codigo ""{TxtCodigoPS.Text}"". ", TipoMensaje.MsgAdvertencia, "window.setTimeout(FocusAdd,200);") + RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") + TxtCodigoPS.Text = "" + Exit Sub + End If + + If Dr("Inv_CveMetodoInventario").ToString.ToEntero = 5 Then + TdSeriePSAdd.Visible = True + TxtSeriePS.Focus() + CvePSSerieLote = Dr("CvePS").ToString.ToEntero + PSSerieLote = Dr("PSCodigo").ToString + CveUMSerieLote = Dr("CveUM").ToString.ToEntero + UMSerieLote = Dr("UnidadMedida").ToString + Exit Sub + End If + + AddNew(Dr("CvePS").ToString.ToEntero, Dr("PSCodigo").ToString, Dr("CveUM").ToString.ToEntero, Dr("UnidadMedida").ToString, 1, Dr("CostoPromedio").ToString.ToDouble, "", "", "", "", "", "", "", -1, "") + + TxtCodigoPS.Text = "" + TxtCodigoPS.Focus() + + End Sub + Protected Sub BtnSeriePSAdd_Click(sender As Object, e As EventArgs) + + If TxtSeriePS.Text.Trim = "" Then + Exit Sub + End If + + AddNew(CvePSSerieLote, PSSerieLote, CveUMSerieLote, UMSerieLote, 1, 0, TxtSeriePS.Text.Trim, "", "", "", "", "", "", -1, "") + + TdSeriePSAdd.Visible = False + TxtSeriePS.Text = "" + TxtCodigoPS.Text = "" + TxtCodigoPS.Focus() + End Sub + +#End Region + + +#Region " CONSUMO INTERNO " + Private Sub ActivaConsumoInterno() + EsConsumoInterno = True + + Panel1.Visible = False + DdlConcepto.Items.Insert(0, New ListItem("Salida por Consumo Interno", "30")) + DdlConcepto.SelectedValue = "30" + DdlAlmacen.AutoPostBack = False + DivFolio1.Visible = False + DivFolio2.Visible = False + DivConcepto1.Visible = False + DivConcepto2.Visible = False + divMonedaSeccion.Visible = False + divGuia.Visible = False + TrResponsable.Visible = False + CargaPersonal() + LtlTitulo.Text = "Consumo Interno" + + 'RECARGA ALMACENES SOLO DE CONSUMO INTERNO + DdlAlmacen.Items.Clear() + DdlAlmacen.DataBind() + Dim dttA As DataTable = Nothing + dttA = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 14) + If UsuarioActual.CveEmpresa = 119 Then + dttA.Merge(GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 1)) + End If + DdlAlmacen.DataSource = dttA 'GlobalDTAlmacen(UsuarioActual.CveEmpresa) + DdlAlmacen.Items.Insert(0, New ListItem("Seleccione", "-1")) + ' DdlAlmacen.SelectedValue = "-1" + DdlAlmacen.DataBind() + If IsNothing(Request("CveMovimiento")) Then + DdlAlmacen.SelectedValueExist(UsuarioActual.CveAlmacen) + End If + + End Sub +#End Region + + +#Region "PAQUETERIA GUIA" + Protected Sub LnkAgregarGuia_Click(sender As Object, e As EventArgs) + RegistraScript(String.Format("AbrirVentana('/General/PopUpPaqueteriasGuias.aspx?CveMovimiento={0}',800,620);", CveMovimiento)) + End Sub + + Protected Sub BtnAgregarGuia_Click(sender As Object, e As EventArgs) + + 'Dim objInventario As New ClsInventarios + + 'If objInventario.AddPaqueteriaGuia(DdlPaqueteria.SelectedValue.ToEntero, CveMovimiento, TxtPaqueteriaGuia.Text.Trim, TxtPaqueteriaNumcajas.Text.ToEntero, TxtPaqueteriaPeso.Text.ToDecimal, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, + ' TxtRastreo.Text.Trim, TxtDimensiones.Text.Trim, TxtFechaEst.Text.Trim) Then + ' CargaGvPaqueteria() + ' LimpiacontrolesPaqueteria() + 'End If + + 'objInventario.Dispose() + + End Sub + + Protected Sub LnkRemovePaqueteriaGuia_Click(sender As Object, e As EventArgs) + + 'Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + 'Dim CvePaqueteriaGuia As Integer = GvRow.DataKey("CvePaqueteriaGuia").ToString.ToEntero + 'Dim objInventario As New ClsInventarios + + 'If objInventario.RemovePaqueteriaGuia(CvePaqueteriaGuia, UsuarioActual.CveEmpresa) Then + ' CargaGvPaqueteria() + 'End If + + 'objInventario.Dispose() + + End Sub + + Private Sub CargaGvPaqueteria() + + 'Dim objInventario As New ClsInventarios + + 'If objInventario.GetPaqueteriaGuia(CveMovimiento, UsuarioActual.CveEmpresa) Then + ' GvPaqueriaGuias.DataSource = objInventario.DtResultados + + ' If objInventario.DtResultados.Rows.Count > 0 Then + ' BtnAgregarGuia.Attributes.Add("data-toggle", "confirmation") + ' BtnAgregarGuia.Attributes.Add("data-popout", "true") + ' BtnAgregarGuia.Attributes.Add("data-original-title", "¿Está seguro de registrar una nueva guia a la factura?") + ' BtnAgregarGuia.Attributes.Add("data-btn-ok-label", "si") + + ' Else + + ' BtnAgregarGuia.Attributes.Remove("data-toggle") + ' BtnAgregarGuia.Attributes.Remove("data-popout") + ' BtnAgregarGuia.Attributes.Remove("data-original-title") + ' BtnAgregarGuia.Attributes.Remove("data-btn-ok-label") + + + ' End If + + 'Else + ' GvPaqueriaGuias.DataSource = Nothing + 'End If + + 'objInventario.Dispose() + 'GvPaqueriaGuias.DataBind() + 'UpModalGuias.Update() + + End Sub + + Private Sub LimpiacontrolesPaqueteria() + + 'DdlPaqueteria.SelectedIndex = 0 + 'TxtPaqueteriaGuia.Text = "" + 'TxtPaqueteriaNumcajas.Text = "" + 'TxtPaqueteriaPeso.Text = "" + + 'TxtRastreo.Text = "" + 'TxtDimensiones.Text = "" + 'TxtFechaEst.Text = "" + + End Sub + + Protected Sub LnkGuiaPaqueteriaGuia_Click(sender As Object, e As EventArgs) + 'Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + + 'Dim CvePaqueteriaGuia As Integer = GvRow.DataKey("CvePaqueteriaGuia").ToString.ToEntero + 'Dim NumCajas As String = GvRow.DataKey("NumCajas").ToString + 'Dim Guia As String = GvRow.DataKey("Guia").ToString + 'Dim Peso As String = GvRow.DataKey("Peso").ToString.ToDecimal.ToString("####.00") + 'Dim DTDatosClienteGuia As New DataTable + 'Dim DTMovimientosDetalle As New DataTable + 'Dim CvePaqueteria As Integer = GvRow.DataKey("CvePaqueteria").ToString.ToEntero + 'Dim RutaRdlc As String = Server.MapPath("~") & "\Empresas\Grales\Formatos\GuiasFormato" & CvePaqueteria & ".rdlc" + + 'Dim Rastreo As String = GvRow.DataKey("Rastreo") + 'Dim Dimensiones As String = GvRow.DataKey("Dimensiones") + 'Dim FechaEstimada As String = GvRow.DataKey("FechaEstimada") + 'Dim ValorStimado As Double = 0 + + 'If Not File.Exists(RutaRdlc) Then + ' RutaRdlc = Server.MapPath("~") & "\Empresas\Grales\Formatos\GuiasFormato0.rdlc" + 'End If + + 'RutaRdlc = RutaRdlc.Replace(Server.MapPath("~") & "\", "") + + 'Dim params As New List(Of ReportParameter) + 'Dim ObjInventario As New ClsInventarios + + 'If ObjInventario.GetPaqueteriaGuiasInfoFormato(CveMovimiento, UsuarioActual.CveEmpresa) Then + ' DTDatosClienteGuia = ObjInventario.DtResultados + 'Else + ' ObjInventario.Dispose() + ' Exit Sub + 'End If + + 'If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then + + ' DTMovimientosDetalle = ObjInventario.DtResultados + ' DTMovimientosDetalle.Columns.Add("Peso") + ' DTMovimientosDetalle.Columns.Add("Dimensiones") + ' DTMovimientosDetalle.AcceptChanges() + + ' For Each Drow As DataRow In DTMovimientosDetalle.Rows + ' Drow("Peso") = Peso + ' Drow("Dimensiones") = Dimensiones + ' DTMovimientosDetalle.AcceptChanges() + ' Next + + ' ValorStimado = DtMovimientos.SUM("PU") + ' ObjInventario.Dispose() + 'Else + ' ObjInventario.Dispose() + ' Exit Sub + 'End If + + 'If DTDatosClienteGuia.Rows.Count > 0 Then + ' params.Add(New ReportParameter("NombreComercial", DTDatosClienteGuia.Rows(0)("NombreComercial").ToString)) + ' params.Add(New ReportParameter("Direccion", DTDatosClienteGuia.Rows(0)("Direccion").ToString)) + ' params.Add(New ReportParameter("Colonia", DTDatosClienteGuia.Rows(0)("Colonia").ToString)) + ' params.Add(New ReportParameter("NoExt", DTDatosClienteGuia.Rows(0)("NoExt").ToString)) + ' params.Add(New ReportParameter("NoInt", DTDatosClienteGuia.Rows(0)("NoInt").ToString)) + ' params.Add(New ReportParameter("Localidad", DTDatosClienteGuia.Rows(0)("Localidad").ToString)) + ' params.Add(New ReportParameter("Telefono", DTDatosClienteGuia.Rows(0)("Telefono").ToString)) + ' params.Add(New ReportParameter("RFCCliente", DTDatosClienteGuia.Rows(0)("RFC").ToString)) + ' params.Add(New ReportParameter("CiudadCliente", DTDatosClienteGuia.Rows(0)("Ciudad").ToString)) + 'Else + ' Exit Sub + 'End If + + 'Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta)) + 'Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa) + + 'params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa)) + 'params.Add(New ReportParameter("EmpresaDireccion", UsuarioActual.Empresa.Direccion)) + 'params.Add(New ReportParameter("EmpresaTelefono", UsuarioActual.Empresa.Telefono)) + 'params.Add(New ReportParameter("EmpresaColonia", UsuarioActual.Empresa.Colonia)) + 'params.Add(New ReportParameter("EmpresaLocalidad", UsuarioActual.Empresa.Localidad)) + 'params.Add(New ReportParameter("RFCEmpresa", UsuarioActual.Empresa.RFC)) + 'params.Add(New ReportParameter("CiudadEmpresa", UsuarioActual.Empresa.Ciudad)) + + 'params.Add(New ReportParameter("EmpresaTelefono", UsuarioActual.Empresa.Telefono)) + 'params.Add(New ReportParameter("NumCajas", NumCajas)) + 'params.Add(New ReportParameter("Peso", Peso)) + 'params.Add(New ReportParameter("Guia", Guia)) + + 'params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre)) + 'params.Add(New ReportParameter("FechaImpresion", Now.ToDateTime.ToShortDateString)) + + 'params.Add(New ReportParameter("Anio", Now.Year.ToString)) + 'params.Add(New ReportParameter("Mes", Now.Month.ToString("00"))) + 'params.Add(New ReportParameter("Dia", Now.Day.ToString("00"))) + + 'params.Add(New ReportParameter("Rastreo", Rastreo)) + 'params.Add(New ReportParameter("Dimensiones", Dimensiones)) + 'params.Add(New ReportParameter("FechaEstimada", FechaEstimada)) + + 'If Imagen.Exists Then + ' params.Add(New ReportParameter("LogoPath", logouri)) + 'Else + ' params.Add(New ReportParameter("LogoPath", "")) + 'End If + + 'ImprimirPDF(RutaRdlc, DTMovimientosDetalle, params, $"ReporteGuia_{Now.ToString("yyyyMMddhhmmss")}") + + End Sub + + Private Sub GvPaqueriaGuias_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvPaqueriaGuias.RowDataBound + + 'If e.Row.RowType = DataControlRowType.DataRow Then + ' Dim Lnk As LinkButton = e.Row.FCLinkButton("LnkGuiaPaqueteriaGuia") + ' Dim Destinatario As String = e.Row.DataKey("Mail").ToString + + ' If Destinatario.Length = 0 Then + ' e.Row.FCLinkButton("LnkGuiaPaqueteriaMail").Visible = False + ' Else + ' e.Row.FCLinkButton("LnkGuiaPaqueteriaMail").Attributes.Add("title", "Enviar correo a: " & Destinatario) + ' End If + + ' ScriptManager.GetCurrent(Me).RegisterPostBackControl(Lnk) + 'End If + + End Sub + + Private Sub GvPaqueteriaCreaEnlaces() + + 'For Each GvRow As GridViewRow In GvPaqueriaGuias.Rows + + ' If GvRow.RowType = DataControlRowType.DataRow Then + ' Dim Lnk As LinkButton = GvRow.FCLinkButton("LnkGuiaPaqueteriaGuia") + ' ScriptManager.GetCurrent(Me).RegisterPostBackControl(Lnk) + ' End If + + 'Next + End Sub + + Protected Sub LnkGuiaPaqueteriaMail_Click(sender As Object, e As EventArgs) + + 'Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + + + + 'Dim SerieFolio As String = GvRow.DataKey("SerieFolio").ToString + 'Dim NombreComercial As String = GvRow.DataKey("NombreComercial").ToString + 'Dim Destinatario As String = GvRow.DataKey("Mail").ToString + 'Dim Paqueteria As String = GvRow.DataKey("Paqueteria").ToString + 'Dim Guia As String = GvRow.DataKey("Guia").ToString + 'Dim Rastreo As String = GvRow.DataKey("Rastreo").ToString + 'Dim CveVenta As Integer = GvRow.DataKey("CveVenta").ToEntero + + 'EnviarCorreoNotificacion(SerieFolio, NombreComercial, Destinatario, Paqueteria, Guia, Rastreo, CveVenta) + + + End Sub + + Private Sub EnviarCorreoNotificacion(SerieFolio As String, NombreComercial As String, Destinatario As String, Paqueteria As String, Guia As String, Rastreo As String, CveVenta As Integer) + + 'Dim Correo As New ClsSisMail() + 'Dim Asunto As String = UsuarioActual.Empresa.NombreCorto & " Envio de pedido: " & SerieFolio + 'Dim Cuerpo As New StringBuilder + + 'Cuerpo.AppendLine($"Estimado {NombreComercial} le informamos que los productos de la factura {SerieFolio} han sido enviados mediante la paquetería {Paqueteria} con Guia {Guia} , Rastreo {Rastreo}.

") + + 'Cuerpo.AppendLine("") + 'Cuerpo.AppendLine("") + + 'For Each Drow As DataRow In DtMovimientos.Rows + ' Cuerpo.AppendLine($"") + 'Next + 'Cuerpo.AppendLine("
CantidadProducto
{Drow("Cantidad").ToString.ToEntero }{Drow("PS").ToString}
") + 'Cuerpo.AppendLine("

Dudas y aclaraciones departamento de ateción al cliente Tel. 2142200.") + + 'Destinatario = "rakcsle.rakcsle@gmail.com" + + 'If Correo.SendMail(UsuarioActual.Empresa, Destinatario, Asunto, Cuerpo.ToString) Then + ' GuardarBitacora(CveVenta, "", "Notificación de envío de productos al cliente") + ' Alert("Correo enviado existosamente a " & Destinatario) + 'Else + ' Alert("Se presento un error al enviar el correo a " & Destinatario) + 'End If + + + End Sub + +#End Region + + +#Region "DDL CLIENTE / CLIENTE SUCURSAL - SELECTED INDEX CHANGED" + Private Sub InicializaClientes() + If UsuarioActual.CveEmpresa.Contiene(72, 80) Then + DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa) + DdlClientes.DataBind() + + DdlClientes.Items.Insert(0, New ListItem("Seleccione", "-1")) + DdlClientes.SelectedValue = "-1" + End If + End Sub + Protected Sub ActivaClientes() + If UsuarioActual.CveEmpresa.Contiene(72, 80) Then + DivCliente.Visible = True + DivDepartamentoEntrega.Visible = True + 'TxtDepartamentoEntrega.Text = "" + End If + + 'If UsuarioActual.CveRol = 1 Then + ' RfvCliente.Enabled = False + 'End If + + End Sub + Protected Sub DdlClientes_SelectedIndexChanged(sender As Object, e As EventArgs) + CambiaCliente() + End Sub + Private Sub CambiaCliente() + DivClienteSucursal.Visible = False + DdlClientesSucursales.Items.Clear() + CargaSucursalesCliente() + End Sub + Protected Sub CargaSucursalesCliente() + DdlClientesSucursales.Enabled = True + Dim ObjCliente As New ClsClientes + If ObjCliente.GetSucursales(DdlClientes.SelectedValue.ToEntero) Then + If ObjCliente.DtResultados.Rows.Count > 0 Then + + DivClienteSucursal.Visible = True + UpGenerales.Update() + + DdlClientesSucursales.DataSource = ObjCliente.DtResultados + DdlClientesSucursales.DataBind() + + DdlClientesSucursales.Items.Insert(0, New ListItem("Seleccione", "-1")) + DdlClientesSucursales.SelectedValue = "-1" + + UpGenerales.Update() + End If + End If + ObjCliente.Dispose() + End Sub + + Private Sub BtnGeneraPrepoliza_Click(sender As Object, e As EventArgs) Handles BtnGeneraPrepoliza.Click + ''PREPOLIZA - SE CAMBIO DE LUGAR EL USO DE ESTA PARTE + Dim ObjInventario As New ClsInventarios + + Dim ErrorMovInv As Boolean = False + Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL()) + + + Dim DtCostos As DataTable = Nothing + Dim ValorInventario As Decimal = 0 + Dim ValorInventarioME As Decimal = 0 + Dim CvePrePolizaRegistrada As Integer = -1 - ObjInventario.GetMovimientos(CveMovimiento, -1, -1, UsuarioActual.CveEmpresa) - Dim CveVenta As Integer = ObjInventario.CveVenta - Dim MovAlmacen As Boolean = True - - Dim OrigenMov As Integer = GlobalDTInvConceptos.FiltroPrimeroValor("Origen", "CveConcepto = " & DdlConcepto.SelectedValue).ToEntero - If OrigenMov = 1 Then MovAlmacen = False Else MovAlmacen = True - - If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then - DtCostos = ObjInventario.DtResultados - Dim tmpCostos As DataTable = DtCostos.FiltraParametros("", "", {"CveClasificacion"}) - Dim DTOCs As DataTable = DtCostos.FiltraParametros("", "", {"CveOrdenCompraDetalle"}) - Dim IdCtaContable As Integer = 0 - Dim ConceptoPoliza As String = String.Format("{0}-{1}", DdlConcepto.SelectedItem.Text, If(DdlConcepto.SelectedValue.ToEntero.Contiene(3), HplVenta.Text, TxtFolio.Text)) - - If tmpCostos.Rows.Count > 0 Then - Dim Concepto As String = If(TxtObservaciones.Text = "", ConceptoPoliza, $" {TxtObservaciones.Text}") - Dim CvePrePoliza = ObjConta.AddPrePolizas("Inv_EntradaSalida", 74, DtCostos.SUM("Total"), DtCostos.SUM("Total"), 1, TxtFecha.Text.ToDate, ConceptoPoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - CvePrePolizaRegistrada = CvePrePoliza - - If HdnCveOrdenCompra.Value.ToEntero > 0 Then - MovAlmacen = False - For Each RowOC As DataRow In DTOCs.Rows - ValorInventario = DtCostos.SUM("Total", $"CveOrdenCompraDetalle = {RowOC("CveOrdenCompraDetalle")}").ToString.ToDecimal - ValorInventarioME = DtCostos.SUM("TotalExtranjero", $"CveOrdenCompraDetalle = {RowOC("CveOrdenCompraDetalle")}").ToString.ToDecimal - If ValorInventarioME > 0 Then - If ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ValorInventarioME, Concepto, 228, Concepto, TxtFecha.Text.ToDate, IdCtaContable, -1, CveVenta:=CveVenta, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=ValorInventarioME, ImporteME:=ValorInventarioME, CveOC:=HdnCveOrdenCompra.Value.ToEntero, CveOCDetalle:=RowOC("CveOrdenCompraDetalle").ToString.ToEntero, TipoCambio:=LbTipoCambio.Text.ToDecimal) Then - ValorInventario = ValorInventario - ValorInventarioME - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ValorInventario, Concepto, 229, Concepto, TxtFecha.Text.ToDate, IdCtaContable, -1, CveVenta:=CveVenta, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=ValorInventario, ImporteME:=ValorInventarioME, CveOC:=HdnCveOrdenCompra.Value.ToEntero, CveOCDetalle:=RowOC("CveOrdenCompraDetalle").ToString.ToEntero, TipoCambio:=LbTipoCambio.Text.ToDecimal) Then - ErrorMovInv = True - Exit For - End If - Else - ErrorMovInv = True - Exit For - End If - Else - If ObjConta.GetRetCuenta(176, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContable = ObjConta.DtResultados.FiltroPrimeroValor("IdCtaContable").ToEntero - End If - - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ValorInventario, Concepto, 176, Concepto, TxtFecha.Text.ToDate, IdCtaContable, -1, CveVenta:=CveVenta, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=ValorInventario, CveOC:=HdnCveOrdenCompra.Value.ToEntero, CveOCDetalle:=RowOC("CveOrdenCompraDetalle").ToString.ToEntero) Then - ErrorMovInv = True - Exit For - End If - End If - Next - Else - If DdlConcepto.SelectedValue.Contiene("6", "22", "23", "7", "16", "21", "24") Then - 'genero las prepolizas manuales - Dim tCveConcepto As Integer = 95 - Dim CveCuenta As Integer - If UsuarioActual.CveEmpresa = 119 Then CveCuenta = 55519 - IdCtaContable = 1 - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not MovAlmacen, DtCostos.SUMD("Total"), Concepto, tCveConcepto, Concepto, TxtFecha.Text.ToDate, IdCtaContable, -1, CveVenta:=CveVenta, CveClasificacion:=-1, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=DtCostos.SUMD("Total"), CveSubProyecto:=-1, CveCuenta:=CveCuenta) Then - ErrorMovInv = True - - End If - - Else - - Dim tCveSubProyecto = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveSubProyecto", $"CveAlmacen={DdlAlmacen.SelectedValue.ToEntero}").ToEntero - Dim tCveConcepto As Integer = 69 - If DdlConcepto.SelectedValue = "30" Then - tCveConcepto = 181 - IdCtaContable = UsuarioActual.Empresa.Funcionalidad(342).ToEntero - End If - - For Each RowInv As DataRow In tmpCostos.Rows - ValorInventario = DtCostos.SUM("Total", $"CveClasificacion = {RowInv("CveClasificacion")}").ToString.ToDecimal.RoundSQL - If tCveConcepto = 69 Then - IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaCostos", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero - End If - - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not MovAlmacen, ValorInventario, Concepto, tCveConcepto, Concepto, TxtFecha.Text.ToDate, IdCtaContable, -1, CveVenta:=CveVenta, CveClasificacion:=RowInv("CveClasificacion").ToString.ToEntero, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=ValorInventario, CveSubProyecto:=tCveSubProyecto) Then - ErrorMovInv = True - Exit For - End If - - Next - - End If - End If - - - - IdCtaContable = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", $"CveAlmacen={DdlAlmacen.SelectedValue.ToEntero}").ToEntero - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, MovAlmacen, DtCostos.SUMD("Total").RoundSQL, Concepto, 68, Concepto, TxtFecha.Text.ToDate, IdCtaContable, -1, CveVenta:=CveVenta, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=DtCostos.SUMD("Total").RoundSQL) Then - ErrorMovInv = True - End If - End If - End If - - If ErrorMovInv = False Then + ObjInventario.GetMovimientos(CveMovimiento, -1, -1, UsuarioActual.CveEmpresa) + Dim CveVenta As Integer = ObjInventario.CveVenta + Dim MovAlmacen As Boolean = True + + Dim OrigenMov As Integer = GlobalDTInvConceptos.FiltroPrimeroValor("Origen", "CveConcepto = " & DdlConcepto.SelectedValue).ToEntero + If OrigenMov = 1 Then MovAlmacen = False Else MovAlmacen = True + + If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then + DtCostos = ObjInventario.DtResultados + Dim tmpCostos As DataTable = DtCostos.FiltraParametros("", "", {"CveClasificacion"}) + Dim DTOCs As DataTable = DtCostos.FiltraParametros("", "", {"CveOrdenCompraDetalle"}) + Dim IdCtaContable As Integer = 0 + Dim ConceptoPoliza As String = String.Format("{0}-{1}", DdlConcepto.SelectedItem.Text, If(DdlConcepto.SelectedValue.ToEntero.Contiene(3), HplVenta.Text, TxtFolio.Text)) + + If tmpCostos.Rows.Count > 0 Then + Dim Concepto As String = If(TxtObservaciones.Text = "", ConceptoPoliza, $" {TxtObservaciones.Text}") + Dim CvePrePoliza = ObjConta.AddPrePolizas("Inv_EntradaSalida", 74, DtCostos.SUM("Total"), DtCostos.SUM("Total"), 1, TxtFecha.Text.ToDate, ConceptoPoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + CvePrePolizaRegistrada = CvePrePoliza + + If HdnCveOrdenCompra.Value.ToEntero > 0 Then + MovAlmacen = False + For Each RowOC As DataRow In DTOCs.Rows + ValorInventario = DtCostos.SUM("Total", $"CveOrdenCompraDetalle = {RowOC("CveOrdenCompraDetalle")}").ToString.ToDecimal + ValorInventarioME = DtCostos.SUM("TotalExtranjero", $"CveOrdenCompraDetalle = {RowOC("CveOrdenCompraDetalle")}").ToString.ToDecimal + If ValorInventarioME > 0 Then + If ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ValorInventarioME, Concepto, 228, Concepto, TxtFecha.Text.ToDate, IdCtaContable, -1, CveVenta:=CveVenta, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=ValorInventarioME, ImporteME:=ValorInventarioME, CveOC:=HdnCveOrdenCompra.Value.ToEntero, CveOCDetalle:=RowOC("CveOrdenCompraDetalle").ToString.ToEntero, TipoCambio:=LbTipoCambio.Text.ToDecimal) Then + ValorInventario = ValorInventario - ValorInventarioME + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ValorInventario, Concepto, 229, Concepto, TxtFecha.Text.ToDate, IdCtaContable, -1, CveVenta:=CveVenta, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=ValorInventario, ImporteME:=ValorInventarioME, CveOC:=HdnCveOrdenCompra.Value.ToEntero, CveOCDetalle:=RowOC("CveOrdenCompraDetalle").ToString.ToEntero, TipoCambio:=LbTipoCambio.Text.ToDecimal) Then + ErrorMovInv = True + Exit For + End If + Else + ErrorMovInv = True + Exit For + End If + Else + If ObjConta.GetRetCuenta(176, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjConta.DtResultados.FiltroPrimeroValor("IdCtaContable").ToEntero + End If + + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ValorInventario, Concepto, 176, Concepto, TxtFecha.Text.ToDate, IdCtaContable, -1, CveVenta:=CveVenta, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=ValorInventario, CveOC:=HdnCveOrdenCompra.Value.ToEntero, CveOCDetalle:=RowOC("CveOrdenCompraDetalle").ToString.ToEntero) Then + ErrorMovInv = True + Exit For + End If + End If + Next + Else + If DdlConcepto.SelectedValue.Contiene("6", "22", "23", "7", "16", "21", "24") Then + 'genero las prepolizas manuales + Dim tCveConcepto As Integer = 95 + Dim CveCuenta As Integer + If UsuarioActual.CveEmpresa = 119 Then CveCuenta = 55519 + IdCtaContable = 1 + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not MovAlmacen, DtCostos.SUMD("Total"), Concepto, tCveConcepto, Concepto, TxtFecha.Text.ToDate, IdCtaContable, -1, CveVenta:=CveVenta, CveClasificacion:=-1, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=DtCostos.SUMD("Total"), CveSubProyecto:=-1, CveCuenta:=CveCuenta) Then + ErrorMovInv = True + + End If + + Else + + Dim tCveSubProyecto = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveSubProyecto", $"CveAlmacen={DdlAlmacen.SelectedValue.ToEntero}").ToEntero + Dim tCveConcepto As Integer = 69 + If DdlConcepto.SelectedValue = "30" Then + tCveConcepto = 181 + IdCtaContable = UsuarioActual.Empresa.Funcionalidad(342).ToEntero + End If + + For Each RowInv As DataRow In tmpCostos.Rows + ValorInventario = DtCostos.SUM("Total", $"CveClasificacion = {RowInv("CveClasificacion")}").ToString.ToDecimal.RoundSQL + If tCveConcepto = 69 Then + IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaCostos", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero + End If + + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not MovAlmacen, ValorInventario, Concepto, tCveConcepto, Concepto, TxtFecha.Text.ToDate, IdCtaContable, -1, CveVenta:=CveVenta, CveClasificacion:=RowInv("CveClasificacion").ToString.ToEntero, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=ValorInventario, CveSubProyecto:=tCveSubProyecto) Then + ErrorMovInv = True + Exit For + End If + + Next + + End If + End If + + + + IdCtaContable = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", $"CveAlmacen={DdlAlmacen.SelectedValue.ToEntero}").ToEntero + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, MovAlmacen, DtCostos.SUMD("Total").RoundSQL, Concepto, 68, Concepto, TxtFecha.Text.ToDate, IdCtaContable, -1, CveVenta:=CveVenta, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=DtCostos.SUMD("Total").RoundSQL) Then + ErrorMovInv = True + End If + End If + End If + + If ErrorMovInv = False Then ObjInventario.Commit() ObjInventario.Dispose() - ObjConta.Dispose() - + ObjConta.Dispose() + If CvePrePolizaRegistrada > 0 Then Response.Redirect($"../Contabilidad/RegPrePoliza.aspx?CvePrePoliza={CvePrePolizaRegistrada}", True) End If @@ -3396,749 +3396,749 @@ Partial Class Inventarios_EntradasSalidas ObjInventario.Dispose() - ObjConta.Dispose() - - End If - - - - End Sub - -#End Region - - -#Region "CAMBIO INVENTARIO FISICO" - Protected Sub LnkCambioInventarioFisico_Click(sender As Object, e As EventArgs) - RegistraScript(String.Format("$('#{0}').modal();", "DivModalCambioFisico")) - End Sub - -#Region "ENTRADAS" - Private Sub BtnAgregarEntrada_Click(sender As Object, e As EventArgs) Handles BtnAgregarEntrada.Click - If Not DdlPS.SelectedValue.ToEntero > 0 Then - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - Alert("Es necesario especificar el producto.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - AddPSEntrada(DdlPS.SelectedValue.ToEntero, TxtCantidadInvFisico.Text.ToDouble, TxtCostoPromedio.Text.ToDecimal) - End Sub - - Protected Sub AddPSEntrada(CvePS As Integer, Cantidad As Double, CostoPromedio As Double) - If DdlAlmacenInventarioFisico.SelectedValue.ToEntero <= 0 Then Alert("Seleccione un almacen", TipoMensaje.MsgAdvertencia) : RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") : DdlPS.SelectedText = "" : Exit Sub - - Dim Valido As Boolean = True - - If Valido Then - Dim CveClasificacion As Integer - Dim CveUM As Double - Dim CodigoPS As String = "" - Dim PS As String = "" - - Dim dr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS).FiltroPrimero("", "PS") - If dr IsNot Nothing Then - CveClasificacion = dr("CveClasificacion").ToString.ToEntero - CveUM = dr("CveUM").ToString.ToEntero - CodigoPS = dr("PSCodigo").ToString.ToString - PS = dr("PS").ToString.ToString - End If - - Dim registro As DataRow = DtMovimientosEntradaInvFisico.NewRow - registro.Item("Cantidad") = Cantidad - registro.Item("CveUM") = CveUM - registro.Item("CvePS") = CvePS - registro.Item("CodigoPS") = CodigoPS - registro.Item("PS") = PS - registro.Item("PU") = CostoPromedio - registro.Item("Total") = Cantidad * CostoPromedio - registro.Item("CveClasificacion") = CveClasificacion - registro.Item("Estatus") = "" - - DtMovimientosEntradaInvFisico.Rows.Add(registro) - CargaGvEntradas(DtMovimientosEntradaInvFisico) - RegistraScript("playsonidito('beep-07.wav')") - End If - End Sub - - Private Sub CargaGvEntradas(DtTemp As DataTable) - GvEntradas.DataSource = DtTemp - GvEntradas.DataBind() - End Sub - - Protected Sub DdlPSInvFisico_ValueChanged(sender As Object, e As EventArgs) Handles DdlPS.selectedindexchange - ProductChange() - End Sub - - Private Sub ProductChange() - - If DdlPS.SelectedValue.ToEntero > 0 Then - Dim ObjInventario As New ClsInventarios - - Dim CostoPromedio As Decimal = ObjInventario.GetCostoPS(DdlPS.SelectedValue.ToEntero, txtCantidad.Text.ToDouble, DdlAlmacenInventarioFisico.SelectedValue.ToEntero, "", TxtFecha.Text.ToDate) - 'GlobalDTPS(UsuarioActual.CveEmpresa, DdlPS.SelectedValue.ToEntero).FiltroPrimeroValor("CostoPromedio", "").ToDecimal - If CostoPromedio > 0 Then - - TxtCostoPromedio.Text = CostoPromedio.FormatoNumero - Else - TxtCostoPromedio.Text = "0.00" - End If - ObjInventario.Dispose() - End If - - - UpModalInventarioFisico.Update() - End Sub - - Protected Sub DeleteRowInvFisicoEntrada(ByVal sender As Object, ByVal e As EventArgs) - Dim lnkRemove As LinkButton = DirectCast(sender, LinkButton) - - If DtMovimientosEntradaInvFisico.Rows.Count > 0 And lnkRemove.CommandArgument.ToString.Length > 0 Then - Dim i As Integer - i = lnkRemove.CommandArgument.ToString.ToEntero - Dim Drs As DataRow() = DtMovimientosEntradaInvFisico.Select(String.Format("No = {0}", i)) - If Drs.Count > 0 Then - - Drs(0).Delete() - End If - DtMovimientosEntradaInvFisico.AcceptChanges() - End If - - GvEntradas.EditIndex = -1 - - CargaGvEntradas(DtMovimientosEntradaInvFisico) - End Sub -#End Region - -#Region "SALIDAS" - Private Sub BtnAgregarSalida_Click(sender As Object, e As EventArgs) Handles BtnAgregarSalida.Click - If Not DdlPSSalida.SelectedValue.ToEntero > 0 Then - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - Alert("Es necesario especificar el producto.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - AddPSSalida(DdlPSSalida.SelectedValue.ToEntero, TxtCantidadSalidaInv.Text.ToDouble) - End Sub - - Protected Sub AddPSSalida(CvePS As Integer, Cantidad As Double) - If DdlAlmacenInventarioFisico.SelectedValue.ToEntero <= 0 Then Alert("Seleccione un almacen", TipoMensaje.MsgAdvertencia) : RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") : DdlPSSalida.SelectedText = "" : Exit Sub - - Dim Valido As Boolean = True - - If Valido Then - Dim CveClasificacion As Integer - Dim CveUM As Double - Dim CodigoPS As String = "" - Dim PS As String = "" - - Dim dr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS).FiltroPrimero("", "PS") - If dr IsNot Nothing Then - CveClasificacion = dr("CveClasificacion").ToString.ToEntero - CveUM = dr("CveUM").ToString.ToEntero - CodigoPS = dr("PSCodigo").ToString.ToString - PS = dr("PS").ToString.ToString - End If - - Dim registro As DataRow = DtMovimientosSalidaInvFisico.NewRow - registro.Item("Cantidad") = Cantidad - registro.Item("CveUM") = CveUM - registro.Item("CvePS") = CvePS - registro.Item("CodigoPS") = CodigoPS - registro.Item("PS") = PS - registro.Item("PU") = 0 - registro.Item("Total") = 0 - registro.Item("CveClasificacion") = CveClasificacion - registro.Item("Estatus") = "" - - DtMovimientosSalidaInvFisico.Rows.Add(registro) - CargaGvSalidas(DtMovimientosSalidaInvFisico) - RegistraScript("playsonidito('beep-07.wav')") - End If - End Sub - - Private Sub CargaGvSalidas(DtTemp As DataTable) - GvSalidas.DataSource = DtTemp - GvSalidas.DataBind() - End Sub - - Protected Sub DeleteRowInvFisicoSalida(ByVal sender As Object, ByVal e As EventArgs) - Dim lnkRemove As LinkButton = DirectCast(sender, LinkButton) - - If DtMovimientosSalidaInvFisico.Rows.Count > 0 And lnkRemove.CommandArgument.ToString.Length > 0 Then - Dim i As Integer - i = lnkRemove.CommandArgument.ToString.ToEntero - Dim Drs As DataRow() = DtMovimientosSalidaInvFisico.Select(String.Format("No = {0}", i)) - If Drs.Count > 0 Then - - Drs(0).Delete() - End If - DtMovimientosSalidaInvFisico.AcceptChanges() - End If - - GvSalidas.EditIndex = -1 - - CargaGvSalidas(DtMovimientosSalidaInvFisico) - End Sub -#End Region - -#Region "GUARDAR" - Private Sub BtnAplicarCambioInvFisico_Click(sender As Object, e As EventArgs) Handles BtnAplicarCambioInvFisico.Click - - If GvEntradas.Rows.Count = 0 And GvSalidas.Rows.Count = 0 Then - Alert("No hay ningun registro para generar el movimiento. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgError) - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - RegistraScript(String.Format("$('#{0}').modal();", "DivModalCambioFisico")) - Exit Sub - End If - - Dim ObjInventario As New ClsInventarios - Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL()) - Dim CveMovimientoEntrada As Integer - Dim CveMovimientoSalida As Integer - Dim ErrorMovInv As Boolean = False - Dim Mensaje As String = "" - Dim ValorEntrada As Decimal = 0 - Dim ValorSalida As Decimal = 0 - Dim ImporteConcepto As Decimal = 0 - Dim tConcepto As String = TxtIFDescripcion.Text.Trim - Dim Fecha = TxtFechaInvFisico.Text.ToDate.ToString("yyyy/MM/dd").ToDate - Dim tCveSubProyecto As Integer = -1 - Dim TipoMovto As Boolean = False - Dim idCtaContableEntrada As Integer = 0 - Dim idCtaContableSalida As Integer = 0 - - Dim IdCuentaOtrosIngresos As Integer = UsuarioActual.Empresa.IdCuentaOtrosIngresos - Select Case UsuarioActual.CveEmpresa - Case 119 - IdCuentaOtrosIngresos = 1319 - End Select - - 'MOVIMIENTO DE ENTRADA - If DtMovimientosEntradaInvFisico.Rows.Count > 0 Then - Dim FolioEntrada As Integer = ObjInventario.GetFolioSiguiente(32, UsuarioActual.CveEmpresa) + ObjConta.Dispose() + + End If + + + + End Sub + +#End Region + + +#Region "CAMBIO INVENTARIO FISICO" + Protected Sub LnkCambioInventarioFisico_Click(sender As Object, e As EventArgs) + RegistraScript(String.Format("$('#{0}').modal();", "DivModalCambioFisico")) + End Sub + +#Region "ENTRADAS" + Private Sub BtnAgregarEntrada_Click(sender As Object, e As EventArgs) Handles BtnAgregarEntrada.Click + If Not DdlPS.SelectedValue.ToEntero > 0 Then + RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") + Alert("Es necesario especificar el producto.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + AddPSEntrada(DdlPS.SelectedValue.ToEntero, TxtCantidadInvFisico.Text.ToDouble, TxtCostoPromedio.Text.ToDecimal) + End Sub + + Protected Sub AddPSEntrada(CvePS As Integer, Cantidad As Double, CostoPromedio As Double) + If DdlAlmacenInventarioFisico.SelectedValue.ToEntero <= 0 Then Alert("Seleccione un almacen", TipoMensaje.MsgAdvertencia) : RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") : DdlPS.SelectedText = "" : Exit Sub + + Dim Valido As Boolean = True + + If Valido Then + Dim CveClasificacion As Integer + Dim CveUM As Double + Dim CodigoPS As String = "" + Dim PS As String = "" + + Dim dr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS).FiltroPrimero("", "PS") + If dr IsNot Nothing Then + CveClasificacion = dr("CveClasificacion").ToString.ToEntero + CveUM = dr("CveUM").ToString.ToEntero + CodigoPS = dr("PSCodigo").ToString.ToString + PS = dr("PS").ToString.ToString + End If + + Dim registro As DataRow = DtMovimientosEntradaInvFisico.NewRow + registro.Item("Cantidad") = Cantidad + registro.Item("CveUM") = CveUM + registro.Item("CvePS") = CvePS + registro.Item("CodigoPS") = CodigoPS + registro.Item("PS") = PS + registro.Item("PU") = CostoPromedio + registro.Item("Total") = Cantidad * CostoPromedio + registro.Item("CveClasificacion") = CveClasificacion + registro.Item("Estatus") = "" + + DtMovimientosEntradaInvFisico.Rows.Add(registro) + CargaGvEntradas(DtMovimientosEntradaInvFisico) + RegistraScript("playsonidito('beep-07.wav')") + End If + End Sub + + Private Sub CargaGvEntradas(DtTemp As DataTable) + GvEntradas.DataSource = DtTemp + GvEntradas.DataBind() + End Sub + + Protected Sub DdlPSInvFisico_ValueChanged(sender As Object, e As EventArgs) Handles DdlPS.selectedindexchange + ProductChange() + End Sub + + Private Sub ProductChange() + + If DdlPS.SelectedValue.ToEntero > 0 Then + Dim ObjInventario As New ClsInventarios + + Dim CostoPromedio As Decimal = ObjInventario.GetCostoPS(DdlPS.SelectedValue.ToEntero, txtCantidad.Text.ToDouble, DdlAlmacenInventarioFisico.SelectedValue.ToEntero, "", TxtFecha.Text.ToDate) + 'GlobalDTPS(UsuarioActual.CveEmpresa, DdlPS.SelectedValue.ToEntero).FiltroPrimeroValor("CostoPromedio", "").ToDecimal + If CostoPromedio > 0 Then + + TxtCostoPromedio.Text = CostoPromedio.FormatoNumero + Else + TxtCostoPromedio.Text = "0.00" + End If + ObjInventario.Dispose() + End If + + + UpModalInventarioFisico.Update() + End Sub + + Protected Sub DeleteRowInvFisicoEntrada(ByVal sender As Object, ByVal e As EventArgs) + Dim lnkRemove As LinkButton = DirectCast(sender, LinkButton) + + If DtMovimientosEntradaInvFisico.Rows.Count > 0 And lnkRemove.CommandArgument.ToString.Length > 0 Then + Dim i As Integer + i = lnkRemove.CommandArgument.ToString.ToEntero + Dim Drs As DataRow() = DtMovimientosEntradaInvFisico.Select(String.Format("No = {0}", i)) + If Drs.Count > 0 Then + + Drs(0).Delete() + End If + DtMovimientosEntradaInvFisico.AcceptChanges() + End If + + GvEntradas.EditIndex = -1 + + CargaGvEntradas(DtMovimientosEntradaInvFisico) + End Sub +#End Region + +#Region "SALIDAS" + Private Sub BtnAgregarSalida_Click(sender As Object, e As EventArgs) Handles BtnAgregarSalida.Click + If Not DdlPSSalida.SelectedValue.ToEntero > 0 Then + RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") + Alert("Es necesario especificar el producto.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + AddPSSalida(DdlPSSalida.SelectedValue.ToEntero, TxtCantidadSalidaInv.Text.ToDouble) + End Sub + + Protected Sub AddPSSalida(CvePS As Integer, Cantidad As Double) + If DdlAlmacenInventarioFisico.SelectedValue.ToEntero <= 0 Then Alert("Seleccione un almacen", TipoMensaje.MsgAdvertencia) : RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") : DdlPSSalida.SelectedText = "" : Exit Sub + + Dim Valido As Boolean = True + + If Valido Then + Dim CveClasificacion As Integer + Dim CveUM As Double + Dim CodigoPS As String = "" + Dim PS As String = "" + + Dim dr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS).FiltroPrimero("", "PS") + If dr IsNot Nothing Then + CveClasificacion = dr("CveClasificacion").ToString.ToEntero + CveUM = dr("CveUM").ToString.ToEntero + CodigoPS = dr("PSCodigo").ToString.ToString + PS = dr("PS").ToString.ToString + End If + + Dim registro As DataRow = DtMovimientosSalidaInvFisico.NewRow + registro.Item("Cantidad") = Cantidad + registro.Item("CveUM") = CveUM + registro.Item("CvePS") = CvePS + registro.Item("CodigoPS") = CodigoPS + registro.Item("PS") = PS + registro.Item("PU") = 0 + registro.Item("Total") = 0 + registro.Item("CveClasificacion") = CveClasificacion + registro.Item("Estatus") = "" + + DtMovimientosSalidaInvFisico.Rows.Add(registro) + CargaGvSalidas(DtMovimientosSalidaInvFisico) + RegistraScript("playsonidito('beep-07.wav')") + End If + End Sub + + Private Sub CargaGvSalidas(DtTemp As DataTable) + GvSalidas.DataSource = DtTemp + GvSalidas.DataBind() + End Sub + + Protected Sub DeleteRowInvFisicoSalida(ByVal sender As Object, ByVal e As EventArgs) + Dim lnkRemove As LinkButton = DirectCast(sender, LinkButton) + + If DtMovimientosSalidaInvFisico.Rows.Count > 0 And lnkRemove.CommandArgument.ToString.Length > 0 Then + Dim i As Integer + i = lnkRemove.CommandArgument.ToString.ToEntero + Dim Drs As DataRow() = DtMovimientosSalidaInvFisico.Select(String.Format("No = {0}", i)) + If Drs.Count > 0 Then + + Drs(0).Delete() + End If + DtMovimientosSalidaInvFisico.AcceptChanges() + End If + + GvSalidas.EditIndex = -1 + + CargaGvSalidas(DtMovimientosSalidaInvFisico) + End Sub +#End Region + +#Region "GUARDAR" + Private Sub BtnAplicarCambioInvFisico_Click(sender As Object, e As EventArgs) Handles BtnAplicarCambioInvFisico.Click + + If GvEntradas.Rows.Count = 0 And GvSalidas.Rows.Count = 0 Then + Alert("No hay ningun registro para generar el movimiento. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgError) + RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") + RegistraScript(String.Format("$('#{0}').modal();", "DivModalCambioFisico")) + Exit Sub + End If + + Dim ObjInventario As New ClsInventarios + Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL()) + Dim CveMovimientoEntrada As Integer + Dim CveMovimientoSalida As Integer + Dim ErrorMovInv As Boolean = False + Dim Mensaje As String = "" + Dim ValorEntrada As Decimal = 0 + Dim ValorSalida As Decimal = 0 + Dim ImporteConcepto As Decimal = 0 + Dim tConcepto As String = TxtIFDescripcion.Text.Trim + Dim Fecha = TxtFechaInvFisico.Text.ToDate.ToString("yyyy/MM/dd").ToDate + Dim tCveSubProyecto As Integer = -1 + Dim TipoMovto As Boolean = False + Dim idCtaContableEntrada As Integer = 0 + Dim idCtaContableSalida As Integer = 0 + + Dim IdCuentaOtrosIngresos As Integer = UsuarioActual.Empresa.IdCuentaOtrosIngresos + Select Case UsuarioActual.CveEmpresa + Case 119 + IdCuentaOtrosIngresos = 1319 + End Select + + 'MOVIMIENTO DE ENTRADA + If DtMovimientosEntradaInvFisico.Rows.Count > 0 Then + Dim FolioEntrada As Integer = ObjInventario.GetFolioSiguiente(32, UsuarioActual.CveEmpresa) CveMovimientoEntrada = ObjInventario.AddMovimiento(DdlAlmacenInventarioFisico.SelectedValue.ToEntero, 32, 1, Fecha, FolioEntrada, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtIFDescripcion.Text.Trim) - Else - CveMovimientoEntrada = -1 - End If - - 'MOVIMIENTO DE SALIDA - If DtMovimientosSalidaInvFisico.Rows.Count > 0 Then - Dim FolioSalida As Integer = ObjInventario.GetFolioSiguiente(34, UsuarioActual.CveEmpresa) - CveMovimientoSalida = ObjInventario.AddMovimiento(DdlAlmacenInventarioFisico.SelectedValue.ToEntero, 34, 1, Fecha, FolioSalida, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, CveMovimientoRelacionado:=CveMovimientoEntrada, Observaciones:=TxtIFDescripcion.Text.Trim) - - End If - - 'Registro PrePoliza - Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Inv/E/S INVENTARIO FISICO", 53, 0, 0, 1, Fecha, TxtIFDescripcion.Text.Trim, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoPoliza:=3) - - 'VALIDA, sino hay registrado ningun movimiento, que no siga - If (CveMovimientoEntrada <= 0 AndAlso CveMovimientoSalida <= 0) Or CvePrePoliza <= 0 Then - Alert("Ocurrió un error al realizar los registros. Por favor verifique y vuelva a intentar", TipoMensaje.MsgError) - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - ObjInventario.RollBack() 'deshace lo insertado. - ObjInventario.Dispose() 'elimino la instancia - Exit Sub - End If - - 'VALIDA EXISTENCIAS SALIDA E INSERTA DETALLES - For Each Dr As DataRow In DtMovimientosSalidaInvFisico.Rows - If ObjInventario.GetExistenciasPS(Dr("CvePS").ToString.ToEntero, Dr("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacenInventarioFisico.SelectedValue.ToEntero) >= Dr("Cantidad").ToString.ToDouble Then - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDouble, -1) Then - Mensaje = "Ocurrió un error al guardar los movimientos de salida" - ErrorMovInv = True - Exit For - End If - Else - Mensaje = String.Format("No hay existencias suficientes del producto: {0}", Dr("PS")) - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - ErrorMovInv = True - Exit For - End If - Next - - If Not ErrorMovInv Then - For Each Dr As DataRow In DtMovimientosEntradaInvFisico.Rows - ImporteConcepto = Dr("PU").ToString.ToDecimal - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, ImporteConcepto, -1) Then - Mensaje = "Ocurrió un error al guardar los movimientos de entrada" - ErrorMovInv = True - Exit For - End If - Next - End If - - 'Obtiene valor entrada - If Not ErrorMovInv AndAlso CveMovimientoEntrada > 0 Then - If ObjInventario.GetMovimientosDetalle(CveMovimientoEntrada, UsuarioActual.CveEmpresa) Then - Dim tValorInventario As Decimal = ObjInventario.DtResultados.SUMD("Total", "").RoundSQL() - ValorEntrada = tValorInventario - - Dim drA2 As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveAlmacen = {0}", DdlAlmacenInventarioFisico.SelectedValue)) - If drA2 IsNot Nothing Then - idCtaContableEntrada = drA2("IdCtaContable").ToString.ToEntero - tCveSubProyecto = drA2("CveSubProyecto").ToString.ToEntero - End If - Else - ErrorMovInv = True - Mensaje = "Ocurrió un error al validar los movimientos contables de entrada" - End If - End If - - 'Obtiene valor salida - If Not ErrorMovInv AndAlso CveMovimientoSalida > 0 Then - If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then - Dim tValorInventario As Decimal = ObjInventario.DtResultados.SUM("Total", "").ToDecimal.RoundSQL() - ValorSalida = tValorInventario - Dim drA2 As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveAlmacen = {0}", DdlAlmacenInventarioFisico.SelectedValue)) - If drA2 IsNot Nothing Then idCtaContableSalida = drA2("IdCtaContable").ToString.ToEntero - Else - ErrorMovInv = True - Mensaje = "Ocurrió un error al validar los movimientos contables de salida" - End If - End If - - If Not ErrorMovInv Then - 'NOTA - ' cuando el valor entrada sea mayor al de salida, el valor de salida debe de ser negativo y cargado - ' cuando el valor salida sea mayor al de entrada, el valor de entrada debe de ser negativo y abonado - - 'Registro la prepólizaDetalle Entradas - If CveMovimientoEntrada > 0 Then - TipoMovto = False - If ValorEntrada <= ValorSalida Then - TipoMovto = True : ValorEntrada = -ValorEntrada ' invierto su naturaleza - End If - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, ValorEntrada, "", 68, tConcepto, Fecha, idCtaContableEntrada, -1, CveMovimientoAlmacen:=CveMovimientoEntrada, ImporteMX:=ValorEntrada) Then - ErrorMovInv = True - Mensaje = "Ocurrió un error al guardar los movimientos contables de entrada" - End If - End If - - 'Registro la prepólizaDetalle Salidas - If CveMovimientoSalida > 0 Then - TipoMovto = True - If ValorSalida < ValorEntrada Then - TipoMovto = False : ValorSalida = -ValorSalida ' invierto su naturaleza - End If - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, ValorSalida, "", 68, tConcepto, Fecha, idCtaContableSalida, -1, CveMovimientoAlmacen:=CveMovimientoSalida, ImporteMX:=ValorSalida) Then - ErrorMovInv = True - Mensaje = "Ocurrió un error al guardar los movimientos contables de salida" - End If - End If - - If ValorEntrada >= ValorSalida Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ValorEntrada + ValorSalida, "", 260, tConcepto, Fecha, IdCuentaOtrosIngresos, -1, CveMovimientoAlmacen:=CveMovimientoSalida, ImporteMX:=ValorEntrada + ValorSalida) Then - ErrorMovInv = True - Mensaje = "Ocurrió un error al guardar los movimientos contables de ajuste de ingreso" - End If - ElseIf ValorSalida >= ValorEntrada Then - 'inserta el gasto - Dim dr As DataRow = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimero("") - Dim tCveClasificacion As Integer = -1 - Dim tIdCtaGasto As Integer = -1 - If dr IsNot Nothing Then - tCveClasificacion = dr("CveClasificacion").ToString.ToEntero - tIdCtaGasto = dr("IdCuentaGasto").ToString.ToEntero - End If - - '[IPP] PARCHE - CUENTA CONTABLE DIRECTA - Select Case UsuarioActual.CveEmpresa - Case 119 - tIdCtaGasto = 1321 - End Select - - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ValorSalida + ValorEntrada, "", 51, tConcepto, Fecha, tIdCtaGasto, -1, CveMovimientoAlmacen:=CveMovimientoSalida, CveClasificacion:=tCveClasificacion, CveSubProyecto:=tCveSubProyecto, ImporteMX:=ValorSalida + ValorEntrada) Then - ErrorMovInv = True - Mensaje = "Ocurrió un error al guardar los movimientos contables de ajuste de salida" - End If - End If - End If - - - - If Not ErrorMovInv Then - If ObjConta.ValidacionPrePolizaCuadre(CvePrePoliza, -1) Then - ObjConta.GetPrePolizasDetalle(CvePrePoliza) - If ObjConta.ValorPolizaDescuadre > 0 Then - ErrorMovInv = True - Mensaje = "Ocurrió un error al validar los movimientos contables" - End If - End If - End If - - If Not ErrorMovInv Then - ObjInventario.Commit() ' aplica los movimientos insertados - - Dim Msg As New StringBuilder - Msg.AppendFormat("
El Movimiento se registro con el Folio: {0}", ObjInventario.Folio) - If CveMovimientoEntrada > 0 Then Msg.AppendFormat("

Imprimir Movimiento Entrada ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoEntrada))) - If CveMovimientoSalida > 0 Then Msg.AppendFormat("

Imprimir Movimiento Salida ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoSalida))) - Alert(Msg.ToString, TipoMensaje.MsgInformacion) - - RegistraScript("playsonidito('beep-07.wav')") - RegistraScript(String.Format("$('#{0}').modal('hide');", "DivModalCambioFisico")) - GvEntradas.DataBind() - GvSalidas.DataBind() - TxtIFDescripcion.Text = "" - - Else - ObjInventario.RollBack() - - Alert(Mensaje, TipoMensaje.MsgError) - - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - End If - ObjInventario.Dispose() 'elimino la instancia - - End Sub -#End Region - -#End Region - - - Private Sub GuardarBitacora(CveVenta As Integer, RutaAdjunto As String, Obser As String) - Dim ObjEventos As New ClsOIEventos() - - - Try - If ObjEventos.AddEventoBitacora(Obser, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveVenta:=CveVenta) Then - - - End If - Catch ex As Exception - OnError("Se presento un error al guardar la Bitacora", ex) - End Try - - ObjEventos.Dispose() - - End Sub - -#Region "DESCARGAR E IMPRIMIR LISTADO" - Public Sub DescargarFormato() - Dim Directorio As String = AppDomain.CurrentDomain.BaseDirectory & "Empresas\Grales\Formatos\FormatoEntradasSalidas.xlsx" - - Dim Archivo As New IO.FileInfo(Directorio) - If Archivo.Exists Then - Response.Clear() - Response.ClearHeaders() - Response.ClearContent() - Response.AddHeader("Content-Disposition", "attachment; filename=" + Archivo.Name) - Response.AddHeader("Content-Length", Archivo.Length.ToString()) - Response.ContentType = "text/plain" - Response.Flush() - Response.TransmitFile(Archivo.FullName) - Response.End() - End If - End Sub - Public Sub LbDescargarExcel_Click(sender As Object, e As EventArgs) Handles LbDescargarExcelConceptos.Click - DescargarFormato() - End Sub - Private Sub CargarArchivo(Ruta As String, FileName As String, Tipo As String) - Dim dt As New DataTable - Dim Conexion As Odbc.OdbcConnection = Nothing - Dim ErrorArchivo = False - Dim n As Integer = 0 - Try - Select Case Tipo - Case "EXCEL" - Conexion = New Odbc.OdbcConnection("Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ=" + Ruta + FileName + ";") - Conexion.Open() - Dim cmd = Conexion.CreateCommand() - cmd.CommandType = CommandType.Text - cmd.CommandText = "Select * FROM [Hoja1$]" - Dim DataAdapter = New Odbc.OdbcDataAdapter(cmd) - DataAdapter.Fill(dt) - Case Else - Alert("El archivo no tiene el formato correcto", TipoMensaje.MsgError) - Exit Sub - End Select - Catch ex As Exception - ErrorArchivo = True - OnError("Ocurrio un Error al leer el archivo
" & ex.Message, ex) - End Try - Conexion.Close() - If Not ErrorArchivo Then - If Not dt.Columns(0).ColumnName = "Cantidad" Then - Alert("El nombre de la primera columna debe ser 'Cantidad'.Favor de corregirlo", TipoMensaje.MsgError) - Exit Sub - End If - If Not dt.Columns(1).ColumnName = "Código" Then - Alert("El nombre de la segunda columna debe ser 'Código'. Favor de corregirlo", TipoMensaje.MsgError) - Exit Sub - End If - 'If Not dt.Columns(2).ColumnName = "Codigo Barras" Then - ' Alert("El nombre de la tecera columna debe ser 'Codigo Barras'. Favor de corregirlo", TipoMensaje.MsgError) - ' Exit Sub - 'End If - If Not dt.Columns(2).ColumnName = "Producto/Servicio" Then - Alert("El nombre de la cuarta columna debe ser 'Producto/Servicio'. Favor de corregirlo", TipoMensaje.MsgError) - Exit Sub - End If - If Not dt.Columns(3).ColumnName = "UM" Then - Alert("El nombre de la quinta columna debe ser 'U.M'. Favor de corregirlo", TipoMensaje.MsgError) - Exit Sub - End If - If Not dt.Columns(4).ColumnName = "Precio Unitario" Then - Alert("El nombre de la sexta columna debe ser 'Precio Unitario'. Favor de corregirlo", TipoMensaje.MsgError) - Exit Sub - End If - - dt.TableName = "Datos" - - If Not ErrorArchivo Then - NumRow = 0 - Dim RowNoEncontrados As String = "" - Dim NumAgregados As Integer = 0 - For Each Row As DataRow In dt.Rows - Dim Cantidad As Decimal = Row("Cantidad").ToString.ToDecimal - Dim UM As String = Row("UM").ToString - Dim Codigo As String = Row("Código").ToString.Trim.ToUpper - 'Dim CodigoBarras As String = Row("Codigo Barras").ToString.Trim.ToUpper - Dim ProductoServicio As String = Row("Producto/Servicio").ToString.Trim.ToUpper - Dim PrecioUnitario As Decimal = Row("Precio Unitario").ToString.ToDecimal - - Dim CvePS As Integer = 0 - Dim CveUM As Integer = 0 - - NumRow = NumRow + 1 - - If Codigo <> "" Then - Dim StrArray() As String = GetPS("Codigo", Codigo).Split("|"c) - If StrArray.Length > 0 Then - If CBool(StrArray(0)) = True Then - CvePS = StrArray(1).ToEntero - Else - RowNoEncontrados &= StrArray(1) & "<\BR>" - End If - End If - 'ElseIf CodigoBarras <> "" Then - ' Dim StrArray() As String = GetPS("CodigoBarras", CodigoBarras).Split("|"c) - ' If StrArray.Length > 0 Then - ' If CBool(StrArray(0)) = True Then - ' CvePS = StrArray(1).ToEntero - ' Else - ' RowNoEncontrados &= StrArray(1) & "<\BR>" - ' End If - ' End If - ElseIf ProductoServicio <> "" Then - Dim StrArray() As String = GetPS("PS", ProductoServicio).Split("|"c) - If StrArray.Length > 0 Then - If CBool(StrArray(0)) = True Then - CvePS = StrArray(1).ToEntero - Else - RowNoEncontrados &= StrArray(1) & "<\BR>" - End If - End If - Else - RowNoEncontrados &= "<\BR>    - En la fila " & NumRow & " no se especificó código, código de barras ó descripción." - End If - - If CvePS > 0 Then - 'CveUM = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveUnidadMedida", $"CvePS = '{CvePS}'").ToString.ToEntero - - txtCantidad.Text = Cantidad.ToString - DdlProducto2.SelectedValue = CvePS.ToString - DdlProducto2.SelectedText = Codigo + " - " + ProductoServicio - txtPrecio.Text = PrecioUnitario.ToString - - ElProductoChange() - - AgregarPS() - txtPrecio.Text = "" - DdlUnidad.SelectedItem.Text = "" - NumAgregados = NumAgregados + 1 - - End If - - Next - - If RowNoEncontrados.Length > 0 Then - Alert("Se Cargaron " & NumAgregados & " Productos o Servicios.<\BR>Los siguientes Productos o Servicios no se encontraron en la Base de Datos.<\BR>" & RowNoEncontrados, TipoMensaje.MsgAdvertencia) - If NumAgregados > 0 Then - RegistraScript("$('#DivCargaExcel').modal('hide')", "hidemodal") - TxtExcel.Text = "[]" - End If - Else - Alert("Se Cargaron " & NumAgregados & " Productos o Servicios correctamente.") - RegistraScript("$('#DivCargaExcel').modal('hide')", "hidemodal") - TxtExcel.Text = "[]" - End If - End If - End If - dt.Dispose() - End Sub - Private Sub BtnCargaExcel_Click(sender As Object, e As EventArgs) Handles BtnCargaExcel.Click - If DdlAlmacen.SelectedValue.ToEntero > 0 Then - If TxtExcel.getfiles().Archivos.Count > 0 Then - Dim file As Archivo = TxtExcel.getfiles().Archivos(0) - Dim Directorio As String = AppDomain.CurrentDomain.BaseDirectory & file.patch - Dim Tipo As String = If(file.Extencion.Contiene("xlsx", "xlsx", "xlsm", "xlsb", "xls"), "EXCEL", "CSV") - CargarArchivo(Directorio, file.filename, Tipo) - Else - Alert("No existe el archivo. Favor de subir un archivo excel a la plataforma.", TipoMensaje.MsgError) - End If - Else - Alert("Seleccione un almacén", TipoMensaje.MsgAdvertencia) - RegistraScript("$('#DivCargaExcel').modal('hide')", "hidemodal") - End If - End Sub - Private Function GetPS(Opt As String, Valor As String) As String - Dim StrReturn As String = String.Empty - Dim CvePS As Integer = 0 - CvePS = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CvePS", Opt & " = '" & Valor & "'").ToString.ToEntero - If CvePS > 0 Then - StrReturn = "True|" & CvePS.ToString - Else - StrReturn = "False|    - No se encontró " & Valor & " en la fila " & NumRow & ", columna " & Opt - End If - Return StrReturn - End Function -#End Region - Protected Sub LnkAgregarNuevoMov_Click(sender As Object, e As EventArgs) - EsNuevoMov = True - - For Each gvr As GridViewRow In GvM.Rows - If (gvr.RowState <> 5 AndAlso gvr.RowState <> DataControlRowState.Edit) Then GvM.Rows(gvr.RowIndex).FCLinkButton("lnkRemove").Visible = True - Next - - If DdlAlmacen.Visible Then DdlAlmacen.Enabled = True - DdlAlmacen.SelectedValueExist(-1) - If DdlConcepto.Visible Then DdlConcepto.Enabled = True - DdlConcepto.SelectedValueExist(-1) - If TxtDepartamentoEntrega.Visible Then TxtDepartamentoEntrega.Enabled = True - If TxtPedidoContrato.Visible Then TxtPedidoContrato.Enabled = True - If TxtFolio.Visible Then TxtFolio.Enabled = True - If TxtFecha.Visible Then TxtFecha.Enabled = True - If TxtResponsable.Visible Then TxtResponsable.Enabled = True - If TxtObservaciones.Visible Then TxtObservaciones.Enabled = True - If DdlProveedor.Visible Then DdlProveedor.Enabled = True - If TxtRemision.Visible Then TxtRemision.Enabled = True - If DdlMoneda.Visible Then DdlMoneda.Enabled = True - If TxtGuia.Visible Then TxtGuia.Enabled = True - If DdlSeccion.Visible Then DdlSeccion.Enabled = True - - If BtnEliminar.Visible Then BtnEliminar.Visible = False - - LnkAgregarNuevoMov.Visible = False - End Sub - -#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("SeccionAlmacen", GetType(String)) - DtSeccionAlmacen.Columns.Add("Consec", GetType(Integer)) - End Sub - Private Sub CargaDdlAlmacen() - DdlSeccionAlmacenModal.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa) - DdlSeccionAlmacenModal.Items.Insert(0, New ListItem("Seleccione", "-1")) - DdlSeccionAlmacenModal.DataBind() - End Sub - Protected Sub LnkSeccionAlmacen_Click(sender As Object, e As EventArgs) - If Not DdlConcepto.SelectedValue.ToEntero > 0 Then - Alert("Tiene que seleccionar un concepto", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - Tipo = GlobalDTInvConceptos().FiltroPrimeroValor("Origen", $"CveConcepto = {DdlConcepto.SelectedValue}").ToEntero - Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) - CantidadTotal = gvRow.DataKey("Cantidad").ToDecimal - IndexSeccionAlmacen = gvRow.RowIndex - CargaSeccionAlmacen() - RegistraScript("$('#DModalSeccionAlmacen').modal()") - End Sub - - Private Sub CargaSeccionAlmacen() - Dim CantidadTotalSeccion As Decimal = DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {IndexSeccionAlmacen}").SUMD("CantidadSeccionAlmacen") - GvSeccionAlmacen.DataSource = DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {IndexSeccionAlmacen}") - GvSeccionAlmacen.DataBind() - - TxtCantidadSeccion.Text = "" - DdlSeccionAlmacenModal.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 - GvM.Rows(IndexSeccionAlmacen).FCLinkButton("imgE").Visible = False - GvM.Rows(IndexSeccionAlmacen).FCLinkButton("imgE").ToolTip = "Cuenta con sección almacen" - GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").Visible = False - GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").ToolTip = "Cuenta con sección almacen" - GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkDividir").Visible = False - GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkDividir").ToolTip = "Cuenta con sección almacen" - Else - GvM.Rows(IndexSeccionAlmacen).FCLinkButton("imgE").Visible = True - GvM.Rows(IndexSeccionAlmacen).FCLinkButton("imgE").ToolTip = "" - GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").Visible = True - GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").ToolTip = "" - GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkDividir").Visible = True - GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkDividir").ToolTip = "" - End If - - If DtSeccionAlmacen.SUMD("CantidadSeccionAlmacen") > 0 AndAlso Tipo = -1 Then - DdlAlmacen.Enabled = False - DdlAlmacen.ToolTip = "Cuenta con sección almacen" - Else - DdlAlmacen.Enabled = True - DdlAlmacen.ToolTip = "" - End If - - UpModalSeccionAlmacen.Update() - UppGrid.Update() - End Sub - - Protected Sub LnkAddSeccionAlmacen_Click(sender As Object, e As EventArgs) - If Tipo = -1 Then - Dim ObjInv As New ClsInventarios - Dim CantidadDisponible As Decimal = 0 - If ObjInv.GetMovimientosDetalleSeccionesAlmacen(DdlSeccionAlmacenModal.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 = {DdlSeccionAlmacenModal.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 - End If - - Dim Row As DataRow = Nothing - DtSeccionAlmacen.AcceptChanges() - Row = DtSeccionAlmacen.NewRow - Row("CantidadSeccionAlmacen") = TxtCantidadSeccion.Text.ToDecimal - Row("IndexSeccionAlmacen") = IndexSeccionAlmacen - Row("CveSeccionAlmacen") = DdlSeccionAlmacenModal.SelectedValue.ToEntero - Row("SeccionAlmacen") = DdlSeccionAlmacenModal.SelectedItem.Text - 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 - -#End Region - -End Class + Else + CveMovimientoEntrada = -1 + End If + + 'MOVIMIENTO DE SALIDA + If DtMovimientosSalidaInvFisico.Rows.Count > 0 Then + Dim FolioSalida As Integer = ObjInventario.GetFolioSiguiente(34, UsuarioActual.CveEmpresa) + CveMovimientoSalida = ObjInventario.AddMovimiento(DdlAlmacenInventarioFisico.SelectedValue.ToEntero, 34, 1, Fecha, FolioSalida, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, CveMovimientoRelacionado:=CveMovimientoEntrada, Observaciones:=TxtIFDescripcion.Text.Trim) + + End If + + 'Registro PrePoliza + Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Inv/E/S INVENTARIO FISICO", 53, 0, 0, 1, Fecha, TxtIFDescripcion.Text.Trim, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoPoliza:=3) + + 'VALIDA, sino hay registrado ningun movimiento, que no siga + If (CveMovimientoEntrada <= 0 AndAlso CveMovimientoSalida <= 0) Or CvePrePoliza <= 0 Then + Alert("Ocurrió un error al realizar los registros. Por favor verifique y vuelva a intentar", TipoMensaje.MsgError) + RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") + ObjInventario.RollBack() 'deshace lo insertado. + ObjInventario.Dispose() 'elimino la instancia + Exit Sub + End If + + 'VALIDA EXISTENCIAS SALIDA E INSERTA DETALLES + For Each Dr As DataRow In DtMovimientosSalidaInvFisico.Rows + If ObjInventario.GetExistenciasPS(Dr("CvePS").ToString.ToEntero, Dr("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacenInventarioFisico.SelectedValue.ToEntero) >= Dr("Cantidad").ToString.ToDouble Then + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, -1) Then + Mensaje = "Ocurrió un error al guardar los movimientos de salida" + ErrorMovInv = True + Exit For + End If + Else + Mensaje = String.Format("No hay existencias suficientes del producto: {0}", Dr("PS")) + RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") + ErrorMovInv = True + Exit For + End If + Next + + If Not ErrorMovInv Then + For Each Dr As DataRow In DtMovimientosEntradaInvFisico.Rows + ImporteConcepto = Dr("PU").ToString.ToDecimal + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, ImporteConcepto, -1) Then + Mensaje = "Ocurrió un error al guardar los movimientos de entrada" + ErrorMovInv = True + Exit For + End If + Next + End If + + 'Obtiene valor entrada + If Not ErrorMovInv AndAlso CveMovimientoEntrada > 0 Then + If ObjInventario.GetMovimientosDetalle(CveMovimientoEntrada, UsuarioActual.CveEmpresa) Then + Dim tValorInventario As Decimal = ObjInventario.DtResultados.SUMD("Total", "").RoundSQL() + ValorEntrada = tValorInventario + + Dim drA2 As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveAlmacen = {0}", DdlAlmacenInventarioFisico.SelectedValue)) + If drA2 IsNot Nothing Then + idCtaContableEntrada = drA2("IdCtaContable").ToString.ToEntero + tCveSubProyecto = drA2("CveSubProyecto").ToString.ToEntero + End If + Else + ErrorMovInv = True + Mensaje = "Ocurrió un error al validar los movimientos contables de entrada" + End If + End If + + 'Obtiene valor salida + If Not ErrorMovInv AndAlso CveMovimientoSalida > 0 Then + If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then + Dim tValorInventario As Decimal = ObjInventario.DtResultados.SUM("Total", "").ToDecimal.RoundSQL() + ValorSalida = tValorInventario + Dim drA2 As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveAlmacen = {0}", DdlAlmacenInventarioFisico.SelectedValue)) + If drA2 IsNot Nothing Then idCtaContableSalida = drA2("IdCtaContable").ToString.ToEntero + Else + ErrorMovInv = True + Mensaje = "Ocurrió un error al validar los movimientos contables de salida" + End If + End If + + If Not ErrorMovInv Then + 'NOTA + ' cuando el valor entrada sea mayor al de salida, el valor de salida debe de ser negativo y cargado + ' cuando el valor salida sea mayor al de entrada, el valor de entrada debe de ser negativo y abonado + + 'Registro la prepólizaDetalle Entradas + If CveMovimientoEntrada > 0 Then + TipoMovto = False + If ValorEntrada <= ValorSalida Then + TipoMovto = True : ValorEntrada = -ValorEntrada ' invierto su naturaleza + End If + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, ValorEntrada, "", 68, tConcepto, Fecha, idCtaContableEntrada, -1, CveMovimientoAlmacen:=CveMovimientoEntrada, ImporteMX:=ValorEntrada) Then + ErrorMovInv = True + Mensaje = "Ocurrió un error al guardar los movimientos contables de entrada" + End If + End If + + 'Registro la prepólizaDetalle Salidas + If CveMovimientoSalida > 0 Then + TipoMovto = True + If ValorSalida < ValorEntrada Then + TipoMovto = False : ValorSalida = -ValorSalida ' invierto su naturaleza + End If + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, ValorSalida, "", 68, tConcepto, Fecha, idCtaContableSalida, -1, CveMovimientoAlmacen:=CveMovimientoSalida, ImporteMX:=ValorSalida) Then + ErrorMovInv = True + Mensaje = "Ocurrió un error al guardar los movimientos contables de salida" + End If + End If + + If ValorEntrada >= ValorSalida Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ValorEntrada + ValorSalida, "", 260, tConcepto, Fecha, IdCuentaOtrosIngresos, -1, CveMovimientoAlmacen:=CveMovimientoSalida, CveSubProyecto:=tCveSubProyecto, ImporteMX:=ValorEntrada + ValorSalida) Then + ErrorMovInv = True + Mensaje = "Ocurrió un error al guardar los movimientos contables de ajuste de ingreso" + End If + ElseIf ValorSalida >= ValorEntrada Then + 'inserta el gasto + Dim dr As DataRow = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimero("") + Dim tCveClasificacion As Integer = -1 + Dim tIdCtaGasto As Integer = -1 + If dr IsNot Nothing Then + tCveClasificacion = dr("CveClasificacion").ToString.ToEntero + tIdCtaGasto = dr("IdCuentaGasto").ToString.ToEntero + End If + + '[IPP] PARCHE - CUENTA CONTABLE DIRECTA + Select Case UsuarioActual.CveEmpresa + Case 119 + tIdCtaGasto = 1321 + End Select + + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ValorSalida + ValorEntrada, "", 51, tConcepto, Fecha, tIdCtaGasto, -1, CveMovimientoAlmacen:=CveMovimientoSalida, CveClasificacion:=tCveClasificacion, CveSubProyecto:=tCveSubProyecto, ImporteMX:=ValorSalida + ValorEntrada) Then + ErrorMovInv = True + Mensaje = "Ocurrió un error al guardar los movimientos contables de ajuste de salida" + End If + End If + End If + + + + If Not ErrorMovInv Then + If ObjConta.ValidacionPrePolizaCuadre(CvePrePoliza, -1) Then + ObjConta.GetPrePolizasDetalle(CvePrePoliza) + If ObjConta.ValorPolizaDescuadre > 0 Then + ErrorMovInv = True + Mensaje = "Ocurrió un error al validar los movimientos contables" + End If + End If + End If + + If Not ErrorMovInv Then + ObjInventario.Commit() ' aplica los movimientos insertados + + Dim Msg As New StringBuilder + Msg.AppendFormat("
El Movimiento se registro con el Folio: {0}", ObjInventario.Folio) + If CveMovimientoEntrada > 0 Then Msg.AppendFormat("

Imprimir Movimiento Entrada ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoEntrada))) + If CveMovimientoSalida > 0 Then Msg.AppendFormat("

Imprimir Movimiento Salida ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoSalida))) + Alert(Msg.ToString, TipoMensaje.MsgInformacion) + + RegistraScript("playsonidito('beep-07.wav')") + RegistraScript(String.Format("$('#{0}').modal('hide');", "DivModalCambioFisico")) + GvEntradas.DataBind() + GvSalidas.DataBind() + TxtIFDescripcion.Text = "" + + Else + ObjInventario.RollBack() + + Alert(Mensaje, TipoMensaje.MsgError) + + RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") + End If + ObjInventario.Dispose() 'elimino la instancia + + End Sub +#End Region + +#End Region + + + Private Sub GuardarBitacora(CveVenta As Integer, RutaAdjunto As String, Obser As String) + Dim ObjEventos As New ClsOIEventos() + + + Try + If ObjEventos.AddEventoBitacora(Obser, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveVenta:=CveVenta) Then + + + End If + Catch ex As Exception + OnError("Se presento un error al guardar la Bitacora", ex) + End Try + + ObjEventos.Dispose() + + End Sub + +#Region "DESCARGAR E IMPRIMIR LISTADO" + Public Sub DescargarFormato() + Dim Directorio As String = AppDomain.CurrentDomain.BaseDirectory & "Empresas\Grales\Formatos\FormatoEntradasSalidas.xlsx" + + Dim Archivo As New IO.FileInfo(Directorio) + If Archivo.Exists Then + Response.Clear() + Response.ClearHeaders() + Response.ClearContent() + Response.AddHeader("Content-Disposition", "attachment; filename=" + Archivo.Name) + Response.AddHeader("Content-Length", Archivo.Length.ToString()) + Response.ContentType = "text/plain" + Response.Flush() + Response.TransmitFile(Archivo.FullName) + Response.End() + End If + End Sub + Public Sub LbDescargarExcel_Click(sender As Object, e As EventArgs) Handles LbDescargarExcelConceptos.Click + DescargarFormato() + End Sub + Private Sub CargarArchivo(Ruta As String, FileName As String, Tipo As String) + Dim dt As New DataTable + Dim Conexion As Odbc.OdbcConnection = Nothing + Dim ErrorArchivo = False + Dim n As Integer = 0 + Try + Select Case Tipo + Case "EXCEL" + Conexion = New Odbc.OdbcConnection("Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ=" + Ruta + FileName + ";") + Conexion.Open() + Dim cmd = Conexion.CreateCommand() + cmd.CommandType = CommandType.Text + cmd.CommandText = "Select * FROM [Hoja1$]" + Dim DataAdapter = New Odbc.OdbcDataAdapter(cmd) + DataAdapter.Fill(dt) + Case Else + Alert("El archivo no tiene el formato correcto", TipoMensaje.MsgError) + Exit Sub + End Select + Catch ex As Exception + ErrorArchivo = True + OnError("Ocurrio un Error al leer el archivo
" & ex.Message, ex) + End Try + Conexion.Close() + If Not ErrorArchivo Then + If Not dt.Columns(0).ColumnName = "Cantidad" Then + Alert("El nombre de la primera columna debe ser 'Cantidad'.Favor de corregirlo", TipoMensaje.MsgError) + Exit Sub + End If + If Not dt.Columns(1).ColumnName = "Código" Then + Alert("El nombre de la segunda columna debe ser 'Código'. Favor de corregirlo", TipoMensaje.MsgError) + Exit Sub + End If + 'If Not dt.Columns(2).ColumnName = "Codigo Barras" Then + ' Alert("El nombre de la tecera columna debe ser 'Codigo Barras'. Favor de corregirlo", TipoMensaje.MsgError) + ' Exit Sub + 'End If + If Not dt.Columns(2).ColumnName = "Producto/Servicio" Then + Alert("El nombre de la cuarta columna debe ser 'Producto/Servicio'. Favor de corregirlo", TipoMensaje.MsgError) + Exit Sub + End If + If Not dt.Columns(3).ColumnName = "UM" Then + Alert("El nombre de la quinta columna debe ser 'U.M'. Favor de corregirlo", TipoMensaje.MsgError) + Exit Sub + End If + If Not dt.Columns(4).ColumnName = "Precio Unitario" Then + Alert("El nombre de la sexta columna debe ser 'Precio Unitario'. Favor de corregirlo", TipoMensaje.MsgError) + Exit Sub + End If + + dt.TableName = "Datos" + + If Not ErrorArchivo Then + NumRow = 0 + Dim RowNoEncontrados As String = "" + Dim NumAgregados As Integer = 0 + For Each Row As DataRow In dt.Rows + Dim Cantidad As Decimal = Row("Cantidad").ToString.ToDecimal + Dim UM As String = Row("UM").ToString + Dim Codigo As String = Row("Código").ToString.Trim.ToUpper + 'Dim CodigoBarras As String = Row("Codigo Barras").ToString.Trim.ToUpper + Dim ProductoServicio As String = Row("Producto/Servicio").ToString.Trim.ToUpper + Dim PrecioUnitario As Decimal = Row("Precio Unitario").ToString.ToDecimal + + Dim CvePS As Integer = 0 + Dim CveUM As Integer = 0 + + NumRow = NumRow + 1 + + If Codigo <> "" Then + Dim StrArray() As String = GetPS("Codigo", Codigo).Split("|"c) + If StrArray.Length > 0 Then + If CBool(StrArray(0)) = True Then + CvePS = StrArray(1).ToEntero + Else + RowNoEncontrados &= StrArray(1) & "<\BR>" + End If + End If + 'ElseIf CodigoBarras <> "" Then + ' Dim StrArray() As String = GetPS("CodigoBarras", CodigoBarras).Split("|"c) + ' If StrArray.Length > 0 Then + ' If CBool(StrArray(0)) = True Then + ' CvePS = StrArray(1).ToEntero + ' Else + ' RowNoEncontrados &= StrArray(1) & "<\BR>" + ' End If + ' End If + ElseIf ProductoServicio <> "" Then + Dim StrArray() As String = GetPS("PS", ProductoServicio).Split("|"c) + If StrArray.Length > 0 Then + If CBool(StrArray(0)) = True Then + CvePS = StrArray(1).ToEntero + Else + RowNoEncontrados &= StrArray(1) & "<\BR>" + End If + End If + Else + RowNoEncontrados &= "<\BR>    - En la fila " & NumRow & " no se especificó código, código de barras ó descripción." + End If + + If CvePS > 0 Then + 'CveUM = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveUnidadMedida", $"CvePS = '{CvePS}'").ToString.ToEntero + + txtCantidad.Text = Cantidad.ToString + DdlProducto2.SelectedValue = CvePS.ToString + DdlProducto2.SelectedText = Codigo + " - " + ProductoServicio + txtPrecio.Text = PrecioUnitario.ToString + + ElProductoChange() + + AgregarPS() + txtPrecio.Text = "" + DdlUnidad.SelectedItem.Text = "" + NumAgregados = NumAgregados + 1 + + End If + + Next + + If RowNoEncontrados.Length > 0 Then + Alert("Se Cargaron " & NumAgregados & " Productos o Servicios.<\BR>Los siguientes Productos o Servicios no se encontraron en la Base de Datos.<\BR>" & RowNoEncontrados, TipoMensaje.MsgAdvertencia) + If NumAgregados > 0 Then + RegistraScript("$('#DivCargaExcel').modal('hide')", "hidemodal") + TxtExcel.Text = "[]" + End If + Else + Alert("Se Cargaron " & NumAgregados & " Productos o Servicios correctamente.") + RegistraScript("$('#DivCargaExcel').modal('hide')", "hidemodal") + TxtExcel.Text = "[]" + End If + End If + End If + dt.Dispose() + End Sub + Private Sub BtnCargaExcel_Click(sender As Object, e As EventArgs) Handles BtnCargaExcel.Click + If DdlAlmacen.SelectedValue.ToEntero > 0 Then + If TxtExcel.getfiles().Archivos.Count > 0 Then + Dim file As Archivo = TxtExcel.getfiles().Archivos(0) + Dim Directorio As String = AppDomain.CurrentDomain.BaseDirectory & file.patch + Dim Tipo As String = If(file.Extencion.Contiene("xlsx", "xlsx", "xlsm", "xlsb", "xls"), "EXCEL", "CSV") + CargarArchivo(Directorio, file.filename, Tipo) + Else + Alert("No existe el archivo. Favor de subir un archivo excel a la plataforma.", TipoMensaje.MsgError) + End If + Else + Alert("Seleccione un almacén", TipoMensaje.MsgAdvertencia) + RegistraScript("$('#DivCargaExcel').modal('hide')", "hidemodal") + End If + End Sub + Private Function GetPS(Opt As String, Valor As String) As String + Dim StrReturn As String = String.Empty + Dim CvePS As Integer = 0 + CvePS = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CvePS", Opt & " = '" & Valor & "'").ToString.ToEntero + If CvePS > 0 Then + StrReturn = "True|" & CvePS.ToString + Else + StrReturn = "False|    - No se encontró " & Valor & " en la fila " & NumRow & ", columna " & Opt + End If + Return StrReturn + End Function +#End Region + Protected Sub LnkAgregarNuevoMov_Click(sender As Object, e As EventArgs) + EsNuevoMov = True + + For Each gvr As GridViewRow In GvM.Rows + If (gvr.RowState <> 5 AndAlso gvr.RowState <> DataControlRowState.Edit) Then GvM.Rows(gvr.RowIndex).FCLinkButton("lnkRemove").Visible = True + Next + + If DdlAlmacen.Visible Then DdlAlmacen.Enabled = True + DdlAlmacen.SelectedValueExist(-1) + If DdlConcepto.Visible Then DdlConcepto.Enabled = True + DdlConcepto.SelectedValueExist(-1) + If TxtDepartamentoEntrega.Visible Then TxtDepartamentoEntrega.Enabled = True + If TxtPedidoContrato.Visible Then TxtPedidoContrato.Enabled = True + If TxtFolio.Visible Then TxtFolio.Enabled = True + If TxtFecha.Visible Then TxtFecha.Enabled = True + If TxtResponsable.Visible Then TxtResponsable.Enabled = True + If TxtObservaciones.Visible Then TxtObservaciones.Enabled = True + If DdlProveedor.Visible Then DdlProveedor.Enabled = True + If TxtRemision.Visible Then TxtRemision.Enabled = True + If DdlMoneda.Visible Then DdlMoneda.Enabled = True + If TxtGuia.Visible Then TxtGuia.Enabled = True + If DdlSeccion.Visible Then DdlSeccion.Enabled = True + + If BtnEliminar.Visible Then BtnEliminar.Visible = False + + LnkAgregarNuevoMov.Visible = False + End Sub + +#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("SeccionAlmacen", GetType(String)) + DtSeccionAlmacen.Columns.Add("Consec", GetType(Integer)) + End Sub + Private Sub CargaDdlAlmacen() + DdlSeccionAlmacenModal.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa) + DdlSeccionAlmacenModal.Items.Insert(0, New ListItem("Seleccione", "-1")) + DdlSeccionAlmacenModal.DataBind() + End Sub + Protected Sub LnkSeccionAlmacen_Click(sender As Object, e As EventArgs) + If Not DdlConcepto.SelectedValue.ToEntero > 0 Then + Alert("Tiene que seleccionar un concepto", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + Tipo = GlobalDTInvConceptos().FiltroPrimeroValor("Origen", $"CveConcepto = {DdlConcepto.SelectedValue}").ToEntero + Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) + CantidadTotal = gvRow.DataKey("Cantidad").ToDecimal + IndexSeccionAlmacen = gvRow.RowIndex + CargaSeccionAlmacen() + RegistraScript("$('#DModalSeccionAlmacen').modal()") + End Sub + + Private Sub CargaSeccionAlmacen() + Dim CantidadTotalSeccion As Decimal = DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {IndexSeccionAlmacen}").SUMD("CantidadSeccionAlmacen") + GvSeccionAlmacen.DataSource = DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {IndexSeccionAlmacen}") + GvSeccionAlmacen.DataBind() + + TxtCantidadSeccion.Text = "" + DdlSeccionAlmacenModal.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 + GvM.Rows(IndexSeccionAlmacen).FCLinkButton("imgE").Visible = False + GvM.Rows(IndexSeccionAlmacen).FCLinkButton("imgE").ToolTip = "Cuenta con sección almacen" + GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").Visible = False + GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").ToolTip = "Cuenta con sección almacen" + GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkDividir").Visible = False + GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkDividir").ToolTip = "Cuenta con sección almacen" + Else + GvM.Rows(IndexSeccionAlmacen).FCLinkButton("imgE").Visible = True + GvM.Rows(IndexSeccionAlmacen).FCLinkButton("imgE").ToolTip = "" + GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").Visible = True + GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").ToolTip = "" + GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkDividir").Visible = True + GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkDividir").ToolTip = "" + End If + + If DtSeccionAlmacen.SUMD("CantidadSeccionAlmacen") > 0 AndAlso Tipo = -1 Then + DdlAlmacen.Enabled = False + DdlAlmacen.ToolTip = "Cuenta con sección almacen" + Else + DdlAlmacen.Enabled = True + DdlAlmacen.ToolTip = "" + End If + + UpModalSeccionAlmacen.Update() + UppGrid.Update() + End Sub + + Protected Sub LnkAddSeccionAlmacen_Click(sender As Object, e As EventArgs) + If Tipo = -1 Then + Dim ObjInv As New ClsInventarios + Dim CantidadDisponible As Decimal = 0 + If ObjInv.GetMovimientosDetalleSeccionesAlmacen(DdlSeccionAlmacenModal.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 = {DdlSeccionAlmacenModal.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 + End If + + Dim Row As DataRow = Nothing + DtSeccionAlmacen.AcceptChanges() + Row = DtSeccionAlmacen.NewRow + Row("CantidadSeccionAlmacen") = TxtCantidadSeccion.Text.ToDecimal + Row("IndexSeccionAlmacen") = IndexSeccionAlmacen + Row("CveSeccionAlmacen") = DdlSeccionAlmacenModal.SelectedValue.ToEntero + Row("SeccionAlmacen") = DdlSeccionAlmacenModal.SelectedItem.Text + 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 + +#End Region + +End Class diff --git a/Inventarios/KardexSeccionAlmacen.aspx.vb b/Inventarios/KardexSeccionAlmacen.aspx.vb index cb541e0ee..d242ead2e 100644 --- a/Inventarios/KardexSeccionAlmacen.aspx.vb +++ b/Inventarios/KardexSeccionAlmacen.aspx.vb @@ -1,328 +1,337 @@ -Option Strict On Imports System.Data Imports System.Collections.Generic Imports System.Linq Imports System.Web Imports System.Web.UI.WebControls Imports Extensiones -Partial Class Inventarios_KardexSeccionAlmacen - Inherits ClsPaginas - - -#Region "PROPIEDADES" - Private Property DtSeccionAlmacen As DataTable - Get - Return CType(ViewState("DtSeccionAlmacen"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtSeccionAlmacen") = value - End Set - End Property - Private Property CantidadTotal As Decimal - Get - Return CType(ViewState("CantidadTotal"), Decimal) - End Get - Set(value As Decimal) - ViewState("CantidadTotal") = value - End Set - End Property - Private Property CvePS As Integer - Get - Return CType(ViewState("CvePS"), Integer) - End Get - Set(value As Integer) - ViewState("CvePS") = value - End Set - End Property - Private Property CveSeccionAlmacenOrigen As Integer - Get - Return CType(ViewState("CveSeccionAlmacenOrigen"), Integer) - End Get - Set(value As Integer) - ViewState("CveSeccionAlmacenOrigen") = value - End Set - End Property - Private Property SeccionAlmacenOrigen As String - Get - Return CType(ViewState("SeccionAlmacenOrigen"), String) - End Get - Set(value As String) - ViewState("SeccionAlmacenOrigen") = value - End Set - End Property - Private Property CveAlmacen As Integer - Get - Return CType(ViewState("CveAlmacen"), Integer) - End Get - Set(value As Integer) - ViewState("CveAlmacen") = value - End Set - End Property - Private Property CveUM As Integer - Get - Return CType(ViewState("CveUM"), Integer) - End Get - Set(value As Integer) - ViewState("CveUM") = 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 SerieLote As String - Get - Return CType(ViewState("SerieLote"), String) - End Get - Set(value As String) - ViewState("SerieLote") = value - End Set - End Property - - -#End Region - - Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load - If Not IsPostBack Then - InicializaValores() End If End Sub - -#Region "CARGAS" - - Private Sub InicializaValores() - CantidadTotal = 0 - SeccionAlmacenOrigen = "" - CvePS = 0 - CveAlmacen = 0 - CveSeccionAlmacenOrigen = 0 - CveSubProyecto = 0 - CveUM = 0 - SerieLote = "" - - CreaDtSeccionAlmacen() - CargaDdlAlmacen() - CargaPS() - End Sub - - Private Sub CargaPS() - DdlPS.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1") - - If UsuarioActual.Empresa.Funcionalidad(105) = "1" Then - DdlPS.ddlWS.Attributes.Add("data-cveclasificacion", "-1") - DdlPS.SelectedText = "Seleccione" - DdlPS.SelectedValue = "-1" - Else - DdlPS.ddl.Items.Clear() - DdlPS.ddl.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa) - DdlPS.ddl.DataBind() - DdlPS.ddl.Items.Insert(0, New ListItem("Seleccione", "-1")) - End If - End Sub - - Private Sub CargaDdlAlmacen() - DdlAlmacen.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa) - DdlAlmacen.Items.Insert(0, New ListItem("Seleccione", "-1")) - DdlAlmacen.DataBind() - - DdlSeccionAlmacen.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa) - DdlSeccionAlmacen.Items.Insert(0, New ListItem("Todos", "-1")) - DdlSeccionAlmacen.DataBind() - - DdlSeccionAlmacenDestino.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa) - DdlSeccionAlmacenDestino.Items.Insert(0, New ListItem("Seleccione", "-1")) - DdlSeccionAlmacenDestino.DataBind() - End Sub - - Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) - CargaDatos() - End Sub - - Private Sub CargaDatos() - If Not DdlPS.SelectedValue.ToEntero > 0 Then - Alert("Tiene que seleccionar un producto/servicio.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - If Not DdlAlmacen.SelectedValue.ToEntero > 0 Then - Alert("Tiene que seleccionar un alamacen.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - Dim ObjInv As New ClsInventarios - If ObjInv.GetKardexSeccionAlmacen(DdlPS.SelectedValue.ToEntero, DdlAlmacen.SelectedValue.ToEntero, DdlSeccionAlmacen.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then - GvDatos.DataSource = ObjInv.DtResultados - End If - ObjInv.Dispose() - GvDatos.DataBind() - UpDatos.Update() - End Sub - -#End Region - - -#Region "SECCION ALMACEN" - Private Sub CreaDtSeccionAlmacen() - DtSeccionAlmacen = New DataTable - DtSeccionAlmacen.Columns.Add("CantidadSeccionAlmacen", GetType(Decimal)) - DtSeccionAlmacen.Columns.Add("CveSeccionAlmacenOrigen", GetType(Integer)) - DtSeccionAlmacen.Columns.Add("CveSeccionAlmacenDestino", GetType(Integer)) - DtSeccionAlmacen.Columns.Add("SeccionAlmacenOrigen", GetType(String)) - DtSeccionAlmacen.Columns.Add("SeccionAlmacenDestino", GetType(String)) - DtSeccionAlmacen.Columns.Add("Consec", GetType(Integer)) - End Sub - - Protected Sub LnkSeccionAlmacen_Click(sender As Object, e As EventArgs) - Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) - DtSeccionAlmacen.Rows.Clear() - CantidadTotal = gvRow.DataKey("Existencia").ToDecimal - CveSeccionAlmacenOrigen = gvRow.DataKey("CveAlmacenSeccion").ToEntero - SeccionAlmacenOrigen = gvRow.DataKey("AlmacenSeccion").ToString - CvePS = gvRow.DataKey("CvePS").ToEntero - SerieLote = gvRow.DataKey("SerieLote").ToString - CveAlmacen = gvRow.DataKey("CveAlmacen").ToEntero - CveUM = gvRow.DataKey("CveUM").ToEntero - CveSubProyecto = gvRow.DataKey("CveSubProyecto").ToEntero - RegistraScript("$('#DModalSeccionAlmacen').modal()") - CargaSeccionAlmacen() - 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(CveSeccionAlmacenOrigen, CveAlmacen, 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.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("CveSeccionAlmacenOrigen") = CveSeccionAlmacenOrigen - Row("SeccionAlmacenOrigen") = SeccionAlmacenOrigen - Row("CveSeccionAlmacenDestino") = DdlSeccionAlmacenDestino.SelectedValue.ToEntero - Row("SeccionAlmacenDestino") = DdlSeccionAlmacenDestino.SelectedItem.Text - 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 - - Private Sub CargaSeccionAlmacen() - Dim CantidadTotalSeccion As Decimal = DtSeccionAlmacen.SUMD("CantidadSeccionAlmacen") - GvSeccion.DataSource = DtSeccionAlmacen - GvSeccion.DataBind() - - TxtCantidadSeccion.Text = "" - DdlSeccionAlmacenDestino.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 - - UpModalSeccionAlmacen.Update() - End Sub - - Protected Sub BtnTraspasar_Click(sender As Object, e As EventArgs) - Dim ObjInv As New ClsInventarios - ObjInv.IniciaTransacSQL() - Dim TieneError As Boolean = False - Dim MensajeError As String = "" - - 'SALIDA - Dim CveMovimientoSalida As Integer = ObjInv.AddMovimiento(DdlAlmacen.SelectedValue.ToEntero, 3, 1, Now, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, CveSubProyecto, -1, CveAlmacenDestino:=CveAlmacen) - - If CveMovimientoSalida <= 0 Then - TieneError = True - MensajeError = "Ocurrió un error al guardar el movimiento de salida. Por favor vuelva a intentar." - End If - - Dim Cantidad As Decimal = DtSeccionAlmacen.SUMD("CantidadSeccionAlmacen") - - If Not ObjInv.AddMovimientoDetalle(CveMovimientoSalida, Cantidad, CveUM, CvePS, 0, -1, SerieLote:=SerieLote) Then - MensajeError = "Ocurrió un error al guardar los detalles del movimiento de salida. Por favor vuelva a intentar." - TieneError = True - Else - If ObjInv.CveMovimientoDetalle > 0 AndAlso DtSeccionAlmacen.Rows.Count > 0 Then - For Each Dr2 As DataRow In DtSeccionAlmacen.Rows - If Not ObjInv.AddMovimientosDetalleSeccionesAlmacen(ObjInv.CveMovimientoDetalle, Dr2("CveSeccionAlmacenOrigen").ToString.ToEntero, -Dr2("CantidadSeccionAlmacen").ToString.ToDecimal) Then - TieneError = True - MensajeError = "Ocurrió un error al procesar las secciones de almacen. Por favor vuelva a intentar." - Exit For - End If - Next - End If - End If - - 'ENTRADA - If Not TieneError Then - Dim CveMovimientoEntrada As Integer = ObjInv.AddMovimiento(CveAlmacen, 2, 1, Now, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, CveSubProyecto, -1, CveMovimientoRelacionado:=CveMovimientoSalida) - - If CveMovimientoEntrada <= 0 Then - MensajeError = "Ocurrió un error al guardar el movimiento de entrada correctamente. Por favor vuelva a intentar." - TieneError = True - Else - If ObjInv.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then - For Each Dr As DataRow In ObjInv.DtResultados.Rows - If Not ObjInv.AddMovimientoDetalle(CveMovimientoEntrada, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDouble, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, Dr("Observaciones").ToString) Then - TieneError = True - MensajeError = "Ocurrió un error al guardar los movimientos de entrada" - Exit For - Else - If ObjInv.CveMovimientoDetalle > 0 AndAlso DtSeccionAlmacen.Rows.Count > 0 Then - For Each Dr2 As DataRow In DtSeccionAlmacen.Rows - If Not ObjInv.AddMovimientosDetalleSeccionesAlmacen(ObjInv.CveMovimientoDetalle, Dr2("CveSeccionAlmacenDestino").ToString.ToEntero, Dr2("CantidadSeccionAlmacen").ToString.ToDecimal) Then - TieneError = True - MensajeError = "Ocurrió un error al procesar las secciones de almacen. Por favor vuelva a intentar." - Exit For - End If - Next - End If - End If - Next - End If - End If - End If - - If Not TieneError Then - ObjInv.Commit() - Alert("El traspaso se ha hecho correctamente") - CargaDatos() - RegistraScript("$('#DModalSeccionAlmacen').modal('hide')") - Else - ObjInv.RollBack() - Alert(MensajeError, TipoMensaje.MsgError) - End If - - End Sub - -#End Region - - - -End Class +Option Strict On +Imports System.Data +Imports System.Collections.Generic +Imports System.Linq +Imports System.Web +Imports System.Web.UI.WebControls +Imports Extensiones +Partial Class Inventarios_KardexSeccionAlmacen + Inherits ClsPaginas + + +#Region "PROPIEDADES" + + Private Property DtSeccionAlmacen As DataTable + Get + Return CType(ViewState("DtSeccionAlmacen"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtSeccionAlmacen") = value + End Set + End Property + Private Property CantidadTotal As Decimal + Get + Return CType(ViewState("CantidadTotal"), Decimal) + End Get + Set(value As Decimal) + ViewState("CantidadTotal") = value + End Set + End Property + Private Property CvePS As Integer + Get + Return CType(ViewState("CvePS"), Integer) + End Get + Set(value As Integer) + ViewState("CvePS") = value + End Set + End Property + Private Property CveSeccionAlmacenOrigen As Integer + Get + Return CType(ViewState("CveSeccionAlmacenOrigen"), Integer) + End Get + Set(value As Integer) + ViewState("CveSeccionAlmacenOrigen") = value + End Set + End Property + Private Property SeccionAlmacenOrigen As String + Get + Return CType(ViewState("SeccionAlmacenOrigen"), String) + End Get + Set(value As String) + ViewState("SeccionAlmacenOrigen") = value + End Set + End Property + Private Property CveAlmacen As Integer + Get + Return CType(ViewState("CveAlmacen"), Integer) + End Get + Set(value As Integer) + ViewState("CveAlmacen") = value + End Set + End Property + Private Property CveUM As Integer + Get + Return CType(ViewState("CveUM"), Integer) + End Get + Set(value As Integer) + ViewState("CveUM") = 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 SerieLote As String + Get + Return CType(ViewState("SerieLote"), String) + End Get + Set(value As String) + ViewState("SerieLote") = value + End Set + End Property + + +#End Region + + Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load + If Not IsPostBack Then + InicializaValores() + End If + End Sub + +#Region "CARGAS" + + Private Sub InicializaValores() + CantidadTotal = 0 + SeccionAlmacenOrigen = "" + CvePS = 0 + CveAlmacen = 0 + CveSeccionAlmacenOrigen = 0 + CveSubProyecto = 0 + CveUM = 0 + SerieLote = "" + + CreaDtSeccionAlmacen() + CargaDdlAlmacen() + CargaPS() + End Sub + + Private Sub CargaPS() + DdlPS.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1") + + If UsuarioActual.Empresa.Funcionalidad(105) = "1" Then + DdlPS.ddlWS.Attributes.Add("data-cveclasificacion", "-1") + DdlPS.SelectedText = "Seleccione" + DdlPS.SelectedValue = "-1" + Else + DdlPS.ddl.Items.Clear() + DdlPS.ddl.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa) + DdlPS.ddl.DataBind() + DdlPS.ddl.Items.Insert(0, New ListItem("Seleccione", "-1")) + End If + End Sub + + Private Sub CargaDdlAlmacen() + DdlAlmacen.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa) + DdlAlmacen.Items.Insert(0, New ListItem("Seleccione", "-1")) + DdlAlmacen.DataBind() + + DdlSeccionAlmacen.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa) + DdlSeccionAlmacen.Items.Insert(0, New ListItem("Todos", "-1")) + DdlSeccionAlmacen.DataBind() + + DdlSeccionAlmacenDestino.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa) + DdlSeccionAlmacenDestino.Items.Insert(0, New ListItem("Seleccione", "-1")) + DdlSeccionAlmacenDestino.DataBind() + End Sub + + Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) + CargaDatos() + End Sub + + Private Sub CargaDatos() + If Not DdlPS.SelectedValue.ToEntero > 0 Then + Alert("Tiene que seleccionar un producto/servicio.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If Not DdlAlmacen.SelectedValue.ToEntero > 0 Then + Alert("Tiene que seleccionar un alamacen.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + Dim ObjInv As New ClsInventarios + If ObjInv.GetKardexSeccionAlmacen(DdlPS.SelectedValue.ToEntero, DdlAlmacen.SelectedValue.ToEntero, DdlSeccionAlmacen.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then + GvDatos.DataSource = ObjInv.DtResultados + End If + ObjInv.Dispose() + GvDatos.DataBind() + UpDatos.Update() + End Sub + +#End Region + + +#Region "SECCION ALMACEN" + Private Sub CreaDtSeccionAlmacen() + DtSeccionAlmacen = New DataTable + DtSeccionAlmacen.Columns.Add("CantidadSeccionAlmacen", GetType(Decimal)) + DtSeccionAlmacen.Columns.Add("CveSeccionAlmacenOrigen", GetType(Integer)) + DtSeccionAlmacen.Columns.Add("CveSeccionAlmacenDestino", GetType(Integer)) + DtSeccionAlmacen.Columns.Add("SeccionAlmacenOrigen", GetType(String)) + DtSeccionAlmacen.Columns.Add("SeccionAlmacenDestino", GetType(String)) + DtSeccionAlmacen.Columns.Add("Consec", GetType(Integer)) + End Sub + + Protected Sub LnkSeccionAlmacen_Click(sender As Object, e As EventArgs) + Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) + DtSeccionAlmacen.Rows.Clear() + CantidadTotal = gvRow.DataKey("Existencia").ToDecimal + CveSeccionAlmacenOrigen = gvRow.DataKey("CveAlmacenSeccion").ToEntero + SeccionAlmacenOrigen = gvRow.DataKey("AlmacenSeccion").ToString + CvePS = gvRow.DataKey("CvePS").ToEntero + SerieLote = gvRow.DataKey("SerieLote").ToString + CveAlmacen = gvRow.DataKey("CveAlmacen").ToEntero + CveUM = gvRow.DataKey("CveUM").ToEntero + CveSubProyecto = gvRow.DataKey("CveSubProyecto").ToEntero + RegistraScript("$('#DModalSeccionAlmacen').modal()") + CargaSeccionAlmacen() + 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(CveSeccionAlmacenOrigen, CveAlmacen, 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.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("CveSeccionAlmacenOrigen") = CveSeccionAlmacenOrigen + Row("SeccionAlmacenOrigen") = SeccionAlmacenOrigen + Row("CveSeccionAlmacenDestino") = DdlSeccionAlmacenDestino.SelectedValue.ToEntero + Row("SeccionAlmacenDestino") = DdlSeccionAlmacenDestino.SelectedItem.Text + 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 + + Private Sub CargaSeccionAlmacen() + Dim CantidadTotalSeccion As Decimal = DtSeccionAlmacen.SUMD("CantidadSeccionAlmacen") + GvSeccion.DataSource = DtSeccionAlmacen + GvSeccion.DataBind() + + TxtCantidadSeccion.Text = "" + DdlSeccionAlmacenDestino.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 + + UpModalSeccionAlmacen.Update() + End Sub + + Protected Sub BtnTraspasar_Click(sender As Object, e As EventArgs) + Dim ObjInv As New ClsInventarios + ObjInv.IniciaTransacSQL() + Dim TieneError As Boolean = False + Dim MensajeError As String = "" + + 'SALIDA + Dim CveMovimientoSalida As Integer = ObjInv.AddMovimiento(DdlAlmacen.SelectedValue.ToEntero, 3, 1, Now, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, CveSubProyecto, -1, CveAlmacenDestino:=CveAlmacen) + + If CveMovimientoSalida <= 0 Then + TieneError = True + MensajeError = "Ocurrió un error al guardar el movimiento de salida. Por favor vuelva a intentar." + End If + + Dim Cantidad As Decimal = DtSeccionAlmacen.SUMD("CantidadSeccionAlmacen") + + If Not ObjInv.AddMovimientoDetalle(CveMovimientoSalida, Cantidad, CveUM, CvePS, 0, -1, SerieLote:=SerieLote) Then + MensajeError = "Ocurrió un error al guardar los detalles del movimiento de salida. Por favor vuelva a intentar." + TieneError = True + Else + If ObjInv.CveMovimientoDetalle > 0 AndAlso DtSeccionAlmacen.Rows.Count > 0 Then + For Each Dr2 As DataRow In DtSeccionAlmacen.Rows + If Not ObjInv.AddMovimientosDetalleSeccionesAlmacen(ObjInv.CveMovimientoDetalle, Dr2("CveSeccionAlmacenOrigen").ToString.ToEntero, -Dr2("CantidadSeccionAlmacen").ToString.ToDecimal) Then + TieneError = True + MensajeError = "Ocurrió un error al procesar las secciones de almacen. Por favor vuelva a intentar." + Exit For + End If + Next + End If + End If + + 'ENTRADA + If Not TieneError Then + Dim CveMovimientoEntrada As Integer = ObjInv.AddMovimiento(CveAlmacen, 2, 1, Now, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, CveSubProyecto, -1, CveMovimientoRelacionado:=CveMovimientoSalida) + + If CveMovimientoEntrada <= 0 Then + MensajeError = "Ocurrió un error al guardar el movimiento de entrada correctamente. Por favor vuelva a intentar." + TieneError = True + Else + If ObjInv.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then + For Each Dr As DataRow In ObjInv.DtResultados.Rows + If Not ObjInv.AddMovimientoDetalle(CveMovimientoEntrada, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, Dr("Observaciones").ToString) Then + TieneError = True + MensajeError = "Ocurrió un error al guardar los movimientos de entrada" + Exit For + Else + If ObjInv.CveMovimientoDetalle > 0 AndAlso DtSeccionAlmacen.Rows.Count > 0 Then + For Each Dr2 As DataRow In DtSeccionAlmacen.Rows + If Not ObjInv.AddMovimientosDetalleSeccionesAlmacen(ObjInv.CveMovimientoDetalle, Dr2("CveSeccionAlmacenDestino").ToString.ToEntero, Dr2("CantidadSeccionAlmacen").ToString.ToDecimal) Then + TieneError = True + MensajeError = "Ocurrió un error al procesar las secciones de almacen. Por favor vuelva a intentar." + Exit For + End If + Next + End If + End If + Next + End If + End If + End If + + If Not TieneError Then + ObjInv.Commit() + Alert("El traspaso se ha hecho correctamente") + CargaDatos() + RegistraScript("$('#DModalSeccionAlmacen').modal('hide')") + Else + ObjInv.RollBack() + Alert(MensajeError, TipoMensaje.MsgError) + End If + + End Sub + +#End Region + + + +End Class diff --git a/Inventarios/PaquetesArmadoDesarmado.aspx.vb b/Inventarios/PaquetesArmadoDesarmado.aspx.vb index b6eff1c35..077c657b7 100644 --- a/Inventarios/PaquetesArmadoDesarmado.aspx.vb +++ b/Inventarios/PaquetesArmadoDesarmado.aspx.vb @@ -507,11 +507,11 @@ Partial Class Inventarios_PaquetesArmadoDesarmado TieneError = True Else If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then - Dim PUTemp = 0.0 + Dim PUTemp As Decimal = 0 For Each Dr As DataRow In ObjInventario.DtResultados.Rows - PUTemp += Dr("PU").ToString.ToDouble * Dr("Cantidad").ToString.ToDouble + PUTemp += Dr("PU").ToString.ToDecimal * Dr("Cantidad").ToString.ToDecimal Next - PUTemp = PUTemp / LbCantidadArmado.Text.ToDouble + PUTemp = PUTemp / LbCantidadArmado.Text.ToDecimal Dim CvePSTemp = CvePaqueteArmado Dim CveUMTemp = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePaqueteArmado).FiltroPrimeroValor("CveUM").ToEntero @@ -611,14 +611,14 @@ Partial Class Inventarios_PaquetesArmadoDesarmado If Gvr.DataKey("Cantidad").ToString.ToDouble > 0 Then If Gvr.DataKey("Inv_CveMetodoInventario").ToString.ToEntero = 5 Then For Each Dr As DataRow In DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Gvr.DataKey("Consec").ToEntero)).Rows - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, 1, Gvr.DataKey("CveUM").ToString.ToEntero, Gvr.DataKey("CvePS").ToString.ToEntero, Gvr.FCTextBox("TxtCosto").Text.ToDouble, -1, SerieLote:=Dr("Serie").ToString) Then + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, 1, Gvr.DataKey("CveUM").ToString.ToEntero, Gvr.DataKey("CvePS").ToString.ToEntero, Gvr.FCTextBox("TxtCosto").Text.ToDecimal, -1, SerieLote:=Dr("Serie").ToString) Then MensajeError = "Ocurrió un error al guardar los detalles con serie del movimiento de entrada. Por favor vuelva a intentar." TieneError = True Exit For End If Next Else - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Gvr.DataKey("Cantidad").ToString.ToDouble, Gvr.DataKey("CveUM").ToString.ToEntero, Gvr.DataKey("CvePS").ToString.ToEntero, Gvr.FCTextBox("TxtCosto").Text.ToDouble, -1) Then + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Gvr.DataKey("Cantidad").ToString.ToDouble, Gvr.DataKey("CveUM").ToString.ToEntero, Gvr.DataKey("CvePS").ToString.ToEntero, Gvr.FCTextBox("TxtCosto").Text.ToDecimal, -1) Then MensajeError = "Ocurrió un error al guardar los detalles del movimiento de entrada. Por favor vuelva a intentar." TieneError = True Exit For diff --git a/Inventarios/RecepcionAlmacen.aspx.vb b/Inventarios/RecepcionAlmacen.aspx.vb index 161b1714c..6a926090f 100644 --- a/Inventarios/RecepcionAlmacen.aspx.vb +++ b/Inventarios/RecepcionAlmacen.aspx.vb @@ -1,849 +1,849 @@ -Option Strict On -Option Explicit On - -Imports Microsoft.Reporting.WebForms -Imports System.Data -Imports Extensiones -Imports System.IO -Imports System.Linq - -Partial Class Inventarios_RecepcionAlmacen +Option Strict On +Option Explicit On + +Imports Microsoft.Reporting.WebForms +Imports System.Data +Imports Extensiones +Imports System.IO +Imports System.Linq + +Partial Class Inventarios_RecepcionAlmacen Inherits ClsPaginas -#Region "PROPIEDADES" - Private Shared missing As Object = System.Reflection.Missing.Value - Private Property EstatusInicial As String - Get - EstatusInicial = ViewState("EstatusInicial").ToString - End Get - Set(value As String) - ViewState("EstatusInicial") = value - End Set - End Property - Private Property EstatusFinalOK As String - Get - EstatusFinalOK = ViewState("EstatusFinalOK").ToString - End Get - Set(value As String) - ViewState("EstatusFinalOK") = value - End Set - End Property - Private Property DtInv As DataTable - Get - Return CType(ViewState("DtInv"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtInv") = value - End Set - End Property - Private Property DtSeccionAlmacen As DataTable - Get - Return CType(ViewState("DtSeccionAlmacen"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtSeccionAlmacen") = value - End Set - End Property - - Private Property dt As DataTable - Get - Return CType(ViewState("dt"), DataTable) - End Get - Set(value As DataTable) - ViewState("dt") = value - End Set - End Property - - Private Property CveMoneda As Integer - Get - Return CType(ViewState("CveMoneda"), Integer) - End Get - Set(value As Integer) - ViewState("CveMoneda") = value - End Set - End Property - - Private Property CveCompraParametro As Integer - Get - Return CType(ViewState("CveCompraParametro"), Integer) - End Get - Set(value As Integer) - ViewState("CveCompraParametro") = value - End Set - End Property - - Private Property CveTipoCompra As Integer - Get - Return CType(IfNull(ViewState("CveTipoCompra"), 0), Integer) - End Get - Set(value As Integer) - ViewState("CveTipoCompra") = value - End Set - End Property - Private Property DtCuentas As DataTable - Get - Return CType(ViewState("DtCuentas"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtCuentas") = value - End Set - End Property - Private ReadOnly Property IdPoliza As Integer - Get - Return ViewState("IdPoliza").ToString.ToEntero - End Get - 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 DtDatosLoteDetalle As DataTable - Get - Return CType(ViewState("DtDatosLoteDetalle"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtDatosLoteDetalle") = value - End Set - End Property - Private Property CvePSSerieLote As Integer - Get - Return CType(ViewState("CvePSSerieLote"), Integer) - End Get - Set(value As Integer) - ViewState("CvePSSerieLote") = value - End Set - End Property - Private Property CveUMSerieLote As Integer - Get - Return CType(ViewState("CveUMSerieLote"), Integer) - End Get - Set(value As Integer) - ViewState("CveUMSerieLote") = value - End Set - End Property - Private Property CantidadTotal As Decimal - Get - Return CType(ViewState("CantidadTotal"), Decimal) - End Get - Set(value As Decimal) - ViewState("CantidadTotal") = value - End Set - End Property - Private Property IndexSeccionAlmacen As Integer - Get - Return CType(ViewState("IndexSeccionAlmacen"), Integer) - End Get - Set(value As Integer) - ViewState("IndexSeccionAlmacen") = value - End Set - End Property - Private Property PUSerieLote As Decimal - Get - Return CType(ViewState("PUSerieLote"), Decimal) - End Get - Set(value As Decimal) - ViewState("PUSerieLote") = value - End Set - End Property - Private Property CveConsecSerieLote As Integer - Get - Return CType(ViewState("CveConsecSerieLote"), Integer) - End Get - Set(value As Integer) - ViewState("CveConsecSerieLote") = value - End Set - End Property - Private Property TotalGV As Decimal - Get - Return CType(ViewState("TotalGV"), Decimal) - End Get - Set(value As Decimal) - ViewState("TotalGV") = value - End Set - End Property - Private Property TotalCompraOC As Decimal - Get - Return CType(ViewState("TotalCompraOC"), Decimal) - End Get - Set(value As Decimal) - ViewState("TotalCompraOC") = value - End Set - End Property - - Private Property TipoCambio As Double - Get - Return ViewState("TipoCambio").ToString.ToDouble - End Get - Set(value As Double) - ViewState("TipoCambio") = value - End Set - End Property - Private Property DtBitacora As DataTable - Get - Return CType(ViewState("DtBitacora"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtBitacora") = 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 EntregaDirecta As Boolean - Get - Return CBool(ViewState("EntregaDirecta")) - End Get - Set(value As Boolean) - ViewState("EntregaDirecta") = value - End Set - End Property - - Private Property RecibidaCompleta As Boolean - Get - Return CBool(ViewState("RecibidaCompleta")) - End Get - Set(value As Boolean) - ViewState("RecibidaCompleta") = value - End Set - End Property - Private Property Apartado As Boolean - Get - Return CBool(ViewState("Apartado")) - End Get - Set(value As Boolean) - ViewState("Apartado") = value - End Set - End Property - Private Property BuscaEntregaDirecta As Integer - Get - Return CType(ViewState("BuscaEntregaDirecta"), Integer) - End Get - Set(value As Integer) - ViewState("BuscaEntregaDirecta") = value - End Set - End Property - Private Property CveAlmacenApartado As Integer - Get - Return CType(ViewState("CveAlmacenApartado"), Integer) - End Get - Set(value As Integer) - ViewState("CveAlmacenApartado") = 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 CveCompraSurtir As Integer - Get - Return CType(ViewState("CveCompraSurtir"), Integer) - End Get - Set(value As Integer) - ViewState("CveCompraSurtir") = value - End Set - End Property - Private Property CvePrePolizaCompra As Integer - Get - Return CType(ViewState("CvePrePolizaCompra"), Integer) - End Get - Set(value As Integer) - ViewState("CvePrePolizaCompra") = value - End Set - End Property - Private Property CveOCSurtir As Integer - Get - Return CType(ViewState("CveOCSurtir"), Integer) - End Get - Set(value As Integer) - ViewState("CveOCSurtir") = value - End Set - End Property - - Private Property CveImportacionSurtir As Integer - Get - Return CType(ViewState("CveImportacionSurtir"), Integer) - End Get - Set(value As Integer) - ViewState("CveImportacionSurtir") = value - End Set - End Property - Private Property CveImportacionCompra As Integer - Get - Return CType(ViewState("CveImportacionCompra"), Integer) - End Get - Set(value As Integer) - ViewState("CveImportacionCompra") = value - End Set - End Property - Private Property CveImportacionProveedor As Integer - Get - Return CType(ViewState("CveImportacionProveedor"), Integer) - End Get - Set(value As Integer) - ViewState("CveImportacionProveedor") = value - End Set - End Property - Private Property CveFleteSurtir As Integer - Get - Return CType(ViewState("CveFleteSurtir"), Integer) - End Get - Set(value As Integer) - ViewState("CveFleteSurtir") = value - End Set - End Property - Private Property CveFleteOrdenCompra As Integer - Get - Return CType(ViewState("CveFleteOrdenCompra"), Integer) - End Get - Set(value As Integer) - ViewState("CveFleteOrdenCompra") = value - End Set - End Property - Private Property CveFleteCompra As Integer - Get - Return CType(ViewState("CveFleteCompra"), Integer) - End Get - Set(value As Integer) - ViewState("CveFleteCompra") = 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 CveCliente As Integer - Get - Return CType(ViewState("CveCliente"), Integer) - End Get - Set(value As Integer) - ViewState("CveCliente") = 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 +#Region "PROPIEDADES" + Private Shared missing As Object = System.Reflection.Missing.Value + Private Property EstatusInicial As String + Get + EstatusInicial = ViewState("EstatusInicial").ToString + End Get + Set(value As String) + ViewState("EstatusInicial") = value + End Set + End Property + Private Property EstatusFinalOK As String + Get + EstatusFinalOK = ViewState("EstatusFinalOK").ToString + End Get + Set(value As String) + ViewState("EstatusFinalOK") = value + End Set + End Property + Private Property DtInv As DataTable + Get + Return CType(ViewState("DtInv"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtInv") = value + End Set + End Property + Private Property DtSeccionAlmacen As DataTable + Get + Return CType(ViewState("DtSeccionAlmacen"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtSeccionAlmacen") = value + End Set End Property -#End Region + Private Property dt As DataTable + Get + Return CType(ViewState("dt"), DataTable) + End Get + Set(value As DataTable) + ViewState("dt") = value + End Set + End Property - Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load - If Not IsPostBack Then - - InicializaValores() - - CargaUrlParametros() - CargaPendientes() - - CargaPermisos() - - End If + Private Property CveMoneda As Integer + Get + Return CType(ViewState("CveMoneda"), Integer) + End Get + Set(value As Integer) + ViewState("CveMoneda") = value + End Set + End Property + + Private Property CveCompraParametro As Integer + Get + Return CType(ViewState("CveCompraParametro"), Integer) + End Get + Set(value As Integer) + ViewState("CveCompraParametro") = value + End Set + End Property + + Private Property CveTipoCompra As Integer + Get + Return CType(IfNull(ViewState("CveTipoCompra"), 0), Integer) + End Get + Set(value As Integer) + ViewState("CveTipoCompra") = value + End Set + End Property + Private Property DtCuentas As DataTable + Get + Return CType(ViewState("DtCuentas"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtCuentas") = value + End Set + End Property + Private ReadOnly Property IdPoliza As Integer + Get + Return ViewState("IdPoliza").ToString.ToEntero + End Get + 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 DtDatosLoteDetalle As DataTable + Get + Return CType(ViewState("DtDatosLoteDetalle"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtDatosLoteDetalle") = value + End Set + End Property + Private Property CvePSSerieLote As Integer + Get + Return CType(ViewState("CvePSSerieLote"), Integer) + End Get + Set(value As Integer) + ViewState("CvePSSerieLote") = value + End Set + End Property + Private Property CveUMSerieLote As Integer + Get + Return CType(ViewState("CveUMSerieLote"), Integer) + End Get + Set(value As Integer) + ViewState("CveUMSerieLote") = value + End Set + End Property + Private Property CantidadTotal As Decimal + Get + Return CType(ViewState("CantidadTotal"), Decimal) + End Get + Set(value As Decimal) + ViewState("CantidadTotal") = value + End Set + End Property + Private Property IndexSeccionAlmacen As Integer + Get + Return CType(ViewState("IndexSeccionAlmacen"), Integer) + End Get + Set(value As Integer) + ViewState("IndexSeccionAlmacen") = value + End Set + End Property + Private Property PUSerieLote As Decimal + Get + Return CType(ViewState("PUSerieLote"), Decimal) + End Get + Set(value As Decimal) + ViewState("PUSerieLote") = value + End Set + End Property + Private Property CveConsecSerieLote As Integer + Get + Return CType(ViewState("CveConsecSerieLote"), Integer) + End Get + Set(value As Integer) + ViewState("CveConsecSerieLote") = value + End Set + End Property + Private Property TotalGV As Decimal + Get + Return CType(ViewState("TotalGV"), Decimal) + End Get + Set(value As Decimal) + ViewState("TotalGV") = value + End Set + End Property + Private Property TotalCompraOC As Decimal + Get + Return CType(ViewState("TotalCompraOC"), Decimal) + End Get + Set(value As Decimal) + ViewState("TotalCompraOC") = value + End Set + End Property + + Private Property TipoCambio As Double + Get + Return ViewState("TipoCambio").ToString.ToDouble + End Get + Set(value As Double) + ViewState("TipoCambio") = value + End Set + End Property + Private Property DtBitacora As DataTable + Get + Return CType(ViewState("DtBitacora"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtBitacora") = 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 EntregaDirecta As Boolean + Get + Return CBool(ViewState("EntregaDirecta")) + End Get + Set(value As Boolean) + ViewState("EntregaDirecta") = value + End Set + End Property + + Private Property RecibidaCompleta As Boolean + Get + Return CBool(ViewState("RecibidaCompleta")) + End Get + Set(value As Boolean) + ViewState("RecibidaCompleta") = value + End Set + End Property + Private Property Apartado As Boolean + Get + Return CBool(ViewState("Apartado")) + End Get + Set(value As Boolean) + ViewState("Apartado") = value + End Set + End Property + Private Property BuscaEntregaDirecta As Integer + Get + Return CType(ViewState("BuscaEntregaDirecta"), Integer) + End Get + Set(value As Integer) + ViewState("BuscaEntregaDirecta") = value + End Set + End Property + Private Property CveAlmacenApartado As Integer + Get + Return CType(ViewState("CveAlmacenApartado"), Integer) + End Get + Set(value As Integer) + ViewState("CveAlmacenApartado") = 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 CveCompraSurtir As Integer + Get + Return CType(ViewState("CveCompraSurtir"), Integer) + End Get + Set(value As Integer) + ViewState("CveCompraSurtir") = value + End Set + End Property + Private Property CvePrePolizaCompra As Integer + Get + Return CType(ViewState("CvePrePolizaCompra"), Integer) + End Get + Set(value As Integer) + ViewState("CvePrePolizaCompra") = value + End Set + End Property + Private Property CveOCSurtir As Integer + Get + Return CType(ViewState("CveOCSurtir"), Integer) + End Get + Set(value As Integer) + ViewState("CveOCSurtir") = value + End Set + End Property + + Private Property CveImportacionSurtir As Integer + Get + Return CType(ViewState("CveImportacionSurtir"), Integer) + End Get + Set(value As Integer) + ViewState("CveImportacionSurtir") = value + End Set + End Property + Private Property CveImportacionCompra As Integer + Get + Return CType(ViewState("CveImportacionCompra"), Integer) + End Get + Set(value As Integer) + ViewState("CveImportacionCompra") = value + End Set + End Property + Private Property CveImportacionProveedor As Integer + Get + Return CType(ViewState("CveImportacionProveedor"), Integer) + End Get + Set(value As Integer) + ViewState("CveImportacionProveedor") = value + End Set + End Property + Private Property CveFleteSurtir As Integer + Get + Return CType(ViewState("CveFleteSurtir"), Integer) + End Get + Set(value As Integer) + ViewState("CveFleteSurtir") = value + End Set + End Property + Private Property CveFleteOrdenCompra As Integer + Get + Return CType(ViewState("CveFleteOrdenCompra"), Integer) + End Get + Set(value As Integer) + ViewState("CveFleteOrdenCompra") = value + End Set + End Property + Private Property CveFleteCompra As Integer + Get + Return CType(ViewState("CveFleteCompra"), Integer) + End Get + Set(value As Integer) + ViewState("CveFleteCompra") = 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 CveCliente As Integer + Get + Return CType(ViewState("CveCliente"), Integer) + End Get + Set(value As Integer) + ViewState("CveCliente") = 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 + +#End Region + + Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load + If Not IsPostBack Then + + InicializaValores() + + CargaUrlParametros() + CargaPendientes() + + CargaPermisos() + + End If End Sub -#Region " PERMISOS PAGINAS " - Private Sub CargaPermisos() - - 'IMPORTES - Dim TienePermisoImportes As Boolean = UsuarioActual.TienePermisoProceso(201) - GvInv.Columns(8).Visible = TienePermisoImportes - GvInv.Columns(11).Visible = TienePermisoImportes - - 'SECCION ALMACEN - GvInv.Columns(10).Visible = UsuarioActual.Empresa.Funcionalidad(147) = "1" - - 'SECCION ALMACEN EXISTENCIAS - GvInv.Columns(11).Visible = UsuarioActual.Empresa.Funcionalidad(563).ToString = "1" - - End Sub -#End Region +#Region " PERMISOS PAGINAS " + Private Sub CargaPermisos() -#Region " INICIALIZA VALORES " - Private Sub InicializaValores() - CveCompraParametro = -1 - CveCompraSurtir = -1 - CvePrePolizaCompra = -1 - CveOCSurtir = -1 - CveImportacionSurtir = -1 - CveImportacionProveedor = -1 - CveImportacionCompra = -1 - CveFleteSurtir = -1 - CveFleteOrdenCompra = -1 - CveFleteCompra = -1 - BuscaEntregaDirecta = -1 - CveAlmacenApartado = -1 - TipoMovimiento = 1 - - CantidadTotal = 0 - IndexSeccionAlmacen = 0 - CreaDtSeccionAlmacen() - CargaDdlAlmacen() - - ddlAlmacenAdd.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoAlmacen NOT IN (9)") - ddlAlmacenAdd.DataBind() - - CargaAlmacenes(-1) - - ddlProveedor.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1") - - If ddlProveedor.UsaWebService Then - - ddlProveedor.Attributes.Add("data-metodo", "getproveedores") - Else - ddlProveedor.DataSource = GlobalDTCompProveedores(UsuarioActual.CveEmpresa) - ddlProveedor.DataBind() - ddlProveedor.ddl.Items.Insert(0, New ListItem("Seleccione el Proveedor", "-1")) - ddlProveedor.SelectedValue = "-1" - End If - - - DdlFolio.Items.Insert(0, New ListItem("Seleccione", "-1")) - DdlFolioOC.Items.Insert(0, New ListItem("Seleccione", "-1")) - - ConfiguraTipoRecepcion() - - If UsuarioActual.CveEmpresa = 119 Then - DivRemision.Visible = True - End If - - TxtFechaCaducidad.Text = Now.ToShortDateString - TxtFechaPendientes.Text = Now.ToShortDateString - TipoCambio = -1 - CreaDtDetalle() - - ImgClose.Attributes.Add("onclick", "$('#DivAlmacen').hide();") - ImgAdd.Attributes.Add("onclick", "$('#DivAlmacen').hide();") - - BtnGuardar.Visible = False - 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 - InicializaBitacoraTemporal() - DdlMonedaTC.Enabled = False - - - - End Sub - ''' - ''' Recarga los almacenes [DdlAlmacen] que se pueden usar para el movimiento - ''' - ''' - ''' Parametro sin espacios y separado por comas ["1,2,3,21"] - Private Sub CargaAlmacenes(CveSubProyecto As Integer, Optional CveTiposAlmacen As String = "") - Dim StrAlmacenes As String = "" - - If UsuarioActual.CveSubProyecto = 8804 Then 'AGS - StrAlmacenes = $"CveTipoAlmacen IN ({If(CveTiposAlmacen.Length > 0, CveTiposAlmacen, "1,2,12,15")}) {If(CveSubProyecto > 0, $"And CveSubProyecto = {CveSubProyecto}", "")}" - Else - StrAlmacenes = $"CveTipoAlmacen IN ({If(CveTiposAlmacen.Length > 0, CveTiposAlmacen, "1,2,15,6")}) {If(CveSubProyecto > 0, $"And CveSubProyecto = {CveSubProyecto}", "")}" - End If - - DdlAlmacen.Items.Clear() - 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) - - UpGenerales.Update() - End Sub - Private Sub ConfiguraTipoRecepcion() - DdlTipo.Items.Insert(0, New ListItem("Compra", "1")) - - If UsuarioActual.Empresa.Funcionalidad(131).ToEntero > 0 Then - DdlTipo.Items.Insert(1, New ListItem("OC", "2")) - If UsuarioActual.Empresa.Funcionalidad(153).ToEntero > 0 Then - DdlTipo.Items.RemoveAt(0) - DdlTipo.SelectedValue = "2" - ModalidadRecepcion() - End If - End If - - If UsuarioActual.Empresa.Funcionalidad(155).ToEntero > 0 Then - DdlTipo.Items.Insert(DdlTipo.Items.Count - 1, New ListItem("Importación", "3")) - End If - - If UsuarioActual.Empresa.Funcionalidad(158).ToEntero > 0 Then - DdlTipo.Items.Insert(DdlTipo.Items.Count - 1, New ListItem("Costo Indirecto", "4")) - End If - - UpFiltros.Update() - - End Sub -#End Region + 'IMPORTES + Dim TienePermisoImportes As Boolean = UsuarioActual.TienePermisoProceso(201) + GvInv.Columns(8).Visible = TienePermisoImportes + GvInv.Columns(11).Visible = TienePermisoImportes -#Region " CARGA URL PARAMETROS " - Private Sub CargaUrlParametros() - - CveCompraParametro = IfNull(Request("CveCompra"), "-1").ToString.ToEntero - BuscaEntregaDirecta = IfNull(Request("ED"), "-1").ToString.ToEntero - - - If CveCompraParametro > 0 Then - Dim ObjCompras As New ClsCompras - If ObjCompras.GetCompras(CveCompraParametro, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa) Then - If ObjCompras.DtResultados.Rows.Count >= 1 Then - ddlProveedor.SelectedValue = ObjCompras.DtResultados.Rows(0)("CveProveedor").ToString - ddlProveedor.SelectedText = ObjCompras.DtResultados.Rows(0)("RazonSocial").ToString - ddlProveedor_SelectedIndexChanged(ddlProveedor, EventArgs.Empty) - - If (DdlFolio.Items.FindByValue(CveCompraParametro.ToString) Is Nothing) Then - DdlFolio.Items.Insert(1, New ListItem(ObjCompras.DtResultados.Rows(0)("SerieFolio").ToString, CveCompraParametro.ToString)) ' lo genera Obj.SelectedValue = Valor.ToString - End If - DdlFolio.SelectedValueExist(CveCompraParametro.ToString) - btnBuscar_Click(BtnBuscar, EventArgs.Empty) - - Else - Alert("La Compra solicitada no se pudo encontrar. Por favor vuelva a intentar.", TipoMensaje.MsgAdvertencia) - End If - Else - Alert("Ocurrió un error al cargar los datos de la Compra. Por favor vuelva a intentar.", TipoMensaje.MsgError) - End If - ObjCompras.Dispose() - End If - - + 'SECCION ALMACEN + GvInv.Columns(10).Visible = UsuarioActual.Empresa.Funcionalidad(147) = "1" + + 'SECCION ALMACEN EXISTENCIAS + GvInv.Columns(11).Visible = UsuarioActual.Empresa.Funcionalidad(563).ToString = "1" + End Sub -#End Region +#End Region + +#Region " INICIALIZA VALORES " + Private Sub InicializaValores() + CveCompraParametro = -1 + CveCompraSurtir = -1 + CvePrePolizaCompra = -1 + CveOCSurtir = -1 + CveImportacionSurtir = -1 + CveImportacionProveedor = -1 + CveImportacionCompra = -1 + CveFleteSurtir = -1 + CveFleteOrdenCompra = -1 + CveFleteCompra = -1 + BuscaEntregaDirecta = -1 + CveAlmacenApartado = -1 + TipoMovimiento = 1 + + CantidadTotal = 0 + IndexSeccionAlmacen = 0 + CreaDtSeccionAlmacen() + CargaDdlAlmacen() + + ddlAlmacenAdd.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoAlmacen NOT IN (9)") + ddlAlmacenAdd.DataBind() + + CargaAlmacenes(-1) + + ddlProveedor.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1") + + If ddlProveedor.UsaWebService Then + + ddlProveedor.Attributes.Add("data-metodo", "getproveedores") + Else + ddlProveedor.DataSource = GlobalDTCompProveedores(UsuarioActual.CveEmpresa) + ddlProveedor.DataBind() + ddlProveedor.ddl.Items.Insert(0, New ListItem("Seleccione el Proveedor", "-1")) + ddlProveedor.SelectedValue = "-1" + End If + + + DdlFolio.Items.Insert(0, New ListItem("Seleccione", "-1")) + DdlFolioOC.Items.Insert(0, New ListItem("Seleccione", "-1")) + + ConfiguraTipoRecepcion() + + If UsuarioActual.CveEmpresa = 119 Then + DivRemision.Visible = True + End If + + TxtFechaCaducidad.Text = Now.ToShortDateString + TxtFechaPendientes.Text = Now.ToShortDateString + TipoCambio = -1 + CreaDtDetalle() + + ImgClose.Attributes.Add("onclick", "$('#DivAlmacen').hide();") + ImgAdd.Attributes.Add("onclick", "$('#DivAlmacen').hide();") + + BtnGuardar.Visible = False + 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 + InicializaBitacoraTemporal() + DdlMonedaTC.Enabled = False + + + + End Sub + ''' + ''' Recarga los almacenes [DdlAlmacen] que se pueden usar para el movimiento + ''' + ''' + ''' Parametro sin espacios y separado por comas ["1,2,3,21"] + Private Sub CargaAlmacenes(CveSubProyecto As Integer, Optional CveTiposAlmacen As String = "") + Dim StrAlmacenes As String = "" + + If UsuarioActual.CveSubProyecto = 8804 Then 'AGS + StrAlmacenes = $"CveTipoAlmacen IN ({If(CveTiposAlmacen.Length > 0, CveTiposAlmacen, "1,2,12,15")}) {If(CveSubProyecto > 0, $"And CveSubProyecto = {CveSubProyecto}", "")}" + Else + StrAlmacenes = $"CveTipoAlmacen IN ({If(CveTiposAlmacen.Length > 0, CveTiposAlmacen, "1,2,15,6")}) {If(CveSubProyecto > 0, $"And CveSubProyecto = {CveSubProyecto}", "")}" + End If + + DdlAlmacen.Items.Clear() + 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) + + UpGenerales.Update() + End Sub + Private Sub ConfiguraTipoRecepcion() + DdlTipo.Items.Insert(0, New ListItem("Compra", "1")) + + If UsuarioActual.Empresa.Funcionalidad(131).ToEntero > 0 Then + DdlTipo.Items.Insert(1, New ListItem("OC", "2")) + If UsuarioActual.Empresa.Funcionalidad(153).ToEntero > 0 Then + DdlTipo.Items.RemoveAt(0) + DdlTipo.SelectedValue = "2" + ModalidadRecepcion() + End If + End If + + If UsuarioActual.Empresa.Funcionalidad(155).ToEntero > 0 Then + DdlTipo.Items.Insert(DdlTipo.Items.Count - 1, New ListItem("Importación", "3")) + End If + + If UsuarioActual.Empresa.Funcionalidad(158).ToEntero > 0 Then + DdlTipo.Items.Insert(DdlTipo.Items.Count - 1, New ListItem("Costo Indirecto", "4")) + End If + + UpFiltros.Update() + + End Sub +#End Region + +#Region " CARGA URL PARAMETROS " + Private Sub CargaUrlParametros() + + CveCompraParametro = IfNull(Request("CveCompra"), "-1").ToString.ToEntero + BuscaEntregaDirecta = IfNull(Request("ED"), "-1").ToString.ToEntero + + + If CveCompraParametro > 0 Then + Dim ObjCompras As New ClsCompras + If ObjCompras.GetCompras(CveCompraParametro, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa) Then + If ObjCompras.DtResultados.Rows.Count >= 1 Then + ddlProveedor.SelectedValue = ObjCompras.DtResultados.Rows(0)("CveProveedor").ToString + ddlProveedor.SelectedText = ObjCompras.DtResultados.Rows(0)("RazonSocial").ToString + ddlProveedor_SelectedIndexChanged(ddlProveedor, EventArgs.Empty) + + If (DdlFolio.Items.FindByValue(CveCompraParametro.ToString) Is Nothing) Then + DdlFolio.Items.Insert(1, New ListItem(ObjCompras.DtResultados.Rows(0)("SerieFolio").ToString, CveCompraParametro.ToString)) ' lo genera Obj.SelectedValue = Valor.ToString + End If + DdlFolio.SelectedValueExist(CveCompraParametro.ToString) + btnBuscar_Click(BtnBuscar, EventArgs.Empty) + + Else + Alert("La Compra solicitada no se pudo encontrar. Por favor vuelva a intentar.", TipoMensaje.MsgAdvertencia) + End If + Else + Alert("Ocurrió un error al cargar los datos de la Compra. Por favor vuelva a intentar.", TipoMensaje.MsgError) + End If + ObjCompras.Dispose() + End If + + + End Sub +#End Region + +#Region " MODALIDAD RECEPCION " + Protected Sub DdlTipo_SelectedIndexChanged(sender As Object, e As EventArgs) + ModalidadRecepcion() + + End Sub + Private Sub ModalidadRecepcion() + LblCompra.Visible = False + DivCompra.Visible = False + LblOC.Visible = False + DivOC.Visible = False + LblImportacion.Visible = False + DivImportacion.Visible = False + LblFletes.Visible = False + DivFletes.Visible = False + LblFactura.Visible = False + DivDdlFactura.Visible = False + + Select Case DdlTipo.SelectedValue.ToEntero + Case 1 + LblCompra.Visible = True + DivCompra.Visible = True + Case 2 + LblOC.Visible = True + DivOC.Visible = True + Case 3 + LblImportacion.Visible = True + DivImportacion.Visible = True + LblFactura.Visible = True + DivDdlFactura.Visible = True + Case 4 + LblFletes.Visible = True + DivFletes.Visible = True + End Select + + CargaFoliosRecepcion() -#Region " MODALIDAD RECEPCION " - Protected Sub DdlTipo_SelectedIndexChanged(sender As Object, e As EventArgs) - ModalidadRecepcion() - - End Sub - Private Sub ModalidadRecepcion() - LblCompra.Visible = False - DivCompra.Visible = False - LblOC.Visible = False - DivOC.Visible = False - LblImportacion.Visible = False - DivImportacion.Visible = False - LblFletes.Visible = False - DivFletes.Visible = False - LblFactura.Visible = False - DivDdlFactura.Visible = False - - Select Case DdlTipo.SelectedValue.ToEntero - Case 1 - LblCompra.Visible = True - DivCompra.Visible = True - Case 2 - LblOC.Visible = True - DivOC.Visible = True - Case 3 - LblImportacion.Visible = True - DivImportacion.Visible = True - LblFactura.Visible = True - DivDdlFactura.Visible = True - Case 4 - LblFletes.Visible = True - DivFletes.Visible = True - End Select - - CargaFoliosRecepcion() - End Sub -#End Region +#End Region -#Region " CARGA FOLIOS RECEPCION " - Protected Sub ddlProveedor_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddlProveedor.selectedindexchange - CargaFoliosRecepcion() - 'DdlTipo_SelectedIndexChanged(DdlTipo, EventArgs.Empty) - End Sub - Private Sub CargaFoliosRecepcion() - Select Case DdlTipo.SelectedValue.ToEntero - Case 1 - CargaFolios() - Case 2 - CargaFoliosOC() - Case 3 - CargaFoliosImportacion() - Case 4 - CargaFletes() - End Select - UpFiltros.Update() - End Sub - Private Sub CargaFolios() - DdlFolio.Items.Clear() - - Dim ObjInventarios As New ClsInventarios - If ddlProveedor.SelectedValue.ToEntero > 0 Then - If ObjInventarios.ComprasPendientesAlmacenGet(ddlProveedor.SelectedValue.ToEntero, MinFecha.ToShortDateString.ToDate, UsuarioActual.CveEmpresa) Then - Dim FiltroTemporal = If(UsuarioActual.CveEmpresa = 119, "AND TipoDocto IN ('Fac','NC','DEV')", "AND TipoDocto IN ('Fac')") - DdlFolio.DataSource = ObjInventarios.DtResultados.FiltraParametros($"CantOC >= 0 {FiltroTemporal}") - 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")) - End Sub - Private Sub CargaFoliosImportacion() - DdlFolioImportacion.Items.Clear() - - Dim ObjInventarios As New ClsInventarios - If ddlProveedor.SelectedValue.ToEntero > 0 Then - If ObjInventarios.PendientesAlmacenImportacionGet(ddlProveedor.SelectedValue.ToEntero, MinFecha.ToShortDateString.ToDate, UsuarioActual.CveEmpresa) Then - DdlFolioImportacion.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() - - DdlFolioImportacion.DataBind() - DdlFolioImportacion.Items.Insert(0, New ListItem("Seleccione", "-1")) - CargaFactura() - End Sub - Protected Sub DdlFolioImportacion_SelectedIndexChanged(sender As Object, e As EventArgs) - CargaFactura() - End Sub - Private Sub CargaFactura() - - DdlFactura.Items.Clear() - - Dim ObjInventarios As New ClsInventarios - If DdlFolioImportacion.SelectedValue.ToEntero > 0 Then - If ObjInventarios.PendientesAlmacenImportacionComprasGet(DdlFolioImportacion.SelectedValue.ToEntero, ddlProveedor.SelectedValue.ToEntero) Then - DdlFactura.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() - - DdlFactura.DataBind() - DdlFactura.Items.Insert(0, New ListItem("Todos", "-1")) - - End Sub - Private Sub CargaFletes() - DdlFletes.Items.Clear() - - Dim ObjInventarios As New ClsInventarios - If ddlProveedor.SelectedValue.ToEntero > 0 Then - If ObjInventarios.GetFletes(UsuarioActual.CveEmpresa, CveProveedor:=ddlProveedor.SelectedValue.ToEntero) Then - DdlFletes.DataSource = ObjInventarios.DtResultados.FiltraParametros("CantRest > 0") - Else - Alert("Ocurrió un error al obtener las ordenes de compra pendientes de recibir del proveedor. Por favor vuelva a intentar", TipoMensaje.MsgError) - End If - End If - ObjInventarios.Dispose() - - DdlFletes.DataBind() - DdlFletes.Items.Insert(0, New ListItem("Seleccione", "-1")) +#Region " CARGA FOLIOS RECEPCION " + Protected Sub ddlProveedor_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddlProveedor.selectedindexchange + CargaFoliosRecepcion() + 'DdlTipo_SelectedIndexChanged(DdlTipo, EventArgs.Empty) End Sub -#End Region - -#Region " CARGA POR SURTIR - GV " - 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() - Dim ObjInventarios As New ClsInventarios - Dim DtPendientes As New DataTable - - If ObjInventarios.ComprasPendientesAlmacenGet(-1, TxtFechaPendientes.Text.ToDate, UsuarioActual.CveEmpresa) Then - Dim FiltroTemporal = If(UsuarioActual.CveEmpresa.Contiene(119, 140), "AND TipoDocto IN ('Fac','NC','DEV')", "AND TipoDocto IN ('Fac')") - DtPendientes = ObjInventarios.DtResultados.FiltraParametros($"CantOC >= 0 {FiltroTemporal}") - 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(539) = "1" Then - ' BtnGuardar.Enabled = False - ' Dim FI As Date = Now.AddDays(-1) - ' Dim FF As Date = Now.AddDays(-7) - ' If ObjInventarios.RepNotasSinAlmacen(2, -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 recepción de mercancía si no se les da entrada a los documentos pendientes. Para más información ver el Reporte de notas sin entrada en la sección Compras.", 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() - 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 = e.Row.DBCampo("CveCompra") - - If e.Row.DBCampo("TipoDocto").ToString.Contiene({"Fac"}) And e.Row.DBCampo("EstatusAlmacen").ToString.ToEntero = 0 Then - e.Row.FCLinkButton("BtnSurtir").CssClass = "btn btn-primary" - e.Row.FCLinkButton("BtnSurtir").Text = " Recibir" - Else - e.Row.FCLinkButton("BtnSurtir").CssClass = "btn yellow-gold" - e.Row.FCLinkButton("BtnSurtir").Text = " Devolver " - End If - - If UsuarioActual.TienePermisoProceso(201) Then - Dim Css = "Texto" - Dim Liga = $"/Compras/Compras.aspx?&CveCompra={e.Row.DataKey("CveCompra")}" - e.Row.FCLabel("LblSerieFolio").Text = "" + e.Row.FCLabel("LblSerieFolio").Text + "" - End If - - End If + Private Sub CargaFoliosRecepcion() + Select Case DdlTipo.SelectedValue.ToEntero + Case 1 + CargaFolios() + Case 2 + CargaFoliosOC() + Case 3 + CargaFoliosImportacion() + Case 4 + CargaFletes() + End Select + UpFiltros.Update() End Sub -#End Region + Private Sub CargaFolios() + DdlFolio.Items.Clear() -#Region " CARGA POR SURTIR " - Protected Sub btnBuscar_Click(sender As Object, e As EventArgs) Handles BtnBuscar.Click - - 'REINICIA VALORES - DdlMonedaTC.SelectedValueExist("1") - TipoCambio = -1 - DivBitacora.Visible = False - DtBitacora.Clear() - GvInv.Columns(2).Visible = False - GvInv.Columns(3).Visible = False - CveCompraSurtir = -1 - CvePrePolizaCompra = -1 - CveOCSurtir = -1 - CveImportacionSurtir = -1 - CveImportacionProveedor = -1 - CveImportacionCompra = -1 - CveFleteSurtir = -1 - CveFleteOrdenCompra = -1 - CveFleteCompra = -1 - DivAdvertencia.Visible = False - EntregaDirecta = False - DivTipoCambio.Visible = False - Apartado = False - CveAlmacenApartado = -1 - BtnGuardar.Enabled = True - CargaAlmacenes(-1) - - DtInv = Nothing - TxtObservaciones.Text = "" - TxtOC.Text = "" - TxtFecha.Text = Now.ToShortDateString - DdlAlmacen.SelectedValueExist(-1) - TxtRemision.Text = "" - UpTipoCambio.Update() - UPInv.Update() - UpGenerales.Update() - UpFiltros.Update() - UpDatosCompra.Update() - - - If TxtOC.Text <> "" Then - LtDocumento.Text = "ORDEN DE COMPRA" - CargaOC() - ElseIf DdlFolioOC.SelectedValue.ToEntero > 0 Then - LtDocumento.Text = "ORDEN DE COMPRA" - CargaOCPorSurtir(DdlFolioOC.SelectedValue.ToEntero) - ElseIf DdlFolio.SelectedValue.ToEntero > 0 Then - LtDocumento.Text = "COMPRA" - CargaCompra(DdlFolio.SelectedValue.ToEntero, ddlProveedor.SelectedValue.ToEntero) - ElseIf DdlFolioImportacion.SelectedValue.ToEntero > 0 Then - LtDocumento.Text = "IMPORTACIÓN" - CargaImportacionSurtir(DdlFolioImportacion.SelectedValue.ToEntero) - ElseIf DdlFletes.SelectedValue.ToEntero > 0 Then - LtDocumento.Text = "FLETE" - CargaFleteSurtir(DdlFletes.SelectedValue.ToEntero) - Else - Alert("Debe seleccionar algun criterio de busqueda (Compra, OC, Importación). Por favor rectifique y vuelva a intentar", TipoMensaje.MsgAdvertencia) - BtnGuardar.Visible = False - End If - - CargaGVInv() - - DtSeccionAlmacen.Rows.Clear() - DtSeccionAlmacen.AcceptChanges() - - End Sub - Protected Sub BtnSurtir_Click(sender As Object, e As EventArgs) - If CType(sender, LinkButton).CommandArgument.ToEntero > 0 Then - CargaCompra(CType(sender, LinkButton).CommandArgument.ToEntero, -1) - TimmerRefresh.Enabled = False - End If - End Sub - Private Sub CargaCompra(pCveCompra As Integer, pCveProveedor As Integer) - CargaAlmacenes(-1) - - Dim ObjCompras As New ClsCompras - Dim ObjInventario As New ClsInventarios - - If ObjCompras.GetCompras(pCveCompra, "-1", "-1", pCveProveedor, -1, UsuarioActual.CveEmpresa) Then - If ObjCompras.DtResultados.Rows.Count > 0 Then - - CveCompraSurtir = pCveCompra - CvePrePolizaCompra = ObjCompras.DtResultados.Rows(0)("CvePrePoliza").ToString.ToEntero - - LbProveedor.Text = ObjCompras.DtResultados.Rows(0)("RazonSocial").ToString - HLFolio.Text = ObjCompras.DtResultados.Rows(0)("SerieFolio").ToString - If UsuarioActual.TienePermisoProceso(201) Then - HLFolio.NavigateUrl = $"/Compras/Compras.aspx?CveCompra={CveCompraSurtir}" - End If - LbDescripcionCompra.Text = ObjCompras.DtResultados.Rows(0)("Descripcion").ToString - UpDatosCompra.Update() - - CveMoneda = ObjCompras.DtResultados.Rows(0)("CveMoneda").ToString.ToEntero - lbDescripcion.Text = ObjCompras.DtResultados.Rows(0)("Descripcion").ToString - HdnTipoDocto.Value = ObjCompras.DtResultados.Rows(0)("TipoDocto").ToString - - TipoCambio = ObjCompras.DtResultados.Rows(0)("TipoCambio").ToString.ToDecimal - TipoMovimiento = If(ObjCompras.DtResultados.Rows(0)("EstatusAlmacen").ToString.ToEntero = 1, 2, 1) - TipoMovimiento = If(ObjCompras.DtResultados.Rows(0)("TipoDocto").ToString.Contiene("NC", "DEV"), 3, TipoMovimiento) - TotalCompraOC = ObjCompras.DtResultados.Rows(0)("SubTotal").ToString.ToDecimal - CveTipoCompra = ObjCompras.DtResultados.Rows(0)("CveTipoCompra").ToString.ToEntero - - If TipoMovimiento = 3 Then - CargaAlmacenes(-1, "21,2") - End If - RecibidaCompleta = False - - Dim CargaSoloUsados As Boolean = False - If ObjInventario.RecepcionAlmacenGet(pCveCompra, BuscaEntregaDirecta, UsuarioActual.CveEmpresa) AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then - Dim DtRecepcion As DataTable = Nothing + Dim ObjInventarios As New ClsInventarios + If ddlProveedor.SelectedValue.ToEntero > 0 Then + If ObjInventarios.ComprasPendientesAlmacenGet(ddlProveedor.SelectedValue.ToEntero, MinFecha.ToShortDateString.ToDate, UsuarioActual.CveEmpresa) Then + Dim FiltroTemporal = If(UsuarioActual.CveEmpresa = 119, "AND TipoDocto IN ('Fac','NC','DEV')", "AND TipoDocto IN ('Fac')") + DdlFolio.DataSource = ObjInventarios.DtResultados.FiltraParametros($"CantOC >= 0 {FiltroTemporal}") + 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")) + End Sub + Private Sub CargaFoliosImportacion() + DdlFolioImportacion.Items.Clear() + + Dim ObjInventarios As New ClsInventarios + If ddlProveedor.SelectedValue.ToEntero > 0 Then + If ObjInventarios.PendientesAlmacenImportacionGet(ddlProveedor.SelectedValue.ToEntero, MinFecha.ToShortDateString.ToDate, UsuarioActual.CveEmpresa) Then + DdlFolioImportacion.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() + + DdlFolioImportacion.DataBind() + DdlFolioImportacion.Items.Insert(0, New ListItem("Seleccione", "-1")) + CargaFactura() + End Sub + Protected Sub DdlFolioImportacion_SelectedIndexChanged(sender As Object, e As EventArgs) + CargaFactura() + End Sub + Private Sub CargaFactura() + + DdlFactura.Items.Clear() + + Dim ObjInventarios As New ClsInventarios + If DdlFolioImportacion.SelectedValue.ToEntero > 0 Then + If ObjInventarios.PendientesAlmacenImportacionComprasGet(DdlFolioImportacion.SelectedValue.ToEntero, ddlProveedor.SelectedValue.ToEntero) Then + DdlFactura.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() + + DdlFactura.DataBind() + DdlFactura.Items.Insert(0, New ListItem("Todos", "-1")) + + End Sub + Private Sub CargaFletes() + DdlFletes.Items.Clear() + + Dim ObjInventarios As New ClsInventarios + If ddlProveedor.SelectedValue.ToEntero > 0 Then + If ObjInventarios.GetFletes(UsuarioActual.CveEmpresa, CveProveedor:=ddlProveedor.SelectedValue.ToEntero) Then + DdlFletes.DataSource = ObjInventarios.DtResultados.FiltraParametros("CantRest > 0") + Else + Alert("Ocurrió un error al obtener las ordenes de compra pendientes de recibir del proveedor. Por favor vuelva a intentar", TipoMensaje.MsgError) + End If + End If + ObjInventarios.Dispose() + + DdlFletes.DataBind() + DdlFletes.Items.Insert(0, New ListItem("Seleccione", "-1")) + End Sub +#End Region + +#Region " CARGA POR SURTIR - GV " + 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() + Dim ObjInventarios As New ClsInventarios + Dim DtPendientes As New DataTable + + If ObjInventarios.ComprasPendientesAlmacenGet(-1, TxtFechaPendientes.Text.ToDate, UsuarioActual.CveEmpresa) Then + Dim FiltroTemporal = If(UsuarioActual.CveEmpresa.Contiene(119, 140), "AND TipoDocto IN ('Fac','NC','DEV')", "AND TipoDocto IN ('Fac')") + DtPendientes = ObjInventarios.DtResultados.FiltraParametros($"CantOC >= 0 {FiltroTemporal}") + 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(539) = "1" Then + ' BtnGuardar.Enabled = False + ' Dim FI As Date = Now.AddDays(-1) + ' Dim FF As Date = Now.AddDays(-7) + ' If ObjInventarios.RepNotasSinAlmacen(2, -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 recepción de mercancía si no se les da entrada a los documentos pendientes. Para más información ver el Reporte de notas sin entrada en la sección Compras.", 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() + 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 = e.Row.DBCampo("CveCompra") + + If e.Row.DBCampo("TipoDocto").ToString.Contiene({"Fac"}) And e.Row.DBCampo("EstatusAlmacen").ToString.ToEntero = 0 Then + e.Row.FCLinkButton("BtnSurtir").CssClass = "btn btn-primary" + e.Row.FCLinkButton("BtnSurtir").Text = " Recibir" + Else + e.Row.FCLinkButton("BtnSurtir").CssClass = "btn yellow-gold" + e.Row.FCLinkButton("BtnSurtir").Text = " Devolver " + End If + + If UsuarioActual.TienePermisoProceso(201) Then + Dim Css = "Texto" + Dim Liga = $"/Compras/Compras.aspx?&CveCompra={e.Row.DataKey("CveCompra")}" + e.Row.FCLabel("LblSerieFolio").Text = "" + e.Row.FCLabel("LblSerieFolio").Text + "" + End If + + End If + End Sub +#End Region + +#Region " CARGA POR SURTIR " + Protected Sub btnBuscar_Click(sender As Object, e As EventArgs) Handles BtnBuscar.Click + + 'REINICIA VALORES + DdlMonedaTC.SelectedValueExist("1") + TipoCambio = -1 + DivBitacora.Visible = False + DtBitacora.Clear() + GvInv.Columns(2).Visible = False + GvInv.Columns(3).Visible = False + CveCompraSurtir = -1 + CvePrePolizaCompra = -1 + CveOCSurtir = -1 + CveImportacionSurtir = -1 + CveImportacionProveedor = -1 + CveImportacionCompra = -1 + CveFleteSurtir = -1 + CveFleteOrdenCompra = -1 + CveFleteCompra = -1 + DivAdvertencia.Visible = False + EntregaDirecta = False + DivTipoCambio.Visible = False + Apartado = False + CveAlmacenApartado = -1 + BtnGuardar.Enabled = True + CargaAlmacenes(-1) + + DtInv = Nothing + TxtObservaciones.Text = "" + TxtOC.Text = "" + TxtFecha.Text = Now.ToShortDateString + DdlAlmacen.SelectedValueExist(-1) + TxtRemision.Text = "" + UpTipoCambio.Update() + UPInv.Update() + UpGenerales.Update() + UpFiltros.Update() + UpDatosCompra.Update() + + + If TxtOC.Text <> "" Then + LtDocumento.Text = "ORDEN DE COMPRA" + CargaOC() + ElseIf DdlFolioOC.SelectedValue.ToEntero > 0 Then + LtDocumento.Text = "ORDEN DE COMPRA" + CargaOCPorSurtir(DdlFolioOC.SelectedValue.ToEntero) + ElseIf DdlFolio.SelectedValue.ToEntero > 0 Then + LtDocumento.Text = "COMPRA" + CargaCompra(DdlFolio.SelectedValue.ToEntero, ddlProveedor.SelectedValue.ToEntero) + ElseIf DdlFolioImportacion.SelectedValue.ToEntero > 0 Then + LtDocumento.Text = "IMPORTACIÓN" + CargaImportacionSurtir(DdlFolioImportacion.SelectedValue.ToEntero) + ElseIf DdlFletes.SelectedValue.ToEntero > 0 Then + LtDocumento.Text = "FLETE" + CargaFleteSurtir(DdlFletes.SelectedValue.ToEntero) + Else + Alert("Debe seleccionar algun criterio de busqueda (Compra, OC, Importación). Por favor rectifique y vuelva a intentar", TipoMensaje.MsgAdvertencia) + BtnGuardar.Visible = False + End If + + CargaGVInv() + + DtSeccionAlmacen.Rows.Clear() + DtSeccionAlmacen.AcceptChanges() + + End Sub + Protected Sub BtnSurtir_Click(sender As Object, e As EventArgs) + If CType(sender, LinkButton).CommandArgument.ToEntero > 0 Then + CargaCompra(CType(sender, LinkButton).CommandArgument.ToEntero, -1) + TimmerRefresh.Enabled = False + End If + End Sub + Private Sub CargaCompra(pCveCompra As Integer, pCveProveedor As Integer) + CargaAlmacenes(-1) + + Dim ObjCompras As New ClsCompras + Dim ObjInventario As New ClsInventarios + + If ObjCompras.GetCompras(pCveCompra, "-1", "-1", pCveProveedor, -1, UsuarioActual.CveEmpresa) Then + If ObjCompras.DtResultados.Rows.Count > 0 Then + + CveCompraSurtir = pCveCompra + CvePrePolizaCompra = ObjCompras.DtResultados.Rows(0)("CvePrePoliza").ToString.ToEntero + + LbProveedor.Text = ObjCompras.DtResultados.Rows(0)("RazonSocial").ToString + HLFolio.Text = ObjCompras.DtResultados.Rows(0)("SerieFolio").ToString + If UsuarioActual.TienePermisoProceso(201) Then + HLFolio.NavigateUrl = $"/Compras/Compras.aspx?CveCompra={CveCompraSurtir}" + End If + LbDescripcionCompra.Text = ObjCompras.DtResultados.Rows(0)("Descripcion").ToString + UpDatosCompra.Update() + + CveMoneda = ObjCompras.DtResultados.Rows(0)("CveMoneda").ToString.ToEntero + lbDescripcion.Text = ObjCompras.DtResultados.Rows(0)("Descripcion").ToString + HdnTipoDocto.Value = ObjCompras.DtResultados.Rows(0)("TipoDocto").ToString + + TipoCambio = ObjCompras.DtResultados.Rows(0)("TipoCambio").ToString.ToDecimal + TipoMovimiento = If(ObjCompras.DtResultados.Rows(0)("EstatusAlmacen").ToString.ToEntero = 1, 2, 1) + TipoMovimiento = If(ObjCompras.DtResultados.Rows(0)("TipoDocto").ToString.Contiene("NC", "DEV"), 3, TipoMovimiento) + TotalCompraOC = ObjCompras.DtResultados.Rows(0)("SubTotal").ToString.ToDecimal + CveTipoCompra = ObjCompras.DtResultados.Rows(0)("CveTipoCompra").ToString.ToEntero + + If TipoMovimiento = 3 Then + CargaAlmacenes(-1, "21,2") + End If + RecibidaCompleta = False + + Dim CargaSoloUsados As Boolean = False + If ObjInventario.RecepcionAlmacenGet(pCveCompra, BuscaEntregaDirecta, UsuarioActual.CveEmpresa) AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then + Dim DtRecepcion As DataTable = Nothing Dim NumUsados = ObjInventario.DtResultados.COUNT("EsUsado", "EsUsado = True").ToEntero() Dim NumProductos = ObjInventario.DtResultados.COUNT("EsUsado", "EsUsado = False").ToEntero() @@ -863,1072 +863,1072 @@ Partial Class Inventarios_RecepcionAlmacen DtRecepcion = ObjInventario.DtResultados.Copy() End If - DtDatosDetalle = Nothing - CreaDtDetalle() - DtDatosLoteDetalle = Nothing - CreaDtLoteDetalle() - CreaDTInv(DtRecepcion) - BtnGuardar.Visible = True - - 'cuando están todos los detalles de la compra, nos indica que se va a recibir la totalidad de la compra - If DtRecepcion.Rows.Count = DtRecepcion.Rows(0)("NumDetalles").ToString.ToEntero Then - RecibidaCompleta = True - End If - - ''MONEDA DIFERENTE - If CveMoneda <> 1 Then - 'DivTipoCambio.Visible = True - DdlMonedaTC.SelectedValueExist("2") - DdlMonedaTC_SelectedIndexChanged(DdlMonedaTC, EventArgs.Empty) - 'TxtTipoCambio.Text = If(TipoCambio <= 0, GlobalTipoCambio(TxtFecha.Text.ToDate).ToString, TipoCambio.ToString) - TipoCambio = If(TipoCambio <= 0, GlobalTipoCambio(TxtFecha.Text.ToDate), TipoCambio) - LtAdvertencia.Text = "El cambio de moneda se aplicara al guardar el movimiento con el tipo de cambio indicado." - DivAdvertencia.Visible = True - End If - UpTipoCambio.Update() - - ''ENTREGA DIRECTA - If BuscaEntregaDirecta > 0 Then - If UsuarioActual.Empresa.Funcionalidad(149) = "1" Then - LtAdvertencia.Text = "La mercancía tendra salida inmediata por ser entrega directa al cliente" - DivAdvertencia.Visible = True - EntregaDirecta = True - CveCliente = DtRecepcion.Rows(0)("CveCliente").ToString.ToEntero - CveVendedor = DtRecepcion.Rows(0)("CveVendedor").ToString.ToEntero - - - If DtInv.COUNT("EntregaDirecta") <> DtInv.Rows.Count Then - Alert("Todos los conceptos deben estar facturados.", TipoMensaje.MsgAdvertencia) - BtnGuardar.Enabled = False - End If - End If - End If - - If DtInv.Rows.Count = 0 Then - Alert("No hay productos pendientes de surtir de esta compra. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) - Else - - If DtRecepcion.Rows(0)("CveVendedor").ToString.ToEntero > 0 And DtRecepcion.Rows(0)("CveCliente").ToString.ToEntero > 0 Then - If DtInv.SUM("EntregaDirecta") > 0 Then - ''ENTREGA DIRECTA - 'LtAdvertencia.Text = "La mercancía tendra salida inmediata por ser entrega directa al cliente" - 'DivAdvertencia.Visible = True - 'EntregaDirecta = True - Else - 'APARTADO - 'If UsuarioActual.CveUsuario.Contiene(100) Or (DtRecepcion .Rows(0)("CveUsuarioOC").ToString.ToEntero = 1559 And DtRecepcion .Rows(0)("FechaIngOC").ToString.ToDateTime > "2017-04-24 12:00".ToDateTime) Then - If UsuarioActual.Empresa.Funcionalidad(148) = "1" Then - CveAlmacenApartado = DtRecepcion.Rows(0)("CveAlmacenApartado").ToString.ToEntero - DivAdvertencia.Visible = True - Apartado = True - - If CveAlmacenApartado <= 0 Then - BtnGuardar.Enabled = False - LtAdvertencia.Text = "No se puede recibir la mercancía por ser de apartados y no contar con un almacen de apartado." - Else - LtAdvertencia.Text = "La mercancía sera traspasada ha apartados" + DtDatosDetalle = Nothing + CreaDtDetalle() + DtDatosLoteDetalle = Nothing + CreaDtLoteDetalle() + CreaDTInv(DtRecepcion) + BtnGuardar.Visible = True + + 'cuando están todos los detalles de la compra, nos indica que se va a recibir la totalidad de la compra + If DtRecepcion.Rows.Count = DtRecepcion.Rows(0)("NumDetalles").ToString.ToEntero Then + RecibidaCompleta = True + End If + + ''MONEDA DIFERENTE + If CveMoneda <> 1 Then + 'DivTipoCambio.Visible = True + DdlMonedaTC.SelectedValueExist("2") + DdlMonedaTC_SelectedIndexChanged(DdlMonedaTC, EventArgs.Empty) + 'TxtTipoCambio.Text = If(TipoCambio <= 0, GlobalTipoCambio(TxtFecha.Text.ToDate).ToString, TipoCambio.ToString) + TipoCambio = If(TipoCambio <= 0, GlobalTipoCambio(TxtFecha.Text.ToDate), TipoCambio) + LtAdvertencia.Text = "El cambio de moneda se aplicara al guardar el movimiento con el tipo de cambio indicado." + DivAdvertencia.Visible = True + End If + UpTipoCambio.Update() + + ''ENTREGA DIRECTA + If BuscaEntregaDirecta > 0 Then + If UsuarioActual.Empresa.Funcionalidad(149) = "1" Then + LtAdvertencia.Text = "La mercancía tendra salida inmediata por ser entrega directa al cliente" + DivAdvertencia.Visible = True + EntregaDirecta = True + CveCliente = DtRecepcion.Rows(0)("CveCliente").ToString.ToEntero + CveVendedor = DtRecepcion.Rows(0)("CveVendedor").ToString.ToEntero + + + If DtInv.COUNT("EntregaDirecta") <> DtInv.Rows.Count Then + Alert("Todos los conceptos deben estar facturados.", TipoMensaje.MsgAdvertencia) + BtnGuardar.Enabled = False + End If + End If + End If + + If DtInv.Rows.Count = 0 Then + Alert("No hay productos pendientes de surtir de esta compra. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) + Else + + If DtRecepcion.Rows(0)("CveVendedor").ToString.ToEntero > 0 And DtRecepcion.Rows(0)("CveCliente").ToString.ToEntero > 0 Then + If DtInv.SUM("EntregaDirecta") > 0 Then + ''ENTREGA DIRECTA + 'LtAdvertencia.Text = "La mercancía tendra salida inmediata por ser entrega directa al cliente" + 'DivAdvertencia.Visible = True + 'EntregaDirecta = True + Else + 'APARTADO + 'If UsuarioActual.CveUsuario.Contiene(100) Or (DtRecepcion .Rows(0)("CveUsuarioOC").ToString.ToEntero = 1559 And DtRecepcion .Rows(0)("FechaIngOC").ToString.ToDateTime > "2017-04-24 12:00".ToDateTime) Then + If UsuarioActual.Empresa.Funcionalidad(148) = "1" Then + CveAlmacenApartado = DtRecepcion.Rows(0)("CveAlmacenApartado").ToString.ToEntero + DivAdvertencia.Visible = True + Apartado = True + + If CveAlmacenApartado <= 0 Then + BtnGuardar.Enabled = False + LtAdvertencia.Text = "No se puede recibir la mercancía por ser de apartados y no contar con un almacen de apartado." + Else + LtAdvertencia.Text = "La mercancía sera traspasada ha apartados" If CargaSoloUsados Then CargaAlmacenes(DtRecepcion.Rows(0)("CveSubProyecto").ToString.ToEntero, "22") Else CargaAlmacenes(DtRecepcion.Rows(0)("CveSubProyecto").ToString.ToEntero) - End If - End If - End If - 'End If - End If - End If - - End If - - Dim CantidadFaltante As Double = DtRecepcion.SUM("CantidadC", "CantidadF > 0") - - If UsuarioActual.Empresa.UsaAC AndAlso CantidadFaltante > 0 Then - PnlAC.Visible = True - CargaAC() - LbTotalPorDevengar.Text = DtRecepcion.SUM("Total", "CantidadF > 0").FormatoNumero - End If - - - 'Existencias - If TipoMovimiento = 2 Then - If ObjInventario.ComprasDevolucionExistenciasGet(CveCompraSurtir) Then + End If + End If + End If + 'End If + End If + End If + + End If + + Dim CantidadFaltante As Double = DtRecepcion.SUM("CantidadC", "CantidadF > 0") + + If UsuarioActual.Empresa.UsaAC AndAlso CantidadFaltante > 0 Then + PnlAC.Visible = True + CargaAC() + LbTotalPorDevengar.Text = DtRecepcion.SUM("Total", "CantidadF > 0").FormatoNumero + End If + + + 'Existencias + If TipoMovimiento = 2 Then + If ObjInventario.ComprasDevolucionExistenciasGet(CveCompraSurtir) Then DtExistencias = ObjInventario.DtResultados.Copy - Else - Alert("No se pudieron cargar las existencias del movimiento de entrada, por lo cual no se podra hacer la devolución.", TipoMensaje.MsgError) - BtnGuardar.Enabled = False - End If - End If - End If - - - - DivBitacora.Visible = True - - If UsuarioActual.Empresa.Funcionalidad(132) = "1" Then - DivCodigoSeriePS.Visible = True - Else - DivCodigoSeriePS.Visible = False - End If - + Else + Alert("No se pudieron cargar las existencias del movimiento de entrada, por lo cual no se podra hacer la devolución.", TipoMensaje.MsgError) + BtnGuardar.Enabled = False + End If + End If + End If + + + + DivBitacora.Visible = True + + If UsuarioActual.Empresa.Funcionalidad(132) = "1" Then + DivCodigoSeriePS.Visible = True + Else + DivCodigoSeriePS.Visible = False + End If + If UsuarioActual.Empresa.Funcionalidad(573) = "1" Then DivVirtualAdvertencia.Visible = True - End If - - End If - Else - BtnGuardar.Visible = False - End If - - - ObjCompras.Dispose() - ObjInventario.Dispose() - - CargaGVInv() - End Sub - - Private Sub CargaImportacionSurtir(pCveImportacion As Integer) - Dim ObjCompras As New ClsCompras - Dim ObjInventario As New ClsInventarios - - If ObjCompras.GetImportaciones(pCveImportacion, -1, -1, "-1", "-1", UsuarioActual.CveEmpresa) Then - If ObjCompras.DtResultados.Rows.Count > 0 Then - CveImportacionSurtir = pCveImportacion - CveImportacionProveedor = ddlProveedor.SelectedValue.ToEntero - CveImportacionCompra = DdlFactura.SelectedValue.ToEntero - LbProveedor.Text = ObjCompras.DtResultados.Rows(0)("Aduanal").ToString - HLFolio.Text = ObjCompras.DtResultados.Rows(0)("PedimentoDescripcion").ToString - If UsuarioActual.TienePermisoProceso(201) Then - HLFolio.NavigateUrl = $"/Compras/Importaciones.aspx?CveImportacion={CveImportacionSurtir}" - End If - UpDatosCompra.Update() - CveMoneda = 1 - lbDescripcion.Text = "" - TipoMovimiento = 1 - - If ObjInventario.RecepcionAlmacenImportacionGet(CveImportacionSurtir, DdlFactura.SelectedValue.ToEntero, CveImportacionProveedor, UsuarioActual.CveEmpresa) AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then - DtDatosDetalle = Nothing - CreaDtDetalle() - DtDatosLoteDetalle = Nothing - CreaDtLoteDetalle() - CreaDTInv(ObjInventario.DtResultados) - BtnGuardar.Visible = True - End If - - If DtInv Is Nothing OrElse DtInv.Rows.Count = 0 Then - Alert("No hay productos pendientes de surtir de esta importación. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) - End If - - DivBitacora.Visible = True - - If UsuarioActual.Empresa.Funcionalidad(132) = "1" Then - DivCodigoSeriePS.Visible = True - Else - DivCodigoSeriePS.Visible = False - End If - - End If - Else - BtnGuardar.Visible = False - End If - - ObjCompras.Dispose() - ObjInventario.Dispose() - - CargaGVInv() - - End Sub - Private Sub CargaFleteSurtir(pCveImportacion As Integer) - Dim ObjInventario As New ClsInventarios - - If ObjInventario.GetFletes(UsuarioActual.CveEmpresa, CveFlete:=pCveImportacion) Then - If ObjInventario.DtResultados.Rows.Count > 0 Then - CveFleteSurtir = pCveImportacion - CveFleteOrdenCompra = ObjInventario.DtResultados.Rows(0)("CveOC").ToString.ToEntero - CveFleteCompra = ObjInventario.DtResultados.Rows(0)("CveCompra").ToString.ToEntero - LbProveedor.Text = ObjInventario.DtResultados.Rows(0)("RazonSocial").ToString - HLFolio.Text = ObjInventario.DtResultados.Rows(0)("Folio").ToString - If UsuarioActual.TienePermisoProceso(201) Then - HLFolio.NavigateUrl = $"/Inventarios/Fletes.aspx?CveFlete={CveFleteSurtir}" - End If - UpDatosCompra.Update() - CveMoneda = 1 - lbDescripcion.Text = "" - TipoMovimiento = 1 - - If ObjInventario.RecepcionAlmacenFleteGet(CveFleteSurtir, CveFleteOrdenCompra, CveFleteCompra, UsuarioActual.CveEmpresa) AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then - DtDatosDetalle = Nothing - CreaDtDetalle() - DtDatosLoteDetalle = Nothing - CreaDtLoteDetalle() - CreaDTInv(ObjInventario.DtResultados) - BtnGuardar.Visible = True - End If - - If DtInv Is Nothing OrElse DtInv.Rows.Count = 0 Then - Alert("No hay productos pendientes de surtir de esta importación. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) - End If - - DivBitacora.Visible = True - - If UsuarioActual.Empresa.Funcionalidad(132) = "1" Then - DivCodigoSeriePS.Visible = True - Else - DivCodigoSeriePS.Visible = False - End If - - End If - Else - BtnGuardar.Visible = False - End If - - ObjInventario.Dispose() - - CargaGVInv() - - End Sub -#End Region + End If -#Region " GVINV " - Private Sub CreaDTInv(TmDT As DataTable) - TmDT.Columns.Add("CveAlmacen", GetType(Integer)) - TmDT.Columns.Add("PUExtranjero", GetType(Double)) - TmDT.Columns.Add("CostoIndirectoExtranjero", GetType(Double)) - TmDT.Columns.Add("Consec", GetType(Integer)) - TmDT.Columns.Add("CantidadSurtidaPantalla", GetType(Double)) - If Not TmDT.Columns.Contains("CostoIndirecto") Then - TmDT.Columns.Add("CostoIndirecto", GetType(Double)) - End If - - GvInv.Columns(2).Visible = False - GvInv.Columns(3).Visible = False - GvInv.Columns(9).Visible = TmDT.SUM("CostoIndirecto") > 0 - - Dim VariableCampo = If(TipoMovimiento.Contiene(1, 3), "CantidadF", "CantidadS") - - Dim Index = 1 - For Each Dr As DataRow In TmDT.Rows - Dr("PUExtranjero") = Dr("PU") - Dr("CostoIndirectoExtranjero") = Dr("CostoIndirecto") - Dr("Consec") = Index - Index += 1 - Dr("CantidadF") = Dr(VariableCampo) - - If Dr(VariableCampo).ToString.ToDecimal <> Dr("CantidadC").ToString.ToDecimal Then - GvInv.Columns(3).Visible = True - End If - Next - - DtInv = TmDT '.FiltraParametros("CantidadF > 0") - dt = TmDT - If DtInv.SUM("CantidadS") > 0 Then - GvInv.Columns(2).Visible = True - End If - - End Sub - Private Sub CargaGVInv() - If UsuarioActual.CveEmpresa = 119 Then - DtInv = DtInv.FiltraParametros("", "PS") - End If - GvInv.DataSource = DtInv - GvInv.DataBind() - UPInv.Update() - End Sub - Protected Sub GVINV_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvInv.RowDataBound - - If e.Row.RowType = DataControlRowType.DataRow Then - - If e.Row.DBCampo("CveMetodoInventario").ToString.Contiene("5", "6") Then - - If e.Row.DBCampo("CveMetodoInventario").ToString = "5" Then - e.Row.FCButton("BtnSerieLote").Visible = True - e.Row.FCButton("BtnSerieLote").CommandArgument = String.Format("{0}°{1}°{2}°{3}°{4}°{5}", e.Row.DBCampo("CvePS"), e.Row.DBCampo("CveUM"), e.Row.DBCampo("PU"), e.Row.DBCampo("PS"), e.Row.DBCampo("CantidadF"), e.Row.DBCampo("Consec")) - - e.Row.FCTextBox("TbCantidadF").Enabled = False - e.Row.FCCheckBox("cbInv").Enabled = False - Dim Contador = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", e.Row.DataKey("Consec"))).Rows.Count - e.Row.FCTextBox("TbCantidadF").Text = Contador.ToString - ElseIf e.Row.DBCampo("CveMetodoInventario").ToString = "6" Then - e.Row.FCButton("BtnLote").Visible = True - e.Row.FCButton("BtnLote").CommandArgument = String.Format("{0}°{1}°{2}°{3}°{4}°{5}", e.Row.DBCampo("CvePS"), e.Row.DBCampo("CveUM"), e.Row.DBCampo("PU"), e.Row.DBCampo("PS"), e.Row.DBCampo("CantidadF"), e.Row.DBCampo("Consec")) - - e.Row.FCTextBox("TbCantidadF").Enabled = False - e.Row.FCCheckBox("cbInv").Enabled = False - Dim Contador = DtDatosLoteDetalle.FiltraParametros(String.Format("ConsecId = {0}", e.Row.DataKey("Consec"))).Rows.Count - e.Row.FCTextBox("TbCantidadF").Text = Contador.ToString - End If - - Else - e.Row.FCButton("BtnSerieLote").Visible = False - e.Row.FCButton("BtnLote").Visible = False - - e.Row.FCTextBox("TbCantidadF").Enabled = True - e.Row.FCTextBox("TbCantidadF").Attributes.Add("onblur", String.Format("ValidarCantidad(this,{0})", e.Row.DBCampo("CantidadF"))) - e.Row.FCCheckBox("cbInv").Attributes.Add("onclick", String.Format("Check(this, {0}, {1});", e.Row.FCTextBox("TbCantidadF").ClientID, e.Row.DBCampo("CantidadF"))) - - If e.Row.DBCampo("EntregaDirecta").ToString = "1" And TipoMovimiento = 1 Then - e.Row.FCCheckBox("cbInv").Checked = True - e.Row.FCCheckBox("cbInv").Enabled = False - e.Row.FCTextBox("TbCantidadF").Text = e.Row.DBCampo("CantidadF").FormatoNumero - e.Row.FCTextBox("TbCantidadF").Enabled = False - End If - End If - - - 'FUNCIONALIDAD PISTOLA DE CODIGOS - If UsuarioActual.Empresa.Funcionalidad(132) = "1" And e.Row.DBCampo("CodigoBarras").Trim <> "" And Not UsuarioActual.TienePermisoProceso(174) Then - e.Row.FCTextBox("TbCantidadF").Enabled = False - End If - - If e.Row.DBCampo("CantidadF").ToDecimal = 0 Then - e.Row.FCTextBox("TbCantidadF").Visible = False - e.Row.Cells(3).Text = "0" - e.Row.FCCheckBox("cbInv").Visible = False - End If - - 'TotalGV += e.Row.DBCampo("PU").ToString.ToDecimal * e.Row.DBCampo("CantidadF").ToString.ToDecimal - - If UsuarioActual.Empresa.Funcionalidad(147) = "1" Then - e.Row.FCDropDownList("DdlSeccionAlmacen").DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa) - e.Row.FCDropDownList("DdlSeccionAlmacen").DataBind() - e.Row.FCDropDownList("DdlSeccionAlmacen").Items.Insert(0, New ListItem("Seleccione", "-1")) - End If - - e.Row.FCLabel("LbTotal").Text = ((e.Row.DBCampo("PU").ToDecimal + e.Row.DBCampo("CostoIndirecto").ToDecimal) * e.Row.DBCampo("CantidadF").ToDecimal).FormatoNumero - - TotalGV += (e.Row.DBCampo("PU").ToDecimal + e.Row.DBCampo("CostoIndirecto").ToDecimal) * e.Row.DBCampo("CantidadF").ToDecimal - - End If - - If e.Row.RowType = DataControlRowType.Footer Then - Dim TienePermisoImportes As Boolean = UsuarioActual.TienePermisoProceso(201) - - e.Row.FCLabel("LbTotal").Visible = TienePermisoImportes - - If TienePermisoImportes Then - e.Row.FCLabel("LbTotal").Text = TotalGV.FormatoNumero - TotalGV = 0.0D - e.Row.Font.Bold = True - e.Row.Cells(6).Text = "Total" - e.Row.Cells(6).HorizontalAlign = HorizontalAlign.Right - End If - - End If - - End Sub -#End Region + End If + Else + BtnGuardar.Visible = False + End If -#Region " AGREGAR " -#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 - - For Each Gvr As GridViewRow In GvInv.Rows - If Gvr.DataKey("CodigoBarras") = TxtCodigoPS.Text.Trim Then - Dim TxtCantidad = GvInv.Rows(Gvr.RowIndex).FCTextBox("TbCantidadF") - If Gvr.DataKey("CantidadF").ToDecimal - TxtCantidad.Text.ToDecimal - 1 >= 0 Then - - If Gvr.DataKey("AplicaSerieLote") = "True" Then - TdSeriePS.Visible = True - TxtSeriePS.Focus() - - CveConsecSerieLote = Gvr.DataKey("Consec").ToEntero - CvePSSerieLote = Gvr.DataKey("CvePS").ToEntero - CveUMSerieLote = 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 - - 'VERIFICA EXISTENCIAS - Dim MensajeSinExistencias As New StringBuilder - If TipoMovimiento > 1 Then - Dim ExistenciaActual = DtInv.SUM("CantidadSurtidaPantalla", $"CvePS = {Gvr.DataKey("CvePS").ToEntero} AND CveUM = {Gvr.DataKey("CveUM").ToEntero} ") + 1 - Dim ObjInventarios As New ClsInventarios - Dim Existencia = ObjInventarios.GetExistenciasPS(Gvr.DataKey("CvePS").ToEntero, Gvr.DataKey("CveUM").ToEntero, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm")) - ObjInventarios.Dispose() - - If Existencia < ExistenciaActual Then - Alert($"El producto con el codigo de barras {TxtCodigoPS.Text} no tiene la existencia suficiente.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - 'EXISTENCIAS DE LA COMPRAR - PARA DEVOLUCION - If TipoMovimiento = 2 Then - If DtExistencias.SUM("Existencia", $"CvePS = {Gvr.DataKey("CvePS").ToEntero} AND CveUM = {Gvr.DataKey("CveUM").ToEntero}") < ExistenciaActual Then - Alert($"El producto con el codigo de barras {TxtCodigoPS.Text} no tiene la existencia suficiente de recepción.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - End If - End If - - TxtCantidad.Text = (TxtCantidad.Text.ToDecimal + 1).ToString.FormatoNumero - TxtCodigoPS.Text = "" - RegistraScript("playsonidito('beep-07.wav')") - UPInv.Update() - Dim Dr = DtInv.Select($"Consec = {Gvr.DataKey("Consec")}")(0) - Dr("CantidadSurtidaPantalla") = TxtCantidad.Text.ToDouble - DtInv.AcceptChanges() - Exit Sub - End If - - End If - - Alert($"Ya se ha cargado la totalidad del Producto ""{Gvr.DataKey("PS").ToString}"" con el Codigo ""{TxtCodigoPS.Text}"".", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus,200);") - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - End If - Next - - - Alert($"No se ha encontrado un producto para surtir con el Codigo ""{TxtCodigoPS.Text}"". ", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus,200);") - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - TxtCodigoPS.Text = "" - - End Sub - Protected Sub BtnSeriePS_Click(sender As Object, e As EventArgs) - AgregaSerieLote(TxtSeriePS.Text.Trim, 2) - TdSeriePS.Visible = False - TxtSeriePS.Text = "" - TxtCodigoPS.Text = "" - TxtCodigoPS.Focus() - End Sub - Protected Sub BtnGuardarCantidadEspecial_Click(sender As Object, e As EventArgs) - AgregaCantidadEspecial() - End Sub - Private Sub AgregaCantidadEspecial() - Dim TxtCantidad = GvInv.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);") - UPInv.Update() - TxtCodigoPS.Focus() - RegistraScript("playsonidito('beep-07.wav')") - 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 + ObjCompras.Dispose() + ObjInventario.Dispose() -#Region " AGREGA POR SERIE/LOTE " - Protected Sub BtnSerieLote_Click(sender As Object, e As EventArgs) - - Dim Argumentos = CType(sender, Button).CommandArgument.Split("°"c) - - LbProducto.Text = Argumentos(3) - LbCantidad.Text = Argumentos(4).FormatoNumero - TxtFechaCaducidad.Text = Now.ToShortDateString() - - CvePSSerieLote = Argumentos(0).ToEntero - CveUMSerieLote = Argumentos(1).ToEntero - PUSerieLote = Argumentos(2).ToDecimal - CveConsecSerieLote = Argumentos(5).ToEntero - - CargaSerie(1) - - End Sub - Private Sub CreaDtDetalle() - If DtDatosDetalle Is Nothing Then - DtDatosDetalle = New DataTable - DtDatosDetalle.Columns.Add("Consec", GetType(Integer)) - DtDatosDetalle.Columns.Add("ConsecId", GetType(Integer)) - DtDatosDetalle.Columns.Add("CvePS", GetType(Integer)) - DtDatosDetalle.Columns.Add("CveUM", GetType(Integer)) - DtDatosDetalle.Columns.Add("PU", GetType(Decimal)) - DtDatosDetalle.Columns.Add("Serie", GetType(String)) - DtDatosDetalle.Columns.Add("FechaCaducidad", GetType(String)) - End If - End Sub - - Private Sub CargaSerie(Tipo As Integer, Optional CerrarCompletado As Boolean = False) - 'RegistraScript("document.getElementById(""TxtSerieLote"").focus();") - RegistraScript("$('#DivSerie').modal();", "ModalLote") - - Dim AplicaCaducidad = False - If GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePSSerieLote).FiltraParametros("").Rows(0) IsNot Nothing Then - AplicaCaducidad = If(GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePSSerieLote).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}", CveConsecSerieLote), "Consec DESC") - GvSerie.DataBind() - - 'VALIDA QUE SIGA AGREGANDO - If Not DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", CveConsecSerieLote)).Rows.Count < LbCantidad.Text.ToEntero Then - BtnAgregarPS.Enabled = False - If CerrarCompletado Then - RegistraScript("$('#DivSerie').modal('hide');") - End If - Else - BtnAgregarPS.Enabled = True - End If - - 'SI TIENE ENTRADA POR SERIE LOTE, BLOQUEAMOS CHECK Y TXTCANTIDAD - Dim Contador = 0 - For Each Gvr As GridViewRow In GvInv.Rows - If Gvr.DataKey("CvePS").ToEntero = CvePSSerieLote Then - Contador = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Gvr.DataKey("Consec"))).Rows.Count - Gvr.FCCheckBox("cbInv").Enabled = False - Gvr.FCTextBox("TbCantidadF").Enabled = False - If DtDatosDetalle IsNot Nothing AndAlso Contador > 0 Then - Gvr.FCCheckBox("cbInv").Checked = True - Gvr.FCTextBox("TbCantidadF").Text = Contador.ToString - ElseIf Gvr.DataKey("CantidadF").ToString.ToDecimal <> 0 Then - Gvr.FCCheckBox("cbInv").Checked = False - Gvr.FCTextBox("TbCantidadF").Text = "0" - End If - End If - - Dim Dr = DtInv.Select($"Consec = {Gvr.DataKey("Consec")}")(0) - Dr("CantidadSurtidaPantalla") = Gvr.FCTextBox("TbCantidadF").Text.ToDouble - DtInv.AcceptChanges() - Next - - - UPInv.Update() - UpSerie.Update() - TxtSerieLote.Text = "" - TxtSerieLote.Focus() - - If Tipo = 1 Then - RegistraScript(String.Format("$('#{0}').on('shown.bs.modal', function () {{$('#{0}').focus(); $('#{0}').trigger(jQuery.Event('keypress', {{which: 13}})); }});$('#DivSerie').modal('show'); ", TxtSerieLote.ClientID)) - End If - - End Sub - Protected Sub BtnAgregarPS_Click(sender As Object, e As EventArgs) - AgregaSerieLote(TxtSerieLote.Text.Replace(" ", String.Empty), 1) - End Sub - Private Sub AgregaSerieLote(SerieLote As String, Tipo As Integer) - 'SerieLote = SerieLote.Trim.Replace(" ", " ") - - If SerieLote.Trim = "" Then - Alert("El campo Serie es obligatorio. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - Dim SeriesArreglo = SerieLote.Trim.Split(";"c) - - '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)) - - 'PARA VALIDAR SI LA SERIE ES IGUAL AL CODIGO O CODIGOBARRAS - Dim dr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePSSerieLote).FiltroPrimero("", "PS") - - For Each Serie In SeriesArreglo - DtDuplicado = DtDatosDetalle.FiltraParametros($"ConsecId = {CveConsecSerieLote} AND Serie = '{Serie}'") - If DtDuplicado IsNot Nothing AndAlso DtDuplicado.Rows.Count > 0 Then - MensajeAlert.Append($"
El numero de Serie ""{Serie}"" proporcionado ya se encuentra ingresado.") - Continue For - End If - - DtDuplicado = DtSeriesNuevas.FiltraParametros($"Serie = '{Serie}'") - If DtDuplicado IsNot Nothing AndAlso DtDuplicado.Rows.Count > 0 Then - MensajeAlert.Append($"
El numero de Serie ""{Serie}"" proporcionado se encuentra duplicado.") - Continue For - End If - - 'PARA VALIDAR SI LA SERIE ES IGUAL AL CODIGO O CODIGOBARRAS - If Serie.ToUpper = dr("Codigo").ToString.ToUpper Or Serie.ToUpper = dr("CodigoBarras").ToString.ToUpper Then - MensajeAlert.Append($"
El numero de Serie {Serie} coincide con el codigo o codigo de barras del producto. Por favor rectifique y vuelva a intentar.") - Continue For - End If - - Dim Row = DtSeriesNuevas.NewRow - Row("Serie") = Serie - DtSeriesNuevas.Rows.Add(Row) - Next - - If MensajeAlert.ToString <> "" Then - Alert(MensajeAlert.ToString, TipoMensaje.MsgAdvertencia) - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - Exit Sub - End If - - - Dim MensajeSinExistencias As New StringBuilder - Dim ObjInventarios As New ClsInventarios - Dim Index = 0 - - For Each Serie In SeriesArreglo - Dim Row = DtDatosDetalle.NewRow - - Index = Index + 1 - If Index > LbCantidad.Text.ToEntero Then - Exit For - End If - - 'VALIDA QUE SIGA AGREGANDO - If Not DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", CveConsecSerieLote)).Rows.Count < LbCantidad.Text.ToEntero Then - Exit For - End If - - 'VERIFICA EXISTENCIAS - If TipoMovimiento > 1 Then - Dim Existencia = ObjInventarios.GetExistenciasPS(CvePSSerieLote, CveUMSerieLote, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), SerieLote:=Serie) - If Existencia < 1 Then - MensajeSinExistencias.Append($"Serie: {Serie}.
") - Continue For - End If - - If TipoMovimiento = 2 Then - If DtExistencias.SUM("Existencia", $"SerieLote = {Serie}") = 0 Then - MensajeSinExistencias.Append($"Serie: {Serie}.
") - Continue For - End If - End If - End If - - Dim AplicaCaducidad = False - If GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePSSerieLote).FiltraParametros("").Rows(0) IsNot Nothing Then - AplicaCaducidad = If(GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePSSerieLote).FiltraParametros("").Rows(0)("AplicaCaducidad").ToString = "True", True, False) - End If - - Row("ConsecId") = CveConsecSerieLote - Row("Consec") = DtDatosDetalle.Rows.Count + 1 - Row("CvePS") = CvePSSerieLote - Row("CveUM") = CveUMSerieLote - Row("PU") = PUSerieLote - Row("Serie") = Serie - Row("FechaCaducidad") = If(AplicaCaducidad, TxtFechaCaducidad.Text, MinFecha.ToShortDateString) - - DtDatosDetalle.Rows.Add(Row) - Next - ObjInventarios.Dispose() - - If Tipo = 1 Then - TxtSerieLote.Text = "" - TxtFechaCaducidad.Text = Now.ToShortDateString - End If - - CargaSerie(Tipo, True) - - If MensajeAlert.ToString <> "" Then - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - Else - If MensajeSinExistencias.ToString <> "" Then - Alert($"Las siguientes Series no cuentan con la existencia suficiente por lo cual se omitieron.
{MensajeSinExistencias.ToString}", TipoMensaje.MsgAdvertencia) - End If - RegistraScript("playsonidito('beep-07.wav')") - End If - - End Sub - - Protected Sub GvSerie_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvSerie.RowDeleting - Dim keySerieLote As String = e.Keys("Serie").ToString - Try - For Each dr As DataRow In DtDatosDetalle.Rows - If dr("Serie").ToString = keySerieLote Then - dr.Delete() - End If - Next - Catch ex As Exception - - End Try - - DtDatosDetalle.AcceptChanges() - CargaSerie(1) + CargaGVInv() End Sub -#End Region + Private Sub CargaImportacionSurtir(pCveImportacion As Integer) + Dim ObjCompras As New ClsCompras + Dim ObjInventario As New ClsInventarios + + If ObjCompras.GetImportaciones(pCveImportacion, -1, -1, "-1", "-1", UsuarioActual.CveEmpresa) Then + If ObjCompras.DtResultados.Rows.Count > 0 Then + CveImportacionSurtir = pCveImportacion + CveImportacionProveedor = ddlProveedor.SelectedValue.ToEntero + CveImportacionCompra = DdlFactura.SelectedValue.ToEntero + LbProveedor.Text = ObjCompras.DtResultados.Rows(0)("Aduanal").ToString + HLFolio.Text = ObjCompras.DtResultados.Rows(0)("PedimentoDescripcion").ToString + If UsuarioActual.TienePermisoProceso(201) Then + HLFolio.NavigateUrl = $"/Compras/Importaciones.aspx?CveImportacion={CveImportacionSurtir}" + End If + UpDatosCompra.Update() + CveMoneda = 1 + lbDescripcion.Text = "" + TipoMovimiento = 1 + + If ObjInventario.RecepcionAlmacenImportacionGet(CveImportacionSurtir, DdlFactura.SelectedValue.ToEntero, CveImportacionProveedor, UsuarioActual.CveEmpresa) AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then + DtDatosDetalle = Nothing + CreaDtDetalle() + DtDatosLoteDetalle = Nothing + CreaDtLoteDetalle() + CreaDTInv(ObjInventario.DtResultados) + BtnGuardar.Visible = True + End If + + If DtInv Is Nothing OrElse DtInv.Rows.Count = 0 Then + Alert("No hay productos pendientes de surtir de esta importación. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) + End If + + DivBitacora.Visible = True + + If UsuarioActual.Empresa.Funcionalidad(132) = "1" Then + DivCodigoSeriePS.Visible = True + Else + DivCodigoSeriePS.Visible = False + End If + + End If + Else + BtnGuardar.Visible = False + End If + + ObjCompras.Dispose() + ObjInventario.Dispose() + + CargaGVInv() -#Region " AGREGAR POR LOTE BATCH " - Private Sub CreaDtLoteDetalle() - If DtDatosLoteDetalle Is Nothing Then - DtDatosLoteDetalle = New DataTable - DtDatosLoteDetalle.Columns.Add("Consec", GetType(Integer)) - DtDatosLoteDetalle.Columns.Add("ConsecId", GetType(Integer)) - DtDatosLoteDetalle.Columns.Add("Cantidad", GetType(Double)) - DtDatosLoteDetalle.Columns.Add("CvePS", GetType(Integer)) - DtDatosLoteDetalle.Columns.Add("CveUM", GetType(Integer)) - DtDatosLoteDetalle.Columns.Add("PU", GetType(Decimal)) - DtDatosLoteDetalle.Columns.Add("Lote", GetType(String)) - DtDatosLoteDetalle.Columns.Add("Batch", GetType(String)) - DtDatosLoteDetalle.Columns.Add("FechaCaducidad", GetType(String)) - End If - End Sub - Protected Sub BtnLote_Click(sender As Object, e As EventArgs) - Dim Argumentos = CType(sender, Button).CommandArgument.Split("°"c) - - LbLoteProducto2.Text = Argumentos(3) - LbLoteCantidad2.Text = Argumentos(4).FormatoNumero - - CvePSSerieLote = Argumentos(0).ToEntero - CveUMSerieLote = Argumentos(1).ToEntero - PUSerieLote = Argumentos(2).ToDecimal - CveConsecSerieLote = Argumentos(5).ToEntero - - CargaLote(1) - End Sub - Private Sub CargaLote(Tipo As Integer, Optional CerrarCompletado As Boolean = False) - RegistraScript("$('#DivLote').modal();", "ModalLote") - GvLote.DataSource = DtDatosLoteDetalle.FiltraParametros(String.Format("ConsecId = {0}", CveConsecSerieLote), "Consec DESC") - GvLote.DataBind() - - 'VALIDA QUE SIGA AGREGANDO - If Not DtDatosLoteDetalle.SUM("Cantidad", String.Format("ConsecId = {0}", CveConsecSerieLote)) < LbLoteCantidad2.Text.ToDouble Then - BtnAddPSLote.Enabled = False - If CerrarCompletado Then - RegistraScript("$('#DivLote').modal('hide');") - End If - Else - BtnAddPSLote.Enabled = True - End If - - 'SI TIENE ENTRADA POR LOTE, BLOQUEAMOS CHECK Y TXTCANTIDAD - Dim Contador = 0.0 - For Each Gvr As GridViewRow In GvInv.Rows - If Gvr.DataKey("CvePS").ToEntero = CvePSSerieLote Then - Contador = DtDatosLoteDetalle.SUM("Cantidad", String.Format("ConsecId = {0}", Gvr.DataKey("Consec"))) - Gvr.FCCheckBox("cbInv").Enabled = False - Gvr.FCTextBox("TbCantidadF").Enabled = False - If DtDatosLoteDetalle IsNot Nothing AndAlso Contador > 0 Then - Gvr.FCCheckBox("cbInv").Checked = True - Gvr.FCTextBox("TbCantidadF").Text = Contador.ToString - ElseIf Gvr.DataKey("CantidadF").ToString.ToDecimal <> 0 Then - Gvr.FCCheckBox("cbInv").Checked = False - Gvr.FCTextBox("TbCantidadF").Text = "0" - End If - End If - - Dim Dr = DtInv.Select($"Consec = {Gvr.DataKey("Consec")}")(0) - Dr("CantidadSurtidaPantalla") = Gvr.FCTextBox("TbCantidadF").Text.ToDouble - DtInv.AcceptChanges() - Next - - RVCantidadLote.MaximumValue = (If((LbLoteCantidad2.Text.ToDouble - Contador) = 0, 0.02, LbLoteCantidad2.Text.ToDouble - Contador)).ToString.FormatoNumero - - TxtCantidadLote.Text = "1" - TxtLote.Text = "" - TxtBatch.Text = "" - TxtFechaCaducidadLote.Text = If(TxtFechaCaducidadLote.Text.Trim = "", Now.ToShortDateString(), TxtFechaCaducidadLote.Text) - TxtLote.Focus() - - UPInv.Update() - UpLote.Update() - - If Tipo = 1 Then - RegistraScript(String.Format("$('#{0}').on('shown.bs.modal', function () {{$('#{0}').focus(); $('#{0}').trigger(jQuery.Event('keypress', {{which: 13}})); }});$('#DivLote').modal('show'); ", TxtLote.ClientID)) - End If - End Sub - - Protected Sub BtnAddPSLote_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.Trim = "" 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 = DtDatosLoteDetalle.FiltraParametros($"ConsecId = {CveConsecSerieLote} 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 = DtDatosLoteDetalle.NewRow - Dim CantidadLote = TxtCantidadLote.Text.ToDouble - - Dim MensajeSinExistencias As New StringBuilder - Dim ObjInventarios As New ClsInventarios - - 'VERIFICA EXISTENCIAS - If TipoMovimiento > 1 Then - Dim Existencia = ObjInventarios.GetExistenciasPS(CvePSSerieLote, CveUMSerieLote, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), Lote:=Lote, Batch:=Batch) - If Existencia < CantidadLote Then - Alert($"
El numero de Lote ""{Lote}"" y Batch = '{Batch}' proporcionado ya se encuentra ingresado.", TipoMensaje.MsgAdvertencia) - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - End If - - If TipoMovimiento = 2 Then - If Not DtExistencias.SUM("Existencia", $"Lote = '{Lote}' Batch = '{Batch}'") = 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')") - End If - End If - End If - - Row("ConsecId") = CveConsecSerieLote - Row("Consec") = DtDatosDetalle.Rows.Count + 1 - Row("Cantidad") = CantidadLote - Row("CvePS") = CvePSSerieLote - Row("CveUM") = CveUMSerieLote - Row("PU") = PUSerieLote - Row("Lote") = Lote - Row("Batch") = Batch - Row("FechaCaducidad") = If(IsDate(TxtFechaCaducidadLote.Text), TxtFechaCaducidadLote.Text, MinFecha.ToShortDateString) - 'Row("FechaCaducidad") = If(AplicaCaducidad, TxtFechaCaducidadLote.Text, MinFecha.ToShortDateString) - - DtDatosLoteDetalle.Rows.Add(Row) - ObjInventarios.Dispose() - - If Tipo = 1 Then - TxtLote.Text = "" - TxtBatch.Text = "" - TxtFechaCaducidad.Text = Now.ToShortDateString - End If - - CargaLote(1, 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 - Dim keyBatch As String = e.Keys("Batch").ToString - Try - For Each dr As DataRow In DtDatosLoteDetalle.Rows - If dr("Lote").ToString = keyLote And dr("Batch").ToString = keyBatch Then - dr.Delete() - End If - Next - Catch ex As Exception - - End Try - - DtDatosLoteDetalle.AcceptChanges() - CargaLote(1) End Sub -#End Region + Private Sub CargaFleteSurtir(pCveImportacion As Integer) + Dim ObjInventario As New ClsInventarios -#End Region + If ObjInventario.GetFletes(UsuarioActual.CveEmpresa, CveFlete:=pCveImportacion) Then + If ObjInventario.DtResultados.Rows.Count > 0 Then + CveFleteSurtir = pCveImportacion + CveFleteOrdenCompra = ObjInventario.DtResultados.Rows(0)("CveOC").ToString.ToEntero + CveFleteCompra = ObjInventario.DtResultados.Rows(0)("CveCompra").ToString.ToEntero + LbProveedor.Text = ObjInventario.DtResultados.Rows(0)("RazonSocial").ToString + HLFolio.Text = ObjInventario.DtResultados.Rows(0)("Folio").ToString + If UsuarioActual.TienePermisoProceso(201) Then + HLFolio.NavigateUrl = $"/Inventarios/Fletes.aspx?CveFlete={CveFleteSurtir}" + End If + UpDatosCompra.Update() + CveMoneda = 1 + lbDescripcion.Text = "" + TipoMovimiento = 1 + + If ObjInventario.RecepcionAlmacenFleteGet(CveFleteSurtir, CveFleteOrdenCompra, CveFleteCompra, UsuarioActual.CveEmpresa) AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then + DtDatosDetalle = Nothing + CreaDtDetalle() + DtDatosLoteDetalle = Nothing + CreaDtLoteDetalle() + CreaDTInv(ObjInventario.DtResultados) + BtnGuardar.Visible = True + End If + + If DtInv Is Nothing OrElse DtInv.Rows.Count = 0 Then + Alert("No hay productos pendientes de surtir de esta importación. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) + End If + + DivBitacora.Visible = True + + If UsuarioActual.Empresa.Funcionalidad(132) = "1" Then + DivCodigoSeriePS.Visible = True + Else + DivCodigoSeriePS.Visible = False + End If + + End If + Else + BtnGuardar.Visible = False + End If + + ObjInventario.Dispose() + + CargaGVInv() + + End Sub +#End Region + +#Region " GVINV " + Private Sub CreaDTInv(TmDT As DataTable) + TmDT.Columns.Add("CveAlmacen", GetType(Integer)) + TmDT.Columns.Add("PUExtranjero", GetType(Double)) + TmDT.Columns.Add("CostoIndirectoExtranjero", GetType(Double)) + TmDT.Columns.Add("Consec", GetType(Integer)) + TmDT.Columns.Add("CantidadSurtidaPantalla", GetType(Double)) + If Not TmDT.Columns.Contains("CostoIndirecto") Then + TmDT.Columns.Add("CostoIndirecto", GetType(Double)) + End If + + GvInv.Columns(2).Visible = False + GvInv.Columns(3).Visible = False + GvInv.Columns(9).Visible = TmDT.SUM("CostoIndirecto") > 0 + + Dim VariableCampo = If(TipoMovimiento.Contiene(1, 3), "CantidadF", "CantidadS") + + Dim Index = 1 + For Each Dr As DataRow In TmDT.Rows + Dr("PUExtranjero") = Dr("PU") + Dr("CostoIndirectoExtranjero") = Dr("CostoIndirecto") + Dr("Consec") = Index + Index += 1 + Dr("CantidadF") = Dr(VariableCampo) + + If Dr(VariableCampo).ToString.ToDecimal <> Dr("CantidadC").ToString.ToDecimal Then + GvInv.Columns(3).Visible = True + End If + Next + + DtInv = TmDT '.FiltraParametros("CantidadF > 0") + dt = TmDT + If DtInv.SUM("CantidadS") > 0 Then + GvInv.Columns(2).Visible = True + End If + + End Sub + Private Sub CargaGVInv() + If UsuarioActual.CveEmpresa = 119 Then + DtInv = DtInv.FiltraParametros("", "PS") + End If + GvInv.DataSource = DtInv + GvInv.DataBind() + UPInv.Update() + End Sub + Protected Sub GVINV_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvInv.RowDataBound + + If e.Row.RowType = DataControlRowType.DataRow Then + + If e.Row.DBCampo("CveMetodoInventario").ToString.Contiene("5", "6") Then + + If e.Row.DBCampo("CveMetodoInventario").ToString = "5" Then + e.Row.FCButton("BtnSerieLote").Visible = True + e.Row.FCButton("BtnSerieLote").CommandArgument = String.Format("{0}°{1}°{2}°{3}°{4}°{5}", e.Row.DBCampo("CvePS"), e.Row.DBCampo("CveUM"), e.Row.DBCampo("PU"), e.Row.DBCampo("PS"), e.Row.DBCampo("CantidadF"), e.Row.DBCampo("Consec")) + + e.Row.FCTextBox("TbCantidadF").Enabled = False + e.Row.FCCheckBox("cbInv").Enabled = False + Dim Contador = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", e.Row.DataKey("Consec"))).Rows.Count + e.Row.FCTextBox("TbCantidadF").Text = Contador.ToString + ElseIf e.Row.DBCampo("CveMetodoInventario").ToString = "6" Then + e.Row.FCButton("BtnLote").Visible = True + e.Row.FCButton("BtnLote").CommandArgument = String.Format("{0}°{1}°{2}°{3}°{4}°{5}", e.Row.DBCampo("CvePS"), e.Row.DBCampo("CveUM"), e.Row.DBCampo("PU"), e.Row.DBCampo("PS"), e.Row.DBCampo("CantidadF"), e.Row.DBCampo("Consec")) + + e.Row.FCTextBox("TbCantidadF").Enabled = False + e.Row.FCCheckBox("cbInv").Enabled = False + Dim Contador = DtDatosLoteDetalle.FiltraParametros(String.Format("ConsecId = {0}", e.Row.DataKey("Consec"))).Rows.Count + e.Row.FCTextBox("TbCantidadF").Text = Contador.ToString + End If + + Else + e.Row.FCButton("BtnSerieLote").Visible = False + e.Row.FCButton("BtnLote").Visible = False + + e.Row.FCTextBox("TbCantidadF").Enabled = True + e.Row.FCTextBox("TbCantidadF").Attributes.Add("onblur", String.Format("ValidarCantidad(this,{0})", e.Row.DBCampo("CantidadF"))) + e.Row.FCCheckBox("cbInv").Attributes.Add("onclick", String.Format("Check(this, {0}, {1});", e.Row.FCTextBox("TbCantidadF").ClientID, e.Row.DBCampo("CantidadF"))) + + If e.Row.DBCampo("EntregaDirecta").ToString = "1" And TipoMovimiento = 1 Then + e.Row.FCCheckBox("cbInv").Checked = True + e.Row.FCCheckBox("cbInv").Enabled = False + e.Row.FCTextBox("TbCantidadF").Text = e.Row.DBCampo("CantidadF").FormatoNumero + e.Row.FCTextBox("TbCantidadF").Enabled = False + End If + End If + + + 'FUNCIONALIDAD PISTOLA DE CODIGOS + If UsuarioActual.Empresa.Funcionalidad(132) = "1" And e.Row.DBCampo("CodigoBarras").Trim <> "" And Not UsuarioActual.TienePermisoProceso(174) Then + e.Row.FCTextBox("TbCantidadF").Enabled = False + End If + + If e.Row.DBCampo("CantidadF").ToDecimal = 0 Then + e.Row.FCTextBox("TbCantidadF").Visible = False + e.Row.Cells(3).Text = "0" + e.Row.FCCheckBox("cbInv").Visible = False + End If + + 'TotalGV += e.Row.DBCampo("PU").ToString.ToDecimal * e.Row.DBCampo("CantidadF").ToString.ToDecimal + + If UsuarioActual.Empresa.Funcionalidad(147) = "1" Then + e.Row.FCDropDownList("DdlSeccionAlmacen").DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa) + e.Row.FCDropDownList("DdlSeccionAlmacen").DataBind() + e.Row.FCDropDownList("DdlSeccionAlmacen").Items.Insert(0, New ListItem("Seleccione", "-1")) + End If + + e.Row.FCLabel("LbTotal").Text = ((e.Row.DBCampo("PU").ToDecimal + e.Row.DBCampo("CostoIndirecto").ToDecimal) * e.Row.DBCampo("CantidadF").ToDecimal).FormatoNumero + + TotalGV += (e.Row.DBCampo("PU").ToDecimal + e.Row.DBCampo("CostoIndirecto").ToDecimal) * e.Row.DBCampo("CantidadF").ToDecimal + + End If + + If e.Row.RowType = DataControlRowType.Footer Then + Dim TienePermisoImportes As Boolean = UsuarioActual.TienePermisoProceso(201) + + e.Row.FCLabel("LbTotal").Visible = TienePermisoImportes + + If TienePermisoImportes Then + e.Row.FCLabel("LbTotal").Text = TotalGV.FormatoNumero + TotalGV = 0.0D + e.Row.Font.Bold = True + e.Row.Cells(6).Text = "Total" + e.Row.Cells(6).HorizontalAlign = HorizontalAlign.Right + End If + + End If + + End Sub +#End Region + +#Region " AGREGAR " + +#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 + + For Each Gvr As GridViewRow In GvInv.Rows + If Gvr.DataKey("CodigoBarras") = TxtCodigoPS.Text.Trim Then + Dim TxtCantidad = GvInv.Rows(Gvr.RowIndex).FCTextBox("TbCantidadF") + If Gvr.DataKey("CantidadF").ToDecimal - TxtCantidad.Text.ToDecimal - 1 >= 0 Then + + If Gvr.DataKey("AplicaSerieLote") = "True" Then + TdSeriePS.Visible = True + TxtSeriePS.Focus() + + CveConsecSerieLote = Gvr.DataKey("Consec").ToEntero + CvePSSerieLote = Gvr.DataKey("CvePS").ToEntero + CveUMSerieLote = 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 + + 'VERIFICA EXISTENCIAS + Dim MensajeSinExistencias As New StringBuilder + If TipoMovimiento > 1 Then + Dim ExistenciaActual = DtInv.SUM("CantidadSurtidaPantalla", $"CvePS = {Gvr.DataKey("CvePS").ToEntero} AND CveUM = {Gvr.DataKey("CveUM").ToEntero} ") + 1 + Dim ObjInventarios As New ClsInventarios + Dim Existencia = ObjInventarios.GetExistenciasPS(Gvr.DataKey("CvePS").ToEntero, Gvr.DataKey("CveUM").ToEntero, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm")) + ObjInventarios.Dispose() + + If Existencia < ExistenciaActual Then + Alert($"El producto con el codigo de barras {TxtCodigoPS.Text} no tiene la existencia suficiente.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + 'EXISTENCIAS DE LA COMPRAR - PARA DEVOLUCION + If TipoMovimiento = 2 Then + If DtExistencias.SUM("Existencia", $"CvePS = {Gvr.DataKey("CvePS").ToEntero} AND CveUM = {Gvr.DataKey("CveUM").ToEntero}") < ExistenciaActual Then + Alert($"El producto con el codigo de barras {TxtCodigoPS.Text} no tiene la existencia suficiente de recepción.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + End If + End If + + TxtCantidad.Text = (TxtCantidad.Text.ToDecimal + 1).ToString.FormatoNumero + TxtCodigoPS.Text = "" + RegistraScript("playsonidito('beep-07.wav')") + UPInv.Update() + Dim Dr = DtInv.Select($"Consec = {Gvr.DataKey("Consec")}")(0) + Dr("CantidadSurtidaPantalla") = TxtCantidad.Text.ToDouble + DtInv.AcceptChanges() + Exit Sub + End If + + End If + + Alert($"Ya se ha cargado la totalidad del Producto ""{Gvr.DataKey("PS").ToString}"" con el Codigo ""{TxtCodigoPS.Text}"".", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus,200);") + RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") + End If + Next + + + Alert($"No se ha encontrado un producto para surtir con el Codigo ""{TxtCodigoPS.Text}"". ", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus,200);") + RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") + TxtCodigoPS.Text = "" + + End Sub + Protected Sub BtnSeriePS_Click(sender As Object, e As EventArgs) + AgregaSerieLote(TxtSeriePS.Text.Trim, 2) + TdSeriePS.Visible = False + TxtSeriePS.Text = "" + TxtCodigoPS.Text = "" + TxtCodigoPS.Focus() + End Sub + Protected Sub BtnGuardarCantidadEspecial_Click(sender As Object, e As EventArgs) + AgregaCantidadEspecial() + End Sub + Private Sub AgregaCantidadEspecial() + Dim TxtCantidad = GvInv.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);") + UPInv.Update() + TxtCodigoPS.Focus() + RegistraScript("playsonidito('beep-07.wav')") + 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 + +#Region " AGREGA POR SERIE/LOTE " + Protected Sub BtnSerieLote_Click(sender As Object, e As EventArgs) + + Dim Argumentos = CType(sender, Button).CommandArgument.Split("°"c) + + LbProducto.Text = Argumentos(3) + LbCantidad.Text = Argumentos(4).FormatoNumero + TxtFechaCaducidad.Text = Now.ToShortDateString() + + CvePSSerieLote = Argumentos(0).ToEntero + CveUMSerieLote = Argumentos(1).ToEntero + PUSerieLote = Argumentos(2).ToDecimal + CveConsecSerieLote = Argumentos(5).ToEntero + + CargaSerie(1) + + End Sub + Private Sub CreaDtDetalle() + If DtDatosDetalle Is Nothing Then + DtDatosDetalle = New DataTable + DtDatosDetalle.Columns.Add("Consec", GetType(Integer)) + DtDatosDetalle.Columns.Add("ConsecId", GetType(Integer)) + DtDatosDetalle.Columns.Add("CvePS", GetType(Integer)) + DtDatosDetalle.Columns.Add("CveUM", GetType(Integer)) + DtDatosDetalle.Columns.Add("PU", GetType(Decimal)) + DtDatosDetalle.Columns.Add("Serie", GetType(String)) + DtDatosDetalle.Columns.Add("FechaCaducidad", GetType(String)) + End If + End Sub + + Private Sub CargaSerie(Tipo As Integer, Optional CerrarCompletado As Boolean = False) + 'RegistraScript("document.getElementById(""TxtSerieLote"").focus();") + RegistraScript("$('#DivSerie').modal();", "ModalLote") + + Dim AplicaCaducidad = False + If GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePSSerieLote).FiltraParametros("").Rows(0) IsNot Nothing Then + AplicaCaducidad = If(GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePSSerieLote).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}", CveConsecSerieLote), "Consec DESC") + GvSerie.DataBind() + + 'VALIDA QUE SIGA AGREGANDO + If Not DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", CveConsecSerieLote)).Rows.Count < LbCantidad.Text.ToEntero Then + BtnAgregarPS.Enabled = False + If CerrarCompletado Then + RegistraScript("$('#DivSerie').modal('hide');") + End If + Else + BtnAgregarPS.Enabled = True + End If + + 'SI TIENE ENTRADA POR SERIE LOTE, BLOQUEAMOS CHECK Y TXTCANTIDAD + Dim Contador = 0 + For Each Gvr As GridViewRow In GvInv.Rows + If Gvr.DataKey("CvePS").ToEntero = CvePSSerieLote Then + Contador = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Gvr.DataKey("Consec"))).Rows.Count + Gvr.FCCheckBox("cbInv").Enabled = False + Gvr.FCTextBox("TbCantidadF").Enabled = False + If DtDatosDetalle IsNot Nothing AndAlso Contador > 0 Then + Gvr.FCCheckBox("cbInv").Checked = True + Gvr.FCTextBox("TbCantidadF").Text = Contador.ToString + ElseIf Gvr.DataKey("CantidadF").ToString.ToDecimal <> 0 Then + Gvr.FCCheckBox("cbInv").Checked = False + Gvr.FCTextBox("TbCantidadF").Text = "0" + End If + End If + + Dim Dr = DtInv.Select($"Consec = {Gvr.DataKey("Consec")}")(0) + Dr("CantidadSurtidaPantalla") = Gvr.FCTextBox("TbCantidadF").Text.ToDouble + DtInv.AcceptChanges() + Next + + + UPInv.Update() + UpSerie.Update() + TxtSerieLote.Text = "" + TxtSerieLote.Focus() + + If Tipo = 1 Then + RegistraScript(String.Format("$('#{0}').on('shown.bs.modal', function () {{$('#{0}').focus(); $('#{0}').trigger(jQuery.Event('keypress', {{which: 13}})); }});$('#DivSerie').modal('show'); ", TxtSerieLote.ClientID)) + End If + + End Sub + Protected Sub BtnAgregarPS_Click(sender As Object, e As EventArgs) + AgregaSerieLote(TxtSerieLote.Text.Replace(" ", String.Empty), 1) + End Sub + Private Sub AgregaSerieLote(SerieLote As String, Tipo As Integer) + 'SerieLote = SerieLote.Trim.Replace(" ", " ") + + If SerieLote.Trim = "" Then + Alert("El campo Serie es obligatorio. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + Dim SeriesArreglo = SerieLote.Trim.Split(";"c) + + '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)) + + 'PARA VALIDAR SI LA SERIE ES IGUAL AL CODIGO O CODIGOBARRAS + Dim dr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePSSerieLote).FiltroPrimero("", "PS") + + For Each Serie In SeriesArreglo + DtDuplicado = DtDatosDetalle.FiltraParametros($"ConsecId = {CveConsecSerieLote} AND Serie = '{Serie}'") + If DtDuplicado IsNot Nothing AndAlso DtDuplicado.Rows.Count > 0 Then + MensajeAlert.Append($"
El numero de Serie ""{Serie}"" proporcionado ya se encuentra ingresado.") + Continue For + End If + + DtDuplicado = DtSeriesNuevas.FiltraParametros($"Serie = '{Serie}'") + If DtDuplicado IsNot Nothing AndAlso DtDuplicado.Rows.Count > 0 Then + MensajeAlert.Append($"
El numero de Serie ""{Serie}"" proporcionado se encuentra duplicado.") + Continue For + End If + + 'PARA VALIDAR SI LA SERIE ES IGUAL AL CODIGO O CODIGOBARRAS + If Serie.ToUpper = dr("Codigo").ToString.ToUpper Or Serie.ToUpper = dr("CodigoBarras").ToString.ToUpper Then + MensajeAlert.Append($"
El numero de Serie {Serie} coincide con el codigo o codigo de barras del producto. Por favor rectifique y vuelva a intentar.") + Continue For + End If + + Dim Row = DtSeriesNuevas.NewRow + Row("Serie") = Serie + DtSeriesNuevas.Rows.Add(Row) + Next + + If MensajeAlert.ToString <> "" Then + Alert(MensajeAlert.ToString, TipoMensaje.MsgAdvertencia) + RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") + Exit Sub + End If + + + Dim MensajeSinExistencias As New StringBuilder + Dim ObjInventarios As New ClsInventarios + Dim Index = 0 + + For Each Serie In SeriesArreglo + Dim Row = DtDatosDetalle.NewRow + + Index = Index + 1 + If Index > LbCantidad.Text.ToEntero Then + Exit For + End If + + 'VALIDA QUE SIGA AGREGANDO + If Not DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", CveConsecSerieLote)).Rows.Count < LbCantidad.Text.ToEntero Then + Exit For + End If + + 'VERIFICA EXISTENCIAS + If TipoMovimiento > 1 Then + Dim Existencia = ObjInventarios.GetExistenciasPS(CvePSSerieLote, CveUMSerieLote, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), SerieLote:=Serie) + If Existencia < 1 Then + MensajeSinExistencias.Append($"Serie: {Serie}.
") + Continue For + End If + + If TipoMovimiento = 2 Then + If DtExistencias.SUM("Existencia", $"SerieLote = {Serie}") = 0 Then + MensajeSinExistencias.Append($"Serie: {Serie}.
") + Continue For + End If + End If + End If + + Dim AplicaCaducidad = False + If GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePSSerieLote).FiltraParametros("").Rows(0) IsNot Nothing Then + AplicaCaducidad = If(GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePSSerieLote).FiltraParametros("").Rows(0)("AplicaCaducidad").ToString = "True", True, False) + End If + + Row("ConsecId") = CveConsecSerieLote + Row("Consec") = DtDatosDetalle.Rows.Count + 1 + Row("CvePS") = CvePSSerieLote + Row("CveUM") = CveUMSerieLote + Row("PU") = PUSerieLote + Row("Serie") = Serie + Row("FechaCaducidad") = If(AplicaCaducidad, TxtFechaCaducidad.Text, MinFecha.ToShortDateString) + + DtDatosDetalle.Rows.Add(Row) + Next + ObjInventarios.Dispose() + + If Tipo = 1 Then + TxtSerieLote.Text = "" + TxtFechaCaducidad.Text = Now.ToShortDateString + End If + + CargaSerie(Tipo, True) + + If MensajeAlert.ToString <> "" Then + RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") + Else + If MensajeSinExistencias.ToString <> "" Then + Alert($"Las siguientes Series no cuentan con la existencia suficiente por lo cual se omitieron.
{MensajeSinExistencias.ToString}", TipoMensaje.MsgAdvertencia) + End If + RegistraScript("playsonidito('beep-07.wav')") + End If + + End Sub + + Protected Sub GvSerie_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvSerie.RowDeleting + Dim keySerieLote As String = e.Keys("Serie").ToString + Try + For Each dr As DataRow In DtDatosDetalle.Rows + If dr("Serie").ToString = keySerieLote Then + dr.Delete() + End If + Next + Catch ex As Exception + + End Try + + DtDatosDetalle.AcceptChanges() + CargaSerie(1) + End Sub + +#End Region + +#Region " AGREGAR POR LOTE BATCH " + Private Sub CreaDtLoteDetalle() + If DtDatosLoteDetalle Is Nothing Then + DtDatosLoteDetalle = New DataTable + DtDatosLoteDetalle.Columns.Add("Consec", GetType(Integer)) + DtDatosLoteDetalle.Columns.Add("ConsecId", GetType(Integer)) + DtDatosLoteDetalle.Columns.Add("Cantidad", GetType(Double)) + DtDatosLoteDetalle.Columns.Add("CvePS", GetType(Integer)) + DtDatosLoteDetalle.Columns.Add("CveUM", GetType(Integer)) + DtDatosLoteDetalle.Columns.Add("PU", GetType(Decimal)) + DtDatosLoteDetalle.Columns.Add("Lote", GetType(String)) + DtDatosLoteDetalle.Columns.Add("Batch", GetType(String)) + DtDatosLoteDetalle.Columns.Add("FechaCaducidad", GetType(String)) + End If + End Sub + Protected Sub BtnLote_Click(sender As Object, e As EventArgs) + Dim Argumentos = CType(sender, Button).CommandArgument.Split("°"c) + + LbLoteProducto2.Text = Argumentos(3) + LbLoteCantidad2.Text = Argumentos(4).FormatoNumero + + CvePSSerieLote = Argumentos(0).ToEntero + CveUMSerieLote = Argumentos(1).ToEntero + PUSerieLote = Argumentos(2).ToDecimal + CveConsecSerieLote = Argumentos(5).ToEntero + + CargaLote(1) + End Sub + Private Sub CargaLote(Tipo As Integer, Optional CerrarCompletado As Boolean = False) + RegistraScript("$('#DivLote').modal();", "ModalLote") + GvLote.DataSource = DtDatosLoteDetalle.FiltraParametros(String.Format("ConsecId = {0}", CveConsecSerieLote), "Consec DESC") + GvLote.DataBind() + + 'VALIDA QUE SIGA AGREGANDO + If Not DtDatosLoteDetalle.SUM("Cantidad", String.Format("ConsecId = {0}", CveConsecSerieLote)) < LbLoteCantidad2.Text.ToDouble Then + BtnAddPSLote.Enabled = False + If CerrarCompletado Then + RegistraScript("$('#DivLote').modal('hide');") + End If + Else + BtnAddPSLote.Enabled = True + End If + + 'SI TIENE ENTRADA POR LOTE, BLOQUEAMOS CHECK Y TXTCANTIDAD + Dim Contador = 0.0 + For Each Gvr As GridViewRow In GvInv.Rows + If Gvr.DataKey("CvePS").ToEntero = CvePSSerieLote Then + Contador = DtDatosLoteDetalle.SUM("Cantidad", String.Format("ConsecId = {0}", Gvr.DataKey("Consec"))) + Gvr.FCCheckBox("cbInv").Enabled = False + Gvr.FCTextBox("TbCantidadF").Enabled = False + If DtDatosLoteDetalle IsNot Nothing AndAlso Contador > 0 Then + Gvr.FCCheckBox("cbInv").Checked = True + Gvr.FCTextBox("TbCantidadF").Text = Contador.ToString + ElseIf Gvr.DataKey("CantidadF").ToString.ToDecimal <> 0 Then + Gvr.FCCheckBox("cbInv").Checked = False + Gvr.FCTextBox("TbCantidadF").Text = "0" + End If + End If + + Dim Dr = DtInv.Select($"Consec = {Gvr.DataKey("Consec")}")(0) + Dr("CantidadSurtidaPantalla") = Gvr.FCTextBox("TbCantidadF").Text.ToDouble + DtInv.AcceptChanges() + Next + + RVCantidadLote.MaximumValue = (If((LbLoteCantidad2.Text.ToDouble - Contador) = 0, 0.02, LbLoteCantidad2.Text.ToDouble - Contador)).ToString.FormatoNumero + + TxtCantidadLote.Text = "1" + TxtLote.Text = "" + TxtBatch.Text = "" + TxtFechaCaducidadLote.Text = If(TxtFechaCaducidadLote.Text.Trim = "", Now.ToShortDateString(), TxtFechaCaducidadLote.Text) + TxtLote.Focus() + + UPInv.Update() + UpLote.Update() + + If Tipo = 1 Then + RegistraScript(String.Format("$('#{0}').on('shown.bs.modal', function () {{$('#{0}').focus(); $('#{0}').trigger(jQuery.Event('keypress', {{which: 13}})); }});$('#DivLote').modal('show'); ", TxtLote.ClientID)) + End If + End Sub + + Protected Sub BtnAddPSLote_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.Trim = "" 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 = DtDatosLoteDetalle.FiltraParametros($"ConsecId = {CveConsecSerieLote} 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 = DtDatosLoteDetalle.NewRow + Dim CantidadLote = TxtCantidadLote.Text.ToDouble + + Dim MensajeSinExistencias As New StringBuilder + Dim ObjInventarios As New ClsInventarios + + 'VERIFICA EXISTENCIAS + If TipoMovimiento > 1 Then + Dim Existencia = ObjInventarios.GetExistenciasPS(CvePSSerieLote, CveUMSerieLote, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), Lote:=Lote, Batch:=Batch) + If Existencia < CantidadLote Then + Alert($"
El numero de Lote ""{Lote}"" y Batch = '{Batch}' proporcionado ya se encuentra ingresado.", TipoMensaje.MsgAdvertencia) + RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") + End If + + If TipoMovimiento = 2 Then + If Not DtExistencias.SUM("Existencia", $"Lote = '{Lote}' Batch = '{Batch}'") = 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')") + End If + End If + End If + + Row("ConsecId") = CveConsecSerieLote + Row("Consec") = DtDatosDetalle.Rows.Count + 1 + Row("Cantidad") = CantidadLote + Row("CvePS") = CvePSSerieLote + Row("CveUM") = CveUMSerieLote + Row("PU") = PUSerieLote + Row("Lote") = Lote + Row("Batch") = Batch + Row("FechaCaducidad") = If(IsDate(TxtFechaCaducidadLote.Text), TxtFechaCaducidadLote.Text, MinFecha.ToShortDateString) + 'Row("FechaCaducidad") = If(AplicaCaducidad, TxtFechaCaducidadLote.Text, MinFecha.ToShortDateString) + + DtDatosLoteDetalle.Rows.Add(Row) + ObjInventarios.Dispose() + + If Tipo = 1 Then + TxtLote.Text = "" + TxtBatch.Text = "" + TxtFechaCaducidad.Text = Now.ToShortDateString + End If + + CargaLote(1, 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 + Dim keyBatch As String = e.Keys("Batch").ToString + Try + For Each dr As DataRow In DtDatosLoteDetalle.Rows + If dr("Lote").ToString = keyLote And dr("Batch").ToString = keyBatch Then + dr.Delete() + End If + Next + Catch ex As Exception + + End Try + + DtDatosLoteDetalle.AcceptChanges() + CargaLote(1) + End Sub +#End Region + +#End Region + +#Region " GUARDAR " + Private Function ValidaGuardar() As Boolean + + Dim TotalCantidad As Double = GvInv.Rows.Cast(Of GridViewRow)().Sum(Function(gvr) gvr.FCTextBox("TbCantidadF").Text.ToDouble) + If TotalCantidad <= 0 Then + Alert("No se seleccionó ninguna cantidad de productos a guardar. Por favor verifique e intente nuevamente.", TipoMensaje.MsgAdvertencia) + RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") + Return False + End If + 'verifica si recibió al 100% la compra + 'bandera que me indica que se cargaron todos los productos, yque se verifique si los detalle s se van a recibir al 100 + ' que la cantidad orginal sea igual a la recibida. para considedrarse completa + If RecibidaCompleta Then + For Each Gvr As GridViewRow In GvInv.Rows + If Not Gvr.FCCheckBox("cbInv").Checked Or Gvr.FCTextBox("TbCantidadF").Text.ToDecimal <> Gvr.DataKey("CantidadF").ToString.ToDecimal OrElse Gvr.DataKey("CantidadC").ToString.ToDecimal <> Gvr.DataKey("CantidadF").ToString.ToDecimal Then + RecibidaCompleta = False + End If + Next + End If + + + If EntregaDirecta Then + For Each Gvr As GridViewRow In GvInv.Rows + If Not Gvr.FCCheckBox("cbInv").Checked Or Gvr.FCTextBox("TbCantidadF").Text.ToDecimal <> Gvr.DataKey("CantidadF").ToString.ToDecimal Then + Alert("La compra se debe surtir completa por ser entrega directa. Por favor verifique e intente nuevamente.", TipoMensaje.MsgAdvertencia) + RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") + Return False + End If + Next + End If + + + Dim TotalPorDevengar As Double = 0.0 + If UsuarioActual.Empresa.UsaAC Then + TotalPorDevengar += GvAC.Rows.Cast(Of GridViewRow)().Sum(Function(Gvr) Gvr.FCTextBox("TxtImporte").Text.ToDouble) + If TotalPorDevengar <= 0 Then + Alert("Especifique el importe del presupuesto", TipoMensaje.MsgAdvertencia) + RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") + Return False + End If + End If + + If DdlMonedaTC.SelectedValue = "2" Then + AplicarTipoCambio() + If TipoCambio <= 0 Then + Alert("Ocurrió un error al obtener el tipo de cambio. Por favor verifique e intente de nuevo.", TipoMensaje.MsgAdvertencia) + RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") + Return False + End If + End If + + + 'VALIDA SI HUBO CAMBIOS EN LOS DETALLES COMPRA + If CveCompraSurtir > 0 Then + Dim VariableCampo = If(TipoMovimiento.Contiene(1, 3), "CantidadF", "CantidadS") + Dim ObjComprasDif As New ClsInventarios + Dim DtDatosCompra As New DataTable + If ObjComprasDif.RecepcionAlmacenGet(CveCompraSurtir, BuscaEntregaDirecta, UsuarioActual.CveEmpresa) Then + DtDatosCompra = ObjComprasDif.DtResultados + End If + Dim CantidadGV = GvInv.Rows.Cast(Of GridViewRow)().Sum(Function(gvr) gvr.DataKey("CantidadF").ToDouble) + Dim CantConsulta = DtDatosCompra.SUM(VariableCampo) + If Math.Abs(CantidadGV - CantConsulta) > 0.01 Then + CargaCompra(CveCompraSurtir, -1) + CargaPendientes() + Alert("Ha sido cambiada la información de existencias de la compra actual, se han recargado la información.", TipoMensaje.MsgAdvertencia) + ObjComprasDif.Dispose() + Return False + End If + ObjComprasDif.Dispose() + End If + + 'VALIDA SI HUBO CAMBIOS EN LOS DETALLES OC + If CveOCSurtir > 0 Then + Dim VariableCampo = If(TipoMovimiento = 1, "CantidadF", "CantidadS") + Dim ObjComprasDif As New ClsInventarios + Dim DtDatosOC As New DataTable + If ObjComprasDif.RecepcionAlmacenOCGet(CveOCSurtir, UsuarioActual.CveEmpresa) Then + DtDatosOC = ObjComprasDif.DtResultados.FiltraParametros("CantidadCompra = 0") + End If + Dim CantidadGV = GvInv.Rows.Cast(Of GridViewRow)().Sum(Function(gvr) gvr.DataKey("CantidadF").ToDouble) + Dim CantConsulta = DtDatosOC.SUM(VariableCampo) + If Math.Abs(CantidadGV - CantConsulta) > 0.1 Then + CargaOCPorSurtir(CveOCSurtir) + Alert("Ha sido cambiada la información de existencias de la orden de compra actual, se han recargado la información.", TipoMensaje.MsgAdvertencia) + ObjComprasDif.Dispose() + Return False + End If + ObjComprasDif.Dispose() + End If + + 'VALIDA SI HUBO CAMBIOS EN LOS DETALLES IMPORTACION + If CveImportacionSurtir > 0 Then + Dim VariableCampo = If(TipoMovimiento = 1, "CantidadF", "CantidadS") + Dim ObjComprasDif As New ClsInventarios + Dim DtDatosImportacion As New DataTable + If ObjComprasDif.RecepcionAlmacenImportacionGet(CveImportacionSurtir, CveImportacionCompra, CveImportacionProveedor, UsuarioActual.CveEmpresa) Then + DtDatosImportacion = ObjComprasDif.DtResultados + End If + Dim CantidadGV = GvInv.Rows.Cast(Of GridViewRow)().Sum(Function(gvr) gvr.DataKey("CantidadF").ToDouble) + Dim CantConsulta = DtDatosImportacion.SUM(VariableCampo) + If CantidadGV <> CantConsulta Then + CargaImportacionSurtir(CveImportacionSurtir) + Alert("Ha sido cambiada la información de existencias de la importación actual, se han recargado la información.", TipoMensaje.MsgAdvertencia) + ObjComprasDif.Dispose() + Return False + End If + ObjComprasDif.Dispose() + End If + + 'VALIDA SI HUBO CAMBIOS EN LOS DETALLES FLETES + If CveFleteSurtir > 0 Then + Dim VariableCampo = If(TipoMovimiento = 1, "CantidadF", "CantidadS") + Dim ObjComprasDif As New ClsInventarios + Dim DtDatosImportacion As New DataTable + If ObjComprasDif.RecepcionAlmacenFleteGet(CveFleteSurtir, CveFleteOrdenCompra, CveFleteCompra, UsuarioActual.CveEmpresa) Then + DtDatosImportacion = ObjComprasDif.DtResultados + End If + Dim CantidadGV = GvInv.Rows.Cast(Of GridViewRow)().Sum(Function(gvr) gvr.DataKey("CantidadF").ToDouble) + Dim CantConsulta = DtDatosImportacion.SUM(VariableCampo) + If CantidadGV <> CantConsulta Then + CargaFleteSurtir(CveFleteSurtir) + Alert("Ha sido cambiada la informacion de existencias costo indirecto actual, se han recargado la información.", TipoMensaje.MsgAdvertencia) + ObjComprasDif.Dispose() + Return False + End If + ObjComprasDif.Dispose() + End If + + 'PASA DATOS DEL GV A DATATABLE PARA MANEJOR CON FOR EACH + Dim Index = 0 + For Each gvr As GridViewRow In GvInv.Rows + If gvr.FCCheckBox("cbInv").Checked AndAlso gvr.FCTextBox("TbCantidadF").Text.ToDecimal > 0 Then + DtInv.Rows(Index)("CantidadSurtidaPantalla") = gvr.FCTextBox("TbCantidadF").Text.ToDouble + End If + Index += 1 + Next + + 'VERIFICA EXISTENCIAS + If TipoMovimiento > 1 Then + Dim MensajeExistencias As New StringBuilder + Dim ObjInventarios As New ClsInventarios + For Each gvr As GridViewRow In GvInv.Rows + Dim ExistenciaActual = DtInv.SUM("CantidadSurtidaPantalla", $"CvePS = {gvr.DataKey("CvePS").ToEntero} AND CveUM = {gvr.DataKey("CveUM").ToEntero} ") + + If TipoMovimiento = 2 Then + 'If gvr.DataKey("CantidadC").ToString.ToDecimal <> ExistenciaActual Then + ' Alert("La devolución debe de ser completa.", TipoMensaje.MsgAdvertencia) + ' Exit Sub + 'End If + + If DtExistencias.SUM("Existencia", $"CvePS = {gvr.DataKey("CvePS").ToEntero} AND CveUM = {gvr.DataKey("CveUM").ToEntero}") < ExistenciaActual Then + MensajeExistencias.Append($"Producto: {GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=gvr.DataKey("CvePS").ToString.ToEntero).FiltroPrimeroValor("PSCodigo")}.
") + Continue For + End If + End If + + Dim Existencia = ObjInventarios.GetExistenciasPS(gvr.DataKey("CvePS").ToEntero, gvr.DataKey("CveUM").ToEntero, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm")) + If Existencia < ExistenciaActual Then + MensajeExistencias.Append($"Producto: {GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=gvr.DataKey("CvePS").ToString.ToEntero).FiltroPrimeroValor("PSCodigo")}.
") + Continue For + End If + Next + ObjInventarios.Dispose() + + If MensajeExistencias.ToString <> "" Then + Alert($"Los siguientes productos no cuentan con la existencia suficiente para hacer la devolución.

{MensajeExistencias.ToString}", TipoMensaje.MsgAdvertencia) + Return False + End If + + End If + + If UsuarioActual.Empresa.Funcionalidad(563) = "1" Then + If TotalCantidad <> DtSeccionAlmacen.SUMD("CantidadSeccionAlmacen") Then + Alert("La seccion de almacen no ha sido agregada completamente.", TipoMensaje.MsgAdvertencia) + Return False + End If + End If + + Return True + End Function + Protected Sub BtnGuardar_Click(sender As Object, e As EventArgs) Handles BtnGuardar.Click + + 'VALIDACIONES + If Not ValidaGuardar() Then + Exit Sub + End If + + If CveCompraSurtir > 0 Or CveOCSurtir > 0 Then + GuardaCompraOC() + ElseIf CveImportacionSurtir > 0 Then + GuardaImportacionFlete() + ElseIf CveFleteSurtir > 0 Then + GuardaImportacionFlete() + Else + Alert("Ocurrio un error al procesar la informacion para guardar el movimiento. Por favor comuniquese con atencion SIG.", TipoMensaje.MsgError) + End If + + End Sub -#Region " GUARDAR " - Private Function ValidaGuardar() As Boolean - - Dim TotalCantidad As Double = GvInv.Rows.Cast(Of GridViewRow)().Sum(Function(gvr) gvr.FCTextBox("TbCantidadF").Text.ToDouble) - If TotalCantidad <= 0 Then - Alert("No se seleccionó ninguna cantidad de productos a guardar. Por favor verifique e intente nuevamente.", TipoMensaje.MsgAdvertencia) - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - Return False - End If - 'verifica si recibió al 100% la compra - 'bandera que me indica que se cargaron todos los productos, yque se verifique si los detalle s se van a recibir al 100 - ' que la cantidad orginal sea igual a la recibida. para considedrarse completa - If RecibidaCompleta Then - For Each Gvr As GridViewRow In GvInv.Rows - If Not Gvr.FCCheckBox("cbInv").Checked Or Gvr.FCTextBox("TbCantidadF").Text.ToDecimal <> Gvr.DataKey("CantidadF").ToString.ToDecimal OrElse Gvr.DataKey("CantidadC").ToString.ToDecimal <> Gvr.DataKey("CantidadF").ToString.ToDecimal Then - RecibidaCompleta = False - End If - Next - End If - - - If EntregaDirecta Then - For Each Gvr As GridViewRow In GvInv.Rows - If Not Gvr.FCCheckBox("cbInv").Checked Or Gvr.FCTextBox("TbCantidadF").Text.ToDecimal <> Gvr.DataKey("CantidadF").ToString.ToDecimal Then - Alert("La compra se debe surtir completa por ser entrega directa. Por favor verifique e intente nuevamente.", TipoMensaje.MsgAdvertencia) - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - Return False - End If - Next - End If - - - Dim TotalPorDevengar As Double = 0.0 - If UsuarioActual.Empresa.UsaAC Then - TotalPorDevengar += GvAC.Rows.Cast(Of GridViewRow)().Sum(Function(Gvr) Gvr.FCTextBox("TxtImporte").Text.ToDouble) - If TotalPorDevengar <= 0 Then - Alert("Especifique el importe del presupuesto", TipoMensaje.MsgAdvertencia) - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - Return False - End If - End If - - If DdlMonedaTC.SelectedValue = "2" Then - AplicarTipoCambio() - If TipoCambio <= 0 Then - Alert("Ocurrió un error al obtener el tipo de cambio. Por favor verifique e intente de nuevo.", TipoMensaje.MsgAdvertencia) - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - Return False - End If - End If - - - 'VALIDA SI HUBO CAMBIOS EN LOS DETALLES COMPRA - If CveCompraSurtir > 0 Then - Dim VariableCampo = If(TipoMovimiento.Contiene(1, 3), "CantidadF", "CantidadS") - Dim ObjComprasDif As New ClsInventarios - Dim DtDatosCompra As New DataTable - If ObjComprasDif.RecepcionAlmacenGet(CveCompraSurtir, BuscaEntregaDirecta, UsuarioActual.CveEmpresa) Then - DtDatosCompra = ObjComprasDif.DtResultados - End If - Dim CantidadGV = GvInv.Rows.Cast(Of GridViewRow)().Sum(Function(gvr) gvr.DataKey("CantidadF").ToDouble) - Dim CantConsulta = DtDatosCompra.SUM(VariableCampo) - If Math.Abs(CantidadGV - CantConsulta) > 0.01 Then - CargaCompra(CveCompraSurtir, -1) - CargaPendientes() - Alert("Ha sido cambiada la información de existencias de la compra actual, se han recargado la información.", TipoMensaje.MsgAdvertencia) - ObjComprasDif.Dispose() - Return False - End If - ObjComprasDif.Dispose() - End If - - 'VALIDA SI HUBO CAMBIOS EN LOS DETALLES OC - If CveOCSurtir > 0 Then - Dim VariableCampo = If(TipoMovimiento = 1, "CantidadF", "CantidadS") - Dim ObjComprasDif As New ClsInventarios - Dim DtDatosOC As New DataTable - If ObjComprasDif.RecepcionAlmacenOCGet(CveOCSurtir, UsuarioActual.CveEmpresa) Then - DtDatosOC = ObjComprasDif.DtResultados.FiltraParametros("CantidadCompra = 0") - End If - Dim CantidadGV = GvInv.Rows.Cast(Of GridViewRow)().Sum(Function(gvr) gvr.DataKey("CantidadF").ToDouble) - Dim CantConsulta = DtDatosOC.SUM(VariableCampo) - If Math.Abs(CantidadGV - CantConsulta) > 0.1 Then - CargaOCPorSurtir(CveOCSurtir) - Alert("Ha sido cambiada la información de existencias de la orden de compra actual, se han recargado la información.", TipoMensaje.MsgAdvertencia) - ObjComprasDif.Dispose() - Return False - End If - ObjComprasDif.Dispose() - End If - - 'VALIDA SI HUBO CAMBIOS EN LOS DETALLES IMPORTACION - If CveImportacionSurtir > 0 Then - Dim VariableCampo = If(TipoMovimiento = 1, "CantidadF", "CantidadS") - Dim ObjComprasDif As New ClsInventarios - Dim DtDatosImportacion As New DataTable - If ObjComprasDif.RecepcionAlmacenImportacionGet(CveImportacionSurtir, CveImportacionCompra, CveImportacionProveedor, UsuarioActual.CveEmpresa) Then - DtDatosImportacion = ObjComprasDif.DtResultados - End If - Dim CantidadGV = GvInv.Rows.Cast(Of GridViewRow)().Sum(Function(gvr) gvr.DataKey("CantidadF").ToDouble) - Dim CantConsulta = DtDatosImportacion.SUM(VariableCampo) - If CantidadGV <> CantConsulta Then - CargaImportacionSurtir(CveImportacionSurtir) - Alert("Ha sido cambiada la información de existencias de la importación actual, se han recargado la información.", TipoMensaje.MsgAdvertencia) - ObjComprasDif.Dispose() - Return False - End If - ObjComprasDif.Dispose() - End If - - 'VALIDA SI HUBO CAMBIOS EN LOS DETALLES FLETES - If CveFleteSurtir > 0 Then - Dim VariableCampo = If(TipoMovimiento = 1, "CantidadF", "CantidadS") - Dim ObjComprasDif As New ClsInventarios - Dim DtDatosImportacion As New DataTable - If ObjComprasDif.RecepcionAlmacenFleteGet(CveFleteSurtir, CveFleteOrdenCompra, CveFleteCompra, UsuarioActual.CveEmpresa) Then - DtDatosImportacion = ObjComprasDif.DtResultados - End If - Dim CantidadGV = GvInv.Rows.Cast(Of GridViewRow)().Sum(Function(gvr) gvr.DataKey("CantidadF").ToDouble) - Dim CantConsulta = DtDatosImportacion.SUM(VariableCampo) - If CantidadGV <> CantConsulta Then - CargaFleteSurtir(CveFleteSurtir) - Alert("Ha sido cambiada la informacion de existencias costo indirecto actual, se han recargado la información.", TipoMensaje.MsgAdvertencia) - ObjComprasDif.Dispose() - Return False - End If - ObjComprasDif.Dispose() - End If - - 'PASA DATOS DEL GV A DATATABLE PARA MANEJOR CON FOR EACH - Dim Index = 0 - For Each gvr As GridViewRow In GvInv.Rows - If gvr.FCCheckBox("cbInv").Checked AndAlso gvr.FCTextBox("TbCantidadF").Text.ToDecimal > 0 Then - DtInv.Rows(Index)("CantidadSurtidaPantalla") = gvr.FCTextBox("TbCantidadF").Text.ToDouble - End If - Index += 1 - Next - - 'VERIFICA EXISTENCIAS - If TipoMovimiento > 1 Then - Dim MensajeExistencias As New StringBuilder - Dim ObjInventarios As New ClsInventarios - For Each gvr As GridViewRow In GvInv.Rows - Dim ExistenciaActual = DtInv.SUM("CantidadSurtidaPantalla", $"CvePS = {gvr.DataKey("CvePS").ToEntero} AND CveUM = {gvr.DataKey("CveUM").ToEntero} ") - - If TipoMovimiento = 2 Then - 'If gvr.DataKey("CantidadC").ToString.ToDecimal <> ExistenciaActual Then - ' Alert("La devolución debe de ser completa.", TipoMensaje.MsgAdvertencia) - ' Exit Sub - 'End If - - If DtExistencias.SUM("Existencia", $"CvePS = {gvr.DataKey("CvePS").ToEntero} AND CveUM = {gvr.DataKey("CveUM").ToEntero}") < ExistenciaActual Then - MensajeExistencias.Append($"Producto: {GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=gvr.DataKey("CvePS").ToString.ToEntero).FiltroPrimeroValor("PSCodigo")}.
") - Continue For - End If - End If - - Dim Existencia = ObjInventarios.GetExistenciasPS(gvr.DataKey("CvePS").ToEntero, gvr.DataKey("CveUM").ToEntero, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm")) - If Existencia < ExistenciaActual Then - MensajeExistencias.Append($"Producto: {GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=gvr.DataKey("CvePS").ToString.ToEntero).FiltroPrimeroValor("PSCodigo")}.
") - Continue For - End If - Next - ObjInventarios.Dispose() - - If MensajeExistencias.ToString <> "" Then - Alert($"Los siguientes productos no cuentan con la existencia suficiente para hacer la devolución.

{MensajeExistencias.ToString}", TipoMensaje.MsgAdvertencia) - Return False - End If - - End If - - If UsuarioActual.Empresa.Funcionalidad(563) = "1" Then - If TotalCantidad <> DtSeccionAlmacen.SUMD("CantidadSeccionAlmacen") Then - Alert("La seccion de almacen no ha sido agregada completamente.", TipoMensaje.MsgAdvertencia) - Return False - End If - End If - - Return True - End Function - Protected Sub BtnGuardar_Click(sender As Object, e As EventArgs) Handles BtnGuardar.Click - - 'VALIDACIONES - If Not ValidaGuardar() Then - Exit Sub - End If - - If CveCompraSurtir > 0 Or CveOCSurtir > 0 Then - GuardaCompraOC() - ElseIf CveImportacionSurtir > 0 Then - GuardaImportacionFlete() - ElseIf CveFleteSurtir > 0 Then - GuardaImportacionFlete() - Else - Alert("Ocurrio un error al procesar la informacion para guardar el movimiento. Por favor comuniquese con atencion SIG.", TipoMensaje.MsgError) - End If - - End Sub - Private Function GeneraPrePolizaSalidaEntregaDirecta(CveMovimiento As Integer, ByRef ObjInventario As ClsInventarios, ByRef ObjConta As ClsContabilidad, ByRef ObjContaContPAQ As ClsContPAQi) As Boolean Dim Retorno As Boolean = True Try @@ -2014,44 +2014,44 @@ Partial Class Inventarios_RecepcionAlmacen Retorno = False End Try - Return Retorno - End Function - - Private Sub GuardaCompraOC() - Dim CveMovimiento As Integer - Dim InvFolio As String = "" - Dim FechaMovto As Date = TxtFecha.Text.ToDate - - Dim ErrorMovInv As Boolean - Dim MensajeError = "" - - Dim ObjInventario As New ClsInventarios - Dim ObjBitacora As New ClsOIEventos(ObjInventario.IniciaTransacSQL()) - Dim ObjCompras As New ClsCompras(ObjInventario.IniciaTransacSQL()) - Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL()) - Dim ObjOC As New ClsOC(ObjInventario.IniciaTransacSQL()) - Dim ObjAcum As New ClsAcumuladores(ObjInventario.IniciaTransacSQL()) - Dim ObjContaAC As ClsContPAQi = Nothing - Dim ObjContaContPAQ As ClsContPAQi = Nothing - + Return Retorno + End Function + + Private Sub GuardaCompraOC() + Dim CveMovimiento As Integer + Dim InvFolio As String = "" + Dim FechaMovto As Date = TxtFecha.Text.ToDate + + Dim ErrorMovInv As Boolean + Dim MensajeError = "" + + Dim ObjInventario As New ClsInventarios + Dim ObjBitacora As New ClsOIEventos(ObjInventario.IniciaTransacSQL()) + Dim ObjCompras As New ClsCompras(ObjInventario.IniciaTransacSQL()) + Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL()) + Dim ObjOC As New ClsOC(ObjInventario.IniciaTransacSQL()) + Dim ObjAcum As New ClsAcumuladores(ObjInventario.IniciaTransacSQL()) + Dim ObjContaAC As ClsContPAQi = Nothing + Dim ObjContaContPAQ As ClsContPAQi = Nothing + 'ENTREGA DIRECTA - Dim MovtosSalidaDirecta As New List(Of Integer) - Dim FoliosSalidaDirecta As New List(Of Integer) - - 'APARTADOS - Dim MovtosSalida As New List(Of Integer) - Dim FoliosSalida As New List(Of Integer) - Dim MovtosEntrada As New List(Of Integer) - Dim FoliosEntrada As New List(Of Integer) - - 'VIRUAL - Dim CveMovimientoVirtual As Integer = -1 - Dim FolioVirtual As Integer = -1 - - 'CONTABILIDAD - Dim CvePrePoliza = -1 - Dim MensajeContabilidad = "" - + Dim MovtosSalidaDirecta As New List(Of Integer) + Dim FoliosSalidaDirecta As New List(Of Integer) + + 'APARTADOS + Dim MovtosSalida As New List(Of Integer) + Dim FoliosSalida As New List(Of Integer) + Dim MovtosEntrada As New List(Of Integer) + Dim FoliosEntrada As New List(Of Integer) + + 'VIRUAL + Dim CveMovimientoVirtual As Integer = -1 + Dim FolioVirtual As Integer = -1 + + 'CONTABILIDAD + Dim CvePrePoliza = -1 + Dim MensajeContabilidad = "" + Try 'RECARGA TC CUANDO ES RECEPCION CON OC Y DOLARES If CveOCSurtir > 0 And CveMoneda <> 1 Then @@ -2192,7 +2192,7 @@ Partial Class Inventarios_RecepcionAlmacen If Not ErrorMovInv AndAlso Dt IsNot Nothing Then For Each Dr As DataRow In Dt.FiltraParametros($"CveVenta={CveVenta}").Rows - If Not ObjInventario.AddMovimientoDetalle(CveMovtoSalidaDirecta, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDouble, Dr("CveAF").ToString.ToEntero, Dr("CveSeccionAlmacen").ToString.ToEntero, Dr("SerieLote").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then + If Not ObjInventario.AddMovimientoDetalle(CveMovtoSalidaDirecta, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero, Dr("CveSeccionAlmacen").ToString.ToEntero, Dr("SerieLote").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then ErrorMovInv = True Exit For End If @@ -2253,12 +2253,12 @@ Partial Class Inventarios_RecepcionAlmacen Exit For End If - If Not ObjInventario.AddMovimientoDetalle(CveMovtoSalidaActual, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDouble, Dr("CveAF").ToString.ToEntero, Dr("CveSeccionAlmacen").ToString.ToEntero, Dr("SerieLote").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then + If Not ObjInventario.AddMovimientoDetalle(CveMovtoSalidaActual, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero, Dr("CveSeccionAlmacen").ToString.ToEntero, Dr("SerieLote").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then ErrorMovInv = True Exit For End If - If Not ObjInventario.AddMovimientoDetalle(CveMovtoEntradaActual, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDouble, Dr("CveAF").ToString.ToEntero, Dr("CveSeccionAlmacen").ToString.ToEntero, Dr("SerieLote").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then + If Not ObjInventario.AddMovimientoDetalle(CveMovtoEntradaActual, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero, Dr("CveSeccionAlmacen").ToString.ToEntero, Dr("SerieLote").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then ErrorMovInv = True Exit For End If @@ -2322,7 +2322,7 @@ Partial Class Inventarios_RecepcionAlmacen 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 Double = RowUsado("PU").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, -1, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then @@ -2746,993 +2746,993 @@ Partial Class Inventarios_RecepcionAlmacen Catch ex As Exception OnError("Ocurrió un error al guardar", ex) ErrorMovInv = True - End Try - - 'FINAL - If Not ErrorMovInv Then - ObjInventario.Commit() ' aplica los movimientos insertados - If ObjContaAC IsNot Nothing Then ObjContaAC.Commit() - If ObjContaContPAQ IsNot Nothing Then ObjContaContPAQ.Commit() - RegistraScript("playsonidito('beep-07.wav')") - - ' 'ENVIO DE CORREO NOTIFICACION A VENDEDORES DE OC - MandaCorreoOCVendedores(CveCompraSurtir, CveMovimiento) - - Dim Msg As New StringBuilder - Dim link As String = String.Format("{1}", CveMovimiento, InvFolio) - Msg.AppendFormat("Movimiento Registrado: Folio: {0}", link) + End Try + + 'FINAL + If Not ErrorMovInv Then + ObjInventario.Commit() ' aplica los movimientos insertados + If ObjContaAC IsNot Nothing Then ObjContaAC.Commit() + If ObjContaContPAQ IsNot Nothing Then ObjContaContPAQ.Commit() + RegistraScript("playsonidito('beep-07.wav')") + + ' 'ENVIO DE CORREO NOTIFICACION A VENDEDORES DE OC + MandaCorreoOCVendedores(CveCompraSurtir, CveMovimiento) + + Dim Msg As New StringBuilder + Dim link As String = String.Format("{1}", CveMovimiento, InvFolio) + Msg.AppendFormat("Movimiento Registrado: Folio: {0}", link) Msg.AppendFormat("
Imprimir Movimiento ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimiento))) - 'If CveMovtoSalidaDirecta > 0 Then - ' Msg.AppendFormat("

Movimientos de control:
") - ' link = String.Format("{1}", CveMovtoSalidaDirecta, FolioSalidaDirecta) - ' Msg.AppendFormat("Movimiento de Salida Folio: {0}", link) + 'If CveMovtoSalidaDirecta > 0 Then + ' Msg.AppendFormat("

Movimientos de control:
") + ' link = String.Format("{1}", CveMovtoSalidaDirecta, FolioSalidaDirecta) + ' Msg.AppendFormat("Movimiento de Salida Folio: {0}", link) 'End If 'ENTREGA DIRECTA - If MovtosSalidaDirecta.Count > 0 Then - Msg.AppendFormat("

Movimientos de control:
") - For index = 0 To MovtosSalidaDirecta.Count - 1 - link = String.Format("{1}", MovtosSalidaDirecta(index), FoliosSalidaDirecta(index)) - Msg.AppendFormat("
Movimiento de Salida Folio: {0}", link) - Next - End If - - 'APARTADO - If MovtosSalida.Count > 0 Then - Msg.AppendFormat("

Movimientos de control:
") - For index = 0 To MovtosSalida.Count - 1 - link = String.Format("{1}", MovtosSalida(index), FoliosSalida(index)) - Msg.AppendFormat("
Movimiento de Salida por Traspaso: Folio: {0}", link) - link = String.Format("{1}", MovtosEntrada(index), FoliosEntrada(index)) - Msg.AppendFormat("
Movimiento de Entrada por Traspaso: Folio: {0}
", link) - Next + If MovtosSalidaDirecta.Count > 0 Then + Msg.AppendFormat("

Movimientos de control:
") + For index = 0 To MovtosSalidaDirecta.Count - 1 + link = String.Format("{1}", MovtosSalidaDirecta(index), FoliosSalidaDirecta(index)) + Msg.AppendFormat("
Movimiento de Salida Folio: {0}", link) + Next + End If + + 'APARTADO + If MovtosSalida.Count > 0 Then + Msg.AppendFormat("

Movimientos de control:
") + For index = 0 To MovtosSalida.Count - 1 + link = String.Format("{1}", MovtosSalida(index), FoliosSalida(index)) + Msg.AppendFormat("
Movimiento de Salida por Traspaso: Folio: {0}", link) + link = String.Format("{1}", MovtosEntrada(index), FoliosEntrada(index)) + Msg.AppendFormat("
Movimiento de Entrada por Traspaso: Folio: {0}
", link) + Next End If 'VIRTUAL - If CveMovimientoVirtual > 0 Then + If CveMovimientoVirtual > 0 Then link = String.Format("{1}", CveMovimientoVirtual, FolioVirtual) Msg.AppendFormat("
Movimiento de Entrada al Almacen Virtual: Folio: {0}", link) - Msg.AppendFormat("
Imprimir Movimiento ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoVirtual))) - - End If - - 'CONTABILIDAD - Msg.Append(MensajeContabilidad) - - Alert(Msg.ToString, TipoMensaje.MsgInformacion) - - If ObjInventario.RecepcionAlmacenGet(CveCompraSurtir, -1, UsuarioActual.CveEmpresa) Then - CreaDTInv(ObjInventario.DtResultados) - CargaGVInv() - BtnGuardar.Visible = True - End If - Limpia() - - Else - ObjInventario.RollBack() - If ObjContaAC IsNot Nothing Then ObjContaAC.RollBack() - If ObjContaContPAQ IsNot Nothing Then ObjContaContPAQ.RollBack() - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - Alert($"Ocurrió un error al guardar el movimiento de almacén. Por favor vuelva a intentar.

{MensajeError}", TipoMensaje.MsgError) - End If - - ObjInventario.Dispose() - If ObjContaAC IsNot Nothing Then ObjContaAC.Dispose() - If ObjContaContPAQ IsNot Nothing Then ObjContaContPAQ.Dispose() - End Sub - Private Sub GuardaImportacionFlete() - Dim CveMovimiento As Integer - Dim InvFolio As String = "" - Dim FechaMovto As Date = TxtFecha.Text.ToDate - Dim ErrorMovInv As Boolean - Dim MensajeError = "" - - Dim ObjInventario As New ClsInventarios - Dim ObjBitacora As New ClsOIEventos(ObjInventario.IniciaTransacSQL()) - Dim ObjCompras As New ClsCompras(ObjInventario.IniciaTransacSQL()) - Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL()) - Dim ObjOC As New ClsOC(ObjInventario.IniciaTransacSQL()) - Dim ObjContaAC As ClsContPAQi = Nothing - - 'ENTRADA ALMACÉN - CveMovimiento = ObjInventario.AddMovimiento(DdlAlmacen.SelectedValue.ToEntero, 2, 1, FechaMovto, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveImportacionCompra, -1, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, TipoCambio:=-1, Remision:=TxtRemision.Text, Modulo:="RA/G") - If CveMovimiento > 0 Then - InvFolio = ObjInventario.Folio.ToString - Dim DtDetalle As New DataTable - Dim DtDetalleLote As New DataTable - Dim PU As Decimal = 0 - Dim CostoIndirecto As Decimal = 0 - Dim PUExtranjero As Decimal = 0 - For Each gvr As GridViewRow In GvInv.Rows - If gvr.FCCheckBox("cbInv").Checked AndAlso gvr.FCTextBox("TbCantidadF").Text.ToDecimal > 0 Then - - PU = DtInv.Rows(gvr.RowIndex)("PU").ToString.ToDecimal - CostoIndirecto = DtInv.Rows(gvr.RowIndex)("CostoIndirecto").ToString.ToDecimal - PUExtranjero = DtInv.Rows(gvr.RowIndex)("PUExtranjero").ToString.ToDecimal - - 'SI FUE POR SERIE LOTE - DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", gvr.DataKey("Consec").ToEntero)) - DtDetalleLote = DtDatosLoteDetalle.FiltraParametros(String.Format("ConsecId = {0}", gvr.DataKey("Consec").ToEntero)) - If DtDetalle.Rows.Count > 0 Then - For Each Dr As DataRow In DtDetalle.Rows - If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, 1, gvr.DataKey("CveUM").ToEntero, gvr.DataKey("CvePS").ToEntero, PU, -1, CveSeccionAlmacen:=gvr.FCDropDownList("DdlSeccionAlmacen").SelectedValue.ToEntero, PUTC:=If(DdlMonedaTC.SelectedValue.ToEntero = 1, -1, PUExtranjero), SerieLote:=Dr("Serie").ToString, FechaCaducidad:=Dr("FechaCaducidad").ToString.ToDate, CveCompraDetalle:=gvr.DataKey("CveCompraDetalle").ToEntero, CveOrdenCompraDetalle:=gvr.DataKey("CveOrdenCompraDetalle").ToEntero, CveVentaDetalle:=gvr.DataKey("CveVentaDetalle").ToEntero, CostoIndirecto:=CostoIndirecto) Then - ErrorMovInv = True - Exit For - End If - Next - ElseIf DtDetalleLote.Rows.Count > 0 Then - For Each Dr As DataRow In DtDetalleLote.Rows - If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, gvr.DataKey("CveUM").ToEntero, gvr.DataKey("CvePS").ToEntero, PU, -1, CveSeccionAlmacen:=gvr.FCDropDownList("DdlSeccionAlmacen").SelectedValue.ToEntero, PUTC:=If(DdlMonedaTC.SelectedValue.ToEntero = 1, -1, PUExtranjero), Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, FechaCaducidad:=Dr("FechaCaducidad").ToString.ToDate, CveCompraDetalle:=gvr.DataKey("CveCompraDetalle").ToEntero, CveOrdenCompraDetalle:=gvr.DataKey("CveOrdenCompraDetalle").ToEntero, CveVentaDetalle:=gvr.DataKey("CveVentaDetalle").ToEntero, CostoIndirecto:=CostoIndirecto) Then - ErrorMovInv = True - Exit For - End If - Next - Else - If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, gvr.FCTextBox("TbCantidadF").Text.ToDouble, gvr.DataKey("CveUM").ToEntero, gvr.DataKey("CvePS").ToEntero, PU, -1, CveSeccionAlmacen:=gvr.FCDropDownList("DdlSeccionAlmacen").SelectedValue.ToEntero, PUTC:=If(DdlMonedaTC.SelectedValue.ToEntero = 1, -1, PUExtranjero), CveCompraDetalle:=gvr.DataKey("CveCompraDetalle").ToEntero, CveOrdenCompraDetalle:=gvr.DataKey("CveOrdenCompraDetalle").ToEntero, CveVentaDetalle:=gvr.DataKey("CveVentaDetalle").ToEntero, CostoIndirecto:=CostoIndirecto) Then - ErrorMovInv = True - Exit For - End If - End If - - End If - Next - Else - ErrorMovInv = True - End If - - 'AGREGA BITACORA TEMPORAL - If DtBitacora IsNot Nothing AndAlso DtBitacora.Rows.Count > 0 Then - ErrorMovInv = GuardaBitacoraTemporal(ObjBitacora, CveMovimiento) - End If - Dim CvePrePoliza As Integer = 0 - Dim UsaComplementariaCostoIndirecto As Boolean = False - If UsuarioActual.CveEmpresa = 119 Then UsaComplementariaCostoIndirecto = False - Dim PorcentajeCompraImportacion As Decimal = 0 ' si hay mas de una factura de importación saber lo que se está recibiendo - - 'SE REGISTRAN LAS PREPOLIZAS - If Not ErrorMovInv Then - CvePrePoliza = ObjConta.AddPrePolizas("Inventario/RecepcionAlmacen CostoInd", 74, 0, 0, 1, FechaMovto, TxtObservaciones.Text.Trim, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - Dim DtTempCompras As DataTable = Nothing - PorcentajeCompraImportacion = 1 - If CveFleteSurtir > 0 Then - If ObjInventario.GetFleteDetalle(CveFleteSurtir) Then - DtTempCompras = ObjInventario.DtResultados - ' faltaría agregar la factura de producto, - If ObjCompras.GetCompras(CveFleteCompra, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa) Then - Dim drc As DataRow = DtTempCompras.NewRow - Dim drr As DataRow = ObjCompras.DtResultados.FiltroPrimero("") - If drr IsNot Nothing Then - drc("CveCompra") = CveFleteCompra - drc("SubTotal") = drr("SubTotal") - drc("TipoCambio") = drr("TipoCambio") - drc("CveProveedor") = drr("CveProveedor") - DtTempCompras.Rows.Add(drc) - End If - - End If - - Else - ErrorMovInv = True - End If - Else - - If CveImportacionSurtir > 0 Then - - If ObjCompras.GetImportacionesDetalle(CveImportacionSurtir, -1) Then - DtTempCompras = ObjCompras.DtResultados - Dim CveCompraImportacion As Integer = -1 - If (DdlFactura.SelectedValue.ToEntero > 0) Then CveCompraImportacion = DdlFactura.SelectedValue.ToEntero - - If ObjCompras.GetImportacionCompras(CveImportacionSurtir, CveCompraImportacion) Then - For Each drt As DataRow In ObjCompras.DtResultados.Rows - PorcentajeCompraImportacion = If(CveCompraImportacion > 0, drt("PorcentajeCompra").ToString.ToDecimal, 1) - Dim drc As DataRow = DtTempCompras.NewRow - drc("CveCompra") = drt("CveCompra") - drc("SubTotal") = drt("SubTotal") - drc("TipoCambio") = drt("TipoCambio") - drc("CveProveedor") = drt("CveProveedor") - DtTempCompras.Rows.Add(drc) - Next - - End If - - - - Else - ErrorMovInv = True - End If - End If - End If - If CvePrePoliza > 0 Then - 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 - ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) - Dim TotalCosto As Decimal = ObjInventario.DtResultados.SUMD("Total").RoundSQL() - Dim IdCtaContableCostoInd As Integer = 0 - - If ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, TotalCosto, InvFolio, 68, InvFolio, FechaMovto, IdCtaContableAlmacen, -1, CveCompra:=CveCompraSurtir, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=TotalCosto, CveCuenta:=CveCuentaAlmacen) Then - 'se recorren las facturas a descontar el recepción - If DtTempCompras IsNot Nothing AndAlso DtTempCompras.Rows.Count > 0 Then - - For Each dr As DataRow In DtTempCompras.Rows - Dim CveComp As Integer = dr("CveCompra").ToString.ToEntero - 'el porcentaje solo aplica a las facturas de costo indirecto - Dim SubTotalPartida As Decimal = dr("SubTotal").ToString.ToDecimal * If(dr("TipoCompra").ToString = "CI", PorcentajeCompraImportacion, 1) - Dim ImporteAbono As Decimal = (SubTotalPartida * dr("TipoCambio").ToString.ToDecimal).RoundSQL - Dim ImporteAbonoME As Decimal = 0 - Dim CveConceptoCostoIndirecto As Integer = If(CveImportacionSurtir > 0, 240, 237) - - If ObjConta.GetRetCuenta(CveConceptoCostoIndirecto, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then - IdCtaContableCostoInd = ObjConta.DtResultados.FiltroPrimeroValor("IdCtaContable").ToEntero - End If - - If UsaComplementariaCostoIndirecto Then - CveConceptoCostoIndirecto = If(CveImportacionSurtir > 0, 241, 238) - ImporteAbono = SubTotalPartida - ImporteAbonoME = (SubTotalPartida * dr("TipoCambio").ToString.ToDecimal) - SubTotalPartida - End If - - - - If ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImporteAbono, InvFolio, CveConceptoCostoIndirecto, InvFolio, FechaMovto, IdCtaContableCostoInd, -1, CveCompra:=CveComp, CveProveedor:=dr("CveProveedor").ToString.ToEntero, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=ImporteAbono) Then - ' si tiene valor es que hay complementaria - If ImporteAbonoME > 0 Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImporteAbono, InvFolio, If(CveImportacionSurtir > 0, 242, 239), InvFolio, FechaMovto, IdCtaContableCostoInd, -1, CveCompra:=CveComp, CveProveedor:=dr("CveProveedor").ToString.ToEntero, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=ImporteAbono) Then - ErrorMovInv = True - End If - End If - Else - ErrorMovInv = True - End If - Next - - End If - End If - - - Else - ErrorMovInv = True - End If - End If - - If ObjConta.ValidacionPrePolizaCuadre(CvePrePoliza, -1) Then - If ObjConta.ValorPolizaDescuadre > 0 Then - GuardaLogAD($"Inventarios/RecepcionAlmacen-PPCompOC | Error:{ObjConta.MensajePolizaDescuadre} Diferencia:{ObjConta.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas") - ErrorMovInv = True - End If - End If - - If Not ErrorMovInv AndAlso UsuarioActual.Empresa.Funcionalidad(200) = "1" Then - ObjContaAC = New ClsContPAQi(UsuarioActual.Empresa) - ObjContaAC.IniciaTransacSQL() - If ObjConta.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa, ObjConta:=ObjContaAC) Then - MensajeError = $"
Movimiento contabilizado en el folio: {ObjConta.ContaFolio}
" - Else - ErrorMovInv = True - MensajeError = "Error al contabilizar los conceptos contables" - End If - End If - - - 'FINAL - If Not ErrorMovInv Then - ObjInventario.Commit() ' aplica los movimientos insertados - If ObjContaAC IsNot Nothing Then ObjContaAC.Commit() - RegistraScript("playsonidito('beep-07.wav')") - - Dim Msg As New StringBuilder - Dim link As String = String.Format("{1}", CveMovimiento, InvFolio) - Msg.AppendFormat("Movimiento Registrado: Folio: {0}", link) - Msg.AppendFormat("
Imprimir Movimiento ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimiento))) - - Alert(Msg.ToString, TipoMensaje.MsgInformacion) - - Limpia() - Else - ObjInventario.RollBack() - If ObjContaAC IsNot Nothing Then ObjContaAC.RollBack() - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - GuardaLog(MensajeError) - Alert("Error al guardar el movimiento de almacen. Por favor vuelva a intentar.", TipoMensaje.MsgError) - End If - - ObjInventario.Dispose() - If ObjContaAC IsNot Nothing Then ObjContaAC.Dispose() - End Sub - Private Sub Limpia() - CveCompraSurtir = -1 - CvePrePolizaCompra = -1 - CveOCSurtir = -1 - CveImportacionSurtir = -1 - CveImportacionProveedor = -1 - CveImportacionCompra = -1 - BuscaEntregaDirecta = -1 - DivAdvertencia.Visible = False - EntregaDirecta = False - DtInv = Nothing - CargaGVInv() - TxtObservaciones.Text = "" - TxtOC.Text = "" - TxtFecha.Text = Now.ToShortDateString - DdlAlmacen.SelectedValueExist(-1) - TxtRemision.Text = "" - - 'ddlProveedor.SelectedValueExist(-1) - ddlProveedor.SelectedValue = "-1" - DdlFolio.Items.Clear() - DdlFolio.Items.Insert(0, New ListItem("Seleccione", "-1")) - DdlFolioOC.Items.Clear() - DdlFolioOC.Items.Insert(0, New ListItem("Seleccione", "-1")) - DdlFolioImportacion.Items.Clear() - DdlFolioImportacion.Items.Insert(0, New ListItem("Seleccione", "-1")) - CargaFoliosRecepcion() - - DtBitacora.Clear() - DivBitacora.Visible = False - CargaEventoBitacoraTemp() - - DdlMonedaTC.SelectedValueExist("1") - TipoCambio = 0 - 'TxtTipoCambio.Text = GlobalTipoCambio(TxtFecha.Text.ToDate).ToString - DivTipoCambio.Visible = False - - DivAdvertencia.Visible = False - - UpTipoCambio.Update() - UPInv.Update() - UpGenerales.Update() - UpFiltros.Update() - - HLFolio.Text = "" - HLFolio.NavigateUrl = "#" - LbProveedor.Text = "" - LbDescripcionCompra.Text = "" - UpDatosCompra.Update() - CargaPendientes() - - End Sub - Private Function GuardaPrePoliza() As Boolean - Return True + Msg.AppendFormat("
Imprimir Movimiento ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoVirtual))) + + End If + + 'CONTABILIDAD + Msg.Append(MensajeContabilidad) + + Alert(Msg.ToString, TipoMensaje.MsgInformacion) + + If ObjInventario.RecepcionAlmacenGet(CveCompraSurtir, -1, UsuarioActual.CveEmpresa) Then + CreaDTInv(ObjInventario.DtResultados) + CargaGVInv() + BtnGuardar.Visible = True + End If + Limpia() + + Else + ObjInventario.RollBack() + If ObjContaAC IsNot Nothing Then ObjContaAC.RollBack() + If ObjContaContPAQ IsNot Nothing Then ObjContaContPAQ.RollBack() + RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") + Alert($"Ocurrió un error al guardar el movimiento de almacén. Por favor vuelva a intentar.

{MensajeError}", TipoMensaje.MsgError) + End If + + ObjInventario.Dispose() + If ObjContaAC IsNot Nothing Then ObjContaAC.Dispose() + If ObjContaContPAQ IsNot Nothing Then ObjContaContPAQ.Dispose() + End Sub + Private Sub GuardaImportacionFlete() + Dim CveMovimiento As Integer + Dim InvFolio As String = "" + Dim FechaMovto As Date = TxtFecha.Text.ToDate + Dim ErrorMovInv As Boolean + Dim MensajeError = "" + + Dim ObjInventario As New ClsInventarios + Dim ObjBitacora As New ClsOIEventos(ObjInventario.IniciaTransacSQL()) + Dim ObjCompras As New ClsCompras(ObjInventario.IniciaTransacSQL()) + Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL()) + Dim ObjOC As New ClsOC(ObjInventario.IniciaTransacSQL()) + Dim ObjContaAC As ClsContPAQi = Nothing + + 'ENTRADA ALMACÉN + CveMovimiento = ObjInventario.AddMovimiento(DdlAlmacen.SelectedValue.ToEntero, 2, 1, FechaMovto, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveImportacionCompra, -1, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, TipoCambio:=-1, Remision:=TxtRemision.Text, Modulo:="RA/G") + If CveMovimiento > 0 Then + InvFolio = ObjInventario.Folio.ToString + Dim DtDetalle As New DataTable + Dim DtDetalleLote As New DataTable + Dim PU As Decimal = 0 + Dim CostoIndirecto As Decimal = 0 + Dim PUExtranjero As Decimal = 0 + For Each gvr As GridViewRow In GvInv.Rows + If gvr.FCCheckBox("cbInv").Checked AndAlso gvr.FCTextBox("TbCantidadF").Text.ToDecimal > 0 Then + + PU = DtInv.Rows(gvr.RowIndex)("PU").ToString.ToDecimal + CostoIndirecto = DtInv.Rows(gvr.RowIndex)("CostoIndirecto").ToString.ToDecimal + PUExtranjero = DtInv.Rows(gvr.RowIndex)("PUExtranjero").ToString.ToDecimal + + 'SI FUE POR SERIE LOTE + DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", gvr.DataKey("Consec").ToEntero)) + DtDetalleLote = DtDatosLoteDetalle.FiltraParametros(String.Format("ConsecId = {0}", gvr.DataKey("Consec").ToEntero)) + If DtDetalle.Rows.Count > 0 Then + For Each Dr As DataRow In DtDetalle.Rows + If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, 1, gvr.DataKey("CveUM").ToEntero, gvr.DataKey("CvePS").ToEntero, PU, -1, CveSeccionAlmacen:=gvr.FCDropDownList("DdlSeccionAlmacen").SelectedValue.ToEntero, PUTC:=If(DdlMonedaTC.SelectedValue.ToEntero = 1, -1, PUExtranjero), SerieLote:=Dr("Serie").ToString, FechaCaducidad:=Dr("FechaCaducidad").ToString.ToDate, CveCompraDetalle:=gvr.DataKey("CveCompraDetalle").ToEntero, CveOrdenCompraDetalle:=gvr.DataKey("CveOrdenCompraDetalle").ToEntero, CveVentaDetalle:=gvr.DataKey("CveVentaDetalle").ToEntero, CostoIndirecto:=CostoIndirecto) Then + ErrorMovInv = True + Exit For + End If + Next + ElseIf DtDetalleLote.Rows.Count > 0 Then + For Each Dr As DataRow In DtDetalleLote.Rows + If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, gvr.DataKey("CveUM").ToEntero, gvr.DataKey("CvePS").ToEntero, PU, -1, CveSeccionAlmacen:=gvr.FCDropDownList("DdlSeccionAlmacen").SelectedValue.ToEntero, PUTC:=If(DdlMonedaTC.SelectedValue.ToEntero = 1, -1, PUExtranjero), Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, FechaCaducidad:=Dr("FechaCaducidad").ToString.ToDate, CveCompraDetalle:=gvr.DataKey("CveCompraDetalle").ToEntero, CveOrdenCompraDetalle:=gvr.DataKey("CveOrdenCompraDetalle").ToEntero, CveVentaDetalle:=gvr.DataKey("CveVentaDetalle").ToEntero, CostoIndirecto:=CostoIndirecto) Then + ErrorMovInv = True + Exit For + End If + Next + Else + If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, gvr.FCTextBox("TbCantidadF").Text.ToDouble, gvr.DataKey("CveUM").ToEntero, gvr.DataKey("CvePS").ToEntero, PU, -1, CveSeccionAlmacen:=gvr.FCDropDownList("DdlSeccionAlmacen").SelectedValue.ToEntero, PUTC:=If(DdlMonedaTC.SelectedValue.ToEntero = 1, -1, PUExtranjero), CveCompraDetalle:=gvr.DataKey("CveCompraDetalle").ToEntero, CveOrdenCompraDetalle:=gvr.DataKey("CveOrdenCompraDetalle").ToEntero, CveVentaDetalle:=gvr.DataKey("CveVentaDetalle").ToEntero, CostoIndirecto:=CostoIndirecto) Then + ErrorMovInv = True + Exit For + End If + End If + + End If + Next + Else + ErrorMovInv = True + End If + + 'AGREGA BITACORA TEMPORAL + If DtBitacora IsNot Nothing AndAlso DtBitacora.Rows.Count > 0 Then + ErrorMovInv = GuardaBitacoraTemporal(ObjBitacora, CveMovimiento) + End If + Dim CvePrePoliza As Integer = 0 + Dim UsaComplementariaCostoIndirecto As Boolean = False + If UsuarioActual.CveEmpresa = 119 Then UsaComplementariaCostoIndirecto = False + Dim PorcentajeCompraImportacion As Decimal = 0 ' si hay mas de una factura de importación saber lo que se está recibiendo + + 'SE REGISTRAN LAS PREPOLIZAS + If Not ErrorMovInv Then + CvePrePoliza = ObjConta.AddPrePolizas("Inventario/RecepcionAlmacen CostoInd", 74, 0, 0, 1, FechaMovto, TxtObservaciones.Text.Trim, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + Dim DtTempCompras As DataTable = Nothing + PorcentajeCompraImportacion = 1 + If CveFleteSurtir > 0 Then + If ObjInventario.GetFleteDetalle(CveFleteSurtir) Then + DtTempCompras = ObjInventario.DtResultados + ' faltaría agregar la factura de producto, + If ObjCompras.GetCompras(CveFleteCompra, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa) Then + Dim drc As DataRow = DtTempCompras.NewRow + Dim drr As DataRow = ObjCompras.DtResultados.FiltroPrimero("") + If drr IsNot Nothing Then + drc("CveCompra") = CveFleteCompra + drc("SubTotal") = drr("SubTotal") + drc("TipoCambio") = drr("TipoCambio") + drc("CveProveedor") = drr("CveProveedor") + DtTempCompras.Rows.Add(drc) + End If + + End If + + Else + ErrorMovInv = True + End If + Else + + If CveImportacionSurtir > 0 Then + + If ObjCompras.GetImportacionesDetalle(CveImportacionSurtir, -1) Then + DtTempCompras = ObjCompras.DtResultados + Dim CveCompraImportacion As Integer = -1 + If (DdlFactura.SelectedValue.ToEntero > 0) Then CveCompraImportacion = DdlFactura.SelectedValue.ToEntero + + If ObjCompras.GetImportacionCompras(CveImportacionSurtir, CveCompraImportacion) Then + For Each drt As DataRow In ObjCompras.DtResultados.Rows + PorcentajeCompraImportacion = If(CveCompraImportacion > 0, drt("PorcentajeCompra").ToString.ToDecimal, 1) + Dim drc As DataRow = DtTempCompras.NewRow + drc("CveCompra") = drt("CveCompra") + drc("SubTotal") = drt("SubTotal") + drc("TipoCambio") = drt("TipoCambio") + drc("CveProveedor") = drt("CveProveedor") + DtTempCompras.Rows.Add(drc) + Next + + End If + + + + Else + ErrorMovInv = True + End If + End If + End If + If CvePrePoliza > 0 Then + 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 + ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) + Dim TotalCosto As Decimal = ObjInventario.DtResultados.SUMD("Total").RoundSQL() + Dim IdCtaContableCostoInd As Integer = 0 + + If ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, TotalCosto, InvFolio, 68, InvFolio, FechaMovto, IdCtaContableAlmacen, -1, CveCompra:=CveCompraSurtir, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=TotalCosto, CveCuenta:=CveCuentaAlmacen) Then + 'se recorren las facturas a descontar el recepción + If DtTempCompras IsNot Nothing AndAlso DtTempCompras.Rows.Count > 0 Then + + For Each dr As DataRow In DtTempCompras.Rows + Dim CveComp As Integer = dr("CveCompra").ToString.ToEntero + 'el porcentaje solo aplica a las facturas de costo indirecto + Dim SubTotalPartida As Decimal = dr("SubTotal").ToString.ToDecimal * If(dr("TipoCompra").ToString = "CI", PorcentajeCompraImportacion, 1) + Dim ImporteAbono As Decimal = (SubTotalPartida * dr("TipoCambio").ToString.ToDecimal).RoundSQL + Dim ImporteAbonoME As Decimal = 0 + Dim CveConceptoCostoIndirecto As Integer = If(CveImportacionSurtir > 0, 240, 237) + + If ObjConta.GetRetCuenta(CveConceptoCostoIndirecto, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then + IdCtaContableCostoInd = ObjConta.DtResultados.FiltroPrimeroValor("IdCtaContable").ToEntero + End If + + If UsaComplementariaCostoIndirecto Then + CveConceptoCostoIndirecto = If(CveImportacionSurtir > 0, 241, 238) + ImporteAbono = SubTotalPartida + ImporteAbonoME = (SubTotalPartida * dr("TipoCambio").ToString.ToDecimal) - SubTotalPartida + End If + + + + If ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImporteAbono, InvFolio, CveConceptoCostoIndirecto, InvFolio, FechaMovto, IdCtaContableCostoInd, -1, CveCompra:=CveComp, CveProveedor:=dr("CveProveedor").ToString.ToEntero, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=ImporteAbono) Then + ' si tiene valor es que hay complementaria + If ImporteAbonoME > 0 Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImporteAbono, InvFolio, If(CveImportacionSurtir > 0, 242, 239), InvFolio, FechaMovto, IdCtaContableCostoInd, -1, CveCompra:=CveComp, CveProveedor:=dr("CveProveedor").ToString.ToEntero, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=ImporteAbono) Then + ErrorMovInv = True + End If + End If + Else + ErrorMovInv = True + End If + Next + + End If + End If + + + Else + ErrorMovInv = True + End If + End If + + If ObjConta.ValidacionPrePolizaCuadre(CvePrePoliza, -1) Then + If ObjConta.ValorPolizaDescuadre > 0 Then + GuardaLogAD($"Inventarios/RecepcionAlmacen-PPCompOC | Error:{ObjConta.MensajePolizaDescuadre} Diferencia:{ObjConta.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas") + ErrorMovInv = True + End If + End If + + If Not ErrorMovInv AndAlso UsuarioActual.Empresa.Funcionalidad(200) = "1" Then + ObjContaAC = New ClsContPAQi(UsuarioActual.Empresa) + ObjContaAC.IniciaTransacSQL() + If ObjConta.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa, ObjConta:=ObjContaAC) Then + MensajeError = $"
Movimiento contabilizado en el folio: {ObjConta.ContaFolio}
" + Else + ErrorMovInv = True + MensajeError = "Error al contabilizar los conceptos contables" + End If + End If + + + 'FINAL + If Not ErrorMovInv Then + ObjInventario.Commit() ' aplica los movimientos insertados + If ObjContaAC IsNot Nothing Then ObjContaAC.Commit() + RegistraScript("playsonidito('beep-07.wav')") + + Dim Msg As New StringBuilder + Dim link As String = String.Format("{1}", CveMovimiento, InvFolio) + Msg.AppendFormat("Movimiento Registrado: Folio: {0}", link) + Msg.AppendFormat("
Imprimir Movimiento ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimiento))) + + Alert(Msg.ToString, TipoMensaje.MsgInformacion) + + Limpia() + Else + ObjInventario.RollBack() + If ObjContaAC IsNot Nothing Then ObjContaAC.RollBack() + RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") + GuardaLog(MensajeError) + Alert("Error al guardar el movimiento de almacen. Por favor vuelva a intentar.", TipoMensaje.MsgError) + End If + + ObjInventario.Dispose() + If ObjContaAC IsNot Nothing Then ObjContaAC.Dispose() + End Sub + Private Sub Limpia() + CveCompraSurtir = -1 + CvePrePolizaCompra = -1 + CveOCSurtir = -1 + CveImportacionSurtir = -1 + CveImportacionProveedor = -1 + CveImportacionCompra = -1 + BuscaEntregaDirecta = -1 + DivAdvertencia.Visible = False + EntregaDirecta = False + DtInv = Nothing + CargaGVInv() + TxtObservaciones.Text = "" + TxtOC.Text = "" + TxtFecha.Text = Now.ToShortDateString + DdlAlmacen.SelectedValueExist(-1) + TxtRemision.Text = "" + + 'ddlProveedor.SelectedValueExist(-1) + ddlProveedor.SelectedValue = "-1" + DdlFolio.Items.Clear() + DdlFolio.Items.Insert(0, New ListItem("Seleccione", "-1")) + DdlFolioOC.Items.Clear() + DdlFolioOC.Items.Insert(0, New ListItem("Seleccione", "-1")) + DdlFolioImportacion.Items.Clear() + DdlFolioImportacion.Items.Insert(0, New ListItem("Seleccione", "-1")) + CargaFoliosRecepcion() + + DtBitacora.Clear() + DivBitacora.Visible = False + CargaEventoBitacoraTemp() + + DdlMonedaTC.SelectedValueExist("1") + TipoCambio = 0 + 'TxtTipoCambio.Text = GlobalTipoCambio(TxtFecha.Text.ToDate).ToString + DivTipoCambio.Visible = False + + DivAdvertencia.Visible = False + + UpTipoCambio.Update() + UPInv.Update() + UpGenerales.Update() + UpFiltros.Update() + + HLFolio.Text = "" + HLFolio.NavigateUrl = "#" + LbProveedor.Text = "" + LbDescripcionCompra.Text = "" + UpDatosCompra.Update() + CargaPendientes() + + End Sub + Private Function GuardaPrePoliza() As Boolean + Return True End Function -#End Region +#End Region -#Region " OC " - Private Sub CargaFoliosOC() - DdlFolioOC.Items.Clear() - - Dim ObjInventarios As New ClsInventarios - If ddlProveedor.SelectedValue.ToEntero > 0 Then - If ObjInventarios.PendientesAlmacenOCGet(ddlProveedor.SelectedValue.ToEntero, MinFecha.ToShortDateString.ToDate, UsuarioActual.CveEmpresa) Then - DdlFolioOC.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() - - DdlFolioOC.DataBind() - DdlFolioOC.Items.Insert(0, New ListItem("Seleccione", "-1")) - - End Sub - Private Sub CargaPendientesOC() - Dim ObjInventarios As New ClsInventarios - Dim DtPendientesOC As New DataTable - - If ObjInventarios.PendientesAlmacenOCGet(ddlProveedor.SelectedValue.ToEntero, TxtFechaPendientes.Text.ToDate, UsuarioActual.CveEmpresa) Then - DtPendientesOC = ObjInventarios.DtResultados - Else - DtPendientesOC = Nothing - Alert("Ocurrió un error al obtener las OC pendientes de recibir del proveedor. Por favor vuelva a intentar", TipoMensaje.MsgError) - End If - - ObjInventarios.Dispose() - - If DtPendientesOC IsNot Nothing Then - GVPendientes.DataSource = DtPendientesOC - End If - - LtActualizado.Text = String.Format("Actualizado: {0}", Now.ToString("H:mm")) - - GVPendientes.DataBind() - UpPendientes.Update() - End Sub - - Protected Sub BtnBuscarOC_Click(sender As Object, e As EventArgs) Handles BtnBuscarOC.Click - CargaOC() - End Sub - - Private Sub CargaOC() - - 'OBTENE CveOC - Dim CveOC = -1 - Dim MensajeCompra = "" - Dim FolioOC = TxtOC.Text.Trim.ToEntero - Dim ObjOC As New ClsOC - If ObjOC.GetOrdenesCompraRep("OC", -1, -1, -1, -1, MinFecha, MaxFecha, -1, -1, FolioOC, -1, -1, UsuarioActual.CveEmpresa, -1) Then - 'If ObjOC.DtResultados.FiltraParametros("TipoTermino = 3").Rows.Count = 1 Then - If ObjOC.DtResultados.Rows(0)("TieneCompra").ToString.ToEntero > 0 And UsuarioActual.Empresa.Funcionalidad(153).ToEntero > 0 Then 'Or UsuarioActual.Empresa.Funcionalidad(153).ToEntero > 0 - MensajeCompra = String.Format("{1}", ObjOC.DtResultados.Rows(0)("CveCompraVinculada").ToString, ObjOC.DtResultados.Rows(0)("SerieFolioCompraVinculada").ToString) - Else - CveOC = ObjOC.DtResultados.FiltroPrimeroValor("CveOrdenCompra").ToString.ToEntero - End If - 'End If - End If - ObjOC.Dispose() - - RecibidaCompleta = False - If CveOC > 0 Then - CargaOCPorSurtir(CveOC) - Else - If MensajeCompra <> "" Then - Alert($"La orden de compra ya esta vinculada y debe darse recepción por medio de su compra:
{MensajeCompra}", TipoMensaje.MsgAdvertencia) - Else - Alert("No se encontro ninguna orden de compra pendiente de recepción de almacén con el folio especificado.", TipoMensaje.MsgAdvertencia) - End If - End If - - UpGenerales.Update() - UPInv.Update() - - End Sub - Private Sub CargaOCPorSurtir(CveOC As Integer) - - 'REINICIALIZA VALORES - DdlMonedaTC.SelectedValueExist("1") - TipoCambio = 0 - DivAdvertencia.Visible = False - EntregaDirecta = False - DivTipoCambio.Visible = False - DivAdvertencia.Visible = False - Apartado = False - BtnGuardar.Enabled = True - CargaAlmacenes(-1) - LtDocumento.Text = "ORDEN DE COMPRA" - CveCompraSurtir = -1 - CvePrePolizaCompra = -1 - - - Dim ObjOC As New ClsOC - Dim ObjInventario As New ClsInventarios - - If ObjOC.GetOC(CveOC, UsuarioActual.CveEmpresa) Then - If ObjOC.DtResultados.Rows.Count > 0 Then - - CveOCSurtir = CveOC - LbProveedor.Text = ObjOC.DtResultados.Rows(0)("RazonSocial").ToString - HLFolio.Text = ObjOC.DtResultados.Rows(0)("Folio").ToString - If UsuarioActual.TienePermisoProceso(201) Then - HLFolio.NavigateUrl = $"/OC/OC.aspx?OC={CveOCSurtir}" - End If - LbDescripcionCompra.Text = ObjOC.DtResultados.Rows(0)("Descripcion").ToString - - CveMoneda = ObjOC.DtResultados.Rows(0)("CveMoneda").ToString.ToEntero - lbDescripcion.Text = ObjOC.DtResultados.Rows(0)("Descripcion").ToString - TotalCompraOC = ObjOC.DtResultados.Rows(0)("SubTotal").ToString.ToDecimal - - 'TipoCambio = ObjOC.DtResultados.Rows(0)("TipoCambio").ToString.ToDecimal - TipoCambio = 0 - TipoMovimiento = 1 - - If ObjInventario.RecepcionAlmacenOCGet(CveOC, UsuarioActual.CveEmpresa) AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then - DtDatosDetalle = Nothing - CreaDtDetalle() - DtDatosLoteDetalle = Nothing - CreaDtLoteDetalle() - CreaDTInv(ObjInventario.DtResultados.FiltraParametros("CantidadCompra = 0")) - BtnGuardar.Visible = True - - - ''MONEDA DIFERENTE - If CveMoneda <> 1 Then - 'DivTipoCambio.Visible = True - DdlMonedaTC.SelectedValueExist("2") - DdlMonedaTC_SelectedIndexChanged(DdlMonedaTC, EventArgs.Empty) - 'TxtTipoCambio.Text = If(TipoCambio <= 0, GlobalTipoCambio(TxtFecha.Text.ToDate).ToString, TipoCambio.ToString) - TipoCambio = If(TipoCambio <= 0, GlobalTipoCambio(TxtFecha.Text.ToDate), TipoCambio) - If TipoCambio > 0 Then - LtAdvertencia.Text = "El cambio de moneda se aplicara al guardar el movimiento con el tipo de cambio indicado." - DivAdvertencia.Visible = True - Else - Alert("Ocurrió un error al cargar el tipo cambio. Por favor comuniquese con asistencia SIG.", TipoMensaje.MsgError) - BtnGuardar.Visible = False - End If - End If - UpTipoCambio.Update() - - DivBitacora.Visible = True - - If UsuarioActual.Empresa.Funcionalidad(132) = "1" Then - DivCodigoSeriePS.Visible = True - Else - DivCodigoSeriePS.Visible = False - End If - CargaGVInv() - - Else - Alert("No hay productos pendientes de surtir de esta orden de compra. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) - HLFolio.Text = "" - HLFolio.NavigateUrl = "#" - LbProveedor.Text = "" - LbDescripcionCompra.Text = "" - DtInv = Nothing - CargaGVInv() - CargaFoliosRecepcion() - End If - End If - Else - BtnGuardar.Visible = False - End If - - ObjOC.Dispose() - ObjInventario.Dispose() - - UpDatosCompra.Update() - +#Region " OC " + Private Sub CargaFoliosOC() + DdlFolioOC.Items.Clear() + + Dim ObjInventarios As New ClsInventarios + If ddlProveedor.SelectedValue.ToEntero > 0 Then + If ObjInventarios.PendientesAlmacenOCGet(ddlProveedor.SelectedValue.ToEntero, MinFecha.ToShortDateString.ToDate, UsuarioActual.CveEmpresa) Then + DdlFolioOC.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() + + DdlFolioOC.DataBind() + DdlFolioOC.Items.Insert(0, New ListItem("Seleccione", "-1")) + + End Sub + Private Sub CargaPendientesOC() + Dim ObjInventarios As New ClsInventarios + Dim DtPendientesOC As New DataTable + + If ObjInventarios.PendientesAlmacenOCGet(ddlProveedor.SelectedValue.ToEntero, TxtFechaPendientes.Text.ToDate, UsuarioActual.CveEmpresa) Then + DtPendientesOC = ObjInventarios.DtResultados + Else + DtPendientesOC = Nothing + Alert("Ocurrió un error al obtener las OC pendientes de recibir del proveedor. Por favor vuelva a intentar", TipoMensaje.MsgError) + End If + + ObjInventarios.Dispose() + + If DtPendientesOC IsNot Nothing Then + GVPendientes.DataSource = DtPendientesOC + End If + + LtActualizado.Text = String.Format("Actualizado: {0}", Now.ToString("H:mm")) + + GVPendientes.DataBind() + UpPendientes.Update() End Sub -#End Region + Protected Sub BtnBuscarOC_Click(sender As Object, e As EventArgs) Handles BtnBuscarOC.Click + CargaOC() + End Sub -#Region " TIPO DE CAMBIO " - Protected Sub DdlMonedaTC_SelectedIndexChanged(sender As Object, e As EventArgs) - Select Case DdlMonedaTC.SelectedValue.ToEntero - Case 1 - TrTC1.Visible = False - TrTC2.Visible = False - - For Each Dr As DataRow In DtInv.Rows - Dr("PU") = Dr("PUExtranjero") - Dr("Total") = Dr("PU").ToString.ToDouble * Dr("Cantidad").ToString.ToDouble - Dr("CostoIndirecto") = Dr("CostoIndirectoExtranjero") - Next - - CargaGVInv() - - 'LtTotal.Text = DtMovimientos.SUM("Total", "").ToString.FormatoNumero - - UPInv.Update() - - Case 2 - TrTC1.Visible = True - TrTC2.Visible = True - End Select - End Sub - Protected Sub BtnAplicarTC_Click(sender As Object, e As EventArgs) - AplicarTipoCambio() - CargaGVInv() - End Sub - Private Sub AplicarTipoCambio() - 'TipoCambio = TxtTipoCambio.Text.ToDouble - - If CveOCSurtir > 0 Then - TipoCambio = GlobalTipoCambio(TxtFecha.Text.ToDate) - End If - - For Each Dr As DataRow In DtInv.Rows - Dr("PU") = Dr("PUExtranjero").ToString.ToDouble * TipoCambio - Dr("Total") = Dr("PU").ToString.ToDouble * Dr("CantidadC").ToString.ToDouble - Dr("CostoIndirecto") = Dr("CostoIndirectoExtranjero").ToString.ToDouble * TipoCambio - Next - DtInv.AcceptChanges() + Private Sub CargaOC() + + 'OBTENE CveOC + Dim CveOC = -1 + Dim MensajeCompra = "" + Dim FolioOC = TxtOC.Text.Trim.ToEntero + Dim ObjOC As New ClsOC + If ObjOC.GetOrdenesCompraRep("OC", -1, -1, -1, -1, MinFecha, MaxFecha, -1, -1, FolioOC, -1, -1, UsuarioActual.CveEmpresa, -1) Then + 'If ObjOC.DtResultados.FiltraParametros("TipoTermino = 3").Rows.Count = 1 Then + If ObjOC.DtResultados.Rows(0)("TieneCompra").ToString.ToEntero > 0 And UsuarioActual.Empresa.Funcionalidad(153).ToEntero > 0 Then 'Or UsuarioActual.Empresa.Funcionalidad(153).ToEntero > 0 + MensajeCompra = String.Format("{1}", ObjOC.DtResultados.Rows(0)("CveCompraVinculada").ToString, ObjOC.DtResultados.Rows(0)("SerieFolioCompraVinculada").ToString) + Else + CveOC = ObjOC.DtResultados.FiltroPrimeroValor("CveOrdenCompra").ToString.ToEntero + End If + 'End If + End If + ObjOC.Dispose() + + RecibidaCompleta = False + If CveOC > 0 Then + CargaOCPorSurtir(CveOC) + Else + If MensajeCompra <> "" Then + Alert($"La orden de compra ya esta vinculada y debe darse recepción por medio de su compra:
{MensajeCompra}", TipoMensaje.MsgAdvertencia) + Else + Alert("No se encontro ninguna orden de compra pendiente de recepción de almacén con el folio especificado.", TipoMensaje.MsgAdvertencia) + End If + End If + + UpGenerales.Update() + UPInv.Update() + + End Sub + Private Sub CargaOCPorSurtir(CveOC As Integer) + + 'REINICIALIZA VALORES + DdlMonedaTC.SelectedValueExist("1") + TipoCambio = 0 + DivAdvertencia.Visible = False + EntregaDirecta = False + DivTipoCambio.Visible = False + DivAdvertencia.Visible = False + Apartado = False + BtnGuardar.Enabled = True + CargaAlmacenes(-1) + LtDocumento.Text = "ORDEN DE COMPRA" + CveCompraSurtir = -1 + CvePrePolizaCompra = -1 + + + Dim ObjOC As New ClsOC + Dim ObjInventario As New ClsInventarios + + If ObjOC.GetOC(CveOC, UsuarioActual.CveEmpresa) Then + If ObjOC.DtResultados.Rows.Count > 0 Then + + CveOCSurtir = CveOC + LbProveedor.Text = ObjOC.DtResultados.Rows(0)("RazonSocial").ToString + HLFolio.Text = ObjOC.DtResultados.Rows(0)("Folio").ToString + If UsuarioActual.TienePermisoProceso(201) Then + HLFolio.NavigateUrl = $"/OC/OC.aspx?OC={CveOCSurtir}" + End If + LbDescripcionCompra.Text = ObjOC.DtResultados.Rows(0)("Descripcion").ToString + + CveMoneda = ObjOC.DtResultados.Rows(0)("CveMoneda").ToString.ToEntero + lbDescripcion.Text = ObjOC.DtResultados.Rows(0)("Descripcion").ToString + TotalCompraOC = ObjOC.DtResultados.Rows(0)("SubTotal").ToString.ToDecimal + + 'TipoCambio = ObjOC.DtResultados.Rows(0)("TipoCambio").ToString.ToDecimal + TipoCambio = 0 + TipoMovimiento = 1 + + If ObjInventario.RecepcionAlmacenOCGet(CveOC, UsuarioActual.CveEmpresa) AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then + DtDatosDetalle = Nothing + CreaDtDetalle() + DtDatosLoteDetalle = Nothing + CreaDtLoteDetalle() + CreaDTInv(ObjInventario.DtResultados.FiltraParametros("CantidadCompra = 0")) + BtnGuardar.Visible = True + + + ''MONEDA DIFERENTE + If CveMoneda <> 1 Then + 'DivTipoCambio.Visible = True + DdlMonedaTC.SelectedValueExist("2") + DdlMonedaTC_SelectedIndexChanged(DdlMonedaTC, EventArgs.Empty) + 'TxtTipoCambio.Text = If(TipoCambio <= 0, GlobalTipoCambio(TxtFecha.Text.ToDate).ToString, TipoCambio.ToString) + TipoCambio = If(TipoCambio <= 0, GlobalTipoCambio(TxtFecha.Text.ToDate), TipoCambio) + If TipoCambio > 0 Then + LtAdvertencia.Text = "El cambio de moneda se aplicara al guardar el movimiento con el tipo de cambio indicado." + DivAdvertencia.Visible = True + Else + Alert("Ocurrió un error al cargar el tipo cambio. Por favor comuniquese con asistencia SIG.", TipoMensaje.MsgError) + BtnGuardar.Visible = False + End If + End If + UpTipoCambio.Update() + + DivBitacora.Visible = True + + If UsuarioActual.Empresa.Funcionalidad(132) = "1" Then + DivCodigoSeriePS.Visible = True + Else + DivCodigoSeriePS.Visible = False + End If + CargaGVInv() + + Else + Alert("No hay productos pendientes de surtir de esta orden de compra. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) + HLFolio.Text = "" + HLFolio.NavigateUrl = "#" + LbProveedor.Text = "" + LbDescripcionCompra.Text = "" + DtInv = Nothing + CargaGVInv() + CargaFoliosRecepcion() + End If + End If + Else + BtnGuardar.Visible = False + End If + + ObjOC.Dispose() + ObjInventario.Dispose() + + UpDatosCompra.Update() + + End Sub + +#End Region + +#Region " TIPO DE CAMBIO " + Protected Sub DdlMonedaTC_SelectedIndexChanged(sender As Object, e As EventArgs) + Select Case DdlMonedaTC.SelectedValue.ToEntero + Case 1 + TrTC1.Visible = False + TrTC2.Visible = False + + For Each Dr As DataRow In DtInv.Rows + Dr("PU") = Dr("PUExtranjero") + Dr("Total") = Dr("PU").ToString.ToDouble * Dr("Cantidad").ToString.ToDouble + Dr("CostoIndirecto") = Dr("CostoIndirectoExtranjero") + Next + + CargaGVInv() + + 'LtTotal.Text = DtMovimientos.SUM("Total", "").ToString.FormatoNumero + + UPInv.Update() + + Case 2 + TrTC1.Visible = True + TrTC2.Visible = True + End Select + End Sub + Protected Sub BtnAplicarTC_Click(sender As Object, e As EventArgs) + AplicarTipoCambio() + CargaGVInv() + End Sub + Private Sub AplicarTipoCambio() + 'TipoCambio = TxtTipoCambio.Text.ToDouble + + If CveOCSurtir > 0 Then + TipoCambio = GlobalTipoCambio(TxtFecha.Text.ToDate) + End If + + For Each Dr As DataRow In DtInv.Rows + Dr("PU") = Dr("PUExtranjero").ToString.ToDouble * TipoCambio + Dr("Total") = Dr("PU").ToString.ToDouble * Dr("CantidadC").ToString.ToDouble + Dr("CostoIndirecto") = Dr("CostoIndirectoExtranjero").ToString.ToDouble * TipoCambio + Next + DtInv.AcceptChanges() End Sub -#End Region +#End Region -#Region " BITACORA " +#Region " BITACORA " - Protected Sub GVEventoBitacora_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvBitacora.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - If e.Row.DBCampo("Archivo").ToString.Trim <> "" AndAlso -1 > 0 Then - e.Row.FCLinkButton("LinkArchivo").Visible = True - e.Row.FCLinkButton("LinkArchivo").CommandArgument = String.Format("OI\{0}", e.Row.DBCampo("Archivo").ToString) - ScriptManager.GetCurrent(Me).RegisterPostBackControl(e.Row.FCLinkButton("LinkArchivo")) 'Registro un evento Postbacktrigger, que recargue toda la pagina para que funcione - End If - - If e.Row.DBCampo("Archivo").ToString.Trim <> "" Then - e.Row.Cells(5).Text = "SI" - Else - e.Row.Cells(5).Text = "NO" - End If - - End If - End Sub - - Private Sub InicializaBitacoraTemporal() - - - DtBitacora = New DataTable - DtBitacora.Columns.Add("FechaIng", GetType(String)) - DtBitacora.Columns.Add("FechaInicio", GetType(String)) - DtBitacora.Columns.Add("Usuario", GetType(String)) - DtBitacora.Columns.Add("CveUsuario", GetType(String)) - DtBitacora.Columns.Add("Descripcion", GetType(String)) - DtBitacora.Columns.Add("Prioridad", GetType(String)) - DtBitacora.Columns.Add("FileExtension", GetType(String)) - DtBitacora.Columns.Add("Archivo", GetType(String)) - DtBitacora.Columns.Add("CveOrdenCompra", GetType(String)) - DtBitacora.Columns.Add("CveEmpresa", GetType(String)) - End Sub - Protected Sub BtnGuardarEventoBitacora_Click(sender As Object, e As EventArgs) Handles BtnGuardarEventoBitacora.Click - AgregaBitacoraTemporal() - End Sub - Private Sub AgregaBitacoraTemporal() - Dim ObjEventoBitacora As New ClsOIEventos - - 'Archivo - Dim FileExtension As String = "" - Dim Filename As String = "" - Dim Filesgral As List(Of Archivo) = Anexo.getfiles().Archivos - - For Each fileItem As Archivo In Filesgral - FileExtension = IO.Path.GetExtension(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", "") - Filename = fileItem.filename - Next - - Dim Archivo As New System.IO.FileInfo(String.Format("{0}OI\Temp\OI{1}{2}.{3}", UsuarioActual.Empresa.Ruta, UsuarioActual.CveUsuario, Now.ToString("HH-mm"), FileExtension)) - If Archivo.Exists() Then - Archivo.Delete() - 'File.Delete(String.Format("\Empresas\{0}\OI\Temp\OI{1}{2}.{3}", CveEmpresaActual, UsuarioActual.CveUsuario, DtDetalle.Rows.Count, FileExtension)) - End If - - If Filename <> "" Then - Filename.FilesMove(String.Format("OI{0}{1}", UsuarioActual.CveUsuario, Now.ToString("HH-mm")), String.Format("Empresas\{0}\OI\Temp", UsuarioActual.CveEmpresa)) - End If - - - 'AGREGA - Dim Dr = DtBitacora.NewRow - Dr("FechaIng") = Now - Dr("FechaInicio") = "" - Dr("Usuario") = UsuarioActual.Usuario - Dr("CveUsuario") = UsuarioActual.CveUsuario - Dr("Descripcion") = TxtEventoDescripcion.Text.Trim - Dr("Prioridad") = 1 - Dr("Archivo") = If(FileExtension = "", "", $"{UsuarioActual.Empresa.Ruta}OI\Temp\OI{UsuarioActual.CveUsuario}{Now.ToString("HH-mm")}.{FileExtension}") - Dr("FileExtension") = String.Format(".{0}", FileExtension) - Dr("CveOrdenCompra") = -1 - Dr("CveEmpresa") = UsuarioActual.CveEmpresa - DtBitacora.Rows.Add(Dr) - - - 'LIMPIA - TxtEventoDescripcion.Text = "" - 'ChkEventoPrioridad.Checked = False - RegistraScript("$('#ModalBitacora').modal('hide')", "hidemodal") - - CargaEventoBitacoraTemp() - - - End Sub - Private Sub CargaEventoBitacoraTemp() - GvBitacora.DataSource = DtBitacora - GvBitacora.DataBind() - UPAddEventoBitacora.Update() - UPEventoBitacora.Update() - End Sub - Private Function GuardaBitacoraTemporal(ObjEventoBitacora As ClsOIEventos, CveMovimiento As Integer) As Boolean - Dim Retorno = False - Dim Archivo As System.IO.FileInfo = Nothing - - For Each Dr As DataRow In DtBitacora.Rows - If ObjEventoBitacora.AddEventoBitacora(Dr("Descripcion").ToString, Dr("FileExtension").ToString, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveMovimientoAlmacen:=CveMovimiento) Then - Try - If Dr("Archivo").ToString <> "" Then - Archivo = New System.IO.FileInfo(Dr("Archivo").ToString) - If Archivo.Exists() Then - File.Move(Archivo.ToString, String.Format("{0}OI\OI{1}{2}", UsuarioActual.Empresa.Ruta, ObjEventoBitacora.CveEvento.ToString, Archivo.Extension)) - End If - End If - Catch ex As Exception - Retorno = True - Alert("Ocurrió un error al guardar los datos adjuntos de la Bitácora.", TipoMensaje.MsgError) - Exit For - End Try - - Else - Retorno = True - Exit For - End If - Next - - Return Retorno + Protected Sub GVEventoBitacora_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvBitacora.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + If e.Row.DBCampo("Archivo").ToString.Trim <> "" AndAlso -1 > 0 Then + e.Row.FCLinkButton("LinkArchivo").Visible = True + e.Row.FCLinkButton("LinkArchivo").CommandArgument = String.Format("OI\{0}", e.Row.DBCampo("Archivo").ToString) + ScriptManager.GetCurrent(Me).RegisterPostBackControl(e.Row.FCLinkButton("LinkArchivo")) 'Registro un evento Postbacktrigger, que recargue toda la pagina para que funcione + End If + + If e.Row.DBCampo("Archivo").ToString.Trim <> "" Then + e.Row.Cells(5).Text = "SI" + Else + e.Row.Cells(5).Text = "NO" + End If + + End If + End Sub + + Private Sub InicializaBitacoraTemporal() + + + DtBitacora = New DataTable + DtBitacora.Columns.Add("FechaIng", GetType(String)) + DtBitacora.Columns.Add("FechaInicio", GetType(String)) + DtBitacora.Columns.Add("Usuario", GetType(String)) + DtBitacora.Columns.Add("CveUsuario", GetType(String)) + DtBitacora.Columns.Add("Descripcion", GetType(String)) + DtBitacora.Columns.Add("Prioridad", GetType(String)) + DtBitacora.Columns.Add("FileExtension", GetType(String)) + DtBitacora.Columns.Add("Archivo", GetType(String)) + DtBitacora.Columns.Add("CveOrdenCompra", GetType(String)) + DtBitacora.Columns.Add("CveEmpresa", GetType(String)) + End Sub + Protected Sub BtnGuardarEventoBitacora_Click(sender As Object, e As EventArgs) Handles BtnGuardarEventoBitacora.Click + AgregaBitacoraTemporal() + End Sub + Private Sub AgregaBitacoraTemporal() + Dim ObjEventoBitacora As New ClsOIEventos + + 'Archivo + Dim FileExtension As String = "" + Dim Filename As String = "" + Dim Filesgral As List(Of Archivo) = Anexo.getfiles().Archivos + + For Each fileItem As Archivo In Filesgral + FileExtension = IO.Path.GetExtension(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", "") + Filename = fileItem.filename + Next + + Dim Archivo As New System.IO.FileInfo(String.Format("{0}OI\Temp\OI{1}{2}.{3}", UsuarioActual.Empresa.Ruta, UsuarioActual.CveUsuario, Now.ToString("HH-mm"), FileExtension)) + If Archivo.Exists() Then + Archivo.Delete() + 'File.Delete(String.Format("\Empresas\{0}\OI\Temp\OI{1}{2}.{3}", CveEmpresaActual, UsuarioActual.CveUsuario, DtDetalle.Rows.Count, FileExtension)) + End If + + If Filename <> "" Then + Filename.FilesMove(String.Format("OI{0}{1}", UsuarioActual.CveUsuario, Now.ToString("HH-mm")), String.Format("Empresas\{0}\OI\Temp", UsuarioActual.CveEmpresa)) + End If + + + 'AGREGA + Dim Dr = DtBitacora.NewRow + Dr("FechaIng") = Now + Dr("FechaInicio") = "" + Dr("Usuario") = UsuarioActual.Usuario + Dr("CveUsuario") = UsuarioActual.CveUsuario + Dr("Descripcion") = TxtEventoDescripcion.Text.Trim + Dr("Prioridad") = 1 + Dr("Archivo") = If(FileExtension = "", "", $"{UsuarioActual.Empresa.Ruta}OI\Temp\OI{UsuarioActual.CveUsuario}{Now.ToString("HH-mm")}.{FileExtension}") + Dr("FileExtension") = String.Format(".{0}", FileExtension) + Dr("CveOrdenCompra") = -1 + Dr("CveEmpresa") = UsuarioActual.CveEmpresa + DtBitacora.Rows.Add(Dr) + + + 'LIMPIA + TxtEventoDescripcion.Text = "" + 'ChkEventoPrioridad.Checked = False + RegistraScript("$('#ModalBitacora').modal('hide')", "hidemodal") + + CargaEventoBitacoraTemp() + + + End Sub + Private Sub CargaEventoBitacoraTemp() + GvBitacora.DataSource = DtBitacora + GvBitacora.DataBind() + UPAddEventoBitacora.Update() + UPEventoBitacora.Update() + End Sub + Private Function GuardaBitacoraTemporal(ObjEventoBitacora As ClsOIEventos, CveMovimiento As Integer) As Boolean + Dim Retorno = False + Dim Archivo As System.IO.FileInfo = Nothing + + For Each Dr As DataRow In DtBitacora.Rows + If ObjEventoBitacora.AddEventoBitacora(Dr("Descripcion").ToString, Dr("FileExtension").ToString, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveMovimientoAlmacen:=CveMovimiento) Then + Try + If Dr("Archivo").ToString <> "" Then + Archivo = New System.IO.FileInfo(Dr("Archivo").ToString) + If Archivo.Exists() Then + File.Move(Archivo.ToString, String.Format("{0}OI\OI{1}{2}", UsuarioActual.Empresa.Ruta, ObjEventoBitacora.CveEvento.ToString, Archivo.Extension)) + End If + End If + Catch ex As Exception + Retorno = True + Alert("Ocurrió un error al guardar los datos adjuntos de la Bitácora.", TipoMensaje.MsgError) + Exit For + End Try + + Else + Retorno = True + Exit For + End If + Next + + Return Retorno End Function -#End Region +#End Region + +#Region " FINANCIAMIENTO - AC " + Protected Sub CargaAC() + Dim Cont As New ClsContPAQi(UsuarioActual.Empresa) + Dim DtAC As DataTable = Nothing + If Cont.GetACSaldos(UsuarioActual.Empresa.EjercicioActual, 2) Then + DtAC = Cont.DtResultados.Copy.FiltraParametros("PorDevengar > 0") + Else + Alert("Ocurrió un error al cargar los Presupuestos. Por favor vuelva a cargar la página", TipoMensaje.MsgError) + End If + + Cont.Dispose() + GvAC.DataSource = DtAC + GvAC.DataBind() + + Dim Total As Double = GvAC.Rows.Cast(Of GridViewRow)().Sum(Function(gvr) gvr.DataKey("PorDevengar").ToDouble) + + Lbtotalsaldo.Text = Total.ToString.FormatoNumero + UPPM.Update() -#Region " FINANCIAMIENTO - AC " - Protected Sub CargaAC() - Dim Cont As New ClsContPAQi(UsuarioActual.Empresa) - Dim DtAC As DataTable = Nothing - If Cont.GetACSaldos(UsuarioActual.Empresa.EjercicioActual, 2) Then - DtAC = Cont.DtResultados.Copy.FiltraParametros("PorDevengar > 0") - Else - Alert("Ocurrió un error al cargar los Presupuestos. Por favor vuelva a cargar la página", TipoMensaje.MsgError) - End If - - Cont.Dispose() - GvAC.DataSource = DtAC - GvAC.DataBind() - - Dim Total As Double = GvAC.Rows.Cast(Of GridViewRow)().Sum(Function(gvr) gvr.DataKey("PorDevengar").ToDouble) - - Lbtotalsaldo.Text = Total.ToString.FormatoNumero - UPPM.Update() - - End Sub - - Protected Sub GvAC_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvAC.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - e.Row.FCTextBox("TxtImporte").Attributes.Add("onkeyup", String.Format("ValidaImporte(this, {0});", e.Row.DBCampo("PorDevengar"))) - e.Row.FCRangeValidator("RVA").MaximumValue = e.Row.DBCampo("PorDevengar").FormatoNumero - End If End Sub -#End Region - -#Region " ENVIA CORREO NOTICIACION - VENDEDOR " - Private Sub MandaCorreoOCVendedores(CveCompra As Integer, CveMovimiento As Integer) - - 'SI NO TIENE FUNCIONALIDAD DATOS DE VENTA EN OC - If Not UsuarioActual.Empresa.Funcionalidad(108) = "1" Then - Exit Sub - End If - - Dim DTCorreos As New DataTable - Dim DTMovimientos As New DataTable - Dim strBody As New StringBuilder - Dim Asunto, Para, ArrayCC, Body As String - - Dim ObjOC As New ClsOC - ObjOC.GetOrdenesCompraCorreo(CveCompra, CveMovimiento:=CveMovimiento) - DTCorreos = ObjOC.DtResultados - ObjOC.GetOrdenesCompraMovimiento(CveCompra, CveMovimiento:=CveMovimiento) - DTMovimientos = ObjOC.DtResultados - ObjOC.Dispose() - - - For Each row As DataRow In DTCorreos.Rows - - strBody.Clear() - - 'SI DE UNA OC DE LA COMPRA NO SE RECIBIÓ NADA NO MANDA CORREO - If DTMovimientos.FiltraParametros($"CveOrdenCompra = {row("CveOrdenCompra")}").Rows.Count = 0 Then - Continue For - End If - - strBody.Append(" ") - strBody.Append(" ") - strBody.Append(" ") - strBody.Append(" ") - strBody.Append("") - strBody.Append("

Notificación de recepción de material

") - strBody.Append("

") - strBody.AppendFormat(" Se confirma recepción de material en almacén {0} vinculado la OC # {1} {2}.", DdlAlmacen.SelectedItem.Text, row("Folio").ToString, If(row("FolioREQ").ToString.Length > 0, $", relacionada a la(s) requisicion(es) # {row("FolioREQ")}", "")) - strBody.Append("
") - strBody.Append(" Con los siguientes productos:") - strBody.Append("

") - - 'DETALLES - strBody.Append(" ") - strBody.Append(" ") - strBody.Append(" ") - strBody.Append(" ") - strBody.Append(" ") - strBody.Append(" ") - strBody.Append(" ") - strBody.Append(" ") - - For Each RowM As DataRow In DTMovimientos.FiltraParametros($"CveOrdenCompra = {row("CveOrdenCompra")}").Rows - strBody.AppendFormat(" ") - strBody.AppendFormat(" ", RowM("Cantidad").ToString.FormatoNumero) - strBody.AppendFormat(" ", RowM("UnidadMedida")) - strBody.AppendFormat(" ", RowM("Codigo")) - strBody.AppendFormat(" ", RowM("PS")) - strBody.AppendFormat(" ") - Next - - strBody.Append("
CantidadUMCódigoProducto
{0}{0}{0}{0}
") - strBody.Append("") - strBody.Append("") - - '' ENVIO DEL CORREO - Asunto = "Recepción de Material de OC " - Para = row("Correo").ToString - ArrayCC = row("CorreoAsistente").ToString - Body = strBody.ToString - Dim Mail As New ClsSisMail() - Mail.SendMail(ClsPaginas.EmpresaNotificaciones, Para, Asunto, Body, ArrayCC) - Next - - + Protected Sub GvAC_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvAC.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + e.Row.FCTextBox("TxtImporte").Attributes.Add("onkeyup", String.Format("ValidaImporte(this, {0});", e.Row.DBCampo("PorDevengar"))) + e.Row.FCRangeValidator("RVA").MaximumValue = e.Row.DBCampo("PorDevengar").FormatoNumero + End If End Sub -#End Region -#Region "Imprimir PDF/Excel" +#End Region + +#Region " ENVIA CORREO NOTICIACION - VENDEDOR " + Private Sub MandaCorreoOCVendedores(CveCompra As Integer, CveMovimiento As Integer) + + 'SI NO TIENE FUNCIONALIDAD DATOS DE VENTA EN OC + If Not UsuarioActual.Empresa.Funcionalidad(108) = "1" Then + Exit Sub + End If + + Dim DTCorreos As New DataTable + Dim DTMovimientos As New DataTable + Dim strBody As New StringBuilder + Dim Asunto, Para, ArrayCC, Body As String + + Dim ObjOC As New ClsOC + ObjOC.GetOrdenesCompraCorreo(CveCompra, CveMovimiento:=CveMovimiento) + DTCorreos = ObjOC.DtResultados + ObjOC.GetOrdenesCompraMovimiento(CveCompra, CveMovimiento:=CveMovimiento) + DTMovimientos = ObjOC.DtResultados + ObjOC.Dispose() + + + For Each row As DataRow In DTCorreos.Rows + + strBody.Clear() + + 'SI DE UNA OC DE LA COMPRA NO SE RECIBIÓ NADA NO MANDA CORREO + If DTMovimientos.FiltraParametros($"CveOrdenCompra = {row("CveOrdenCompra")}").Rows.Count = 0 Then + Continue For + End If + + strBody.Append(" ") + strBody.Append(" ") + strBody.Append(" ") + strBody.Append(" ") + strBody.Append("") + strBody.Append("

Notificación de recepción de material

") + strBody.Append("

") + strBody.AppendFormat(" Se confirma recepción de material en almacén {0} vinculado la OC # {1} {2}.", DdlAlmacen.SelectedItem.Text, row("Folio").ToString, If(row("FolioREQ").ToString.Length > 0, $", relacionada a la(s) requisicion(es) # {row("FolioREQ")}", "")) + strBody.Append("
") + strBody.Append(" Con los siguientes productos:") + strBody.Append("

") + + 'DETALLES + strBody.Append(" ") + strBody.Append(" ") + strBody.Append(" ") + strBody.Append(" ") + strBody.Append(" ") + strBody.Append(" ") + strBody.Append(" ") + strBody.Append(" ") + + For Each RowM As DataRow In DTMovimientos.FiltraParametros($"CveOrdenCompra = {row("CveOrdenCompra")}").Rows + strBody.AppendFormat(" ") + strBody.AppendFormat(" ", RowM("Cantidad").ToString.FormatoNumero) + strBody.AppendFormat(" ", RowM("UnidadMedida")) + strBody.AppendFormat(" ", RowM("Codigo")) + strBody.AppendFormat(" ", RowM("PS")) + strBody.AppendFormat(" ") + Next + + strBody.Append("
CantidadUMCódigoProducto
{0}{0}{0}{0}
") + strBody.Append("") + strBody.Append("") + + '' ENVIO DEL CORREO + Asunto = "Recepción de Material de OC " + Para = row("Correo").ToString + ArrayCC = row("CorreoAsistente").ToString + Body = strBody.ToString + Dim Mail As New ClsSisMail() + Mail.SendMail(ClsPaginas.EmpresaNotificaciones, Para, Asunto, Body, ArrayCC) + Next + + + End Sub +#End Region + +#Region "Imprimir PDF/Excel" + + Private Sub LnkExportar_Click(sender As Object, e As EventArgs) Handles LnkExportar.Click + ImprimiReporte("EXCEL") + End Sub + Private Sub LnkImprimir_Click(sender As Object, e As EventArgs) Handles LnkImprimir.Click + ImprimiReporte() + End Sub + Protected Sub ImprimiReporte(Optional Formato As String = "PDF") + + Dim Proveedor As String = ddlProveedor.SelectedText + Dim Compra As String = DdlFolio.SelectedItem.Text + + Dim RutaPDF As String + Dim Ruta As String = $"{AppDomain.CurrentDomain.BaseDirectory}Empresas\{UsuarioActual.CveEmpresa}\" + RutaPDF = $"{Ruta}\Formatos\EntradaAlmacen.rdlc" + If Not File.Exists(RutaPDF) Then + RutaPDF = "Empresas/Grales/Formatos/EntradaAlmacen.rdlc" + End If + Dim params As New List(Of ReportParameter) + params.Add(New ReportParameter("pEmp", UsuarioActual.Empresa.Empresa)) + params.Add(New ReportParameter("pImg", New Uri(Server.MapPath(String.Format("~/Empresas/{0}/Logo.png", UsuarioActual.CveEmpresa))).AbsoluteUri)) + params.Add(New ReportParameter("Proveedor", Proveedor)) + params.Add(New ReportParameter("Compra", Compra)) + params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre)) + params.Add(New ReportParameter("FechaImpresion", Now.ToDateTime.ToShortDateString)) + ImprimirPDF(RutaPDF, dt, params, "Reporte de Entrada Almacén", Formato:=Formato) - Private Sub LnkExportar_Click(sender As Object, e As EventArgs) Handles LnkExportar.Click - ImprimiReporte("EXCEL") - End Sub - Private Sub LnkImprimir_Click(sender As Object, e As EventArgs) Handles LnkImprimir.Click - ImprimiReporte() - End Sub - Protected Sub ImprimiReporte(Optional Formato As String = "PDF") - - Dim Proveedor As String = ddlProveedor.SelectedText - Dim Compra As String = DdlFolio.SelectedItem.Text - - Dim RutaPDF As String - Dim Ruta As String = $"{AppDomain.CurrentDomain.BaseDirectory}Empresas\{UsuarioActual.CveEmpresa}\" - RutaPDF = $"{Ruta}\Formatos\EntradaAlmacen.rdlc" - If Not File.Exists(RutaPDF) Then - RutaPDF = "Empresas/Grales/Formatos/EntradaAlmacen.rdlc" - End If - Dim params As New List(Of ReportParameter) - params.Add(New ReportParameter("pEmp", UsuarioActual.Empresa.Empresa)) - params.Add(New ReportParameter("pImg", New Uri(Server.MapPath(String.Format("~/Empresas/{0}/Logo.png", UsuarioActual.CveEmpresa))).AbsoluteUri)) - params.Add(New ReportParameter("Proveedor", Proveedor)) - params.Add(New ReportParameter("Compra", Compra)) - params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre)) - params.Add(New ReportParameter("FechaImpresion", Now.ToDateTime.ToShortDateString)) - ImprimirPDF(RutaPDF, dt, params, "Reporte de Entrada Almacén", Formato:=Formato) - End Sub -#End Region +#End Region + +#Region " VIEJO - POR ELIMINAR 22 NOVIEMBRE 2017 " + Protected Sub ImgAlmacen_Click(sender As Object, e As ImageClickEventArgs) + For i As Integer = 0 To GvInv.Rows.Count - 1 + If Not DtInv.Rows(i)("CantidadF").ToString.ToEntero = 0 Then + DtInv.Rows(i)("CveAlmacen") = GvInv.HeaderRow.FCDropDownList("ddlPAlmacen").SelectedValue + End If + Next + CargaGVInv() + End Sub + Private Sub AddDTEnvio(Cantidad As Double, UM As String, CveUM As Integer, CvePS As Integer, PS As String, PU As Double, CveAlmacen As Integer) + + Dim dr As DataRow = DtInv.NewRow + + dr("CantidadF") = Cantidad + + dr("UM") = UM + dr("CveUM") = CveUM + dr("CvePS") = CvePS + dr("PS") = PS + dr("PU") = PU + dr("CveAlmacen") = CveAlmacen + + + DtInv.Rows.InsertAt(dr, hdnIndexInv.Value.ToEntero + 1) + CargaGVInv() + + End Sub + Protected Sub Enviar_Click(sender As Object, e As ImageClickEventArgs) Handles ImgAdd.Click + If TbCantidadAlm.Text.ToDouble < DtInv.Rows.Item(hdnIndexInv.Value.ToEntero)("CantidadF").ToString.ToDouble And TbCantidadAlm.Text.ToDouble > 0 Then + + DtInv.Rows.Item(hdnIndexInv.Value.ToEntero)("CantidadF") = DtInv.Rows.Item(hdnIndexInv.Value.ToEntero)("CantidadF").ToString.ToDouble - TbCantidadAlm.Text.ToDouble + AddDTEnvio(TbCantidadAlm.Text.ToDouble, + DtInv.Rows.Item(hdnIndexInv.Value.ToEntero)("UM").ToString, + DtInv.Rows.Item(hdnIndexInv.Value.ToEntero)("CveUM").ToString.ToEntero, + DtInv.Rows.Item(hdnIndexInv.Value.ToEntero)("CvePS").ToString().ToEntero, + DtInv.Rows.Item(hdnIndexInv.Value.ToEntero)("PS").ToString, + DtInv.Rows.Item(hdnIndexInv.Value.ToEntero)("PU").ToString.ToDouble, + ddlAlmacenAdd.SelectedValue.ToEntero) + + Else + Alert("El campo cantidad es necesario que sea mayor que 0 y menor a la cantidad faltante.", TipoMensaje.MsgAdvertencia) + End If + CargaGVInv() + TbCantidadAlm.Text = "" + ddlAlmacenAdd.SelectedIndex = 0 -#Region " VIEJO - POR ELIMINAR 22 NOVIEMBRE 2017 " - Protected Sub ImgAlmacen_Click(sender As Object, e As ImageClickEventArgs) - For i As Integer = 0 To GvInv.Rows.Count - 1 - If Not DtInv.Rows(i)("CantidadF").ToString.ToEntero = 0 Then - DtInv.Rows(i)("CveAlmacen") = GvInv.HeaderRow.FCDropDownList("ddlPAlmacen").SelectedValue - End If - Next - CargaGVInv() - End Sub - Private Sub AddDTEnvio(Cantidad As Double, UM As String, CveUM As Integer, CvePS As Integer, PS As String, PU As Double, CveAlmacen As Integer) - - Dim dr As DataRow = DtInv.NewRow - - dr("CantidadF") = Cantidad - - dr("UM") = UM - dr("CveUM") = CveUM - dr("CvePS") = CvePS - dr("PS") = PS - dr("PU") = PU - dr("CveAlmacen") = CveAlmacen - - - DtInv.Rows.InsertAt(dr, hdnIndexInv.Value.ToEntero + 1) - CargaGVInv() - - End Sub - Protected Sub Enviar_Click(sender As Object, e As ImageClickEventArgs) Handles ImgAdd.Click - If TbCantidadAlm.Text.ToDouble < DtInv.Rows.Item(hdnIndexInv.Value.ToEntero)("CantidadF").ToString.ToDouble And TbCantidadAlm.Text.ToDouble > 0 Then - - DtInv.Rows.Item(hdnIndexInv.Value.ToEntero)("CantidadF") = DtInv.Rows.Item(hdnIndexInv.Value.ToEntero)("CantidadF").ToString.ToDouble - TbCantidadAlm.Text.ToDouble - AddDTEnvio(TbCantidadAlm.Text.ToDouble, - DtInv.Rows.Item(hdnIndexInv.Value.ToEntero)("UM").ToString, - DtInv.Rows.Item(hdnIndexInv.Value.ToEntero)("CveUM").ToString.ToEntero, - DtInv.Rows.Item(hdnIndexInv.Value.ToEntero)("CvePS").ToString().ToEntero, - DtInv.Rows.Item(hdnIndexInv.Value.ToEntero)("PS").ToString, - DtInv.Rows.Item(hdnIndexInv.Value.ToEntero)("PU").ToString.ToDouble, - ddlAlmacenAdd.SelectedValue.ToEntero) - - Else - Alert("El campo cantidad es necesario que sea mayor que 0 y menor a la cantidad faltante.", TipoMensaje.MsgAdvertencia) - End If - CargaGVInv() - TbCantidadAlm.Text = "" - ddlAlmacenAdd.SelectedIndex = 0 - End Sub -#End Region +#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("SeccionAlmacen", GetType(String)) - DtSeccionAlmacen.Columns.Add("Consec", GetType(Integer)) - End Sub - Private Sub CargaDdlAlmacen() - DdlSeccionAlmacen.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa) - 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) - CantidadTotal = gvRow.FCTextBox("TbCantidadF").Text.ToDecimal - IndexSeccionAlmacen = gvRow.RowIndex - CargaSeccionAlmacen() - RegistraScript("$('#DModalSeccionAlmacen').modal()") - End Sub - - Private Sub CargaSeccionAlmacen() - Dim CantidadTotalSeccion As Decimal = DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {IndexSeccionAlmacen}").SUMD("CantidadSeccionAlmacen") - GvSeccionAlmacen.DataSource = DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {IndexSeccionAlmacen}") - GvSeccionAlmacen.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 - GvInv.Rows(IndexSeccionAlmacen).FCTextBox("TbCantidadF").Enabled = False - GvInv.Rows(IndexSeccionAlmacen).FCTextBox("TbCantidadF").ToolTip = "Cuenta con sección almacen" - Else - GvInv.Rows(IndexSeccionAlmacen).FCTextBox("TbCantidadF").Enabled = True - GvInv.Rows(IndexSeccionAlmacen).FCTextBox("TbCantidadF").ToolTip = "" - End If - UpModalSeccionAlmacen.Update() - UPInv.Update() - End Sub - - Protected Sub LnkAddSeccionAlmacen_Click(sender As Object, e As EventArgs) - 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("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() +#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("SeccionAlmacen", GetType(String)) + DtSeccionAlmacen.Columns.Add("Consec", GetType(Integer)) + End Sub + Private Sub CargaDdlAlmacen() + DdlSeccionAlmacen.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa) + 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) + CantidadTotal = gvRow.FCTextBox("TbCantidadF").Text.ToDecimal + IndexSeccionAlmacen = gvRow.RowIndex + CargaSeccionAlmacen() + RegistraScript("$('#DModalSeccionAlmacen').modal()") End Sub -#End Region + Private Sub CargaSeccionAlmacen() + Dim CantidadTotalSeccion As Decimal = DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {IndexSeccionAlmacen}").SUMD("CantidadSeccionAlmacen") + GvSeccionAlmacen.DataSource = DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {IndexSeccionAlmacen}") + GvSeccionAlmacen.DataBind() -End Class + 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 + GvInv.Rows(IndexSeccionAlmacen).FCTextBox("TbCantidadF").Enabled = False + GvInv.Rows(IndexSeccionAlmacen).FCTextBox("TbCantidadF").ToolTip = "Cuenta con sección almacen" + Else + GvInv.Rows(IndexSeccionAlmacen).FCTextBox("TbCantidadF").Enabled = True + GvInv.Rows(IndexSeccionAlmacen).FCTextBox("TbCantidadF").ToolTip = "" + End If + UpModalSeccionAlmacen.Update() + UPInv.Update() + End Sub + + Protected Sub LnkAddSeccionAlmacen_Click(sender As Object, e As EventArgs) + 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("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 + +#End Region + +End Class diff --git a/Inventarios/RecepcionEntrega.aspx.vb b/Inventarios/RecepcionEntrega.aspx.vb index afcd7d2e8..50ee62e69 100644 --- a/Inventarios/RecepcionEntrega.aspx.vb +++ b/Inventarios/RecepcionEntrega.aspx.vb @@ -1844,7 +1844,7 @@ Partial Class Inventarios_RecepcionEntrega 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.ToDouble, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString) Then + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntradaApartado, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString) Then ErrorMovInv = True TextoError = "Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar." Exit For @@ -1878,7 +1878,7 @@ Partial Class Inventarios_RecepcionEntrega 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 Double = RowGarantia("Importe").ToString().ToDouble() ' / RowGarantia("Cantidad").ToString().ToDouble() + Dim PU As Decimal = RowGarantia("Importe").ToString().ToDecimal() ' / RowGarantia("Cantidad").ToString().ToDouble() If Not ObjInventario.AddMovimientoDetalle(CveMovimientoGarantia, RowGarantia("Cantidad").ToString().ToDouble(), CveUM, CvePS, PU, -1) Then ErrorMovInv = True @@ -1942,7 +1942,7 @@ Partial Class Inventarios_RecepcionEntrega 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.ToDouble, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString) Then + If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString) Then ErrorMovInv = True TextoError = "Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar." Exit For @@ -2033,7 +2033,7 @@ Partial Class Inventarios_RecepcionEntrega 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.ToDouble, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, EsInterno:=EsInterno, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero()) Then + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, EsInterno:=EsInterno, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero()) Then ErrorMovInv = True TextoError = "Ocurrió un error al guardar los movimientos de entrada" Exit For @@ -2298,7 +2298,7 @@ Partial Class Inventarios_RecepcionEntrega 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 Double = RowUsado("PU").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, -1) Then diff --git a/Inventarios/RecepcionUsados.aspx.vb b/Inventarios/RecepcionUsados.aspx.vb index 46e950f43..07a1b7403 100644 --- a/Inventarios/RecepcionUsados.aspx.vb +++ b/Inventarios/RecepcionUsados.aspx.vb @@ -190,11 +190,11 @@ Partial Class Inventarios_RecepcionUsados ViewState("UMSerieLote") = value End Set End Property - Private Property CostoPromedioSerieLote As Double + Private Property CostoPromedioSerieLote As Decimal Get - Return CType(ViewState("CostoPromedioSerieLote"), Double) + Return CType(ViewState("CostoPromedioSerieLote"), Decimal) End Get - Set(value As Double) + Set(value As Decimal) ViewState("CostoPromedioSerieLote") = value End Set End Property @@ -1070,7 +1070,7 @@ Partial Class Inventarios_RecepcionUsados Dim ErrorMovInv As Boolean = False Dim ErrorAC As Boolean = False Dim IDPoliza As Integer = 0 - Dim ImporteConcepto = 0.0 + Dim ImporteConcepto As Decimal = 0 Try Dim CveSubProyecto = -1 @@ -1128,9 +1128,9 @@ Partial Class Inventarios_RecepcionUsados For Each Dr As DataRow In DtMovimientos.Rows If CveConcepto = 42 AndAlso DdlMoneda.SelectedValue.ToEntero = 2 Then - ImporteConcepto = Dr("PU").ToString.ToDouble * GlobalTipoCambio(TxtFecha.Text.ToDate) + ImporteConcepto = Dr("PU").ToString.ToDecimal * GlobalTipoCambio(TxtFecha.Text.ToDate).ToDecimal Else - ImporteConcepto = Dr("PU").ToString.ToDouble + ImporteConcepto = Dr("PU").ToString.ToDecimal End If If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, ImporteConcepto, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, Dr("Observaciones").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then @@ -1236,11 +1236,11 @@ Partial Class Inventarios_RecepcionUsados TxtCodigoSerie.Focus() CvePSSerieLote = DrPS("CvePS").ToString.ToEntero CveUMSerieLote = DrPS("CveUnidadMedida").ToString.ToEntero - CostoPromedioSerieLote = DrPS("CostoPromedio").ToString.ToDouble + CostoPromedioSerieLote = DrPS("CostoPromedio").ToString.ToDecimal Exit Sub End If - GuardaCodigoSerie(TxtCantidadProducto.Text.ToDouble, DrPS("CvePS").ToString.ToEntero, DrPS("CveUnidadMedida").ToString.ToEntero, DrPS("CostoPromedio").ToString.ToDouble) + GuardaCodigoSerie(TxtCantidadProducto.Text.ToDouble, DrPS("CvePS").ToString.ToEntero, DrPS("CveUnidadMedida").ToString.ToEntero, DrPS("CostoPromedio").ToString.ToDecimal) TxtCodigoBarras.Text = "" TxtCodigoBarras.Focus() @@ -1258,14 +1258,14 @@ Partial Class Inventarios_RecepcionUsados Dim DrP = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimero($"Codigo= '{TxtCodigo.Text.Trim}'") If DrP IsNot Nothing AndAlso DrP("CvePS").ToString.ToEntero > 0 Then - GuardaCodigoSerie(TxtCantidadProducto.Text.ToDouble, DrP("CvePS").ToString.ToEntero, DrP("CveUnidadMedida").ToString.ToEntero, DrP("CostoPromedio").ToString.ToDouble) + GuardaCodigoSerie(TxtCantidadProducto.Text.ToDouble, DrP("CvePS").ToString.ToEntero, DrP("CveUnidadMedida").ToString.ToEntero, DrP("CostoPromedio").ToString.ToDecimal) Else Alert("No se encontró el producto. Favor de verificar y volver a intentar.", TipoMensaje.MsgError, "window.setTimeout(Focus2,200);") End If End Sub - Private Sub GuardaCodigoSerie(Cantidad As Double, CvePS As Integer, CveUM As Integer, CostoPromedio As Double, Optional SerieLote As String = "-1") + Private Sub GuardaCodigoSerie(Cantidad As Double, CvePS As Integer, CveUM As Integer, CostoPromedio As Decimal, Optional SerieLote As String = "-1") Dim ObjInv As New ClsInventarios If CveMovimiento <= 0 Then @@ -2159,223 +2159,223 @@ Partial Class Inventarios_RecepcionUsados End Sub - Private Function AddPSRNC(ByRef TmpDT As DataTable, Cantidad As Decimal, CveUM As Integer, UM As String, CveClasificacion As Integer, Clasificacion As String, CvePS As Integer, PS As String, Obs As String, - PU As Decimal, Descuento As Decimal, - CveProyecto As Integer, Proyecto As String, CveSubProyecto As Integer, SubProyecto As String, - Optional SerieLote As String = "", Optional TiempoEntrega As String = "", Optional EntregaDirecta As Integer = 0, - Optional CveContratoDetalle As Integer = 0, Optional CveVentaDetalle As Integer = 0, Optional CveMovimientoDetallePedido As Integer = 0, - Optional CveOrdenCompraDetalle As Integer = 0, Optional CveVentaDetalleRemision As Integer = 0, Optional CveVentaDetalleCotizacion As Integer = 0, - Optional CuentaPredial As String = "", Optional RegeneraIEPS As Boolean = True, Optional CveVentaDetallePedido2 As Integer = 0, Optional EsCargo As Boolean = False, Optional PorcentajeIVA As Decimal = 0D, Optional CveTamaño As Integer = 0) As Boolean - - Dim Retorno As Boolean = False - If Not CvePS > 0 Then - Alert("Ocurrió un error al cargar la información del producto a agregar. Por favor verifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) - Return False - End If - - If (Obs.Length + PS.Length > 1000) Then - Alert(String.Format("El Nombre y observación del producto tiene longitud de {0} caracteres y excede los 1000 caracteres permitidos.", Obs.Length + PS.Length), TipoMensaje.MsgAdvertencia) - Return False - End If - - - Dim Row As DataRow = Nothing - Dim TotalCalculableImpuestos As Decimal = 0 - PU = Math.Round(PU, 6) ' el precio unitario puede llevar hasta 6 decimales permitidos - - Row = TmpDT.NewRow() - Row("CveProyecto") = CveProyecto - Row("Proyecto") = Proyecto - Row("CveSubProyecto") = CveSubProyecto - Row("SubProyecto") = SubProyecto - Row("SerieLote") = SerieLote - Row("TiempoEntrega") = TiempoEntrega - Row("Orden") = TmpDT.Rows.Count + 1 - Row("Cantidad") = Cantidad - Row("CveUM") = CveUM - Row("UM") = UM - Row("CveClasificacion") = CveClasificacion - Row("Clasificacion") = Clasificacion - Row("CvePS") = CvePS - Row("Obs") = Obs - - - - Dim DrPS As DataRow = Nothing - - DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("") ' Estado = -1 - - If DrPS Is Nothing Then - Alert("Ocurrió un error al cargar la información del Producto. Por favor vuelva a intentar.", TipoMensaje.MsgAdvertencia) - Return False - End If - - - DrPS("IEPSPorcentaje") = 0 - - 'verifica si tiene ventaminima - If Cantidad > 0 AndAlso DrPS("VentaMinima").ToString.ToDecimal > 0 Then - 'verifico que la cantidad sea multiplo de venta minima, es decir ventaminima =5, solo puede vender 5,10,15... - If Cantidad Mod DrPS("VentaMinima").ToString.ToDecimal <> 0 Then - Alert(String.Format("El producto se vende solo en cantidades de {0}", DrPS("VentaMinima").ToString)) - Return False - End If - End If - - TotalCalculableImpuestos = (Cantidad * (PU)) - Descuento - - Row("PU") = PU - Row("Codigo") = DrPS("Codigo") - Row("NoIdentificacion") = DrPS("Codigo") - Row("ClaveSATFraccionArancelaria") = DrPS("ClaveSATFraccionArancelaria") - Row("ClaveSATUnidadAduana") = DrPS("ClaveSATUnidadAduana") - Row("ClaveSATFraccionArancelariaDescripcion") = DrPS("ClaveSATFraccionArancelariaDescripcion") - Row("ClaveSATUnidadAduanaDescripcion") = DrPS("ClaveSATUnidadAduanaDescripcion") - Row("Consec") = TmpDT.Rows.Count + 1 - - Row("PS") = DrPS("PS") - Row("CodigoPS") = DrPS("PSCodigo").ToString - Row("CveTipoPS") = DrPS("CveTipoPS") - Row("CveTipoInvPS") = DrPS("Inv_CveMetodoInventario") - Row("CveTamaño") = DrPS("CveTamaño") - - If CveClasificacion <= 0 Then Row("CveClasificacion") = DrPS("CveClasificacion") - If Clasificacion = "" Then Row("Clasificacion") = DrPS("Clasificacion") - - Row("PorcentajeIVA") = PorcentajeIVA - - Row("IVA") = Row("PorcentajeIVA") - Row("ImporteIVA") = Math.Round(Row("PorcentajeIVA").ToString.ToDecimal * TotalCalculableImpuestos, 2) - - - Row("ImporteRetIVA") = 0 - Row("ImporteRetISR") = 0 - Row("PorcentajeRetIVA") = 0 - Row("PorcentajeRetISR") = 0 - Row("PorcentajeIEPS") = DrPS("IEPSPorcentaje") - Row("ImporteIEPS") = Math.Round(DrPS("IEPSPorcentaje").ToString.ToDecimal * TotalCalculableImpuestos, 2) - Row("IEPS") = Row("ImporteIEPS") - Row("Descuento") = Math.Round(Descuento, 2) - Row("TipoDescuento") = 0 - Row("Total") = (Cantidad * PU) - Row("TotalImporte") = Math.Round(Cantidad * PU, 2) - 'Row("AsientoContableVentas") = DrPS("AsientoContableVentas") - ' Row("IdCtaContVentas") = IdCtaContable - ' Row("AplicaParaConcepto") = AplicaParaConcepto - - Row("SATClaveProdServ") = DrPS("SATClavePS") - Row("SATClaveUM") = DrPS("SATClaveUnidadMedida") - - - Row("EntregaDirecta") = EntregaDirecta - 'Contratos - Row("CveContratoDetalle") = CveContratoDetalle - Row("CveVentaDetalle") = CveVentaDetalle - Row("CveMovimientoDetallePedido") = CveVentaDetalle - Row("CveOrdenCompraDetalle") = CveOrdenCompraDetalle - Row("CveVentaDetalleRemision") = CveVentaDetalleRemision - Row("CveVentaDetalleCotizacion") = CveVentaDetalleCotizacion - Row("CveVentaDetallePedido2") = CveVentaDetallePedido2 - Row("CuentaPredial") = CuentaPredial - Row("EsCargo") = EsCargo + Private Function AddPSRNC(ByRef TmpDT As DataTable, Cantidad As Decimal, CveUM As Integer, UM As String, CveClasificacion As Integer, Clasificacion As String, CvePS As Integer, PS As String, Obs As String, + PU As Decimal, Descuento As Decimal, + CveProyecto As Integer, Proyecto As String, CveSubProyecto As Integer, SubProyecto As String, + Optional SerieLote As String = "", Optional TiempoEntrega As String = "", Optional EntregaDirecta As Integer = 0, + Optional CveContratoDetalle As Integer = 0, Optional CveVentaDetalle As Integer = 0, Optional CveMovimientoDetallePedido As Integer = 0, + Optional CveOrdenCompraDetalle As Integer = 0, Optional CveVentaDetalleRemision As Integer = 0, Optional CveVentaDetalleCotizacion As Integer = 0, + Optional CuentaPredial As String = "", Optional RegeneraIEPS As Boolean = True, Optional CveVentaDetallePedido2 As Integer = 0, Optional EsCargo As Boolean = False, Optional PorcentajeIVA As Decimal = 0D, Optional CveTamaño As Integer = 0) As Boolean + + Dim Retorno As Boolean = False + If Not CvePS > 0 Then + Alert("Ocurrió un error al cargar la información del producto a agregar. Por favor verifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) + Return False + End If + + If (Obs.Length + PS.Length > 1000) Then + Alert(String.Format("El Nombre y observación del producto tiene longitud de {0} caracteres y excede los 1000 caracteres permitidos.", Obs.Length + PS.Length), TipoMensaje.MsgAdvertencia) + Return False + End If + + + Dim Row As DataRow = Nothing + Dim TotalCalculableImpuestos As Decimal = 0 + PU = Math.Round(PU, 6) ' el precio unitario puede llevar hasta 6 decimales permitidos + + Row = TmpDT.NewRow() + Row("CveProyecto") = CveProyecto + Row("Proyecto") = Proyecto + Row("CveSubProyecto") = CveSubProyecto + Row("SubProyecto") = SubProyecto + Row("SerieLote") = SerieLote + Row("TiempoEntrega") = TiempoEntrega + Row("Orden") = TmpDT.Rows.Count + 1 + Row("Cantidad") = Cantidad + Row("CveUM") = CveUM + Row("UM") = UM + Row("CveClasificacion") = CveClasificacion + Row("Clasificacion") = Clasificacion + Row("CvePS") = CvePS + Row("Obs") = Obs + + + + Dim DrPS As DataRow = Nothing + + DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("") ' Estado = -1 + + If DrPS Is Nothing Then + Alert("Ocurrió un error al cargar la información del Producto. Por favor vuelva a intentar.", TipoMensaje.MsgAdvertencia) + Return False + End If + + + DrPS("IEPSPorcentaje") = 0 + + 'verifica si tiene ventaminima + If Cantidad > 0 AndAlso DrPS("VentaMinima").ToString.ToDecimal > 0 Then + 'verifico que la cantidad sea multiplo de venta minima, es decir ventaminima =5, solo puede vender 5,10,15... + If Cantidad Mod DrPS("VentaMinima").ToString.ToDecimal <> 0 Then + Alert(String.Format("El producto se vende solo en cantidades de {0}", DrPS("VentaMinima").ToString)) + Return False + End If + End If + + TotalCalculableImpuestos = (Cantidad * (PU)) - Descuento + + Row("PU") = PU + Row("Codigo") = DrPS("Codigo") + Row("NoIdentificacion") = DrPS("Codigo") + Row("ClaveSATFraccionArancelaria") = DrPS("ClaveSATFraccionArancelaria") + Row("ClaveSATUnidadAduana") = DrPS("ClaveSATUnidadAduana") + Row("ClaveSATFraccionArancelariaDescripcion") = DrPS("ClaveSATFraccionArancelariaDescripcion") + Row("ClaveSATUnidadAduanaDescripcion") = DrPS("ClaveSATUnidadAduanaDescripcion") + Row("Consec") = TmpDT.Rows.Count + 1 + + Row("PS") = DrPS("PS") + Row("CodigoPS") = DrPS("PSCodigo").ToString + Row("CveTipoPS") = DrPS("CveTipoPS") + Row("CveTipoInvPS") = DrPS("Inv_CveMetodoInventario") + Row("CveTamaño") = DrPS("CveTamaño") + + If CveClasificacion <= 0 Then Row("CveClasificacion") = DrPS("CveClasificacion") + If Clasificacion = "" Then Row("Clasificacion") = DrPS("Clasificacion") + + Row("PorcentajeIVA") = PorcentajeIVA + + Row("IVA") = Row("PorcentajeIVA") + Row("ImporteIVA") = Math.Round(Row("PorcentajeIVA").ToString.ToDecimal * TotalCalculableImpuestos, 2) + + + Row("ImporteRetIVA") = 0 + Row("ImporteRetISR") = 0 + Row("PorcentajeRetIVA") = 0 + Row("PorcentajeRetISR") = 0 + Row("PorcentajeIEPS") = DrPS("IEPSPorcentaje") + Row("ImporteIEPS") = Math.Round(DrPS("IEPSPorcentaje").ToString.ToDecimal * TotalCalculableImpuestos, 2) + Row("IEPS") = Row("ImporteIEPS") + Row("Descuento") = Math.Round(Descuento, 2) + Row("TipoDescuento") = 0 + Row("Total") = (Cantidad * PU) + Row("TotalImporte") = Math.Round(Cantidad * PU, 2) + 'Row("AsientoContableVentas") = DrPS("AsientoContableVentas") + ' Row("IdCtaContVentas") = IdCtaContable + ' Row("AplicaParaConcepto") = AplicaParaConcepto + + Row("SATClaveProdServ") = DrPS("SATClavePS") + Row("SATClaveUM") = DrPS("SATClaveUnidadMedida") + + + Row("EntregaDirecta") = EntregaDirecta + 'Contratos + Row("CveContratoDetalle") = CveContratoDetalle + Row("CveVentaDetalle") = CveVentaDetalle + Row("CveMovimientoDetallePedido") = CveVentaDetalle + Row("CveOrdenCompraDetalle") = CveOrdenCompraDetalle + Row("CveVentaDetalleRemision") = CveVentaDetalleRemision + Row("CveVentaDetalleCotizacion") = CveVentaDetalleCotizacion + Row("CveVentaDetallePedido2") = CveVentaDetallePedido2 + Row("CuentaPredial") = CuentaPredial + Row("EsCargo") = EsCargo Row("CveTamaño") = CveTamaño 'RECARGAR GV - TmpDT.Rows.Add(Row) - TmpDT.AcceptChanges() - Retorno = True - Return Retorno - + TmpDT.Rows.Add(Row) + TmpDT.AcceptChanges() + Retorno = True + Return Retorno + End Function - Protected Function CreaDTDetalleRNC() As DataTable - Dim TmpDT = New DataTable - TmpDT.Columns.Add("CveVenta", GetType(Integer)) - TmpDT.Columns.Add("Consec", GetType(Integer)) - TmpDT.Columns.Add("Cantidad", GetType(Decimal)) - TmpDT.Columns.Add("Codigo", GetType(String)) - TmpDT.Columns.Add("CveUM", GetType(Integer)) - TmpDT.Columns.Add("UM", GetType(String)) - TmpDT.Columns.Add("SATClaveUM", GetType(String)) - TmpDT.Columns.Add("CveClasificacion", GetType(Integer)) - TmpDT.Columns.Add("Clasificacion", GetType(String)) - TmpDT.Columns.Add("CvePS", GetType(Integer)) - TmpDT.Columns.Add("PS", GetType(String)) - TmpDT.Columns.Add("CodigoPS", GetType(String)) - TmpDT.Columns.Add("SATClaveProdServ", GetType(String)) - TmpDT.Columns.Add("NoIdentificacion", GetType(String)) - TmpDT.Columns.Add("CveTipoPS", GetType(Integer)) - TmpDT.Columns.Add("CveTipoInvPS", GetType(Integer)) - TmpDT.Columns.Add("SerieLote", GetType(String)) - TmpDT.Columns.Add("CuentaPredial", GetType(String)) - TmpDT.Columns.Add("Obs", GetType(String)) - TmpDT.Columns.Add("TiempoEntrega", GetType(String)) - TmpDT.Columns.Add("PU", GetType(Decimal)) - TmpDT.Columns.Add("IVA", GetType(Decimal)) - TmpDT.Columns.Add("ImporteIVA", GetType(Decimal)) - TmpDT.Columns.Add("PorcentajeIVA", GetType(Decimal)) - TmpDT.Columns.Add("ImporteRetIVA", GetType(Decimal)) - TmpDT.Columns.Add("ImporteRetISR", GetType(Decimal)) - TmpDT.Columns.Add("PorcentajeRetIVA", GetType(Decimal)) - TmpDT.Columns.Add("PorcentajeRetISR", GetType(Decimal)) - TmpDT.Columns.Add("ImporteIEPS", GetType(Decimal)) - TmpDT.Columns.Add("IEPS", GetType(Decimal)) - TmpDT.Columns.Add("PorcentajeIEPS", GetType(Decimal)) - TmpDT.Columns.Add("Descuento", GetType(Decimal)) - TmpDT.Columns.Add("TipoDescuento", GetType(Integer)) - TmpDT.Columns.Add("TotalImporte", GetType(Decimal)) - TmpDT.Columns.Add("Total", GetType(Decimal)) - 'Para uso del módulo contable - TmpDT.Columns.Add("AsientoContableVentas", GetType(Integer)) - TmpDT.Columns.Add("IdCtaContVentas", GetType(Integer)) - TmpDT.Columns.Add("AplicaParaConcepto", GetType(Boolean)) - TmpDT.Columns.Add("CveProyecto", GetType(Integer)) - TmpDT.Columns.Add("Proyecto", GetType(String)) - TmpDT.Columns.Add("CveSubProyecto", GetType(Integer)) - TmpDT.Columns.Add("SubProyecto", GetType(String)) - TmpDT.Columns.Add("CveVentaDetallePadre", GetType(Integer)) - - 'TipoDescuento: 1 = Descuento * PU; 2 = Descuento por Total del concepto - TmpDT.Columns.Add("CvePresupuestoIngreso", GetType(Integer)) - TmpDT.Columns.Add("CveFuenteRecaudacion", GetType(Integer)) - 'Contratos - TmpDT.Columns.Add("CveContratoDetalle", GetType(Integer)) - 'Remisiones a Facturas - TmpDT.Columns.Add("CveVentaDetalle", GetType(Integer)) - TmpDT.Columns.Add("CveVentaDetalleRemision", GetType(Integer)) - TmpDT.Columns.Add("CveVentaDetalleCotizacion", GetType(Integer)) - - 'Pedido2 a Facturas - TmpDT.Columns.Add("CveVentaDetallePedido2", GetType(Integer)) - - TmpDT.Columns.Add("Origen", GetType(Integer)) - 'Ordenes Servicio - TmpDT.Columns.Add("CveOS", GetType(Integer)) - TmpDT.Columns.Add("CveOSDetalle", GetType(Integer)) - TmpDT.Columns.Add("SeFacturara", GetType(Integer)) - TmpDT.Columns.Add("Folio", GetType(Integer)) - TmpDT.Columns.Add("Estatus", GetType(String)) - 'Ordenamiento - TmpDT.Columns.Add("Orden", GetType(Integer)) - TmpDT.Columns.Add("TipoDocto", GetType(String)) - 'OC - TmpDT.Columns.Add("CveOrdenCompraDetalle", GetType(Integer)) - TmpDT.Columns.Add("EntregaDirecta", GetType(Integer)) - - TmpDT.Columns.Add("CveMovimientoDetallePedido", GetType(Integer)) - TmpDT.Columns.Add("CantidadFacturadaRem", GetType(Decimal)) - TmpDT.Columns.Add("CantidadFacturadaCot", GetType(Decimal)) - TmpDT.Columns.Add("CantidadFacturadaPed2", GetType(Decimal)) - TmpDT.Columns.Add("CantidadInventario", GetType(Decimal)) - - TmpDT.Columns.Add("ClaveSATFraccionArancelaria", GetType(String)) - TmpDT.Columns.Add("ClaveSATUnidadAduana", GetType(String)) - TmpDT.Columns.Add("ClaveSATFraccionArancelariaDescripcion", GetType(String)) - TmpDT.Columns.Add("ClaveSATUnidadAduanaDescripcion", GetType(String)) - - TmpDT.Columns.Add("CveTamaño", GetType(Integer)) - TmpDT.Columns.Add("EsCargo", GetType(Boolean)) - - Return TmpDT + Protected Function CreaDTDetalleRNC() As DataTable + Dim TmpDT = New DataTable + TmpDT.Columns.Add("CveVenta", GetType(Integer)) + TmpDT.Columns.Add("Consec", GetType(Integer)) + TmpDT.Columns.Add("Cantidad", GetType(Decimal)) + TmpDT.Columns.Add("Codigo", GetType(String)) + TmpDT.Columns.Add("CveUM", GetType(Integer)) + TmpDT.Columns.Add("UM", GetType(String)) + TmpDT.Columns.Add("SATClaveUM", GetType(String)) + TmpDT.Columns.Add("CveClasificacion", GetType(Integer)) + TmpDT.Columns.Add("Clasificacion", GetType(String)) + TmpDT.Columns.Add("CvePS", GetType(Integer)) + TmpDT.Columns.Add("PS", GetType(String)) + TmpDT.Columns.Add("CodigoPS", GetType(String)) + TmpDT.Columns.Add("SATClaveProdServ", GetType(String)) + TmpDT.Columns.Add("NoIdentificacion", GetType(String)) + TmpDT.Columns.Add("CveTipoPS", GetType(Integer)) + TmpDT.Columns.Add("CveTipoInvPS", GetType(Integer)) + TmpDT.Columns.Add("SerieLote", GetType(String)) + TmpDT.Columns.Add("CuentaPredial", GetType(String)) + TmpDT.Columns.Add("Obs", GetType(String)) + TmpDT.Columns.Add("TiempoEntrega", GetType(String)) + TmpDT.Columns.Add("PU", GetType(Decimal)) + TmpDT.Columns.Add("IVA", GetType(Decimal)) + TmpDT.Columns.Add("ImporteIVA", GetType(Decimal)) + TmpDT.Columns.Add("PorcentajeIVA", GetType(Decimal)) + TmpDT.Columns.Add("ImporteRetIVA", GetType(Decimal)) + TmpDT.Columns.Add("ImporteRetISR", GetType(Decimal)) + TmpDT.Columns.Add("PorcentajeRetIVA", GetType(Decimal)) + TmpDT.Columns.Add("PorcentajeRetISR", GetType(Decimal)) + TmpDT.Columns.Add("ImporteIEPS", GetType(Decimal)) + TmpDT.Columns.Add("IEPS", GetType(Decimal)) + TmpDT.Columns.Add("PorcentajeIEPS", GetType(Decimal)) + TmpDT.Columns.Add("Descuento", GetType(Decimal)) + TmpDT.Columns.Add("TipoDescuento", GetType(Integer)) + TmpDT.Columns.Add("TotalImporte", GetType(Decimal)) + TmpDT.Columns.Add("Total", GetType(Decimal)) + 'Para uso del módulo contable + TmpDT.Columns.Add("AsientoContableVentas", GetType(Integer)) + TmpDT.Columns.Add("IdCtaContVentas", GetType(Integer)) + TmpDT.Columns.Add("AplicaParaConcepto", GetType(Boolean)) + TmpDT.Columns.Add("CveProyecto", GetType(Integer)) + TmpDT.Columns.Add("Proyecto", GetType(String)) + TmpDT.Columns.Add("CveSubProyecto", GetType(Integer)) + TmpDT.Columns.Add("SubProyecto", GetType(String)) + TmpDT.Columns.Add("CveVentaDetallePadre", GetType(Integer)) + + 'TipoDescuento: 1 = Descuento * PU; 2 = Descuento por Total del concepto + TmpDT.Columns.Add("CvePresupuestoIngreso", GetType(Integer)) + TmpDT.Columns.Add("CveFuenteRecaudacion", GetType(Integer)) + 'Contratos + TmpDT.Columns.Add("CveContratoDetalle", GetType(Integer)) + 'Remisiones a Facturas + TmpDT.Columns.Add("CveVentaDetalle", GetType(Integer)) + TmpDT.Columns.Add("CveVentaDetalleRemision", GetType(Integer)) + TmpDT.Columns.Add("CveVentaDetalleCotizacion", GetType(Integer)) + + 'Pedido2 a Facturas + TmpDT.Columns.Add("CveVentaDetallePedido2", GetType(Integer)) + + TmpDT.Columns.Add("Origen", GetType(Integer)) + 'Ordenes Servicio + TmpDT.Columns.Add("CveOS", GetType(Integer)) + TmpDT.Columns.Add("CveOSDetalle", GetType(Integer)) + TmpDT.Columns.Add("SeFacturara", GetType(Integer)) + TmpDT.Columns.Add("Folio", GetType(Integer)) + TmpDT.Columns.Add("Estatus", GetType(String)) + 'Ordenamiento + TmpDT.Columns.Add("Orden", GetType(Integer)) + TmpDT.Columns.Add("TipoDocto", GetType(String)) + 'OC + TmpDT.Columns.Add("CveOrdenCompraDetalle", GetType(Integer)) + TmpDT.Columns.Add("EntregaDirecta", GetType(Integer)) + + TmpDT.Columns.Add("CveMovimientoDetallePedido", GetType(Integer)) + TmpDT.Columns.Add("CantidadFacturadaRem", GetType(Decimal)) + TmpDT.Columns.Add("CantidadFacturadaCot", GetType(Decimal)) + TmpDT.Columns.Add("CantidadFacturadaPed2", GetType(Decimal)) + TmpDT.Columns.Add("CantidadInventario", GetType(Decimal)) + + TmpDT.Columns.Add("ClaveSATFraccionArancelaria", GetType(String)) + TmpDT.Columns.Add("ClaveSATUnidadAduana", GetType(String)) + TmpDT.Columns.Add("ClaveSATFraccionArancelariaDescripcion", GetType(String)) + TmpDT.Columns.Add("ClaveSATUnidadAduanaDescripcion", GetType(String)) + + TmpDT.Columns.Add("CveTamaño", GetType(Integer)) + TmpDT.Columns.Add("EsCargo", GetType(Boolean)) + + Return TmpDT End Function Protected Sub CargaDTDetalleRNC() diff --git a/Inventarios/Remanufactura.aspx.vb b/Inventarios/Remanufactura.aspx.vb index 994467378..d64eaa79a 100644 --- a/Inventarios/Remanufactura.aspx.vb +++ b/Inventarios/Remanufactura.aspx.vb @@ -223,7 +223,7 @@ Partial Class Inventarios_Remanufactura If CveMovimiento > 0 Then If GlobalDTPS(UsuarioActual.CveEmpresa, DdlPS.SelectedValue.ToEntero).Rows.Count > 0 Then Dim DrPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, DdlPS.SelectedValue.ToEntero).Rows(0) - ObjInv.AddMovimientoDetalle(CveMovimiento, TxtCantidad.Text.ToDouble, DrPS("CveUnidadMedida").ToString().ToEntero(), DdlPS.SelectedValue.ToEntero, TxtPrecio.Text.ToDouble, -1) + ObjInv.AddMovimientoDetalle(CveMovimiento, TxtCantidad.Text.ToDouble, DrPS("CveUnidadMedida").ToString().ToEntero(), DdlPS.SelectedValue.ToEntero, TxtPrecio.Text.ToDecimal, -1) If ObjInv.GetMovimientos(CveMovimiento, -1, -1, UsuarioActual.CveEmpresa) Then If ObjInv.DtResultados.Rows.Count > 0 Then FolioMov = ObjInv.DtResultados.Rows(0)("Folio").ToString diff --git a/Inventarios/TraspasoAlmacen.aspx.vb b/Inventarios/TraspasoAlmacen.aspx.vb index 34ef3d6fa..d9ea15561 100644 --- a/Inventarios/TraspasoAlmacen.aspx.vb +++ b/Inventarios/TraspasoAlmacen.aspx.vb @@ -1,818 +1,818 @@ -Option Explicit On -Option Strict On - -Imports System.Data -Imports System.IO -Imports Extensiones +Option Explicit On +Option Strict On + +Imports System.Data +Imports System.IO +Imports Extensiones Imports GemBox.Spreadsheet -Imports Microsoft.Reporting.WebForms - -Partial Class Inventarios_TraspasoAlmacen +Imports Microsoft.Reporting.WebForms + +Partial Class Inventarios_TraspasoAlmacen Inherits ClsPaginas -#Region "PROPIEDADES" - Public Property DtMovimientos() As DataTable - Get - Return CType(ViewState("DtMovimientos"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtMovimientos") = value - End Set - End Property - - Private Property DtTraslado As DataTable - Get - Return CType(ViewState("DtTraslado"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtTraslado") = value - End Set - End Property - - - Private Property CveAlmacenTransitorio As Integer - Get - Return CType(ViewState("CveAlmacenTransitorio"), Integer) - End Get - Set(value As Integer) - ViewState("CveAlmacenTransitorio") = value - End Set - End Property - Private Property CveAlmacenDestino As Integer - Get - Return CType(ViewState("CveAlmacenDestino"), Integer) - End Get - Set(value As Integer) - ViewState("CveAlmacenDestino") = value - End Set - End Property - Private Property CveUsuarioResponsable As Integer - Get - Return CType(ViewState("CveUsuarioResponsable"), Integer) - End Get - Set(value As Integer) - ViewState("CveUsuarioResponsable") = value - End Set - End Property - Private Property CvePSSerieLote As Integer - Get - Return CType(ViewState("CvePSSerieLote"), Integer) - End Get - Set(value As Integer) - ViewState("CvePSSerieLote") = value - End Set - End Property - Private Property CveUMSerieLote As Integer - Get - Return CType(ViewState("CveUMSerieLote"), Integer) - End Get - Set(value As Integer) - ViewState("CveUMSerieLote") = value - End Set - End Property - Private Property CargadoDeMov As Boolean - Get - Return CType(ViewState("CargadoDeMov"), Boolean) - End Get - Set(value As Boolean) - ViewState("CargadoDeMov") = value - End Set - End Property - Private Property CveMovimientoSalida As Integer - Get - Return CType(ViewState("CveMovimientoSalida"), Integer) - End Get - Set(value As Integer) - ViewState("CveMovimientoSalida") = value - End Set - End Property - Private Property CveMov As Integer - Get - Return CType(ViewState("CveMov"), Integer) - End Get - Set(value As Integer) - ViewState("CveMov") = value - End Set - End Property - Private Property ObjFactura As Modelos.Factura - Get - Return CType(ViewState("ObjFactura"), Modelos.Factura) - End Get - Set(value As Modelos.Factura) - ViewState("ObjFactura") = value - End Set - End Property - Private Property Folio As Integer - Get - Return CType(ViewState("Folio"), Integer) - End Get - Set(value As Integer) - ViewState("Folio") = value - End Set - End Property - Private Property MensajeAlert As StringBuilder - Get - Return CType(ViewState("MensajeAlert"), StringBuilder) - End Get - Set(value As StringBuilder) - ViewState("MensajeAlert") = value - End Set - End Property - - Private Property CveMovimientoTimbrado As Integer - Get - Return CType(ViewState("CveMovimientoTimbrado"), Integer) - End Get - Set(value As Integer) - ViewState("CveMovimientoTimbrado") = value - End Set - End Property - - Private Property DtSeccionAlmacen As DataTable - Get - Return CType(ViewState("DtSeccionAlmacen"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtSeccionAlmacen") = value - End Set - End Property - Private Property IndexSeccionAlmacen As Integer - Get - Return CType(ViewState("IndexSeccionAlmacen"), Integer) - End Get - Set(value As Integer) - ViewState("IndexSeccionAlmacen") = value - End Set - End Property - Private Property CantidadTotal As Decimal - Get - Return CType(ViewState("CantidadTotal"), Decimal) - End Get - Set(value As Decimal) - ViewState("CantidadTotal") = value - End Set - End Property - Private Property CvePS As Integer - Get - Return CType(ViewState("CvePS"), Integer) - End Get - Set(value As Integer) - ViewState("CvePS") = value - End Set - End Property - Private Property TipoSeccionAlmacen As Integer - Get - Return CType(ViewState("TipoSeccionAlmacen"), Integer) - End Get - Set(value As Integer) - ViewState("TipoSeccionAlmacen") = value - End Set +#Region "PROPIEDADES" + Public Property DtMovimientos() As DataTable + Get + Return CType(ViewState("DtMovimientos"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtMovimientos") = value + End Set End Property - Private Property FolioBusqueda As Integer - Get - Return CType(ViewState("FolioBusqueda"), Integer) - End Get - Set(value As Integer) - ViewState("FolioBusqueda") = value - End Set - End Property - Private Property DtCamiones As DataTable - Get - Return CType(ViewState("DtCamiones"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtCamiones") = value - End Set - End Property -#End Region - Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load - If Not Page.IsPostBack Then - - TxtFecha.Text = Now.ToShortDateString - CEFecha.EndDate = Now.AddDays(-1) - RVFecha.MaximumValue = Now.ToShortDateString - - TxtFechaRecepcion.Text = Now.ToShortDateString - CEFechaRecepcion.EndDate = Now.AddDays(-1) - RVFechaRecepcion.MaximumValue = Now.ToShortDateString - Folio = 0 - CveMovimientoTimbrado = -1 - + Private Property DtTraslado As DataTable + Get + Return CType(ViewState("DtTraslado"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtTraslado") = value + End Set + End Property + + + Private Property CveAlmacenTransitorio As Integer + Get + Return CType(ViewState("CveAlmacenTransitorio"), Integer) + End Get + Set(value As Integer) + ViewState("CveAlmacenTransitorio") = value + End Set + End Property + Private Property CveAlmacenDestino As Integer + Get + Return CType(ViewState("CveAlmacenDestino"), Integer) + End Get + Set(value As Integer) + ViewState("CveAlmacenDestino") = value + End Set + End Property + Private Property CveUsuarioResponsable As Integer + Get + Return CType(ViewState("CveUsuarioResponsable"), Integer) + End Get + Set(value As Integer) + ViewState("CveUsuarioResponsable") = value + End Set + End Property + Private Property CvePSSerieLote As Integer + Get + Return CType(ViewState("CvePSSerieLote"), Integer) + End Get + Set(value As Integer) + ViewState("CvePSSerieLote") = value + End Set + End Property + Private Property CveUMSerieLote As Integer + Get + Return CType(ViewState("CveUMSerieLote"), Integer) + End Get + Set(value As Integer) + ViewState("CveUMSerieLote") = value + End Set + End Property + Private Property CargadoDeMov As Boolean + Get + Return CType(ViewState("CargadoDeMov"), Boolean) + End Get + Set(value As Boolean) + ViewState("CargadoDeMov") = value + End Set + End Property + Private Property CveMovimientoSalida As Integer + Get + Return CType(ViewState("CveMovimientoSalida"), Integer) + End Get + Set(value As Integer) + ViewState("CveMovimientoSalida") = value + End Set + End Property + Private Property CveMov As Integer + Get + Return CType(ViewState("CveMov"), Integer) + End Get + Set(value As Integer) + ViewState("CveMov") = value + End Set + End Property + Private Property ObjFactura As Modelos.Factura + Get + Return CType(ViewState("ObjFactura"), Modelos.Factura) + End Get + Set(value As Modelos.Factura) + ViewState("ObjFactura") = value + End Set + End Property + Private Property Folio As Integer + Get + Return CType(ViewState("Folio"), Integer) + End Get + Set(value As Integer) + ViewState("Folio") = value + End Set + End Property + Private Property MensajeAlert As StringBuilder + Get + Return CType(ViewState("MensajeAlert"), StringBuilder) + End Get + Set(value As StringBuilder) + ViewState("MensajeAlert") = value + End Set + End Property + + Private Property CveMovimientoTimbrado As Integer + Get + Return CType(ViewState("CveMovimientoTimbrado"), Integer) + End Get + Set(value As Integer) + ViewState("CveMovimientoTimbrado") = value + End Set + End Property + + Private Property DtSeccionAlmacen As DataTable + Get + Return CType(ViewState("DtSeccionAlmacen"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtSeccionAlmacen") = value + End Set + End Property + Private Property IndexSeccionAlmacen As Integer + Get + Return CType(ViewState("IndexSeccionAlmacen"), Integer) + End Get + Set(value As Integer) + ViewState("IndexSeccionAlmacen") = value + End Set + End Property + Private Property CantidadTotal As Decimal + Get + Return CType(ViewState("CantidadTotal"), Decimal) + End Get + Set(value As Decimal) + ViewState("CantidadTotal") = value + End Set + End Property + Private Property CvePS As Integer + Get + Return CType(ViewState("CvePS"), Integer) + End Get + Set(value As Integer) + ViewState("CvePS") = value + End Set + End Property + Private Property TipoSeccionAlmacen As Integer + Get + Return CType(ViewState("TipoSeccionAlmacen"), Integer) + End Get + Set(value As Integer) + ViewState("TipoSeccionAlmacen") = value + End Set + End Property + Private Property FolioBusqueda As Integer + Get + Return CType(ViewState("FolioBusqueda"), Integer) + End Get + Set(value As Integer) + ViewState("FolioBusqueda") = value + End Set + End Property + Private Property DtCamiones As DataTable + Get + Return CType(ViewState("DtCamiones"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtCamiones") = value + End Set + End Property +#End Region + + Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load + If Not Page.IsPostBack Then + + TxtFecha.Text = Now.ToShortDateString + CEFecha.EndDate = Now.AddDays(-1) + RVFecha.MaximumValue = Now.ToShortDateString + + TxtFechaRecepcion.Text = Now.ToShortDateString + CEFechaRecepcion.EndDate = Now.AddDays(-1) + RVFechaRecepcion.MaximumValue = Now.ToShortDateString + Folio = 0 + CveMovimientoTimbrado = -1 + If UsuarioActual.CveEmpresa = 119 Then divGastoIndirecto.Visible = False divResponsable.Visible = False - End If - - - CargaCombos() - CreaDT() - AlmacenTransitorioDefaults() - - If Request("CveEntrada") IsNot Nothing AndAlso Request("CveEntrada").ToString.ToEntero > 0 Then - CargaMovimiento(Request("CveEntrada").ToString.ToEntero) - Else - GvDatos.Columns(7).Visible = UsuarioActual.Empresa.Funcionalidad(563) = "1" - GvDatosRecepcion.Columns(7).Visible = UsuarioActual.Empresa.Funcionalidad(563) = "1" - ThSeccionAlmacen.Visible = UsuarioActual.Empresa.Funcionalidad(563) = "1" - End If - - If UsuarioActual.Empresa.Funcionalidad(132) = "1" Then - DivCodigoSeriePS.Visible = True - Else - DivCodigoSeriePS.Visible = False - End If - If ChkTransitorio.Checked Then RegistraScript("$('#DivTransitorio').show(0);$('#DivGastoIndirecto').show(0);$('#DivDocChofer').show(0);") - - If UsuarioActual.CveEmpresa.Contiene(1, 119) Then DivEmitirTimbrado.Visible = True - - CantidadTotal = 0 - IndexSeccionAlmacen = 0 - CvePS = 0 - CreaDtSeccionAlmacen() - CargaDdlAlmacen() - TipoSeccionAlmacen = 0 - - Else - If ChkTransitorio.Checked Then RegistraScript("$('#DivTransitorio').show(0);$('#DivGastoIndirecto').show(0);$('#DivDocChofer').show(0);") - End If + End If + + + CargaCombos() + CreaDT() + AlmacenTransitorioDefaults() + + If Request("CveEntrada") IsNot Nothing AndAlso Request("CveEntrada").ToString.ToEntero > 0 Then + CargaMovimiento(Request("CveEntrada").ToString.ToEntero) + Else + GvDatos.Columns(7).Visible = UsuarioActual.Empresa.Funcionalidad(563) = "1" + GvDatosRecepcion.Columns(7).Visible = UsuarioActual.Empresa.Funcionalidad(563) = "1" + ThSeccionAlmacen.Visible = UsuarioActual.Empresa.Funcionalidad(563) = "1" + End If + + If UsuarioActual.Empresa.Funcionalidad(132) = "1" Then + DivCodigoSeriePS.Visible = True + Else + DivCodigoSeriePS.Visible = False + End If + If ChkTransitorio.Checked Then RegistraScript("$('#DivTransitorio').show(0);$('#DivGastoIndirecto').show(0);$('#DivDocChofer').show(0);") + + If UsuarioActual.CveEmpresa.Contiene(1, 119) Then DivEmitirTimbrado.Visible = True + + CantidadTotal = 0 + IndexSeccionAlmacen = 0 + CvePS = 0 + CreaDtSeccionAlmacen() + CargaDdlAlmacen() + TipoSeccionAlmacen = 0 + + Else + If ChkTransitorio.Checked Then RegistraScript("$('#DivTransitorio').show(0);$('#DivGastoIndirecto').show(0);$('#DivDocChofer').show(0);") + End If End Sub -#Region "CARGA DATOS" - Protected Sub CreaDT() - Dim dt As New DataTable - - Dim column As DataColumn = New DataColumn("No") - column.DataType = Type.GetType("System.Int32") - With column - .AutoIncrement = True - .AutoIncrementSeed = 1 - .AutoIncrementStep = 1 - End With - - dt.Columns.Add(column) - - 'dt.Columns.Add("CveMovimiento", Type.GetType("System.Int32")) - 'dt.Columns.Add("CveMovimientoDetalle", Type.GetType("System.Int32")) - - dt.Columns.Add("Cantidad", Type.GetType("System.Double")) - dt.Columns.Add("CveUM", Type.GetType("System.Int32")) - dt.Columns.Add("UnidadMedida") - dt.Columns.Add("UM") - dt.Columns.Add("CvePS", Type.GetType("System.Int32")) - dt.Columns.Add("CveAF", Type.GetType("System.Int32")) - dt.Columns.Add("PS") - dt.Columns.Add("Observaciones") - dt.Columns.Add("SerieLote") - dt.Columns.Add("Lote") - dt.Columns.Add("Batch") - - 'dt.Columns.Add("PU", Type.GetType("System.Double")) - 'dt.Columns.Add("Total", Type.GetType("System.Double")) - - dt.Columns.Add("CveClasificacion", Type.GetType("System.Int32")) - dt.Columns.Add("EstatusExistencia") - - dt.Columns.Add("TotalImporte", Type.GetType("System.Double")) - dt.Columns.Add("PU", Type.GetType("System.Double")) - dt.Columns.Add("Descuento", Type.GetType("System.Double")) - dt.Columns.Add("SATClaveUM") - dt.Columns.Add("SATClaveProdServ") - dt.Columns.Add("Noidentificacion") - dt.Columns.Add("CuentaPredial") - dt.Columns.Add("Obs") - dt.Columns.Add("ImporteIVA", Type.GetType("System.Double")) - dt.Columns.Add("PorcentajeIVA", Type.GetType("System.Double")) - - - DtMovimientos = dt - - CargaGvDatos() - - End Sub - - Private Sub CargaMovimiento(CveMovimiento As Integer) - Dim Mov As New ClsInventarios - - If Mov.GetMovimientos(CveMovimiento, 2, -1, UsuarioActual.CveEmpresa) Then - If Mov.DtResultados.Rows.Count = 1 Then - DivMov.Visible = True - ltlFolio.Text = Mov.DtResultados(0)("Folio").ToString - ltlFecha.Text = Mov.DtResultados(0)("FechaMovto").ToString.ToDate.ToShortDateString - - If Mov.CveCompra > 0 Then - hplRef.NavigateUrl = $"/Compras/Compras.aspx?CveCompra={Mov.CveCompra}" - lblCompraRef.Visible = True - hplRef.Visible = True - Else - hplRef.Visible = False - lblCompraRef.Visible = False - End If - - - CargadoDeMov = True - - If (DdlAlmacenOrigen.Items.FindByValue(Mov.CveAlmacen.ToString()) Is Nothing) Then - Dim dr As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveAlmacen = {0}", Mov.CveAlmacen)) - If dr IsNot Nothing Then - DdlAlmacenOrigen.Items.Insert(0, New ListItem(dr("Almacen").ToString, dr("CveAlmacen").ToString)) ' lo genera Obj.SelectedValue = Valor.ToString - DdlAlmacenOrigen.Enabled = False - End If - Else - DdlAlmacenOrigen.SelectedValue = Mov.CveAlmacen.ToString - End If - DdlAlmacenOrigen.Enabled = False - - 'If GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveTipoAlmacen", $"CveAlmacen = {Mov.CveAlmacenDestino}").ToEntero = 16 Then - ' CveMov = CveMovimiento - ' LnkEnviarMail.Attributes.Add("onclick", "$('#ModalDivMail').modal();") - ' LnkEnviarMail.Visible = True - 'End If - - If Mov.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then - DtMovimientos = Mov.DtResultados.DefaultView.ToTable("Cantidad, CveUM, CvePS, CveAF, PS, SerieLote, CveClasificacion, EstatusExistencia") - CargaGvDatos() - End If - - Else - Alert("El movimiento solicitado no existe. ", TipoMensaje.MsgAdvertencia) - End If - Else - Alert("Ocurrió un error al cargar el movimiento a traspasar. Por favor vuelva a intentar.", TipoMensaje.MsgError) - End If - - Mov.Dispose() - UpMov.Update() - End Sub - - Private Sub AlmacenTransitorioDefaults() - ChkTransitorio.Checked = UsuarioActual.Empresa.Funcionalidad(154).ToString.ToEntero > 0 - ChkTransitorio.Enabled = Not UsuarioActual.Empresa.Funcionalidad(154).ToString.ToEntero > 0 - End Sub - - Private Sub CargaCombos() - - 'Llenar Clasificaciones - If UsuarioActual.CveEmpresa = 66 Then - DdlClasificacion.DataSource = GlobalDTSubFamilias(UsuarioActual.CveEmpresa).FiltraParametros("", Orderby:="Clasificacion") - Else - DdlClasificacion.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltraParametros(" Codigo = '' OR Codigo IS NULL ", Orderby:="Clasificacion") - End If - DdlClasificacion.DataBind() - - 'Llena Almacen Origen - CargaAlmacenOrigen() - 'DdlAlmacenOrigen.Items.Insert(0, New ListItem("Seleccione", "-1")) - - 'Dim dtAlm As DataTable = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 1) - 'dtAlm.Merge(GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 2)) - - 'Llena Almacen Destino, todos los almacenes destino, - - DdlAlmacenDestino.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoAlmacen NOT IN (3,4,9,10,11) AND Estatus = 'Activo'") - 'DdlAlmacenDestino.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen <> 4") - DdlAlmacenDestino.DataBind() - DdlAlmacenDestino.Items.Insert(0, New ListItem("Seleccione", "-1")) - - 'Llena Almacen Transitorio - DdlAlmacenTransitorio.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 3) - DdlAlmacenTransitorio.DataBind() - DdlAlmacenTransitorio.Items.Insert(0, New ListItem("Seleccione", "-1")) - - 'Llena Almacen Recepcion - DdlAlmacenRecepcion.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen NOT IN (3,4,9,10,11)") - DdlAlmacenRecepcion.DataBind() - DdlAlmacenRecepcion.Items.Insert(0, New ListItem("Todos", "-1")) - - 'Llena Almacen Transitorio Recepcion - DdlAlmacenTransitorioRecepcion.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 3) - DdlAlmacenTransitorioRecepcion.DataBind() - DdlAlmacenTransitorioRecepcion.Items.Insert(0, New ListItem("Seleccione", "-1")) - - ''Llena Almacen Recibe - 'DdlAlmacenRecibe.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - 'DdlAlmacenRecibe.DataBind() - - 'Llena Unidaddes Medida - DdlUnidad.DataSource = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa) - DdlUnidad.DataBind() - - 'Llena Choferes - Dim ObjAcar As New ClsAcarreos() - If ObjAcar.GetChofer(-1, UsuarioActual.CveEmpresa, 1, -1) Then - DdlChofer.DataSource = ObjAcar.DtResultados - DdlChofer.DataBind() - End If - ObjAcar.Dispose() - DdlChofer.Items.Insert(0, New ListItem("Seleccione", "-1")) - TxtFechaEntrega.Text = Now.ToShortDateString - - 'Llena Responsables Transitorio - 'DdlResponsable.DataSource = GlobalDTUsuarios(-1, UsuarioActual.CveEmpresa) - 'DdlResponsable.DataBind() - 'DdlResponsable.Items.Insert(0, New ListItem("Seleccione", "-1")) - - 'Llena Responsables Transitorio recepcion - 'DdlResponsableRecepcion.DataSource = GlobalDTUsuarios(-1, UsuarioActual.CveEmpresa) - 'DdlResponsableRecepcion.DataBind() - 'DdlResponsableRecepcion.Items.Insert(0, New ListItem("Seleccione", "-1")) - - 'Llenar el dropdownlist de Productos y servicios - - 'If UsuarioActual.Empresa.Funcionalidad(105) = "" Then - - ' DdlProducto.DataSource = GlobalDTProductosServicios(UsuarioActual.CveEmpresa) - ' DdlProducto.DataBind() - ' DdlProducto.Items.Insert(0, New ListItem("----", "-1")) - ' DdlProductows.Visible = False - 'Else - ' DdlProducto.Visible = False - 'End If - - CargaPS() - - 'Folio - SiguienteFolio(If(ChkTransitorio.Checked, 9, 8)) - - 'DdlProducto.DataBind() - CargarCamiones() - End Sub - Private Sub CargaAlmacenOrigen() - DdlAlmacenOrigen.Enabled = True - DdlAlmacenOrigen.Items.Clear() - DdlAlmacenOrigen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen NOT IN (3,4,9,10,11,21)") - DdlAlmacenOrigen.Items.Insert(0, New ListItem(" Seleccione ", "-1")) - DdlAlmacenOrigen.SelectedValue = "-1" - DdlAlmacenOrigen.DataBind() - DdlAlmacenOrigen.SelectedValueExist(UsuarioActual.CveAlmacen) - End Sub - Private Sub CargaPS() - 'DdlProducto2.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1") - - 'If Not DdlProducto2.UsaWebService AndAlso CType(DdlProducto2.DataSource, DataTable) Is Nothing Then - ' DdlProducto2.DataSource = GlobalDTProductosServicios(UsuarioActual.CveEmpresa) - ' DdlProducto2.DataBind() - 'End If - - Dim EsWS = If(UsuarioActual.Empresa.Funcionalidad(105) = "1" Or UsuarioActual.Empresa.Funcionalidad(141) = "1", True, False) - DdlProducto2.setEsWebService(EsWS) - - If DdlProducto2.UsaWebService Then - DdlProducto2.ddlWS.Attributes.Add("data-cveclasificacion", DdlClasificacion.SelectedValue) - If UsuarioActual.Empresa.Funcionalidad(141) = "1" Then - DdlProducto2.ddlWS.Attributes.Add("data-pagina", "inv/traspaso") - DdlProducto2.ddlWS.Attributes.Add("Data-onresult", "CargaExistenciaAlmacenes") - CargaExistenciasSucursal() - DdlAlmacenOrigen.AutoPostBack = True - End If - ElseIf Not DdlProducto2.UsaWebService AndAlso CType(DdlProducto2.DataSource, DataTable) Is Nothing Then - DdlProducto2.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=DdlClasificacion.SelectedValue.ToEntero).FiltraParametros("CveTipoPS = 2") - DdlProducto2.DataBind() - End If - - End Sub - Protected Sub DdlAlmacenOrigen_SelectedIndexChanged(sender As Object, e As EventArgs) - If UsuarioActual.Empresa.Funcionalidad(141) = "1" Then - CargaExistenciasSucursal() - End If - End Sub - Protected Sub DdlAlmacenDestino_SelectedIndexChanged(sender As Object, e As EventArgs) - If GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveTipoAlmacen", $"CveAlmacen = {DdlAlmacenDestino.SelectedValue.ToEntero}").ToString.ToEntero = 21 Then - ChkTransitorio.Checked = False - ChkTransitorio.Enabled = False - Else - ChkTransitorio.Enabled = True - End If - End Sub - Private Sub CargaExistenciasSucursal() - DdlProducto2.Attributes.Remove("Data-cvesubproyecto") - DdlProducto2.Attributes.Add("Data-cvesubproyecto", GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveSubProyecto", $"CveAlmacen = {DdlAlmacenOrigen.SelectedValue}")) - End Sub - Private Sub SiguienteFolio(CveConcepto As Integer) - 'Dim Inv As New ClsInventarios - 'Dim Folio As Integer = Inv.GetFolioSiguiente(CveConcepto, UsuarioActual.CveEmpresa) - 'Inv.Dispose() - - 'TxtFolio.Text = Folio.ToString - End Sub -#End Region +#Region "CARGA DATOS" + Protected Sub CreaDT() + Dim dt As New DataTable -#Region " AGREGAR " - Protected Sub btnAgregar_Click(sender As Object, e As EventArgs) Handles LbAgregar.Click - BtnAgregarPS(txtCantidad.Text.ToDecimal) - End Sub - Protected Sub BtnSerieAddNew_Click(sender As Object, e As EventArgs) - BtnAgregarPS(1) - End Sub - Private Sub BtnAgregarPS(Cantidad As Decimal) - Dim CveProducto As Integer = DdlProducto2.SelectedValue.ToEntero - Dim FuncionalidadSinSerie = True - - If CveProducto > 0 Then - If TxtnSerieLote.Visible Then - Cantidad = 1 - If TxtnSerieLote.Text = "" Then - Alert("Serie-Lote es necesario", TipoMensaje.MsgAdvertencia) - RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')") - Exit Sub - End If - If txtCantidad.Text.ToDouble > 1 Then - FuncionalidadSinSerie = False - End If - End If - Dim DrPS As DataRow = Nothing - - DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CveProducto).FiltroPrimero("") ' Estado = -1 - - If Cantidad > 0 AndAlso DrPS("VentaMinima").ToString.ToDecimal > 0 Then - 'verifico que la cantidad sea multiplo de venta minima, es decir ventaminima =5, solo puede vender 5,10,15... - If Cantidad Mod DrPS("VentaMinima").ToString.ToDecimal <> 0 Then - Alert(String.Format("El producto se vende solo en cantidades de {0:#,###.####}", DrPS("VentaMinima"))) - Exit Sub - End If - End If - - Dim Valido = ValidaExistencia(Cantidad, CveProducto, DdlUnidad.SelectedValue.ToEntero, If(TxtnSerieLote.Visible, TxtnSerieLote.Text, "-1"), If(TxtnLote.Visible, TxtnLote.Text, "-1"), If(TxtnBatch.Visible, TxtnBatch.Text, "-1")) - - If Valido Then - AgregarPS(Cantidad, CveProducto, DdlUnidad.SelectedValue.ToEntero, TxtnObservaciones.Text, If(TxtnSerieLote.Visible, TxtnSerieLote.Text, ""), If(TxtnLote.Visible, TxtnLote.Text, ""), If(TxtnBatch.Visible, TxtnBatch.Text, ""), FuncionalidadSinSerie) - End If - - End If - End Sub - Private Function ValidaExistencia(Cantidad As Double, CvePS As Integer, CveUnidadMedida As Integer, Optional SerieLote As String = "-1", Optional Lote As String = "-1", Optional Batch As String = "-1") As Boolean - Dim Retorno = True - - Dim Inv As New ClsInventarios - Dim Existencia As Double = Inv.GetExistenciasPS(CvePS, CveUnidadMedida, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDate.ToString("yyyy/MM/dd 23:59"), SerieLote:=SerieLote, Lote:=Lote, Batch:=Batch, PendientePorSurtir:=1) - Inv.Dispose() - - If Existencia - Cantidad - DtMovimientos.SUM("Cantidad", $"CvePS = {CvePS} AND CveUM = {CveUnidadMedida} {If(SerieLote <> "-1", $" AND SerieLote = '{SerieLote}'", "")}") < 0 Then - If Existencia < 0 Then - Alert("No hay existencia del producto", TipoMensaje.MsgAdvertencia) - RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')") - Else - Alert(String.Format("Solo hay en existencia: {0}", Existencia), TipoMensaje.MsgAdvertencia) - RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')") - End If - Retorno = False - End If - - Return Retorno - End Function - Private Sub AgregarPS(Cantidad As Double, CvePS As Integer, CveUnidadMedida As Integer, Optional Observaciones As String = "", Optional SerieLote As String = "", Optional Lote As String = "", Optional Batch As String = "", Optional Limpia As Boolean = True) - If Cantidad <= 0 Then - Alert("La cantidad debe ser mayor a cero (0). Por favor verifique y vuelva a intentar", TipoMensaje.MsgAdvertencia) - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - End If - - Dim CveClasificacion As Integer - - Dim DrPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("") - If DrPS IsNot Nothing Then CveClasificacion = DrPS("CveClasificacion").ToString.ToEntero - - Dim DrUM = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa).FiltroPrimero($"CveUnidadMedida = {CveUnidadMedida}") - - Dim registro As DataRow = DtMovimientos.NewRow - registro.Item("Cantidad") = Cantidad - registro.Item("CveUM") = CveUnidadMedida - registro.Item("UM") = DrUM("UnidadMedida") - registro.Item("UnidadMedida") = DrUM("UnidadMedida") - registro.Item("CvePS") = CvePS - registro.Item("PS") = DrPS("PSCodigo") - registro.Item("Observaciones") = Observaciones - registro.Item("SerieLote") = SerieLote - registro.Item("Lote") = Lote - registro.Item("Batch") = Batch - registro.Item("CveClasificacion") = CveClasificacion - registro.Item("CveAF") = -1 - registro.Item("EstatusExistencia") = "1" - - registro.Item("TotalImporte") = 0 - registro.Item("PU") = 0 - registro.Item("Descuento") = 0 - registro.Item("SATClaveUM") = DrPS("SATClaveUnidadMedida") - registro.Item("SATClaveProdServ") = DrPS("SATClavePS") - registro.Item("Noidentificacion") = DrPS("Codigo") - registro.Item("CuentaPredial") = "" - registro.Item("Obs") = "" - registro.Item("ImporteIVA") = 0 - registro.Item("PorcentajeIVA") = 0 - - - DtMovimientos.Rows.Add(registro) - RegistraScript("playsonidito('beep-07.wav')") - CargaGvDatos() - - If Limpia Then - LimpiaAgregar() - Else - txtCantidad.Text = (txtCantidad.Text.ToDouble - 1.0).ToString - TxtnSerieLote.Text = "" - TxtnSerieLote.Focus() - End If - End Sub - - Private Sub LimpiaAgregar() - DdlClasificacion.SelectedValue = "-1" - DdlClasificacion_SelectedIndexChanged(DdlClasificacion, EventArgs.Empty) - txtCantidad.Text = "" - TxtnObservaciones.Text = "" - TxtnSerieLote.Text = "" - TxtnSerieLote.Visible = False - TxtnLote.Text = "" - TxtnBatch.Text = "" - - txtCantidad.Focus() - If TxtCodigoPS.Visible Then - TxtCodigoPS.Focus() - End If + Dim column As DataColumn = New DataColumn("No") + column.DataType = Type.GetType("System.Int32") + With column + .AutoIncrement = True + .AutoIncrementSeed = 1 + .AutoIncrementStep = 1 + End With + + dt.Columns.Add(column) + + 'dt.Columns.Add("CveMovimiento", Type.GetType("System.Int32")) + 'dt.Columns.Add("CveMovimientoDetalle", Type.GetType("System.Int32")) + + dt.Columns.Add("Cantidad", Type.GetType("System.Double")) + dt.Columns.Add("CveUM", Type.GetType("System.Int32")) + dt.Columns.Add("UnidadMedida") + dt.Columns.Add("UM") + dt.Columns.Add("CvePS", Type.GetType("System.Int32")) + dt.Columns.Add("CveAF", Type.GetType("System.Int32")) + dt.Columns.Add("PS") + dt.Columns.Add("Observaciones") + dt.Columns.Add("SerieLote") + dt.Columns.Add("Lote") + dt.Columns.Add("Batch") + + 'dt.Columns.Add("PU", Type.GetType("System.Double")) + 'dt.Columns.Add("Total", Type.GetType("System.Double")) + + dt.Columns.Add("CveClasificacion", Type.GetType("System.Int32")) + dt.Columns.Add("EstatusExistencia") + + dt.Columns.Add("TotalImporte", Type.GetType("System.Double")) + dt.Columns.Add("PU", Type.GetType("System.Double")) + dt.Columns.Add("Descuento", Type.GetType("System.Double")) + dt.Columns.Add("SATClaveUM") + dt.Columns.Add("SATClaveProdServ") + dt.Columns.Add("Noidentificacion") + dt.Columns.Add("CuentaPredial") + dt.Columns.Add("Obs") + dt.Columns.Add("ImporteIVA", Type.GetType("System.Double")) + dt.Columns.Add("PorcentajeIVA", Type.GetType("System.Double")) + + + DtMovimientos = dt + + CargaGvDatos() + + End Sub + + Private Sub CargaMovimiento(CveMovimiento As Integer) + Dim Mov As New ClsInventarios + + If Mov.GetMovimientos(CveMovimiento, 2, -1, UsuarioActual.CveEmpresa) Then + If Mov.DtResultados.Rows.Count = 1 Then + DivMov.Visible = True + ltlFolio.Text = Mov.DtResultados(0)("Folio").ToString + ltlFecha.Text = Mov.DtResultados(0)("FechaMovto").ToString.ToDate.ToShortDateString + + If Mov.CveCompra > 0 Then + hplRef.NavigateUrl = $"/Compras/Compras.aspx?CveCompra={Mov.CveCompra}" + lblCompraRef.Visible = True + hplRef.Visible = True + Else + hplRef.Visible = False + lblCompraRef.Visible = False + End If + + + CargadoDeMov = True + + If (DdlAlmacenOrigen.Items.FindByValue(Mov.CveAlmacen.ToString()) Is Nothing) Then + Dim dr As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveAlmacen = {0}", Mov.CveAlmacen)) + If dr IsNot Nothing Then + DdlAlmacenOrigen.Items.Insert(0, New ListItem(dr("Almacen").ToString, dr("CveAlmacen").ToString)) ' lo genera Obj.SelectedValue = Valor.ToString + DdlAlmacenOrigen.Enabled = False + End If + Else + DdlAlmacenOrigen.SelectedValue = Mov.CveAlmacen.ToString + End If + DdlAlmacenOrigen.Enabled = False + + 'If GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveTipoAlmacen", $"CveAlmacen = {Mov.CveAlmacenDestino}").ToEntero = 16 Then + ' CveMov = CveMovimiento + ' LnkEnviarMail.Attributes.Add("onclick", "$('#ModalDivMail').modal();") + ' LnkEnviarMail.Visible = True + 'End If + + If Mov.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then + DtMovimientos = Mov.DtResultados.DefaultView.ToTable("Cantidad, CveUM, CvePS, CveAF, PS, SerieLote, CveClasificacion, EstatusExistencia") + CargaGvDatos() + End If + + Else + Alert("El movimiento solicitado no existe. ", TipoMensaje.MsgAdvertencia) + End If + Else + Alert("Ocurrió un error al cargar el movimiento a traspasar. Por favor vuelva a intentar.", TipoMensaje.MsgError) + End If + + Mov.Dispose() + UpMov.Update() + End Sub + + Private Sub AlmacenTransitorioDefaults() + ChkTransitorio.Checked = UsuarioActual.Empresa.Funcionalidad(154).ToString.ToEntero > 0 + ChkTransitorio.Enabled = Not UsuarioActual.Empresa.Funcionalidad(154).ToString.ToEntero > 0 + End Sub + + Private Sub CargaCombos() + + 'Llenar Clasificaciones + If UsuarioActual.CveEmpresa = 66 Then + DdlClasificacion.DataSource = GlobalDTSubFamilias(UsuarioActual.CveEmpresa).FiltraParametros("", Orderby:="Clasificacion") + Else + DdlClasificacion.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltraParametros(" Codigo = '' OR Codigo IS NULL ", Orderby:="Clasificacion") + End If + DdlClasificacion.DataBind() + + 'Llena Almacen Origen + CargaAlmacenOrigen() + 'DdlAlmacenOrigen.Items.Insert(0, New ListItem("Seleccione", "-1")) + + 'Dim dtAlm As DataTable = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 1) + 'dtAlm.Merge(GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 2)) + + 'Llena Almacen Destino, todos los almacenes destino, + + DdlAlmacenDestino.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoAlmacen NOT IN (3,4,9,10,11) AND Estatus = 'Activo'") + 'DdlAlmacenDestino.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen <> 4") + DdlAlmacenDestino.DataBind() + DdlAlmacenDestino.Items.Insert(0, New ListItem("Seleccione", "-1")) + + 'Llena Almacen Transitorio + DdlAlmacenTransitorio.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 3) + DdlAlmacenTransitorio.DataBind() + DdlAlmacenTransitorio.Items.Insert(0, New ListItem("Seleccione", "-1")) + + 'Llena Almacen Recepcion + DdlAlmacenRecepcion.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen NOT IN (3,4,9,10,11)") + DdlAlmacenRecepcion.DataBind() + DdlAlmacenRecepcion.Items.Insert(0, New ListItem("Todos", "-1")) + + 'Llena Almacen Transitorio Recepcion + DdlAlmacenTransitorioRecepcion.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 3) + DdlAlmacenTransitorioRecepcion.DataBind() + DdlAlmacenTransitorioRecepcion.Items.Insert(0, New ListItem("Seleccione", "-1")) + + ''Llena Almacen Recibe + 'DdlAlmacenRecibe.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + 'DdlAlmacenRecibe.DataBind() + + 'Llena Unidaddes Medida + DdlUnidad.DataSource = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa) + DdlUnidad.DataBind() + + 'Llena Choferes + Dim ObjAcar As New ClsAcarreos() + If ObjAcar.GetChofer(-1, UsuarioActual.CveEmpresa, 1, -1) Then + DdlChofer.DataSource = ObjAcar.DtResultados + DdlChofer.DataBind() + End If + ObjAcar.Dispose() + DdlChofer.Items.Insert(0, New ListItem("Seleccione", "-1")) + TxtFechaEntrega.Text = Now.ToShortDateString + + 'Llena Responsables Transitorio + 'DdlResponsable.DataSource = GlobalDTUsuarios(-1, UsuarioActual.CveEmpresa) + 'DdlResponsable.DataBind() + 'DdlResponsable.Items.Insert(0, New ListItem("Seleccione", "-1")) + + 'Llena Responsables Transitorio recepcion + 'DdlResponsableRecepcion.DataSource = GlobalDTUsuarios(-1, UsuarioActual.CveEmpresa) + 'DdlResponsableRecepcion.DataBind() + 'DdlResponsableRecepcion.Items.Insert(0, New ListItem("Seleccione", "-1")) + + 'Llenar el dropdownlist de Productos y servicios + + 'If UsuarioActual.Empresa.Funcionalidad(105) = "" Then + + ' DdlProducto.DataSource = GlobalDTProductosServicios(UsuarioActual.CveEmpresa) + ' DdlProducto.DataBind() + ' DdlProducto.Items.Insert(0, New ListItem("----", "-1")) + ' DdlProductows.Visible = False + 'Else + ' DdlProducto.Visible = False + 'End If + + CargaPS() + + 'Folio + SiguienteFolio(If(ChkTransitorio.Checked, 9, 8)) + + 'DdlProducto.DataBind() + CargarCamiones() + End Sub + Private Sub CargaAlmacenOrigen() + DdlAlmacenOrigen.Enabled = True + DdlAlmacenOrigen.Items.Clear() + DdlAlmacenOrigen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen NOT IN (3,4,9,10,11,21)") + DdlAlmacenOrigen.Items.Insert(0, New ListItem(" Seleccione ", "-1")) + DdlAlmacenOrigen.SelectedValue = "-1" + DdlAlmacenOrigen.DataBind() + DdlAlmacenOrigen.SelectedValueExist(UsuarioActual.CveAlmacen) + End Sub + Private Sub CargaPS() + 'DdlProducto2.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1") + + 'If Not DdlProducto2.UsaWebService AndAlso CType(DdlProducto2.DataSource, DataTable) Is Nothing Then + ' DdlProducto2.DataSource = GlobalDTProductosServicios(UsuarioActual.CveEmpresa) + ' DdlProducto2.DataBind() + 'End If + + Dim EsWS = If(UsuarioActual.Empresa.Funcionalidad(105) = "1" Or UsuarioActual.Empresa.Funcionalidad(141) = "1", True, False) + DdlProducto2.setEsWebService(EsWS) + + If DdlProducto2.UsaWebService Then + DdlProducto2.ddlWS.Attributes.Add("data-cveclasificacion", DdlClasificacion.SelectedValue) + If UsuarioActual.Empresa.Funcionalidad(141) = "1" Then + DdlProducto2.ddlWS.Attributes.Add("data-pagina", "inv/traspaso") + DdlProducto2.ddlWS.Attributes.Add("Data-onresult", "CargaExistenciaAlmacenes") + CargaExistenciasSucursal() + DdlAlmacenOrigen.AutoPostBack = True + End If + ElseIf Not DdlProducto2.UsaWebService AndAlso CType(DdlProducto2.DataSource, DataTable) Is Nothing Then + DdlProducto2.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=DdlClasificacion.SelectedValue.ToEntero).FiltraParametros("CveTipoPS = 2") + DdlProducto2.DataBind() + End If + + End Sub + Protected Sub DdlAlmacenOrigen_SelectedIndexChanged(sender As Object, e As EventArgs) + If UsuarioActual.Empresa.Funcionalidad(141) = "1" Then + CargaExistenciasSucursal() + End If + End Sub + Protected Sub DdlAlmacenDestino_SelectedIndexChanged(sender As Object, e As EventArgs) + If GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveTipoAlmacen", $"CveAlmacen = {DdlAlmacenDestino.SelectedValue.ToEntero}").ToString.ToEntero = 21 Then + ChkTransitorio.Checked = False + ChkTransitorio.Enabled = False + Else + ChkTransitorio.Enabled = True + End If + End Sub + Private Sub CargaExistenciasSucursal() + DdlProducto2.Attributes.Remove("Data-cvesubproyecto") + DdlProducto2.Attributes.Add("Data-cvesubproyecto", GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveSubProyecto", $"CveAlmacen = {DdlAlmacenOrigen.SelectedValue}")) + End Sub + Private Sub SiguienteFolio(CveConcepto As Integer) + 'Dim Inv As New ClsInventarios + 'Dim Folio As Integer = Inv.GetFolioSiguiente(CveConcepto, UsuarioActual.CveEmpresa) + 'Inv.Dispose() + + 'TxtFolio.Text = Folio.ToString + End Sub +#End Region + +#Region " AGREGAR " + Protected Sub btnAgregar_Click(sender As Object, e As EventArgs) Handles LbAgregar.Click + BtnAgregarPS(txtCantidad.Text.ToDecimal) + End Sub + Protected Sub BtnSerieAddNew_Click(sender As Object, e As EventArgs) + BtnAgregarPS(1) + End Sub + Private Sub BtnAgregarPS(Cantidad As Decimal) + Dim CveProducto As Integer = DdlProducto2.SelectedValue.ToEntero + Dim FuncionalidadSinSerie = True + + If CveProducto > 0 Then + If TxtnSerieLote.Visible Then + Cantidad = 1 + If TxtnSerieLote.Text = "" Then + Alert("Serie-Lote es necesario", TipoMensaje.MsgAdvertencia) + RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')") + Exit Sub + End If + If txtCantidad.Text.ToDouble > 1 Then + FuncionalidadSinSerie = False + End If + End If + Dim DrPS As DataRow = Nothing + + DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CveProducto).FiltroPrimero("") ' Estado = -1 + + If Cantidad > 0 AndAlso DrPS("VentaMinima").ToString.ToDecimal > 0 Then + 'verifico que la cantidad sea multiplo de venta minima, es decir ventaminima =5, solo puede vender 5,10,15... + If Cantidad Mod DrPS("VentaMinima").ToString.ToDecimal <> 0 Then + Alert(String.Format("El producto se vende solo en cantidades de {0:#,###.####}", DrPS("VentaMinima"))) + Exit Sub + End If + End If + + Dim Valido = ValidaExistencia(Cantidad, CveProducto, DdlUnidad.SelectedValue.ToEntero, If(TxtnSerieLote.Visible, TxtnSerieLote.Text, "-1"), If(TxtnLote.Visible, TxtnLote.Text, "-1"), If(TxtnBatch.Visible, TxtnBatch.Text, "-1")) + + If Valido Then + AgregarPS(Cantidad, CveProducto, DdlUnidad.SelectedValue.ToEntero, TxtnObservaciones.Text, If(TxtnSerieLote.Visible, TxtnSerieLote.Text, ""), If(TxtnLote.Visible, TxtnLote.Text, ""), If(TxtnBatch.Visible, TxtnBatch.Text, ""), FuncionalidadSinSerie) + End If + + End If + End Sub + Private Function ValidaExistencia(Cantidad As Double, CvePS As Integer, CveUnidadMedida As Integer, Optional SerieLote As String = "-1", Optional Lote As String = "-1", Optional Batch As String = "-1") As Boolean + Dim Retorno = True + + Dim Inv As New ClsInventarios + Dim Existencia As Double = Inv.GetExistenciasPS(CvePS, CveUnidadMedida, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDate.ToString("yyyy/MM/dd 23:59"), SerieLote:=SerieLote, Lote:=Lote, Batch:=Batch, PendientePorSurtir:=1) + Inv.Dispose() + + If Existencia - Cantidad - DtMovimientos.SUM("Cantidad", $"CvePS = {CvePS} AND CveUM = {CveUnidadMedida} {If(SerieLote <> "-1", $" AND SerieLote = '{SerieLote}'", "")}") < 0 Then + If Existencia < 0 Then + Alert("No hay existencia del producto", TipoMensaje.MsgAdvertencia) + RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')") + Else + Alert(String.Format("Solo hay en existencia: {0}", Existencia), TipoMensaje.MsgAdvertencia) + RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')") + End If + Retorno = False + End If + + Return Retorno + End Function + Private Sub AgregarPS(Cantidad As Double, CvePS As Integer, CveUnidadMedida As Integer, Optional Observaciones As String = "", Optional SerieLote As String = "", Optional Lote As String = "", Optional Batch As String = "", Optional Limpia As Boolean = True) + If Cantidad <= 0 Then + Alert("La cantidad debe ser mayor a cero (0). Por favor verifique y vuelva a intentar", TipoMensaje.MsgAdvertencia) + RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") + End If + + Dim CveClasificacion As Integer + + Dim DrPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("") + If DrPS IsNot Nothing Then CveClasificacion = DrPS("CveClasificacion").ToString.ToEntero + + Dim DrUM = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa).FiltroPrimero($"CveUnidadMedida = {CveUnidadMedida}") + + Dim registro As DataRow = DtMovimientos.NewRow + registro.Item("Cantidad") = Cantidad + registro.Item("CveUM") = CveUnidadMedida + registro.Item("UM") = DrUM("UnidadMedida") + registro.Item("UnidadMedida") = DrUM("UnidadMedida") + registro.Item("CvePS") = CvePS + registro.Item("PS") = DrPS("PSCodigo") + registro.Item("Observaciones") = Observaciones + registro.Item("SerieLote") = SerieLote + registro.Item("Lote") = Lote + registro.Item("Batch") = Batch + registro.Item("CveClasificacion") = CveClasificacion + registro.Item("CveAF") = -1 + registro.Item("EstatusExistencia") = "1" + + registro.Item("TotalImporte") = 0 + registro.Item("PU") = 0 + registro.Item("Descuento") = 0 + registro.Item("SATClaveUM") = DrPS("SATClaveUnidadMedida") + registro.Item("SATClaveProdServ") = DrPS("SATClavePS") + registro.Item("Noidentificacion") = DrPS("Codigo") + registro.Item("CuentaPredial") = "" + registro.Item("Obs") = "" + registro.Item("ImporteIVA") = 0 + registro.Item("PorcentajeIVA") = 0 + + + DtMovimientos.Rows.Add(registro) + RegistraScript("playsonidito('beep-07.wav')") + CargaGvDatos() + + If Limpia Then + LimpiaAgregar() + Else + txtCantidad.Text = (txtCantidad.Text.ToDouble - 1.0).ToString + TxtnSerieLote.Text = "" + TxtnSerieLote.Focus() + End If + End Sub + + Private Sub LimpiaAgregar() + DdlClasificacion.SelectedValue = "-1" + DdlClasificacion_SelectedIndexChanged(DdlClasificacion, EventArgs.Empty) + txtCantidad.Text = "" + TxtnObservaciones.Text = "" + TxtnSerieLote.Text = "" + TxtnSerieLote.Visible = False + TxtnLote.Text = "" + TxtnBatch.Text = "" + + txtCantidad.Focus() + If TxtCodigoPS.Visible Then + TxtCodigoPS.Focus() + End If End Sub -#End Region +#End Region + +#Region " GUARDAR " + Protected Sub BtnGuardar_Click(sender As Object, e As EventArgs) Handles BtnGuardar.Click + + 'VALIDA ALMACEN ORIGEN Y DESTINO + If DdlAlmacenOrigen.SelectedValue = DdlAlmacenDestino.SelectedValue Then + Alert("No se puede realizar un traspaso entre el mismo almacén.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + 'VALIDA TRANSITORIO + If ChkTransitorio.Checked Then + If TxtResponsable.Text.Trim = "" And Not UsuarioActual.CveEmpresa.Contiene(119) 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 -#Region " GUARDAR " - Protected Sub BtnGuardar_Click(sender As Object, e As EventArgs) Handles BtnGuardar.Click - - 'VALIDA ALMACEN ORIGEN Y DESTINO - If DdlAlmacenOrigen.SelectedValue = DdlAlmacenDestino.SelectedValue Then - Alert("No se puede realizar un traspaso entre el mismo almacén.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - 'VALIDA TRANSITORIO - If ChkTransitorio.Checked Then - If TxtResponsable.Text.Trim = "" And Not UsuarioActual.CveEmpresa.Contiene(119) 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 - If DdlChofer.SelectedValue.ToEntero <= 0 And UsuarioActual.CveEmpresa.Contiene(119) Then Alert("Debe seleccionar un Chofer", TipoMensaje.MsgAdvertencia) - RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')") - If ChkTransitorio.Checked Then RegistraScript("$('#DivTransitorio').show(200);") + RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')") + If ChkTransitorio.Checked Then RegistraScript("$('#DivTransitorio').show(200);") Exit Sub - End If - End If - - 'VALIDA ALMACEN DISTINTA SUCURSAL DEBE SER TRANSITORIO - If Not UsuarioActual.CveEmpresa.Contiene(7, 140) Then '[IPP] EMPRESA VIGILANCIA NO OCUPA TRANSITORIOS - TIENEN MIL SUCURSALES Xd - If Not ChkTransitorio.Checked Then - 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 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") - ChkTransitorio.Checked = True - If ChkTransitorio.Checked Then RegistraScript("$('#DivTransitorio').show(200);", "MuestraDivTransitorio") - Exit Sub - End If - End If - End If - End If - - 'VALIDA QUE TENGA MOVTOS - If Not GvDatos.Rows.Count > 0 Then - Alert("No hay movimientos para el traspaso", TipoMensaje.MsgAdvertencia) - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - Exit Sub - End If - - 'VALIDA ESTATUS EXISTENCIA - For Each dr As DataRow In DtMovimientos.Rows - If dr("EstatusExistencia").ToString = "-1" Then - Alert("Tiene que rectificar los movimientos con error.", TipoMensaje.MsgError) - If ChkTransitorio.Checked Then RegistraScript("$('#DivTransitorio').show(200);") - Exit Sub - End If - Next - - Dim ObjInventario As New ClsInventarios - - 'VALIDA LA EXISTENCIA DEL ALMACEN DE ORIGEN - Dim ErrorExistencia = False - Dim TextoExistencia As StringBuilder = New StringBuilder - Dim Existencia As Double - TextoExistencia.Append("Los siguiente productos se ajustaron por falta de exitencia:
") - If Not CargadoDeMov Then - - For Each dr As DataRow In DtMovimientos.Rows - Existencia = ObjInventario.GetExistenciasPS(dr("CvePS").ToString.ToEntero, dr("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDate.ToString("yyyy/MM/dd 23:59"), SerieLote:=If(dr("SerieLote").ToString = "", "-1", dr("SerieLote").ToString), PendientePorSurtir:=1) - Existencia -= DtMovimientos.SUM("Cantidad", $"CvePS = {dr("CvePS").ToString.ToEntero} AND CveUM = {dr("CveUM").ToString.ToEntero} {If(dr("SerieLote").ToString <> "-1", $" AND SerieLote = '{dr("SerieLote").ToString}'", "")}") - 'DtMovimientos.SUM("Cantidad", String.Format("CvePS = {0}", dr("CvePS").ToString.ToEntero)) - - If Existencia < 0 Then - ErrorExistencia = True - dr("EstatusExistencia") = "-1" - dr("Cantidad") = Existencia - 'If Existencia <= 0 Then - TextoExistencia.AppendFormat("- #{0} {1}
", dr("No").ToString, dr("PS").ToString) - 'Else - 'Alert(String.Format("Solo hay en existencia: {0}", Existencia), TipoMensaje.MsgError) - 'End If - End If - Next - Else - For Each gvr As GridViewRow In GvDatos.Rows - Existencia = ObjInventario.GetExistenciasPS(gvr.DataKey("CvePS").ToString.ToEntero, gvr.DataKey("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDate.ToString("yyyy/MM/dd 23:59"), SerieLote:=If(gvr.DataKey("SerieLote").ToString = "", "-1", gvr.DataKey("SerieLote").ToString), PendientePorSurtir:=1) - Existencia -= gvr.FCTextBox("TxtCantidad2").Text.ToEntero - If Existencia < 0 Then - ErrorExistencia = True - - gvr.FCTextBox("TxtCantidad2").Text = (Existencia + gvr.FCTextBox("TxtCantidad2").Text.ToEntero).ToString - TextoExistencia.AppendFormat("- #{0} {1}
", gvr.DataKey("No").ToString, gvr.DataKey("PS").ToString) - End If - Next - End If - - If ErrorExistencia Then - Alert(TextoExistencia.ToString, TipoMensaje.MsgError) - RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')") - ObjInventario.Dispose() - Exit Sub - End If - - Dim TotalCantidad As Decimal = DtMovimientos.SUMD("Cantidad") - If UsuarioActual.Empresa.Funcionalidad(563) = "1" Then - If TotalCantidad <> DtSeccionAlmacen.FiltraParametros("TipoSeccionAlmacen = 1").SUMD("CantidadSeccionAlmacen") Then - Alert("La seccion de almacen no ha sido agregada completamente.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - End If - - - Dim TipoAlmacenOrigen = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveTipoAlmacen", $"CveAlmacen = {DdlAlmacenOrigen.SelectedValue.ToEntero}").ToEntero - Dim TipoAlmacenDestino = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveTipoAlmacen", $"CveAlmacen = {DdlAlmacenDestino.SelectedValue.ToEntero}").ToEntero - - ''[IPP-1Noviembre2018] SE COMENTA PORQUE NO TIENE NI PIES NI CABEZA. LE FALTA DESARROLLO - 'If (TipoAlmacenOrigen = 14 Or TipoAlmacenDestino = 14) And TipoAlmacenOrigen <> TipoAlmacenDestino Then - ' ObjInventario.Dispose() - ' 'es consumo interno - ' ConsumoInterno(TipoAlmacenOrigen, TipoAlmacenDestino) - 'End If - - 'Inicia la transacción - Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL()) - Dim CveMovimientoSalida = 0 - Dim CveMovimientoEntrada = 0 - Dim IDPoliza As Integer = 0 - Dim FolioSalida = 0 + End If + End If + + 'VALIDA ALMACEN DISTINTA SUCURSAL DEBE SER TRANSITORIO + If Not UsuarioActual.CveEmpresa.Contiene(7, 140) Then '[IPP] EMPRESA VIGILANCIA NO OCUPA TRANSITORIOS - TIENEN MIL SUCURSALES Xd + If Not ChkTransitorio.Checked Then + 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 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") + ChkTransitorio.Checked = True + If ChkTransitorio.Checked Then RegistraScript("$('#DivTransitorio').show(200);", "MuestraDivTransitorio") + Exit Sub + End If + End If + End If + End If + + 'VALIDA QUE TENGA MOVTOS + If Not GvDatos.Rows.Count > 0 Then + Alert("No hay movimientos para el traspaso", TipoMensaje.MsgAdvertencia) + RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") + Exit Sub + End If + + 'VALIDA ESTATUS EXISTENCIA + For Each dr As DataRow In DtMovimientos.Rows + If dr("EstatusExistencia").ToString = "-1" Then + Alert("Tiene que rectificar los movimientos con error.", TipoMensaje.MsgError) + If ChkTransitorio.Checked Then RegistraScript("$('#DivTransitorio').show(200);") + Exit Sub + End If + Next + + Dim ObjInventario As New ClsInventarios + + 'VALIDA LA EXISTENCIA DEL ALMACEN DE ORIGEN + Dim ErrorExistencia = False + Dim TextoExistencia As StringBuilder = New StringBuilder + Dim Existencia As Double + TextoExistencia.Append("Los siguiente productos se ajustaron por falta de exitencia:
") + If Not CargadoDeMov Then + + For Each dr As DataRow In DtMovimientos.Rows + Existencia = ObjInventario.GetExistenciasPS(dr("CvePS").ToString.ToEntero, dr("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDate.ToString("yyyy/MM/dd 23:59"), SerieLote:=If(dr("SerieLote").ToString = "", "-1", dr("SerieLote").ToString), PendientePorSurtir:=1) + Existencia -= DtMovimientos.SUM("Cantidad", $"CvePS = {dr("CvePS").ToString.ToEntero} AND CveUM = {dr("CveUM").ToString.ToEntero} {If(dr("SerieLote").ToString <> "-1", $" AND SerieLote = '{dr("SerieLote").ToString}'", "")}") + 'DtMovimientos.SUM("Cantidad", String.Format("CvePS = {0}", dr("CvePS").ToString.ToEntero)) + + If Existencia < 0 Then + ErrorExistencia = True + dr("EstatusExistencia") = "-1" + dr("Cantidad") = Existencia + 'If Existencia <= 0 Then + TextoExistencia.AppendFormat("- #{0} {1}
", dr("No").ToString, dr("PS").ToString) + 'Else + 'Alert(String.Format("Solo hay en existencia: {0}", Existencia), TipoMensaje.MsgError) + 'End If + End If + Next + Else + For Each gvr As GridViewRow In GvDatos.Rows + Existencia = ObjInventario.GetExistenciasPS(gvr.DataKey("CvePS").ToString.ToEntero, gvr.DataKey("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDate.ToString("yyyy/MM/dd 23:59"), SerieLote:=If(gvr.DataKey("SerieLote").ToString = "", "-1", gvr.DataKey("SerieLote").ToString), PendientePorSurtir:=1) + Existencia -= gvr.FCTextBox("TxtCantidad2").Text.ToEntero + If Existencia < 0 Then + ErrorExistencia = True + + gvr.FCTextBox("TxtCantidad2").Text = (Existencia + gvr.FCTextBox("TxtCantidad2").Text.ToEntero).ToString + TextoExistencia.AppendFormat("- #{0} {1}
", gvr.DataKey("No").ToString, gvr.DataKey("PS").ToString) + End If + Next + End If + + If ErrorExistencia Then + Alert(TextoExistencia.ToString, TipoMensaje.MsgError) + RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')") + ObjInventario.Dispose() + Exit Sub + End If + + Dim TotalCantidad As Decimal = DtMovimientos.SUMD("Cantidad") + If UsuarioActual.Empresa.Funcionalidad(563) = "1" Then + If TotalCantidad <> DtSeccionAlmacen.FiltraParametros("TipoSeccionAlmacen = 1").SUMD("CantidadSeccionAlmacen") Then + Alert("La seccion de almacen no ha sido agregada completamente.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + End If + + + Dim TipoAlmacenOrigen = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveTipoAlmacen", $"CveAlmacen = {DdlAlmacenOrigen.SelectedValue.ToEntero}").ToEntero + Dim TipoAlmacenDestino = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveTipoAlmacen", $"CveAlmacen = {DdlAlmacenDestino.SelectedValue.ToEntero}").ToEntero + + ''[IPP-1Noviembre2018] SE COMENTA PORQUE NO TIENE NI PIES NI CABEZA. LE FALTA DESARROLLO + 'If (TipoAlmacenOrigen = 14 Or TipoAlmacenDestino = 14) And TipoAlmacenOrigen <> TipoAlmacenDestino Then + ' ObjInventario.Dispose() + ' 'es consumo interno + ' ConsumoInterno(TipoAlmacenOrigen, TipoAlmacenDestino) + 'End If + + 'Inicia la transacción + Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL()) + Dim CveMovimientoSalida = 0 + Dim CveMovimientoEntrada = 0 + Dim IDPoliza As Integer = 0 + Dim FolioSalida = 0 Dim CveMovimientoVirtualEntrada As Integer = 0 Dim CveMovimientoVirtualSalida As Integer = 0 Dim FolioVirtualEntrada As Integer = 0 Dim FolioVirtualSalida As Integer = 0 - Dim FolioEntrada = 0 - Dim AlmacenEntrada = -1 - Dim Fecha As Date = TxtFecha.Text.ToDate - Dim ErrorMovInv As Boolean = False - Dim ErrorAC As Boolean = False - Dim TextoError = "" - Dim TipoMovimientoSalida As Integer = 26 'If(ChkTransitorio.Checked, 26, If(TipoAlmacenOrigen = 24, 26, 26)) - - 'AGREGAMOS LA SALIDA DEL ALMACEN ORIGEN - CveMovimientoSalida = ObjInventario.AddMovimiento(DdlAlmacenOrigen.SelectedValue.ToEntero, TipoMovimientoSalida, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, - Observaciones:=TxtObservaciones.Text.Trim, Recibio:=If(ChkTransitorio.Checked, TxtResponsable.Text.Trim, "-1"), - CveAlmacenDestino:=DdlAlmacenDestino.SelectedValue.ToEntero, GastoIndirecto:=If(ChkTransitorio.Checked And TxtGastoIndirecto.Text.ToDouble > 0, TxtGastoIndirecto.Text, "-1").ToDouble, - CveChofer:=If(ChkTransitorio.Checked, DdlChofer.SelectedValue.ToEntero, -1), Placa:=If(ChkTransitorio.Checked, TxtPlaca.Text.Trim, "-1"), FechaEntrega:=If(ChkTransitorio.Checked, TxtFechaEntrega.Text.Trim.ToDateTime.ToString("dd/MM/yyyy"), "-1"), EspecifUnidad:=If(ChkTransitorio.Checked, TxtEspecifUnidad.Text.Trim, "-1"), - ResponsableCarga:=If(ChkTransitorio.Checked, TxtResponsableCarga.Text.Trim, "-1"), ResponsableRecibio:=If(ChkTransitorio.Checked, TxtResponsableRecibio.Text.Trim, "-1"), Identificacion:=If(ChkTransitorio.Checked, TxtIdentificacion.Text.Trim, "-1"), Domicilio:=If(ChkTransitorio.Checked, TxtDomicilio.Text.Trim, "-1"), - Telefono:=If(ChkTransitorio.Checked, TxtTelefono.Text.Trim, "-1"), Ciudad:=If(ChkTransitorio.Checked, TxtCiudad.Text.Trim, "-1"), Licencia:=If(ChkTransitorio.Checked, TxtLicencia.Text.Trim, "-1"), Modulo:="TA/G2") - FolioSalida = ObjInventario.Folio - Folio = ObjInventario.Folio - If CveMovimientoSalida <= 0 Then - TextoError = "Ocurrió un error al generar el movimiento de salida" - ErrorMovInv = True - Else - Dim Cont As Integer = 0 - For Each Dr As DataRow In DtMovimientos.Rows - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, Observaciones:=Dr("Observaciones").ToString) Then - ErrorMovInv = True - TextoError = "Ocurrió un error al guardar los movimientos de salida" - Exit For - Else - If ObjInventario.CveMovimientoDetalle > 0 AndAlso DtSeccionAlmacen.Rows.Count > 0 Then - For Each Dr2 As DataRow In DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {Cont} AND TipoSeccionAlmacen = 1").Rows - If Not ObjInventario.AddMovimientosDetalleSeccionesAlmacen(ObjInventario.CveMovimientoDetalle, Dr2("CveSeccionAlmacenOrigen").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 - End If - Cont += 1 - Next + Dim FolioEntrada = 0 + Dim AlmacenEntrada = -1 + Dim Fecha As Date = TxtFecha.Text.ToDate + Dim ErrorMovInv As Boolean = False + Dim ErrorAC As Boolean = False + Dim TextoError = "" + Dim TipoMovimientoSalida As Integer = 26 'If(ChkTransitorio.Checked, 26, If(TipoAlmacenOrigen = 24, 26, 26)) + + 'AGREGAMOS LA SALIDA DEL ALMACEN ORIGEN + CveMovimientoSalida = ObjInventario.AddMovimiento(DdlAlmacenOrigen.SelectedValue.ToEntero, TipoMovimientoSalida, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, + Observaciones:=TxtObservaciones.Text.Trim, Recibio:=If(ChkTransitorio.Checked, TxtResponsable.Text.Trim, "-1"), + CveAlmacenDestino:=DdlAlmacenDestino.SelectedValue.ToEntero, GastoIndirecto:=If(ChkTransitorio.Checked And TxtGastoIndirecto.Text.ToDouble > 0, TxtGastoIndirecto.Text, "-1").ToDouble, + CveChofer:=If(ChkTransitorio.Checked, DdlChofer.SelectedValue.ToEntero, -1), Placa:=If(ChkTransitorio.Checked, TxtPlaca.Text.Trim, "-1"), FechaEntrega:=If(ChkTransitorio.Checked, TxtFechaEntrega.Text.Trim.ToDateTime.ToString("dd/MM/yyyy"), "-1"), EspecifUnidad:=If(ChkTransitorio.Checked, TxtEspecifUnidad.Text.Trim, "-1"), + ResponsableCarga:=If(ChkTransitorio.Checked, TxtResponsableCarga.Text.Trim, "-1"), ResponsableRecibio:=If(ChkTransitorio.Checked, TxtResponsableRecibio.Text.Trim, "-1"), Identificacion:=If(ChkTransitorio.Checked, TxtIdentificacion.Text.Trim, "-1"), Domicilio:=If(ChkTransitorio.Checked, TxtDomicilio.Text.Trim, "-1"), + Telefono:=If(ChkTransitorio.Checked, TxtTelefono.Text.Trim, "-1"), Ciudad:=If(ChkTransitorio.Checked, TxtCiudad.Text.Trim, "-1"), Licencia:=If(ChkTransitorio.Checked, TxtLicencia.Text.Trim, "-1"), Modulo:="TA/G2") + FolioSalida = ObjInventario.Folio + Folio = ObjInventario.Folio + If CveMovimientoSalida <= 0 Then + TextoError = "Ocurrió un error al generar el movimiento de salida" + ErrorMovInv = True + Else + Dim Cont As Integer = 0 + For Each Dr As DataRow In DtMovimientos.Rows + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, Observaciones:=Dr("Observaciones").ToString) Then + ErrorMovInv = True + TextoError = "Ocurrió un error al guardar los movimientos de salida" + Exit For + Else + If ObjInventario.CveMovimientoDetalle > 0 AndAlso DtSeccionAlmacen.Rows.Count > 0 Then + For Each Dr2 As DataRow In DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {Cont} AND TipoSeccionAlmacen = 1").Rows + If Not ObjInventario.AddMovimientosDetalleSeccionesAlmacen(ObjInventario.CveMovimientoDetalle, Dr2("CveSeccionAlmacenOrigen").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 + End If + Cont += 1 + Next End If @@ -832,7 +832,7 @@ Partial Class Inventarios_TraspasoAlmacen For Each RowVirtual As DataRow In dtvirtual.Rows Dim CvePS = RowVirtual("CvePS").ToString().ToEntero() Dim CantidadUsado As Double = RowVirtual("Cantidad").ToString().ToDouble() - Dim PU As Double = RowVirtual("PU").ToString().ToDouble() + Dim PU As Decimal = RowVirtual("PU").ToString().ToDecimal() Dim CveUM As Integer = RowVirtual("CveUM").ToString().ToEntero() If Not ObjInventario.AddMovimientoDetalle(CveMovimientoVirtualSalida, CantidadUsado, CveUM, CvePS, PU, -1, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then @@ -846,39 +846,39 @@ Partial Class Inventarios_TraspasoAlmacen End If 'AGREGAMOS LA ENTRADA - If Not ChkTransitorio.Checked Then 'SI NO ES TRANSITORIO SE HACE LA RECEPCION DE INMEDIATO - If Not ErrorMovInv Then - Dim TipoMovimientoEntrada = 27 - AlmacenEntrada = If(ChkTransitorio.Checked, DdlAlmacenTransitorio.SelectedValue.ToEntero, DdlAlmacenDestino.SelectedValue.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") - FolioEntrada = ObjInventario.Folio - If CveMovimientoEntrada <= 0 Then - TextoError = "Ocurrió un error al generar el movimiento de entrada" - ErrorMovInv = True - Else - 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.ToDouble, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, Observaciones:=Dr("Observaciones").ToString) Then - ErrorMovInv = True - TextoError = "Ocurrió un error al guardar los movimientos de entrada" - Exit For - Else - If ObjInventario.CveMovimientoDetalle > 0 AndAlso DtSeccionAlmacen.Rows.Count > 0 Then - For Each Dr2 As DataRow In DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {Cont} AND TipoSeccionAlmacen = 1").Rows - If Not ObjInventario.AddMovimientosDetalleSeccionesAlmacen(ObjInventario.CveMovimientoDetalle, Dr2("CveSeccionAlmacenDestino").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 - End If - Cont += 1 - Next - End If + If Not ChkTransitorio.Checked Then 'SI NO ES TRANSITORIO SE HACE LA RECEPCION DE INMEDIATO + If Not ErrorMovInv Then + Dim TipoMovimientoEntrada = 27 + AlmacenEntrada = If(ChkTransitorio.Checked, DdlAlmacenTransitorio.SelectedValue.ToEntero, DdlAlmacenDestino.SelectedValue.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") + FolioEntrada = ObjInventario.Folio + If CveMovimientoEntrada <= 0 Then + TextoError = "Ocurrió un error al generar el movimiento de entrada" + ErrorMovInv = True + Else + 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, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, Observaciones:=Dr("Observaciones").ToString) Then + ErrorMovInv = True + TextoError = "Ocurrió un error al guardar los movimientos de entrada" + Exit For + Else + If ObjInventario.CveMovimientoDetalle > 0 AndAlso DtSeccionAlmacen.Rows.Count > 0 Then + For Each Dr2 As DataRow In DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {Cont} AND TipoSeccionAlmacen = 1").Rows + If Not ObjInventario.AddMovimientosDetalleSeccionesAlmacen(ObjInventario.CveMovimientoDetalle, Dr2("CveSeccionAlmacenDestino").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 + End If + Cont += 1 + Next + End If End If 'VIRTUAL ENTRADA If UsuarioActual.Empresa.Funcionalidad(573) = "1" Then @@ -895,7 +895,7 @@ Partial Class Inventarios_TraspasoAlmacen For Each RowVirtual As DataRow In dtvirtual.Rows Dim CvePS = RowVirtual("CvePS").ToString().ToEntero() Dim CantidadUsado As Double = RowVirtual("Cantidad").ToString().ToDouble() - Dim PU As Double = RowVirtual("PU").ToString().ToDouble() + Dim PU As Decimal = RowVirtual("PU").ToString().ToDecimal() Dim CveUM As Integer = RowVirtual("CveUM").ToString().ToEntero() If Not ObjInventario.AddMovimientoDetalle(CveMovimientoVirtualEntrada, CantidadUsado, CveUM, CvePS, PU, -1, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then @@ -952,389 +952,389 @@ Partial Class Inventarios_TraspasoAlmacen End If End If End If - End If - - - - ''[IPP-1Noviembre2018] SE COMENTA PORQUE NO TIENE NI PIES NI CABEZA. LE FALTA DESARROLLO - ''CONSUMO INTERNO - 'If Not ErrorMovInv Then - ' If (TipoAlmacenOrigen = 14 Or TipoAlmacenDestino = 14) And TipoAlmacenOrigen <> TipoAlmacenDestino Then - ' ConsumoInterno(TipoAlmacenOrigen, TipoAlmacenDestino) - ' End If - 'End If - - If Not ErrorMovInv Then - DtTraslado = DtMovimientos.Copy - ObjInventario.Commit() - MensajeAlert = New StringBuilder - - MensajeAlert.Append("Se realizó con éxito el traspaso.") - - MensajeAlert.AppendFormat("
Folio de Salida: {0}", FolioSalida, CveMovimientoSalida) - MensajeAlert.AppendFormat("
Imprimir Reporte", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoSalida))) + End If + + + + ''[IPP-1Noviembre2018] SE COMENTA PORQUE NO TIENE NI PIES NI CABEZA. LE FALTA DESARROLLO + ''CONSUMO INTERNO + 'If Not ErrorMovInv Then + ' If (TipoAlmacenOrigen = 14 Or TipoAlmacenDestino = 14) And TipoAlmacenOrigen <> TipoAlmacenDestino Then + ' ConsumoInterno(TipoAlmacenOrigen, TipoAlmacenDestino) + ' End If + 'End If + + If Not ErrorMovInv Then + DtTraslado = DtMovimientos.Copy + ObjInventario.Commit() + MensajeAlert = New StringBuilder + + MensajeAlert.Append("Se realizó con éxito el traspaso.") + + MensajeAlert.AppendFormat("
Folio de Salida: {0}", FolioSalida, CveMovimientoSalida) + MensajeAlert.AppendFormat("
Imprimir Reporte", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoSalida))) If CveMovimientoVirtualSalida > 0 Then MensajeAlert.AppendFormat("
Folio: {2} Imprimir Salida Virtual", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoVirtualSalida)), CveMovimientoVirtualSalida, FolioVirtualSalida) - If Not ChkTransitorio.Checked Then - MensajeAlert.AppendFormat("

Folio de Entrada: {0}", FolioEntrada, CveMovimientoEntrada) - MensajeAlert.AppendFormat("
Imprimir Reporte", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoEntrada))) + If Not ChkTransitorio.Checked Then + MensajeAlert.AppendFormat("

Folio de Entrada: {0}", FolioEntrada, CveMovimientoEntrada) + MensajeAlert.AppendFormat("
Imprimir Reporte", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoEntrada))) If CveMovimientoVirtualEntrada > 0 Then MensajeAlert.AppendFormat("
Folio: {2} Imprimir Entrada Virtual", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoVirtualEntrada)), CveMovimientoVirtualEntrada, FolioVirtualEntrada) - End If - - 'DdlClasificacion.SelectedValue = "-1" - 'DdlClasificacion_SelectedIndexChanged(DdlClasificacion, EventArgs.Empty) - - If ChkEmitirTimbrado.Checked Then CveMovimientoTimbrado = CveMovimientoSalida : Timbrar() - - Alert(MensajeAlert.ToString, TipoMensaje.MsgInformacion, "") - - - If ChkTransitorio.Checked AndAlso UsuarioActual.CveEmpresa.Contiene(72, 80) Then - RegistraScript(String.Format("AbrirVentana('/General/PopUpPaqueteriasGuias.aspx?CveMovimiento={0}',800,620);", CveMovimientoSalida)) - End If - - If UsuarioActual.CveEmpresa.Contiene(72, 80) Then - Dim Correo As String = "jorgegonzalez@compuproveedores.com" - If GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveTipoAlmacen", $"CveAlmacen = {DdlAlmacenDestino.SelectedValue.ToEntero}").ToEntero = 16 Then - MandaCorreo(CveMovimientoSalida, Correo) - End If - End If - - LimpiaMovimiento() - - Else - ObjInventario.RollBack() - Alert(TextoError, TipoMensaje.MsgError) - RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')") - End If - - ' If ObjContaAC IsNot Nothing Then ObjContaAC.Dispose() - - 'SI OCURRIO UN ERROR EN LA EXISTENCIA RECARGAMOS EL GRID PARA COLOREAR LOS DETALLES CON ERROR - If ErrorExistencia Then - CargaGvDatos() - End If - ObjConta.Dispose() - ObjInventario.Dispose() - End Sub - - Function ConsumoInterno(TipoAlmacenOrigen As Integer, TipoAlmacenDestino As Integer) As Boolean - Dim Retorno As Boolean = False - Dim ErrorMovInv As Boolean = False - Dim TextoError As String = "" - Dim Fecha As Date = TxtFecha.Text.ToDate - - Dim ObjInventario As New ClsInventarios - Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL()) - Dim CveMovimiento As Integer = 0 - Dim TipoMovto = If(TipoAlmacenOrigen = 14, -1, 1) - Dim CveConceptoInventario As Integer = 8 - - - Dim CveAlmacenCI = If(TipoAlmacenOrigen = 14, DdlAlmacenOrigen.SelectedValue.ToEntero, DdlAlmacenDestino.SelectedValue.ToEntero) - Dim DtCostos As DataTable = Nothing - Dim ValorInventario As Decimal = 0 - - 'AGREGAMOS LA SALIDA DEL ALMACEN ORIGEN - CveMovimiento = ObjInventario.AddMovimiento(DdlAlmacenOrigen.SelectedValue.ToEntero, CveConceptoInventario, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, + End If + + 'DdlClasificacion.SelectedValue = "-1" + 'DdlClasificacion_SelectedIndexChanged(DdlClasificacion, EventArgs.Empty) + + If ChkEmitirTimbrado.Checked Then CveMovimientoTimbrado = CveMovimientoSalida : Timbrar() + + Alert(MensajeAlert.ToString, TipoMensaje.MsgInformacion, "") + + + If ChkTransitorio.Checked AndAlso UsuarioActual.CveEmpresa.Contiene(72, 80) Then + RegistraScript(String.Format("AbrirVentana('/General/PopUpPaqueteriasGuias.aspx?CveMovimiento={0}',800,620);", CveMovimientoSalida)) + End If + + If UsuarioActual.CveEmpresa.Contiene(72, 80) Then + Dim Correo As String = "jorgegonzalez@compuproveedores.com" + If GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveTipoAlmacen", $"CveAlmacen = {DdlAlmacenDestino.SelectedValue.ToEntero}").ToEntero = 16 Then + MandaCorreo(CveMovimientoSalida, Correo) + End If + End If + + LimpiaMovimiento() + + Else + ObjInventario.RollBack() + Alert(TextoError, TipoMensaje.MsgError) + RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')") + End If + + ' If ObjContaAC IsNot Nothing Then ObjContaAC.Dispose() + + 'SI OCURRIO UN ERROR EN LA EXISTENCIA RECARGAMOS EL GRID PARA COLOREAR LOS DETALLES CON ERROR + If ErrorExistencia Then + CargaGvDatos() + End If + ObjConta.Dispose() + ObjInventario.Dispose() + End Sub + + Function ConsumoInterno(TipoAlmacenOrigen As Integer, TipoAlmacenDestino As Integer) As Boolean + Dim Retorno As Boolean = False + Dim ErrorMovInv As Boolean = False + Dim TextoError As String = "" + Dim Fecha As Date = TxtFecha.Text.ToDate + + Dim ObjInventario As New ClsInventarios + Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL()) + Dim CveMovimiento As Integer = 0 + Dim TipoMovto = If(TipoAlmacenOrigen = 14, -1, 1) + Dim CveConceptoInventario As Integer = 8 + + + Dim CveAlmacenCI = If(TipoAlmacenOrigen = 14, DdlAlmacenOrigen.SelectedValue.ToEntero, DdlAlmacenDestino.SelectedValue.ToEntero) + Dim DtCostos As DataTable = Nothing + Dim ValorInventario As Decimal = 0 + + 'AGREGAMOS LA SALIDA DEL ALMACEN ORIGEN + CveMovimiento = ObjInventario.AddMovimiento(DdlAlmacenOrigen.SelectedValue.ToEntero, CveConceptoInventario, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Recibio:=If(ChkTransitorio.Checked, TxtResponsable.Text.Trim, ""), - GastoIndirecto:=If(ChkTransitorio.Checked And TxtGastoIndirecto.Text.ToDouble > 0, TxtGastoIndirecto.Text, "-1").ToDouble, Modulo:="TA/G4") - Dim FolioMov As Integer = ObjInventario.Folio - - If CveMovimiento <= 0 Then - TextoError = "No se pudo generar el movimiento de salida correctamente" - ErrorMovInv = True - Else - - For Each Dr As DataRow In DtMovimientos.Rows - If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString) Then - ErrorMovInv = True - TextoError = "Ocurrió un error al guardar los movimientos de salida" - Exit For - End If - Next - End If - - If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then - DtCostos = ObjInventario.DtResultados - Dim tmpCostos As DataTable = DtCostos.FiltraParametros("", "", {"CveClasificacion"}) - Dim IdCtaContable As Integer = 0 - Dim CveCuenta As Integer = 0 - - If tmpCostos.Rows.Count > 0 Then - Dim Concepto As String = $"Consumo Interno: {ObjInventario.Folio} - {TxtObservaciones.Text}" - Dim CvePrePoliza = ObjConta.AddPrePolizas("Inv/ConsumoInterno", 53, DtCostos.SUM("Total") * TipoMovto, DtCostos.SUM("Total") * TipoMovto, 1, TxtFecha.Text.ToDate, $"Consumo Interno: {TxtObservaciones.Text}", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - - For Each RowInv As DataRow In tmpCostos.Rows - ValorInventario = DtCostos.SUM("Total", $"CveClasificacion = {RowInv("CveClasificacion")}").ToString.ToDecimal - IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaGasto", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero - CveCuenta = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaGastoSIG", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ValorInventario * TipoMovto, Concepto, 181, Concepto, TxtFecha.Text.ToDate, IdCtaContable, -1, CveClasificacion:=RowInv("CveClasificacion").ToString.ToEntero, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=ValorInventario * TipoMovto, CveCuenta:=CveCuenta) Then - ErrorMovInv = True - Exit For - End If - Next - - IdCtaContable = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", $"CveAlmacen={CveAlmacenCI}").ToEntero - CveCuenta = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContableSIG", $"CveAlmacen={CveAlmacenCI}").ToEntero - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, DtCostos.SUM("Total").ToDecimal * TipoMovto, Concepto, 68, Concepto, TxtFecha.Text.ToDate, IdCtaContable, -1, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=DtCostos.SUM("Total").ToDecimal * TipoMovto, CveCuenta:=CveCuenta) Then - ErrorMovInv = True - End If - - End If - End If - - If Not ErrorMovInv Then - - ObjInventario.Commit() - Dim Mensaje As StringBuilder = New StringBuilder - - Mensaje.Append("Se realizó el consumo interno.") - - Mensaje.AppendFormat("
Folio: {0}", FolioMov, CveMovimiento) - + GastoIndirecto:=If(ChkTransitorio.Checked And TxtGastoIndirecto.Text.ToDouble > 0, TxtGastoIndirecto.Text, "-1").ToDouble, Modulo:="TA/G4") + Dim FolioMov As Integer = ObjInventario.Folio + + If CveMovimiento <= 0 Then + TextoError = "No se pudo generar el movimiento de salida correctamente" + ErrorMovInv = True + Else + + For Each Dr As DataRow In DtMovimientos.Rows + If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString) Then + ErrorMovInv = True + TextoError = "Ocurrió un error al guardar los movimientos de salida" + Exit For + End If + Next + End If + + If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then + DtCostos = ObjInventario.DtResultados + Dim tmpCostos As DataTable = DtCostos.FiltraParametros("", "", {"CveClasificacion"}) + Dim IdCtaContable As Integer = 0 + Dim CveCuenta As Integer = 0 + + If tmpCostos.Rows.Count > 0 Then + Dim Concepto As String = $"Consumo Interno: {ObjInventario.Folio} - {TxtObservaciones.Text}" + Dim CvePrePoliza = ObjConta.AddPrePolizas("Inv/ConsumoInterno", 53, DtCostos.SUM("Total") * TipoMovto, DtCostos.SUM("Total") * TipoMovto, 1, TxtFecha.Text.ToDate, $"Consumo Interno: {TxtObservaciones.Text}", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + + For Each RowInv As DataRow In tmpCostos.Rows + ValorInventario = DtCostos.SUM("Total", $"CveClasificacion = {RowInv("CveClasificacion")}").ToString.ToDecimal + IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaGasto", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero + CveCuenta = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaGastoSIG", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ValorInventario * TipoMovto, Concepto, 181, Concepto, TxtFecha.Text.ToDate, IdCtaContable, -1, CveClasificacion:=RowInv("CveClasificacion").ToString.ToEntero, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=ValorInventario * TipoMovto, CveCuenta:=CveCuenta) Then + ErrorMovInv = True + Exit For + End If + Next + + IdCtaContable = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", $"CveAlmacen={CveAlmacenCI}").ToEntero + CveCuenta = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContableSIG", $"CveAlmacen={CveAlmacenCI}").ToEntero + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, DtCostos.SUM("Total").ToDecimal * TipoMovto, Concepto, 68, Concepto, TxtFecha.Text.ToDate, IdCtaContable, -1, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=DtCostos.SUM("Total").ToDecimal * TipoMovto, CveCuenta:=CveCuenta) Then + ErrorMovInv = True + End If + + End If + End If + + If Not ErrorMovInv Then + + ObjInventario.Commit() + Dim Mensaje As StringBuilder = New StringBuilder + + Mensaje.Append("Se realizó el consumo interno.") + + Mensaje.AppendFormat("
Folio: {0}", FolioMov, CveMovimiento) + Alert(Mensaje.ToString, TipoMensaje.MsgInformacion) - LimpiaMovimiento() - - Else - ObjInventario.RollBack() - Alert(TextoError, TipoMensaje.MsgError) - RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')") - End If - - - - Return Retorno - + LimpiaMovimiento() + + Else + ObjInventario.RollBack() + Alert(TextoError, TipoMensaje.MsgError) + RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')") + End If + + + + Return Retorno + End Function -#End Region +#End Region -#Region " NUEVO - LIMPIA " - Protected Sub BtnNuevo_Click(sender As Object, e As EventArgs) - LimpiaMovimiento() - End Sub - Private Sub LimpiaMovimiento() - CargaAlmacenOrigen() - TxtResponsable.Text = "" - TxtFecha.Text = Now.ToShortDateString - TxtObservaciones.Text = "" - txtCantidad.Text = "" - SiguienteFolio(If(ChkTransitorio.Checked, 9, 8)) - ChkTransitorio.Checked = False - ChkTransitorio.Enabled = True - TxtGastoIndirecto.Text = "" - TxtPlaca.Text = "" - TxtEspecifUnidad.Text = "" - DtSeccionAlmacen.Rows.Clear() - TxtResponsableCarga.Text = "" - TxtResponsableRecibio.Text = "" - TxtIdentificacion.Text = "" - TxtDomicilio.Text = "" - TxtTelefono.Text = "" - TxtCiudad.Text = "" - TxtLicencia.Text = "" - - DivMov.Visible = False - CargadoDeMov = False - - UPDatosAlmacen.Update() - UpMov.Update() - - DtMovimientos.Rows.Clear() - CargaGvDatos() +#Region " NUEVO - LIMPIA " + Protected Sub BtnNuevo_Click(sender As Object, e As EventArgs) + LimpiaMovimiento() End Sub -#End Region + Private Sub LimpiaMovimiento() + CargaAlmacenOrigen() + TxtResponsable.Text = "" + TxtFecha.Text = Now.ToShortDateString + TxtObservaciones.Text = "" + txtCantidad.Text = "" + SiguienteFolio(If(ChkTransitorio.Checked, 9, 8)) + ChkTransitorio.Checked = False + ChkTransitorio.Enabled = True + TxtGastoIndirecto.Text = "" + TxtPlaca.Text = "" + TxtEspecifUnidad.Text = "" + DtSeccionAlmacen.Rows.Clear() + TxtResponsableCarga.Text = "" + TxtResponsableRecibio.Text = "" + TxtIdentificacion.Text = "" + TxtDomicilio.Text = "" + TxtTelefono.Text = "" + TxtCiudad.Text = "" + TxtLicencia.Text = "" -#Region "DDL CLASIFICACION" - Protected Sub DdlClasificacion_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlClasificacion.SelectedIndexChanged - ChangeDdlProducto() - End Sub - Private Sub ChangeDdlProducto() - If UsuarioActual.Empresa.Funcionalidad(105) = "" Then - DdlProducto2.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=DdlClasificacion.SelectedValue.ToEntero).FiltraParametros("", "PSCodigo") - DdlProducto2.DataBind() - DdlProducto2.ddl.Items.Insert(0, New ListItem(" ", "-1")) - Else - DdlProducto2.ddlWS.Attributes.Add("data-cveclasificacion", DdlClasificacion.SelectedValue) - DdlProducto2.SelectedText = "" - DdlProducto2.SelectedValue = "-1" - End If - End Sub - Protected Sub DdlProducto_ValueChanged(sender As Object, e As EventArgs) Handles DdlProducto2.selectedindexchange - ElProductoChange() - End Sub - Private Sub ElProductoChange() - TxtnSerieLote.Visible = False - TxtnLote.Visible = False - TxtnBatch.Visible = False - - EscondeColumnasGVM(DtMovimientos) - - If DdlProducto2.SelectedValue.ToEntero > 0 Then - If GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DdlProducto2.SelectedValue.ToEntero).FiltraParametros("Inv_CveMetodoInventario = 5 ", "PS").Rows.Count > 0 Then - ThSerieLote.Visible = True - TdSerieLote.Visible = True - TxtnSerieLote.Visible = True - GvDatos.Columns(5).Visible = True - End If - If GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DdlProducto2.SelectedValue.ToEntero).FiltraParametros("Inv_CveMetodoInventario = 6", "PS").Rows.Count > 0 Then - TxtnLote.Visible = True - ThLote.Visible = True - TdLote.Visible = True - GvDatos.Columns(6).Visible = True - - TxtnBatch.Visible = True - ThBatch.Visible = True - TdBatch.Visible = True - GvDatos.Columns(7).Visible = True - End If - End If - - DdlUnidad.Items.Clear() - DdlUnidad.DataSource = GlobalDTProductosServiciosEquivalencias(DdlProducto2.SelectedValue.ToEntero, -1, UsuarioActual.CveEmpresa) - DdlUnidad.DataBind() - UpDatos.Update() - End Sub - Private Function isWhitFamily() As Boolean - Return (UsuarioActual.CveEmpresa = 66) - End Function - Protected Sub DdlClasificacion_GV(sender As Object, e As System.EventArgs) - Dim pDdlClasificacion As DropDownList = CType(sender, DropDownList) - Dim pDdlProducto As DropDownList = CType(pDdlClasificacion.NamingContainer.FindControl("DdlProducto"), DropDownList) - - If pDdlClasificacion.SelectedValue = "-1" Then - pDdlProducto.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa) - pDdlProducto.DataBind() - Else - pDdlProducto.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=pDdlClasificacion.SelectedValue.ToEntero) - pDdlProducto.DataBind() - End If - - If pDdlClasificacion.SelectedValue = "-1" Then - pDdlProducto.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa) - Else - pDdlProducto.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=DdlClasificacion.SelectedValue.ToEntero) - End If - pDdlProducto.DataBind() - pDdlProducto.Items.Insert(0, New ListItem("----", "-1")) - + DivMov.Visible = False + CargadoDeMov = False + + UPDatosAlmacen.Update() + UpMov.Update() + + DtMovimientos.Rows.Clear() + CargaGvDatos() End Sub -#End Region +#End Region -#Region "GV DATOS" - Private Sub CargaGvDatos() - EscondeColumnasGVM(DtMovimientos) - - GvDatos.DataSource = DtMovimientos - GvDatos.DataBind() - UpDatos.Update() - End Sub - - Private Sub EscondeColumnasGVM(DtTemp As DataTable) - TxtnSerieLote.Visible = False - ThSerieLote.Visible = False - TdSerieLote.Visible = False - GvDatos.Columns(5).Visible = False - - TxtnLote.Visible = False - ThLote.Visible = False - TdLote.Visible = False - GvDatos.Columns(6).Visible = False - - TxtnBatch.Visible = False - ThBatch.Visible = False - TdBatch.Visible = False - GvDatos.Columns(7).Visible = False - - If DtTemp.MAX("SerieLote").ToString <> "" Then - TxtnSerieLote.Visible = True - ThSerieLote.Visible = True - TdSerieLote.Visible = True - GvDatos.Columns(5).Visible = True - End If - If DtTemp.MAX("Lote").ToString <> "" Then - TxtnLote.Visible = True - ThLote.Visible = True - TdLote.Visible = True - GvDatos.Columns(6).Visible = True - - TxtnBatch.Visible = True - ThBatch.Visible = True - TdBatch.Visible = True - GvDatos.Columns(7).Visible = True - End If - End Sub - - 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 - e.Row.Cells(0).BackColor = Drawing.Color.Red - End If - - If CargadoDeMov Then - e.Row.FCLiteral("ltlCantidad").Visible = False - e.Row.FCTextBox("TxtCantidad2").Visible = True - e.Row.FCTextBox("TxtCantidad2").Attributes.Add("onblur", String.Format("ValidaCantidad(this,{0})", e.Row.DBCampo("Cantidad"))) - End If - - If DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {e.Row.RowIndex}").SUMD("CantidadSeccionAlmacen") > 0 Then - e.Row.FCLinkButton("lnkRemove").Visible = False - e.Row.FCLinkButton("lnkRemove").ToolTip = "Cuenta con sección almacen" - End If - 'If If(e.Row.DBCampo("SerieLote").ToString = "", "-1", e.Row.DBCampo("SerieLote").ToString) <> "-1" Then - ' TxtnSerieLote.Visible = True - ' ThSerieLote.Visible = True - ' TdSerieLote.Visible = True - ' GvDatos.Columns(4).Visible = True - ' e.Row.Cells(4).Text = e.Row.DBCampo("SerieLote").ToString - 'Else - ' e.Row.Cells(4).Text = "" - 'End If - - 'If If(e.Row.DBCampo("Lote").ToString = "", "-1", e.Row.DBCampo("Lote").ToString) <> "-1" Then - ' TxtnLote.Visible = True - ' ThLote.Visible = True - ' TdLote.Visible = True - ' GvDatos.Columns(5).Visible = True - ' e.Row.Cells(5).Text = e.Row.DBCampo("Lote").ToString - - ' TxtnBatch.Visible = True - ' ThBatch.Visible = True - ' TdBatch.Visible = True - ' GvDatos.Columns(6).Visible = True - ' e.Row.Cells(6).Text = e.Row.DBCampo("Batch").ToString - 'Else - ' e.Row.Cells(5).Text = "" - ' e.Row.Cells(6).Text = "" - 'End If - - 'If e.Row.RowState = DataControlRowState.Edit Then - ' e.Row.FCDropDownList("DdlUnidad").DataSource = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa) - ' e.Row.FCDropDownList("DdlUnidad").DataBind() - ' e.Row.FCDropDownList("DdlUnidad").SelectedValue = e.Row.DBCampo("CveUM") - - ' e.Row.FCDropDownList("DdlClasificacion").DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa) - ' e.Row.FCDropDownList("DdlClasificacion").DataBind() - ' e.Row.FCDropDownList("DdlClasificacion").SelectedValue = e.Row.DBCampo("CveClasificacion") - - ' e.Row.FCDropDownList("DdlProducto").DataSource = GlobalDTProductosServicios(UsuarioActual.CveEmpresa) - ' e.Row.FCDropDownList("DdlProducto").DataBind() - ' e.Row.FCDropDownList("DdlProducto").SelectedValue = e.Row.DBCampo("CvePS") - 'End If - - End If - End Sub - Protected Sub GvPS_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvDatos.RowDeleting - Dim DbRow As DataRow = Nothing - DbRow = DtMovimientos.Rows(e.RowIndex) - - DtMovimientos.Rows.Remove(DbRow) - CargaGvDatos() +#Region "DDL CLASIFICACION" + Protected Sub DdlClasificacion_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlClasificacion.SelectedIndexChanged + ChangeDdlProducto() + End Sub + Private Sub ChangeDdlProducto() + If UsuarioActual.Empresa.Funcionalidad(105) = "" Then + DdlProducto2.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=DdlClasificacion.SelectedValue.ToEntero).FiltraParametros("", "PSCodigo") + DdlProducto2.DataBind() + DdlProducto2.ddl.Items.Insert(0, New ListItem(" ", "-1")) + Else + DdlProducto2.ddlWS.Attributes.Add("data-cveclasificacion", DdlClasificacion.SelectedValue) + DdlProducto2.SelectedText = "" + DdlProducto2.SelectedValue = "-1" + End If + End Sub + Protected Sub DdlProducto_ValueChanged(sender As Object, e As EventArgs) Handles DdlProducto2.selectedindexchange + ElProductoChange() + End Sub + Private Sub ElProductoChange() + TxtnSerieLote.Visible = False + TxtnLote.Visible = False + TxtnBatch.Visible = False + + EscondeColumnasGVM(DtMovimientos) + + If DdlProducto2.SelectedValue.ToEntero > 0 Then + If GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DdlProducto2.SelectedValue.ToEntero).FiltraParametros("Inv_CveMetodoInventario = 5 ", "PS").Rows.Count > 0 Then + ThSerieLote.Visible = True + TdSerieLote.Visible = True + TxtnSerieLote.Visible = True + GvDatos.Columns(5).Visible = True + End If + If GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DdlProducto2.SelectedValue.ToEntero).FiltraParametros("Inv_CveMetodoInventario = 6", "PS").Rows.Count > 0 Then + TxtnLote.Visible = True + ThLote.Visible = True + TdLote.Visible = True + GvDatos.Columns(6).Visible = True + + TxtnBatch.Visible = True + ThBatch.Visible = True + TdBatch.Visible = True + GvDatos.Columns(7).Visible = True + End If + End If + + DdlUnidad.Items.Clear() + DdlUnidad.DataSource = GlobalDTProductosServiciosEquivalencias(DdlProducto2.SelectedValue.ToEntero, -1, UsuarioActual.CveEmpresa) + DdlUnidad.DataBind() + UpDatos.Update() + End Sub + Private Function isWhitFamily() As Boolean + Return (UsuarioActual.CveEmpresa = 66) + End Function + Protected Sub DdlClasificacion_GV(sender As Object, e As System.EventArgs) + Dim pDdlClasificacion As DropDownList = CType(sender, DropDownList) + Dim pDdlProducto As DropDownList = CType(pDdlClasificacion.NamingContainer.FindControl("DdlProducto"), DropDownList) + + If pDdlClasificacion.SelectedValue = "-1" Then + pDdlProducto.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa) + pDdlProducto.DataBind() + Else + pDdlProducto.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=pDdlClasificacion.SelectedValue.ToEntero) + pDdlProducto.DataBind() + End If + + If pDdlClasificacion.SelectedValue = "-1" Then + pDdlProducto.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa) + Else + pDdlProducto.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=DdlClasificacion.SelectedValue.ToEntero) + End If + pDdlProducto.DataBind() + pDdlProducto.Items.Insert(0, New ListItem("----", "-1")) + + End Sub +#End Region + +#Region "GV DATOS" + Private Sub CargaGvDatos() + EscondeColumnasGVM(DtMovimientos) + + GvDatos.DataSource = DtMovimientos + GvDatos.DataBind() + UpDatos.Update() + End Sub + + Private Sub EscondeColumnasGVM(DtTemp As DataTable) + TxtnSerieLote.Visible = False + ThSerieLote.Visible = False + TdSerieLote.Visible = False + GvDatos.Columns(5).Visible = False + + TxtnLote.Visible = False + ThLote.Visible = False + TdLote.Visible = False + GvDatos.Columns(6).Visible = False + + TxtnBatch.Visible = False + ThBatch.Visible = False + TdBatch.Visible = False + GvDatos.Columns(7).Visible = False + + If DtTemp.MAX("SerieLote").ToString <> "" Then + TxtnSerieLote.Visible = True + ThSerieLote.Visible = True + TdSerieLote.Visible = True + GvDatos.Columns(5).Visible = True + End If + If DtTemp.MAX("Lote").ToString <> "" Then + TxtnLote.Visible = True + ThLote.Visible = True + TdLote.Visible = True + GvDatos.Columns(6).Visible = True + + TxtnBatch.Visible = True + ThBatch.Visible = True + TdBatch.Visible = True + GvDatos.Columns(7).Visible = True + End If + End Sub + + 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 + e.Row.Cells(0).BackColor = Drawing.Color.Red + End If + + If CargadoDeMov Then + e.Row.FCLiteral("ltlCantidad").Visible = False + e.Row.FCTextBox("TxtCantidad2").Visible = True + e.Row.FCTextBox("TxtCantidad2").Attributes.Add("onblur", String.Format("ValidaCantidad(this,{0})", e.Row.DBCampo("Cantidad"))) + End If + + If DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {e.Row.RowIndex}").SUMD("CantidadSeccionAlmacen") > 0 Then + e.Row.FCLinkButton("lnkRemove").Visible = False + e.Row.FCLinkButton("lnkRemove").ToolTip = "Cuenta con sección almacen" + End If + 'If If(e.Row.DBCampo("SerieLote").ToString = "", "-1", e.Row.DBCampo("SerieLote").ToString) <> "-1" Then + ' TxtnSerieLote.Visible = True + ' ThSerieLote.Visible = True + ' TdSerieLote.Visible = True + ' GvDatos.Columns(4).Visible = True + ' e.Row.Cells(4).Text = e.Row.DBCampo("SerieLote").ToString + 'Else + ' e.Row.Cells(4).Text = "" + 'End If + + 'If If(e.Row.DBCampo("Lote").ToString = "", "-1", e.Row.DBCampo("Lote").ToString) <> "-1" Then + ' TxtnLote.Visible = True + ' ThLote.Visible = True + ' TdLote.Visible = True + ' GvDatos.Columns(5).Visible = True + ' e.Row.Cells(5).Text = e.Row.DBCampo("Lote").ToString + + ' TxtnBatch.Visible = True + ' ThBatch.Visible = True + ' TdBatch.Visible = True + ' GvDatos.Columns(6).Visible = True + ' e.Row.Cells(6).Text = e.Row.DBCampo("Batch").ToString + 'Else + ' e.Row.Cells(5).Text = "" + ' e.Row.Cells(6).Text = "" + 'End If + + 'If e.Row.RowState = DataControlRowState.Edit Then + ' e.Row.FCDropDownList("DdlUnidad").DataSource = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa) + ' e.Row.FCDropDownList("DdlUnidad").DataBind() + ' e.Row.FCDropDownList("DdlUnidad").SelectedValue = e.Row.DBCampo("CveUM") + + ' e.Row.FCDropDownList("DdlClasificacion").DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa) + ' e.Row.FCDropDownList("DdlClasificacion").DataBind() + ' e.Row.FCDropDownList("DdlClasificacion").SelectedValue = e.Row.DBCampo("CveClasificacion") + + ' e.Row.FCDropDownList("DdlProducto").DataSource = GlobalDTProductosServicios(UsuarioActual.CveEmpresa) + ' e.Row.FCDropDownList("DdlProducto").DataBind() + ' e.Row.FCDropDownList("DdlProducto").SelectedValue = e.Row.DBCampo("CvePS") + 'End If + + End If + End Sub + Protected Sub GvPS_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvDatos.RowDeleting + Dim DbRow As DataRow = Nothing + DbRow = DtMovimientos.Rows(e.RowIndex) + + DtMovimientos.Rows.Remove(DbRow) + CargaGvDatos() End Sub 'Protected Sub GvM_RowEditing(sender As Object, e As GridViewEditEventArgs) Handles GvDatos.RowEditing @@ -1392,135 +1392,135 @@ Partial Class Inventarios_TraspasoAlmacen 'End Sub -#End Region +#End Region -#Region " TRANSITORIO - RECEPCION " +#Region " TRANSITORIO - RECEPCION " - Protected Sub ChkTransitorio_CheckedChanged(sender As Object, e As EventArgs) - - Dim TipoAlmacenOrigen = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveTipoAlmacen", $"CveAlmacen = {DdlAlmacenOrigen.SelectedValue.ToEntero}").ToEntero - Dim TipoAlmacenDestino = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveTipoAlmacen", $"CveAlmacen = {DdlAlmacenDestino.SelectedValue.ToEntero}").ToEntero - If TipoAlmacenOrigen = 14 Or TipoAlmacenDestino = 14 Then - ChkTransitorio.Checked = False - Alert("Un traspaso de consumo interno no puede ser transitorio.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - If ChkTransitorio.Checked Then - 'DdlResponsable.SelectedValue = "-1" - TxtResponsable.Text = "" - TxtGastoIndirecto.Text = "" - RegistraScript("$('#DivTransitorio').show(200);$('#DivGastoIndirecto').show(100);$('#DivDocChofer').show(100);") - Else - RegistraScript("$('#DivTransitorio').hide(500);$('#DivGastoIndirecto').hide(500);$('#DivDocChofer').hide(500);") - End If - - UpModalSeccionAlmacen.Update() - SiguienteFolio(If(ChkTransitorio.Checked, 9, 8)) - End Sub - Protected Sub BtnCargaTransitorios_Click(sender As Object, e As EventArgs) - CargaRecepcion() - End Sub - Private Sub CargaRecepcion() - Dim ObjInventarios As New ClsInventarios - Dim Dtt As DataTable = Nothing - - FolioBusqueda = If(TxtFolioRecepcion.Text = "", -1, TxtFolioRecepcion.Text.ToEntero) - - If ObjInventarios.GetMovimientosTransitorios(DdlAlmacenRecepcion.SelectedValue.ToEntero, -1, DdlAlmacenTransitorioRecepcion.SelectedValue.ToEntero, -1, FolioBusqueda, UsuarioActual.CveEmpresa) Then - Dtt = ObjInventarios.DtResultados.FiltraParametros(String.Format("CveTipoAlmacenDestino <> 4")) - If TxtFolioRecepcion.Text.Trim <> "" Then - CveMovimientoSalida = ObjInventarios.DtResultados.FiltroPrimeroValor("CveMovimiento", "").ToEntero - - End If - CveAlmacenDestino = DdlAlmacenRecepcion.SelectedValue.ToEntero - CveAlmacenTransitorio = DdlAlmacenTransitorioRecepcion.SelectedValue.ToEntero - 'CveUsuarioResponsable = DdlResponsableRecepcion.SelectedValue.ToEntero - Else - Alert("Ocurrió un error al consultar los movimientos transitorios. Por favor vuelva a intentar.", TipoMensaje.MsgAdvertencia) - Dtt = Nothing - End If - - ObjInventarios.Dispose() - - If Dtt IsNot Nothing Then - GvDatosRecepcion.DataSource = Dtt - GvDatosRecepcion.DataBind() - 'Dt.Dispose() - End If - - DtSeccionAlmacen.Rows.Clear() - - If TxtFolioRecepcion.Text = "" Then - BtnRecibir.Visible = False - BtnCancelarTraspaso.Visible = False - Else - BtnRecibir.Visible = True + Protected Sub ChkTransitorio_CheckedChanged(sender As Object, e As EventArgs) + + Dim TipoAlmacenOrigen = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveTipoAlmacen", $"CveAlmacen = {DdlAlmacenOrigen.SelectedValue.ToEntero}").ToEntero + Dim TipoAlmacenDestino = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveTipoAlmacen", $"CveAlmacen = {DdlAlmacenDestino.SelectedValue.ToEntero}").ToEntero + If TipoAlmacenOrigen = 14 Or TipoAlmacenDestino = 14 Then + ChkTransitorio.Checked = False + Alert("Un traspaso de consumo interno no puede ser transitorio.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If ChkTransitorio.Checked Then + 'DdlResponsable.SelectedValue = "-1" + TxtResponsable.Text = "" + TxtGastoIndirecto.Text = "" + RegistraScript("$('#DivTransitorio').show(200);$('#DivGastoIndirecto').show(100);$('#DivDocChofer').show(100);") + Else + RegistraScript("$('#DivTransitorio').hide(500);$('#DivGastoIndirecto').hide(500);$('#DivDocChofer').hide(500);") + End If + + UpModalSeccionAlmacen.Update() + SiguienteFolio(If(ChkTransitorio.Checked, 9, 8)) + End Sub + Protected Sub BtnCargaTransitorios_Click(sender As Object, e As EventArgs) + CargaRecepcion() + End Sub + Private Sub CargaRecepcion() + Dim ObjInventarios As New ClsInventarios + Dim Dtt As DataTable = Nothing + + FolioBusqueda = If(TxtFolioRecepcion.Text = "", -1, TxtFolioRecepcion.Text.ToEntero) + + If ObjInventarios.GetMovimientosTransitorios(DdlAlmacenRecepcion.SelectedValue.ToEntero, -1, DdlAlmacenTransitorioRecepcion.SelectedValue.ToEntero, -1, FolioBusqueda, UsuarioActual.CveEmpresa) Then + Dtt = ObjInventarios.DtResultados.FiltraParametros(String.Format("CveTipoAlmacenDestino <> 4")) + If TxtFolioRecepcion.Text.Trim <> "" Then + CveMovimientoSalida = ObjInventarios.DtResultados.FiltroPrimeroValor("CveMovimiento", "").ToEntero + + End If + CveAlmacenDestino = DdlAlmacenRecepcion.SelectedValue.ToEntero + CveAlmacenTransitorio = DdlAlmacenTransitorioRecepcion.SelectedValue.ToEntero + 'CveUsuarioResponsable = DdlResponsableRecepcion.SelectedValue.ToEntero + Else + Alert("Ocurrió un error al consultar los movimientos transitorios. Por favor vuelva a intentar.", TipoMensaje.MsgAdvertencia) + Dtt = Nothing + End If + + ObjInventarios.Dispose() + + If Dtt IsNot Nothing Then + GvDatosRecepcion.DataSource = Dtt + GvDatosRecepcion.DataBind() + 'Dt.Dispose() + End If + + DtSeccionAlmacen.Rows.Clear() + + If TxtFolioRecepcion.Text = "" Then + BtnRecibir.Visible = False + BtnCancelarTraspaso.Visible = False + Else + BtnRecibir.Visible = True If UsuarioActual.TienePermisoProceso(290) Then BtnCancelarTraspaso.Visible = True - End If - End If - - - If UsuarioActual.Empresa.Funcionalidad(132) = "1" Then - DivCodigoSeriePSRecepcion.Visible = True - Else - DivCodigoSeriePSRecepcion.Visible = False - End If - - - UpDatosRecepcion.Update() - UPDivCodigoSeriePSRecepcion.Update() - End Sub - - Protected Sub GvDatosRecepcion_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDatosRecepcion.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - - e.Row.FCTextBox("TxtCantidad").Visible = True - - If TxtFolioRecepcion.Text = "" Then - e.Row.FCCheckBox("Chk").Visible = False - e.Row.FCTextBox("TxtCantidad").Enabled = False - End If - - 'Cuando es titulo - If e.Row.DBCampo("PS").ToString.Trim = "" Then - e.Row.CssClass = "Totales" - - e.Row.FCCheckBox("Chk").Visible = False - e.Row.FCTextBox("TxtCantidad").Visible = False - - e.Row.Cells(2).Text = String.Format("Folio: {0} ", e.Row.DBCampo("FolioSalida"), e.Row.DBCampo("CveMovimientoSalida")) - e.Row.Cells(3).Text = String.Format("{0}", e.Row.DBCampo("FechaMovto").ToString.ToDate.ToShortDateString) - e.Row.Cells(5).Text = String.Format("Almacen Origen: {0}     Almacen Destino: {1}       Responsable: {2}", e.Row.DBCampo("Almacen"), e.Row.DBCampo("AlmacenDestino"), e.Row.DBCampo("Recibio")) - - Else - e.Row.FCTextBox("TxtCantidad").Attributes.Add("onkeyup", String.Format("ValidaCantidad(this,{0});", e.Row.DBCampo("Cantidad"))) - End If - - 'FUNCIONALIDAD PISTOLA DE CODIGOS - If UsuarioActual.Empresa.Funcionalidad(132) = "1" And e.Row.DBCampo("CodigoBarras").Trim <> "" Then - e.Row.FCTextBox("TxtCantidad").Enabled = False - End If - - End If - End Sub - - Protected Sub BtnCancelarTraspaso_Click(sender As Object, e As EventArgs) - If Not GvDatosRecepcion.Rows.Count > 0 Then - Alert("No hay movimientos para el traspaso", TipoMensaje.MsgAdvertencia) - Exit Sub + End If + End If + + + If UsuarioActual.Empresa.Funcionalidad(132) = "1" Then + DivCodigoSeriePSRecepcion.Visible = True + Else + DivCodigoSeriePSRecepcion.Visible = False + End If + + + UpDatosRecepcion.Update() + UPDivCodigoSeriePSRecepcion.Update() + End Sub + + Protected Sub GvDatosRecepcion_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDatosRecepcion.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + + e.Row.FCTextBox("TxtCantidad").Visible = True + + If TxtFolioRecepcion.Text = "" Then + e.Row.FCCheckBox("Chk").Visible = False + e.Row.FCTextBox("TxtCantidad").Enabled = False + End If + + 'Cuando es titulo + If e.Row.DBCampo("PS").ToString.Trim = "" Then + e.Row.CssClass = "Totales" + + e.Row.FCCheckBox("Chk").Visible = False + e.Row.FCTextBox("TxtCantidad").Visible = False + + e.Row.Cells(2).Text = String.Format("Folio: {0} ", e.Row.DBCampo("FolioSalida"), e.Row.DBCampo("CveMovimientoSalida")) + e.Row.Cells(3).Text = String.Format("{0}", e.Row.DBCampo("FechaMovto").ToString.ToDate.ToShortDateString) + e.Row.Cells(5).Text = String.Format("Almacen Origen: {0}     Almacen Destino: {1}       Responsable: {2}", e.Row.DBCampo("Almacen"), e.Row.DBCampo("AlmacenDestino"), e.Row.DBCampo("Recibio")) + + Else + e.Row.FCTextBox("TxtCantidad").Attributes.Add("onkeyup", String.Format("ValidaCantidad(this,{0});", e.Row.DBCampo("Cantidad"))) + End If + + 'FUNCIONALIDAD PISTOLA DE CODIGOS + If UsuarioActual.Empresa.Funcionalidad(132) = "1" And e.Row.DBCampo("CodigoBarras").Trim <> "" Then + e.Row.FCTextBox("TxtCantidad").Enabled = False + End If + + End If + End Sub + + Protected Sub BtnCancelarTraspaso_Click(sender As Object, e As EventArgs) + If Not GvDatosRecepcion.Rows.Count > 0 Then + Alert("No hay movimientos para el traspaso", TipoMensaje.MsgAdvertencia) + Exit Sub End If Dim CveMovimientoEntrada As Integer = 0 Dim Folio As Integer = 0 Dim ErrorMovInv As Boolean = False Dim TextoError As String = "" - Dim Fecha As Date = TxtFechaRecepcion.Text.ToDate - - Dim ObjInventario As New ClsInventarios - Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL()) - ObjInventario.IniciaTransacSQL() + Dim Fecha As Date = TxtFechaRecepcion.Text.ToDate + + Dim ObjInventario As New ClsInventarios + Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL()) + ObjInventario.IniciaTransacSQL() Try CveMovimientoEntrada = ObjInventario.AddMovimiento(GvDatosRecepcion.Rows(0).DataKey("CveAlmacenSalida").ToEntero, 27, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservacionesRecepcion.Text.Trim, Recibio:=TxtRecibio.Text, CveAlmacenDestino:=GvDatosRecepcion.Rows(0).DataKey("CveAlmacenSalida").ToEntero, @@ -1553,8 +1553,8 @@ Partial Class Inventarios_TraspasoAlmacen If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then For Each Dr As DataRow In ObjInventario.DtResultados.Rows CveMovimientoDetalleSalida = Dr("CveMovimientoDetalle").ToString.ToEntero - Dim Cantidad As Double = Dr("Cantidad").ToString.ToDouble - Dim PrecioUnitario As Double = Dr("PU").ToString.ToDouble + Dim Cantidad As Decimal = Dr("Cantidad").ToString.ToDecimal + Dim PrecioUnitario As Decimal = Dr("PU").ToString.ToDecimal If CveMovimientoDetalleSalida <= 0 Then ErrorMovInv = True TextoError = "Ocurrió un error al guardar los movimientos de salida" @@ -1622,43 +1622,43 @@ Partial Class Inventarios_TraspasoAlmacen Alert(TextoError, TipoMensaje.MsgError) End If - ObjConta.Dispose() - ObjInventario.Dispose() - - CargaRecepcion() - End Sub - - Protected Sub BtnRecibir_Click(sender As Object, e As EventArgs) - If GvDatosRecepcion.Rows.Count > 0 Then - 'Valida Movimientos - Dim ValidaMovtos = 0.0 - For Each gvr As GridViewRow In GvDatosRecepcion.Rows - If gvr.FCCheckBox("Chk").Checked AndAlso gvr.FCTextBox("TxtCantidad").Text.ToString.ToDecimal > 0 Then - ValidaMovtos += gvr.FCTextBox("TxtCantidad").Text.ToString.ToDecimal - End If - Next - - If Not ValidaMovtos > 0 Then - Alert("No hay movimientos que realizar. Por favor verifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - If UsuarioActual.Empresa.Funcionalidad(563) = "1" Then - If ValidaMovtos <> DtSeccionAlmacen.FiltraParametros("TipoSeccionAlmacen = 2").SUMD("CantidadSeccionAlmacen") Then - Alert("La seccion de almacen no ha sido agregada completamente.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - End If - - Dim ObjInventario As New ClsInventarios - Dim Dtt As DataTable = Nothing - Dim CveMovimientoEntrada As Integer = 0 - Dim Folio = 0 - Dim ErrorMovInv As Boolean = False - Dim TextoError = "" - Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL()) - - '' verifica que no se halla recibido previamente, si ya se recibió da salida + ObjConta.Dispose() + ObjInventario.Dispose() + + CargaRecepcion() + End Sub + + Protected Sub BtnRecibir_Click(sender As Object, e As EventArgs) + If GvDatosRecepcion.Rows.Count > 0 Then + 'Valida Movimientos + Dim ValidaMovtos = 0.0 + For Each gvr As GridViewRow In GvDatosRecepcion.Rows + If gvr.FCCheckBox("Chk").Checked AndAlso gvr.FCTextBox("TxtCantidad").Text.ToString.ToDecimal > 0 Then + ValidaMovtos += gvr.FCTextBox("TxtCantidad").Text.ToString.ToDecimal + End If + Next + + If Not ValidaMovtos > 0 Then + Alert("No hay movimientos que realizar. Por favor verifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If UsuarioActual.Empresa.Funcionalidad(563) = "1" Then + If ValidaMovtos <> DtSeccionAlmacen.FiltraParametros("TipoSeccionAlmacen = 2").SUMD("CantidadSeccionAlmacen") Then + Alert("La seccion de almacen no ha sido agregada completamente.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + End If + + Dim ObjInventario As New ClsInventarios + Dim Dtt As DataTable = Nothing + Dim CveMovimientoEntrada As Integer = 0 + Dim Folio = 0 + Dim ErrorMovInv As Boolean = False + Dim TextoError = "" + Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL()) + + '' verifica que no se halla recibido previamente, si ya se recibió da salida If ObjInventario.GetMovimientosTransitorios(CveAlmacenDestino, -1, CveAlmacenTransitorio, -1, FolioBusqueda, UsuarioActual.CveEmpresa) Then Dtt = ObjInventario.DtResultados.FiltraParametros(String.Format("CveTipoAlmacenDestino <> 4"), "", {"CveMovimientoDetalle", "Codigo", "Cantidad"}) If Dtt IsNot Nothing AndAlso Dtt.FiltraParametros("Cantidad < 0").Rows.Count > 0 Then @@ -1670,64 +1670,64 @@ Partial Class Inventarios_TraspasoAlmacen End If 'REGISTRA LA SALIDA Y ENTRADA (TRASPASO) - ObjInventario.IniciaTransacSQL() 'Inicia la transacción - Dim Fecha As Date = TxtFechaRecepcion.Text.ToDate - - 'AGREGAMOS LA ENTRADA - CveMovimientoSalida = ObjInventario.AddMovimiento(GvDatosRecepcion.Rows(0).DataKey("CveAlmacenDestino").ToEntero, 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 - - If CveMovimientoSalida <= 0 Then - TextoError = "No se pudo generar el movimiento de salida correctamente" - ErrorMovInv = True - Else - - Dim CveMovimientoDetalleEntrada As Integer = 0 - Dim Cont As Integer = 0 + ObjInventario.IniciaTransacSQL() 'Inicia la transacción + Dim Fecha As Date = TxtFechaRecepcion.Text.ToDate + + 'AGREGAMOS LA ENTRADA + CveMovimientoSalida = ObjInventario.AddMovimiento(GvDatosRecepcion.Rows(0).DataKey("CveAlmacenDestino").ToEntero, 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 + + If CveMovimientoSalida <= 0 Then + TextoError = "No se pudo generar el movimiento de salida correctamente" + ErrorMovInv = True + Else + + Dim CveMovimientoDetalleEntrada As Integer = 0 + Dim Cont As Integer = 0 For Each gvr As GridViewRow In GvDatosRecepcion.Rows - Dim dataRowAux As DataRow = Dtt.FiltroPrimero(String.Format(" CveMovimientoDetalle = '{0}'", If(gvr.DataKey("CveMovimientoDetalle").ToString = "", "0", gvr.DataKey("CveMovimientoDetalle").ToString))) - Dim cantidadDisponibleValidacion As Decimal = 0 - + Dim dataRowAux As DataRow = Dtt.FiltroPrimero(String.Format(" CveMovimientoDetalle = '{0}'", If(gvr.DataKey("CveMovimientoDetalle").ToString = "", "0", gvr.DataKey("CveMovimientoDetalle").ToString))) + Dim cantidadDisponibleValidacion As Decimal = 0 + If gvr.DataKey("Codigo").ToString IsNot "" Then If dataRowAux IsNot Nothing Then cantidadDisponibleValidacion = dataRowAux.Item("Cantidad").ToString.ToDecimal - gvr.FCTextBox("TxtCantidad").Text.ToString.ToDecimal Else cantidadDisponibleValidacion = -1 End If - End If - - If gvr.FCCheckBox("Chk").Checked AndAlso gvr.FCTextBox("TxtCantidad").Text.ToString.ToDecimal > 0 AndAlso cantidadDisponibleValidacion >= 0 Then - CveMovimientoDetalleEntrada = gvr.DataKey("CveMovimientoDetalle").ToString.ToEntero - - If CveMovimientoDetalleEntrada <= 0 Then - ErrorMovInv = True - 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.ToDouble, gvr.DataKey("CveAF").ToString.ToEntero, CveMovimientoDetalleEntrada:=CveMovimientoDetalleEntrada, SerieLote:=gvr.DataKey("SerieLote").ToString, Lote:=gvr.DataKey("Lote").ToString, Batch:=gvr.DataKey("Batch").ToString) Then - ErrorMovInv = True - TextoError = "Ocurrió un error al guardar los movimientos de salida" - Exit For - Else - If ObjInventario.CveMovimientoDetalle > 0 AndAlso DtSeccionAlmacen.Rows.Count > 0 Then - For Each Dr2 As DataRow In DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {Cont} AND TipoSeccionAlmacen = 2").Rows - If Not ObjInventario.AddMovimientosDetalleSeccionesAlmacen(ObjInventario.CveMovimientoDetalle, Dr2("CveSeccionAlmacenDestino").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 - End If - ElseIf cantidadDisponibleValidacion < 0 Then - TextoError = String.Format("Se exceden la cantidad disponibles para {0}", gvr.DataKey("PS").ToString) - ErrorMovInv = True - End If - Cont += 1 - Next + End If + + If gvr.FCCheckBox("Chk").Checked AndAlso gvr.FCTextBox("TxtCantidad").Text.ToString.ToDecimal > 0 AndAlso cantidadDisponibleValidacion >= 0 Then + CveMovimientoDetalleEntrada = gvr.DataKey("CveMovimientoDetalle").ToString.ToEntero + + If CveMovimientoDetalleEntrada <= 0 Then + ErrorMovInv = True + 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, gvr.DataKey("CveAF").ToString.ToEntero, CveMovimientoDetalleEntrada:=CveMovimientoDetalleEntrada, SerieLote:=gvr.DataKey("SerieLote").ToString, Lote:=gvr.DataKey("Lote").ToString, Batch:=gvr.DataKey("Batch").ToString) Then + ErrorMovInv = True + TextoError = "Ocurrió un error al guardar los movimientos de salida" + Exit For + Else + If ObjInventario.CveMovimientoDetalle > 0 AndAlso DtSeccionAlmacen.Rows.Count > 0 Then + For Each Dr2 As DataRow In DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {Cont} AND TipoSeccionAlmacen = 2").Rows + If Not ObjInventario.AddMovimientosDetalleSeccionesAlmacen(ObjInventario.CveMovimientoDetalle, Dr2("CveSeccionAlmacenDestino").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 + End If + ElseIf cantidadDisponibleValidacion < 0 Then + TextoError = String.Format("Se exceden la cantidad disponibles para {0}", gvr.DataKey("PS").ToString) + ErrorMovInv = True + End If + Cont += 1 + Next If Not ErrorMovInv Then Dim Concepto As String = TxtObservacionesRecepcion.Text If Concepto = "" Then Concepto = "Recepción Traspaso" @@ -1746,7 +1746,7 @@ Partial Class Inventarios_TraspasoAlmacen ErrorMovInv = True End If End If - End If + End If End If @@ -1768,8 +1768,8 @@ Partial Class Inventarios_TraspasoAlmacen dtvirtual = ObjInventario.DtResultados For Each RowVirtual As DataRow In dtvirtual.Rows Dim CvePS = RowVirtual("CvePS").ToString().ToEntero() - Dim CantidadUsado As Double = RowVirtual("Cantidad").ToString().ToDouble() - Dim PU As Double = RowVirtual("PU").ToString().ToDouble() + Dim CantidadUsado As Decimal = RowVirtual("Cantidad").ToString().ToDecimal() + Dim PU As Decimal = RowVirtual("PU").ToString().ToDecimal() Dim CveUM As Integer = RowVirtual("CveUM").ToString().ToEntero() If Not ObjInventario.AddMovimientoDetalle(CveMovimientoVirtualEntrada, CantidadUsado, CveUM, CvePS, PU, -1, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then @@ -1785,120 +1785,120 @@ Partial Class Inventarios_TraspasoAlmacen TextoError = "La Sucursal no tiene creado un almacen virtual" ErrorMovInv = True End If - End If - - ''AGREGAMOS LA ENTRADA - 'If Not ErrorMovInv Then - ' CveMovimientoEntrada = ObjInventario.AddMovimiento(GvDatosRecepcion.Rows(0).DataKey("CveAlmacenDestino").ToEntero, 9, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, - ' Observaciones:=TxtObservacionesRecepcion.Text.Trim, Recibio:=TxtRecibio.Text, CveAlmacenDestino:=GvDatosRecepcion.Rows(0).DataKey("CveAlmacenSalida").ToEntero, CveMovimientoRelacionado:=CveMovimientoSalida) - ' Folio = ObjInventario.Folio - - ' If CveMovimientoEntrada <= 0 Then - ' TextoError = "No se pudo generar el movimiento de entrada correctamente" - ' ErrorMovInv = True - ' Else - - ' 'COSTO INDIRECTO - ' Dim GastoIndirectoTotal As Double = GvDatosRecepcion.Rows(0).DataKey("GastoIndirectoSalida").ToDouble - ' Dim Importe As Double = GvDatosRecepcion.Rows(0).DataKey("Importe").ToDouble - - ' If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then - ' Dim CostoIndirecto As Double - ' For Each Dr As DataRow In ObjInventario.DtResultados.Rows - - ' CostoIndirecto = 0 - ' If GastoIndirectoTotal > 0 Then - ' 'PRORRATEAMOS EL GASTO INDIRECTO - ' CostoIndirecto = ((Dr("Total").ToString.ToDouble * GastoIndirectoTotal) / Importe) / Dr("Cantidad").ToString.ToDouble - ' End If - - ' If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDouble, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, CostoIndirecto:=CostoIndirecto) Then - ' ErrorMovInv = True - ' TextoError = "Ocurrió un error al guardar los movimientos de entrada" - ' Exit For - ' End If - ' Next - - ' End If - - ' End If - 'End If - - 'AGREGAMOS LA ENTRADA VIEJO - 'If Not ErrorMovInv Then - ' 'Folio = ObjInventario.GetFolioSiguiente(9, UsuarioActual.CveEmpresa) - ' CveMovimientoEntrada = ObjInventario.AddMovimiento(GvDatosRecepcion.Rows(0).DataKey("CveAlmacenDestino").ToEntero, 9, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1) - - ' If CveMovimientoEntrada <= 0 Then - ' TextoError = "No se pudo generar el movimiento de entrada correctamente" - ' ErrorMovInv = True - ' Else - - ' If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) 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.ToDouble, Dr("CveAF").ToString.ToEntero) Then - ' ErrorMovInv = True - ' TextoError = "Ocurrió un error al guardar los movimientos de salida" - ' Exit For - ' End If - ' Next - - ' End If - - ' End If - 'End If - - - If Not ErrorMovInv Then - ObjInventario.Commit() - - TxtRecibio.Text = "" - TxtFechaRecepcion.Text = Now.ToShortDateString - TxtObservacionesRecepcion.Text = "" - - Dim Mensaje As StringBuilder = New StringBuilder - Mensaje.AppendFormat("Se realizo correctamente la recepción.
Folio de Entrada: {0}", Folio, CveMovimientoSalida) - Mensaje.AppendFormat("
Imprimir Reporte", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoSalida))) 'onclick='ImprimirTraslado()' - If CveMovimientoVirtualEntrada > 0 Then Mensaje.AppendFormat("

Virtual{2}Imprimir Reporte", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoVirtualEntrada)), CveMovimientoVirtualEntrada, FolioVirtualEntrada) 'onclick='ImprimirTraslado()' - - - Alert(Mensaje.ToString, TipoMensaje.MsgInformacion) - - DivCodigoSeriePSRecepcion.Visible = False - - GvDatosRecepcion.DataBind() - UpDatosRecepcion.Update() - UPDatosAlmacen.Update() - Else - ObjInventario.RollBack() - Alert(TextoError, TipoMensaje.MsgError) - End If - ObjInventario.Dispose() - ObjConta.Dispose() - CargaRecepcion() - Else - Alert("No hay movimientos para el traspaso", TipoMensaje.MsgAdvertencia) - If ChkTransitorio.Checked Then RegistraScript("$('#DivTransitorio').show(200);") - End If - End Sub - - 'Private Sub DdlProducto_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlProducto.SelectedIndexChanged - ' 'CargarUM(DdlProducto.SelectedValue.ToEntero) - ' ElProductoChange() - 'End Sub - - 'Private Sub HFProducto_ValueChanged(sender As Object, e As EventArgs) Handles HFProducto.ValueChanged - ' ElProductoChange() - 'End Sub - Private Sub CargarUM(CvePS As Integer) - Dim ObjUM As New ClsProductosServicios() - If ObjUM.GetPSEquivalencias(CvePS, UsuarioActual.CveEmpresa) Then - DdlUnidad.Items.Clear() - DdlUnidad.DataSource = ObjUM.DtResultados - End If - ObjUM.Dispose() - DdlUnidad.DataBind() + End If + + ''AGREGAMOS LA ENTRADA + 'If Not ErrorMovInv Then + ' CveMovimientoEntrada = ObjInventario.AddMovimiento(GvDatosRecepcion.Rows(0).DataKey("CveAlmacenDestino").ToEntero, 9, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, + ' Observaciones:=TxtObservacionesRecepcion.Text.Trim, Recibio:=TxtRecibio.Text, CveAlmacenDestino:=GvDatosRecepcion.Rows(0).DataKey("CveAlmacenSalida").ToEntero, CveMovimientoRelacionado:=CveMovimientoSalida) + ' Folio = ObjInventario.Folio + + ' If CveMovimientoEntrada <= 0 Then + ' TextoError = "No se pudo generar el movimiento de entrada correctamente" + ' ErrorMovInv = True + ' Else + + ' 'COSTO INDIRECTO + ' Dim GastoIndirectoTotal As Double = GvDatosRecepcion.Rows(0).DataKey("GastoIndirectoSalida").ToDouble + ' Dim Importe As Double = GvDatosRecepcion.Rows(0).DataKey("Importe").ToDouble + + ' If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then + ' Dim CostoIndirecto As Double + ' For Each Dr As DataRow In ObjInventario.DtResultados.Rows + + ' CostoIndirecto = 0 + ' If GastoIndirectoTotal > 0 Then + ' 'PRORRATEAMOS EL GASTO INDIRECTO + ' CostoIndirecto = ((Dr("Total").ToString.ToDouble * GastoIndirectoTotal) / Importe) / Dr("Cantidad").ToString.ToDouble + ' End If + + ' If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDouble, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, CostoIndirecto:=CostoIndirecto) Then + ' ErrorMovInv = True + ' TextoError = "Ocurrió un error al guardar los movimientos de entrada" + ' Exit For + ' End If + ' Next + + ' End If + + ' End If + 'End If + + 'AGREGAMOS LA ENTRADA VIEJO + 'If Not ErrorMovInv Then + ' 'Folio = ObjInventario.GetFolioSiguiente(9, UsuarioActual.CveEmpresa) + ' CveMovimientoEntrada = ObjInventario.AddMovimiento(GvDatosRecepcion.Rows(0).DataKey("CveAlmacenDestino").ToEntero, 9, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1) + + ' If CveMovimientoEntrada <= 0 Then + ' TextoError = "No se pudo generar el movimiento de entrada correctamente" + ' ErrorMovInv = True + ' Else + + ' If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) 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.ToDouble, Dr("CveAF").ToString.ToEntero) Then + ' ErrorMovInv = True + ' TextoError = "Ocurrió un error al guardar los movimientos de salida" + ' Exit For + ' End If + ' Next + + ' End If + + ' End If + 'End If + + + If Not ErrorMovInv Then + ObjInventario.Commit() + + TxtRecibio.Text = "" + TxtFechaRecepcion.Text = Now.ToShortDateString + TxtObservacionesRecepcion.Text = "" + + Dim Mensaje As StringBuilder = New StringBuilder + Mensaje.AppendFormat("Se realizo correctamente la recepción.
Folio de Entrada: {0}", Folio, CveMovimientoSalida) + Mensaje.AppendFormat("
Imprimir Reporte", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoSalida))) 'onclick='ImprimirTraslado()' + If CveMovimientoVirtualEntrada > 0 Then Mensaje.AppendFormat("

Virtual{2}Imprimir Reporte", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoVirtualEntrada)), CveMovimientoVirtualEntrada, FolioVirtualEntrada) 'onclick='ImprimirTraslado()' + + + Alert(Mensaje.ToString, TipoMensaje.MsgInformacion) + + DivCodigoSeriePSRecepcion.Visible = False + + GvDatosRecepcion.DataBind() + UpDatosRecepcion.Update() + UPDatosAlmacen.Update() + Else + ObjInventario.RollBack() + Alert(TextoError, TipoMensaje.MsgError) + End If + ObjInventario.Dispose() + ObjConta.Dispose() + CargaRecepcion() + Else + Alert("No hay movimientos para el traspaso", TipoMensaje.MsgAdvertencia) + If ChkTransitorio.Checked Then RegistraScript("$('#DivTransitorio').show(200);") + End If + End Sub + + 'Private Sub DdlProducto_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlProducto.SelectedIndexChanged + ' 'CargarUM(DdlProducto.SelectedValue.ToEntero) + ' ElProductoChange() + 'End Sub + + 'Private Sub HFProducto_ValueChanged(sender As Object, e As EventArgs) Handles HFProducto.ValueChanged + ' ElProductoChange() + 'End Sub + Private Sub CargarUM(CvePS As Integer) + Dim ObjUM As New ClsProductosServicios() + If ObjUM.GetPSEquivalencias(CvePS, UsuarioActual.CveEmpresa) Then + DdlUnidad.Items.Clear() + DdlUnidad.DataSource = ObjUM.DtResultados + End If + ObjUM.Dispose() + DdlUnidad.DataBind() End Sub 'Protected Sub BtnImprimirTraspaso_Click(sender As Object, e As EventArgs) Handles BtnImprimirTraspaso.Click @@ -1913,756 +1913,756 @@ Partial Class Inventarios_TraspasoAlmacen ' ImprimirPDF(String.Format("{0}Formatos\Traslado.rdlc", UsuarioActual.Empresa.Ruta), DtTraslado, params, "Reporte Traslado", RDSName:="DsInventarios") 'End Sub -#End Region +#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 DrPS = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimero($"CodigoBarras = '{TxtCodigoPS.Text}'") + If DrPS Is Nothing Then + Alert($"No se ha encontrado un producto del Codigo ""{TxtCodigoPS.Text}"". ", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus,200);") + RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") + TxtCodigoPS.Text = "" + Exit Sub + End If + + If DrPS("Inv_CveMetodoInventario").ToString.ToEntero = 5 Then + TdSeriePS.Visible = True + TxtSeriePS.Focus() + CvePSSerieLote = DrPS("CvePS").ToString.ToEntero + CveUMSerieLote = DrPS("CveUnidadMedida").ToString.ToEntero + Exit Sub + End If + + AgregarPS(1, DrPS("CvePS").ToString.ToEntero, DrPS("CveUnidadMedida").ToString.ToEntero) + + TxtCodigoPS.Text = "" -#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 DrPS = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimero($"CodigoBarras = '{TxtCodigoPS.Text}'") - If DrPS Is Nothing Then - Alert($"No se ha encontrado un producto del Codigo ""{TxtCodigoPS.Text}"". ", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus,200);") - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - TxtCodigoPS.Text = "" - Exit Sub - End If - - If DrPS("Inv_CveMetodoInventario").ToString.ToEntero = 5 Then - TdSeriePS.Visible = True - TxtSeriePS.Focus() - CvePSSerieLote = DrPS("CvePS").ToString.ToEntero - CveUMSerieLote = DrPS("CveUnidadMedida").ToString.ToEntero - Exit Sub - End If - - AgregarPS(1, DrPS("CvePS").ToString.ToEntero, DrPS("CveUnidadMedida").ToString.ToEntero) - - TxtCodigoPS.Text = "" - - End Sub - Protected Sub BtnSeriePS_Click(sender As Object, e As EventArgs) - If TxtSeriePS.Text.Trim = "" Then - Exit Sub - End If - - txtCantidad.Text = "1" - - Dim Valido = ValidaExistencia(1, CvePSSerieLote, CveUMSerieLote, TxtSeriePS.Text.Trim) - - If Valido Then - AgregarPS(1, CvePSSerieLote, CveUMSerieLote, TxtSeriePS.Text.Trim) - Else - TxtSeriePS.Text = "" - TxtSeriePS.Focus() - Exit Sub - End If - - TdSeriePS.Visible = False - TxtSeriePS.Text = "" - TxtCodigoPS.Text = "" - TxtCodigoPS.Focus() - End Sub -#End Region + Protected Sub BtnSeriePS_Click(sender As Object, e As EventArgs) + If TxtSeriePS.Text.Trim = "" Then + Exit Sub + End If + + txtCantidad.Text = "1" + + Dim Valido = ValidaExistencia(1, CvePSSerieLote, CveUMSerieLote, TxtSeriePS.Text.Trim) + + If Valido Then + AgregarPS(1, CvePSSerieLote, CveUMSerieLote, TxtSeriePS.Text.Trim) + Else + TxtSeriePS.Text = "" + TxtSeriePS.Focus() + Exit Sub + End If + + TdSeriePS.Visible = False + TxtSeriePS.Text = "" + TxtCodigoPS.Text = "" + TxtCodigoPS.Focus() -#Region " AGREGA CON TXT | CODIGO - SERIE --- RECEPCION " - Protected Sub BtnCodigoPSRecepcion_Click(sender As Object, e As EventArgs) - If TxtCodigoPSRecepcion.Text = "" Then - Exit Sub - End If - - Dim Existe = False - Dim PSTemp = "" - TdSeriePSRecepcion.Visible = False - - For Each Gvr As GridViewRow In GvDatosRecepcion.Rows - If Gvr.DataKey("CodigoBarras") = TxtCodigoPSRecepcion.Text.Trim Then - Dim TxtCantidad = GvDatosRecepcion.Rows(Gvr.RowIndex).FCTextBox("TxtCantidad") - If Gvr.DataKey("Cantidad").ToDecimal - TxtCantidad.Text.ToDecimal - 1 >= 0 Then - - If Gvr.DataKey("AplicaSerieLote") = "True" Then - TdSeriePSRecepcion.Visible = True - TxtSeriePSRecepcion.Focus() - Exit Sub - End If - - TxtCantidad.Text = (TxtCantidad.Text.ToDecimal + 1).ToString.FormatoNumero - TxtCodigoPSRecepcion.Text = "" - RegistraScript("playsonidito('beep-07.wav')") - UpDatosRecepcion.Update() - 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 ""{TxtCodigoPSRecepcion.Text}"".", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus1,200);") - End If - Next - - If Existe Then - Alert($"Ya se ha cargado la totalidad del Producto ""{PSTemp}"" con el Codigo ""{TxtCodigoPSRecepcion.Text}"".", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus1,200);") - Else - Alert($"No se ha encontrado un producto para surtir con el Codigo ""{TxtCodigoPSRecepcion.Text}"". ", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus1,200);") - End If - - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - TxtCodigoPSRecepcion.Text = "" - - End Sub - Protected Sub BtnSeriePSRecepcion_Click(sender As Object, e As EventArgs) - - If TxtSeriePSRecepcion.Text = "" Then - Exit Sub - End If - - For Each Gvr As GridViewRow In GvDatosRecepcion.Rows - If Gvr.DataKey("CodigoBarras") = TxtCodigoPSRecepcion.Text.Trim And Gvr.DataKey("SerieLote") = TxtSeriePSRecepcion.Text.Trim Then - Dim TxtCantidad = GvDatosRecepcion.Rows(Gvr.RowIndex).FCTextBox("TxtCantidad") - If Gvr.DataKey("Cantidad").ToDecimal - TxtCantidad.Text.ToDecimal - 1 >= 0 Then - - TxtCantidad.Text = (TxtCantidad.Text.ToDecimal + 1).ToString.FormatoNumero - TxtCodigoPSRecepcion.Text = "" - TdSeriePSRecepcion.Visible = False - TxtSeriePSRecepcion.Text = "" - UpDatosRecepcion.Update() - Exit Sub - End If - - Alert($"Ya se ha cargado la totalidad del Producto ""{Gvr.DataKey("PS").ToString}"" con el Codigo ""{TxtCodigoPSRecepcion.Text}"".", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus1,200);") - RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')") - - End If - Next - - Alert($"No se ha encontrado un producto para surtir con el Codigo ""{TxtCodigoPSRecepcion.Text}"". ", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus1,200);") - RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')") - 'Alert($"Ya se han cargado todos los productos o no se ha encontrado un producto de la Serie ""{TxtSeriePSRecepcion.Text}"". ", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus2,200);") - TxtSeriePSRecepcion.Text = "" End Sub -#End Region +#End Region -#Region "CORREO" +#Region " AGREGA CON TXT | CODIGO - SERIE --- RECEPCION " + Protected Sub BtnCodigoPSRecepcion_Click(sender As Object, e As EventArgs) + If TxtCodigoPSRecepcion.Text = "" Then + Exit Sub + End If - Private Sub MandaCorreo(CveMovimiento As Integer, Para As String, Optional CCP As String = "") - Dim Mail As New ClsSisMail() - Dim Asunto As String = "NOTIFICACION DE TRASPASO ENTRE ALMACENES" - Dim Body As String = GeneraCorreo(CveMovimiento) - - If Not Mail.SendMail(ClsPaginas.EmpresaNotificaciones, Para, Asunto, Body, CCP) Then - 'Dim objIE As New ClsBancos - 'objIE.UpdateBancos_IENotificaciones(1, "-1", "-1", CveIE) - 'objIE.Dispose() - Alert("No se pudo enviar el correo electrónico.", TipoMensaje.MsgError) - End If - End Sub - 'Private Sub BtnSendMail_Click(sender As Object, e As EventArgs) Handles BtnSendMail.Click - ' MandaCorreo(CveMov, TxtParaMail.Text.Trim, TxtCC.Text.Trim) - ' RegistraScript("$('#ModalDivMail').modal('hide');") - 'End Sub - Private Function GeneraCorreo(CveMovimientoSalida As Integer) As String - Dim strBody As New StringBuilder - Dim ObjInventario As New ClsInventarios - - If ObjInventario.GetMovimientos(CveMovimientoSalida, -1, -1, UsuarioActual.CveEmpresa) Then - strBody.Append(" ") - strBody.Append(" ") - strBody.Append(" ") - strBody.Append(" ") - strBody.Append(" ") - strBody.AppendFormat("
") - strBody.AppendFormat("
") - strBody.AppendFormat(" {0}", UsuarioActual.Empresa.Empresa) - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ", UsuarioActual.Empresa.Direccion) - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ", UsuarioActual.Empresa.Colonia) - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ", UsuarioActual.Empresa.Ciudad, UsuarioActual.Empresa.Estado, UsuarioActual.Empresa.CP) - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ", UsuarioActual.Empresa.RFC) - strBody.AppendFormat(" ") - strBody.AppendFormat("
{0}
Col. {0}
{0}, {1}, C.P.{2}
RFC {0}
") - strBody.AppendFormat("
") - strBody.AppendFormat("


") - - - strBody.AppendFormat("
") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat("
") - strBody.AppendFormat("
") - strBody.AppendFormat(" TRASPASO ENTRE ALMACENES{0} ", " ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ", ObjInventario.Fecha.ToString("dd/MM/yyyy")) - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ", ObjInventario.Almacen) - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ", ObjInventario.AlmacenDestino) - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ", ObjInventario.Observaciones) - strBody.AppendFormat(" ") - 'strBody.AppendFormat(" ") - 'strBody.AppendFormat(" ") - 'strBody.AppendFormat(" ", objIE.Importe.FormatoNumero, objIE.Moneda) - 'strBody.AppendFormat(" ") - 'strBody.AppendFormat(" ") - 'strBody.AppendFormat(" ") - 'strBody.AppendFormat(" ", objIE.Observaciones) - 'strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat("
Fecha:{0}
Almacén Origen:{0}
Almacén Destino:{0}
Observaciones:{0}
Importe:$ {0} {1}
Observaciones:{0}
") - strBody.AppendFormat("
") - strBody.AppendFormat("
") - strBody.AppendFormat("
") - strBody.AppendFormat("
") - strBody.AppendFormat("
") - - - 'MOVIMIENTOS CHEQUE - 'Dim Textov33 As String = "" - 'If UsuarioActual.Empresa.Funcionalidad(520) = "1" Then - ' Textov33 = "Favor de emitir complemento de pago de los siguientes documentos" - 'End If - If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then - strBody.AppendFormat("
") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat("
") - strBody.AppendFormat("
") - strBody.AppendFormat(" Productos / Servicios
{0}
", "") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - 'strBody.AppendFormat(" ") - 'strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - - - For Each dr As DataRow In ObjInventario.DtResultados.Rows - strBody.AppendFormat(" ") - strBody.AppendFormat(" ", dr("Cantidad").ToString.FormatoNumero) - strBody.AppendFormat(" ", dr("UnidadMedida").ToString) - strBody.AppendFormat(" ", dr("CodigoPS").ToString) - 'strBody.AppendFormat(" ", dr("FolioFiscal")) - 'strBody.AppendFormat(" ", dr("ImporteNC").ToString.FormatoNumero) - strBody.AppendFormat(" ") - Next - - - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat("
CantidadUnidadProducto / ServicioFolio FiscalNC Aplicadas
{0}{0}{0}{0}{0}
") - strBody.AppendFormat("
") - strBody.AppendFormat("
") - strBody.AppendFormat("
") - strBody.AppendFormat("
") - strBody.AppendFormat("
") - End If - - strBody.Append("
Favor de no responder a este correo.
") - - strBody.Append("") - - - End If - - ObjInventario.Dispose() - Return strBody.ToString + Dim Existe = False + Dim PSTemp = "" + TdSeriePSRecepcion.Visible = False + + For Each Gvr As GridViewRow In GvDatosRecepcion.Rows + If Gvr.DataKey("CodigoBarras") = TxtCodigoPSRecepcion.Text.Trim Then + Dim TxtCantidad = GvDatosRecepcion.Rows(Gvr.RowIndex).FCTextBox("TxtCantidad") + If Gvr.DataKey("Cantidad").ToDecimal - TxtCantidad.Text.ToDecimal - 1 >= 0 Then + + If Gvr.DataKey("AplicaSerieLote") = "True" Then + TdSeriePSRecepcion.Visible = True + TxtSeriePSRecepcion.Focus() + Exit Sub + End If + + TxtCantidad.Text = (TxtCantidad.Text.ToDecimal + 1).ToString.FormatoNumero + TxtCodigoPSRecepcion.Text = "" + RegistraScript("playsonidito('beep-07.wav')") + UpDatosRecepcion.Update() + 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 ""{TxtCodigoPSRecepcion.Text}"".", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus1,200);") + End If + Next + + If Existe Then + Alert($"Ya se ha cargado la totalidad del Producto ""{PSTemp}"" con el Codigo ""{TxtCodigoPSRecepcion.Text}"".", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus1,200);") + Else + Alert($"No se ha encontrado un producto para surtir con el Codigo ""{TxtCodigoPSRecepcion.Text}"". ", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus1,200);") + End If + + RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") + TxtCodigoPSRecepcion.Text = "" + + End Sub + Protected Sub BtnSeriePSRecepcion_Click(sender As Object, e As EventArgs) + + If TxtSeriePSRecepcion.Text = "" Then + Exit Sub + End If + + For Each Gvr As GridViewRow In GvDatosRecepcion.Rows + If Gvr.DataKey("CodigoBarras") = TxtCodigoPSRecepcion.Text.Trim And Gvr.DataKey("SerieLote") = TxtSeriePSRecepcion.Text.Trim Then + Dim TxtCantidad = GvDatosRecepcion.Rows(Gvr.RowIndex).FCTextBox("TxtCantidad") + If Gvr.DataKey("Cantidad").ToDecimal - TxtCantidad.Text.ToDecimal - 1 >= 0 Then + + TxtCantidad.Text = (TxtCantidad.Text.ToDecimal + 1).ToString.FormatoNumero + TxtCodigoPSRecepcion.Text = "" + TdSeriePSRecepcion.Visible = False + TxtSeriePSRecepcion.Text = "" + UpDatosRecepcion.Update() + Exit Sub + End If + + Alert($"Ya se ha cargado la totalidad del Producto ""{Gvr.DataKey("PS").ToString}"" con el Codigo ""{TxtCodigoPSRecepcion.Text}"".", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus1,200);") + RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')") + + End If + Next + + Alert($"No se ha encontrado un producto para surtir con el Codigo ""{TxtCodigoPSRecepcion.Text}"". ", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus1,200);") + RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')") + 'Alert($"Ya se han cargado todos los productos o no se ha encontrado un producto de la Serie ""{TxtSeriePSRecepcion.Text}"". ", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus2,200);") + TxtSeriePSRecepcion.Text = "" + End Sub +#End Region + +#Region "CORREO" + + Private Sub MandaCorreo(CveMovimiento As Integer, Para As String, Optional CCP As String = "") + Dim Mail As New ClsSisMail() + Dim Asunto As String = "NOTIFICACION DE TRASPASO ENTRE ALMACENES" + Dim Body As String = GeneraCorreo(CveMovimiento) + + If Not Mail.SendMail(ClsPaginas.EmpresaNotificaciones, Para, Asunto, Body, CCP) Then + 'Dim objIE As New ClsBancos + 'objIE.UpdateBancos_IENotificaciones(1, "-1", "-1", CveIE) + 'objIE.Dispose() + Alert("No se pudo enviar el correo electrónico.", TipoMensaje.MsgError) + End If + End Sub + 'Private Sub BtnSendMail_Click(sender As Object, e As EventArgs) Handles BtnSendMail.Click + ' MandaCorreo(CveMov, TxtParaMail.Text.Trim, TxtCC.Text.Trim) + ' RegistraScript("$('#ModalDivMail').modal('hide');") + 'End Sub + Private Function GeneraCorreo(CveMovimientoSalida As Integer) As String + Dim strBody As New StringBuilder + Dim ObjInventario As New ClsInventarios + + If ObjInventario.GetMovimientos(CveMovimientoSalida, -1, -1, UsuarioActual.CveEmpresa) Then + strBody.Append(" ") + strBody.Append(" ") + strBody.Append(" ") + strBody.Append(" ") + strBody.Append(" ") + strBody.AppendFormat("
") + strBody.AppendFormat("
") + strBody.AppendFormat(" {0}", UsuarioActual.Empresa.Empresa) + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ", UsuarioActual.Empresa.Direccion) + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ", UsuarioActual.Empresa.Colonia) + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ", UsuarioActual.Empresa.Ciudad, UsuarioActual.Empresa.Estado, UsuarioActual.Empresa.CP) + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ", UsuarioActual.Empresa.RFC) + strBody.AppendFormat(" ") + strBody.AppendFormat("
{0}
Col. {0}
{0}, {1}, C.P.{2}
RFC {0}
") + strBody.AppendFormat("
") + strBody.AppendFormat("


") + + + strBody.AppendFormat("
") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat("
") + strBody.AppendFormat("
") + strBody.AppendFormat(" TRASPASO ENTRE ALMACENES{0} ", " ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ", ObjInventario.Fecha.ToString("dd/MM/yyyy")) + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ", ObjInventario.Almacen) + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ", ObjInventario.AlmacenDestino) + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ", ObjInventario.Observaciones) + strBody.AppendFormat(" ") + 'strBody.AppendFormat(" ") + 'strBody.AppendFormat(" ") + 'strBody.AppendFormat(" ", objIE.Importe.FormatoNumero, objIE.Moneda) + 'strBody.AppendFormat(" ") + 'strBody.AppendFormat(" ") + 'strBody.AppendFormat(" ") + 'strBody.AppendFormat(" ", objIE.Observaciones) + 'strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat("
Fecha:{0}
Almacén Origen:{0}
Almacén Destino:{0}
Observaciones:{0}
Importe:$ {0} {1}
Observaciones:{0}
") + strBody.AppendFormat("
") + strBody.AppendFormat("
") + strBody.AppendFormat("
") + strBody.AppendFormat("
") + strBody.AppendFormat("
") + + + 'MOVIMIENTOS CHEQUE + 'Dim Textov33 As String = "" + 'If UsuarioActual.Empresa.Funcionalidad(520) = "1" Then + ' Textov33 = "Favor de emitir complemento de pago de los siguientes documentos" + 'End If + If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then + strBody.AppendFormat("
") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat("
") + strBody.AppendFormat("
") + strBody.AppendFormat(" Productos / Servicios
{0}
", "") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + 'strBody.AppendFormat(" ") + 'strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + + + For Each dr As DataRow In ObjInventario.DtResultados.Rows + strBody.AppendFormat(" ") + strBody.AppendFormat(" ", dr("Cantidad").ToString.FormatoNumero) + strBody.AppendFormat(" ", dr("UnidadMedida").ToString) + strBody.AppendFormat(" ", dr("CodigoPS").ToString) + 'strBody.AppendFormat(" ", dr("FolioFiscal")) + 'strBody.AppendFormat(" ", dr("ImporteNC").ToString.FormatoNumero) + strBody.AppendFormat(" ") + Next + + + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat("
CantidadUnidadProducto / ServicioFolio FiscalNC Aplicadas
{0}{0}{0}{0}{0}
") + strBody.AppendFormat("
") + strBody.AppendFormat("
") + strBody.AppendFormat("
") + strBody.AppendFormat("
") + strBody.AppendFormat("
") + End If + + strBody.Append("
Favor de no responder a este correo.
") + + strBody.Append("") + + + End If + + ObjInventario.Dispose() + Return strBody.ToString End Function -#End Region +#End Region -#Region "TIMBRADO" - Private Sub CreaObjetosVenta() - ObjFactura = New Modelos.Factura - ObjFactura.Version = "3.3" - ObjFactura.CveUsuario = UsuarioActual.CveUsuario - ObjFactura.CveEmpresa = UsuarioActual.CveEmpresa - ObjFactura.TipoCambio = 0 - ObjFactura.ConvertirPesos = False - ObjFactura.TipoCambio = 0 - ObjFactura.CveMoneda = 1 - ObjFactura.Moneda = GlobalDTMonedas.FiltroPrimeroValor("Moneda", $"CveMoneda = {ObjFactura.CveMoneda} ") - ObjFactura.MonedaSAT = GlobalDTMonedas.FiltroPrimeroValor("AbreviaturaSAT", "CveMoneda = 1") - ObjFactura.MonedaAbreviatura = GlobalDTMonedas.FiltroPrimeroValor("Abreviatura", $"CveMoneda = {ObjFactura.CveMoneda} ") - ObjFactura.TipoDocto = "Tra" - ObjFactura.RefDocto = "" - ObjFactura.Folio = Folio.ToEntero - ObjFactura.Serie = "Tra" - ObjFactura.CveMesa = -1 - ObjFactura.Fecha = Now - ObjFactura.CvePrePoliza = -1 - ObjFactura.FechaPago = Now - ObjFactura.MotivoDescuento = "" - ObjFactura.Observaciones = "" - ObjFactura.FechaEjecucion = Now - ObjFactura.UsuarioCreo = UsuarioActual.Usuario - ObjFactura.CveCondicionEntrega = -1 - ObjFactura.CondicionEntrega = "" - ObjFactura.NumeroCuenta = "" - ObjFactura.CondicionesPago = 0 - ObjFactura.FormaPago = 0 - ObjFactura.PedidoContrato = "" - ObjFactura.OrdenCompra = "" - ObjFactura.NumeroContrato = "" - ObjFactura.NumeroDescripcionContrato = "" - ObjFactura.DescripcionContrato = "" - ObjFactura.CveCorte = -1 - ObjFactura.TipoDocumento = "Traspaso" - ObjFactura.Alfa1 = "" - ObjFactura.Alfa2 = "" - ObjFactura.Alfa3 = "" - ObjFactura.Descuento = 0 - ObjFactura.Amortizacion = 0 - ObjFactura.CveContrato = 0 - ObjFactura.CveVendedor = 0 - ObjFactura.FechaVencimiento = Now - ObjFactura.TipoEstatus = 0 - ObjFactura.Det_OrdenCompra = "" - ObjFactura.Inv_CveEstatusEntrega = 0 - ObjFactura.FormaPago33 = "" - ObjFactura.MetodoPago33 = "" - ObjFactura.UsoCFDI = "" - ObjFactura.CveClienteSucursal = 0 - Dim CveSubProyecto As Integer = -1 - If GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros($"CveAlmacen = {DdlAlmacenOrigen.SelectedValue}").Rows.Count > 0 Then - CveSubProyecto = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros($"CveAlmacen = {DdlAlmacenOrigen.SelectedValue}").Rows(0)("CveSubProyecto").ToString.ToEntero - End If - ObjFactura.CveSubProyecto = CveSubProyecto - ObjFactura.CveSubProyectoCobranza = CveSubProyecto - ObjFactura.CveSubProyectoEjecucion = CveSubProyecto - - ObjFactura.SubTotal = 0 - ObjFactura.Descuento = 0 - ObjFactura.Amortizacion = 0 - ObjFactura.IVA = 0 - ObjFactura.RetIVA = 0 - ObjFactura.RetISR = 0 - ObjFactura.IEPS = 0 - ObjFactura.Total = 0 - - 'DETALLES - ObjFactura.DtDetalle = DtMovimientos - - 'SUBPROYECTO - ObjFactura.SetSubProyectoMatriz(Me) - ObjFactura.SetSubProyecto(Me) - - ObjFactura.Inv_CveMovimiento = CveMovimientoTimbrado - - ObjFactura.Timbre = PreParaTimbre(ObjFactura) - - End Sub - Private Function PreParaTimbre(Obj As Modelos.Factura) As CFDITimbre - Dim Timbre As New CFDITimbre - Timbre.Comprobante.TipoComprobante = "T" - Timbre.Comprobante.Folio = Obj.Folio.ToString - Timbre.Comprobante.Serie = Obj.Serie - Timbre.Comprobante.Fecha = Obj.Fecha - Timbre.Comprobante.FormadePago = Obj.FormaPagoSAT33 - Timbre.Comprobante.CondicionesdePago = Obj.FormaPago33 - Timbre.Comprobante.MetodoPago = Obj.ClaveMetodoPagoSAT - Timbre.Comprobante.Subtotal = Obj.SubTotal - Timbre.Comprobante.Descuentos = Obj.Descuento - Timbre.Comprobante.Moneda = Obj.MonedaSAT - Timbre.Comprobante.TipoCambio = If(Obj.CveMoneda = 1, "1", Obj.TipoCambio.ToString) - Timbre.Comprobante.Total = Obj.Total - - Timbre.Comprobante.LugarExpedicion = Obj.SubProyecto.CP - Timbre.Comprobante.Confirmacion = "" - - Timbre.Receptor.RFC = "XAXX010101000" - Timbre.Receptor.Nombre = UsuarioActual.Empresa.Empresa - Timbre.Receptor.UsoCFDI = "P01" - - Dim totSubTotal As Decimal = Obj.SubTotal - Dim totIVA As Decimal = Obj.IVA - Dim totRetIVA As Decimal = Obj.RetIVA - Dim totRetISR As Decimal = Obj.RetISR - Dim i As Integer = 1 - - 'DETALLES - Dim tPS As String = "" - - For Each drr As DataRow In Obj.DtDetalle.Rows - If drr("PS").ToString.Length = 1 Then - tPS = drr("Obs").ToString - Else - If drr("PS").ToString.Length = 0 Then - tPS = "" - Else - tPS = String.Format("{0} {1}", drr("PS"), drr("Obs")) - End If - End If - - 'CONDICIONANTE, ESPECIAL - If UsuarioActual.CveEmpresa = 15 Then drr("UM") = "" 'LES COMENTAN QUE NO DEBE IR LA ETIQUETA DE LA UNIDAD EN EL PRODUCTO - - Dim concepto As New CFDIConceptos With {.Cantidad = drr("Cantidad").ToString.ToDecimal, - .Descripcion = tPS, - .ValorUnitario = drr("PU").ToString.ToDecimal, - .Importe = drr("TotalImporte").ToString.ToDecimal, - .Descuento = drr("Descuento").ToString.ToDecimal, - .Unidad = drr("UM").ToString, - .ClaveUnidad = drr("SATClaveUM").ToString, - .ClaveProdServ = drr("SATClaveProdServ").ToString, - .Noidentificacion = drr("Noidentificacion").ToString, - .CuentaPredial = drr("CuentaPredial").ToString} - 'VERIFICA SUMA SUBTOTALES - If i = Obj.DtDetalle.Rows.Count AndAlso totSubTotal <> concepto.Importe Then 'PROCESO DE AJUSTA DE DECIMALES - concepto.Importe = totSubTotal - End If - totSubTotal = totSubTotal - concepto.Importe - - 'SIEMPRE ESTAMOS AGREGANDO EL IVA - 'concepto.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "T", .Base = concepto.Importe - concepto.Descuento, .TasaOCuota = drr("PorcentajeIVA").ToString.ToDecimal, .Impuesto = "002", .Importe = drr("ImporteIVA").ToString.ToDecimal}) - - Timbre.Conceptos.Add(concepto) - i += 1 - Next - Return Timbre - End Function - - Private Sub PrepararTimbrado(ByRef FM As Modelos.FemsaFactura, ByRef TmpDT7Eleven As DataTable, ByRef TmpDTComplementosTimbrado As DataTable) - FM.AplicaFEMSA = False - FM.FEMSA_NumSociedad = "" - FM.FEMSA_NumProveedor = "" - FM.FEMSA_Mail = "" - FM.FEMSA_Version = 0 - FM.FEMSA_NumPedido = 0 - FM.FEMSA_NumEntrada = "" - FM.FEMSA_NumRemision = "" - FM.FEMSA_NumSocio = "" - FM.FEMSA_CentroCosto = "" - FM.FEMSA_IPeriodoLiquidacion = "" - FM.FEMSA_FPeriodoLiquidacion = "" - FM.FEMSA_CodRetencion1 = "" - FM.FEMSA_CodRetencion2 = "" - - TmpDT7Eleven.Columns.Add("sevenElevenNumProveedor") - TmpDT7Eleven.Columns.Add("sevenElevenFolio") - TmpDT7Eleven.Columns.Add("sevenElevenTienda") - TmpDT7Eleven.Columns.Add("sevenElevenFecha") - - Dim Row As DataRow = TmpDT7Eleven.NewRow - Row("sevenElevenNumProveedor") = "" - Row("sevenElevenFolio") = "" - Row("sevenElevenTienda") = "" - Row("sevenElevenFecha") = "" - - TmpDT7Eleven.Rows.Add(Row) - - TmpDTComplementosTimbrado.Columns.Add("CveComplemento") - TmpDTComplementosTimbrado.Columns.Add("IdContabilidad") - TmpDTComplementosTimbrado.Columns.Add("TipoProceso") - TmpDTComplementosTimbrado.Columns.Add("TipoAmbito") - TmpDTComplementosTimbrado.Columns.Add("Entidad") - - Dim Row2 As DataRow = TmpDTComplementosTimbrado.NewRow - - Row2("CveComplemento") = "" - Row2("IdContabilidad") = "" - Row2("TipoProceso") = "" - Row2("TipoAmbito") = "" - Row2("Entidad") = "" - - TmpDTComplementosTimbrado.Rows.Add(Row2) - End Sub - - Private Sub Timbrar() - CreaObjetosVenta() - Dim ObjTimbrado As New Timbrado - Dim FM As New Modelos.FemsaFactura - Dim TmpDT7Eleven As New DataTable - Dim TmpDTComplementosTimbrado As New DataTable - PrepararTimbrado(FM, TmpDT7Eleven, TmpDTComplementosTimbrado) - MensajeAlert.Append("

") - If ObjTimbrado.TimbrarFactura(UsuarioActual, ObjFactura) Then - MensajeAlert.Append("Emitido con exito.") - 'XML - Dim ArchivoXML = String.Format("{0}/XML/{1}/{2}.xml", UsuarioActual.Empresa.Ruta, ObjFactura.TipoDocto, ObjFactura.SerieFolio) - If File.Exists(ArchivoXML) Then - MensajeAlert.AppendFormat("", Encripta(String.Format("OP=DesXmlTra&CVEMOVIMIENTO={0}&EXT={1}&FOLIO={2}&TIPODOCTO={3}", CveMovimientoTimbrado, "XML", ObjFactura.SerieFolio, ObjFactura.TipoDocto))) - End If - 'PDF - GeneraPDFFactura() - Dim ArchivoPDF = String.Format("{0}/PDF/{1}/{2}.pdf", UsuarioActual.Empresa.Ruta, ObjFactura.TipoDocto, ObjFactura.SerieFolio) - If File.Exists(ArchivoPDF) Then - MensajeAlert.AppendFormat("", Encripta(String.Format("OP=DesPdfTra&CVEMOVIMIENTO={0}&EXT={1}&FOLIO={2}&TIPODOCTO={3}", CveMovimientoTimbrado, "PDF", ObjFactura.SerieFolio, ObjFactura.TipoDocto))) - End If - - MensajeAlert.AppendFormat("", Encripta(String.Format("OP=CARPO&CVEMOV={0}", CveMovimientoTimbrado))) - - Else - MensajeAlert.AppendFormat(ObjTimbrado.MensajeErrorCFDI) - End If - - End Sub - - Private Sub GeneraPDFFactura() - Try - PdfFactura(ObjFactura) - Catch ex As Exception - Alert("Ocurrió un error al generar el PDF", TipoMensaje.MsgError) - End Try +#Region "TIMBRADO" + Private Sub CreaObjetosVenta() + ObjFactura = New Modelos.Factura + ObjFactura.Version = "3.3" + ObjFactura.CveUsuario = UsuarioActual.CveUsuario + ObjFactura.CveEmpresa = UsuarioActual.CveEmpresa + ObjFactura.TipoCambio = 0 + ObjFactura.ConvertirPesos = False + ObjFactura.TipoCambio = 0 + ObjFactura.CveMoneda = 1 + ObjFactura.Moneda = GlobalDTMonedas.FiltroPrimeroValor("Moneda", $"CveMoneda = {ObjFactura.CveMoneda} ") + ObjFactura.MonedaSAT = GlobalDTMonedas.FiltroPrimeroValor("AbreviaturaSAT", "CveMoneda = 1") + ObjFactura.MonedaAbreviatura = GlobalDTMonedas.FiltroPrimeroValor("Abreviatura", $"CveMoneda = {ObjFactura.CveMoneda} ") + ObjFactura.TipoDocto = "Tra" + ObjFactura.RefDocto = "" + ObjFactura.Folio = Folio.ToEntero + ObjFactura.Serie = "Tra" + ObjFactura.CveMesa = -1 + ObjFactura.Fecha = Now + ObjFactura.CvePrePoliza = -1 + ObjFactura.FechaPago = Now + ObjFactura.MotivoDescuento = "" + ObjFactura.Observaciones = "" + ObjFactura.FechaEjecucion = Now + ObjFactura.UsuarioCreo = UsuarioActual.Usuario + ObjFactura.CveCondicionEntrega = -1 + ObjFactura.CondicionEntrega = "" + ObjFactura.NumeroCuenta = "" + ObjFactura.CondicionesPago = 0 + ObjFactura.FormaPago = 0 + ObjFactura.PedidoContrato = "" + ObjFactura.OrdenCompra = "" + ObjFactura.NumeroContrato = "" + ObjFactura.NumeroDescripcionContrato = "" + ObjFactura.DescripcionContrato = "" + ObjFactura.CveCorte = -1 + ObjFactura.TipoDocumento = "Traspaso" + ObjFactura.Alfa1 = "" + ObjFactura.Alfa2 = "" + ObjFactura.Alfa3 = "" + ObjFactura.Descuento = 0 + ObjFactura.Amortizacion = 0 + ObjFactura.CveContrato = 0 + ObjFactura.CveVendedor = 0 + ObjFactura.FechaVencimiento = Now + ObjFactura.TipoEstatus = 0 + ObjFactura.Det_OrdenCompra = "" + ObjFactura.Inv_CveEstatusEntrega = 0 + ObjFactura.FormaPago33 = "" + ObjFactura.MetodoPago33 = "" + ObjFactura.UsoCFDI = "" + ObjFactura.CveClienteSucursal = 0 + Dim CveSubProyecto As Integer = -1 + If GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros($"CveAlmacen = {DdlAlmacenOrigen.SelectedValue}").Rows.Count > 0 Then + CveSubProyecto = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros($"CveAlmacen = {DdlAlmacenOrigen.SelectedValue}").Rows(0)("CveSubProyecto").ToString.ToEntero + End If + ObjFactura.CveSubProyecto = CveSubProyecto + ObjFactura.CveSubProyectoCobranza = CveSubProyecto + ObjFactura.CveSubProyectoEjecucion = CveSubProyecto + + ObjFactura.SubTotal = 0 + ObjFactura.Descuento = 0 + ObjFactura.Amortizacion = 0 + ObjFactura.IVA = 0 + ObjFactura.RetIVA = 0 + ObjFactura.RetISR = 0 + ObjFactura.IEPS = 0 + ObjFactura.Total = 0 + + 'DETALLES + ObjFactura.DtDetalle = DtMovimientos + + 'SUBPROYECTO + ObjFactura.SetSubProyectoMatriz(Me) + ObjFactura.SetSubProyecto(Me) + + ObjFactura.Inv_CveMovimiento = CveMovimientoTimbrado + + ObjFactura.Timbre = PreParaTimbre(ObjFactura) + + End Sub + Private Function PreParaTimbre(Obj As Modelos.Factura) As CFDITimbre + Dim Timbre As New CFDITimbre + Timbre.Comprobante.TipoComprobante = "T" + Timbre.Comprobante.Folio = Obj.Folio.ToString + Timbre.Comprobante.Serie = Obj.Serie + Timbre.Comprobante.Fecha = Obj.Fecha + Timbre.Comprobante.FormadePago = Obj.FormaPagoSAT33 + Timbre.Comprobante.CondicionesdePago = Obj.FormaPago33 + Timbre.Comprobante.MetodoPago = Obj.ClaveMetodoPagoSAT + Timbre.Comprobante.Subtotal = Obj.SubTotal + Timbre.Comprobante.Descuentos = Obj.Descuento + Timbre.Comprobante.Moneda = Obj.MonedaSAT + Timbre.Comprobante.TipoCambio = If(Obj.CveMoneda = 1, "1", Obj.TipoCambio.ToString) + Timbre.Comprobante.Total = Obj.Total + + Timbre.Comprobante.LugarExpedicion = Obj.SubProyecto.CP + Timbre.Comprobante.Confirmacion = "" + + Timbre.Receptor.RFC = "XAXX010101000" + Timbre.Receptor.Nombre = UsuarioActual.Empresa.Empresa + Timbre.Receptor.UsoCFDI = "P01" + + Dim totSubTotal As Decimal = Obj.SubTotal + Dim totIVA As Decimal = Obj.IVA + Dim totRetIVA As Decimal = Obj.RetIVA + Dim totRetISR As Decimal = Obj.RetISR + Dim i As Integer = 1 + + 'DETALLES + Dim tPS As String = "" + + For Each drr As DataRow In Obj.DtDetalle.Rows + If drr("PS").ToString.Length = 1 Then + tPS = drr("Obs").ToString + Else + If drr("PS").ToString.Length = 0 Then + tPS = "" + Else + tPS = String.Format("{0} {1}", drr("PS"), drr("Obs")) + End If + End If + + 'CONDICIONANTE, ESPECIAL + If UsuarioActual.CveEmpresa = 15 Then drr("UM") = "" 'LES COMENTAN QUE NO DEBE IR LA ETIQUETA DE LA UNIDAD EN EL PRODUCTO + + Dim concepto As New CFDIConceptos With {.Cantidad = drr("Cantidad").ToString.ToDecimal, + .Descripcion = tPS, + .ValorUnitario = drr("PU").ToString.ToDecimal, + .Importe = drr("TotalImporte").ToString.ToDecimal, + .Descuento = drr("Descuento").ToString.ToDecimal, + .Unidad = drr("UM").ToString, + .ClaveUnidad = drr("SATClaveUM").ToString, + .ClaveProdServ = drr("SATClaveProdServ").ToString, + .Noidentificacion = drr("Noidentificacion").ToString, + .CuentaPredial = drr("CuentaPredial").ToString} + 'VERIFICA SUMA SUBTOTALES + If i = Obj.DtDetalle.Rows.Count AndAlso totSubTotal <> concepto.Importe Then 'PROCESO DE AJUSTA DE DECIMALES + concepto.Importe = totSubTotal + End If + totSubTotal = totSubTotal - concepto.Importe + + 'SIEMPRE ESTAMOS AGREGANDO EL IVA + 'concepto.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "T", .Base = concepto.Importe - concepto.Descuento, .TasaOCuota = drr("PorcentajeIVA").ToString.ToDecimal, .Impuesto = "002", .Importe = drr("ImporteIVA").ToString.ToDecimal}) + + Timbre.Conceptos.Add(concepto) + i += 1 + Next + Return Timbre + End Function + + Private Sub PrepararTimbrado(ByRef FM As Modelos.FemsaFactura, ByRef TmpDT7Eleven As DataTable, ByRef TmpDTComplementosTimbrado As DataTable) + FM.AplicaFEMSA = False + FM.FEMSA_NumSociedad = "" + FM.FEMSA_NumProveedor = "" + FM.FEMSA_Mail = "" + FM.FEMSA_Version = 0 + FM.FEMSA_NumPedido = 0 + FM.FEMSA_NumEntrada = "" + FM.FEMSA_NumRemision = "" + FM.FEMSA_NumSocio = "" + FM.FEMSA_CentroCosto = "" + FM.FEMSA_IPeriodoLiquidacion = "" + FM.FEMSA_FPeriodoLiquidacion = "" + FM.FEMSA_CodRetencion1 = "" + FM.FEMSA_CodRetencion2 = "" + + TmpDT7Eleven.Columns.Add("sevenElevenNumProveedor") + TmpDT7Eleven.Columns.Add("sevenElevenFolio") + TmpDT7Eleven.Columns.Add("sevenElevenTienda") + TmpDT7Eleven.Columns.Add("sevenElevenFecha") + + Dim Row As DataRow = TmpDT7Eleven.NewRow + Row("sevenElevenNumProveedor") = "" + Row("sevenElevenFolio") = "" + Row("sevenElevenTienda") = "" + Row("sevenElevenFecha") = "" + + TmpDT7Eleven.Rows.Add(Row) + + TmpDTComplementosTimbrado.Columns.Add("CveComplemento") + TmpDTComplementosTimbrado.Columns.Add("IdContabilidad") + TmpDTComplementosTimbrado.Columns.Add("TipoProceso") + TmpDTComplementosTimbrado.Columns.Add("TipoAmbito") + TmpDTComplementosTimbrado.Columns.Add("Entidad") + + Dim Row2 As DataRow = TmpDTComplementosTimbrado.NewRow + + Row2("CveComplemento") = "" + Row2("IdContabilidad") = "" + Row2("TipoProceso") = "" + Row2("TipoAmbito") = "" + Row2("Entidad") = "" + + TmpDTComplementosTimbrado.Rows.Add(Row2) End Sub -#End Region + Private Sub Timbrar() + CreaObjetosVenta() + Dim ObjTimbrado As New Timbrado + Dim FM As New Modelos.FemsaFactura + Dim TmpDT7Eleven As New DataTable + Dim TmpDTComplementosTimbrado As New DataTable + PrepararTimbrado(FM, TmpDT7Eleven, TmpDTComplementosTimbrado) + MensajeAlert.Append("

") + If ObjTimbrado.TimbrarFactura(UsuarioActual, ObjFactura) Then + MensajeAlert.Append("Emitido con exito.") + 'XML + Dim ArchivoXML = String.Format("{0}/XML/{1}/{2}.xml", UsuarioActual.Empresa.Ruta, ObjFactura.TipoDocto, ObjFactura.SerieFolio) + If File.Exists(ArchivoXML) Then + MensajeAlert.AppendFormat("", Encripta(String.Format("OP=DesXmlTra&CVEMOVIMIENTO={0}&EXT={1}&FOLIO={2}&TIPODOCTO={3}", CveMovimientoTimbrado, "XML", ObjFactura.SerieFolio, ObjFactura.TipoDocto))) + End If + 'PDF + GeneraPDFFactura() + Dim ArchivoPDF = String.Format("{0}/PDF/{1}/{2}.pdf", UsuarioActual.Empresa.Ruta, ObjFactura.TipoDocto, ObjFactura.SerieFolio) + If File.Exists(ArchivoPDF) Then + MensajeAlert.AppendFormat("", Encripta(String.Format("OP=DesPdfTra&CVEMOVIMIENTO={0}&EXT={1}&FOLIO={2}&TIPODOCTO={3}", CveMovimientoTimbrado, "PDF", ObjFactura.SerieFolio, ObjFactura.TipoDocto))) + End If -#Region "SECCION ALMACEN" - Private Sub CreaDtSeccionAlmacen() - DtSeccionAlmacen = New DataTable - DtSeccionAlmacen.Columns.Add("CantidadSeccionAlmacen", GetType(Decimal)) - DtSeccionAlmacen.Columns.Add("IndexSeccionAlmacen", GetType(Integer)) - DtSeccionAlmacen.Columns.Add("CveSeccionAlmacenOrigen", GetType(Integer)) - DtSeccionAlmacen.Columns.Add("CveSeccionAlmacenDestino", GetType(Integer)) - DtSeccionAlmacen.Columns.Add("CvePS", GetType(Integer)) - DtSeccionAlmacen.Columns.Add("SeccionAlmacenOrigen", GetType(String)) - DtSeccionAlmacen.Columns.Add("SeccionAlmacenDestino", GetType(String)) - DtSeccionAlmacen.Columns.Add("Consec", GetType(Integer)) - DtSeccionAlmacen.Columns.Add("TipoSeccionAlmacen", GetType(Integer)) - End Sub - Private Sub CargaDdlAlmacen() - DdlSeccionAlmacenOrigen.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa) - DdlSeccionAlmacenOrigen.Items.Insert(0, New ListItem("Seleccione", "-1")) - DdlSeccionAlmacenOrigen.DataBind() - - DdlSeccionAlmacenDestino.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa) - DdlSeccionAlmacenDestino.Items.Insert(0, New ListItem("Seleccione", "-1")) - DdlSeccionAlmacenDestino.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 DdlAlmacenOrigen.SelectedValue.ToEntero > 0 Then - Alert("Tiene que tener seleccionado un almacen para registrar seccion almacen origen.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - 'If Not DdlAlmacenDestino.SelectedValue.ToEntero > 0 AndAlso Not ChkTransitorio.Checked Then - ' Alert("Tiene que tener seleccionado un almacen para registrar seccion almacen destino.", TipoMensaje.MsgAdvertencia) - ' Exit Sub - 'End If - - If ChkTransitorio.Checked Then - GvSeccion.Columns(2).Visible = False - DivSeccionAlmacenDestino.Visible = False - Else - GvSeccion.Columns(2).Visible = True - DivSeccionAlmacenDestino.Visible = True - End If - - DivSeccionAlmacenOrigen.Visible = True - GvSeccion.Columns(1).Visible = True - - CantidadTotal = gvRow.DataKey("Cantidad").ToDecimal - IndexSeccionAlmacen = gvRow.RowIndex - CvePS = gvRow.DataKey("CvePS").ToEntero - TipoSeccionAlmacen = 1 - CargaSeccionAlmacen() - RegistraScript("$('#DModalSeccionAlmacen').modal()") - End Sub - - Protected Sub LnkSeccionAlmacenDestino_Click(sender As Object, e As EventArgs) - Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) - - If Not DdlAlmacenRecepcion.SelectedValue.ToEntero > 0 Then - Alert("Tiene que tener seleccionado un almacen para registrar seccion almacen destino.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - DivSeccionAlmacenOrigen.Visible = False - DivSeccionAlmacenDestino.Visible = True - GvSeccion.Columns(1).Visible = False - GvSeccion.Columns(2).Visible = True - - CantidadTotal = gvRow.FCTextBox("TxtCantidad").Text.ToDecimal - IndexSeccionAlmacen = gvRow.RowIndex - CvePS = gvRow.DataKey("CvePS").ToEntero - TipoSeccionAlmacen = 2 - CargaSeccionAlmacen() - RegistraScript("$('#DModalSeccionAlmacen').modal()") - - End Sub - - Private Sub CargaSeccionAlmacen() - Dim CantidadTotalSeccion As Decimal = DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {IndexSeccionAlmacen} AND TipoSeccionAlmacen = {TipoSeccionAlmacen}").SUMD("CantidadSeccionAlmacen") - GvSeccion.DataSource = DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {IndexSeccionAlmacen} AND TipoSeccionAlmacen = {TipoSeccionAlmacen}") - GvSeccion.DataBind() - - TxtCantidadSeccion.Text = "" - DdlSeccionAlmacenOrigen.SelectedIndex = 0 - DdlSeccionAlmacenDestino.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 TipoSeccionAlmacen = 1 Then - If DtSeccionAlmacen.SUMD("CantidadSeccionAlmacen") > 0 Then - DdlAlmacenOrigen.Enabled = False - DdlAlmacenOrigen.ToolTip = "Cuenta con sección almacen" - - ChkTransitorio.Enabled = False - ChkTransitorio.ToolTip = "Cuenta con sección almacen" - - GvDatos.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").Enabled = False - GvDatos.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").ToolTip = "Cuenta con sección almacen" - - Else - DdlAlmacenOrigen.Enabled = True - DdlAlmacenOrigen.ToolTip = "" - - ChkTransitorio.Enabled = True - ChkTransitorio.ToolTip = "" - - GvDatos.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").Enabled = True - GvDatos.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").ToolTip = "" - End If - UpDatos.Update() - - ElseIf TipoSeccionAlmacen = 2 Then - If CantidadTotalSeccion > 0 Then - GvDatosRecepcion.Rows(IndexSeccionAlmacen).FCTextBox("TxtCantidad").Enabled = False - GvDatosRecepcion.Rows(IndexSeccionAlmacen).FCTextBox("TxtCantidad").ToolTip = "Cuenta con sección almacen" - Else - GvDatosRecepcion.Rows(IndexSeccionAlmacen).FCTextBox("TxtCantidad").Enabled = True - GvDatosRecepcion.Rows(IndexSeccionAlmacen).FCTextBox("TxtCantidad").ToolTip = "" - End If - UpDatosRecepcion.Update() - End If - - UpModalSeccionAlmacen.Update() - End Sub - - Protected Sub LnkAddSeccionAlmacen_Click(sender As Object, e As EventArgs) - - If TipoSeccionAlmacen = 1 Then - Dim ObjInv As New ClsInventarios - Dim CantidadDisponible As Decimal = 0 - If ObjInv.GetMovimientosDetalleSeccionesAlmacen(DdlSeccionAlmacenOrigen.SelectedValue.ToEntero, DdlAlmacenOrigen.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 CveSeccionAlmacenOrigen = {DdlSeccionAlmacenOrigen.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 - End If - - Dim Row As DataRow = Nothing - DtSeccionAlmacen.AcceptChanges() - Row = DtSeccionAlmacen.NewRow - Row("CantidadSeccionAlmacen") = TxtCantidadSeccion.Text.ToDecimal - Row("IndexSeccionAlmacen") = IndexSeccionAlmacen - Row("CveSeccionAlmacenOrigen") = DdlSeccionAlmacenOrigen.SelectedValue.ToEntero - Row("SeccionAlmacenOrigen") = DdlSeccionAlmacenOrigen.SelectedItem.Text - Row("CveSeccionAlmacenDestino") = DdlSeccionAlmacenDestino.SelectedValue.ToEntero - Row("SeccionAlmacenDestino") = DdlSeccionAlmacenDestino.SelectedItem.Text - Row("CvePS") = CvePS - Row("Consec") = DtSeccionAlmacen.Rows.Count + 1 - Row("TipoSeccionAlmacen") = TipoSeccionAlmacen - 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() + MensajeAlert.AppendFormat("", Encripta(String.Format("OP=CARPO&CVEMOV={0}", CveMovimientoTimbrado))) + + Else + MensajeAlert.AppendFormat(ObjTimbrado.MensajeErrorCFDI) + End If + + End Sub + + Private Sub GeneraPDFFactura() + Try + PdfFactura(ObjFactura) + Catch ex As Exception + Alert("Ocurrió un error al generar el PDF", TipoMensaje.MsgError) + End Try + 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("CveSeccionAlmacenOrigen", GetType(Integer)) + DtSeccionAlmacen.Columns.Add("CveSeccionAlmacenDestino", GetType(Integer)) + DtSeccionAlmacen.Columns.Add("CvePS", GetType(Integer)) + DtSeccionAlmacen.Columns.Add("SeccionAlmacenOrigen", GetType(String)) + DtSeccionAlmacen.Columns.Add("SeccionAlmacenDestino", GetType(String)) + DtSeccionAlmacen.Columns.Add("Consec", GetType(Integer)) + DtSeccionAlmacen.Columns.Add("TipoSeccionAlmacen", GetType(Integer)) + End Sub + Private Sub CargaDdlAlmacen() + DdlSeccionAlmacenOrigen.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa) + DdlSeccionAlmacenOrigen.Items.Insert(0, New ListItem("Seleccione", "-1")) + DdlSeccionAlmacenOrigen.DataBind() + + DdlSeccionAlmacenDestino.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa) + DdlSeccionAlmacenDestino.Items.Insert(0, New ListItem("Seleccione", "-1")) + DdlSeccionAlmacenDestino.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 DdlAlmacenOrigen.SelectedValue.ToEntero > 0 Then + Alert("Tiene que tener seleccionado un almacen para registrar seccion almacen origen.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + 'If Not DdlAlmacenDestino.SelectedValue.ToEntero > 0 AndAlso Not ChkTransitorio.Checked Then + ' Alert("Tiene que tener seleccionado un almacen para registrar seccion almacen destino.", TipoMensaje.MsgAdvertencia) + ' Exit Sub + 'End If + + If ChkTransitorio.Checked Then + GvSeccion.Columns(2).Visible = False + DivSeccionAlmacenDestino.Visible = False + Else + GvSeccion.Columns(2).Visible = True + DivSeccionAlmacenDestino.Visible = True + End If + + DivSeccionAlmacenOrigen.Visible = True + GvSeccion.Columns(1).Visible = True + + CantidadTotal = gvRow.DataKey("Cantidad").ToDecimal + IndexSeccionAlmacen = gvRow.RowIndex + CvePS = gvRow.DataKey("CvePS").ToEntero + TipoSeccionAlmacen = 1 + CargaSeccionAlmacen() + RegistraScript("$('#DModalSeccionAlmacen').modal()") + End Sub + + Protected Sub LnkSeccionAlmacenDestino_Click(sender As Object, e As EventArgs) + Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) + + If Not DdlAlmacenRecepcion.SelectedValue.ToEntero > 0 Then + Alert("Tiene que tener seleccionado un almacen para registrar seccion almacen destino.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + DivSeccionAlmacenOrigen.Visible = False + DivSeccionAlmacenDestino.Visible = True + GvSeccion.Columns(1).Visible = False + GvSeccion.Columns(2).Visible = True + + CantidadTotal = gvRow.FCTextBox("TxtCantidad").Text.ToDecimal + IndexSeccionAlmacen = gvRow.RowIndex + CvePS = gvRow.DataKey("CvePS").ToEntero + TipoSeccionAlmacen = 2 + CargaSeccionAlmacen() + RegistraScript("$('#DModalSeccionAlmacen').modal()") + + End Sub + + Private Sub CargaSeccionAlmacen() + Dim CantidadTotalSeccion As Decimal = DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {IndexSeccionAlmacen} AND TipoSeccionAlmacen = {TipoSeccionAlmacen}").SUMD("CantidadSeccionAlmacen") + GvSeccion.DataSource = DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {IndexSeccionAlmacen} AND TipoSeccionAlmacen = {TipoSeccionAlmacen}") + GvSeccion.DataBind() + + TxtCantidadSeccion.Text = "" + DdlSeccionAlmacenOrigen.SelectedIndex = 0 + DdlSeccionAlmacenDestino.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 TipoSeccionAlmacen = 1 Then + If DtSeccionAlmacen.SUMD("CantidadSeccionAlmacen") > 0 Then + DdlAlmacenOrigen.Enabled = False + DdlAlmacenOrigen.ToolTip = "Cuenta con sección almacen" + + ChkTransitorio.Enabled = False + ChkTransitorio.ToolTip = "Cuenta con sección almacen" + + GvDatos.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").Enabled = False + GvDatos.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").ToolTip = "Cuenta con sección almacen" + + Else + DdlAlmacenOrigen.Enabled = True + DdlAlmacenOrigen.ToolTip = "" + + ChkTransitorio.Enabled = True + ChkTransitorio.ToolTip = "" + + GvDatos.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").Enabled = True + GvDatos.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").ToolTip = "" + End If + UpDatos.Update() + + ElseIf TipoSeccionAlmacen = 2 Then + If CantidadTotalSeccion > 0 Then + GvDatosRecepcion.Rows(IndexSeccionAlmacen).FCTextBox("TxtCantidad").Enabled = False + GvDatosRecepcion.Rows(IndexSeccionAlmacen).FCTextBox("TxtCantidad").ToolTip = "Cuenta con sección almacen" + Else + GvDatosRecepcion.Rows(IndexSeccionAlmacen).FCTextBox("TxtCantidad").Enabled = True + GvDatosRecepcion.Rows(IndexSeccionAlmacen).FCTextBox("TxtCantidad").ToolTip = "" + End If + UpDatosRecepcion.Update() + End If + + UpModalSeccionAlmacen.Update() + End Sub + + Protected Sub LnkAddSeccionAlmacen_Click(sender As Object, e As EventArgs) + + If TipoSeccionAlmacen = 1 Then + Dim ObjInv As New ClsInventarios + Dim CantidadDisponible As Decimal = 0 + If ObjInv.GetMovimientosDetalleSeccionesAlmacen(DdlSeccionAlmacenOrigen.SelectedValue.ToEntero, DdlAlmacenOrigen.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 CveSeccionAlmacenOrigen = {DdlSeccionAlmacenOrigen.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 + End If + + Dim Row As DataRow = Nothing + DtSeccionAlmacen.AcceptChanges() + Row = DtSeccionAlmacen.NewRow + Row("CantidadSeccionAlmacen") = TxtCantidadSeccion.Text.ToDecimal + Row("IndexSeccionAlmacen") = IndexSeccionAlmacen + Row("CveSeccionAlmacenOrigen") = DdlSeccionAlmacenOrigen.SelectedValue.ToEntero + Row("SeccionAlmacenOrigen") = DdlSeccionAlmacenOrigen.SelectedItem.Text + Row("CveSeccionAlmacenDestino") = DdlSeccionAlmacenDestino.SelectedValue.ToEntero + Row("SeccionAlmacenDestino") = DdlSeccionAlmacenDestino.SelectedItem.Text + Row("CvePS") = CvePS + Row("Consec") = DtSeccionAlmacen.Rows.Count + 1 + Row("TipoSeccionAlmacen") = TipoSeccionAlmacen + 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) @@ -2686,32 +2686,32 @@ Partial Class Inventarios_TraspasoAlmacen ' RegistraScript("$('#ModalVerSeccionesAlmacen').modal()") 'End Sub -#End Region +#End Region - Protected Sub DldChofer_SelectedIndexChanged(sender As Object, e As EventArgs) - Dim ObjAcar As New ClsAcarreos() - - If ObjAcar.GetChofer(DdlChofer.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, 1, -1) Then - Dim dr As DataRow = ObjAcar.DtResultados.Rows(0) - If dr IsNot Nothing Then - TxtResponsableRecibio.Text = dr("Chofer").ToString - TxtIdentificacion.Text = dr("Identificacion").ToString - TxtDomicilio.Text = dr("Domicilio").ToString - TxtTelefono.Text = dr("Telefono").ToString - TxtCiudad.Text = dr("Ciudad").ToString - TxtLicencia.Text = dr("Licencia").ToString - End If - End If - ObjAcar.Dispose() + Protected Sub DldChofer_SelectedIndexChanged(sender As Object, e As EventArgs) + Dim ObjAcar As New ClsAcarreos() + + If ObjAcar.GetChofer(DdlChofer.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, 1, -1) Then + Dim dr As DataRow = ObjAcar.DtResultados.Rows(0) + If dr IsNot Nothing Then + TxtResponsableRecibio.Text = dr("Chofer").ToString + TxtIdentificacion.Text = dr("Identificacion").ToString + TxtDomicilio.Text = dr("Domicilio").ToString + TxtTelefono.Text = dr("Telefono").ToString + TxtCiudad.Text = dr("Ciudad").ToString + TxtLicencia.Text = dr("Licencia").ToString + End If + End If + ObjAcar.Dispose() End Sub Protected Sub BtnCargaExcelConceptos_Click(sender As Object, e As EventArgs) - If TxtExcelConceptos.getfiles().Archivos.Count > 0 Then - Dim file As Archivo = TxtExcelConceptos.getfiles().Archivos(0) - Dim Directorio As String = AppDomain.CurrentDomain.BaseDirectory & file.patch - CargarArchivoConceptos(Directorio, file.filename) - RegistraScript("$('#DivCargaExcelConceptos').modal('hide');") - Else - Alert("No existe el archivo. Favor de subir un archivo excel a la plataforma.", TipoMensaje.MsgError) + If TxtExcelConceptos.getfiles().Archivos.Count > 0 Then + Dim file As Archivo = TxtExcelConceptos.getfiles().Archivos(0) + Dim Directorio As String = AppDomain.CurrentDomain.BaseDirectory & file.patch + CargarArchivoConceptos(Directorio, file.filename) + RegistraScript("$('#DivCargaExcelConceptos').modal('hide');") + Else + Alert("No existe el archivo. Favor de subir un archivo excel a la plataforma.", TipoMensaje.MsgError) End If End Sub Protected Sub BtnDescargarFormatoExcelConceptos_Click(sender As Object, e As EventArgs) @@ -2722,70 +2722,70 @@ Partial Class Inventarios_TraspasoAlmacen DtExcel.Columns.Add(New DataColumn("SerieLote", GetType(String))) DtExcel.Columns.Add(New DataColumn("Observaciones", GetType(String))) - DtExcel.TableName = "Traspaso" - - SpreadsheetInfo.SetLicense(ModExtensiones.SerialGemBoxSpreadsheet) - - Dim FileExcel As New ExcelFile() - - Dim worksheet = FileExcel.Worksheets.Add(DtExcel.TableName) - worksheet.InsertDataTable(DtExcel, New InsertDataTableOptions() With - { - .ColumnHeaders = True, - .StartRow = 0, - .StartColumn = 0 - }) - worksheet.Rows(0).Style.FillPattern.SetPattern(FillPatternStyle.Solid, SpreadsheetColor.FromArgb(75, 119, 190), SpreadsheetColor.FromArgb(255, 255, 255)) - worksheet.Rows(0).Style.Font.Color = SpreadsheetColor.FromArgb(255, 255, 255) - - Dim columnCount = worksheet.CalculateMaxUsedColumns() - For i = 0 To columnCount - worksheet.Columns(i).AutoFit(1, worksheet.Rows(0), worksheet.Rows(worksheet.Rows.Count - 1)) - Next - + DtExcel.TableName = "Traspaso" + + SpreadsheetInfo.SetLicense(ModExtensiones.SerialGemBoxSpreadsheet) + + Dim FileExcel As New ExcelFile() + + Dim worksheet = FileExcel.Worksheets.Add(DtExcel.TableName) + worksheet.InsertDataTable(DtExcel, New InsertDataTableOptions() With + { + .ColumnHeaders = True, + .StartRow = 0, + .StartColumn = 0 + }) + worksheet.Rows(0).Style.FillPattern.SetPattern(FillPatternStyle.Solid, SpreadsheetColor.FromArgb(75, 119, 190), SpreadsheetColor.FromArgb(255, 255, 255)) + worksheet.Rows(0).Style.Font.Color = SpreadsheetColor.FromArgb(255, 255, 255) + + Dim columnCount = worksheet.CalculateMaxUsedColumns() + For i = 0 To columnCount + worksheet.Columns(i).AutoFit(1, worksheet.Rows(0), worksheet.Rows(worksheet.Rows.Count - 1)) + Next + FileExcel.Save(Response, "Traspaso.xlsx", SaveOptions.XlsxDefault) End Sub - Protected Sub CargarArchivoConceptos(Ruta As String, FileName As String) - SpreadsheetInfo.SetLicense(ModExtensiones.SerialGemBoxSpreadsheet) - - Dim dt As DataTable = Nothing - Dim ErrorArchivo = False - - Try - dt = ReadExcelFile(Ruta + FileName, True) - Catch ex As Exception - ErrorArchivo = True - OnError("Ocurrio un error al leer el archivo
" & ex.Message, ex) - End Try - - If Not ErrorArchivo AndAlso dt IsNot Nothing Then - - If Not dt.Columns(0).ColumnName = "Cantidad" Then - Alert("El nombre de la primera columna debe ser 'Cantidad'. Favor de corregirlo", TipoMensaje.MsgError) - Exit Sub + Protected Sub CargarArchivoConceptos(Ruta As String, FileName As String) + SpreadsheetInfo.SetLicense(ModExtensiones.SerialGemBoxSpreadsheet) + + Dim dt As DataTable = Nothing + Dim ErrorArchivo = False + + Try + dt = ReadExcelFile(Ruta + FileName, True) + Catch ex As Exception + ErrorArchivo = True + OnError("Ocurrio un error al leer el archivo
" & ex.Message, ex) + End Try + + If Not ErrorArchivo AndAlso dt IsNot Nothing Then + + If Not dt.Columns(0).ColumnName = "Cantidad" Then + Alert("El nombre de la primera columna debe ser 'Cantidad'. Favor de corregirlo", TipoMensaje.MsgError) + Exit Sub End If - If Not dt.Columns(1).ColumnName = "Codigo" Then - Alert("El nombre de la segunda columna debe ser 'Codigo'. Favor de corregirlo", TipoMensaje.MsgError) - Exit Sub - End If - If Not dt.Columns(2).ColumnName = "Producto" Then - Alert("El nombre de la tercera columna debe ser 'Producto'. Favor de corregirlo", TipoMensaje.MsgError) - Exit Sub + If Not dt.Columns(1).ColumnName = "Codigo" Then + Alert("El nombre de la segunda columna debe ser 'Codigo'. Favor de corregirlo", TipoMensaje.MsgError) + Exit Sub End If - If Not dt.Columns(3).ColumnName = "SerieLote" Then - Alert("El nombre de la cuarta columna debe ser 'SerieLote'. Favor de corregirlo", TipoMensaje.MsgError) - Exit Sub + If Not dt.Columns(2).ColumnName = "Producto" Then + Alert("El nombre de la tercera columna debe ser 'Producto'. Favor de corregirlo", TipoMensaje.MsgError) + Exit Sub End If - If Not dt.Columns(4).ColumnName = "Observaciones" Then - Alert("El nombre de la quinta columna debe ser 'Observaciones'. Favor de corregirlo", TipoMensaje.MsgError) - Exit Sub - End If - - dt.TableName = "Datos" - Dim ProductosNoCargados As New StringBuilder() - Dim RowsCargados As Integer = 0 + If Not dt.Columns(3).ColumnName = "SerieLote" Then + Alert("El nombre de la cuarta columna debe ser 'SerieLote'. Favor de corregirlo", TipoMensaje.MsgError) + Exit Sub + End If + If Not dt.Columns(4).ColumnName = "Observaciones" Then + Alert("El nombre de la quinta columna debe ser 'Observaciones'. Favor de corregirlo", TipoMensaje.MsgError) + Exit Sub + End If + + dt.TableName = "Datos" + Dim ProductosNoCargados As New StringBuilder() + Dim RowsCargados As Integer = 0 Dim RowsNoCargados As Integer = 0 Dim NoPSConSerieLote As Integer = 0 Try @@ -2843,9 +2843,9 @@ Partial Class Inventarios_TraspasoAlmacen ProductosNoCargados.AppendFormat("{0},", RowExcel("Producto").ToString()) End If End If - Next - Catch ex As Exception - OnError("Ocurrió un error al cargar los productos." & ProductosNoCargados.ToString(), ex) + Next + Catch ex As Exception + OnError("Ocurrió un error al cargar los productos." & ProductosNoCargados.ToString(), ex) Finally If NoPSConSerieLote > 0 Then @@ -2855,74 +2855,74 @@ Partial Class Inventarios_TraspasoAlmacen GvDatos.Columns(5).Visible = True End If - Dim MensajeFinal As New StringBuilder() - If RowsNoCargados = 0 AndAlso RowsCargados > 0 Then - MensajeFinal.Append("Los productos se cargaron correctamente.

") - End If - If RowsCargados > 0 Then - MensajeFinal.Append("Se cargaron " & RowsCargados & " productos correctamente.") - End If - If RowsNoCargados > 0 Then - MensajeFinal.Append("No se pudieron cargar " & RowsNoCargados & " productos.
Los siguientes productos no se pudieron cargar: " & ProductosNoCargados.ToString()) - End If - + Dim MensajeFinal As New StringBuilder() + If RowsNoCargados = 0 AndAlso RowsCargados > 0 Then + MensajeFinal.Append("Los productos se cargaron correctamente.

") + End If + If RowsCargados > 0 Then + MensajeFinal.Append("Se cargaron " & RowsCargados & " productos correctamente.") + End If + If RowsNoCargados > 0 Then + MensajeFinal.Append("No se pudieron cargar " & RowsNoCargados & " productos.
Los siguientes productos no se pudieron cargar: " & ProductosNoCargados.ToString()) + End If + Alert(MensajeFinal.ToString()) End Try - UpDatos.Update() - End If + UpDatos.Update() + End If End Sub - Private Function ReadExcelFile(ByVal flatFilePath As String, ByVal firstRowHasHeaders As Boolean) As DataTable - SpreadsheetInfo.SetLicense(ModExtensiones.SerialGemBoxSpreadsheet) - Dim excelFile As ExcelFile = ExcelFile.Load(flatFilePath) - - Dim unnamed As Integer = 0 - Dim cols As Integer - Dim columns As String() - Dim curRow As Integer = 0 - Dim curCol As Integer = 0 - Dim dataTable As DataTable = New DataTable() - Dim worksheet As ExcelWorksheet = excelFile.Worksheets(0) - - For cols = 0 To worksheet.Rows(0).AllocatedCells.Count - 1 - - If firstRowHasHeaders Then - - If worksheet.Rows(0).Cells(cols).Value IsNot Nothing Then - dataTable.Columns.Add(worksheet.Rows(0).Cells(cols).Value.ToString()) - Else - dataTable.Columns.Add("Unnamed Column " & (System.Threading.Interlocked.Increment(unnamed))) - End If - - curRow = 1 - Else - dataTable.Columns.Add("Column " & (cols + 1)) - End If - Next - - While curRow < worksheet.Rows.Count - columns = New String(cols - 1) {} - - For curCol = 0 To cols - 1 - - If worksheet.Rows(curRow).Cells(curCol).Value Is Nothing Then - columns(curCol) = "" - Else - columns(curCol) = worksheet.Rows(curRow).Cells(curCol).Value.ToString() - End If - Next - - dataTable.Rows.Add(columns) - curRow += 1 - End While - - Return dataTable + Private Function ReadExcelFile(ByVal flatFilePath As String, ByVal firstRowHasHeaders As Boolean) As DataTable + SpreadsheetInfo.SetLicense(ModExtensiones.SerialGemBoxSpreadsheet) + Dim excelFile As ExcelFile = ExcelFile.Load(flatFilePath) + + Dim unnamed As Integer = 0 + Dim cols As Integer + Dim columns As String() + Dim curRow As Integer = 0 + Dim curCol As Integer = 0 + Dim dataTable As DataTable = New DataTable() + Dim worksheet As ExcelWorksheet = excelFile.Worksheets(0) + + For cols = 0 To worksheet.Rows(0).AllocatedCells.Count - 1 + + If firstRowHasHeaders Then + + If worksheet.Rows(0).Cells(cols).Value IsNot Nothing Then + dataTable.Columns.Add(worksheet.Rows(0).Cells(cols).Value.ToString()) + Else + dataTable.Columns.Add("Unnamed Column " & (System.Threading.Interlocked.Increment(unnamed))) + End If + + curRow = 1 + Else + dataTable.Columns.Add("Column " & (cols + 1)) + End If + Next + + While curRow < worksheet.Rows.Count + columns = New String(cols - 1) {} + + For curCol = 0 To cols - 1 + + If worksheet.Rows(curRow).Cells(curCol).Value Is Nothing Then + columns(curCol) = "" + Else + columns(curCol) = worksheet.Rows(curRow).Cells(curCol).Value.ToString() + End If + Next + + dataTable.Rows.Add(columns) + curRow += 1 + End While + + Return dataTable End Function Public Sub CargarCamiones() - DdlUnidadCamion.Items.Clear + DdlUnidadCamion.Items.Clear() Dim ObjInventarios As New ClsInventarios If ObjInventarios.GetCamiones(-1, UsuarioActual.CveEmpresa) AndAlso ObjInventarios.DtResultados.Rows.Count > 0 Then DdlUnidadCamion.DataSource = ObjInventarios.DtResultados @@ -2954,4 +2954,4 @@ Partial Class Inventarios_TraspasoAlmacen TxtEspecifUnidad.Text = DtCamiones.FiltroPrimeroValor("Especificacion", String.Format("CveCamion = {0}", DdlUnidadCamion.SelectedValue)) End If End Sub -End Class +End Class diff --git a/Ventas/ClientesAbonar.aspx.vb b/Ventas/ClientesAbonar.aspx.vb index c21cb69c8..6d0ebb761 100644 --- a/Ventas/ClientesAbonar.aspx.vb +++ b/Ventas/ClientesAbonar.aspx.vb @@ -1475,7 +1475,7 @@ Partial Class Ventas_ClientesAbonar CveCuentaContabilizacion = 0 End If - If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, Referencia, ConceptoContable, ConceptoMovimiento, FechaMovimiento, IdCtaContable, -1, CveIE, gvr.FCHyperLink("HplF2").Text.ToEntero, -1, CveSubProyectoContabilizar, ViewState("CveCliente").ToString.ToEntero, ImporteMX:=importeMX, CveCuenta:=CveCuenta, TipoCambio:=TipoCambioGeneral, TipoCambioPago:=tipoCambioPago, PorcentajeImpuesto:=PorcentajeImpuesto) Then + If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, Referencia, ConceptoContable, ConceptoMovimiento, FechaMovimiento, IdCtaContable, -1, CveIE, gvr.FCHyperLink("HplF2").Text.ToEntero, -1, CveSubProyecto:=CveSubProyectoContabilizar, ViewState("CveCliente").ToString.ToEntero, ImporteMX:=importeMX, CveCuenta:=CveCuenta, TipoCambio:=TipoCambioGeneral, TipoCambioPago:=tipoCambioPago, PorcentajeImpuesto:=PorcentajeImpuesto) Then MsgError = "No se pudo insertar la póliza" End If @@ -2667,7 +2667,7 @@ Partial Class Ventas_ClientesAbonar End If 'al gasto,Subtotal - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, SubtotalMovto, SubTotal, gr.DataKey("SerieFolio").ToString, CveConceptoDeduccion, ConceptoPartida, TxtFechaIncobrable.Text.ToDate, IdCuentaContableNoDeducible, -1, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, ImporteMX:=SubTotal, CveCuenta:=-1, TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, SubtotalMovto, SubTotal, gr.DataKey("SerieFolio").ToString, CveConceptoDeduccion, ConceptoPartida, TxtFechaIncobrable.Text.ToDate, IdCuentaContableNoDeducible, -1, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, ImporteMX:=SubTotal, CveSubProyecto:=CveSubProyecto, CveCuenta:=-1, TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then MsgError = "Ocurrio un error al saldar el movimiento" End If diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 9ae4f6495..fc9564082 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -13173,7 +13173,7 @@ Partial Class Ventas Dim Cantidad As Double = MovDet("Cantidad").ToString.ToDouble Dim CveUnidad As Integer = MovDet("CveUM").ToString.ToEntero - Dim PU As Double = MovDet("PU").ToString.ToDouble + Dim PU As Decimal = MovDet("PU").ToString.ToDecimal Dim CveProducto As Integer = MovDet("CvePS").ToString.ToEntero Dim SerieLote As String = MovDet("SerieLote").ToString @@ -16350,7 +16350,7 @@ Partial Class Ventas 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 Double = RowUsado("PU").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, -1) Then @@ -20321,7 +20321,7 @@ Partial Class Ventas If CveMovimientoEntradaGeneral > 0 Then If ObjInventario.GetMovimientosDetalle(CveMovimientoSalidaConsignacion, UsuarioActual.CveEmpresa) Then For Each Dr As DataRow In ObjInventario.DtResultados.Rows - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntradaGeneral, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDouble, Dr("CveAF").ToString.ToEntero, Dr("CveSeccionAlmacen").ToString.ToEntero, Dr("SerieLote").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntradaGeneral, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero, Dr("CveSeccionAlmacen").ToString.ToEntero, Dr("SerieLote").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then Return False End If Next @@ -20335,7 +20335,7 @@ Partial Class Ventas If CveMovimientoEntradaGeneral > 0 Then If ObjInventario.GetMovimientosDetalle(CveMovimientoSalidaConsignacion, UsuarioActual.CveEmpresa) Then For Each Dr As DataRow In ObjInventario.DtResultados.Rows - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntradaGeneral, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDouble, Dr("CveAF").ToString.ToEntero, Dr("CveSeccionAlmacen").ToString.ToEntero, Dr("SerieLote").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntradaGeneral, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero, Dr("CveSeccionAlmacen").ToString.ToEntero, Dr("SerieLote").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then Return False End If Next From 1613876298c1216b6343a5456af1d1e4e5ae8264 Mon Sep 17 00:00:00 2001 From: rrene Date: Mon, 6 Apr 2020 23:17:42 -0700 Subject: [PATCH 4/6] - cambio PU a decimal --- Inventarios/ResguardoMaterial.aspx.vb | 2262 ++++++++++++------------- 1 file changed, 1131 insertions(+), 1131 deletions(-) diff --git a/Inventarios/ResguardoMaterial.aspx.vb b/Inventarios/ResguardoMaterial.aspx.vb index 6edc201b6..723cf5821 100644 --- a/Inventarios/ResguardoMaterial.aspx.vb +++ b/Inventarios/ResguardoMaterial.aspx.vb @@ -1,946 +1,946 @@ -Option Explicit On -Option Strict On - -Imports System.Data -Imports Extensiones -Imports Microsoft.Reporting.WebForms -Partial Class Inventarios_ResguardoMaterial +Option Explicit On +Option Strict On + +Imports System.Data +Imports Extensiones +Imports Microsoft.Reporting.WebForms +Partial Class Inventarios_ResguardoMaterial Inherits ClsPaginas -#Region "Propiedades" - Public Property DtMovimientos() As DataTable - Get - Return CType(ViewState("DtMovimientos"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtMovimientos") = value - End Set - End Property - Public Property DtMovimientosLiberacion() As DataTable - Get - Return CType(ViewState("DtMovimientosLiberacion"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtMovimientosLiberacion") = value - End Set - End Property - - - Public Property CveAlmacenLiberación() As Integer - Get - Return ViewState("CveAlmacenLiberación").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("CveAlmacenLiberación") = value - End Set - End Property - Public Property CvePersonalLiberacion() As Integer - Get - Return ViewState("CvePersonalLiberacion").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("CvePersonalLiberacion") = value - End Set - End Property - Public Property CveClienteLiberacion() As Integer - Get - Return ViewState("CveClienteLiberacion").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("CveClienteLiberacion") = value - End Set - End Property - Public Property CveProveedorLiberacion() As Integer - Get - Return ViewState("CveProveedorLiberacion").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("CveProveedorLiberacion") = value - End Set - End Property - Public Property FechaLiberacion As String - Get - Return ViewState("FechaLiberacion").ToString - End Get - Set(value As String) - ViewState("FechaLiberacion") = value - End Set - End Property - - - Public Property EsSurtidoUniforme As Boolean - Get - If ViewState("EsSurtidoUniforme") Is Nothing Then - Return False - - Else - Return Boolean.Parse(ViewState("EsSurtidoUniforme").ToString) - End If - - End Get - Set(value As Boolean) - ViewState("EsSurtidoUniforme") = value - End Set - End Property - - - Private Property DtSeccionAlmacen As DataTable - Get - Return CType(ViewState("DtSeccionAlmacen"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtSeccionAlmacen") = value - End Set - End Property - Private Property IndexSeccionAlmacen As Integer - Get - Return CType(ViewState("IndexSeccionAlmacen"), Integer) - End Get - Set(value As Integer) - ViewState("IndexSeccionAlmacen") = value - End Set - End Property - Private Property CantidadTotal As Decimal - Get - Return CType(ViewState("CantidadTotal"), Decimal) - End Get - Set(value As Decimal) - ViewState("CantidadTotal") = value - End Set - End Property - Private Property CvePS As Integer - Get - Return CType(ViewState("CvePS"), Integer) - End Get - Set(value As Integer) - ViewState("CvePS") = value - End Set - End Property - Private Property TipoSeccionAlmacen As Integer - Get - Return CType(ViewState("TipoSeccionAlmacen"), Integer) - End Get - Set(value As Integer) - ViewState("TipoSeccionAlmacen") = value - End Set +#Region "Propiedades" + Public Property DtMovimientos() As DataTable + Get + Return CType(ViewState("DtMovimientos"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtMovimientos") = value + End Set + End Property + Public Property DtMovimientosLiberacion() As DataTable + Get + Return CType(ViewState("DtMovimientosLiberacion"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtMovimientosLiberacion") = value + End Set + End Property + + + Public Property CveAlmacenLiberación() As Integer + Get + Return ViewState("CveAlmacenLiberación").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveAlmacenLiberación") = value + End Set + End Property + Public Property CvePersonalLiberacion() As Integer + Get + Return ViewState("CvePersonalLiberacion").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CvePersonalLiberacion") = value + End Set + End Property + Public Property CveClienteLiberacion() As Integer + Get + Return ViewState("CveClienteLiberacion").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveClienteLiberacion") = value + End Set + End Property + Public Property CveProveedorLiberacion() As Integer + Get + Return ViewState("CveProveedorLiberacion").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveProveedorLiberacion") = value + End Set + End Property + Public Property FechaLiberacion As String + Get + Return ViewState("FechaLiberacion").ToString + End Get + Set(value As String) + ViewState("FechaLiberacion") = value + End Set + End Property + + + Public Property EsSurtidoUniforme As Boolean + Get + If ViewState("EsSurtidoUniforme") Is Nothing Then + Return False + + Else + Return Boolean.Parse(ViewState("EsSurtidoUniforme").ToString) + End If + + End Get + Set(value As Boolean) + ViewState("EsSurtidoUniforme") = value + End Set + End Property + + + Private Property DtSeccionAlmacen As DataTable + Get + Return CType(ViewState("DtSeccionAlmacen"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtSeccionAlmacen") = value + End Set + End Property + Private Property IndexSeccionAlmacen As Integer + Get + Return CType(ViewState("IndexSeccionAlmacen"), Integer) + End Get + Set(value As Integer) + ViewState("IndexSeccionAlmacen") = value + End Set + End Property + Private Property CantidadTotal As Decimal + Get + Return CType(ViewState("CantidadTotal"), Decimal) + End Get + Set(value As Decimal) + ViewState("CantidadTotal") = value + End Set + End Property + Private Property CvePS As Integer + Get + Return CType(ViewState("CvePS"), Integer) + End Get + Set(value As Integer) + ViewState("CvePS") = value + End Set + End Property + Private Property TipoSeccionAlmacen As Integer + Get + Return CType(ViewState("TipoSeccionAlmacen"), Integer) + End Get + Set(value As Integer) + ViewState("TipoSeccionAlmacen") = value + End Set End Property -#End Region +#End Region - Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load - If Not IsPostBack Then - - - If Not Request.QueryString("EsSurtidoUniforme") Is Nothing Then - EsSurtidoUniforme = If(Request.QueryString("EsSurtidoUniforme").ToString = "1", True, False) - End If - - - InicializaValores() - - If Not Request.QueryString("CvePersonal") Is Nothing Then - Try - Dim CvePersonal As Integer = Request.QueryString("CvePersonal").ToString.ToEntero - OcultarControles(CvePersonal) - Catch ex As Exception - End Try - - End If - - - - - End If - End Sub - - Private Sub OcultarControles(CvePersonal As Integer) - - DdlPersonal.ddl.SelectedValueExist(CvePersonal) - DdlPersonal.Enabled = False - DVTipo.Visible = False + Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load + If Not IsPostBack Then + + + If Not Request.QueryString("EsSurtidoUniforme") Is Nothing Then + EsSurtidoUniforme = If(Request.QueryString("EsSurtidoUniforme").ToString = "1", True, False) + End If + + + InicializaValores() + + If Not Request.QueryString("CvePersonal") Is Nothing Then + Try + Dim CvePersonal As Integer = Request.QueryString("CvePersonal").ToString.ToEntero + OcultarControles(CvePersonal) + Catch ex As Exception + End Try + + End If + + + + + End If End Sub -#Region " INICIALIZA VALORES " - Private Sub InicializaValores() - CreaDT() - CargaCombos() - TxtFecha.Text = Now.ToShortDateString - TxtFechaLiberacion.Text = Now.ToShortDateString - GvM.Columns(6).Visible = UsuarioActual.Empresa.Funcionalidad(563) = "1" - GvMLiberacion.Columns(7).Visible = UsuarioActual.Empresa.Funcionalidad(563) = "1" - - GvM.DataBind() - - CantidadTotal = 0 - IndexSeccionAlmacen = 0 - CvePS = 0 - CreaDtSeccionAlmacen() - CargaDdlAlmacen() - TipoSeccionAlmacen = 0 - - End Sub - - Protected Sub CreaDT() - Dim dt As New DataTable - - Dim column As DataColumn = New DataColumn("No") - column.DataType = Type.GetType("System.Int32") - With column - .AutoIncrement = True - .AutoIncrementSeed = 1 - .AutoIncrementStep = 1 - End With - dt.Columns.Add(column) - dt.Columns.Add("CveMovimiento", Type.GetType("System.Int32")) - dt.Columns.Add("CveMovimientoDetalle", Type.GetType("System.Int32")) - dt.Columns.Add("Cantidad", Type.GetType("System.Double")) - dt.Columns.Add("CveUM", Type.GetType("System.Int32")) - dt.Columns.Add("UnidadMedida") - dt.Columns.Add("CvePS", Type.GetType("System.Int32")) - dt.Columns.Add("PS") - dt.Columns.Add("Estatus") - dt.Columns.Add("Codigo") - dt.Columns.Add("SerieLote") - dt.Columns.Add("Observaciones") - dt.Columns.Add("CvePersonal", Type.GetType("System.Int32")) - dt.Columns.Add("Checado", Type.GetType("System.Boolean")) - - DtMovimientos = dt - - CargaGvM() - - End Sub - Private Sub CargaCombos() - - DdlPersonal.setEsWebService(True) - DdlPersonal.Attributes.Add("data-metodo", "getpersonal") - DdlPersonal.SelectedValue = "-1" - DdlPersonal.SelectedText = "Seleccione" - - DdlPersonalLiberacion.setEsWebService(True) - DdlPersonalLiberacion.Attributes.Add("data-metodo", "getpersonal") - DdlPersonalLiberacion.SelectedValue = "-1" - DdlPersonalLiberacion.SelectedText = "Seleccione" - - DdlCliente.setEsWebService(True) - DdlCliente.Attributes.Add("data-metodo", "getcliente") - DdlCliente.SelectedValue = "-1" - DdlCliente.SelectedText = "Seleccione" - - DdlClienteLiberacion.setEsWebService(True) - DdlClienteLiberacion.Attributes.Add("data-metodo", "getcliente") - DdlClienteLiberacion.SelectedValue = "-1" - DdlClienteLiberacion.SelectedText = "Seleccione" - - DdlProveedor.setEsWebService(True) - DdlProveedor.Attributes.Add("data-metodo", "getproveedores") - DdlProveedor.SelectedValue = "-1" - DdlProveedor.SelectedText = "Seleccione" - - DdlProveedorLiberacion.setEsWebService(True) - DdlProveedorLiberacion.Attributes.Add("data-metodo", "getproveedores") - DdlProveedorLiberacion.SelectedValue = "-1" - DdlProveedorLiberacion.SelectedText = "Seleccione" - - If isWhitFamily() Then - DdlClasificacion.DataSource = GlobalDTSubFamilias(UsuarioActual.CveEmpresa).FiltraParametros("", Orderby:="Clasificacion") - Else - DdlClasificacion.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltraParametros(" Codigo = '' OR Codigo IS NULL ", Orderby:="Clasificacion") - End If - DdlClasificacion.DataBind() - - - - If EsSurtidoUniforme Then - 'RESGUARDO - DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen IN (19)") 'GlobalDTAlmacen(UsuarioActual.CveEmpresa) - DdlAlmacen.DataBind() - DdlAlmacen.Items.Insert(0, New ListItem("Seleccione", "-1")) - 'Almacen Destino - DdlAlmacenDestino.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 20) - DdlAlmacenDestino.DataBind() - DdlAlmacenDestino.Items.Insert(0, New ListItem("Seleccione", "-1")) - - 'LIBERACION - DdlAlmacenLiberacion.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 20) - DdlAlmacenLiberacion.DataBind() - DdlAlmacenLiberacion.Items.Insert(0, New ListItem("Seleccione", "-1")) - ''Almacen Destino - Else - 'RESGUARDO - DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1) '.FiltraParametros("CveTipoAlmacen IN (1,2)") 'GlobalDTAlmacen(UsuarioActual.CveEmpresa) - DdlAlmacen.DataBind() - DdlAlmacen.Items.Insert(0, New ListItem("Seleccione", "-1")) - 'Almacen Destino - DdlAlmacenDestino.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 8) - DdlAlmacenDestino.DataBind() - DdlAlmacenDestino.Items.Insert(0, New ListItem("Seleccione", "-1")) - - - 'LIBERACION - DdlAlmacenLiberacion.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 8) - DdlAlmacenLiberacion.DataBind() - DdlAlmacenLiberacion.Items.Insert(0, New ListItem("Seleccione", "-1")) - End If - - - ''Almacen Destino - DdlAlmacenDestinoLiberacion.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1) '.FiltraParametros("CveTipoAlmacen IN (1,2)") - DdlAlmacenDestinoLiberacion.DataBind() - DdlAlmacenDestinoLiberacion.Items.Insert(0, New ListItem("Seleccione", "-1")) - - CargaPS() - End Sub - Private Sub CargaPS() - DdlProducto2.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1") - - If DdlProducto2.UsaWebService Then - DdlProducto2.ddlWS.Attributes.Add("data-pagina", "Inventarios") - DdlProducto2.ddlWS.Attributes.Add("data-cveclasificacion", DdlClasificacion.SelectedValue.ToString) - End If - If Not DdlProducto2.UsaWebService AndAlso CType(DdlProducto2.DataSource, DataTable) Is Nothing Then - DdlProducto2.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa) - DdlProducto2.DataBind() - End If - - VerificaProducto() - End Sub - Private Function isWhitFamily() As Boolean - Return (UsuarioActual.CveEmpresa = 66) - End Function -#End Region + Private Sub OcultarControles(CvePersonal As Integer) - - -#Region " RESGUARDO " - - -#Region " FUNCIONALIDAD 105 - CLASIFICACION PS" - Protected Sub DdlClasificacion_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlClasificacion.SelectedIndexChanged - CargaProductosPorClasificacion() - End Sub - Protected Sub DdlProducto_ValueChanged(sender As Object, e As EventArgs) Handles DdlProducto2.selectedindexchange - VerificaProducto() - End Sub - Private Sub CargaProductosPorClasificacion() - If UsuarioActual.Empresa.Funcionalidad(105) = "" Then - 'Dim filtro As String = "" - 'If Not (DdlClasificacion.SelectedValue = "-1") Then - - ' If isWhitFamily() Then - ' 'filtro = String.Format("CveSubFamilia={0}", DdlClasificacion.SelectedValue) - ' Else - ' filtro = String.Format("CveClasificacion={0}", DdlClasificacion.SelectedValue) - ' End If - 'End If - DdlProducto2.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=DdlClasificacion.SelectedValue.ToEntero).FiltraParametros("", "PSCodigo") - DdlProducto2.DataBind() - DdlProducto2.ddl.Items.Insert(0, New ListItem("----", "-1")) - Else - 'If isWhitFamily() Then - ' 'DdlProducto2.ddlWS.Attributes.Add("data-idSubFamilia", DdlClasificacion.SelectedValue) - 'Else - DdlProducto2.ddlWS.Attributes.Add("data-cveclasificacion", DdlClasificacion.SelectedValue) - 'End If - End If - End Sub - Private Sub VerificaProducto() - If DdlProducto2.SelectedValue.ToEntero > 0 Then - If GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DdlProducto2.SelectedValue.ToEntero).FiltraParametros("Inv_CveMetodoInventario = 5", "PS").Rows.Count > 0 Then - ThSerieLote.Visible = True - TrSerieLote.Visible = True - TxtnSerieLote.Visible = True - GvM.Columns(4).Visible = True - Else - TxtnSerieLote.Visible = False - End If - End If - - 'If (1.Contiene("3", "7", "8", "11")) Then - ' Dim objinv As New ClsInventarios - ' If objinv.GetExistenciasPS(DdlProducto2.SelectedValue.ToEntero, -1, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, FechaMovto:=DateTime.Today.AddDays(1).ToString("yyyy/MM/dd HH:mm")) Then - ' DdlUnidad.DataSource = objinv.DtResultados.FiltraParametros("", "UnidadMedida", {"CveUnidadMedida", "UnidadMedida"}) - ' If objinv.DtResultados.Rows.Count = 0 Then - ' Alert("No hay existencias de este producto", TipoMensaje.MsgAdvertencia) - ' End If - ' End If - ' objinv.Dispose() - 'Else - ' DdlUnidad.DataSource = GlobalDTProductosServiciosEquivalencias(DdlProducto2.SelectedValue.ToEntero, -1) - 'End If - - DdlUnidad.Items.Clear() - DdlUnidad.DataSource = GlobalDTProductosServiciosEquivalencias(DdlProducto2.SelectedValue.ToEntero, -1, UsuarioActual.CveEmpresa) - DdlUnidad.DataBind() - UPDatos.Update() - + DdlPersonal.ddl.SelectedValueExist(CvePersonal) + DdlPersonal.Enabled = False + DVTipo.Visible = False End Sub -#End Region - - -#Region " EISTENCIAS " - Private Function GetExistencias(CvePS As Integer, CveUnidadMedida As Integer, CveEmpresa As Integer, CveAlmacen As Integer, Optional SerieLote As String = "-1") As Double - Dim Inv As New ClsInventarios - Dim Existencia As Double = Inv.GetExistenciasPS(CvePS, CveUnidadMedida, CveEmpresa, CveAlmacen, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), SerieLote:=SerieLote) - Inv.Dispose() - Return Existencia - End Function -#End Region - - -#Region " AGREGAR " - Protected Sub btnAgregar_Click(sender As Object, e As EventArgs) Handles LbAgregar.Click - AgregaProducto() - LimpiarAgregar() - End Sub - Protected Sub AgregaProducto() - Dim PSSelected As Integer = DdlProducto2.SelectedValue.ToEntero - If DdlAlmacen.SelectedValue.ToEntero <= 0 Then Alert("Seleccione un almacen", TipoMensaje.MsgInformacion) : Exit Sub - If PSSelected > 0 Then - If TxtnSerieLote.Visible Then - If TxtnSerieLote.Text = "" Then - Alert("Serie-Lote es necesario", TipoMensaje.MsgAdvertencia) - Return - End If - End If - Dim Valido As Boolean = True - Dim cantidadd As Double = txtCantidad.Text.ToDouble - Dim Existencia As Double = GetExistencias(PSSelected, DdlUnidad.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, If(TxtnSerieLote.Visible, TxtnSerieLote.Text, "-1").ToString) - If Existencia - txtCantidad.Text.ToDouble < 0 Then - If Existencia <= 0 Then - Alert("No hay existencia del producto", TipoMensaje.MsgAdvertencia) - Else - Alert(String.Format("Solo hay en existencia: {0}", Existencia), TipoMensaje.MsgAdvertencia) - If Not UsuarioActual.TienePermisoProceso(114) Then - cantidadd = Existencia - End If - End If - Valido = False - 'Valido = If(UsuarioActual.TienePermisoProceso(114), True, False) - End If - If Valido Then - Dim CveClasificacion As Integer - Dim dr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=PSSelected).FiltroPrimero("", "PS") - If dr IsNot Nothing Then CveClasificacion = dr("CveClasificacion").ToString.ToEntero - - Dim registro As DataRow = DtMovimientos.NewRow - registro.Item("Cantidad") = cantidadd - registro.Item("CveUM") = DdlUnidad.SelectedValue.ToEntero - registro.Item("UnidadMedida") = DdlUnidad.SelectedItem.Text - registro.Item("CvePS") = PSSelected - registro.Item("PS") = DdlProducto2.SelectedText - registro.Item("Estatus") = "" - registro.Item("SerieLote") = TxtnSerieLote.Text - registro.Item("Observaciones") = TxtObservacionesdetalle.Text - DtMovimientos.Rows.Add(registro) - CargaGvM() - - txtCantidad.Text = "" - txtCantidad.Focus() - - End If - End If - End Sub - Private Sub LimpiarAgregar() - DdlClasificacion.SelectedValue = "-1" - txtCantidad.Text = "" - TxtObservacionesdetalle.Text = "" - End Sub -#End Region - - -#Region " GvM " - Private Sub CargaGvM() - - ThSerieLote.Visible = False - TrSerieLote.Visible = False - TxtnSerieLote.Visible = False - GvM.Columns(4).Visible = False - For Each Dr As DataRow In DtMovimientos.Rows - If Dr("SerieLote").ToString <> "" Then - ThSerieLote.Visible = True - TrSerieLote.Visible = True - GvM.Columns(4).Visible = True - Exit For - End If - Next - - GvM.DataSource = DtMovimientos - GvM.DataBind() - End Sub - - Private Sub GvM_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) Handles GvM.RowDeleting - Dim DbRow As DataRow = Nothing - DbRow = DtMovimientos.Rows(e.RowIndex) - DtMovimientos.Rows.Remove(DbRow) - - GvM.EditIndex = -1 - CargaGvM() - End Sub - - Protected Sub GvM_RowDataBound(sender As Object, e As GridViewRowEventArgs) - If e.Row.RowType = DataControlRowType.DataRow Then - If DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {e.Row.RowIndex}").SUMD("CantidadSeccionAlmacen") > 0 Then - e.Row.FCLinkButton("lnkRemove").Visible = False - e.Row.FCLinkButton("lnkRemove").ToolTip = "Cuenta con sección almacen" - End If - End If - End Sub -#End Region - - -#Region " NUEVO " - Protected Sub BtnNuevo_Click(sender As Object, e As EventArgs) - LimpiarMovimiento() - End Sub - Private Sub LimpiarMovimiento() - DtMovimientos.Clear() - CargaGvM() - - BtnGuardarResguardo.Visible = True - - DdlAlmacen.SelectedValueExist("-1") - DdlAlmacenDestino.SelectedValueExist("-1") - DtSeccionAlmacen.Rows.Clear() - - TxtObservaciones.Text = "" +#Region " INICIALIZA VALORES " + Private Sub InicializaValores() + CreaDT() + CargaCombos() TxtFecha.Text = Now.ToShortDateString - DdlPersonal.SelectedValue = "-1" - DdlPersonal.SelectedText = "Seleccione" - LimpiarAgregar() - UPDatos.Update() - UpGenerales.Update() - End Sub -#End Region + TxtFechaLiberacion.Text = Now.ToShortDateString + GvM.Columns(6).Visible = UsuarioActual.Empresa.Funcionalidad(563) = "1" + GvMLiberacion.Columns(7).Visible = UsuarioActual.Empresa.Funcionalidad(563) = "1" + GvM.DataBind() -#End Region + CantidadTotal = 0 + IndexSeccionAlmacen = 0 + CvePS = 0 + CreaDtSeccionAlmacen() + CargaDdlAlmacen() + TipoSeccionAlmacen = 0 - -#Region " LIBERACION " - - -#Region " GV DATOS LIBERACION " - Protected Sub GvMLiberacion_RowDataBound(sender As Object, e As GridViewRowEventArgs) - If e.Row.RowType = DataControlRowType.DataRow Then - e.Row.FCLabel("LblCantidad").Text = e.Row.FCLabel("LblCantidad").Text.FormatoNumero(2) - End If - End Sub - - Protected Sub GvMLiberacion_RowCreated(sender As Object, e As GridViewRowEventArgs) - If e.Row.RowType = DataControlRowType.DataRow Then - Dim Index = e.Row.RowIndex - e.Row.FCTextBox("TxtCantidad").Attributes.Add("onKeyUp", String.Format("ValidarCantidad({0});", Index)) - End If - End Sub -#End Region - - -#Region " CARGA RESGUARDOS PARA LIBERACION " - - Protected Sub BtnVerificarExistencias_Click(sender As Object, e As EventArgs) - If Not DdlProveedorLiberacion.SelectedValue.ToEntero > 0 AndAlso DdlTipo.SelectedValue.ToEntero = 3 Then - Alert("Tiene que seleccionar un proveedor.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - If Not DdlPersonalLiberacion.SelectedValue.ToEntero > 0 AndAlso DdlTipo.SelectedValue.ToEntero = 1 Then - Alert("Tiene que seleccionar un personal.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - If Not DdlClienteLiberacion.SelectedValue.ToEntero > 0 AndAlso DdlTipo.SelectedValue.ToEntero = 2 Then - Alert("Tiene que seleccionar un cliente.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - CargaResguardos() - End Sub - - Private Sub CargaResguardos() - Dim ObjInventario As New ClsInventarios() - Dim Existencias As Double = 0 - - If ObjInventario.GetMovimientosDetallePorPersonal(DdlPersonalLiberacion.SelectedValue.ToEntero, DdlAlmacenLiberacion.SelectedValue.ToEntero, DdlClienteLiberacion.SelectedValue.ToEntero, DdlProveedorLiberacion.SelectedValue.ToEntero) Then - DtMovimientosLiberacion = ObjInventario.DtResultados - - DtMovimientosLiberacion.Columns("No").AutoIncrement = True - DtMovimientosLiberacion.Columns("No").AutoIncrementSeed = DtMovimientosLiberacion.Rows.Count + 1 - DtMovimientosLiberacion.Columns("No").AutoIncrementStep = 1 - - Dim keys(1) As DataColumn - keys(0) = DtMovimientosLiberacion.Columns("No") - DtMovimientosLiberacion.PrimaryKey = keys - - CargaGvMLiberacion() - If DdlPersonalLiberacion.SelectedValue.ToEntero <> -1 Then - LblTipo.InnerText = "Personal/Responsable:" - LbTipoLiberacion.Text = DdlPersonalLiberacion.SelectedText - End If - If DdlProveedorLiberacion.SelectedValue.ToEntero <> -1 Then - LblTipo.InnerText = "Proveedor:" - LbTipoLiberacion.Text = DdlProveedorLiberacion.SelectedText - End If - If DdlClienteLiberacion.SelectedValue.ToEntero <> -1 Then - LblTipo.InnerText = "Cliente:" - LbTipoLiberacion.Text = DdlClienteLiberacion.SelectedText - End If - CvePersonalLiberacion = DdlPersonalLiberacion.SelectedValue.ToEntero - CveClienteLiberacion = DdlClienteLiberacion.SelectedValue.ToEntero - CveProveedorLiberacion = DdlProveedorLiberacion.SelectedValue.ToEntero - LbAlmacenLiberacion.Text = DdlAlmacenLiberacion.SelectedItem.Text - CveAlmacenLiberación = DdlAlmacenLiberacion.SelectedValue.ToEntero - LbFechaLiberacion.Text = TxtFechaLiberacion.Text - FechaLiberacion = TxtFechaLiberacion.Text - BtnGuardarLiberacion.Visible = True - - DtSeccionAlmacen.Rows.Clear() - - UpGeneralesLibreacion.Update() - Else - Alert("Ocurrió un error al cargar los resguardos del personal. Por favor vuelva a intentar.", TipoMensaje.MsgError) - End If - ObjInventario.Dispose() - - End Sub - - Private Sub CargaGvMLiberacion() - GvM.Columns(5).Visible = False - For Each Dr As DataRow In DtMovimientosLiberacion.Rows - If Dr("SerieLote").ToString <> "" Then - GvM.Columns(5).Visible = True - Exit For - End If - Next - - GvMLiberacion.DataSource = DtMovimientosLiberacion - GvMLiberacion.DataBind() - UpGridLiberacion.Update() End Sub -#End Region + Protected Sub CreaDT() + Dim dt As New DataTable + + Dim column As DataColumn = New DataColumn("No") + column.DataType = Type.GetType("System.Int32") + With column + .AutoIncrement = True + .AutoIncrementSeed = 1 + .AutoIncrementStep = 1 + End With + dt.Columns.Add(column) + dt.Columns.Add("CveMovimiento", Type.GetType("System.Int32")) + dt.Columns.Add("CveMovimientoDetalle", Type.GetType("System.Int32")) + dt.Columns.Add("Cantidad", Type.GetType("System.Double")) + dt.Columns.Add("CveUM", Type.GetType("System.Int32")) + dt.Columns.Add("UnidadMedida") + dt.Columns.Add("CvePS", Type.GetType("System.Int32")) + dt.Columns.Add("PS") + dt.Columns.Add("Estatus") + dt.Columns.Add("Codigo") + dt.Columns.Add("SerieLote") + dt.Columns.Add("Observaciones") + dt.Columns.Add("CvePersonal", Type.GetType("System.Int32")) + dt.Columns.Add("Checado", Type.GetType("System.Boolean")) + + DtMovimientos = dt + + CargaGvM() -#Region " LIMPIAR LIBERACION " - Private Sub LimpiarLiberacion() - LbTipoLiberacion.Text = "" - LblTipo.InnerText = "" - CvePersonalLiberacion = -1 - CveClienteLiberacion = -1 - CveProveedorLiberacion = -1 - LbAlmacenLiberacion.Text = "" - CveAlmacenLiberación = -1 - LbFechaLiberacion.Text = "" - FechaLiberacion = "" - BtnGuardarLiberacion.Visible = False - DtSeccionAlmacen.Rows.Clear() - - DdlAlmacenDestinoLiberacion.SelectedValue = "-1" - TxtObservacionesLiberacion.Text = "" - - DtMovimientosLiberacion.Clear() - CargaGvMLiberacion() - - UpGeneralesLibreacion.Update() End Sub -#End Region + Private Sub CargaCombos() + DdlPersonal.setEsWebService(True) + DdlPersonal.Attributes.Add("data-metodo", "getpersonal") + DdlPersonal.SelectedValue = "-1" + DdlPersonal.SelectedText = "Seleccione" -#End Region + DdlPersonalLiberacion.setEsWebService(True) + DdlPersonalLiberacion.Attributes.Add("data-metodo", "getpersonal") + DdlPersonalLiberacion.SelectedValue = "-1" + DdlPersonalLiberacion.SelectedText = "Seleccione" + + DdlCliente.setEsWebService(True) + DdlCliente.Attributes.Add("data-metodo", "getcliente") + DdlCliente.SelectedValue = "-1" + DdlCliente.SelectedText = "Seleccione" + + DdlClienteLiberacion.setEsWebService(True) + DdlClienteLiberacion.Attributes.Add("data-metodo", "getcliente") + DdlClienteLiberacion.SelectedValue = "-1" + DdlClienteLiberacion.SelectedText = "Seleccione" + + DdlProveedor.setEsWebService(True) + DdlProveedor.Attributes.Add("data-metodo", "getproveedores") + DdlProveedor.SelectedValue = "-1" + DdlProveedor.SelectedText = "Seleccione" + + DdlProveedorLiberacion.setEsWebService(True) + DdlProveedorLiberacion.Attributes.Add("data-metodo", "getproveedores") + DdlProveedorLiberacion.SelectedValue = "-1" + DdlProveedorLiberacion.SelectedText = "Seleccione" + + If isWhitFamily() Then + DdlClasificacion.DataSource = GlobalDTSubFamilias(UsuarioActual.CveEmpresa).FiltraParametros("", Orderby:="Clasificacion") + Else + DdlClasificacion.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltraParametros(" Codigo = '' OR Codigo IS NULL ", Orderby:="Clasificacion") + End If + DdlClasificacion.DataBind() -#Region " GUARDAR " - Protected Sub BtnGuardarResguardo_Click(sender As Object, e As EventArgs) Handles BtnGuardarResguardo.Click - - If Not GvM.Rows.Count > 0 Then - Alert("No hay ningun registro para generar el movimiento. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - If Not DdlProveedor.SelectedValue.ToEntero > 0 And DivProveedor.Visible Then - Alert("Tiene que seleccionar un proveedor.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - 'VALIDA LA EXISTENCIA DEL ALMACEN - Dim ObjInventario As New ClsInventarios - Dim ErrorExistencia = False - Dim TextoExistencia As StringBuilder = New StringBuilder - Dim Existencia As Double - TextoExistencia.Append("Los siguiente productos se ajustaron por falta de exitencia:
") - For Each dr As DataRow In DtMovimientos.Rows - Existencia = ObjInventario.GetExistenciasPS(dr("CvePS").ToString.ToEntero, dr("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDate.ToString("yyyy/MM/dd 23:59"), SerieLote:=If(dr("SerieLote").ToString = "", "-1", dr("SerieLote").ToString)) - Existencia -= DtMovimientos.SUM("Cantidad", $"CvePS = {dr("CvePS").ToString.ToEntero} AND CveUM = {dr("CveUM").ToString.ToEntero} {If(dr("SerieLote").ToString <> "-1", $" AND SerieLote = '{dr("SerieLote").ToString}'", "")}") - - If Existencia < 0 Then - ErrorExistencia = True - dr("Cantidad") = Existencia - TextoExistencia.AppendFormat("- #{0} {1}
", dr("No").ToString, dr("PS").ToString) - End If - Next - ObjInventario.Dispose() - - If ErrorExistencia Then - Alert(TextoExistencia.ToString, TipoMensaje.MsgError) - End If - - Dim TotalCantidad As Double = DtMovimientos.SUMD("Cantidad") - If UsuarioActual.Empresa.Funcionalidad(563) = "1" Then - If TotalCantidad <> DtSeccionAlmacen.FiltraParametros("TipoSeccionAlmacen = 1").SUMD("CantidadSeccionAlmacen") Then - Alert("La seccion de almacen no ha sido agregada completamente.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - End If - - Guardar(23) - - End Sub - Protected Sub BtnGuardarLiberacion_Click(sender As Object, e As EventArgs) - - If Not DdlProveedorLiberacion.SelectedValue.ToEntero > 0 And DivProveedorLiberacion2.Visible Then - Alert("Tiene que seleccionar un proveedor.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - If Not GvMLiberacion.Rows.Count > 0 Then - Alert("No hay ningun registro para generar el movimiento. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - Dim TieneError = True - Dim TotalCantidad As Decimal = 0 - For Each Gvr As GridViewRow In GvMLiberacion.Rows - If Gvr.FCTextBox("TxtCantidad").Text.ToDecimal > 0 Then - TieneError = False - Exit For - Else - TotalCantidad += Gvr.FCTextBox("TxtCantidad").Text.ToDecimal - End If - Next - - If TieneError Then - Alert("Se debe seleccionar por lo menos una cantidad de los resguardos para generar la liberación. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - If UsuarioActual.Empresa.Funcionalidad(563) = "1" Then - If TotalCantidad <> DtSeccionAlmacen.FiltraParametros("TipoSeccionAlmacen = 2").SUMD("CantidadSeccionAlmacen") Then - Alert("La seccion de almacen no ha sido agregada completamente.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - End If - - Guardar(24) - - - End Sub - - Private Sub Guardar(Concepto As Integer) - Dim ObjInventario As New ClsInventarios - Dim ObjEventos As New ClsOIEventos(ObjInventario.IniciaTransacSQL()) 'Inicia la transacción - Dim TieneError = False - Dim MensajeError As String = "" - Dim ImporteConcepto = 0.0 - - Dim CveMovimientoSalida = 0 - Dim FolioSalida = 0 - Dim CveMovimientoEntrada = 0 - Dim FolioEntrada = 0 - - 'Para Campos Nuevos AF y OC - Dim SubProyecto = -1 - Dim ActivoFijo = -1 - - Dim CveProveedor = -1 - Dim CveCliente = -1 - Dim CvePersonal = -1 - - If RbTipoCliente.Checked Then CveCliente = DdlCliente.SelectedValue.ToEntero - If RbTipoProveedor.Checked Then CveProveedor = DdlProveedor.SelectedValue.ToEntero - If RbTipoPersonal.Checked Then CvePersonal = DdlPersonal.SelectedValue.ToEntero - - Dim Fecha = If(Concepto = 23, TxtFecha.Text.ToDate, FechaLiberacion.ToDate) - - Select Case (Concepto) - Case 23 ' Resguardo - - 'SALIDA ORIGEN - CveMovimientoSalida = ObjInventario.AddMovimiento(DdlAlmacen.SelectedValue.ToEntero, 24, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, SubProyecto, ActivoFijo, Observaciones:=TxtObservaciones.Text, CvePersonal:=CvePersonal, CveAlmacenDestino:=DdlAlmacenDestino.SelectedValue.ToEntero, CveCliente:=CveCliente, CveProveedor:=CveProveedor) - FolioSalida = ObjInventario.Folio - - If CveMovimientoSalida <= 0 Then - TieneError = True - MensajeError = "Ocurrió un error al guardar el movimiento de salida. Por favor vuelva a intentar." - Exit Select - End If - - Dim Cont As Integer = 0 - For Each Dr As DataRow In DtMovimientos.Rows - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0, -1, -1, Dr("SerieLote").ToString, Dr("Observaciones").ToString) Then - MensajeError = "Ocurrió un error al guardar los detalles del movimiento de salida. Por favor vuelva a intentar." - TieneError = True - Exit For - Else - If ObjInventario.CveMovimientoDetalle > 0 AndAlso DtSeccionAlmacen.Rows.Count > 0 Then - For Each Dr2 As DataRow In DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {Cont} AND TipoSeccionAlmacen = 1").Rows - If Not ObjInventario.AddMovimientosDetalleSeccionesAlmacen(ObjInventario.CveMovimientoDetalle, Dr2("CveSeccionAlmacenOrigen").ToString.ToEntero, -Dr2("CantidadSeccionAlmacen").ToString.ToDecimal) Then - TieneError = True - MensajeError = "Ocurrió un error al procesar las secciones de almacen. Por favor vuelva a intentar." - Exit For - End If - Next - End If - End If - Cont += 1 - Next - - Cont = 0 - If Not TieneError Then - CveMovimientoEntrada = ObjInventario.AddMovimiento(DdlAlmacenDestino.SelectedValue.ToEntero, 2, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, SubProyecto, ActivoFijo, Observaciones:=TxtObservaciones.Text, CvePersonal:=CvePersonal, CveMovimientoRelacionado:=CveMovimientoSalida, CveCliente:=CveCliente, CveProveedor:=CveProveedor) - FolioEntrada = ObjInventario.Folio - - If CveMovimientoEntrada <= 0 Then - MensajeError = "Ocurrió un error al guardar el movimiento de entrada correctamente. Por favor vuelva a intentar." - TieneError = True - Else - If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) 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.ToDouble, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, Dr("Observaciones").ToString) Then - TieneError = True - MensajeError = "Ocurrió un error al guardar los movimientos de entrada" - Exit For - Else - If ObjInventario.CveMovimientoDetalle > 0 AndAlso DtSeccionAlmacen.Rows.Count > 0 Then - For Each Dr2 As DataRow In DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {Cont} AND TipoSeccionAlmacen = 1").Rows - If Not ObjInventario.AddMovimientosDetalleSeccionesAlmacen(ObjInventario.CveMovimientoDetalle, Dr2("CveSeccionAlmacenDestino").ToString.ToEntero, Dr2("CantidadSeccionAlmacen").ToString.ToDecimal) Then - TieneError = True - MensajeError = "Ocurrió un error al procesar las secciones de almacen. Por favor vuelva a intentar." - Exit For - End If - Next - End If - End If - Cont += 1 - Next - End If - End If - End If - - Case 24 'LIBERACION - - - 'SALIDA ORIGEN - RESGUARDO - CveMovimientoSalida = ObjInventario.AddMovimiento(CveAlmacenLiberación, 3, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, SubProyecto, ActivoFijo, Observaciones:=TxtObservacionesLiberacion.Text, CvePersonal:=CvePersonalLiberacion, CveAlmacenDestino:=DdlAlmacenDestinoLiberacion.SelectedValue.ToEntero, CveProveedor:=CveProveedorLiberacion, CveCliente:=CveClienteLiberacion, MovimientoFijo:=True) - FolioSalida = ObjInventario.Folio - - If CveMovimientoSalida <= 0 Then - TieneError = True - MensajeError = "Ocurrió un error al guardar el movimiento de salida. Por favor vuelva a intentar." - Exit Select - End If - - Dim Cont As Integer = 0 - For Each Gvr As GridViewRow In GvMLiberacion.Rows - If Gvr.FCTextBox("TxtCantidad").Text.ToDouble > 0 Then - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Gvr.FCTextBox("TxtCantidad").Text.ToDouble, Gvr.DataKey("CveUM").ToString.ToEntero, Gvr.DataKey("CvePS").ToString.ToEntero, Gvr.DataKey("PU").ToString.ToDouble, -1, -1, Gvr.DataKey("SerieLote").ToString, Gvr.DataKey("Observaciones").ToString) Then - MensajeError = "Ocurrió un error al guardar los detalles del movimiento de salida. Por favor vuelva a intentar." - TieneError = True - Exit For - Else - If ObjInventario.CveMovimientoDetalle > 0 AndAlso DtSeccionAlmacen.Rows.Count > 0 Then - For Each Dr2 As DataRow In DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {Cont} AND TipoSeccionAlmacen = 2").Rows - If Not ObjInventario.AddMovimientosDetalleSeccionesAlmacen(ObjInventario.CveMovimientoDetalle, Dr2("CveSeccionAlmacenOrigen").ToString.ToEntero, -Dr2("CantidadSeccionAlmacen").ToString.ToDecimal) Then - TieneError = True - MensajeError = "Ocurrió un error al procesar las secciones de almacen. Por favor vuelva a intentar." - Exit For - End If - Next - End If - End If - End If - Cont += 1 - Next - - - If Not TieneError Then - CveMovimientoEntrada = ObjInventario.AddMovimiento(DdlAlmacenDestinoLiberacion.SelectedValue.ToEntero, 23, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, SubProyecto, ActivoFijo, Observaciones:=TxtObservacionesLiberacion.Text, CvePersonal:=CvePersonalLiberacion, CveMovimientoRelacionado:=CveMovimientoSalida, CveProveedor:=CveProveedorLiberacion, CveCliente:=CveClienteLiberacion, MovimientoFijo:=True) - FolioEntrada = ObjInventario.Folio - - If CveMovimientoEntrada <= 0 Then - MensajeError = "Ocurrió un error al guardar el movimiento de entrada correctamente. Por favor vuelva a intentar." - TieneError = True - Else - If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then - Cont = 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.ToDouble, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, Dr("Observaciones").ToString) Then - TieneError = True - MensajeError = "Ocurrió un error al guardar los movimientos de entrada" - Exit For - Else - If ObjInventario.CveMovimientoDetalle > 0 AndAlso DtSeccionAlmacen.Rows.Count > 0 Then - For Each Dr2 As DataRow In DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {Cont} AND TipoSeccionAlmacen = 2").Rows - If Not ObjInventario.AddMovimientosDetalleSeccionesAlmacen(ObjInventario.CveMovimientoDetalle, Dr2("CveSeccionAlmacenDestino").ToString.ToEntero, Dr2("CantidadSeccionAlmacen").ToString.ToDecimal) Then - TieneError = True - MensajeError = "Ocurrió un error al procesar las secciones de almacen. Por favor vuelva a intentar." - Exit For - End If - Next - End If - End If - Cont += 1 - Next - End If - End If - End If - - End Select - + If EsSurtidoUniforme Then + 'RESGUARDO + DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen IN (19)") 'GlobalDTAlmacen(UsuarioActual.CveEmpresa) + DdlAlmacen.DataBind() + DdlAlmacen.Items.Insert(0, New ListItem("Seleccione", "-1")) + 'Almacen Destino + DdlAlmacenDestino.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 20) + DdlAlmacenDestino.DataBind() + DdlAlmacenDestino.Items.Insert(0, New ListItem("Seleccione", "-1")) + + 'LIBERACION + DdlAlmacenLiberacion.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 20) + DdlAlmacenLiberacion.DataBind() + DdlAlmacenLiberacion.Items.Insert(0, New ListItem("Seleccione", "-1")) + ''Almacen Destino + Else + 'RESGUARDO + DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1) '.FiltraParametros("CveTipoAlmacen IN (1,2)") 'GlobalDTAlmacen(UsuarioActual.CveEmpresa) + DdlAlmacen.DataBind() + DdlAlmacen.Items.Insert(0, New ListItem("Seleccione", "-1")) + 'Almacen Destino + DdlAlmacenDestino.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 8) + DdlAlmacenDestino.DataBind() + DdlAlmacenDestino.Items.Insert(0, New ListItem("Seleccione", "-1")) + + + 'LIBERACION + DdlAlmacenLiberacion.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 8) + DdlAlmacenLiberacion.DataBind() + DdlAlmacenLiberacion.Items.Insert(0, New ListItem("Seleccione", "-1")) + End If + + + ''Almacen Destino + DdlAlmacenDestinoLiberacion.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1) '.FiltraParametros("CveTipoAlmacen IN (1,2)") + DdlAlmacenDestinoLiberacion.DataBind() + DdlAlmacenDestinoLiberacion.Items.Insert(0, New ListItem("Seleccione", "-1")) + + CargaPS() + End Sub + Private Sub CargaPS() + DdlProducto2.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1") + + If DdlProducto2.UsaWebService Then + DdlProducto2.ddlWS.Attributes.Add("data-pagina", "Inventarios") + DdlProducto2.ddlWS.Attributes.Add("data-cveclasificacion", DdlClasificacion.SelectedValue.ToString) + End If + If Not DdlProducto2.UsaWebService AndAlso CType(DdlProducto2.DataSource, DataTable) Is Nothing Then + DdlProducto2.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa) + DdlProducto2.DataBind() + End If + + VerificaProducto() + End Sub + Private Function isWhitFamily() As Boolean + Return (UsuarioActual.CveEmpresa = 66) + End Function +#End Region + + + +#Region " RESGUARDO " + + +#Region " FUNCIONALIDAD 105 - CLASIFICACION PS" + Protected Sub DdlClasificacion_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlClasificacion.SelectedIndexChanged + CargaProductosPorClasificacion() + End Sub + Protected Sub DdlProducto_ValueChanged(sender As Object, e As EventArgs) Handles DdlProducto2.selectedindexchange + VerificaProducto() + End Sub + Private Sub CargaProductosPorClasificacion() + If UsuarioActual.Empresa.Funcionalidad(105) = "" Then + 'Dim filtro As String = "" + 'If Not (DdlClasificacion.SelectedValue = "-1") Then + + ' If isWhitFamily() Then + ' 'filtro = String.Format("CveSubFamilia={0}", DdlClasificacion.SelectedValue) + ' Else + ' filtro = String.Format("CveClasificacion={0}", DdlClasificacion.SelectedValue) + ' End If + 'End If + DdlProducto2.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=DdlClasificacion.SelectedValue.ToEntero).FiltraParametros("", "PSCodigo") + DdlProducto2.DataBind() + DdlProducto2.ddl.Items.Insert(0, New ListItem("----", "-1")) + Else + 'If isWhitFamily() Then + ' 'DdlProducto2.ddlWS.Attributes.Add("data-idSubFamilia", DdlClasificacion.SelectedValue) + 'Else + DdlProducto2.ddlWS.Attributes.Add("data-cveclasificacion", DdlClasificacion.SelectedValue) + 'End If + End If + End Sub + Private Sub VerificaProducto() + If DdlProducto2.SelectedValue.ToEntero > 0 Then + If GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DdlProducto2.SelectedValue.ToEntero).FiltraParametros("Inv_CveMetodoInventario = 5", "PS").Rows.Count > 0 Then + ThSerieLote.Visible = True + TrSerieLote.Visible = True + TxtnSerieLote.Visible = True + GvM.Columns(4).Visible = True + Else + TxtnSerieLote.Visible = False + End If + End If + + 'If (1.Contiene("3", "7", "8", "11")) Then + ' Dim objinv As New ClsInventarios + ' If objinv.GetExistenciasPS(DdlProducto2.SelectedValue.ToEntero, -1, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, FechaMovto:=DateTime.Today.AddDays(1).ToString("yyyy/MM/dd HH:mm")) Then + ' DdlUnidad.DataSource = objinv.DtResultados.FiltraParametros("", "UnidadMedida", {"CveUnidadMedida", "UnidadMedida"}) + ' If objinv.DtResultados.Rows.Count = 0 Then + ' Alert("No hay existencias de este producto", TipoMensaje.MsgAdvertencia) + ' End If + ' End If + ' objinv.Dispose() + 'Else + ' DdlUnidad.DataSource = GlobalDTProductosServiciosEquivalencias(DdlProducto2.SelectedValue.ToEntero, -1) + 'End If + + DdlUnidad.Items.Clear() + DdlUnidad.DataSource = GlobalDTProductosServiciosEquivalencias(DdlProducto2.SelectedValue.ToEntero, -1, UsuarioActual.CveEmpresa) + DdlUnidad.DataBind() + UPDatos.Update() + + End Sub + +#End Region + + +#Region " EISTENCIAS " + Private Function GetExistencias(CvePS As Integer, CveUnidadMedida As Integer, CveEmpresa As Integer, CveAlmacen As Integer, Optional SerieLote As String = "-1") As Double + Dim Inv As New ClsInventarios + Dim Existencia As Double = Inv.GetExistenciasPS(CvePS, CveUnidadMedida, CveEmpresa, CveAlmacen, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), SerieLote:=SerieLote) + Inv.Dispose() + Return Existencia + End Function +#End Region + + +#Region " AGREGAR " + Protected Sub btnAgregar_Click(sender As Object, e As EventArgs) Handles LbAgregar.Click + AgregaProducto() + LimpiarAgregar() + End Sub + Protected Sub AgregaProducto() + Dim PSSelected As Integer = DdlProducto2.SelectedValue.ToEntero + If DdlAlmacen.SelectedValue.ToEntero <= 0 Then Alert("Seleccione un almacen", TipoMensaje.MsgInformacion) : Exit Sub + If PSSelected > 0 Then + If TxtnSerieLote.Visible Then + If TxtnSerieLote.Text = "" Then + Alert("Serie-Lote es necesario", TipoMensaje.MsgAdvertencia) + Return + End If + End If + Dim Valido As Boolean = True + Dim cantidadd As Double = txtCantidad.Text.ToDouble + Dim Existencia As Double = GetExistencias(PSSelected, DdlUnidad.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, If(TxtnSerieLote.Visible, TxtnSerieLote.Text, "-1").ToString) + If Existencia - txtCantidad.Text.ToDouble < 0 Then + If Existencia <= 0 Then + Alert("No hay existencia del producto", TipoMensaje.MsgAdvertencia) + Else + Alert(String.Format("Solo hay en existencia: {0}", Existencia), TipoMensaje.MsgAdvertencia) + If Not UsuarioActual.TienePermisoProceso(114) Then + cantidadd = Existencia + End If + End If + Valido = False + 'Valido = If(UsuarioActual.TienePermisoProceso(114), True, False) + End If + If Valido Then + Dim CveClasificacion As Integer + Dim dr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=PSSelected).FiltroPrimero("", "PS") + If dr IsNot Nothing Then CveClasificacion = dr("CveClasificacion").ToString.ToEntero + + Dim registro As DataRow = DtMovimientos.NewRow + registro.Item("Cantidad") = cantidadd + registro.Item("CveUM") = DdlUnidad.SelectedValue.ToEntero + registro.Item("UnidadMedida") = DdlUnidad.SelectedItem.Text + registro.Item("CvePS") = PSSelected + registro.Item("PS") = DdlProducto2.SelectedText + registro.Item("Estatus") = "" + registro.Item("SerieLote") = TxtnSerieLote.Text + registro.Item("Observaciones") = TxtObservacionesdetalle.Text + DtMovimientos.Rows.Add(registro) + CargaGvM() + + txtCantidad.Text = "" + txtCantidad.Focus() + + End If + End If + End Sub + Private Sub LimpiarAgregar() + DdlClasificacion.SelectedValue = "-1" + txtCantidad.Text = "" + TxtObservacionesdetalle.Text = "" + End Sub +#End Region + + +#Region " GvM " + Private Sub CargaGvM() + + ThSerieLote.Visible = False + TrSerieLote.Visible = False + TxtnSerieLote.Visible = False + GvM.Columns(4).Visible = False + For Each Dr As DataRow In DtMovimientos.Rows + If Dr("SerieLote").ToString <> "" Then + ThSerieLote.Visible = True + TrSerieLote.Visible = True + GvM.Columns(4).Visible = True + Exit For + End If + Next + + GvM.DataSource = DtMovimientos + GvM.DataBind() + End Sub + + Private Sub GvM_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) Handles GvM.RowDeleting + Dim DbRow As DataRow = Nothing + DbRow = DtMovimientos.Rows(e.RowIndex) + DtMovimientos.Rows.Remove(DbRow) + + GvM.EditIndex = -1 + CargaGvM() + End Sub + + Protected Sub GvM_RowDataBound(sender As Object, e As GridViewRowEventArgs) + If e.Row.RowType = DataControlRowType.DataRow Then + If DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {e.Row.RowIndex}").SUMD("CantidadSeccionAlmacen") > 0 Then + e.Row.FCLinkButton("lnkRemove").Visible = False + e.Row.FCLinkButton("lnkRemove").ToolTip = "Cuenta con sección almacen" + End If + End If + End Sub +#End Region + + +#Region " NUEVO " + Protected Sub BtnNuevo_Click(sender As Object, e As EventArgs) + LimpiarMovimiento() + End Sub + Private Sub LimpiarMovimiento() + DtMovimientos.Clear() + CargaGvM() + + BtnGuardarResguardo.Visible = True + + DdlAlmacen.SelectedValueExist("-1") + DdlAlmacenDestino.SelectedValueExist("-1") + DtSeccionAlmacen.Rows.Clear() + + TxtObservaciones.Text = "" + TxtFecha.Text = Now.ToShortDateString + DdlPersonal.SelectedValue = "-1" + DdlPersonal.SelectedText = "Seleccione" + LimpiarAgregar() + UPDatos.Update() + UpGenerales.Update() + End Sub +#End Region + + +#End Region + + +#Region " LIBERACION " + + +#Region " GV DATOS LIBERACION " + Protected Sub GvMLiberacion_RowDataBound(sender As Object, e As GridViewRowEventArgs) + If e.Row.RowType = DataControlRowType.DataRow Then + e.Row.FCLabel("LblCantidad").Text = e.Row.FCLabel("LblCantidad").Text.FormatoNumero(2) + End If + End Sub + + Protected Sub GvMLiberacion_RowCreated(sender As Object, e As GridViewRowEventArgs) + If e.Row.RowType = DataControlRowType.DataRow Then + Dim Index = e.Row.RowIndex + e.Row.FCTextBox("TxtCantidad").Attributes.Add("onKeyUp", String.Format("ValidarCantidad({0});", Index)) + End If + End Sub +#End Region + + +#Region " CARGA RESGUARDOS PARA LIBERACION " + + Protected Sub BtnVerificarExistencias_Click(sender As Object, e As EventArgs) + If Not DdlProveedorLiberacion.SelectedValue.ToEntero > 0 AndAlso DdlTipo.SelectedValue.ToEntero = 3 Then + Alert("Tiene que seleccionar un proveedor.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If Not DdlPersonalLiberacion.SelectedValue.ToEntero > 0 AndAlso DdlTipo.SelectedValue.ToEntero = 1 Then + Alert("Tiene que seleccionar un personal.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If Not DdlClienteLiberacion.SelectedValue.ToEntero > 0 AndAlso DdlTipo.SelectedValue.ToEntero = 2 Then + Alert("Tiene que seleccionar un cliente.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + CargaResguardos() + End Sub + + Private Sub CargaResguardos() + Dim ObjInventario As New ClsInventarios() + Dim Existencias As Double = 0 + + If ObjInventario.GetMovimientosDetallePorPersonal(DdlPersonalLiberacion.SelectedValue.ToEntero, DdlAlmacenLiberacion.SelectedValue.ToEntero, DdlClienteLiberacion.SelectedValue.ToEntero, DdlProveedorLiberacion.SelectedValue.ToEntero) Then + DtMovimientosLiberacion = ObjInventario.DtResultados + + DtMovimientosLiberacion.Columns("No").AutoIncrement = True + DtMovimientosLiberacion.Columns("No").AutoIncrementSeed = DtMovimientosLiberacion.Rows.Count + 1 + DtMovimientosLiberacion.Columns("No").AutoIncrementStep = 1 + + Dim keys(1) As DataColumn + keys(0) = DtMovimientosLiberacion.Columns("No") + DtMovimientosLiberacion.PrimaryKey = keys + + CargaGvMLiberacion() + If DdlPersonalLiberacion.SelectedValue.ToEntero <> -1 Then + LblTipo.InnerText = "Personal/Responsable:" + LbTipoLiberacion.Text = DdlPersonalLiberacion.SelectedText + End If + If DdlProveedorLiberacion.SelectedValue.ToEntero <> -1 Then + LblTipo.InnerText = "Proveedor:" + LbTipoLiberacion.Text = DdlProveedorLiberacion.SelectedText + End If + If DdlClienteLiberacion.SelectedValue.ToEntero <> -1 Then + LblTipo.InnerText = "Cliente:" + LbTipoLiberacion.Text = DdlClienteLiberacion.SelectedText + End If + CvePersonalLiberacion = DdlPersonalLiberacion.SelectedValue.ToEntero + CveClienteLiberacion = DdlClienteLiberacion.SelectedValue.ToEntero + CveProveedorLiberacion = DdlProveedorLiberacion.SelectedValue.ToEntero + LbAlmacenLiberacion.Text = DdlAlmacenLiberacion.SelectedItem.Text + CveAlmacenLiberación = DdlAlmacenLiberacion.SelectedValue.ToEntero + LbFechaLiberacion.Text = TxtFechaLiberacion.Text + FechaLiberacion = TxtFechaLiberacion.Text + BtnGuardarLiberacion.Visible = True + + DtSeccionAlmacen.Rows.Clear() + + UpGeneralesLibreacion.Update() + Else + Alert("Ocurrió un error al cargar los resguardos del personal. Por favor vuelva a intentar.", TipoMensaje.MsgError) + End If + ObjInventario.Dispose() + + End Sub + + Private Sub CargaGvMLiberacion() + GvM.Columns(5).Visible = False + For Each Dr As DataRow In DtMovimientosLiberacion.Rows + If Dr("SerieLote").ToString <> "" Then + GvM.Columns(5).Visible = True + Exit For + End If + Next + + GvMLiberacion.DataSource = DtMovimientosLiberacion + GvMLiberacion.DataBind() + UpGridLiberacion.Update() + End Sub + +#End Region + +#Region " LIMPIAR LIBERACION " + Private Sub LimpiarLiberacion() + LbTipoLiberacion.Text = "" + LblTipo.InnerText = "" + CvePersonalLiberacion = -1 + CveClienteLiberacion = -1 + CveProveedorLiberacion = -1 + LbAlmacenLiberacion.Text = "" + CveAlmacenLiberación = -1 + LbFechaLiberacion.Text = "" + FechaLiberacion = "" + BtnGuardarLiberacion.Visible = False + DtSeccionAlmacen.Rows.Clear() + + DdlAlmacenDestinoLiberacion.SelectedValue = "-1" + TxtObservacionesLiberacion.Text = "" + + DtMovimientosLiberacion.Clear() + CargaGvMLiberacion() + + UpGeneralesLibreacion.Update() + End Sub +#End Region + + +#End Region + + + +#Region " GUARDAR " + Protected Sub BtnGuardarResguardo_Click(sender As Object, e As EventArgs) Handles BtnGuardarResguardo.Click + + If Not GvM.Rows.Count > 0 Then + Alert("No hay ningun registro para generar el movimiento. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If Not DdlProveedor.SelectedValue.ToEntero > 0 And DivProveedor.Visible Then + Alert("Tiene que seleccionar un proveedor.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + 'VALIDA LA EXISTENCIA DEL ALMACEN + Dim ObjInventario As New ClsInventarios + Dim ErrorExistencia = False + Dim TextoExistencia As StringBuilder = New StringBuilder + Dim Existencia As Double + TextoExistencia.Append("Los siguiente productos se ajustaron por falta de exitencia:
") + For Each dr As DataRow In DtMovimientos.Rows + Existencia = ObjInventario.GetExistenciasPS(dr("CvePS").ToString.ToEntero, dr("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDate.ToString("yyyy/MM/dd 23:59"), SerieLote:=If(dr("SerieLote").ToString = "", "-1", dr("SerieLote").ToString)) + Existencia -= DtMovimientos.SUM("Cantidad", $"CvePS = {dr("CvePS").ToString.ToEntero} AND CveUM = {dr("CveUM").ToString.ToEntero} {If(dr("SerieLote").ToString <> "-1", $" AND SerieLote = '{dr("SerieLote").ToString}'", "")}") + + If Existencia < 0 Then + ErrorExistencia = True + dr("Cantidad") = Existencia + TextoExistencia.AppendFormat("- #{0} {1}
", dr("No").ToString, dr("PS").ToString) + End If + Next + ObjInventario.Dispose() + + If ErrorExistencia Then + Alert(TextoExistencia.ToString, TipoMensaje.MsgError) + End If + + Dim TotalCantidad As Double = DtMovimientos.SUMD("Cantidad") + If UsuarioActual.Empresa.Funcionalidad(563) = "1" Then + If TotalCantidad <> DtSeccionAlmacen.FiltraParametros("TipoSeccionAlmacen = 1").SUMD("CantidadSeccionAlmacen") Then + Alert("La seccion de almacen no ha sido agregada completamente.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + End If + + Guardar(23) + + End Sub + Protected Sub BtnGuardarLiberacion_Click(sender As Object, e As EventArgs) + + If Not DdlProveedorLiberacion.SelectedValue.ToEntero > 0 And DivProveedorLiberacion2.Visible Then + Alert("Tiene que seleccionar un proveedor.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If Not GvMLiberacion.Rows.Count > 0 Then + Alert("No hay ningun registro para generar el movimiento. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + Dim TieneError = True + Dim TotalCantidad As Decimal = 0 + For Each Gvr As GridViewRow In GvMLiberacion.Rows + If Gvr.FCTextBox("TxtCantidad").Text.ToDecimal > 0 Then + TieneError = False + Exit For + Else + TotalCantidad += Gvr.FCTextBox("TxtCantidad").Text.ToDecimal + End If + Next + + If TieneError Then + Alert("Se debe seleccionar por lo menos una cantidad de los resguardos para generar la liberación. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If UsuarioActual.Empresa.Funcionalidad(563) = "1" Then + If TotalCantidad <> DtSeccionAlmacen.FiltraParametros("TipoSeccionAlmacen = 2").SUMD("CantidadSeccionAlmacen") Then + Alert("La seccion de almacen no ha sido agregada completamente.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + End If + + Guardar(24) + + + End Sub + + Private Sub Guardar(Concepto As Integer) + Dim ObjInventario As New ClsInventarios + Dim ObjEventos As New ClsOIEventos(ObjInventario.IniciaTransacSQL()) 'Inicia la transacción + Dim TieneError = False + Dim MensajeError As String = "" + Dim ImporteConcepto = 0.0 + + Dim CveMovimientoSalida = 0 + Dim FolioSalida = 0 + Dim CveMovimientoEntrada = 0 + Dim FolioEntrada = 0 + + 'Para Campos Nuevos AF y OC + Dim SubProyecto = -1 + Dim ActivoFijo = -1 + + Dim CveProveedor = -1 + Dim CveCliente = -1 + Dim CvePersonal = -1 + + If RbTipoCliente.Checked Then CveCliente = DdlCliente.SelectedValue.ToEntero + If RbTipoProveedor.Checked Then CveProveedor = DdlProveedor.SelectedValue.ToEntero + If RbTipoPersonal.Checked Then CvePersonal = DdlPersonal.SelectedValue.ToEntero + + Dim Fecha = If(Concepto = 23, TxtFecha.Text.ToDate, FechaLiberacion.ToDate) + + Select Case (Concepto) + Case 23 ' Resguardo + + 'SALIDA ORIGEN + CveMovimientoSalida = ObjInventario.AddMovimiento(DdlAlmacen.SelectedValue.ToEntero, 24, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, SubProyecto, ActivoFijo, Observaciones:=TxtObservaciones.Text, CvePersonal:=CvePersonal, CveAlmacenDestino:=DdlAlmacenDestino.SelectedValue.ToEntero, CveCliente:=CveCliente, CveProveedor:=CveProveedor) + FolioSalida = ObjInventario.Folio + + If CveMovimientoSalida <= 0 Then + TieneError = True + MensajeError = "Ocurrió un error al guardar el movimiento de salida. Por favor vuelva a intentar." + Exit Select + End If + + Dim Cont As Integer = 0 + For Each Dr As DataRow In DtMovimientos.Rows + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0, -1, -1, Dr("SerieLote").ToString, Dr("Observaciones").ToString) Then + MensajeError = "Ocurrió un error al guardar los detalles del movimiento de salida. Por favor vuelva a intentar." + TieneError = True + Exit For + Else + If ObjInventario.CveMovimientoDetalle > 0 AndAlso DtSeccionAlmacen.Rows.Count > 0 Then + For Each Dr2 As DataRow In DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {Cont} AND TipoSeccionAlmacen = 1").Rows + If Not ObjInventario.AddMovimientosDetalleSeccionesAlmacen(ObjInventario.CveMovimientoDetalle, Dr2("CveSeccionAlmacenOrigen").ToString.ToEntero, -Dr2("CantidadSeccionAlmacen").ToString.ToDecimal) Then + TieneError = True + MensajeError = "Ocurrió un error al procesar las secciones de almacen. Por favor vuelva a intentar." + Exit For + End If + Next + End If + End If + Cont += 1 + Next + + Cont = 0 + If Not TieneError Then + CveMovimientoEntrada = ObjInventario.AddMovimiento(DdlAlmacenDestino.SelectedValue.ToEntero, 2, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, SubProyecto, ActivoFijo, Observaciones:=TxtObservaciones.Text, CvePersonal:=CvePersonal, CveMovimientoRelacionado:=CveMovimientoSalida, CveCliente:=CveCliente, CveProveedor:=CveProveedor) + FolioEntrada = ObjInventario.Folio + + If CveMovimientoEntrada <= 0 Then + MensajeError = "Ocurrió un error al guardar el movimiento de entrada correctamente. Por favor vuelva a intentar." + TieneError = True + Else + If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) 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, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, Dr("Observaciones").ToString) Then + TieneError = True + MensajeError = "Ocurrió un error al guardar los movimientos de entrada" + Exit For + Else + If ObjInventario.CveMovimientoDetalle > 0 AndAlso DtSeccionAlmacen.Rows.Count > 0 Then + For Each Dr2 As DataRow In DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {Cont} AND TipoSeccionAlmacen = 1").Rows + If Not ObjInventario.AddMovimientosDetalleSeccionesAlmacen(ObjInventario.CveMovimientoDetalle, Dr2("CveSeccionAlmacenDestino").ToString.ToEntero, Dr2("CantidadSeccionAlmacen").ToString.ToDecimal) Then + TieneError = True + MensajeError = "Ocurrió un error al procesar las secciones de almacen. Por favor vuelva a intentar." + Exit For + End If + Next + End If + End If + Cont += 1 + Next + End If + End If + End If + + Case 24 'LIBERACION + + + 'SALIDA ORIGEN - RESGUARDO + CveMovimientoSalida = ObjInventario.AddMovimiento(CveAlmacenLiberación, 3, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, SubProyecto, ActivoFijo, Observaciones:=TxtObservacionesLiberacion.Text, CvePersonal:=CvePersonalLiberacion, CveAlmacenDestino:=DdlAlmacenDestinoLiberacion.SelectedValue.ToEntero, CveProveedor:=CveProveedorLiberacion, CveCliente:=CveClienteLiberacion, MovimientoFijo:=True) + FolioSalida = ObjInventario.Folio + + If CveMovimientoSalida <= 0 Then + TieneError = True + MensajeError = "Ocurrió un error al guardar el movimiento de salida. Por favor vuelva a intentar." + Exit Select + End If + + Dim Cont As Integer = 0 + For Each Gvr As GridViewRow In GvMLiberacion.Rows + If Gvr.FCTextBox("TxtCantidad").Text.ToDouble > 0 Then + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Gvr.FCTextBox("TxtCantidad").Text.ToDouble, Gvr.DataKey("CveUM").ToString.ToEntero, Gvr.DataKey("CvePS").ToString.ToEntero, Gvr.DataKey("PU").ToString.ToDecimal, -1, -1, Gvr.DataKey("SerieLote").ToString, Gvr.DataKey("Observaciones").ToString) Then + MensajeError = "Ocurrió un error al guardar los detalles del movimiento de salida. Por favor vuelva a intentar." + TieneError = True + Exit For + Else + If ObjInventario.CveMovimientoDetalle > 0 AndAlso DtSeccionAlmacen.Rows.Count > 0 Then + For Each Dr2 As DataRow In DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {Cont} AND TipoSeccionAlmacen = 2").Rows + If Not ObjInventario.AddMovimientosDetalleSeccionesAlmacen(ObjInventario.CveMovimientoDetalle, Dr2("CveSeccionAlmacenOrigen").ToString.ToEntero, -Dr2("CantidadSeccionAlmacen").ToString.ToDecimal) Then + TieneError = True + MensajeError = "Ocurrió un error al procesar las secciones de almacen. Por favor vuelva a intentar." + Exit For + End If + Next + End If + End If + End If + Cont += 1 + Next + + + If Not TieneError Then + CveMovimientoEntrada = ObjInventario.AddMovimiento(DdlAlmacenDestinoLiberacion.SelectedValue.ToEntero, 23, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, SubProyecto, ActivoFijo, Observaciones:=TxtObservacionesLiberacion.Text, CvePersonal:=CvePersonalLiberacion, CveMovimientoRelacionado:=CveMovimientoSalida, CveProveedor:=CveProveedorLiberacion, CveCliente:=CveClienteLiberacion, MovimientoFijo:=True) + FolioEntrada = ObjInventario.Folio + + If CveMovimientoEntrada <= 0 Then + MensajeError = "Ocurrió un error al guardar el movimiento de entrada correctamente. Por favor vuelva a intentar." + TieneError = True + Else + If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then + Cont = 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, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, Dr("Observaciones").ToString) Then + TieneError = True + MensajeError = "Ocurrió un error al guardar los movimientos de entrada" + Exit For + Else + If ObjInventario.CveMovimientoDetalle > 0 AndAlso DtSeccionAlmacen.Rows.Count > 0 Then + For Each Dr2 As DataRow In DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {Cont} AND TipoSeccionAlmacen = 2").Rows + If Not ObjInventario.AddMovimientosDetalleSeccionesAlmacen(ObjInventario.CveMovimientoDetalle, Dr2("CveSeccionAlmacenDestino").ToString.ToEntero, Dr2("CantidadSeccionAlmacen").ToString.ToDecimal) Then + TieneError = True + MensajeError = "Ocurrió un error al procesar las secciones de almacen. Por favor vuelva a intentar." + Exit For + End If + Next + End If + End If + Cont += 1 + Next + End If + End If + End If + + End Select + If Not TieneError Then TieneError = Not AgregarAgenda(ObjEventos, FolioEntrada, FolioSalida) - End If - - If Not TieneError Then - Dim Msg As New StringBuilder - If Concepto = 23 Then - Msg.AppendFormat("
Resguardo con Folio: {1}", CveMovimientoSalida, FolioSalida) - Msg.AppendFormat("
Imprimir Resguardo ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoSalida))) - - Msg.AppendFormat("


El Movimiento de control se registro con el Folio: {1}", CveMovimientoEntrada, FolioEntrada) - Else - Msg.AppendFormat("
Liberación de Resguardo con Folio: {1}", CveMovimientoEntrada, FolioEntrada) - Msg.AppendFormat("
Imprimir liberación de Resguardo ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoEntrada))) - - Msg.AppendFormat("


El Movimiento de control se registro con el Folio: {1}", CveMovimientoSalida, FolioSalida) - End If - - - Alert(Msg.ToString, TipoMensaje.MsgInformacion) - - 'Limpia Valores cuando inserta de campos especiales - If UsuarioActual.CveEmpresa = 66 Then - DdlSubProyecto.SelectedValueExist("-1") - End If - - ObjInventario.Commit() - - If Concepto = 23 Then - LimpiarMovimiento() - Else - LimpiarLiberacion() - End If - - UPDatos.Update() - Else - Alert(MensajeError, TipoMensaje.MsgError) - ObjInventario.RollBack() - End If - - ObjInventario.Dispose() - ObjEventos.Dispose() + End If + + If Not TieneError Then + Dim Msg As New StringBuilder + If Concepto = 23 Then + Msg.AppendFormat("
Resguardo con Folio: {1}", CveMovimientoSalida, FolioSalida) + Msg.AppendFormat("
Imprimir Resguardo ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoSalida))) + + Msg.AppendFormat("


El Movimiento de control se registro con el Folio: {1}", CveMovimientoEntrada, FolioEntrada) + Else + Msg.AppendFormat("
Liberación de Resguardo con Folio: {1}", CveMovimientoEntrada, FolioEntrada) + Msg.AppendFormat("
Imprimir liberación de Resguardo ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoEntrada))) + + Msg.AppendFormat("


El Movimiento de control se registro con el Folio: {1}", CveMovimientoSalida, FolioSalida) + End If + + + Alert(Msg.ToString, TipoMensaje.MsgInformacion) + + 'Limpia Valores cuando inserta de campos especiales + If UsuarioActual.CveEmpresa = 66 Then + DdlSubProyecto.SelectedValueExist("-1") + End If + + ObjInventario.Commit() + + If Concepto = 23 Then + LimpiarMovimiento() + Else + LimpiarLiberacion() + End If + + UPDatos.Update() + Else + Alert(MensajeError, TipoMensaje.MsgError) + ObjInventario.RollBack() + End If + + ObjInventario.Dispose() + ObjEventos.Dispose() End Sub Private Function AgregarAgenda(ByRef ObjEventos As ClsOIEventos, FolioEntrada As Integer, FolioSalida As Integer) As Boolean Dim TieneError As Boolean = False @@ -961,232 +961,232 @@ Partial Class Inventarios_ResguardoMaterial End Function -#End Region +#End Region -#Region "TIPOS" +#Region "TIPOS" - Protected Sub RbTipo_CheckedChanged(sender As Object, e As EventArgs) - DivCliente.Visible = False - DivPersonal.Visible = False - DivProveedor.Visible = False + Protected Sub RbTipo_CheckedChanged(sender As Object, e As EventArgs) + DivCliente.Visible = False + DivPersonal.Visible = False + DivProveedor.Visible = False If RbTipoCliente.Checked Then - DivCliente.Visible = True - 'DdlPersonal.Attributes.Add("data-metodo", "getcliente") + DivCliente.Visible = True + 'DdlPersonal.Attributes.Add("data-metodo", "getcliente") End If If RbTipoPersonal.Checked Then - DivPersonal.Visible = True - 'DdlPersonal.Attributes.Add("data-metodo", "getpersonal") + DivPersonal.Visible = True + 'DdlPersonal.Attributes.Add("data-metodo", "getpersonal") End If If RbTipoProveedor.Checked Then - DivProveedor.Visible = True - 'DdlPersonal.Attributes.Add("data-metodo", "getproveedores") + DivProveedor.Visible = True + 'DdlPersonal.Attributes.Add("data-metodo", "getproveedores") End If - UpGenerales.Update() - End Sub - - Protected Sub DdlTipo_SelectedIndexChanged(sender As Object, e As EventArgs) - 'DdlPersonalLiberacion.ddl.SelectedIndex = 0 - 'DdlProveedorLiberacion.SelectedValue = "-1" - 'DdlProveedorLiberacion.SelectedText = "Seleccione" - 'DdlClienteLiberacion.SelectedValue = "0" - DivPersonalLiberacion.Visible = False - DivPersonalLiberacion2.Visible = False - DivClienteLiberacion.Visible = False - DivClienteLiberacion2.Visible = False - DivProveedorLiberacion.Visible = False - DivProveedorLiberacion2.Visible = False - If DdlTipo.SelectedValue.ToEntero = 1 Then - DivPersonalLiberacion.Visible = True - DivPersonalLiberacion2.Visible = True - End If - If DdlTipo.SelectedValue.ToEntero = 2 Then - DivClienteLiberacion.Visible = True - DivClienteLiberacion2.Visible = True - End If - If DdlTipo.SelectedValue.ToEntero = 3 Then - DivProveedorLiberacion.Visible = True - DivProveedorLiberacion2.Visible = True - End If - UpFiltraLiberacion.Update() + UpGenerales.Update() End Sub -#End Region + Protected Sub DdlTipo_SelectedIndexChanged(sender As Object, e As EventArgs) + 'DdlPersonalLiberacion.ddl.SelectedIndex = 0 + 'DdlProveedorLiberacion.SelectedValue = "-1" + 'DdlProveedorLiberacion.SelectedText = "Seleccione" + 'DdlClienteLiberacion.SelectedValue = "0" + DivPersonalLiberacion.Visible = False + DivPersonalLiberacion2.Visible = False + DivClienteLiberacion.Visible = False + DivClienteLiberacion2.Visible = False + DivProveedorLiberacion.Visible = False + DivProveedorLiberacion2.Visible = False + If DdlTipo.SelectedValue.ToEntero = 1 Then + DivPersonalLiberacion.Visible = True + DivPersonalLiberacion2.Visible = True + End If + If DdlTipo.SelectedValue.ToEntero = 2 Then + DivClienteLiberacion.Visible = True + DivClienteLiberacion2.Visible = True + End If + If DdlTipo.SelectedValue.ToEntero = 3 Then + DivProveedorLiberacion.Visible = True + DivProveedorLiberacion2.Visible = True + End If + UpFiltraLiberacion.Update() + End Sub -#Region "SECCION ALMACEN" - Private Sub CreaDtSeccionAlmacen() - DtSeccionAlmacen = New DataTable - DtSeccionAlmacen.Columns.Add("CantidadSeccionAlmacen", GetType(Decimal)) - DtSeccionAlmacen.Columns.Add("IndexSeccionAlmacen", GetType(Integer)) - DtSeccionAlmacen.Columns.Add("CveSeccionAlmacenOrigen", GetType(Integer)) - DtSeccionAlmacen.Columns.Add("CveSeccionAlmacenDestino", GetType(Integer)) - DtSeccionAlmacen.Columns.Add("CvePS", GetType(Integer)) - DtSeccionAlmacen.Columns.Add("SeccionAlmacenOrigen", GetType(String)) - DtSeccionAlmacen.Columns.Add("SeccionAlmacenDestino", GetType(String)) - DtSeccionAlmacen.Columns.Add("Consec", GetType(Integer)) - DtSeccionAlmacen.Columns.Add("TipoSeccionAlmacen", GetType(Integer)) - End Sub - Private Sub CargaDdlAlmacen() - DdlSeccionAlmacenOrigen.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa) - DdlSeccionAlmacenOrigen.Items.Insert(0, New ListItem("Seleccione", "-1")) - DdlSeccionAlmacenOrigen.DataBind() - - DdlSeccionAlmacenDestino.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa) - DdlSeccionAlmacenDestino.Items.Insert(0, New ListItem("Seleccione", "-1")) - DdlSeccionAlmacenDestino.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 origen.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - 'If Not DdlAlmacenDestino.SelectedValue.ToEntero > 0 AndAlso Not ChkTransitorio.Checked Then - ' Alert("Tiene que tener seleccionado un almacen para registrar seccion almacen destino.", TipoMensaje.MsgAdvertencia) - ' Exit Sub - 'End If - - GvSeccion.Columns(2).Visible = True - DivSeccionAlmacenDestino.Visible = True - - DivSeccionAlmacenOrigen.Visible = True - GvSeccion.Columns(1).Visible = True - - CantidadTotal = gvRow.DataKey("Cantidad").ToDecimal - IndexSeccionAlmacen = gvRow.RowIndex - CvePS = gvRow.DataKey("CvePS").ToEntero - TipoSeccionAlmacen = 1 - CargaSeccionAlmacen() - RegistraScript("$('#DModalSeccionAlmacen').modal()") - End Sub - - Protected Sub LnkSeccionAlmacenDestino_Click(sender As Object, e As EventArgs) - Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) - - If Not DdlAlmacenLiberacion.SelectedValue.ToEntero > 0 Then - Alert("Tiene que tener seleccionado un almacen para registrar seccion almacen destino.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - DivSeccionAlmacenOrigen.Visible = True - DivSeccionAlmacenDestino.Visible = True - GvSeccion.Columns(1).Visible = True - GvSeccion.Columns(2).Visible = True - - CantidadTotal = gvRow.FCTextBox("TxtCantidad").Text.ToDecimal - IndexSeccionAlmacen = gvRow.RowIndex - CvePS = gvRow.DataKey("CvePS").ToEntero - TipoSeccionAlmacen = 2 - CargaSeccionAlmacen() - RegistraScript("$('#DModalSeccionAlmacen').modal()") - - End Sub - - Private Sub CargaSeccionAlmacen() - Dim CantidadTotalSeccion As Decimal = DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {IndexSeccionAlmacen} AND TipoSeccionAlmacen = {TipoSeccionAlmacen}").SUMD("CantidadSeccionAlmacen") - GvSeccion.DataSource = DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {IndexSeccionAlmacen} AND TipoSeccionAlmacen = {TipoSeccionAlmacen}") - GvSeccion.DataBind() - - TxtCantidadSeccion.Text = "" - DdlSeccionAlmacenOrigen.SelectedIndex = 0 - DdlSeccionAlmacenDestino.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 TipoSeccionAlmacen = 1 Then - If CantidadTotalSeccion > 0 Then - GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").Visible = False - GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").ToolTip = "Cuenta con sección almacen" - Else - GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").Visible = True - GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").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 +#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("CveSeccionAlmacenOrigen", GetType(Integer)) + DtSeccionAlmacen.Columns.Add("CveSeccionAlmacenDestino", GetType(Integer)) + DtSeccionAlmacen.Columns.Add("CvePS", GetType(Integer)) + DtSeccionAlmacen.Columns.Add("SeccionAlmacenOrigen", GetType(String)) + DtSeccionAlmacen.Columns.Add("SeccionAlmacenDestino", GetType(String)) + DtSeccionAlmacen.Columns.Add("Consec", GetType(Integer)) + DtSeccionAlmacen.Columns.Add("TipoSeccionAlmacen", GetType(Integer)) + End Sub + Private Sub CargaDdlAlmacen() + DdlSeccionAlmacenOrigen.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa) + DdlSeccionAlmacenOrigen.Items.Insert(0, New ListItem("Seleccione", "-1")) + DdlSeccionAlmacenOrigen.DataBind() + + DdlSeccionAlmacenDestino.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa) + DdlSeccionAlmacenDestino.Items.Insert(0, New ListItem("Seleccione", "-1")) + DdlSeccionAlmacenDestino.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 origen.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + 'If Not DdlAlmacenDestino.SelectedValue.ToEntero > 0 AndAlso Not ChkTransitorio.Checked Then + ' Alert("Tiene que tener seleccionado un almacen para registrar seccion almacen destino.", TipoMensaje.MsgAdvertencia) + ' Exit Sub + 'End If + + GvSeccion.Columns(2).Visible = True + DivSeccionAlmacenDestino.Visible = True + + DivSeccionAlmacenOrigen.Visible = True + GvSeccion.Columns(1).Visible = True + + CantidadTotal = gvRow.DataKey("Cantidad").ToDecimal + IndexSeccionAlmacen = gvRow.RowIndex + CvePS = gvRow.DataKey("CvePS").ToEntero + TipoSeccionAlmacen = 1 + CargaSeccionAlmacen() + RegistraScript("$('#DModalSeccionAlmacen').modal()") + End Sub + + Protected Sub LnkSeccionAlmacenDestino_Click(sender As Object, e As EventArgs) + Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) + + If Not DdlAlmacenLiberacion.SelectedValue.ToEntero > 0 Then + Alert("Tiene que tener seleccionado un almacen para registrar seccion almacen destino.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + DivSeccionAlmacenOrigen.Visible = True + DivSeccionAlmacenDestino.Visible = True + GvSeccion.Columns(1).Visible = True + GvSeccion.Columns(2).Visible = True + + CantidadTotal = gvRow.FCTextBox("TxtCantidad").Text.ToDecimal + IndexSeccionAlmacen = gvRow.RowIndex + CvePS = gvRow.DataKey("CvePS").ToEntero + TipoSeccionAlmacen = 2 + CargaSeccionAlmacen() + RegistraScript("$('#DModalSeccionAlmacen').modal()") + + End Sub + + Private Sub CargaSeccionAlmacen() + Dim CantidadTotalSeccion As Decimal = DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {IndexSeccionAlmacen} AND TipoSeccionAlmacen = {TipoSeccionAlmacen}").SUMD("CantidadSeccionAlmacen") + GvSeccion.DataSource = DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {IndexSeccionAlmacen} AND TipoSeccionAlmacen = {TipoSeccionAlmacen}") + GvSeccion.DataBind() + + TxtCantidadSeccion.Text = "" + DdlSeccionAlmacenOrigen.SelectedIndex = 0 + DdlSeccionAlmacenDestino.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 TipoSeccionAlmacen = 1 Then + If CantidadTotalSeccion > 0 Then + GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").Visible = False + GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").ToolTip = "Cuenta con sección almacen" + Else + GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").Visible = True + GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").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 UpGenerales.Update() - ElseIf TipoSeccionAlmacen = 2 Then - If CantidadTotalSeccion > 0 Then - GvMLiberacion.Rows(IndexSeccionAlmacen).FCTextBox("TxtCantidad").Enabled = False - GvMLiberacion.Rows(IndexSeccionAlmacen).FCTextBox("TxtCantidad").ToolTip = "Cuenta con sección almacen" - Else - GvMLiberacion.Rows(IndexSeccionAlmacen).FCTextBox("TxtCantidad").Enabled = True - GvMLiberacion.Rows(IndexSeccionAlmacen).FCTextBox("TxtCantidad").ToolTip = "" - End If - If DtSeccionAlmacen.SUMD("CantidadSeccionAlmacen") > 0 Then - DdlAlmacenLiberacion.Enabled = False - DdlAlmacenLiberacion.ToolTip = "Cuenta con sección almacen" - Else - DdlAlmacenLiberacion.Enabled = True - DdlAlmacenLiberacion.ToolTip = "" - End If - UpGridLiberacion.Update() - UpFiltraLiberacion.Update() - End If - - UpModalSeccionAlmacen.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(DdlSeccionAlmacenOrigen.SelectedValue.ToEntero, If(TipoSeccionAlmacen = 1, DdlAlmacen.SelectedValue.ToEntero, DdlAlmacenLiberacion.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 CveSeccionAlmacenOrigen = {DdlSeccionAlmacenOrigen.SelectedValue} AND TipoSeccionAlmacen = {TipoSeccionAlmacen}").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("CveSeccionAlmacenOrigen") = DdlSeccionAlmacenOrigen.SelectedValue.ToEntero - Row("SeccionAlmacenOrigen") = DdlSeccionAlmacenOrigen.SelectedItem.Text - Row("CveSeccionAlmacenDestino") = DdlSeccionAlmacenDestino.SelectedValue.ToEntero - Row("SeccionAlmacenDestino") = DdlSeccionAlmacenDestino.SelectedItem.Text - Row("CvePS") = CvePS - Row("Consec") = DtSeccionAlmacen.Rows.Count + 1 - Row("TipoSeccionAlmacen") = TipoSeccionAlmacen - 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() + ElseIf TipoSeccionAlmacen = 2 Then + If CantidadTotalSeccion > 0 Then + GvMLiberacion.Rows(IndexSeccionAlmacen).FCTextBox("TxtCantidad").Enabled = False + GvMLiberacion.Rows(IndexSeccionAlmacen).FCTextBox("TxtCantidad").ToolTip = "Cuenta con sección almacen" + Else + GvMLiberacion.Rows(IndexSeccionAlmacen).FCTextBox("TxtCantidad").Enabled = True + GvMLiberacion.Rows(IndexSeccionAlmacen).FCTextBox("TxtCantidad").ToolTip = "" + End If + If DtSeccionAlmacen.SUMD("CantidadSeccionAlmacen") > 0 Then + DdlAlmacenLiberacion.Enabled = False + DdlAlmacenLiberacion.ToolTip = "Cuenta con sección almacen" + Else + DdlAlmacenLiberacion.Enabled = True + DdlAlmacenLiberacion.ToolTip = "" + End If + UpGridLiberacion.Update() + UpFiltraLiberacion.Update() + End If + + UpModalSeccionAlmacen.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(DdlSeccionAlmacenOrigen.SelectedValue.ToEntero, If(TipoSeccionAlmacen = 1, DdlAlmacen.SelectedValue.ToEntero, DdlAlmacenLiberacion.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 CveSeccionAlmacenOrigen = {DdlSeccionAlmacenOrigen.SelectedValue} AND TipoSeccionAlmacen = {TipoSeccionAlmacen}").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("CveSeccionAlmacenOrigen") = DdlSeccionAlmacenOrigen.SelectedValue.ToEntero + Row("SeccionAlmacenOrigen") = DdlSeccionAlmacenOrigen.SelectedItem.Text + Row("CveSeccionAlmacenDestino") = DdlSeccionAlmacenDestino.SelectedValue.ToEntero + Row("SeccionAlmacenDestino") = DdlSeccionAlmacenDestino.SelectedItem.Text + Row("CvePS") = CvePS + Row("Consec") = DtSeccionAlmacen.Rows.Count + 1 + Row("TipoSeccionAlmacen") = TipoSeccionAlmacen + 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) @@ -1210,7 +1210,7 @@ Partial Class Inventarios_ResguardoMaterial ' RegistraScript("$('#ModalVerSeccionesAlmacen').modal()") 'End Sub -#End Region +#End Region Private Sub ImgExcel_Click(sender As Object, e As EventArgs) Handles ImgExcel.Click Imprime("Excel") @@ -1228,4 +1228,4 @@ Partial Class Inventarios_ResguardoMaterial End If End Sub -End Class +End Class From a3a98b2d1fb75639d2822efd4b2a647083d17fa4 Mon Sep 17 00:00:00 2001 From: rrene Date: Mon, 6 Apr 2020 23:50:23 -0700 Subject: [PATCH 5/6] - cambio en PU --- Inventarios/TraspasoAlmacen.aspx.vb | 84 ++++++++++++++--------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/Inventarios/TraspasoAlmacen.aspx.vb b/Inventarios/TraspasoAlmacen.aspx.vb index 401a6bcf5..ca5e6f059 100644 --- a/Inventarios/TraspasoAlmacen.aspx.vb +++ b/Inventarios/TraspasoAlmacen.aspx.vb @@ -1557,8 +1557,8 @@ Partial Class Inventarios_TraspasoAlmacen 'DEBE CONSIDERAR SOLO LAS FILAS QUE TENGA PRODUCTOS, NO EL TOTALIZADOR If CvePS > 0 Then CveMovimientoDetalleSalida = GvRow.DataKey("CveMovimientoDetalle").ToString.ToEntero - Dim Cantidad As Double = GvRow.DataKey("Cantidad").ToString.ToDouble - Dim PrecioUnitario As Double = GvRow.DataKey("PU").ToString.ToDouble + Dim Cantidad As Decimal = GvRow.DataKey("Cantidad").ToString.ToDecimal + Dim PrecioUnitario As Decimal = GvRow.DataKey("PU").ToString.ToDecimal If CveMovimientoDetalleSalida <= 0 Then ErrorMovInv = True TextoError = "Ocurrió un error al guardar los movimientos de salida" @@ -1566,54 +1566,54 @@ Partial Class Inventarios_TraspasoAlmacen End If If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Cantidad, GvRow.DataKey("CveUM").ToEntero, CvePS, PrecioUnitario, GvRow.DataKey("CveAF").ToEntero, -1, GvRow.DataKey("SerieLote").ToString, Lote:=GvRow.DataKey("Lote"), Batch:=GvRow.DataKey("Batch"), CveMovimientoDetalleEntrada:=CveMovimientoDetalleSalida) Then - ErrorMovInv = True - TextoError = "Ocurrió un error al guardar los movimientos de entrada" - Exit For + ErrorMovInv = True + TextoError = "Ocurrió un error al guardar los movimientos de entrada" + Exit For + End If + importe += Cantidad * PrecioUnitario End If - importe += Cantidad * PrecioUnitario - End If - End If - Next + End If + Next - 'If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then - ' For Each Dr As DataRow In ObjInventario.DtResultados.Rows - ' CveMovimientoDetalleSalida = Dr("CveMovimientoDetalle").ToString.ToEntero - ' Dim Cantidad As Double = Dr("Cantidad").ToString.ToDouble - ' Dim PrecioUnitario As Double = Dr("PU").ToString.ToDouble - ' If CveMovimientoDetalleSalida <= 0 Then - ' ErrorMovInv = True - ' TextoError = "Ocurrió un error al guardar los movimientos de salida" - ' Exit For - ' End If + 'If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then + ' For Each Dr As DataRow In ObjInventario.DtResultados.Rows + ' CveMovimientoDetalleSalida = Dr("CveMovimientoDetalle").ToString.ToEntero + ' Dim Cantidad As Double = Dr("Cantidad").ToString.ToDouble + ' Dim PrecioUnitario As Double = Dr("PU").ToString.ToDouble + ' If CveMovimientoDetalleSalida <= 0 Then + ' ErrorMovInv = True + ' TextoError = "Ocurrió un error al guardar los movimientos de salida" + ' Exit For + ' End If - ' If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Cantidad, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, PrecioUnitario, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, CveMovimientoDetalleEntrada:=CveMovimientoDetalleSalida) Then - ' ErrorMovInv = True - ' TextoError = "Ocurrió un error al guardar los movimientos de entrada" - ' Exit For - ' End If - ' importe += Cantidad * PrecioUnitario - ' Next - 'Else - ' ErrorMovInv = True - ' TextoError = "Ocurrió un error al obtener los movimientos de salida" - 'End If + ' If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Cantidad, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, PrecioUnitario, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, CveMovimientoDetalleEntrada:=CveMovimientoDetalleSalida) Then + ' ErrorMovInv = True + ' TextoError = "Ocurrió un error al guardar los movimientos de entrada" + ' Exit For + ' End If + ' importe += Cantidad * PrecioUnitario + ' Next + 'Else + ' ErrorMovInv = True + ' TextoError = "Ocurrió un error al obtener los movimientos de salida" + 'End If - If Not ErrorMovInv Then - Dim ImporteDecimal As Decimal = importe.ToDecimal.RoundSQL - Dim IdCtaContable As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", String.Format("CveAlmacen = {0}", DdlAlmacenTransitorioRecepcion.SelectedValue.ToEntero)).ToEntero + If Not ErrorMovInv Then + Dim ImporteDecimal As Decimal = importe.ToDecimal.RoundSQL + Dim IdCtaContable As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", String.Format("CveAlmacen = {0}", DdlAlmacenTransitorioRecepcion.SelectedValue.ToEntero)).ToEntero - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImporteDecimal, TxtObservaciones.Text, 289, TxtObservaciones.Text, Fecha, IdCtaContable, -1, + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImporteDecimal, TxtObservaciones.Text, 289, TxtObservaciones.Text, Fecha, IdCtaContable, -1, CveMovimientoAlmacen:=CveMovimientoEntrada, ImporteMX:=ImporteDecimal) Then - ErrorMovInv = True - TextoError = "Ocurrió un erro al cancelar el traspaso" - End If + ErrorMovInv = True + TextoError = "Ocurrió un erro al cancelar el traspaso" + End If - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteDecimal, TxtObservaciones.Text, 68, TxtObservaciones.Text, Fecha, IdCtaContable, -1, + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteDecimal, TxtObservaciones.Text, 68, TxtObservaciones.Text, Fecha, IdCtaContable, -1, CveMovimientoAlmacen:=CveMovimientoEntrada, ImporteMX:=ImporteDecimal) Then - ErrorMovInv = True - TextoError = "Ocurrió un erro al cancelar el traspaso" + ErrorMovInv = True + TextoError = "Ocurrió un erro al cancelar el traspaso" + End If End If - End If End If @@ -2901,7 +2901,7 @@ Partial Class Inventarios_TraspasoAlmacen Private Function ReadExcelFile(ByVal flatFilePath As String, ByVal firstRowHasHeaders As Boolean) As DataTable SpreadsheetInfo.SetLicense(ModExtensiones.SerialGemBoxSpreadsheet) - Dim excelFile As ExcelFile = excelFile.Load(flatFilePath) + Dim excelFile As ExcelFile = ExcelFile.Load(flatFilePath) Dim unnamed As Integer = 0 Dim cols As Integer From e12c38bb08bc93e7ec00132595738498897971f8 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Tue, 7 Apr 2020 09:16:56 -0700 Subject: [PATCH 6/6] Correcione al pop up buscar venta --- Ventas/PopUpBuscarFolio.aspx | 17 ++++++----------- Ventas/PopUpBuscarFolio.aspx.vb | 2 +- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/Ventas/PopUpBuscarFolio.aspx b/Ventas/PopUpBuscarFolio.aspx index a725c5285..fa9005ee8 100644 --- a/Ventas/PopUpBuscarFolio.aspx +++ b/Ventas/PopUpBuscarFolio.aspx @@ -140,22 +140,17 @@ - - Clasificación: + + Clasificación: - - + + - Producto Servicio: + Producto Servicio: - - <%-- - - - --%> + - diff --git a/Ventas/PopUpBuscarFolio.aspx.vb b/Ventas/PopUpBuscarFolio.aspx.vb index 04777e43d..dc21afb62 100644 --- a/Ventas/PopUpBuscarFolio.aspx.vb +++ b/Ventas/PopUpBuscarFolio.aspx.vb @@ -75,7 +75,7 @@ Partial Class PopUpBuscarFolio DdlPS.ddl.Items.Clear() DdlPS.ddl.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=CveClasificacion) DdlPS.ddl.DataBind() - DdlPS.ddl.Items.Insert(0, New ListItem("Seleccione el Producto", "-1")) + DdlPS.ddl.Items.Insert(0, New ListItem("Todos", "-1")) End If End Sub