From c6b70a7d978b302bd1d546820466c98dccdb4918 Mon Sep 17 00:00:00 2001 From: rrene Date: Wed, 3 Feb 2021 09:56:49 -0700 Subject: [PATCH] --cambios modulos -- preciolibre --- App_Code/ClsProductosServicios.vb | 4399 +++++++++++++------------- App_Code/Modelos.vb | 86 +- Bancos/PopIECompras.aspx.vb | 21 +- Inventarios/RecepcionAlmacen.aspx.vb | 18 + 4 files changed, 2278 insertions(+), 2246 deletions(-) diff --git a/App_Code/ClsProductosServicios.vb b/App_Code/ClsProductosServicios.vb index 1a939af3d..0c327b82a 100644 --- a/App_Code/ClsProductosServicios.vb +++ b/App_Code/ClsProductosServicios.vb @@ -1,2208 +1,2215 @@ -Option Explicit On -Option Strict On - -Imports System.Data -Imports System.Data.SqlClient -Imports Extensiones -Imports System -Imports System.Configuration -Imports Modelos - -Public Class ClsProductosServicios - Implements IDisposable - -#Region "Campos" - Private SqlConexion As SqlConnection - Private SqlAdapter As SqlDataAdapter - Private SqlCommand As SqlCommand - Private SqlTransacc As SqlTransaction - Private Data As DataTable - Private disposedValue As Boolean = False - 'PARA REGISTRAR CONEXION - Private CveConexion As Integer = 0 - Private EsTransaccionCompartida As Boolean = False -#End Region - -#Region "Propiedades" - - Public Property CvePS As Integer - Public Property CveClasificacion As Integer - Public Property Clasificacion As String - Public Property CveUnidadMedida As Integer - Public Property CveSATPS As Integer - Public Property SATClavePS As String - Public Property SATDescripcion As String - Public Property Codigo As String - Public Property Codigo2 As String - Public Property CodigoBarras As String - Public Property PS As String - Public Property Precio As Double - Public Property PrecioMinimo As Double - Public Property Oferta As Double - Public Property IVA As Double - Public Property RetIVA As Double - Public Property MargenGanancia As Double - 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 Estado As Boolean - Public Property Fecha As Date - Public Property Usuario As String - Public Property CveEmpresa As Integer - Public Property CveMetodoInventario As Integer - Public Property CveTipoPS As Integer - Public Property Estado2 As Integer - Public Property CveMarca As Integer - - Public Property IEPSPorcentaje As Double - - Public Property AplicaIEPS As Boolean - Public Property IEPSGrabaIVA As Boolean - - Public Property AplicaSerie As Boolean - Public Property AplicaLote As Boolean - Public Property AplicaCaducidad As Boolean - Public Property AplicaSeccion As Boolean - - Public Property CveConceptoContable As Integer - - 'Nuevo R: 26/09/2017' - Public Property Inventariable As Boolean - Public Property CveProveedorCompra As Integer - Public Property ProveedorCompra As String - Public Property VentaMinima As Decimal - Public Property CveMoneda As Integer - Public Property RetISR As Double - - - 'Nuevo Rjb: 12/01/2018' - Public Property CveTipoFactor As Integer - - 'Nuevo Raul: 08/03/2018 - Public Property CveFraccionArancelaria As Integer - Public Property CveUnidadAduana As Integer - Public Property ClaveSATFraccionArancelariaDescripcion As String - Public Property ClaveSATUnidadAduanaDescripcion As String - Public Property ClaveSATFraccionArancelaria As String - Public Property ClaveSATUnidadAduana As String - - 'Nuevo Raul: 10/08/2018 - Public Property CveUsuarioModifico As Integer - Public Property UsuarioModifico As String - Public Property FechaUltimaModificacion As Date - - 'Nuevo Raul: 11/09/2018 - Public Property CveClasificacionDetalle As Integer - Public Property ClaveImpuestoTipoProducto As String - Public Property ClaveImpuestoEmpaque As String - Public Property ClaveImpuestoUnidadMedida As String - Public Property ClaveCategoriaToxicidad As String - - Public Property EsOutSourcing As Boolean - - Public ReadOnly Property DtResultados() As DataTable - Get - DtResultados = Data - End Get - End Property -#End Region - - - Sub New() - SqlConexion = New SqlConnection - SqlConexion.ConnectionString = ConfigurationManager.ConnectionStrings("Conexion").ConnectionString - SqlAdapter = New SqlDataAdapter("", SqlConexion) - Try - SqlConexion.Open() - Catch ex As Exception - OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex) - End Try - ConexionAdd() - End Sub - - - Public Function IniciaTransacSQL() As SqlTransaction - If SqlTransacc Is Nothing Then SqlTransacc = SqlConexion.BeginTransaction() - - Return SqlTransacc - End Function - Public Sub RollBack() - SqlTransacc.Rollback() - End Sub - Public Sub Commit() - SqlTransacc.Commit() - End Sub - - Sub New(Optional TransaccionCompartida As SqlTransaction = Nothing) - - If TransaccionCompartida Is Nothing Then - SqlConexion = New SqlConnection - SqlConexion.ConnectionString = ConfigurationManager.ConnectionStrings("Conexion").ConnectionString - Try - SqlConexion.Open() - Catch ex As Exception - OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex) - End Try - Else - SqlConexion = TransaccionCompartida.Connection - SqlTransacc = TransaccionCompartida - EsTransaccionCompartida = True - End If - - SqlAdapter = New SqlDataAdapter("", SqlConexion) - ConexionAdd() - End Sub - Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) - With SqlAdapter.SelectCommand - .Parameters.Clear() - .CommandText = StrSQL - .CommandType = TipoComando - End With - If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc - Data = New DataTable - End Sub -#Region "Conexiones" - - Private Sub ConexionAdd() - If Not EsTransaccionCompartida AndAlso ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then - - - Try - 'DataAdapter(String.Format("INSERT INTO Sis_Conexiones (Clase,Modulo) VALUES ('ClsRH','{0}')", "RH/CatMotivosBaja"), CommandType.Text) ' pendiente de terminar parra registrar el cveconexion, falta el rarámetro de módulo - DataAdapter("PA_Sis_RegistrarConexion") - With SqlAdapter.SelectCommand.Parameters - .Add("@Clase", SqlDbType.VarChar).Value = Me.GetType().Name - .Add("@Modulo", SqlDbType.VarChar).Value = String.Format("{0}?{1}", HttpContext.Current.Request.Url.AbsolutePath.ToString, HttpContext.Current.Request.QueryString.ToString) - .Add("@IDConexion", SqlDbType.Int).Direction = ParameterDirection.Output - End With - SqlAdapter.Fill(Data) - CveConexion = SqlAdapter.SelectCommand.Parameters("@IDConexion").Value.ToString.ToEntero - Catch ex As Exception - OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - End If - End Sub - - Private Sub ConexionClose() - If CveConexion > 0 AndAlso ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then - - DataAdapter(String.Format("UPDATE Sis_Conexiones SET FechaCierre = GETDATE() WHERE CveConexion = {0}", CveConexion), CommandType.Text) - - Try - SqlAdapter.Fill(Data) - - Catch ex As Exception - OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - CveConexion = 0 - End If - - End Sub -#End Region - Public Function GetPS(CvePS As Integer, CveClasificacion As Integer, CveEmpresa As Integer, Optional Codigo As String = "-1", Optional Codigo2 As String = "-1", - Optional CodigoBarras As String = "-1", Optional PS As String = "-1", Optional EsPaquete As Integer = -1, Optional CveSubProyecto As Integer = -1, - Optional pAplicaParaVenta As Integer = -1, Optional pEstado As Integer = -1, Optional CveClasificacionCosto As Integer = -1, Optional CveTipoPS As Integer = -1, - Optional CveCompuesto As Integer = -1, Optional SATClavePS As String = "-1", Optional TopSelect As Integer = 10000) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_ProductosServiciosGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@Codigo", SqlDbType.VarChar).Value = Codigo - .Add("@Codigo2", SqlDbType.VarChar).Value = Codigo2 - .Add("@CodigoBarras", SqlDbType.VarChar).Value = CodigoBarras - .Add("@PS", SqlDbType.VarChar).Value = PS - .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion - .Add("@EsPaquete", SqlDbType.SmallInt).Value = EsPaquete - .Add("@AplicaParaVenta", SqlDbType.Int).Value = pAplicaParaVenta - .Add("@Estado", SqlDbType.Int).Value = pEstado - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveClasificacionCosto", SqlDbType.Int).Value = CveClasificacionCosto - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveTipoPS", SqlDbType.Int).Value = CveTipoPS - .Add("@CveCompuesto", SqlDbType.Int).Value = CveCompuesto - .Add("@SATClavePS", SqlDbType.VarChar).Value = SATClavePS - .Add("@TopSelect", SqlDbType.Int).Value = TopSelect - End With - - Try - SqlAdapter.Fill(Data) - If Data.Rows.Count > 0 Then - Me.CvePS = Data.Rows(0)("CvePS").ToString().ToEntero - Me.CveClasificacion = Data.Rows(0)("CveClasificacion").ToString.ToEntero - Me.Clasificacion = Data.Rows(0)("Clasificacion").ToString - CveUnidadMedida = Data.Rows(0)("CveUnidadMedida").ToString.ToEntero - CveSATPS = Data.Rows(0)("CveSATPS").ToString.ToEntero - Me.SATClavePS = Data.Rows(0)("SATClavePS").ToString - 'SATDescripcion = Data.Rows(0)("SATDescripcion").ToString - Me.CveTipoPS = Data.Rows(0)("CveTipoPS").ToString.ToEntero - Me.Codigo = Data.Rows(0)("Codigo").ToString - Me.Codigo2 = Data.Rows(0)("Codigo2").ToString - Me.CodigoBarras = Data.Rows(0)("CodigoBarras").ToString - Me.PS = Data.Rows(0)("PS").ToString - Precio = Data.Rows(0)("Precio").ToString.ToDouble - PrecioMinimo = Data.Rows(0)("PrecioMinimo").ToString.ToDouble - Oferta = Data.Rows(0)("Oferta").ToString.ToDouble - IVA = Data.Rows(0)("IVA").ToString.ToDouble - RetIVA = Data.Rows(0)("RetIVA").ToString.ToDouble - CveMarca = Data.Rows(0)("CveMarca").ToString.ToEntero - AplicaParaConcepto = CBool(Data.Rows(0)("AplicaParaConcepto").ToString) - AplicaParaVenta = Data.Rows(0)("AplicaParaVenta").ToString = "True" - Estado = Data.Rows(0)("Estado").ToString = "Activo" - Estado2 = Data.Rows(0)("Estado2").ToString.ToEntero - Fecha = Data.Rows(0)("Fecha").ToString.ToDate - Usuario = Data.Rows(0)("Usuario").ToString - - 'AlmacenSeccion = Data.Rows(0)("AlmacenSeccion").ToString - AplicaIEPS = (Data.Rows(0)("AplicaIEPS").ToString) = "True" - IEPSGrabaIVA = (Data.Rows(0)("IEPSGrabaIVA").ToString) = "True" - IEPSPorcentaje = Data.Rows(0)("IEPSPorcentaje").ToString.ToDouble - CveConceptoContable = Data.Rows(0)("CveConceptoContable").ToString.ToEntero - - AplicaSerie = (Data.Rows(0)("AplicaSerie").ToString) = "True" - AplicaLote = (Data.Rows(0)("AplicaLote").ToString) = "True" - AplicaCaducidad = (Data.Rows(0)("AplicaCaducidad").ToString) = "True" - AplicaSeccion = (Data.Rows(0)("AplicaSeccion").ToString) = "True" - - 'Nuevo R: 26/09/2017' - - Inventariable = Data.Rows(0)("Inventariable").ToString = "True" - CveProveedorCompra = Data.Rows(0)("CveProveedorCompra").ToString.ToEntero - ProveedorCompra = Data.Rows(0)("ProveedorCompra").ToString - - 'Nuevo R: 12/01/2018' - CveTipoFactor = Data.Rows(0)("CveTipoFactor").ToString.ToEntero - - Me.CveEmpresa = Data.Rows(0)("CveEmpresa").ToString.ToEntero - CveMetodoInventario = Data.Rows(0)("Inv_CveMetodoInventario").ToString.ToEntero - VentaMinima = Data.Rows(0)("VentaMinima").ToString.ToDecimal - CveMoneda = Data.Rows(0)("CveMoneda").ToString.ToEntero - RetISR = Data.Rows(0)("RetISR").ToString.ToDouble - - 'Nuevo Raul: 08/03/2018 - CveFraccionArancelaria = Data.Rows(0)("CveFraccionArancelaria").ToString.ToEntero - CveUnidadAduana = Data.Rows(0)("CveUnidadAduana").ToString.ToEntero - ClaveSATFraccionArancelaria = Data.Rows(0)("ClaveSATFraccionArancelaria").ToString - ClaveSATUnidadAduana = Data.Rows(0)("ClaveSATUnidadAduana").ToString - ClaveSATFraccionArancelariaDescripcion = Data.Rows(0)("ClaveSATFraccionArancelariaDescripcion").ToString - ClaveSATUnidadAduanaDescripcion = Data.Rows(0)("ClaveSATUnidadAduanaDescripcion").ToString - - 'Nuevo Raul: 10/08/2018 - CveUsuarioModifico = Data.Rows(0)("CveUsuarioModifico").ToString.ToEntero - UsuarioModifico = Data.Rows(0)("UsuarioModifico").ToString - FechaUltimaModificacion = Data.Rows(0)("FechaUltimaModificacion").ToString.ToDate - - 'Nuevo Raul: 11/09/2018 - CveClasificacionDetalle = Data.Rows(0)("CveClasificacionDetalle").ToString.ToEntero - - ClaveImpuestoTipoProducto = Data.Rows(0)("ClaveImpuestoTipoProducto").ToString - ClaveImpuestoEmpaque = Data.Rows(0)("ClaveImpuestoEmpaque").ToString - ClaveImpuestoUnidadMedida = Data.Rows(0)("ClaveImpuestoUM").ToString - ClaveCategoriaToxicidad = Data.Rows(0)("ClaveCategoriaToxicidad").ToString - EsOutSourcing = Data.Rows(0)("EsOutSourcing").ToString = "True" - End If - Retorno = True - Catch ex As SqlException - If CvePS <> -1 Then - OnError("Ocurrió un error al consultar El Producto o Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - Else - OnError("Ocurrió un error al consultar El Producto o Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End If - End Try - - Return Retorno - End Function - Public Function GetPSSimplificado(CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_ProductosServiciosSimplificadoGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - - End With - - Try - SqlAdapter.Fill(Data) - - Retorno = True - Catch ex As SqlException - If CvePS <> -1 Then - OnError("Ocurrió un error al consultar El Producto o Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - Else - OnError("Ocurrió un error al consultar El Producto o Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End If - End Try - - Return Retorno - End Function - Public Function GetPSLite(CveClasificacion As Integer, CveEmpresa As Integer, Optional Codigo As String = "-1", Optional CodigoBarras As String = "-1", Optional PS As String = "-1", Optional pAplicaParaVenta As Integer = -1, Optional pEstado As Integer = -1, Optional CveTipoPS As Integer = -1, Optional UsoClasificacion As Integer = -1) As Boolean - Dim Retorno As Boolean = False - ' @CveClasificacion int, @Codigo varchar(50) = '-1', @PS varchar(300) = '-1', @AplicaParaVenta int = -1, @Estado int = -1, @CodigoBarras varchar(50) = '-1', @CveTipoPS int = -1, @CveEmpresa int - DataAdapter("PA_ProductosServiciosLiteGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Codigo", SqlDbType.VarChar).Value = Codigo - .Add("@CodigoBarras", SqlDbType.VarChar).Value = CodigoBarras - .Add("@PS", SqlDbType.VarChar).Value = PS - .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion - .Add("@AplicaParaVenta", SqlDbType.Int).Value = pAplicaParaVenta - .Add("@Estado", SqlDbType.Int).Value = pEstado - .Add("@CveTipoPS", SqlDbType.Int).Value = CveTipoPS - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@UsoClasificacion", SqlDbType.Int).Value = UsoClasificacion - End With - - Try - SqlAdapter.Fill(Data) - - Retorno = True - Catch ex As SqlException - If CvePS <> -1 Then - OnError("Ocurrió un error al consultar El Producto o Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - Else - OnError("Ocurrió un error al consultar El Producto o Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End If - End Try - - Return Retorno - End Function - Public Function GetPSClasificados(CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_ProductosServiciosClasificadosGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - - End With - Try - SqlAdapter.Fill(Data) - - Retorno = True - Catch ex As SqlException - If CvePS <> -1 Then - OnError("Ocurrió un error al consultar El Producto o Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - Else - OnError("Ocurrió un error al consultar El Producto o Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End If - End Try - Return Retorno - End Function - Public Function AddPS(CveClasificacion As Integer, CveClasificacionCosto As Integer, CveUnidadMedida As Integer, Codigo As String, Codigo2 As String, CodigoBarras As String, PS As String, Precio As Double, IVA As Double, RetIVA As Double, Inventariable As Boolean, CveProveedorCompra As Integer, - AplicaParaConcepto As Boolean, AplicaParaVenta As Boolean, CveUsuario As Integer, CveEmpresa As Integer, CveMetodoInventario As Integer, EsPaquete As Integer, - Optional CveTipoPS As Integer = -1, Optional FuePorXML As Boolean = True, Optional TipoServicio As Integer = -1, Optional CveClasificacion2 As Integer = -1, - Optional CveMarca As Integer = -1, Optional AlmacenSeccion As String = "", Optional AplicaIEPS As Boolean = False, Optional IEPSPorcentaje As Decimal = -1, - Optional CveConceptoContable As Integer = -1, Optional CveCompuesto As Integer = -1, Optional CveSATPS As Integer = -1, Optional IEPSGrabaIVA As Boolean = False, Optional VentaMinima As Decimal = 0, - Optional CveMoneda As Integer = 1, Optional RetISR As Double = 0, Optional PrecioMinimo As Decimal = Nothing, Optional CveTipoFactor As Integer = 1, - Optional CveFraccionArancelaria As Integer = -1, Optional CveClasificacionDetalle As Integer = -1, Optional CveTamaño As Integer = -1, - Optional CveModelo As Integer = -1, Optional CveMedida As Integer = -1, Optional CveRinTamaño As Integer = -1, Optional ClaveImpuestoEmpaque As String = "", Optional ClaveImpuestoUM As String = "", - Optional ClaveCategoriaToxicidad As String = "", Optional ClaveImpuestoTipoProducto As String = "", Optional Litraje As Double = -1, Optional EsOutSourcing As Boolean = False, Optional AplicaSerie As Boolean = False, Optional AplicaLote As Boolean = False, - Optional AplicaCaducidad As Boolean = False, Optional AplicaSeccion As Boolean = False, Optional TiempoCaducidad As Integer = -1, Optional CvePSAdicionalVigencia As Integer = -1) As Integer - Dim Retorno As Integer = -1 - - DataAdapter("PA_ProductosServiciosAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion - .Add("@CveClasificacionCosto", SqlDbType.Int).Value = CveClasificacionCosto - .Add("@CveUnidadMedida", SqlDbType.Int).Value = CveUnidadMedida - .Add("@Codigo", SqlDbType.VarChar).Value = Codigo - .Add("@Codigo2", SqlDbType.VarChar).Value = If(Codigo2 = "", "-1", Codigo2) - .Add("@CodigoBarras", SqlDbType.VarChar).Value = If(CodigoBarras = "", "-1", CodigoBarras) - .Add("@PS", SqlDbType.VarChar).Value = If(PS.Length > 845, PS.Substring(0, 845), PS) - .Add("@Precio", SqlDbType.Float).Value = Precio - .Add("@IVA", SqlDbType.Float).Value = IVA - .Add("@RetIVA", SqlDbType.Float).Value = RetIVA - .Add("@AplicaParaConcepto", SqlDbType.Bit).Value = AplicaParaConcepto - .Add("@AplicaParaVenta", SqlDbType.Bit).Value = AplicaParaVenta - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@EsPaquete", SqlDbType.Bit).Value = EsPaquete - .Add("@CveMetodoInventario", SqlDbType.Int).Value = CveMetodoInventario - .Add("@RETURN_VALUE", SqlDbType.Int).Direction = ParameterDirection.ReturnValue - .Add("@CveTipoPS", SqlDbType.Int).Value = CveTipoPS - .Add("@FuePorXML", SqlDbType.Bit).Value = If(FuePorXML, 1, 0) - .Add("@TipoServicio", SqlDbType.Int).Value = TipoServicio - .Add("@CveClasificacion2", SqlDbType.Int).Value = CveClasificacion2 - .Add("@CveMarca", SqlDbType.Int).Value = CveMarca - .Add("@AlmacenSeccion", SqlDbType.VarChar).Value = AlmacenSeccion - .Add("@AplicaIEPS", SqlDbType.Bit).Value = AplicaIEPS - .Add("@IEPSGrabaIVA", SqlDbType.Bit).Value = IEPSGrabaIVA - .Add("@IEPSPorcentaje", SqlDbType.SmallMoney).Value = IEPSPorcentaje - .Add("@CveConceptoContable", SqlDbType.Int).Value = CveConceptoContable - .Add("@CveCompuesto", SqlDbType.Int).Value = CveCompuesto - .Add("@CveSATPS", SqlDbType.Int).Value = CveSATPS - - 'Nuevo R: 26/09/2017' - .Add("@Inventariable", SqlDbType.Bit).Value = Inventariable - .Add("@CveProveedorCompra", SqlDbType.Int).Value = CveProveedorCompra - .Add("@VentaMinima", SqlDbType.Decimal).Value = VentaMinima - - 'Nuevo R: 08/11/2017' - .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda - - 'Nuevo R: 30/11/2017 - .Add("@RetISR", SqlDbType.Float).Value = RetISR - - - 'Nuevo Oscar 29/12/2017 - .Add("@PrecioMinimo", SqlDbType.Money).Value = PrecioMinimo - - 'Nuevo Rigo 12/01/2018 - .Add("@CveTipoFactor", SqlDbType.Int).Value = CveTipoFactor - - 'Nuevo Raul 08/03/2018 - .Add("@CveFraccionArancelaria", SqlDbType.Int).Value = CveFraccionArancelaria - - 'Nuevo Raul 11/09/2018 - .Add("@CveClasificacionDetalle", SqlDbType.Int).Value = CveClasificacionDetalle - - 'Nuevo Oscar 31/10/2018 - .Add("@CveTamaño", SqlDbType.Int).Value = CveTamaño - - 'Nuevo Happy 25/04/2019 - .Add("@CveModelo", SqlDbType.Int).Value = CveModelo - .Add("@CveMedida", SqlDbType.Int).Value = CveMedida - .Add("@CveRinTamaño", SqlDbType.Int).Value = CveRinTamaño - - .Add("@ClaveImpuestoTipoProducto", SqlDbType.VarChar).Value = ClaveImpuestoTipoProducto - .Add("@ClaveImpuestoEmpaque", SqlDbType.VarChar).Value = ClaveImpuestoEmpaque - .Add("@ClaveImpuestoUM", SqlDbType.VarChar).Value = ClaveImpuestoUM - .Add("@ClaveCategoriaToxicidad", SqlDbType.VarChar).Value = ClaveCategoriaToxicidad - .Add("@Litraje", SqlDbType.Float).Value = Litraje - .Add("@EsOutSourcing", SqlDbType.Bit).Value = EsOutSourcing - - .Add("@AplicaSerie", SqlDbType.Bit).Value = AplicaSerie - .Add("@AplicaLote", SqlDbType.Bit).Value = AplicaLote - .Add("@AplicaCaducidad", SqlDbType.Bit).Value = AplicaCaducidad - .Add("@AplicaSeccion", SqlDbType.Bit).Value = AplicaSeccion +Option Explicit On +Option Strict On + +Imports System.Data +Imports System.Data.SqlClient +Imports Extensiones +Imports System +Imports System.Configuration +Imports Modelos + +Public Class ClsProductosServicios + Implements IDisposable + +#Region "Campos" + Private SqlConexion As SqlConnection + Private SqlAdapter As SqlDataAdapter + Private SqlCommand As SqlCommand + Private SqlTransacc As SqlTransaction + Private Data As DataTable + Private disposedValue As Boolean = False + 'PARA REGISTRAR CONEXION + Private CveConexion As Integer = 0 + Private EsTransaccionCompartida As Boolean = False +#End Region + +#Region "Propiedades" + + Public Property CvePS As Integer + Public Property CveClasificacion As Integer + Public Property Clasificacion As String + Public Property CveUnidadMedida As Integer + Public Property CveSATPS As Integer + Public Property SATClavePS As String + Public Property SATDescripcion As String + Public Property Codigo As String + Public Property Codigo2 As String + Public Property CodigoBarras As String + Public Property PS As String + Public Property Precio As Double + Public Property PrecioMinimo As Double + Public Property Oferta As Double + Public Property IVA As Double + Public Property RetIVA As Double + Public Property MargenGanancia As Double + 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 Estado As Boolean + Public Property Fecha As Date + Public Property Usuario As String + Public Property CveEmpresa As Integer + Public Property CveMetodoInventario As Integer + Public Property CveTipoPS As Integer + Public Property Estado2 As Integer + Public Property CveMarca As Integer + + Public Property IEPSPorcentaje As Double + + Public Property AplicaIEPS As Boolean + Public Property IEPSGrabaIVA As Boolean + + Public Property AplicaSerie As Boolean + Public Property AplicaLote As Boolean + Public Property AplicaCaducidad As Boolean + Public Property AplicaSeccion As Boolean + + Public Property CveConceptoContable As Integer + + 'Nuevo R: 26/09/2017' + Public Property Inventariable As Boolean + Public Property CveProveedorCompra As Integer + Public Property ProveedorCompra As String + Public Property VentaMinima As Decimal + Public Property CveMoneda As Integer + Public Property RetISR As Double + + + 'Nuevo Rjb: 12/01/2018' + Public Property CveTipoFactor As Integer + + 'Nuevo Raul: 08/03/2018 + Public Property CveFraccionArancelaria As Integer + Public Property CveUnidadAduana As Integer + Public Property ClaveSATFraccionArancelariaDescripcion As String + Public Property ClaveSATUnidadAduanaDescripcion As String + Public Property ClaveSATFraccionArancelaria As String + Public Property ClaveSATUnidadAduana As String + + 'Nuevo Raul: 10/08/2018 + Public Property CveUsuarioModifico As Integer + Public Property UsuarioModifico As String + Public Property FechaUltimaModificacion As Date + + 'Nuevo Raul: 11/09/2018 + Public Property CveClasificacionDetalle As Integer + Public Property ClaveImpuestoTipoProducto As String + Public Property ClaveImpuestoEmpaque As String + Public Property ClaveImpuestoUnidadMedida As String + Public Property ClaveCategoriaToxicidad As String + + Public Property EsOutSourcing As Boolean + Public Property PrecioLibre As Boolean + + Public ReadOnly Property DtResultados() As DataTable + Get + DtResultados = Data + End Get + End Property +#End Region + + + Sub New() + SqlConexion = New SqlConnection + SqlConexion.ConnectionString = ConfigurationManager.ConnectionStrings("Conexion").ConnectionString + SqlAdapter = New SqlDataAdapter("", SqlConexion) + Try + SqlConexion.Open() + Catch ex As Exception + OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex) + End Try + ConexionAdd() + End Sub + + + Public Function IniciaTransacSQL() As SqlTransaction + If SqlTransacc Is Nothing Then SqlTransacc = SqlConexion.BeginTransaction() + + Return SqlTransacc + End Function + Public Sub RollBack() + SqlTransacc.Rollback() + End Sub + Public Sub Commit() + SqlTransacc.Commit() + End Sub + + Sub New(Optional TransaccionCompartida As SqlTransaction = Nothing) + + If TransaccionCompartida Is Nothing Then + SqlConexion = New SqlConnection + SqlConexion.ConnectionString = ConfigurationManager.ConnectionStrings("Conexion").ConnectionString + Try + SqlConexion.Open() + Catch ex As Exception + OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex) + End Try + Else + SqlConexion = TransaccionCompartida.Connection + SqlTransacc = TransaccionCompartida + EsTransaccionCompartida = True + End If + + SqlAdapter = New SqlDataAdapter("", SqlConexion) + ConexionAdd() + End Sub + Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) + With SqlAdapter.SelectCommand + .Parameters.Clear() + .CommandText = StrSQL + .CommandType = TipoComando + End With + If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc + Data = New DataTable + End Sub +#Region "Conexiones" + + Private Sub ConexionAdd() + If Not EsTransaccionCompartida AndAlso ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + + + Try + 'DataAdapter(String.Format("INSERT INTO Sis_Conexiones (Clase,Modulo) VALUES ('ClsRH','{0}')", "RH/CatMotivosBaja"), CommandType.Text) ' pendiente de terminar parra registrar el cveconexion, falta el rarámetro de módulo + DataAdapter("PA_Sis_RegistrarConexion") + With SqlAdapter.SelectCommand.Parameters + .Add("@Clase", SqlDbType.VarChar).Value = Me.GetType().Name + .Add("@Modulo", SqlDbType.VarChar).Value = String.Format("{0}?{1}", HttpContext.Current.Request.Url.AbsolutePath.ToString, HttpContext.Current.Request.QueryString.ToString) + .Add("@IDConexion", SqlDbType.Int).Direction = ParameterDirection.Output + End With + SqlAdapter.Fill(Data) + CveConexion = SqlAdapter.SelectCommand.Parameters("@IDConexion").Value.ToString.ToEntero + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + End Sub + + Private Sub ConexionClose() + If CveConexion > 0 AndAlso ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + + DataAdapter(String.Format("UPDATE Sis_Conexiones SET FechaCierre = GETDATE() WHERE CveConexion = {0}", CveConexion), CommandType.Text) + + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + CveConexion = 0 + End If + + End Sub +#End Region + Public Function GetPS(CvePS As Integer, CveClasificacion As Integer, CveEmpresa As Integer, Optional Codigo As String = "-1", Optional Codigo2 As String = "-1", + Optional CodigoBarras As String = "-1", Optional PS As String = "-1", Optional EsPaquete As Integer = -1, Optional CveSubProyecto As Integer = -1, + Optional pAplicaParaVenta As Integer = -1, Optional pEstado As Integer = -1, Optional CveClasificacionCosto As Integer = -1, Optional CveTipoPS As Integer = -1, + Optional CveCompuesto As Integer = -1, Optional SATClavePS As String = "-1", Optional TopSelect As Integer = 10000) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_ProductosServiciosGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@Codigo", SqlDbType.VarChar).Value = Codigo + .Add("@Codigo2", SqlDbType.VarChar).Value = Codigo2 + .Add("@CodigoBarras", SqlDbType.VarChar).Value = CodigoBarras + .Add("@PS", SqlDbType.VarChar).Value = PS + .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion + .Add("@EsPaquete", SqlDbType.SmallInt).Value = EsPaquete + .Add("@AplicaParaVenta", SqlDbType.Int).Value = pAplicaParaVenta + .Add("@Estado", SqlDbType.Int).Value = pEstado + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveClasificacionCosto", SqlDbType.Int).Value = CveClasificacionCosto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveTipoPS", SqlDbType.Int).Value = CveTipoPS + .Add("@CveCompuesto", SqlDbType.Int).Value = CveCompuesto + .Add("@SATClavePS", SqlDbType.VarChar).Value = SATClavePS + .Add("@TopSelect", SqlDbType.Int).Value = TopSelect + End With + + Try + SqlAdapter.Fill(Data) + If Data.Rows.Count > 0 Then + Me.CvePS = Data.Rows(0)("CvePS").ToString().ToEntero + Me.CveClasificacion = Data.Rows(0)("CveClasificacion").ToString.ToEntero + Me.Clasificacion = Data.Rows(0)("Clasificacion").ToString + CveUnidadMedida = Data.Rows(0)("CveUnidadMedida").ToString.ToEntero + CveSATPS = Data.Rows(0)("CveSATPS").ToString.ToEntero + Me.SATClavePS = Data.Rows(0)("SATClavePS").ToString + 'SATDescripcion = Data.Rows(0)("SATDescripcion").ToString + Me.CveTipoPS = Data.Rows(0)("CveTipoPS").ToString.ToEntero + Me.Codigo = Data.Rows(0)("Codigo").ToString + Me.Codigo2 = Data.Rows(0)("Codigo2").ToString + Me.CodigoBarras = Data.Rows(0)("CodigoBarras").ToString + Me.PS = Data.Rows(0)("PS").ToString + Precio = Data.Rows(0)("Precio").ToString.ToDouble + PrecioMinimo = Data.Rows(0)("PrecioMinimo").ToString.ToDouble + Oferta = Data.Rows(0)("Oferta").ToString.ToDouble + IVA = Data.Rows(0)("IVA").ToString.ToDouble + RetIVA = Data.Rows(0)("RetIVA").ToString.ToDouble + CveMarca = Data.Rows(0)("CveMarca").ToString.ToEntero + AplicaParaConcepto = CBool(Data.Rows(0)("AplicaParaConcepto").ToString) + AplicaParaVenta = Data.Rows(0)("AplicaParaVenta").ToString = "True" + Estado = Data.Rows(0)("Estado").ToString = "Activo" + Estado2 = Data.Rows(0)("Estado2").ToString.ToEntero + Fecha = Data.Rows(0)("Fecha").ToString.ToDate + Usuario = Data.Rows(0)("Usuario").ToString + + 'AlmacenSeccion = Data.Rows(0)("AlmacenSeccion").ToString + AplicaIEPS = (Data.Rows(0)("AplicaIEPS").ToString) = "True" + IEPSGrabaIVA = (Data.Rows(0)("IEPSGrabaIVA").ToString) = "True" + IEPSPorcentaje = Data.Rows(0)("IEPSPorcentaje").ToString.ToDouble + CveConceptoContable = Data.Rows(0)("CveConceptoContable").ToString.ToEntero + + AplicaSerie = (Data.Rows(0)("AplicaSerie").ToString) = "True" + AplicaLote = (Data.Rows(0)("AplicaLote").ToString) = "True" + AplicaCaducidad = (Data.Rows(0)("AplicaCaducidad").ToString) = "True" + AplicaSeccion = (Data.Rows(0)("AplicaSeccion").ToString) = "True" + + 'Nuevo R: 26/09/2017' + + Inventariable = Data.Rows(0)("Inventariable").ToString = "True" + CveProveedorCompra = Data.Rows(0)("CveProveedorCompra").ToString.ToEntero + ProveedorCompra = Data.Rows(0)("ProveedorCompra").ToString + + 'Nuevo R: 12/01/2018' + CveTipoFactor = Data.Rows(0)("CveTipoFactor").ToString.ToEntero + + Me.CveEmpresa = Data.Rows(0)("CveEmpresa").ToString.ToEntero + CveMetodoInventario = Data.Rows(0)("Inv_CveMetodoInventario").ToString.ToEntero + VentaMinima = Data.Rows(0)("VentaMinima").ToString.ToDecimal + CveMoneda = Data.Rows(0)("CveMoneda").ToString.ToEntero + RetISR = Data.Rows(0)("RetISR").ToString.ToDouble + + 'Nuevo Raul: 08/03/2018 + CveFraccionArancelaria = Data.Rows(0)("CveFraccionArancelaria").ToString.ToEntero + CveUnidadAduana = Data.Rows(0)("CveUnidadAduana").ToString.ToEntero + ClaveSATFraccionArancelaria = Data.Rows(0)("ClaveSATFraccionArancelaria").ToString + ClaveSATUnidadAduana = Data.Rows(0)("ClaveSATUnidadAduana").ToString + ClaveSATFraccionArancelariaDescripcion = Data.Rows(0)("ClaveSATFraccionArancelariaDescripcion").ToString + ClaveSATUnidadAduanaDescripcion = Data.Rows(0)("ClaveSATUnidadAduanaDescripcion").ToString + + 'Nuevo Raul: 10/08/2018 + CveUsuarioModifico = Data.Rows(0)("CveUsuarioModifico").ToString.ToEntero + UsuarioModifico = Data.Rows(0)("UsuarioModifico").ToString + FechaUltimaModificacion = Data.Rows(0)("FechaUltimaModificacion").ToString.ToDate + + 'Nuevo Raul: 11/09/2018 + CveClasificacionDetalle = Data.Rows(0)("CveClasificacionDetalle").ToString.ToEntero + + ClaveImpuestoTipoProducto = Data.Rows(0)("ClaveImpuestoTipoProducto").ToString + ClaveImpuestoEmpaque = Data.Rows(0)("ClaveImpuestoEmpaque").ToString + ClaveImpuestoUnidadMedida = Data.Rows(0)("ClaveImpuestoUM").ToString + ClaveCategoriaToxicidad = Data.Rows(0)("ClaveCategoriaToxicidad").ToString + EsOutSourcing = Data.Rows(0)("EsOutSourcing").ToString = "True" + EsOutSourcing = Data.Rows(0)("PrecioLibre").ToString = "True" + + End If + Retorno = True + Catch ex As SqlException + If CvePS <> -1 Then + OnError("Ocurrió un error al consultar El Producto o Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + Else + OnError("Ocurrió un error al consultar El Producto o Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End If + End Try + + Return Retorno + End Function + Public Function GetPSSimplificado(CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_ProductosServiciosSimplificadoGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + + End With + + Try + SqlAdapter.Fill(Data) + + Retorno = True + Catch ex As SqlException + If CvePS <> -1 Then + OnError("Ocurrió un error al consultar El Producto o Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + Else + OnError("Ocurrió un error al consultar El Producto o Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End If + End Try + + Return Retorno + End Function + Public Function GetPSLite(CveClasificacion As Integer, CveEmpresa As Integer, Optional Codigo As String = "-1", Optional CodigoBarras As String = "-1", Optional PS As String = "-1", Optional pAplicaParaVenta As Integer = -1, Optional pEstado As Integer = -1, Optional CveTipoPS As Integer = -1, Optional UsoClasificacion As Integer = -1) As Boolean + Dim Retorno As Boolean = False + ' @CveClasificacion int, @Codigo varchar(50) = '-1', @PS varchar(300) = '-1', @AplicaParaVenta int = -1, @Estado int = -1, @CodigoBarras varchar(50) = '-1', @CveTipoPS int = -1, @CveEmpresa int + DataAdapter("PA_ProductosServiciosLiteGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Codigo", SqlDbType.VarChar).Value = Codigo + .Add("@CodigoBarras", SqlDbType.VarChar).Value = CodigoBarras + .Add("@PS", SqlDbType.VarChar).Value = PS + .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion + .Add("@AplicaParaVenta", SqlDbType.Int).Value = pAplicaParaVenta + .Add("@Estado", SqlDbType.Int).Value = pEstado + .Add("@CveTipoPS", SqlDbType.Int).Value = CveTipoPS + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@UsoClasificacion", SqlDbType.Int).Value = UsoClasificacion + End With + + Try + SqlAdapter.Fill(Data) + + Retorno = True + Catch ex As SqlException + If CvePS <> -1 Then + OnError("Ocurrió un error al consultar El Producto o Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + Else + OnError("Ocurrió un error al consultar El Producto o Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End If + End Try + + Return Retorno + End Function + Public Function GetPSClasificados(CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_ProductosServiciosClasificadosGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + + End With + Try + SqlAdapter.Fill(Data) + + Retorno = True + Catch ex As SqlException + If CvePS <> -1 Then + OnError("Ocurrió un error al consultar El Producto o Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + Else + OnError("Ocurrió un error al consultar El Producto o Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End If + End Try + Return Retorno + End Function + Public Function AddPS(CveClasificacion As Integer, CveClasificacionCosto As Integer, CveUnidadMedida As Integer, Codigo As String, Codigo2 As String, CodigoBarras As String, PS As String, Precio As Double, IVA As Double, RetIVA As Double, Inventariable As Boolean, CveProveedorCompra As Integer, + AplicaParaConcepto As Boolean, AplicaParaVenta As Boolean, CveUsuario As Integer, CveEmpresa As Integer, CveMetodoInventario As Integer, EsPaquete As Integer, + Optional CveTipoPS As Integer = -1, Optional FuePorXML As Boolean = True, Optional TipoServicio As Integer = -1, Optional CveClasificacion2 As Integer = -1, + Optional CveMarca As Integer = -1, Optional AlmacenSeccion As String = "", Optional AplicaIEPS As Boolean = False, Optional IEPSPorcentaje As Decimal = -1, + Optional CveConceptoContable As Integer = -1, Optional CveCompuesto As Integer = -1, Optional CveSATPS As Integer = -1, Optional IEPSGrabaIVA As Boolean = False, Optional VentaMinima As Decimal = 0, + Optional CveMoneda As Integer = 1, Optional RetISR As Double = 0, Optional PrecioMinimo As Decimal = Nothing, Optional CveTipoFactor As Integer = 1, + Optional CveFraccionArancelaria As Integer = -1, Optional CveClasificacionDetalle As Integer = -1, Optional CveTamaño As Integer = -1, + Optional CveModelo As Integer = -1, Optional CveMedida As Integer = -1, Optional CveRinTamaño As Integer = -1, Optional ClaveImpuestoEmpaque As String = "", Optional ClaveImpuestoUM As String = "", + Optional ClaveCategoriaToxicidad As String = "", Optional ClaveImpuestoTipoProducto As String = "", Optional Litraje As Double = -1, Optional EsOutSourcing As Boolean = False, Optional AplicaSerie As Boolean = False, Optional AplicaLote As Boolean = False, + Optional AplicaCaducidad As Boolean = False, Optional AplicaSeccion As Boolean = False, Optional TiempoCaducidad As Integer = -1, Optional CvePSAdicionalVigencia As Integer = -1, Optional PrecioLibre As Boolean = False) As Integer + Dim Retorno As Integer = -1 + + DataAdapter("PA_ProductosServiciosAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion + .Add("@CveClasificacionCosto", SqlDbType.Int).Value = CveClasificacionCosto + .Add("@CveUnidadMedida", SqlDbType.Int).Value = CveUnidadMedida + .Add("@Codigo", SqlDbType.VarChar).Value = Codigo + .Add("@Codigo2", SqlDbType.VarChar).Value = If(Codigo2 = "", "-1", Codigo2) + .Add("@CodigoBarras", SqlDbType.VarChar).Value = If(CodigoBarras = "", "-1", CodigoBarras) + .Add("@PS", SqlDbType.VarChar).Value = If(PS.Length > 845, PS.Substring(0, 845), PS) + .Add("@Precio", SqlDbType.Float).Value = Precio + .Add("@IVA", SqlDbType.Float).Value = IVA + .Add("@RetIVA", SqlDbType.Float).Value = RetIVA + .Add("@AplicaParaConcepto", SqlDbType.Bit).Value = AplicaParaConcepto + .Add("@AplicaParaVenta", SqlDbType.Bit).Value = AplicaParaVenta + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@EsPaquete", SqlDbType.Bit).Value = EsPaquete + .Add("@CveMetodoInventario", SqlDbType.Int).Value = CveMetodoInventario + .Add("@RETURN_VALUE", SqlDbType.Int).Direction = ParameterDirection.ReturnValue + .Add("@CveTipoPS", SqlDbType.Int).Value = CveTipoPS + .Add("@FuePorXML", SqlDbType.Bit).Value = If(FuePorXML, 1, 0) + .Add("@TipoServicio", SqlDbType.Int).Value = TipoServicio + .Add("@CveClasificacion2", SqlDbType.Int).Value = CveClasificacion2 + .Add("@CveMarca", SqlDbType.Int).Value = CveMarca + .Add("@AlmacenSeccion", SqlDbType.VarChar).Value = AlmacenSeccion + .Add("@AplicaIEPS", SqlDbType.Bit).Value = AplicaIEPS + .Add("@IEPSGrabaIVA", SqlDbType.Bit).Value = IEPSGrabaIVA + .Add("@IEPSPorcentaje", SqlDbType.SmallMoney).Value = IEPSPorcentaje + .Add("@CveConceptoContable", SqlDbType.Int).Value = CveConceptoContable + .Add("@CveCompuesto", SqlDbType.Int).Value = CveCompuesto + .Add("@CveSATPS", SqlDbType.Int).Value = CveSATPS + + 'Nuevo R: 26/09/2017' + .Add("@Inventariable", SqlDbType.Bit).Value = Inventariable + .Add("@CveProveedorCompra", SqlDbType.Int).Value = CveProveedorCompra + .Add("@VentaMinima", SqlDbType.Decimal).Value = VentaMinima + + 'Nuevo R: 08/11/2017' + .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda + + 'Nuevo R: 30/11/2017 + .Add("@RetISR", SqlDbType.Float).Value = RetISR + + + 'Nuevo Oscar 29/12/2017 + .Add("@PrecioMinimo", SqlDbType.Money).Value = PrecioMinimo + + 'Nuevo Rigo 12/01/2018 + .Add("@CveTipoFactor", SqlDbType.Int).Value = CveTipoFactor + + 'Nuevo Raul 08/03/2018 + .Add("@CveFraccionArancelaria", SqlDbType.Int).Value = CveFraccionArancelaria + + 'Nuevo Raul 11/09/2018 + .Add("@CveClasificacionDetalle", SqlDbType.Int).Value = CveClasificacionDetalle + + 'Nuevo Oscar 31/10/2018 + .Add("@CveTamaño", SqlDbType.Int).Value = CveTamaño + + 'Nuevo Happy 25/04/2019 + .Add("@CveModelo", SqlDbType.Int).Value = CveModelo + .Add("@CveMedida", SqlDbType.Int).Value = CveMedida + .Add("@CveRinTamaño", SqlDbType.Int).Value = CveRinTamaño + + .Add("@ClaveImpuestoTipoProducto", SqlDbType.VarChar).Value = ClaveImpuestoTipoProducto + .Add("@ClaveImpuestoEmpaque", SqlDbType.VarChar).Value = ClaveImpuestoEmpaque + .Add("@ClaveImpuestoUM", SqlDbType.VarChar).Value = ClaveImpuestoUM + .Add("@ClaveCategoriaToxicidad", SqlDbType.VarChar).Value = ClaveCategoriaToxicidad + .Add("@Litraje", SqlDbType.Float).Value = Litraje + .Add("@EsOutSourcing", SqlDbType.Bit).Value = EsOutSourcing + + .Add("@AplicaSerie", SqlDbType.Bit).Value = AplicaSerie + .Add("@AplicaLote", SqlDbType.Bit).Value = AplicaLote + .Add("@AplicaCaducidad", SqlDbType.Bit).Value = AplicaCaducidad + .Add("@AplicaSeccion", SqlDbType.Bit).Value = AplicaSeccion .Add("@TiempoCaducidad", SqlDbType.SmallInt).Value = TiempoCaducidad - .Add("@CvePSAdicionalVigencia", SqlDbType.Int).Value = CvePSAdicionalVigencia - End With - - Try - SqlAdapter.Fill(Data) - _CvePS = SqlAdapter.SelectCommand.Parameters("@RETURN_VALUE").Value.ToString.ToEntero - Retorno = _CvePS - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 2627;") Then - Alert("El Nuevo Producto o Servicio no se guardo debido a que actualmente se encuentra registrado", TipoMensaje.MsgAdvertencia) - ElseIf Ex1.Message.Contains("Número: 2601;") Then - Alert("El Nuevo Producto o Servicio tiene Codigo duplicado:" & Codigo, TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al guardar el nuevo Producto o Servicio.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - OnError("Ocurrió un error al guardar el nuevo Producto o Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function AddPSApp(PS As MProductoServicio) As Integer - Dim Retorno As Integer = -1 - - DataAdapter("PA_ProductosServiciosAppAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveClasificacion", SqlDbType.Int).Value = PS.CveClasificacion - .Add("@CveClasificacionCosto", SqlDbType.Int).Value = PS.CveClasificacionCosto - .Add("@CveUnidadMedida", SqlDbType.Int).Value = PS.CveUnidadMedida - .Add("@Codigo", SqlDbType.VarChar).Value = PS.Codigo - .Add("@Codigo2", SqlDbType.VarChar).Value = If(PS.Codigo2 = "", "-1", PS.Codigo2) - .Add("@CodigoBarras", SqlDbType.VarChar).Value = If(PS.CodigoBarras = "", "-1", PS.CodigoBarras) - .Add("@PS", SqlDbType.VarChar).Value = If(PS.PS.Length > 845, PS.PS.Substring(0, 845), PS.PS) - .Add("@Precio", SqlDbType.Float).Value = PS.Precio - .Add("@IVA", SqlDbType.Float).Value = PS.IVA - .Add("@RetIVA", SqlDbType.Float).Value = PS.RetIVA - .Add("@AplicaParaConcepto", SqlDbType.Bit).Value = PS.AplicaParaConcepto - .Add("@AplicaParaVenta", SqlDbType.Bit).Value = PS.AplicaParaVenta - .Add("@CveUsuario", SqlDbType.Int).Value = PS.CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = PS.CveEmpresa - .Add("@EsPaquete", SqlDbType.Bit).Value = PS.EsPaquete - .Add("@CveMetodoInventario", SqlDbType.Int).Value = PS.CveMetodoInventario - .Add("@RETURN_VALUE", SqlDbType.Int).Direction = ParameterDirection.ReturnValue - .Add("@CveTipoPS", SqlDbType.Int).Value = PS.CveTipoPS - .Add("@FuePorXML", SqlDbType.Bit).Value = PS.FuePorXML - .Add("@TipoServicio", SqlDbType.Int).Value = PS.TipoServicio - .Add("@CveClasificacion2", SqlDbType.Int).Value = PS.CveClasificacion2 - .Add("@CveMarca", SqlDbType.Int).Value = PS.CveMarca - .Add("@AlmacenSeccion", SqlDbType.VarChar).Value = PS.AlmacenSeccion - .Add("@AplicaIEPS", SqlDbType.Bit).Value = PS.AplicaIEPS - .Add("@IEPSGrabaIVA", SqlDbType.Bit).Value = PS.IEPSGrabaIVA - .Add("@IEPSPorcentaje", SqlDbType.SmallMoney).Value = PS.IEPSPorcentaje - .Add("@CveConceptoContable", SqlDbType.Int).Value = PS.CveConceptoContable - .Add("@CveCompuesto", SqlDbType.Int).Value = PS.CveCompuesto - .Add("@CveSATPS", SqlDbType.Int).Value = PS.CveSATPS - - 'Nuevo R: 26/09/2017' - .Add("@Inventariable", SqlDbType.Bit).Value = PS.Inventariable - .Add("@CveProveedorCompra", SqlDbType.Int).Value = PS.CveProveedorCompra - .Add("@VentaMinima", SqlDbType.Decimal).Value = PS.VentaMinima - - 'Nuevo R: 08/11/2017' - .Add("@CveMoneda", SqlDbType.Int).Value = PS.CveMoneda - - 'Nuevo R: 30/11/2017 - .Add("@RetISR", SqlDbType.Float).Value = PS.RetISR - - - 'Nuevo Oscar 29/12/2017 - .Add("@PrecioMinimo", SqlDbType.Money).Value = PS.PrecioMinimo - - 'Nuevo Rigo 12/01/2018 - .Add("@CveTipoFactor", SqlDbType.Int).Value = PS.CveTipoFactor - - 'Nuevo Raul 08/03/2018 - .Add("@CveFraccionArancelaria", SqlDbType.Int).Value = PS.CveFraccionArancelaria - - 'Nuevo Raul 11/09/2018 - .Add("@CveClasificacionDetalle", SqlDbType.Int).Value = PS.CveClasificacionDetalle - - 'Nuevo Oscar 31/10/2018 - .Add("@CveTamaño", SqlDbType.Int).Value = PS.CveTamaño - - End With - - Try - SqlAdapter.Fill(Data) - _CvePS = SqlAdapter.SelectCommand.Parameters("@RETURN_VALUE").Value.ToString.ToEntero - Retorno = _CvePS - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 2627;") Then - Alert("El Nuevo Producto o Servicio no se guardo debido a que actualmente se encuentra registrado", TipoMensaje.MsgAdvertencia) - ElseIf Ex1.Message.Contains("Número: 2601;") Then - Alert("El Nuevo Producto o Servicio tiene Codigo duplicado.", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al guardar el nuevo Producto o Servicio.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - OnError("Ocurrió un error al guardar el nuevo Producto o Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function AddPSSimplificado(PS As MProductoServicio) As Integer - Dim Retorno As Integer = -1 - - DataAdapter("PA_ProductosServiciosSimplificadoAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveClasificacion", SqlDbType.Int).Value = PS.CveClasificacion - .Add("@CveUnidadMedida", SqlDbType.Int).Value = PS.CveUnidadMedida - .Add("@Codigo", SqlDbType.VarChar).Value = PS.Codigo - .Add("@PS", SqlDbType.VarChar).Value = If(PS.PS.Length > 845, PS.PS.Substring(0, 845), PS.PS) - .Add("@AplicaParaVenta", SqlDbType.Bit).Value = PS.AplicaParaVenta - .Add("@CveTipoPS", SqlDbType.Int).Value = PS.CveTipoPS - .Add("@CveUsuario", SqlDbType.Int).Value = PS.CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = PS.CveEmpresa - .Add("@RETURN_VALUE", SqlDbType.Int).Direction = ParameterDirection.ReturnValue - End With - - Try - SqlAdapter.Fill(Data) - _CvePS = SqlAdapter.SelectCommand.Parameters("@RETURN_VALUE").Value.ToString.ToEntero - Retorno = _CvePS - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 2627;") Then - Alert("El Nuevo Producto o Servicio no se guardo debido a que actualmente se encuentra registrado", TipoMensaje.MsgAdvertencia) - ElseIf Ex1.Message.Contains("Número: 2601;") Then - Alert("El Nuevo Producto o Servicio tiene Codigo duplicado.", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al guardar el nuevo Producto o Servicio.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - OnError("Ocurrió un error al guardar el nuevo Producto o Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function UpdatePS(CveClasificacion As Integer, CveClasificacionCosto As Integer, CveUnidadMedida As Integer, Codigo As String, Codigo2 As String, CodigoBarras As String, PS As String, Precio As Double, IVA As Double, RetIVA As Double, Inventariable As Boolean, CveProveedorCompra As Integer, - AplicaParaConcepto As Boolean, AplicaParaVenta As Boolean, Estado As Boolean, CveUsuario As Integer, CvePS As Integer, CveMetodoInventario As Integer, EsPaquete As Integer, CveSATPS As Integer, Optional CveTipoPS As Integer = -1, Optional TipoServicio As Integer = -1, - Optional CveClasificacion2 As Integer = -1, Optional CveMarca As Integer = -1, Optional AlmacenSeccion As String = "", Optional AplicaIEPS As Boolean = False, Optional IEPSPorcentaje As Decimal = -1, - Optional CveConceptoContable As Integer = -1, Optional CveCompuesto As Integer = -1, Optional IEPSGrabaIVA As Boolean = False, Optional VentaMinima As Decimal = 0, - Optional CveMoneda As Integer = 1, Optional RetISR As Double = 0, Optional PrecioMinimo As Decimal = Nothing, Optional CveTipoFactor As Integer = 1, - Optional CveFraccionArancelaria As Integer = -1, Optional CveUsuarioModifico As Integer = -1, - Optional CveClasificacionDetalle As Integer = -1, Optional CveTamaño As Integer = -1, Optional CveModelo As Integer = -1, Optional CveMedida As Integer = -1, Optional CveRinTamaño As Integer = -1, Optional ClaveImpuestoEmpaque As String = "", Optional ClaveImpuestoUM As String = "", - Optional ClaveCategoriaToxicidad As String = "", Optional ClaveImpuestoTipoProducto As String = "", Optional Litraje As Double = -1, Optional EsOutSourcing As Boolean = False, - Optional AplicaSerie As Boolean = False, Optional AplicaLote As Boolean = False, Optional AplicaCaducidad As Boolean = False, Optional AplicaSeccion As Boolean = False, Optional TiempoCaducidad As Integer = -1, Optional CvePSAdicionalVigencia As Integer = -1) As Boolean - - Dim Retorno As Boolean = False - - DataAdapter("PA_ProductosServiciosUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion - .Add("@CveClasificacionCosto", SqlDbType.Int).Value = CveClasificacionCosto - .Add("@CveUnidadMedida", SqlDbType.Int).Value = CveUnidadMedida - .Add("@Codigo", SqlDbType.VarChar).Value = Codigo - .Add("@Codigo2", SqlDbType.VarChar).Value = If(Codigo2 = "", "-1", Codigo2) - .Add("@CodigoBarras", SqlDbType.VarChar).Value = If(CodigoBarras = "", "-1", CodigoBarras) - .Add("@PS", SqlDbType.VarChar).Value = PS - .Add("@Precio", SqlDbType.Float).Value = Precio - .Add("@IVA", SqlDbType.Float).Value = IVA - .Add("@RetIVA", SqlDbType.Float).Value = RetIVA - .Add("@AplicaParaConcepto", SqlDbType.Bit).Value = AplicaParaConcepto - .Add("@AplicaParaVenta", SqlDbType.Bit).Value = AplicaParaVenta - .Add("@Estado", SqlDbType.Bit).Value = Estado - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@EsPaquete", SqlDbType.Bit).Value = EsPaquete - .Add("@CveMetodoInventario", SqlDbType.Int).Value = CveMetodoInventario - .Add("@CveTipoPS", SqlDbType.Int).Value = CveTipoPS - .Add("@TipoServicio", SqlDbType.Int).Value = TipoServicio - .Add("@CveClasificacion2", SqlDbType.Int).Value = CveClasificacion2 - .Add("@CveMarca", SqlDbType.Int).Value = CveMarca - .Add("@AlmacenSeccion", SqlDbType.VarChar).Value = AlmacenSeccion - .Add("@AplicaIEPS", SqlDbType.Bit).Value = AplicaIEPS - .Add("@IEPSGrabaIVA", SqlDbType.Bit).Value = IEPSGrabaIVA - .Add("@IEPSPorcentaje", SqlDbType.SmallMoney).Value = IEPSPorcentaje - .Add("@CveConceptoContable", SqlDbType.Int).Value = CveConceptoContable - .Add("@CveCompuesto", SqlDbType.Int).Value = CveCompuesto - .Add("@CveSATPS", SqlDbType.Int).Value = CveSATPS - - 'Nuevo R: 26/09/2017' - .Add("@Inventariable", SqlDbType.Bit).Value = Inventariable - .Add("@CveProveedorCompra", SqlDbType.Int).Value = CveProveedorCompra - .Add("@VentaMinima", SqlDbType.Decimal).Value = VentaMinima - - 'Nuevo R: 08/11/2017' - .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda - - 'Nuevo R: 30/11/2017 - .Add("@RetISR", SqlDbType.Float).Value = RetISR - - 'Nuevo Oscar 29/12/2017 - .Add("@PrecioMinimo", SqlDbType.Money).Value = PrecioMinimo - - 'Nuevo Rigo 12/01/2018 - .Add("@CveTipoFactor", SqlDbType.Int).Value = CveTipoFactor - - 'Nuevo Raul 08/03/2018 - .Add("@CveFraccionArancelaria", SqlDbType.Int).Value = CveFraccionArancelaria - - 'Nuevo Raul 10/08/2018 - .Add("@CveUsuarioModifico", SqlDbType.Int).Value = CveUsuarioModifico - - 'Nuevo Raul 11/09/2018 - .Add("@CveClasificacionDetalle", SqlDbType.Int).Value = CveClasificacionDetalle - - 'Nuevo Oscar 31/10/2018 - .Add("@CveTamaño", SqlDbType.Int).Value = CveTamaño - - 'Nuevo Happy 25/04/2019 - .Add("@CveModelo", SqlDbType.Int).Value = CveModelo - .Add("@CveMedida", SqlDbType.Int).Value = CveMedida - .Add("@CveRinTamaño", SqlDbType.Int).Value = CveRinTamaño - - .Add("@ClaveImpuestoTipoProducto", SqlDbType.VarChar).Value = ClaveImpuestoTipoProducto - .Add("@ClaveImpuestoEmpaque", SqlDbType.VarChar).Value = ClaveImpuestoEmpaque - .Add("@ClaveImpuestoUM", SqlDbType.VarChar).Value = ClaveImpuestoUM - .Add("@ClaveCategoriaToxicidad", SqlDbType.VarChar).Value = ClaveCategoriaToxicidad - .Add("@Litraje", SqlDbType.Float).Value = Litraje - .Add("@EsOutSourcing", SqlDbType.Bit).Value = EsOutSourcing - - .Add("@AplicaSerie", SqlDbType.Bit).Value = AplicaSerie - .Add("@AplicaLote", SqlDbType.Bit).Value = AplicaLote - .Add("@AplicaCaducidad", SqlDbType.Bit).Value = AplicaCaducidad - .Add("@AplicaSeccion", SqlDbType.Bit).Value = AplicaSeccion + .Add("@CvePSAdicionalVigencia", SqlDbType.Int).Value = CvePSAdicionalVigencia + .Add("@PrecioLibre", SqlDbType.Bit).Value = PrecioLibre + + End With + + Try + SqlAdapter.Fill(Data) + _CvePS = SqlAdapter.SelectCommand.Parameters("@RETURN_VALUE").Value.ToString.ToEntero + Retorno = _CvePS + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 2627;") Then + Alert("El Nuevo Producto o Servicio no se guardo debido a que actualmente se encuentra registrado", TipoMensaje.MsgAdvertencia) + ElseIf Ex1.Message.Contains("Número: 2601;") Then + Alert("El Nuevo Producto o Servicio tiene Codigo duplicado:" & Codigo, TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al guardar el nuevo Producto o Servicio.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + OnError("Ocurrió un error al guardar el nuevo Producto o Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function AddPSApp(PS As MProductoServicio) As Integer + Dim Retorno As Integer = -1 + + DataAdapter("PA_ProductosServiciosAppAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveClasificacion", SqlDbType.Int).Value = PS.CveClasificacion + .Add("@CveClasificacionCosto", SqlDbType.Int).Value = PS.CveClasificacionCosto + .Add("@CveUnidadMedida", SqlDbType.Int).Value = PS.CveUnidadMedida + .Add("@Codigo", SqlDbType.VarChar).Value = PS.Codigo + .Add("@Codigo2", SqlDbType.VarChar).Value = If(PS.Codigo2 = "", "-1", PS.Codigo2) + .Add("@CodigoBarras", SqlDbType.VarChar).Value = If(PS.CodigoBarras = "", "-1", PS.CodigoBarras) + .Add("@PS", SqlDbType.VarChar).Value = If(PS.PS.Length > 845, PS.PS.Substring(0, 845), PS.PS) + .Add("@Precio", SqlDbType.Float).Value = PS.Precio + .Add("@IVA", SqlDbType.Float).Value = PS.IVA + .Add("@RetIVA", SqlDbType.Float).Value = PS.RetIVA + .Add("@AplicaParaConcepto", SqlDbType.Bit).Value = PS.AplicaParaConcepto + .Add("@AplicaParaVenta", SqlDbType.Bit).Value = PS.AplicaParaVenta + .Add("@CveUsuario", SqlDbType.Int).Value = PS.CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = PS.CveEmpresa + .Add("@EsPaquete", SqlDbType.Bit).Value = PS.EsPaquete + .Add("@CveMetodoInventario", SqlDbType.Int).Value = PS.CveMetodoInventario + .Add("@RETURN_VALUE", SqlDbType.Int).Direction = ParameterDirection.ReturnValue + .Add("@CveTipoPS", SqlDbType.Int).Value = PS.CveTipoPS + .Add("@FuePorXML", SqlDbType.Bit).Value = PS.FuePorXML + .Add("@TipoServicio", SqlDbType.Int).Value = PS.TipoServicio + .Add("@CveClasificacion2", SqlDbType.Int).Value = PS.CveClasificacion2 + .Add("@CveMarca", SqlDbType.Int).Value = PS.CveMarca + .Add("@AlmacenSeccion", SqlDbType.VarChar).Value = PS.AlmacenSeccion + .Add("@AplicaIEPS", SqlDbType.Bit).Value = PS.AplicaIEPS + .Add("@IEPSGrabaIVA", SqlDbType.Bit).Value = PS.IEPSGrabaIVA + .Add("@IEPSPorcentaje", SqlDbType.SmallMoney).Value = PS.IEPSPorcentaje + .Add("@CveConceptoContable", SqlDbType.Int).Value = PS.CveConceptoContable + .Add("@CveCompuesto", SqlDbType.Int).Value = PS.CveCompuesto + .Add("@CveSATPS", SqlDbType.Int).Value = PS.CveSATPS + + 'Nuevo R: 26/09/2017' + .Add("@Inventariable", SqlDbType.Bit).Value = PS.Inventariable + .Add("@CveProveedorCompra", SqlDbType.Int).Value = PS.CveProveedorCompra + .Add("@VentaMinima", SqlDbType.Decimal).Value = PS.VentaMinima + + 'Nuevo R: 08/11/2017' + .Add("@CveMoneda", SqlDbType.Int).Value = PS.CveMoneda + + 'Nuevo R: 30/11/2017 + .Add("@RetISR", SqlDbType.Float).Value = PS.RetISR + + + 'Nuevo Oscar 29/12/2017 + .Add("@PrecioMinimo", SqlDbType.Money).Value = PS.PrecioMinimo + + 'Nuevo Rigo 12/01/2018 + .Add("@CveTipoFactor", SqlDbType.Int).Value = PS.CveTipoFactor + + 'Nuevo Raul 08/03/2018 + .Add("@CveFraccionArancelaria", SqlDbType.Int).Value = PS.CveFraccionArancelaria + + 'Nuevo Raul 11/09/2018 + .Add("@CveClasificacionDetalle", SqlDbType.Int).Value = PS.CveClasificacionDetalle + + 'Nuevo Oscar 31/10/2018 + .Add("@CveTamaño", SqlDbType.Int).Value = PS.CveTamaño + + End With + + Try + SqlAdapter.Fill(Data) + _CvePS = SqlAdapter.SelectCommand.Parameters("@RETURN_VALUE").Value.ToString.ToEntero + Retorno = _CvePS + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 2627;") Then + Alert("El Nuevo Producto o Servicio no se guardo debido a que actualmente se encuentra registrado", TipoMensaje.MsgAdvertencia) + ElseIf Ex1.Message.Contains("Número: 2601;") Then + Alert("El Nuevo Producto o Servicio tiene Codigo duplicado.", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al guardar el nuevo Producto o Servicio.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + OnError("Ocurrió un error al guardar el nuevo Producto o Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function AddPSSimplificado(PS As MProductoServicio) As Integer + Dim Retorno As Integer = -1 + + DataAdapter("PA_ProductosServiciosSimplificadoAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveClasificacion", SqlDbType.Int).Value = PS.CveClasificacion + .Add("@CveUnidadMedida", SqlDbType.Int).Value = PS.CveUnidadMedida + .Add("@Codigo", SqlDbType.VarChar).Value = PS.Codigo + .Add("@PS", SqlDbType.VarChar).Value = If(PS.PS.Length > 845, PS.PS.Substring(0, 845), PS.PS) + .Add("@AplicaParaVenta", SqlDbType.Bit).Value = PS.AplicaParaVenta + .Add("@CveTipoPS", SqlDbType.Int).Value = PS.CveTipoPS + .Add("@CveUsuario", SqlDbType.Int).Value = PS.CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = PS.CveEmpresa + .Add("@RETURN_VALUE", SqlDbType.Int).Direction = ParameterDirection.ReturnValue + End With + + Try + SqlAdapter.Fill(Data) + _CvePS = SqlAdapter.SelectCommand.Parameters("@RETURN_VALUE").Value.ToString.ToEntero + Retorno = _CvePS + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 2627;") Then + Alert("El Nuevo Producto o Servicio no se guardo debido a que actualmente se encuentra registrado", TipoMensaje.MsgAdvertencia) + ElseIf Ex1.Message.Contains("Número: 2601;") Then + Alert("El Nuevo Producto o Servicio tiene Codigo duplicado.", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al guardar el nuevo Producto o Servicio.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + OnError("Ocurrió un error al guardar el nuevo Producto o Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function UpdatePS(CveClasificacion As Integer, CveClasificacionCosto As Integer, CveUnidadMedida As Integer, Codigo As String, Codigo2 As String, CodigoBarras As String, PS As String, Precio As Double, IVA As Double, RetIVA As Double, Inventariable As Boolean, CveProveedorCompra As Integer, + AplicaParaConcepto As Boolean, AplicaParaVenta As Boolean, Estado As Boolean, CveUsuario As Integer, CvePS As Integer, CveMetodoInventario As Integer, EsPaquete As Integer, CveSATPS As Integer, Optional CveTipoPS As Integer = -1, Optional TipoServicio As Integer = -1, + Optional CveClasificacion2 As Integer = -1, Optional CveMarca As Integer = -1, Optional AlmacenSeccion As String = "", Optional AplicaIEPS As Boolean = False, Optional IEPSPorcentaje As Decimal = -1, + Optional CveConceptoContable As Integer = -1, Optional CveCompuesto As Integer = -1, Optional IEPSGrabaIVA As Boolean = False, Optional VentaMinima As Decimal = 0, + Optional CveMoneda As Integer = 1, Optional RetISR As Double = 0, Optional PrecioMinimo As Decimal = Nothing, Optional CveTipoFactor As Integer = 1, + Optional CveFraccionArancelaria As Integer = -1, Optional CveUsuarioModifico As Integer = -1, + Optional CveClasificacionDetalle As Integer = -1, Optional CveTamaño As Integer = -1, Optional CveModelo As Integer = -1, Optional CveMedida As Integer = -1, Optional CveRinTamaño As Integer = -1, Optional ClaveImpuestoEmpaque As String = "", Optional ClaveImpuestoUM As String = "", + Optional ClaveCategoriaToxicidad As String = "", Optional ClaveImpuestoTipoProducto As String = "", Optional Litraje As Double = -1, Optional EsOutSourcing As Boolean = False, + Optional AplicaSerie As Boolean = False, Optional AplicaLote As Boolean = False, Optional AplicaCaducidad As Boolean = False, Optional AplicaSeccion As Boolean = False, Optional TiempoCaducidad As Integer = -1, Optional CvePSAdicionalVigencia As Integer = -1, Optional PrecioLibre As Boolean = False) As Boolean + + Dim Retorno As Boolean = False + + DataAdapter("PA_ProductosServiciosUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion + .Add("@CveClasificacionCosto", SqlDbType.Int).Value = CveClasificacionCosto + .Add("@CveUnidadMedida", SqlDbType.Int).Value = CveUnidadMedida + .Add("@Codigo", SqlDbType.VarChar).Value = Codigo + .Add("@Codigo2", SqlDbType.VarChar).Value = If(Codigo2 = "", "-1", Codigo2) + .Add("@CodigoBarras", SqlDbType.VarChar).Value = If(CodigoBarras = "", "-1", CodigoBarras) + .Add("@PS", SqlDbType.VarChar).Value = PS + .Add("@Precio", SqlDbType.Float).Value = Precio + .Add("@IVA", SqlDbType.Float).Value = IVA + .Add("@RetIVA", SqlDbType.Float).Value = RetIVA + .Add("@AplicaParaConcepto", SqlDbType.Bit).Value = AplicaParaConcepto + .Add("@AplicaParaVenta", SqlDbType.Bit).Value = AplicaParaVenta + .Add("@Estado", SqlDbType.Bit).Value = Estado + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@EsPaquete", SqlDbType.Bit).Value = EsPaquete + .Add("@CveMetodoInventario", SqlDbType.Int).Value = CveMetodoInventario + .Add("@CveTipoPS", SqlDbType.Int).Value = CveTipoPS + .Add("@TipoServicio", SqlDbType.Int).Value = TipoServicio + .Add("@CveClasificacion2", SqlDbType.Int).Value = CveClasificacion2 + .Add("@CveMarca", SqlDbType.Int).Value = CveMarca + .Add("@AlmacenSeccion", SqlDbType.VarChar).Value = AlmacenSeccion + .Add("@AplicaIEPS", SqlDbType.Bit).Value = AplicaIEPS + .Add("@IEPSGrabaIVA", SqlDbType.Bit).Value = IEPSGrabaIVA + .Add("@IEPSPorcentaje", SqlDbType.SmallMoney).Value = IEPSPorcentaje + .Add("@CveConceptoContable", SqlDbType.Int).Value = CveConceptoContable + .Add("@CveCompuesto", SqlDbType.Int).Value = CveCompuesto + .Add("@CveSATPS", SqlDbType.Int).Value = CveSATPS + + 'Nuevo R: 26/09/2017' + .Add("@Inventariable", SqlDbType.Bit).Value = Inventariable + .Add("@CveProveedorCompra", SqlDbType.Int).Value = CveProveedorCompra + .Add("@VentaMinima", SqlDbType.Decimal).Value = VentaMinima + + 'Nuevo R: 08/11/2017' + .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda + + 'Nuevo R: 30/11/2017 + .Add("@RetISR", SqlDbType.Float).Value = RetISR + + 'Nuevo Oscar 29/12/2017 + .Add("@PrecioMinimo", SqlDbType.Money).Value = PrecioMinimo + + 'Nuevo Rigo 12/01/2018 + .Add("@CveTipoFactor", SqlDbType.Int).Value = CveTipoFactor + + 'Nuevo Raul 08/03/2018 + .Add("@CveFraccionArancelaria", SqlDbType.Int).Value = CveFraccionArancelaria + + 'Nuevo Raul 10/08/2018 + .Add("@CveUsuarioModifico", SqlDbType.Int).Value = CveUsuarioModifico + + 'Nuevo Raul 11/09/2018 + .Add("@CveClasificacionDetalle", SqlDbType.Int).Value = CveClasificacionDetalle + + 'Nuevo Oscar 31/10/2018 + .Add("@CveTamaño", SqlDbType.Int).Value = CveTamaño + + 'Nuevo Happy 25/04/2019 + .Add("@CveModelo", SqlDbType.Int).Value = CveModelo + .Add("@CveMedida", SqlDbType.Int).Value = CveMedida + .Add("@CveRinTamaño", SqlDbType.Int).Value = CveRinTamaño + + .Add("@ClaveImpuestoTipoProducto", SqlDbType.VarChar).Value = ClaveImpuestoTipoProducto + .Add("@ClaveImpuestoEmpaque", SqlDbType.VarChar).Value = ClaveImpuestoEmpaque + .Add("@ClaveImpuestoUM", SqlDbType.VarChar).Value = ClaveImpuestoUM + .Add("@ClaveCategoriaToxicidad", SqlDbType.VarChar).Value = ClaveCategoriaToxicidad + .Add("@Litraje", SqlDbType.Float).Value = Litraje + .Add("@EsOutSourcing", SqlDbType.Bit).Value = EsOutSourcing + + .Add("@AplicaSerie", SqlDbType.Bit).Value = AplicaSerie + .Add("@AplicaLote", SqlDbType.Bit).Value = AplicaLote + .Add("@AplicaCaducidad", SqlDbType.Bit).Value = AplicaCaducidad + .Add("@AplicaSeccion", SqlDbType.Bit).Value = AplicaSeccion .Add("@TiempoCaducidad", SqlDbType.SmallInt).Value = TiempoCaducidad - .Add("@CvePSAdicionalVigencia", SqlDbType.Int).Value = CvePSAdicionalVigencia - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 2627;") Then - Alert("El Producto o Servicio no se guardo debido a que actualmente se encuentra registrado.", TipoMensaje.MsgAdvertencia) - ElseIf Ex1.Message.Contains("Número: 2601;") Then - Alert("El Nuevo Producto o Servicio tiene Codigo duplicado.", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al intentar guardar los cambios en el Producto o Servicio.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - OnError("Ocurrió un error al intentar guardar los cambios en el Producto o Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function UpdateClasificacionPS(CveClasificacion As Integer, CveUsuario As Integer, CvePS As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_ProductosServiciosClasificacionUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CvePS", SqlDbType.Int).Value = CvePS - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 2627;") Then - Alert("El Producto o Servicio no se guardo debido a que actualmente se encuentra registrado.", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al intentar guardar los cambios de clasificación del Producto o Servicio.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - OnError("Ocurrió un error al intentar guardar los cambio de clasificación del Producto o Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function RemovePS(CvePS As Integer) As Boolean - Dim OnError As Boolean = False - DataAdapter("PA_ProductosServiciosRemove") - - SqlAdapter.SelectCommand.Parameters.Add("@CvePS", SqlDbType.Int).Value = CvePS - - Try - SqlAdapter.Fill(Data) - OnError = True - Catch ex As Exception - Me.OnError("Ocurrió un error al eliminar El Producto Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return OnError - End Function - Public Function GetAllPS(CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_ProductosServiciosGetAll") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As SqlException - If CvePS <> -1 Then - OnError("Ocurrió un error al consultar El Producto o Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - Else - OnError("Ocurrió un error al consultar El Producto o Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End If - End Try - - Return Retorno - End Function - Public Function GetPrecioUnitarioPS(CveEmpresa As Integer, CvePS As Integer) As Double - - Dim Retorno As Double = -1 - - DataAdapter("PA_Inv_PrecioUnitarioSalidaGet") - - With SqlAdapter.SelectCommand.Parameters - - - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@PU", SqlDbType.Money).Direction = ParameterDirection.Output - End With - - Try - SqlAdapter.Fill(Data) - Retorno = CDbl(SqlAdapter.SelectCommand.Parameters("@PU").Value) - - Catch Ex1 As SqlException - Me.OnError("Ocurrió un error al obtener el precio unitario.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - Catch ex As Exception - OnError("Ocurrió un error al obtener el precio unitario", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - -#Region "P R O D U C T O S - E Q U I V A L E N C I A S " - - Public Function GetPSEquivalencias(CvePS As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Gral_ProductosServiciosEquivalenciasGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener las equivalencias.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function AddPSEquivalencias(CvePS As Integer, CveUM As Integer, Cantidad As Decimal, UnidadBase As Boolean, Precio As Double, CveUsuario As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Gral_ProductosServiciosEquivalenciasAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@CveUM", SqlDbType.Int).Value = CveUM - .Add("@Cantidad", SqlDbType.Float).Value = Cantidad - .Add("@UnidadBase", SqlDbType.Bit).Value = UnidadBase - .Add("@Precio", SqlDbType.Money).Value = Precio - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - - - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 2627;") Then - Alert("Ya existe una equivalencia con la misma unidad de medida.", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al Guardar la Equivalencia.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - - Catch ex As Exception - OnError("Ocurrió un error al Guardar la Equivalencia", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function UpdatePSEquivalencias(CvePS As Integer, CveUM As Integer, Cantidad As Decimal, UnidadBase As Boolean, Precio As Double, CveUsuario As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Gral_ProductosServiciosEquivalenciasUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@CveUM", SqlDbType.Int).Value = CveUM - .Add("@Cantidad", SqlDbType.Float).Value = Cantidad - .Add("@UnidadBase", SqlDbType.Bit).Value = UnidadBase - .Add("@Precio", SqlDbType.Money).Value = Precio - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 2627;") Then - Alert("Ya existe una equivalencia con la misma unidad de medida." + Ex1.Message.ToString, TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al Guardar la Equivalencia.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - OnError("Ocurrió un error al actualizar la Equivalencia", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function RemovePSEquivalencias(CvePS As Integer, CveUM As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Gral_ProductosServiciosEquivalenciasRemove") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@CveUM", SqlDbType.Int).Value = CveUM - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - Me.OnError("Ocurrió un error al eliminar la equivalencia.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - - Catch ex As Exception - Me.OnError("Ocurrió un error al eliminar la equivalencia.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - - -#End Region - -#Region "P R O D U C T O S A D I C I O N A L E S " - - Public Function GetPSAdicionales(CvePS As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Gral_ProductosServiciosAdicionalesGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los Productos/Servicios Adicionales.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function AddPSAdicionales(CvePS As Integer, CvePSAdicional As Integer, Cantidad As Decimal) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Gral_ProductosServiciosAdicionalesAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@CvePSAdicional", SqlDbType.Int).Value = CvePSAdicional - .Add("@Cantidad", SqlDbType.Money).Value = Cantidad - - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 2627;") Then - Alert("Ya existe una equivalencia con el mismo Producto/Servicio Adicional.", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al Guardar el Producto/Servicio Adicional.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - - Catch ex As Exception - OnError("Ocurrió un error al Guardar el Producto/Servicio Adicional.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function UpdatePSAdicionales(CvePS As Integer, CvePSAdicional As Integer, CvePSAdicionalAnterior As Integer, Cantidad As Decimal) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Gral_ProductosServiciosAdicionalesUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@CvePSAdicional", SqlDbType.Int).Value = CvePSAdicional - .Add("@CvePSAdicionalAnterior", SqlDbType.Int).Value = CvePSAdicionalAnterior - .Add("@Cantidad", SqlDbType.Money).Value = Cantidad - - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 2627;") Then - Alert("Ya existe una equivalencia con el mismo Producto/Servicio Adicional." + Ex1.Message.ToString, TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al Guardar el Producto/Servicio Adicional.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - OnError("Ocurrió un error al actualizar el Producto/Servicio Adicional.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function RemovePSAdicionales(CvePS As Integer, CvePSAdicional As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Gral_ProductosServiciosAdicionalesRemove") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@CvePSAdicional", SqlDbType.Int).Value = CvePSAdicional - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - Me.OnError("Ocurrió un error al eliminar el Producto/Servicio Adicional.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - - Catch ex As Exception - Me.OnError("Ocurrió un error al eliminar el Producto/Servicio Adicional.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - - -#End Region - -#Region "P A Q U E T E S" - - Public Function UpdatePaquete(CvePS As Integer, PS As String, Precio As Double, Estado As Boolean) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Inv_PaqueteUpdate") - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@PS", SqlDbType.VarChar).Value = PS - .Add("@Precio", SqlDbType.Money).Value = Precio - .Add("@Estado", SqlDbType.Bit).Value = Estado - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar el paquete.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetPaqueteDetalle(CvePSPaquete As Integer, CveEmpresa As Integer, Optional CveUMPaquete As Integer = -1, Optional Cantidad As Double = 0, Optional CveAlmacen As Integer = -1, Optional Fecha As Date = MinFecha, Optional CveVendedor As Integer = -1, Optional CveCliente As Integer = -1) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Inv_PaqueteDetallesGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePSPaquete", SqlDbType.Int).Value = CvePSPaquete - .Add("@CveUMPaquete", SqlDbType.Int).Value = CveUMPaquete - .Add("@Cantidad", SqlDbType.Money).Value = Cantidad - .Add("@CveAlmacen", SqlDbType.Int).Value = CveAlmacen - .Add("@Fecha", SqlDbType.Date).Value = Fecha - .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los Productos y servicios del paquete.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function AddPaqueteDetalle(CvePSPaquete As Integer, CvePS As Integer, Cantidad As Double, Tipo As Integer, CveUnidadMedida As Integer, Optional CveUsuarioModifico As Integer = -1) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Inv_PaquetesAdd") - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePSPaquete", SqlDbType.Int).Value = CvePSPaquete - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@Cantidad", SqlDbType.Money).Value = Cantidad - .Add("@CveUnidadMedida", SqlDbType.Int).Value = CveUnidadMedida - .Add("@Tipo", SqlDbType.Int).Value = Tipo - .Add("@CveUsuarioModifico", SqlDbType.Int).Value = CveUsuarioModifico - - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 2627;") Then - Alert("Ya existe en el Paquete el Producto o Servicio.", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al guardar el Paquete.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - OnError("Ocurrió un error al guardar el Paquete", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - - Public Function DeletePaqueteDetalle(CvePSPaquete As Integer, CvePS As Integer, Cantidad As Double, Tipo As Integer, CveUnidadMedida As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Inv_PaqueteDetalleDelete") - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePSPaquete", SqlDbType.Int).Value = CvePSPaquete - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@Cantidad", SqlDbType.Money).Value = Cantidad - .Add("@Tipo", SqlDbType.Int).Value = Tipo - .Add("@CveUnidadMedida", SqlDbType.Int).Value = CveUnidadMedida - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al ingresar el producto al paquete.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function UpdatePaqueteDetalle(CvePSPaquete As Integer, CvePS As Integer, Cantidad As Double, Tipo As Integer, CveUnidadMedida As Integer, Optional CveUsuarioModifico As Integer = -1) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Inv_PaqueteDetalleUpdate") - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePSPaquete", SqlDbType.Int).Value = CvePSPaquete - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@Cantidad", SqlDbType.Money).Value = Cantidad - .Add("@Tipo", SqlDbType.SmallInt).Value = Tipo - .Add("@CveUnidadMedida", SqlDbType.Int).Value = CveUnidadMedida - .Add("@CveUsuarioModifico", SqlDbType.Int).Value = CveUsuarioModifico - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar el paquete.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - -#End Region - -#Region "P R O D U C T O S - S U C U R S A L E S" - - Public Function GetPSSucursales(CvePS As Integer, CveEmpresa As Integer, Optional CveSubProyecto As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Gral_ProductosServiciosSucursalesGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener las Sucursales habilitadas para el Producto y/o Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetPSSucursalesALL(CvePS As Integer, CveEmpresa As Integer, Optional Codigo As String = "", Optional CodigoBarras As String = "", Optional CveSubProyecto As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Gral_ProductosServiciosSucursalesGetAll") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@Codigo", SqlDbType.VarChar).Value = Codigo - .Add("@CodigoBarras", SqlDbType.VarChar).Value = CodigoBarras - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener las Sucursales habilitadas para el Producto y/o Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function AddPSSucursales(CvePS As Integer, Importe As Double, Minimo As Double, Maximo As Double, CveUsuario As Integer, CveSubProyecto As Integer, Optional PrecioMinimo As Decimal = Nothing) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Gral_ProductosServiciosSucursalesAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@Importe", SqlDbType.Float).Value = Importe - .Add("@Minimo", SqlDbType.Float).Value = Minimo - .Add("@Maximo", SqlDbType.Float).Value = Maximo - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@PrecioMinimo", SqlDbType.Decimal).Value = PrecioMinimo - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 2627;") Then - Alert("Ya existe una Sucursal para el mismo Producto y/o Servicio.", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al Guardar la Sucursal para Producto y/o Servicio.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - - Catch ex As Exception - OnError("Ocurrió un error al Guardar la Sucursal para Producto y/o Servicio", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function UpdatePSSucursales(CvePS As Integer, Importe As Double, Minimo As Double, Maximo As Double, CveUsuario As Integer, CveSubProyecto As Integer, Optional PrecioMinimo As Decimal = Nothing) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Gral_ProductosServiciosSucursalesUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@Importe", SqlDbType.Float).Value = Importe - .Add("@Minimo", SqlDbType.Float).Value = Minimo - .Add("@Maximo", SqlDbType.Float).Value = Maximo - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@PrecioMinimo", SqlDbType.Decimal).Value = PrecioMinimo - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 2627;") Then - Alert("Ya existe una Sucursal para el mismo Producto y/o Servicio.", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al Guardar la Sucursal para Producto y/o Servicio.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - OnError("Ocurrió un error al Guardar la Sucursal para Producto y/o Servicio", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function RemovePSSucursales(CvePS As Integer, CveSubProyecto As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Gral_ProductosServiciosSucursalesRemove") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - Me.OnError("Ocurrió un error al eliminar la Sucursal para Producto y/o Servicio.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - - Catch ex As Exception - Me.OnError("Ocurrió un error al eliminar la Sucursal para Producto y/o Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - -#End Region - - 'Ubicacion temporal - Public Function GetMetodosInv() As Boolean - Dim Retorno = False - - DataAdapter("PA_Inv_MetodosGet") - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - Me.OnError("Ocurrió un error al obtener los Metodos de Inventario.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - Catch ex As Exception - OnError("Ocurrió un error al obtener los Metodos de Inventario.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - - End Function - -#Region " Marcas " - Public Function GetPSAlias(CvePS As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Gral_ProductosServiciosAliasGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - - Retorno = True - Catch ex As SqlException - If CvePS <> -1 Then - OnError("Ocurrió un error al consultar El Producto o Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - Else - OnError("Ocurrió un error al consultar El Producto o Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End If - End Try - - Return Retorno - End Function - - Public Function AddPSAlias(PS As String, CvePS As Integer, Optional CveUsuarioModifico As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Gral_ProductosServiciosAliasAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@PSAlias", SqlDbType.VarChar).Value = If(PS.Length > 845, PS.Substring(0, 845), PS) - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@CveUsuarioModifico", SqlDbType.Int).Value = CveUsuarioModifico - End With - - Try - SqlAdapter.Fill(Data) - - Retorno = True - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 2627;") Then - OnError("El Nuevo Producto o Servicio no se guardo debido a que actualmente se encuentra registrado", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - Else - Me.OnError("Ocurrió un error al guardar el nuevo Producto o Servicio.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - OnError("Ocurrió un error al guardar el nuevo Producto o Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function RemovePSAlias(CvePS As Integer, PSAlias As String, CveUsuarioModifico As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Gral_ProductosServiciosAliasRemove") - - SqlAdapter.SelectCommand.Parameters.Add("@CvePS", SqlDbType.Int).Value = CvePS - SqlAdapter.SelectCommand.Parameters.Add("@PSAlias", SqlDbType.VarChar).Value = PSAlias - SqlAdapter.SelectCommand.Parameters.Add("@CveUsuarioModifico", SqlDbType.Int).Value = CveUsuarioModifico - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al eliminar el Alias del Producto o Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function UpdateAplicaSeccionAlmacen(CvePS As Integer, CveEmpresa As Integer, AplicaSeccionAlmacen As Boolean) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Gral_ProductosServiciosSeccionAlmacenUpdate") - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@AplicaSeccionAlmacen", SqlDbType.Bit).Value = AplicaSeccionAlmacen - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - - Catch ex As Exception - OnError("Ocurrió un error al actualizar aplica seccion almacen.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function GetMarcas(CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Gral_MarcasGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Catálogo de Marcas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - - - Public Function AddMarcas(Marca As String, Estatus As Boolean, CveUsuario As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Gral_MarcasAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Marca", SqlDbType.VarChar).Value = Marca - .Add("@Estatus", SqlDbType.Bit).Value = Estatus - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 2627;") Then - Alert("Ya existe una Marca del Producto o Servicio con el mismo nombre: " & Marca & ".", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al Guardar la Marca.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - OnError("Ocurrió un error al Guardar la Marca.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - - - Public Function RemoveMarca(CveMarca As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Gral_MarcasRemove") - - SqlAdapter.SelectCommand.Parameters.Add("@CveMarca", SqlDbType.Int).Value = CveMarca - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - Me.OnError("Ocurrió un error al eliminar la Marca.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - Catch ex As Exception - Me.OnError("Ocurrió un error al eliminar la Marca.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - - - - Public Function UpdateMarca(Marca As String, CveMarca As Integer, Estatus As Boolean) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Gral_MarcasUpdate") - With SqlAdapter.SelectCommand.Parameters - .Add("@Marca", SqlDbType.VarChar).Value = Marca - .Add("@CveMarca", SqlDbType.Int).Value = CveMarca - .Add("@Estatus", SqlDbType.Bit).Value = Estatus - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - - Catch ex As Exception - OnError("Ocurrió un error al actualizar la Marca.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - -#End Region - Public Function GetPSMarcas(CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_GRAL_PSMarcasGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Catálogo de Marcas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - -#Region "IMPUESTOS LOCALES" - Public Function GetPSImpuestosLocales(CvePS As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Gral_PSImpuestosLocalesGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los datos de impuestos locales.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - - - Public Function AddPSImpuestosLocales(CvePS As Integer, CveImpuestoLocal As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Gral_PSImpuestosLocalesAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@CveImpuestoLocal", SqlDbType.Int).Value = CveImpuestoLocal - End With - - Try - SqlAdapter.Fill(Data) - - Catch ex As Exception - OnError("Ocurrió un error al tratar de agregar datos a la base de datos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - - Public Function LimpiaImpuestosLocales(CveCliente As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Gral_PSImpuestosLocalesRemove") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePS", SqlDbType.Int).Value = CveCliente - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al limpiar la lista de deducciones.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - -#End Region - -#Region "C O M P U E S T O S" - Public Function GetCompuestosActivos(CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Gral_CompuestosGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Catálogo de Compuestos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - Return Retorno - End Function - - - - Public Function AddCompuestoActivo(Compuesto As String, Estatus As Boolean, CveUsuario As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Gral_CompuestosAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Compuesto", SqlDbType.VarChar).Value = Compuesto - .Add("@Estatus", SqlDbType.Bit).Value = Estatus - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 2627;") Then - Alert("Ya existe un compuesto activo con el mismo nombre: " & Compuesto & ".", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al Guardar el compuesto.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - OnError("Ocurrió un error al Guardar el compuesto.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - - - Public Function RemoveCompuestoActivo(CveCompuesto As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Gral_CompuestosRemove") - - SqlAdapter.SelectCommand.Parameters.Add("@CveCompuesto", SqlDbType.Int).Value = CveCompuesto - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - Me.OnError("Ocurrió un error al eliminar el compuesto.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - Catch ex As Exception - Me.OnError("Ocurrió un error al eliminar el compuesto.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - - - - Public Function UpdateCompuestoActivo(Compuesto As String, CveCompuesto As Integer, Estatus As Boolean) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Gral_CompuestoUpdate") - With SqlAdapter.SelectCommand.Parameters - .Add("@Compuesto", SqlDbType.VarChar).Value = Compuesto - .Add("@CveCompuesto", SqlDbType.Int).Value = CveCompuesto - .Add("@Estatus", SqlDbType.Bit).Value = Estatus - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - - Catch ex As Exception - OnError("Ocurrió un error al actualizar el compuesto.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function -#End Region - -#Region "UNIFICAR PRODUCTO" - Public Function UnificarPS(CvePSPrincipal As Integer, CvePSUnificado As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_PS_PSUnificar") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePSPrincipal", SqlDbType.Int).Value = CvePSPrincipal - .Add("@CvePSUnificado", SqlDbType.Int).Value = CvePSUnificado - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - OnError("Ocurrió un error al intentar Unificar los Productos o Servicios.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - Catch ex As Exception - OnError("Ocurrió un error al intentar Unificar los Productos o Servicios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function -#End Region - - -#Region "Precios Lista" - Public Function GetPSPreciosLista(CveEmpresa As Integer, CvePrecioLista As Integer, Optional CveClasificacion As Integer = -1, Optional CvePS As Integer = -1, - Optional CveProveedor As Integer = -1, Optional Estado As Integer = -1, Optional Marcas As String = "-1", Optional CveModelo As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_PSPrecioListaGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CvePrecioLista", SqlDbType.Int).Value = CvePrecioLista - .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor - .Add("@Estado", SqlDbType.Int).Value = Estado - .Add("@Marcas", SqlDbType.VarChar).Value = Marcas - .Add("@CveModelo", SqlDbType.Int).Value = CveModelo - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Catálogo de PS con precios de lista.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function UpdatePSPreciosLista(Importe As Decimal, CvePrecioLista As Integer, Porcentaje As Decimal, CvePS As Integer, CveUsuario As Integer, Fecha As DateTime, Fijo As Boolean, Optional PrecioMinimo As Decimal = Nothing) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_PSPrecioListaAdd") - - With SqlAdapter.SelectCommand.Parameters - - If Importe = -1 Then - .Add("@Importe", SqlDbType.Float).Value = DBNull.Value - Else - .Add("@Importe", SqlDbType.Float).Value = Importe - End If - - .Add("@CvePrecioLista", SqlDbType.Int).Value = CvePrecioLista - - If Porcentaje = -1 Then - .Add("@Porcentaje", SqlDbType.Money).Value = DBNull.Value - Else - .Add("@Porcentaje", SqlDbType.Money).Value = Porcentaje - End If - - .Add("@PrecioMinimo", SqlDbType.Decimal).Value = PrecioMinimo - - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@Fecha", SqlDbType.DateTime).Value = Fecha - .Add("@Fijo", SqlDbType.Bit).Value = Fijo - - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar los precios de lista.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function UpdatePSPrecios(Importe As Decimal, CvePrecioLista As Integer, Porcentaje As Decimal, CvePS As Integer, CveUsuario As Integer, Fecha As DateTime, Fijo As Boolean, Optional PrecioMinimo As Decimal = Nothing) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_PSPrecioUpdate") - - With SqlAdapter.SelectCommand.Parameters - - If Importe = -1 Then - .Add("@Importe", SqlDbType.Float).Value = DBNull.Value - Else - .Add("@Importe", SqlDbType.Float).Value = Importe - End If - - If Porcentaje = -1 Then - .Add("@Porcentaje", SqlDbType.Money).Value = DBNull.Value - Else - .Add("@Porcentaje", SqlDbType.Money).Value = Porcentaje - End If - - .Add("@PrecioMinimo", SqlDbType.Decimal).Value = PrecioMinimo - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@Fecha", SqlDbType.DateTime).Value = Fecha - .Add("@Fijo", SqlDbType.Bit).Value = Fijo - - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar los precios de lista.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - - Public Function GetPSPrecioLista(CvePS As Integer, CveEmpresa As Integer, Optional CvePrecioLista As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Gral_ProductosServiciosPrecioListaGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@CvePrecioLista", SqlDbType.Int).Value = CvePrecioLista - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los precios de lista para el Producto/Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - - End Function - - Public Function GetPSExistencias(CvePS As Integer, CvePrecioLista As Integer, CveUnidadMedida As Integer, CveEmpresa As Integer, - CveAlmacen As Integer, Optional CveSeccionAlmacen As Integer = -1, Optional CveTipoAlmacen As Integer = -1, Optional CveSubProyecto As Integer = -1, - Optional FechaMovto As String = "-1", Optional Serie As String = "-1", Optional CveVendedor As Integer = -1, Optional CveCliente As Integer = -1, - Optional ExcluyeAdelantado As Integer = -1, Optional PendientePorSurtir As Integer = -1, Optional Lote As String = "-1", Optional Batch As String = "-1", - Optional ExcluyeApartados As Integer = 1, Optional RestringirAlmacenes As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_ProductosExistenciasGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@CvePrecioLista", SqlDbType.Int).Value = CvePrecioLista - .Add("@CveUnidadMedida", SqlDbType.Int).Value = CveUnidadMedida - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveAlmacen", SqlDbType.Int).Value = CveAlmacen - .Add("@CveSeccionAlmacen", SqlDbType.Int).Value = CveSeccionAlmacen - .Add("@CveTipoAlmacen", SqlDbType.Int).Value = CveTipoAlmacen - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@FechaMovto", SqlDbType.DateTime).Value = DateTime.ParseExact(FechaMovto, "yyyy/MM/dd HH:mm", Nothing) - .Add("@Serie", SqlDbType.VarChar).Value = Serie - .Add("@Lote", SqlDbType.VarChar).Value = Lote - .Add("@Batch", SqlDbType.VarChar).Value = Batch - .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@ExcluyeAdelantado", SqlDbType.Int).Value = ExcluyeAdelantado - .Add("@PendientePorSurtir", SqlDbType.Int).Value = PendientePorSurtir - .Add("@ExcluyeApartados", SqlDbType.Int).Value = ExcluyeApartados - .Add("@RestringirAlmacenes", SqlDbType.Int).Value = RestringirAlmacenes - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener las productos y sus existencias.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function GetPSExistenciasWS(CvePS As Integer, CvePrecioLista As Integer, CveUnidadMedida As Integer, CveEmpresa As Integer, - CveAlmacen As Integer, Optional CveSeccionAlmacen As Integer = -1, Optional CveTipoAlmacen As Integer = -1, Optional CveSubProyecto As Integer = -1, - Optional FechaMovto As String = "-1", Optional Serie As String = "-1", Optional CveVendedor As Integer = -1, Optional CveCliente As Integer = -1, - Optional ExcluyeAdelantado As Integer = -1, Optional PendientePorSurtir As Integer = -1, Optional Lote As String = "-1", Optional Batch As String = "-1", - Optional ExcluyeApartados As Integer = 1, Optional RestringirAlmacenes As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_ProductosExistenciasWSGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@CvePrecioLista", SqlDbType.Int).Value = CvePrecioLista - .Add("@CveUnidadMedida", SqlDbType.Int).Value = CveUnidadMedida - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveAlmacen", SqlDbType.Int).Value = CveAlmacen - .Add("@CveSeccionAlmacen", SqlDbType.Int).Value = CveSeccionAlmacen - .Add("@CveTipoAlmacen", SqlDbType.Int).Value = CveTipoAlmacen - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@FechaMovto", SqlDbType.DateTime).Value = DateTime.ParseExact(FechaMovto, "yyyy/MM/dd HH:mm", Nothing) - .Add("@Serie", SqlDbType.VarChar).Value = Serie - .Add("@Lote", SqlDbType.VarChar).Value = Lote - .Add("@Batch", SqlDbType.VarChar).Value = Batch - .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@ExcluyeAdelantado", SqlDbType.Int).Value = ExcluyeAdelantado - .Add("@PendientePorSurtir", SqlDbType.Int).Value = PendientePorSurtir - .Add("@ExcluyeApartados", SqlDbType.Int).Value = ExcluyeApartados - .Add("@RestringirAlmacenes", SqlDbType.Int).Value = RestringirAlmacenes - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener las productos y sus existencias.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - -#End Region - -#Region "Porcentaje Productos" - Public Function GetPorcentajeProductos(CveCliente As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_PorcentajeProductosGet") - - With SqlAdapter.SelectCommand.Parameters - - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los porcentajes de los productos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function AddPorcentajeProductos(CveCliente As Integer, CvePS As Integer, PorcentajeProducto As Decimal, CveUsuario As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_PorcentajeProductosAdd") - - With SqlAdapter.SelectCommand.Parameters - - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@PorcentajeProducto", SqlDbType.SmallMoney).Value = PorcentajeProducto - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar el porcentaje del producto.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function UpdatePorcentajeProductos(CveCliente As Integer, CvePS As Integer, PorcentajeProducto As Decimal) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_PorcentajeProductosUpdate") - - With SqlAdapter.SelectCommand.Parameters - - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@PorcentajeProducto", SqlDbType.SmallMoney).Value = PorcentajeProducto - - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar el porcentaje del producto.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function RemovePorcentajeProductos(CveCliente As Integer, CvePS As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_PorcentajeProductosRemove") - - With SqlAdapter.SelectCommand.Parameters - - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CvePS", SqlDbType.Int).Value = CvePS - - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al eliminar el porcentaje del producto.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function -#End Region - -#Region "Porcentaje Marcas de Productos" - Public Function GetPorcentajeMarcas(CveCliente As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_PorcentajeMarcasGet") - - With SqlAdapter.SelectCommand.Parameters - - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los porcentajes de las Marcas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function AddPorcentajeMarcas(CveCliente As Integer, CveMarca As Integer, PorcentajeProducto As Decimal, PorcentajeProducto2 As Decimal, PorcentajeProducto3 As Decimal, CveUsuario As Integer, Optional ProntoPago As Decimal = -1, Optional Plazo As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_PorcentajeMarcasAdd") - - With SqlAdapter.SelectCommand.Parameters - - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveMarca", SqlDbType.Int).Value = CveMarca - .Add("@PorcentajeProducto", SqlDbType.SmallMoney).Value = PorcentajeProducto - .Add("@PorcentajeProducto2", SqlDbType.SmallMoney).Value = PorcentajeProducto2 - .Add("@PorcentajeProducto3", SqlDbType.SmallMoney).Value = PorcentajeProducto3 - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@ProntoPago", SqlDbType.SmallMoney).Value = ProntoPago - .Add("@Plazo", SqlDbType.SmallInt).Value = Plazo - - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar el porcentaje de la Marca.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function UpdatePorcentajeMarcas(CveCliente As Integer, CveMarca As Integer, PorcentajeProducto As Decimal, PorcentajeProducto2 As Decimal, PorcentajeProducto3 As Decimal, Optional ProntoPago As Decimal = -1, Optional Plazo As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_PorcentajeMarcasUpdate") - - With SqlAdapter.SelectCommand.Parameters - - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveMarca", SqlDbType.Int).Value = CveMarca - .Add("@PorcentajeProducto", SqlDbType.SmallMoney).Value = PorcentajeProducto - .Add("@PorcentajeProducto2", SqlDbType.SmallMoney).Value = PorcentajeProducto2 - .Add("@PorcentajeProducto3", SqlDbType.SmallMoney).Value = PorcentajeProducto3 - .Add("@ProntoPago", SqlDbType.SmallMoney).Value = ProntoPago - .Add("@Plazo", SqlDbType.SmallInt).Value = Plazo - - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar el porcentaje de la Marca.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function RemovePorcentajeMarcas(CveCliente As Integer, CveMarca As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_PorcentajeMarcasRemove") - - With SqlAdapter.SelectCommand.Parameters - - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveMarca", SqlDbType.Int).Value = CveMarca - - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al eliminar el porcentaje de la Marca.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function -#End Region -#Region "IDisposable Support" - - - ' IDisposable - Protected Overridable Sub Dispose(disposing As Boolean) - If Not Me.disposedValue Then - If disposing Then - ' TODO: dispose managed state (managed objects). - If Not Data Is Nothing Then Data.Dispose() - If Not SqlAdapter Is Nothing Then SqlAdapter.Dispose() - If Not SqlCommand Is Nothing Then SqlCommand.Dispose() - If SqlConexion.State <> ConnectionState.Closed Then SqlConexion.Close() - If Not SqlConexion Is Nothing Then SqlConexion.Dispose() - End If - - ' TODO: free unmanaged resources (unmanaged objects) and override Finalize() below. - ' TODO: set large fields to null. - End If - Me.disposedValue = True - End Sub - - ' TODO: override Finalize() only if Dispose(disposing As Boolean) above has code to free unmanaged resources. - 'Protected Overrides Sub Finalize() - ' ' Do not change this code. Put cleanup code in Dispose(disposing As Boolean) above. - ' Dispose(False) - ' MyBase.Finalize() - '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. - ConexionClose() - Dispose(True) - GC.SuppressFinalize(Me) - End Sub -#End Region - - - - Public Function GetProductosServiciosSinSAT(Opcion As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Gral_ProductosServiciosSinSATGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@Opcion", SqlDbType.Int).Value = Opcion - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los productos sin SAT.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function UpdateProductosServiciosSAT(CvePS As Integer, CveSATPS As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Gral_ProductosServiciosSATUpdate") - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@CveSATPS", SqlDbType.Int).Value = CveSATPS - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar la clave SAT del producto o servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function + .Add("@CvePSAdicionalVigencia", SqlDbType.Int).Value = CvePSAdicionalVigencia + .Add("@PrecioLibre", SqlDbType.Bit).Value = PrecioLibre - Public Function GetProductosModificados(CveEmpresa As Integer, CvePrecioLista As Integer, Optional HorasDiferencia As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_ProductosModificadosGet") - With SqlAdapter.SelectCommand.Parameters + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 2627;") Then + Alert("El Producto o Servicio no se guardo debido a que actualmente se encuentra registrado.", TipoMensaje.MsgAdvertencia) + ElseIf Ex1.Message.Contains("Número: 2601;") Then + Alert("El Nuevo Producto o Servicio tiene Codigo duplicado.", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al intentar guardar los cambios en el Producto o Servicio.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + OnError("Ocurrió un error al intentar guardar los cambios en el Producto o Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function UpdateClasificacionPS(CveClasificacion As Integer, CveUsuario As Integer, CvePS As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_ProductosServiciosClasificacionUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CvePS", SqlDbType.Int).Value = CvePS + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 2627;") Then + Alert("El Producto o Servicio no se guardo debido a que actualmente se encuentra registrado.", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al intentar guardar los cambios de clasificación del Producto o Servicio.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + OnError("Ocurrió un error al intentar guardar los cambio de clasificación del Producto o Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function RemovePS(CvePS As Integer) As Boolean + Dim OnError As Boolean = False + DataAdapter("PA_ProductosServiciosRemove") + + SqlAdapter.SelectCommand.Parameters.Add("@CvePS", SqlDbType.Int).Value = CvePS + + Try + SqlAdapter.Fill(Data) + OnError = True + Catch ex As Exception + Me.OnError("Ocurrió un error al eliminar El Producto Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return OnError + End Function + Public Function GetAllPS(CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_ProductosServiciosGetAll") + + With SqlAdapter.SelectCommand.Parameters .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CvePrecioLista", SqlDbType.Int).Value = CvePrecioLista - .Add("@HorasDiferencia", SqlDbType.Int).Value = HorasDiferencia - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los productos modificados.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As SqlException + If CvePS <> -1 Then + OnError("Ocurrió un error al consultar El Producto o Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + Else + OnError("Ocurrió un error al consultar El Producto o Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End If + End Try + + Return Retorno End Function - Public Function GetPreciosModificados(CveEmpresa As Integer, CvePrecioLista As Integer, Optional HorasDiferencia As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_ProductosPreciosModificadosGet") - With SqlAdapter.SelectCommand.Parameters + Public Function GetPrecioUnitarioPS(CveEmpresa As Integer, CvePS As Integer) As Double + + Dim Retorno As Double = -1 + + DataAdapter("PA_Inv_PrecioUnitarioSalidaGet") + + With SqlAdapter.SelectCommand.Parameters + + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CvePrecioLista", SqlDbType.Int).Value = CvePrecioLista - .Add("@HorasDiferencia", SqlDbType.Int).Value = HorasDiferencia - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los precios modificados.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@PU", SqlDbType.Money).Direction = ParameterDirection.Output + End With + + Try + SqlAdapter.Fill(Data) + Retorno = CDbl(SqlAdapter.SelectCommand.Parameters("@PU").Value) + + Catch Ex1 As SqlException + Me.OnError("Ocurrió un error al obtener el precio unitario.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + Catch ex As Exception + OnError("Ocurrió un error al obtener el precio unitario", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno End Function - Public Function GetExistenciasEmpresa(Codigo As String, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_ProductosExistenciasEmpresaGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@Codigo", SqlDbType.VarChar).Value = Codigo - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener las existencias.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno +#Region "P R O D U C T O S - E Q U I V A L E N C I A S " + + Public Function GetPSEquivalencias(CvePS As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Gral_ProductosServiciosEquivalenciasGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener las equivalencias.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno End Function - Public Function GetVendedoresModificados(CveEmpresa As Integer, Optional HorasDiferencia As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_VendedoresModificadosGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@HorasDiferencia", SqlDbType.Int).Value = HorasDiferencia - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los vendedores.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function -End Class + Public Function AddPSEquivalencias(CvePS As Integer, CveUM As Integer, Cantidad As Decimal, UnidadBase As Boolean, Precio As Double, CveUsuario As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Gral_ProductosServiciosEquivalenciasAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CveUM", SqlDbType.Int).Value = CveUM + .Add("@Cantidad", SqlDbType.Float).Value = Cantidad + .Add("@UnidadBase", SqlDbType.Bit).Value = UnidadBase + .Add("@Precio", SqlDbType.Money).Value = Precio + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + + + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 2627;") Then + Alert("Ya existe una equivalencia con la misma unidad de medida.", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al Guardar la Equivalencia.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + + Catch ex As Exception + OnError("Ocurrió un error al Guardar la Equivalencia", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function UpdatePSEquivalencias(CvePS As Integer, CveUM As Integer, Cantidad As Decimal, UnidadBase As Boolean, Precio As Double, CveUsuario As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Gral_ProductosServiciosEquivalenciasUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CveUM", SqlDbType.Int).Value = CveUM + .Add("@Cantidad", SqlDbType.Float).Value = Cantidad + .Add("@UnidadBase", SqlDbType.Bit).Value = UnidadBase + .Add("@Precio", SqlDbType.Money).Value = Precio + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 2627;") Then + Alert("Ya existe una equivalencia con la misma unidad de medida." + Ex1.Message.ToString, TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al Guardar la Equivalencia.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + OnError("Ocurrió un error al actualizar la Equivalencia", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function RemovePSEquivalencias(CvePS As Integer, CveUM As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Gral_ProductosServiciosEquivalenciasRemove") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CveUM", SqlDbType.Int).Value = CveUM + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + Me.OnError("Ocurrió un error al eliminar la equivalencia.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + + Catch ex As Exception + Me.OnError("Ocurrió un error al eliminar la equivalencia.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + + +#End Region + +#Region "P R O D U C T O S A D I C I O N A L E S " + + Public Function GetPSAdicionales(CvePS As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Gral_ProductosServiciosAdicionalesGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los Productos/Servicios Adicionales.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function AddPSAdicionales(CvePS As Integer, CvePSAdicional As Integer, Cantidad As Decimal) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Gral_ProductosServiciosAdicionalesAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CvePSAdicional", SqlDbType.Int).Value = CvePSAdicional + .Add("@Cantidad", SqlDbType.Money).Value = Cantidad + + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 2627;") Then + Alert("Ya existe una equivalencia con el mismo Producto/Servicio Adicional.", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al Guardar el Producto/Servicio Adicional.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + + Catch ex As Exception + OnError("Ocurrió un error al Guardar el Producto/Servicio Adicional.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function UpdatePSAdicionales(CvePS As Integer, CvePSAdicional As Integer, CvePSAdicionalAnterior As Integer, Cantidad As Decimal) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Gral_ProductosServiciosAdicionalesUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CvePSAdicional", SqlDbType.Int).Value = CvePSAdicional + .Add("@CvePSAdicionalAnterior", SqlDbType.Int).Value = CvePSAdicionalAnterior + .Add("@Cantidad", SqlDbType.Money).Value = Cantidad + + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 2627;") Then + Alert("Ya existe una equivalencia con el mismo Producto/Servicio Adicional." + Ex1.Message.ToString, TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al Guardar el Producto/Servicio Adicional.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + OnError("Ocurrió un error al actualizar el Producto/Servicio Adicional.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function RemovePSAdicionales(CvePS As Integer, CvePSAdicional As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Gral_ProductosServiciosAdicionalesRemove") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CvePSAdicional", SqlDbType.Int).Value = CvePSAdicional + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + Me.OnError("Ocurrió un error al eliminar el Producto/Servicio Adicional.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + + Catch ex As Exception + Me.OnError("Ocurrió un error al eliminar el Producto/Servicio Adicional.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + + +#End Region + +#Region "P A Q U E T E S" + + Public Function UpdatePaquete(CvePS As Integer, PS As String, Precio As Double, Estado As Boolean) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Inv_PaqueteUpdate") + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@PS", SqlDbType.VarChar).Value = PS + .Add("@Precio", SqlDbType.Money).Value = Precio + .Add("@Estado", SqlDbType.Bit).Value = Estado + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar el paquete.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetPaqueteDetalle(CvePSPaquete As Integer, CveEmpresa As Integer, Optional CveUMPaquete As Integer = -1, Optional Cantidad As Double = 0, Optional CveAlmacen As Integer = -1, Optional Fecha As Date = MinFecha, Optional CveVendedor As Integer = -1, Optional CveCliente As Integer = -1) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Inv_PaqueteDetallesGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePSPaquete", SqlDbType.Int).Value = CvePSPaquete + .Add("@CveUMPaquete", SqlDbType.Int).Value = CveUMPaquete + .Add("@Cantidad", SqlDbType.Money).Value = Cantidad + .Add("@CveAlmacen", SqlDbType.Int).Value = CveAlmacen + .Add("@Fecha", SqlDbType.Date).Value = Fecha + .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los Productos y servicios del paquete.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function AddPaqueteDetalle(CvePSPaquete As Integer, CvePS As Integer, Cantidad As Double, Tipo As Integer, CveUnidadMedida As Integer, Optional CveUsuarioModifico As Integer = -1) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Inv_PaquetesAdd") + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePSPaquete", SqlDbType.Int).Value = CvePSPaquete + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@Cantidad", SqlDbType.Money).Value = Cantidad + .Add("@CveUnidadMedida", SqlDbType.Int).Value = CveUnidadMedida + .Add("@Tipo", SqlDbType.Int).Value = Tipo + .Add("@CveUsuarioModifico", SqlDbType.Int).Value = CveUsuarioModifico + + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 2627;") Then + Alert("Ya existe en el Paquete el Producto o Servicio.", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al guardar el Paquete.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + OnError("Ocurrió un error al guardar el Paquete", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + + Public Function DeletePaqueteDetalle(CvePSPaquete As Integer, CvePS As Integer, Cantidad As Double, Tipo As Integer, CveUnidadMedida As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Inv_PaqueteDetalleDelete") + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePSPaquete", SqlDbType.Int).Value = CvePSPaquete + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@Cantidad", SqlDbType.Money).Value = Cantidad + .Add("@Tipo", SqlDbType.Int).Value = Tipo + .Add("@CveUnidadMedida", SqlDbType.Int).Value = CveUnidadMedida + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al ingresar el producto al paquete.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function UpdatePaqueteDetalle(CvePSPaquete As Integer, CvePS As Integer, Cantidad As Double, Tipo As Integer, CveUnidadMedida As Integer, Optional CveUsuarioModifico As Integer = -1) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Inv_PaqueteDetalleUpdate") + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePSPaquete", SqlDbType.Int).Value = CvePSPaquete + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@Cantidad", SqlDbType.Money).Value = Cantidad + .Add("@Tipo", SqlDbType.SmallInt).Value = Tipo + .Add("@CveUnidadMedida", SqlDbType.Int).Value = CveUnidadMedida + .Add("@CveUsuarioModifico", SqlDbType.Int).Value = CveUsuarioModifico + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar el paquete.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + +#End Region + +#Region "P R O D U C T O S - S U C U R S A L E S" + + Public Function GetPSSucursales(CvePS As Integer, CveEmpresa As Integer, Optional CveSubProyecto As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Gral_ProductosServiciosSucursalesGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener las Sucursales habilitadas para el Producto y/o Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetPSSucursalesALL(CvePS As Integer, CveEmpresa As Integer, Optional Codigo As String = "", Optional CodigoBarras As String = "", Optional CveSubProyecto As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Gral_ProductosServiciosSucursalesGetAll") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@Codigo", SqlDbType.VarChar).Value = Codigo + .Add("@CodigoBarras", SqlDbType.VarChar).Value = CodigoBarras + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener las Sucursales habilitadas para el Producto y/o Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function AddPSSucursales(CvePS As Integer, Importe As Double, Minimo As Double, Maximo As Double, CveUsuario As Integer, CveSubProyecto As Integer, Optional PrecioMinimo As Decimal = Nothing) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Gral_ProductosServiciosSucursalesAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@Importe", SqlDbType.Float).Value = Importe + .Add("@Minimo", SqlDbType.Float).Value = Minimo + .Add("@Maximo", SqlDbType.Float).Value = Maximo + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@PrecioMinimo", SqlDbType.Decimal).Value = PrecioMinimo + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 2627;") Then + Alert("Ya existe una Sucursal para el mismo Producto y/o Servicio.", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al Guardar la Sucursal para Producto y/o Servicio.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + + Catch ex As Exception + OnError("Ocurrió un error al Guardar la Sucursal para Producto y/o Servicio", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function UpdatePSSucursales(CvePS As Integer, Importe As Double, Minimo As Double, Maximo As Double, CveUsuario As Integer, CveSubProyecto As Integer, Optional PrecioMinimo As Decimal = Nothing) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Gral_ProductosServiciosSucursalesUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@Importe", SqlDbType.Float).Value = Importe + .Add("@Minimo", SqlDbType.Float).Value = Minimo + .Add("@Maximo", SqlDbType.Float).Value = Maximo + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@PrecioMinimo", SqlDbType.Decimal).Value = PrecioMinimo + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 2627;") Then + Alert("Ya existe una Sucursal para el mismo Producto y/o Servicio.", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al Guardar la Sucursal para Producto y/o Servicio.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + OnError("Ocurrió un error al Guardar la Sucursal para Producto y/o Servicio", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function RemovePSSucursales(CvePS As Integer, CveSubProyecto As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Gral_ProductosServiciosSucursalesRemove") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + Me.OnError("Ocurrió un error al eliminar la Sucursal para Producto y/o Servicio.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + + Catch ex As Exception + Me.OnError("Ocurrió un error al eliminar la Sucursal para Producto y/o Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + +#End Region + + 'Ubicacion temporal + Public Function GetMetodosInv() As Boolean + Dim Retorno = False + + DataAdapter("PA_Inv_MetodosGet") + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + Me.OnError("Ocurrió un error al obtener los Metodos de Inventario.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + Catch ex As Exception + OnError("Ocurrió un error al obtener los Metodos de Inventario.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + + End Function + +#Region " Marcas " + Public Function GetPSAlias(CvePS As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Gral_ProductosServiciosAliasGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + + Retorno = True + Catch ex As SqlException + If CvePS <> -1 Then + OnError("Ocurrió un error al consultar El Producto o Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + Else + OnError("Ocurrió un error al consultar El Producto o Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End If + End Try + + Return Retorno + End Function + + Public Function AddPSAlias(PS As String, CvePS As Integer, Optional CveUsuarioModifico As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Gral_ProductosServiciosAliasAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@PSAlias", SqlDbType.VarChar).Value = If(PS.Length > 845, PS.Substring(0, 845), PS) + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CveUsuarioModifico", SqlDbType.Int).Value = CveUsuarioModifico + End With + + Try + SqlAdapter.Fill(Data) + + Retorno = True + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 2627;") Then + OnError("El Nuevo Producto o Servicio no se guardo debido a que actualmente se encuentra registrado", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + Else + Me.OnError("Ocurrió un error al guardar el nuevo Producto o Servicio.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + OnError("Ocurrió un error al guardar el nuevo Producto o Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function RemovePSAlias(CvePS As Integer, PSAlias As String, CveUsuarioModifico As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Gral_ProductosServiciosAliasRemove") + + SqlAdapter.SelectCommand.Parameters.Add("@CvePS", SqlDbType.Int).Value = CvePS + SqlAdapter.SelectCommand.Parameters.Add("@PSAlias", SqlDbType.VarChar).Value = PSAlias + SqlAdapter.SelectCommand.Parameters.Add("@CveUsuarioModifico", SqlDbType.Int).Value = CveUsuarioModifico + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al eliminar el Alias del Producto o Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function UpdateAplicaSeccionAlmacen(CvePS As Integer, CveEmpresa As Integer, AplicaSeccionAlmacen As Boolean) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Gral_ProductosServiciosSeccionAlmacenUpdate") + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@AplicaSeccionAlmacen", SqlDbType.Bit).Value = AplicaSeccionAlmacen + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + + Catch ex As Exception + OnError("Ocurrió un error al actualizar aplica seccion almacen.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function GetMarcas(CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Gral_MarcasGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Catálogo de Marcas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + + + Public Function AddMarcas(Marca As String, Estatus As Boolean, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Gral_MarcasAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Marca", SqlDbType.VarChar).Value = Marca + .Add("@Estatus", SqlDbType.Bit).Value = Estatus + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 2627;") Then + Alert("Ya existe una Marca del Producto o Servicio con el mismo nombre: " & Marca & ".", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al Guardar la Marca.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + OnError("Ocurrió un error al Guardar la Marca.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + + + Public Function RemoveMarca(CveMarca As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Gral_MarcasRemove") + + SqlAdapter.SelectCommand.Parameters.Add("@CveMarca", SqlDbType.Int).Value = CveMarca + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + Me.OnError("Ocurrió un error al eliminar la Marca.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + Catch ex As Exception + Me.OnError("Ocurrió un error al eliminar la Marca.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + + + + Public Function UpdateMarca(Marca As String, CveMarca As Integer, Estatus As Boolean) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Gral_MarcasUpdate") + With SqlAdapter.SelectCommand.Parameters + .Add("@Marca", SqlDbType.VarChar).Value = Marca + .Add("@CveMarca", SqlDbType.Int).Value = CveMarca + .Add("@Estatus", SqlDbType.Bit).Value = Estatus + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + + Catch ex As Exception + OnError("Ocurrió un error al actualizar la Marca.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + +#End Region + Public Function GetPSMarcas(CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_GRAL_PSMarcasGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Catálogo de Marcas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + +#Region "IMPUESTOS LOCALES" + Public Function GetPSImpuestosLocales(CvePS As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Gral_PSImpuestosLocalesGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los datos de impuestos locales.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + + + Public Function AddPSImpuestosLocales(CvePS As Integer, CveImpuestoLocal As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Gral_PSImpuestosLocalesAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CveImpuestoLocal", SqlDbType.Int).Value = CveImpuestoLocal + End With + + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error al tratar de agregar datos a la base de datos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + + Public Function LimpiaImpuestosLocales(CveCliente As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Gral_PSImpuestosLocalesRemove") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePS", SqlDbType.Int).Value = CveCliente + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al limpiar la lista de deducciones.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + +#End Region + +#Region "C O M P U E S T O S" + Public Function GetCompuestosActivos(CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Gral_CompuestosGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Catálogo de Compuestos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + + + + Public Function AddCompuestoActivo(Compuesto As String, Estatus As Boolean, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Gral_CompuestosAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Compuesto", SqlDbType.VarChar).Value = Compuesto + .Add("@Estatus", SqlDbType.Bit).Value = Estatus + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 2627;") Then + Alert("Ya existe un compuesto activo con el mismo nombre: " & Compuesto & ".", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al Guardar el compuesto.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + OnError("Ocurrió un error al Guardar el compuesto.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + + + Public Function RemoveCompuestoActivo(CveCompuesto As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Gral_CompuestosRemove") + + SqlAdapter.SelectCommand.Parameters.Add("@CveCompuesto", SqlDbType.Int).Value = CveCompuesto + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + Me.OnError("Ocurrió un error al eliminar el compuesto.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + Catch ex As Exception + Me.OnError("Ocurrió un error al eliminar el compuesto.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + + + + Public Function UpdateCompuestoActivo(Compuesto As String, CveCompuesto As Integer, Estatus As Boolean) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Gral_CompuestoUpdate") + With SqlAdapter.SelectCommand.Parameters + .Add("@Compuesto", SqlDbType.VarChar).Value = Compuesto + .Add("@CveCompuesto", SqlDbType.Int).Value = CveCompuesto + .Add("@Estatus", SqlDbType.Bit).Value = Estatus + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + + Catch ex As Exception + OnError("Ocurrió un error al actualizar el compuesto.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function +#End Region + +#Region "UNIFICAR PRODUCTO" + Public Function UnificarPS(CvePSPrincipal As Integer, CvePSUnificado As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_PS_PSUnificar") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePSPrincipal", SqlDbType.Int).Value = CvePSPrincipal + .Add("@CvePSUnificado", SqlDbType.Int).Value = CvePSUnificado + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + OnError("Ocurrió un error al intentar Unificar los Productos o Servicios.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + Catch ex As Exception + OnError("Ocurrió un error al intentar Unificar los Productos o Servicios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function +#End Region + + +#Region "Precios Lista" + Public Function GetPSPreciosLista(CveEmpresa As Integer, CvePrecioLista As Integer, Optional CveClasificacion As Integer = -1, Optional CvePS As Integer = -1, + Optional CveProveedor As Integer = -1, Optional Estado As Integer = -1, Optional Marcas As String = "-1", Optional CveModelo As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_PSPrecioListaGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CvePrecioLista", SqlDbType.Int).Value = CvePrecioLista + .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor + .Add("@Estado", SqlDbType.Int).Value = Estado + .Add("@Marcas", SqlDbType.VarChar).Value = Marcas + .Add("@CveModelo", SqlDbType.Int).Value = CveModelo + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Catálogo de PS con precios de lista.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function UpdatePSPreciosLista(Importe As Decimal, CvePrecioLista As Integer, Porcentaje As Decimal, CvePS As Integer, CveUsuario As Integer, Fecha As DateTime, Fijo As Boolean, Optional PrecioMinimo As Decimal = Nothing) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_PSPrecioListaAdd") + + With SqlAdapter.SelectCommand.Parameters + + If Importe = -1 Then + .Add("@Importe", SqlDbType.Float).Value = DBNull.Value + Else + .Add("@Importe", SqlDbType.Float).Value = Importe + End If + + .Add("@CvePrecioLista", SqlDbType.Int).Value = CvePrecioLista + + If Porcentaje = -1 Then + .Add("@Porcentaje", SqlDbType.Money).Value = DBNull.Value + Else + .Add("@Porcentaje", SqlDbType.Money).Value = Porcentaje + End If + + .Add("@PrecioMinimo", SqlDbType.Decimal).Value = PrecioMinimo + + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@Fecha", SqlDbType.DateTime).Value = Fecha + .Add("@Fijo", SqlDbType.Bit).Value = Fijo + + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar los precios de lista.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function UpdatePSPrecios(Importe As Decimal, CvePrecioLista As Integer, Porcentaje As Decimal, CvePS As Integer, CveUsuario As Integer, Fecha As DateTime, Fijo As Boolean, Optional PrecioMinimo As Decimal = Nothing) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_PSPrecioUpdate") + + With SqlAdapter.SelectCommand.Parameters + + If Importe = -1 Then + .Add("@Importe", SqlDbType.Float).Value = DBNull.Value + Else + .Add("@Importe", SqlDbType.Float).Value = Importe + End If + + If Porcentaje = -1 Then + .Add("@Porcentaje", SqlDbType.Money).Value = DBNull.Value + Else + .Add("@Porcentaje", SqlDbType.Money).Value = Porcentaje + End If + + .Add("@PrecioMinimo", SqlDbType.Decimal).Value = PrecioMinimo + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@Fecha", SqlDbType.DateTime).Value = Fecha + .Add("@Fijo", SqlDbType.Bit).Value = Fijo + + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar los precios de lista.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + + Public Function GetPSPrecioLista(CvePS As Integer, CveEmpresa As Integer, Optional CvePrecioLista As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Gral_ProductosServiciosPrecioListaGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CvePrecioLista", SqlDbType.Int).Value = CvePrecioLista + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los precios de lista para el Producto/Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + + End Function + + Public Function GetPSExistencias(CvePS As Integer, CvePrecioLista As Integer, CveUnidadMedida As Integer, CveEmpresa As Integer, + CveAlmacen As Integer, Optional CveSeccionAlmacen As Integer = -1, Optional CveTipoAlmacen As Integer = -1, Optional CveSubProyecto As Integer = -1, + Optional FechaMovto As String = "-1", Optional Serie As String = "-1", Optional CveVendedor As Integer = -1, Optional CveCliente As Integer = -1, + Optional ExcluyeAdelantado As Integer = -1, Optional PendientePorSurtir As Integer = -1, Optional Lote As String = "-1", Optional Batch As String = "-1", + Optional ExcluyeApartados As Integer = 1, Optional RestringirAlmacenes As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_ProductosExistenciasGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CvePrecioLista", SqlDbType.Int).Value = CvePrecioLista + .Add("@CveUnidadMedida", SqlDbType.Int).Value = CveUnidadMedida + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveAlmacen", SqlDbType.Int).Value = CveAlmacen + .Add("@CveSeccionAlmacen", SqlDbType.Int).Value = CveSeccionAlmacen + .Add("@CveTipoAlmacen", SqlDbType.Int).Value = CveTipoAlmacen + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@FechaMovto", SqlDbType.DateTime).Value = DateTime.ParseExact(FechaMovto, "yyyy/MM/dd HH:mm", Nothing) + .Add("@Serie", SqlDbType.VarChar).Value = Serie + .Add("@Lote", SqlDbType.VarChar).Value = Lote + .Add("@Batch", SqlDbType.VarChar).Value = Batch + .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@ExcluyeAdelantado", SqlDbType.Int).Value = ExcluyeAdelantado + .Add("@PendientePorSurtir", SqlDbType.Int).Value = PendientePorSurtir + .Add("@ExcluyeApartados", SqlDbType.Int).Value = ExcluyeApartados + .Add("@RestringirAlmacenes", SqlDbType.Int).Value = RestringirAlmacenes + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener las productos y sus existencias.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function GetPSExistenciasWS(CvePS As Integer, CvePrecioLista As Integer, CveUnidadMedida As Integer, CveEmpresa As Integer, + CveAlmacen As Integer, Optional CveSeccionAlmacen As Integer = -1, Optional CveTipoAlmacen As Integer = -1, Optional CveSubProyecto As Integer = -1, + Optional FechaMovto As String = "-1", Optional Serie As String = "-1", Optional CveVendedor As Integer = -1, Optional CveCliente As Integer = -1, + Optional ExcluyeAdelantado As Integer = -1, Optional PendientePorSurtir As Integer = -1, Optional Lote As String = "-1", Optional Batch As String = "-1", + Optional ExcluyeApartados As Integer = 1, Optional RestringirAlmacenes As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_ProductosExistenciasWSGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CvePrecioLista", SqlDbType.Int).Value = CvePrecioLista + .Add("@CveUnidadMedida", SqlDbType.Int).Value = CveUnidadMedida + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveAlmacen", SqlDbType.Int).Value = CveAlmacen + .Add("@CveSeccionAlmacen", SqlDbType.Int).Value = CveSeccionAlmacen + .Add("@CveTipoAlmacen", SqlDbType.Int).Value = CveTipoAlmacen + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@FechaMovto", SqlDbType.DateTime).Value = DateTime.ParseExact(FechaMovto, "yyyy/MM/dd HH:mm", Nothing) + .Add("@Serie", SqlDbType.VarChar).Value = Serie + .Add("@Lote", SqlDbType.VarChar).Value = Lote + .Add("@Batch", SqlDbType.VarChar).Value = Batch + .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@ExcluyeAdelantado", SqlDbType.Int).Value = ExcluyeAdelantado + .Add("@PendientePorSurtir", SqlDbType.Int).Value = PendientePorSurtir + .Add("@ExcluyeApartados", SqlDbType.Int).Value = ExcluyeApartados + .Add("@RestringirAlmacenes", SqlDbType.Int).Value = RestringirAlmacenes + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener las productos y sus existencias.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + +#End Region + +#Region "Porcentaje Productos" + Public Function GetPorcentajeProductos(CveCliente As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_PorcentajeProductosGet") + + With SqlAdapter.SelectCommand.Parameters + + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los porcentajes de los productos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function AddPorcentajeProductos(CveCliente As Integer, CvePS As Integer, PorcentajeProducto As Decimal, CveUsuario As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_PorcentajeProductosAdd") + + With SqlAdapter.SelectCommand.Parameters + + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@PorcentajeProducto", SqlDbType.SmallMoney).Value = PorcentajeProducto + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar el porcentaje del producto.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function UpdatePorcentajeProductos(CveCliente As Integer, CvePS As Integer, PorcentajeProducto As Decimal) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_PorcentajeProductosUpdate") + + With SqlAdapter.SelectCommand.Parameters + + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@PorcentajeProducto", SqlDbType.SmallMoney).Value = PorcentajeProducto + + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar el porcentaje del producto.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function RemovePorcentajeProductos(CveCliente As Integer, CvePS As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_PorcentajeProductosRemove") + + With SqlAdapter.SelectCommand.Parameters + + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CvePS", SqlDbType.Int).Value = CvePS + + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar el porcentaje del producto.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +#End Region + +#Region "Porcentaje Marcas de Productos" + Public Function GetPorcentajeMarcas(CveCliente As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_PorcentajeMarcasGet") + + With SqlAdapter.SelectCommand.Parameters + + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los porcentajes de las Marcas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function AddPorcentajeMarcas(CveCliente As Integer, CveMarca As Integer, PorcentajeProducto As Decimal, PorcentajeProducto2 As Decimal, PorcentajeProducto3 As Decimal, CveUsuario As Integer, Optional ProntoPago As Decimal = -1, Optional Plazo As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_PorcentajeMarcasAdd") + + With SqlAdapter.SelectCommand.Parameters + + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveMarca", SqlDbType.Int).Value = CveMarca + .Add("@PorcentajeProducto", SqlDbType.SmallMoney).Value = PorcentajeProducto + .Add("@PorcentajeProducto2", SqlDbType.SmallMoney).Value = PorcentajeProducto2 + .Add("@PorcentajeProducto3", SqlDbType.SmallMoney).Value = PorcentajeProducto3 + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@ProntoPago", SqlDbType.SmallMoney).Value = ProntoPago + .Add("@Plazo", SqlDbType.SmallInt).Value = Plazo + + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar el porcentaje de la Marca.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function UpdatePorcentajeMarcas(CveCliente As Integer, CveMarca As Integer, PorcentajeProducto As Decimal, PorcentajeProducto2 As Decimal, PorcentajeProducto3 As Decimal, Optional ProntoPago As Decimal = -1, Optional Plazo As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_PorcentajeMarcasUpdate") + + With SqlAdapter.SelectCommand.Parameters + + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveMarca", SqlDbType.Int).Value = CveMarca + .Add("@PorcentajeProducto", SqlDbType.SmallMoney).Value = PorcentajeProducto + .Add("@PorcentajeProducto2", SqlDbType.SmallMoney).Value = PorcentajeProducto2 + .Add("@PorcentajeProducto3", SqlDbType.SmallMoney).Value = PorcentajeProducto3 + .Add("@ProntoPago", SqlDbType.SmallMoney).Value = ProntoPago + .Add("@Plazo", SqlDbType.SmallInt).Value = Plazo + + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar el porcentaje de la Marca.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function RemovePorcentajeMarcas(CveCliente As Integer, CveMarca As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_PorcentajeMarcasRemove") + + With SqlAdapter.SelectCommand.Parameters + + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveMarca", SqlDbType.Int).Value = CveMarca + + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar el porcentaje de la Marca.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +#End Region +#Region "IDisposable Support" + + + ' IDisposable + Protected Overridable Sub Dispose(disposing As Boolean) + If Not Me.disposedValue Then + If disposing Then + ' TODO: dispose managed state (managed objects). + If Not Data Is Nothing Then Data.Dispose() + If Not SqlAdapter Is Nothing Then SqlAdapter.Dispose() + If Not SqlCommand Is Nothing Then SqlCommand.Dispose() + If SqlConexion.State <> ConnectionState.Closed Then SqlConexion.Close() + If Not SqlConexion Is Nothing Then SqlConexion.Dispose() + End If + + ' TODO: free unmanaged resources (unmanaged objects) and override Finalize() below. + ' TODO: set large fields to null. + End If + Me.disposedValue = True + End Sub + + ' TODO: override Finalize() only if Dispose(disposing As Boolean) above has code to free unmanaged resources. + 'Protected Overrides Sub Finalize() + ' ' Do not change this code. Put cleanup code in Dispose(disposing As Boolean) above. + ' Dispose(False) + ' MyBase.Finalize() + '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. + ConexionClose() + Dispose(True) + GC.SuppressFinalize(Me) + End Sub +#End Region + + + + Public Function GetProductosServiciosSinSAT(Opcion As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Gral_ProductosServiciosSinSATGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@Opcion", SqlDbType.Int).Value = Opcion + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los productos sin SAT.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function UpdateProductosServiciosSAT(CvePS As Integer, CveSATPS As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Gral_ProductosServiciosSATUpdate") + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CveSATPS", SqlDbType.Int).Value = CveSATPS + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar la clave SAT del producto o servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetProductosModificados(CveEmpresa As Integer, CvePrecioLista As Integer, Optional HorasDiferencia As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_ProductosModificadosGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CvePrecioLista", SqlDbType.Int).Value = CvePrecioLista + .Add("@HorasDiferencia", SqlDbType.Int).Value = HorasDiferencia + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los productos modificados.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function GetPreciosModificados(CveEmpresa As Integer, CvePrecioLista As Integer, Optional HorasDiferencia As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_ProductosPreciosModificadosGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CvePrecioLista", SqlDbType.Int).Value = CvePrecioLista + .Add("@HorasDiferencia", SqlDbType.Int).Value = HorasDiferencia + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los precios modificados.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetExistenciasEmpresa(Codigo As String, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_ProductosExistenciasEmpresaGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@Codigo", SqlDbType.VarChar).Value = Codigo + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener las existencias.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetVendedoresModificados(CveEmpresa As Integer, Optional HorasDiferencia As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_VendedoresModificadosGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@HorasDiferencia", SqlDbType.Int).Value = HorasDiferencia + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los vendedores.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +End Class diff --git a/App_Code/Modelos.vb b/App_Code/Modelos.vb index 0f1d562f6..807954b16 100644 --- a/App_Code/Modelos.vb +++ b/App_Code/Modelos.vb @@ -382,7 +382,7 @@ Namespace Modelos Me.ListaMensajes = New List(Of String) Me.FolioFiscal = "" Me.GenerarPDFFactura = False - IniciaValores() + IniciaValores() Dim ObjVentas As New ClsVentas() If ObjVentas.GetVenta(CveVenta, CveEmpresa) Then @@ -414,49 +414,49 @@ Namespace Modelos TmpDTImpuestos.Columns.Add("Importe", GetType(Double)) TmpDTImpuestos.Columns.Add("Orden", GetType(Integer)) - Dim DR As DataRow = TmpDTImpuestos.NewRow() - If dtVentas(0)("SubTotal").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Subtotal" : DR("Importe") = dtVentas(0)("SubTotal").ToString.ToDouble : DR("Orden") = 10 : TmpDTImpuestos.Rows.Add(DR) - DR = TmpDTImpuestos.NewRow() - If dtVentas(0)("Descuento").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Descuentos" : DR("Importe") = dtVentas(0)("Descuento").ToString.ToDouble : DR("Orden") = 20 : TmpDTImpuestos.Rows.Add(DR) - DR = TmpDTImpuestos.NewRow() - If dtVentas(0)("Amortizacion").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Amort.Ant" : DR("Importe") = dtVentas(0)("Amortizacion").ToString.ToDouble : DR("Orden") = 30 : TmpDTImpuestos.Rows.Add(DR) - DR = TmpDTImpuestos.NewRow() - If dtVentas(0)("SubTotal").ToString.ToDouble <> (dtVentas(0)("SubTotal").ToString.ToDouble - dtVentas(0)("Descuento").ToString.ToDouble - dtVentas(0)("Amortizacion").ToString.ToDouble) Then DR("ImpuestoLocal") = "SubTotal2" : DR("Importe") = (dtVentas(0)("SubTotal").ToString.ToDouble - dtVentas(0)("Descuento").ToString.ToDouble - dtVentas(0)("Amortizacion").ToString.ToDouble) : DR("Orden") = 40 : TmpDTImpuestos.Rows.Add(DR) - DR = TmpDTImpuestos.NewRow() - If dtVentas(0)("IVA").ToString.ToDouble >= 0 Then DR("ImpuestoLocal") = "IVA" : DR("Importe") = dtVentas(0)("IVA").ToString.ToDouble : DR("Orden") = 50 : TmpDTImpuestos.Rows.Add(DR) - - 'solo para eclipse, que muesre un subtotal debajo de IVA - If UsuarioActual.CveEmpresa = 15 Then DR = TmpDTImpuestos.NewRow() : DR("ImpuestoLocal") = "Subtotal2" : DR("Importe") = (dtVentas(0)("SubTotal").ToString.ToDouble - dtVentas(0)("Descuento").ToString.ToDouble - dtVentas(0)("Amortizacion").ToString.ToDouble) + dtVentas(0)("IVA").ToString.ToDouble : DR("Orden") = 51 : TmpDTImpuestos.Rows.Add(DR) - DR = TmpDTImpuestos.NewRow() - If dtVentas(0)("RetIVA").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Ret.IVA" : DR("Importe") = dtVentas(0)("RetIVA").ToString.ToDouble : DR("Orden") = 60 : TmpDTImpuestos.Rows.Add(DR) - DR = TmpDTImpuestos.NewRow() - If dtVentas(0)("RetISR").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Ret.ISR" : DR("Importe") = dtVentas(0)("RetISR").ToString.ToDouble : DR("Orden") = 70 : TmpDTImpuestos.Rows.Add(DR) - DR = TmpDTImpuestos.NewRow() - - If dtVentas(0)("IEPS").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "IEPS" : DR("Importe") = dtVentas(0)("IEPS").ToString.ToDouble : DR("Orden") = 80 : TmpDTImpuestos.Rows.Add(DR) - DR = TmpDTImpuestos.NewRow() - - If dtVentas(0)("Total").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Total" : DR("Importe") = dtVentas(0)("Total").ToString.ToDouble : DR("Orden") = 100 : TmpDTImpuestos.Rows.Add(DR) + Dim DR As DataRow = TmpDTImpuestos.NewRow() + If dtVentas(0)("SubTotal").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Subtotal" : DR("Importe") = dtVentas(0)("SubTotal").ToString.ToDouble : DR("Orden") = 10 : TmpDTImpuestos.Rows.Add(DR) + DR = TmpDTImpuestos.NewRow() + If dtVentas(0)("Descuento").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Descuentos" : DR("Importe") = dtVentas(0)("Descuento").ToString.ToDouble : DR("Orden") = 20 : TmpDTImpuestos.Rows.Add(DR) + DR = TmpDTImpuestos.NewRow() + If dtVentas(0)("Amortizacion").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Amort.Ant" : DR("Importe") = dtVentas(0)("Amortizacion").ToString.ToDouble : DR("Orden") = 30 : TmpDTImpuestos.Rows.Add(DR) + DR = TmpDTImpuestos.NewRow() + If dtVentas(0)("SubTotal").ToString.ToDouble <> (dtVentas(0)("SubTotal").ToString.ToDouble - dtVentas(0)("Descuento").ToString.ToDouble - dtVentas(0)("Amortizacion").ToString.ToDouble) Then DR("ImpuestoLocal") = "SubTotal2" : DR("Importe") = (dtVentas(0)("SubTotal").ToString.ToDouble - dtVentas(0)("Descuento").ToString.ToDouble - dtVentas(0)("Amortizacion").ToString.ToDouble) : DR("Orden") = 40 : TmpDTImpuestos.Rows.Add(DR) + DR = TmpDTImpuestos.NewRow() + If dtVentas(0)("IVA").ToString.ToDouble >= 0 Then DR("ImpuestoLocal") = "IVA" : DR("Importe") = dtVentas(0)("IVA").ToString.ToDouble : DR("Orden") = 50 : TmpDTImpuestos.Rows.Add(DR) + + 'solo para eclipse, que muesre un subtotal debajo de IVA + If UsuarioActual.CveEmpresa = 15 Then DR = TmpDTImpuestos.NewRow() : DR("ImpuestoLocal") = "Subtotal2" : DR("Importe") = (dtVentas(0)("SubTotal").ToString.ToDouble - dtVentas(0)("Descuento").ToString.ToDouble - dtVentas(0)("Amortizacion").ToString.ToDouble) + dtVentas(0)("IVA").ToString.ToDouble : DR("Orden") = 51 : TmpDTImpuestos.Rows.Add(DR) + DR = TmpDTImpuestos.NewRow() + If dtVentas(0)("RetIVA").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Ret.IVA" : DR("Importe") = dtVentas(0)("RetIVA").ToString.ToDouble : DR("Orden") = 60 : TmpDTImpuestos.Rows.Add(DR) + DR = TmpDTImpuestos.NewRow() + If dtVentas(0)("RetISR").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Ret.ISR" : DR("Importe") = dtVentas(0)("RetISR").ToString.ToDouble : DR("Orden") = 70 : TmpDTImpuestos.Rows.Add(DR) DR = TmpDTImpuestos.NewRow() - If ObjVentas.GetVentaImpuestosLocales(CveVenta) Then - - Dim dtImpuesto As DataTable = ObjVentas.DtResultados - If dtImpuesto.Rows.Count > 0 Then - For Each Row As DataRow In dtImpuesto.Rows - Dim Orden = 80 - If Row("Importe").ToString.ToDouble <> 0 Then - DR("ImpuestoLocal") = Row("ImpuestoLocal").ToString - DR("Importe") = Row("Importe").ToString.ToDouble - DR("Orden") = Orden - TmpDTImpuestos.Rows.Add(DR) - DR = TmpDTImpuestos.NewRow() - Orden = Orden + 1 - End If - Next - End If - Me.DtDeduccion = TmpDTImpuestos.FiltraParametros("", Orderby:="Orden ASC") - + If dtVentas(0)("IEPS").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "IEPS" : DR("Importe") = dtVentas(0)("IEPS").ToString.ToDouble : DR("Orden") = 80 : TmpDTImpuestos.Rows.Add(DR) + DR = TmpDTImpuestos.NewRow() + + If dtVentas(0)("Total").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Total" : DR("Importe") = dtVentas(0)("Total").ToString.ToDouble : DR("Orden") = 100 : TmpDTImpuestos.Rows.Add(DR) + DR = TmpDTImpuestos.NewRow() + + If ObjVentas.GetVentaImpuestosLocales(CveVenta) Then + + Dim dtImpuesto As DataTable = ObjVentas.DtResultados + If dtImpuesto.Rows.Count > 0 Then + For Each Row As DataRow In dtImpuesto.Rows + Dim Orden = 80 + If Row("Importe").ToString.ToDouble <> 0 Then + DR("ImpuestoLocal") = Row("ImpuestoLocal").ToString + DR("Importe") = Row("Importe").ToString.ToDouble + DR("Orden") = Orden + TmpDTImpuestos.Rows.Add(DR) + DR = TmpDTImpuestos.NewRow() + Orden = Orden + 1 + End If + Next + End If + Me.DtDeduccion = TmpDTImpuestos.FiltraParametros("", Orderby:="Orden ASC") + End If End Sub @@ -3952,7 +3952,7 @@ Namespace Modelos 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,, Modulo:="Mod/M2") + Dim CveMovimientoInventario As Integer = ObjInventario.AddMovimiento(CveAlmacen, ConceptoEntrada, CveMoneda, Now, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVenta, -1, -1, CveMovimientoRelacionado:=CveMovimientoRelacionado, Modulo:="Mod/M2") If CveMovimientoInventario > 0 Then diff --git a/Bancos/PopIECompras.aspx.vb b/Bancos/PopIECompras.aspx.vb index 11f73ffd5..8f1a3f8bf 100644 --- a/Bancos/PopIECompras.aspx.vb +++ b/Bancos/PopIECompras.aspx.vb @@ -122,6 +122,14 @@ Partial Class Bancos_PopIECompras Set(value As Integer) ViewState("IdCuentaBancaria") = value End Set + End Property + Private Property IdCuentaBancariaComplementaria As Integer + Get + Return ViewState("IdCuentaBancariaComplementaria").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("IdCuentaBancariaComplementaria") = value + End Set End Property Private ReadOnly Property IdCtaContMonedaExtranjera As Integer Get @@ -482,6 +490,7 @@ Partial Class Bancos_PopIECompras ViewState("IdCtaContRetIVA") = 0 ViewState("IdCtaContRetISR") = 0 ViewState("IdCuentaBancaria") = 0 + ViewState("IdCuentaBancariaComplementaria") = 0 ViewState("IdCtaAnticipo") = 0 ViewState("CveCuentaMonedaExtranjera") = 0 @@ -1107,9 +1116,9 @@ Partial Class Bancos_PopIECompras RegistraScript("CambiaDolaresPesos();") End If - IdCuentaBancaria = dr("IdCtaContable").ToString.ToEntero - CveCuentaBancaria = dr("IdCtaContableSIG").ToString.ToEntero - + IdCuentaBancaria = dr("IdCtaContable").ToString.ToEntero + IdCuentaBancariaComplementaria = dr("IdCtaContableComplementaria").ToString.ToEntero + If dr("UsaTarjeta").ToString = "True" Then CargaGridTarjetas() Else @@ -2814,15 +2823,13 @@ Partial Class Bancos_PopIECompras CveCuenta = CveCuentaCliente End If Else - IdCtaContable = IdCtaContComplementaria - CveCuenta = CveCuentaComplementaria + IdCtaContable = IdCuentaBancariaComplementaria If ImporteMovimiento <> 0 AndAlso (IdCtaContable > 0 Or UsuarioActual.CveEmpresa = 119) Then If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, TxtObservaciones.Text, 204, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, -1, CveCompra, -1, -1, CveProveedor:=CveProveedor2, CvePersonal:=CvePersonal, ImporteMX:=ImporteMovimiento * tipoCambioPago - ImporteMovimiento, ImporteME:=ImporteMovimiento, TipoCambio:=tipoCambioPago, CveCuenta:=CveCuenta) Then MsgError = "No se pudo insertar la póliza" End If ImporteMX = ImporteMovimiento - IdCtaContable = IdCtaContMonedaExtranjera - CveCuenta = CveCuentaMonedaExtranjera + IdCtaContable = IdCuentaBancaria End If End If diff --git a/Inventarios/RecepcionAlmacen.aspx.vb b/Inventarios/RecepcionAlmacen.aspx.vb index 8bdefd9e1..705787fee 100644 --- a/Inventarios/RecepcionAlmacen.aspx.vb +++ b/Inventarios/RecepcionAlmacen.aspx.vb @@ -1021,6 +1021,7 @@ Partial Class Inventarios_RecepcionAlmacen If UsuarioActual.Empresa.Funcionalidad(594) = "1" AndAlso Not UsuarioActual.TienePermisoProceso(314) Then DivDocumentos.Visible = True + UpDocumentos.Update() End If DtDatosDetalle = Nothing @@ -1184,6 +1185,11 @@ Partial Class Inventarios_RecepcionAlmacen DivCodigoSeriePS.Visible = False End If + If UsuarioActual.Empresa.Funcionalidad(594) = "1" AndAlso Not UsuarioActual.TienePermisoProceso(314) Then + DivDocumentos.Visible = True + UpDocumentos.Update() + End If + End If Else BtnGuardar.Visible = False @@ -1235,6 +1241,11 @@ Partial Class Inventarios_RecepcionAlmacen DivCodigoSeriePS.Visible = False End If + If UsuarioActual.Empresa.Funcionalidad(594) = "1" AndAlso Not UsuarioActual.TienePermisoProceso(314) Then + DivDocumentos.Visible = True + UpDocumentos.Update() + End If + End If Else BtnGuardar.Visible = False @@ -4072,6 +4083,13 @@ Partial Class Inventarios_RecepcionAlmacen Else DivCodigoSeriePS.Visible = False End If + + If UsuarioActual.Empresa.Funcionalidad(594) = "1" AndAlso Not UsuarioActual.TienePermisoProceso(314) Then + DivDocumentos.Visible = True + UpDocumentos.Update() + End If + + CargaGVInv() Else