diff --git a/App_Code/ClsAF.vb b/App_Code/ClsAF.vb index 274b51195..8c9c1da2b 100644 --- a/App_Code/ClsAF.vb +++ b/App_Code/ClsAF.vb @@ -1,3440 +1,3440 @@ -Option Strict On -Option Explicit On - -Imports System.Data -Imports System.Data.SqlClient -Imports Extensiones -Imports System -Imports System.Configuration - -Public Class ClsAF - Implements IDisposable - -#Region "Campos" - 'SQL - Private SqlConexion As SqlConnection - Private SqlAdapter As SqlDataAdapter - Private SqlCommand As SqlCommand - Private SqlTransacc As SqlTransaction - Private Data As DataTable - Private DSet As New DataSet - - Private disposedValue As Boolean = False ' Para detectar llamadas redundantes - 'REGISTRAR CONEXIÓN - Private CveConexion As Integer = 0 +Option Strict On +Option Explicit On + +Imports System.Data +Imports System.Data.SqlClient +Imports Extensiones +Imports System +Imports System.Configuration + +Public Class ClsAF + Implements IDisposable + +#Region "Campos" + 'SQL + Private SqlConexion As SqlConnection + Private SqlAdapter As SqlDataAdapter + Private SqlCommand As SqlCommand + Private SqlTransacc As SqlTransaction + Private Data As DataTable + Private DSet As New DataSet + + Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'REGISTRAR CONEXIÓN + Private CveConexion As Integer = 0 Private EsTransaccionCompartida As Boolean = False Public CveMetricaValor As Integer = 0 -#End Region +#End Region -#Region "Propiedades" - Public ReadOnly Property DtResultados() As DataTable - Get - DtResultados = Data - End Get +#Region "Propiedades" + Public ReadOnly Property DtResultados() As DataTable + Get + DtResultados = Data + End Get End Property Public ReadOnly Property DSResultados() As DataSet Get DSResultados = DSet End Get - End Property - - Public Property CveActivoFijo As Integer - Public Property Codigo As String - Public Property Descripcion As String - Public Property CveCompra As Integer - Public Property ValorCompra As Double - Public Property FechaCompra As Date - Public Property CuentaInicial As Integer - Public Property CveTipoActivoFijo As Integer - Public Property TipoActivoFijo As String - Public Property CveSubTipoActivoFijo As Integer - Public Property SubTipoActivoFijo As String - Public Property CveModeloActivoFijo As Integer - Public Property ModeloActivoFijo As String - Public Property CveMarcaActivoFijo As Integer - Public Property MarcaActivoFijo As String - Public Property CvePersonaResponsable As Integer - Public Property Responsable As String - Public Property NoSerie As String - Public Property Año As Integer - Public Property CveSubProyecto As Integer - Public Property SubProyecto As String - Public Property CveProyecto As Integer - Public Property Proyecto As String - Public Property Cuenta As Integer - Public Property CveEstadoActivoFijo As Integer - Public Property EstadoActivoFijo As String - Public Property IdCtaContDepreciacion As Integer - Public Property PorDepreciacion As Double - Public Property FechaUltimaDepreciacion As DateTime - Public Property Observaciones As String - Public Property FechaIng As Date - Public Property CveUsuario As Integer - Public Property Usuario As String - Public Property CveEmpresa As Integer - Public Property FolioVale As Integer - Public Property FolioResguardo As Integer - Public Property MesesDepreciacion As Integer - Public Property CveCliente As Integer - Public Property NombreCliente As String - Public Property MedidaUso As String - Public Property CveMovimientoInv As Integer - Public Property FolioInv As String - Public Property AlmacenInv As String - Public Property CveMarcaAF As Integer - Public Property CveModeloAF As Integer - Public Property CveGrupoAF As Integer - Public Property CveAFPadre As Integer - Public Property CveDispositivo As Integer + End Property + + Public Property CveActivoFijo As Integer + Public Property Codigo As String + Public Property Descripcion As String + Public Property CveCompra As Integer + Public Property ValorCompra As Double + Public Property FechaCompra As Date + Public Property CuentaInicial As Integer + Public Property CveTipoActivoFijo As Integer + Public Property TipoActivoFijo As String + Public Property CveSubTipoActivoFijo As Integer + Public Property SubTipoActivoFijo As String + Public Property CveModeloActivoFijo As Integer + Public Property ModeloActivoFijo As String + Public Property CveMarcaActivoFijo As Integer + Public Property MarcaActivoFijo As String + Public Property CvePersonaResponsable As Integer + Public Property Responsable As String + Public Property NoSerie As String + Public Property Año As Integer + Public Property CveSubProyecto As Integer + Public Property SubProyecto As String + Public Property CveProyecto As Integer + Public Property Proyecto As String + Public Property Cuenta As Integer + Public Property CveEstadoActivoFijo As Integer + Public Property EstadoActivoFijo As String + Public Property IdCtaContDepreciacion As Integer + Public Property PorDepreciacion As Double + Public Property FechaUltimaDepreciacion As DateTime + Public Property Observaciones As String + Public Property FechaIng As Date + Public Property CveUsuario As Integer + Public Property Usuario As String + Public Property CveEmpresa As Integer + Public Property FolioVale As Integer + Public Property FolioResguardo As Integer + Public Property MesesDepreciacion As Integer + Public Property CveCliente As Integer + Public Property NombreCliente As String + Public Property MedidaUso As String + Public Property CveMovimientoInv As Integer + Public Property FolioInv As String + Public Property AlmacenInv As String + Public Property CveMarcaAF As Integer + Public Property CveModeloAF As Integer + Public Property CveGrupoAF As Integer + Public Property CveAFPadre As Integer + Public Property CveDispositivo As Integer Public Property MedidaVehicular As Integer Public Property CveTipoServicio As Integer Public Property CveOrdenTrabajo As Integer Public Property FolioOT As Integer -#End Region +#End Region - 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("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 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 - - -#Region "A C T I V O S- F I J O S" - - Public Function GetRepActivosFijos(CveActivoFijo As Integer, CveEmpresa As Integer, Codigo As String, Descripcion As String, CveTipoActivoFijo As Integer, CveSubTipoActivoFijo As Integer, NoSerie As String, Año As Integer, CvePersonaResponsable As Integer, CveProyecto As Integer, CveSubProyecto As Integer, CveEstadoActivoFijo As Integer, CaracteristicaValor As String, Optional BuscaGrupoEmpresa As Integer = -1, Optional Agrupador As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_AFGetRep") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@Codigo", SqlDbType.VarChar).Value = Codigo - .Add("@Descripcion", SqlDbType.VarChar).Value = Descripcion - .Add("@CveTipoActivoFijo", SqlDbType.Int).Value = CveTipoActivoFijo - .Add("@CveSubTipoActivoFijo", SqlDbType.Int).Value = CveSubTipoActivoFijo - .Add("@NoSerie", SqlDbType.VarChar).Value = NoSerie - .Add("@Año", SqlDbType.Int).Value = Año - .Add("@CvePersonaResponsable", SqlDbType.Int).Value = CvePersonaResponsable - .Add("@CveProyecto", SqlDbType.Int).Value = CveProyecto - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveEstadoActivoFijo", SqlDbType.Int).Value = CveEstadoActivoFijo - .Add("@CaracteristicaValor", SqlDbType.VarChar).Value = CaracteristicaValor - .Add("@BuscaGrupoEmpresa", SqlDbType.Int).Value = BuscaGrupoEmpresa - .Add("@Gpo", SqlDbType.Int).Value = Agrupador - - End With - Try - SqlAdapter.Fill(Data) - - If CveActivoFijo > 0 AndAlso Data IsNot Nothing AndAlso Data.Rows.Count > 0 Then - Me.CveActivoFijo = Data.Rows(0)("CveActivoFijo").ToString.ToEntero - - Me.Codigo = Data.Rows(0)("Codigo").ToString - Me.Descripcion = Data.Rows(0)("Descripcion").ToString - Me.CuentaInicial = Data.Rows(0)("Conta_CuentaInicial").ToString.ToEntero - Me.CveTipoActivoFijo = Data.Rows(0)("CveTipoActivoFijo").ToString.ToEntero - Me.TipoActivoFijo = Data.Rows(0)("TipoActivoFijo").ToString - Me.CveSubTipoActivoFijo = Data.Rows(0)("CveSubTipoActivoFijo").ToString.ToEntero - Me.SubTipoActivoFijo = Data.Rows(0)("SubTipoActivoFijo").ToString - Me.CveCompra = Data.Rows(0)("CveCompra").ToString.ToEntero - Me.ValorCompra = Data.Rows(0)("ValorCompra").ToString.ToDouble - Me.FechaCompra = Data.Rows(0)("FechaCompra").ToString.ToDate - Me.CvePersonaResponsable = Data.Rows(0)("CvePersonaResponsable").ToString.ToEntero - Me.Responsable = Data.Rows(0)("Responsable").ToString - Me.NoSerie = Data.Rows(0)("NoSerie").ToString - Me.Año = Data.Rows(0)("Año").ToString.ToEntero - Me.CveSubProyecto = Data.Rows(0)("CveSubProyecto").ToString.ToEntero - Me.SubProyecto = Data.Rows(0)("SubProyecto").ToString - Me.CveProyecto = Data.Rows(0)("CveProyecto").ToString.ToEntero - Me.Proyecto = Data.Rows(0)("Proyecto").ToString - Me.Cuenta = Data.Rows(0)("Cuenta").ToString.ToEntero - Me.CveEstadoActivoFijo = Data.Rows(0)("CveEstadoActivoFijo").ToString.ToEntero - Me.EstadoActivoFijo = Data.Rows(0)("EstadoActivoFijo").ToString - Me.IdCtaContDepreciacion = Data.Rows(0)("IdCtaContDepreciacion").ToString.ToEntero - Me.PorDepreciacion = Data.Rows(0)("PorDepreciacion").ToString.ToDouble - Me.Observaciones = Data.Rows(0)("Observaciones").ToString - Me.FechaIng = Data.Rows(0)("FechaIng").ToString.ToDate - Me.CveUsuario = Data.Rows(0)("CveUsuario").ToString.ToEntero - Me.Usuario = Data.Rows(0)("Usuario").ToString - Me.CveEmpresa = Data.Rows(0)("CveEmpresa").ToString.ToEntero - End If - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Catálogo de Activos Fijos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetActivosFijosProyectos(CveEmpresa As Integer, CveProyecto As Integer, CveSubProyecto As Integer, CveEstadoActivoFijo As Integer, CveUsuario As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_ActivosFijosUsuarioGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveProyecto", SqlDbType.Int).Value = CveProyecto - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveEstadoActivoFijo", SqlDbType.Int).Value = CveEstadoActivoFijo - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Catálogo de Activos Fijos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetRepActivosFijosDepreciacion(CveEmpresa As Integer, Fecha As Date) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_DepreciacionesGetRep") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@Fecha", SqlDbType.Date).Value = Fecha - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Reporte de Depreciaciones.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetActivosFijos(CveActivoFijo As Integer, CveEmpresa As Integer, Codigo As String, Descripcion As String, CveTipoActivoFijo As Integer, CveSubTipoActivoFijo As Integer, NoSerie As String, Año As Integer, CvePersonaResponsable As Integer, CveProyecto As Integer, CveSubProyecto As Integer, CveEstadoActivoFijo As Integer, CaracteristicaValor As String, CveCliente As Integer, Optional BuscaGrupoEmpresa As Integer = -1, Optional BuscaPorAFPadre As Integer = -1, Optional CveGrupo As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_ActivosFijosGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@Codigo", SqlDbType.VarChar).Value = Codigo - .Add("@Descripcion", SqlDbType.VarChar).Value = Descripcion - .Add("@CveTipoActivoFijo", SqlDbType.Int).Value = CveTipoActivoFijo - .Add("@CveSubTipoActivoFijo", SqlDbType.Int).Value = CveSubTipoActivoFijo - .Add("@NoSerie", SqlDbType.VarChar).Value = NoSerie - .Add("@Año", SqlDbType.Int).Value = Año - .Add("@CvePersonaResponsable", SqlDbType.Int).Value = CvePersonaResponsable - .Add("@CveProyecto", SqlDbType.Int).Value = CveProyecto - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveEstadoActivoFijo", SqlDbType.Int).Value = CveEstadoActivoFijo - .Add("@CaracteristicaValor", SqlDbType.VarChar).Value = CaracteristicaValor - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@BuscaGrupoEmpresa", SqlDbType.Int).Value = BuscaGrupoEmpresa - .Add("@CveAFPadre", SqlDbType.Int).Value = BuscaPorAFPadre - .Add("@CveGrupo", SqlDbType.Int).Value = CveGrupo - End With - Try - SqlAdapter.Fill(Data) - - If CveActivoFijo > 0 AndAlso Data IsNot Nothing AndAlso Data.Rows.Count > 0 Then - Me.CveActivoFijo = Data.Rows(0)("CveActivoFijo").ToString.ToEntero - - Me.Codigo = Data.Rows(0)("Codigo").ToString - Me.Descripcion = Data.Rows(0)("Descripcion").ToString - Me.CuentaInicial = Data.Rows(0)("Conta_CuentaInicial").ToString.ToEntero - Me.CveTipoActivoFijo = Data.Rows(0)("CveTipoActivoFijo").ToString.ToEntero - Me.TipoActivoFijo = Data.Rows(0)("TipoActivoFijo").ToString - Me.CveSubTipoActivoFijo = Data.Rows(0)("CveSubTipoActivoFijo").ToString.ToEntero - Me.SubTipoActivoFijo = Data.Rows(0)("SubTipoActivoFijo").ToString - Me.CveCompra = Data.Rows(0)("CveCompra").ToString.ToEntero - Me.ValorCompra = Data.Rows(0)("ValorCompra").ToString.ToDouble - Me.FechaCompra = Data.Rows(0)("FechaCompra").ToString.ToDate - Me.CvePersonaResponsable = Data.Rows(0)("CvePersonaResponsable").ToString.ToEntero - Me.Responsable = Data.Rows(0)("Responsable").ToString - Me.NoSerie = Data.Rows(0)("NoSerie").ToString - Me.Año = Data.Rows(0)("Año").ToString.ToEntero - Me.CveSubProyecto = Data.Rows(0)("CveSubProyecto").ToString.ToEntero - Me.SubProyecto = Data.Rows(0)("SubProyecto").ToString - Me.CveProyecto = Data.Rows(0)("CveProyecto").ToString.ToEntero - Me.Proyecto = Data.Rows(0)("Proyecto").ToString - Me.Cuenta = Data.Rows(0)("Cuenta").ToString.ToEntero - Me.CveEstadoActivoFijo = Data.Rows(0)("CveEstadoActivoFijo").ToString.ToEntero - Me.EstadoActivoFijo = Data.Rows(0)("EstadoActivoFijo").ToString - Me.IdCtaContDepreciacion = Data.Rows(0)("IdCtaContDepreciacion").ToString.ToEntero - Me.PorDepreciacion = Data.Rows(0)("PorDepreciacion").ToString.ToDouble - Me.Observaciones = Data.Rows(0)("Observaciones").ToString - Me.MesesDepreciacion = Data.Rows(0)("MesesDepreciacion").ToString.ToEntero - Me.CveCliente = Data.Rows(0)("CveCliente").ToString.ToEntero - Me.NombreCliente = Data.Rows(0)("NombreCliente").ToString - Me.FechaIng = Data.Rows(0)("FechaIng").ToString.ToDate - Me.CveUsuario = Data.Rows(0)("CveUsuario").ToString.ToEntero - Me.Usuario = Data.Rows(0)("Usuario").ToString - Me.CveEmpresa = Data.Rows(0)("CveEmpresa").ToString.ToEntero - Me.MedidaUso = Data.Rows(0)("MedidaUso").ToString - Me.CveMovimientoInv = Data.Rows(0)("CveMovimientoInv").ToString.ToEntero - Me.FolioInv = Data.Rows(0)("FolioInv").ToString - Me.AlmacenInv = Data.Rows(0)("AlmacenInv").ToString - Me.CveMarcaActivoFijo = Data.Rows(0)("CveMarcaActivoFijo").ToString.ToEntero - Me.CveModeloActivoFijo = Data.Rows(0)("CveModeloActivoFijo").ToString.ToEntero - Me.CveGrupoAF = Data.Rows(0)("CveGrupo").ToString.ToEntero - Me.CveAFPadre = Data.Rows(0)("CveAFPadre").ToString.ToEntero - Me.CveDispositivo = Data.Rows(0)("CveDispositivo").ToString.ToEntero - End If - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Catálogo de Activos Fijos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - 'Public Function AddActivosFijos(Codigo As String, Descripcion As String, ValorCompra As Double, FechaCompra As Date, CveSubTipoActivoFijo As Integer, - ' CvePersonalResponsable As Integer, NoSerie As String, Año As Integer, CveSubProyecto As Integer, Cuenta As Integer, - ' CveEstadoActivoFijo As Integer, IdCtaContDepreciacion As Integer, PorDepreciacion As Double, PorDeduccion As Double, CveUsuario As Integer, CveEmpresa As Integer) As Boolean - ' Dim Retorno As Boolean = False - - ' DataAdapter("PA_AF_ActivosFijosAdd") - - ' With SqlAdapter.SelectCommand.Parameters - ' .Add("@Codigo", SqlDbType.VarChar).Value = Codigo - ' .Add("@Descripcion", SqlDbType.VarChar).Value = Descripcion - ' .Add("@CveSubTipoActivoFijo", SqlDbType.Int).Value = CveSubTipoActivoFijo - ' .Add("@ValorCompra", SqlDbType.Money).Value = ValorCompra - ' .Add("@FechaCompra", SqlDbType.Date).Value = FechaCompra - ' .Add("@CvePersonalResponsable", SqlDbType.Int).Value = CvePersonalResponsable - ' .Add("@NoSerie", SqlDbType.VarChar).Value = NoSerie - ' .Add("@Año", SqlDbType.Int).Value = Año - ' .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - ' .Add("@IdCtaContActivoFijo", SqlDbType.Int).Value = Cuenta - ' .Add("@CveEstadoActivoFijo", SqlDbType.Int).Value = CveEstadoActivoFijo - ' .Add("@IdCtaContDepreciacion", SqlDbType.Int).Value = IdCtaContDepreciacion - ' .Add("@PorDepreciacion", SqlDbType.Float).Value = PorDepreciacion - ' .Add("@PorDeduccion", SqlDbType.Float).Value = PorDeduccion - ' .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 Activo Fijo con el mismo nombre: " & Descripcion & ".", TipoMensaje.MsgAdvertencia) - ' Else - ' Me.OnError("Ocurrió un error al Guardar el Activo Fijo.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - ' End If - ' Catch ex As Exception - - ' End Try - - ' Return Retorno - 'End Function - Public Function AddActivosFijos(Codigo As String, Descripcion As String, ValorCompra As Double, FechaCompra As Date, CveSubTipoActivoFijo As Integer, CvePersonalResponsable As Integer, NoSerie As String, Año As Integer, - CveSubProyecto As Integer, Cuenta As Integer, CveEstadoActivoFijo As Integer, IdCtaContDepreciacion As Integer, PorDepreciacion As Double, Observaciones As String, CveCliente As Integer, - CveMovimiento As Integer, CveUsuario As Integer, CveEmpresa As Integer, Optional CveMarca As Integer = -1, Optional CveModelo As Integer = -1, Optional CveGrupo As Integer = -1, - Optional CveAFPadre As Integer = -1, Optional CveDispositivo As Integer = -1) As Integer - Dim Retorno As Integer = -1 - - DataAdapter("PA_AF_ActivosFijosAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Codigo", SqlDbType.VarChar).Value = Codigo - .Add("@Descripcion", SqlDbType.VarChar).Value = Descripcion - .Add("@CveSubTipoActivoFijo", SqlDbType.Int).Value = CveSubTipoActivoFijo - .Add("@ValorCompra", SqlDbType.Money).Value = ValorCompra - .Add("@FechaCompra", SqlDbType.Date).Value = FechaCompra - .Add("@CvePersonalResponsable", SqlDbType.Int).Value = CvePersonalResponsable - .Add("@NoSerie", SqlDbType.VarChar).Value = NoSerie - .Add("@Año", SqlDbType.Int).Value = Año - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@IdCtaContActivoFijo", SqlDbType.Int).Value = Cuenta - .Add("@CveEstadoActivoFijo", SqlDbType.Int).Value = CveEstadoActivoFijo - .Add("@IdCtaContDepreciacion", SqlDbType.Int).Value = IdCtaContDepreciacion - .Add("@PorDepreciacion", SqlDbType.Float).Value = PorDepreciacion - '.Add("@CveEstadoActivoFijo", SqlDbType.Int).Value = CveEstadoActivoFijo - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones - .Add("@CveMovimiento", SqlDbType.Int).Value = CveMovimiento - .Add("@CveMarca", SqlDbType.Int).Value = CveMarca - .Add("@CveModelo", SqlDbType.Int).Value = CveModelo - .Add("@CveGrupo", SqlDbType.Int).Value = CveGrupo - .Add("@CveAFPadre", SqlDbType.Int).Value = CveAFPadre - .Add("@CveDispositivo", SqlDbType.Int).Value = CveDispositivo - - .Add("@CveActivoFijo", SqlDbType.Int).Direction = ParameterDirection.Output - .Add("@RETURN_VALUE", SqlDbType.Int).Direction = ParameterDirection.ReturnValue - End With - - Try - SqlAdapter.Fill(Data) - CveActivoFijo = SqlAdapter.SelectCommand.Parameters("@CveActivoFijo").Value.ToString.ToEntero - 'Dim RetValue As Integer = SqlAdapter.SelectCommand.Parameters("@RETURN_VALUE").Value.ToString.ToEntero - Retorno = CveActivoFijo - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 2627;") Then - If Ex1.Message.Contains("UN_ActivoFijo") Then - Alert("El Codigo ya se encuentra registrado", TipoMensaje.MsgAdvertencia) - Else - Alert("Ya existe un Activo Fijo con el mismo nombre: " & Descripcion & ".", TipoMensaje.MsgAdvertencia) - End If - - Else - Me.OnError("Ocurrió un error al Guardar el Activo Fijo.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - - End Try - - Return Retorno - End Function - Public Function UpdateActivosFijos(CveActivoFijo As Integer, Codigo As String, Descripcion As String, ValorCompra As Double, FechaCompra As Date, CveSubTipoActivoFijo As Integer, - CvePersonalResponsable As Integer, NoSerie As String, Año As Integer, CveSubProyecto As Integer, IdCtaContActivoFijo As Integer, - CveEstadoActivoFijo As Integer, IdCtaContDepreciacion As Integer, PorDepreciacion As Double, Observaciones As String, CveCliente As Integer, - CveUsuarioModifico As Integer, CveEmpresa As Integer, Optional CveMarca As Integer = -1, Optional CveModelo As Integer = -1, Optional CveGrupo As Integer = -1, - Optional CveAFPadre As Integer = -1, Optional CveDispositivo As Integer = -1) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_ActivosFijosUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo - .Add("@Codigo", SqlDbType.VarChar).Value = Codigo - .Add("@Descripcion", SqlDbType.VarChar).Value = Descripcion - .Add("@CveSubTipoActivoFijo", SqlDbType.Int).Value = CveSubTipoActivoFijo - .Add("@ValorCompra", SqlDbType.Money).Value = ValorCompra - .Add("@FechaCompra", SqlDbType.Date).Value = FechaCompra - '.Add("@CveModeloActivoFijo", SqlDbType.Int).Value = CveModeloActivoFijo - '.Add("@CveMarcaActivoFijo", SqlDbType.Int).Value = CveMarcaActivoFijo - .Add("@CvePersonalResponsable", SqlDbType.Int).Value = CvePersonalResponsable - .Add("@NoSerie", SqlDbType.VarChar).Value = NoSerie - .Add("@Año", SqlDbType.Int).Value = Año - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@IdCtaContActivoFijo", SqlDbType.Int).Value = IdCtaContActivoFijo - .Add("@IdCtaContDepreciacion", SqlDbType.Int).Value = IdCtaContDepreciacion - .Add("@PorDepreciacion", SqlDbType.Float).Value = PorDepreciacion - .Add("@PorDeduccion", SqlDbType.Float).Value = -1 - .Add("@CveEstadoActivoFijo", SqlDbType.Int).Value = CveEstadoActivoFijo - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveUsuarioModifico", SqlDbType.Int).Value = CveUsuarioModifico - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones - .Add("@CveMarca", SqlDbType.Int).Value = CveMarca - .Add("@CveModelo", SqlDbType.Int).Value = CveModelo - .Add("@CveGrupo", SqlDbType.Int).Value = CveGrupo - .Add("@CveAFPadre", SqlDbType.Int).Value = CveAFPadre - .Add("@CveDispositivo", SqlDbType.Int).Value = CveDispositivo - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 2627;") Then - Alert("Ya existe un Activo Fijo con el mismo nombre: " & Descripcion & ".", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al guardar los cambios en el Activo Fijo", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - OnError("Ocurrió un error al guardar los cambios en el Activo Fijo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function RemoveActivosFijos(CveActivoFijo As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_ActivosFijosRemove") - SqlAdapter.SelectCommand.Parameters.Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 547;") Then - Alert("El Activo Fijo no se pudo eliminar porque está siendo usado por un registro.", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al eliminar el Activo Fijo.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - Me.OnError("Ocurrió un error al eliminar el Activo Fijo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function UpdateActivosFijosCompra(CveActivoFijo As Integer, CveCompraDetalle As Integer, TipoAF As Integer, ValorCompra As Double, FechaCompra As Date) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_ActivosFijosCompraUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo - .Add("@CveCompraDetalle", SqlDbType.Int).Value = CveCompraDetalle - .Add("@TipoAF", SqlDbType.Int).Value = TipoAF - .Add("@ValorCompra", SqlDbType.Float).Value = ValorCompra - .Add("@FechaCompra", SqlDbType.Date).Value = FechaCompra - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 2627;") Then - Alert("Ya existe un Activo Fijo con el mismo nombre: " & Descripcion & ".", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al guardar los cambios en el Activo Fijo", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - OnError("Ocurrió un error al guardar los cambios en el Activo Fijo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function UpdateActivosFijosCuentaAC(CveActivoFijo As Integer, IdCuentaContable As Integer, CveUsuario As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_ActivosFijosCtaContableUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo - .Add("@IdCuentaContable", SqlDbType.Int).Value = IdCuentaContable - .Add("@CveUsuarioModifico", SqlDbType.Int).Value = CveUsuario - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - OnError("Ocurrió un error al actualizar la cuenta contable en el Activo Fijo", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - Catch ex As Exception - OnError("Ocurrió un error al actualizar la cuenta contable en el Activo Fijo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - -#End Region - -#Region "A C T I V O S - F I J O S- B I T A C O R A S" - Public Function GetActivosFijosBitacora(CveActivoFijo As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_ActivosFijosBitacoraGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveActivoFijo", SqlDbType.VarChar).Value = CveActivoFijo - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Catálogo de Activos Fijos - Bitacora.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function AddActivosFijosBitacora(CveActivoFijo As Integer, Observacion As String, CveUsuario As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_ActivosFijosBitacoraAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo - .Add("@Observacion", SqlDbType.VarChar).Value = Observacion - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex As SqlException - OnError("Ocurrió un error al Guardar la Bitacora del Activo Fijo ", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function -#End Region - -#Region "A C T I V O S - F I J O S - C A R A C T E R I S T I C A S" - - Public Function GetActivosFijosCaracteristicas(CveActivoFijo As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_ActivosFijosCaracteristicasGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveActivoFijo", SqlDbType.VarChar).Value = CveActivoFijo - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Catálogo de Activos Fijos - Caracteristicas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - -#End Region - -#Region "A C T I V O S- F I J O S - H I S T O R I A L" - Public Function GetActivosFijosHistorial(CveActivoFijo As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_ActivosFijosHistorialGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveActivoFijo", SqlDbType.VarChar).Value = CveActivoFijo - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Catálogo de Activos Fijos - Historial.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function AddActivosFijosHistorial(CveActivoFijo As Integer, CveConceptoHistorialActivoFijo As Integer, Actual As String, Anterior As String, CveUsuario As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_ActivosFijosHistorialAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo - .Add("@CveConceptoHistorialActivoFijo", SqlDbType.Int).Value = CveConceptoHistorialActivoFijo - .Add("@Actual", SqlDbType.VarChar).Value = Actual - .Add("@Anterior", SqlDbType.VarChar).Value = Anterior - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex As SqlException - OnError("Ocurrió un error al Guardar el Historial del Activo Fijo", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function -#End Region - -#Region "A C T I V O S- F I J O S - I M A G E N E S" - Public Function GetActivosFijosImagenes(CveActivoFijo As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_ActivosFijosImagenesGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveActivoFijo", SqlDbType.VarChar).Value = CveActivoFijo - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Catálogo de Activos Fijos - Imagenes.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function AddActivosFijosImagenes(CveActivoFijo As Integer, URL As String, CveUsuario As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_ActivosFijosImagenesAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo - .Add("@URL", SqlDbType.VarChar).Value = URL - .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 Imagen en Fijo Imagenes con el mismo nombre: " & Descripcion & ".", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al Guardar la Imagen en Activo Fijo.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - OnError("Ocurrió un error al Guardar la Imagen en Activo Fijo", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function RemoveActivosFijosImagenes(CveImagenActivoFijo As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_ActivosFijosImagenesRemove") - SqlAdapter.SelectCommand.Parameters.Add("@CveImagenActivoFijo", SqlDbType.Int).Value = CveImagenActivoFijo - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 547;") Then - Alert("La Imagen del Activo Fijo no se pudo eliminar porque está siendo usado por un registro.", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al eliminar la Imagen del Activo Fijo.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - Me.OnError("Ocurrió un error al eliminar la Imagen del Activo Fijo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function -#End Region - -#Region "A C T I V O S - F I J O S - R E S G U A R D O S" - Public Function GetActivosFijosResguardos(CveActivoFijo As Integer, CveActivoFijoResguardo As Integer, CveResponsable As Integer, CveResguardo As Integer, Optional CveEmpresa As Integer = -1, Optional CveSubProyecto As Integer = -1, Optional Folio As Integer = -1, Optional CveResguardo2 As Integer = -1, Optional UsuarioImprimio As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_ActivosFijosResguardosGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo - .Add("@CveActivoFijoResguardo", SqlDbType.Int).Value = CveActivoFijoResguardo - .Add("@CveResponsable", SqlDbType.Int).Value = CveResponsable - .Add("@CveResguardo", SqlDbType.Int).Value = CveResguardo - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@Folio", SqlDbType.Int).Value = Folio - .Add("@CveResguardo2", SqlDbType.Int).Value = CveResguardo2 - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@UsuarioImprimio", SqlDbType.Int).Value = UsuarioImprimio - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex As Exception - OnError("Ocurrió un error al obtener el Catálogo de Activos Fijos - Resguardos.", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - Return Retorno - End Function - - Public Function ActivoFijoResguardoADD(FechaInicio As Date, CvePersonal As Integer, CveUsuario As Integer, CveSubProyecto As Integer, CveActivoFijo As Integer, TipoDocto As String, Tipo As Integer, CveEmpresa As Integer, Optional Observaciones As String = " ", Optional CveResguardo As Integer = -1) As Boolean - 'Dim CveResguardo As Integer = -1 - Dim Retorno = False - DataAdapter("PA_AF_ActivosFijosResguardosAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePersonal", SqlDbType.Int).Value = CvePersonal - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo - .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones - .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio - .Add("@Tipo", SqlDbType.Int).Value = Tipo - .Add("@CveResguardo", SqlDbType.Int).Value = CveResguardo - .Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@Folio", SqlDbType.Int).Direction = ParameterDirection.Output - End With - Try - SqlAdapter.Fill(Data) - FolioResguardo = SqlAdapter.SelectCommand.Parameters("@Folio").Value.ToString().ToEntero() - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al guardar el resguardo", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function ActivoFijoResguardoGpo() As Integer - Dim CveResguardo As Integer = -1 - DataAdapter("PA_AF_ActivosFijosResguardosGpo") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveResguardo", SqlDbType.Int).Direction = ParameterDirection.Output - End With - Try - SqlAdapter.Fill(Data) - CveResguardo = SqlAdapter.SelectCommand.Parameters("@CveResguardo").Value.ToString().ToEntero() - Catch ex As Exception - OnError("Ocurrió un error al obtener el grupo del resguardo", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return CveResguardo - End Function - Public Function UpdateActivosFijosResguardos(FechaFin As String, Observaciones As String, URL As String, CveActivoFijoResguardo As Integer, CveActivoFijo As Integer, Optional URL2 As String = "-1", Optional CveResguardo2 As Integer = -1, Optional CveSubProyecto As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_ActivosFijosResguardosUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaFin", SqlDbType.VarChar).Value = FechaFin - .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones - .Add("@URL", SqlDbType.VarChar).Value = URL - .Add("@CveActivoFijoResguardo", SqlDbType.Int).Value = CveActivoFijoResguardo - .Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo - .Add("@URL2", SqlDbType.VarChar).Value = URL2 - .Add("@CveResguardo2", SqlDbType.Int).Value = CveResguardo2 - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - - Catch ex As Exception - OnError("Ocurrió un error al guardar los cambios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function UpdateEstatusResguardo(EstatusResguardo As Integer, CveEmpresa As Integer, CveActivoFijo As Integer, Optional CveSubProyecto As Integer = -1, Optional CveUsuarioModifico As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_UpdateEstatusResguardo") - 'ESTATUS RESGUARDO: 1- Disponible, 2- En Traslado, 3- Asignado - With SqlAdapter.SelectCommand.Parameters - .Add("@EstatusResguardo", SqlDbType.Int).Value = EstatusResguardo - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo - .Add("@CveUsuarioModifico", SqlDbType.Int).Value = CveUsuarioModifico - - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - - Catch ex As Exception - OnError("Ocurrió un error al guardar los cambios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function UpdateActivosFijosResguardosURL(URL As String, URL2 As String, CveActivoFijoResguardo As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_ActivosFijosResguardosUrlUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@URL", SqlDbType.VarChar).Value = URL - .Add("@URL2", SqlDbType.VarChar).Value = URL2 - .Add("@CveActivoFijoResguardo", SqlDbType.Int).Value = CveActivoFijoResguardo - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - - Catch ex As Exception - OnError("Ocurrió un error al guardar los cambios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function UpdateActivosFijosResguardosURLGpo(URL As String, URL2 As String, CveResguardo As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_ActivosFijosResguardosGpoUrl") - - With SqlAdapter.SelectCommand.Parameters - .Add("@URL", SqlDbType.VarChar).Value = URL - .Add("@URL2", SqlDbType.VarChar).Value = URL2 - .Add("@CveActivoFijoResguardo", SqlDbType.Int).Value = CveResguardo - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - - Catch ex As Exception - OnError("Ocurrió un error al guardar los cambios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function GetActivosFijosHijos(CveEmpresa As Integer, CveAFPadre As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_ActivosFijosHijosGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveAFPadre", SqlDbType.Int).Value = CveAFPadre - .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 AF Hijos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - -#End Region - -#Region "A C T I V O S - F I J O S - COMPRAS " - Public Function GetActivosFijosCompras(CveActivoFijo As Integer, Optional CveClasificacion As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_ActivosFijosCompras") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo - .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex As Exception - OnError("Ocurrió un error al obtener las Compras del Activo Fijo.", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - Return Retorno - End Function -#End Region - -#Region " ************************************************ C A R A C T E R I S T I C A S ************************************************ " - -#Region "ClasificacionesCaracteristicas" - - Public Function GetCaracteristicasClasificaciones(CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_CaracteristicasClasificacionesGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - Try - SqlAdapter.Fill(Data) - Data.TableName = "CaracteristicasClasificaciones" - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Catálogo de Clasificaciones de Características.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function AddClasificacionesCaracteristicas(CaracteristicaClasificacion As String, CveUsuario As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_CaracteristicasClasificacionesAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CaracteristicaClasificacion", SqlDbType.VarChar).Value = CaracteristicaClasificacion - .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 Guardar la Clasificacion de Caracteristica.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function UpdateClasificacionesCaracteristicas(CaracteristicaClasificacion As String, Estatus As Boolean, CveCaracteristicaClasificacion As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_CaracteristicasClasificacionesUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CaracteristicaClasificacion", SqlDbType.VarChar).Value = CaracteristicaClasificacion - '.Add("@CveSubTipoActivoFijo", SqlDbType.Int).Value = CveSubTipoActivoFijo - '.Add("@Orden", SqlDbType.Int).Value = Orden - .Add("@Estatus", SqlDbType.Bit).Value = Estatus - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveCaracteristicaClasificacion", SqlDbType.Int).Value = CveCaracteristicaClasificacion - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 2627;") Then - Alert("Ya existe una Clasificacion de Caracteristica con el mismo nombre: " & CaracteristicaClasificacion & ".", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al guardar los cambios en la Clasificacion de Caracteristica", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - OnError("Ocurrió un error al guardar los cambios en la Clasificacion de Caracteristica.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function RemoveClasificacionesCaracteristicas(CveCaracteristicaClasificacion As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_CaracteristicasClasificacionesRemove") - - SqlAdapter.SelectCommand.Parameters.Add("@CveCaracteristicaClasificacion", SqlDbType.Int).Value = CveCaracteristicaClasificacion - SqlAdapter.SelectCommand.Parameters.Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 547;") Then - Alert("La Clasificacion de Caracteristica no se pudo eliminar porque está siendo usado por un registro.", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al eliminar la Clasificacion de Caracteristica.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - Me.OnError("Ocurrió un error al eliminar la Clasificacion de Caracteristica.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function -#End Region - - -#Region "Características" - Public Function GetCaracteristicas(CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_CaracteristicasGet") - - SqlAdapter.SelectCommand.Parameters.Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - - Try - SqlAdapter.Fill(Data) - Data.TableName = "Caracteristicas" - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Catálogo de Características.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - - Return Retorno - End Function - Public Function AddCaracteristica(Caracteristica As String, CveCaracteristicaClasificacion As Integer, CveTipoActivoFijo As Integer, CveSubTipoActivoFijo As Integer, TipoCampo As Integer, Longitud As Integer, Requerido As Integer, Orden As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_CaracteristicasAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Caracteristica", SqlDbType.VarChar).Value = Caracteristica - .Add("@CveTipoActivoFijo", SqlDbType.Int).Value = CveTipoActivoFijo - .Add("@CveSubTipoActivoFijo", SqlDbType.Int).Value = CveSubTipoActivoFijo - .Add("@TipoCampo", SqlDbType.TinyInt).Value = TipoCampo - .Add("@CveCaracteristicaClasificacion", SqlDbType.Int).Value = CveCaracteristicaClasificacion - .Add("@Longitud", SqlDbType.Int).Value = Longitud - .Add("@Requerido", SqlDbType.Int).Value = Requerido - .Add("@Orden", SqlDbType.Int).Value = Orden - .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 Característica con el mismo nombre: " & Caracteristica & ".", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al Guardar la Característica.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - OnError("Ocurrió un error al Guardar la Característica.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function UpdateCaracteristica(CveCaracteristicaClasificacion As Integer, Caracteristica As String, CveTipoActivoFijo As Integer, CveSubTipoActivoFijo As Integer, TipoCampo As Integer, Longitud As Integer, Requerida As Boolean, Orden As Integer, Estatus As Boolean, CveEmpresa As Integer, CveCaracteristica As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_CaracteristicasUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCaracteristica", SqlDbType.VarChar).Value = CveCaracteristica - .Add("@Caracteristica", SqlDbType.VarChar).Value = Caracteristica - .Add("@CveCaracteristicaClasificacion", SqlDbType.Int).Value = CveCaracteristicaClasificacion - .Add("@CveTipoActivoFijo", SqlDbType.Int).Value = CveTipoActivoFijo - .Add("@CveSubTipoActivoFijo", SqlDbType.Int).Value = CveSubTipoActivoFijo - .Add("@TipoCampo", SqlDbType.TinyInt).Value = TipoCampo - .Add("@Longitud", SqlDbType.Int).Value = Longitud - .Add("@Orden", SqlDbType.Int).Value = Orden - .Add("@Requerida", SqlDbType.Bit).Value = Requerida - .Add("@Estatus", SqlDbType.Bit).Value = Estatus - .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 Caracteristica con el mismo nombre: " & Caracteristica & ".", TipoMensaje.MsgAdvertencia) - ElseIf Ex1.Message.Contains("Número: 547;") Then - Alert("La Característica tiene Opciones que están siendo usado por un registro.", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al guardar los cambios en la Característica.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - OnError("Ocurrió un error al guardar los cambios en la Característica.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function RemoveCaracteristica(CveCaracteristica As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_CaracteristicasRemove") - - SqlAdapter.SelectCommand.Parameters.Add("@CveCaracteristica", SqlDbType.Int).Value = CveCaracteristica - SqlAdapter.SelectCommand.Parameters.Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 547;") Then - Alert("La Característica no se pudo eliminar porque está siendo usado por un registro.", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al eliminar la Característica.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - Me.OnError("Ocurrió un error al eliminar la Característica de Tipo de Cuenta y/o Equipo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function -#End Region - - -#Region "CaracteristicasOpciones" - - Public Function GetCaracteristicasOpciones(CveCaracteristica As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_CaracteristicasOpcionesGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCaracteristica", SqlDbType.Int).Value = CveCaracteristica - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Data.TableName = "CaracteristicasOpciones" - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener las Opciones para las Caracteristicas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetCaracteristicasOpcionesSubTipo(CveCaracteristica As Integer, CveSubTipoActivoFijo As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_CaracteristicasOpcionesSubTipoGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCaracteristica", SqlDbType.Int).Value = CveCaracteristica - .Add("@CveSubTipoActivoFijo", SqlDbType.Int).Value = CveSubTipoActivoFijo - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Data.TableName = "CaracteristicasOpciones" - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener las Opciones para las Caracteristicas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function AddCaracteristicasOpciones(CaracteristicaOpcion As String, CveCaracteristica As Integer, Orden As Integer, CveUsuario As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_CaracteristicasOpcionesAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CaracteristicaOpcion", SqlDbType.VarChar).Value = CaracteristicaOpcion - .Add("@CveCaracteristica", SqlDbType.Int).Value = CveCaracteristica - .Add("@Orden", SqlDbType.Int).Value = Orden - .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 Opcion para la Caracteristica con el mismo nombre: " & CaracteristicaOpcion & ".", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al Guardar la Opcion para la Caracteristica.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - OnError("Ocurrió un error al Guardar la Opcion para la Caracteristica.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function UpdateCaracteristicasOpciones(CveCaracteristica As Integer, CaracteristicaOpcion As String, Orden As Integer, Estatus As Boolean, CveCaracteristicaOpcion As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_CaracteristicasOpcionesUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CaracteristicaOpcion", SqlDbType.VarChar).Value = CaracteristicaOpcion - .Add("@Orden", SqlDbType.Int).Value = Orden - .Add("@Estatus", SqlDbType.Bit).Value = Estatus - .Add("@CveCaracteristica", SqlDbType.Int).Value = CveCaracteristica - .Add("@CveCaracteristicaOpcion", SqlDbType.Int).Value = CveCaracteristicaOpcion - .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 Opcion para la Caracteristica con el mismo nombre: " & CaracteristicaOpcion & ".", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al guardar los cambios en la Opcion para la Caracteristica.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - OnError("Ocurrió un error al guardar los cambios en la Opcion para la Caracteristica.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function RemoveCaracteristicasOpciones(CveCaracteristicaOpcion As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_CaracteristicasOpcionesRemove") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCaracteristicaOpcion", SqlDbType.Int).Value = CveCaracteristicaOpcion - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 547;") Then - Alert("La Opcion para la Caracteristica no se pudo eliminar porque está siendo usado por un registro.", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al eliminar la Opcion para la Caracteristica.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - Me.OnError("Ocurrió un error al eliminar la Opcion para la Caracteristica.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function -#End Region - - -#Region "A C T I V O S V A L O R E S" - Public Function GetActivosFijosValores(CveActivoFijo As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_ActivoFijoValoresGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo - .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 Valores de Activos Fijos .", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function AddActivosFijosValores(CveActivoFijo As Integer, CveCaracteristica As Integer, CveOpcion As Integer, Valor As String, CveUsuario As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_ActivoFijoValoresAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo - .Add("@CveCaracteristica", SqlDbType.Int).Value = CveCaracteristica - .Add("@CveOpcion", SqlDbType.Int).Value = CveOpcion - .Add("@Valor", SqlDbType.VarChar).Value = Valor - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - Me.OnError("Ocurrió un error al Guardar el Valor de Activo Fijo.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - Catch ex As Exception - - End Try - - Return Retorno - End Function - - Public Function AddUpdActivosFijosValores(CveActivoFijo As Integer, CveCaracteristica As Integer, CveOpcion As Integer, Valor As String, CveUsuario As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_ActivoFijoValoresAddUpd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo - .Add("@CveCaracteristica", SqlDbType.Int).Value = CveCaracteristica - .Add("@CveOpcion", SqlDbType.Int).Value = CveOpcion - .Add("@Valor", SqlDbType.VarChar).Value = Valor - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - Me.OnError("Ocurrió un error al Guardar el Valor de Activo Fijo.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - Catch ex As Exception - - End Try - - Return Retorno - End Function - - Public Function UpdateActivosFijosValores(CveActivoFijo As Integer, CveCaracteristica As Integer, CveOpcion As Integer, Valor As String, CveUsuario As Integer, CveValor As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_ActivoFijoValoresUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo - .Add("@CveCaracteristica", SqlDbType.Int).Value = CveCaracteristica - .Add("@CveOpcion", SqlDbType.Int).Value = CveOpcion - .Add("@Valor", SqlDbType.VarChar).Value = Valor - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveValor", SqlDbType.Int).Value = CveValor - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - Me.OnError("Ocurrió un error al guardar los cambios en el Valor del Activo Fijo", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - Catch ex As Exception - OnError("Ocurrió un error al guardar los cambios en el Valor del Activo Fijo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function RemoveActivosFijosValores(CveActivoFijo As Integer, CveValor As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_ActivoFijoValoresRemove") - SqlAdapter.SelectCommand.Parameters.Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo - SqlAdapter.SelectCommand.Parameters.Add("@CveValor", SqlDbType.Int).Value = CveValor - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 547;") Then - Alert("El Valor de Activo Fijo no se pudo eliminar porque está siendo usado por un registro.", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al eliminar el Valor de Activo Fijo.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - Me.OnError("Ocurrió un error al eliminar el Valor de Activo Fijo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function -#End Region -#End Region - -#Region "Subtipos Activos Fijos" - - Public Function GetSubTiposActivosFijos(CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_SubTiposActivosFijosGet") - - 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 Subtipos de Activos Fijos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function AddSubTiposActivosFijos(CveTipoActivoFijo As Integer, SubTipoActivoFijo As String, CveUsuario As Integer, CveEmpresa As Integer, Optional AplicaGPS As Boolean = False) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_SubTiposActivosFijosAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveTipoActivoFijo", SqlDbType.Int).Value = CveTipoActivoFijo - .Add("@SubTipoActivoFijo", SqlDbType.VarChar).Value = SubTipoActivoFijo - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@AplicaGPS", SqlDbType.Bit).Value = AplicaGPS - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex As SqlException - OnError("Ocurrió un error al Guardar el Subtipo de Activo Fijo", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function UpdateSubTiposActivosFijos(CveSubTipoActivoFijo As Integer, CveTipoActivoFijo As Integer, SubTipoActivoFijo As String, Estado As Boolean, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_SubTiposActivosFijosUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveSubTipoActivoFijo", SqlDbType.Int).Value = CveSubTipoActivoFijo - .Add("@CveTipoActivoFijo", SqlDbType.Int).Value = CveTipoActivoFijo - .Add("@SubTipoActivoFijo", SqlDbType.VarChar).Value = SubTipoActivoFijo - .Add("@Estado", SqlDbType.Bit).Value = Estado - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex As SqlException - Catch ex As Exception - OnError("Ocurrió un error al guardar los cambios en el Subtipo del Activo Fijo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function RemoveSubTiposActivosFijos(CveSubTiposActivosFijos As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_SubTiposActivosFijosRemove") - - SqlAdapter.SelectCommand.Parameters.Add("@CveSubTipoActivoFijo", SqlDbType.Int).Value = CveSubTiposActivosFijos - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex As SqlException - Me.OnError("Ocurrió un error al eliminar el Subtipo del Activo Fijo.", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function -#End Region - -#Region "Tipos Activos Fijos" - - Public Function GetTiposActivosFijos(CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_TiposActivosFijosGet") - - 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 Tipos de Activos Fijos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function AddTiposActivosFijos(TipoActivoFijo As String, CuentaInicial As Integer, CveUsuario As Integer, CveEmpresa As Integer, Optional PorDepreciacion As Decimal = 0, Optional MedidaVehicular As Integer = 1, Optional AutoFolio As Boolean = False, Optional Contable As Boolean = False) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_TiposActivosFijosAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@TipoActivoFijo", SqlDbType.VarChar).Value = TipoActivoFijo - .Add("@CuentaInicial", SqlDbType.VarChar).Value = CuentaInicial - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@PorDepreciacion", SqlDbType.Money).Value = PorDepreciacion - .Add("@MedidaVehicular", SqlDbType.TinyInt).Value = MedidaVehicular - .Add("@AutoFolio", SqlDbType.Bit).Value = AutoFolio - .Add("@Contable", SqlDbType.Bit).Value = Contable - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex As SqlException - OnError("Ocurrió un error al Guardar el Tipo de Activo Fijo", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function UpdateTiposActivosFijos(CveTipoActivoFijo As Integer, TipoActivoFijo As String, CuentaInicial As Integer, Estado As Boolean, Optional PorDepreciacion As Decimal = 0, Optional MedidaVehicular As Integer = 1, Optional AutoFolio As Boolean = False, Optional Contable As Boolean = False) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_TiposActivosFijosUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveTipoActivoFijo", SqlDbType.Int).Value = CveTipoActivoFijo - .Add("@TipoActivoFijo", SqlDbType.VarChar).Value = TipoActivoFijo - .Add("@CuentaInicial", SqlDbType.VarChar).Value = CuentaInicial - .Add("@Estado", SqlDbType.Bit).Value = Estado - .Add("@PorDepreciacion", SqlDbType.Money).Value = PorDepreciacion - .Add("@MedidaVehicular", SqlDbType.TinyInt).Value = MedidaVehicular - .Add("@AutoFolio", SqlDbType.Bit).Value = AutoFolio - .Add("@Contable", SqlDbType.Bit).Value = Contable - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex As SqlException - Catch ex As Exception - OnError("Ocurrió un error al guardar los cambios en el Tipo del Activo Fijo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function RemoveTiposActivosFijos(CveTiposActivosFijos As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_TiposActivosFijosRemove") - - SqlAdapter.SelectCommand.Parameters.Add("@CveTipoActivoFijo", SqlDbType.Int).Value = CveTiposActivosFijos - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex As SqlException - Me.OnError("Ocurrió un error al eliminar el tipo del Activo Fijo.", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function -#End Region - -#Region "A C T I V O S - S U B T I P O S " - - Public Function GetSubTiposCaracteristicas(CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_SubTiposCaracteristicasGet") - - 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 caracteristicas de Subtipos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function AddSubTipoCaracteristica(CveSubTipoActivoFijo As Integer, CveCaracteristica As Integer, CveUsuario As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_SubTiposCaracteristicasAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveSubTipoActivoFijo", SqlDbType.Int).Value = CveSubTipoActivoFijo - .Add("@CveCaracteristica", SqlDbType.Int).Value = CveCaracteristica - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex As SqlException - OnError("Ocurrió un error al Guardar el Subtipo de Activo Fijo", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function RemoveSubTipoCaracteristica(CveSubTipoActivosFijos As Integer, CveCaracteristica As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_SubTiposCaracteristicasRemove") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveSubTipoActivoFijo", SqlDbType.Int).Value = CveSubTipoActivosFijos - .Add("@CveCaracteristica", SqlDbType.Int).Value = CveCaracteristica - End With - - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex As SqlException - Me.OnError("Ocurrió un error al eliminar el Subtipo del Activo Fijo.", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function -#End Region - -#Region "ESTATUS DE ACTIVOS FIJOS" - Public Function GetEstatusActivoFijo() As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_EstatusActivoFijoGet") - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Catálogo de Estatus de Activo Fijo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function AddEstatusActivoFIjo(EstadoActivoFijo As Integer, CveUsuario As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_EstatusActivoFijoAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@EstadoActivoFijo", SqlDbType.Int).Value = EstadoActivoFijo - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex As SqlException - OnError("Ocurrió un error al Guardar el Departamento", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function UpdateEstatusActivoFijo(CveEstadoActivoFIjo As Integer, EstadoActivoFijo As Integer, Estado As Boolean) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_EstatusActivoFijoUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@EstadoActivoFijo", SqlDbType.Int).Value = EstadoActivoFijo - .Add("@CveEstadoActivoFijo", SqlDbType.Int).Value = CveEstadoActivoFIjo - .Add("@Estado", SqlDbType.Bit).Value = Estado - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex As SqlException - OnError("Ocurrió un error al guardar los cambios en el Estado del Activo Fijo.", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - Public Function RemoveEstatusActivoFijo(CveEstadoActivoFijo As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_EstatusActivoFijoRemove") - - SqlAdapter.SelectCommand.Parameters.Add("@CveEstadoActivoFijo", SqlDbType.Int).Value = CveEstadoActivoFijo - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 547;") Then - Alert("El Departamento no se pudo eliminar porque está siendo usado por un registro.", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al eliminar el Departamento.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - Me.OnError("Ocurrió un error al eliminar el Departamento.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function -#End Region - -#Region "ClsAFModelosActivosFijos" - Public Function GetModelosActivosFijos(CveEmpresa As Integer, CveMarca As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_ModelosActivosFijosGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveMarca", SqlDbType.Int).Value = CveMarca - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Catálogo de Modelos de Activos Fijos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function AddModelosActivosFijos(ModeloActivoFijo As String, CveMarcaAF As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_ModelosActivosFijosAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@ModeloActivoFijo", SqlDbType.VarChar).Value = ModeloActivoFijo - .Add("@CveMarcaAF", SqlDbType.Int).Value = CveMarcaAF - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex As SqlException - OnError("Ocurrió un error al Guardar el Modelo del Activo Fijo", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function UpdateModelosActivosFijos(CveModeloActivoFijo As Integer, ModeloActivoFijo As String, CveMarcaAF As Integer, Estado As Boolean, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_ModelosActivosFijosUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveModeloActivoFijo", SqlDbType.Int).Value = CveModeloActivoFijo - .Add("@ModeloActivoFijo", SqlDbType.VarChar).Value = ModeloActivoFijo - .Add("@CveMarcaAF", SqlDbType.Int).Value = CveMarcaAF - .Add("@Estado", SqlDbType.Bit).Value = Estado - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex As SqlException - Catch ex As Exception - OnError("Ocurrió un error al guardar los cambios en el Modelo del Activo Fijo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function RemoveModelosActivosFijos(CveModelosActivosFijos As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_ModelosActivosFijosRemove") - - SqlAdapter.SelectCommand.Parameters.Add("@CveModeloActivoFijo", SqlDbType.Int).Value = CveModelosActivosFijos - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex As SqlException - Me.OnError("Ocurrió un error al eliminar el Modelo del Activo Fijo.", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function -#End Region - -#Region "ClsAFMarcasActivosFijos" - Public Function GetMarcasActivosFijos(CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_MarcasActivosFijosGet") - - 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 de Activos Fijos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function AddMarcasActivosFijos(MarcaActivoFijo As String, CveUsuario As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_MarcasActivosFijosAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@MarcaActivoFijo", SqlDbType.VarChar).Value = MarcaActivoFijo - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex As SqlException - OnError("Ocurrió un error al Guardar la Marca del Activo Fijo", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function UpdateMarcasActivosFijos(CveMarcaActivoFijo As Integer, MarcaActivoFijo As String, Estado As Boolean, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_MarcasActivosFijosUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveMarcaActivoFijo", SqlDbType.Int).Value = CveMarcaActivoFijo - .Add("@MarcaActivoFijo", SqlDbType.VarChar).Value = MarcaActivoFijo - .Add("@Estado", SqlDbType.Bit).Value = Estado - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex As SqlException - Catch ex As Exception - OnError("Ocurrió un error al guardar los cambios en la Marca del Activo Fijo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function RemoveMarcasActivosFijos(CveMarcaActivoFijo As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_MarcasActivosFijosRemove") - - SqlAdapter.SelectCommand.Parameters.Add("@CveMarcaActivoFijo", SqlDbType.Int).Value = CveMarcaActivoFijo - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex As SqlException - Me.OnError("Ocurrió un error al eliminar la Marca del Activo Fijo.", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function -#End Region - -#Region "AF G R U P O S" - Public Function GetGrupoAF(CveGrupo As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_GruposGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveGrupo", SqlDbType.Int).Value = CveGrupo - .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 Grupos de Activos Fijos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function AddGrupoAF(Grupo As String, CveUsuario As Integer, CveEmpresa As Integer) As Integer - Dim Retorno As Integer = -1 - - DataAdapter("PA_AF_GruposAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Grupo", SqlDbType.VarChar).Value = Grupo - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveGrupo", SqlDbType.Int).Direction = ParameterDirection.Output - End With - - Try - SqlAdapter.Fill(Data) - Retorno = SqlAdapter.SelectCommand.Parameters("@CveGrupo").Value.ToString.ToEntero - Catch Ex As SqlException - OnError("Ocurrió un error al Guardar el Grupo", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function UpdateGrupoAF(Grupo As String, Estatus As Boolean, CveGrupo As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_GruposUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Grupo", SqlDbType.VarChar).Value = Grupo - .Add("@Estatus", SqlDbType.Bit).Value = Estatus - .Add("@CveGrupo", SqlDbType.Int).Value = CveGrupo - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex As SqlException - OnError("Ocurrió un error al Actualizar el Grupo", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function RemoveGrupoAF(CveEmpresa As Integer, CveGrupo As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_GruposRemove") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveGrupo", SqlDbType.Int).Value = CveGrupo - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex As SqlException - OnError("Ocurrió un error al Eliminar el Grupo", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function -#End Region - -#Region "ClsAFConceptosHistorial" - - Public Function GetConceptosHistorial() As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_ConceptosHistorialGet") - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Catálogo Historial de Conceptos", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function AddConceptosHistorial(ConceptoHistorialActivoFijo As String, CveUsuario As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_ConceptosHistorialAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@ConceptoHistorialActivoFijo", SqlDbType.VarChar).Value = ConceptoHistorialActivoFijo - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex As SqlException - OnError("Ocurrió un error al Guardar el Concepto del Historial", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function UpdateDepartamento(CveConceptoHistorialActivoFijo As Integer, ConceptoHistorialActivoFijo As String, Estado As Boolean) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_RH_DepartamentoUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveConceptoHistorialActivoFijo", SqlDbType.Int).Value = CveConceptoHistorialActivoFijo - .Add("@ConceptoHistorialActivoFijo", SqlDbType.VarChar).Value = ConceptoHistorialActivoFijo - .Add("@Estado", SqlDbType.Bit).Value = Estado - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex As SqlException - OnError("Ocurrió un error al guardar los cambios en el Concepto del Historial.", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function RemoveConceptosHistorialRemove(CveConceptoHistorialActivoFijo As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_ConceptosHistorialRemove") - SqlAdapter.SelectCommand.Parameters.Add("@CveConceptoHistorialActivoFijo", SqlDbType.Int).Value = CveConceptoHistorialActivoFijo - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex As SqlException - Me.OnError("Ocurrió un error al eliminar el Concepto del Historial.", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function -#End Region - -#Region "ClsAFCaracteristicasActivosFijos" - - Public Function GetCaracteristicasActivosFijos(CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_CaracteristicasActivosFijos") - - 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 Características de Activos Fijos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function AddCaracteristicasActivosFijos(CveActivoFijo As Integer, Caracteristica As String, EsRequerido As Boolean, EsUnico As Boolean, CveUsuario As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_CaracteristicasActivosFijosAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveActivoFijo", SqlDbType.VarChar).Value = CveActivoFijo - .Add("@Caracteristica", SqlDbType.VarChar).Value = Caracteristica - .Add("@EsRequerido", SqlDbType.Bit).Value = EsUnico - .Add("@EsUnico", SqlDbType.Bit).Value = EsRequerido - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex As SqlException - OnError("Ocurrió un error al Guardar la Característica del Activo Fijo", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function UpdateCaracteristicasActivosFijos(CveTipoActivoFijo As Integer, Caracteristica As String, EsRequerido As Boolean, EsUnico As Boolean, CveEmpresa As Integer, CveCaracteristicaActivoFijo As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_CaracteristicasActivosFijosUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveTipoActivoFijo", SqlDbType.VarChar).Value = CveTipoActivoFijo - .Add("@Caracteristica", SqlDbType.VarChar).Value = Caracteristica - .Add("@EsRequerido", SqlDbType.Bit).Value = EsUnico - .Add("@EsUnico", SqlDbType.Bit).Value = EsRequerido - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveCaracteristicaActivoFijo", SqlDbType.VarChar).Value = CveCaracteristicaActivoFijo - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex As SqlException - OnError("Ocurrió un error al guardar los cambios en la Característica del Activo Fijo.", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function RemoveCaracteristicasActivosFijos(CveCaracteristicaActivoFijo As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_CaracteristicasActivosFijosRemove") - - SqlAdapter.SelectCommand.Parameters.Add("@CveCaracteristicaActivoFijo", SqlDbType.Int).Value = CveCaracteristicaActivoFijo - - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex As SqlException - Me.OnError("Ocurrió un error al eliminar la Característica del Activo Fijo.", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - -#End Region - -#Region "O P E R A D O R E S" - Public Function GetTipoOperadores(CveTipoOperador As String, CveEmpresa As Integer, Estatus As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_TipoOperadoresGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveTipoOperador", SqlDbType.VarChar).Value = CveTipoOperador - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@Estatus", SqlDbType.Int).Value = Estatus - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Tipo Operador.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function AddOperador(Operador As String, CveTipoOperador As String, CveUsuario As Integer, CveEmpresa As Integer, Optional CveTransportista As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_OperadoresAdd") - With SqlAdapter.SelectCommand.Parameters - .Add("@Operador", SqlDbType.VarChar).Value = Operador - .Add("@CveTipoOperador", SqlDbType.VarChar).Value = CveTipoOperador - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveTransportista", SqlDbType.Int).Value = CveTransportista - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar el Operador.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function UpdateOperador(CveOperador As Integer, Operador As String, CveTipoOperador As String, CveUsuario As Integer, CveEmpresa As Integer, Estatus As Integer, Optional CveTransportista As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_OperadoresUpdate") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveOperador", SqlDbType.Int).Value = CveOperador - .Add("@Operador", SqlDbType.VarChar).Value = Operador - .Add("@CveTipoOperador", SqlDbType.VarChar).Value = CveTipoOperador - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@Estatus", SqlDbType.Int).Value = Estatus - .Add("@CveTransportista", SqlDbType.Int).Value = CveTransportista - - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar el chofer.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function RemoveOperador(CveOperador As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_OperadoresRemove") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveOperador", SqlDbType.Int).Value = CveOperador - - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al eliminar el Operador.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function GetOperadores(CveOperador As Integer, CveEmpresa As Integer, Estatus As Integer, Optional CveTransportista As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_OperadoresGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveOperador", SqlDbType.Int).Value = CveOperador - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@Estatus", SqlDbType.Int).Value = Estatus - .Add("@CveTransportista", SqlDbType.Int).Value = CveTransportista - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el chofer.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function -#End Region - -#Region "T I P O S C O M B U S T I B L E S" - Public Function GetTiposCombustible(CveTipoCombustible As Integer, Estatus As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_TiposCombustibleGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveTiposCombustible", SqlDbType.VarChar).Value = CveTipoCombustible - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@Estatus", SqlDbType.Int).Value = Estatus - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Catálogo de Tipos de combustible", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function AddTipoCombustible(TipoCombustible As String, Estatus As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_TiposCombustibleAdd") - With SqlAdapter.SelectCommand.Parameters - .Add("@TipoCombustible", SqlDbType.VarChar).Value = TipoCombustible - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@Estatus", SqlDbType.Int).Value = Estatus - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar el tipo de combustible.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function UpdateTipoCombustible(CveTipoCombustible As Integer, TipoCombustible As String, Estatus As Integer, CveUsuario As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_TiposCombustibleUpdate") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveTipoCombustible", SqlDbType.Int).Value = CveTipoCombustible - .Add("@TipoCombustible", SqlDbType.VarChar).Value = TipoCombustible - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@Estatus", SqlDbType.Int).Value = Estatus - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar el tipo de combustible.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function RemoveTipoCombustible(CveTipoCombustible As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_OperadoresRemove") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveTipoCombustible", SqlDbType.Int).Value = CveTipoCombustible - - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al eliminar el Operador.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function -#End Region - -#Region "C O M B U S T I B L E S" - Public Function GetCombustibles(CveCombustible As Integer, Estatus As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_CombustiblesGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCombustible", SqlDbType.Int).Value = CveCombustible - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@Estatus", SqlDbType.Int).Value = Estatus - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el combustible.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function AddCombustible(Combustible As String, CveTipoCombustible As Integer, Estatus As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_CombustiblesAdd") - With SqlAdapter.SelectCommand.Parameters - .Add("@Combustible", SqlDbType.VarChar).Value = Combustible - .Add("@CveTipoCombustible", SqlDbType.Int).Value = CveTipoCombustible - .Add("@Estatus", SqlDbType.Int).Value = Estatus - .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 agregar el Combustible.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function UpdateCombustible(CveCombustible As Integer, Combustible As String, CveTipoCombustible As Integer, Estatus As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_CombustiblesUpdate") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCombustible", SqlDbType.Int).Value = CveCombustible - .Add("@Combustible", SqlDbType.VarChar).Value = Combustible - .Add("@CveTipoCombustible", SqlDbType.Int).Value = CveTipoCombustible - .Add("@Estatus", SqlDbType.Int).Value = Estatus - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar el Combustible.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function RemoveCombustible(CveCombustible As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_CombustiblesRemove") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCombustible", SqlDbType.Int).Value = CveCombustible - - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al eliminar el Combustible.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function -#End Region - -#Region "C A R G A S C O M B U S T I B L E S " - Public Function GetCargasCombustible(CveAF As Integer, CveProveedor As Integer, CveTipoAF As Integer, CveSubProyecto As Integer, FechaI As String, FechaF As String, CveEmpresa As Integer, Optional CveCargaCombustible As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_CargaCombustibleGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveAF", SqlDbType.Int).Value = CveAF - .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor - .Add("@CveTipoAF", SqlDbType.Int).Value = CveTipoAF - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@FechaI", SqlDbType.VarChar).Value = FechaI - .Add("@FechaF", SqlDbType.VarChar).Value = FechaF - .Add("@CveEmpresa", SqlDbType.VarChar).Value = CveEmpresa - .Add("@CveCargaCombustible", SqlDbType.Int).Value = CveCargaCombustible - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener las cargas de combustible.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function AddCargaCombustible(CveCombustible As Integer, CveProveedor As Integer, CveAF As Integer, Folio As String, FechaCarga As DateTime, TanqueLleno As Integer, Cantidad As Double, CostoUnitario As Double, Odometro As Double, CveUsuario As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_CargaCombustiblesAdd") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCombustible", SqlDbType.Int).Value = CveCombustible - .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor - .Add("@CveAF", SqlDbType.Int).Value = CveAF - .Add("@Folio", SqlDbType.VarChar).Value = Folio - .Add("@FechaCarga", SqlDbType.DateTime).Value = FechaCarga - .Add("@TanqueLleno", SqlDbType.Int).Value = TanqueLleno - .Add("@Cantidad", SqlDbType.Float).Value = Cantidad - .Add("@CostoUnitario", SqlDbType.SmallMoney).Value = CostoUnitario - .Add("@Odometro", SqlDbType.SmallMoney).Value = Odometro - .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 agregar la carga de combustible.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function GetRepCargasCombustible(FechaI As String, FechaF As String, CveTipoAF As Integer, CveSubProyecto As Integer, GPO As Integer, CveProveedor As Integer, CveEstatus As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_RepCargasCombustibleGet") - - With SqlAdapter.SelectCommand.Parameters - '.Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@FechaI", SqlDbType.VarChar).Value = FechaI - .Add("@FechaF", SqlDbType.VarChar).Value = FechaF - .Add("@CveTipoAF", SqlDbType.Int).Value = CveTipoAF - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@GPO", SqlDbType.Int).Value = GPO - .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor - .Add("@CveEstatus", SqlDbType.Int).Value = CveEstatus - .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 Reporte de Flotillas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function -#End Region - -#Region "P L A C A S" - Public Function GetPlacas(CvePlaca As Integer, CveAF As Integer, CveEmpresa As Integer, Optional CveDispositivo As Integer = -1, Optional CveCliente As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_PlacasGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePlaca", SqlDbType.Int).Value = CvePlaca - .Add("@CveAF", SqlDbType.Int).Value = CveAF - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveDispositivo", SqlDbType.Int).Value = CveDispositivo - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Catálogo de Placas", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function AddPlacas(CveAF As Integer, Placa As String, CveUsuario As Integer, CveEmpresa As Integer, Optional CveDispositivo As Integer = -1, Optional CveCliente As Integer = -1, Optional Observacion As String = "-1", Optional Adjunto As String = "-1", - Optional FechaExpedicion As String = "-1", Optional FechaVencimiento As String = "-1") As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_PlacasAdd") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveAF", SqlDbType.Int).Value = CveAF - .Add("@Placa", SqlDbType.VarChar).Value = Placa - .Add("@FechaExpedicion", SqlDbType.VarChar).Value = FechaExpedicion - .Add("@FechaVencimiento", SqlDbType.VarChar).Value = FechaVencimiento - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveDispositivo", SqlDbType.Int).Value = CveDispositivo - .Add("@Observacion", SqlDbType.VarChar).Value = Observacion - .Add("@Adjunto", SqlDbType.VarChar).Value = Adjunto - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar la placa.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function UpdatePlacas(CvePlaca As Integer, Placa As String, Optional Observacion As String = "-1", Optional Adjunto As String = "-1", Optional FechaExpedicion As Date = MinFecha, Optional FechaVencimiento As Date = MinFecha) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_PlacasUpdate") - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePlaca", SqlDbType.Int).Value = CvePlaca - .Add("@Placa", SqlDbType.VarChar).Value = Placa - .Add("@FechaExpedicion", SqlDbType.Date).Value = FechaExpedicion - .Add("@FechaVencimiento", SqlDbType.Date).Value = FechaVencimiento - .Add("@Observacion", SqlDbType.VarChar).Value = Observacion - .Add("@Adjunto", SqlDbType.VarChar).Value = Adjunto - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar la placa", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function RemovePlaca(CvePlaca As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_PlacasRemove") - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePlaca", SqlDbType.Int).Value = CvePlaca - - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al eliminar la placa.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetRepPlacas(CvePlaca As Integer, CveAF As Integer, CveEmpresa As Integer, FechaExpedicionI As DateTime, FechaExpedicionF As DateTime, FechaVencimientoI As DateTime, FechaVencimientoF As DateTime, Optional CveDispositivo As Integer = -1, Optional CveCliente As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_RepPlacas") - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePlaca", SqlDbType.Int).Value = CvePlaca - .Add("@CveAF", SqlDbType.Int).Value = CveAF - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@FechaExpedicionI", SqlDbType.DateTime).Value = FechaExpedicionI - .Add("@FechaExpedicionF", SqlDbType.DateTime).Value = FechaExpedicionF - .Add("@FechaVencimientoI", SqlDbType.DateTime).Value = FechaVencimientoI - .Add("@FechaVencimientoF", SqlDbType.DateTime).Value = FechaVencimientoF - .Add("@CveDispositivo", SqlDbType.Int).Value = CveDispositivo - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Catálogo de Placas", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function -#End Region - -#Region "L I C E N C I A S" - Public Function GetLicencias(CveLicencia As Integer, CveAF As Integer, CveEmpresa As Integer, Optional CveDispositivo As Integer = -1, Optional CveCliente As Integer = -1, Optional CvePersonal As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_LicenciasGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveLicencia", SqlDbType.Int).Value = CveLicencia - .Add("@CveAF", SqlDbType.Int).Value = CveAF - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveDispositivo", SqlDbType.Int).Value = CveDispositivo - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CvePersonal", SqlDbType.Int).Value = CvePersonal - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Catálogo de Licencias", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetLicenciasVencidas(CveLicencia As Integer, CveAF As Integer, CveEmpresa As Integer, Optional CveDispositivo As Integer = -1, Optional CveCliente As Integer = -1, Optional CvePersonal As Integer = -1, Optional Estatus As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_LicenciasVencidasGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveLicencia", SqlDbType.Int).Value = CveLicencia - .Add("@CveAF", SqlDbType.Int).Value = CveAF - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveDispositivo", SqlDbType.Int).Value = CveDispositivo - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CvePersonal", SqlDbType.Int).Value = CvePersonal - .Add("@Estatus", SqlDbType.Int).Value = Estatus - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Catálogo de Licencias", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetLicenciasRep(CveLicencia As Integer, CveAF As Integer, CveEmpresa As Integer, FechaEI As DateTime, FechaEF As DateTime, FechaVI As DateTime, FechaVF As DateTime, Optional CveDispositivo As Integer = -1, Optional CveCliente As Integer = -1, Optional Estatus As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_LicenciasRepGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveLicencia", SqlDbType.Int).Value = CveLicencia - .Add("@CveAF", SqlDbType.Int).Value = CveAF - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@FechaEI", SqlDbType.DateTime).Value = FechaEI - .Add("@FechaEF", SqlDbType.DateTime).Value = FechaEF - .Add("@FechaVI", SqlDbType.DateTime).Value = FechaVI - .Add("@FechaVF", SqlDbType.DateTime).Value = FechaVF - .Add("@CveDispositivo", SqlDbType.Int).Value = CveDispositivo - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveCliente", SqlDbType.Int).Value = Estatus - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Catálogo de Licencias", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function AddLicencia(CveAF As Integer, Licencia As String, FechaExpedicion As DateTime, FechaVencimiento As DateTime, CveUsuario As Integer, CveEmpresa As Integer, Optional CveDispositivo As Integer = -1, Optional CveCliente As Integer = -1, Optional Observacion As String = "-1", Optional Adjunto As String = "-1", Optional CvePersonal As Integer = -1, Optional Estatus As Boolean = True) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_LicenciasAdd") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveAF", SqlDbType.Int).Value = CveAF - .Add("@Licencia", SqlDbType.VarChar).Value = Licencia - .Add("@FechaExpedicion", SqlDbType.DateTime).Value = FechaExpedicion - .Add("@FechaVencimiento", SqlDbType.DateTime).Value = FechaVencimiento - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveDispositivo", SqlDbType.Int).Value = CveDispositivo - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@Observacion", SqlDbType.VarChar).Value = Observacion - .Add("@Adjunto", SqlDbType.VarChar).Value = Adjunto - .Add("@CvePersonal", SqlDbType.Int).Value = CvePersonal - .Add("@Estatus", SqlDbType.Bit).Value = Estatus - - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar la licencia.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function UpdateLicencia(CveLicencia As Integer, Licencia As String, FechaExpedicion As DateTime, FechaVencimiento As DateTime, Optional Observacion As String = "-1", Optional Adjunto As String = "-1", Optional Estatus As Boolean = True) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_LicenciasUpdate") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveLicencia", SqlDbType.Int).Value = CveLicencia - .Add("@Licencia", SqlDbType.VarChar).Value = Licencia - .Add("@FechaExpedicion", SqlDbType.DateTime).Value = FechaExpedicion - .Add("@FechaVencimiento", SqlDbType.DateTime).Value = FechaVencimiento - .Add("@Observacion", SqlDbType.VarChar).Value = Observacion - .Add("@Adjunto", SqlDbType.VarChar).Value = Adjunto - .Add("@Estatus", SqlDbType.Bit).Value = Estatus - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar la licencia", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function RemoveLicencia(CveLicencia As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_LicenciasRemove") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveLicencia", SqlDbType.Int).Value = CveLicencia - - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al eliminar la licencia.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function -#End Region - -#Region "P O L I Z A S S E G U R O S " - Public Function GetPolizasSeguro(CvePoliza As Integer, CveAF As Integer, CveProveedor As Integer, CveEmpresa As Integer, Optional CveDispositivo As Integer = -1, Optional CveCliente As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_PolizasSeguroGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePoliza", SqlDbType.Int).Value = CvePoliza - .Add("@CveAF", SqlDbType.Int).Value = CveAF - .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveDispositivo", SqlDbType.Int).Value = CveDispositivo - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Catálogo de Pólizas de seguro", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetRepPolizaSeguro(CveAF As Integer, CveProveedor As Integer, FechaExpedicionI As DateTime, FechaExpedicionF As DateTime, FechaVencimientoI As DateTime, FechaVencimientoF As DateTime, CveEmpresa As Integer, Optional CveDispositivo As Integer = -1, Optional CveCliente As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_RepPolizaSeguroGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveAF", SqlDbType.Int).Value = CveAF - .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor - .Add("@FechaExpedicionI", SqlDbType.DateTime).Value = FechaExpedicionI - .Add("@FechaExpedicionF", SqlDbType.DateTime).Value = FechaExpedicionF - .Add("@FechaVencimientoI", SqlDbType.DateTime).Value = FechaVencimientoI - .Add("@FechaVencimientoF", SqlDbType.DateTime).Value = FechaVencimientoF - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveDispositivo", SqlDbType.Int).Value = CveDispositivo - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Reporte de Polizas de Seguros.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function AddPolizasSeguro(CveAF As Integer, CveProveedor As Integer, PolizaSeguro As String, FechaExpedicion As DateTime, FechaVencimiento As DateTime, CveUsuario As Integer, CveEmpresa As Integer, Optional CveDispositivo As Integer = -1, Optional CveCliente As Integer = -1, Optional Observacion As String = "-1", Optional Adjunto As String = "-1", Optional Proveedor As String = "-1") As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_PolizasSegurosAdd") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveAF", SqlDbType.Int).Value = CveAF - .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor - .Add("@PolizaSeguro", SqlDbType.VarChar).Value = PolizaSeguro - .Add("@FechaExpedicion", SqlDbType.DateTime).Value = FechaExpedicion - .Add("@FechaVencimiento", SqlDbType.DateTime).Value = FechaVencimiento - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveDispositivo", SqlDbType.Int).Value = CveDispositivo - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@Observacion", SqlDbType.VarChar).Value = Observacion - .Add("@Adjunto", SqlDbType.VarChar).Value = Adjunto - .Add("@Proveedor", SqlDbType.VarChar).Value = Proveedor - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar la póliza de seguro.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function UpdatePolizaSeguro(CvePoliza As Integer, CveProveedor As Integer, PolizaSeguro As String, FechaExpedicion As DateTime, FechaVencimiento As DateTime, Optional Observacion As String = "-1", Optional Adjunto As String = "-1", Optional Proveedor As String = "-1") As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_PolizasSegurosUpdate") - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePoliza", SqlDbType.Int).Value = CvePoliza - .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor - .Add("@PolizaSeguro", SqlDbType.VarChar).Value = PolizaSeguro - .Add("@FechaExpedicion", SqlDbType.DateTime).Value = FechaExpedicion - .Add("@FechaVencimiento", SqlDbType.DateTime).Value = FechaVencimiento - .Add("@Observacion", SqlDbType.VarChar).Value = Observacion - .Add("@Adjunto", SqlDbType.VarChar).Value = Adjunto - .Add("@Proveedor", SqlDbType.VarChar).Value = Proveedor - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar la póliza de seguro", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function RemovePoliza(CvePoliza As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_PolizasSeguroRemove") - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePoliza", SqlDbType.Int).Value = CvePoliza - - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al eliminar la póliza de seguro.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function -#End Region - -#Region "I N C I D E N T E S " - Public Function GetIncidentes(CveIncidente As Integer, CveAF As Integer, CveEmpresa As Integer, Optional CveDispositivo As Integer = -1, Optional CveCliente As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_IncidentesGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveIncidente", SqlDbType.Int).Value = CveIncidente - .Add("@CveAF", SqlDbType.Int).Value = CveAF - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveDispositivo", SqlDbType.Int).Value = CveDispositivo - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Catálogo de Incidentes", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetIncidentesRep(CveIncidente As Integer, CveAF As Integer, CveEmpresa As Integer, FechaInicio As String, FechaFin As String, Optional CveDispositivo As Integer = -1, Optional CveCliente As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_IncidentesRepGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveIncidente", SqlDbType.Int).Value = CveIncidente - .Add("@CveAF", SqlDbType.Int).Value = CveAF - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@FechaInicial", SqlDbType.VarChar).Value = FechaInicio - .Add("@FechaFinal", SqlDbType.VarChar).Value = FechaFin - .Add("@CveDispositivo", SqlDbType.Int).Value = CveDispositivo - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Reporte de Incidentes", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function AddIncidente(CveAF As Integer, Asunto As String, Descripcion As String, Odometro As Double, Horometro As Double, Prioridad As Integer, FechaIncidente As DateTime, CveUsuario As Integer, CveEmpresa As Integer, Optional CveDispositivo As Integer = -1, Optional CveCliente As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_IncidentesAdd") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveAF", SqlDbType.Int).Value = CveAF - .Add("@Asunto", SqlDbType.VarChar).Value = Asunto - .Add("@Descripcion", SqlDbType.VarChar).Value = Descripcion - .Add("@Odometro", SqlDbType.Float).Value = Odometro - .Add("@Horometro", SqlDbType.Float).Value = Horometro - .Add("@FechaIncidente", SqlDbType.DateTime).Value = FechaIncidente - .Add("@Prioridad", SqlDbType.Int).Value = Prioridad - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveDispositivo", SqlDbType.Int).Value = CveDispositivo - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar el incidente.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function UpdateIncidente(CveIncidente As Integer, Asunto As String, Descripcion As String, Odometro As Double, Horometro As Double, Prioridad As Integer, FechaIncidente As DateTime) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_IncidentesUpdate") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveIncidente", SqlDbType.Int).Value = CveIncidente - .Add("@Asunto", SqlDbType.VarChar).Value = Asunto - .Add("@Descripcion", SqlDbType.VarChar).Value = Descripcion - .Add("@Odometro", SqlDbType.Float).Value = Odometro - .Add("@Horometro", SqlDbType.Float).Value = Horometro - .Add("@Prioridad", SqlDbType.Int).Value = Prioridad - .Add("@FechaIncidente", SqlDbType.DateTime).Value = FechaIncidente - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar el incidente", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function RemoveIncidente(CveIncidente As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_IncidenteRemove") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveIncidente", SqlDbType.Int).Value = CveIncidente - - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al eliminar el incidente.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function -#End Region - -#Region "F A L L A S / A C C I D E N T E S " - Public Function GetTipoFallas(CveTipoFalla As Integer, CveEmpresa As Integer, ClasificacionTipoFalla As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_TipoFallasGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveTipoFalla", SqlDbType.Int).Value = CveTipoFalla - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@ClasificacionTipoFalla", SqlDbType.Int).Value = ClasificacionTipoFalla - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Catálogo de Tipo Fallas", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function GetFallas(CveFalla As Integer, CveAF As Integer, CveEmpresa As Integer, CveTipoFalla As Integer, ClasificacionTipoFalla As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_FallasGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveFalla", SqlDbType.Int).Value = CveFalla - .Add("@CveAF", SqlDbType.Int).Value = CveAF - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveTipoFalla", SqlDbType.Int).Value = CveTipoFalla - .Add("@ClasificacionTipoFalla", SqlDbType.Int).Value = ClasificacionTipoFalla - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Catálogo de Fallas", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function AddFalla(CveAF As Integer, Asunto As String, Descripcion As String, AFMedida As Integer, Prioridad As Integer, FechaFalla As DateTime, CveUsuario As Integer, CveEmpresa As Integer, CveTipoFalla As Integer, CorreoNotificacion As String) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_FallasAdd") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveAF", SqlDbType.Int).Value = CveAF - .Add("@Asunto", SqlDbType.VarChar).Value = Asunto - .Add("@Descripcion", SqlDbType.VarChar).Value = Descripcion - .Add("@AFMedida", SqlDbType.Int).Value = AFMedida - .Add("@FechaFalla", SqlDbType.DateTime).Value = FechaFalla - .Add("@Prioridad", SqlDbType.Int).Value = Prioridad - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveTipoFalla", SqlDbType.Int).Value = CveTipoFalla - .Add("@CorreoNotificacion", SqlDbType.VarChar).Value = CorreoNotificacion - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al Registrar la Falla.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function UpdateFalla(CveFalla As Integer, Asunto As String, Descripcion As String, AFMedida As Integer, Prioridad As Integer, FechaFalla As DateTime, CveTipoFalla As Integer, CorreoNotificacion As String) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_FallasUpdate") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveFalla", SqlDbType.Int).Value = CveFalla - .Add("@Asunto", SqlDbType.VarChar).Value = Asunto - .Add("@Descripcion", SqlDbType.VarChar).Value = Descripcion - .Add("@AFMedida", SqlDbType.Int).Value = AFMedida - .Add("@Prioridad", SqlDbType.Int).Value = Prioridad - .Add("@FechaFalla", SqlDbType.DateTime).Value = FechaFalla - .Add("@CveTipoFalla", SqlDbType.Int).Value = CveTipoFalla - .Add("@CorreoNotificacion", SqlDbType.VarChar).Value = CorreoNotificacion - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar la falla", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function RemoveFalla(CveFalla As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_FallasRemove") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveFalla", SqlDbType.Int).Value = CveFalla - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al eliminar la falla.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function -#End Region -#Region "S E R V I C I O S" - Public Function GetServicios(CveServicio As Integer, CveAF As Integer, CveEmpresa As Integer, Optional CveDispositivo As Integer = -1, Optional CveCliente As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_ServiciosGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveServicio", SqlDbType.Int).Value = CveServicio - .Add("@CveAF", SqlDbType.Int).Value = CveAF - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveDispositivo", SqlDbType.Int).Value = CveDispositivo - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Catálogo de Servicios", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetServiciosTotal(CveServicio As Integer, CveAF As Integer, CveEmpresa As Integer, Optional CveDispositivo As Integer = -1, Optional CveCliente As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_ServiciosTotalCompraGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveServicio", SqlDbType.Int).Value = CveServicio - .Add("@CveAF", SqlDbType.Int).Value = CveAF - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveDispositivo", SqlDbType.Int).Value = CveDispositivo - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Catálogo de Servicios", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function AddServicio(CveAF As Integer, CveTipoServicio As Integer, FechaServicio As DateTime, CveProveedor As Integer, CveCompra As Integer, Horometro As Double, Observaciones As String, CveUsuario As Integer, CveEmpresa As Integer, Optional CveDispositivo As Integer = -1, Optional CveCliente As Integer = -1, Optional Proveedor As String = "-1", Optional Importe As Double = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_ServiciosAdd") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveAF", SqlDbType.Int).Value = CveAF - .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor - .Add("@CveCompra", SqlDbType.Int).Value = CveCompra - .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones - .Add("@Horometro", SqlDbType.Float).Value = Horometro - .Add("@FechaServicio", SqlDbType.DateTime).Value = FechaServicio - .Add("@CveTipoServicio", SqlDbType.Int).Value = CveTipoServicio - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveDispositivo", SqlDbType.Int).Value = CveDispositivo - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@Proveedor", SqlDbType.VarChar).Value = Proveedor - .Add("@Importe", SqlDbType.Float).Value = Importe - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar el servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function UpdateServicio(CveServicio As Integer, CveTipoServicio As Integer, FechaServicio As DateTime, CveProveedor As Integer, CveCompra As Integer, Horometro As Double, Observaciones As String, Optional Proveedor As String = "-1", Optional Importe As Double = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_ServiciosUpdate") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveServicio", SqlDbType.Int).Value = CveServicio - .Add("@CveTipoServicio", SqlDbType.Int).Value = CveTipoServicio - .Add("@FechaServicio", SqlDbType.DateTime).Value = FechaServicio - .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor - .Add("@CveCompra", SqlDbType.Int).Value = CveCompra - .Add("@Horometro", SqlDbType.Float).Value = Horometro - .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones - .Add("@Proveedor", SqlDbType.VarChar).Value = Proveedor - .Add("@Importe", SqlDbType.Float).Value = Importe - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar el servicio", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function RemoveServicio(CveServicio As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_ServiciosRemove") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveServicio", SqlDbType.Int).Value = CveServicio - - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al eliminar el servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetRepServicios(CveAF As Integer, CveEmpresa As Integer, CveTipoServicio As Integer, CveProveedor As Integer, FechaI As Date, FechaF As Date, Optional CveDispositivo As Integer = -1, Optional CveCliente As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_RepServicios") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveAF", SqlDbType.Int).Value = CveAF - .Add("@CveTipoServicio", SqlDbType.Int).Value = CveTipoServicio - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor - .Add("@FechaI", SqlDbType.Date).Value = FechaI - .Add("@FechaF", SqlDbType.Date).Value = FechaF - .Add("@CveDispositivo", SqlDbType.Int).Value = CveDispositivo - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el reporte de servicios", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function -#End Region - -#Region "E V E N T O S P R O G R A M A D O S " - Public Function GetRepEventosProgramados(CveAF As Integer, CveTipoAF As Integer, CveSubTipoAF As Integer, Asunto As String, FechaInicio As Date, FechaFin As Date, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_RepEventosProgramadosGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveAF", SqlDbType.Int).Value = CveAF - .Add("@CveTipoAF", SqlDbType.Int).Value = CveTipoAF - .Add("@CveSubTipoAF", SqlDbType.Int).Value = CveSubTipoAF - .Add("@Asunto", SqlDbType.VarChar).Value = Asunto - .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio - .Add("@FechaFin", SqlDbType.Date).Value = FechaFin - .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 Reporte de Eventos", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function -#End Region - -#Region "ValesCombustible" - Public Function AddValesCombustible(FolioUsuario As Integer, CveCompra As Integer, CveProveedor As Integer, CveAF As Integer, CvePersonal As Integer, Fecha As Date, NombreRecibe As String, CveSubProyecto As Integer, Observaciones As String, Odometro As Integer, CveCombustible As Integer, Litros As Double, TipoVale As Integer, CveUsuario As Integer, CveEmpresa As Integer, Optional Recibo As Integer = -1, Optional Importe As Integer = -1) As Integer - Dim Retorno As Integer = -1 - - DataAdapter("PA_AF_ValesCombustibleAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@FolioUsuario", SqlDbType.Int).Value = FolioUsuario - .Add("@CveCompra", SqlDbType.Int).Value = CveCompra - .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor - .Add("@CveAF", SqlDbType.Int).Value = CveAF - .Add("@CvePersonal", SqlDbType.Int).Value = CvePersonal - .Add("@NombreRecibe", SqlDbType.VarChar).Value = NombreRecibe - .Add("@Fecha", SqlDbType.Date).Value = Fecha - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones - .Add("@Odometro", SqlDbType.Int).Value = Odometro - .Add("@CveCombustible", SqlDbType.Int).Value = CveCombustible - .Add("@Litros", SqlDbType.Float).Value = Litros - .Add("@Recibo", SqlDbType.Float).Value = Recibo - .Add("@Importe", SqlDbType.Float).Value = Importe - .Add("@TipoVale", SqlDbType.Int).Value = TipoVale - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveVale", SqlDbType.Int).Direction = ParameterDirection.Output - .Add("@vFolio", SqlDbType.Int).Direction = ParameterDirection.Output - End With - - Try - SqlAdapter.Fill(Data) - FolioVale = SqlAdapter.SelectCommand.Parameters("@vFolio").Value.ToString.ToEntero - Retorno = SqlAdapter.SelectCommand.Parameters("@CveVale").Value.ToString.ToEntero - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 2627;") Then - Alert("Ya existe un Vale de Combustible con el mismo nombre: " & Descripcion & ".", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al Guardar el Vale de Combustible.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - - End Try - - Return Retorno - - End Function - Public Function GetValesCombustible(CveCompra As Integer, CveValeCombustible As Integer, Folio As Integer, CveProveedor As Integer, CveAF As Integer, CveSubProyecto As Integer, Odometro As Integer, CveCombustible As Integer, Litros As Double, CvePersonal As Integer, CveUsuario As Integer, CveEmpresa As Integer, Recibo As Integer, Importe As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AF_ValesCombustibleGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCompra", SqlDbType.Int).Value = CveCompra - .Add("@CveValeCombustible", SqlDbType.Int).Value = CveValeCombustible - .Add("@Folio", SqlDbType.Int).Value = Folio - .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor - .Add("@CveAF", SqlDbType.Int).Value = CveAF - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@Odometro", SqlDbType.Int).Value = Odometro - .Add("@CveCombustible", SqlDbType.Int).Value = CveCombustible - .Add("@Litros", SqlDbType.Float).Value = Litros - .Add("@CvePersonal", SqlDbType.Int).Value = CvePersonal - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@Recibo", SqlDbType.Int).Value = Recibo - .Add("@Importe", SqlDbType.Int).Value = Importe - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Catálogo de Estatus de Vales Combustible.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function UpdateValeCombustible(CveVale As Integer, CveCompra As Integer, CveProveedor As Integer, NombreRecibe As String, Litros As Double, Recibo As Integer, Importe As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_ValesCombustibleUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVale", SqlDbType.Int).Value = CveVale - .Add("@CveCompra", SqlDbType.Int).Value = CveCompra - .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor - .Add("@NombreRecibe", SqlDbType.VarChar).Value = NombreRecibe - .Add("@Litros", SqlDbType.Float).Value = Litros - .Add("@Recibo", SqlDbType.Int).Value = Recibo - .Add("@Importe", SqlDbType.Int).Value = Importe - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - OnError("Ocurrió un error al actualizar la cuenta contable en el Activo Fijo", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - Catch ex As Exception - OnError("Ocurrió un error al actualizar la cuenta contable en el Activo Fijo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function -#End Region -#Region "M E T R I C A S" + Sub New(Optional TransaccionCompartida As SqlTransaction = Nothing) - Public Function GetMetricas(CveMetrica As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_MetricasGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveMetrica", SqlDbType.Int).Value = CveMetrica - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener las métricas de Activo Fijo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function AddMetricas(Metrica As String) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_MetricasAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Metrica", SqlDbType.Int).Value = Metrica - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar la métrica de Activo Fijo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function DeleteMetricas(CveMetrica As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_MetricasRemove") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveMetrica", SqlDbType.Int).Value = CveMetrica - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar la métrica de Activo Fijo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno + 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("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 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 +#Region "A C T I V O S- F I J O S" - Public Function GetMetricasRegistro(CveSubProyecto As Integer, CveEmpresa As Integer, Fecha As Date) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_MetricasRegistroGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + Public Function GetRepActivosFijos(CveActivoFijo As Integer, CveEmpresa As Integer, Codigo As String, Descripcion As String, CveTipoActivoFijo As Integer, CveSubTipoActivoFijo As Integer, NoSerie As String, Año As Integer, CvePersonaResponsable As Integer, CveProyecto As Integer, CveSubProyecto As Integer, CveEstadoActivoFijo As Integer, CaracteristicaValor As String, Optional BuscaGrupoEmpresa As Integer = -1, Optional Agrupador As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_AFGetRep") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@Fecha", SqlDbType.Date).Value = Fecha - End With - - Try - SqlAdapter.Fill(DSet) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los valores de métricas de Activo Fijo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - - Public Function GetMetricasValores(CveMetricaValor As Integer, CveAF As Integer, CvePersonal As Integer, CveUsuario As Integer, CveSubProyecto As Integer, CveTipoActivoFijo As Integer, CveSubTipoActivoFijo As Integer, FechaI As Date, FechaF As Date, - CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_MetricasValoresGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveMetricaValor", SqlDbType.Int).Value = CveMetricaValor - .Add("@CveAF", SqlDbType.Int).Value = CveAF - .Add("@CvePersonal", SqlDbType.Int).Value = CvePersonal - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveTipoActivoFijo", SqlDbType.Int).Value = CveTipoActivoFijo - .Add("@CveSubTipoActivoFijo", SqlDbType.Int).Value = CveSubTipoActivoFijo + .Add("@Codigo", SqlDbType.VarChar).Value = Codigo + .Add("@Descripcion", SqlDbType.VarChar).Value = Descripcion + .Add("@CveTipoActivoFijo", SqlDbType.Int).Value = CveTipoActivoFijo + .Add("@CveSubTipoActivoFijo", SqlDbType.Int).Value = CveSubTipoActivoFijo + .Add("@NoSerie", SqlDbType.VarChar).Value = NoSerie + .Add("@Año", SqlDbType.Int).Value = Año + .Add("@CvePersonaResponsable", SqlDbType.Int).Value = CvePersonaResponsable + .Add("@CveProyecto", SqlDbType.Int).Value = CveProyecto + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveEstadoActivoFijo", SqlDbType.Int).Value = CveEstadoActivoFijo + .Add("@CaracteristicaValor", SqlDbType.VarChar).Value = CaracteristicaValor + .Add("@BuscaGrupoEmpresa", SqlDbType.Int).Value = BuscaGrupoEmpresa + .Add("@Gpo", SqlDbType.Int).Value = Agrupador + + End With + Try + SqlAdapter.Fill(Data) + + If CveActivoFijo > 0 AndAlso Data IsNot Nothing AndAlso Data.Rows.Count > 0 Then + Me.CveActivoFijo = Data.Rows(0)("CveActivoFijo").ToString.ToEntero + + Me.Codigo = Data.Rows(0)("Codigo").ToString + Me.Descripcion = Data.Rows(0)("Descripcion").ToString + Me.CuentaInicial = Data.Rows(0)("Conta_CuentaInicial").ToString.ToEntero + Me.CveTipoActivoFijo = Data.Rows(0)("CveTipoActivoFijo").ToString.ToEntero + Me.TipoActivoFijo = Data.Rows(0)("TipoActivoFijo").ToString + Me.CveSubTipoActivoFijo = Data.Rows(0)("CveSubTipoActivoFijo").ToString.ToEntero + Me.SubTipoActivoFijo = Data.Rows(0)("SubTipoActivoFijo").ToString + Me.CveCompra = Data.Rows(0)("CveCompra").ToString.ToEntero + Me.ValorCompra = Data.Rows(0)("ValorCompra").ToString.ToDouble + Me.FechaCompra = Data.Rows(0)("FechaCompra").ToString.ToDate + Me.CvePersonaResponsable = Data.Rows(0)("CvePersonaResponsable").ToString.ToEntero + Me.Responsable = Data.Rows(0)("Responsable").ToString + Me.NoSerie = Data.Rows(0)("NoSerie").ToString + Me.Año = Data.Rows(0)("Año").ToString.ToEntero + Me.CveSubProyecto = Data.Rows(0)("CveSubProyecto").ToString.ToEntero + Me.SubProyecto = Data.Rows(0)("SubProyecto").ToString + Me.CveProyecto = Data.Rows(0)("CveProyecto").ToString.ToEntero + Me.Proyecto = Data.Rows(0)("Proyecto").ToString + Me.Cuenta = Data.Rows(0)("Cuenta").ToString.ToEntero + Me.CveEstadoActivoFijo = Data.Rows(0)("CveEstadoActivoFijo").ToString.ToEntero + Me.EstadoActivoFijo = Data.Rows(0)("EstadoActivoFijo").ToString + Me.IdCtaContDepreciacion = Data.Rows(0)("IdCtaContDepreciacion").ToString.ToEntero + Me.PorDepreciacion = Data.Rows(0)("PorDepreciacion").ToString.ToDouble + Me.Observaciones = Data.Rows(0)("Observaciones").ToString + Me.FechaIng = Data.Rows(0)("FechaIng").ToString.ToDate + Me.CveUsuario = Data.Rows(0)("CveUsuario").ToString.ToEntero + Me.Usuario = Data.Rows(0)("Usuario").ToString + Me.CveEmpresa = Data.Rows(0)("CveEmpresa").ToString.ToEntero + End If + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Catálogo de Activos Fijos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetActivosFijosProyectos(CveEmpresa As Integer, CveProyecto As Integer, CveSubProyecto As Integer, CveEstadoActivoFijo As Integer, CveUsuario As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_ActivosFijosUsuarioGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveProyecto", SqlDbType.Int).Value = CveProyecto + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveEstadoActivoFijo", SqlDbType.Int).Value = CveEstadoActivoFijo + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Catálogo de Activos Fijos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetRepActivosFijosDepreciacion(CveEmpresa As Integer, Fecha As Date) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_DepreciacionesGetRep") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@Fecha", SqlDbType.Date).Value = Fecha + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Reporte de Depreciaciones.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetActivosFijos(CveActivoFijo As Integer, CveEmpresa As Integer, Codigo As String, Descripcion As String, CveTipoActivoFijo As Integer, CveSubTipoActivoFijo As Integer, NoSerie As String, Año As Integer, CvePersonaResponsable As Integer, CveProyecto As Integer, CveSubProyecto As Integer, CveEstadoActivoFijo As Integer, CaracteristicaValor As String, CveCliente As Integer, Optional BuscaGrupoEmpresa As Integer = -1, Optional BuscaPorAFPadre As Integer = -1, Optional CveGrupo As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_ActivosFijosGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@Codigo", SqlDbType.VarChar).Value = Codigo + .Add("@Descripcion", SqlDbType.VarChar).Value = Descripcion + .Add("@CveTipoActivoFijo", SqlDbType.Int).Value = CveTipoActivoFijo + .Add("@CveSubTipoActivoFijo", SqlDbType.Int).Value = CveSubTipoActivoFijo + .Add("@NoSerie", SqlDbType.VarChar).Value = NoSerie + .Add("@Año", SqlDbType.Int).Value = Año + .Add("@CvePersonaResponsable", SqlDbType.Int).Value = CvePersonaResponsable + .Add("@CveProyecto", SqlDbType.Int).Value = CveProyecto + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveEstadoActivoFijo", SqlDbType.Int).Value = CveEstadoActivoFijo + .Add("@CaracteristicaValor", SqlDbType.VarChar).Value = CaracteristicaValor + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@BuscaGrupoEmpresa", SqlDbType.Int).Value = BuscaGrupoEmpresa + .Add("@CveAFPadre", SqlDbType.Int).Value = BuscaPorAFPadre + .Add("@CveGrupo", SqlDbType.Int).Value = CveGrupo + End With + Try + SqlAdapter.Fill(Data) + + If CveActivoFijo > 0 AndAlso Data IsNot Nothing AndAlso Data.Rows.Count > 0 Then + Me.CveActivoFijo = Data.Rows(0)("CveActivoFijo").ToString.ToEntero + + Me.Codigo = Data.Rows(0)("Codigo").ToString + Me.Descripcion = Data.Rows(0)("Descripcion").ToString + Me.CuentaInicial = Data.Rows(0)("Conta_CuentaInicial").ToString.ToEntero + Me.CveTipoActivoFijo = Data.Rows(0)("CveTipoActivoFijo").ToString.ToEntero + Me.TipoActivoFijo = Data.Rows(0)("TipoActivoFijo").ToString + Me.CveSubTipoActivoFijo = Data.Rows(0)("CveSubTipoActivoFijo").ToString.ToEntero + Me.SubTipoActivoFijo = Data.Rows(0)("SubTipoActivoFijo").ToString + Me.CveCompra = Data.Rows(0)("CveCompra").ToString.ToEntero + Me.ValorCompra = Data.Rows(0)("ValorCompra").ToString.ToDouble + Me.FechaCompra = Data.Rows(0)("FechaCompra").ToString.ToDate + Me.CvePersonaResponsable = Data.Rows(0)("CvePersonaResponsable").ToString.ToEntero + Me.Responsable = Data.Rows(0)("Responsable").ToString + Me.NoSerie = Data.Rows(0)("NoSerie").ToString + Me.Año = Data.Rows(0)("Año").ToString.ToEntero + Me.CveSubProyecto = Data.Rows(0)("CveSubProyecto").ToString.ToEntero + Me.SubProyecto = Data.Rows(0)("SubProyecto").ToString + Me.CveProyecto = Data.Rows(0)("CveProyecto").ToString.ToEntero + Me.Proyecto = Data.Rows(0)("Proyecto").ToString + Me.Cuenta = Data.Rows(0)("Cuenta").ToString.ToEntero + Me.CveEstadoActivoFijo = Data.Rows(0)("CveEstadoActivoFijo").ToString.ToEntero + Me.EstadoActivoFijo = Data.Rows(0)("EstadoActivoFijo").ToString + Me.IdCtaContDepreciacion = Data.Rows(0)("IdCtaContDepreciacion").ToString.ToEntero + Me.PorDepreciacion = Data.Rows(0)("PorDepreciacion").ToString.ToDouble + Me.Observaciones = Data.Rows(0)("Observaciones").ToString + Me.MesesDepreciacion = Data.Rows(0)("MesesDepreciacion").ToString.ToEntero + Me.CveCliente = Data.Rows(0)("CveCliente").ToString.ToEntero + Me.NombreCliente = Data.Rows(0)("NombreCliente").ToString + Me.FechaIng = Data.Rows(0)("FechaIng").ToString.ToDate + Me.CveUsuario = Data.Rows(0)("CveUsuario").ToString.ToEntero + Me.Usuario = Data.Rows(0)("Usuario").ToString + Me.CveEmpresa = Data.Rows(0)("CveEmpresa").ToString.ToEntero + Me.MedidaUso = Data.Rows(0)("MedidaUso").ToString + Me.CveMovimientoInv = Data.Rows(0)("CveMovimientoInv").ToString.ToEntero + Me.FolioInv = Data.Rows(0)("FolioInv").ToString + Me.AlmacenInv = Data.Rows(0)("AlmacenInv").ToString + Me.CveMarcaActivoFijo = Data.Rows(0)("CveMarcaActivoFijo").ToString.ToEntero + Me.CveModeloActivoFijo = Data.Rows(0)("CveModeloActivoFijo").ToString.ToEntero + Me.CveGrupoAF = Data.Rows(0)("CveGrupo").ToString.ToEntero + Me.CveAFPadre = Data.Rows(0)("CveAFPadre").ToString.ToEntero + Me.CveDispositivo = Data.Rows(0)("CveDispositivo").ToString.ToEntero + End If + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Catálogo de Activos Fijos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + 'Public Function AddActivosFijos(Codigo As String, Descripcion As String, ValorCompra As Double, FechaCompra As Date, CveSubTipoActivoFijo As Integer, + ' CvePersonalResponsable As Integer, NoSerie As String, Año As Integer, CveSubProyecto As Integer, Cuenta As Integer, + ' CveEstadoActivoFijo As Integer, IdCtaContDepreciacion As Integer, PorDepreciacion As Double, PorDeduccion As Double, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + ' Dim Retorno As Boolean = False + + ' DataAdapter("PA_AF_ActivosFijosAdd") + + ' With SqlAdapter.SelectCommand.Parameters + ' .Add("@Codigo", SqlDbType.VarChar).Value = Codigo + ' .Add("@Descripcion", SqlDbType.VarChar).Value = Descripcion + ' .Add("@CveSubTipoActivoFijo", SqlDbType.Int).Value = CveSubTipoActivoFijo + ' .Add("@ValorCompra", SqlDbType.Money).Value = ValorCompra + ' .Add("@FechaCompra", SqlDbType.Date).Value = FechaCompra + ' .Add("@CvePersonalResponsable", SqlDbType.Int).Value = CvePersonalResponsable + ' .Add("@NoSerie", SqlDbType.VarChar).Value = NoSerie + ' .Add("@Año", SqlDbType.Int).Value = Año + ' .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + ' .Add("@IdCtaContActivoFijo", SqlDbType.Int).Value = Cuenta + ' .Add("@CveEstadoActivoFijo", SqlDbType.Int).Value = CveEstadoActivoFijo + ' .Add("@IdCtaContDepreciacion", SqlDbType.Int).Value = IdCtaContDepreciacion + ' .Add("@PorDepreciacion", SqlDbType.Float).Value = PorDepreciacion + ' .Add("@PorDeduccion", SqlDbType.Float).Value = PorDeduccion + ' .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 Activo Fijo con el mismo nombre: " & Descripcion & ".", TipoMensaje.MsgAdvertencia) + ' Else + ' Me.OnError("Ocurrió un error al Guardar el Activo Fijo.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + ' End If + ' Catch ex As Exception + + ' End Try + + ' Return Retorno + 'End Function + Public Function AddActivosFijos(Codigo As String, Descripcion As String, ValorCompra As Double, FechaCompra As Date, CveSubTipoActivoFijo As Integer, CvePersonalResponsable As Integer, NoSerie As String, Año As Integer, + CveSubProyecto As Integer, Cuenta As Integer, CveEstadoActivoFijo As Integer, IdCtaContDepreciacion As Integer, PorDepreciacion As Double, Observaciones As String, CveCliente As Integer, + CveMovimiento As Integer, CveUsuario As Integer, CveEmpresa As Integer, Optional CveMarca As Integer = -1, Optional CveModelo As Integer = -1, Optional CveGrupo As Integer = -1, + Optional CveAFPadre As Integer = -1, Optional CveDispositivo As Integer = -1) As Integer + Dim Retorno As Integer = -1 + + DataAdapter("PA_AF_ActivosFijosAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Codigo", SqlDbType.VarChar).Value = Codigo + .Add("@Descripcion", SqlDbType.VarChar).Value = Descripcion + .Add("@CveSubTipoActivoFijo", SqlDbType.Int).Value = CveSubTipoActivoFijo + .Add("@ValorCompra", SqlDbType.Money).Value = ValorCompra + .Add("@FechaCompra", SqlDbType.Date).Value = FechaCompra + .Add("@CvePersonalResponsable", SqlDbType.Int).Value = CvePersonalResponsable + .Add("@NoSerie", SqlDbType.VarChar).Value = NoSerie + .Add("@Año", SqlDbType.Int).Value = Año + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@IdCtaContActivoFijo", SqlDbType.Int).Value = Cuenta + .Add("@CveEstadoActivoFijo", SqlDbType.Int).Value = CveEstadoActivoFijo + .Add("@IdCtaContDepreciacion", SqlDbType.Int).Value = IdCtaContDepreciacion + .Add("@PorDepreciacion", SqlDbType.Float).Value = PorDepreciacion + '.Add("@CveEstadoActivoFijo", SqlDbType.Int).Value = CveEstadoActivoFijo + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones + .Add("@CveMovimiento", SqlDbType.Int).Value = CveMovimiento + .Add("@CveMarca", SqlDbType.Int).Value = CveMarca + .Add("@CveModelo", SqlDbType.Int).Value = CveModelo + .Add("@CveGrupo", SqlDbType.Int).Value = CveGrupo + .Add("@CveAFPadre", SqlDbType.Int).Value = CveAFPadre + .Add("@CveDispositivo", SqlDbType.Int).Value = CveDispositivo + + .Add("@CveActivoFijo", SqlDbType.Int).Direction = ParameterDirection.Output + .Add("@RETURN_VALUE", SqlDbType.Int).Direction = ParameterDirection.ReturnValue + End With + + Try + SqlAdapter.Fill(Data) + CveActivoFijo = SqlAdapter.SelectCommand.Parameters("@CveActivoFijo").Value.ToString.ToEntero + 'Dim RetValue As Integer = SqlAdapter.SelectCommand.Parameters("@RETURN_VALUE").Value.ToString.ToEntero + Retorno = CveActivoFijo + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 2627;") Then + If Ex1.Message.Contains("UN_ActivoFijo") Then + Alert("El Codigo ya se encuentra registrado", TipoMensaje.MsgAdvertencia) + Else + Alert("Ya existe un Activo Fijo con el mismo nombre: " & Descripcion & ".", TipoMensaje.MsgAdvertencia) + End If + + Else + Me.OnError("Ocurrió un error al Guardar el Activo Fijo.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + + End Try + + Return Retorno + End Function + Public Function UpdateActivosFijos(CveActivoFijo As Integer, Codigo As String, Descripcion As String, ValorCompra As Double, FechaCompra As Date, CveSubTipoActivoFijo As Integer, + CvePersonalResponsable As Integer, NoSerie As String, Año As Integer, CveSubProyecto As Integer, IdCtaContActivoFijo As Integer, + CveEstadoActivoFijo As Integer, IdCtaContDepreciacion As Integer, PorDepreciacion As Double, Observaciones As String, CveCliente As Integer, + CveUsuarioModifico As Integer, CveEmpresa As Integer, Optional CveMarca As Integer = -1, Optional CveModelo As Integer = -1, Optional CveGrupo As Integer = -1, + Optional CveAFPadre As Integer = -1, Optional CveDispositivo As Integer = -1) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_ActivosFijosUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo + .Add("@Codigo", SqlDbType.VarChar).Value = Codigo + .Add("@Descripcion", SqlDbType.VarChar).Value = Descripcion + .Add("@CveSubTipoActivoFijo", SqlDbType.Int).Value = CveSubTipoActivoFijo + .Add("@ValorCompra", SqlDbType.Money).Value = ValorCompra + .Add("@FechaCompra", SqlDbType.Date).Value = FechaCompra + '.Add("@CveModeloActivoFijo", SqlDbType.Int).Value = CveModeloActivoFijo + '.Add("@CveMarcaActivoFijo", SqlDbType.Int).Value = CveMarcaActivoFijo + .Add("@CvePersonalResponsable", SqlDbType.Int).Value = CvePersonalResponsable + .Add("@NoSerie", SqlDbType.VarChar).Value = NoSerie + .Add("@Año", SqlDbType.Int).Value = Año + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@IdCtaContActivoFijo", SqlDbType.Int).Value = IdCtaContActivoFijo + .Add("@IdCtaContDepreciacion", SqlDbType.Int).Value = IdCtaContDepreciacion + .Add("@PorDepreciacion", SqlDbType.Float).Value = PorDepreciacion + .Add("@PorDeduccion", SqlDbType.Float).Value = -1 + .Add("@CveEstadoActivoFijo", SqlDbType.Int).Value = CveEstadoActivoFijo + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveUsuarioModifico", SqlDbType.Int).Value = CveUsuarioModifico + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones + .Add("@CveMarca", SqlDbType.Int).Value = CveMarca + .Add("@CveModelo", SqlDbType.Int).Value = CveModelo + .Add("@CveGrupo", SqlDbType.Int).Value = CveGrupo + .Add("@CveAFPadre", SqlDbType.Int).Value = CveAFPadre + .Add("@CveDispositivo", SqlDbType.Int).Value = CveDispositivo + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 2627;") Then + Alert("Ya existe un Activo Fijo con el mismo nombre: " & Descripcion & ".", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al guardar los cambios en el Activo Fijo", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + OnError("Ocurrió un error al guardar los cambios en el Activo Fijo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function RemoveActivosFijos(CveActivoFijo As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_ActivosFijosRemove") + SqlAdapter.SelectCommand.Parameters.Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 547;") Then + Alert("El Activo Fijo no se pudo eliminar porque está siendo usado por un registro.", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al eliminar el Activo Fijo.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + Me.OnError("Ocurrió un error al eliminar el Activo Fijo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function UpdateActivosFijosCompra(CveActivoFijo As Integer, CveCompraDetalle As Integer, TipoAF As Integer, ValorCompra As Double, FechaCompra As Date) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_ActivosFijosCompraUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo + .Add("@CveCompraDetalle", SqlDbType.Int).Value = CveCompraDetalle + .Add("@TipoAF", SqlDbType.Int).Value = TipoAF + .Add("@ValorCompra", SqlDbType.Float).Value = ValorCompra + .Add("@FechaCompra", SqlDbType.Date).Value = FechaCompra + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 2627;") Then + Alert("Ya existe un Activo Fijo con el mismo nombre: " & Descripcion & ".", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al guardar los cambios en el Activo Fijo", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + OnError("Ocurrió un error al guardar los cambios en el Activo Fijo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function UpdateActivosFijosCuentaAC(CveActivoFijo As Integer, IdCuentaContable As Integer, CveUsuario As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_ActivosFijosCtaContableUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo + .Add("@IdCuentaContable", SqlDbType.Int).Value = IdCuentaContable + .Add("@CveUsuarioModifico", SqlDbType.Int).Value = CveUsuario + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + OnError("Ocurrió un error al actualizar la cuenta contable en el Activo Fijo", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + Catch ex As Exception + OnError("Ocurrió un error al actualizar la cuenta contable en el Activo Fijo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + +#End Region + +#Region "A C T I V O S - F I J O S- B I T A C O R A S" + Public Function GetActivosFijosBitacora(CveActivoFijo As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_ActivosFijosBitacoraGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveActivoFijo", SqlDbType.VarChar).Value = CveActivoFijo + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Catálogo de Activos Fijos - Bitacora.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function AddActivosFijosBitacora(CveActivoFijo As Integer, Observacion As String, CveUsuario As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_ActivosFijosBitacoraAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo + .Add("@Observacion", SqlDbType.VarChar).Value = Observacion + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex As SqlException + OnError("Ocurrió un error al Guardar la Bitacora del Activo Fijo ", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function +#End Region + +#Region "A C T I V O S - F I J O S - C A R A C T E R I S T I C A S" + + Public Function GetActivosFijosCaracteristicas(CveActivoFijo As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_ActivosFijosCaracteristicasGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveActivoFijo", SqlDbType.VarChar).Value = CveActivoFijo + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Catálogo de Activos Fijos - Caracteristicas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + +#End Region + +#Region "A C T I V O S- F I J O S - H I S T O R I A L" + Public Function GetActivosFijosHistorial(CveActivoFijo As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_ActivosFijosHistorialGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveActivoFijo", SqlDbType.VarChar).Value = CveActivoFijo + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Catálogo de Activos Fijos - Historial.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function AddActivosFijosHistorial(CveActivoFijo As Integer, CveConceptoHistorialActivoFijo As Integer, Actual As String, Anterior As String, CveUsuario As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_ActivosFijosHistorialAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo + .Add("@CveConceptoHistorialActivoFijo", SqlDbType.Int).Value = CveConceptoHistorialActivoFijo + .Add("@Actual", SqlDbType.VarChar).Value = Actual + .Add("@Anterior", SqlDbType.VarChar).Value = Anterior + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex As SqlException + OnError("Ocurrió un error al Guardar el Historial del Activo Fijo", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function +#End Region + +#Region "A C T I V O S- F I J O S - I M A G E N E S" + Public Function GetActivosFijosImagenes(CveActivoFijo As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_ActivosFijosImagenesGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveActivoFijo", SqlDbType.VarChar).Value = CveActivoFijo + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Catálogo de Activos Fijos - Imagenes.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function AddActivosFijosImagenes(CveActivoFijo As Integer, URL As String, CveUsuario As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_ActivosFijosImagenesAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo + .Add("@URL", SqlDbType.VarChar).Value = URL + .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 Imagen en Fijo Imagenes con el mismo nombre: " & Descripcion & ".", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al Guardar la Imagen en Activo Fijo.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + OnError("Ocurrió un error al Guardar la Imagen en Activo Fijo", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function RemoveActivosFijosImagenes(CveImagenActivoFijo As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_ActivosFijosImagenesRemove") + SqlAdapter.SelectCommand.Parameters.Add("@CveImagenActivoFijo", SqlDbType.Int).Value = CveImagenActivoFijo + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 547;") Then + Alert("La Imagen del Activo Fijo no se pudo eliminar porque está siendo usado por un registro.", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al eliminar la Imagen del Activo Fijo.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + Me.OnError("Ocurrió un error al eliminar la Imagen del Activo Fijo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +#End Region + +#Region "A C T I V O S - F I J O S - R E S G U A R D O S" + Public Function GetActivosFijosResguardos(CveActivoFijo As Integer, CveActivoFijoResguardo As Integer, CveResponsable As Integer, CveResguardo As Integer, Optional CveEmpresa As Integer = -1, Optional CveSubProyecto As Integer = -1, Optional Folio As Integer = -1, Optional CveResguardo2 As Integer = -1, Optional UsuarioImprimio As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_ActivosFijosResguardosGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo + .Add("@CveActivoFijoResguardo", SqlDbType.Int).Value = CveActivoFijoResguardo + .Add("@CveResponsable", SqlDbType.Int).Value = CveResponsable + .Add("@CveResguardo", SqlDbType.Int).Value = CveResguardo + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@Folio", SqlDbType.Int).Value = Folio + .Add("@CveResguardo2", SqlDbType.Int).Value = CveResguardo2 + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@UsuarioImprimio", SqlDbType.Int).Value = UsuarioImprimio + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex As Exception + OnError("Ocurrió un error al obtener el Catálogo de Activos Fijos - Resguardos.", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + + Public Function ActivoFijoResguardoADD(FechaInicio As Date, CvePersonal As Integer, CveUsuario As Integer, CveSubProyecto As Integer, CveActivoFijo As Integer, TipoDocto As String, Tipo As Integer, CveEmpresa As Integer, Optional Observaciones As String = " ", Optional CveResguardo As Integer = -1) As Boolean + 'Dim CveResguardo As Integer = -1 + Dim Retorno = False + DataAdapter("PA_AF_ActivosFijosResguardosAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePersonal", SqlDbType.Int).Value = CvePersonal + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo + .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones + .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio + .Add("@Tipo", SqlDbType.Int).Value = Tipo + .Add("@CveResguardo", SqlDbType.Int).Value = CveResguardo + .Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@Folio", SqlDbType.Int).Direction = ParameterDirection.Output + End With + Try + SqlAdapter.Fill(Data) + FolioResguardo = SqlAdapter.SelectCommand.Parameters("@Folio").Value.ToString().ToEntero() + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al guardar el resguardo", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function ActivoFijoResguardoGpo() As Integer + Dim CveResguardo As Integer = -1 + DataAdapter("PA_AF_ActivosFijosResguardosGpo") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveResguardo", SqlDbType.Int).Direction = ParameterDirection.Output + End With + Try + SqlAdapter.Fill(Data) + CveResguardo = SqlAdapter.SelectCommand.Parameters("@CveResguardo").Value.ToString().ToEntero() + Catch ex As Exception + OnError("Ocurrió un error al obtener el grupo del resguardo", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return CveResguardo + End Function + Public Function UpdateActivosFijosResguardos(FechaFin As String, Observaciones As String, URL As String, CveActivoFijoResguardo As Integer, CveActivoFijo As Integer, Optional URL2 As String = "-1", Optional CveResguardo2 As Integer = -1, Optional CveSubProyecto As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_ActivosFijosResguardosUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaFin", SqlDbType.VarChar).Value = FechaFin + .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones + .Add("@URL", SqlDbType.VarChar).Value = URL + .Add("@CveActivoFijoResguardo", SqlDbType.Int).Value = CveActivoFijoResguardo + .Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo + .Add("@URL2", SqlDbType.VarChar).Value = URL2 + .Add("@CveResguardo2", SqlDbType.Int).Value = CveResguardo2 + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + + Catch ex As Exception + OnError("Ocurrió un error al guardar los cambios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function UpdateEstatusResguardo(EstatusResguardo As Integer, CveEmpresa As Integer, CveActivoFijo As Integer, Optional CveSubProyecto As Integer = -1, Optional CveUsuarioModifico As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_UpdateEstatusResguardo") + 'ESTATUS RESGUARDO: 1- Disponible, 2- En Traslado, 3- Asignado + With SqlAdapter.SelectCommand.Parameters + .Add("@EstatusResguardo", SqlDbType.Int).Value = EstatusResguardo + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo + .Add("@CveUsuarioModifico", SqlDbType.Int).Value = CveUsuarioModifico + + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + + Catch ex As Exception + OnError("Ocurrió un error al guardar los cambios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function UpdateActivosFijosResguardosURL(URL As String, URL2 As String, CveActivoFijoResguardo As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_ActivosFijosResguardosUrlUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@URL", SqlDbType.VarChar).Value = URL + .Add("@URL2", SqlDbType.VarChar).Value = URL2 + .Add("@CveActivoFijoResguardo", SqlDbType.Int).Value = CveActivoFijoResguardo + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + + Catch ex As Exception + OnError("Ocurrió un error al guardar los cambios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function UpdateActivosFijosResguardosURLGpo(URL As String, URL2 As String, CveResguardo As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_ActivosFijosResguardosGpoUrl") + + With SqlAdapter.SelectCommand.Parameters + .Add("@URL", SqlDbType.VarChar).Value = URL + .Add("@URL2", SqlDbType.VarChar).Value = URL2 + .Add("@CveActivoFijoResguardo", SqlDbType.Int).Value = CveResguardo + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + + Catch ex As Exception + OnError("Ocurrió un error al guardar los cambios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function GetActivosFijosHijos(CveEmpresa As Integer, CveAFPadre As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_ActivosFijosHijosGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveAFPadre", SqlDbType.Int).Value = CveAFPadre + .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 AF Hijos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + +#End Region + +#Region "A C T I V O S - F I J O S - COMPRAS " + Public Function GetActivosFijosCompras(CveActivoFijo As Integer, Optional CveClasificacion As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_ActivosFijosCompras") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo + .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex As Exception + OnError("Ocurrió un error al obtener las Compras del Activo Fijo.", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function +#End Region + +#Region " ************************************************ C A R A C T E R I S T I C A S ************************************************ " + +#Region "ClasificacionesCaracteristicas" + + Public Function GetCaracteristicasClasificaciones(CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_CaracteristicasClasificacionesGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Data.TableName = "CaracteristicasClasificaciones" + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Catálogo de Clasificaciones de Características.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function AddClasificacionesCaracteristicas(CaracteristicaClasificacion As String, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_CaracteristicasClasificacionesAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CaracteristicaClasificacion", SqlDbType.VarChar).Value = CaracteristicaClasificacion + .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 Guardar la Clasificacion de Caracteristica.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function UpdateClasificacionesCaracteristicas(CaracteristicaClasificacion As String, Estatus As Boolean, CveCaracteristicaClasificacion As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_CaracteristicasClasificacionesUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CaracteristicaClasificacion", SqlDbType.VarChar).Value = CaracteristicaClasificacion + '.Add("@CveSubTipoActivoFijo", SqlDbType.Int).Value = CveSubTipoActivoFijo + '.Add("@Orden", SqlDbType.Int).Value = Orden + .Add("@Estatus", SqlDbType.Bit).Value = Estatus + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveCaracteristicaClasificacion", SqlDbType.Int).Value = CveCaracteristicaClasificacion + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 2627;") Then + Alert("Ya existe una Clasificacion de Caracteristica con el mismo nombre: " & CaracteristicaClasificacion & ".", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al guardar los cambios en la Clasificacion de Caracteristica", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + OnError("Ocurrió un error al guardar los cambios en la Clasificacion de Caracteristica.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function RemoveClasificacionesCaracteristicas(CveCaracteristicaClasificacion As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_CaracteristicasClasificacionesRemove") + + SqlAdapter.SelectCommand.Parameters.Add("@CveCaracteristicaClasificacion", SqlDbType.Int).Value = CveCaracteristicaClasificacion + SqlAdapter.SelectCommand.Parameters.Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 547;") Then + Alert("La Clasificacion de Caracteristica no se pudo eliminar porque está siendo usado por un registro.", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al eliminar la Clasificacion de Caracteristica.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + Me.OnError("Ocurrió un error al eliminar la Clasificacion de Caracteristica.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +#End Region + + +#Region "Características" + Public Function GetCaracteristicas(CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_CaracteristicasGet") + + SqlAdapter.SelectCommand.Parameters.Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + + Try + SqlAdapter.Fill(Data) + Data.TableName = "Caracteristicas" + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Catálogo de Características.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + + Return Retorno + End Function + Public Function AddCaracteristica(Caracteristica As String, CveCaracteristicaClasificacion As Integer, CveTipoActivoFijo As Integer, CveSubTipoActivoFijo As Integer, TipoCampo As Integer, Longitud As Integer, Requerido As Integer, Orden As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_CaracteristicasAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Caracteristica", SqlDbType.VarChar).Value = Caracteristica + .Add("@CveTipoActivoFijo", SqlDbType.Int).Value = CveTipoActivoFijo + .Add("@CveSubTipoActivoFijo", SqlDbType.Int).Value = CveSubTipoActivoFijo + .Add("@TipoCampo", SqlDbType.TinyInt).Value = TipoCampo + .Add("@CveCaracteristicaClasificacion", SqlDbType.Int).Value = CveCaracteristicaClasificacion + .Add("@Longitud", SqlDbType.Int).Value = Longitud + .Add("@Requerido", SqlDbType.Int).Value = Requerido + .Add("@Orden", SqlDbType.Int).Value = Orden + .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 Característica con el mismo nombre: " & Caracteristica & ".", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al Guardar la Característica.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + OnError("Ocurrió un error al Guardar la Característica.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function UpdateCaracteristica(CveCaracteristicaClasificacion As Integer, Caracteristica As String, CveTipoActivoFijo As Integer, CveSubTipoActivoFijo As Integer, TipoCampo As Integer, Longitud As Integer, Requerida As Boolean, Orden As Integer, Estatus As Boolean, CveEmpresa As Integer, CveCaracteristica As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_CaracteristicasUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCaracteristica", SqlDbType.VarChar).Value = CveCaracteristica + .Add("@Caracteristica", SqlDbType.VarChar).Value = Caracteristica + .Add("@CveCaracteristicaClasificacion", SqlDbType.Int).Value = CveCaracteristicaClasificacion + .Add("@CveTipoActivoFijo", SqlDbType.Int).Value = CveTipoActivoFijo + .Add("@CveSubTipoActivoFijo", SqlDbType.Int).Value = CveSubTipoActivoFijo + .Add("@TipoCampo", SqlDbType.TinyInt).Value = TipoCampo + .Add("@Longitud", SqlDbType.Int).Value = Longitud + .Add("@Orden", SqlDbType.Int).Value = Orden + .Add("@Requerida", SqlDbType.Bit).Value = Requerida + .Add("@Estatus", SqlDbType.Bit).Value = Estatus + .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 Caracteristica con el mismo nombre: " & Caracteristica & ".", TipoMensaje.MsgAdvertencia) + ElseIf Ex1.Message.Contains("Número: 547;") Then + Alert("La Característica tiene Opciones que están siendo usado por un registro.", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al guardar los cambios en la Característica.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + OnError("Ocurrió un error al guardar los cambios en la Característica.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function RemoveCaracteristica(CveCaracteristica As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_CaracteristicasRemove") + + SqlAdapter.SelectCommand.Parameters.Add("@CveCaracteristica", SqlDbType.Int).Value = CveCaracteristica + SqlAdapter.SelectCommand.Parameters.Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 547;") Then + Alert("La Característica no se pudo eliminar porque está siendo usado por un registro.", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al eliminar la Característica.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + Me.OnError("Ocurrió un error al eliminar la Característica de Tipo de Cuenta y/o Equipo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +#End Region + + +#Region "CaracteristicasOpciones" + + Public Function GetCaracteristicasOpciones(CveCaracteristica As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_CaracteristicasOpcionesGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCaracteristica", SqlDbType.Int).Value = CveCaracteristica + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Data.TableName = "CaracteristicasOpciones" + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener las Opciones para las Caracteristicas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetCaracteristicasOpcionesSubTipo(CveCaracteristica As Integer, CveSubTipoActivoFijo As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_CaracteristicasOpcionesSubTipoGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCaracteristica", SqlDbType.Int).Value = CveCaracteristica + .Add("@CveSubTipoActivoFijo", SqlDbType.Int).Value = CveSubTipoActivoFijo + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Data.TableName = "CaracteristicasOpciones" + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener las Opciones para las Caracteristicas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function AddCaracteristicasOpciones(CaracteristicaOpcion As String, CveCaracteristica As Integer, Orden As Integer, CveUsuario As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_CaracteristicasOpcionesAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CaracteristicaOpcion", SqlDbType.VarChar).Value = CaracteristicaOpcion + .Add("@CveCaracteristica", SqlDbType.Int).Value = CveCaracteristica + .Add("@Orden", SqlDbType.Int).Value = Orden + .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 Opcion para la Caracteristica con el mismo nombre: " & CaracteristicaOpcion & ".", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al Guardar la Opcion para la Caracteristica.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + OnError("Ocurrió un error al Guardar la Opcion para la Caracteristica.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function UpdateCaracteristicasOpciones(CveCaracteristica As Integer, CaracteristicaOpcion As String, Orden As Integer, Estatus As Boolean, CveCaracteristicaOpcion As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_CaracteristicasOpcionesUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CaracteristicaOpcion", SqlDbType.VarChar).Value = CaracteristicaOpcion + .Add("@Orden", SqlDbType.Int).Value = Orden + .Add("@Estatus", SqlDbType.Bit).Value = Estatus + .Add("@CveCaracteristica", SqlDbType.Int).Value = CveCaracteristica + .Add("@CveCaracteristicaOpcion", SqlDbType.Int).Value = CveCaracteristicaOpcion + .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 Opcion para la Caracteristica con el mismo nombre: " & CaracteristicaOpcion & ".", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al guardar los cambios en la Opcion para la Caracteristica.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + OnError("Ocurrió un error al guardar los cambios en la Opcion para la Caracteristica.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function RemoveCaracteristicasOpciones(CveCaracteristicaOpcion As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_CaracteristicasOpcionesRemove") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCaracteristicaOpcion", SqlDbType.Int).Value = CveCaracteristicaOpcion + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 547;") Then + Alert("La Opcion para la Caracteristica no se pudo eliminar porque está siendo usado por un registro.", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al eliminar la Opcion para la Caracteristica.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + Me.OnError("Ocurrió un error al eliminar la Opcion para la Caracteristica.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +#End Region + + +#Region "A C T I V O S V A L O R E S" + Public Function GetActivosFijosValores(CveActivoFijo As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_ActivoFijoValoresGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo + .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 Valores de Activos Fijos .", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function AddActivosFijosValores(CveActivoFijo As Integer, CveCaracteristica As Integer, CveOpcion As Integer, Valor As String, CveUsuario As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_ActivoFijoValoresAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo + .Add("@CveCaracteristica", SqlDbType.Int).Value = CveCaracteristica + .Add("@CveOpcion", SqlDbType.Int).Value = CveOpcion + .Add("@Valor", SqlDbType.VarChar).Value = Valor + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + Me.OnError("Ocurrió un error al Guardar el Valor de Activo Fijo.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + Catch ex As Exception + + End Try + + Return Retorno + End Function + + Public Function AddUpdActivosFijosValores(CveActivoFijo As Integer, CveCaracteristica As Integer, CveOpcion As Integer, Valor As String, CveUsuario As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_ActivoFijoValoresAddUpd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo + .Add("@CveCaracteristica", SqlDbType.Int).Value = CveCaracteristica + .Add("@CveOpcion", SqlDbType.Int).Value = CveOpcion + .Add("@Valor", SqlDbType.VarChar).Value = Valor + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + Me.OnError("Ocurrió un error al Guardar el Valor de Activo Fijo.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + Catch ex As Exception + + End Try + + Return Retorno + End Function + + Public Function UpdateActivosFijosValores(CveActivoFijo As Integer, CveCaracteristica As Integer, CveOpcion As Integer, Valor As String, CveUsuario As Integer, CveValor As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_ActivoFijoValoresUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo + .Add("@CveCaracteristica", SqlDbType.Int).Value = CveCaracteristica + .Add("@CveOpcion", SqlDbType.Int).Value = CveOpcion + .Add("@Valor", SqlDbType.VarChar).Value = Valor + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveValor", SqlDbType.Int).Value = CveValor + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + Me.OnError("Ocurrió un error al guardar los cambios en el Valor del Activo Fijo", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + Catch ex As Exception + OnError("Ocurrió un error al guardar los cambios en el Valor del Activo Fijo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function RemoveActivosFijosValores(CveActivoFijo As Integer, CveValor As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_ActivoFijoValoresRemove") + SqlAdapter.SelectCommand.Parameters.Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo + SqlAdapter.SelectCommand.Parameters.Add("@CveValor", SqlDbType.Int).Value = CveValor + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 547;") Then + Alert("El Valor de Activo Fijo no se pudo eliminar porque está siendo usado por un registro.", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al eliminar el Valor de Activo Fijo.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + Me.OnError("Ocurrió un error al eliminar el Valor de Activo Fijo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +#End Region +#End Region + +#Region "Subtipos Activos Fijos" + + Public Function GetSubTiposActivosFijos(CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_SubTiposActivosFijosGet") + + 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 Subtipos de Activos Fijos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function AddSubTiposActivosFijos(CveTipoActivoFijo As Integer, SubTipoActivoFijo As String, CveUsuario As Integer, CveEmpresa As Integer, Optional AplicaGPS As Boolean = False) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_SubTiposActivosFijosAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveTipoActivoFijo", SqlDbType.Int).Value = CveTipoActivoFijo + .Add("@SubTipoActivoFijo", SqlDbType.VarChar).Value = SubTipoActivoFijo + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@AplicaGPS", SqlDbType.Bit).Value = AplicaGPS + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex As SqlException + OnError("Ocurrió un error al Guardar el Subtipo de Activo Fijo", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function UpdateSubTiposActivosFijos(CveSubTipoActivoFijo As Integer, CveTipoActivoFijo As Integer, SubTipoActivoFijo As String, Estado As Boolean, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_SubTiposActivosFijosUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveSubTipoActivoFijo", SqlDbType.Int).Value = CveSubTipoActivoFijo + .Add("@CveTipoActivoFijo", SqlDbType.Int).Value = CveTipoActivoFijo + .Add("@SubTipoActivoFijo", SqlDbType.VarChar).Value = SubTipoActivoFijo + .Add("@Estado", SqlDbType.Bit).Value = Estado + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex As SqlException + Catch ex As Exception + OnError("Ocurrió un error al guardar los cambios en el Subtipo del Activo Fijo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function RemoveSubTiposActivosFijos(CveSubTiposActivosFijos As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_SubTiposActivosFijosRemove") + + SqlAdapter.SelectCommand.Parameters.Add("@CveSubTipoActivoFijo", SqlDbType.Int).Value = CveSubTiposActivosFijos + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex As SqlException + Me.OnError("Ocurrió un error al eliminar el Subtipo del Activo Fijo.", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +#End Region + +#Region "Tipos Activos Fijos" + + Public Function GetTiposActivosFijos(CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_TiposActivosFijosGet") + + 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 Tipos de Activos Fijos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function AddTiposActivosFijos(TipoActivoFijo As String, CuentaInicial As Integer, CveUsuario As Integer, CveEmpresa As Integer, Optional PorDepreciacion As Decimal = 0, Optional MedidaVehicular As Integer = 1, Optional AutoFolio As Boolean = False, Optional Contable As Boolean = False) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_TiposActivosFijosAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@TipoActivoFijo", SqlDbType.VarChar).Value = TipoActivoFijo + .Add("@CuentaInicial", SqlDbType.VarChar).Value = CuentaInicial + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@PorDepreciacion", SqlDbType.Money).Value = PorDepreciacion + .Add("@MedidaVehicular", SqlDbType.TinyInt).Value = MedidaVehicular + .Add("@AutoFolio", SqlDbType.Bit).Value = AutoFolio + .Add("@Contable", SqlDbType.Bit).Value = Contable + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex As SqlException + OnError("Ocurrió un error al Guardar el Tipo de Activo Fijo", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function UpdateTiposActivosFijos(CveTipoActivoFijo As Integer, TipoActivoFijo As String, CuentaInicial As Integer, Estado As Boolean, Optional PorDepreciacion As Decimal = 0, Optional MedidaVehicular As Integer = 1, Optional AutoFolio As Boolean = False, Optional Contable As Boolean = False) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_TiposActivosFijosUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveTipoActivoFijo", SqlDbType.Int).Value = CveTipoActivoFijo + .Add("@TipoActivoFijo", SqlDbType.VarChar).Value = TipoActivoFijo + .Add("@CuentaInicial", SqlDbType.VarChar).Value = CuentaInicial + .Add("@Estado", SqlDbType.Bit).Value = Estado + .Add("@PorDepreciacion", SqlDbType.Money).Value = PorDepreciacion + .Add("@MedidaVehicular", SqlDbType.TinyInt).Value = MedidaVehicular + .Add("@AutoFolio", SqlDbType.Bit).Value = AutoFolio + .Add("@Contable", SqlDbType.Bit).Value = Contable + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex As SqlException + Catch ex As Exception + OnError("Ocurrió un error al guardar los cambios en el Tipo del Activo Fijo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function RemoveTiposActivosFijos(CveTiposActivosFijos As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_TiposActivosFijosRemove") + + SqlAdapter.SelectCommand.Parameters.Add("@CveTipoActivoFijo", SqlDbType.Int).Value = CveTiposActivosFijos + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex As SqlException + Me.OnError("Ocurrió un error al eliminar el tipo del Activo Fijo.", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +#End Region + +#Region "A C T I V O S - S U B T I P O S " + + Public Function GetSubTiposCaracteristicas(CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_SubTiposCaracteristicasGet") + + 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 caracteristicas de Subtipos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function AddSubTipoCaracteristica(CveSubTipoActivoFijo As Integer, CveCaracteristica As Integer, CveUsuario As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_SubTiposCaracteristicasAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveSubTipoActivoFijo", SqlDbType.Int).Value = CveSubTipoActivoFijo + .Add("@CveCaracteristica", SqlDbType.Int).Value = CveCaracteristica + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex As SqlException + OnError("Ocurrió un error al Guardar el Subtipo de Activo Fijo", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function RemoveSubTipoCaracteristica(CveSubTipoActivosFijos As Integer, CveCaracteristica As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_SubTiposCaracteristicasRemove") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveSubTipoActivoFijo", SqlDbType.Int).Value = CveSubTipoActivosFijos + .Add("@CveCaracteristica", SqlDbType.Int).Value = CveCaracteristica + End With + + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex As SqlException + Me.OnError("Ocurrió un error al eliminar el Subtipo del Activo Fijo.", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +#End Region + +#Region "ESTATUS DE ACTIVOS FIJOS" + Public Function GetEstatusActivoFijo() As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_EstatusActivoFijoGet") + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Catálogo de Estatus de Activo Fijo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function AddEstatusActivoFIjo(EstadoActivoFijo As Integer, CveUsuario As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_EstatusActivoFijoAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@EstadoActivoFijo", SqlDbType.Int).Value = EstadoActivoFijo + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex As SqlException + OnError("Ocurrió un error al Guardar el Departamento", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function UpdateEstatusActivoFijo(CveEstadoActivoFIjo As Integer, EstadoActivoFijo As Integer, Estado As Boolean) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_EstatusActivoFijoUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@EstadoActivoFijo", SqlDbType.Int).Value = EstadoActivoFijo + .Add("@CveEstadoActivoFijo", SqlDbType.Int).Value = CveEstadoActivoFIjo + .Add("@Estado", SqlDbType.Bit).Value = Estado + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex As SqlException + OnError("Ocurrió un error al guardar los cambios en el Estado del Activo Fijo.", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + Public Function RemoveEstatusActivoFijo(CveEstadoActivoFijo As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_EstatusActivoFijoRemove") + + SqlAdapter.SelectCommand.Parameters.Add("@CveEstadoActivoFijo", SqlDbType.Int).Value = CveEstadoActivoFijo + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 547;") Then + Alert("El Departamento no se pudo eliminar porque está siendo usado por un registro.", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al eliminar el Departamento.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + Me.OnError("Ocurrió un error al eliminar el Departamento.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +#End Region + +#Region "ClsAFModelosActivosFijos" + Public Function GetModelosActivosFijos(CveEmpresa As Integer, CveMarca As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_ModelosActivosFijosGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveMarca", SqlDbType.Int).Value = CveMarca + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Catálogo de Modelos de Activos Fijos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function AddModelosActivosFijos(ModeloActivoFijo As String, CveMarcaAF As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_ModelosActivosFijosAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@ModeloActivoFijo", SqlDbType.VarChar).Value = ModeloActivoFijo + .Add("@CveMarcaAF", SqlDbType.Int).Value = CveMarcaAF + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex As SqlException + OnError("Ocurrió un error al Guardar el Modelo del Activo Fijo", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function UpdateModelosActivosFijos(CveModeloActivoFijo As Integer, ModeloActivoFijo As String, CveMarcaAF As Integer, Estado As Boolean, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_ModelosActivosFijosUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveModeloActivoFijo", SqlDbType.Int).Value = CveModeloActivoFijo + .Add("@ModeloActivoFijo", SqlDbType.VarChar).Value = ModeloActivoFijo + .Add("@CveMarcaAF", SqlDbType.Int).Value = CveMarcaAF + .Add("@Estado", SqlDbType.Bit).Value = Estado + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex As SqlException + Catch ex As Exception + OnError("Ocurrió un error al guardar los cambios en el Modelo del Activo Fijo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function RemoveModelosActivosFijos(CveModelosActivosFijos As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_ModelosActivosFijosRemove") + + SqlAdapter.SelectCommand.Parameters.Add("@CveModeloActivoFijo", SqlDbType.Int).Value = CveModelosActivosFijos + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex As SqlException + Me.OnError("Ocurrió un error al eliminar el Modelo del Activo Fijo.", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +#End Region + +#Region "ClsAFMarcasActivosFijos" + Public Function GetMarcasActivosFijos(CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_MarcasActivosFijosGet") + + 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 de Activos Fijos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function AddMarcasActivosFijos(MarcaActivoFijo As String, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_MarcasActivosFijosAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@MarcaActivoFijo", SqlDbType.VarChar).Value = MarcaActivoFijo + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex As SqlException + OnError("Ocurrió un error al Guardar la Marca del Activo Fijo", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function UpdateMarcasActivosFijos(CveMarcaActivoFijo As Integer, MarcaActivoFijo As String, Estado As Boolean, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_MarcasActivosFijosUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveMarcaActivoFijo", SqlDbType.Int).Value = CveMarcaActivoFijo + .Add("@MarcaActivoFijo", SqlDbType.VarChar).Value = MarcaActivoFijo + .Add("@Estado", SqlDbType.Bit).Value = Estado + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex As SqlException + Catch ex As Exception + OnError("Ocurrió un error al guardar los cambios en la Marca del Activo Fijo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function RemoveMarcasActivosFijos(CveMarcaActivoFijo As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_MarcasActivosFijosRemove") + + SqlAdapter.SelectCommand.Parameters.Add("@CveMarcaActivoFijo", SqlDbType.Int).Value = CveMarcaActivoFijo + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex As SqlException + Me.OnError("Ocurrió un error al eliminar la Marca del Activo Fijo.", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +#End Region + +#Region "AF G R U P O S" + Public Function GetGrupoAF(CveGrupo As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_GruposGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveGrupo", SqlDbType.Int).Value = CveGrupo + .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 Grupos de Activos Fijos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function AddGrupoAF(Grupo As String, CveUsuario As Integer, CveEmpresa As Integer) As Integer + Dim Retorno As Integer = -1 + + DataAdapter("PA_AF_GruposAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Grupo", SqlDbType.VarChar).Value = Grupo + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveGrupo", SqlDbType.Int).Direction = ParameterDirection.Output + End With + + Try + SqlAdapter.Fill(Data) + Retorno = SqlAdapter.SelectCommand.Parameters("@CveGrupo").Value.ToString.ToEntero + Catch Ex As SqlException + OnError("Ocurrió un error al Guardar el Grupo", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function UpdateGrupoAF(Grupo As String, Estatus As Boolean, CveGrupo As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_GruposUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Grupo", SqlDbType.VarChar).Value = Grupo + .Add("@Estatus", SqlDbType.Bit).Value = Estatus + .Add("@CveGrupo", SqlDbType.Int).Value = CveGrupo + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex As SqlException + OnError("Ocurrió un error al Actualizar el Grupo", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function RemoveGrupoAF(CveEmpresa As Integer, CveGrupo As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_GruposRemove") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveGrupo", SqlDbType.Int).Value = CveGrupo + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex As SqlException + OnError("Ocurrió un error al Eliminar el Grupo", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function +#End Region + +#Region "ClsAFConceptosHistorial" + + Public Function GetConceptosHistorial() As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_ConceptosHistorialGet") + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Catálogo Historial de Conceptos", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function AddConceptosHistorial(ConceptoHistorialActivoFijo As String, CveUsuario As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_ConceptosHistorialAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@ConceptoHistorialActivoFijo", SqlDbType.VarChar).Value = ConceptoHistorialActivoFijo + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex As SqlException + OnError("Ocurrió un error al Guardar el Concepto del Historial", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function UpdateDepartamento(CveConceptoHistorialActivoFijo As Integer, ConceptoHistorialActivoFijo As String, Estado As Boolean) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_RH_DepartamentoUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveConceptoHistorialActivoFijo", SqlDbType.Int).Value = CveConceptoHistorialActivoFijo + .Add("@ConceptoHistorialActivoFijo", SqlDbType.VarChar).Value = ConceptoHistorialActivoFijo + .Add("@Estado", SqlDbType.Bit).Value = Estado + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex As SqlException + OnError("Ocurrió un error al guardar los cambios en el Concepto del Historial.", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function RemoveConceptosHistorialRemove(CveConceptoHistorialActivoFijo As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_ConceptosHistorialRemove") + SqlAdapter.SelectCommand.Parameters.Add("@CveConceptoHistorialActivoFijo", SqlDbType.Int).Value = CveConceptoHistorialActivoFijo + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex As SqlException + Me.OnError("Ocurrió un error al eliminar el Concepto del Historial.", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +#End Region + +#Region "ClsAFCaracteristicasActivosFijos" + + Public Function GetCaracteristicasActivosFijos(CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_CaracteristicasActivosFijos") + + 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 Características de Activos Fijos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function AddCaracteristicasActivosFijos(CveActivoFijo As Integer, Caracteristica As String, EsRequerido As Boolean, EsUnico As Boolean, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_CaracteristicasActivosFijosAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveActivoFijo", SqlDbType.VarChar).Value = CveActivoFijo + .Add("@Caracteristica", SqlDbType.VarChar).Value = Caracteristica + .Add("@EsRequerido", SqlDbType.Bit).Value = EsUnico + .Add("@EsUnico", SqlDbType.Bit).Value = EsRequerido + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex As SqlException + OnError("Ocurrió un error al Guardar la Característica del Activo Fijo", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function UpdateCaracteristicasActivosFijos(CveTipoActivoFijo As Integer, Caracteristica As String, EsRequerido As Boolean, EsUnico As Boolean, CveEmpresa As Integer, CveCaracteristicaActivoFijo As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_CaracteristicasActivosFijosUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveTipoActivoFijo", SqlDbType.VarChar).Value = CveTipoActivoFijo + .Add("@Caracteristica", SqlDbType.VarChar).Value = Caracteristica + .Add("@EsRequerido", SqlDbType.Bit).Value = EsUnico + .Add("@EsUnico", SqlDbType.Bit).Value = EsRequerido + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveCaracteristicaActivoFijo", SqlDbType.VarChar).Value = CveCaracteristicaActivoFijo + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex As SqlException + OnError("Ocurrió un error al guardar los cambios en la Característica del Activo Fijo.", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function RemoveCaracteristicasActivosFijos(CveCaracteristicaActivoFijo As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_CaracteristicasActivosFijosRemove") + + SqlAdapter.SelectCommand.Parameters.Add("@CveCaracteristicaActivoFijo", SqlDbType.Int).Value = CveCaracteristicaActivoFijo + + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex As SqlException + Me.OnError("Ocurrió un error al eliminar la Característica del Activo Fijo.", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + +#End Region + +#Region "O P E R A D O R E S" + Public Function GetTipoOperadores(CveTipoOperador As String, CveEmpresa As Integer, Estatus As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_TipoOperadoresGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveTipoOperador", SqlDbType.VarChar).Value = CveTipoOperador + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@Estatus", SqlDbType.Int).Value = Estatus + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Tipo Operador.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function AddOperador(Operador As String, CveTipoOperador As String, CveUsuario As Integer, CveEmpresa As Integer, Optional CveTransportista As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_OperadoresAdd") + With SqlAdapter.SelectCommand.Parameters + .Add("@Operador", SqlDbType.VarChar).Value = Operador + .Add("@CveTipoOperador", SqlDbType.VarChar).Value = CveTipoOperador + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveTransportista", SqlDbType.Int).Value = CveTransportista + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar el Operador.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function UpdateOperador(CveOperador As Integer, Operador As String, CveTipoOperador As String, CveUsuario As Integer, CveEmpresa As Integer, Estatus As Integer, Optional CveTransportista As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_OperadoresUpdate") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveOperador", SqlDbType.Int).Value = CveOperador + .Add("@Operador", SqlDbType.VarChar).Value = Operador + .Add("@CveTipoOperador", SqlDbType.VarChar).Value = CveTipoOperador + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@Estatus", SqlDbType.Int).Value = Estatus + .Add("@CveTransportista", SqlDbType.Int).Value = CveTransportista + + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar el chofer.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function RemoveOperador(CveOperador As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_OperadoresRemove") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveOperador", SqlDbType.Int).Value = CveOperador + + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar el Operador.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function GetOperadores(CveOperador As Integer, CveEmpresa As Integer, Estatus As Integer, Optional CveTransportista As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_OperadoresGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveOperador", SqlDbType.Int).Value = CveOperador + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@Estatus", SqlDbType.Int).Value = Estatus + .Add("@CveTransportista", SqlDbType.Int).Value = CveTransportista + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el chofer.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +#End Region + +#Region "T I P O S C O M B U S T I B L E S" + Public Function GetTiposCombustible(CveTipoCombustible As Integer, Estatus As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_TiposCombustibleGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveTiposCombustible", SqlDbType.VarChar).Value = CveTipoCombustible + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@Estatus", SqlDbType.Int).Value = Estatus + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Catálogo de Tipos de combustible", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function AddTipoCombustible(TipoCombustible As String, Estatus As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_TiposCombustibleAdd") + With SqlAdapter.SelectCommand.Parameters + .Add("@TipoCombustible", SqlDbType.VarChar).Value = TipoCombustible + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@Estatus", SqlDbType.Int).Value = Estatus + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar el tipo de combustible.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function UpdateTipoCombustible(CveTipoCombustible As Integer, TipoCombustible As String, Estatus As Integer, CveUsuario As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_TiposCombustibleUpdate") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveTipoCombustible", SqlDbType.Int).Value = CveTipoCombustible + .Add("@TipoCombustible", SqlDbType.VarChar).Value = TipoCombustible + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@Estatus", SqlDbType.Int).Value = Estatus + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar el tipo de combustible.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function RemoveTipoCombustible(CveTipoCombustible As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_OperadoresRemove") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveTipoCombustible", SqlDbType.Int).Value = CveTipoCombustible + + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar el Operador.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +#End Region + +#Region "C O M B U S T I B L E S" + Public Function GetCombustibles(CveCombustible As Integer, Estatus As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_CombustiblesGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCombustible", SqlDbType.Int).Value = CveCombustible + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@Estatus", SqlDbType.Int).Value = Estatus + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el combustible.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function AddCombustible(Combustible As String, CveTipoCombustible As Integer, Estatus As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_CombustiblesAdd") + With SqlAdapter.SelectCommand.Parameters + .Add("@Combustible", SqlDbType.VarChar).Value = Combustible + .Add("@CveTipoCombustible", SqlDbType.Int).Value = CveTipoCombustible + .Add("@Estatus", SqlDbType.Int).Value = Estatus + .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 agregar el Combustible.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function UpdateCombustible(CveCombustible As Integer, Combustible As String, CveTipoCombustible As Integer, Estatus As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_CombustiblesUpdate") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCombustible", SqlDbType.Int).Value = CveCombustible + .Add("@Combustible", SqlDbType.VarChar).Value = Combustible + .Add("@CveTipoCombustible", SqlDbType.Int).Value = CveTipoCombustible + .Add("@Estatus", SqlDbType.Int).Value = Estatus + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar el Combustible.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function RemoveCombustible(CveCombustible As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_CombustiblesRemove") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCombustible", SqlDbType.Int).Value = CveCombustible + + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar el Combustible.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +#End Region + +#Region "C A R G A S C O M B U S T I B L E S " + Public Function GetCargasCombustible(CveAF As Integer, CveProveedor As Integer, CveTipoAF As Integer, CveSubProyecto As Integer, FechaI As String, FechaF As String, CveEmpresa As Integer, Optional CveCargaCombustible As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_CargaCombustibleGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveAF", SqlDbType.Int).Value = CveAF + .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor + .Add("@CveTipoAF", SqlDbType.Int).Value = CveTipoAF + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@FechaI", SqlDbType.VarChar).Value = FechaI + .Add("@FechaF", SqlDbType.VarChar).Value = FechaF + .Add("@CveEmpresa", SqlDbType.VarChar).Value = CveEmpresa + .Add("@CveCargaCombustible", SqlDbType.Int).Value = CveCargaCombustible + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener las cargas de combustible.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function AddCargaCombustible(CveCombustible As Integer, CveProveedor As Integer, CveAF As Integer, Folio As String, FechaCarga As DateTime, TanqueLleno As Integer, Cantidad As Double, CostoUnitario As Double, Odometro As Double, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_CargaCombustiblesAdd") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCombustible", SqlDbType.Int).Value = CveCombustible + .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor + .Add("@CveAF", SqlDbType.Int).Value = CveAF + .Add("@Folio", SqlDbType.VarChar).Value = Folio + .Add("@FechaCarga", SqlDbType.DateTime).Value = FechaCarga + .Add("@TanqueLleno", SqlDbType.Int).Value = TanqueLleno + .Add("@Cantidad", SqlDbType.Float).Value = Cantidad + .Add("@CostoUnitario", SqlDbType.SmallMoney).Value = CostoUnitario + .Add("@Odometro", SqlDbType.SmallMoney).Value = Odometro + .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 agregar la carga de combustible.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function GetRepCargasCombustible(FechaI As String, FechaF As String, CveTipoAF As Integer, CveSubProyecto As Integer, GPO As Integer, CveProveedor As Integer, CveEstatus As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_RepCargasCombustibleGet") + + With SqlAdapter.SelectCommand.Parameters + '.Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@FechaI", SqlDbType.VarChar).Value = FechaI + .Add("@FechaF", SqlDbType.VarChar).Value = FechaF + .Add("@CveTipoAF", SqlDbType.Int).Value = CveTipoAF + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@GPO", SqlDbType.Int).Value = GPO + .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor + .Add("@CveEstatus", SqlDbType.Int).Value = CveEstatus + .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 Reporte de Flotillas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function +#End Region + +#Region "P L A C A S" + Public Function GetPlacas(CvePlaca As Integer, CveAF As Integer, CveEmpresa As Integer, Optional CveDispositivo As Integer = -1, Optional CveCliente As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_PlacasGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePlaca", SqlDbType.Int).Value = CvePlaca + .Add("@CveAF", SqlDbType.Int).Value = CveAF + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveDispositivo", SqlDbType.Int).Value = CveDispositivo + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Catálogo de Placas", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function AddPlacas(CveAF As Integer, Placa As String, CveUsuario As Integer, CveEmpresa As Integer, Optional CveDispositivo As Integer = -1, Optional CveCliente As Integer = -1, Optional Observacion As String = "-1", Optional Adjunto As String = "-1", + Optional FechaExpedicion As String = "-1", Optional FechaVencimiento As String = "-1") As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_PlacasAdd") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveAF", SqlDbType.Int).Value = CveAF + .Add("@Placa", SqlDbType.VarChar).Value = Placa + .Add("@FechaExpedicion", SqlDbType.VarChar).Value = FechaExpedicion + .Add("@FechaVencimiento", SqlDbType.VarChar).Value = FechaVencimiento + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveDispositivo", SqlDbType.Int).Value = CveDispositivo + .Add("@Observacion", SqlDbType.VarChar).Value = Observacion + .Add("@Adjunto", SqlDbType.VarChar).Value = Adjunto + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar la placa.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function UpdatePlacas(CvePlaca As Integer, Placa As String, Optional Observacion As String = "-1", Optional Adjunto As String = "-1", Optional FechaExpedicion As Date = MinFecha, Optional FechaVencimiento As Date = MinFecha) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_PlacasUpdate") + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePlaca", SqlDbType.Int).Value = CvePlaca + .Add("@Placa", SqlDbType.VarChar).Value = Placa + .Add("@FechaExpedicion", SqlDbType.Date).Value = FechaExpedicion + .Add("@FechaVencimiento", SqlDbType.Date).Value = FechaVencimiento + .Add("@Observacion", SqlDbType.VarChar).Value = Observacion + .Add("@Adjunto", SqlDbType.VarChar).Value = Adjunto + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar la placa", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function RemovePlaca(CvePlaca As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_PlacasRemove") + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePlaca", SqlDbType.Int).Value = CvePlaca + + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar la placa.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetRepPlacas(CvePlaca As Integer, CveAF As Integer, CveEmpresa As Integer, FechaExpedicionI As DateTime, FechaExpedicionF As DateTime, FechaVencimientoI As DateTime, FechaVencimientoF As DateTime, Optional CveDispositivo As Integer = -1, Optional CveCliente As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_RepPlacas") + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePlaca", SqlDbType.Int).Value = CvePlaca + .Add("@CveAF", SqlDbType.Int).Value = CveAF + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@FechaExpedicionI", SqlDbType.DateTime).Value = FechaExpedicionI + .Add("@FechaExpedicionF", SqlDbType.DateTime).Value = FechaExpedicionF + .Add("@FechaVencimientoI", SqlDbType.DateTime).Value = FechaVencimientoI + .Add("@FechaVencimientoF", SqlDbType.DateTime).Value = FechaVencimientoF + .Add("@CveDispositivo", SqlDbType.Int).Value = CveDispositivo + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Catálogo de Placas", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +#End Region + +#Region "L I C E N C I A S" + Public Function GetLicencias(CveLicencia As Integer, CveAF As Integer, CveEmpresa As Integer, Optional CveDispositivo As Integer = -1, Optional CveCliente As Integer = -1, Optional CvePersonal As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_LicenciasGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveLicencia", SqlDbType.Int).Value = CveLicencia + .Add("@CveAF", SqlDbType.Int).Value = CveAF + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveDispositivo", SqlDbType.Int).Value = CveDispositivo + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CvePersonal", SqlDbType.Int).Value = CvePersonal + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Catálogo de Licencias", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetLicenciasVencidas(CveLicencia As Integer, CveAF As Integer, CveEmpresa As Integer, Optional CveDispositivo As Integer = -1, Optional CveCliente As Integer = -1, Optional CvePersonal As Integer = -1, Optional Estatus As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_LicenciasVencidasGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveLicencia", SqlDbType.Int).Value = CveLicencia + .Add("@CveAF", SqlDbType.Int).Value = CveAF + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveDispositivo", SqlDbType.Int).Value = CveDispositivo + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CvePersonal", SqlDbType.Int).Value = CvePersonal + .Add("@Estatus", SqlDbType.Int).Value = Estatus + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Catálogo de Licencias", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetLicenciasRep(CveLicencia As Integer, CveAF As Integer, CveEmpresa As Integer, FechaEI As DateTime, FechaEF As DateTime, FechaVI As DateTime, FechaVF As DateTime, Optional CveDispositivo As Integer = -1, Optional CveCliente As Integer = -1, Optional Estatus As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_LicenciasRepGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveLicencia", SqlDbType.Int).Value = CveLicencia + .Add("@CveAF", SqlDbType.Int).Value = CveAF + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@FechaEI", SqlDbType.DateTime).Value = FechaEI + .Add("@FechaEF", SqlDbType.DateTime).Value = FechaEF + .Add("@FechaVI", SqlDbType.DateTime).Value = FechaVI + .Add("@FechaVF", SqlDbType.DateTime).Value = FechaVF + .Add("@CveDispositivo", SqlDbType.Int).Value = CveDispositivo + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveCliente", SqlDbType.Int).Value = Estatus + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Catálogo de Licencias", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function AddLicencia(CveAF As Integer, Licencia As String, FechaExpedicion As DateTime, FechaVencimiento As DateTime, CveUsuario As Integer, CveEmpresa As Integer, Optional CveDispositivo As Integer = -1, Optional CveCliente As Integer = -1, Optional Observacion As String = "-1", Optional Adjunto As String = "-1", Optional CvePersonal As Integer = -1, Optional Estatus As Boolean = True) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_LicenciasAdd") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveAF", SqlDbType.Int).Value = CveAF + .Add("@Licencia", SqlDbType.VarChar).Value = Licencia + .Add("@FechaExpedicion", SqlDbType.DateTime).Value = FechaExpedicion + .Add("@FechaVencimiento", SqlDbType.DateTime).Value = FechaVencimiento + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveDispositivo", SqlDbType.Int).Value = CveDispositivo + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@Observacion", SqlDbType.VarChar).Value = Observacion + .Add("@Adjunto", SqlDbType.VarChar).Value = Adjunto + .Add("@CvePersonal", SqlDbType.Int).Value = CvePersonal + .Add("@Estatus", SqlDbType.Bit).Value = Estatus + + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar la licencia.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function UpdateLicencia(CveLicencia As Integer, Licencia As String, FechaExpedicion As DateTime, FechaVencimiento As DateTime, Optional Observacion As String = "-1", Optional Adjunto As String = "-1", Optional Estatus As Boolean = True) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_LicenciasUpdate") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveLicencia", SqlDbType.Int).Value = CveLicencia + .Add("@Licencia", SqlDbType.VarChar).Value = Licencia + .Add("@FechaExpedicion", SqlDbType.DateTime).Value = FechaExpedicion + .Add("@FechaVencimiento", SqlDbType.DateTime).Value = FechaVencimiento + .Add("@Observacion", SqlDbType.VarChar).Value = Observacion + .Add("@Adjunto", SqlDbType.VarChar).Value = Adjunto + .Add("@Estatus", SqlDbType.Bit).Value = Estatus + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar la licencia", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function RemoveLicencia(CveLicencia As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_LicenciasRemove") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveLicencia", SqlDbType.Int).Value = CveLicencia + + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar la licencia.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +#End Region + +#Region "P O L I Z A S S E G U R O S " + Public Function GetPolizasSeguro(CvePoliza As Integer, CveAF As Integer, CveProveedor As Integer, CveEmpresa As Integer, Optional CveDispositivo As Integer = -1, Optional CveCliente As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_PolizasSeguroGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePoliza", SqlDbType.Int).Value = CvePoliza + .Add("@CveAF", SqlDbType.Int).Value = CveAF + .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveDispositivo", SqlDbType.Int).Value = CveDispositivo + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Catálogo de Pólizas de seguro", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetRepPolizaSeguro(CveAF As Integer, CveProveedor As Integer, FechaExpedicionI As DateTime, FechaExpedicionF As DateTime, FechaVencimientoI As DateTime, FechaVencimientoF As DateTime, CveEmpresa As Integer, Optional CveDispositivo As Integer = -1, Optional CveCliente As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_RepPolizaSeguroGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveAF", SqlDbType.Int).Value = CveAF + .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor + .Add("@FechaExpedicionI", SqlDbType.DateTime).Value = FechaExpedicionI + .Add("@FechaExpedicionF", SqlDbType.DateTime).Value = FechaExpedicionF + .Add("@FechaVencimientoI", SqlDbType.DateTime).Value = FechaVencimientoI + .Add("@FechaVencimientoF", SqlDbType.DateTime).Value = FechaVencimientoF + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveDispositivo", SqlDbType.Int).Value = CveDispositivo + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Reporte de Polizas de Seguros.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function AddPolizasSeguro(CveAF As Integer, CveProveedor As Integer, PolizaSeguro As String, FechaExpedicion As DateTime, FechaVencimiento As DateTime, CveUsuario As Integer, CveEmpresa As Integer, Optional CveDispositivo As Integer = -1, Optional CveCliente As Integer = -1, Optional Observacion As String = "-1", Optional Adjunto As String = "-1", Optional Proveedor As String = "-1") As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_PolizasSegurosAdd") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveAF", SqlDbType.Int).Value = CveAF + .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor + .Add("@PolizaSeguro", SqlDbType.VarChar).Value = PolizaSeguro + .Add("@FechaExpedicion", SqlDbType.DateTime).Value = FechaExpedicion + .Add("@FechaVencimiento", SqlDbType.DateTime).Value = FechaVencimiento + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveDispositivo", SqlDbType.Int).Value = CveDispositivo + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@Observacion", SqlDbType.VarChar).Value = Observacion + .Add("@Adjunto", SqlDbType.VarChar).Value = Adjunto + .Add("@Proveedor", SqlDbType.VarChar).Value = Proveedor + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar la póliza de seguro.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function UpdatePolizaSeguro(CvePoliza As Integer, CveProveedor As Integer, PolizaSeguro As String, FechaExpedicion As DateTime, FechaVencimiento As DateTime, Optional Observacion As String = "-1", Optional Adjunto As String = "-1", Optional Proveedor As String = "-1") As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_PolizasSegurosUpdate") + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePoliza", SqlDbType.Int).Value = CvePoliza + .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor + .Add("@PolizaSeguro", SqlDbType.VarChar).Value = PolizaSeguro + .Add("@FechaExpedicion", SqlDbType.DateTime).Value = FechaExpedicion + .Add("@FechaVencimiento", SqlDbType.DateTime).Value = FechaVencimiento + .Add("@Observacion", SqlDbType.VarChar).Value = Observacion + .Add("@Adjunto", SqlDbType.VarChar).Value = Adjunto + .Add("@Proveedor", SqlDbType.VarChar).Value = Proveedor + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar la póliza de seguro", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function RemovePoliza(CvePoliza As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_PolizasSeguroRemove") + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePoliza", SqlDbType.Int).Value = CvePoliza + + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar la póliza de seguro.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +#End Region + +#Region "I N C I D E N T E S " + Public Function GetIncidentes(CveIncidente As Integer, CveAF As Integer, CveEmpresa As Integer, Optional CveDispositivo As Integer = -1, Optional CveCliente As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_IncidentesGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveIncidente", SqlDbType.Int).Value = CveIncidente + .Add("@CveAF", SqlDbType.Int).Value = CveAF + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveDispositivo", SqlDbType.Int).Value = CveDispositivo + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Catálogo de Incidentes", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetIncidentesRep(CveIncidente As Integer, CveAF As Integer, CveEmpresa As Integer, FechaInicio As String, FechaFin As String, Optional CveDispositivo As Integer = -1, Optional CveCliente As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_IncidentesRepGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveIncidente", SqlDbType.Int).Value = CveIncidente + .Add("@CveAF", SqlDbType.Int).Value = CveAF + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@FechaInicial", SqlDbType.VarChar).Value = FechaInicio + .Add("@FechaFinal", SqlDbType.VarChar).Value = FechaFin + .Add("@CveDispositivo", SqlDbType.Int).Value = CveDispositivo + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Reporte de Incidentes", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function AddIncidente(CveAF As Integer, Asunto As String, Descripcion As String, Odometro As Double, Horometro As Double, Prioridad As Integer, FechaIncidente As DateTime, CveUsuario As Integer, CveEmpresa As Integer, Optional CveDispositivo As Integer = -1, Optional CveCliente As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_IncidentesAdd") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveAF", SqlDbType.Int).Value = CveAF + .Add("@Asunto", SqlDbType.VarChar).Value = Asunto + .Add("@Descripcion", SqlDbType.VarChar).Value = Descripcion + .Add("@Odometro", SqlDbType.Float).Value = Odometro + .Add("@Horometro", SqlDbType.Float).Value = Horometro + .Add("@FechaIncidente", SqlDbType.DateTime).Value = FechaIncidente + .Add("@Prioridad", SqlDbType.Int).Value = Prioridad + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveDispositivo", SqlDbType.Int).Value = CveDispositivo + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar el incidente.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function UpdateIncidente(CveIncidente As Integer, Asunto As String, Descripcion As String, Odometro As Double, Horometro As Double, Prioridad As Integer, FechaIncidente As DateTime) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_IncidentesUpdate") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveIncidente", SqlDbType.Int).Value = CveIncidente + .Add("@Asunto", SqlDbType.VarChar).Value = Asunto + .Add("@Descripcion", SqlDbType.VarChar).Value = Descripcion + .Add("@Odometro", SqlDbType.Float).Value = Odometro + .Add("@Horometro", SqlDbType.Float).Value = Horometro + .Add("@Prioridad", SqlDbType.Int).Value = Prioridad + .Add("@FechaIncidente", SqlDbType.DateTime).Value = FechaIncidente + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar el incidente", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function RemoveIncidente(CveIncidente As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_IncidenteRemove") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveIncidente", SqlDbType.Int).Value = CveIncidente + + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar el incidente.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +#End Region + +#Region "F A L L A S / A C C I D E N T E S " + Public Function GetTipoFallas(CveTipoFalla As Integer, CveEmpresa As Integer, ClasificacionTipoFalla As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_TipoFallasGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveTipoFalla", SqlDbType.Int).Value = CveTipoFalla + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@ClasificacionTipoFalla", SqlDbType.Int).Value = ClasificacionTipoFalla + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Catálogo de Tipo Fallas", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function GetFallas(CveFalla As Integer, CveAF As Integer, CveEmpresa As Integer, CveTipoFalla As Integer, ClasificacionTipoFalla As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_FallasGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveFalla", SqlDbType.Int).Value = CveFalla + .Add("@CveAF", SqlDbType.Int).Value = CveAF + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveTipoFalla", SqlDbType.Int).Value = CveTipoFalla + .Add("@ClasificacionTipoFalla", SqlDbType.Int).Value = ClasificacionTipoFalla + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Catálogo de Fallas", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function AddFalla(CveAF As Integer, Asunto As String, Descripcion As String, AFMedida As Integer, Prioridad As Integer, FechaFalla As DateTime, CveUsuario As Integer, CveEmpresa As Integer, CveTipoFalla As Integer, CorreoNotificacion As String) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_FallasAdd") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveAF", SqlDbType.Int).Value = CveAF + .Add("@Asunto", SqlDbType.VarChar).Value = Asunto + .Add("@Descripcion", SqlDbType.VarChar).Value = Descripcion + .Add("@AFMedida", SqlDbType.Int).Value = AFMedida + .Add("@FechaFalla", SqlDbType.DateTime).Value = FechaFalla + .Add("@Prioridad", SqlDbType.Int).Value = Prioridad + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveTipoFalla", SqlDbType.Int).Value = CveTipoFalla + .Add("@CorreoNotificacion", SqlDbType.VarChar).Value = CorreoNotificacion + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al Registrar la Falla.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function UpdateFalla(CveFalla As Integer, Asunto As String, Descripcion As String, AFMedida As Integer, Prioridad As Integer, FechaFalla As DateTime, CveTipoFalla As Integer, CorreoNotificacion As String) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_FallasUpdate") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveFalla", SqlDbType.Int).Value = CveFalla + .Add("@Asunto", SqlDbType.VarChar).Value = Asunto + .Add("@Descripcion", SqlDbType.VarChar).Value = Descripcion + .Add("@AFMedida", SqlDbType.Int).Value = AFMedida + .Add("@Prioridad", SqlDbType.Int).Value = Prioridad + .Add("@FechaFalla", SqlDbType.DateTime).Value = FechaFalla + .Add("@CveTipoFalla", SqlDbType.Int).Value = CveTipoFalla + .Add("@CorreoNotificacion", SqlDbType.VarChar).Value = CorreoNotificacion + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar la falla", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function RemoveFalla(CveFalla As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_FallasRemove") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveFalla", SqlDbType.Int).Value = CveFalla + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar la falla.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +#End Region +#Region "S E R V I C I O S" + Public Function GetServicios(CveServicio As Integer, CveAF As Integer, CveEmpresa As Integer, Optional CveDispositivo As Integer = -1, Optional CveCliente As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_ServiciosGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveServicio", SqlDbType.Int).Value = CveServicio + .Add("@CveAF", SqlDbType.Int).Value = CveAF + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveDispositivo", SqlDbType.Int).Value = CveDispositivo + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Catálogo de Servicios", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetServiciosTotal(CveServicio As Integer, CveAF As Integer, CveEmpresa As Integer, Optional CveDispositivo As Integer = -1, Optional CveCliente As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_ServiciosTotalCompraGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveServicio", SqlDbType.Int).Value = CveServicio + .Add("@CveAF", SqlDbType.Int).Value = CveAF + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveDispositivo", SqlDbType.Int).Value = CveDispositivo + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Catálogo de Servicios", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function AddServicio(CveAF As Integer, CveTipoServicio As Integer, FechaServicio As DateTime, CveProveedor As Integer, CveCompra As Integer, Horometro As Double, Observaciones As String, CveUsuario As Integer, CveEmpresa As Integer, Optional CveDispositivo As Integer = -1, Optional CveCliente As Integer = -1, Optional Proveedor As String = "-1", Optional Importe As Double = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_ServiciosAdd") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveAF", SqlDbType.Int).Value = CveAF + .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor + .Add("@CveCompra", SqlDbType.Int).Value = CveCompra + .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones + .Add("@Horometro", SqlDbType.Float).Value = Horometro + .Add("@FechaServicio", SqlDbType.DateTime).Value = FechaServicio + .Add("@CveTipoServicio", SqlDbType.Int).Value = CveTipoServicio + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveDispositivo", SqlDbType.Int).Value = CveDispositivo + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@Proveedor", SqlDbType.VarChar).Value = Proveedor + .Add("@Importe", SqlDbType.Float).Value = Importe + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar el servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function UpdateServicio(CveServicio As Integer, CveTipoServicio As Integer, FechaServicio As DateTime, CveProveedor As Integer, CveCompra As Integer, Horometro As Double, Observaciones As String, Optional Proveedor As String = "-1", Optional Importe As Double = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_ServiciosUpdate") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveServicio", SqlDbType.Int).Value = CveServicio + .Add("@CveTipoServicio", SqlDbType.Int).Value = CveTipoServicio + .Add("@FechaServicio", SqlDbType.DateTime).Value = FechaServicio + .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor + .Add("@CveCompra", SqlDbType.Int).Value = CveCompra + .Add("@Horometro", SqlDbType.Float).Value = Horometro + .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones + .Add("@Proveedor", SqlDbType.VarChar).Value = Proveedor + .Add("@Importe", SqlDbType.Float).Value = Importe + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar el servicio", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function RemoveServicio(CveServicio As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_ServiciosRemove") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveServicio", SqlDbType.Int).Value = CveServicio + + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar el servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetRepServicios(CveAF As Integer, CveEmpresa As Integer, CveTipoServicio As Integer, CveProveedor As Integer, FechaI As Date, FechaF As Date, Optional CveDispositivo As Integer = -1, Optional CveCliente As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_RepServicios") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveAF", SqlDbType.Int).Value = CveAF + .Add("@CveTipoServicio", SqlDbType.Int).Value = CveTipoServicio + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor .Add("@FechaI", SqlDbType.Date).Value = FechaI .Add("@FechaF", SqlDbType.Date).Value = FechaF - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(DSet) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los valores de métricas de Activo Fijo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function AddMetricasValores(CveAF As Integer, CvePersonal As Integer, CveUsuario As Integer, CveSubProyecto As Integer, Fecha As Date, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - CveMetricaValor = -1 - - DataAdapter("PA_AF_MetricasValoresAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveAF", SqlDbType.Int).Value = CveAF - .Add("@CvePersonal", SqlDbType.Int).Value = CvePersonal - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveDispositivo", SqlDbType.Int).Value = CveDispositivo + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el reporte de servicios", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +#End Region + +#Region "E V E N T O S P R O G R A M A D O S " + Public Function GetRepEventosProgramados(CveAF As Integer, CveTipoAF As Integer, CveSubTipoAF As Integer, Asunto As String, FechaInicio As Date, FechaFin As Date, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_RepEventosProgramadosGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveAF", SqlDbType.Int).Value = CveAF + .Add("@CveTipoAF", SqlDbType.Int).Value = CveTipoAF + .Add("@CveSubTipoAF", SqlDbType.Int).Value = CveSubTipoAF + .Add("@Asunto", SqlDbType.VarChar).Value = Asunto + .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio + .Add("@FechaFin", SqlDbType.Date).Value = FechaFin + .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 Reporte de Eventos", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +#End Region + +#Region "ValesCombustible" + Public Function AddValesCombustible(FolioUsuario As Integer, CveCompra As Integer, CveProveedor As Integer, CveAF As Integer, CvePersonal As Integer, Fecha As Date, NombreRecibe As String, CveSubProyecto As Integer, Observaciones As String, Odometro As Integer, CveCombustible As Integer, Litros As Double, TipoVale As Integer, CveUsuario As Integer, CveEmpresa As Integer, Optional Recibo As Integer = -1, Optional Importe As Integer = -1) As Integer + Dim Retorno As Integer = -1 + + DataAdapter("PA_AF_ValesCombustibleAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@FolioUsuario", SqlDbType.Int).Value = FolioUsuario + .Add("@CveCompra", SqlDbType.Int).Value = CveCompra + .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor + .Add("@CveAF", SqlDbType.Int).Value = CveAF + .Add("@CvePersonal", SqlDbType.Int).Value = CvePersonal + .Add("@NombreRecibe", SqlDbType.VarChar).Value = NombreRecibe + .Add("@Fecha", SqlDbType.Date).Value = Fecha + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones + .Add("@Odometro", SqlDbType.Int).Value = Odometro + .Add("@CveCombustible", SqlDbType.Int).Value = CveCombustible + .Add("@Litros", SqlDbType.Float).Value = Litros + .Add("@Recibo", SqlDbType.Float).Value = Recibo + .Add("@Importe", SqlDbType.Float).Value = Importe + .Add("@TipoVale", SqlDbType.Int).Value = TipoVale + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveVale", SqlDbType.Int).Direction = ParameterDirection.Output + .Add("@vFolio", SqlDbType.Int).Direction = ParameterDirection.Output + End With + + Try + SqlAdapter.Fill(Data) + FolioVale = SqlAdapter.SelectCommand.Parameters("@vFolio").Value.ToString.ToEntero + Retorno = SqlAdapter.SelectCommand.Parameters("@CveVale").Value.ToString.ToEntero + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 2627;") Then + Alert("Ya existe un Vale de Combustible con el mismo nombre: " & Descripcion & ".", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al Guardar el Vale de Combustible.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + + End Try + + Return Retorno + + End Function + Public Function GetValesCombustible(CveCompra As Integer, CveValeCombustible As Integer, Folio As Integer, CveProveedor As Integer, CveAF As Integer, CveSubProyecto As Integer, Odometro As Integer, CveCombustible As Integer, Litros As Double, CvePersonal As Integer, CveUsuario As Integer, CveEmpresa As Integer, Recibo As Integer, Importe As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AF_ValesCombustibleGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCompra", SqlDbType.Int).Value = CveCompra + .Add("@CveValeCombustible", SqlDbType.Int).Value = CveValeCombustible + .Add("@Folio", SqlDbType.Int).Value = Folio + .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor + .Add("@CveAF", SqlDbType.Int).Value = CveAF + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@Odometro", SqlDbType.Int).Value = Odometro + .Add("@CveCombustible", SqlDbType.Int).Value = CveCombustible + .Add("@Litros", SqlDbType.Float).Value = Litros + .Add("@CvePersonal", SqlDbType.Int).Value = CvePersonal + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@Recibo", SqlDbType.Int).Value = Recibo + .Add("@Importe", SqlDbType.Int).Value = Importe + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Catálogo de Estatus de Vales Combustible.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function UpdateValeCombustible(CveVale As Integer, CveCompra As Integer, CveProveedor As Integer, NombreRecibe As String, Litros As Double, Recibo As Integer, Importe As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_ValesCombustibleUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVale", SqlDbType.Int).Value = CveVale + .Add("@CveCompra", SqlDbType.Int).Value = CveCompra + .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor + .Add("@NombreRecibe", SqlDbType.VarChar).Value = NombreRecibe + .Add("@Litros", SqlDbType.Float).Value = Litros + .Add("@Recibo", SqlDbType.Int).Value = Recibo + .Add("@Importe", SqlDbType.Int).Value = Importe + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + OnError("Ocurrió un error al actualizar la cuenta contable en el Activo Fijo", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + Catch ex As Exception + OnError("Ocurrió un error al actualizar la cuenta contable en el Activo Fijo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function +#End Region +#Region "M E T R I C A S" + + Public Function GetMetricas(CveMetrica As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_MetricasGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveMetrica", SqlDbType.Int).Value = CveMetrica + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener las métricas de Activo Fijo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function AddMetricas(Metrica As String) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_MetricasAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Metrica", SqlDbType.Int).Value = Metrica + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar la métrica de Activo Fijo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function DeleteMetricas(CveMetrica As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_MetricasRemove") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveMetrica", SqlDbType.Int).Value = CveMetrica + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar la métrica de Activo Fijo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + + + Public Function GetMetricasRegistro(CveSubProyecto As Integer, CveEmpresa As Integer, Fecha As Date) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_MetricasRegistroGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@Fecha", SqlDbType.Date).Value = Fecha + End With + + Try + SqlAdapter.Fill(DSet) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los valores de métricas de Activo Fijo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + + Public Function GetMetricasValores(CveMetricaValor As Integer, CveAF As Integer, CvePersonal As Integer, CveUsuario As Integer, CveSubProyecto As Integer, CveTipoActivoFijo As Integer, CveSubTipoActivoFijo As Integer, FechaI As Date, FechaF As Date, + CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_MetricasValoresGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveMetricaValor", SqlDbType.Int).Value = CveMetricaValor + .Add("@CveAF", SqlDbType.Int).Value = CveAF + .Add("@CvePersonal", SqlDbType.Int).Value = CvePersonal + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveTipoActivoFijo", SqlDbType.Int).Value = CveTipoActivoFijo + .Add("@CveSubTipoActivoFijo", SqlDbType.Int).Value = CveSubTipoActivoFijo + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(DSet) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los valores de métricas de Activo Fijo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function AddMetricasValores(CveAF As Integer, CvePersonal As Integer, CveUsuario As Integer, CveSubProyecto As Integer, Fecha As Date, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + CveMetricaValor = -1 + + DataAdapter("PA_AF_MetricasValoresAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveAF", SqlDbType.Int).Value = CveAF + .Add("@CvePersonal", SqlDbType.Int).Value = CvePersonal + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto .Add("@Fecha", SqlDbType.Date).Value = Fecha .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa .Add("@CveMetricaValor", SqlDbType.Int).Direction = ParameterDirection.Output - End With - - Try - SqlAdapter.Fill(Data) - CveMetricaValor = SqlAdapter.SelectCommand.Parameters("@CveMetricaValor").Value.ToString.ToEntero - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar el valor de métrica de Activo Fijo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function RemoveMetricasValores(CveMetricaValor As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_MetricasValoresRemove") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveMetricaValor", SqlDbType.Int).Value = CveMetricaValor - - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al eliminar el valor de métrica de Activo Fijo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function GetMetricasValoresDetalle(CveEmpresa As Integer, Optional CveMetricaValor As Integer = -1, Optional CveMetrica As Integer = -1) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_MetricasValoresDetalleGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveMetricaValor", SqlDbType.Int).Value = CveMetricaValor - .Add("@CveMetrica", SqlDbType.Int).Value = CveMetrica - .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 valores de métricas de Activo Fijo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno + End With + + Try + SqlAdapter.Fill(Data) + CveMetricaValor = SqlAdapter.SelectCommand.Parameters("@CveMetricaValor").Value.ToString.ToEntero + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar el valor de métrica de Activo Fijo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function RemoveMetricasValores(CveMetricaValor As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_MetricasValoresRemove") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveMetricaValor", SqlDbType.Int).Value = CveMetricaValor + + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar el valor de métrica de Activo Fijo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function GetMetricasValoresDetalle(CveEmpresa As Integer, Optional CveMetricaValor As Integer = -1, Optional CveMetrica As Integer = -1) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_MetricasValoresDetalleGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveMetricaValor", SqlDbType.Int).Value = CveMetricaValor + .Add("@CveMetrica", SqlDbType.Int).Value = CveMetrica + .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 valores de métricas de Activo Fijo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno End Function Public Function AddMetricasValoresDetalle(CveMetricaValor As Integer, CveMetrica As Integer, Valor As Decimal) As Boolean @@ -3456,723 +3456,724 @@ Public Class ClsAF End Try Return Retorno - End Function - - Public Function DeleteMetricasValoresDetalle(Optional CveMetricaValor As Integer = -1, Optional CveMetrica As Integer = -1, Optional Valor As String = "-1") As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_MetricasValoresDetalleAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveMetricaValor", SqlDbType.Int).Value = CveMetricaValor - .Add("@CveMetrica", SqlDbType.Int).Value = CveMetrica - .Add("@Valor", SqlDbType.VarChar).Value = Valor - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al eliminar el detalle de los valores de métricas de Activo Fijo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno End Function -#End Region + Public Function DeleteMetricasValoresDetalle(Optional CveMetricaValor As Integer = -1, Optional CveMetrica As Integer = -1, Optional Valor As String = "-1") As Boolean + Dim Retorno As Boolean = False -#Region "TIPO SERVICIO" + DataAdapter("PA_AF_MetricasValoresDetalleAdd") - Public Function GetTiposServicios(CveTipoServicio As Integer, CveTipoMantenimiento As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_TiposServicioGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveTipoServicio", SqlDbType.Int).Value = CveTipoServicio - .Add("@CveTipoMantenimiento", SqlDbType.Int).Value = CveTipoMantenimiento - .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 obtener los tipos servicios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function AddTiposServicios(Nombre As String, CveTipoMantenimiento As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - CveTipoServicio = -1 - DataAdapter("PA_AF_TiposServicioAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Nombre", SqlDbType.NVarChar).Value = Nombre - .Add("@CveTipoMantenimiento", SqlDbType.Int).Value = CveTipoMantenimiento - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + With SqlAdapter.SelectCommand.Parameters + .Add("@CveMetricaValor", SqlDbType.Int).Value = CveMetricaValor + .Add("@CveMetrica", SqlDbType.Int).Value = CveMetrica + .Add("@Valor", SqlDbType.VarChar).Value = Valor + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar el detalle de los valores de métricas de Activo Fijo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + +#End Region + +#Region "TIPO SERVICIO" + + Public Function GetTiposServicios(CveTipoServicio As Integer, CveTipoMantenimiento As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_TiposServicioGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveTipoServicio", SqlDbType.Int).Value = CveTipoServicio + .Add("@CveTipoMantenimiento", SqlDbType.Int).Value = CveTipoMantenimiento + .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 obtener los tipos servicios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function AddTiposServicios(Nombre As String, CveTipoMantenimiento As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + CveTipoServicio = -1 + DataAdapter("PA_AF_TiposServicioAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Nombre", SqlDbType.NVarChar).Value = Nombre + .Add("@CveTipoMantenimiento", SqlDbType.Int).Value = CveTipoMantenimiento + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa .Add("@CveTipoServicio", SqlDbType.Int).Direction = ParameterDirection.Output - End With - - Try - SqlAdapter.Fill(Data) - - CveTipoServicio = SqlAdapter.SelectCommand.Parameters("@CveTipoServicio").Value.ToString.ToEntero - - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar los tipos servicios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function UpdateTiposServicios(CveTipoServicio As Integer, Nombre As String, CveTipoMantenimiento As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_TiposServicioUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveTipoServicio", SqlDbType.Int).Value = CveTipoServicio - .Add("@Nombre", SqlDbType.NVarChar).Value = Nombre - .Add("@CveTipoMantenimiento", SqlDbType.Int).Value = CveTipoMantenimiento - .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 los tipos servicios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function DeleteTiposServicios(CveTipoServicio As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_TiposServicioDelete") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveTipoServicio", SqlDbType.Int).Value = CveTipoServicio - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al eliminar los tipos servicios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function GetTiposServiciosActividades(CveTipoServicioActividad As Integer, CveTipoServicio As Integer, CveActividad As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_TiposServiciosActividadesGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveTipoServicioActividad", SqlDbType.Int).Value = CveTipoServicioActividad - .Add("@CveActividad", SqlDbType.Int).Value = CveActividad - .Add("@CveTipoServicio", SqlDbType.Int).Value = CveTipoServicio - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener las actividades tipos servicios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function AddTiposServiciosActividades(CveActividad As Integer, CveTipoServicio As Integer, Duracion As Decimal, Observaciones As String) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_TiposServiciosActividadesAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveActividad", SqlDbType.Int).Value = CveActividad - .Add("@CveTipoServicio", SqlDbType.Int).Value = CveTipoServicio - .Add("@Duracion", SqlDbType.SmallMoney).Value = Duracion - .Add("@Observaciones", SqlDbType.NVarChar).Value = Observaciones - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar las actividades tipos servicios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function UpdateTiposServiciosActividades(CveTipoServicioActividad As Integer, CveActividad As Integer, Duracion As Decimal, Observaciones As String) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_TiposServiciosActividadesUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveTipoServicioActividad", SqlDbType.Int).Value = CveTipoServicioActividad - .Add("@CveActividad", SqlDbType.Int).Value = CveActividad - .Add("@Duracion", SqlDbType.SmallMoney).Value = Duracion - .Add("@Observaciones", SqlDbType.NVarChar).Value = Observaciones - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar las actividades tipos servicios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function DeleteTiposServiciosActividades(CveTipoServicioActividad As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_TiposServiciosActividadesDelete") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveTipoServicioActividad", SqlDbType.Int).Value = CveTipoServicioActividad - .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 actividades tipos servicios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function GetTiposServiciosMaterial(CveTipoServicioMaterial As Integer, CveTipoServicio As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_TiposServiciosMaterialGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveTipoServicioMaterial", SqlDbType.Int).Value = CveTipoServicioMaterial - .Add("@CveTipoServicio", SqlDbType.Int).Value = CveTipoServicio - .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 materiales de los tipos servicios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function AddTiposServiciosMaterial(CveTipoServicio As Integer, Cantidad As Decimal, CveUM As Integer, CvePS As Integer, - Tipo As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_TiposServiciosMaterialAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveTipoServicio", SqlDbType.Int).Value = CveTipoServicio - .Add("@Cantidad", SqlDbType.Money).Value = Cantidad - .Add("@CveUM", SqlDbType.Int).Value = CveUM - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@Tipo", SqlDbType.TinyInt).Value = Tipo - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar las actividades tipos servicios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function UpdateTiposServiciosMaterial(CveTipoServicioMaterial As Integer, CveTipoServicio As Integer, Cantidad As Decimal, CveUM As Integer, CvePS As Integer, - Tipo As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_TiposServiciosMaterialUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveTipoServicioMaterial", SqlDbType.Int).Value = CveTipoServicioMaterial - .Add("@CveTipoServicio", SqlDbType.Int).Value = CveTipoServicio - .Add("@Cantidad", SqlDbType.Money).Value = Cantidad - .Add("@CveUM", SqlDbType.Int).Value = CveUM - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@Tipo", SqlDbType.TinyInt).Value = Tipo - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener las actividades tipos servicios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function DeleteTiposServiciosMaterial(CveTipoServicioMaterial As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_TiposServiciosMaterialDelete") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveTipoServicioMaterial", SqlDbType.Int).Value = CveTipoServicioMaterial - .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 actividades tipos servicios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno + End With + + Try + SqlAdapter.Fill(Data) + + CveTipoServicio = SqlAdapter.SelectCommand.Parameters("@CveTipoServicio").Value.ToString.ToEntero + + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar los tipos servicios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno End Function - Public Function GetTiposMantenimiento(CveTipoMantenimiento As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_TiposMantenimientoGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveTipoMantenimiento", SqlDbType.Int).Value = CveTipoMantenimiento - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los tipos de mantenimiento.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno + Public Function UpdateTiposServicios(CveTipoServicio As Integer, Nombre As String, CveTipoMantenimiento As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_TiposServicioUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveTipoServicio", SqlDbType.Int).Value = CveTipoServicio + .Add("@Nombre", SqlDbType.NVarChar).Value = Nombre + .Add("@CveTipoMantenimiento", SqlDbType.Int).Value = CveTipoMantenimiento + .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 los tipos servicios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno End Function - Public Function GetActividades(CveActividad As Integer, CvePuesto As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_ActividadesGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveActividad", SqlDbType.Int).Value = CveActividad - .Add("@CvePuesto", SqlDbType.Int).Value = CvePuesto - .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 obtener las actividades", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno + Public Function DeleteTiposServicios(CveTipoServicio As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_TiposServicioDelete") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveTipoServicio", SqlDbType.Int).Value = CveTipoServicio + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar los tipos servicios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno End Function - Public Function AddActividades(Nombre As String, CvePuesto As Integer, Cantidad As Decimal, CveUsuario As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_ActividadesAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Nombre", SqlDbType.NVarChar).Value = Nombre - .Add("@CvePuesto", SqlDbType.Int).Value = CvePuesto - .Add("@Cantidad", SqlDbType.SmallMoney).Value = Cantidad - .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 agregar la actividad", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno + + Public Function GetTiposServiciosActividades(CveTipoServicioActividad As Integer, CveTipoServicio As Integer, CveActividad As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_TiposServiciosActividadesGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveTipoServicioActividad", SqlDbType.Int).Value = CveTipoServicioActividad + .Add("@CveActividad", SqlDbType.Int).Value = CveActividad + .Add("@CveTipoServicio", SqlDbType.Int).Value = CveTipoServicio + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener las actividades tipos servicios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno End Function - Public Function UpdateActividades(CveActividad As Integer, Nombre As String, CvePuesto As Integer, Cantidad As Decimal, CveUsuario As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_ActividadesUpdate") - + Public Function AddTiposServiciosActividades(CveActividad As Integer, CveTipoServicio As Integer, Duracion As Decimal, Observaciones As String) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_TiposServiciosActividadesAdd") + With SqlAdapter.SelectCommand.Parameters .Add("@CveActividad", SqlDbType.Int).Value = CveActividad - .Add("@Nombre", SqlDbType.NVarChar).Value = Nombre - .Add("@CvePuesto", SqlDbType.Int).Value = CvePuesto - .Add("@Cantidad", SqlDbType.SmallMoney).Value = Cantidad - .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 actividad", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno + .Add("@CveTipoServicio", SqlDbType.Int).Value = CveTipoServicio + .Add("@Duracion", SqlDbType.SmallMoney).Value = Duracion + .Add("@Observaciones", SqlDbType.NVarChar).Value = Observaciones + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar las actividades tipos servicios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno End Function - Public Function DeleteActividades(CveActividad As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_ActividadesDelete") - + Public Function UpdateTiposServiciosActividades(CveTipoServicioActividad As Integer, CveActividad As Integer, Duracion As Decimal, Observaciones As String) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_TiposServiciosActividadesUpdate") + With SqlAdapter.SelectCommand.Parameters - .Add("@CveActividad", SqlDbType.Int).Value = CveActividad - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al eliminar la actividad", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno + .Add("@CveTipoServicioActividad", SqlDbType.Int).Value = CveTipoServicioActividad + .Add("@CveActividad", SqlDbType.Int).Value = CveActividad + .Add("@Duracion", SqlDbType.SmallMoney).Value = Duracion + .Add("@Observaciones", SqlDbType.NVarChar).Value = Observaciones + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar las actividades tipos servicios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno End Function - Public Function GetCheckListActividadGrupo(CveCheckListActividadGrupo As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_CheckListGrupoGet") - + Public Function DeleteTiposServiciosActividades(CveTipoServicioActividad As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_TiposServiciosActividadesDelete") + With SqlAdapter.SelectCommand.Parameters - .Add("@CveCheckListActividadGrupo", SqlDbType.Int).Value = CveCheckListActividadGrupo - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el grupo de CheckList", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno + .Add("@CveTipoServicioActividad", SqlDbType.Int).Value = CveTipoServicioActividad + .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 actividades tipos servicios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno End Function - Public Function AddCheckListActividadGrupo(CheckListActividadGrupo As String) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_CheckListGrupoAdd") - + Public Function GetTiposServiciosMaterial(CveTipoServicioMaterial As Integer, CveTipoServicio As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_TiposServiciosMaterialGet") + With SqlAdapter.SelectCommand.Parameters - .Add("@CheckListActividadGrupo", SqlDbType.NVarChar).Value = CheckListActividadGrupo - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar el grupo de CheckList", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno + .Add("@CveTipoServicioMaterial", SqlDbType.Int).Value = CveTipoServicioMaterial + .Add("@CveTipoServicio", SqlDbType.Int).Value = CveTipoServicio + .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 materiales de los tipos servicios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno End Function - Public Function UpdateCheckListActividadGrupo(CveCheckListActividadGrupo As Integer, CheckListActividadGrupo As String) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_CheckListGrupoUpdate") - + Public Function AddTiposServiciosMaterial(CveTipoServicio As Integer, Cantidad As Decimal, CveUM As Integer, CvePS As Integer, + Tipo As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_TiposServiciosMaterialAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveTipoServicio", SqlDbType.Int).Value = CveTipoServicio + .Add("@Cantidad", SqlDbType.Money).Value = Cantidad + .Add("@CveUM", SqlDbType.Int).Value = CveUM + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@Tipo", SqlDbType.TinyInt).Value = Tipo + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar las actividades tipos servicios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function UpdateTiposServiciosMaterial(CveTipoServicioMaterial As Integer, CveTipoServicio As Integer, Cantidad As Decimal, CveUM As Integer, CvePS As Integer, + Tipo As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_TiposServiciosMaterialUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveTipoServicioMaterial", SqlDbType.Int).Value = CveTipoServicioMaterial + .Add("@CveTipoServicio", SqlDbType.Int).Value = CveTipoServicio + .Add("@Cantidad", SqlDbType.Money).Value = Cantidad + .Add("@CveUM", SqlDbType.Int).Value = CveUM + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@Tipo", SqlDbType.TinyInt).Value = Tipo + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener las actividades tipos servicios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function DeleteTiposServiciosMaterial(CveTipoServicioMaterial As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_TiposServiciosMaterialDelete") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveTipoServicioMaterial", SqlDbType.Int).Value = CveTipoServicioMaterial + .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 actividades tipos servicios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function GetTiposMantenimiento(CveTipoMantenimiento As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_TiposMantenimientoGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveTipoMantenimiento", SqlDbType.Int).Value = CveTipoMantenimiento + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los tipos de mantenimiento.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function GetActividades(CveActividad As Integer, CvePuesto As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_ActividadesGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveActividad", SqlDbType.Int).Value = CveActividad + .Add("@CvePuesto", SqlDbType.Int).Value = CvePuesto + .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 obtener las actividades", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function AddActividades(Nombre As String, CvePuesto As Integer, Cantidad As Decimal, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_ActividadesAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Nombre", SqlDbType.NVarChar).Value = Nombre + .Add("@CvePuesto", SqlDbType.Int).Value = CvePuesto + .Add("@Cantidad", SqlDbType.SmallMoney).Value = Cantidad + .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 agregar la actividad", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function UpdateActividades(CveActividad As Integer, Nombre As String, CvePuesto As Integer, Cantidad As Decimal, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_ActividadesUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveActividad", SqlDbType.Int).Value = CveActividad + .Add("@Nombre", SqlDbType.NVarChar).Value = Nombre + .Add("@CvePuesto", SqlDbType.Int).Value = CvePuesto + .Add("@Cantidad", SqlDbType.SmallMoney).Value = Cantidad + .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 actividad", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function DeleteActividades(CveActividad As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_ActividadesDelete") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveActividad", SqlDbType.Int).Value = CveActividad + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar la actividad", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function GetCheckListActividadGrupo(CveCheckListActividadGrupo As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_CheckListGrupoGet") + With SqlAdapter.SelectCommand.Parameters .Add("@CveCheckListActividadGrupo", SqlDbType.Int).Value = CveCheckListActividadGrupo - .Add("@CheckListActividadGrupo", SqlDbType.NVarChar).Value = CheckListActividadGrupo - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar el grupo de CheckList", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el grupo de CheckList", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno End Function - Public Function DeleteCheckListActividadGrupo(CveCheckListActividadGrupo As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_CheckListGrupoDelete") - + Public Function AddCheckListActividadGrupo(CheckListActividadGrupo As String) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_CheckListGrupoAdd") + With SqlAdapter.SelectCommand.Parameters - .Add("@CveCheckListActividadGrupo", SqlDbType.Int).Value = CveCheckListActividadGrupo - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al eliminar el grupo de CheckList", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno + .Add("@CheckListActividadGrupo", SqlDbType.NVarChar).Value = CheckListActividadGrupo + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar el grupo de CheckList", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno End Function - Public Function GetCheckListTipo(CveCheckListTipo As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_CheckListTipoGet") - + Public Function UpdateCheckListActividadGrupo(CveCheckListActividadGrupo As Integer, CheckListActividadGrupo As String) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_CheckListGrupoUpdate") + With SqlAdapter.SelectCommand.Parameters - .Add("@CveCheckListTipo", SqlDbType.Int).Value = CveCheckListTipo - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el tipo de CheckList", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno + .Add("@CveCheckListActividadGrupo", SqlDbType.Int).Value = CveCheckListActividadGrupo + .Add("@CheckListActividadGrupo", SqlDbType.NVarChar).Value = CheckListActividadGrupo + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar el grupo de CheckList", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno End Function - Public Function AddCheckListTipo(CheckListTipo As String) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_CheckListTipoAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CheckListTipo", SqlDbType.NVarChar).Value = CheckListTipo - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar el tipo de CheckList", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function + Public Function DeleteCheckListActividadGrupo(CveCheckListActividadGrupo As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_CheckListGrupoDelete") - Public Function UpdateCheckListTipo(CveCheckListTipo As Integer, CheckListTipo As String) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_CheckListTipoUpdate") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCheckListTipo", SqlDbType.Int).Value = CveCheckListTipo - .Add("@CheckListTipo", SqlDbType.NVarChar).Value = CheckListTipo - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar el tipo de CheckList", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno + .Add("@CveCheckListActividadGrupo", SqlDbType.Int).Value = CveCheckListActividadGrupo + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar el grupo de CheckList", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno End Function - Public Function DeleteCheckListTipo(CveCheckListTipo As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_CheckListTipoDelete") - + Public Function GetCheckListTipo(CveCheckListTipo As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_CheckListTipoGet") + With SqlAdapter.SelectCommand.Parameters - .Add("@CveCheckListTipo", SqlDbType.Int).Value = CveCheckListTipo - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al eliminar el tipo de CheckList", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno + .Add("@CveCheckListTipo", SqlDbType.Int).Value = CveCheckListTipo + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el tipo de CheckList", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno End Function - Public Function GetCheckListActividad(CveCheckListActividad As Integer, CveCheckListActividadGrupo As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_CheckListActividadGet") - + Public Function AddCheckListTipo(CheckListTipo As String) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_CheckListTipoAdd") + With SqlAdapter.SelectCommand.Parameters - .Add("@CveCheckListActividad", SqlDbType.Int).Value = CveCheckListActividad - .Add("@CveCheckListActividadGrupo", SqlDbType.Int).Value = CveCheckListActividadGrupo - .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 actividades de CheckList", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno + .Add("@CheckListTipo", SqlDbType.NVarChar).Value = CheckListTipo + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar el tipo de CheckList", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno End Function - Public Function AddCheckListActividad(CheckListActividad As String, CveCheckListActividadGrupo As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_CheckListActividadAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CheckListActividad", SqlDbType.NVarChar).Value = CheckListActividad - .Add("@CveCheckListActividadGrupo", SqlDbType.Int).Value = CveCheckListActividadGrupo - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar las actividades de CheckList", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function + Public Function UpdateCheckListTipo(CveCheckListTipo As Integer, CheckListTipo As String) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_CheckListTipoUpdate") - Public Function UpdateCheckListActividad(CveCheckListActividad As Integer, CheckListActividad As String, CveCheckListActividadGrupo As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_CheckListActividadUpdate") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCheckListActividad", SqlDbType.Int).Value = CveCheckListActividad - .Add("@CheckListActividad", SqlDbType.NVarChar).Value = CheckListActividad - .Add("@CveCheckListActividadGrupo", SqlDbType.Int).Value = CveCheckListActividadGrupo - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar las actividades de CheckList", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno + .Add("@CveCheckListTipo", SqlDbType.Int).Value = CveCheckListTipo + .Add("@CheckListTipo", SqlDbType.NVarChar).Value = CheckListTipo + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar el tipo de CheckList", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno End Function - Public Function DeleteCheckListActividad(CveCheckListActividad As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_CheckListActividadDelete") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCheckListActividad", SqlDbType.Int).Value = CveCheckListActividad - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al eliminar las actividades de CheckList", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno + Public Function DeleteCheckListTipo(CveCheckListTipo As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_CheckListTipoDelete") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCheckListTipo", SqlDbType.Int).Value = CveCheckListTipo + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar el tipo de CheckList", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno End Function - Public Function GetCheckList(CveCheckList As Integer, CveTipoServicio As Integer, CveCheckListActividad As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_CheckListGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCheckList", SqlDbType.Int).Value = CveCheckList - .Add("@CveTipoServicio", SqlDbType.Int).Value = CveTipoServicio - .Add("@CveCheckListActividad", SqlDbType.Int).Value = CveCheckListActividad - .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 CheckList", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno + Public Function GetCheckListActividad(CveCheckListActividad As Integer, CveCheckListActividadGrupo As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_CheckListActividadGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCheckListActividad", SqlDbType.Int).Value = CveCheckListActividad + .Add("@CveCheckListActividadGrupo", SqlDbType.Int).Value = CveCheckListActividadGrupo + .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 actividades de CheckList", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno End Function - Public Function AddCheckList(CveTipoServicio As Integer, CveCheckListActividad As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_CheckListAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveTipoServicio", SqlDbType.Int).Value = CveTipoServicio - .Add("@CveCheckListActividad", SqlDbType.Int).Value = CveCheckListActividad - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar el CheckList", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno + Public Function AddCheckListActividad(CheckListActividad As String, CveCheckListActividadGrupo As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_CheckListActividadAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CheckListActividad", SqlDbType.NVarChar).Value = CheckListActividad + .Add("@CveCheckListActividadGrupo", SqlDbType.Int).Value = CveCheckListActividadGrupo + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar las actividades de CheckList", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno End Function - Public Function UpdateCheckList(CveCheckList As Integer, CveTipoServicio As Integer, CveCheckListActividad As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_CheckListUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCheckList", SqlDbType.Int).Value = CveCheckList - .Add("@CveTipoServicio", SqlDbType.Int).Value = CveTipoServicio - .Add("@CveCheckListActividad", SqlDbType.Int).Value = CveCheckListActividad - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar el CheckList", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno + Public Function UpdateCheckListActividad(CveCheckListActividad As Integer, CheckListActividad As String, CveCheckListActividadGrupo As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_CheckListActividadUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCheckListActividad", SqlDbType.Int).Value = CveCheckListActividad + .Add("@CheckListActividad", SqlDbType.NVarChar).Value = CheckListActividad + .Add("@CveCheckListActividadGrupo", SqlDbType.Int).Value = CveCheckListActividadGrupo + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar las actividades de CheckList", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno End Function - Public Function DeleteCheckList(CveCheckList As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_CheckListDelete") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCheckList", SqlDbType.Int).Value = CveCheckList - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al eliminar el CheckList", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno + Public Function DeleteCheckListActividad(CveCheckListActividad As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_CheckListActividadDelete") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCheckListActividad", SqlDbType.Int).Value = CveCheckListActividad + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar las actividades de CheckList", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function GetCheckList(CveCheckList As Integer, CveTipoServicio As Integer, CveCheckListActividad As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_CheckListGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCheckList", SqlDbType.Int).Value = CveCheckList + .Add("@CveTipoServicio", SqlDbType.Int).Value = CveTipoServicio + .Add("@CveCheckListActividad", SqlDbType.Int).Value = CveCheckListActividad + .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 CheckList", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function AddCheckList(CveTipoServicio As Integer, CveCheckListActividad As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_CheckListAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveTipoServicio", SqlDbType.Int).Value = CveTipoServicio + .Add("@CveCheckListActividad", SqlDbType.Int).Value = CveCheckListActividad + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar el CheckList", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function UpdateCheckList(CveCheckList As Integer, CveTipoServicio As Integer, CveCheckListActividad As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_CheckListUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCheckList", SqlDbType.Int).Value = CveCheckList + .Add("@CveTipoServicio", SqlDbType.Int).Value = CveTipoServicio + .Add("@CveCheckListActividad", SqlDbType.Int).Value = CveCheckListActividad + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar el CheckList", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function DeleteCheckList(CveCheckList As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_CheckListDelete") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCheckList", SqlDbType.Int).Value = CveCheckList + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar el CheckList", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno End Function @@ -4185,176 +4186,176 @@ Public Class ClsAF Public Function GetOrdenesTrabajoEstatus(CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_OrdenesTrabajoEstatusGet") - - 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 los estatus", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_OrdenesTrabajoEstatusGet") + + 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 los estatus", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function Public Function GetOrdenesTrabajo(CveOrdenTrabajo As Integer, CveTipoServicio As Integer, Folio As Integer, CveAF As Integer, CveSubProyecto As Integer, Prioridad As Integer, FechaInicio As Date, FechaFin As Date, FechaFinReal As Date, CveEstatusOT As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_OrdenesTrabajoGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveOrdenTrabajo", SqlDbType.Int).Value = CveOrdenTrabajo - .Add("@CveTipoServicio", SqlDbType.Int).Value = CveTipoServicio - .Add("@Folio", SqlDbType.Int).Value = Folio - .Add("@CveAF", SqlDbType.Int).Value = CveAF - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@Prioridad", SqlDbType.Int).Value = Prioridad - .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio - .Add("@FechaFin", SqlDbType.Date).Value = FechaFin - '.Add("@FechaFinReal", SqlDbType.Date).Value = FechaFinReal - .Add("@CveEstatusOT", SqlDbType.Int).Value = CveEstatusOT + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_OrdenesTrabajoGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveOrdenTrabajo", SqlDbType.Int).Value = CveOrdenTrabajo + .Add("@CveTipoServicio", SqlDbType.Int).Value = CveTipoServicio + .Add("@Folio", SqlDbType.Int).Value = Folio + .Add("@CveAF", SqlDbType.Int).Value = CveAF + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@Prioridad", SqlDbType.Int).Value = Prioridad + .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio + .Add("@FechaFin", SqlDbType.Date).Value = FechaFin + '.Add("@FechaFinReal", SqlDbType.Date).Value = FechaFinReal + .Add("@CveEstatusOT", SqlDbType.Int).Value = CveEstatusOT .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al consultar las ordenes de trabajo", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al consultar las ordenes de trabajo", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function 'Public Function GetOrdenesTrabajoAsignacion(CveSubProyecto As Integer, CveAF As Integer, CveTipoServicio As Integer, FechaInicio As Date, FechaFin As Date, Prioridad As Integer, CveEmpresa As Integer) As Boolean - ' Dim Retorno As Boolean = False - - ' DataAdapter("PA_AF_OrdenesTrabajoAsignacionGet") - - ' With SqlAdapter.SelectCommand.Parameters - ' .Add("@CveOrdenTrabajo", SqlDbType.Int).Value = CveOrdenTrabajo + ' Dim Retorno As Boolean = False + + ' DataAdapter("PA_AF_OrdenesTrabajoAsignacionGet") + + ' With SqlAdapter.SelectCommand.Parameters + ' .Add("@CveOrdenTrabajo", SqlDbType.Int).Value = CveOrdenTrabajo ' .Add("@CveTipoServicio", SqlDbType.Int).Value = CveTipoServicio - ' .Add("@CveAF", SqlDbType.Int).Value = CveAF - ' .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - ' .Add("@Prioridad", SqlDbType.Int).Value = Prioridad - ' .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio + ' .Add("@CveAF", SqlDbType.Int).Value = CveAF + ' .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + ' .Add("@Prioridad", SqlDbType.Int).Value = Prioridad + ' .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio '' .Add("@FechaFin", SqlDbType.Date).Value = FechaFin ' .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - ' End With - - ' Try - ' SqlAdapter.Fill(Data) - ' Retorno = True - ' Catch ex As Exception - ' OnError("Ocurrió un error al consultar las ordenes de trabajo", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - ' End Try - - ' Return Retorno - + ' End With + + ' Try + ' SqlAdapter.Fill(Data) + ' Retorno = True + ' Catch ex As Exception + ' OnError("Ocurrió un error al consultar las ordenes de trabajo", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + ' End Try + + ' Return Retorno + 'End Function Public Function AddOrdenesTrabajo(CveTipoServicio As Integer, CveAF As Integer, Servicio As String, CveSubProyecto As Integer, Prioridad As Integer, FechaInicio As Date, FechaFin As Date, FechaFinReal As Date, CveEstatusOT As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_OrdenesTrabajoAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveTipoServicio", SqlDbType.Int).Value = CveTipoServicio - .Add("@CveAF", SqlDbType.Int).Value = CveAF - .Add("@Servicio", SqlDbType.VarChar).Value = Servicio - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@Prioridad", SqlDbType.Int).Value = Prioridad - .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio - .Add("@FechaFin", SqlDbType.Date).Value = FechaFin - .Add("@FechaFinReal", SqlDbType.Date).Value = FechaFinReal - .Add("@CveEstatusOT", SqlDbType.Int).Value = CveEstatusOT - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - - .Add("@CveOrdenTrabajo", SqlDbType.Int).Direction = ParameterDirection.Output - .Add("@Folio", SqlDbType.Int).Direction = ParameterDirection.Output - - End With - - Try + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_OrdenesTrabajoAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveTipoServicio", SqlDbType.Int).Value = CveTipoServicio + .Add("@CveAF", SqlDbType.Int).Value = CveAF + .Add("@Servicio", SqlDbType.VarChar).Value = Servicio + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@Prioridad", SqlDbType.Int).Value = Prioridad + .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio + .Add("@FechaFin", SqlDbType.Date).Value = FechaFin + .Add("@FechaFinReal", SqlDbType.Date).Value = FechaFinReal + .Add("@CveEstatusOT", SqlDbType.Int).Value = CveEstatusOT + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + + .Add("@CveOrdenTrabajo", SqlDbType.Int).Direction = ParameterDirection.Output + .Add("@Folio", SqlDbType.Int).Direction = ParameterDirection.Output + + End With + + Try SqlAdapter.Fill(Data) CveOrdenTrabajo = SqlAdapter.SelectCommand.Parameters("@CveOrdenTrabajo").Value.ToString.ToEntero - FolioOT = SqlAdapter.SelectCommand.Parameters("@Folio").Value.ToString.ToEntero - - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar la orden de trabajo", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - + FolioOT = SqlAdapter.SelectCommand.Parameters("@Folio").Value.ToString.ToEntero + + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar la orden de trabajo", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function Public Function UpdateOrdenesTrabajo(CveOrdenTrabajo As Integer, CveTipoServicio As Integer, CveAF As Integer, Servicio As String, CveSubProyecto As Integer, Prioridad As Integer, FechaInicio As Date, FechaFin As Date, FechaFinReal As Date, CveEstatusOT As Integer, CveEmpresa As Integer, CvePersonal As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_OrdenesTrabajoUpdate") - + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_OrdenesTrabajoUpdate") + With SqlAdapter.SelectCommand.Parameters .Add("@CveOrdenTrabajo", SqlDbType.Int).Value = CveOrdenTrabajo - .Add("@CveTipoServicio", SqlDbType.Int).Value = CveTipoServicio - .Add("@CveAF", SqlDbType.Int).Value = CveAF - .Add("@Servicio", SqlDbType.VarChar).Value = Servicio - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@Prioridad", SqlDbType.Int).Value = Prioridad - .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio - .Add("@FechaFin", SqlDbType.Date).Value = FechaFin - .Add("@FechaFinReal", SqlDbType.Date).Value = FechaFinReal - .Add("@CveEstatusOT", SqlDbType.Int).Value = CveEstatusOT + .Add("@CveTipoServicio", SqlDbType.Int).Value = CveTipoServicio + .Add("@CveAF", SqlDbType.Int).Value = CveAF + .Add("@Servicio", SqlDbType.VarChar).Value = Servicio + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@Prioridad", SqlDbType.Int).Value = Prioridad + .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio + .Add("@FechaFin", SqlDbType.Date).Value = FechaFin + .Add("@FechaFinReal", SqlDbType.Date).Value = FechaFinReal + .Add("@CveEstatusOT", SqlDbType.Int).Value = CveEstatusOT .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa .Add("@CvePersonal", SqlDbType.Int).Value = CvePersonal - End With - - Try + End With + + Try SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar la orden de trabajo", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar la orden de trabajo", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function Public Function UpdateOrdenesTrabajoOC(CveOrdenTrabajo As Integer, CveOrdenCompra As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_OrdenesTrabajoOCUpdate") - + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_OrdenesTrabajoOCUpdate") + With SqlAdapter.SelectCommand.Parameters @@ -4362,76 +4363,76 @@ Public Class ClsAF .Add("@CveOrdenCompra", SqlDbType.Int).Value = CveOrdenCompra .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try + End With + + Try SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar la orden de trabajo", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar la orden de trabajo", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function Public Function GetOrdenesTrabajoMateriales(CveOrdenTrabajo As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_OrdenesTrabajoMaterialesGet") - + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_OrdenesTrabajoMaterialesGet") + With SqlAdapter.SelectCommand.Parameters - .Add("@CveOrdenTrabajo", SqlDbType.Int).Value = CveOrdenTrabajo + .Add("@CveOrdenTrabajo", SqlDbType.Int).Value = CveOrdenTrabajo .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try + End With + + Try SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los materiales", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los materiales", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function Public Function GetOrdenesTrabajoActividades(CveOrdenTrabajo As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_OrdenesTrabajoActividadesGet") - + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_OrdenesTrabajoActividadesGet") + With SqlAdapter.SelectCommand.Parameters - .Add("@CveOrdenTrabajo", SqlDbType.Int).Value = CveOrdenTrabajo + .Add("@CveOrdenTrabajo", SqlDbType.Int).Value = CveOrdenTrabajo .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try + End With + + Try SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener las actividades", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener las actividades", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function Public Function UpdateOrdenesTrabajoActividades(CveOrdenTrabajoActividad As Integer, Valor As String, Terminado As Integer, Observaciones As String, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_OrdenesTrabajoActividadesUpdate") - + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_OrdenesTrabajoActividadesUpdate") + With SqlAdapter.SelectCommand.Parameters .Add("@CveOrdenTrabajoActividad", SqlDbType.Int).Value = CveOrdenTrabajoActividad @@ -4440,104 +4441,104 @@ Public Class ClsAF .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try + End With + + Try SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar las actividades", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar las actividades", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function Public Function GetOrdenesTrabajoCheckList(CveOrdenTrabajo As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_OrdenesTrabajoCheckListGet") - + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_OrdenesTrabajoCheckListGet") + With SqlAdapter.SelectCommand.Parameters - .Add("@CveOrdenTrabajo", SqlDbType.Int).Value = CveOrdenTrabajo + .Add("@CveOrdenTrabajo", SqlDbType.Int).Value = CveOrdenTrabajo .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try + End With + + Try SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el check list", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el check list", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function Public Function UpdateOrdenesTrabajoCheckList(CveOrdenTrabajoCheckList As Integer, Valor As String, Terminado As Integer, Observaciones As String, Estatus As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AF_OrdenesTrabajoCheckListUpdate") - + Dim Retorno As Boolean = False + + DataAdapter("PA_AF_OrdenesTrabajoCheckListUpdate") + With SqlAdapter.SelectCommand.Parameters .Add("@CveOrdenTrabajoCheckList", SqlDbType.Int).Value = CveOrdenTrabajoCheckList .Add("@Valor", SqlDbType.VarChar).Value = Valor .Add("@Terminado", SqlDbType.Int).Value = Terminado .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones - .Add("@Estatus", SqlDbType.Int).Value = Estatus + .Add("@Estatus", SqlDbType.Int).Value = Estatus .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try + End With + + Try SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar el check list", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar el check list", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function #End Region -#End Region +#End Region -#Region " IDisposable Support " +#Region " IDisposable Support " ' IDisposable - Protected Overridable Sub Dispose(ByVal disposing As Boolean) - If Not disposedValue Then - If disposing Then - ' TODO: Liberar otro estado (objetos administrados). - SqlConexion.Close() - SqlConexion.Dispose() - If Not Data Is Nothing Then Data.Dispose() - If Not SqlAdapter Is Nothing Then SqlAdapter.Dispose() - - End If - - ' TODO: Liberar su propio estado (objetos no administrados). - ' TODO: Establecer campos grandes como Null. - End If - disposedValue = True - End Sub - - ' Visual Basic agregó este código para implementar correctamente el modelo descartable. - Public Sub Dispose() Implements IDisposable.Dispose - ' No cambie este código. Coloque el código de limpieza en Dispose (ByVal que se dispone como Boolean). - ConexionClose() - Dispose(True) - GC.SuppressFinalize(Me) - End Sub -#End Region -End Class + Protected Overridable Sub Dispose(ByVal disposing As Boolean) + If Not disposedValue Then + If disposing Then + ' TODO: Liberar otro estado (objetos administrados). + SqlConexion.Close() + SqlConexion.Dispose() + If Not Data Is Nothing Then Data.Dispose() + If Not SqlAdapter Is Nothing Then SqlAdapter.Dispose() + + End If + + ' TODO: Liberar su propio estado (objetos no administrados). + ' TODO: Establecer campos grandes como Null. + End If + disposedValue = True + End Sub + + ' Visual Basic agregó este código para implementar correctamente el modelo descartable. + Public Sub Dispose() Implements IDisposable.Dispose + ' No cambie este código. Coloque el código de limpieza en Dispose (ByVal que se dispone como Boolean). + ConexionClose() + Dispose(True) + GC.SuppressFinalize(Me) + End Sub +#End Region +End Class diff --git a/App_Code/ClsBancos.vb b/App_Code/ClsBancos.vb index 5098d660e..9ab441dc1 100644 --- a/App_Code/ClsBancos.vb +++ b/App_Code/ClsBancos.vb @@ -1718,7 +1718,7 @@ Public Class ClsBancos Return Retorno End Function - Public Function CancelarBancos_IE(CveUsuario As Integer, CveIE As Integer, MesAnterior As Boolean, IdPoliza As Integer, FolioPoliza As Integer, Optional FechaCancelacion As Date = MinFecha, Optional TipoMovimiento As Integer = 1) As Integer + Public Function CancelarBancos_IE(CveUsuario As Integer, CveIE As Integer, MesAnterior As Boolean, IdPoliza As Integer, FolioPoliza As Integer, Optional FechaCancelacion As Date = MinFecha, Optional TipoMovimiento As Integer = 1, Optional CveTipoTransaccionCancelacion As Integer = -1) As Integer Dim Retorno As Integer = 0 DataAdapter("PA_Banc_IECancelar") @@ -1731,6 +1731,7 @@ Public Class ClsBancos .Add("@FolioPoliza", SqlDbType.Int).Value = FolioPoliza .Add("@FechaCancelacion", SqlDbType.Date).Value = FechaCancelacion .Add("@TipoMovimiento", SqlDbType.Int).Value = TipoMovimiento + .Add("@CveTipoTransaccionCancelacion", SqlDbType.Int).Value = CveTipoTransaccionCancelacion .Add("@CvePrePoliza", SqlDbType.Int).Direction = ParameterDirection.Output End With 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/IE.aspx b/Bancos/IE.aspx index 38f89fdc3..cf228a0c4 100644 --- a/Bancos/IE.aspx +++ b/Bancos/IE.aspx @@ -1153,7 +1153,7 @@