diff --git a/.gitignore b/.gitignore index e3e70ef3d..a7b361013 100644 --- a/.gitignore +++ b/.gitignore @@ -1,127 +1,271 @@ -################################################################################ -# Este archivo .gitignore ha sido creado automáticamente por Microsoft(R) Visual Studio. -################################################################################ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +web.config +*.txt +Log.txt +LogMail.txt +LogTimbrado.txt +[Mm]enu/ +[Mm]anuales/ +[Tt]emp/ +[Ee]mpresas/ +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates -/Empresas -/Menu -/Web.config -/Log.txt -/.vs/localhost/v14/.suo -/LogMail.txt -/.vs -/packages -/Temp/637019018406489106-FormatoPS (1).xlsx -/Temp/637025911245561139-FormatoAlmacenTest2.xlsx -/Temp/637025910298823073-FormatoAlmacenTest2.xlsx -/Temp/637025890843842072-FormatoAlmacenTest.xlsx -/Temp/637025890070124286-FormatoAlmacenTest.xlsx -/Temp/637025889649837823-FormatoAlmacenTest.xlsx -/Temp/637025888979809566-FormatoAlmacenTest.xlsx -/Temp/637025888317991027-FormatoAlmacenTest.xlsx -/Temp/637025886969280729-FormatoAlmacenTest.xlsx -/Temp/637025883478481189-FormatoAlmacenTest.xlsx -/Temp/637025881893726971-FormatoAlmacenTest.xlsx -/Temp/637025875318390368-FormatoAlmacenTest.xlsx -/Temp/637025873461693799-FormatoAlmacenTest.xlsx -/Temp/637025867243299753-FormatoAlmacenTest.xlsx -/Temp/637025866028329141-FormatoAlmacenTest.xlsx -/Temp/637025858967837880-FormatoAlmacen (8).xlsx -/Temp/637025856623805153-FormatoAlmacenTest.xlsx -/Temp/637025854225974598-FormatoAlmacenTest.xlsx -/Temp/637025850746443741-FormatoAlmacenTest.xlsx -/Temp/637025849906896827-FormatoAlmacenTest.xlsx -/Temp/637025811751064573-FormatoAlmacen (9).xlsx -/Temp/637025802306385270-FormatoAlmacen (9).xlsx -/Temp/637024955677385188-FormatoAlmacen (8).xlsx -/Temp/637024223339157610-FormatoAlmacen (8).xlsx -/Temp/637024211080831453-FormatoAlmacen (8).xlsx -/Temp/637024208748075824-FormatoAlmacen (8).xlsx -/Temp/637024206124827330-FormatoAlmacen (8).xlsx -/Temp/637024198603668842-FormatoAlmacen (8).xlsx -/Temp/637024194937999485-FormatoAlmacen (8).xlsx -/Temp/637024187194477421-FormatoAlmacen (8).xlsx -/Temp/637024175396114926-FormatoAlmacen(1).xlsx -/Temp/637024174152414578-FormatoAlmacen(1).xlsx -/Temp/637024172516905613-FormatoAlmacen(1).xlsx -/Temp/637024172339379953-FormatoAlmacen(1).xlsx -/Temp/637024168678743644-FormatoAlmacen(1).xlsx -/Temp/637024167899990250-FormatoAlmacen(1).xlsx -/Temp/637024163796303799-FormatoAlmacen(1).xlsx -/Temp/637024162382548932-FormatoAlmacen(1).xlsx -/Temp/637024154734150595-FormatoAlmacen(1).xlsx -/Temp/637024152618695056-FormatoAlmacen(1).xlsx -/Temp/637024129146071459-FormatoAlmacen(1).xlsx -/Temp/637024111695874769-FormatoAlmacen(1).xlsx -/Temp/637022418959236013-FormatoAlmacen (4).xlsx -/Temp/637022412610855769-FormatoAlmacen (4).xlsx -/Temp/637022411585353362-FormatoAlmacen (4).xlsx -/Temp/637022404788752537-FormatoAlmacen (3).xlsx -/Temp/637022403501450734-FormatoAlmacen (3).xlsx -/Temp/637022402924630398-FormatoAlmacen (3).xlsx -/Temp/637022401250489074-FormatoAlmacen (5).xlsx -/Temp/637022398545213986-FormatoAlmacen (3).xlsx -/Temp/637022382214133336-FormatoAlmacen (5).xlsx -/Temp/637022380557097080-FormatoAlmacen (5).xlsx -/Temp/637022379412790662-FormatoAlmacen (5).xlsx -/Temp/637022378793902185-FormatoAlmacen (5).xlsx -/Temp/637021654534481890-FormatoAlmacen (3).xlsx -/Temp/637021651345315739-FormatoAlmacen (3).xlsx -/Temp/637021616508913486-FormatoAlmacen (3).xlsx -/Temp/637021593875864770-FormatoAlmacen (3).xlsx -/Temp/637021592631992296-FormatoAlmacen (3).xlsx -/Temp/637021592488982043-FormatoAlmacen (3).xlsx -/Temp/637021560097934922-FormatoAlmacen (3).xlsx -/Temp/637021554559110062-FormatoPS (1).xlsx -/Temp/637021550053083909-FormatoAlmacen (3).xlsx -/Temp/637021547214247040-FormatoAlmacen (3).xlsx -/Temp/637021545638924577-FormatoAlmacen (3).xlsx -/Temp/637021527971651311-FormatoAlmacen (3).xlsx -/Temp/637021527073950270-FormatoAlmacen (3).xlsx -/Temp/637021526064707043-FormatoAlmacen (3).xlsx -/Temp/637021522586485282-FormatoAlmacen (3).xlsx -/Temp/637021521403851473-FormatoAlmacen (3).xlsx -/Temp/637021519837377736-FormatoAlmacen (3).xlsx -/Temp/637021515778751967-FormatoAlmacen (3).xlsx -/Temp/637020728341171393-FormatoAlmacen (2).xlsx -/Temp/637020724850629405-FormatoAlmacen (2).xlsx -/Temp/637020723186758192-FormatoAlmacen (2).xlsx -/Temp/637020721382428289-FormatoAlmacen (2).xlsx -/Temp/637019818530193505-FormatoPS (1).xlsx -/Temp/637019811169546741-FormatoPS (1).xlsx -/Temp/637019803848526814-FormatoPS (1).xlsx -/Temp/637019796396388291-FormatoPS (1).xlsx -/Temp/637019783731773074-FormatoPS (1).xlsx -/Temp/637019781961714106-FormatoPS (1).xlsx -/Temp/637019780290041928-FormatoPS (1).xlsx -/Temp/637019777705293557-FormatoPS (1).xlsx -/Temp/637019766664551609-FormatoPS (1).xlsx -/Temp/637019765307733182-FormatoPS (1).xlsx -/Temp/637019764041447352-FormatoPS (1).xlsx -/Temp/637019759922681271-FormatoPS (1).xlsx -/Temp/637019028539049368-FormatoPS (1).xlsx -/Temp/637019027752495331-FormatoPS (1).xlsx -/Temp/637019026870914833-FormatoPS (1).xlsx -/Temp/637019020024023961-FormatoPS (1).xlsx -/Temp/637019018783282466-FormatoPS (1).xlsx -/Temp/637025921934403738-FormatoAlmacen (4)(1).xlsx -/Temp/637025871940254054-FormatoAlmacenTest.xlsx -/Temp/637025819297716436-FormatoAlmacen (9).xlsx -/Temp/637025813094826506-FormatoAlmacen (9).xlsx -/Temp/637025803627482072-FormatoAlmacen (9).xlsx -/Temp/637024210197949659-FormatoAlmacen (8).xlsx -/Temp/637024207387517397-FormatoAlmacen (8).xlsx -/Temp/637024203939520361-FormatoAlmacen (8).xlsx -/Temp/637024200918571845-FormatoAlmacen (8).xlsx -/Temp/637024199786848948-FormatoAlmacen (8).xlsx -/Temp/637024188637374314-FormatoAlmacen (8).xlsx -/Temp/637024170730017118-FormatoAlmacen(1).xlsx -/Temp/637024164939543846-FormatoAlmacen(1).xlsx -/Temp/637024164072145623-FormatoAlmacen(1).xlsx -/Temp/637024156159485931-FormatoAlmacen(1).xlsx -/Temp/637024153420640718-FormatoAlmacen(1).xlsx -/Temp/637024148711869965-FormatoAlmacen(1).xlsx -/Temp/637022414752610497-FormatoAlmacen (4).xlsx -/Temp/637021629396074854-FormatoAlmacen (3).xlsx -/Temp/637021627402424201-FormatoAlmacen (3).xlsx -/Temp/637021547606916146-FormatoAlmacen (3).xlsx -/Temp/637021529455078900-FormatoAlmacen (3).xlsx +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# DNX +project.lock.json +project.fragment.lock.json +artifacts/ + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +#*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignoreable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +node_modules/ +orleans.codegen.cs + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml +*.sln + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc +/Utilerias diff --git a/App_Code/ClsAC.vb b/App_Code/ClsAC.vb index bceaf1869..0f4a0f45e 100644 --- a/App_Code/ClsAC.vb +++ b/App_Code/ClsAC.vb @@ -22,6 +22,8 @@ Public Class ClsAC Private _CveProgramaOperativo As Integer Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'REGISTRAR CONEXIÓN + Private CveConexion As Integer = 0 #End Region #Region "Propiedades" @@ -53,7 +55,7 @@ Public Class ClsAC End If SqlAdapter = New SqlDataAdapter("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlAdapter.SelectCommand @@ -65,6 +67,42 @@ Public Class ClsAC Data = New DataTable End Sub +#Region "Conexiones" + + Private Sub ConexionAdd() + If 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 = HttpContext.Current.Request.Url.AbsolutePath.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 + + End If + + End Sub +#End Region Public Function IniciaTransacSQL() As SqlTransaction If SqlTransacc Is Nothing Then SqlTransacc = SqlConexion.BeginTransaction() Return SqlTransacc @@ -3217,6 +3255,7 @@ Public Class ClsAC Me.disposedValue = True End Sub Public Sub Dispose() Implements IDisposable.Dispose + ConexionClose() Dispose(True) GC.SuppressFinalize(Me) End Sub diff --git a/App_Code/ClsAC2.vb b/App_Code/ClsAC2.vb index 95dd07dd0..5793e36a8 100644 --- a/App_Code/ClsAC2.vb +++ b/App_Code/ClsAC2.vb @@ -22,6 +22,8 @@ Public Class ClsAC2 Private _CveProgramaOperativo As Integer Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'REGISTRAR CONEXIÓN + Private CveConexion As Integer = 0 #End Region #Region "Propiedades" @@ -49,7 +51,7 @@ Public Class ClsAC2 End If SqlAdapter = New SqlDataAdapter("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlAdapter.SelectCommand @@ -60,7 +62,42 @@ Public Class ClsAC2 If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc Data = New DataTable End Sub +#Region "Conexiones" + Private Sub ConexionAdd() + If 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 = HttpContext.Current.Request.Url.AbsolutePath.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 + + End If + + End Sub +#End Region Public Function GetRepPresupuestosEgresosSaldos(Ejercicio As Integer, Fecha As String, Capitulo As String, CveClasificacion As Integer, CveFuenteFinanciamiento As Integer, CveProgramaOperativo As Integer, CveUnidadAdministrativa As Integer, Gpo As Integer) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_PresupuestosEgresosSaldosRep") @@ -125,6 +162,7 @@ Public Class ClsAC2 Me.disposedValue = True End Sub Public Sub Dispose() Implements IDisposable.Dispose + ConexionClose() Dispose(True) GC.SuppressFinalize(Me) End Sub diff --git a/App_Code/ClsAF.vb b/App_Code/ClsAF.vb index 42eb253bb..d312871aa 100644 --- a/App_Code/ClsAF.vb +++ b/App_Code/ClsAF.vb @@ -19,6 +19,8 @@ Public Class ClsAF Private Data As DataTable Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'REGISTRAR CONEXIÓN + Private CveConexion As Integer = 0 #End Region #Region "Propiedades" @@ -96,7 +98,7 @@ Public Class ClsAF End If SqlAdapter = New SqlDataAdapter("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlAdapter.SelectCommand @@ -107,6 +109,42 @@ Public Class ClsAF If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc Data = New DataTable End Sub +#Region "Conexiones" + + Private Sub ConexionAdd() + If 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 = HttpContext.Current.Request.Url.AbsolutePath.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 + + End If + + End Sub +#End Region Public Function IniciaTransacSQL() As SqlTransaction If SqlTransacc Is Nothing Then SqlTransacc = SqlConexion.BeginTransaction() Return SqlTransacc @@ -3225,6 +3263,7 @@ Public Class ClsAF ' 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 diff --git a/App_Code/ClsAIMMGM.vb b/App_Code/ClsAIMMGM.vb index 085124e37..3509f4b9d 100644 --- a/App_Code/ClsAIMMGM.vb +++ b/App_Code/ClsAIMMGM.vb @@ -16,6 +16,8 @@ Public Class ClsAIMMGM Private SqlTransacc As SqlTransaction Private Data As DataTable Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'REGISTRAR CONEXIÓN + Private CveConexion As Integer = 0 #End Region #Region "Propiedades" @@ -61,7 +63,7 @@ Public Class ClsAIMMGM SqlAdapter = New SqlDataAdapter("", SqlConexion) SqlCommand = New SqlCommand("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(pStrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) @@ -73,7 +75,42 @@ Public Class ClsAIMMGM If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc Data = New DataTable End Sub +#Region "Conexiones" + Private Sub ConexionAdd() + If 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 = HttpContext.Current.Request.Url.AbsolutePath.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 + + End If + + End Sub +#End Region Private Sub DataCommand(pStrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlCommand @@ -726,6 +763,7 @@ Public Class ClsAIMMGM ' 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 diff --git a/App_Code/ClsAcarreos.vb b/App_Code/ClsAcarreos.vb index 8a2620b0c..4742e0209 100644 --- a/App_Code/ClsAcarreos.vb +++ b/App_Code/ClsAcarreos.vb @@ -17,7 +17,8 @@ Public Class ClsAcarreos Private Data As DataTable Private disposedValue As Boolean = False ' Para detectar llamadas redundantes - + 'REGISTRAR CONEXIÓN + Private CveConexion As Integer = 0 Public ReadOnly Property DtResultados() As DataTable Get DtResultados = Data @@ -48,7 +49,7 @@ Public Class ClsAcarreos End If SqlAdapter = New SqlDataAdapter("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlAdapter.SelectCommand @@ -59,6 +60,42 @@ Public Class ClsAcarreos If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc Data = New DataTable End Sub +#Region "Conexiones" + + Private Sub ConexionAdd() + If 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 = HttpContext.Current.Request.Url.AbsolutePath.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 + + End If + + End Sub +#End Region Public Function IniciaTransacSQL() As SqlTransaction If SqlTransacc Is Nothing Then SqlTransacc = SqlConexion.BeginTransaction() Return SqlTransacc @@ -1300,6 +1337,7 @@ Public Class ClsAcarreos Me.disposedValue = True End Sub Public Sub Dispose() Implements IDisposable.Dispose + ConexionClose() Dispose(True) GC.SuppressFinalize(Me) End Sub diff --git a/App_Code/ClsAcumuladores.vb b/App_Code/ClsAcumuladores.vb index 14c4d0c58..38d227c6e 100644 --- a/App_Code/ClsAcumuladores.vb +++ b/App_Code/ClsAcumuladores.vb @@ -17,6 +17,8 @@ Public Class ClsAcumuladores 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 Sub SqlDataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlAdapter.SelectCommand @@ -63,9 +65,44 @@ Public Class ClsAcumuladores End If SqlAdapter = New SqlDataAdapter("", SqlConexion) + ConexionAdd() + End Sub +#Region "Conexiones" + Private Sub ConexionAdd() + If ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + Try + SqlDataAdapter("PA_Sis_RegistrarConexion") + With SqlAdapter.SelectCommand.Parameters + .Add("@Clase", SqlDbType.VarChar).Value = Me.GetType().Name + .Add("@Modulo", SqlDbType.VarChar).Value = HttpContext.Current.Request.Url.AbsolutePath.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 + + SqlDataAdapter(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 + + End If + + End Sub +#End Region Public ReadOnly Property DtResultados() As DataTable Get DtResultados = Data @@ -810,6 +847,7 @@ Public Class ClsAcumuladores ' 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 diff --git a/App_Code/ClsBancos.vb b/App_Code/ClsBancos.vb index dfdc4803e..05868a58a 100644 --- a/App_Code/ClsBancos.vb +++ b/App_Code/ClsBancos.vb @@ -9,6 +9,7 @@ Imports System.Configuration Imports Microsoft.Reporting.WebForms Imports System.Xml Imports System.IO +Imports System.Web Public Class ClsBancos Implements IDisposable @@ -47,10 +48,12 @@ Public Class ClsBancos Public Property CveUsuarioCancelacion As Integer Public Property UsuarioCancelacion As String Public Property FechaIngCancelacion As Date - Public Property FechaCancelacion As Date - + Public Property FechaCancelacion As Date + + 'CONTROL DE LA CONEXION + Private CveConexion As Integer = 0 #End Region - + #Region " P R O P I E D A D E S - B A N C O S - I E" Public Property CveIE As Integer Public Property CveCuenta As Integer @@ -178,16 +181,17 @@ Public Class ClsBancos Try SqlConexion.Open() Catch ex As Exception - OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex) + OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex) End Try Else SqlConexion = TransaccionCompartida.Connection - SqlTransacc = TransaccionCompartida + SqlTransacc = TransaccionCompartida End If SqlCommand = New SqlCommand("", SqlConexion) - SqlAdapter = New SqlDataAdapter("", SqlConexion) - + SqlAdapter = New SqlDataAdapter("", SqlConexion) + ConexionAdd() + End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlAdapter.SelectCommand @@ -197,7 +201,45 @@ Public Class ClsBancos End With If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc Data = New DataTable + End Sub + +#Region "Conexiones" + + Private Sub ConexionAdd() + If 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 = HttpContext.Current.Request.Url.AbsolutePath.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 + + End If + + End Sub +#End Region + Private Sub DataCommand(pStrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlCommand .Parameters.Clear() @@ -4066,8 +4108,9 @@ Public Class ClsBancos '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. + 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 diff --git a/App_Code/ClsBase.vb b/App_Code/ClsBase.vb index b67348d02..be5187d63 100644 --- a/App_Code/ClsBase.vb +++ b/App_Code/ClsBase.vb @@ -21,6 +21,8 @@ Public Class ClsBase Protected Data As DataTable Protected disposedValue As Boolean = False ' Para detectar llamadas redundantes Protected EsTransaccion As Boolean = False + 'REGISTRAR CONEXIÓN + Private CveConexion As Integer = 0 #End Region Public Sub IniciaTransacSQL() @@ -44,6 +46,7 @@ Public Class ClsBase Catch ex As Exception OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex) End Try + ConexionAdd() End Sub Protected Sub AbrirConexion() @@ -103,6 +106,42 @@ Public Class ClsBase End With Data = New DataTable End Sub +#Region "Conexiones" + + Private Sub ConexionAdd() + If 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 = HttpContext.Current.Request.Url.AbsolutePath.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 + + End If + + End Sub +#End Region Protected Sub DataCommand(strSQL As String, Optional TipoComando As CommandType = CommandType.Text) If sqlCommand Is Nothing Then sqlCommand = New SqlCommand @@ -161,6 +200,7 @@ Public Class ClsBase ' 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 diff --git a/App_Code/ClsCGame.vb b/App_Code/ClsCGame.vb index 8d52e9a7e..a048e1ad9 100644 --- a/App_Code/ClsCGame.vb +++ b/App_Code/ClsCGame.vb @@ -17,6 +17,8 @@ Public Class ClsCGame Private Data As DataTable Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'REGISTRAR CONEXIÓN + Private CveConexion As Integer = 0 Public ReadOnly Property DtResultados() As DataTable Get @@ -55,7 +57,7 @@ Public Class ClsCGame End If SqlAdapter = New SqlDataAdapter("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlAdapter.SelectCommand @@ -66,6 +68,42 @@ Public Class ClsCGame If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc Data = New DataTable End Sub +#Region "Conexiones" + + Private Sub ConexionAdd() + If 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 = HttpContext.Current.Request.Url.AbsolutePath.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 + + End If + + End Sub +#End Region Public Function IniciaTransacSQL() As SqlTransaction If SqlTransacc Is Nothing Then SqlTransacc = SqlConexion.BeginTransaction() Return SqlTransacc @@ -3365,6 +3403,7 @@ Public Class ClsCGame Me.disposedValue = True End Sub Public Sub Dispose() Implements IDisposable.Dispose + ConexionClose() Dispose(True) GC.SuppressFinalize(Me) End Sub diff --git a/App_Code/ClsCRM.vb b/App_Code/ClsCRM.vb index f3a33b7eb..841e0b7c3 100644 --- a/App_Code/ClsCRM.vb +++ b/App_Code/ClsCRM.vb @@ -18,7 +18,8 @@ Public Class ClsCRM Private DSet As New DataSet Private disposedValue As Boolean = False ' Para detectar llamadas redundantes - + 'REGISTRAR CONEXIONES ABIERTAS + Private CveConexion As Integer = 0 #End Region @@ -52,7 +53,7 @@ Public Class ClsCRM End If SqlAdapter = New SqlDataAdapter("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlAdapter.SelectCommand @@ -63,6 +64,42 @@ Public Class ClsCRM If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc Data = New DataTable End Sub +#Region "Conexiones" + + Private Sub ConexionAdd() + If 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 = HttpContext.Current.Request.Url.AbsolutePath.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 + + End If + + End Sub +#End Region Public Function IniciaTransacSQL() As SqlTransaction If SqlTransacc Is Nothing Then SqlTransacc = SqlConexion.BeginTransaction() Return SqlTransacc @@ -822,6 +859,67 @@ Public Class ClsCRM End Try Return Retorno End Function + Public Function GetAcercamientosGastos(CveAcercamiento As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_CRM_AcercamientosGastosGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveAcercamiento", SqlDbType.Int).Value = CveAcercamiento + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los Gastos del Acercamiento.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + Public Function AddAcercamientosGastos(CveAcercamiento As Integer, Descripcion As String, Importe As Decimal, CveUsuario As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_CRM_AcercamientosGastosAdd") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveAcercamiento", SqlDbType.Int).Value = CveAcercamiento + .Add("@Descripcion", SqlDbType.VarChar).Value = Descripcion + .Add("@Importe", SqlDbType.Money).Value = Importe + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar los Gastos del Acercamiento.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + Public Function UpdateAcercamientosGastos(CveAcercamientoGasto As Integer, Descripcion As String, Importe As Decimal) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_CRM_AcercamientosGastosUpdate") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveAcercamientoGasto", SqlDbType.Int).Value = CveAcercamientoGasto + .Add("@Descripcion", SqlDbType.VarChar).Value = Descripcion + .Add("@Importe", SqlDbType.Money).Value = Importe + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar los Gastos del Acercamiento.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + Public Function RemoveAcercamientosGastos(CveAcercamientoGasto As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_CRM_AcercamientosGastosRemove") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveAcercamientoGasto", SqlDbType.Int).Value = CveAcercamientoGasto + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar los Gastos del Acercamiento.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function #End Region @@ -983,6 +1081,7 @@ Public Class ClsCRM Me.disposedValue = True End Sub Public Sub Dispose() Implements IDisposable.Dispose + ConexionClose() Dispose(True) GC.SuppressFinalize(Me) End Sub diff --git a/App_Code/ClsClaseBase.vb b/App_Code/ClsClaseBase.vb index 78bff9784..5a04b5153 100644 --- a/App_Code/ClsClaseBase.vb +++ b/App_Code/ClsClaseBase.vb @@ -23,6 +23,8 @@ Public Class ClsClaseBase Protected disposedValue As Boolean = False Protected EsTransaccion As Boolean = False Public MyCurrentError As String + 'REGISTRAR CONEXIÓN + Private CveConexion As Integer = 0 #End Region Public Sub New(Optional adsObj As ClsClaseBase = Nothing) @@ -36,6 +38,7 @@ Public Class ClsClaseBase Try SqlConexion.Open() SqlAdapter = New SqlDataAdapter("", SqlConexion) + ConexionAdd() Catch ex As Exception Me.OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex) @@ -75,7 +78,42 @@ Public Class ClsClaseBase DTSet = New DataSet() End If End Sub +#Region "Conexiones" + Private Sub ConexionAdd() + If ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + Try + SqlDataAdapter("PA_Sis_RegistrarConexion") + With SqlAdapter.SelectCommand.Parameters + .Add("@Clase", SqlDbType.VarChar).Value = Me.GetType().Name + .Add("@Modulo", SqlDbType.VarChar).Value = HttpContext.Current.Request.Url.AbsolutePath.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 + + SqlDataAdapter(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 + + End If + + End Sub +#End Region Protected Sub addParameters(name As String, tipo As SqlDbType, valor As Object) If SqlConexion.State = ConnectionState.Open Then @@ -133,6 +171,7 @@ Public Class ClsClaseBase End Sub #End Region Public Sub Dispose() Implements IDisposable.Dispose + ConexionClose() If (SqlConexion IsNot Nothing) Then If SqlConexion.State = ConnectionState.Open Then Try diff --git a/App_Code/ClsClasificaciones.vb b/App_Code/ClsClasificaciones.vb index cac31225d..d1491e709 100644 --- a/App_Code/ClsClasificaciones.vb +++ b/App_Code/ClsClasificaciones.vb @@ -20,7 +20,8 @@ Public Class ClsClasificaciones Private StrSQL As StringBuilder Private Data As DataTable Private disposedValue As Boolean = False ' Para detectar llamadas redundantes - + 'REGISTRAR CONEXIÓN + Private CveConexion As Integer = 0 #End Region #Region "Propiedades" @@ -51,7 +52,7 @@ Public Class ClsClasificaciones SqlCommand = New SqlCommand("", SqlConexion) SqlAdapter = New SqlDataAdapter("", SqlConexion) StrSQL = New StringBuilder - + ConexionAdd() End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) @@ -63,6 +64,42 @@ Public Class ClsClasificaciones If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc Data = New DataTable End Sub +#Region "Conexiones" + + Private Sub ConexionAdd() + If 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 = HttpContext.Current.Request.Url.AbsolutePath.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 + + End If + + End Sub +#End Region Public Function IniciaTransacSQL() As SqlTransaction If SqlTransacc Is Nothing Then SqlTransacc = SqlConexion.BeginTransaction() @@ -531,6 +568,7 @@ Public Class ClsClasificaciones ' 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 diff --git a/App_Code/ClsClientes.vb b/App_Code/ClsClientes.vb index fe0d35a9a..3ac2829ec 100644 --- a/App_Code/ClsClientes.vb +++ b/App_Code/ClsClientes.vb @@ -22,7 +22,8 @@ Public Class ClsClientes 'Atributos de la clase Private disposedValue As Boolean = False ' Para detectar llamadas redundantes - + 'REGISTRAR CONEXIÓN + Private CveConexion As Integer = 0 #End Region #Region "Propiedades" @@ -187,7 +188,7 @@ Public Class ClsClientes SqlCommand = New SqlCommand("", SqlConexion) SqlAdapter = New SqlDataAdapter("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlAdapter.SelectCommand @@ -198,6 +199,42 @@ Public Class ClsClientes If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc Data = New DataTable End Sub +#Region "Conexiones" + + Private Sub ConexionAdd() + If 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 = HttpContext.Current.Request.Url.AbsolutePath.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 + + End If + + End Sub +#End Region Private Sub DataCommand(pStrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlCommand .Parameters.Clear() @@ -1586,6 +1623,7 @@ Public Class ClsClientes ' 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 diff --git a/App_Code/ClsCompEstatusFactura.vb b/App_Code/ClsCompEstatusFactura.vb index 72da2252b..ab0d5245c 100644 --- a/App_Code/ClsCompEstatusFactura.vb +++ b/App_Code/ClsCompEstatusFactura.vb @@ -17,6 +17,8 @@ Public Class ClsCompEstatusFactura Private SqlTransacc As SqlTransaction Private Data As DataTable Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'REGISTRAR CONEXIÓN + Private CveConexion As Integer = 0 #End Region @@ -47,7 +49,7 @@ Public Class ClsCompEstatusFactura SqlCommand = New SqlCommand("", SqlConexion) SqlAdapter = New SqlDataAdapter("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) @@ -59,7 +61,42 @@ Public Class ClsCompEstatusFactura If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc Data = New DataTable End Sub +#Region "Conexiones" + Private Sub ConexionAdd() + If 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 = HttpContext.Current.Request.Url.AbsolutePath.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 + + End If + + End Sub +#End Region Public Function GetEstatusFactura() As Boolean Dim Retorno As Boolean = False @@ -189,6 +226,7 @@ Public Class ClsCompEstatusFactura ' 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 diff --git a/App_Code/ClsCompProveedores.vb b/App_Code/ClsCompProveedores.vb index ec6e221e9..76ebbe8a9 100644 --- a/App_Code/ClsCompProveedores.vb +++ b/App_Code/ClsCompProveedores.vb @@ -19,6 +19,8 @@ Public Class ClsCompProveedores 'Atributos de la clase Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'REGISTRAR CONEXIÓN + Private CveConexion As Integer = 0 #End Region #Region "Propiedades" @@ -171,7 +173,7 @@ Public Class ClsCompProveedores End If SqlAdapter = New SqlDataAdapter("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(ByVal pStrSQL As String, Optional ByVal TipoComando As CommandType = CommandType.StoredProcedure) With SqlAdapter.SelectCommand @@ -182,7 +184,42 @@ Public Class ClsCompProveedores Data = New DataTable If SqlTransacc IsNot Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc End Sub +#Region "Conexiones" + Private Sub ConexionAdd() + If 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 = HttpContext.Current.Request.Url.AbsolutePath.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 + + End If + + End Sub +#End Region Public Function GetClasificacionProveedores() As Boolean Dim Retorno As Boolean = False @@ -1534,6 +1571,7 @@ Public Class ClsCompProveedores ' 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 diff --git a/App_Code/ClsCompras.vb b/App_Code/ClsCompras.vb index a7f69b063..553674a02 100644 --- a/App_Code/ClsCompras.vb +++ b/App_Code/ClsCompras.vb @@ -19,10 +19,12 @@ Public Class ClsCompras Private StrSQL As StringBuilder 'Atributos de la clase - Private disposedValue As Boolean = False ' Para detectar llamadas redundantes - + Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'REGISTRAR CONEXIONES ABIERTAS + Private CveConexion As Integer = 0 + #End Region - + #Region "Propiedades" Public ReadOnly Property DtResultados() As DataTable Get @@ -57,13 +59,14 @@ Public Class ClsCompras SqlConexion.Open() Catch ex As Exception OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex) - End Try + End Try Else SqlConexion = TransaccionCompartida.Connection SqlTransacc = TransaccionCompartida - End If + End If SqlAdapter = New SqlDataAdapter("", SqlConexion) + ConexionAdd() End Sub @@ -75,10 +78,45 @@ Public Class ClsCompras End With Data = New DataTable If SqlTransacc IsNot Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc + End Sub + +#Region "Conexiones" + + Private Sub ConexionAdd() + If 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 = HttpContext.Current.Request.Url.AbsolutePath.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 + + End If + + End Sub +#End Region + Public Function GetCompras(CveCompra As Integer, Serie As String, Folio As String, CveProveedor As Integer, IdPoliza As Integer, CveEmpresa As Integer, Optional ProveedorRFC As String = "-1") As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Comp_ComprasGet") @@ -1838,6 +1876,7 @@ Public Class ClsCompras ' 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 diff --git a/App_Code/ClsContPAQi.vb b/App_Code/ClsContPAQi.vb index 557c15266..35151b8c0 100644 --- a/App_Code/ClsContPAQi.vb +++ b/App_Code/ClsContPAQi.vb @@ -21,7 +21,8 @@ Public Class ClsContPAQi Private DSet As New DataSet Private StrSQL As StringBuilder Public FolioNuevo As Integer - + 'REGISTRAR CONEXIONES ABIERTAS + Private CveConexion As Integer = 0 Private disposedValue As Boolean = False ' Para detectar llamadas redundantes Public Enum TipoPoliza @@ -65,7 +66,7 @@ Public Class ClsContPAQi Catch ex As Exception Me.OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex) End Try - + ConexionAdd() End Sub @@ -88,7 +89,7 @@ Public Class ClsContPAQi Catch ex As Exception Me.OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex) End Try - + 'ConexionAdd() End Sub Private Sub SetTimeOut(Optional Tiempo As Integer = 30) SqlCommand.CommandTimeout = Tiempo @@ -105,7 +106,42 @@ Public Class ClsContPAQi If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc Data = New DataTable End Sub +#Region "Conexiones" + Private Sub ConexionAdd() + If ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + Try + SqlDataAdapter("PA_Sis_RegistrarConexion") + With SqlAdapter.SelectCommand.Parameters + .Add("@Clase", SqlDbType.VarChar).Value = Me.GetType().Name + .Add("@Modulo", SqlDbType.VarChar).Value = HttpContext.Current.Request.Url.AbsolutePath.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 + + SqlDataAdapter(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 + + End If + + End Sub +#End Region Private Sub SqlDataCommand(pStrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlCommand .Parameters.Clear() @@ -11164,6 +11200,7 @@ Public Class ClsContPAQi ' 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 diff --git a/App_Code/ClsContPAQi2.vb b/App_Code/ClsContPAQi2.vb index 27b5610c3..f0c078ca5 100644 --- a/App_Code/ClsContPAQi2.vb +++ b/App_Code/ClsContPAQi2.vb @@ -18,7 +18,8 @@ Public Class ClsContPAQi2 Private Data As DataTable Private StrSQL As StringBuilder Public FolioNuevo As Integer - + 'REGISTRAR CONEXIONES ABIERTAS + Private CveConexion As Integer = 0 Private disposedValue As Boolean = False ' Para detectar llamadas redundantes Public Enum TipoPoliza @@ -55,7 +56,7 @@ Public Class ClsContPAQi2 Catch ex As Exception Me.OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex) End Try - + ConexionAdd() End Sub Sub New(Empresa As Empresa) @@ -72,7 +73,7 @@ Public Class ClsContPAQi2 Catch ex As Exception Me.OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex) End Try - + ConexionAdd() End Sub Private Sub SqlDataAdapter(pStrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) @@ -84,7 +85,42 @@ Public Class ClsContPAQi2 If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc Data = New DataTable End Sub +#Region "Conexiones" + Private Sub ConexionAdd() + If ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + Try + SqlDataAdapter("PA_Sis_RegistrarConexion") + With SqlAdapter.SelectCommand.Parameters + .Add("@Clase", SqlDbType.VarChar).Value = Me.GetType().Name + .Add("@Modulo", SqlDbType.VarChar).Value = HttpContext.Current.Request.Url.AbsolutePath.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 + + SqlDataAdapter(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 + + End If + + End Sub +#End Region Private Sub SqlDataCommand(pStrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlCommand .Parameters.Clear() @@ -999,6 +1035,7 @@ Public Class ClsContPAQi2 ' 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 diff --git a/App_Code/ClsContabilidad.vb b/App_Code/ClsContabilidad.vb index c972e54df..a6f2ad6bd 100644 --- a/App_Code/ClsContabilidad.vb +++ b/App_Code/ClsContabilidad.vb @@ -23,7 +23,8 @@ Public Class ClsContabilidad 'Atributos de la clase Private disposedValue As Boolean = False ' Para detectar llamadas redundantes - + 'REGISTRAR CONEXIONES ABIERTAS + Private CveConexion As Integer = 0 #End Region #Region " P R O P I E D A D E S" @@ -98,7 +99,7 @@ Public Class ClsContabilidad End If Mensaje = New StringBuilder SqlAdapter = New SqlDataAdapter("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) @@ -110,6 +111,42 @@ Public Class ClsContabilidad If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc Data = New DataTable End Sub +#Region "Conexiones" + + Private Sub ConexionAdd() + If 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 = HttpContext.Current.Request.Url.AbsolutePath.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 + + End If + + End Sub +#End Region #Region " C O N T A B I L I D A D - P R E P O L I Z A" @@ -5788,6 +5825,7 @@ Public Class ClsContabilidad Me.disposedValue = True End Sub Public Sub Dispose() Implements IDisposable.Dispose + ConexionClose() Dispose(True) GC.SuppressFinalize(Me) End Sub diff --git a/App_Code/ClsContratos.vb b/App_Code/ClsContratos.vb index 7a6b108c1..8b568dc68 100644 --- a/App_Code/ClsContratos.vb +++ b/App_Code/ClsContratos.vb @@ -16,6 +16,8 @@ Public Class ClsContratos Private Dataset As DataSet Private SqlTransacc As SqlTransaction Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'REGISTRAR CONEXIONES ABIERTAS + Private CveConexion As Integer = 0 #End Region #Region "Propiedades" @@ -66,7 +68,7 @@ Public Class ClsContratos End If SqlAdapter = New SqlDataAdapter("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(pStrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) @@ -80,7 +82,42 @@ Public Class ClsContratos End Sub #End Region +#Region "Conexiones" + Private Sub ConexionAdd() + If 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 = HttpContext.Current.Request.Url.AbsolutePath.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 + + End If + + End Sub +#End Region #Region "P R O P I E D A D E S - C O N T R A T O S" Public Property CveContrato As Integer @@ -2774,6 +2811,7 @@ Public Class ClsContratos ' 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 diff --git a/App_Code/ClsDG.vb b/App_Code/ClsDG.vb index 4208a3875..c31e234dd 100644 --- a/App_Code/ClsDG.vb +++ b/App_Code/ClsDG.vb @@ -20,6 +20,8 @@ Public Class ClsDG Private Data As DataTable Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'REGISTRAR CONEXIONES ABIERTAS + Private CveConexion As Integer = 0 #End Region #Region "Propiedades" @@ -47,7 +49,7 @@ Public Class ClsDG End If SqlAdapter = New SqlDataAdapter("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlAdapter.SelectCommand @@ -58,7 +60,42 @@ Public Class ClsDG If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc Data = New DataTable End Sub +#Region "Conexiones" + Private Sub ConexionAdd() + If 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 = HttpContext.Current.Request.Url.AbsolutePath.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 + + End If + + End Sub +#End Region Public Function IniciaTransacSQL() As SqlTransaction If SqlTransacc Is Nothing Then SqlTransacc = SqlConexion.BeginTransaction() Return SqlTransacc @@ -611,6 +648,7 @@ Public Class ClsDG Me.disposedValue = True End Sub Public Sub Dispose() Implements IDisposable.Dispose + ConexionClose() Dispose(True) GC.SuppressFinalize(Me) End Sub diff --git a/App_Code/ClsDesarrollo.vb b/App_Code/ClsDesarrollo.vb index 00469a8f7..4cf1f0e9f 100644 --- a/App_Code/ClsDesarrollo.vb +++ b/App_Code/ClsDesarrollo.vb @@ -21,7 +21,8 @@ Public Class ClsDesarrollo 'Atributos de la clase Private disposedValue As Boolean = False ' Para detectar llamadas redundantes - + 'REGISTRAR CONEXIONES ABIERTAS + Private CveConexion As Integer = 0 #End Region #Region "Propiedades" @@ -44,7 +45,7 @@ Public Class ClsDesarrollo Catch ex As Exception Me.OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) End Try - + ConexionAdd() End Sub Private Sub DataAdapter(pStrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) @@ -57,7 +58,42 @@ Public Class ClsDesarrollo End With Data = New DataTable End Sub +#Region "Conexiones" + Private Sub ConexionAdd() + If 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 = HttpContext.Current.Request.Url.AbsolutePath.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 + + End If + + End Sub +#End Region Public Function DesarrolloAddUpdate(CveDesarrollo As Integer, Desarrollo As String, CveEvento As Integer, CveUsuarioResponsable As Integer, CveUsuarioPruebas As Integer, CveModulo As Integer, Descripcion As String, CveUsuarioAsignado As Integer, FechaAsignacion As Date, TiempoEstimado As Integer, CveDesarrolloEstado As Integer, Manual As Integer, CveUsuario As Integer, Optional FechaTermino As Date = Nothing) As Boolean Dim Retorno As Boolean = False @@ -535,6 +571,7 @@ Public Class ClsDesarrollo ' 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 diff --git a/App_Code/ClsEdoc.vb b/App_Code/ClsEdoc.vb index 35a71d6ff..69ab4f6d8 100644 --- a/App_Code/ClsEdoc.vb +++ b/App_Code/ClsEdoc.vb @@ -17,6 +17,8 @@ Public Class ClsEdoc Private Data As DataTable Private DSet As New DataSet Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'REGISTRAR CONEXIONES ABIERTAS + Private CveConexion As Integer = 0 Private Sub SqlDataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlAdapter.SelectCommand @@ -29,7 +31,42 @@ Public Class ClsEdoc End If Data = New DataTable End Sub +#Region "Conexiones" + Private Sub ConexionAdd() + If 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 = HttpContext.Current.Request.Url.AbsolutePath.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 + + End If + + End Sub +#End Region Public Function IniciaTransacSQL() As SqlTransaction If SqlTransacc Is Nothing Then SqlTransacc = SqlConexion.BeginTransaction() Return SqlTransacc @@ -62,7 +99,7 @@ Public Class ClsEdoc Catch ex As Exception OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex) End Try - + ConexionAdd() End Sub Private Sub DataAdapter(pStrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlAdapter.SelectCommand @@ -285,6 +322,7 @@ Public Class ClsEdoc ' 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 diff --git a/App_Code/ClsEdocumentacion.vb b/App_Code/ClsEdocumentacion.vb index 1e3d38a74..d8c97c356 100644 --- a/App_Code/ClsEdocumentacion.vb +++ b/App_Code/ClsEdocumentacion.vb @@ -17,6 +17,8 @@ Public Class ClsEdocumentacion Private Data As DataTable Private DSet As New DataSet Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'REGISTRAR CONEXIONES ABIERTAS + Private CveConexion As Integer = 0 Private Sub SqlDataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlAdapter.SelectCommand @@ -57,7 +59,7 @@ Public Class ClsEdocumentacion End If SqlAdapter = New SqlDataAdapter("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlAdapter.SelectCommand @@ -68,7 +70,42 @@ Public Class ClsEdocumentacion If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc Data = New DataTable End Sub +#Region "Conexiones" + Private Sub ConexionAdd() + If 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 = HttpContext.Current.Request.Url.AbsolutePath.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 + + End If + + End Sub +#End Region Public Function IniciaTransacSQL() As SqlTransaction If SqlTransacc Is Nothing Then SqlTransacc = SqlConexion.BeginTransaction() Return SqlTransacc @@ -464,6 +501,7 @@ Public Class ClsEdocumentacion ' 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 diff --git a/App_Code/ClsEdosFinancieros.vb b/App_Code/ClsEdosFinancieros.vb index fe564e6c5..36f2f5eba 100644 --- a/App_Code/ClsEdosFinancieros.vb +++ b/App_Code/ClsEdosFinancieros.vb @@ -14,6 +14,8 @@ Public Class ClsEdosFinancieros Private SqlAdapter As SqlDataAdapter = Nothing Private SqlCommand As SqlCommand = Nothing Private disposedValue As Boolean = False ' To detect redundant calls + 'REGISTRAR CONEXIONES ABIERTAS + Private CveConexion As Integer = 0 Public ReadOnly Property Data As DataTable Get @@ -37,7 +39,7 @@ Public Class ClsEdosFinancieros Catch ex As Exception Me.OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex) End Try - + ConexionAdd() End Sub Sub New(Empresa As Empresa) @@ -54,9 +56,52 @@ Public Class ClsEdosFinancieros Catch ex As Exception Me.OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex) End Try + ConexionAdd() + End Sub +#Region "Conexiones" + Private Sub ConexionAdd() + If 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 = HttpContext.Current.Request.Url.AbsolutePath.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 + + End If + + 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 + DT = New DataTable + End Sub +#End Region Private Sub SqlDataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.Text) With SqlAdapter.SelectCommand .Parameters.Clear() @@ -854,6 +899,7 @@ Public Class ClsEdosFinancieros ' 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(ByVal disposing As Boolean) above. + ConexionClose() Dispose(True) GC.SuppressFinalize(Me) End Sub diff --git a/App_Code/ClsEncuestas.vb b/App_Code/ClsEncuestas.vb index fccbc5790..17f27cfe2 100644 --- a/App_Code/ClsEncuestas.vb +++ b/App_Code/ClsEncuestas.vb @@ -15,6 +15,8 @@ Public Class ClsEncuestas Private Data As DataTable Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'REGISTRAR CONEXIONES ABIERTAS + Private CveConexion As Integer = 0 Public ReadOnly Property DtResultados() As DataTable Get @@ -40,7 +42,7 @@ Public Class ClsEncuestas End If SqlAdapter = New SqlDataAdapter("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlAdapter.SelectCommand @@ -51,6 +53,42 @@ Public Class ClsEncuestas If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc Data = New DataTable End Sub +#Region "Conexiones" + + Private Sub ConexionAdd() + If 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 = HttpContext.Current.Request.Url.AbsolutePath.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 + + End If + + End Sub +#End Region Public Function IniciaTransacSQL() As SqlTransaction If SqlTransacc Is Nothing Then SqlTransacc = SqlConexion.BeginTransaction() Return SqlTransacc @@ -673,6 +711,7 @@ Public Class ClsEncuestas Me.disposedValue = True End Sub Public Sub Dispose() Implements IDisposable.Dispose + ConexionClose() Dispose(True) GC.SuppressFinalize(Me) End Sub diff --git a/App_Code/ClsEsquemasComisiones.vb b/App_Code/ClsEsquemasComisiones.vb index 1ab47954f..2ad0b76f3 100644 --- a/App_Code/ClsEsquemasComisiones.vb +++ b/App_Code/ClsEsquemasComisiones.vb @@ -30,6 +30,8 @@ Public Class ClsEsquemasComisiones 'Atributos de la clase Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'REGISTRAR CONEXIONES ABIERTAS + Private CveConexion As Integer = 0 #End Region @@ -62,7 +64,7 @@ Public Class ClsEsquemasComisiones End If SqlAdapter = New SqlDataAdapter("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(ByVal pStrSQL As String, Optional ByVal TipoComando As CommandType = CommandType.StoredProcedure) With SqlAdapter.SelectCommand @@ -73,6 +75,42 @@ Public Class ClsEsquemasComisiones If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc Data = New DataTable End Sub +#Region "Conexiones" + + Private Sub ConexionAdd() + If 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 = HttpContext.Current.Request.Url.AbsolutePath.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 + + End If + + End Sub +#End Region #Region "ESQUEMAS COMISIONES" Public Function GetEsquemaComisiones(CveEsquemaComision As Integer, EsquemaComision As String, CveUsuario As Integer, CveEmpresa As Integer) As Boolean @@ -485,6 +523,7 @@ Public Class ClsEsquemasComisiones ' 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 diff --git a/App_Code/ClsEstatusFactura.vb b/App_Code/ClsEstatusFactura.vb index 39515686d..b632a68d5 100644 --- a/App_Code/ClsEstatusFactura.vb +++ b/App_Code/ClsEstatusFactura.vb @@ -17,6 +17,8 @@ Public Class ClsEstatusFactura Private SqlTransacc As SqlTransaction Private Data As DataTable Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'REGISTRAR CONEXIONES ABIERTAS + Private CveConexion As Integer = 0 #End Region @@ -47,7 +49,7 @@ Public Class ClsEstatusFactura SqlCommand = New SqlCommand("", SqlConexion) SqlAdapter = New SqlDataAdapter("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) @@ -59,7 +61,42 @@ Public Class ClsEstatusFactura If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc Data = New DataTable End Sub +#Region "Conexiones" + Private Sub ConexionAdd() + If 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 = HttpContext.Current.Request.Url.AbsolutePath.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 + + End If + + End Sub +#End Region Private Sub DataCommand(pStrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlCommand .Parameters.Clear() @@ -216,6 +253,7 @@ Public Class ClsEstatusFactura ' 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 diff --git a/App_Code/ClsEventos.vb b/App_Code/ClsEventos.vb index 9a40cc477..7999a927a 100644 --- a/App_Code/ClsEventos.vb +++ b/App_Code/ClsEventos.vb @@ -21,6 +21,8 @@ Public Class ClsEventos 'Atributos de la clase Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'REGISTRAR CONEXIONES ABIERTAS + Private CveConexion As Integer = 0 #End Region @@ -56,7 +58,7 @@ Public Class ClsEventos Catch ex As Exception Me.OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) End Try - + ConexionAdd() End Sub Private Sub DataAdapter(pStrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) @@ -67,6 +69,42 @@ Public Class ClsEventos End With Data = New DataTable End Sub +#Region "Conexiones" + + Private Sub ConexionAdd() + If 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 = HttpContext.Current.Request.Url.AbsolutePath.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 + + End If + + End Sub +#End Region Public Function GetEventos(TipoReferencia As String, Referencia As String, EsMesActual As Boolean, CveUsuario As Integer, CveEmpresa As Integer, EsAgenda As Boolean, CveEvento As Integer) As Boolean Dim Retorno As Boolean = False @@ -209,6 +247,7 @@ Public Class ClsEventos ' 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 diff --git a/App_Code/ClsFISConfiguracion.vb b/App_Code/ClsFISConfiguracion.vb index 0e6da111a..388701a6c 100644 --- a/App_Code/ClsFISConfiguracion.vb +++ b/App_Code/ClsFISConfiguracion.vb @@ -21,7 +21,8 @@ Public Class ClsFISConfiguracion 'Atributos de la clase Private disposedValue As Boolean = False ' Para detectar llamadas redundantes - + 'REGISTRAR CONEXIONES ABIERTAS + Private CveConexion As Integer = 0 #End Region #Region "Propiedades" @@ -49,8 +50,52 @@ Public Class ClsFISConfiguracion Catch ex As Exception Me.OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) End Try + ConexionAdd() + End Sub +#Region "Conexiones" + + Private Sub ConexionAdd() + If 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 = HttpContext.Current.Request.Url.AbsolutePath.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 + + End If 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 + Data = New DataTable + End Sub +#End Region Public Function GetConfiguracion(CveEmpresa As Integer) As Boolean Dim Retorno As Boolean = False @@ -140,6 +185,7 @@ Public Class ClsFISConfiguracion ' 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 diff --git a/App_Code/ClsFinanzas.vb b/App_Code/ClsFinanzas.vb index ccba6fe2f..73f1be43a 100644 --- a/App_Code/ClsFinanzas.vb +++ b/App_Code/ClsFinanzas.vb @@ -21,6 +21,8 @@ Public Class ClsFinanzas 'Atributos de la clase Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'REGISTRAR CONEXIONES ABIERTAS + Private CveConexion As Integer = 0 #End Region @@ -124,7 +126,7 @@ Public Class ClsFinanzas SqlCommand = New SqlCommand("", SqlConexion) SqlAdapter = New SqlDataAdapter("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlAdapter.SelectCommand @@ -135,6 +137,42 @@ Public Class ClsFinanzas If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc Data = New DataTable End Sub +#Region "Conexiones" + + Private Sub ConexionAdd() + If 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 = HttpContext.Current.Request.Url.AbsolutePath.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 + + End If + + End Sub +#End Region Private Sub DataCommand(pStrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlCommand .Parameters.Clear() @@ -174,6 +212,7 @@ Public Class ClsFinanzas End Sub Public Sub Dispose() Implements IDisposable.Dispose + ConexionClose() Dispose(True) GC.SuppressFinalize(Me) End Sub diff --git a/App_Code/ClsFlotillas.vb b/App_Code/ClsFlotillas.vb index 6752c6db1..6bbe24b8b 100644 --- a/App_Code/ClsFlotillas.vb +++ b/App_Code/ClsFlotillas.vb @@ -22,6 +22,8 @@ Public Class ClsFlotillas 'Atributos de la clase Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'REGISTRAR CONEXIONES ABIERTAS + Private CveConexion As Integer = 0 #End Region @@ -66,7 +68,7 @@ Public Class ClsFlotillas SqlCommand = New SqlCommand("", SqlConexion) SqlAdapter = New SqlDataAdapter("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) @@ -78,7 +80,42 @@ Public Class ClsFlotillas If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc Data = New DataTable End Sub +#Region "Conexiones" + Private Sub ConexionAdd() + If 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 = HttpContext.Current.Request.Url.AbsolutePath.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 + + End If + + End Sub +#End Region Private Sub DataCommand(pStrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlCommand .Parameters.Clear() @@ -725,6 +762,7 @@ Public Class ClsFlotillas ' 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 diff --git a/App_Code/ClsGPS.vb b/App_Code/ClsGPS.vb index 74864bd8a..9ff3a3f5e 100644 --- a/App_Code/ClsGPS.vb +++ b/App_Code/ClsGPS.vb @@ -21,6 +21,8 @@ Public Class ClsGPS Private Dataset As DataSet Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'REGISTRAR CONEXIONES ABIERTAS + Private CveConexion As Integer = 0 Public ReadOnly Property DtResultados() As DataTable Get @@ -62,7 +64,7 @@ Public Class ClsGPS End If SqlAdapter = New SqlDataAdapter("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlAdapter.SelectCommand @@ -73,6 +75,42 @@ Public Class ClsGPS If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc Data = New DataTable End Sub +#Region "Conexiones" + + Private Sub ConexionAdd() + If 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 = HttpContext.Current.Request.Url.AbsolutePath.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 + + End If + + End Sub +#End Region Public Function IniciaTransacSQL() As SqlTransaction If SqlTransacc Is Nothing Then SqlTransacc = SqlConexion.BeginTransaction() Return SqlTransacc @@ -5287,6 +5325,7 @@ Public Class ClsGPS ' 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 diff --git a/App_Code/ClsGPSHerramientas.vb b/App_Code/ClsGPSHerramientas.vb index defe49ff4..ce20150d3 100644 --- a/App_Code/ClsGPSHerramientas.vb +++ b/App_Code/ClsGPSHerramientas.vb @@ -16,6 +16,8 @@ Public Class ClsGPSHerramientas Private Data As DataTable Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'REGISTRAR CONEXIONES ABIERTAS + Private CveConexion As Integer = 0 #End Region #Region "Propiedades" @@ -37,7 +39,7 @@ Public Class ClsGPSHerramientas Catch ex As Exception Me.OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex) End Try - + ConexionAdd() End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) @@ -48,6 +50,42 @@ Public Class ClsGPSHerramientas End With Data = New DataTable End Sub +#Region "Conexiones" + + Private Sub ConexionAdd() + If 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 = HttpContext.Current.Request.Url.AbsolutePath.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 + + End If + + End Sub +#End Region #Region "Metodos Generales" Public Sub EjecutarComandoSMS(CveComando As Integer, CveDispositivo As Integer, CveUsuario As Integer, Optional Valor As String = "") @@ -165,6 +203,7 @@ Public Class ClsGPSHerramientas ' 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 diff --git a/App_Code/ClsGenerales.vb b/App_Code/ClsGenerales.vb index a788434d3..08640bd0a 100644 --- a/App_Code/ClsGenerales.vb +++ b/App_Code/ClsGenerales.vb @@ -17,6 +17,8 @@ Public Class ClsGenerales Private SqlTransacc As SqlTransaction Private Data As DataTable Private disposedValue As Boolean = False + 'REGISTRAR CONEXIONES ABIERTAS + Private CveConexion As Integer = 0 #End Region #Region "Propiedades" @@ -75,7 +77,7 @@ Public Class ClsGenerales End If SqlAdapter = New SqlDataAdapter("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(ByVal pStrSQL As String, Optional ByVal TipoComando As CommandType = CommandType.StoredProcedure) With SqlAdapter.SelectCommand @@ -86,6 +88,42 @@ Public Class ClsGenerales Data = New DataTable If SqlTransacc IsNot Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc End Sub +#Region "Conexiones" + + Private Sub ConexionAdd() + If 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 = HttpContext.Current.Request.Url.AbsolutePath.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 + + End If + + End Sub +#End Region Private Sub DataCommand(ByVal pStrSQL As String, Optional ByVal TipoComando As CommandType = CommandType.StoredProcedure) With SqlCommand @@ -2882,6 +2920,7 @@ Public Class ClsGenerales ' 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 diff --git a/App_Code/ClsGralFolios.vb b/App_Code/ClsGralFolios.vb index 2a3b8f061..db2be89cd 100644 --- a/App_Code/ClsGralFolios.vb +++ b/App_Code/ClsGralFolios.vb @@ -32,6 +32,8 @@ Public Class ClsGralFolios Private _FechaIng As Date Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'REGISTRAR CONEXIONES ABIERTAS + Private CveConexion As Integer = 0 #End Region @@ -73,7 +75,7 @@ Public Class ClsGralFolios End If SqlAdapter = New SqlDataAdapter("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(pStrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) @@ -85,6 +87,42 @@ Public Class ClsGralFolios Data = New DataTable If SqlTransacc IsNot Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc End Sub +#Region "Conexiones" + + Private Sub ConexionAdd() + If 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 = HttpContext.Current.Request.Url.AbsolutePath.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 + + End If + + End Sub +#End Region Public Function GetFolios(Optional TipoDocto As String = "-1", Optional CveEmpresa As Integer = -1) As Boolean Dim Retorno As Boolean = False @@ -257,6 +295,7 @@ Public Class ClsGralFolios ' 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 diff --git a/App_Code/ClsGralProductosServiciosCaracteristicas.vb b/App_Code/ClsGralProductosServiciosCaracteristicas.vb index cfa702a91..aaa5c858e 100644 --- a/App_Code/ClsGralProductosServiciosCaracteristicas.vb +++ b/App_Code/ClsGralProductosServiciosCaracteristicas.vb @@ -16,6 +16,8 @@ Public Class ClsGralProductosServiciosCaracteristicas Private SqlTransacc As SqlTransaction Private Data As DataTable Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'REGISTRAR CONEXIONES ABIERTAS + Private CveConexion As Integer = 0 #End Region #Region "Propiedades" @@ -48,7 +50,7 @@ Public Class ClsGralProductosServiciosCaracteristicas Catch ex As Exception OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex) End Try - + ConexionAdd() End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) @@ -60,7 +62,42 @@ Public Class ClsGralProductosServiciosCaracteristicas Data = New DataTable End Sub +#Region "Conexiones" + Private Sub ConexionAdd() + If 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 = HttpContext.Current.Request.Url.AbsolutePath.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 + + End If + + End Sub +#End Region #Region "ProductosServiciosCaracteristicas" Public Function GetProductosServiciosCaracteristicas(Optional CveEmpresa As Integer = -1, Optional CveSubProyecto As Integer = -1) As Boolean @@ -285,6 +322,7 @@ Public Class ClsGralProductosServiciosCaracteristicas ' 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 diff --git a/App_Code/ClsImpuestos.vb b/App_Code/ClsImpuestos.vb index 91f688677..453ecd832 100644 --- a/App_Code/ClsImpuestos.vb +++ b/App_Code/ClsImpuestos.vb @@ -20,6 +20,8 @@ Public Class ClsImpuestos Private Data As DataTable Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'REGISTRAR CONEXIONES ABIERTAS + Private CveConexion As Integer = 0 #End Region #Region "Propiedades" @@ -45,7 +47,7 @@ Public Class ClsImpuestos End If SqlAdapter = New SqlDataAdapter("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlAdapter.SelectCommand @@ -56,6 +58,42 @@ Public Class ClsImpuestos If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc Data = New DataTable End Sub +#Region "Conexiones" + + Private Sub ConexionAdd() + If 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 = HttpContext.Current.Request.Url.AbsolutePath.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 + + End If + + End Sub +#End Region Public Function IniciaTransacSQL() As SqlTransaction If SqlTransacc Is Nothing Then SqlTransacc = SqlConexion.BeginTransaction() @@ -118,6 +156,7 @@ Public Class ClsImpuestos Me.disposedValue = True End Sub Public Sub Dispose() Implements IDisposable.Dispose + ConexionClose() Dispose(True) GC.SuppressFinalize(Me) End Sub diff --git a/App_Code/ClsIndicadores.vb b/App_Code/ClsIndicadores.vb index 8a7f1c0b5..f15fdb4cf 100644 --- a/App_Code/ClsIndicadores.vb +++ b/App_Code/ClsIndicadores.vb @@ -18,6 +18,8 @@ Public Class ClsIndicadores Private Data As DataTable 'Atributos de la clase Private disposedValue As Boolean = False + 'REGISTRAR CONEXIONES ABIERTAS + Private CveConexion As Integer = 0 #End Region @@ -49,7 +51,7 @@ Public Class ClsIndicadores SqlCommand = New SqlCommand("", SqlConexion) SqlAdapter = New SqlDataAdapter("", SqlConexion) StrSQL = New StringBuilder - + ConexionAdd() End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlAdapter.SelectCommand @@ -60,6 +62,42 @@ Public Class ClsIndicadores If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc Data = New DataTable End Sub +#Region "Conexiones" + + Private Sub ConexionAdd() + If 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 = HttpContext.Current.Request.Url.AbsolutePath.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 + + End If + + End Sub +#End Region Private Sub DataCommand(pStrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlCommand .Parameters.Clear() @@ -107,6 +145,7 @@ Public Class ClsIndicadores ' 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 diff --git a/App_Code/ClsInventarios.vb b/App_Code/ClsInventarios.vb index 270e9143a..e5b2e1482 100644 --- a/App_Code/ClsInventarios.vb +++ b/App_Code/ClsInventarios.vb @@ -16,6 +16,9 @@ Public Class ClsInventarios Private Data As DataTable Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'REGISTRAR CONEXIONES ABIERTAS + Private CveConexion As Integer = 0 + #End Region @@ -147,7 +150,7 @@ Public Class ClsInventarios End If SqlAdapter = New SqlDataAdapter("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(pStrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) @@ -159,7 +162,42 @@ Public Class ClsInventarios If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc Data = New DataTable End Sub +#Region "Conexiones" + Private Sub ConexionAdd() + If 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 = HttpContext.Current.Request.Url.AbsolutePath.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 + + End If + + End Sub +#End Region #Region " INVENTARIOS - CONCEPTOS " @@ -4652,6 +4690,7 @@ Public Class ClsInventarios ' 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 diff --git a/App_Code/ClsLeyendasFiscales.vb b/App_Code/ClsLeyendasFiscales.vb index 19b239e55..03a598f33 100644 --- a/App_Code/ClsLeyendasFiscales.vb +++ b/App_Code/ClsLeyendasFiscales.vb @@ -20,6 +20,8 @@ Public Class ClsLeyendasFiscales 'Atributos de la clase Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'REGISTRAR CONEXIONES ABIERTAS + Private CveConexion As Integer = 0 #End Region @@ -39,8 +41,53 @@ Public Class ClsLeyendasFiscales Catch ex As Exception Me.OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) End Try + SqlAdapter = New SqlDataAdapter("PA_LeyendasFiscalesGet", SqlConexion) + ConexionAdd() + End Sub +#Region "Conexiones" + + Private Sub ConexionAdd() + If 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 = HttpContext.Current.Request.Url.AbsolutePath.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 + + End If End Sub + Private Sub DataAdapter(pStrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) + With SqlAdapter.SelectCommand + .Parameters.Clear() + .CommandText = pStrSQL + .CommandType = TipoComando + End With + Data = New DataTable + End Sub +#End Region Public Function GetLeyendasFiscales() As Boolean Dim Retorno As Boolean = False @@ -167,6 +214,7 @@ Public Class ClsLeyendasFiscales ' 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 diff --git a/App_Code/ClsMF.vb b/App_Code/ClsMF.vb index a9d10026a..83e126cda 100644 --- a/App_Code/ClsMF.vb +++ b/App_Code/ClsMF.vb @@ -15,7 +15,8 @@ Public Class ClsMF Private SqlCommand As SqlCommand Private SqlTransacc As SqlTransaction Private Data As DataTable - + 'REGISTRAR CONEXIONES ABIERTAS + Private CveConexion As Integer = 0 Public ReadOnly Property DtResultados() As DataTable @@ -46,7 +47,7 @@ Public Class ClsMF End If SqlAdapter = New SqlDataAdapter("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlAdapter.SelectCommand @@ -57,6 +58,42 @@ Public Class ClsMF If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc Data = New DataTable End Sub +#Region "Conexiones" + + Private Sub ConexionAdd() + If 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 = HttpContext.Current.Request.Url.AbsolutePath.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 + + End If + + End Sub +#End Region Public Function IniciaTransacSQL() As SqlTransaction If SqlTransacc Is Nothing Then SqlTransacc = SqlConexion.BeginTransaction() Return SqlTransacc @@ -683,6 +720,7 @@ Public Class ClsMF Me.disposedValue = True End Sub Public Sub Dispose() Implements IDisposable.Dispose + ConexionClose() Dispose(True) GC.SuppressFinalize(Me) End Sub diff --git a/App_Code/ClsMetodosPagos.vb b/App_Code/ClsMetodosPagos.vb index 8f94a9b34..712e23378 100644 --- a/App_Code/ClsMetodosPagos.vb +++ b/App_Code/ClsMetodosPagos.vb @@ -20,6 +20,8 @@ Public Class ClsMetodosPagos 'Atributos de la clase Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'REGISTRAR CONEXIONES ABIERTAS + Private CveConexion As Integer = 0 #End Region @@ -41,9 +43,53 @@ Public Class ClsMetodosPagos Catch ex As Exception Me.OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) End Try + SqlAdapter = New SqlDataAdapter("", SqlConexion) + ConexionAdd() + End Sub +#Region "Conexiones" + Private Sub ConexionAdd() + If 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 = HttpContext.Current.Request.Url.AbsolutePath.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 + + End If + + End Sub + Private Sub DataAdapter(pStrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) + With SqlAdapter.SelectCommand + .Parameters.Clear() + .CommandText = pStrSQL + .CommandType = TipoComando + End With + Data = New DataTable + End Sub +#End Region Public Function GetMetodosPago() As Boolean Dim Retorno As Boolean = False Data = New DataTable @@ -90,6 +136,7 @@ Public Class ClsMetodosPagos ' 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 diff --git a/App_Code/ClsModulos.vb b/App_Code/ClsModulos.vb index d3acd63a6..a873b9d5a 100644 --- a/App_Code/ClsModulos.vb +++ b/App_Code/ClsModulos.vb @@ -36,6 +36,8 @@ Public Class ClsModulos Private _CvePlataforma As String Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'REGISTRAR CONEXIONES ABIERTAS + Private CveConexion As Integer = 0 #End Region #Region "Propiedades" @@ -142,7 +144,7 @@ Public Class ClsModulos End Try SqlAdapter = New SqlDataAdapter("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(pStrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) @@ -154,7 +156,42 @@ Public Class ClsModulos Data = New DataTable End Sub +#Region "Conexiones" + Private Sub ConexionAdd() + If 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 = HttpContext.Current.Request.Url.AbsolutePath.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 + + End If + + End Sub +#End Region Public Function GetModulos(CveModulo As Integer, CvePadre As Integer, Descripcion As String, DescripcionLike As String) As Boolean Dim OnError As Boolean = False Data = New DataTable @@ -392,6 +429,7 @@ Public Class ClsModulos ' 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 ( que se dispone como Boolean). + ConexionClose() Dispose(True) GC.SuppressFinalize(Me) End Sub diff --git a/App_Code/ClsMonedas.vb b/App_Code/ClsMonedas.vb index 1fec9696c..749f1b55b 100644 --- a/App_Code/ClsMonedas.vb +++ b/App_Code/ClsMonedas.vb @@ -19,6 +19,8 @@ Public Class ClsMonedas 'Atributos de la clase Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'REGISTRAR CONEXIONES ABIERTAS + Private CveConexion As Integer = 0 #End Region @@ -47,7 +49,7 @@ Public Class ClsMonedas End If SqlAdapter = New SqlDataAdapter("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(pStrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) @@ -59,7 +61,42 @@ Public Class ClsMonedas Data = New DataTable ' If SqlTransacc IsNot Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc End Sub +#Region "Conexiones" + Private Sub ConexionAdd() + If 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 = HttpContext.Current.Request.Url.AbsolutePath.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 + + End If + + End Sub +#End Region Public Function GetMonedas() As Boolean Dim Retorno As Boolean = False DataAdapter("PA_MonedasGet") @@ -120,6 +157,7 @@ Public Class ClsMonedas ' 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 diff --git a/App_Code/ClsMovimientos.vb b/App_Code/ClsMovimientos.vb index 9499f7fe2..04c1e542c 100644 --- a/App_Code/ClsMovimientos.vb +++ b/App_Code/ClsMovimientos.vb @@ -20,6 +20,8 @@ Public Class ClsMovimientos 'Atributos de la clase Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'REGISTRAR CONEXIONES ABIERTAS + Private CveConexion As Integer = 0 #End Region @@ -42,7 +44,7 @@ Public Class ClsMovimientos Catch ex As Exception Me.OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) End Try - + ConexionAdd() End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) @@ -54,6 +56,42 @@ Public Class ClsMovimientos If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc Data = New DataTable End Sub +#Region "Conexiones" + + Private Sub ConexionAdd() + If 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 = HttpContext.Current.Request.Url.AbsolutePath.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 + + End If + + End Sub +#End Region Public Sub IniciaTransacSQL() SqlTransacc = SqlConexion.BeginTransaction() @@ -1688,6 +1726,7 @@ Public Class ClsMovimientos ' 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 diff --git a/App_Code/ClsNominas.vb b/App_Code/ClsNominas.vb index d628856c3..afe153290 100644 --- a/App_Code/ClsNominas.vb +++ b/App_Code/ClsNominas.vb @@ -13,6 +13,14 @@ Public Class ClsNominas Private SqlTransacc As SqlTransaction Private Data As DataTable Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + Protected DTSet As DataSet + + Public ReadOnly Property DTSetResultados() As DataSet + Get + Return DTSet + End Get + End Property 'REGISTRAR CONEXIONES ABIERTAS + Private CveConexion As Integer = 0 #End Region #Region "Propiedades ClsNominas_Nominas" @@ -96,7 +104,7 @@ Public Class ClsNominas Catch ex As Exception OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex) End Try - + ConexionAdd() End Sub Sub New(Optional TransaccionCompartida As SqlTransaction = Nothing) @@ -114,7 +122,7 @@ Public Class ClsNominas End If SqlAdapter = New SqlDataAdapter("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(pStrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlAdapter.SelectCommand @@ -125,6 +133,42 @@ Public Class ClsNominas Data = New DataTable If SqlTransacc IsNot Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc End Sub +#Region "Conexiones" + + Private Sub ConexionAdd() + If 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 = HttpContext.Current.Request.Url.AbsolutePath.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 + + End If + + End Sub +#End Region #Region "ClsNominas_Nominas" @@ -726,6 +770,20 @@ Public Class ClsNominas #End Region #Region "ClsNominasConceptos" + + Public Function GetNom_Refencias() As Boolean + Dim retorno As Boolean = False + DataAdapter("SELECT CveNomReferencia,CveNomReferenciaPadre,Nivel,Texto,Campo,Tipo,IIF(EsUltimo=0,0,1) EsUltimo FROM [dbo].[Nom_Referencia] WHERE Estatus =1 ORDER BY Nivel ASC,CveNomReferencia ", CommandType.Text) + + Try + SqlAdapter.Fill(Data) + retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el o los conceptos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return retorno + End Function + Public Function GetConceptos(CveEmpresa As Integer, Optional CveTipo As String = "-1", Optional CveEstado As Integer = -1, Optional CveTipoGasto As Integer = -1, Optional CveConcepto As Integer = -1) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Nom_ConceptosGet") @@ -1717,6 +1775,59 @@ Public Class ClsNominas End Function #End Region + + Public Function AddUPNom_NominasDetalles(CveNomina As Integer, CvePeriodo As Integer, CvePersonal As Integer, CveConcepto As Integer, Importe As Decimal, ImporteGravado As Decimal, ImporteExento As Decimal, CveUsuario As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Nom_NominasDetallesAddUP") + + With SqlAdapter.SelectCommand.Parameters + .Add("CveNomina", SqlDbType.Int).Value = CveNomina + .Add("CvePeriodo", SqlDbType.Int).Value = CvePeriodo + .Add("CvePersonal", SqlDbType.Int).Value = CvePersonal + .Add("CveConcepto", SqlDbType.Int).Value = CveConcepto + .Add("Importe", SqlDbType.Float).Value = Importe + .Add("ImporteGravado", SqlDbType.Float).Value = ImporteGravado + .Add("ImporteExento", SqlDbType.Float).Value = ImporteExento + .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 Movimiento de Nomina.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetNominaEmpleado(CveProyecto As Integer, CveSubProyecto As Integer, CveTurno As Integer, CvePeriodo As Integer, CveEmpresa As Integer, Agrupador As Integer) As Boolean + Dim retorno As Boolean = False + Try + DataAdapter("PA_Nom_NominaEmpleado", CommandType.StoredProcedure) + With SqlAdapter.SelectCommand.Parameters + .Add("@CveProyecto", SqlDbType.Int).Value = CveProyecto + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveTurno", SqlDbType.Int).Value = CveTurno + .Add("@CvePeriodo", SqlDbType.Int).Value = CvePeriodo + .Add("@Agrupador", SqlDbType.VarChar).Value = Agrupador + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + + SqlAdapter.Fill(DTSet) + retorno = True + Catch sqEx As SqlException + retorno = False + OnError("Ocurrió un error al Realizar el calculo de utilidades.", sqEx, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + Catch ex As Exception + retorno = False + OnError("Ocurrió un error al Realizar el calculo de utilidades.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return retorno + End Function + #Region "IDisposable Support" ' IDisposable Protected Overridable Sub Dispose(ByVal disposing As Boolean) @@ -1733,6 +1844,7 @@ Public Class ClsNominas disposedValue = True End Sub Public Sub Dispose() Implements IDisposable.Dispose + ConexionClose() Dispose(True) GC.SuppressFinalize(Me) End Sub diff --git a/App_Code/ClsOC.vb b/App_Code/ClsOC.vb index c3ac9355d..fce2ade3e 100644 --- a/App_Code/ClsOC.vb +++ b/App_Code/ClsOC.vb @@ -16,7 +16,8 @@ Public Class ClsOC Private Data As DataTable 'Atributos de la clase Private disposedValue As Boolean = False - + 'PARA REGISTRAR CONEXION + Private CveConexion As Integer = 0 #End Region @@ -167,7 +168,7 @@ Public Class ClsOC SqlCommand = New SqlCommand("", SqlConexion) SqlAdapter = New SqlDataAdapter("", SqlConexion) StrSQL = New StringBuilder - + ConexionAdd() End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlAdapter.SelectCommand @@ -178,6 +179,45 @@ Public Class ClsOC If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc Data = New DataTable End Sub +#Region "Conexiones" + + Private Sub ConexionAdd() + If ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + + '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 + + 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) + CveConexion = 0 + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + + End Sub +#End Region Private Sub DataCommand(pStrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlCommand .Parameters.Clear() @@ -2481,6 +2521,7 @@ Public Class ClsOC disposedValue = True End Sub Public Sub Dispose() Implements IDisposable.Dispose + ConexionClose() Dispose(True) GC.SuppressFinalize(Me) End Sub diff --git a/App_Code/ClsOIEventos.vb b/App_Code/ClsOIEventos.vb index d5cb92c8e..6d875be92 100644 --- a/App_Code/ClsOIEventos.vb +++ b/App_Code/ClsOIEventos.vb @@ -16,6 +16,8 @@ Public Class ClsOIEventos Private SqlCommand As SqlCommand Private Data As DataTable Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'PARA REGISTRAR CONEXION + Private CveConexion As Integer = 0 #End Region #Region "Propiedades" @@ -109,7 +111,7 @@ Public Class ClsOIEventos SqlCommand = New SqlCommand("", SqlConexion) SqlAdapter = New SqlDataAdapter("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlAdapter.SelectCommand @@ -120,6 +122,45 @@ Public Class ClsOIEventos Data = New DataTable If SqlTransacc IsNot Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc End Sub +#Region "Conexiones" + + Private Sub ConexionAdd() + If ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + + '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 + + 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) + CveConexion = 0 + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + + End Sub +#End Region Public Sub IniciaTransacSQL() SqlTransacc = SqlConexion.BeginTransaction() End Sub @@ -1339,6 +1380,7 @@ Public Class ClsOIEventos ' 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 diff --git a/App_Code/ClsOS.vb b/App_Code/ClsOS.vb index 06cdedb50..f8348c05a 100644 --- a/App_Code/ClsOS.vb +++ b/App_Code/ClsOS.vb @@ -15,6 +15,8 @@ Public Class ClsOS Private Data As DataTable 'Atributos de la clase Private disposedValue As Boolean = False + 'PARA REGISTRAR CONEXION + Private CveConexion As Integer = 0 #End Region @@ -98,7 +100,7 @@ Public Class ClsOS SqlCommand = New SqlCommand("", SqlConexion) SqlAdapter = New SqlDataAdapter("", SqlConexion) StrSQL = New StringBuilder - + ConexionAdd() End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlAdapter.SelectCommand @@ -109,6 +111,45 @@ Public Class ClsOS If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc Data = New DataTable End Sub +#Region "Conexiones" + + Private Sub ConexionAdd() + If 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) + CveConexion = 0 + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + + End Sub +#End Region Private Sub DataCommand(pStrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlCommand .Parameters.Clear() @@ -1632,6 +1673,7 @@ Public Class ClsOS ' 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 diff --git a/App_Code/ClsPV.vb b/App_Code/ClsPV.vb index cf21fe045..2d882e6ec 100644 --- a/App_Code/ClsPV.vb +++ b/App_Code/ClsPV.vb @@ -21,6 +21,8 @@ Public Class ClsPV 'Atributos de la clase Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'PARA REGISTRAR CONEXION + Private CveConexion As Integer = 0 #End Region @@ -64,7 +66,7 @@ Public Class ClsPV End If SqlAdapter = New SqlDataAdapter("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(ByVal pStrSQL As String, Optional ByVal TipoComando As CommandType = CommandType.StoredProcedure) @@ -76,7 +78,44 @@ Public Class ClsPV If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc Data = New DataTable End Sub +#Region "Conexiones" + Private Sub ConexionAdd() + If 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) + CveConexion = 0 + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + + End Sub +#End Region 'Reporte de Ventas Public Function GetRepPVVentas(FechaI As String, FechaF As String, FechaIEjec As String, FechaFEjec As String, CveCliente As Integer, CveSubProyecto As Integer, CveSubProyectoEjecucion As Integer, @@ -193,6 +232,7 @@ Public Class ClsPV ' 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 diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index 653c048d5..e498feb95 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -4124,7 +4124,7 @@ Public Class ClsPaginas PaginaDict.Add("/Nomina/CatSatRegimenContratacion.aspx".ToUpper(), 257) PaginaDict.Add("/Nomina/CatSatTipoIncapacidad.aspx".ToUpper(), 258) PaginaDict.Add("/Nomina/CatSatRiesgoPuesto.aspx".ToUpper(), 259) - PaginaDict.Add("/Nomina/Utilidades.aspx".ToUpper(), 870) + PaginaDict.Add("/Nomina/ReportePTU.aspx".ToUpper(), 870) #End Region 'Ordenes de Servicios #Region "OS" diff --git a/App_Code/ClsPresupuestos.vb b/App_Code/ClsPresupuestos.vb index 1b7e07982..130490b48 100644 --- a/App_Code/ClsPresupuestos.vb +++ b/App_Code/ClsPresupuestos.vb @@ -21,6 +21,8 @@ Public Class ClsPresupuestos 'Atributos de la clase Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'PARA REGISTRAR CONEXION + Private CveConexion As Integer = 0 #End Region @@ -64,7 +66,7 @@ Public Class ClsPresupuestos End If SqlAdapter = New SqlDataAdapter("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(pStrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) @@ -78,7 +80,45 @@ Public Class ClsPresupuestos End Sub #End Region +#Region "Conexiones" + Private Sub ConexionAdd() + If 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) + CveConexion = 0 + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + + End Sub +#End Region #Region "P R E S U P U E S T O S - P R O D U C T O S - D E T A L L E S" Public Function GetPresupuestosDetalleProductos(CvePresupuestoDetalle As Integer) As Boolean @@ -732,6 +772,7 @@ Public Class ClsPresupuestos ' 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 diff --git a/App_Code/ClsProductosServicios.vb b/App_Code/ClsProductosServicios.vb index c94f491b2..4b7653fbc 100644 --- a/App_Code/ClsProductosServicios.vb +++ b/App_Code/ClsProductosServicios.vb @@ -18,6 +18,9 @@ Public Class ClsProductosServicios Private SqlTransacc As SqlTransaction Private Data As DataTable Private disposedValue As Boolean = False + 'PARA REGISTRAR CONEXION + Private CveConexion As Integer = 0 + #End Region #Region "Propiedades" @@ -113,7 +116,7 @@ Public Class ClsProductosServicios Catch ex As Exception OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex) End Try - + ConexionAdd() End Sub @@ -145,7 +148,7 @@ Public Class ClsProductosServicios End If SqlAdapter = New SqlDataAdapter("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlAdapter.SelectCommand @@ -156,6 +159,45 @@ Public Class ClsProductosServicios If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc Data = New DataTable End Sub +#Region "Conexiones" + + Private Sub ConexionAdd() + If 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) + CveConexion = 0 + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + 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") As Boolean Dim Retorno As Boolean = False diff --git a/App_Code/ClsProsEncuestas.vb b/App_Code/ClsProsEncuestas.vb index a337e00f3..2271cb05b 100644 --- a/App_Code/ClsProsEncuestas.vb +++ b/App_Code/ClsProsEncuestas.vb @@ -17,6 +17,8 @@ Public Class ClsProsEncuestas Private disposedValue As Boolean = False ' Para detectar llamadas redundantes Private StrSQL As StringBuilder + 'PARA REGISTRAR CONEXION + Private CveConexion As Integer = 0 #End Region #Region "Propiedades" @@ -48,7 +50,7 @@ Public Class ClsProsEncuestas End If SqlAdapter = New SqlDataAdapter("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) @@ -60,7 +62,44 @@ Public Class ClsProsEncuestas If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc Data = New DataTable End Sub +#Region "Conexiones" + Private Sub ConexionAdd() + If 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) + CveConexion = 0 + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + + End Sub +#End Region Public Function IniciaTransacSQL() As SqlTransaction If SqlTransacc Is Nothing Then SqlTransacc = SqlConexion.BeginTransaction() Return SqlTransacc @@ -752,6 +791,7 @@ Public Class ClsProsEncuestas ' 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 diff --git a/App_Code/ClsProspectos.vb b/App_Code/ClsProspectos.vb index 6bd8eb740..eeabe87ff 100644 --- a/App_Code/ClsProspectos.vb +++ b/App_Code/ClsProspectos.vb @@ -16,6 +16,8 @@ Public Class ClsProspectos Private Data As DataTable Private StrSQL As StringBuilder Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'PARA REGISTRAR CONEXION + Private CveConexion As Integer = 0 #End Region #Region "Propiedades" @@ -161,7 +163,7 @@ Public Class ClsProspectos End If SqlAdapter = New SqlDataAdapter("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(pStrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) @@ -173,6 +175,44 @@ Public Class ClsProspectos Data = New DataTable If SqlTransacc IsNot Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc End Sub +#Region "Conexiones" + + Private Sub ConexionAdd() + If 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) + CveConexion = 0 + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + + End Sub +#End Region #Region "Prospectos" Public Function GetNext() As Boolean @@ -4591,6 +4631,7 @@ Public Class ClsProspectos ' 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 diff --git a/App_Code/ClsProyectos.vb b/App_Code/ClsProyectos.vb index 47e176c0a..c9275c51b 100644 --- a/App_Code/ClsProyectos.vb +++ b/App_Code/ClsProyectos.vb @@ -23,6 +23,8 @@ Public Class ClsProyectos 'Atributos de la clase Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'PARA REGISTRAR CONEXION + Private CveConexion As Integer = 0 #End Region @@ -55,7 +57,7 @@ Public Class ClsProyectos SqlCommand = New SqlCommand("", SqlConexion) SqlAdapter = New SqlDataAdapter("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlAdapter.SelectCommand @@ -66,6 +68,44 @@ Public Class ClsProyectos If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc Data = New DataTable End Sub +#Region "Conexiones" + + Private Sub ConexionAdd() + If 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) + CveConexion = 0 + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + + End Sub +#End Region Private Sub DataCommand(pStrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlCommand .Parameters.Clear() @@ -210,6 +250,7 @@ Public Class ClsProyectos ' 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 diff --git a/App_Code/ClsPruebasJJMQ.vb b/App_Code/ClsPruebasJJMQ.vb index 3cbc168a2..2fcd9c0b4 100644 --- a/App_Code/ClsPruebasJJMQ.vb +++ b/App_Code/ClsPruebasJJMQ.vb @@ -18,6 +18,8 @@ Public Class ClsPruebasJJMQ Private StrSQL As StringBuilder Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'PARA REGISTRAR CONEXION + Private CveConexion As Integer = 0 #End Region @@ -47,6 +49,7 @@ Public Class ClsPruebasJJMQ SqlAdapter = New SqlDataAdapter("", SqlConexion) StrSQL = New StringBuilder + ConexionAdd() End Sub Private Sub SqlDataAdapter(pStrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) @@ -58,7 +61,44 @@ Public Class ClsPruebasJJMQ If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc Data = New DataTable End Sub +#Region "Conexiones" + Private Sub ConexionAdd() + If 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 + SqlDataAdapter("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 + + SqlDataAdapter(String.Format("UPDATE Sis_Conexiones SET FechaCierre = GETDATE() WHERE CveConexion = {0}", CveConexion), CommandType.Text) + CveConexion = 0 + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + + End Sub +#End Region Private Sub SqlDataCommand(pStrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlCommand .Parameters.Clear() @@ -134,6 +174,7 @@ Public Class ClsPruebasJJMQ ' 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 diff --git a/App_Code/ClsPuntoVenta.vb b/App_Code/ClsPuntoVenta.vb index 7274c8c7b..2b1a20416 100644 --- a/App_Code/ClsPuntoVenta.vb +++ b/App_Code/ClsPuntoVenta.vb @@ -20,6 +20,8 @@ Public Class ClsPuntoVenta 'Atributos de la clase Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'PARA REGISTRAR CONEXION + Private CveConexion As Integer = 0 #End Region @@ -84,7 +86,7 @@ Public Class ClsPuntoVenta End If SqlAdapter = New SqlDataAdapter("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(ByVal pStrSQL As String, Optional ByVal TipoComando As CommandType = CommandType.StoredProcedure) @@ -96,7 +98,44 @@ Public Class ClsPuntoVenta If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc Data = New DataTable End Sub +#Region "Conexiones" + Private Sub ConexionAdd() + If 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) + CveConexion = 0 + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + + End Sub +#End Region Public Function GetVta_CortesDetalles(CveCorte As Integer) As Boolean Dim Retorno As Boolean = False @@ -390,6 +429,7 @@ Public Class ClsPuntoVenta ' 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 diff --git a/App_Code/ClsRH.vb b/App_Code/ClsRH.vb index c6400cce7..a36c44be4 100644 --- a/App_Code/ClsRH.vb +++ b/App_Code/ClsRH.vb @@ -59,6 +59,7 @@ Public Class ClsRH SqlAdapter = New SqlDataAdapter("", SqlConexion) Try SqlConexion.Open() + ConexionAdd() Catch ex As Exception OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex) End Try @@ -72,8 +73,47 @@ Public Class ClsRH End With Data = New DataTable End Sub + Private CveConexion As Integer = 0 +#Region "Conexiones" + Private Sub ConexionAdd() + If ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + + '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 + + 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) + CveConexion = 0 + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + + End Sub +#End Region #Region "ClsRHAsistenciasInasistencias" Public Function GetAsistenciasInasistencias() As Boolean @@ -1984,6 +2024,28 @@ Public Class ClsRH Return Retorno End Function + Public Function UpPersonalAltas(CvePersonal As Integer, fechaInicio As String, fechaFin As String, CvePeriodoFiniquito As Integer, CveMotivoBaja As Integer, esLiquidacion As Boolean) As Boolean + Dim Retorno As Boolean = False + SqlDataAdapter("PA_RH_PersonalAltasUp") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePersonal", SqlDbType.Int).Value = CvePersonal + .Add("@fechaInicio", SqlDbType.VarChar).Value = fechaInicio + .Add("@fechaFin", SqlDbType.VarChar).Value = fechaFin + .Add("@CvePeriodoFiniquito", SqlDbType.Int).Value = CvePeriodoFiniquito + .Add("@CveMotivoBaja", SqlDbType.Int).Value = CveMotivoBaja + .Add("@esLiquidacion", SqlDbType.Int).Value = If(esLiquidacion, 1, 0) + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el reporte de Altas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function GetPersonalAltas(CvePersonal As Integer) As Boolean Dim Retorno As Boolean = False SqlDataAdapter("PA_RH_PersonalAltasGet") @@ -6673,6 +6735,7 @@ Public Class ClsRH ' 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 diff --git a/App_Code/ClsRMA.vb b/App_Code/ClsRMA.vb index 6f4516bbd..92bbff8d7 100644 --- a/App_Code/ClsRMA.vb +++ b/App_Code/ClsRMA.vb @@ -17,6 +17,8 @@ Public Class ClsRMA Private SqlTransacc As SqlTransaction Private Data As DataTable Private disposedValue As Boolean = False + 'PARA REGISTRAR CONEXION + Private CveConexion As Integer = 0 #End Region #Region "Propiedades" @@ -56,7 +58,7 @@ Public Class ClsRMA End If SqlAdapter = New SqlDataAdapter("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(ByVal pStrSQL As String, Optional ByVal TipoComando As CommandType = CommandType.StoredProcedure) With SqlAdapter.SelectCommand @@ -67,7 +69,44 @@ Public Class ClsRMA Data = New DataTable If SqlTransacc IsNot Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc End Sub +#Region "Conexiones" + Private Sub ConexionAdd() + If 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) + CveConexion = 0 + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + + End Sub +#End Region Private Sub DataCommand(ByVal pStrSQL As String, Optional ByVal TipoComando As CommandType = CommandType.StoredProcedure) With SqlCommand .Parameters.Clear() @@ -181,6 +220,7 @@ Public Class ClsRMA ' 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 diff --git a/App_Code/ClsSAT.vb b/App_Code/ClsSAT.vb index 09df0c882..475b7e8b1 100644 --- a/App_Code/ClsSAT.vb +++ b/App_Code/ClsSAT.vb @@ -30,6 +30,8 @@ Public Class ClsSAT Private disposedValue As Boolean = False Private ContListado69B As Integer = 0 + 'PARA REGISTRAR CONEXION + Private CveConexion As Integer = 0 #End Region #Region "Propiedades" @@ -78,7 +80,7 @@ Public Class ClsSAT SqlAdapter = New SqlDataAdapter("", SqlConexion) - 'ConexionAdd() + ConexionAdd() End Sub Private Sub DataAdapter(ByVal pStrSQL As String, Optional ByVal TipoComando As CommandType = CommandType.StoredProcedure) @@ -90,7 +92,44 @@ Public Class ClsSAT Data = New DataTable If SqlTransacc IsNot Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc End Sub +#Region "Conexiones" + Private Sub ConexionAdd() + If 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) + CveConexion = 0 + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + + End Sub +#End Region Public Function ActualizarListado69B(Ruta As String) As Boolean Dim respusta As Boolean = False @@ -337,6 +376,7 @@ Public Class ClsSAT ' 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 diff --git a/App_Code/ClsSCTLicencias.vb b/App_Code/ClsSCTLicencias.vb index fe7650872..24e19a081 100644 --- a/App_Code/ClsSCTLicencias.vb +++ b/App_Code/ClsSCTLicencias.vb @@ -15,6 +15,8 @@ Public Class ClsSCTLicencias Private SqlCommand As SqlCommand Private Data As DataTable Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'PARA REGISTRAR CONEXION + Private CveConexion As Integer = 0 #End Region #Region "Propiedades" @@ -53,7 +55,7 @@ Public Class ClsSCTLicencias Catch ex As Exception OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex) End Try - + ConexionAdd() End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) @@ -64,10 +66,47 @@ Public Class ClsSCTLicencias End With Data = New DataTable End Sub +#Region "Conexiones" + Private Sub ConexionAdd() + If 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) + CveConexion = 0 + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + + End Sub +#End Region #Region "L I C E N C I A S " - + Public Function GetLicencias(CveLicencia As Integer, TipoLicencia As String, NumeroLicencia As String, FechaExpedicionInicio As String, FechaExpedicionFin As String) As Boolean Dim Retorno As Boolean = False @@ -226,6 +265,7 @@ Public Class ClsSCTLicencias ' 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 diff --git a/App_Code/ClsSeguimiento.vb b/App_Code/ClsSeguimiento.vb index 41ae9b40e..4f9aa53a0 100644 --- a/App_Code/ClsSeguimiento.vb +++ b/App_Code/ClsSeguimiento.vb @@ -14,6 +14,8 @@ Public Class ClsSeguimiento Private SqlAdapter As SqlDataAdapter Private Data As DataTable Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'PARA REGISTRAR CONEXION + Private CveConexion As Integer = 0 #End Region #Region "Propiedades" @@ -34,7 +36,7 @@ Public Class ClsSeguimiento Catch ex As Exception OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex) End Try - + ConexionAdd() End Sub Private Sub DataAdapter(pStrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) @@ -45,7 +47,44 @@ Public Class ClsSeguimiento End With Data = New DataTable End Sub +#Region "Conexiones" + Private Sub ConexionAdd() + If 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) + CveConexion = 0 + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + + End Sub +#End Region #Region " S E G U I M I E N T O " @@ -144,6 +183,7 @@ Public Class ClsSeguimiento ' 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 diff --git a/App_Code/ClsSisEmpresas.vb b/App_Code/ClsSisEmpresas.vb index de89d9b0c..7ae8e51ec 100644 --- a/App_Code/ClsSisEmpresas.vb +++ b/App_Code/ClsSisEmpresas.vb @@ -54,6 +54,8 @@ Public Class ClsSisEmpresas Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'PARA REGISTRAR CONEXION + Private CveConexion As Integer = 0 #End Region @@ -221,6 +223,7 @@ Public Class ClsSisEmpresas SqlCommand = New SqlCommand("", SqlConexion) SqlAdapter = New SqlDataAdapter("", SqlConexion) + ConexionAdd() End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) @@ -232,6 +235,44 @@ Public Class ClsSisEmpresas If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc Data = New DataTable End Sub +#Region "Conexiones" + + Private Sub ConexionAdd() + If 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) + CveConexion = 0 + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + + End Sub +#End Region Private Sub DataCommand(pStrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlCommand .Parameters.Clear() @@ -1836,6 +1877,7 @@ Public Class ClsSisEmpresas ' 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 ( que se dispone como Boolean). + ConexionClose() Dispose(True) GC.SuppressFinalize(Me) End Sub diff --git a/App_Code/ClsSisNotificaciones.vb b/App_Code/ClsSisNotificaciones.vb index 7b07140fd..770dc4a57 100644 --- a/App_Code/ClsSisNotificaciones.vb +++ b/App_Code/ClsSisNotificaciones.vb @@ -45,6 +45,8 @@ Public Class ClsSisNotificaciones Private _ClavesNotificaciones As Dictionary(Of String, List(Of Integer)) Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'PARA REGISTRAR CONEXION + Private CveConexion As Integer = 0 #End Region #Region "P R O P I E D A D E S" @@ -92,7 +94,7 @@ Public Class ClsSisNotificaciones 'Inicializamos las propiedades necesarias _ClavesNotificaciones = New Dictionary(Of String, List(Of Integer)) - + ConexionAdd() End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) @@ -103,7 +105,44 @@ Public Class ClsSisNotificaciones End With Data = New DataTable End Sub +#Region "Conexiones" + Private Sub ConexionAdd() + If 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) + CveConexion = 0 + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + + End Sub +#End Region #Region "N O T I F I C A C I O N E S" Public Sub DispararNotificacion(CveNotificacion As Integer, CvesFiltro As List(Of Object), CveEmpresa As Integer) @@ -2046,6 +2085,7 @@ Public Class ClsSisNotificaciones ' 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 diff --git a/App_Code/ClsSisParametros.vb b/App_Code/ClsSisParametros.vb index f11dee532..ceb813bf4 100644 --- a/App_Code/ClsSisParametros.vb +++ b/App_Code/ClsSisParametros.vb @@ -25,6 +25,8 @@ Public Class ClsSisParametros Private _NombreUsuario As String Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'PARA REGISTRAR CONEXION + Private CveConexion As Integer = 0 #End Region #Region "Propiedades" @@ -82,7 +84,7 @@ Public Class ClsSisParametros Catch ex As Exception Me.OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex) End Try - + ConexionAdd() End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) @@ -93,7 +95,44 @@ Public Class ClsSisParametros End With Data = New DataTable End Sub +#Region "Conexiones" + Private Sub ConexionAdd() + If 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) + CveConexion = 0 + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + + End Sub +#End Region Public Function GetParametros() As Boolean Dim OnError As Boolean = False @@ -234,6 +273,7 @@ Public Class ClsSisParametros ' 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 diff --git a/App_Code/ClsSisProcesos.vb b/App_Code/ClsSisProcesos.vb index de402c6a0..34843f32b 100644 --- a/App_Code/ClsSisProcesos.vb +++ b/App_Code/ClsSisProcesos.vb @@ -23,6 +23,8 @@ Public Class ClsSisProcesos Private _NombreUsuario As String Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'PARA REGISTRAR CONEXION + Private CveConexion As Integer = 0 #End Region #Region "Propiedades" @@ -74,7 +76,7 @@ Public Class ClsSisProcesos Catch ex As Exception Me.OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex) End Try - + ConexionAdd() End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) @@ -85,7 +87,44 @@ Public Class ClsSisProcesos End With Data = New DataTable End Sub +#Region "Conexiones" + Private Sub ConexionAdd() + If 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) + CveConexion = 0 + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + + End Sub +#End Region Public Function GetProcesos(CveProceso As Integer) As Boolean Dim OnError As Boolean = False @@ -194,6 +233,7 @@ Public Class ClsSisProcesos ' 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 diff --git a/App_Code/ClsSisRoles.vb b/App_Code/ClsSisRoles.vb index ff34e4a76..47f9ba0a0 100644 --- a/App_Code/ClsSisRoles.vb +++ b/App_Code/ClsSisRoles.vb @@ -18,6 +18,8 @@ Public Class ClsSisRoles Private Data As DataTable Private disposedValue As Boolean = False ' Para detectar llamadas redundantes Private _CveRol As Integer + 'PARA REGISTRAR CONEXION + Private CveConexion As Integer = 0 #End Region #Region "Propiedades" @@ -51,7 +53,7 @@ Public Class ClsSisRoles SqlCommand = New SqlCommand("", SqlConexion) SqlAdapter = New SqlDataAdapter("", SqlConexion) StrSQL = New StringBuilder - + ConexionAdd() End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) @@ -63,7 +65,44 @@ Public Class ClsSisRoles If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc Data = New DataTable End Sub +#Region "Conexiones" + Private Sub ConexionAdd() + If 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) + CveConexion = 0 + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + + End Sub +#End Region Public Function IniciaTransacSQL() As SqlTransaction If SqlTransacc Is Nothing Then SqlTransacc = SqlConexion.BeginTransaction() Return SqlTransacc @@ -312,6 +351,7 @@ Public Class ClsSisRoles ' 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 diff --git a/App_Code/ClsSisUsuarios.vb b/App_Code/ClsSisUsuarios.vb index c28a39021..a2eb7b6a6 100644 --- a/App_Code/ClsSisUsuarios.vb +++ b/App_Code/ClsSisUsuarios.vb @@ -22,6 +22,8 @@ Public Class ClsSisUsuarios 'Atributos de la clase Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'PARA REGISTRAR CONEXION + Private CveConexion As Integer = 0 #End Region @@ -80,7 +82,7 @@ Public Class ClsSisUsuarios SqlCommand = New SqlCommand("", SqlConexion) SqlAdapter = New SqlDataAdapter("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlAdapter.SelectCommand @@ -91,6 +93,44 @@ Public Class ClsSisUsuarios If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc Data = New DataTable End Sub +#Region "Conexiones" + + Private Sub ConexionAdd() + If 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) + CveConexion = 0 + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + + End Sub +#End Region Private Sub DataCommand(pStrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlCommand .Parameters.Clear() @@ -2633,6 +2673,7 @@ Public Class ClsSisUsuarios Me.disposedValue = True End Sub Public Sub Dispose() Implements IDisposable.Dispose + ConexionClose() Dispose(True) GC.SuppressFinalize(Me) End Sub diff --git a/App_Code/ClsVentas.vb b/App_Code/ClsVentas.vb index 8d5a5a673..5373512d4 100644 --- a/App_Code/ClsVentas.vb +++ b/App_Code/ClsVentas.vb @@ -83,7 +83,6 @@ Public Class ClsVentas SqlConexion.ConnectionString = ConfigurationManager.ConnectionStrings("Conexion").ConnectionString Try SqlConexion.Open() - ConexionAdd() Catch ex As Exception OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex) End Try @@ -91,8 +90,8 @@ Public Class ClsVentas SqlConexion = TransaccionCompartida.Connection SqlTransacc = TransaccionCompartida End If - SqlAdapter = New SqlDataAdapter("", SqlConexion) + ConexionAdd() End Sub Private Sub DataAdapter(ByVal pStrSQL As String, Optional ByVal TipoComando As CommandType = CommandType.StoredProcedure) @@ -105,41 +104,40 @@ Public Class ClsVentas Data = New DataTable End Sub -#Region "Conexiones" - - Private Sub ConexionAdd() - If ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then - - DataAdapter(String.Format("INSERT INTO Sis_Conexiones (Clase,Modulo) VALUES ('ClsVentas',{0})", HttpContext.Current.Request.Url.Authority), CommandType.Text) ' pendiente de terminar parra registrar el cveconexion, falta el rarámetro de módulo - With SqlAdapter.SelectCommand.Parameters - - .Add("@CveConexion", SqlDbType.Int).Direction = ParameterDirection.Output - End With +#Region "Conexiones" + Private Sub ConexionAdd() + If ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then Try - SqlAdapter.Fill(Data) - CveConexion = SqlAdapter.SelectCommand.Parameters("@Opcion").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 ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then - - DataAdapter(String.Format("UPDATE Sis_Conexiones SET FechaCierre = GETDATE WHERE CveConexion = ", 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 - - End If - + DataAdapter("PA_Sis_RegistrarConexion") + With SqlAdapter.SelectCommand.Parameters + .Add("@Clase", SqlDbType.VarChar).Value = Me.GetType().Name + .Add("@Modulo", SqlDbType.VarChar).Value = HttpContext.Current.Request.Url.AbsolutePath.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 + + End If + End Sub #End Region @@ -3963,6 +3961,7 @@ Public Class ClsVentas ' 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 diff --git a/App_Code/Modelos.vb b/App_Code/Modelos.vb index 954c278f3..1bff453cf 100644 --- a/App_Code/Modelos.vb +++ b/App_Code/Modelos.vb @@ -1856,9 +1856,11 @@ Namespace Modelos Dim UsaComplementariaClientes As Boolean = False If UsuarioActual.CveEmpresa.Contiene(1, 119) Then UsaComplementariaClientes = True - If ObjConta.GetPlantillaConceptos(ObjFactura.CveEmpresa, CvePlantilaPoliza) Then - For Each Row As DataRow In ObjConta.DtResultados.Rows - + If ObjConta.GetPlantillaConceptos(ObjFactura.CveEmpresa, CvePlantilaPoliza) Then + Dim dtt As DataTable = ObjConta.DtResultados + If ValorMultiplicador = -1 Then dtt = ObjConta.DtResultados.FiltraParametros("", "Orden DESC") ' se ordena contrario al registro para llevar los saldos correctos + For Each Row As DataRow In dtt.Rows + ConceptoContable = Row("CveConcepto").ToString.ToEntero TipoMovimiento = If(Row("TipoMovto").ToString = "True", True, False) importeMovimiento = 0 @@ -2780,23 +2782,17 @@ Namespace Modelos Next - End If - - If DtRemisionesRelacionadas Is Nothing Then - If ObjVentas.GetRemisionesRelacionadas(ObjFactura.CveVenta, ObjFactura.TipoDocto) AndAlso ObjVentas.DtResultados.Rows.Count > 0 Then - DtRemisionesRelacionadas = ObjVentas.DtResultados.Copy() - End If + End If + + If ObjFactura.RemisionesLista.Count = 0 AndAlso (DtRemisionesRelacionadas IsNot Nothing AndAlso DtRemisionesRelacionadas.Rows.Count > 0) Then + For Each Row As DataRow In DtRemisionesRelacionadas.Rows + ObjFactura.RemisionesLista.Add(Row("CveVenta").ToString().ToEntero()) + Next End If 'Si es Facturacion de una remision cancelamos, traspasamos saldos y agregamos evento a la bitacora If (DtRemisionesRelacionadas IsNot Nothing AndAlso DtRemisionesRelacionadas.Rows.Count > 0) OrElse ObjFactura.RemisionesLista.Count > 0 Then - If ObjFactura.RemisionesLista.Count = 0 AndAlso (DtRemisionesRelacionadas IsNot Nothing AndAlso DtRemisionesRelacionadas.Rows.Count > 0) Then - For Each Row As DataRow In DtRemisionesRelacionadas.Rows - ObjFactura.RemisionesLista.Add(Row("CveVenta").ToString().ToEntero()) - Next - End If - If ObjFactura.RemisionesLista.Count > 0 Then For Each CveRemision As Integer In RemisionesLista If Not ObjConta.TraspasarSaldosRemision(CveRemision, ObjFactura.CvePrePoliza, ObjFactura.CveVenta) Then @@ -2817,25 +2813,30 @@ Namespace Modelos Exit For End If Next - End If - - 'REGRESA SALDO A LAS REMISIONES QUE SE FACTURARON EN EL INGRESO QUE SE ESTA CANCELANDO - If ObjFactura.TipoDocto = "Ing" And ValorMultiplicador = -1 AndAlso NuevaFactura <> 1 AndAlso Not SeCancelaRemisionProceso Then ' se debe de excluir cuando es refacturación - For Each Dr As DataRow In DtRemisionesRelacionadas.Rows - - Dim DebeCancelar As Boolean = CancelarRemisiones AndAlso ListaRemisionesCancelar.Any(Function(CveRemision) CveRemision = Dr("CveVenta").ToString.ToEntero()) - - If Not DebeCancelar Then - If Not ObjConta.TraspasarSaldosRemision(Dr("CveVenta").ToString.ToEntero, ObjFactura.CvePrePoliza, ObjFactura.CveVenta, 1) Then - ErrorPrepoliza = True - End If - If Not ObjEventos.AddEventoBitacora($"Facturación cancelada en: {ObjFactura.Folio}", "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveVenta:=Dr("CveVenta").ToString.ToEntero) Then - ErrorPrepoliza = True - End If - End If - Next End If - + End If + + If DtRemisionesRelacionadas Is Nothing Then + If ObjVentas.GetRemisionesRelacionadas(ObjFactura.CveVenta, ObjFactura.TipoDocto) AndAlso ObjVentas.DtResultados.Rows.Count > 0 Then + DtRemisionesRelacionadas = ObjVentas.DtResultados.Copy() + End If + End If + + 'REGRESA SALDO A LAS REMISIONES QUE SE FACTURARON EN EL INGRESO QUE SE ESTA CANCELANDO + If ObjFactura.TipoDocto = "Ing" And ValorMultiplicador = -1 AndAlso NuevaFactura <> 1 AndAlso Not SeCancelaRemisionProceso AndAlso DtRemisionesRelacionadas IsNot Nothing Then ' se debe de excluir cuando es refacturación + For Each Dr As DataRow In DtRemisionesRelacionadas.Rows + + Dim DebeCancelar As Boolean = CancelarRemisiones AndAlso ListaRemisionesCancelar.Any(Function(CveRemision) CveRemision = Dr("CveVenta").ToString.ToEntero()) + + If Not DebeCancelar Then + If Not ObjConta.TraspasarSaldosRemision(Dr("CveVenta").ToString.ToEntero, ObjFactura.CvePrePoliza, ObjFactura.CveVenta, 1) Then + ErrorPrepoliza = True + End If + If Not ObjEventos.AddEventoBitacora($"Facturación cancelada en: {ObjFactura.Folio}", "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveVenta:=Dr("CveVenta").ToString.ToEntero) Then + ErrorPrepoliza = True + End If + End If + Next End If @@ -3583,6 +3584,13 @@ Namespace Modelos Dim TieneAlmacen As Boolean = False + 'If Not EsRefacturacion AndAlso ObjFactura.SaldoAlmacen <> 0 Then + ' Retorno.Mensaje = "El pedido no se puede cancelar ya que tiene movimientos de almacén.
Nota: Primero hay que hacer la devolución al almacén." + ' Retorno.TipoMensaje = TipoMensaje.MsgAdvertencia + + ' Return Retorno + 'End If + 'VALIDA QUE LA FACTURA NO TENGA PAGOS If ObjFactura.TipoDocto.Contiene("Ing", "Rem") AndAlso ObjFactura.Pagado > 0 Then Retorno.Mensaje = "La factura no se puede cancelar debido a que tiene pagos vinculados." @@ -3608,7 +3616,7 @@ Namespace Modelos End If 'LA VALIDACION DE SALDOS CUANDO ES REFACTURACION SE HACE ANTES ASI QUE SI ES REFACTURACION IGNORAMOS ESTA CONDICION, SI ES ANTICIPO VERIFICA QUE NO ESTÉ APLICADO - If ObjFactura.TipoDocto = "Ant" AndAlso ObjFactura.Pagado > 0 AndAlso DTDocumentosRelacionados.Rows.Count > 0 Then + If ObjFactura.TipoDocto.Contiene("Ing", "Ant", "Rem") AndAlso ObjFactura.Pagado > 0 AndAlso DTDocumentosRelacionados.Rows.Count > 0 Then Retorno.Mensaje = "La factura no se puede cancelar debido a que tiene pagos vinculados." Retorno.TipoMensaje = TipoMensaje.MsgAdvertencia @@ -3670,7 +3678,7 @@ Namespace Modelos Dim RevivirRemisiones = Not EsRefacturacion AndAlso ((TieneRemisionesRelacionadas AndAlso ListaRemisionesCancelar Is Nothing) OrElse (DtRemisionesRelacionadas.Rows.Count > ListaRemisionesCancelar.Count)) 'REMISION YA SE DEBE HACER POR EL PROCESO DE DEVOLUCION DE ALMACEN - If Not EsRefacturacion AndAlso (ObjFactura.SaldoAlmacen > 0 AndAlso ObjFactura.EsDevolucionVenta.Contiene(0, 1)) AndAlso Not RealizarDevolucionAlmacen And RevivirRemisiones = False Then + If Not EsRefacturacion AndAlso (ObjFactura.SaldoAlmacen <> 0 AndAlso ObjFactura.EsDevolucionVenta.Contiene(0, 1)) AndAlso Not RealizarDevolucionAlmacen And RevivirRemisiones = False Then Retorno.Mensaje = "La factura no se puede cancelar debido a que tiene movimientos de inventario." Retorno.TipoMensaje = TipoMensaje.MsgAdvertencia @@ -3678,7 +3686,7 @@ Namespace Modelos Return Retorno End If - + Dim CveEstatusRefacturacion As Integer = If(ObjFactura.CveEstatusRefacturacion <= 0, 0, ObjFactura.CveEstatusRefacturacion) Dim CancelacionFecha As Date Dim FolioFiscal As String = ObjFactura.FolioFiscal Dim CancelacionAcuse As String = "" @@ -3839,7 +3847,7 @@ Namespace Modelos End If 'CUANDO LA CANCELACION ESTA EN PROCESO NO DEBE REALIZAR NADA DE ESTE PROCESO - If (((ObjFactura.Saldo > 0 AndAlso (CveEstatus > 0 AndAlso CveEstatus <> 20)) OrElse (ObjFactura.Total = 0 AndAlso UsuarioActual.CveEmpresa.Contiene(72) AndAlso ObjFactura.TipoDocto.Contiene("Ing"))) AndAlso CveEstatus.Contiene(4, 5)) OrElse CvePlantillaPoliza = 7 Then + If (((ObjFactura.Saldo > 0 AndAlso (CveEstatus > 0 AndAlso CveEstatus <> 20)) OrElse (ObjFactura.Total = 0 AndAlso UsuarioActual.CveEmpresa.Contiene(72) AndAlso ObjFactura.TipoDocto.Contiene("Ing"))) AndAlso CveEstatus.Contiene(4, 5)) OrElse (CvePlantillaPoliza = 7 AndAlso (CveEstatus > 0 AndAlso CveEstatus <> 20)) Then 'CUANDO SE CANCELA, LA PÓLIZA DEBE DE SER DE DIARIO CvePrePoliza = ObjConta.AddPrePolizas("Modelos/CancelarDocumento", CvePlantillaPoliza, ObjFactura.Total, ObjFactura.Total, ObjFactura.CveMoneda, Now, ObjFactura.Cliente.Nombre, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoPoliza:=3) @@ -3871,12 +3879,11 @@ Namespace Modelos End If 'CUANDO LA CANCELACION ESTA EN PROCESO NO DEBE REALIZAR NADA DE ESTE PROCESO - If Not EsRefacturacion AndAlso (CveEstatus > 0 AndAlso CveEstatus <> 20) Then + If Not EsRefacturacion AndAlso (CveEstatus > 0 AndAlso CveEstatus <> 20) AndAlso CveEstatusRefacturacion = 0 Then 'DEVOLUCION DE ALMACEN If Not ErrorCancelar AndAlso TieneAlmacen Then Dim TieneSalida As Boolean = False - Dim DtDatos As New DataTable Dim DtExistencias As New DataTable 'CUANDO SE VAYA A REALIZAR LA DEVOLUCION AQUI DEBE MARCALA PARA NO SOLICITARLA DE NUEVO, SI NO LA SOLICITARA @@ -3888,88 +3895,45 @@ Namespace Modelos End If End If - If Not ErrorCancelar AndAlso ObjInventario.EntregaAlmacenGet(CveVenta) Then - If ObjInventario.DtResultados IsNot Nothing AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then - DtDatos = ObjInventario.DtResultados - DtDatos.Columns.Add("Consec", GetType(Integer)) - DtDatos.Columns.Add("CantidadGV", GetType(Double)) - DtDatos.Columns.Add("CantidadTraspaso", GetType(Double)) - Dim Index = 1 - For Each Dr As DataRow In DtDatos.Rows - Dr("Consec") = Index - Dr("CantidadGV") = Dr("CantidadF") - Index += 1 - Next - - If DtDatos IsNot Nothing AndAlso DtDatos.Rows.Count > 0 AndAlso ObjInventario.DtResultados.Rows(0)("CveVentaPadre").ToString.ToEntero > 0 Then - Dim Filtro As String - Select Case ObjInventario.DtResultados.Rows(0)("TipoDocto").ToString - Case "Ing", "Ped" - Filtro = "CveConcepto = 3" - Case "Dev" - Filtro = "CveConcepto = 3" - Case Else - Filtro = "CveConcepto = 9" - End Select - - If ObjInventario.GetInv_Mov(ObjInventario.DtResultados.Rows(0)("CveVentaPadre").ToString.ToEntero, UsuarioActual.CveEmpresa) Then - DtExistencias = ObjInventario.DtResultados.FiltraParametros($"CvePS Is Not NULL AND {Filtro}") - - If DtExistencias.Rows.Count > 0 Then - TieneSalida = True - End If - - Else - ErrorCancelar = True - MensajeError = "Ocurrió un error al cargar los datos de devolución. Por favor vuelva a intentar." - End If - End If + If Not ErrorCancelar Then + Dim Filtro As String + Select Case ObjFactura.TipoDocto + Case "Ing", "Ped" + Filtro = "CveConcepto = 3" + Case "Dev" + Filtro = "CveConcepto = 3" + Case Else + Filtro = "CveConcepto = 9" + End Select + If ObjInventario.GetInv_Mov(CveVenta, UsuarioActual.CveEmpresa) Then + DtExistencias = ObjInventario.DtResultados.FiltraParametros($"CvePS IS NOT NULL AND {Filtro}") + TieneSalida = DtExistencias.Rows.Count > 0 + Else + ErrorCancelar = True + MensajeError = "Ocurrió un error al cargar los datos de devolución. Por favor vuelva a intentar." End If End If If Not ErrorCancelar AndAlso TieneSalida Then - - Dim DtTraspasos As New DataTable - DtTraspasos.Columns.Add("CveAlmacen", GetType(Integer)) - DtTraspasos.Columns.Add("Almacen", GetType(String)) - DtTraspasos.Columns.Add("CveMovimientoSalida", GetType(Integer)) - DtTraspasos.Columns.Add("FolioSalida", GetType(Integer)) - DtTraspasos.Columns.Add("CveMovimientoEntrada", GetType(Integer)) - DtTraspasos.Columns.Add("FolioEntrada", GetType(Integer)) - Dim ConceptoMovimiento = 18 'DEVOLUCION DEL CLIENTE Dim CveMovimiento As Integer = 0 Dim Folio As Integer = 0 - Dim CantidadPendiente As Decimal = 0 If Not ErrorCancelar AndAlso RealizarDevolucionAlmacen Then Dim CveAlmacenDevolucion = ObjFactura.CveAlmacenDevolucion + 'SALIDA DE ALMACEN - SALIDA POR TRASPASO CUANDO ES REMISION - DEVOLUCION (SI ES TRASPASO Y TIENE CONTRATO NO HACE DEVOLUCIóN) CveMovimiento = ObjInventario.AddMovimiento(CveAlmacenDevolucion, ConceptoMovimiento, 1, Now, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVenta, -1, -1, Observaciones:="", Guia:="", CveContrato:=CveContrato, CveAlmacenDestino:=-1) Folio = ObjInventario.Folio - 'SALIDA DE ALMACEN - SALIDA POR TRASPASO CUANDO ES REMISION - DEVOLUCION (SI ES TRASPASO Y TIENE CONTRATO NO HACE DEVOLUCIóN) If CveMovimiento > 0 Then - - 'ES EL MOVIMIENTO PRINCIPAL - CantidadPendiente = 0 - For Each Dr As DataRow In DtDatos.Rows - CantidadPendiente = Dr("CantidadGV").ToString.ToDecimal - Dr("CantidadTraspaso").ToString.ToDecimal - If CantidadPendiente > 0 Then - Dim PU As Decimal = 0 - - If DtExistencias IsNot Nothing Then - PU = DtExistencias.FiltroPrimeroValor("PU", $"CvePS = {Dr("CvePS")} AND CveUM = {Dr("CveUM").ToString.ToEntero}").ToString.ToDecimal - End If - - If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, CantidadPendiente, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, PU, -1, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then - ErrorCancelar = True - MensajeError = "Ocurrió un error al procesar los conceptos de salida. Por favor vuelva a intentar." - Exit For - End If - + For Each Dr As DataRow In DtExistencias.Rows + If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, -1, SerieLote:=Dr("SerieLote").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then + ErrorCancelar = True + MensajeError = "Ocurrió un error al procesar los conceptos de salida. Por favor vuelva a intentar." + Exit For End If Next Else @@ -4059,12 +4023,12 @@ Namespace Modelos End If End If - 'If Not ErrorCancelar AndAlso RevivirRemisiones Then - ' If Not GeneraMovimientosApartados(ObjInventario, DtTraspasos) Then - ' ErrorCancelar = True - ' MensajeError = "Ocurrió un error al guardar los movimientos de control de apartados" - ' End If - 'End If + If Not ErrorCancelar Then + If Not GeneraMovimientosApartados(ObjInventario) Then + ErrorCancelar = True + MensajeError = "Ocurrió un error al guardar los movimientos de control de apartados" + End If + End If 'DEVOLUCION REMISION - REGRESA LAS EXISTENCIAS A ENTREGA POR ADELANTADO SI LA FACTURA VIENE DE REMISION If Not ErrorCancelar AndAlso RevivirRemisiones Then @@ -4190,7 +4154,6 @@ Namespace Modelos End If - Dim CveEstatusRefacturacion As Integer = 0 'ACTUALIZA ESTATUS If Not ErrorCancelar Then Select Case ObjFactura.TipoDocto @@ -4208,11 +4171,17 @@ Namespace Modelos End If End If - - If Not ObjVentas.UpdateEstatusFactura(CveEstatus, FolioFiscal, CancelacionAcuse, CancelacionFecha, CveVenta, IDPoliza, CvePAC:=CvePACCancelacion, CveEstatusRefacturacion:=CveEstatusRefacturacion, - CveUsuarioCambiaEstatus:=UsuarioActual.CveUsuario, FechaCambioEstatus:=Now.ToString("yyyy-MM-dd hh:mm:ss.mmm")) Then - ErrorCancelar = True - MensajeError = "Ocurrió un error al guardar el estatus de cancelación." + If CveEstatus.Contiene(4, 5) Then + If Not ObjVentas.UpdateCancelaVenta(CveVenta, CancelacionFecha, CancelacionAcuse, UsuarioActual.CveEmpresa, CvePACCancelacion) Then + ErrorCancelar = True + MensajeError = "Ocurrió un error al guardar el estatus de cancelación." + End If + Else + If Not ObjVentas.UpdateEstatusFactura(CveEstatus, FolioFiscal, CancelacionAcuse, CancelacionFecha, CveVenta, IDPoliza, CvePAC:=CvePACCancelacion, CveEstatusRefacturacion:=CveEstatusRefacturacion, + CveUsuarioCambiaEstatus:=UsuarioActual.CveUsuario, FechaCambioEstatus:=Now.ToString("yyyy-MM-dd hh:mm:ss.mmm")) Then + ErrorCancelar = True + MensajeError = "Ocurrió un error al guardar el estatus de cancelación." + End If End If If CancelarRemisiones Then @@ -4263,14 +4232,12 @@ Namespace Modelos Retorno.TipoMensaje = TipoMensaje.MsgConfirmacion Else - If Not EsRefacturacion Then - Retorno.Mensaje = "El documento se canceló exitosamente" - Retorno.HuboError = False - Retorno.TipoMensaje = TipoMensaje.MsgInformacion - End If + Retorno.Mensaje = "El documento se canceló exitosamente" + Retorno.HuboError = False + Retorno.TipoMensaje = TipoMensaje.MsgInformacion End If - Me.CveEstatus = CveEstatus + ObjFactura.CveEstatus = CveEstatus Else ObjVentas.RollBack() If ObjAC IsNot Nothing Then ObjAC.RollBack() @@ -4410,11 +4377,19 @@ Namespace Modelos Return Not ErrorCancelar End Function - Private Function GeneraMovimientosApartados(ByRef ObjInventario As ClsInventarios, ByRef DtTraspasos As DataTable) As Boolean + Private Function GeneraMovimientosApartados(ByRef ObjInventario As ClsInventarios) As Boolean Dim ErrorCancelar As Boolean = False If Not ErrorCancelar Then If ObjInventario.VentasAlmacenApartadosGet(CveVenta) Then + Dim DtTraspasos As New DataTable + DtTraspasos.Columns.Add("CveAlmacen", GetType(Integer)) + DtTraspasos.Columns.Add("Almacen", GetType(String)) + DtTraspasos.Columns.Add("CveMovimientoSalida", GetType(Integer)) + DtTraspasos.Columns.Add("FolioSalida", GetType(Integer)) + DtTraspasos.Columns.Add("CveMovimientoEntrada", GetType(Integer)) + DtTraspasos.Columns.Add("FolioEntrada", GetType(Integer)) + Dim DtTempApartados = ObjInventario.DtResultados.FiltraParametros("CveTipoAlmacen = 9", "CveAlmacen") Dim CveMovimientoSalidaApartado = -1 Dim CveAlmacenApartado = -1 @@ -4473,6 +4448,8 @@ Namespace Modelos If ErrorCancelar Then Exit For Next + + DtTraspasos.Dispose() End If Else ErrorCancelar = True @@ -4701,8 +4678,8 @@ Namespace Modelos #End Region -#Region "P R O P I E D A D E S" - +#Region "P R O P I E D A D E S" + Public Property CveEstatusRefacturacion As Integer = 0 Public Property NuevaFactura As Integer Public Property EnviarCorreo As Boolean = False Public Property ErrorList As List(Of String) @@ -4764,32 +4741,32 @@ Namespace Modelos 'Public Property Sucursal As SucursalModel Public Property SubProyecto As Modelos.SubProyectoModel - Public DtDetalle As Data.DataTable - Public DtDetalleAC As Data.DataTable - Public DtAjustes As Data.DataTable - Public DtRecepcionUsados As Data.DataTable - Public DtVentasNC As Data.DataTable - Public DtDeduccion As Data.DataTable - Public DtFirmas As Data.DataTable - Public DtDesgloseImpuestos As Data.DataTable - Public DtDocumentosRelacionados As Data.DataTable - Public DtNCVinculadas As Data.DataTable + Public Property DtDetalle As Data.DataTable + Public Property DtDetalleAC As Data.DataTable + Public Property DtAjustes As Data.DataTable + Public Property DtRecepcionUsados As Data.DataTable + Public Property DtVentasNC As Data.DataTable + Public Property DtDeduccion As Data.DataTable + Public Property DtFirmas As Data.DataTable + Public Property DtDesgloseImpuestos As Data.DataTable + Public Property DtDocumentosRelacionados As Data.DataTable + Public Property DtNCVinculadas As Data.DataTable - Public DtAnticipos As Data.DataTable - Public DtPromociones As Data.DataTable - Public DtImpuestosLocales As Data.DataTable - Public DtPagos As Data.DataTable - Public DtRemisionesPS As Data.DataTable - Public DtRemisiones As Data.DataTable - Public DtPedidos2 As Data.DataTable - Public DtPedidos2PS As Data.DataTable - Public DTOrdenesCompraPS As Data.DataTable - Public DtCotizacionesPS As Data.DataTable - Public DtDocumentacionCliente As Data.DataTable - Public DtContratosSerieDetalle As Data.DataTable - Public DtOtrosConceptos As Data.DataTable - Public DtInventario As Data.DataTable - Public DtRemConceptosSurtidos As Data.DataTable + Public Property DtAnticipos As Data.DataTable + Public Property DtPromociones As Data.DataTable + Public Property DtImpuestosLocales As Data.DataTable + Public Property DtPagos As Data.DataTable + Public Property DtRemisionesPS As Data.DataTable + Public Property DtRemisiones As Data.DataTable + Public Property DtPedidos2 As Data.DataTable + Public Property DtPedidos2PS As Data.DataTable + Public Property DTOrdenesCompraPS As Data.DataTable + Public Property DtCotizacionesPS As Data.DataTable + Public Property DtDocumentacionCliente As Data.DataTable + Public Property DtContratosSerieDetalle As Data.DataTable + Public Property DtOtrosConceptos As Data.DataTable + Public Property DtInventario As Data.DataTable + Public Property DtRemConceptosSurtidos As Data.DataTable Public Property UsadosBonificacion As List(Of Integer) Public Property TipoBonificacion As Integer = 0 Public Property Timbre As CFDITimbre diff --git a/App_Code/Timbrado.vb b/App_Code/Timbrado.vb index ef77aa206..9ccf49d07 100644 --- a/App_Code/Timbrado.vb +++ b/App_Code/Timbrado.vb @@ -634,7 +634,7 @@ Public Class Timbrado 'Retorno = TimbrarFacturaProFact(UsuarioActual, Ventas, TmpDTConceptos, TmpDTImpuestos, TmpDTComplementos, Ruta, LstFordASN, FordGSDBM, ObjV) Case 4 - Dim Ret As String = TimbrarFacturaGoCFDIv33(Ventas, UsuarioActual) + Dim Ret As String = TimbrarFacturaGoCFDIv33(Ventas, UsuarioActual, CvePACEspecial) Retorno = If(Ret = "", True, False) End Select @@ -1571,7 +1571,10 @@ Public Class Timbrado 'GC.Collect() Return Retorno End Function - Public Function TimbrarFacturaGoCFDIv33(Ventas As Modelos.Factura, UsuarioActual As Usuario) As String + Public Function TimbrarFacturaGoCFDIv33(Ventas As Modelos.Factura, UsuarioActual As Usuario, Optional CvePACEspecial As Integer = -1) As String + If CvePACEspecial = -1 Then + CvePACEspecial = UsuarioActual.Empresa.CvePAC + End If Dim sw As New Diagnostics.Stopwatch Dim swmili As Long = 0 Dim swTiempo As New StringBuilder @@ -1581,8 +1584,8 @@ Public Class Timbrado ' 'Sucursal matriz de la empresa Dim ArchivoLLave As String = String.Format("{0}Certificados\{1}", UsuarioActual.Empresa.Ruta, UsuarioActual.Empresa.ArchivoKey) Dim ArchivoCertificado As String = String.Format("{0}Certificados\{1}", UsuarioActual.Empresa.Ruta, UsuarioActual.Empresa.ArchivoCer) - Dim UsuarioServicio As String = If(UsuarioActual.Empresa.CvePAC = 2, UsuarioActual.Empresa.RFC, "rene.molina@adsistemas.mx") - Dim ClaveServicio As String = If(UsuarioActual.Empresa.CvePAC = 2, UsuarioActual.Empresa.RFC.ToLower, "rene2018") + Dim UsuarioServicio As String = If(CvePACEspecial = 2, UsuarioActual.Empresa.RFC, "rene.molina@adsistemas.mx") + Dim ClaveServicio As String = If(CvePACEspecial = 2, UsuarioActual.Empresa.RFC.ToLower, "rene2018") Dim Clave As String = UsuarioActual.Empresa.ContraseñaKey Dim EmisorRFC As String = UsuarioActual.Empresa.RFC Dim UrlServicio As String = "" ' Produccion @@ -1591,8 +1594,7 @@ Public Class Timbrado Dim SubTotal As Decimal = 0 Dim TimbraProduccion As Boolean = True If Not Directory.Exists(RutaArchivo) Then Directory.CreateDirectory(RutaArchivo) - - Select Case UsuarioActual.Empresa.CvePAC + Select Case CvePACEspecial Case 2 UrlServicio = "http://generacfdi.com.mx/rvltimbrado/service1.asmx?WSDL" Case 4 @@ -1606,7 +1608,7 @@ Public Class Timbrado ArchivoCertificado = $"{UsuarioActual.Empresa.Ruta}Certificados\CSD01_AAA010101AAA.cer" Clave = "12345678a" TimbraProduccion = False - Select Case UsuarioActual.Empresa.CvePAC + Select Case CvePACEspecial Case 2 UsuarioServicio = "fgomez" ClaveServicio = "12121212" @@ -2090,7 +2092,7 @@ Public Class Timbrado Using ObjVentas As New ClsVentas() - If ObjVentas.UpdateEstatusFactura(3, FolioFiscal, "", ObjCFDITimbre.Comprobante.Fecha, Ventas.CveVenta, CvePAC:=UsuarioActual.Empresa.CvePAC) Then + If ObjVentas.UpdateEstatusFactura(3, FolioFiscal, "", ObjCFDITimbre.Comprobante.Fecha, Ventas.CveVenta, CvePAC:=CvePACEspecial) Then Retorno = "" Else Retorno = "Error" @@ -2113,7 +2115,7 @@ Public Class Timbrado If ObjCFDITimbre.Comprobante.TipoComprobante = "N" Then Using ObjNomina2 As New ClsNominas() - If ObjNomina2.UpdateEstatusNomNominas(3, UsuarioActual.Empresa.CvePAC, FolioFiscal, "", ("01/01/2000").ToDate, ObjCFDITimbre.Nomina.CveNomina, 0, 0, 0, 0, 0) Then + If ObjNomina2.UpdateEstatusNomNominas(3, CvePACEspecial, FolioFiscal, "", ("01/01/2000").ToDate, ObjCFDITimbre.Nomina.CveNomina, 0, 0, 0, 0, 0) Then Retorno = "" Else Retorno = "Error" @@ -2159,7 +2161,7 @@ Public Class Timbrado End If #End Region - GuardaLogTimbrado(swTiempo.ToString, UsuarioActual.Empresa.CvePAC) + GuardaLogTimbrado(swTiempo.ToString, CvePACEspecial) Return Retorno End Function Public Sub GuardaLogTimbrado(Str As String, CvePAC As Integer) diff --git a/Bancos/CargarConciliacionesBancarias.aspx.vb b/Bancos/CargarConciliacionesBancarias.aspx.vb index 450f45940..27ab10ceb 100644 --- a/Bancos/CargarConciliacionesBancarias.aspx.vb +++ b/Bancos/CargarConciliacionesBancarias.aspx.vb @@ -5,6 +5,8 @@ Imports System.Data Imports Extensiones Imports System.Xml Imports Microsoft.Reporting.WebForms +Imports GemBox.Spreadsheet + Partial Class Bancos_CargarConciliacionesBancarias Inherits ClsPaginas @@ -83,51 +85,99 @@ Partial Class Bancos_CargarConciliacionesBancarias End If End Sub + Private Function ReadExcelFile(ByVal flatFilePath As String, ByVal firstRowHasHeaders As Boolean) As DataTable + SpreadsheetInfo.SetLicense(ModExtensiones.SerialGemBoxSpreadsheet) + Dim excelFile As ExcelFile = ExcelFile.Load(flatFilePath) + + Dim unnamed As Integer = 0 + Dim cols As Integer + Dim columns As String() + Dim curRow As Integer = 0 + Dim curCol As Integer = 0 + Dim dataTable As DataTable = New DataTable() + Dim worksheet As ExcelWorksheet = excelFile.Worksheets(0) + + For cols = 0 To worksheet.Rows(0).AllocatedCells.Count - 1 + + If firstRowHasHeaders Then + + If worksheet.Rows(0).Cells(cols).Value IsNot Nothing Then + dataTable.Columns.Add(worksheet.Rows(0).Cells(cols).Value.ToString()) + Else + dataTable.Columns.Add("Unnamed Column " & (System.Threading.Interlocked.Increment(unnamed))) + End If + + curRow = 1 + Else + dataTable.Columns.Add("Column " & (cols + 1)) + End If + Next + + While curRow < worksheet.Rows.Count + columns = New String(cols - 1) {} + + For curCol = 0 To cols - 1 + + If worksheet.Rows(curRow).Cells(curCol).Value Is Nothing Then + columns(curCol) = "" + Else + columns(curCol) = worksheet.Rows(curRow).Cells(curCol).Value.ToString() + End If + Next + + dataTable.Rows.Add(columns) + curRow += 1 + End While + + Return dataTable + End Function + Private Sub CargaExcel(Ruta As String, FileName As String, Tipo As String) If Not DdlCuenta.SelectedValue.ToEntero > 0 Then Alert("Tiene que seleccionar una cuenta", TipoMensaje.MsgAdvertencia) Exit Sub End If Dim dt As New DataTable - Dim Conexion As Odbc.OdbcConnection = Nothing - Dim ErrorArchivo = False - Dim ErrorExcel = False - Dim strConnString As String = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" + Ruta + FileName + ";Extended Properties=Excel 8.0;" - Dim objDbFactory As Common.DbProviderFactory = Common.DbProviderFactories.GetFactory("System.Data.OleDb") - Dim objDbAdapter As Common.DbDataAdapter = objDbFactory.CreateDataAdapter() - Dim objDbConnection As Common.DbConnection = objDbFactory.CreateConnection() - objDbConnection.ConnectionString = strConnString - objDbConnection.Open() - Dim objSheetNames As DataTable = objDbConnection.GetSchema("Tables") - Dim HojaExcel As String = objSheetNames.FiltroPrimeroValor("TABLE_NAME") - Try - Select Case Tipo - Case "CSV" - Conexion = New Odbc.OdbcConnection("Driver={Microsoft Access Text Driver (*.txt, *.csv)};Dbq=" + Ruta + ";Extensions=asc,csv,tab,txt;") - Conexion.Open() - Dim cmd = Conexion.CreateCommand() - cmd.CommandType = CommandType.Text - cmd.CommandText = $"SELECT * FROM [{FileName}]" - Dim DataAdapter = New Odbc.OdbcDataAdapter(cmd) - DataAdapter.Fill(dt) - Case "EXCEL" - Conexion = New Odbc.OdbcConnection("Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ=" + Ruta + FileName + ";") - Conexion.Open() - Dim cmd = Conexion.CreateCommand() - cmd.CommandType = CommandType.Text - cmd.CommandText = $"SELECT * FROM [{HojaExcel}]" - Dim DataAdapter = New Odbc.OdbcDataAdapter(cmd) - DataAdapter.Fill(dt) - Case Else - Alert("El archivo no tiene el formato correcto", TipoMensaje.MsgError) - Exit Sub - End Select - Catch ex As Exception - ErrorArchivo = True - OnError("Ocurrio un error al leer el archivo
" & ex.Message, ex) - End Try - Conexion.Close() - If Not ErrorArchivo Then + dt = ReadExcelFile(Ruta + FileName, True) + 'Dim Conexion As Odbc.OdbcConnection = Nothing + 'Dim ErrorArchivo = False + 'Dim ErrorExcel = False + 'Dim strConnString As String = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" + Ruta + FileName + ";Extended Properties=Excel 8.0;" + 'Dim objDbFactory As Common.DbProviderFactory = Common.DbProviderFactories.GetFactory("System.Data.OleDb") + 'Dim objDbAdapter As Common.DbDataAdapter = objDbFactory.CreateDataAdapter() + 'Dim objDbConnection As Common.DbConnection = objDbFactory.CreateConnection() + 'objDbConnection.ConnectionString = strConnString + 'objDbConnection.Open() + 'Dim objSheetNames As DataTable = objDbConnection.GetSchema("Tables") + 'Dim HojaExcel As String = objSheetNames.FiltroPrimeroValor("TABLE_NAME") + 'Try + ' Select Case Tipo + ' Case "CSV" + ' Conexion = New Odbc.OdbcConnection("Driver={Microsoft Access Text Driver (*.txt, *.csv)};Dbq=" + Ruta + ";Extensions=asc,csv,tab,txt;") + ' Conexion.Open() + ' Dim cmd = Conexion.CreateCommand() + ' cmd.CommandType = CommandType.Text + ' cmd.CommandText = $"SELECT * FROM [{FileName}]" + ' Dim DataAdapter = New Odbc.OdbcDataAdapter(cmd) + ' DataAdapter.Fill(dt) + ' Case "EXCEL" + ' Conexion = New Odbc.OdbcConnection("Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ=" + Ruta + FileName + ";") + ' Conexion.Open() + ' Dim cmd = Conexion.CreateCommand() + ' cmd.CommandType = CommandType.Text + ' cmd.CommandText = $"SELECT * FROM [{HojaExcel}]" + ' Dim DataAdapter = New Odbc.OdbcDataAdapter(cmd) + ' DataAdapter.Fill(dt) + ' Case Else + ' Alert("El archivo no tiene el formato correcto", TipoMensaje.MsgError) + ' Exit Sub + ' End Select + 'Catch ex As Exception + ' ErrorArchivo = True + ' OnError("Ocurrio un error al leer el archivo
" & ex.Message, ex) + 'End Try + 'Conexion.Close() + If dt IsNot Nothing Then dt.Columns(0).ColumnName = "FechaDocumento" dt.Columns(1).ColumnName = "Referencia" dt.Columns(2).ColumnName = "Importe" @@ -166,6 +216,8 @@ Partial Class Bancos_CargarConciliacionesBancarias ObjBancos.RollBack() End If ObjBancos.Dispose() + Else + Alert("Hubo un error al intentar leer el archivo.", TipoMensaje.MsgError) End If End Sub diff --git a/Bancos/CatBancos.aspx b/Bancos/CatBancos.aspx index b0ce3dd00..3fa839955 100644 --- a/Bancos/CatBancos.aspx +++ b/Bancos/CatBancos.aspx @@ -6,6 +6,12 @@ +
  • + PDF +
  • +
  • + Excel +
  • Catálogo de Bancos @@ -15,7 +21,7 @@ - +
    + "--%> + + diff --git a/SigAyuda.aspx.vb b/SigAyuda.aspx.vb new file mode 100644 index 000000000..5172f53a7 --- /dev/null +++ b/SigAyuda.aspx.vb @@ -0,0 +1,32 @@ + +Partial Class Metronic_SigAyuda + Inherits System.Web.UI.Page + + Protected Sub btnDownload_Click(sender As Object, e As EventArgs) + Try + Dim docto As String = TxtDocto.Text.Replace("/", "\") + + Dim path As String = $"{AppDomain.CurrentDomain.BaseDirectory}{docto}" + + + Dim file As New System.IO.FileInfo(path) + Dim mimeType As String = "text/plain" + Try + mimeType = MimeMapping.GetMimeMapping(path) + Catch ex As Exception + End Try + 'Response.Write(path) + Response.Clear() + Response.ClearHeaders() + Response.ClearContent() + Response.AddHeader("Content-Disposition", $"attachment; filename= {Uri.EscapeDataString(file.Name)}") + Response.AddHeader("Content-Length", file.Length.ToString()) + Response.ContentType = mimeType + Response.Flush() + Response.TransmitFile(file.FullName) + Response.End() + Catch ex As Exception + 'GuardaLog($"GenerateFile: {ex.ToString()}") + End Try + End Sub +End Class diff --git a/Sistemas/ConfiguracionEmpresa.aspx b/Sistemas/ConfiguracionEmpresa.aspx index ca36a2e4c..4d55ec0e0 100644 --- a/Sistemas/ConfiguracionEmpresa.aspx +++ b/Sistemas/ConfiguracionEmpresa.aspx @@ -54,43 +54,191 @@ - - - - + + + + + + + + + + + + + + + + +
    diff --git a/Bancos/CatBancos.aspx.vb b/Bancos/CatBancos.aspx.vb index 1319d2070..9a57ab193 100644 --- a/Bancos/CatBancos.aspx.vb +++ b/Bancos/CatBancos.aspx.vb @@ -4,54 +4,67 @@ Option Strict On Imports System.Data Imports System.Linq Imports Extensiones +Imports Microsoft.Reporting.WebForms Partial Class Bancos_CatBancos - Inherits ClsPaginas + Inherits ClsPaginas - Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load - If Not Page.IsPostBack Then - ViewState("Orden") = "" - CargaDatos() - End If - End Sub + Private Property DtBan As DataTable + Get + DtBan = DirectCast(ViewState("DtBan"), DataTable) + End Get - Public Sub CargaDatos() - Dim ObjBancos As New ClsBancos - If ObjBancos.GetBancos() Then - ViewState("DTBancos") = ObjBancos.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) - GlobalDTBancos = ObjBancos.DtResultados - Else - Me.GvDatos.DataSource = Nothing - End If + Set(ByVal value As DataTable) + ViewState("DtBan") = value + End Set + End Property - ObjBancos.Dispose() + Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load + If Not Page.IsPostBack Then + ViewState("Orden") = "" + CargaDatos() + End If + End Sub - If ViewState("Orden").ToString() <> String.Empty Then - CargaGrid(ViewState("Orden").ToString()) - Else - CargaGrid("") - End If - End Sub + Public Sub CargaDatos() + Dim ObjBancos As New ClsBancos + If ObjBancos.GetBancos() Then + ViewState("DTBancos") = ObjBancos.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) + DtBan = ObjBancos.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) + GlobalDTBancos = ObjBancos.DtResultados + Else + Me.GvDatos.DataSource = Nothing + End If - Protected Sub LbAgregar_Click(sender As Object, e As System.EventArgs) Handles LbAgregar.Click - Dim ObjBancos As New ClsBancos - If ObjBancos.AddBancos(TxtBanco.Text.Trim, TxtEjecutivo.Text.Trim, TxtTelefono.Text.Trim, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then - TxtBanco.Text = "" - TxtEjecutivo.Text = "" + ObjBancos.Dispose() + + If ViewState("Orden").ToString() <> String.Empty Then + CargaGrid(ViewState("Orden").ToString()) + Else + CargaGrid("") + End If + End Sub + + Protected Sub LbAgregar_Click(sender As Object, e As System.EventArgs) Handles LbAgregar.Click + Dim ObjBancos As New ClsBancos + If ObjBancos.AddBancos(TxtBanco.Text.Trim, TxtEjecutivo.Text.Trim, TxtTelefono.Text.Trim, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then + TxtBanco.Text = "" + TxtEjecutivo.Text = "" TxtTelefono.Text = "" Alert("El nuevo Banco se guardó correctamente.", TipoMensaje.MsgInformacion) - UpTitulos.Update() - ViewState("DTBancos") = ObjBancos.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) - GlobalDTBancos = ObjBancos.DtResultados + UpTitulos.Update() + ViewState("DTBancos") = ObjBancos.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) + DtBan = ObjBancos.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) + GlobalDTBancos = ObjBancos.DtResultados - If ViewState("Orden").ToString() <> String.Empty Then - CargaGrid(ViewState("Orden").ToString()) - Else - CargaGrid("") - End If - End If - ObjBancos.Dispose() - End Sub + If ViewState("Orden").ToString() <> String.Empty Then + CargaGrid(ViewState("Orden").ToString()) + Else + CargaGrid("") + End If + End If + ObjBancos.Dispose() + End Sub #Region "G V D A T O S" Protected Sub GvDatos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvDatos.RowDataBound @@ -80,6 +93,7 @@ Partial Class Bancos_CatBancos If ObjBancos.RemoveBancos(GvDatos.DataKeys(e.RowIndex).Value.ToString.ToEntero) Then GvDatos.EditIndex = -1 ViewState("DTBancos") = ObjBancos.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) + DtBan = ObjBancos.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) GlobalDTBancos = ObjBancos.DtResultados Alert("El Banco se eliminó correctamente.", TipoMensaje.MsgInformacion) End If @@ -116,6 +130,7 @@ Partial Class Bancos_CatBancos If ObjBancos.UpdateBancos(Banco, Ejecutivo, Telefono, Estatus, CveBanco) Then GvDatos.EditIndex = -1 ViewState("DTBancos") = ObjBancos.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) + DtBan = ObjBancos.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) GlobalDTBancos = ObjBancos.DtResultados Alert("Los cambios se guardaron correctamente.", TipoMensaje.MsgInformacion) End If @@ -178,4 +193,28 @@ Partial Class Bancos_CatBancos UpDatos.Update() End Sub #End Region + Protected Sub LbPDF_Click(sender As Object, e As EventArgs) + Imprime("PDF") + End Sub + Protected Sub LbExcel_Click(sender As Object, e As EventArgs) + Imprime("Excel") + End Sub + Private Sub Imprime(Formato As String) + + If DtBan IsNot Nothing AndAlso DtBan.Rows.Count > 0 Then + Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta)) + Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa) + Dim params As New List(Of ReportParameter) + params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa)) + params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre)) + If Imagen.Exists Then + params.Add(New ReportParameter("LogoPath", logouri)) + Else + params.Add(New ReportParameter("LogoPath", "")) + End If + ImprimirPDF("Empresas/Grales/Formatos/RepBancos.rdlc", DtBan, params, "Reporte Bancos", Formato) + Else + Alert("No hay información para mostrar.", TipoMensaje.MsgAdvertencia) + End If + End Sub End Class diff --git a/Bancos/CuentasBancarias.aspx b/Bancos/CuentasBancarias.aspx index 54c0bf16e..af859f8e3 100644 --- a/Bancos/CuentasBancarias.aspx +++ b/Bancos/CuentasBancarias.aspx @@ -6,14 +6,17 @@ - - -
  • - Agregar Cuenta Bancaria - <%-- Nuevo Número de Cuenta Bancaria--%> -
  • -
    -
    + +
  • + Agregar Cuenta Bancaria + <%-- Nuevo Número de Cuenta Bancaria--%> +
  • +
  • + PDF +
  • +
  • + Excel +
  • Catálogo de Número de Cuentas Bancarias / Cajas Chicas. @@ -23,10 +26,10 @@ - + - - + + Banco   @@ -35,7 +38,7 @@   - + CLABE   @@ -43,26 +46,30 @@ Moneda   - + Folio Inicial - - + + + Estatus - + + Fecha - + + - + Usuario - + + diff --git a/Bancos/CuentasBancarias.aspx.vb b/Bancos/CuentasBancarias.aspx.vb index 22baa958e..6d32e50af 100644 --- a/Bancos/CuentasBancarias.aspx.vb +++ b/Bancos/CuentasBancarias.aspx.vb @@ -4,9 +4,21 @@ Option Strict On Imports System.Data Imports System.Linq Imports Extensiones +Imports Microsoft.Reporting.WebForms Partial Class Bancos_CuentasBancarias Inherits ClsPaginas + + Private Property DtBan As DataTable + Get + DtBan = DirectCast(ViewState("DtBan"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtBan") = value + End Set + End Property + 'Configuración Private ReadOnly Property CveCuenta As Integer Get @@ -22,7 +34,7 @@ Partial Class Bancos_CuentasBancarias Dim ObjBancos As New ClsBancos If ObjBancos.GetBancosCuentas(-1) Then ViewState("DTBancosCuentas") = ObjBancos.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) - + DtBan = ObjBancos.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) Else Me.GvDatos.DataSource = Nothing End If @@ -53,6 +65,7 @@ Partial Class Bancos_CuentasBancarias If ObjBancos.RemoveBancosCuentas(GvDatos.DataKeys(e.RowIndex).Value.ToString.ToEntero) Then GvDatos.EditIndex = -1 ViewState("DTBancosCuentas") = ObjBancos.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) + DtBan = ObjBancos.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) If ObjBancos.GetBancosCuentasUsuarios(-1) Then GlobalDTBancosCuentas(-1) = ObjBancos.DtResultados End If @@ -126,4 +139,27 @@ Partial Class Bancos_CuentasBancarias GvDatos.DataBind() UpDatos.Update() End Sub + Protected Sub LbPDF_Click(sender As Object, e As EventArgs) + Imprime("PDF") + End Sub + Protected Sub LbExcel_Click(sender As Object, e As EventArgs) + Imprime("Excel") + End Sub + Private Sub Imprime(Formato As String) + If DtBan IsNot Nothing AndAlso DtBan.Rows.Count > 0 Then + Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta)) + Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa) + Dim params As New List(Of ReportParameter) + params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa)) + params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre)) + If Imagen.Exists Then + params.Add(New ReportParameter("LogoPath", logouri)) + Else + params.Add(New ReportParameter("LogoPath", "")) + End If + ImprimirPDF("Empresas/Grales/Formatos/CuentasBancarias.rdlc", DtBan, params, "Reporte de Cuentas Bancarias", Formato) + Else + Alert("No hay información para mostrar.", TipoMensaje.MsgAdvertencia) + End If + End Sub End Class diff --git a/Bancos/IE.aspx b/Bancos/IE.aspx index d0acbfa05..0e5e68162 100644 --- a/Bancos/IE.aspx +++ b/Bancos/IE.aspx @@ -712,6 +712,7 @@
    PercepcionesDeducciones
    Clave de Empresa: - - - + + + + +
    Razón Social:Proveedores: - - - + + + + + + + + + + +
    Deudores: + + + + + + + + + + +
    Almacen: + + + + + + + + + + +
    Costo: + + + + + + + + + +
    + +
    +
    +
    + + Clasificaciones +
    +
    +
    +
    +
    +
    + +
    +
    +
    + + + + + + + +
    + +
    +
    +
    + +
    +
    +
    +
    + + Impuestos +
    +
    +
    +
    +
    +
    + +
    +
    +
    + + + + + + + + + + +
    IVA Trasladado:
    +
    +
    +
    +
    +
    + + Configuración del Servidor de Contabilidad +
    +
    +
    +
    +
    +
    + +
    +
    +
    + + + + + + + + + + + + + + + + + +
    BDContPAQi: + + <%-- + --%> +
    Server ContPAQi: + +
    Usuario ContPAQi: + +
    Password ContPAQi: + +
    +
    +
    - - - - - - - - - - +
    -
    diff --git a/Sistemas/ConfiguracionEmpresa.aspx.vb b/Sistemas/ConfiguracionEmpresa.aspx.vb index 2089a9192..9726e9958 100644 --- a/Sistemas/ConfiguracionEmpresa.aspx.vb +++ b/Sistemas/ConfiguracionEmpresa.aspx.vb @@ -17,7 +17,158 @@ Partial Class Sistemas_ConfiguracionEmpresa Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not IsPostBack Then + CargaCuentasClientesSIG(DdlCtaContableClientes) + CargaCuentasClientesSIG(DdlCtaContableProveedores) + CargaCuentasClientesSIG(DdlCtaContableDeudores) + CargaCuentasClientesSIG(DdlCtaContableAlmacen) + CargaCuentasClientesSIG(DdlCtaContableCosto) End If End Sub +#Region "Carga Cuentas" + Private Sub CargaCuentasClientesSIG(ddl As DropDownList) + Dim ObjContabilidad As New ClsContabilidad + + If ObjContabilidad.GetCuentas(-1, "-1", 1, UsuarioActual.CveEmpresa) Then + ddl.Items.Clear() + ddl.Items.Add(New ListItem("Seleccione", "0")) + ddl.DataSource = ObjContabilidad.DtResultados + ddl.DataBind() + End If + ObjContabilidad.Dispose() + End Sub + Private Sub CargaCuentasClientesCompaq(ddl As DropDownList) + Dim ObjCompaq As New ClsContPAQi(UsuarioActual.Empresa) + + If ObjCompaq.GetCuentas(-1, "-1", 1) Then + ddl.Items.Clear() + ddl.Items.Add(New ListItem("Seleccione", "0")) + ddl.DataSource = ObjCompaq.DtResultados + ddl.DataBind() + End If + ObjCompaq.Dispose() + End Sub + + 'Private Sub CargaCuentasProveedoresSIG() + ' Dim ObjContabilidad As New ClsContabilidad + + ' If ObjContabilidad.GetCuentas(-1, "-1", 1, UsuarioActual.CveEmpresa) Then + ' DdlCtaContableClientes.Items.Clear() + ' DdlCtaContableClientes.Items.Add(New ListItem("Seleccione", "0")) + ' DdlCtaContableClientes.DataSource = ObjContabilidad.DtResultados + ' DdlCtaContableClientes.DataBind() + ' End If + ' ObjContabilidad.Dispose() + 'End Sub + 'Private Sub CargaCuentasProveedoresCompaq() + ' Dim ObjCompaq As New ClsContPAQi(UsuarioActual.Empresa) + + ' If ObjCompaq.GetCuentas(-1, "-1", 1) Then + ' DdlCtaContableClientes.Items.Clear() + ' DdlCtaContableClientes.Items.Add(New ListItem("Seleccione", "0")) + ' DdlCtaContableClientes.DataSource = ObjCompaq.DtResultados + ' DdlCtaContableClientes.DataBind() + ' End If + ' ObjCompaq.Dispose() + 'End Sub + + 'Private Sub CargaCuentasDeudoresSIG() + ' Dim ObjContabilidad As New ClsContabilidad + + ' If ObjContabilidad.GetCuentas(-1, "-1", 1, UsuarioActual.CveEmpresa) Then + ' DdlCtaContableClientes.Items.Clear() + ' DdlCtaContableClientes.Items.Add(New ListItem("Seleccione", "0")) + ' DdlCtaContableClientes.DataSource = ObjContabilidad.DtResultados + ' DdlCtaContableClientes.DataBind() + ' End If + ' ObjContabilidad.Dispose() + 'End Sub + 'Private Sub CargaCuentassDeudoresCompaq() + ' Dim ObjCompaq As New ClsContPAQi(UsuarioActual.Empresa) + + ' If ObjCompaq.GetCuentas(-1, "-1", 1) Then + ' DdlCtaContableClientes.Items.Clear() + ' DdlCtaContableClientes.Items.Add(New ListItem("Seleccione", "0")) + ' DdlCtaContableClientes.DataSource = ObjCompaq.DtResultados + ' DdlCtaContableClientes.DataBind() + ' End If + ' ObjCompaq.Dispose() + 'End Sub + + 'Private Sub CargaCuentasAlmacenSIG() + ' Dim ObjContabilidad As New ClsContabilidad + + ' If ObjContabilidad.GetCuentas(-1, "-1", 1, UsuarioActual.CveEmpresa) Then + ' DdlCtaContableClientes.Items.Clear() + ' DdlCtaContableClientes.Items.Add(New ListItem("Seleccione", "0")) + ' DdlCtaContableClientes.DataSource = ObjContabilidad.DtResultados + ' DdlCtaContableClientes.DataBind() + ' End If + ' ObjContabilidad.Dispose() + 'End Sub + 'Private Sub CargaCuentasAlmacenCompaq() + ' Dim ObjCompaq As New ClsContPAQi(UsuarioActual.Empresa) + + ' If ObjCompaq.GetCuentas(-1, "-1", 1) Then + ' DdlCtaContableClientes.Items.Clear() + ' DdlCtaContableClientes.Items.Add(New ListItem("Seleccione", "0")) + ' DdlCtaContableClientes.DataSource = ObjCompaq.DtResultados + ' DdlCtaContableClientes.DataBind() + ' End If + ' ObjCompaq.Dispose() + 'End Sub + + 'Private Sub CargaCuentasCostoSIG() + ' Dim ObjContabilidad As New ClsContabilidad + + ' If ObjContabilidad.GetCuentas(-1, "-1", 1, UsuarioActual.CveEmpresa) Then + ' DdlCtaContableClientes.Items.Clear() + ' DdlCtaContableClientes.Items.Add(New ListItem("Seleccione", "0")) + ' DdlCtaContableClientes.DataSource = ObjContabilidad.DtResultados + ' DdlCtaContableClientes.DataBind() + ' End If + ' ObjContabilidad.Dispose() + 'End Sub + 'Private Sub CargaCuentasCostoCompaq() + ' Dim ObjCompaq As New ClsContPAQi(UsuarioActual.Empresa) + + ' If ObjCompaq.GetCuentas(-1, "-1", 1) Then + ' DdlCtaContableClientes.Items.Clear() + ' DdlCtaContableClientes.Items.Add(New ListItem("Seleccione", "0")) + ' DdlCtaContableClientes.DataSource = ObjCompaq.DtResultados + ' DdlCtaContableClientes.DataBind() + ' End If + ' ObjCompaq.Dispose() + 'End Sub +#End Region + + Protected Sub RblTipo_SelectedIndexChanged(sender As Object, e As EventArgs) Handles RblTipo.SelectedIndexChanged + If RblTipo.SelectedValue = "SIG" Then + DvServidorConta.Visible = False + CargaCuentasClientesSIG(DdlCtaContableClientes) + CargaCuentasClientesSIG(DdlCtaContableProveedores) + CargaCuentasClientesSIG(DdlCtaContableDeudores) + CargaCuentasClientesSIG(DdlCtaContableAlmacen) + CargaCuentasClientesSIG(DdlCtaContableCosto) + Else + DvServidorConta.Visible = True + CargaCuentasClientesCompaq(DdlCtaContableClientes) + CargaCuentasClientesCompaq(DdlCtaContableProveedores) + CargaCuentasClientesCompaq(DdlCtaContableDeudores) + CargaCuentasClientesCompaq(DdlCtaContableAlmacen) + CargaCuentasClientesCompaq(DdlCtaContableCosto) + End If + End Sub + + Protected Sub BtnGuardar_Click(sender As Object, e As System.EventArgs) Handles BtnGuardar.Click + Dim ObjEmpresas As New ClsSisEmpresas + ObjEmpresas.IniciaTransacSQL() + + Alert("sdfsz") + + + + ObjEmpresas.Dispose() + + End Sub End Class diff --git a/Ventas/PV.aspx b/Ventas/PV.aspx index 29036f542..ccd0a5d7e 100644 --- a/Ventas/PV.aspx +++ b/Ventas/PV.aspx @@ -1193,11 +1193,22 @@ - - + <%----%> + <%----%>

    +
    +
    +
    + +
    + $ + + +

    +
    +
    @@ -3180,7 +3191,17 @@ var totalTransferencia = ToDouble($get("TxtImporteTransferencia").value); var total = totalEfectivo + totalCredito + totalDebito + totalCheque + totalTransferencia; + + var totalVenta = ToDouble($get('TxtTotal').value); + + if (totalEfectivo > totalVenta) { + $get("TxtCambio").value = FormatoNumero(totalEfectivo - totalVenta); + } else { + $get("TxtCambio").value = "0.00"; + } + $get("TxtImporteContado").value = total; + } // **************************************************************************************************************************************************************************** @@ -3491,9 +3512,17 @@ $('#divAgregarCliente').modal(); } + function hideDivEC() { $('#divAgregarCliente').modal('hide'); } + function CambiaAjuste(txt, txtajuste) { + Recalcula(); + if (txtajuste != null) { + txtajuste.value = ToDouble(txt.value) + } + } +
    diff --git a/Ventas/PV.aspx.vb b/Ventas/PV.aspx.vb index 4e27af4bd..d212cc67b 100644 --- a/Ventas/PV.aspx.vb +++ b/Ventas/PV.aspx.vb @@ -1032,8 +1032,8 @@ Partial Class PV TxtFecha.Text = Now.ToShortDateString() LblUsuario.Text = UsuarioActual.Usuario - TxtPrecio.Attributes.Add("onKeyUp ", "Recalcula();") TxtCantidad.Attributes.Add("onKeyUp ", "Recalcula();") + TxtPrecio.Attributes.Add("onKeyUp ", "Recalcula();") ImgDescPU.Attributes.Add("onclick", "javascript:$('#ModalDescuento').modal(); $get('LblTitulo1').style.display = ''; $get('LblTitulo2').style.display = 'none'; $get('LblTituloTipo1').style.display = ''; $get('LblTituloTipo2').style.display = 'none'; $get('HdnTipoDescuento').value = '0'; $get('LblPrecio1').style.display = ''; $get('LblTotalPS1').style.display = 'none'; $get('LblSubTotal1').style.display = 'none'; $get('LblAmort').style.display = 'none'; $get('BtnAplicarDescP').style.display = ''; $get('BtnAplicarDescG').style.display = 'none'; $get('TrMotivoDescuento').style.display = '';") 'ImgDescConcepto.Attributes.Add("onclick", "javascript:$('#ModalDescuento').modal(); $get('LblTitulo1').style.display = ''; $get('LblTitulo2').style.display = 'none'; $get('LblTituloTipo1').style.display = ''; $get('LblTituloTipo2').style.display = 'none'; $get('HdnTipoDescuento').value = '1'; $get('LblPrecio1').style.display = 'none'; $get('LblTotalPS1').style.display = ''; $get('LblSubTotal1').style.display = 'none'; $get('LblAmort').style.display = 'none'; $get('BtnAplicarDescP').style.display = ''; $get('BtnAplicarDescG').style.display = 'none'; $get('TrMotivoDescuento').style.display = '';") ImgDescTotal.Attributes.Add("onclick", "javascript:$('#ModalDescuento').modal(); $get('LblTitulo1').style.display = ''; $get('LblTitulo2').style.display = 'none'; $get('LblTituloTipo1').style.display = ''; $get('LblTituloTipo2').style.display = 'none'; $get('HdnTipoDescuento').value = '2'; $get('LblPrecio1').style.display = 'none'; $get('LblTotalPS1').style.display = 'none'; $get('LblSubTotal1').style.display = ''; $get('LblAmort').style.display = 'none'; $get('BtnAplicarDescP').style.display = 'none'; $get('BtnAplicarDescG').style.display = ''; $get('TrMotivoDescuento').style.display = '';") @@ -1476,7 +1476,7 @@ Partial Class PV HdnIVAOriginal.Value = TxtIVA.Text 'JJMQ 20160506: Se agrego para la validacion de pago de contado. - CVImporteContado.ValueToCompare = TxtTotal.Text.Replace(",", "") + 'CVImporteContado.ValueToCompare = TxtTotal.Text.Replace(",", "") If DdlVendedor.SelectedValue.ToEntero > 0 AndAlso Not UsuarioActual.TienePermisoProceso(161) Then DdlVendedor.Enabled = False @@ -1967,7 +1967,7 @@ Partial Class PV Alert("Eliminado Correctamente.", TipoMensaje.MsgInformacion) 'JJMQ 20160506: Se agrego para la validacion de pago de contado. - CVImporteContado.ValueToCompare = TxtTotal.Text.Replace(",", "") + 'CVImporteContado.ValueToCompare = TxtTotal.Text.Replace(",", "") UpContado.Update() End Sub @@ -3085,7 +3085,7 @@ Partial Class PV End If 'JJMQ 20160506: Se agrego para la validacion de pago de contado. - CVImporteContado.ValueToCompare = TxtTotal.Text.Replace(",", "") + 'CVImporteContado.ValueToCompare = TxtTotal.Text.Replace(",", "") UpContado.Update() Else @@ -3903,7 +3903,7 @@ Partial Class PV HdnIVAOriginal.Value = TxtIVA.Text 'JJMQ 20160506: Se agrego para la validacion de pago de contado. - CVImporteContado.ValueToCompare = Total.ToString + 'CVImporteContado.ValueToCompare = Total.ToString Dim view As DataView = New DataView(TmpDT) view.Sort = "Consec" @@ -4264,6 +4264,7 @@ Partial Class PV TxtImporteCheque.Text = "0.00" TxtImporteTransferencia.Text = "0.00" TxtImporteContado.Text = "0.00" + TxtCambio.Text = "0.00" End Sub Private Sub LimpiaEscondeContado() 'LIMPIA @@ -4336,7 +4337,7 @@ Partial Class PV 'JJMQ 20160506: Validacion para no pagar de mas a peticion de I.P. Dim abonado = DtPagos.SUM("Importe") Dim saldo = TxtTotal.Text.Replace(",", "").ToDouble - abonado - CVImporteContado.ValueToCompare = (saldo.FormatoNumero(2).ToDouble).ToString + 'CVImporteContado.ValueToCompare = (saldo.FormatoNumero(2).ToDouble).ToString CargaGridContado() UpContado.Update() @@ -4350,7 +4351,7 @@ Partial Class PV If total <= 0 Then Alert("No se ha ingresado importe", TipoMensaje.MsgAdvertencia) : Exit Sub - If DtPagos.SUM("Importe").ToString.ToDecimal + total > TxtTotal.Text.ToDecimal Then + If (DtPagos.SUM("Importe").ToString.ToDecimal + total - TxtCambio.Text.ToDecimal) > TxtTotal.Text.ToDecimal Then Alert("El importe de los pagos no puede exceder el importe de la factura. Por favor rectifique.", TipoMensaje.MsgAdvertencia) Exit Sub End If @@ -4363,7 +4364,7 @@ Partial Class PV DrEfectivo("TipoMovimiento") = "Pago en Efectivo" DrEfectivo("CveCuenta") = DdlCuentaEfectivo.SelectedValue DrEfectivo("Cuenta") = DdlCuentaEfectivo.SelectedItem.Text - DrEfectivo("Importe") = TxtImporteEfectivo.Text + DrEfectivo("Importe") = TxtImporteEfectivo.Text.ToDecimal - TxtCambio.Text.ToDecimal DrEfectivo("Folio") = CargaFolioContado(DdlCuentaEfectivo.SelectedValue.ToEntero, 6) DrEfectivo("Observaciones") = "" DrEfectivo("Tipo") = "Caja Chica" @@ -4456,7 +4457,7 @@ Partial Class PV 'JJMQ 20160506: Validacion para no pagar de mas a peticion de I.P. abonado = DtPagos.SUM("Importe") saldo = TxtTotal.Text.Replace(",", "").ToDouble - abonado - CVImporteContado.ValueToCompare = (saldo.FormatoNumero(2).ToDouble).ToString + 'CVImporteContado.ValueToCompare = (saldo.FormatoNumero(2).ToDouble).ToString CargaGridContado() UpContado.Update() @@ -4873,7 +4874,7 @@ Partial Class PV Dim ObjVenta As New ClsVentas If ObjVenta.GetVentas(UsuarioActual.CveEmpresa, "Ing", "-1", -1, "-1", CveCliente, -1, -1, -1, "-1", "-1", "-1", CveUsuarioConsulta:=UsuarioActual.CveUsuario) Then DdlFacturas.DataSource = ObjVenta.DtResultados - DdlFacturas.Items.Insert(0, New ListItem("Seleccione", "-1")) + DdlFacturas.Items.Insert(0, New ListItem("Sin Factura", "-1")) End If ObjVenta.Dispose() DdlFacturas.DataBind() @@ -4888,7 +4889,7 @@ Partial Class PV End If - DdlFacturas.Items.Insert(0, New ListItem("Seleccione", "-1")) + DdlFacturas.Items.Insert(0, New ListItem("Sin Factura", "-1")) DdlTipoUso.DataSource = GlobalDTAcumTiposUso.FiltraParametros($"CveEmpresa = {UsuarioActual.CveEmpresa}") DdlTipoUso.Items.Insert(0, New ListItem("Seleccione", "-1")) @@ -4920,7 +4921,7 @@ Partial Class PV DtPUFacturas.Rows.Clear() If DdlFacturas.SelectedValue.ToEntero > 0 Then - TxtPUFactura.Enabled = False + 'TxtPUFactura.Enabled = False Dim ObjVenta As New ClsVentas If ObjVenta.GetVentaDetalle(DdlFacturas.SelectedValue.ToEntero) Then DdlPSAjuste.DataSource = ObjVenta.DtResultados @@ -4929,8 +4930,8 @@ Partial Class PV End If ObjVenta.Dispose() Else - TxtPUFactura.Enabled = True - TxtPUFactura.Text = "" + 'TxtPUFactura.Enabled = True + 'TxtPUFactura.Text = "" DdlPSAjuste.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa) End If DdlPSAjuste.DataBind() @@ -4944,11 +4945,13 @@ Partial Class PV LimpiaAjuste() If TmpDTAjustes IsNot Nothing AndAlso TmpDTAjustes.FiltraParametros($"ConsecutivoVenta = {ConsecutivoVenta}").Rows.Count > 0 Then ModalidadAjuste = "U" + TxtPrecio.Attributes.Add("onKeyUp", $"CambiaAjuste(this,{TxtPUFactura.ClientID});") ChkAjuste.Checked = True DivAjuste.Visible = True CargaAjusteDetalle() Else ModalidadAjuste = "A" + TxtPrecio.Attributes.Add("onKeyUp ", "Recalcula();") End If End Sub @@ -4958,6 +4961,7 @@ Partial Class PV TxtCodEnsamble.Text = "" DdlTipoUso.SelectedIndex = -1 TxtCodLinea.Text = "" + TxtPUFactura.Text = "" TxtFechaAjuste.Text = Now.ToShortDateString CEEFechaAjuste.EndDate = Now TxtCodInspeccion.Text = "" @@ -5023,11 +5027,11 @@ Partial Class PV End If Contador += 1 Next - TxtPUFactura.Text = PUFactura.FormatoNumero(2) + 'TxtPUFactura.Text = PUFactura.FormatoNumero(2) End If If Not DdlPSAjuste.SelectedValue.ToEntero > 0 AndAlso DdlFacturas.SelectedValue.ToEntero > 0 Then - TxtPUFactura.Text = "" + 'TxtPUFactura.Text = "" End If CalculaPorcentajeAjuste() @@ -5115,6 +5119,9 @@ Partial Class PV 'End Function Private Sub GuardaAjuste() + TxtPUFactura.Text = TxtPrecio.Text + UpAjuste.Update() + Dim CargoAnterior As Double = 0 Dim CargoActual As Double = 0 If ModalidadAjuste = "A" Then @@ -5222,9 +5229,12 @@ Partial Class PV DivAjuste.Attributes.Add("class", "col-md-6") DivDatosVenta.Attributes.Remove("class") DivDatosVenta.Attributes.Add("class", "col-md-6") + TxtPrecio.Attributes.Add("onKeyUp", $"CambiaAjuste(this,{TxtPUFactura.ClientID});") + TxtPUFactura.Text = TxtPrecio.Text Else DivAjuste.Visible = False TxtCantidad.Enabled = True + TxtPrecio.Attributes.Add("onKeyUp ", "Recalcula();") DivModalVenta.Attributes.Remove("class") DivModalVenta.Attributes.Add("class", "modal-dialog") DivAjuste.Attributes.Remove("class") diff --git a/Ventas/ProductosServicios.aspx b/Ventas/ProductosServicios.aspx index 29c2aca5d..a58e7234a 100644 --- a/Ventas/ProductosServicios.aspx +++ b/Ventas/ProductosServicios.aspx @@ -140,7 +140,7 @@ -
    +
    @@ -201,7 +201,7 @@
    -
    +
    @@ -209,7 +209,9 @@
    + +
    Seleccione @@ -1970,6 +1972,7 @@
    + <%-- FIN MODAL PS ADICIONALES --%> @@ -2146,7 +2149,10 @@ var initcarusel2 = initcarusel; - + function ADSReady() + { + setPoscicion(); + } //TERMINA: ECOMMERCE diff --git a/Ventas/ProductosServicios.aspx.vb b/Ventas/ProductosServicios.aspx.vb index 31ec53798..165888d40 100644 --- a/Ventas/ProductosServicios.aspx.vb +++ b/Ventas/ProductosServicios.aspx.vb @@ -216,7 +216,7 @@ Partial Class ProductosyServicios 'DivDatos.Attributes("class") = "col-md-12" DivDdlTipo.Visible = True - DdlTipoPSDes.Attributes.Add("onChange", "CreaDescripcionPS();") + 'DdlTipoPSDes.Attributes.Add("onChange", "CreaDescripcionPS();") End If @@ -235,16 +235,11 @@ Partial Class ProductosyServicios If ddlMetodos.SelectedValue.ToEntero = 5 And Not UsuarioActual.TienePermisoProceso(255) Then ddlMetodos.Enabled = False End If + Dim posiciontipo As String = If(UsuarioActual.Empresa.Funcionalidad(558).ToString = "1", "$('.DIVCLASIFICACIONCONTABLE').after( $('.DIVTIPO') );", "") + LtlScripts.Text = $"" If Not CvePS > 0 Then MuestraPanel(True) - - - - - - - End If End Sub diff --git a/Ventas/RepProductosServicios.aspx b/Ventas/RepProductosServicios.aspx index df1d14bf3..ee9d8692e 100644 --- a/Ventas/RepProductosServicios.aspx +++ b/Ventas/RepProductosServicios.aspx @@ -9,6 +9,40 @@ background-color: rgba(172, 195, 222, 0.65) !important; } + .select2 .select2-selection__rendered { + line-height: 1; + color: #111; + } + + .select2 .select2-selection--multiple { + box-sizing: border-box; + cursor: pointer; + display: block; + min-height: 20px; + user-select: none; + -webkit-user-select: none; + } + + .select2-container--default .select2-selection--multiple .select2-selection__choice { + margin-top: 10px; + } + + .select2-selection__rendered { + margin-top: 0px; + height: 25px; + } + + .select2-selection { + margin-top: 0px; + height: 31px; + } + + .select2-container--default.select2-container--focus .select2-selection--multiple { + border: none; + outline: 0; + } + + #chartdiv { width: 100%; height: 500px; @@ -65,7 +99,17 @@
    - + + + + + + + + + + + <%-- @@ -74,7 +118,7 @@ - + --%>
    Fecha Inicio: diff --git a/Ventas/RepProductosServicios.aspx.vb b/Ventas/RepProductosServicios.aspx.vb index 648d3cfdf..cf47e16aa 100644 --- a/Ventas/RepProductosServicios.aspx.vb +++ b/Ventas/RepProductosServicios.aspx.vb @@ -248,6 +248,7 @@ Partial Class Ventas_RepProductosServicios Private Sub CargaDatos() + Dim TipoComprobante As String = If(DdlTipoComprobante.GetSelectedValuesM = "", "-1", DdlTipoComprobante.GetSelectedValuesM) Dim FechaI, FechaF, FechaIEjec, FechaFEjec As Date FechaI = If(IsDate(txtFechaI.Text.Trim()), txtFechaI.Text.ToDate, MinFecha) FechaF = If(IsDate(txtFechaF.Text.Trim()), txtFechaF.Text.ToDate, MaxFecha) @@ -262,7 +263,7 @@ Partial Class Ventas_RepProductosServicios If ObjVentas.GetRepProductosServicios(DdlProyecto.SelectedValue.ToEntero, DdlSubProyecto.SelectedValue.ToEntero, DdlCategoria.SelectedValue.ToEntero, DdlClasificacion.SelectedValue.ToEntero, DdlPS.SelectedValue.ToEntero, FechaI, FechaF, FechaIEjec, FechaFEjec, CveCliente, DdlSubProyectoEjecucion.SelectedValue.ToEntero, DdlVendedor.SelectedValue.ToEntero, DdlUsuario.SelectedValue.ToEntero, DdlEstatus.SelectedValue.ToEntero, "-1", - UsuarioActual.CveEmpresa, DdlGrupo.SelectedValue.ToEntero, CveUsuarioConsulta:=UsuarioActual.CveUsuario, TipoDocto:=DdlTipoComprobante.SelectedValue, + UsuarioActual.CveEmpresa, DdlGrupo.SelectedValue.ToEntero, CveUsuarioConsulta:=UsuarioActual.CveUsuario, TipoDocto:=TipoComprobante, CveClienteClasificacion:=DdlClienteClasificacion.SelectedValue.ToEntero, TipoCambio:=TipoCambio, TCEspecifico:=TCEspecifico, CveProveedorCompra:=CveProveedorCompra, CveMarca:=DdlMarcaPSDes.SelectedValue.ToEntero) Then GvDatos.DataSource = ObjVentas.DtResultados DtVentas = ObjVentas.DtResultados diff --git a/Ventas/RepProductosServiciosDetalle.aspx b/Ventas/RepProductosServiciosDetalle.aspx index 744e2616b..70da39f4f 100644 --- a/Ventas/RepProductosServiciosDetalle.aspx +++ b/Ventas/RepProductosServiciosDetalle.aspx @@ -5,6 +5,39 @@