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/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
- <%-- --%>
-
-
-
+
+
+ Agregar 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 @@
+
@@ -1533,5 +1534,14 @@
t.value = (ToDouble(t.value) > ToDouble(c) ? c : t.value)
}
+ var TipoCambioActual = 0.0;
+ function CambiaTC(txt) {
+ let TipoCambioTxt = ToDouble(txt.value)
+ if (TipoCambioActual != TipoCambioTxt) {
+ $get("BtnCambiaTipoMoneda").click();
+ TipoCambioActual = TipoCambioTxt;
+ }
+ }
+
diff --git a/Bancos/IE.aspx.vb b/Bancos/IE.aspx.vb
index 014263330..5f49dda1f 100644
--- a/Bancos/IE.aspx.vb
+++ b/Bancos/IE.aspx.vb
@@ -649,6 +649,7 @@ Partial Class Bancos_IE
CveIE = -1
TxtFechaDocumento.Text = Now.ToShortDateString
ImgUpdateCuentaDeposito.Visible = False
+ TxtFechaDocumento.Attributes.Add("onchange", "CambiaTC(this);")
End If
InicializaSolicitudAnticipoOC()
@@ -2251,7 +2252,12 @@ Partial Class Bancos_IE
Dep.Dispose()
Return EsValido
- End Function
+ End Function
+
+ Protected Sub BtnCambiaTipoMoneda_Click(sender As Object, e As EventArgs)
+ CambiaTipoMoneda()
+ End Sub
+
Protected Sub BtnGuardar_Click(sender As Object, e As System.EventArgs) Handles BtnGuardar.Click
@@ -2259,9 +2265,7 @@ Partial Class Bancos_IE
Exit Sub
End If
- 'PARA QUE TOME EL TIPO DE CAMBIO DEL DIA
- TxtTipoCambio.Text = GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).ToString
- UpTipoCambio.Update()
+
Dim ObjIE As New ClsBancos()
@@ -3045,14 +3049,13 @@ Partial Class Bancos_IE
'BANCOS COMPLEMENTARIA
If DdlMoneda.SelectedValue.ToEntero > 1 AndAlso UsuarioActual.CveEmpresa.Contiene(1, 119) Then
Dim ImporteAplicar As Decimal = TxtImporte.Text.ToDecimal
- Dim TCPago As Decimal = GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).ToDecimal
- Dim ImporteAplicarMN = (ImporteAplicar * TCPago - ImporteAplicar).RoundSQL()
- If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteAplicar, Ref, 204, Conc, Now, IDCtaContableComplementaria, -1, CveIE, CveCompra:=CveCompraDeCDin, CveProveedor:=CveProveedor, ImporteMX:=ImporteAplicarMN, ImporteME:=ImporteAplicar, CveCuenta:=CveCuentaConta, TipoCambio:=TCPago) Then
+ Dim ImporteAplicarMN = (ImporteAplicar * TxtTipoCambio.Text.ToDecimal - ImporteAplicar).RoundSQL()
+ If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteAplicar, Ref, 204, Conc, Now, IDCtaContableComplementaria, -1, CveIE, CveCompra:=CveCompraDeCDin, CveProveedor:=CveProveedor, ImporteMX:=ImporteAplicarMN, ImporteME:=ImporteAplicar, CveCuenta:=CveCuentaConta, TipoCambio:=TxtTipoCambio.Text.ToDecimal) Then
MsgError = "Ocurrió un error al registrar el asiento de bancos complementaria de devolución"
End If
If CveConceptoCompra = 10 Then
- If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, ImporteAplicar, Ref, 266, Conc, Now, IdCtaAnticipoComplementaria, -1, CveIE, CveCompra:=CveCompraDeCDin, CveProveedor:=CveProveedor, ImporteMX:=ImporteAplicarMN, ImporteME:=ImporteAplicar, CveCuenta:=0, TipoCambio:=TCPago) Then
+ If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, ImporteAplicar, Ref, 266, Conc, Now, IdCtaAnticipoComplementaria, -1, CveIE, CveCompra:=CveCompraDeCDin, CveProveedor:=CveProveedor, ImporteMX:=ImporteAplicarMN, ImporteME:=ImporteAplicar, CveCuenta:=0, TipoCambio:=TxtTipoCambio.Text.ToDecimal) Then
MsgError = "Ocurrió un error al registrar el asiento de bancos complementaria de devolución"
End If
End If
@@ -3834,24 +3837,6 @@ Partial Class Bancos_IE
Else
- 'SE COMENTO PARA PODER DESBLOQUEAR LA PREPOLIZA Y CREAR UNA NUEVA POLIZA
- ''LIMPIA POLIZA PONIENDO IMPORTE EN CEROS
- 'For Each dr As DataRow In dt.Rows
- ' If Not ObjAC.UpdateMovimiento(dr("Id").ToString.ToEntero, dr("IdCuenta").ToString.ToEntero, dr("TipoMovto").ToString = "1", 0, dr("Referencia").ToString, dr("Concepto").ToString, dr("IdSegNeg").ToString.ToEntero, dr("Fecha").ToString.ToDate) Then
- ' ErrorCancelar = True
- ' MensajeError = "Error al actualizar Movimientos con importe 0"
- ' Exit For
- ' End If
- 'Next
-
- ''AJUSTA POLIZA
- 'If Not ErrorCancelar Then
- ' If Not ObjAC.AjustaPoliza(IDPoliza) Then
- ' ErrorCancelar = True
- ' MensajeError = "Error al ajustar poliza negativa"
- ' End If
- 'End If
-
If ObjAC.RemovePoliza(IDPoliza) Then
If Not ObjConta.DesvincularPrePolizaContabilizada(IDPoliza, UsuarioActual.CveEmpresa) Then
ErrorCancelar = True
@@ -3883,7 +3868,9 @@ Partial Class Bancos_IE
End If
End If
-
+ Else
+ ErrorCancelar = True
+ MensajeError = "Error al obtener la poliza"
End If
End If
diff --git a/Bancos/PopIEVentas.aspx.vb b/Bancos/PopIEVentas.aspx.vb
index c19aea954..834dc6bbf 100644
--- a/Bancos/PopIEVentas.aspx.vb
+++ b/Bancos/PopIEVentas.aspx.vb
@@ -1414,6 +1414,7 @@ Partial Class Bancos_PopIEVentas
Dim ObjIE As New ClsBancos()
Dim ObjMov As New ClsContabilidad(ObjIE.IniciaTransacSQL)
+ Dim ObjCliente As New ClsClientes(ObjIE.IniciaTransacSQL)
Dim CvePlantillaPoliza As Integer = 11
Dim ConceptoPoliza As String = String.Format("{0} {1}", NombreCliente, SerieFolio)
@@ -2171,32 +2172,50 @@ Partial Class Bancos_PopIEVentas
TimpocambioGeneral = tipoCambioPago
CveSubProyectoContabilizar = CveSubProyectoVenta
+
+
CveIE = rw.DataKey("CveIE").ToString.ToEntero
'si la factura es en dólares y trae complementaria, el importemn debe ser igual al importe
If CveMoneda = 2 Then
ImporteMX = ImporteMovimiento
IdCtaContable = IdCtaContMonedaExtranjeraAnticipo
+ CveCuenta = CveCuentaMonedaExtranjera
Else
IdCtaContable = IdCtaAnticipo
CveCuenta = CveCuentaAnticipo
End If
TotalPagarCliente = ImporteMovimiento
- If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, ReferenciaConcepto, ConceptoContable, ConceptoMovimiento, Fecha, IdCtaAnticipo, -1, CveIE, CveVenta, -1, CveSubProyectoContabilizar, If(ViewState("CveCliente") IsNot Nothing, ViewState("CveCliente").ToString.ToEntero, -1), ImporteMX:=ImporteMX, CveCuenta:=CveCuenta, TipoCambio:=tipoCambioPago) Then
+
+ If ObjCliente.GetClientes(CveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa) Then
+ If ObjCliente.DtResultados.Rows.Count > 0 Then
+ If CveMoneda = 2 Then
+ IdCtaContable = ObjCliente.IdCtaMonedaExtranjeraAnticipos
+ Else
+ IdCtaContable = ObjCliente.IdCtaContAnticipos
+ End If
+ End If
+ End If
+
+ If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, ReferenciaConcepto, ConceptoContable, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, CveVenta, -1, CveSubProyectoContabilizar, If(ViewState("CveCliente") IsNot Nothing, ViewState("CveCliente").ToString.ToEntero, -1), ImporteMX:=ImporteMX, TipoCambio:=tipoCambioPago) Then
MsgError = "No se pudo insertar la póliza"
End If
If CveMoneda <> 1 AndAlso (IdCtaContMonedaComplementariaAnticipo > 0 Or UsuarioActual.CveEmpresa = 119) Then
IdCtaContable = IdCtaContMonedaComplementariaAnticipo
- CveCuenta = CveCuentaComplementaria
+ If ObjCliente.DtResultados.Rows.Count > 0 Then
+ IdCtaContable = ObjCliente.IdCtaContCompAnticipos
+ End If
If ImporteMovimiento <> 0 AndAlso (IdCtaContable > 0 Or UsuarioActual.CveEmpresa = 119) Then
- If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, ReferenciaConcepto, 227, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, CveVenta, -1, CveSubProyectoContabilizar, If(ViewState("CveCliente") IsNot Nothing, ViewState("CveCliente").ToString.ToEntero, -1), ImporteMX:=ImporteMovimiento * tipoCambioPago - ImporteMovimiento, CveCuenta:=CveCuenta, ImporteME:=ImporteMovimiento, TipoCambio:=tipoCambioPago) Then
+ If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, ReferenciaConcepto, 227, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, CveVenta, -1, CveSubProyectoContabilizar, If(ViewState("CveCliente") IsNot Nothing, ViewState("CveCliente").ToString.ToEntero, -1), ImporteMX:=ImporteMovimiento * tipoCambioPago - ImporteMovimiento, ImporteME:=ImporteMovimiento, TipoCambio:=tipoCambioPago) Then
MsgError = "No se pudo insertar la póliza"
End If
TotalPagarCliente += Math.Round(ImporteMovimiento * tipoCambioVenta - ImporteMovimiento, 2) 'le agrego la complementario
ImporteMX = ImporteMovimiento
IdCtaContable = IdCtaContMonedaExtranjeraAnticipo
- CveCuenta = CveCuentaMonedaExtranjera
+ If ObjCliente.DtResultados.Rows.Count > 0 Then
+ IdCtaContable = ObjCliente.IdCtaMonedaExtranjeraAnticipos
+ End If
End If
End If
@@ -3462,6 +3481,7 @@ Partial Class Bancos_PopIEVentas
ObjIE.Dispose()
ObjMov.Dispose()
+ ObjCliente.Dispose()
'CargaVenta(CveVenta)
'UpDatosVenta.Update()
diff --git a/Bancos/Reportes.aspx.vb b/Bancos/Reportes.aspx.vb
index 3bb4858d2..cdd1eb1d7 100644
--- a/Bancos/Reportes.aspx.vb
+++ b/Bancos/Reportes.aspx.vb
@@ -119,7 +119,7 @@ Partial Class Bancos_Reportes
If Not UsuarioActual.CveEmpresa.Contiene(13, 83) Then
'CONVIERTO A PESOS CUANDO SE PAGA CON PESOS FACTURAS DE DOLARES
For Each Dr As DataRow In dtMovs.Rows
- Dr("Importe") = Dr("Importe").ToString.ToDecimal * Dr("TC").ToString.ToDecimal
+ Dr("Importe") = Dr("ImporteMN").ToString.ToDecimal
Dr("ImporteNC") = Dr("ImporteNC").ToString.ToDecimal * Dr("TC").ToString.ToDecimal
Dr("Total") = Dr("Total").ToString.ToDecimal * Dr("TC").ToString.ToDecimal
Dr("Saldo") = Dr("Saldo").ToString.ToDecimal * Dr("TC").ToString.ToDecimal
diff --git a/CRM/Acercamiento.aspx b/CRM/Acercamiento.aspx
index e60f298e0..8cfb6f104 100644
--- a/CRM/Acercamiento.aspx
+++ b/CRM/Acercamiento.aspx
@@ -718,8 +718,8 @@
+ <%-- FIN MODAL AGREGAR GASTO --%>
diff --git a/CRM/Acercamiento.aspx.cs b/CRM/Acercamiento.aspx.cs
index fc97d5b46..069fe6c19 100644
--- a/CRM/Acercamiento.aspx.cs
+++ b/CRM/Acercamiento.aspx.cs
@@ -210,6 +210,30 @@ public partial class CRM_Acercamiento : ClsPaginas
{
return ModExtensiones.Encripta(param);
}
+ private Boolean Actualizar
+ {
+ get
+ {
+ return (Boolean)ViewState["Actualizar"];
+ }
+
+ set
+ {
+ ViewState["Actualizar"] = value;
+ }
+ }
+ private int CveAcercamientoGasto
+ {
+ get
+ {
+ return ViewState["CveAcercamientoGasto"].ToString().ToEntero();
+ }
+
+ set
+ {
+ ViewState["CveAcercamientoGasto"] = value;
+ }
+ }
#endregion
protected void Page_Load(object sender, EventArgs e)
@@ -219,8 +243,15 @@ public partial class CRM_Acercamiento : ClsPaginas
InicializaDatos();
CargaDatos();
CargaCotizaciones();
+ CargaGastos();
CargaRechazosMotivos();
+ if (UsuarioActual.CveEmpresa == 72)
+ {
+ TabDatosTecnicos.Visible = false;
+ TabImagenes.Visible = false;
+ }
+
if (CveAcercamiento > 0)
{
CargaEtapasBitacora();
@@ -502,7 +533,7 @@ public partial class CRM_Acercamiento : ClsPaginas
}
else
{
- DdlEtapaProceso.DataSource = DTEtapasProceso.FiltraParametros(String.Format("( Orden >= {0} ) AND ( Orden <= {1} )", (OrdenEtapaActual - 1), (OrdenEtapaActual + 1)));
+ DdlEtapaProceso.DataSource = DTEtapasProceso.FiltraParametros(String.Format("(( Orden >= {0} ) AND ( Orden <= {1} )) OR (Orden = 6)", (OrdenEtapaActual - 1), (OrdenEtapaActual + 1)));
}
}
ObjCRM.Dispose();
@@ -524,7 +555,7 @@ public partial class CRM_Acercamiento : ClsPaginas
}
//AUTOGUARDADO DE CAMBIO DE ETAPA
- if (DTEtapasProceso.FiltroPrimeroValor("CveTipoEtapa", String.Format("CveEtapaProceso = {0}", DdlEtapaProceso.SelectedValue.ToEntero())).Contiene("1","2","3"))
+ if (DTEtapasProceso.FiltroPrimeroValor("CveTipoEtapa", String.Format("CveEtapaProceso = {0}", DdlEtapaProceso.SelectedValue.ToEntero())).Contiene("1", "2", "3"))
GuardarCambioEtapa();
}
#endregion
@@ -646,7 +677,7 @@ public partial class CRM_Acercamiento : ClsPaginas
{
CveEtapaActual = CveEtapaProcesoActualActualizar;
HdfEtapaSeleccionada.Value = CveEtapaProcesoActualActualizar.ToString();
-
+
}
ObjCRM.Dispose();
@@ -1412,7 +1443,7 @@ public partial class CRM_Acercamiento : ClsPaginas
if (TieneError)
{
ObjCRM.RollBack();
- Alert("El archivo el eliminó correctamente.",ModExtensiones.TipoMensaje.MsgError);
+ Alert("El archivo el eliminó correctamente.", ModExtensiones.TipoMensaje.MsgError);
}
else
{
@@ -1420,11 +1451,11 @@ public partial class CRM_Acercamiento : ClsPaginas
Alert("El archivo se agregó correctamente");
}
ObjCRM.Dispose();
-
+
CargaImagenes();
UpGaleria.Update();
RegistraScript("$('#Modalupfotos').modal('hide');clickgaleria();");
- }
+ }
}
protected void BtnEliminarFoto_Click(object sender, EventArgs e)
@@ -1473,4 +1504,126 @@ public partial class CRM_Acercamiento : ClsPaginas
}
}
#endregion
+
+ #region "TAB GASTOS"
+ protected void CargaGastos()
+ {
+ ClsCRM ObjCRM = new ClsCRM();
+ if (ObjCRM.GetAcercamientosGastos(CveAcercamiento))
+ {
+ GvGastos.DataSource = ObjCRM.DtResultados;
+ }
+ ObjCRM.Dispose();
+ GvGastos.DataBind();
+ UpGastos.Update();
+ }
+
+ protected void LbAddGastos_Click(object sender, EventArgs e)
+ {
+ LtlTituloModalGasto.Text = "Agregar Gasto";
+ BtnAgregarGastoModal.Text = "Agregar";
+
+ UpModalGastos.Update();
+
+ TxtDescripcionGasto.Text = "";
+ TxtImporteGasto.Text = "";
+
+ Actualizar = false;
+
+ RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarGasto"));
+ }
+
+ protected void BtnAgregarGastoModal_Click(object sender, EventArgs e)
+ {
+ ClsCRM ObjCRM = new ClsCRM();
+
+ if(!Actualizar)
+ {
+ if (ObjCRM.AddAcercamientosGastos(CveAcercamiento, TxtDescripcionGasto.Text, TxtImporteGasto.Text.ToDecimal(), UsuarioActual.CveUsuario))
+ {
+ CargaGastos();
+
+ RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarGasto"), "jsHideModalFolioGarantia");
+ Alert("Gasto Agregado Correctamente", ModExtensiones.TipoMensaje.MsgInformacion);
+ }
+ else
+ {
+ Alert("Ocurrió un error al guardar el Gasto", ModExtensiones.TipoMensaje.MsgError);
+ }
+ }
+ else
+ {
+ if (ObjCRM.UpdateAcercamientosGastos(CveAcercamientoGasto, TxtDescripcionGasto.Text, TxtImporteGasto.Text.ToDecimal()))
+ {
+ CargaGastos();
+
+ RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarGasto"), "jsHideModalFolioGarantia");
+ Alert("Gasto Actualizado Correctamente", ModExtensiones.TipoMensaje.MsgInformacion);
+ }
+ else
+ {
+ Alert("Ocurrió un error al actualizar el Gasto", ModExtensiones.TipoMensaje.MsgError);
+ }
+ }
+
+ Actualizar = false;
+ CveAcercamientoGasto = -1;
+
+ ObjCRM.Dispose();
+ }
+
+ protected void GvGastos_RowDataBound(object sender, GridViewRowEventArgs e)
+ {
+ if (e.Row.RowType == DataControlRowType.DataRow)
+ {
+ if (e.Row.DBCampo("CveAcercamiento").ToEntero() < 1)
+ {
+ e.Row.CssClass = "Totales";
+ e.Row.Cells[0].Text = "Total";
+ e.Row.FCLinkButton("ImgE").Visible = false;
+ e.Row.FCLinkButton("imgD").Visible = false;
+ }
+ }
+ }
+
+ protected void ImgE_Click(object sender, EventArgs e)
+ {
+ GridViewRow GvRow = (GridViewRow)((LinkButton)sender).NamingContainer;
+ LtlTituloModalGasto.Text = "Editar Gasto";
+ BtnAgregarGastoModal.Text = "Actualizar";
+ Actualizar = true;
+
+ CveAcercamientoGasto = GvRow.DataKey("CveAcercamientoGasto").ToEntero();
+
+ TxtDescripcionGasto.Text = GvRow.DataKey("Descripcion");
+ TxtImporteGasto.Text = GvRow.DataKey("Importe");
+
+ UpModalGastos.Update();
+
+ RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarGasto"));
+ }
+
+ protected void imgD_Click(object sender, EventArgs e)
+ {
+
+ ClsCRM ObjCRM = new ClsCRM();
+ GridViewRow GvRow = (GridViewRow)((LinkButton)sender).NamingContainer;
+ CveAcercamientoGasto = GvRow.DataKey("CveAcercamientoGasto").ToEntero();
+
+ if (ObjCRM.RemoveAcercamientosGastos(CveAcercamientoGasto))
+ {
+ CargaGastos();
+ Alert("Gasto eliminado Correctamente", ModExtensiones.TipoMensaje.MsgInformacion);
+ }
+ else
+ {
+ Alert("Ocurrió un error al eliminar el Gasto", ModExtensiones.TipoMensaje.MsgError);
+ }
+
+ ObjCRM.Dispose();
+
+ CveAcercamientoGasto = -1;
+ }
+
+ #endregion
}
\ No newline at end of file
diff --git a/Compras/Compras.aspx.vb b/Compras/Compras.aspx.vb
index 02bb186f9..47b2f010e 100644
--- a/Compras/Compras.aspx.vb
+++ b/Compras/Compras.aspx.vb
@@ -1126,9 +1126,9 @@ Partial Class Compras_Compras
CveCuentaBancaria = 0
End If
- If UsuarioActual.TienePermisoProceso(259) Then
- DivEsNoDeducible.Visible = True
- End If
+ 'If UsuarioActual.TienePermisoProceso(259) Then
+ DivEsNoDeducible.Visible = True
+ 'End If
If UsuarioActual.Empresa.Funcionalidad(125) = "1" Then 'Seleccionar a quien se abona la Prepoliza
'ddlCargoPrePoliza.Visible = True
@@ -4166,2223 +4166,1346 @@ Partial Class Compras_Compras
'seria de contado, solo cuando no tenga vinculado ningun anticipo
If RBLPago.SelectedValue.ToEntero = 2 AndAlso ArrAnticipos.Count = 0 Then 'Contado
- If RBLContado.SelectedValue = "1" Then
- 'se registra primero el movimiento en bancos para luego vincularlo en la compra
- CveIE = ObjIE.AddBancos_IE(DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero, TxtFechaPago.Text.Trim.ToDate, TxtDocumentoFolio.Text.Trim, DdlProveedor.SelectedItem.Text.Trim, TxtDocumentoImporte.Text.Trim.ToDouble, DdlMoneda.SelectedValue.ToEntero, 0.0, TxtDocumentoObservaciones.Text.Trim, "", True, True, -1, CvePrePoliza, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCuentaTarjeta:=If(DivTarjeta.Visible, DdlTarjeta.SelectedValue.ToEntero, -1))
- ElseIf RBLContado.SelectedValue = "6" Then
- 'se registra primero el movimiento en bancos para luego vincularlo en la compra
- CveIE = ObjIE.AddBancos_IE(DdlCuentaCaja.SelectedValue.ToEntero, DdlTipoTransaccionCaja.SelectedValue.ToEntero, TxtFechaPago.Text.Trim.ToDate, TxtDocumentoFolioCaja.Text.Trim, DdlProveedor.SelectedItem.Text.Trim, TxtDocumentoImporteCaja.Text.Trim.ToDouble, DdlMoneda.SelectedValue.ToEntero, 0.0, TxtDocumentoObservacionesCaja.Text.Trim, "", True, True, -1, CvePrePoliza, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
- End If
-
- If (RBLContado.SelectedValue = "1" OrElse RBLContado.SelectedValue = "6") AndAlso Not CveIE > 0 Then
- ErrorMovtosIE = True
- End If
- End If
-
- If Not ErrorMovtosIE Then
-
- 'REEMBOLSOS NO USA AC
- Dim NumeroReembolso = "-1"
- If TxtNumeroReembolso IsNot Nothing And RBLPago.SelectedValue = "3" Then
- NumeroReembolso = TxtNumeroReembolso.Text
-
- ''GUARDA VALORES PARA SESSION
- UsuarioActual.Sesion("Comp-NumeroReembolso") = TxtNumeroReembolso.Text
- UsuarioActual.Sesion("Comp-CveFYE") = DdlPersonalReembolso.SelectedValue
- UsuarioActual.Sesion("Comp-Descripcion") = TxtDescripcion.Text
-
- If NumeroReembolso <> "-1" Then
- If CvePersonal <= 0 And CveCajaChica <= 0 Then
- ErrorReembolso = True
- End If
+ If RBLContado.SelectedValue = "1" Then
+ 'se registra primero el movimiento en bancos para luego vincularlo en la compra
+ CveIE = ObjIE.AddBancos_IE(DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero, TxtFechaPago.Text.Trim.ToDate, TxtDocumentoFolio.Text.Trim, DdlProveedor.SelectedItem.Text.Trim, TxtDocumentoImporte.Text.Trim.ToDouble, DdlMoneda.SelectedValue.ToEntero, 0.0, TxtDocumentoObservaciones.Text.Trim, "", True, True, -1, CvePrePoliza, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCuentaTarjeta:=If(DivTarjeta.Visible, DdlTarjeta.SelectedValue.ToEntero, -1))
+ ElseIf RBLContado.SelectedValue = "6" Then
+ 'se registra primero el movimiento en bancos para luego vincularlo en la compra
+ CveIE = ObjIE.AddBancos_IE(DdlCuentaCaja.SelectedValue.ToEntero, DdlTipoTransaccionCaja.SelectedValue.ToEntero, TxtFechaPago.Text.Trim.ToDate, TxtDocumentoFolioCaja.Text.Trim, DdlProveedor.SelectedItem.Text.Trim, TxtDocumentoImporteCaja.Text.Trim.ToDouble, DdlMoneda.SelectedValue.ToEntero, 0.0, TxtDocumentoObservacionesCaja.Text.Trim, "", True, True, -1, CvePrePoliza, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
+ End If
+
+ If (RBLContado.SelectedValue = "1" OrElse RBLContado.SelectedValue = "6") AndAlso Not CveIE > 0 Then
+ ErrorMovtosIE = True
End If
- Else
- UsuarioActual.Sesion("Comp-NumeroReembolso") = ""
End If
+ If Not ErrorMovtosIE Then
- If Not ErrorReembolso Then
+ 'REEMBOLSOS NO USA AC
+ Dim NumeroReembolso = "-1"
+ If TxtNumeroReembolso IsNot Nothing And RBLPago.SelectedValue = "3" Then
+ NumeroReembolso = TxtNumeroReembolso.Text
- 'PORCENTAJE IVA
- Dim PorcentajeIVA As Decimal = TmpDT.MAX("IVAPorcentaje").ToDecimal
+ ''GUARDA VALORES PARA SESSION
+ UsuarioActual.Sesion("Comp-NumeroReembolso") = TxtNumeroReembolso.Text
+ UsuarioActual.Sesion("Comp-CveFYE") = DdlPersonalReembolso.SelectedValue
+ UsuarioActual.Sesion("Comp-Descripcion") = TxtDescripcion.Text
- 'If DdlIVA.SelectedValue.ToDouble = 1.16 Then
- ' PorcentajeIVA = 0.16
- 'ElseIf DdlIVA.SelectedValue.ToDouble = 1.08 Then
- ' PorcentajeIVA = 0.08
- 'End If
-
- 'METODO DE PREPOLIZA DE ALMACEN
- If UsuarioActual.CveEmpresa.Contiene(1, 119) And UsuarioActual.Empresa.UsaInventarios And Not UsuarioActual.Empresa.Funcionalidad(126) = "1" Then
- Dim ImporteAlmacen = TmpDT.SUM(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total"), $"ISNULL(TipoAF,0) <> 2 AND ISNULL(CveAlmacen,0) = 0 AND ISNULL(AplicaCostoIndirecto,0) <> 1 AND CveTipoPS = 2").ToString.ToDecimal
- If ImporteAlmacen > 0 Then
- If Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") Then
- If (CveImportacion > 0 Or CveFlete > 0) Then
- CveConceptoContableAlmacen = CveConceptoContableAlmacen
- Else
- CveConceptoContableAlmacen = 205
- End If
- If OCVinculada And Not (CveImportacion > 0 Or CveFlete > 0) Then
- CveConceptoContableAlmacen = DdlOCVinculaInv.SelectedValue.ToEntero
- End If
- Else
- CveConceptoContableAlmacen = 225
+ If NumeroReembolso <> "-1" Then
+ If CvePersonal <= 0 And CveCajaChica <= 0 Then
+ ErrorReembolso = True
End If
-
- 'Condiciones para los casos de facturas que son en 0 pero que se utiliza el almacen
- ElseIf OCVinculada AndAlso Not (CveImportacion > 0 Or CveFlete > 0) AndAlso Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") Then
- CveConceptoContableAlmacen = DdlOCVinculaInv.SelectedValue.ToEntero
- ElseIf (CveImportacion > 0 Or CveFlete > 0) AndAlso Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") Then
- CveConceptoContableAlmacen = CveConceptoContableAlmacen
End If
+ Else
+ UsuarioActual.Sesion("Comp-NumeroReembolso") = ""
End If
- If RBLPago.SelectedValue.ToEntero = 4 And EstatusCredito.Contiene(1, 101) Then
- CveEstatusFactura = 6
- End If
+ If Not ErrorReembolso Then
- 'Compra
- If ObjCompras.AddCompra(DdlTipoComprobante.SelectedValue, TxtDescripcion.Text.Trim, TxtSerie.Text.Trim, TxtFolio.Text.Trim, TxtFolioSecundario.Text.Trim, CveProveedor, TxtSubTotal.Text.ToDouble, TxtDescuento.Text.ToDouble,
- LblAmortizacion.Text.ToDouble, TxtIVA.Text.ToDouble, TxtRetIVA.Text.ToDouble, TxtRetISR.Text.ToDouble, TxtIEPS.Text.ToDouble, TxtOtrosImpuestos.Text.ToDouble,
- TxtRedondeo.Text.ToDouble, TxtTotal.Text.ToDouble, TxtFecha.Text.Trim.ToDate, DdlMoneda.SelectedValue.ToEntero, TipoCambio, TxtFechaPago.Text.Trim.ToDate, ChkAplicaNotaCredito.Checked, TxtObsFact.Text.Trim, CveEstatusFactura,
- CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, IdPoliza, CveCajaChica:=CveCajaChica, CvePersonal:=CvePersonal, NumeroReembolso:=NumeroReembolso, CveProveedorSucursal:=DdlProveedorSucursal.SelectedValue.ToEntero,
- AplicoPromocion:=ChkOCPromocion.Checked, PorcentajeIVA:=PorcentajeIVA, CveMetodoPago:=CveMetodoPago, CveRetIVAConcepto:=If(DdlRetIVAConcepto.Items.Count > 0, DdlRetIVAConcepto.SelectedValue.ToEntero, -1), CveConceptoContableAlmacen:=CveConceptoContableAlmacen,
- CveRetISRConcepto:=If(DdlRetISRConcepto.Items.Count > 0, DdlRetISRConcepto.SelectedValue.ToEntero, -1), NoDeducible:=EsNoDeducible, CveTipoCompra:=DdlTipoCompra.SelectedValue.ToEntero) Then
+ 'PORCENTAJE IVA
+ Dim PorcentajeIVA As Decimal = TmpDT.MAX("IVAPorcentaje").ToDecimal
- ViewState("CveCompra") = ObjCompras.CveCompra
- If ObjCompras.DtResultados.Rows.Count > 0 Then ViewState("CompraFolio") = ObjCompras.DtResultados.Rows(0)("vFolio").ToString
- If DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") Then
- ErrorMovDev = guardardevolucion(ObjInventario, ObjCompras.CveCompra, TxtSubTotal.Text.ToDouble, TxtFecha.Text.Trim.ToDate)
- End If
- Dim ErrorDetalles As Boolean = False
- ' Dim IDPoliza As Integer
- Dim IDPolizaComprometido = 0
- Dim ErrorComprometido = False
+ 'If DdlIVA.SelectedValue.ToDouble = 1.16 Then
+ ' PorcentajeIVA = 0.16
+ 'ElseIf DdlIVA.SelectedValue.ToDouble = 1.08 Then
+ ' PorcentajeIVA = 0.08
+ 'End If
- If CveImportacion > 0 Or CveFlete > 0 Then
-
-
- Select Case CveConceptoContableAlmacen
- Case 237
- Select Case FleteImportacionOpcion
- Case 1
- Dim Dr As DataRow = Nothing
- If ObjInventario.GetFletes(UsuarioActual.CveEmpresa, CveFlete) Then
- If ObjInventario.DtResultados.Rows.Count > 0 Then
- Dr = ObjInventario.DtResultados.Rows(0)
- End If
- End If
- If Dr IsNot Nothing Then
- If Not ObjInventario.UpdateFlete(CveFlete, Dr("Descripcion").ToString, Dr("Fecha").ToString.ToDate, -1, CveCompra, UsuarioActual.CveUsuario) Then
- ErrorOC = True
- End If
- Else
- ErrorOC = True
- End If
- Case 2
- If Not ObjInventario.AddFleteDetalle(CveFlete, CveCompra) Then
- ErrorOC = True
- End If
- 'actualiza la compra para que no se surta en almacen. sino por el flete o importación
- If Not ObjCompras.UpdateEstatusAlmacen(CveCompra, 2) Then
- ErrorOC = True
- End If
- End Select
- Case 240
- Select Case FleteImportacionOpcion
- Case 1
- If Not ObjCompras.AddImportacionCompra(CveImportacion, CveCompra) Then
- ErrorOC = True
- End If
- Case 2
- If Not ObjCompras.AddImportacionDetalle(CveImportacion, CveCompra) Then
- ErrorOC = True
- End If
- 'actualiza la compra para que no se surta en almacen. sino por el flete o importación
- If Not ObjCompras.UpdateEstatusAlmacen(CveCompra, 2) Then
- ErrorOC = True
- End If
- End Select
- End Select
- End If
-
-
- If UsuarioActual.Empresa.UsaAC Then
-
- If TotalPorDevengar <= TxtTotal.Text.ToDouble And TotalPorDevengar > 0 Then
- ObjContaAC = New ClsContPAQi(UsuarioActual.Empresa)
- ObjContaAC.IniciaTransacSQL()
-
- ''POLIZA COMPROMETIDO SOLO SI NO SE VINCULA OC
- If HdnVCveOC.Value.ToEntero > 0 Then
- ' IDPolizaComprometido = ObjContaAC.AddPoliza( 4, "Comprometido", Total, Total, UsuarioActual.CveUsuario, Now)
- ' If IDPolizaComprometido <= 0 Then
- ' ErrorComprometido = True
- ' End If
- IDPolizaComprometido = 1
- TotalPorDevengar = TotalPorDevengar * 2
+ 'METODO DE PREPOLIZA DE ALMACEN
+ If UsuarioActual.CveEmpresa.Contiene(1, 119) And UsuarioActual.Empresa.UsaInventarios And Not UsuarioActual.Empresa.Funcionalidad(126) = "1" Then
+ Dim ImporteAlmacen = TmpDT.SUM(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total"), $"ISNULL(TipoAF,0) <> 2 AND ISNULL(CveAlmacen,0) = 0 AND ISNULL(AplicaCostoIndirecto,0) <> 1 AND CveTipoPS = 2").ToString.ToDecimal
+ If ImporteAlmacen > 0 Then
+ If Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") Then
+ If (CveImportacion > 0 Or CveFlete > 0) Then
+ CveConceptoContableAlmacen = CveConceptoContableAlmacen
+ Else
+ CveConceptoContableAlmacen = 205
+ End If
+ If OCVinculada And Not (CveImportacion > 0 Or CveFlete > 0) Then
+ CveConceptoContableAlmacen = DdlOCVinculaInv.SelectedValue.ToEntero
+ End If
Else
- TotalPorDevengar = TotalPorDevengar * 3
+ CveConceptoContableAlmacen = 225
End If
- IdPoliza = ObjContaAC.AddPoliza(3, TxtDescripcion.Text.Trim, TotalPorDevengar, TotalPorDevengar, UsuarioActual.CveUsuario, TxtFecha.Text.ToDate)
-
- 'Dim filtro As New StringBuilder
- If IdPoliza > 0 Then
- PolizaFolio = ObjContaAC.Folio
- 'Dim RegistroMatriz As DataRow
- 'Dim CuentaCargo As Integer
- Dim CuentaAbono As Integer
- Dim Importe As Decimal
-
- 'CUENTA PROVEEDOR
- If tIdContaProveedor <= 0 Then
- 'normalmente debe de ser la cuenta 021120000000000000, para el caso de APH, se el cmabio al 2119
- If ObjContaAC.GetCuentas(-1, "021190000000000000", -1) Then
- Dim drCuenta As DataRow = ObjContaAC.DtResultados.FiltroPrimero("")
- If drCuenta IsNot Nothing Then
-
- CuentaAbono = drCuenta("Id").ToString.ToEntero
- Dim FolioProveedor = ObjContaAC.GetFolioProveedores("021190000000000000").ToString
- ViewState("CtaProveedor") = ObjContaAC.AddCuenta(String.Format("02119{0}000000000", FolioProveedor.PadLeft(4, "0"c)), NombreProveedor, "D", 2, 0, 1, 0, "", 1, CuentaAbono)
- ObjProveedores.UpdateProveedorIdCuentaAC(CveProveedor, CtaProveedor)
- tIdContaProveedor = CtaProveedor
-
- Else
- ErrorAC = True
- ErrorACMEnsaje.Append(" - DrCuenta Nula")
- End If
- Else
- ErrorACMEnsaje.Append(" - Error al consultar cuenta 021190000000000000 ")
- ErrorAC = True
- End If
- End If
-
- Dim ConceptoRenglon As String = ""
- If Not ErrorAC Then
+ 'Condiciones para los casos de facturas que son en 0 pero que se utiliza el almacen
+ ElseIf OCVinculada AndAlso Not (CveImportacion > 0 Or CveFlete > 0) AndAlso Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") Then
+ CveConceptoContableAlmacen = DdlOCVinculaInv.SelectedValue.ToEntero
+ ElseIf (CveImportacion > 0 Or CveFlete > 0) AndAlso Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") Then
+ CveConceptoContableAlmacen = CveConceptoContableAlmacen
+ End If
+ End If
- 'INVENTARIOS EN AC
- Dim ContadorInventario As Integer = GvInv.Rows.Cast(Of GridViewRow)().Count(Function(gvr) gvr.FCCheckBox("cbInv").Checked)
- Dim CtaAlmacen As Integer
- If ContadorInventario > 0 Then
- Dim drr As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveAlmacen = {0}", GvInv.HeaderRow.FCDropDownList("ddlAlmacen").SelectedValue.ToString.ToEntero))
- If drr IsNot Nothing Then
- CtaAlmacen = drr("IdCtaContable").ToString.ToEntero
- End If
- End If
+ If RBLPago.SelectedValue.ToEntero = 4 And EstatusCredito.Contiene(1, 101) Then
+ CveEstatusFactura = 6
+ End If
- Dim tTotalIVA, tTotalGral, tDiferenciaIVA, tIVA, tRetIVA, tRetISR As Decimal
- Dim ipresup As Integer = 0
- 'COMIENZA: PRUEBA AGRUPACION CONCEPTOS
- Dim Presup = From gvr As DataRow In TmpDT.Rows.Cast(Of DataRow)()
- Group gvr By Grp = New With {
- Key .CvePresupuestoEgreso = gvr("CvePresupuestoEgreso").ToString.ToEntero,
- Key .CveOrdencompraDetalle = If(gvr("CveOrdencompraDetalle").ToString.ToEntero > 0, 1, -1),
- Key .CveActivoFijo = If(gvr("TipoAF").ToString.ToEntero = 2, gvr("CveActivoFijo").ToString.ToEntero, -1)
- } Into Group
- Select Grp.CvePresupuestoEgreso, Grp.CveActivoFijo, Grp.CveOrdencompraDetalle,
- TotalImporte = Group.Sum(Function(r) r("Total").ToString.ToDecimal)
- Dim Fecha As Date = TxtFecha.Text.ToDate
+ 'Compra
+ If ObjCompras.AddCompra(DdlTipoComprobante.SelectedValue, TxtDescripcion.Text.Trim, TxtSerie.Text.Trim, TxtFolio.Text.Trim, TxtFolioSecundario.Text.Trim, CveProveedor, TxtSubTotal.Text.ToDouble, TxtDescuento.Text.ToDouble,
+ LblAmortizacion.Text.ToDouble, TxtIVA.Text.ToDouble, TxtRetIVA.Text.ToDouble, TxtRetISR.Text.ToDouble, TxtIEPS.Text.ToDouble, TxtOtrosImpuestos.Text.ToDouble,
+ TxtRedondeo.Text.ToDouble, TxtTotal.Text.ToDouble, TxtFecha.Text.Trim.ToDate, DdlMoneda.SelectedValue.ToEntero, TipoCambio, TxtFechaPago.Text.Trim.ToDate, ChkAplicaNotaCredito.Checked, TxtObsFact.Text.Trim, CveEstatusFactura,
+ CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, IdPoliza, CveCajaChica:=CveCajaChica, CvePersonal:=CvePersonal, NumeroReembolso:=NumeroReembolso, CveProveedorSucursal:=DdlProveedorSucursal.SelectedValue.ToEntero,
+ AplicoPromocion:=ChkOCPromocion.Checked, PorcentajeIVA:=PorcentajeIVA, CveMetodoPago:=CveMetodoPago, CveRetIVAConcepto:=If(DdlRetIVAConcepto.Items.Count > 0, DdlRetIVAConcepto.SelectedValue.ToEntero, -1), CveConceptoContableAlmacen:=CveConceptoContableAlmacen,
+ CveRetISRConcepto:=If(DdlRetISRConcepto.Items.Count > 0, DdlRetISRConcepto.SelectedValue.ToEntero, -1), NoDeducible:=EsNoDeducible, CveTipoCompra:=DdlTipoCompra.SelectedValue.ToEntero) Then
- 'Dim tTotalIVA, tTotalGral, tDiferenciaIVA, tIVA As Double
- tTotalIVA = TxtIVA.Text.ToDecimal
- tRetIVA = TxtRetIVA.Text.ToDecimal
- tRetISR = TxtRetISR.Text.ToDecimal
+ ViewState("CveCompra") = ObjCompras.CveCompra
+ If ObjCompras.DtResultados.Rows.Count > 0 Then ViewState("CompraFolio") = ObjCompras.DtResultados.Rows(0)("vFolio").ToString
+ If DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") Then
+ ErrorMovDev = guardardevolucion(ObjInventario, ObjCompras.CveCompra, TxtSubTotal.Text.ToDouble, TxtFecha.Text.Trim.ToDate)
+ End If
+ Dim ErrorDetalles As Boolean = False
+ ' Dim IDPoliza As Integer
+ Dim IDPolizaComprometido = 0
+ Dim ErrorComprometido = False
- 'tTotalIVA = tTotalIVA - tRetIVA - tRetISR
+ If CveImportacion > 0 Or CveFlete > 0 Then
- tTotalGral = TxtTotal.Text.ToDecimal + tRetIVA + tRetISR ' EL TOTAL GENERAL DEBE DE SER EL SUBTOTAL + IVA, NO SE DEBEN DE INCLUIR LAS RETENCIONES, POR ESO SE RESTA
- tDiferenciaIVA = tTotalIVA
- ipresup = 0
-
- Dim CuentaMatrizAlmacen As Integer
-
- 'PresupuestoEgresos
- Dim DtPresupuestosTemp As DataTable
- Dim IdCuentaComprometido, IdCuentaPorEjercer, IdCuentaDevengado, IdCuentaMatriz As Integer
- ' Dim DescuentoConIVA As Decimal
- Dim tPorIVA As Decimal = tTotalIVA / (tTotalGral - tTotalIVA)
- Dim tAjusteTotal As Decimal
-
- For Each grp In Presup
- Importe = grp.TotalImporte
- TotalDetalle += Importe
- ipresup += 1
- If Importe > 0 Then
- 'saco la proporcion de iva que le corresponde
- tIVA = Math.Round(Importe * tPorIVA, 2)
- tDiferenciaIVA -= tIVA
- 'identifico si es el ultimo registro, para ver si es necesario un ajuste
- If ipresup = Presup.Count Then
- If Math.Round(TotalDetalle - tTotalGral, 2) <= 0.01 AndAlso tDiferenciaIVA > 0 Then
- tIVA += tDiferenciaIVA
+ Select Case CveConceptoContableAlmacen
+ Case 237
+ Select Case FleteImportacionOpcion
+ Case 1
+ Dim Dr As DataRow = Nothing
+ If ObjInventario.GetFletes(UsuarioActual.CveEmpresa, CveFlete) Then
+ If ObjInventario.DtResultados.Rows.Count > 0 Then
+ Dr = ObjInventario.DtResultados.Rows(0)
End If
End If
-
- 'le sumo el iva al concepto
- Importe += tIVA
-
- 'codigo Provisional, para cuand tenga descuento, solo tome el subtotal * el iva,RMF
- If TxtDescuento.Text.ToDouble > 0 Then
- Importe = grp.TotalImporte * 1.16D
+ If Dr IsNot Nothing Then
+ If Not ObjInventario.UpdateFlete(CveFlete, Dr("Descripcion").ToString, Dr("Fecha").ToString.ToDate, -1, CveCompra, UsuarioActual.CveUsuario) Then
+ ErrorOC = True
+ End If
+ Else
+ ErrorOC = True
End If
-
- tAjusteTotal += Importe
- 'valido que la sumas de lo detalles no exceda al totalgeneral
- If Math.Round(tAjusteTotal, 2) > tTotalGral Then
- 'le resto la diferencia
- Importe -= (tAjusteTotal - tTotalGral)
+ Case 2
+ If Not ObjInventario.AddFleteDetalle(CveFlete, CveCompra) Then
+ ErrorOC = True
End If
+ 'actualiza la compra para que no se surta en almacen. sino por el flete o importación
+ If Not ObjCompras.UpdateEstatusAlmacen(CveCompra, 2) Then
+ ErrorOC = True
+ End If
+ End Select
+ Case 240
+ Select Case FleteImportacionOpcion
+ Case 1
+ If Not ObjCompras.AddImportacionCompra(CveImportacion, CveCompra) Then
+ ErrorOC = True
+ End If
+ Case 2
+ If Not ObjCompras.AddImportacionDetalle(CveImportacion, CveCompra) Then
+ ErrorOC = True
+ End If
+ 'actualiza la compra para que no se surta en almacen. sino por el flete o importación
+ If Not ObjCompras.UpdateEstatusAlmacen(CveCompra, 2) Then
+ ErrorOC = True
+ End If
+ End Select
+ End Select
+ End If
- 'Presupuesto Egresos
- DtPresupuestosTemp = DtPresupuestos.FiltraParametros(String.Format("CvePresupuestoEgreso = {0}", grp.CvePresupuestoEgreso))
- If DtPresupuestosTemp.Rows.Count <> 1 Then
+
+ If UsuarioActual.Empresa.UsaAC Then
+
+ If TotalPorDevengar <= TxtTotal.Text.ToDouble And TotalPorDevengar > 0 Then
+ ObjContaAC = New ClsContPAQi(UsuarioActual.Empresa)
+ ObjContaAC.IniciaTransacSQL()
+
+ ''POLIZA COMPROMETIDO SOLO SI NO SE VINCULA OC
+ If HdnVCveOC.Value.ToEntero > 0 Then
+ ' IDPolizaComprometido = ObjContaAC.AddPoliza( 4, "Comprometido", Total, Total, UsuarioActual.CveUsuario, Now)
+ ' If IDPolizaComprometido <= 0 Then
+ ' ErrorComprometido = True
+ ' End If
+ IDPolizaComprometido = 1
+ TotalPorDevengar = TotalPorDevengar * 2
+ Else
+ TotalPorDevengar = TotalPorDevengar * 3
+ End If
+
+ IdPoliza = ObjContaAC.AddPoliza(3, TxtDescripcion.Text.Trim, TotalPorDevengar, TotalPorDevengar, UsuarioActual.CveUsuario, TxtFecha.Text.ToDate)
+
+ 'Dim filtro As New StringBuilder
+ If IdPoliza > 0 Then
+ PolizaFolio = ObjContaAC.Folio
+ 'Dim RegistroMatriz As DataRow
+ 'Dim CuentaCargo As Integer
+ Dim CuentaAbono As Integer
+ Dim Importe As Decimal
+
+ 'CUENTA PROVEEDOR
+ If tIdContaProveedor <= 0 Then
+ 'normalmente debe de ser la cuenta 021120000000000000, para el caso de APH, se el cmabio al 2119
+ If ObjContaAC.GetCuentas(-1, "021190000000000000", -1) Then
+ Dim drCuenta As DataRow = ObjContaAC.DtResultados.FiltroPrimero("")
+ If drCuenta IsNot Nothing Then
+
+ CuentaAbono = drCuenta("Id").ToString.ToEntero
+ Dim FolioProveedor = ObjContaAC.GetFolioProveedores("021190000000000000").ToString
+ ViewState("CtaProveedor") = ObjContaAC.AddCuenta(String.Format("02119{0}000000000", FolioProveedor.PadLeft(4, "0"c)), NombreProveedor, "D", 2, 0, 1, 0, "", 1, CuentaAbono)
+ ObjProveedores.UpdateProveedorIdCuentaAC(CveProveedor, CtaProveedor)
+ tIdContaProveedor = CtaProveedor
+
+ Else
ErrorAC = True
- ErrorACMEnsaje.Append(" - DtPresupuestosTemp.Rows.Count <> 1 ")
- Exit For
+ ErrorACMEnsaje.Append(" - DrCuenta Nula")
End If
- IdCuentaComprometido = DtPresupuestosTemp.Rows(0)("IdCuentaComprometido").ToString.ToEntero
- IdCuentaPorEjercer = DtPresupuestosTemp.Rows(0)("IdCuentaPorEjercer").ToString.ToEntero
- IdCuentaDevengado = DtPresupuestosTemp.Rows(0)("IdCuentaDevengado").ToString.ToEntero
- IdCuentaMatriz = DtPresupuestosTemp.Rows(0)("IdCuentaMatriz").ToString.ToEntero
+ Else
+ ErrorACMEnsaje.Append(" - Error al consultar cuenta 021190000000000000 ")
+ ErrorAC = True
+ End If
+ End If
- 'COMPROMETIDO DEPENDIENTE SI EXISTE SU POLIZA
- If grp.CveOrdencompraDetalle = -1 Then
- ConceptoRenglon = String.Format("GC Fact: {0}-{1} {2}", TxtSerie.Text.Trim, TxtFolio.Text.Trim, DdlProveedor.SelectedItem.Text)
- If ObjContaAC.AddMovimiento(IdPoliza, IdCuentaComprometido, False, MultiplicadorNC * Importe, "", ConceptoRenglon, 0, Fecha, "") Then
- If Not ObjContaAC.AddMovimiento(IdPoliza, IdCuentaPorEjercer, True, MultiplicadorNC * Importe, "", ConceptoRenglon, 0, Fecha, "") Then
+ Dim ConceptoRenglon As String = ""
+ If Not ErrorAC Then
+
+
+ 'INVENTARIOS EN AC
+ Dim ContadorInventario As Integer = GvInv.Rows.Cast(Of GridViewRow)().Count(Function(gvr) gvr.FCCheckBox("cbInv").Checked)
+ Dim CtaAlmacen As Integer
+ If ContadorInventario > 0 Then
+ Dim drr As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveAlmacen = {0}", GvInv.HeaderRow.FCDropDownList("ddlAlmacen").SelectedValue.ToString.ToEntero))
+ If drr IsNot Nothing Then
+ CtaAlmacen = drr("IdCtaContable").ToString.ToEntero
+ End If
+ End If
+
+ Dim tTotalIVA, tTotalGral, tDiferenciaIVA, tIVA, tRetIVA, tRetISR As Decimal
+ Dim ipresup As Integer = 0
+ 'COMIENZA: PRUEBA AGRUPACION CONCEPTOS
+ Dim Presup = From gvr As DataRow In TmpDT.Rows.Cast(Of DataRow)()
+ Group gvr By Grp = New With {
+ Key .CvePresupuestoEgreso = gvr("CvePresupuestoEgreso").ToString.ToEntero,
+ Key .CveOrdencompraDetalle = If(gvr("CveOrdencompraDetalle").ToString.ToEntero > 0, 1, -1),
+ Key .CveActivoFijo = If(gvr("TipoAF").ToString.ToEntero = 2, gvr("CveActivoFijo").ToString.ToEntero, -1)
+ } Into Group
+ Select Grp.CvePresupuestoEgreso, Grp.CveActivoFijo, Grp.CveOrdencompraDetalle,
+ TotalImporte = Group.Sum(Function(r) r("Total").ToString.ToDecimal)
+ Dim Fecha As Date = TxtFecha.Text.ToDate
+
+ 'Dim tTotalIVA, tTotalGral, tDiferenciaIVA, tIVA As Double
+ tTotalIVA = TxtIVA.Text.ToDecimal
+ tRetIVA = TxtRetIVA.Text.ToDecimal
+ tRetISR = TxtRetISR.Text.ToDecimal
+
+ 'tTotalIVA = tTotalIVA - tRetIVA - tRetISR
+
+ tTotalGral = TxtTotal.Text.ToDecimal + tRetIVA + tRetISR ' EL TOTAL GENERAL DEBE DE SER EL SUBTOTAL + IVA, NO SE DEBEN DE INCLUIR LAS RETENCIONES, POR ESO SE RESTA
+ tDiferenciaIVA = tTotalIVA
+
+ ipresup = 0
+
+ Dim CuentaMatrizAlmacen As Integer
+
+ 'PresupuestoEgresos
+ Dim DtPresupuestosTemp As DataTable
+ Dim IdCuentaComprometido, IdCuentaPorEjercer, IdCuentaDevengado, IdCuentaMatriz As Integer
+ ' Dim DescuentoConIVA As Decimal
+ Dim tPorIVA As Decimal = tTotalIVA / (tTotalGral - tTotalIVA)
+ Dim tAjusteTotal As Decimal
+
+ For Each grp In Presup
+ Importe = grp.TotalImporte
+ TotalDetalle += Importe
+ ipresup += 1
+ If Importe > 0 Then
+ 'saco la proporcion de iva que le corresponde
+ tIVA = Math.Round(Importe * tPorIVA, 2)
+ tDiferenciaIVA -= tIVA
+ 'identifico si es el ultimo registro, para ver si es necesario un ajuste
+ If ipresup = Presup.Count Then
+ If Math.Round(TotalDetalle - tTotalGral, 2) <= 0.01 AndAlso tDiferenciaIVA > 0 Then
+ tIVA += tDiferenciaIVA
+ End If
+ End If
+
+ 'le sumo el iva al concepto
+ Importe += tIVA
+
+ 'codigo Provisional, para cuand tenga descuento, solo tome el subtotal * el iva,RMF
+ If TxtDescuento.Text.ToDouble > 0 Then
+ Importe = grp.TotalImporte * 1.16D
+ End If
+
+ tAjusteTotal += Importe
+ 'valido que la sumas de lo detalles no exceda al totalgeneral
+ If Math.Round(tAjusteTotal, 2) > tTotalGral Then
+ 'le resto la diferencia
+ Importe -= (tAjusteTotal - tTotalGral)
+ End If
+
+ 'Presupuesto Egresos
+ DtPresupuestosTemp = DtPresupuestos.FiltraParametros(String.Format("CvePresupuestoEgreso = {0}", grp.CvePresupuestoEgreso))
+ If DtPresupuestosTemp.Rows.Count <> 1 Then
+ ErrorAC = True
+ ErrorACMEnsaje.Append(" - DtPresupuestosTemp.Rows.Count <> 1 ")
+ Exit For
+ End If
+ IdCuentaComprometido = DtPresupuestosTemp.Rows(0)("IdCuentaComprometido").ToString.ToEntero
+ IdCuentaPorEjercer = DtPresupuestosTemp.Rows(0)("IdCuentaPorEjercer").ToString.ToEntero
+ IdCuentaDevengado = DtPresupuestosTemp.Rows(0)("IdCuentaDevengado").ToString.ToEntero
+ IdCuentaMatriz = DtPresupuestosTemp.Rows(0)("IdCuentaMatriz").ToString.ToEntero
+
+ 'COMPROMETIDO DEPENDIENTE SI EXISTE SU POLIZA
+ If grp.CveOrdencompraDetalle = -1 Then
+ ConceptoRenglon = String.Format("GC Fact: {0}-{1} {2}", TxtSerie.Text.Trim, TxtFolio.Text.Trim, DdlProveedor.SelectedItem.Text)
+ If ObjContaAC.AddMovimiento(IdPoliza, IdCuentaComprometido, False, MultiplicadorNC * Importe, "", ConceptoRenglon, 0, Fecha, "") Then
+ If Not ObjContaAC.AddMovimiento(IdPoliza, IdCuentaPorEjercer, True, MultiplicadorNC * Importe, "", ConceptoRenglon, 0, Fecha, "") Then
+ ErrorAC = True
+ ErrorACMEnsaje.Append(" - Error al agregar movimiento contabilidad 1")
+ Exit For
+ End If
+ Else
+ ErrorACMEnsaje.Append(" - Error al agregar movimiento contabilidad 2")
+ ErrorAC = True
+ Exit For
+ End If
+ End If
+
+ ConceptoRenglon = String.Format("GD Fact:{0}-{1} {2}", TxtSerie.Text.Trim, TxtFolio.Text.Trim, DdlProveedor.SelectedItem.Text)
+ 'DEVENGADO
+ If ObjContaAC.AddMovimiento(IdPoliza, IdCuentaDevengado, False, MultiplicadorNC * Importe, "", ConceptoRenglon, 0, Fecha, "") Then
+ If Not ObjContaAC.AddMovimiento(IdPoliza, IdCuentaComprometido, True, MultiplicadorNC * Importe, "", ConceptoRenglon, 0, Fecha, "") Then
+ ErrorACMEnsaje.Append(" - Error al agregar movimiento contabilidad 3")
ErrorAC = True
- ErrorACMEnsaje.Append(" - Error al agregar movimiento contabilidad 1")
Exit For
End If
Else
- ErrorACMEnsaje.Append(" - Error al agregar movimiento contabilidad 2")
+ ErrorACMEnsaje.Append(" - Error al agregar movimiento contabilidad 4")
ErrorAC = True
Exit For
End If
- End If
- ConceptoRenglon = String.Format("GD Fact:{0}-{1} {2}", TxtSerie.Text.Trim, TxtFolio.Text.Trim, DdlProveedor.SelectedItem.Text)
- 'DEVENGADO
- If ObjContaAC.AddMovimiento(IdPoliza, IdCuentaDevengado, False, MultiplicadorNC * Importe, "", ConceptoRenglon, 0, Fecha, "") Then
- If Not ObjContaAC.AddMovimiento(IdPoliza, IdCuentaComprometido, True, MultiplicadorNC * Importe, "", ConceptoRenglon, 0, Fecha, "") Then
- ErrorACMEnsaje.Append(" - Error al agregar movimiento contabilidad 3")
- ErrorAC = True
- Exit For
- End If
- Else
- ErrorACMEnsaje.Append(" - Error al agregar movimiento contabilidad 4")
- ErrorAC = True
- Exit For
- End If
+ If ContadorInventario > 0 Then
+ CuentaMatrizAlmacen = CtaAlmacen
+ ElseIf grp.CveActivoFijo > 0 Then
- If ContadorInventario > 0 Then
- CuentaMatrizAlmacen = CtaAlmacen
- ElseIf grp.CveActivoFijo > 0 Then
+ Dim CtaAF = -1
+ Dim AF = ""
+ Dim CuentaInicial = -1
- Dim CtaAF = -1
- Dim AF = ""
- Dim CuentaInicial = -1
+ If ObjAF.GetActivosFijos(grp.CveActivoFijo, UsuarioActual.CveEmpresa, "-1", "-1", -1, -1, "-1", -1, -1, -1, -1, -1, "", -1, UsuarioActual.CveEmpresa) Then
+ CtaAF = ObjAF.Cuenta
+ AF = ObjAF.Descripcion
+ CuentaInicial = ObjAF.CuentaInicial
+ Else
+ ErrorAC = True
+ ErrorACMEnsaje.Append(" - Error al obtener activos fijos ")
+ Exit For
+ End If
- If ObjAF.GetActivosFijos(grp.CveActivoFijo, UsuarioActual.CveEmpresa, "-1", "-1", -1, -1, "-1", -1, -1, -1, -1, -1, "", -1, UsuarioActual.CveEmpresa) Then
- CtaAF = ObjAF.Cuenta
- AF = ObjAF.Descripcion
- CuentaInicial = ObjAF.CuentaInicial
- Else
- ErrorAC = True
- ErrorACMEnsaje.Append(" - Error al obtener activos fijos ")
- Exit For
- End If
+ If Not CuentaInicial > 0 Then
+ CuentaInicial = 1241
+ End If
- If Not CuentaInicial > 0 Then
- CuentaInicial = 1241
- End If
+ 'CUENTA AF
+ If CtaAF <= 0 Then
+ If ObjContaAC.GetCuentas(-1, String.Format("0{0}0000000000000", CuentaInicial), -1) Then
+ Dim drCuenta As DataRow = ObjContaAC.DtResultados.FiltroPrimero("")
+ If drCuenta IsNot Nothing Then
+ ErrorACMEnsaje.Append(" - Error al obtener cuentas 0{0}0000000000000 drCuenta nula")
+ CuentaAbono = drCuenta("Id").ToString.ToEntero
+ Dim FolioAF = ObjContaAC.GetFolioProveedores(String.Format("0{0}0000000000000", CuentaInicial)).ToString
+ CtaAF = ObjContaAC.AddCuenta(String.Format("0{0}{1}000000000", CuentaInicial, FolioAF.PadLeft(4, "0"c)), AF, "A", 2, 0, 1, 0, "", 1, CuentaAbono)
- 'CUENTA AF
- If CtaAF <= 0 Then
- If ObjContaAC.GetCuentas(-1, String.Format("0{0}0000000000000", CuentaInicial), -1) Then
- Dim drCuenta As DataRow = ObjContaAC.DtResultados.FiltroPrimero("")
- If drCuenta IsNot Nothing Then
- ErrorACMEnsaje.Append(" - Error al obtener cuentas 0{0}0000000000000 drCuenta nula")
- CuentaAbono = drCuenta("Id").ToString.ToEntero
- Dim FolioAF = ObjContaAC.GetFolioProveedores(String.Format("0{0}0000000000000", CuentaInicial)).ToString
- CtaAF = ObjContaAC.AddCuenta(String.Format("0{0}{1}000000000", CuentaInicial, FolioAF.PadLeft(4, "0"c)), AF, "A", 2, 0, 1, 0, "", 1, CuentaAbono)
-
- ObjAF.UpdateActivosFijosCuentaAC(grp.CveActivoFijo, CtaAF, UsuarioActual.CveUsuario)
+ ObjAF.UpdateActivosFijosCuentaAC(grp.CveActivoFijo, CtaAF, UsuarioActual.CveUsuario)
+ Else
+ ErrorACMEnsaje.Append(" - Error al obtener cuentas 0{0}0000000000000 drCuenta nulo")
+ ErrorAC = True
+ End If
Else
- ErrorACMEnsaje.Append(" - Error al obtener cuentas 0{0}0000000000000 drCuenta nulo")
+ ErrorACMEnsaje.Append(" - Error al obtener cuentas 0{0}0000000000000")
ErrorAC = True
End If
- Else
- ErrorACMEnsaje.Append(" - Error al obtener cuentas 0{0}0000000000000")
- ErrorAC = True
End If
+
+ CuentaMatrizAlmacen = CtaAF
+ Else
+ CuentaMatrizAlmacen = IdCuentaMatriz
End If
- CuentaMatrizAlmacen = CtaAF
- Else
- CuentaMatrizAlmacen = IdCuentaMatriz
- End If
+
+ ''AFECTAR MATRIZ EGRESOS
+ If ObjContaAC.AddMovimiento(IdPoliza, CuentaMatrizAlmacen, False, MultiplicadorNC * Importe, "", ConceptoRenglon, 0, Fecha, "") Then
- ''AFECTAR MATRIZ EGRESOS
- If ObjContaAC.AddMovimiento(IdPoliza, CuentaMatrizAlmacen, False, MultiplicadorNC * Importe, "", ConceptoRenglon, 0, Fecha, "") Then
+ ''VERIFICA SI TIENE DESCUENTO (AMORTIZACION)
+ 'If TxtDescuento.Text.ToDouble > 0 Then
+ ' DescuentoConIVA = TxtDescuento.Text.ToDouble * 1.16
+
+ ' 'Valida que el descuento con iva cuadre en los totales
+ ' If Math.Abs(DescuentoConIVA - (Importe - TxtTotal.Text.ToDouble)) < 0.02 Then
+ ' DescuentoConIVA = Importe - TxtTotal.Text.ToDouble
+ ' ElseIf DescuentoConIVA <> (Importe - TxtTotal.Text.ToDouble) Then
+ ' ErrorAC = True
+ ' Exit For
+ ' End If
+
+ ' 'actualizo el idcuenta del presupuesto
+ ' If ObjContaAC.AddMovimiento(123456, IdPoliza, tIdContaProveedor, True, Importe - DescuentoConIVA, "", ConceptoRenglon, 0, Fecha, "") Then
+ ' 'agrego a la cuenta contable anticipos
+ ' If Not ObjContaAC.AddMovimiento(123456, IdPoliza, CtaProveedorAnticipos, True, DescuentoConIVA, "", ConceptoRenglon, 0, Fecha, "") Then
+ ' ErrorAC = True
+ ' Exit For
+ ' End If
+ ' Else
+ ' ErrorAC = True
+ ' Exit For
+ ' End If
+
+ 'Else
+ ' 'actualizo el idcuenta del presupuesto
+ ' Importe = TxtTotal.Text.ToDouble
+ ' If Not ObjContaAC.AddMovimiento(123456, IdPoliza, tIdContaProveedor, True, If(ArrAnticipos.Count > 0, ImporteAnticipo, Importe), "", ConceptoRenglon, 0, Fecha, "") Then
+ ' ErrorAC = True
+ ' Exit For
+ ' End If
+
+ 'End If
- ''VERIFICA SI TIENE DESCUENTO (AMORTIZACION)
- 'If TxtDescuento.Text.ToDouble > 0 Then
- ' DescuentoConIVA = TxtDescuento.Text.ToDouble * 1.16
-
- ' 'Valida que el descuento con iva cuadre en los totales
- ' If Math.Abs(DescuentoConIVA - (Importe - TxtTotal.Text.ToDouble)) < 0.02 Then
- ' DescuentoConIVA = Importe - TxtTotal.Text.ToDouble
- ' ElseIf DescuentoConIVA <> (Importe - TxtTotal.Text.ToDouble) Then
- ' ErrorAC = True
- ' Exit For
- ' End If
-
- ' 'actualizo el idcuenta del presupuesto
- ' If ObjContaAC.AddMovimiento(123456, IdPoliza, tIdContaProveedor, True, Importe - DescuentoConIVA, "", ConceptoRenglon, 0, Fecha, "") Then
- ' 'agrego a la cuenta contable anticipos
- ' If Not ObjContaAC.AddMovimiento(123456, IdPoliza, CtaProveedorAnticipos, True, DescuentoConIVA, "", ConceptoRenglon, 0, Fecha, "") Then
- ' ErrorAC = True
- ' Exit For
- ' End If
- ' Else
- ' ErrorAC = True
- ' Exit For
- ' End If
-
- 'Else
- ' 'actualizo el idcuenta del presupuesto
- ' Importe = TxtTotal.Text.ToDouble
- ' If Not ObjContaAC.AddMovimiento(123456, IdPoliza, tIdContaProveedor, True, If(ArrAnticipos.Count > 0, ImporteAnticipo, Importe), "", ConceptoRenglon, 0, Fecha, "") Then
- ' ErrorAC = True
- ' Exit For
- ' End If
-
- 'End If
-
+ Else
+ ErrorACMEnsaje.Append(" - Error AFECTAR MATRIZ EGRESOS ObjContaAC.AddMovimiento")
+ ErrorAC = True
+ Exit For
+ End If
+ ''TERMINA AFECTAR MATRIZ EGRESOS
Else
- ErrorACMEnsaje.Append(" - Error AFECTAR MATRIZ EGRESOS ObjContaAC.AddMovimiento")
+ ErrorACMEnsaje.Append(" - For Each grp In Presup Importe > 0 ")
ErrorAC = True
Exit For
End If
- ''TERMINA AFECTAR MATRIZ EGRESOS
- Else
- ErrorACMEnsaje.Append(" - For Each grp In Presup Importe > 0 ")
- ErrorAC = True
- Exit For
- End If
+ Next
- Next
+ ''[IPP] COMENTADO A MIRAS DE ELIMINAR 21-FEBRERO-2018
+ ''VERIFICA SI TIENE DESCUENTO (AMORTIZACION)
+ 'If TxtDescuento.Text.ToDouble > 0 Then
+ ' DescuentoConIVA = TxtDescuento.Text.ToDecimal * 1.16D
- ''[IPP] COMENTADO A MIRAS DE ELIMINAR 21-FEBRERO-2018
- ''VERIFICA SI TIENE DESCUENTO (AMORTIZACION)
- 'If TxtDescuento.Text.ToDouble > 0 Then
- ' DescuentoConIVA = TxtDescuento.Text.ToDecimal * 1.16D
+ ' 'Valida que el descuento con iva cuadre en los totales
+ ' If Math.Abs(DescuentoConIVA - (Importe - TxtTotal.Text.ToDecimal)) < 0.02 Then
+ ' DescuentoConIVA = Importe - TxtTotal.Text.ToDecimal
+ ' ElseIf DescuentoConIVA <> (Importe - TxtTotal.Text.ToDecimal) Then
+ ' ErrorACMEnsaje.Append(" - Valida que el descuento con iva cuadre en los totales ")
+ ' ErrorAC = True
+ ' End If
- ' 'Valida que el descuento con iva cuadre en los totales
- ' If Math.Abs(DescuentoConIVA - (Importe - TxtTotal.Text.ToDecimal)) < 0.02 Then
- ' DescuentoConIVA = Importe - TxtTotal.Text.ToDecimal
- ' ElseIf DescuentoConIVA <> (Importe - TxtTotal.Text.ToDecimal) Then
- ' ErrorACMEnsaje.Append(" - Valida que el descuento con iva cuadre en los totales ")
- ' ErrorAC = True
- ' End If
-
- ' 'actualizo el idcuenta del presupuesto
- ' If ObjContaAC.AddMovimiento(IdPoliza, tIdContaProveedor, True, MultiplicadorNC * (Importe - DescuentoConIVA), "", ConceptoRenglon, 0, Fecha, "") Then
- ' 'agrego a la cuenta contable anticipos
- ' If Not ObjContaAC.AddMovimiento(IdPoliza, CtaProveedorAnticipos, True, MultiplicadorNC * DescuentoConIVA, "", ConceptoRenglon, 0, Fecha, "") Then
- ' ErrorACMEnsaje.Append(" - actualizo el idcuenta del presupuesto ObjContaAC.AddMovimiento 1")
- ' ErrorAC = True
- ' End If
- ' Else
- ' ErrorACMEnsaje.Append(" - actualizo el idcuenta del presupuesto ObjContaAC.AddMovimiento 2")
- ' ErrorAC = True
- ' End If
- 'Else
- 'actualizo el idcuenta del presupuesto
- Importe = TxtTotal.Text.ToDecimal
- If Not ObjContaAC.AddMovimiento(IdPoliza, tIdContaProveedor, True, MultiplicadorNC * (If(ArrAnticipos.Count > 0, ImporteAnticipo, Importe)), "", ConceptoRenglon, 0, Fecha, "") Then
- ErrorACMEnsaje.Append(" - actualizo el idcuenta del presupuesto ObjContaAC.AddMovimiento 3")
- ErrorAC = True
- End If
- 'End If
-
-
- If tRetISR > 0 Then
- ConceptoRenglon = String.Format("GD Fact: {0}-{1} {2}", TxtSerie.Text.Trim, TxtFolio.Text.Trim, DdlProveedor.SelectedItem.Text)
- If Not ObjContaAC.AddMovimiento(IdPoliza, CtaProveedorRetISR, True, MultiplicadorNC * tRetISR, "", ConceptoRenglon, 0, Fecha, "") Then
- ErrorACMEnsaje.Append(" RetISR > 0 ObjContaAC.AddMovimiento")
+ ' 'actualizo el idcuenta del presupuesto
+ ' If ObjContaAC.AddMovimiento(IdPoliza, tIdContaProveedor, True, MultiplicadorNC * (Importe - DescuentoConIVA), "", ConceptoRenglon, 0, Fecha, "") Then
+ ' 'agrego a la cuenta contable anticipos
+ ' If Not ObjContaAC.AddMovimiento(IdPoliza, CtaProveedorAnticipos, True, MultiplicadorNC * DescuentoConIVA, "", ConceptoRenglon, 0, Fecha, "") Then
+ ' ErrorACMEnsaje.Append(" - actualizo el idcuenta del presupuesto ObjContaAC.AddMovimiento 1")
+ ' ErrorAC = True
+ ' End If
+ ' Else
+ ' ErrorACMEnsaje.Append(" - actualizo el idcuenta del presupuesto ObjContaAC.AddMovimiento 2")
+ ' ErrorAC = True
+ ' End If
+ 'Else
+ 'actualizo el idcuenta del presupuesto
+ Importe = TxtTotal.Text.ToDecimal
+ If Not ObjContaAC.AddMovimiento(IdPoliza, tIdContaProveedor, True, MultiplicadorNC * (If(ArrAnticipos.Count > 0, ImporteAnticipo, Importe)), "", ConceptoRenglon, 0, Fecha, "") Then
+ ErrorACMEnsaje.Append(" - actualizo el idcuenta del presupuesto ObjContaAC.AddMovimiento 3")
ErrorAC = True
End If
+ 'End If
+
+
+ If tRetISR > 0 Then
+ ConceptoRenglon = String.Format("GD Fact: {0}-{1} {2}", TxtSerie.Text.Trim, TxtFolio.Text.Trim, DdlProveedor.SelectedItem.Text)
+ If Not ObjContaAC.AddMovimiento(IdPoliza, CtaProveedorRetISR, True, MultiplicadorNC * tRetISR, "", ConceptoRenglon, 0, Fecha, "") Then
+ ErrorACMEnsaje.Append(" RetISR > 0 ObjContaAC.AddMovimiento")
+ ErrorAC = True
+ End If
+ End If
+
+ 'TERMINA: PRUEBA AGRUPACION CONCEPTOS
+
+ 'registrar amortizar anticipos
End If
- 'TERMINA: PRUEBA AGRUPACION CONCEPTOS
-
- 'registrar amortizar anticipos
+ Else
+ ErrorACMEnsaje.Append(" - Id Poliza = 0 ")
+ ErrorAC = True
End If
-
Else
- ErrorACMEnsaje.Append(" - Id Poliza = 0 ")
+ TieneError = True
+ ErrorACMEnsaje.Append("- TotalPorDevengar <= TxtTotal.Text.ToDouble And TotalPorDevengar > 0")
ErrorAC = True
End If
- Else
- TieneError = True
- ErrorACMEnsaje.Append("- TotalPorDevengar <= TxtTotal.Text.ToDouble And TotalPorDevengar > 0")
- ErrorAC = True
End If
- End If
- If Not ErrorAC Then
-
- ''EMPIEZA: INSERTA DETALLES DE LA COMPRA
- Dim indiceTR = 0
- Dim Cont As Integer = 0
- For Each Row As DataRow In TmpDT.Rows
- Dim TipoRecepcion As Integer = -1
+ If Not ErrorAC Then
- ''INVENTARIOS
- If GvInv.Rows.Count > indiceTR Then
- If GvInv.Rows(indiceTR).FCCheckBox("cbInv").Checked = True And GvInv.Rows(indiceTR).FCDropDownList("DdlRecibirInv").SelectedValue = "1" Then
- TipoRecepcion = 1
- ElseIf GvInv.Rows(indiceTR).FCCheckBox("cbInv").Checked = True And GvInv.Rows(indiceTR).FCDropDownList("DdlRecibirInv").SelectedValue = "0" Then
- TipoRecepcion = 2
- End If
+ Dim AutoConta As Boolean = UsuarioActual.Empresa.Funcionalidad(200) = "1"
+
+ If UsuarioActual.CveEmpresa = 119 AndAlso (DdlPersonalReembolso.SelectedValue.ToEntero > 0 Or DdlCuentaCajaChicaReembolso.SelectedValue.ToEntero > 0) Then
+ AutoConta = False
End If
- Dim CvePersonal = -1
- Dim Referencia = ""
-
- If GvPersonal.Rows.Count > Cont Then
- CvePersonal = GvPersonal.Rows(Cont).FCDropDownList("DdlPersonalGv").SelectedValue.ToEntero
- Referencia = GvPersonal.Rows(Cont).FCTextBox("TxtReferencia").Text
+ If (AutoConta Or UsuarioActual.Empresa.UsaAC) And ObjContaAC Is Nothing Then
+ ObjContaAC = New ClsContPAQi(UsuarioActual.Empresa)
+ ObjContaAC.IniciaTransacSQL()
End If
- Cont = Cont + 1
- 'Si es AF-INSUMO se guarda CveAF en CompraDetalle
- Dim CveAF = If(Row("CveActivoFijo").ToString.ToEntero > 0 AndAlso Row("TipoAF").ToString.ToEntero = 1, Row("CveActivoFijo").ToString.ToEntero, -1)
+ ''EMPIEZA: INSERTA DETALLES DE LA COMPRA
+ Dim indiceTR = 0
+ Dim Cont As Integer = 0
+ For Each Row As DataRow In TmpDT.Rows
+ Dim TipoRecepcion As Integer = -1
- 'Si es AF-COMPRA se guarda CveAF en la Columna CveAFCompra
- Dim CveAFC = If(Row("CveActivoFijo").ToString.ToEntero > 0 AndAlso Row("TipoAF").ToString.ToEntero = 2, Row("CveActivoFijo").ToString.ToEntero, -1)
- 'AGREGA COMPRA DETALLE
- If Not ObjCompras.AddCompraDetalle(CveCompra, Row("CveUM").ToString.ToEntero, Row("CvePS").ToString.ToEntero, Row("CveSubProyecto").ToString.ToEntero, -1, CveAF,
- Row("Cantidad").ToString.ToDouble, Row("PU").ToString.ToDouble, Row("IVA").ToString.ToDouble, Row("Total").ToString.ToDouble, Row("Descuento").ToString.ToDouble,
- Row("Obs").ToString, Row("CveOrdenCompraDetalle").ToString.ToEntero, TipoRecepcion, Row("CveContrato").ToString.ToEntero, Row("CvePresupuestoEgreso").ToString.ToEntero,
- AplicaCostoIndirecto:=Row("AplicaCostoIndirecto").ToString.ToEntero, EstatusAlmacen:=Row("EntregaDirecta").ToString.ToEntero, CvePersonal:=CvePersonal,
- CveTipoGasto:=Row("CveTipoGasto").ToString.ToEntero, AF_Medida:=Row("AFMedida").ToString.ToEntero, AF_TipoMantenimiento:=Row("AFTipoMantenimiento").ToString.ToEntero, Referencia:=Referencia, OtrosGastos:=Row("OtrosGastos").ToString.ToDecimal,
- RetIVA:=Row("RetIVA").ToString.ToDouble, RetISR:=Row("RetISR").ToString.ToDouble, IEPSPS:=Row("IEPSPS").ToString.ToDouble, IEPSPSIVA:=Row("IEPSPSIVA").ToString.ToDouble,
- IVAPorcentaje:=Row("IVAPorcentaje").ToString.ToDouble, RetIVAPorcentaje:=Row("RetIVAPorcentaje").ToString.ToDouble, RetISRPorcentaje:=Row("RetISRPorcentaje").ToString.ToDouble,
- IEPSPSPorcentaje:=Row("IEPSPSPorcentaje").ToString.ToDouble, IEPSPSIVAPorcentaje:=Row("IEPSPSIVAPorcentaje").ToString.ToDouble, NoDeducible:=If(Row("NoDeducible").ToString = "True" AndAlso EsNoDeducible, True, False)) Then
-
- ErrorDetalles = True
- Exit For
- Else
-
- If Row("EntregaDirecta").ToString.ToEntero > 0 Then
- EntregaDirecta = True
+ ''INVENTARIOS
+ If GvInv.Rows.Count > indiceTR Then
+ If GvInv.Rows(indiceTR).FCCheckBox("cbInv").Checked = True And GvInv.Rows(indiceTR).FCDropDownList("DdlRecibirInv").SelectedValue = "1" Then
+ TipoRecepcion = 1
+ ElseIf GvInv.Rows(indiceTR).FCCheckBox("cbInv").Checked = True And GvInv.Rows(indiceTR).FCDropDownList("DdlRecibirInv").SelectedValue = "0" Then
+ TipoRecepcion = 2
+ End If
End If
- Dim TmpDr As DataRow = TmpDT.Select($"Consec = {Row("Consec").ToString}")(0)
- TmpDr("CveCompraDetalle") = ObjCompras.CveCompraDetalle
+ Dim CvePersonal = -1
+ Dim Referencia = ""
- ' Si no es un movimiento de almacen va a tronar
- Try
- Dim InvDr As DataRow = DtInv.Select($"Consec = {Row("Consec").ToString}")(0)
- InvDr("CveCompraDetalle") = ObjCompras.CveCompraDetalle
- Catch ex As Exception
- End Try
+ If GvPersonal.Rows.Count > Cont Then
+ CvePersonal = GvPersonal.Rows(Cont).FCDropDownList("DdlPersonalGv").SelectedValue.ToEntero
+ Referencia = GvPersonal.Rows(Cont).FCTextBox("TxtReferencia").Text
+ End If
+ Cont = Cont + 1
- End If
+ 'Si es AF-INSUMO se guarda CveAF en CompraDetalle
+ Dim CveAF = If(Row("CveActivoFijo").ToString.ToEntero > 0 AndAlso Row("TipoAF").ToString.ToEntero = 1, Row("CveActivoFijo").ToString.ToEntero, -1)
- 'Vincula Vales
- If IdVale.Count > 0 Then
- For Each cve In IdVale
- If Not ObjAF.UpdateValeCombustible(cve, CveCompra, -1, "", -1, -1, -1, UsuarioActual.CveEmpresa) Then
- ErrorAF = True
+ 'Si es AF-COMPRA se guarda CveAF en la Columna CveAFCompra
+ Dim CveAFC = If(Row("CveActivoFijo").ToString.ToEntero > 0 AndAlso Row("TipoAF").ToString.ToEntero = 2, Row("CveActivoFijo").ToString.ToEntero, -1)
+
+ 'AGREGA COMPRA DETALLE
+ If Not ObjCompras.AddCompraDetalle(CveCompra, Row("CveUM").ToString.ToEntero, Row("CvePS").ToString.ToEntero, Row("CveSubProyecto").ToString.ToEntero, -1, CveAF,
+ Row("Cantidad").ToString.ToDouble, Row("PU").ToString.ToDouble, Row("IVA").ToString.ToDouble, Row("Total").ToString.ToDouble, Row("Descuento").ToString.ToDouble,
+ Row("Obs").ToString, Row("CveOrdenCompraDetalle").ToString.ToEntero, TipoRecepcion, Row("CveContrato").ToString.ToEntero, Row("CvePresupuestoEgreso").ToString.ToEntero,
+ AplicaCostoIndirecto:=Row("AplicaCostoIndirecto").ToString.ToEntero, EstatusAlmacen:=Row("EntregaDirecta").ToString.ToEntero, CvePersonal:=CvePersonal,
+ CveTipoGasto:=Row("CveTipoGasto").ToString.ToEntero, AF_Medida:=Row("AFMedida").ToString.ToEntero, AF_TipoMantenimiento:=Row("AFTipoMantenimiento").ToString.ToEntero, Referencia:=Referencia, OtrosGastos:=Row("OtrosGastos").ToString.ToDecimal,
+ RetIVA:=Row("RetIVA").ToString.ToDouble, RetISR:=Row("RetISR").ToString.ToDouble, IEPSPS:=Row("IEPSPS").ToString.ToDouble, IEPSPSIVA:=Row("IEPSPSIVA").ToString.ToDouble,
+ IVAPorcentaje:=Row("IVAPorcentaje").ToString.ToDouble, RetIVAPorcentaje:=Row("RetIVAPorcentaje").ToString.ToDouble, RetISRPorcentaje:=Row("RetISRPorcentaje").ToString.ToDouble,
+ IEPSPSPorcentaje:=Row("IEPSPSPorcentaje").ToString.ToDouble, IEPSPSIVAPorcentaje:=Row("IEPSPSIVAPorcentaje").ToString.ToDouble, NoDeducible:=If(Row("NoDeducible").ToString = "True" AndAlso EsNoDeducible, True, False)) Then
+
+ ErrorDetalles = True
+ Exit For
+ Else
+
+ If Row("EntregaDirecta").ToString.ToEntero > 0 Then
+ EntregaDirecta = True
+ End If
+
+ Dim TmpDr As DataRow = TmpDT.Select($"Consec = {Row("Consec").ToString}")(0)
+ TmpDr("CveCompraDetalle") = ObjCompras.CveCompraDetalle
+
+ ' Si no es un movimiento de almacen va a tronar
+ Try
+ Dim InvDr As DataRow = DtInv.Select($"Consec = {Row("Consec").ToString}")(0)
+ InvDr("CveCompraDetalle") = ObjCompras.CveCompraDetalle
+ Catch ex As Exception
+ End Try
+
+ End If
+
+ 'Vincula Vales
+ If IdVale.Count > 0 Then
+ For Each cve In IdVale
+ If Not ObjAF.UpdateValeCombustible(cve, CveCompra, -1, "", -1, -1, -1, UsuarioActual.CveEmpresa) Then
+ ErrorAF = True
+ Exit For
+ End If
+ Next
+ Else
+
+ End If
+
+
+
+ 'AGREGA AF COMPRA - Cuando es Compra se guarda CveCompraDetalle en AF
+ If Row("TipoAF").ToString.ToEntero = 2 Then
+ If Not ObjAF.UpdateActivosFijosCompra(Row("CveActivoFijo").ToString.ToEntero, ObjCompras.CveCompraDetalle, Row("TipoAF").ToString.ToEntero, Row("Total").ToString.ToDouble, TxtFecha.Text.Trim.ToDate) Then
+ ErrorDetalles = True
+ Exit For
+ End If
+ End If
+
+ 'ACTUALIZAR PRODUCTO/SERVICIO SAT
+ If Version = "3.3" Then
+ If Not ObjProductosServicios.UpdateProductosServiciosSAT(Row("CvePS").ToString().ToEntero(), Row("CveSATPS").ToString().ToEntero(), UsuarioActual.CveUsuario) Then
+ ErrorSATPS = True
+ End If
+ End If
+
+ indiceTR += 1
+ Next
+ ''TERMINA: INSERTA DETALLES DE LA COMPRA
+
+ 'QUEMA SALDOS DE INV-COMPRA | MERCANCIA RECIBIDA POR ADELANTADO (OC) | PP 176
+ If OCVinculada And Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") And Not UsuarioActual.Empresa.Funcionalidad(126) = "1" Then
+ For Each Row As DataRow In TmpDT.FiltraParametros("CveTipoPS = 2").Rows
+ If Not ObjOC.OrdenesCompraDetalleSaldosInvCompraAdd(Row("CveOrdenCompraDetalle").ToString.ToEntero, -1, -1, Row("CveCompraDetalle").ToString.ToEntero, Row("Cantidad").ToString.ToDouble) Then
+ ErrorSaldosInvComp = True
Exit For
End If
Next
- Else
+
+ 'verifica si fue vinculada con una OC, y si fue la opción de entrega por adelantado, que si hubo cambios de precios
+ If DdlOCVinculaInv.SelectedValue.ToEntero.Contiene(176, 205) Then
+ If Not AjustarPrePolizaVinculacionOC(ObjOC, ObjEventos, ObjInventario, ObjConta, ObjContaAC) Then
+ ErrorPrepoliza = True
+ End If
+ End If
End If
+ If CvePrePoliza > 0 Then
+ 'INVENTARIOS - ALMACEN
+ If UsuarioActual.Empresa.UsaInventarios Then 'And UsuarioActual.Empresa.UsaAC = False
- 'AGREGA AF COMPRA - Cuando es Compra se guarda CveCompraDetalle en AF
- If Row("TipoAF").ToString.ToEntero = 2 Then
- If Not ObjAF.UpdateActivosFijosCompra(Row("CveActivoFijo").ToString.ToEntero, ObjCompras.CveCompraDetalle, Row("TipoAF").ToString.ToEntero, Row("Total").ToString.ToDouble, TxtFecha.Text.Trim.ToDate) Then
- ErrorDetalles = True
- Exit For
- End If
- End If
+ ''SI ES CON DOLARES VALIDA QUE SE TENGA EL TIPO DE CAMBIO DEL DIA DE LA FACTURA - SI NO, NO HACE NADA, la validación del TC, ya está chk constrains
+ ' If DdlMoneda.SelectedValue.ToEntero = 1 Or (DdlMoneda.SelectedValue.ToEntero > 1 AndAlso GlobalTipoCambio(TxtFecha.Text.ToDate) > 0) Then
- 'ACTUALIZAR PRODUCTO/SERVICIO SAT
- If Version = "3.3" Then
- If Not ObjProductosServicios.UpdateProductosServiciosSAT(Row("CvePS").ToString().ToEntero(), Row("CveSATPS").ToString().ToEntero(), UsuarioActual.CveUsuario) Then
- ErrorSATPS = True
- End If
- End If
+ ''ALMACEN CONSIGNACION
+ If CveConsignacion > 0 Then
- indiceTR += 1
- Next
- ''TERMINA: INSERTA DETALLES DE LA COMPRA
-
- 'QUEMA SALDOS DE INV-COMPRA | MERCANCIA RECIBIDA POR ADELANTADO (OC) | PP 176
- If OCVinculada And Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") And Not UsuarioActual.Empresa.Funcionalidad(126) = "1" Then
- For Each Row As DataRow In TmpDT.FiltraParametros("CveTipoPS = 2").Rows
- If Not ObjOC.OrdenesCompraDetalleSaldosInvCompraAdd(Row("CveOrdenCompraDetalle").ToString.ToEntero, -1, -1, Row("CveCompraDetalle").ToString.ToEntero, Row("Cantidad").ToString.ToDouble) Then
- ErrorSaldosInvComp = True
- Exit For
- End If
- Next
-
- 'verifica si fue vinculada con una OC, y si fue la opción de entrega por adelantado, que si hubo cambios de precios
- If DdlOCVinculaInv.SelectedValue.ToEntero.Contiene(176, 205) Then
- If Not AjustarPrePolizaVinculacionOC(ObjOC, ObjEventos, ObjInventario, ObjConta) Then
- ErrorPrepoliza = True
- End If
- End If
-
- End If
-
- If CvePrePoliza > 0 Then
-
- 'INVENTARIOS - ALMACEN
- If UsuarioActual.Empresa.UsaInventarios Then 'And UsuarioActual.Empresa.UsaAC = False
-
- ''SI ES CON DOLARES VALIDA QUE SE TENGA EL TIPO DE CAMBIO DEL DIA DE LA FACTURA - SI NO, NO HACE NADA, la validación del TC, ya está chk constrains
- ' If DdlMoneda.SelectedValue.ToEntero = 1 Or (DdlMoneda.SelectedValue.ToEntero > 1 AndAlso GlobalTipoCambio(TxtFecha.Text.ToDate) > 0) Then
-
- ''ALMACEN CONSIGNACION
- If CveConsignacion > 0 Then
-
- 'actualizamos cvecompraconsignacion
- For Each gvr As GridViewRow In GvInv.Rows
- If gvr.FCCheckBox("cbinv").Checked AndAlso gvr.FCHiddenField("HdnCveConsignacion").Value.ToEntero > 0 Then
- If Not ObjInventario.UpdateConsignacionesCompra(CveCompra, gvr.FCHiddenField("HdnCveConsignacion").Value.ToEntero, gvr.FCHiddenField("HdnCveAlmacen").Value.ToEntero, gvr.FCHiddenField("HdnCvePS").Value.ToEntero, gvr.DataKey("Cantidad").ToDouble, UsuarioActual.CveEmpresa) Then
- ErrorMovInv = True
- Exit For
+ 'actualizamos cvecompraconsignacion
+ For Each gvr As GridViewRow In GvInv.Rows
+ If gvr.FCCheckBox("cbinv").Checked AndAlso gvr.FCHiddenField("HdnCveConsignacion").Value.ToEntero > 0 Then
+ If Not ObjInventario.UpdateConsignacionesCompra(CveCompra, gvr.FCHiddenField("HdnCveConsignacion").Value.ToEntero, gvr.FCHiddenField("HdnCveAlmacen").Value.ToEntero, gvr.FCHiddenField("HdnCvePS").Value.ToEntero, gvr.DataKey("Cantidad").ToDouble, UsuarioActual.CveEmpresa) Then
+ ErrorMovInv = True
+ Exit For
+ End If
End If
+ Next
+
+ If Not ErrorMovInv Then
+
+ Dim x As Integer = 0
+ For Each dr As DataRow In DtInv.Rows
+ If GvInv.Rows(x).FCCheckBox("cbInv").Checked And GvInv.Rows(x).FCTextBox("TbCantidad").Text.ToDouble > 0 Then
+
+ Dim TmpDr As DataRow = TmpDT.Select($"Consec = {dr("Consec").ToString.ToEntero}")(0) 'Charlie
+ TmpDr("CveAlmacen") = GvInv.Rows(x).FCDropDownList("ddlEAlmacen").SelectedValue.ToEntero 'Charlie
+
+ dr("CveAlmacen") = GvInv.Rows(x).FCDropDownList("ddlealmacen").SelectedValue.ToEntero
+ dr("Cantidad") = GvInv.Rows(x).FCTextBox("TbCantidad").Text.ToDouble
+ Else
+ Dim TmpDr As DataRow = TmpDT.Select($"Consec = {dr("Consec").ToString.ToEntero}")(0) 'Charlie
+ TmpDr("CveAlmacen") = 0 'Charlie
+
+ dr("CveAlmacen") = 0
+ End If
+ x = x + 1
+ Next
+
+ Dim cvemovimientosalida = 0
+ Dim cvemovimientoentrada = 0
+ Dim cvemovimientosalidagasto = 0
+ Dim folio = 0
+ Dim fecha As Date = TxtFecha.Text.ToDate
+ Dim indice = 0
+ Dim importeconcepto = 0.0
+
+ Dim listalmacenes = (From cvealmacen In DtInv.AsEnumerable() Where cvealmacen.Field(Of Integer)("cvealmacen") > 0 Select cvealmacen.Field(Of Integer)("cvealmacen")).Distinct().ToList
+
+ For Each tcvealmacen As Integer In listalmacenes
+ If GvInv.Rows(indice).FCDropDownList("ddlrecibirinv").SelectedValue = "1" Then
+ Continue For
+ End If
+ indice += 1
+
+
+ ''agregamos la salida de consignacion
+ 'folio = objinventario.getfoliosiguiente(3, usuarioactual.cveempresa)
+ 'cvemovimientosalida = objinventario.addmovimiento(cvealmacenconsignacion, 3, ddlmoneda.selectedvalue.toentero, fecha, folio, usuarioactual.cveusuario, usuarioactual.cveempresa, cvecompra, -1, -1, -1)
+ 'if cvemovimientosalida <= 0 then
+ ' errormovinv = true
+ ' exit for
+ 'else
+ ' for each dr as datarow in dtinv.rows
+ ' if dr("cvealmacen").tostring.toentero = tcvealmacen then
+ ' if not objinventario.addmovimientodetalle(cvemovimientosalida, dr("cantidad").tostring.todouble, ddlum.selectedvalue.toentero, dr("cveps").tostring.toentero, 0, -1) then
+ ' errormovinv = true
+ ' exit for
+
+ ' end if
+ ' end if
+ ' next
+ 'end if
+
+
+ 'agregamos la entrada
+ If Not UsuarioActual.Empresa.UsaAC Then fecha = Now
+
+ folio = ObjInventario.GetFolioSiguiente(2, UsuarioActual.CveEmpresa)
+ cvemovimientoentrada = ObjInventario.AddMovimiento(tcvealmacen, 2, 1, fecha, folio, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra, -1, -1, -1, TipoCambio:=If(DdlMoneda.SelectedValue.ToEntero = 1, -1, TipoCambioGuardar))
+ If cvemovimientoentrada <= 0 Then
+ ErrorMovInv = True
+ Exit For
+ Else
+ CveMovimientoInventario = cvemovimientoentrada
+ ListaMovimientosAlmacen.Add(CveMovimientoInventario)
+
+ For Each dr As DataRow In DtInv.Rows
+ If dr("cvealmacen").ToString.ToEntero = tcvealmacen Then
+
+ importeconcepto = If(DdlMoneda.SelectedValue.ToEntero = 1, dr("pu").ToString.ToDouble, dr("pu").ToString.ToDouble * TipoCambioGuardar)
+ If Not ObjInventario.AddMovimientoDetalle(cvemovimientoentrada, dr("cantidad").ToString.ToDouble, dr("cveum").ToString.ToEntero, dr("cveps").ToString.ToEntero, importeconcepto, -1, PUTC:=If(DdlMoneda.SelectedValue.ToEntero = 1, -1, dr("pu").ToString.ToDouble), CveCompraDetalle:=dr("CveCompraDetalle").ToString.ToEntero) Then
+
+ ErrorMovInv = True
+ Exit For
+ End If
+ End If
+ Next
+
+ End If
+
+ 'agregamos la salida gasto
+ folio = ObjInventario.GetFolioSiguiente(3, UsuarioActual.CveEmpresa)
+ cvemovimientosalidagasto = ObjInventario.AddMovimiento(tcvealmacen, 3, DdlMoneda.SelectedValue.ToEntero, fecha.AddSeconds(1), folio, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra, -1, -1, -1)
+ If cvemovimientosalidagasto <= 0 Then
+ ErrorMovInv = True
+ Exit For
+ Else
+ If ObjInventario.GetMovimientosDetalle(cvemovimientoentrada, UsuarioActual.CveEmpresa) Then
+ For Each dr As DataRow In ObjInventario.DtResultados.Rows
+ If Not ObjInventario.AddMovimientoDetalle(cvemovimientosalidagasto, dr("cantidad").ToString.ToDouble, dr("cveum").ToString.ToEntero, dr("cveps").ToString.ToEntero, 0, dr("cveaf").ToString.ToEntero, CveCompraDetalle:=dr("CveCompraDetalle").ToString.ToEntero) Then
+ ErrorMovInv = True
+ Exit For
+ End If
+ Next
+ End If
+ End If
+
+ Next
+
End If
- Next
- If Not ErrorMovInv Then
+ ''ALMACEN NORMAL
+ Else
+ 'OBTIENE ALMACENES
Dim x As Integer = 0
- For Each dr As DataRow In DtInv.Rows
- If GvInv.Rows(x).FCCheckBox("cbInv").Checked And GvInv.Rows(x).FCTextBox("TbCantidad").Text.ToDouble > 0 Then
+ For Each Dr As DataRow In DtInv.Rows
+ If GvInv.Rows(x).FCCheckBox("cbInv").Checked And GvInv.Rows(x).FCTextBox("TbCantidad").Text.ToDecimal > 0 Then
- Dim TmpDr As DataRow = TmpDT.Select($"Consec = {dr("Consec").ToString.ToEntero}")(0) 'Charlie
- TmpDr("CveAlmacen") = GvInv.Rows(x).FCDropDownList("ddlEAlmacen").SelectedValue.ToEntero 'Charlie
+ Dim TmpDr As DataRow = TmpDT.Select($"Consec = {Dr("Consec").ToString.ToEntero}")(0)
+ TmpDr("CveAlmacen") = GvInv.Rows(x).FCDropDownList("ddlEAlmacen").SelectedValue.ToEntero
- dr("CveAlmacen") = GvInv.Rows(x).FCDropDownList("ddlealmacen").SelectedValue.ToEntero
- dr("Cantidad") = GvInv.Rows(x).FCTextBox("TbCantidad").Text.ToDouble
- Else
- Dim TmpDr As DataRow = TmpDT.Select($"Consec = {dr("Consec").ToString.ToEntero}")(0) 'Charlie
- TmpDr("CveAlmacen") = 0 'Charlie
+ Dr("CveAlmacen") = GvInv.Rows(x).FCDropDownList("ddlEAlmacen").SelectedValue.ToEntero
+ Dr("Cantidad") = GvInv.Rows(x).FCTextBox("TbCantidad").Text.ToDouble
- dr("CveAlmacen") = 0
+ Else 'limpio el valor para que no truene en linq mas abajo
+
+ Dim TmpDr As DataRow = TmpDT.Select($"Consec = {Dr("Consec").ToString.ToEntero}")(0)
+ TmpDr("CveAlmacen") = 0
+
+ Dr("CveAlmacen") = 0
End If
x = x + 1
Next
- Dim cvemovimientosalida = 0
- Dim cvemovimientoentrada = 0
- Dim cvemovimientosalidagasto = 0
- Dim folio = 0
- Dim fecha As Date = TxtFecha.Text.ToDate
+ Dim i As Integer = 0
+ Dim ListAlmacenes = (From CveAlmacen In DtInv.AsEnumerable() Where CveAlmacen.Field(Of Integer)("CveAlmacen") > 0 Select CveAlmacen.Field(Of Integer)("CveAlmacen")).Distinct().ToList
Dim indice = 0
- Dim importeconcepto = 0.0
+ Dim ImporteConcepto = 0.0
- Dim listalmacenes = (From cvealmacen In DtInv.AsEnumerable() Where cvealmacen.Field(Of Integer)("cvealmacen") > 0 Select cvealmacen.Field(Of Integer)("cvealmacen")).Distinct().ToList
-
- For Each tcvealmacen As Integer In listalmacenes
- If GvInv.Rows(indice).FCDropDownList("ddlrecibirinv").SelectedValue = "1" Then
+ For Each tCveAlmacen As Integer In ListAlmacenes
+ If GvInv.Rows(indice).FCDropDownList("DdlRecibirInv").SelectedValue = "1" Then
Continue For
End If
indice += 1
-
- ''agregamos la salida de consignacion
- 'folio = objinventario.getfoliosiguiente(3, usuarioactual.cveempresa)
- 'cvemovimientosalida = objinventario.addmovimiento(cvealmacenconsignacion, 3, ddlmoneda.selectedvalue.toentero, fecha, folio, usuarioactual.cveusuario, usuarioactual.cveempresa, cvecompra, -1, -1, -1)
- 'if cvemovimientosalida <= 0 then
- ' errormovinv = true
- ' exit for
- 'else
- ' for each dr as datarow in dtinv.rows
- ' if dr("cvealmacen").tostring.toentero = tcvealmacen then
- ' if not objinventario.addmovimientodetalle(cvemovimientosalida, dr("cantidad").tostring.todouble, ddlum.selectedvalue.toentero, dr("cveps").tostring.toentero, 0, -1) then
- ' errormovinv = true
- ' exit for
-
- ' end if
- ' end if
- ' next
- 'end if
-
-
- 'agregamos la entrada
+ Dim fecha As Date = TxtFecha.Text.ToDate
If Not UsuarioActual.Empresa.UsaAC Then fecha = Now
- folio = ObjInventario.GetFolioSiguiente(2, UsuarioActual.CveEmpresa)
- cvemovimientoentrada = ObjInventario.AddMovimiento(tcvealmacen, 2, 1, fecha, folio, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra, -1, -1, -1, TipoCambio:=If(DdlMoneda.SelectedValue.ToEntero = 1, -1, TipoCambioGuardar))
- If cvemovimientoentrada <= 0 Then
+ CveMovimientoInventario = ObjInventario.AddMovimiento(tCveAlmacen, 2, 1, fecha, 0, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra, -1, -1, -1, TipoCambio:=If(DdlMoneda.SelectedValue.ToEntero = 1, -1, TipoCambioGuardar))
+
+ If CveMovimientoInventario <= 0 Then
ErrorMovInv = True
- Exit For
Else
- CveMovimientoInventario = cvemovimientoentrada
+
+ Dim DtDetalle As New DataTable
+ Dim DtEquivalencias As DataTable
+ Dim CveProducto As Integer
+ Dim CantidadInv As Double
+ Dim PUInv As Double
+ Dim CveUnidad As Integer
+ Dim CostoIndirecto As Double
+
ListaMovimientosAlmacen.Add(CveMovimientoInventario)
- For Each dr As DataRow In DtInv.Rows
- If dr("cvealmacen").ToString.ToEntero = tcvealmacen Then
- importeconcepto = If(DdlMoneda.SelectedValue.ToEntero = 1, dr("pu").ToString.ToDouble, dr("pu").ToString.ToDouble * TipoCambioGuardar)
- If Not ObjInventario.AddMovimientoDetalle(cvemovimientoentrada, dr("cantidad").ToString.ToDouble, dr("cveum").ToString.ToEntero, dr("cveps").ToString.ToEntero, importeconcepto, -1, PUTC:=If(DdlMoneda.SelectedValue.ToEntero = 1, -1, dr("pu").ToString.ToDouble), CveCompraDetalle:=dr("CveCompraDetalle").ToString.ToEntero) Then
+ For Each Dr As DataRow In DtInv.Rows
- ErrorMovInv = True
- Exit For
+ CveProducto = Dr("CvePS").ToString.ToEntero
+ CveUnidad = Dr("CveUM").ToString.ToEntero
+ CantidadInv = Dr("Cantidad").ToString.ToDouble
+ PUInv = Dr("PU").ToString.ToDouble
+ CostoIndirecto = Dr("CostoIndirectoAlmacen").ToString.ToDouble
+
+ If Dr("CveMetodoInventario").ToString.ToEntero = 5 Then
+ 'SI FUE POR SERIE LOTE
+ DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("CvePS = {0}", Dr("CvePS")))
+ If DtDetalle.Rows.Count > 0 Then
+ For Each drr As DataRow In DtDetalle.Rows
+ If Not ObjInventario.AddMovimientoDetalle(CveMovimientoInventario, 1, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDouble, -1, SerieLote:=drr("Serie").ToString, FechaCaducidad:=drr("FechaCaducidad").ToString.ToDate, CostoIndirecto:=Dr("CostoIndirectoAlmacen").ToString.ToDouble, CveCompraDetalle:=Dr("CveCompraDetalle").ToString.ToEntero, CveOrdenCompraDetalle:=Dr("CveOrdenCompraDetalle").ToString.ToEntero) Then
+ ErrorMovInv = True
+ Exit For
+ End If
+
+ Next
End If
- End If
- Next
+ Else
- End If
+ 'UNIDAD BASE - EQUIVALENCIAS - INVENTARIO
+ If UsuarioActual.CveEmpresa = 1 Then
+ DtEquivalencias = New DataTable
+ DtEquivalencias = GlobalDTProductosServiciosEquivalencias(CveProducto, -1)
+ Dim CveUnidadBase As Integer = DtEquivalencias.FiltroPrimeroValor("CveUM", "UnidadBase = 'True'").ToEntero
+ Dim drUMBase As DataRow = DtEquivalencias.FiltroPrimero("UnidadBase = 'True'")
- 'agregamos la salida gasto
- folio = ObjInventario.GetFolioSiguiente(3, UsuarioActual.CveEmpresa)
- cvemovimientosalidagasto = ObjInventario.AddMovimiento(tcvealmacen, 3, DdlMoneda.SelectedValue.ToEntero, fecha.AddSeconds(1), folio, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra, -1, -1, -1)
- If cvemovimientosalidagasto <= 0 Then
- ErrorMovInv = True
- Exit For
- Else
- If ObjInventario.GetMovimientosDetalle(cvemovimientoentrada, UsuarioActual.CveEmpresa) Then
- For Each dr As DataRow In ObjInventario.DtResultados.Rows
- If Not ObjInventario.AddMovimientoDetalle(cvemovimientosalidagasto, dr("cantidad").ToString.ToDouble, dr("cveum").ToString.ToEntero, dr("cveps").ToString.ToEntero, 0, dr("cveaf").ToString.ToEntero, CveCompraDetalle:=dr("CveCompraDetalle").ToString.ToEntero) Then
- ErrorMovInv = True
- Exit For
+ 'SI LA UNIDAD ACTUAL NO ES LA BASE SACA PROPORCION (EQUIVALENTE)
+ If CveUnidadBase <> CveUnidad Then
+ ' LO QUE PUSE LO QUE VALE UNIDAD BASE LO QUE VALE UNIDAD SELECCIONADA
+ CantidadInv = Dr("Cantidad").ToString.ToDouble * drUMBase("Cantidad").ToString.ToDouble / DtEquivalencias.FiltraParametros(String.Format("CveUM = {0}", CveUnidad)).Rows(0)("Cantidad").ToString.ToDouble
+ PUInv = PUInv * Dr("Cantidad").ToString.ToDouble / CantidadInv
+ CostoIndirecto = CostoIndirecto * Dr("Cantidad").ToString.ToDouble / CantidadInv
+ CveUnidad = CveUnidadBase
+ End If
End If
- Next
- End If
- End If
- Next
-
- End If
-
- ''ALMACEN NORMAL
- Else
-
- 'OBTIENE ALMACENES
- Dim x As Integer = 0
- For Each Dr As DataRow In DtInv.Rows
- If GvInv.Rows(x).FCCheckBox("cbInv").Checked And GvInv.Rows(x).FCTextBox("TbCantidad").Text.ToDecimal > 0 Then
-
- Dim TmpDr As DataRow = TmpDT.Select($"Consec = {Dr("Consec").ToString.ToEntero}")(0)
- TmpDr("CveAlmacen") = GvInv.Rows(x).FCDropDownList("ddlEAlmacen").SelectedValue.ToEntero
-
- Dr("CveAlmacen") = GvInv.Rows(x).FCDropDownList("ddlEAlmacen").SelectedValue.ToEntero
- Dr("Cantidad") = GvInv.Rows(x).FCTextBox("TbCantidad").Text.ToDouble
-
- Else 'limpio el valor para que no truene en linq mas abajo
-
- Dim TmpDr As DataRow = TmpDT.Select($"Consec = {Dr("Consec").ToString.ToEntero}")(0)
- TmpDr("CveAlmacen") = 0
-
- Dr("CveAlmacen") = 0
- End If
- x = x + 1
- Next
-
- Dim i As Integer = 0
- Dim ListAlmacenes = (From CveAlmacen In DtInv.AsEnumerable() Where CveAlmacen.Field(Of Integer)("CveAlmacen") > 0 Select CveAlmacen.Field(Of Integer)("CveAlmacen")).Distinct().ToList
- Dim indice = 0
- Dim ImporteConcepto = 0.0
-
- For Each tCveAlmacen As Integer In ListAlmacenes
- If GvInv.Rows(indice).FCDropDownList("DdlRecibirInv").SelectedValue = "1" Then
- Continue For
- End If
- indice += 1
-
- Dim fecha As Date = TxtFecha.Text.ToDate
- If Not UsuarioActual.Empresa.UsaAC Then fecha = Now
-
- CveMovimientoInventario = ObjInventario.AddMovimiento(tCveAlmacen, 2, 1, fecha, 0, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra, -1, -1, -1, TipoCambio:=If(DdlMoneda.SelectedValue.ToEntero = 1, -1, TipoCambioGuardar))
-
- If CveMovimientoInventario <= 0 Then
- ErrorMovInv = True
- Else
-
- Dim DtDetalle As New DataTable
- Dim DtEquivalencias As DataTable
- Dim CveProducto As Integer
- Dim CantidadInv As Double
- Dim PUInv As Double
- Dim CveUnidad As Integer
- Dim CostoIndirecto As Double
-
- ListaMovimientosAlmacen.Add(CveMovimientoInventario)
-
-
- For Each Dr As DataRow In DtInv.Rows
-
- CveProducto = Dr("CvePS").ToString.ToEntero
- CveUnidad = Dr("CveUM").ToString.ToEntero
- CantidadInv = Dr("Cantidad").ToString.ToDouble
- PUInv = Dr("PU").ToString.ToDouble
- CostoIndirecto = Dr("CostoIndirectoAlmacen").ToString.ToDouble
-
- If Dr("CveMetodoInventario").ToString.ToEntero = 5 Then
- 'SI FUE POR SERIE LOTE
- DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("CvePS = {0}", Dr("CvePS")))
- If DtDetalle.Rows.Count > 0 Then
- For Each drr As DataRow In DtDetalle.Rows
- If Not ObjInventario.AddMovimientoDetalle(CveMovimientoInventario, 1, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDouble, -1, SerieLote:=drr("Serie").ToString, FechaCaducidad:=drr("FechaCaducidad").ToString.ToDate, CostoIndirecto:=Dr("CostoIndirectoAlmacen").ToString.ToDouble, CveCompraDetalle:=Dr("CveCompraDetalle").ToString.ToEntero, CveOrdenCompraDetalle:=Dr("CveOrdenCompraDetalle").ToString.ToEntero) Then
+ 'si no es por serie lote
+ ImporteConcepto = If(DdlMoneda.SelectedValue.ToEntero = 1, PUInv, PUInv * TipoCambioGuardar)
+ ImporteConcepto = If(UsuarioActual.Empresa.UsaAC, ImporteConcepto * IVA, ImporteConcepto)
+ If Dr("CveAlmacen").ToString.ToEntero = tCveAlmacen Then
+ If Not ObjInventario.AddMovimientoDetalle(CveMovimientoInventario, CantidadInv, CveUnidad, Dr("CvePS").ToString.ToEntero, ImporteConcepto, -1, PUTC:=If(DdlMoneda.SelectedValue.ToEntero = 1, -1, Dr("PU").ToString.ToDouble), CostoIndirecto:=CostoIndirecto, CveCompraDetalle:=Dr("CveCompraDetalle").ToString.ToEntero, CveOrdenCompraDetalle:=Dr("CveOrdenCompraDetalle").ToString.ToEntero) Then
ErrorMovInv = True
Exit For
End If
-
- Next
- End If
- Else
-
- 'UNIDAD BASE - EQUIVALENCIAS - INVENTARIO
- If UsuarioActual.CveEmpresa = 1 Then
- DtEquivalencias = New DataTable
- DtEquivalencias = GlobalDTProductosServiciosEquivalencias(CveProducto, -1)
- Dim CveUnidadBase As Integer = DtEquivalencias.FiltroPrimeroValor("CveUM", "UnidadBase = 'True'").ToEntero
- Dim drUMBase As DataRow = DtEquivalencias.FiltroPrimero("UnidadBase = 'True'")
-
- 'SI LA UNIDAD ACTUAL NO ES LA BASE SACA PROPORCION (EQUIVALENTE)
- If CveUnidadBase <> CveUnidad Then
- ' LO QUE PUSE LO QUE VALE UNIDAD BASE LO QUE VALE UNIDAD SELECCIONADA
- CantidadInv = Dr("Cantidad").ToString.ToDouble * drUMBase("Cantidad").ToString.ToDouble / DtEquivalencias.FiltraParametros(String.Format("CveUM = {0}", CveUnidad)).Rows(0)("Cantidad").ToString.ToDouble
- PUInv = PUInv * Dr("Cantidad").ToString.ToDouble / CantidadInv
- CostoIndirecto = CostoIndirecto * Dr("Cantidad").ToString.ToDouble / CantidadInv
- CveUnidad = CveUnidadBase
End If
+
End If
- 'si no es por serie lote
- ImporteConcepto = If(DdlMoneda.SelectedValue.ToEntero = 1, PUInv, PUInv * TipoCambioGuardar)
- ImporteConcepto = If(UsuarioActual.Empresa.UsaAC, ImporteConcepto * IVA, ImporteConcepto)
- If Dr("CveAlmacen").ToString.ToEntero = tCveAlmacen Then
- If Not ObjInventario.AddMovimientoDetalle(CveMovimientoInventario, CantidadInv, CveUnidad, Dr("CvePS").ToString.ToEntero, ImporteConcepto, -1, PUTC:=If(DdlMoneda.SelectedValue.ToEntero = 1, -1, Dr("PU").ToString.ToDouble), CostoIndirecto:=CostoIndirecto, CveCompraDetalle:=Dr("CveCompraDetalle").ToString.ToEntero, CveOrdenCompraDetalle:=Dr("CveOrdenCompraDetalle").ToString.ToEntero) Then
- ErrorMovInv = True
- Exit For
- End If
- End If
- End If
+ i = i + 1
+ Next
+ End If
+ Next
+
+ End If
- i = i + 1
- Next
- End If
- Next
+
+ If AplicarCostoIndirecto(ObjInventario, ObjCompras) Then
+ ErrorMovInv = True
+ End If
+
+ 'Else
+ ' Alert("El tipo de cambio no esta actualizado. Por favor comuniquese con un asistente SIG.", TipoMensaje.MsgError)
+ ' ErrorMovInv = True
+ 'End If
End If
+ '*************************************************** P R I M E R A P A R T E C O M P R A S **************************************************************************************************************************************************************************************************************************************************************************************************
+ 'P R E P O L I Z A S
+ Dim CveConceptoAfectacion As Integer = 5 'Proveedores
+ Dim CveConceptoAfectacionContado As Integer = 17 'Pago Proveedores
+ Dim CveConceptoCompra As Integer = 6 'Compra
+ Dim CveConceptoIVA As Integer = 14 'IVA Trasladado
+ Dim CveConceptoRetIVA As Integer = 15 'Ret IVA
+ Dim CveConceptoRetISR As Integer = 16 'Ret ISR
+ Dim CveConceptoDescuento As Integer = 24 'DSC
+ Dim CveConceptoRetIEPS As Integer = 25 'IEPS
+ Dim CveConceptoRetOtrosImpuestos As Integer = 27 'Otros Impuestos
+ Dim CveCreditoDetalle As Integer = -1
- If AplicarCostoIndirecto(ObjInventario, ObjCompras) Then
- ErrorMovInv = True
- End If
+ 'Afectable con el tabpanel Contable
+ Dim CveProveedorLocal As Integer
+ Dim CveProveedorConcepto As Integer
+ Dim CveAcreedor As Integer
+ Dim CveColectiva As Integer = -1
- 'Else
- ' Alert("El tipo de cambio no esta actualizado. Por favor comuniquese con un asistente SIG.", TipoMensaje.MsgError)
- ' ErrorMovInv = True
- 'End If
+ Dim TipoCreditoInteres As Boolean = False
+ Dim ImporteIECredito As Decimal = 0
+ Dim SeContabiliza As Boolean = If(UsuarioActual.CveEmpresa.Contiene(119) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ant"), False, True)
- End If
+ If RBLPago.SelectedValue = "1" Or RBLPago.SelectedValue = "3" Then
+ 'Credito Proveedor
+ CveProveedorLocal = CveProveedor
+ CveProveedorConcepto = CveProveedor
+ CveAcreedor = -1
- '*************************************************** P R I M E R A P A R T E C O M P R A S **************************************************************************************************************************************************************************************************************************************************************************************************
- 'P R E P O L I Z A S
+ Else
+ 'cuando es contado
- Dim CveConceptoAfectacion As Integer = 5 'Proveedores
- Dim CveConceptoAfectacionContado As Integer = 17 'Pago Proveedores
- Dim CveConceptoCompra As Integer = 6 'Compra
- Dim CveConceptoIVA As Integer = 14 'IVA Trasladado
- Dim CveConceptoRetIVA As Integer = 15 'Ret IVA
- Dim CveConceptoRetISR As Integer = 16 'Ret ISR
- Dim CveConceptoDescuento As Integer = 24 'DSC
- Dim CveConceptoRetIEPS As Integer = 25 'IEPS
- Dim CveConceptoRetOtrosImpuestos As Integer = 27 'Otros Impuestos
- Dim CveCreditoDetalle As Integer = -1
-
- 'Afectable con el tabpanel Contable
- Dim CveProveedorLocal As Integer
- Dim CveProveedorConcepto As Integer
- Dim CveAcreedor As Integer
- Dim CveColectiva As Integer = -1
-
- Dim TipoCreditoInteres As Boolean = False
- Dim ImporteIECredito As Decimal = 0
- Dim SeContabiliza As Boolean = If(UsuarioActual.CveEmpresa.Contiene(119) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ant"), False, True)
-
- If RBLPago.SelectedValue = "1" Or RBLPago.SelectedValue = "3" Then
- 'Credito Proveedor
- CveProveedorLocal = CveProveedor
- CveProveedorConcepto = CveProveedor
- CveAcreedor = -1
-
- Else
- 'cuando es contado
-
- Select Case RBLContado.SelectedValue
- Case "1", "6" 'Proveedores
- CveProveedorLocal = CveProveedor
- CveProveedorConcepto = CveProveedor
- CveAcreedor = -1
- Case "2" ' F y E
- CveProveedorLocal = CveProveedor
- CveProveedorConcepto = CveProveedor
- CveAcreedor = -1
- CveIE = DDlCheques.SelectedValue.ToEntero
- Case "3" ' Doctos
-
- CveProveedorConcepto = CveProveedor
-
- If DdlTipoCredito.SelectedValue.ToEntero = 2 Then
+ Select Case RBLContado.SelectedValue
+ Case "1", "6" 'Proveedores
CveProveedorLocal = CveProveedor
CveProveedorConcepto = CveProveedor
CveAcreedor = -1
+ Case "2" ' F y E
+ CveProveedorLocal = CveProveedor
+ CveProveedorConcepto = CveProveedor
+ CveAcreedor = -1
+ CveIE = DDlCheques.SelectedValue.ToEntero
+ Case "3" ' Doctos
+
+ CveProveedorConcepto = CveProveedor
+
+ If DdlTipoCredito.SelectedValue.ToEntero = 2 Then
+ CveProveedorLocal = CveProveedor
+ CveProveedorConcepto = CveProveedor
+ CveAcreedor = -1
+ CveColectiva = -1
+ ' CveConceptoAfectacionContado = 55
+ CveConceptoAfectacion = 59
+ CveCreditoDetalle = DdlCreditoDetalle.SelectedValue.ToEntero
+ ObjIE.UpdateCreditosDetalle(3, CveCreditoDetalle)
+ End If
+ Case "4" ' Deudores
+ CveProveedorLocal = CveProveedor
+ CveProveedorConcepto = DdlDeudor.SelectedValue.ToEntero
+ For Each row As GridViewRow In GvDeudores.Rows
+ If row.FCCheckBox("Chk").Checked Then
+ CveIE = row.DataKey("CveIE").ToString.ToEntero
+ Exit For
+ End If
+ Next
+ CveAcreedor = -1
CveColectiva = -1
' CveConceptoAfectacionContado = 55
- CveConceptoAfectacion = 59
- CveCreditoDetalle = DdlCreditoDetalle.SelectedValue.ToEntero
- ObjIE.UpdateCreditosDetalle(3, CveCreditoDetalle)
- End If
- Case "4" ' Deudores
- CveProveedorLocal = CveProveedor
- CveProveedorConcepto = DdlDeudor.SelectedValue.ToEntero
- For Each row As GridViewRow In GvDeudores.Rows
- If row.FCCheckBox("Chk").Checked Then
- CveIE = row.DataKey("CveIE").ToString.ToEntero
- Exit For
+ CveConceptoAfectacion = 37
+ Case "5" ' Acreedores
+ CveProveedorLocal = CveProveedor
+ CveProveedorConcepto = DdlAcreedor.SelectedValue.ToEntero
+ CveAcreedor = -1
+ CveColectiva = -1
+ CveConceptoAfectacion = 41
+
+ If EmpresaPrueba Then
+ CveIE = If(DdlAcreedorDetalle.SelectedValue.ToEntero = -2, -1, DdlAcreedorDetalle.SelectedValue.ToEntero)
End If
- Next
- CveAcreedor = -1
- CveColectiva = -1
- ' CveConceptoAfectacionContado = 55
- CveConceptoAfectacion = 37
- Case "5" ' Acreedores
- CveProveedorLocal = CveProveedor
- CveProveedorConcepto = DdlAcreedor.SelectedValue.ToEntero
- CveAcreedor = -1
- CveColectiva = -1
- CveConceptoAfectacion = 41
-
- If EmpresaPrueba Then
- CveIE = If(DdlAcreedorDetalle.SelectedValue.ToEntero = -2, -1, DdlAcreedorDetalle.SelectedValue.ToEntero)
- End If
- End Select
- End If
-
- If RBLPago.SelectedValue.ToEntero = 4 Then
- Dim TmpTotal As Decimal = TxtTotal.Text.ToDecimal
- Dim TmpTotalCreditos As Decimal = 0
-
- For Each GvRow As GridViewRow In GvCreditos.Rows
- TmpTotalCreditos = TmpTotalCreditos + GvRow.FCTextBox("TxtCapital").Text.ToDecimal
- TmpTotalCreditos = TmpTotalCreditos + GvRow.FCTextBox("TxtInteres").Text.ToDecimal
- TmpTotalCreditos = TmpTotalCreditos + GvRow.FCTextBox("TxtAmbos").Text.ToDecimal
- Next
-
- If TmpTotalCreditos > TmpTotal Then
- ErrorCredito = True
+ End Select
End If
- For Each GvRow As GridViewRow In GvCreditos.Rows
+ If RBLPago.SelectedValue.ToEntero = 4 Then
+ Dim TmpTotal As Decimal = TxtTotal.Text.ToDecimal
+ Dim TmpTotalCreditos As Decimal = 0
- Dim Capital As Decimal = GvRow.FCTextBox("TxtCapital").Text.Replace(",", "").ToDecimal
- Dim Interes As Decimal = GvRow.FCTextBox("TxtInteres").Text.Replace(",", "").ToDecimal
- Dim Ambos As Decimal = GvRow.FCTextBox("TxtAmbos").Text.Replace(",", "").ToDecimal
+ For Each GvRow As GridViewRow In GvCreditos.Rows
+ TmpTotalCreditos = TmpTotalCreditos + GvRow.FCTextBox("TxtCapital").Text.ToDecimal
+ TmpTotalCreditos = TmpTotalCreditos + GvRow.FCTextBox("TxtInteres").Text.ToDecimal
+ TmpTotalCreditos = TmpTotalCreditos + GvRow.FCTextBox("TxtAmbos").Text.ToDecimal
+ Next
- Dim CveCreditoDetalleTemp As Integer = GvRow.DataKey("CveCreditoDetalle").ToEntero
- Dim CveCreditoTemp As Integer = GvRow.DataKey("CveCredito").ToEntero
- Dim EstusTemp = GvRow.DataKey("Estatus").ToEntero
- ' Dim ImporteOpcionCompra As Decimal = GvRow.DataKey("ImporteOpcionCompra").ToDecimal
- Dim Marcador As Decimal = GvRow.DataKey("Marcador").ToEntero
- Dim CreditoEstatus As Integer = -1
+ If TmpTotalCreditos > TmpTotal Then
+ ErrorCredito = True
+ End If
- If Capital > 0 Or Interes > 0 Or Ambos > 0 Then
+ For Each GvRow As GridViewRow In GvCreditos.Rows
- If ObjIE.GetCreditosDetalle(CveCreditoTemp, -1) Then
+ Dim Capital As Decimal = GvRow.FCTextBox("TxtCapital").Text.Replace(",", "").ToDecimal
+ Dim Interes As Decimal = GvRow.FCTextBox("TxtInteres").Text.Replace(",", "").ToDecimal
+ Dim Ambos As Decimal = GvRow.FCTextBox("TxtAmbos").Text.Replace(",", "").ToDecimal
- Dim CveCompraCapital As Integer = -1
- Dim CveCompraInteres As Integer = -1
+ Dim CveCreditoDetalleTemp As Integer = GvRow.DataKey("CveCreditoDetalle").ToEntero
+ Dim CveCreditoTemp As Integer = GvRow.DataKey("CveCredito").ToEntero
+ Dim EstusTemp = GvRow.DataKey("Estatus").ToEntero
+ ' Dim ImporteOpcionCompra As Decimal = GvRow.DataKey("ImporteOpcionCompra").ToDecimal
+ Dim Marcador As Decimal = GvRow.DataKey("Marcador").ToEntero
+ Dim CreditoEstatus As Integer = -1
- 'Dim ImporteCapital As Decimal = 0
- ' Dim ImporteCapitalIVA As Decimal = 0
+ If Capital > 0 Or Interes > 0 Or Ambos > 0 Then
- 'Dim ImporteInteres As Decimal = 0
- ' Dim ImporteInteresIVA As Decimal = 0
+ If ObjIE.GetCreditosDetalle(CveCreditoTemp, -1) Then
- ' Dim ImporteIEMensualidad As Decimal = ObjIE.DtResultados.FiltroPrimeroValor("ImporteIE", $"CveCreditoDetalle = {CveCreditoDetalleTemp}").ToDecimal
- CreditoEstatus = ObjIE.DtResultados.FiltroPrimeroValor("Estatus", $"CveCreditoDetalle = {CveCreditoDetalleTemp}").ToEntero
+ Dim CveCompraCapital As Integer = -1
+ Dim CveCompraInteres As Integer = -1
- CveCompraCapital = ObjIE.DtResultados.FiltroPrimeroValor("CveCompra", $"CveCreditoDetalle = {CveCreditoDetalleTemp}").ToEntero
- CveCompraInteres = ObjIE.DtResultados.FiltroPrimeroValor("CveCompraInteres", $"CveCreditoDetalle = {CveCreditoDetalleTemp}").ToEntero
+ 'Dim ImporteCapital As Decimal = 0
+ ' Dim ImporteCapitalIVA As Decimal = 0
- CveCompraCapital = If(CveCompraCapital < 1, -1, CveCompraCapital)
- CveCompraInteres = If(CveCompraInteres < 1, -1, CveCompraInteres)
+ 'Dim ImporteInteres As Decimal = 0
+ ' Dim ImporteInteresIVA As Decimal = 0
- TipoCreditoInteres = Boolean.Parse(ObjIE.DtResultados.FiltroPrimeroValor("TipoInteres", $"CveCreditoDetalle = {CveCreditoDetalleTemp}"))
- ImporteIECredito = ObjIE.DtResultados.FiltroPrimeroValor("ImportePago", $"CveCreditoDetalle = {CveCreditoDetalleTemp}").ToDecimal
+ ' Dim ImporteIEMensualidad As Decimal = ObjIE.DtResultados.FiltroPrimeroValor("ImporteIE", $"CveCreditoDetalle = {CveCreditoDetalleTemp}").ToDecimal
+ CreditoEstatus = ObjIE.DtResultados.FiltroPrimeroValor("Estatus", $"CveCreditoDetalle = {CveCreditoDetalleTemp}").ToEntero
- If Ambos > 0 Then
- CveCompraCapital = CveCompra
- CveCompraInteres = CveCompra
+ CveCompraCapital = ObjIE.DtResultados.FiltroPrimeroValor("CveCompra", $"CveCreditoDetalle = {CveCreditoDetalleTemp}").ToEntero
+ CveCompraInteres = ObjIE.DtResultados.FiltroPrimeroValor("CveCompraInteres", $"CveCreditoDetalle = {CveCreditoDetalleTemp}").ToEntero
- Capital = Ambos
- Interes = Ambos
+ CveCompraCapital = If(CveCompraCapital < 1, -1, CveCompraCapital)
+ CveCompraInteres = If(CveCompraInteres < 1, -1, CveCompraInteres)
- End If
+ TipoCreditoInteres = Boolean.Parse(ObjIE.DtResultados.FiltroPrimeroValor("TipoInteres", $"CveCreditoDetalle = {CveCreditoDetalleTemp}"))
+ ImporteIECredito = ObjIE.DtResultados.FiltroPrimeroValor("ImportePago", $"CveCreditoDetalle = {CveCreditoDetalleTemp}").ToDecimal
- If Capital > 0 Then
- CveCompraCapital = CveCompra
- End If
- If Interes > 0 Then
- CveCompraInteres = CveCompra
- End If
+ If Ambos > 0 Then
+ CveCompraCapital = CveCompra
+ CveCompraInteres = CveCompra
+ Capital = Ambos
+ Interes = Ambos
-
- If (CveCompraCapital > 0 And CveCompraInteres > 0) And EstusTemp = 2 Then
- If EstusTemp = 2 Then
- EstusTemp = 3
- ElseIf EstusTemp = 1 Or EstusTemp = 4 Then
- EstusTemp = 4
End If
- ElseIf CveCompraCapital > 0 Or CveCompraInteres > 0 Then
- If EstusTemp = 2 Then
- EstusTemp = 2
- ElseIf EstusTemp = 1 Or EstusTemp = 4 Then
- EstusTemp = 4
- End If
- End If
- If Not ObjIE.UpdateCreditosDetalle(CveCreditoDetalleTemp, "01/01/2000".ToDate, -1, -1, -1, -1, -1, -1, EstusTemp, CveCompra:=CveCompraCapital, CveCompraInteres:=CveCompraInteres, importeCapital:=Capital,
- ImporteInteres:=Interes) Then
+ If Capital > 0 Then
+ CveCompraCapital = CveCompra
+ End If
+ If Interes > 0 Then
+ CveCompraInteres = CveCompra
+ End If
+
+
+
+ If (CveCompraCapital > 0 And CveCompraInteres > 0) And EstusTemp = 2 Then
+ If EstusTemp = 2 Then
+ EstusTemp = 3
+ ElseIf EstusTemp = 1 Or EstusTemp = 4 Then
+ EstusTemp = 4
+ End If
+ ElseIf CveCompraCapital > 0 Or CveCompraInteres > 0 Then
+ If EstusTemp = 2 Then
+ EstusTemp = 2
+ ElseIf EstusTemp = 1 Or EstusTemp = 4 Then
+ EstusTemp = 4
+ End If
+ End If
+
+ If Not ObjIE.UpdateCreditosDetalle(CveCreditoDetalleTemp, "01/01/2000".ToDate, -1, -1, -1, -1, -1, -1, EstusTemp, CveCompra:=CveCompraCapital, CveCompraInteres:=CveCompraInteres, importeCapital:=Capital,
+ ImporteInteres:=Interes) Then
+ ErrorCredito = True
+ End If
+ 'ObjIE.UpdateCreditosDetalle(CveCreditoDetalle, "01/01/2000".ToDate, -1, -1, -1, -1, -1, -1, Estatus)
+
+
+
+ Else
ErrorCredito = True
End If
- 'ObjIE.UpdateCreditosDetalle(CveCreditoDetalle, "01/01/2000".ToDate, -1, -1, -1, -1, -1, -1, Estatus)
-
-
-
- Else
- ErrorCredito = True
End If
- End If
- Next
- End If
-
- Dim TipoMovimientoCompra As Boolean = False
- Dim TipoMovimientoImpuestos As Boolean = True
- If DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") Then
- CveConceptoAfectacion = 18 'Devolución del Proveedor (NC)
- TipoMovimientoCompra = Not TipoMovimientoCompra
- TipoMovimientoImpuestos = Not TipoMovimientoImpuestos
- End If
-
- If EmpresaPrueba Then 'Empresa Prueba
-
- Dim PorcentajePagos As Decimal = 0
- Dim sumaPagos As Decimal = 0
- Dim tipoCambioActual As Decimal
- Dim tipoCambioPago As Decimal
- Dim alertaContabilizacion As String = "Se enviaron correctamente las siguientes pólizas:
"
- Dim idCuentaContabilizacion As Long = 1
- Dim CveCuentaContabilizacion As Long = 1
- Dim FechaMovimiento As Date = TxtFecha.Text.ToDate
- Dim DT As DataTable = Nothing
- Dim CuentasContablesInvalidas As New StringBuilder
- Dim CuentasContablesInvalidasSIG As New StringBuilder
- Dim ConceptoPersonal As String = ""
- Dim IdCtaIVAXAcreditar As Integer = 0
- Dim IdCtaIVAAcreditable As Integer = 0
- Dim GuardoConcepto18 As Boolean = False
-
- If GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeIVA).Rows.Count > 0 Then
- IdCtaIVAXAcreditar = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeIVA).Rows(0)("IdCtaIVAXAcreditar").ToString.ToEntero
- IdCtaIVAAcreditable = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeIVA).Rows(0)("IdCtaIVAAcreditable").ToString.ToEntero
+ Next
End If
- Dim AutoConta As Boolean = UsuarioActual.Empresa.Funcionalidad(200) = "1"
-
- If UsuarioActual.CveEmpresa = 119 AndAlso (DdlPersonalReembolso.SelectedValue.ToEntero > 0 Or DdlCuentaCajaChicaReembolso.SelectedValue.ToEntero > 0) Then
- AutoConta = False
- End If
-
- If (AutoConta Or UsuarioActual.Empresa.UsaAC) And ObjContaAC Is Nothing Then
- ObjContaAC = New ClsContPAQi(UsuarioActual.Empresa)
- ObjContaAC.IniciaTransacSQL()
- End If
-
- '********************** Variables '**********************
-
- '****** Pagos
-
- 'Bancos (30)
- Dim importeBanco As Decimal = 0
- If CveIE > 0 AndAlso RBLPago.SelectedValue.ToEntero = 2 AndAlso RBLContado.SelectedValue = "1" AndAlso (Not DivTarjeta.Visible Or DdlTarjeta.SelectedValue.ToEntero = -1) Then
- importeBanco = TxtDocumentoImporte.Text.ToDecimal
- sumaPagos += importeBanco
- End If
-
- 'Caja Chica (30)
- Dim importeCajaChica As Decimal = 0
- If CveIE > 0 AndAlso RBLPago.SelectedValue.ToEntero = 2 AndAlso RBLContado.SelectedValue = "6" Then
- importeCajaChica = TxtDocumentoImporteCaja.Text.ToDecimal
- sumaPagos += importeCajaChica
- End If
-
- 'Funcionarios y Empleados (29)
- Dim importeFE As Decimal = 0
- If CveIE > 0 AndAlso RBLPago.SelectedValue.ToEntero = 2 AndAlso RBLContado.SelectedValue = "2" Then
- ViewState("CvePersonal") = DdlFuncionarioEmpleado.SelectedValue.ToEntero
- ConceptoPersonal = DdlFuncionarioEmpleado.SelectedItem.ToString
- importeFE = TxtDocumentoImporteFE.Text.ToDecimal
- sumaPagos += importeFE
- End If
-
- 'Deudores (37)
- Dim importeDD As Decimal = 0
- If CveIE > 0 AndAlso RBLPago.SelectedValue.ToEntero = 2 AndAlso RBLContado.SelectedValue = "4" Then
- ConceptoPersonal = DdlDeudor.SelectedItem.ToString
- importeDD = TxtContadoDeudor.Text.ToDecimal
- sumaPagos += importeDD
- End If
-
- 'Acreedores (41) SinTarjeta
- Dim importeAcreedores As Decimal = 0
- If (CveIE > 0 Or DdlAcreedorDetalle.SelectedValue.ToEntero = -2) AndAlso RBLPago.SelectedValue.ToEntero = 2 AndAlso RBLContado.SelectedValue = "5" Then
- ConceptoPersonal = DdlAcreedor.SelectedItem.ToString
- importeAcreedores = TxtContadoAcreedor.Text.ToDecimal
- sumaPagos += importeAcreedores
- End If
-
- 'Acreedores (42) ConTarjeta
- Dim importeAcreedoresTarjeta As Decimal = 0
- If CveIE > 0 AndAlso RBLPago.SelectedValue.ToEntero = 2 AndAlso RBLContado.SelectedValue = "1" AndAlso DivTarjeta.Visible AndAlso DdlTarjeta.SelectedValue.ToEntero > 0 Then
- ConceptoPersonal = DdlTarjeta.SelectedItem.ToString
- importeAcreedoresTarjeta = TxtDocumentoImporte.Text.ToDecimal
- sumaPagos += importeAcreedoresTarjeta
- End If
-
- 'Creditos/Documentos (59)
- Dim importeCreditos As Decimal = 0
- Dim CveIECreditos = -1
- If RBLPago.SelectedValue.ToEntero = 2 AndAlso RBLContado.SelectedValue = "3" AndAlso DdlTipoCredito.SelectedValue.ToEntero = 2 Then
- If ObjIE.GetCreditosDetalle(DdlCredito.SelectedValue.ToEntero, -1) Then
- CveIECreditos = ObjIE.DtResultados.FiltroPrimero($"CveCreditoDetalle = {DdlCreditoDetalle.SelectedValue.ToEntero}")("CveIE").ToString.ToEntero
- End If
- ConceptoPersonal = DdlCredito.SelectedItem.ToString
- importeCreditos = TxtTotal.Text.ToDecimal
- sumaPagos += importeCreditos
- End If
-
- PorcentajePagos = If(TxtTotal.Text.ToDecimal > 0, sumaPagos / TxtTotal.Text.ToDecimal, 0)
-
- '****** Acreditables
-
- 'IVA Acreditable (19)
- Dim importeIVAAcreditable As Decimal = 0
- importeIVAAcreditable = TxtIVA.Text.ToDecimal * PorcentajePagos
-
- 'IEPS Acreditable (26)
- Dim ImporteIEPSAcreditable As Decimal = 0
- ImporteIEPSAcreditable = TxtIEPS.Text.ToDecimal * PorcentajePagos
-
- 'RetIVA Acrediable (22)
- Dim importeRetIVAAcreditable As Decimal = 0
- importeRetIVAAcreditable = TxtRetIVA.Text.ToDecimal * PorcentajePagos
-
- 'RetISR Acreditable (23)
- Dim importeRetISRAcreditable As Decimal = 0
- importeRetISRAcreditable = TxtRetISR.Text.ToDecimal * PorcentajePagos
-
-
-
- '****** X Acreditar
- 'IVA X Acreditar (14)
- Dim importeIVAxAcreditar As Decimal = 0
- importeIVAxAcreditar = TxtIVA.Text.ToDecimal
-
- 'IEPS X Acreditar (25)
- Dim ImporteIEPSxAcreditar As Decimal = 0
- ImporteIEPSxAcreditar = TxtIEPS.Text.ToDecimal
-
- 'Otros Impuestos (224)
- Dim OtrosImpuestos As Decimal = 0
- OtrosImpuestos = TxtOtrosImpuestos.Text.ToDecimal
-
- 'RetIVA X Acreditar (15)
- Dim importeRetIVAxAcreditar As Decimal = 0
- importeRetIVAxAcreditar = TxtRetIVA.Text.ToDecimal
-
- 'RetISR X Acreditar (16)
- Dim importeRetISRxAcreditar As Decimal = 0
- importeRetISRxAcreditar = TxtRetISR.Text.ToDecimal
-
-
-
- '****** Movimientos Independientes
-
- 'Pago Proveedores (17)
- Dim importePagoProv As Decimal = 0
- importePagoProv = sumaPagos
-
- 'If CveIE > 0 AndAlso ((RBLContado.SelectedValue = "2" AndAlso DdlFuncionarioEmpleado.SelectedValue.ToEntero > 0) Or (RBLContado.SelectedValue = "4" AndAlso DdlDeudor.SelectedValue.ToEntero > 0)) Then
- ' importePagoProv = TxtDocumentoImporteFE.Text.ToDecimal
- 'End If
-
- 'Compra (6)
- 'Ya que es un foreach todo su proceso esta en el Case 6
-
- 'Proveedores (5)
- Dim importeProv As Decimal = 0
- importeProv = TxtTotal.Text.ToDecimal
-
- 'Nota de Credito (18)
- Dim importeNC As Decimal = 0
+ Dim TipoMovimientoCompra As Boolean = False
+ Dim TipoMovimientoImpuestos As Boolean = True
If DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") Then
- importeNC = TxtTotal.Text.ToDecimal
+ CveConceptoAfectacion = 18 'Devolución del Proveedor (NC)
+ TipoMovimientoCompra = Not TipoMovimientoCompra
+ TipoMovimientoImpuestos = Not TipoMovimientoImpuestos
End If
- '**************************************************************************************************************************
+ If EmpresaPrueba Then 'Empresa Prueba
- If DdlMoneda.SelectedValue.ToString.ToEntero = 2 Then
- tipoCambioActual = GlobalTipoCambio(FechaMovimiento).ToString.ToDecimal
- tipoCambioActual = If(DivTC.Visible, TipoCambio.ToDecimal, tipoCambioActual)
- tipoCambioPago = GlobalTipoCambio(TxtFechaPago.Text.ToDate).ToString.ToDecimal
- Else
- tipoCambioActual = 1
- tipoCambioPago = 1
- End If
+ Dim PorcentajePagos As Decimal = 0
+ Dim sumaPagos As Decimal = 0
+ Dim tipoCambioActual As Decimal
+ Dim tipoCambioPago As Decimal
+ Dim alertaContabilizacion As String = "Se enviaron correctamente las siguientes pólizas:
"
+ Dim idCuentaContabilizacion As Long = 1
+ Dim CveCuentaContabilizacion As Long = 1
+ Dim FechaMovimiento As Date = TxtFecha.Text.ToDate
+ Dim DT As DataTable = Nothing
+ Dim CuentasContablesInvalidas As New StringBuilder
+ Dim CuentasContablesInvalidasSIG As New StringBuilder
+ Dim ConceptoPersonal As String = ""
+ Dim IdCtaIVAXAcreditar As Integer = 0
+ Dim IdCtaIVAAcreditable As Integer = 0
+ Dim GuardoConcepto18 As Boolean = False
- 'CASO ESPECIAL CREDITOS
- If CveIECreditos > 0 Then
- CveIE = CveIECreditos
- 'Dim CveIEProvisional = CveIE
- End If
+ If GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeIVA).Rows.Count > 0 Then
+ IdCtaIVAXAcreditar = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeIVA).Rows(0)("IdCtaIVAXAcreditar").ToString.ToEntero
+ IdCtaIVAAcreditable = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeIVA).Rows(0)("IdCtaIVAAcreditable").ToString.ToEntero
+ End If
- If ObjConta.GetPlantillaConceptos(UsuarioActual.CveEmpresa, CvePlantillaPrePoliza) Then
+ '********************** Variables '**********************
- Dim DTPlatilla As New DataTable
- DTPlatilla = ObjConta.DtResultados
+ '****** Pagos
- For Each Row As DataRow In DTPlatilla.Rows
+ 'Bancos (30)
+ Dim importeBanco As Decimal = 0
+ If CveIE > 0 AndAlso RBLPago.SelectedValue.ToEntero = 2 AndAlso RBLContado.SelectedValue = "1" AndAlso (Not DivTarjeta.Visible Or DdlTarjeta.SelectedValue.ToEntero = -1) Then
+ importeBanco = TxtDocumentoImporte.Text.ToDecimal
+ sumaPagos += importeBanco
+ End If
- Dim ConceptoContable = Row("CveConcepto").ToString.ToEntero
- Dim TipoMovimiento As Boolean = If(Row("TipoMovto").ToString = "True", True, False)
- Dim importeMovimiento As Decimal = 0
- Dim IdCtaContable As Integer = 0
- Dim CveCuenta As Integer = 0
- Dim Concepto As String = ObjConta.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, ConceptoContable, NombreProveedor, $"{TxtSerie.Text}-{TxtFolio.Text}", If(TxtDocumentoFolio.Visible, TxtDocumentoFolio.Text, If(TxtDocumentoFolioCaja.Visible, TxtDocumentoFolioCaja.Text, ConceptoPersonal)))
- Dim importeMN As Decimal = 0
- Dim Multiplicador As Integer = If(Row("Multiplicador").ToString.ToEntero = 1, 1, -1)
- Dim Referencia As String = $"{TxtSerie.Text}-{TxtFolio.Text}" ' concatenation interpolation
- Dim PorcentajeImpuesto As Decimal = 0
+ 'Caja Chica (30)
+ Dim importeCajaChica As Decimal = 0
+ If CveIE > 0 AndAlso RBLPago.SelectedValue.ToEntero = 2 AndAlso RBLContado.SelectedValue = "6" Then
+ importeCajaChica = TxtDocumentoImporteCaja.Text.ToDecimal
+ sumaPagos += importeCajaChica
+ End If
+
+ 'Funcionarios y Empleados (29)
+ Dim importeFE As Decimal = 0
+ If CveIE > 0 AndAlso RBLPago.SelectedValue.ToEntero = 2 AndAlso RBLContado.SelectedValue = "2" Then
+ ViewState("CvePersonal") = DdlFuncionarioEmpleado.SelectedValue.ToEntero
+ ConceptoPersonal = DdlFuncionarioEmpleado.SelectedItem.ToString
+ importeFE = TxtDocumentoImporteFE.Text.ToDecimal
+ sumaPagos += importeFE
+ End If
+
+ 'Deudores (37)
+ Dim importeDD As Decimal = 0
+ If CveIE > 0 AndAlso RBLPago.SelectedValue.ToEntero = 2 AndAlso RBLContado.SelectedValue = "4" Then
+ ConceptoPersonal = DdlDeudor.SelectedItem.ToString
+ importeDD = TxtContadoDeudor.Text.ToDecimal
+ sumaPagos += importeDD
+ End If
+
+ 'Acreedores (41) SinTarjeta
+ Dim importeAcreedores As Decimal = 0
+ If (CveIE > 0 Or DdlAcreedorDetalle.SelectedValue.ToEntero = -2) AndAlso RBLPago.SelectedValue.ToEntero = 2 AndAlso RBLContado.SelectedValue = "5" Then
+ ConceptoPersonal = DdlAcreedor.SelectedItem.ToString
+ importeAcreedores = TxtContadoAcreedor.Text.ToDecimal
+ sumaPagos += importeAcreedores
+ End If
+
+ 'Acreedores (42) ConTarjeta
+ Dim importeAcreedoresTarjeta As Decimal = 0
+ If CveIE > 0 AndAlso RBLPago.SelectedValue.ToEntero = 2 AndAlso RBLContado.SelectedValue = "1" AndAlso DivTarjeta.Visible AndAlso DdlTarjeta.SelectedValue.ToEntero > 0 Then
+ ConceptoPersonal = DdlTarjeta.SelectedItem.ToString
+ importeAcreedoresTarjeta = TxtDocumentoImporte.Text.ToDecimal
+ sumaPagos += importeAcreedoresTarjeta
+ End If
+
+ 'Creditos/Documentos (59)
+ Dim importeCreditos As Decimal = 0
+ Dim CveIECreditos = -1
+ If RBLPago.SelectedValue.ToEntero = 2 AndAlso RBLContado.SelectedValue = "3" AndAlso DdlTipoCredito.SelectedValue.ToEntero = 2 Then
+ If ObjIE.GetCreditosDetalle(DdlCredito.SelectedValue.ToEntero, -1) Then
+ CveIECreditos = ObjIE.DtResultados.FiltroPrimero($"CveCreditoDetalle = {DdlCreditoDetalle.SelectedValue.ToEntero}")("CveIE").ToString.ToEntero
+ End If
+ ConceptoPersonal = DdlCredito.SelectedItem.ToString
+ importeCreditos = TxtTotal.Text.ToDecimal
+ sumaPagos += importeCreditos
+ End If
+
+ PorcentajePagos = If(TxtTotal.Text.ToDecimal > 0, sumaPagos / TxtTotal.Text.ToDecimal, 0)
+
+ '****** Acreditables
+
+ 'IVA Acreditable (19)
+ Dim importeIVAAcreditable As Decimal = 0
+ importeIVAAcreditable = TxtIVA.Text.ToDecimal * PorcentajePagos
+
+ 'IEPS Acreditable (26)
+ Dim ImporteIEPSAcreditable As Decimal = 0
+ ImporteIEPSAcreditable = TxtIEPS.Text.ToDecimal * PorcentajePagos
+
+ 'RetIVA Acrediable (22)
+ Dim importeRetIVAAcreditable As Decimal = 0
+ importeRetIVAAcreditable = TxtRetIVA.Text.ToDecimal * PorcentajePagos
+
+ 'RetISR Acreditable (23)
+ Dim importeRetISRAcreditable As Decimal = 0
+ importeRetISRAcreditable = TxtRetISR.Text.ToDecimal * PorcentajePagos
- Select Case ConceptoContable
+
+ '****** X Acreditar
+ 'IVA X Acreditar (14)
+ Dim importeIVAxAcreditar As Decimal = 0
+ importeIVAxAcreditar = TxtIVA.Text.ToDecimal
+
+ 'IEPS X Acreditar (25)
+ Dim ImporteIEPSxAcreditar As Decimal = 0
+ ImporteIEPSxAcreditar = TxtIEPS.Text.ToDecimal
+
+ 'Otros Impuestos (224)
+ Dim OtrosImpuestos As Decimal = 0
+ OtrosImpuestos = TxtOtrosImpuestos.Text.ToDecimal
+
+ 'RetIVA X Acreditar (15)
+ Dim importeRetIVAxAcreditar As Decimal = 0
+ importeRetIVAxAcreditar = TxtRetIVA.Text.ToDecimal
+
+ 'RetISR X Acreditar (16)
+ Dim importeRetISRxAcreditar As Decimal = 0
+ importeRetISRxAcreditar = TxtRetISR.Text.ToDecimal
+
+
+
+ '****** Movimientos Independientes
+
+ 'Pago Proveedores (17)
+ Dim importePagoProv As Decimal = 0
+ importePagoProv = sumaPagos
+
+ 'If CveIE > 0 AndAlso ((RBLContado.SelectedValue = "2" AndAlso DdlFuncionarioEmpleado.SelectedValue.ToEntero > 0) Or (RBLContado.SelectedValue = "4" AndAlso DdlDeudor.SelectedValue.ToEntero > 0)) Then
+ ' importePagoProv = TxtDocumentoImporteFE.Text.ToDecimal
+ 'End If
+
+ 'Compra (6)
+ 'Ya que es un foreach todo su proceso esta en el Case 6
+
+ 'Proveedores (5)
+ Dim importeProv As Decimal = 0
+ importeProv = TxtTotal.Text.ToDecimal
+
+ 'Nota de Credito (18)
+ Dim importeNC As Decimal = 0
+ If DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") Then
+ importeNC = TxtTotal.Text.ToDecimal
+ End If
+
+ '**************************************************************************************************************************
+
+ If DdlMoneda.SelectedValue.ToString.ToEntero = 2 Then
+ tipoCambioActual = GlobalTipoCambio(FechaMovimiento).ToString.ToDecimal
+ tipoCambioActual = If(DivTC.Visible, TipoCambio.ToDecimal, tipoCambioActual)
+ tipoCambioPago = GlobalTipoCambio(TxtFechaPago.Text.ToDate).ToString.ToDecimal
+ Else
+ tipoCambioActual = 1
+ tipoCambioPago = 1
+ End If
+
+ 'CASO ESPECIAL CREDITOS
+ If CveIECreditos > 0 Then
+ CveIE = CveIECreditos
+ 'Dim CveIEProvisional = CveIE
+ End If
+
+
+
+ If ObjConta.GetPlantillaConceptos(UsuarioActual.CveEmpresa, CvePlantillaPrePoliza) Then
+
+ Dim DTPlatilla As New DataTable
+ DTPlatilla = ObjConta.DtResultados
+
+ For Each Row As DataRow In DTPlatilla.Rows
+
+ Dim ConceptoContable = Row("CveConcepto").ToString.ToEntero
+ Dim TipoMovimiento As Boolean = If(Row("TipoMovto").ToString = "True", True, False)
+ Dim importeMovimiento As Decimal = 0
+ Dim IdCtaContable As Integer = 0
+ Dim CveCuenta As Integer = 0
+ Dim Concepto As String = ObjConta.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, ConceptoContable, NombreProveedor, $"{TxtSerie.Text}-{TxtFolio.Text}", If(TxtDocumentoFolio.Visible, TxtDocumentoFolio.Text, If(TxtDocumentoFolioCaja.Visible, TxtDocumentoFolioCaja.Text, ConceptoPersonal)))
+ Dim importeMN As Decimal = 0
+ Dim Multiplicador As Integer = If(Row("Multiplicador").ToString.ToEntero = 1, 1, -1)
+ Dim Referencia As String = $"{TxtSerie.Text}-{TxtFolio.Text}" ' concatenation interpolation
+ Dim PorcentajeImpuesto As Decimal = 0
+
+
+ Select Case ConceptoContable
- Case 17 'Pago Proveedores
+ Case 17 'Pago Proveedores
- importeMovimiento = importePagoProv
- importeMN = importeMovimiento * tipoCambioActual * Multiplicador
- IdCtaContable = CtaProveedor
- CveCuenta = CveCuentaProveedor
-
-
- If RBLPago.SelectedValue.ToEntero = 4 And EstatusCredito.Contiene(2, 102) Then 'SI ES CRÉDITO Y ESTA PAGADO
-
- Dim IdSegmentoNegocio As Integer = -1
- For Each Row2 As DataRow In TmpDT.Rows
-
- importeMovimiento = TxtTotal.Text.ToDecimal 'TmpDT.SUM("Total", String.Format("ISNULL(TipoAF,0) <> 2 And ISNULL(CveAlmacen,0) = 0 And ISNULL(AplicaCostoIndirecto,0) <> 1 And CveClasificacion = {0} And CveSubProyecto = {1} And ISNULL(CveTipoGasto,0) = {2}", Row2("CveClasificacion").ToString.ToEntero, Row2("CveSubProyecto").ToString.ToEntero, Row2("CveTipoGasto").ToString.ToEntero)).ToString.ToDecimal
- importeMN = importeMovimiento * tipoCambioActual * Multiplicador
- 'CLASIFICACION
- If Row2("CveClasificacion").ToString.ToEntero > 0 Then
- If ObjConta.GetRetCuenta(6, Row2("CveClasificacion").ToString.ToEntero, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero) Then
- If ObjConta.DtResultados.Rows.Count > 0 AndAlso ObjConta.DtResultados.Rows(0)("IdCuentaGasto").ToString.ToEntero > 0 Then
- IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaGasto").ToString.ToEntero
- CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaGastoSIG").ToString.ToEntero
- Else
- IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaGasto", String.Format("CveClasificacion = {0}", Row2("CveClasificacion"))).ToString.ToEntero
- CveCuenta = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaGastoSIG", String.Format("CveClasificacion = {0}", Row2("CveClasificacion"))).ToString.ToEntero
- End If
- End If
- End If
-
-
-
-
- 'SEGMENTO DE NEGOCIO
-
- Dim drT As DataRow = GlobalDTSubProyectos(-1, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero).FiltroPrimero(String.Format("CveSubProyecto = {0} ", Row2("CveSubProyecto").ToString.ToEntero))
- If drT IsNot Nothing Then
- IdSegmentoNegocio = drT("IdSegNeg").ToString.ToEntero
- End If
-
- 'AGREGA MOVIMIENTO
- If importeMovimiento <> 0 Then
- 'Conta ContPAQ
- If IdCtaContable = 0 Then
- CuentasContablesInvalidas.Append(" " & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 6))("ConceptoContable").ToString)
- idCuentaContabilizacion = 0
- End If
- 'Conta SIG
- If CveCuenta = 0 Then
- CuentasContablesInvalidasSIG.Append(" " & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 6))("ConceptoContable").ToString)
- CveCuentaContabilizacion = 0
- End If
- End If
- Next
-
-
-
- Dim CveClasificacionDT As Integer = -1
- Dim CveSubProyectoDT As Integer = -1
- Dim CveTipoGastoDT As Integer = -1
-
- If TmpDT.Rows.Count > 0 Then
- CveClasificacionDT = TmpDT(0)("CveClasificacion").ToString.ToEntero
- CveSubProyectoDT = TmpDT(0)("CveSubProyecto").ToString.ToEntero
- CveTipoGastoDT = TmpDT(0)("CveTipoGasto").ToString.ToEntero
- End If
-
- Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}"
-
- Dim ImporteSubCre As Decimal = TxtSubTotal.Text.ToDecimal
- Dim ImporteSubCreMN As Decimal = TxtSubTotal.Text.ToDecimal * tipoCambioActual
-
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteSubCre, Referencia, 6, Concepto, FechaMovimiento, IdCtaContable, IdSegmentoNegocio, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, CveClasificacion:=CveClasificacionDT, CveSubProyecto:=CveSubProyectoDT, ImporteMX:=ImporteSubCreMN, ImporteME:=If(tipoCambioActual = 1, 0, ImporteSubCre), CveCuenta:=CveCuenta, CveTipoGasto:=CveTipoGastoDT, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then
- ErrorPrepoliza = True
- End If
-
-
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimiento, Referencia, 41, Concepto, FechaMovimiento, CtaProveedorAcreedores, IdSegmentoNegocio, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, CveClasificacion:=CveClasificacionDT, CveSubProyecto:=CveSubProyectoDT, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, CveTipoGasto:=CveTipoGastoDT, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then
- ErrorPrepoliza = True
- End If
-
- If TipoCreditoInteres Then
-
-
- Dim importeMovimientoIn As Decimal = ImporteIECredito - importeMovimiento
- Dim importeMNIn As Decimal = importeMovimientoIn * tipoCambioActual * Multiplicador
-
-
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimientoIn, Referencia, 41, Concepto, FechaMovimiento, CtaProveedorAcreedores, IdSegmentoNegocio, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, CveClasificacion:=CveClasificacionDT, CveSubProyecto:=CveSubProyectoDT, ImporteMX:=importeMNIn, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimientoIn), CveCuenta:=CveCuenta, CveTipoGasto:=CveTipoGastoDT, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then
- ErrorPrepoliza = True
- End If
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMovimientoIn, Referencia, 50, Concepto, FechaMovimiento, ViewState("IdCtaContDocsXPagar").ToString.ToEntero(), IdSegmentoNegocio, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, CveClasificacion:=CveClasificacionDT, CveSubProyecto:=CveSubProyectoDT, ImporteMX:=importeMNIn, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimientoIn), CveCuenta:=CveCuenta, CveTipoGasto:=CveTipoGastoDT, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then
- ErrorPrepoliza = True
-
- End If
- End If
-
-
-
-
- End If
-
- If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}"
-
- If tipoCambioActual = 1 Then
+ importeMovimiento = importePagoProv
+ importeMN = importeMovimiento * tipoCambioActual * Multiplicador
IdCtaContable = CtaProveedor
CveCuenta = CveCuentaProveedor
- Else
- IdCtaContable = CtaProveedorComplementaria
- CveCuenta = CveCuentaProveedorComplementaria
- If importeMovimiento <> 0 AndAlso (IdCtaContable > 0 Or CveCuenta > 0) Then 'Cuando tiene complementaria lo dividimos en dos
- importeMN = importeMovimiento
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, Referencia, 201, Concepto, FechaMovimiento, IdCtaContable, -1, CveIE, CveProveedor:=CveProveedor, ImporteMX:=importeMovimiento * tipoCambioActual - importeMovimiento, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
- ErrorPrepoliza = True
- End If
- End If
- IdCtaContable = CtaProveedorExtranjera
- CveCuenta = CveCuentaProveedorExtranjera
- End If
- Case 30 'Bancos
- importeMovimiento = importeBanco + importeCajaChica 'Uno de los dos debe ser 0
- importeMN = importeMovimiento * tipoCambioPago * Multiplicador
- IdCtaContable = IdCuentaBancaria
- CveCuenta = CveCuentaBancaria
- If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioPago} ${importeMovimiento.FormatoNumero(2)}"
- '' falta complementaria
+ If RBLPago.SelectedValue.ToEntero = 4 And EstatusCredito.Contiene(2, 102) Then 'SI ES CRÉDITO Y ESTA PAGADO
- Case 19 'IVA Acreditable
- If UsuarioActual.Empresa.Funcionalidad(521) = "1" Then
- If importePagoProv = importeProv Then
- importeMovimiento = TxtIVA.Text.ToDecimal
- Else
- importeMovimiento = 0
- End If
- Else
- importeMovimiento = importeIVAAcreditable
- End If
+ Dim IdSegmentoNegocio As Integer = -1
+ For Each Row2 As DataRow In TmpDT.Rows
- importeMN = Math.Round(importeMovimiento, 2) * tipoCambioPago * Multiplicador
-
- PorcentajeImpuesto = PorcentajeIVA
- IdCtaContable = If(IdCtaIVAAcreditable > 0, IdCtaIVAAcreditable, 0)
-
- If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) And Not IdCtaContable > 0 Then
- If ObjConta.DtResultados.Rows.Count > 0 Then
- IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaIVAAcreditable").ToString.ToEntero
- CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaIVAAcreditableSIG").ToString.ToEntero
- End If
- End If
-
- 'Agregamos el Opuesto del 19 -> 14
- If importeMovimiento <> 0 Then
- Dim IdCtaIva As Integer = 0
- Dim CveCuentaIVA As Integer = 0
- IdCtaIva = If(IdCtaIVAXAcreditar > 0, IdCtaIVAXAcreditar, 0)
-
- If ObjConta.GetRetCuenta(14, UsuarioActual.CveEmpresa) And Not IdCtaIva > 0 Then
- If ObjConta.DtResultados.Rows.Count > 0 Then
- IdCtaIva = ObjConta.DtResultados.Rows(0)("IdCuentaIVAxAcreditar").ToString.ToEntero
- CveCuentaIVA = ObjConta.DtResultados.Rows(0)("IdCuentaIVAxAcreditarSIG").ToString.ToEntero
- End If
- End If
-
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, importeMovimiento, Referencia, 14, Concepto + If(tipoCambioActual > 1, $" TC: {tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}", ""), FechaMovimiento, IdCtaIva, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimiento * tipoCambioActual, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuentaIVA, PorcentajeImpuesto:=PorcentajeImpuesto, Contabilizable:=SeContabiliza) Then
- ErrorPrepoliza = True
- End If
- End If
-
- If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioPago} ${importeMovimiento.FormatoNumero(2)}"
- Case 14 'IVA X Acreditar
- importeMovimiento = importeIVAxAcreditar
- importeMN = Math.Round(importeMovimiento, 2) * tipoCambioActual * Multiplicador
- If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}"
- PorcentajeImpuesto = PorcentajeIVA
- IdCtaContable = If(IdCtaIVAXAcreditar > 0, IdCtaIVAXAcreditar, 0)
- If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) And Not IdCtaContable > 0 Then
- If ObjConta.DtResultados.Rows.Count > 0 Then
- IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaIVAxAcreditar").ToString.ToEntero
- CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaIVAxAcreditarSIG").ToString.ToEntero
- End If
- End If
- Case 25 'IEPS X Acreditar
- If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then
- importeMovimiento = ImporteIEPSxAcreditar
- importeMN = Math.Round(importeMovimiento, 2) * tipoCambioActual * Multiplicador
- If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}"
- If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
- If ObjConta.DtResultados.Rows.Count > 0 Then
- IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaIEPSxAcreditar").ToString.ToEntero
- CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaIEPSxAcreditarSIG").ToString.ToEntero
- End If
- End If
- End If
-
- Case 224 'Otros impuestos
- If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then
- importeMovimiento = OtrosImpuestos
- importeMN = Math.Round(importeMovimiento, 2) * tipoCambioActual * Multiplicador
- If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}"
- IdCtaContable = If(UsuarioActual.CveEmpresa = 119, 1171, -1)
- CveCuenta = -1
- End If
- Case 26 'IEPS Acreditable
- If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then
- importeMovimiento = ImporteIEPSAcreditable
- importeMN = Math.Round(importeMovimiento, 2) * tipoCambioPago * Multiplicador
- If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
- If ObjConta.DtResultados.Rows.Count > 0 Then
- IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaIEPSAcreditable").ToString.ToEntero
- CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaIEPSAcreditableSIG").ToString.ToEntero
- End If
- End If
-
- 'Agregamos el Opuesto del 26 -> 25
- If importeMovimiento <> 0 Then
- Dim IdCtaIEPS As Integer = 0
- Dim CveCuentaIEPS As Integer = 0
- If ObjConta.GetRetCuenta(25, UsuarioActual.CveEmpresa) Then
- If ObjConta.DtResultados.Rows.Count > 0 Then
- IdCtaIEPS = ObjConta.DtResultados.Rows(0)("IdCuentaIEPSxAcreditar").ToString.ToEntero
- CveCuentaIEPS = ObjConta.DtResultados.Rows(0)("IdCuentaIEPSxAcreditarSIG").ToString.ToEntero
- End If
- End If
-
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, importeMovimiento, Referencia, 25, Concepto + If(tipoCambioActual > 1, $" TC: {tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}", ""), FechaMovimiento, IdCtaIEPS, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimiento * tipoCambioActual, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuentaIEPS, Contabilizable:=SeContabiliza) Then
- ErrorPrepoliza = True
- End If
- End If
-
- If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioPago} ${importeMovimiento.FormatoNumero(2)}"
-
- End If
- Case 22 'RetIVA Acreditable Honorarios/Serv. Prof.
- If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then
- If DdlRetIVAConcepto.Items.Count > 0 Then
- If DdlRetIVAConcepto.SelectedValue.ToEntero = 1 Then
- importeMovimiento = importeRetIVAAcreditable
- importeMN = Math.Round(importeMovimiento, 2) * tipoCambioPago * Multiplicador
- If CtaProveedorRetIVA > 0 Then
- IdCtaContable = CtaProveedorRetIVA
- CveCuenta = CveCuentaProveedorRetIVA
- ElseIf UsuarioActual.Empresa.Funcionalidad(308).ToEntero > 0 Then
- IdCtaContable = UsuarioActual.Empresa.Funcionalidad(308).ToEntero
- Else
- If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
- If ObjConta.DtResultados.Rows.Count > 0 Then
- IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero
- CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero
- End If
- End If
- End If
-
- 'Agregamos el Opuesto del 22 -> 15
- If importeMovimiento <> 0 Then
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, importeMovimiento, Referencia, 15, Concepto + If(tipoCambioActual > 1, $" TC: {tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}", ""), FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimiento * tipoCambioActual, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
- ErrorPrepoliza = True
- End If
- End If
-
- If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioPago} ${importeMovimiento.FormatoNumero(2)}"
- End If
- End If
- End If
- Case 15 'RetIVA X Acreditar Honorarios/Serv. Prof.
- If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then
- If DdlRetIVAConcepto.Items.Count > 0 Then
- If DdlRetIVAConcepto.SelectedValue.ToEntero = 1 Then
- importeMovimiento = importeRetIVAxAcreditar
- importeMN = Math.Round(importeMovimiento, 2) * tipoCambioActual * Multiplicador
- If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}"
- If CtaProveedorRetIVA > 0 Then
- IdCtaContable = CtaProveedorRetIVA
- CveCuenta = CveCuentaProveedorRetIVA
- ElseIf UsuarioActual.Empresa.Funcionalidad(307).ToEntero > 0 Then
- IdCtaContable = UsuarioActual.Empresa.Funcionalidad(307).ToEntero
- Else
- If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
- If ObjConta.DtResultados.Rows.Count > 0 Then
- IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero
- CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero
- End If
- End If
- End If
- End If
- End If
- End If
- Case 184 'RetIVA Acreditable Fletes P.F
- If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then
- If DdlRetIVAConcepto.Items.Count > 0 Then
- If DdlRetIVAConcepto.SelectedValue.ToEntero = 2 Then
- importeMovimiento = importeRetIVAAcreditable
- importeMN = Math.Round(importeMovimiento, 2) * tipoCambioPago * Multiplicador
- If CtaProveedorRetIVA > 0 Then
- IdCtaContable = CtaProveedorRetIVA
- CveCuenta = CveCuentaProveedorRetIVA
- ElseIf UsuarioActual.Empresa.Funcionalidad(310).ToEntero > 0 Then
- IdCtaContable = UsuarioActual.Empresa.Funcionalidad(310).ToEntero
- Else
- If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
- If ObjConta.DtResultados.Rows.Count > 0 Then
- IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero
- CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero
- End If
- End If
- End If
-
- 'Agregamos el Opuesto del 184 -> 183
- If importeMovimiento <> 0 Then
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, importeMovimiento, Referencia, 183, Concepto + If(tipoCambioActual > 1, $" TC: {tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}", ""), FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimiento * tipoCambioActual, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
- ErrorPrepoliza = True
- End If
- End If
-
- If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioPago} ${importeMovimiento.FormatoNumero(2)}"
- End If
- End If
- End If
- Case 183 'RetIVA X Acreditar Fletes P.F
- If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then
- If DdlRetIVAConcepto.Items.Count > 0 Then
- If DdlRetIVAConcepto.SelectedValue.ToEntero = 2 Then
- importeMovimiento = importeRetIVAxAcreditar
- importeMN = Math.Round(importeMovimiento, 2) * tipoCambioActual * Multiplicador
- If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}"
- If CtaProveedorRetIVA > 0 Then
- IdCtaContable = CtaProveedorRetIVA
- CveCuenta = CveCuentaProveedorRetIVA
- ElseIf UsuarioActual.Empresa.Funcionalidad(309).ToEntero > 0 Then
- IdCtaContable = UsuarioActual.Empresa.Funcionalidad(309).ToEntero
- Else
- If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
- If ObjConta.DtResultados.Rows.Count > 0 Then
- IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero
- CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero
- End If
- End If
- End If
- End If
- End If
- End If
- Case 248 'RetIVA X Acreditar Arrendamiento
- If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then
- If DdlRetIVAConcepto.Items.Count > 0 AndAlso DdlRetIVAConcepto.SelectedValue.ToEntero = 4 Then
- importeMovimiento = importeRetIVAxAcreditar
- importeMN = Math.Round(importeMovimiento, 2) * tipoCambioActual * Multiplicador
- If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}"
- If CtaProveedorRetIVA > 0 Then
- IdCtaContable = CtaProveedorRetIVA
- CveCuenta = CveCuentaProveedorRetIVA
- ElseIf UsuarioActual.Empresa.Funcionalidad(313).ToEntero > 0 Then
- IdCtaContable = UsuarioActual.Empresa.Funcionalidad(313).ToEntero
- Else
- If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
- If ObjConta.DtResultados.Rows.Count > 0 Then
- IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero
- CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero
- End If
- End If
- End If
-
- End If
- End If
- Case 186 'RetIVA Acreditable Fletes P.M.
- If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then
- If DdlRetIVAConcepto.Items.Count > 0 Then
- If DdlRetIVAConcepto.SelectedValue.ToEntero = 3 Then
- importeMovimiento = importeRetIVAAcreditable
- importeMN = Math.Round(importeMovimiento, 2) * tipoCambioPago * Multiplicador
- If CtaProveedorRetIVA > 0 Then
- IdCtaContable = CtaProveedorRetIVA
- CveCuenta = CveCuentaProveedorRetIVA
- ElseIf UsuarioActual.Empresa.Funcionalidad(312).ToEntero > 0 Then
- IdCtaContable = UsuarioActual.Empresa.Funcionalidad(312).ToEntero
- Else
- If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
- If ObjConta.DtResultados.Rows.Count > 0 Then
- IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero
- CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero
- End If
- End If
- End If
-
- 'Agregamos el Opuesto del 186 -> 185
- If importeMovimiento <> 0 Then
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, importeMovimiento, Referencia, 185, Concepto + If(tipoCambioActual > 1, $" TC: {tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}", ""), FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimiento * tipoCambioActual, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
- ErrorPrepoliza = True
- End If
- End If
-
- If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioPago} ${importeMovimiento.FormatoNumero(2)}"
- End If
- End If
- End If
- Case 185 'RetIVA X Acreditar Fletes P.M.
- If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then
- If DdlRetIVAConcepto.Items.Count > 0 Then
- If DdlRetIVAConcepto.SelectedValue.ToEntero = 3 Then
- importeMovimiento = importeRetIVAxAcreditar
- importeMN = Math.Round(importeMovimiento, 2) * tipoCambioActual * Multiplicador
- If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}"
- If CtaProveedorRetIVA > 0 Then
- IdCtaContable = CtaProveedorRetIVA
- CveCuenta = CveCuentaProveedorRetIVA
- ElseIf UsuarioActual.Empresa.Funcionalidad(311).ToEntero > 0 Then
- IdCtaContable = UsuarioActual.Empresa.Funcionalidad(311).ToEntero
- Else
- If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
- If ObjConta.DtResultados.Rows.Count > 0 Then
- IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero
- CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero
- End If
- End If
- End If
- End If
- End If
- End If
- Case 249 'RetIVA Acreditable Arrendamiento
- If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then
- If DdlRetIVAConcepto.Items.Count > 0 AndAlso DdlRetIVAConcepto.SelectedValue.ToEntero = 4 Then
- importeMovimiento = importeRetIVAAcreditable
- importeMN = Math.Round(importeMovimiento, 2) * tipoCambioPago * Multiplicador
- If CtaProveedorRetIVA > 0 Then
- IdCtaContable = CtaProveedorRetIVA
- CveCuenta = CveCuentaProveedorRetIVA
- ElseIf UsuarioActual.Empresa.Funcionalidad(314).ToEntero > 0 Then
- IdCtaContable = UsuarioActual.Empresa.Funcionalidad(314).ToEntero
- Else
- If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
- If ObjConta.DtResultados.Rows.Count > 0 Then
- IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero
- CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero
- End If
- End If
- End If
-
- If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioPago} ${importeMovimiento.FormatoNumero(2)}"
- End If
-
- End If
- Case 23 'RetISR Acreditable
- If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then
- If DdlRetISRConcepto.Items.Count > 0 AndAlso DdlRetISRConcepto.SelectedValue.ToEntero = 1 Then
- importeMovimiento = importeRetISRAcreditable
- importeMN = Math.Round(importeMovimiento, 2) * tipoCambioPago * Multiplicador
- If CtaProveedorRetISR > 0 Then
- IdCtaContable = CtaProveedorRetISR
- CveCuenta = CveCuentaProveedorRetISR
- ElseIf UsuarioActual.Empresa.Funcionalidad(316).ToEntero > 0 Then
- IdCtaContable = UsuarioActual.Empresa.Funcionalidad(316).ToEntero
- Else
- If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
- If ObjConta.DtResultados.Rows.Count > 0 Then
- IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetISRCirculacion").ToString.ToEntero
- CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetISRCirculacionSIG").ToString.ToEntero
- End If
- End If
- End If
-
- 'Agregamos el Opuesto del 23 -> 16
- If importeMovimiento <> 0 Then
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, importeMovimiento, Referencia, 15, Concepto + If(tipoCambioActual > 1, $" TC: {tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}", ""), FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimiento * tipoCambioActual, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
- ErrorPrepoliza = True
- End If
- End If
-
- If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioPago} ${importeMovimiento.FormatoNumero(2)}"
- End If
- End If
- Case 16 'Ret ISR X Acreditar
- If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then
- If DdlRetISRConcepto.Items.Count > 0 AndAlso DdlRetISRConcepto.SelectedValue.ToEntero = 1 Then
- importeMovimiento = importeRetISRxAcreditar
- importeMN = Math.Round(importeMovimiento, 2) * tipoCambioActual * Multiplicador
- If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}"
- If CtaProveedorRetISR > 0 Then
- IdCtaContable = CtaProveedorRetISR
- CveCuenta = CveCuentaProveedorRetISR
- ElseIf UsuarioActual.Empresa.Funcionalidad(315).ToEntero > 0 Then
- IdCtaContable = UsuarioActual.Empresa.Funcionalidad(315).ToEntero
- Else
- If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
- If ObjConta.DtResultados.Rows.Count > 0 Then
- IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetISRCirculacion").ToString.ToEntero
- CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetISRCirculacionSIG").ToString.ToEntero
- End If
- End If
- End If
- End If
- End If
- Case 243 'RetISR X Acreditar Terceros y Arrendamiento
- If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then
- If DdlRetISRConcepto.Items.Count > 0 AndAlso DdlRetISRConcepto.SelectedValue.ToEntero = 2 Then
- importeMovimiento = importeRetISRxAcreditar
- importeMN = Math.Round(importeMovimiento, 2) * tipoCambioPago * Multiplicador
- If CtaProveedorRetISR > 0 Then
- IdCtaContable = CtaProveedorRetISR
- CveCuenta = CveCuentaProveedorRetISR
- ElseIf UsuarioActual.Empresa.Funcionalidad(317).ToEntero > 0 Then
- IdCtaContable = UsuarioActual.Empresa.Funcionalidad(317).ToEntero
- Else
- If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
- If ObjConta.DtResultados.Rows.Count > 0 Then
- IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetISRCirculacion").ToString.ToEntero
- CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetISRCirculacionSIG").ToString.ToEntero
- End If
- End If
- End If
-
- If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioPago} ${importeMovimiento.FormatoNumero(2)}"
- End If
- End If
- Case 244 'RetISR Acreditable Terceros y Arrendamiento
- If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then
- If DdlRetISRConcepto.Items.Count > 0 AndAlso DdlRetISRConcepto.SelectedValue.ToEntero = 2 Then
- importeMovimiento = importeRetISRAcreditable
- importeMN = Math.Round(importeMovimiento, 2) * tipoCambioPago * Multiplicador
- If CtaProveedorRetISR > 0 Then
- IdCtaContable = CtaProveedorRetISR
- CveCuenta = CveCuentaProveedorRetISR
- ElseIf UsuarioActual.Empresa.Funcionalidad(318).ToEntero > 0 Then
- IdCtaContable = UsuarioActual.Empresa.Funcionalidad(318).ToEntero
- Else
- If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
- If ObjConta.DtResultados.Rows.Count > 0 Then
- IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetISRCirculacion").ToString.ToEntero
- CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetISRCirculacionSIG").ToString.ToEntero
- End If
- End If
- End If
- 'Agregamos el Opuesto del 244 -> 243
- If importeMovimiento <> 0 Then
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, importeMovimiento, Referencia, 243, Concepto + If(tipoCambioActual > 1, $" TC: {tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}", ""), FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimiento * tipoCambioActual, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
- ErrorPrepoliza = True
- End If
- End If
- If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioPago} ${importeMovimiento.FormatoNumero(2)}"
- End If
- End If
- Case 64 'Ganancia
- If tipoCambioActual <> 1 AndAlso TxtFechaPago.Text <> TxtFecha.Text Then
- IdCtaContable = UsuarioActual.Empresa.IdCuentaGananciaCambiaria
- CveCuenta = UsuarioActual.Empresa.CveCuentaGananciaCambiaria
- If tipoCambioPago < tipoCambioActual Then
- importeMovimiento = Math.Abs(tipoCambioPago - tipoCambioActual) * importePagoProv
- importeMovimiento -= Math.Abs(tipoCambioPago - tipoCambioActual) * importeIVAAcreditable
- importeMovimiento += Math.Abs(tipoCambioPago - tipoCambioActual) * importeRetIVAAcreditable
- importeMovimiento += Math.Abs(tipoCambioPago - tipoCambioActual) * importeRetISRAcreditable
- importeMN = importeMovimiento
- End If
- Else
- importeMovimiento = 0
- End If
-
- Case 65 'Perdida
- If tipoCambioActual <> 1 AndAlso TxtFechaPago.Text <> TxtFecha.Text Then
- IdCtaContable = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria
- CveCuenta = UsuarioActual.Empresa.CveCuentaPerdidaCambiaria
- If tipoCambioActual < tipoCambioPago Then
- importeMovimiento = Math.Abs(tipoCambioPago - tipoCambioActual) * importePagoProv
- importeMovimiento -= Math.Abs(tipoCambioPago - tipoCambioActual) * importeIVAAcreditable
- importeMovimiento += Math.Abs(tipoCambioPago - tipoCambioActual) * importeRetIVAAcreditable
- importeMovimiento += Math.Abs(tipoCambioPago - tipoCambioActual) * importeRetISRAcreditable
- importeMN = importeMovimiento
- End If
- Else
- importeMovimiento = 0
- End If
-
- Case 6 'Compra
-
- If RBLPago.SelectedValue.ToEntero = 4 Then
- Exit Select 'Es credito el concepto 6 se agrega en CASE 17
- End If
-
- If Not CveCompraRefacturacion > 0 OrElse ChkRefacNC.Checked Then
- 'AF TipoAF 2 Es para las compras
- DT = TmpDT.FiltraParametros("ISNULL(TipoAF,0) = 2 AND ISNULL(AplicaCostoIndirecto,0) <> 1")
- If DT.Rows.Count > 0 AndAlso Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") Then
- For Each Row2 As DataRow In DT.Rows
- importeMovimiento = If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, Row2("ImporteSinImpuestos").ToString.ToDecimal, Row2("Total").ToString.ToDecimal)
+ importeMovimiento = TxtTotal.Text.ToDecimal 'TmpDT.SUM("Total", String.Format("ISNULL(TipoAF,0) <> 2 And ISNULL(CveAlmacen,0) = 0 And ISNULL(AplicaCostoIndirecto,0) <> 1 And CveClasificacion = {0} And CveSubProyecto = {1} And ISNULL(CveTipoGasto,0) = {2}", Row2("CveClasificacion").ToString.ToEntero, Row2("CveSubProyecto").ToString.ToEntero, Row2("CveTipoGasto").ToString.ToEntero)).ToString.ToDecimal
importeMN = importeMovimiento * tipoCambioActual * Multiplicador
- If ObjConta.GetRetCuenta(49, Row2("CveActivoFijo").ToString.ToEntero) Then
- If ObjConta.DtResultados.Rows.Count > 0 Then
- IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCtaContActivoFijo").ToString.ToEntero
- CveCuenta = ObjConta.DtResultados.Rows(0)("IdCtaContActivoFijoSIG").ToString.ToEntero
+ 'CLASIFICACION
+ If Row2("CveClasificacion").ToString.ToEntero > 0 Then
+ If ObjConta.GetRetCuenta(6, Row2("CveClasificacion").ToString.ToEntero, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero) Then
+ If ObjConta.DtResultados.Rows.Count > 0 AndAlso ObjConta.DtResultados.Rows(0)("IdCuentaGasto").ToString.ToEntero > 0 Then
+ IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaGasto").ToString.ToEntero
+ CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaGastoSIG").ToString.ToEntero
+ Else
+ IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaGasto", String.Format("CveClasificacion = {0}", Row2("CveClasificacion"))).ToString.ToEntero
+ CveCuenta = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaGastoSIG", String.Format("CveClasificacion = {0}", Row2("CveClasificacion"))).ToString.ToEntero
+ End If
End If
End If
+
+
+
+ 'SEGMENTO DE NEGOCIO
+
+ Dim drT As DataRow = GlobalDTSubProyectos(-1, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero).FiltroPrimero(String.Format("CveSubProyecto = {0} ", Row2("CveSubProyecto").ToString.ToEntero))
+ If drT IsNot Nothing Then
+ IdSegmentoNegocio = drT("IdSegNeg").ToString.ToEntero
+ End If
+
+ 'AGREGA MOVIMIENTO
If importeMovimiento <> 0 Then
'Conta ContPAQ
If IdCtaContable = 0 Then
- CuentasContablesInvalidas.Append(" " & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 49))("ConceptoContable").ToString)
+ CuentasContablesInvalidas.Append(" " & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 6))("ConceptoContable").ToString)
idCuentaContabilizacion = 0
End If
'Conta SIG
If CveCuenta = 0 Then
- CuentasContablesInvalidasSIG.Append(" " & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 49))("ConceptoContable").ToString)
+ CuentasContablesInvalidasSIG.Append(" " & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 6))("ConceptoContable").ToString)
CveCuentaContabilizacion = 0
End If
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Row2("CodAF").ToString, 49, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveActivoFijo:=Row2("CveActivoFijo").ToString.ToEntero, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then
- ErrorPrepoliza = True
- End If
End If
Next
- End If
-
- 'LIMPIA
- importeMovimiento = 0
- IdCtaContable = 0
- CveCuenta = 0
-
- 'COSTO ALMACEN
- Dim DtAlmacenes = GlobalDTAlmacen(UsuarioActual.CveEmpresa)
- If UsuarioActual.Empresa.UsaInventarios AndAlso Not UsuarioActual.Empresa.Funcionalidad(126) = "1" Then
- DT = TmpDT.FiltraParametros("ISNULL(TipoAF,0) <> 2 AND ISNULL(CveAlmacen,0) > 0", "", {"CveAlmacen"})
- 'RECORREMOS PARA DETECTAR LA MODALIDAD DEL ALMACEN, EN CASO DE SER SOLO EXISTENCIA LIMPIAMOS CVEALMACEN
- For Each Dr As DataRow In DT.Rows
- If DtAlmacenes.FiltroPrimeroValor("Modalidad", $"CveAlmacen = {Dr("CveAlmacen").ToString.ToEntero}").ToString = "Solo Existencia" Then
- Dr("CveAlmacen") = 0
- End If
- Dr.AcceptChanges()
- Next
- DT.AcceptChanges()
- DT = DT.FiltraParametros("ISNULL(CveAlmacen,0) > 0")
- If DT.Rows.Count > 0 AndAlso Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") Then
- For Each Row2 As DataRow In DT.Rows
-
- importeMovimiento = TmpDT.SUM(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total"), $"CveAlmacen = {Row2("CveAlmacen")}").ToString.ToDecimal + TmpDT.SUM("CostoIndirectoAlmacen", $"CveAlmacen = {Row2("CveAlmacen")}").ToString.ToDecimal 'Row2("Total").ToString.ToDecimal + Row2("CostoIndirectoAlmacen").ToString.ToDecimal
- importeMN = importeMovimiento * tipoCambioActual * Multiplicador
- If ObjConta.GetRetCuenta(68, GvInv.HeaderRow.FCDropDownList("ddlAlmacen").SelectedValue.ToString.ToEntero) Then
- If ObjConta.DtResultados.Rows.Count > 0 Then
- IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCtaContable").ToString.ToEntero
- CveCuenta = ObjConta.DtResultados.Rows(0)("IdCtaContableSIG").ToString.ToEntero
- End If
- End If
- If importeMovimiento <> 0 Then
- 'Conta ContPAQ
- If IdCtaContable = 0 Then
- CuentasContablesInvalidas.Append(" " & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 68))("ConceptoContable").ToString)
- idCuentaContabilizacion = 0
- End If
- 'Conta SIG
- If CveCuenta = 0 Then
- CuentasContablesInvalidasSIG.Append(" " & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 68))("ConceptoContable").ToString)
- CveCuentaContabilizacion = 0
- End If
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, 68, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CvePersonal:=CvePersonal, CveMovimientoAlmacen:=CveMovimientoInventario, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then
- ErrorPrepoliza = True
- End If
- End If
- Next
- End If
- End If
-
- 'LIMPIA
- importeMovimiento = 0
- IdCtaContable = 0
- CveCuenta = 0
-
- ''FLETES
- 'If UsuarioActual.CveEmpresa.Contiene(119) And UsuarioActual.Empresa.UsaInventarios And DdlTipoComprobante.SelectedValue <> "NC" And Not UsuarioActual.Empresa.Funcionalidad(126) = "1" And CveConceptoContableAlmacen.Contiene(237, 240) Then
-
- 'End If
- Dim CostoIndirectoAcum176 As Decimal = 0
- 'INV [MERCANCIA RECIBIDA POR ADELANTADO (OC) | MERCANCIA PENDIENTE POR RECIBIR (COMPRA) ]
- If UsuarioActual.CveEmpresa.Contiene(1, 119) And UsuarioActual.Empresa.UsaInventarios And Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") And Not UsuarioActual.Empresa.Funcionalidad(126) = "1" And CveConceptoContableAlmacen.Contiene(205, 176, 237, 240) Then
-
- importeMovimiento = TmpDT.SUM(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total"), $"ISNULL(TipoAF,0) <> 2 AND ISNULL(CveAlmacen,0) = 0 AND (ISNULL(CveTipoPS,0) = 2 OR (ISNULL(CveTipoPS,0) = 1 AND ISNULL(AplicaCostoIndirecto,0) = 1))").ToString.ToDecimal
- importeMN = importeMovimiento * tipoCambioActual * Multiplicador
-
- Dim ConceptoContabilizacion = 205
- Dim ConceptoContabilizacionME = -1
- Dim IdCtaContableME = -1
- Dim ConceptoContabilizacionMEComp = -1
- Dim IdCtaContableMEComp = -1
-
- If OCVinculada Or CveConceptoContableAlmacen.Contiene(237, 240) Then
- ConceptoContabilizacion = CveConceptoContableAlmacen
- End If
- Dim UsaComplementariaFleteImportaciones As Boolean = False
-
- Select Case ConceptoContabilizacion
- Case 176
- ConceptoContabilizacionME = 228
- ConceptoContabilizacionMEComp = 229
- Case 205
- ConceptoContabilizacionME = 230
- ConceptoContabilizacionMEComp = 231
- Case 237
- ConceptoContabilizacionME = 238
- ConceptoContabilizacionMEComp = 239
- importeMovimiento = TmpDT.SUMD(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total"))
- importeMN = importeMovimiento * tipoCambioActual * Multiplicador 'TIENE QUE TENER EL IMPORTEMN IGUAL AL IMPORTEMOVIMIENTO PORQUE NO TOMA EN CUENTA SI UN PRODUCTO ES TIPO SERVICIO
- Case 240
- ConceptoContabilizacionME = 241
- ConceptoContabilizacionMEComp = 242
- importeMovimiento = TmpDT.SUMD(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total"))
- importeMN = importeMovimiento * tipoCambioActual * Multiplicador 'TIENE QUE TENER EL IMPORTEMN IGUAL AL IMPORTEMOVIMIENTO PORQUE NO TOMA EN CUENTA SI UN PRODUCTO ES TIPO SERVICIO
- End Select
-
- If ObjConta.GetRetCuenta(ConceptoContabilizacion, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then
- IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCtaContable").ToString.ToEntero
- End If
-
- If ObjConta.GetRetCuenta(ConceptoContabilizacionME, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then
- IdCtaContableME = ObjConta.DtResultados.Rows(0)("IdCtaContable").ToString.ToEntero
- End If
-
- If ObjConta.GetRetCuenta(ConceptoContabilizacionMEComp, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then
- IdCtaContableMEComp = ObjConta.DtResultados.Rows(0)("IdCtaContable").ToString.ToEntero
- End If
- 'If importeMovimiento <> 0 Then
- Select Case ConceptoContabilizacion
- Case 176
- Dim SumatoriaOCINV = 0.0D, Importe176 = 0.0D, ImporteME176 = 0.0D, ImporteMN176 = 0.0D, Importe228 = 0.0D, ImporteME228 = 0.0D, ImporteMN228 = 0.0D, Importe229 = 0.0D, ImporteME229 = 0.0D, ImporteMN229 = 0.0D, ImporteCI176 = 0.0D
- For Each Dr As DataRow In TmpDT.FiltraParametros("ISNULL(TipoAF,0) <> 2 AND ISNULL(CveAlmacen,0) = 0 AND ISNULL(AplicaCostoIndirecto,0) <> 1 AND ISNULL(CveTipoPS,0) = 2").Rows
- If ObjOC.OrdenesCompraDetalleCostoPP(Dr("CveOrdenCompraDetalle").ToString.ToEntero) AndAlso ObjOC.DtResultados.Rows.Count = 1 Then
- Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text} OC: {ObjOC.DtResultados.FiltroPrimeroValor("Folio").ToString}"
- Importe176 = ObjOC.DtResultados.FiltroPrimeroValor("Importe176").ToDecimal * Dr("Cantidad").ToString.ToDecimal : ImporteME176 = ObjOC.DtResultados.FiltroPrimeroValor("ImporteME176").ToDecimal * Dr("Cantidad").ToString.ToDecimal : ImporteMN176 = ObjOC.DtResultados.FiltroPrimeroValor("ImporteMN176").ToDecimal * Dr("Cantidad").ToString.ToDecimal
- Importe228 = ObjOC.DtResultados.FiltroPrimeroValor("Importe228").ToDecimal * Dr("Cantidad").ToString.ToDecimal : ImporteME228 = ObjOC.DtResultados.FiltroPrimeroValor("ImporteME228").ToDecimal * Dr("Cantidad").ToString.ToDecimal : ImporteMN228 = ObjOC.DtResultados.FiltroPrimeroValor("ImporteMN228").ToDecimal * Dr("Cantidad").ToString.ToDecimal
- Importe229 = ObjOC.DtResultados.FiltroPrimeroValor("Importe229").ToDecimal * Dr("Cantidad").ToString.ToDecimal : ImporteME229 = ObjOC.DtResultados.FiltroPrimeroValor("ImporteME229").ToDecimal * Dr("Cantidad").ToString.ToDecimal : ImporteMN229 = ObjOC.DtResultados.FiltroPrimeroValor("ImporteMN229").ToDecimal * Dr("Cantidad").ToString.ToDecimal
- ImporteCI176 = ObjOC.DtResultados.FiltroPrimeroValor("ImporteCI176").ToDecimal
- Dim TCAjuste As Decimal = ObjOC.DtResultados.FiltroPrimeroValor("TipoCambioAjuste").ToDecimal
- 'RMF. falta verificar el costo indirecto de la OC
- If DdlMoneda.SelectedValue.ToEntero <> 1 And UsuarioActual.CveEmpresa.Contiene(119) Then
- ImporteCI176 = ObjOC.DtResultados.FiltroPrimeroValor("ImporteCI228").ToDecimal
- CostoIndirectoAcum176 += ImporteCI176
- 'se considera costoindirecto, para que la factura tiene en un concepto tipo servicio
- SumatoriaOCINV += (Dr(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total")).ToString.ToDecimal * tipoCambioActual) - (ImporteMN228 + ImporteMN229 - ImporteCI176)
- If ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, Importe228, Referencia, ConceptoContabilizacionME, Concepto, FechaMovimiento, IdCtaContableME, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=ImporteMN228, ImporteME:=ImporteME228, CveCuenta:=CveCuenta, CveOCDetalle:=Dr("CveOrdenCompraDetalle").ToString.ToEntero, TipoCambio:=TCAjuste, Contabilizable:=SeContabiliza) Then
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, Importe229, Referencia, ConceptoContabilizacionMEComp, Concepto, FechaMovimiento, IdCtaContableMEComp, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=ImporteMN229, ImporteME:=ImporteME229, CveCuenta:=CveCuenta, CveOCDetalle:=Dr("CveOrdenCompraDetalle").ToString.ToEntero, TipoCambio:=TCAjuste, Contabilizable:=SeContabiliza) Then
- ErrorPrepoliza = True
- Exit For
- End If
- Else
- ErrorPrepoliza = True
- Exit For
- End If
- Else
- CostoIndirectoAcum176 += ImporteCI176
- 'se considera costoindirecto, para que la factura tiene en un concepto tipo servicio
- SumatoriaOCINV += (Dr(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total")).ToString.ToDecimal * tipoCambioActual) - (ImporteMN176 - ImporteCI176)
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, Importe176, Referencia, ConceptoContabilizacion, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=ImporteMN176, ImporteME:=ImporteME176, CveCuenta:=CveCuenta, CveOCDetalle:=Dr("CveOrdenCompraDetalle").ToString.ToEntero, Contabilizable:=SeContabiliza) Then
- ErrorPrepoliza = True
- Exit For
- End If
- End If
- Else
- Alert("Ocurrió un error al procesar la mercancia recibida por adelantado. Por favor comuniquese con asistencia SIG", TipoMensaje.MsgError)
- ErrorPrepoliza = True
- Exit For
- End If
- Next
- If SumatoriaOCINV.RoundSQL <> 0 Then
- ' se abona el costo, cambiamos su naturaleza
- SumatoriaOCINV = -SumatoriaOCINV
- Dim CveClasificacionCostoOC = TmpDT.FiltroPrimeroValor("CveClasificacion", "ISNULL(TipoAF, 0) <> 2 And ISNULL(CveAlmacen, 0) = 0 And ISNULL(AplicaCostoIndirecto, 0) <> 1 And ISNULL(CveTipoPS, 0) = 2").ToEntero
- IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaCostos", $"CveClasificacion = {CveClasificacionCostoOC}").ToString.ToEntero
- CveCuenta = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaGastoSIG", $"CveClasificacion = {CveClasificacionCostoOC}").ToString.ToEntero
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, SumatoriaOCINV, Referencia, 69, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveClasificacion:=CveClasificacionCostoOC, ImporteMX:=SumatoriaOCINV, CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then
- ErrorPrepoliza = True
- Exit For
- End If
- End If
- Case 205, 237, 240
- Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}"
- If DdlMoneda.SelectedValue.ToEntero <> 1 AndAlso UsaComplementariaFleteImportaciones Then
- If ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, ConceptoContabilizacionME, Concepto, FechaMovimiento, IdCtaContableME, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=importeMovimiento, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMN - importeMovimiento, Referencia, ConceptoContabilizacionMEComp, Concepto, FechaMovimiento, IdCtaContableMEComp, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=importeMN - importeMovimiento, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then
- ErrorPrepoliza = True
- End If
- Else
- ErrorPrepoliza = True
- End If
- Else
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMN, Referencia, ConceptoContabilizacion, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then
- ErrorPrepoliza = True
- End If
- End If
- End Select
- 'End If
+ Dim CveClasificacionDT As Integer = -1
+ Dim CveSubProyectoDT As Integer = -1
+ Dim CveTipoGastoDT As Integer = -1
- End If
-
-
- 'NC CON PRODUCTOS - CUENTA PUENTE
- If UsuarioActual.CveEmpresa.Contiene(119) AndAlso UsuarioActual.Empresa.UsaInventarios AndAlso DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") AndAlso Not UsuarioActual.Empresa.Funcionalidad(126) = "1" Then
-
- importeMovimiento = TmpDT.SUM(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total"), $"ISNULL(TipoAF,0) <> 2 AND ISNULL(CveAlmacen,0) = 0 AND ISNULL(AplicaCostoIndirecto,0) <> 1 AND ISNULL(CveTipoPS,0) = 2").ToString.ToDecimal
- importeMN = importeMovimiento * tipoCambioActual * Multiplicador
-
- Dim ConceptoContabilizacionNC = 225
-
- If ObjConta.GetRetCuenta(ConceptoContabilizacionNC, UsuarioActual.CveEmpresa) Then
- If ObjConta.DtResultados.Rows.Count > 0 Then
- IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCtaContable").ToString.ToEntero
- End If
+ If TmpDT.Rows.Count > 0 Then
+ CveClasificacionDT = TmpDT(0)("CveClasificacion").ToString.ToEntero
+ CveSubProyectoDT = TmpDT(0)("CveSubProyecto").ToString.ToEntero
+ CveTipoGastoDT = TmpDT(0)("CveTipoGasto").ToString.ToEntero
End If
Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}"
- If importeMovimiento <> 0 Then
- 'Conta ContPAQ
- If IdCtaContable = 0 Then
- CuentasContablesInvalidas.Append(" " & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 68))("ConceptoContable").ToString)
- idCuentaContabilizacion = 0
- End If
- 'Conta SIG
- If CveCuenta = 0 Then
- CuentasContablesInvalidasSIG.Append(" " & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 68))("ConceptoContable").ToString)
- CveCuentaContabilizacion = 0
- End If
+ Dim ImporteSubCre As Decimal = TxtSubTotal.Text.ToDecimal
+ Dim ImporteSubCreMN As Decimal = TxtSubTotal.Text.ToDecimal * tipoCambioActual
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, ConceptoContabilizacionNC, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteSubCre, Referencia, 6, Concepto, FechaMovimiento, IdCtaContable, IdSegmentoNegocio, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, CveClasificacion:=CveClasificacionDT, CveSubProyecto:=CveSubProyectoDT, ImporteMX:=ImporteSubCreMN, ImporteME:=If(tipoCambioActual = 1, 0, ImporteSubCre), CveCuenta:=CveCuenta, CveTipoGasto:=CveTipoGastoDT, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then
+ ErrorPrepoliza = True
+ End If
+
+
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimiento, Referencia, 41, Concepto, FechaMovimiento, CtaProveedorAcreedores, IdSegmentoNegocio, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, CveClasificacion:=CveClasificacionDT, CveSubProyecto:=CveSubProyectoDT, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, CveTipoGasto:=CveTipoGastoDT, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then
+ ErrorPrepoliza = True
+ End If
+
+ If TipoCreditoInteres Then
+
+
+ Dim importeMovimientoIn As Decimal = ImporteIECredito - importeMovimiento
+ Dim importeMNIn As Decimal = importeMovimientoIn * tipoCambioActual * Multiplicador
+
+
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimientoIn, Referencia, 41, Concepto, FechaMovimiento, CtaProveedorAcreedores, IdSegmentoNegocio, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, CveClasificacion:=CveClasificacionDT, CveSubProyecto:=CveSubProyectoDT, ImporteMX:=importeMNIn, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimientoIn), CveCuenta:=CveCuenta, CveTipoGasto:=CveTipoGastoDT, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then
ErrorPrepoliza = True
End If
-
-
- End If
-
- Dim ContienePSNeteoBonif As Boolean = False
- For Each Dr As DataRow In TmpDT.Rows
- If Dr("CveClasificacion").ToString.ToEntero.Contiene(20319) Then 'clasificación de Bonificación, no se incluirá en el neteo
- ContienePSNeteoBonif = True
- Exit For
- End If
- Next
-
- If ContienePSNeteoBonif Then
- importeMovimiento = TmpDT.SUM(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total"), $"ISNULL(TipoAF,0) <> 2 AND ISNULL(CveAlmacen,0) = 0 AND ISNULL(AplicaCostoIndirecto,0) <> 1 ").ToString.ToDecimal
- importeMN = importeMovimiento * tipoCambioActual * Multiplicador
- Dim IdCtaContableDescCompra As Integer = UsuarioActual.Empresa.Funcionalidad(405).ToEntero
- If ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimiento, Referencia, 259, Concepto, FechaMovimiento, IdCtaContableDescCompra, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, -importeMovimiento, Referencia, 259, Concepto, FechaMovimiento, IdCtaContableDescCompra, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=-importeMN, ImporteME:=If(tipoCambioActual = 1, 0, -importeMovimiento), CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then
- ErrorPrepoliza = True
- End If
- Else
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMovimientoIn, Referencia, 50, Concepto, FechaMovimiento, ViewState("IdCtaContDocsXPagar").ToString.ToEntero(), IdSegmentoNegocio, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, CveClasificacion:=CveClasificacionDT, CveSubProyecto:=CveSubProyectoDT, ImporteMX:=importeMNIn, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimientoIn), CveCuenta:=CveCuenta, CveTipoGasto:=CveTipoGastoDT, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then
ErrorPrepoliza = True
+
End If
End If
+
+
+
End If
-
-
- If Not ChkNCInvNC.Checked OrElse Not ListaDocumentos.Count > 0 Then
- 'GASTO
- If UsuarioActual.CveEmpresa = 119 Then
- DT = TmpDT
- Else
- DT = TmpDT.FiltraParametros("ISNULL(AplicaCostoIndirecto,0) <> 1")
- End If
- 'RECORREMOS PARA DETECTAR LA MODALIDAD DEL ALMACEN, EN CASO DE SER SOLO EXISTENCIA LIMPIAMOS CVEALMACEN
- For Each Dr As DataRow In DT.Rows
- If DtAlmacenes.FiltroPrimeroValor("Modalidad", $"CveAlmacen = {Dr("CveAlmacen").ToString.ToEntero}").ToString = "Solo Existencia" Then
- Dr("CveAlmacen") = 0
- End If
- Dr.AcceptChanges()
- Next
- DT.AcceptChanges()
- DtAlmacenes.Dispose()
-
- 'QUITA 1-[MERCANCIA RECIBIDA POR ADELANTADO (OC) | MERCANCIA PENDIENTE POR RECIBIR (COMPRA)] 2-[NC CON PRODUCTOS]
- If UsuarioActual.CveEmpresa.Contiene(1, 119) And UsuarioActual.Empresa.UsaInventarios And Not UsuarioActual.Empresa.Funcionalidad(126) = "1" Then
- DT = DT.FiltraParametros("ISNULL(CveTipoPS,0) <> 2")
- End If
-
- Dim DTDistinct = DT.Copy
- If UsuarioActual.Empresa.Funcionalidad(126) = "1" Then
- DTDistinct = DTDistinct.FiltraParametros("ISNULL(TipoAF, 0) <> 2", "", {"CveClasificacion", "Clasificacion", "SubProyecto", "CveProyecto", "CveSubProyecto", "CveTipoGasto", "TipoGasto"})
- Else
- DTDistinct = DTDistinct.FiltraParametros("ISNULL(TipoAF,0) <> 2 And ISNULL(CveAlmacen,0) = 0 And ISNULL(AplicaCostoIndirecto,0) <> 1", "", {"CveClasificacion", "Clasificacion", "SubProyecto", "CveProyecto", "CveSubProyecto", "CveTipoGasto", "TipoGasto"})
- End If
- 'RMF, si es concepto relacionado a flete o importacion, no debe de afectar al gasto
- If CveFlete > 0 OrElse CveImportacion > 0 Then
- DTDistinct.Clear()
- End If
-
- If DTDistinct.Rows.Count > 0 Then
- For Each Row2 As DataRow In DTDistinct.Rows
-
- 'DETERMINA IMPORTE
- If UsuarioActual.Empresa.Funcionalidad(126) = "1" Then
- importeMovimiento = DT.SUM(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total"), String.Format("ISNULL(TipoAF,0) <> 2 And CveClasificacion = {0} And CveSubProyecto = {1} And ISNULL(CveTipoGasto,0) = {2}", Row2("CveClasificacion").ToString.ToEntero, Row2("CveSubProyecto").ToString.ToEntero, Row2("CveTipoGasto").ToString.ToEntero)).ToString.ToDecimal
- Else
- importeMovimiento = DT.SUM(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total"), String.Format("ISNULL(TipoAF,0) <> 2 And ISNULL(CveAlmacen,0) = 0 And ISNULL(AplicaCostoIndirecto,0) <> 1 And CveClasificacion = {0} And CveSubProyecto = {1} And ISNULL(CveTipoGasto,0) = {2}", Row2("CveClasificacion").ToString.ToEntero, Row2("CveSubProyecto").ToString.ToEntero, Row2("CveTipoGasto").ToString.ToEntero)).ToString.ToDecimal
- End If
- 'se debe de restar el costo indirecto, si se recibió por OC sobre el importe del gasto, por si ya está incuido
- importeMovimiento = importeMovimiento - CostoIndirectoAcum176
-
- importeMN = importeMovimiento * tipoCambioActual * Multiplicador '[IPP] EL 6 DEBE SER POSITIVO 27/AGOSTO/2018
-
- 'CLASIFICACION
- If Row2("CveClasificacion").ToString.ToEntero > 0 Then
- If ObjConta.GetRetCuenta(6, Row2("CveClasificacion").ToString.ToEntero, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero) Then
- If ObjConta.DtResultados.Rows.Count > 0 AndAlso ObjConta.DtResultados.Rows(0)("IdCuentaGasto").ToString.ToEntero > 0 Then
- IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaGasto").ToString.ToEntero
- CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaGastoSIG").ToString.ToEntero
- Else
- IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaGasto", String.Format("CveClasificacion = {0}", Row2("CveClasificacion"))).ToString.ToEntero
- CveCuenta = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaGastoSIG", String.Format("CveClasificacion = {0}", Row2("CveClasificacion"))).ToString.ToEntero
- End If
- End If
- End If
-
- 'SEGMENTO DE NEGOCIO
- Dim IdSegmentoNegocio As Integer = -1
- Dim drT As DataRow = GlobalDTSubProyectos(-1, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero).FiltroPrimero(String.Format("CveSubProyecto = {0} ", Row2("CveSubProyecto").ToString.ToEntero))
- If drT IsNot Nothing Then
- IdSegmentoNegocio = drT("IdSegNeg").ToString.ToEntero
- End If
-
- 'AGREGA MOVIMIENTO
- If importeMovimiento.RoundSQL <> 0 Then
- 'Conta ContPAQ
- If IdCtaContable = 0 Then
- CuentasContablesInvalidas.Append(" " & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 6))("ConceptoContable").ToString)
- idCuentaContabilizacion = 0
- End If
- 'Conta SIG
- If CveCuenta = 0 Then
- CuentasContablesInvalidasSIG.Append(" " & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 6))("ConceptoContable").ToString)
- CveCuentaContabilizacion = 0
- End If
-
- Dim tcvecon As Integer = 6
- Dim tidctacon As Integer = 6
- tidctacon = IdCtaContable
- If DdlTipoComprobante.SelectedValue = "Ant" Then
- tcvecon = 264
- tidctacon = ViewState("CtaProveedorAnticipos").ToString.ToEntero
- If DdlMoneda.SelectedValue = "2" Then
- tidctacon = ViewState("CtaProveedorAnticiposExtranjera").ToString.ToEntero
- End If
- End If
-
- Dim usacomplementariaProveedor As Boolean = False
- usacomplementariaProveedor = If(tipoCambioActual > 1 AndAlso UsuarioActual.CveEmpresa.Contiene(1, 119), True, False)
-
- If usacomplementariaProveedor AndAlso DdlTipoComprobante.SelectedValue = "Ant" Then
- 'importeMovimiento
-
- Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}"
- importeMN = tipoCambioActual * importeMovimiento - importeMovimiento
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, 266, Concepto, FechaMovimiento, tidctacon, IdSegmentoNegocio, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, CveClasificacion:=Row2("CveClasificacion").ToString.ToEntero, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero, ImporteMX:=importeMN, ImporteME:=importeMovimiento, CveCuenta:=CveCuenta, CveTipoGasto:=Row2("CveTipoGasto").ToString.ToEntero, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then
- ErrorPrepoliza = True
- End If
- importeMN = importeMovimiento
- End If
-
- Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}"
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, tcvecon, Concepto, FechaMovimiento, tidctacon, IdSegmentoNegocio, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, CveClasificacion:=Row2("CveClasificacion").ToString.ToEntero, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, CveTipoGasto:=Row2("CveTipoGasto").ToString.ToEntero, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then
- ErrorPrepoliza = True
- End If
-
-
-
-
-
- End If
-
- Next
- End If
- End If
-
-
- 'LIMPIA
- importeMovimiento = 0
- IdCtaContable = 0
- CveCuenta = 0
- End If
- Case 5 'Proveedores
- If Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") Then
-
- importeMovimiento = importeProv
- importeMN = importeMovimiento * tipoCambioActual * Multiplicador
-
If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}"
If tipoCambioActual = 1 Then
@@ -6391,387 +5514,1204 @@ Partial Class Compras_Compras
Else
IdCtaContable = CtaProveedorComplementaria
CveCuenta = CveCuentaProveedorComplementaria
- If importeMovimiento <> 0 AndAlso (IdCtaContable > 0 Or CveCuenta > 0 Or UsuarioActual.CveEmpresa = 119) Then 'Cuando tiene complementaria lo dividimos en dos Then
+ If importeMovimiento <> 0 AndAlso (IdCtaContable > 0 Or CveCuenta > 0) Then 'Cuando tiene complementaria lo dividimos en dos
importeMN = importeMovimiento
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, Referencia, 201, Concepto, FechaMovimiento, IdCtaContable, -1, CveIE, CveCompra:=CveCompra, CveProveedor:=CveProveedor, ImporteMX:=importeMovimiento * tipoCambioActual - importeMovimiento, ImporteME:=importeMovimiento, CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, Referencia, 201, Concepto, FechaMovimiento, IdCtaContable, -1, CveIE, CveProveedor:=CveProveedor, ImporteMX:=importeMovimiento * tipoCambioActual - importeMovimiento, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
ErrorPrepoliza = True
End If
End If
+
IdCtaContable = CtaProveedorExtranjera
CveCuenta = CveCuentaProveedorExtranjera
End If
- End If
- Case 59 'Documentos
- importeMovimiento = importeCreditos
- importeMN = importeMovimiento * tipoCambioActual * Multiplicador
- If ObjConta.GetRetCuenta(ConceptoContable, CveProveedor) Then
- If ObjConta.DtResultados.Rows.Count > 0 Then
- If ObjConta.DtResultados.Rows.Count > 0 Then
- IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCtaContable").ToString.ToEntero
- CveCuenta = ObjConta.DtResultados.Rows(0)("IdCtaContableSIG").ToString.ToEntero
- End If
- End If
- End If
+ Case 30 'Bancos
+ importeMovimiento = importeBanco + importeCajaChica 'Uno de los dos debe ser 0
+ importeMN = importeMovimiento * tipoCambioPago * Multiplicador
+ IdCtaContable = IdCuentaBancaria
+ CveCuenta = CveCuentaBancaria
+ If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioPago} ${importeMovimiento.FormatoNumero(2)}"
+ '' falta complementaria
- Case 37 'Deudores
- If RBLTipoDeudor.SelectedValue.ToEntero = 1 Then
- For Each rw As GridViewRow In GvDeudores.Rows
- If rw.FCCheckBox("Chk").Checked Then
- importeMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal
- importeMN = importeMovimiento * tipoCambioActual * Multiplicador
- IdCtaContable = CtaProveedorDeudores
- CveCuenta = CveCuentaProveedorDeudores
-
- 'Conta ContPAQ
- If IdCtaContable = 0 Then
- CuentasContablesInvalidas.Append(" " & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString)
- idCuentaContabilizacion = 0
- End If
- 'Conta SIG
- If CveCuenta = 0 Then
- CuentasContablesInvalidasSIG.Append(" " & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString)
- CveCuentaContabilizacion = 0
- End If
-
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=rw.DataKey("CveIE").ToString.ToEntero, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
- ErrorPrepoliza = True
- End If
- End If
- Next
- Else
- For Each rw As GridViewRow In GvDeudores.Rows
- If rw.FCCheckBox("Chk").Checked Then
- importeMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal
- importeMN = importeMovimiento * tipoCambioActual * Multiplicador
- IdCtaContable = CtaProveedorDeudores
- CveCuenta = CveCuentaProveedorDeudores
-
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, 254, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveIE:=rw.DataKey("CveIE").ToString.ToEntero, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
- ErrorPrepoliza = True
- End If
- End If
- Next
- End If
-
- importeMovimiento = 0
-
- Case 41 'Acreedores
- importeMovimiento = importeAcreedores
- importeMN = importeMovimiento * tipoCambioActual * Multiplicador
-
- IdCtaContable = CtaProveedorAcreedores
- CveCuenta = CveCuentaProveedorAcreedores
-
- Case 42 'Acreedores
- importeMovimiento = importeAcreedoresTarjeta
- importeMN = importeMovimiento * tipoCambioActual * Multiplicador
- IdCtaContable = CtaProveedorAcreedores
- CveCuenta = CveCuentaProveedorAcreedores
-
- Case 18 'NC - Notas de Credito
- importeMovimiento = importeNC
- importeMN = importeMovimiento * tipoCambioActual * Multiplicador
- If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}"
- IdCtaContable = CtaProveedor
- CveCuenta = CveCuentaProveedor
- If DdlMoneda.SelectedValue.ToEntero <> 1 And UsuarioActual.CveEmpresa.Contiene(119) Then
- IdCtaContable = CtaProveedorExtranjera
- CveCuenta = CveCuentaProveedorExtranjera
- End If
-
- If importeMovimiento <> 0 Then
- GuardoConcepto18 = True
- If DdlMoneda.SelectedValue.ToEntero <> 1 And UsuarioActual.CveEmpresa.Contiene(119) Then
-
- 'PROVISION
- IdCtaContable = CtaProveedorExtranjera
- CveCuenta = CveCuentaProveedorExtranjera
- If ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMovimiento, Referencia, ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimiento, ImporteME:=importeMovimiento, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
- IdCtaContable = CtaProveedorComplementaria
- CveCuenta = CveCuentaProveedorComplementaria
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMN - importeMovimiento, Referencia, 234, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMN - importeMovimiento, ImporteME:=importeMovimiento, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
- ErrorPrepoliza = True
- Exit Select
- End If
+ Case 19 'IVA Acreditable
+ If UsuarioActual.Empresa.Funcionalidad(521) = "1" Then
+ If importePagoProv = importeProv Then
+ importeMovimiento = TxtIVA.Text.ToDecimal
Else
- ErrorPrepoliza = True
- Exit Select
+ importeMovimiento = 0
End If
-
- 'AMORTIZACIÓN EN EL REGISTRO
- For Each Gvr As GridViewRow In GvFacturaNC.Rows
- If Gvr.FCCheckBox("ChkFacturaNC").Checked Then
- Dim CvePrePolizaTemp = ObjConta.AddPrePolizas("Compras/Registrar-NC", If(EsContado And CvePlantillaPrePoliza = 1, 2, CvePlantillaPrePoliza), ImporteCompra, TxtTotal.Text.ToDouble, DdlMoneda.SelectedValue.ToEntero, TxtFecha.Text.ToDate, ConceptoPoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, FolioFijo:=FolioFijo, ReglaFolioPoliza:=ObjCompras.ObtenerReglaFolio(DdlTipoTransaccion.SelectedValue, DdlTipoTransaccionCaja.SelectedValue, UsuarioActual.CveEmpresa), CveTipoPoliza:=ObjConta.ObtenerTipoPoliza(DdlTipoTransaccion.SelectedValue, DdlTipoTransaccionCaja.SelectedValue, UsuarioActual.CveEmpresa))
- Dim importeMovimientoNC = Gvr.FCTextBox("TxtImporte").Text.ToDecimal
- Dim importeMNNC = importeMovimientoNC * tipoCambioActual * Multiplicador
- Dim TipoCambioFactura = Gvr.DataKey("TipoCambio").ToDecimal
-
- IdCtaContable = CtaProveedorExtranjera
- CveCuenta = CveCuentaProveedorExtranjera
- If ObjConta.AddPrePolizasDetalle(CvePrePolizaTemp, False, importeMovimientoNC, Referencia, 17, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=Gvr.DataKey("CveCompra").ToEntero, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimientoNC, ImporteME:=importeMovimientoNC, TipoCambio:=TipoCambioFactura, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
- IdCtaContable = CtaProveedorComplementaria
- CveCuenta = CveCuentaProveedorComplementaria
- If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaTemp, False, importeMNNC - importeMovimientoNC, Referencia, 206, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=Gvr.DataKey("CveCompra").ToEntero, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMNNC - importeMovimientoNC, ImporteME:=importeMovimientoNC, TipoCambio:=TipoCambioFactura, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
- ErrorPrepoliza = True
- Exit For
- End If
- Else
- ErrorPrepoliza = True
- Exit For
- End If
-
-
- importeMNNC = importeMovimientoNC * TipoCambioFactura * Multiplicador
- IdCtaContable = CtaProveedorExtranjera
- CveCuenta = CveCuentaProveedorExtranjera
- If ObjConta.AddPrePolizasDetalle(CvePrePolizaTemp, True, importeMovimientoNC, Referencia, 60, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveCompraAmortizacion:=Gvr.DataKey("CveCompra").ToEntero, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimientoNC, ImporteME:=importeMovimientoNC, TipoCambio:=tipoCambioActual, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
- IdCtaContable = CtaProveedorComplementaria
- CveCuenta = CveCuentaProveedorComplementaria
- If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaTemp, True, importeMNNC - importeMovimientoNC, Referencia, 235, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveCompraAmortizacion:=Gvr.DataKey("CveCompra").ToEntero, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMNNC - importeMovimientoNC, ImporteME:=importeMovimientoNC, TipoCambio:=tipoCambioActual, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
- ErrorPrepoliza = True
- Exit For
- End If
- Else
- ErrorPrepoliza = True
- Exit For
- End If
-
- ' FLUCTUACION CAMBIARIA
- If tipoCambioActual <> TipoCambioFactura Then
- importeMovimiento = (importeMovimientoNC * TipoCambioFactura) - (importeMovimientoNC * tipoCambioActual)
-
- If importeMovimiento > 0 Then
- ConceptoContable = 64
- TipoMovimiento = True
- IdCtaContable = UsuarioActual.Empresa.IdCuentaGananciaCambiaria
- CveCuenta = UsuarioActual.Empresa.CveCuentaGananciaCambiaria
- ElseIf importeMovimiento < 0 Then
- ConceptoContable = 65
- TipoMovimiento = False
- IdCtaContable = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria
- CveCuenta = UsuarioActual.Empresa.CveCuentaPerdidaCambiaria
- End If
-
- importeMovimiento = importeMovimiento.Abs.RoundSQL()
- importeMN = importeMovimiento
- If importeMovimiento <> 0 Then
- If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaTemp, TipoMovimiento, importeMovimiento, Concepto, ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=importeMN, CvePrePolizaOriginal:=CvePrePoliza, ImporteME:=0, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
- ErrorPrepoliza = True
- Exit For
- End If
- End If
- End If
-
-
- ObjConta.PrePolizaUnificacion(CvePrePoliza, CvePrePolizaTemp)
- End If
- Next
-
- If ErrorPrepoliza Then
- Exit Select
- End If
-
Else
- IdCtaContable = CtaProveedor
- CveCuenta = CveCuentaProveedor
+ importeMovimiento = importeIVAAcreditable
+ End If
- If ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMovimiento, Referencia, ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
- For Each Gvr As GridViewRow In GvFacturaNC.Rows
- If Gvr.FCCheckBox("ChkFacturaNC").Checked Then
- Dim CvePrePolizaTemp = ObjConta.AddPrePolizas("Compras/Registrar", If(EsContado And CvePlantillaPrePoliza = 1, 2, CvePlantillaPrePoliza), ImporteCompra, TxtTotal.Text.ToDouble, DdlMoneda.SelectedValue.ToEntero, TxtFecha.Text.ToDate, ConceptoPoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, FolioFijo:=FolioFijo, ReglaFolioPoliza:=ObjCompras.ObtenerReglaFolio(DdlTipoTransaccion.SelectedValue, DdlTipoTransaccionCaja.SelectedValue, UsuarioActual.CveEmpresa), CveTipoPoliza:=ObjConta.ObtenerTipoPoliza(DdlTipoTransaccion.SelectedValue, DdlTipoTransaccionCaja.SelectedValue, UsuarioActual.CveEmpresa))
- Dim importeMovimientoNC = Gvr.FCTextBox("TxtImporte").Text.ToDecimal
- Dim importeMNNC = importeMovimientoNC * tipoCambioActual * Multiplicador
- If ObjConta.AddPrePolizasDetalle(CvePrePolizaTemp, False, importeMovimientoNC, Referencia, 272, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=Gvr.DataKey("CveCompra").ToEntero, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMNNC, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimientoNC), CveCompraAmortizacion:=CveCompra, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
- If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaTemp, True, importeMovimientoNC, Referencia, 60, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveCompraAmortizacion:=Gvr.DataKey("CveCompra").ToEntero, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMNNC, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimientoNC), CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
- ErrorPrepoliza = True
+ importeMN = Math.Round(importeMovimiento, 2) * tipoCambioPago * Multiplicador
+
+ PorcentajeImpuesto = PorcentajeIVA
+ IdCtaContable = If(IdCtaIVAAcreditable > 0, IdCtaIVAAcreditable, 0)
+
+ If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) And Not IdCtaContable > 0 Then
+ If ObjConta.DtResultados.Rows.Count > 0 Then
+ IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaIVAAcreditable").ToString.ToEntero
+ CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaIVAAcreditableSIG").ToString.ToEntero
+ End If
+ End If
+
+ 'Agregamos el Opuesto del 19 -> 14
+ If importeMovimiento <> 0 Then
+ Dim IdCtaIva As Integer = 0
+ Dim CveCuentaIVA As Integer = 0
+ IdCtaIva = If(IdCtaIVAXAcreditar > 0, IdCtaIVAXAcreditar, 0)
+
+ If ObjConta.GetRetCuenta(14, UsuarioActual.CveEmpresa) And Not IdCtaIva > 0 Then
+ If ObjConta.DtResultados.Rows.Count > 0 Then
+ IdCtaIva = ObjConta.DtResultados.Rows(0)("IdCuentaIVAxAcreditar").ToString.ToEntero
+ CveCuentaIVA = ObjConta.DtResultados.Rows(0)("IdCuentaIVAxAcreditarSIG").ToString.ToEntero
+ End If
+ End If
+
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, importeMovimiento, Referencia, 14, Concepto + If(tipoCambioActual > 1, $" TC: {tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}", ""), FechaMovimiento, IdCtaIva, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimiento * tipoCambioActual, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuentaIVA, PorcentajeImpuesto:=PorcentajeImpuesto, Contabilizable:=SeContabiliza) Then
+ ErrorPrepoliza = True
+ End If
+ End If
+
+ If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioPago} ${importeMovimiento.FormatoNumero(2)}"
+ Case 14 'IVA X Acreditar
+ importeMovimiento = importeIVAxAcreditar
+ importeMN = Math.Round(importeMovimiento, 2) * tipoCambioActual * Multiplicador
+ If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}"
+ PorcentajeImpuesto = PorcentajeIVA
+ IdCtaContable = If(IdCtaIVAXAcreditar > 0, IdCtaIVAXAcreditar, 0)
+ If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) And Not IdCtaContable > 0 Then
+ If ObjConta.DtResultados.Rows.Count > 0 Then
+ IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaIVAxAcreditar").ToString.ToEntero
+ CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaIVAxAcreditarSIG").ToString.ToEntero
+ End If
+ End If
+ Case 25 'IEPS X Acreditar
+ If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then
+ importeMovimiento = ImporteIEPSxAcreditar
+ importeMN = Math.Round(importeMovimiento, 2) * tipoCambioActual * Multiplicador
+ If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}"
+ If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
+ If ObjConta.DtResultados.Rows.Count > 0 Then
+ IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaIEPSxAcreditar").ToString.ToEntero
+ CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaIEPSxAcreditarSIG").ToString.ToEntero
+ End If
+ End If
+ End If
+
+ Case 224 'Otros impuestos
+ If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then
+ importeMovimiento = OtrosImpuestos
+ importeMN = Math.Round(importeMovimiento, 2) * tipoCambioActual * Multiplicador
+ If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}"
+ IdCtaContable = If(UsuarioActual.CveEmpresa = 119, 1171, -1)
+ CveCuenta = -1
+ End If
+ Case 26 'IEPS Acreditable
+ If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then
+ importeMovimiento = ImporteIEPSAcreditable
+ importeMN = Math.Round(importeMovimiento, 2) * tipoCambioPago * Multiplicador
+ If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
+ If ObjConta.DtResultados.Rows.Count > 0 Then
+ IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaIEPSAcreditable").ToString.ToEntero
+ CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaIEPSAcreditableSIG").ToString.ToEntero
+ End If
+ End If
+
+ 'Agregamos el Opuesto del 26 -> 25
+ If importeMovimiento <> 0 Then
+ Dim IdCtaIEPS As Integer = 0
+ Dim CveCuentaIEPS As Integer = 0
+ If ObjConta.GetRetCuenta(25, UsuarioActual.CveEmpresa) Then
+ If ObjConta.DtResultados.Rows.Count > 0 Then
+ IdCtaIEPS = ObjConta.DtResultados.Rows(0)("IdCuentaIEPSxAcreditar").ToString.ToEntero
+ CveCuentaIEPS = ObjConta.DtResultados.Rows(0)("IdCuentaIEPSxAcreditarSIG").ToString.ToEntero
+ End If
+ End If
+
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, importeMovimiento, Referencia, 25, Concepto + If(tipoCambioActual > 1, $" TC: {tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}", ""), FechaMovimiento, IdCtaIEPS, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimiento * tipoCambioActual, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuentaIEPS, Contabilizable:=SeContabiliza) Then
+ ErrorPrepoliza = True
+ End If
+ End If
+
+ If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioPago} ${importeMovimiento.FormatoNumero(2)}"
+
+ End If
+ Case 22 'RetIVA Acreditable Honorarios/Serv. Prof.
+ If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then
+ If DdlRetIVAConcepto.Items.Count > 0 Then
+ If DdlRetIVAConcepto.SelectedValue.ToEntero = 1 Then
+ importeMovimiento = importeRetIVAAcreditable
+ importeMN = Math.Round(importeMovimiento, 2) * tipoCambioPago * Multiplicador
+ If CtaProveedorRetIVA > 0 Then
+ IdCtaContable = CtaProveedorRetIVA
+ CveCuenta = CveCuentaProveedorRetIVA
+ ElseIf UsuarioActual.Empresa.Funcionalidad(308).ToEntero > 0 Then
+ IdCtaContable = UsuarioActual.Empresa.Funcionalidad(308).ToEntero
+ Else
+ If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
+ If ObjConta.DtResultados.Rows.Count > 0 Then
+ IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero
+ CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero
End If
- Else
+ End If
+ End If
+
+ 'Agregamos el Opuesto del 22 -> 15
+ If importeMovimiento <> 0 Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, importeMovimiento, Referencia, 15, Concepto + If(tipoCambioActual > 1, $" TC: {tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}", ""), FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimiento * tipoCambioActual, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
+ ErrorPrepoliza = True
+ End If
+ End If
+
+ If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioPago} ${importeMovimiento.FormatoNumero(2)}"
+ End If
+ End If
+ End If
+ Case 15 'RetIVA X Acreditar Honorarios/Serv. Prof.
+ If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then
+ If DdlRetIVAConcepto.Items.Count > 0 Then
+ If DdlRetIVAConcepto.SelectedValue.ToEntero = 1 Then
+ importeMovimiento = importeRetIVAxAcreditar
+ importeMN = Math.Round(importeMovimiento, 2) * tipoCambioActual * Multiplicador
+ If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}"
+ If CtaProveedorRetIVA > 0 Then
+ IdCtaContable = CtaProveedorRetIVA
+ CveCuenta = CveCuentaProveedorRetIVA
+ ElseIf UsuarioActual.Empresa.Funcionalidad(307).ToEntero > 0 Then
+ IdCtaContable = UsuarioActual.Empresa.Funcionalidad(307).ToEntero
+ Else
+ If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
+ If ObjConta.DtResultados.Rows.Count > 0 Then
+ IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero
+ CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero
+ End If
+ End If
+ End If
+ End If
+ End If
+ End If
+ Case 184 'RetIVA Acreditable Fletes P.F
+ If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then
+ If DdlRetIVAConcepto.Items.Count > 0 Then
+ If DdlRetIVAConcepto.SelectedValue.ToEntero = 2 Then
+ importeMovimiento = importeRetIVAAcreditable
+ importeMN = Math.Round(importeMovimiento, 2) * tipoCambioPago * Multiplicador
+ If CtaProveedorRetIVA > 0 Then
+ IdCtaContable = CtaProveedorRetIVA
+ CveCuenta = CveCuentaProveedorRetIVA
+ ElseIf UsuarioActual.Empresa.Funcionalidad(310).ToEntero > 0 Then
+ IdCtaContable = UsuarioActual.Empresa.Funcionalidad(310).ToEntero
+ Else
+ If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
+ If ObjConta.DtResultados.Rows.Count > 0 Then
+ IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero
+ CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero
+ End If
+ End If
+ End If
+
+ 'Agregamos el Opuesto del 184 -> 183
+ If importeMovimiento <> 0 Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, importeMovimiento, Referencia, 183, Concepto + If(tipoCambioActual > 1, $" TC: {tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}", ""), FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimiento * tipoCambioActual, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
+ ErrorPrepoliza = True
+ End If
+ End If
+
+ If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioPago} ${importeMovimiento.FormatoNumero(2)}"
+ End If
+ End If
+ End If
+ Case 183 'RetIVA X Acreditar Fletes P.F
+ If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then
+ If DdlRetIVAConcepto.Items.Count > 0 Then
+ If DdlRetIVAConcepto.SelectedValue.ToEntero = 2 Then
+ importeMovimiento = importeRetIVAxAcreditar
+ importeMN = Math.Round(importeMovimiento, 2) * tipoCambioActual * Multiplicador
+ If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}"
+ If CtaProveedorRetIVA > 0 Then
+ IdCtaContable = CtaProveedorRetIVA
+ CveCuenta = CveCuentaProveedorRetIVA
+ ElseIf UsuarioActual.Empresa.Funcionalidad(309).ToEntero > 0 Then
+ IdCtaContable = UsuarioActual.Empresa.Funcionalidad(309).ToEntero
+ Else
+ If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
+ If ObjConta.DtResultados.Rows.Count > 0 Then
+ IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero
+ CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero
+ End If
+ End If
+ End If
+ End If
+ End If
+ End If
+ Case 248 'RetIVA X Acreditar Arrendamiento
+ If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then
+ If DdlRetIVAConcepto.Items.Count > 0 AndAlso DdlRetIVAConcepto.SelectedValue.ToEntero = 4 Then
+ importeMovimiento = importeRetIVAxAcreditar
+ importeMN = Math.Round(importeMovimiento, 2) * tipoCambioActual * Multiplicador
+ If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}"
+ If CtaProveedorRetIVA > 0 Then
+ IdCtaContable = CtaProveedorRetIVA
+ CveCuenta = CveCuentaProveedorRetIVA
+ ElseIf UsuarioActual.Empresa.Funcionalidad(313).ToEntero > 0 Then
+ IdCtaContable = UsuarioActual.Empresa.Funcionalidad(313).ToEntero
+ Else
+ If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
+ If ObjConta.DtResultados.Rows.Count > 0 Then
+ IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero
+ CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero
+ End If
+ End If
+ End If
+
+ End If
+ End If
+ Case 186 'RetIVA Acreditable Fletes P.M.
+ If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then
+ If DdlRetIVAConcepto.Items.Count > 0 Then
+ If DdlRetIVAConcepto.SelectedValue.ToEntero = 3 Then
+ importeMovimiento = importeRetIVAAcreditable
+ importeMN = Math.Round(importeMovimiento, 2) * tipoCambioPago * Multiplicador
+ If CtaProveedorRetIVA > 0 Then
+ IdCtaContable = CtaProveedorRetIVA
+ CveCuenta = CveCuentaProveedorRetIVA
+ ElseIf UsuarioActual.Empresa.Funcionalidad(312).ToEntero > 0 Then
+ IdCtaContable = UsuarioActual.Empresa.Funcionalidad(312).ToEntero
+ Else
+ If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
+ If ObjConta.DtResultados.Rows.Count > 0 Then
+ IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero
+ CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero
+ End If
+ End If
+ End If
+
+ 'Agregamos el Opuesto del 186 -> 185
+ If importeMovimiento <> 0 Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, importeMovimiento, Referencia, 185, Concepto + If(tipoCambioActual > 1, $" TC: {tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}", ""), FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimiento * tipoCambioActual, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
+ ErrorPrepoliza = True
+ End If
+ End If
+
+ If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioPago} ${importeMovimiento.FormatoNumero(2)}"
+ End If
+ End If
+ End If
+ Case 185 'RetIVA X Acreditar Fletes P.M.
+ If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then
+ If DdlRetIVAConcepto.Items.Count > 0 Then
+ If DdlRetIVAConcepto.SelectedValue.ToEntero = 3 Then
+ importeMovimiento = importeRetIVAxAcreditar
+ importeMN = Math.Round(importeMovimiento, 2) * tipoCambioActual * Multiplicador
+ If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}"
+ If CtaProveedorRetIVA > 0 Then
+ IdCtaContable = CtaProveedorRetIVA
+ CveCuenta = CveCuentaProveedorRetIVA
+ ElseIf UsuarioActual.Empresa.Funcionalidad(311).ToEntero > 0 Then
+ IdCtaContable = UsuarioActual.Empresa.Funcionalidad(311).ToEntero
+ Else
+ If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
+ If ObjConta.DtResultados.Rows.Count > 0 Then
+ IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero
+ CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero
+ End If
+ End If
+ End If
+ End If
+ End If
+ End If
+ Case 249 'RetIVA Acreditable Arrendamiento
+ If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then
+ If DdlRetIVAConcepto.Items.Count > 0 AndAlso DdlRetIVAConcepto.SelectedValue.ToEntero = 4 Then
+ importeMovimiento = importeRetIVAAcreditable
+ importeMN = Math.Round(importeMovimiento, 2) * tipoCambioPago * Multiplicador
+ If CtaProveedorRetIVA > 0 Then
+ IdCtaContable = CtaProveedorRetIVA
+ CveCuenta = CveCuentaProveedorRetIVA
+ ElseIf UsuarioActual.Empresa.Funcionalidad(314).ToEntero > 0 Then
+ IdCtaContable = UsuarioActual.Empresa.Funcionalidad(314).ToEntero
+ Else
+ If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
+ If ObjConta.DtResultados.Rows.Count > 0 Then
+ IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero
+ CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero
+ End If
+ End If
+ End If
+
+ If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioPago} ${importeMovimiento.FormatoNumero(2)}"
+ End If
+
+ End If
+ Case 23 'RetISR Acreditable
+ If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then
+ If DdlRetISRConcepto.Items.Count > 0 AndAlso DdlRetISRConcepto.SelectedValue.ToEntero = 1 Then
+ importeMovimiento = importeRetISRAcreditable
+ importeMN = Math.Round(importeMovimiento, 2) * tipoCambioPago * Multiplicador
+ If CtaProveedorRetISR > 0 Then
+ IdCtaContable = CtaProveedorRetISR
+ CveCuenta = CveCuentaProveedorRetISR
+ ElseIf UsuarioActual.Empresa.Funcionalidad(316).ToEntero > 0 Then
+ IdCtaContable = UsuarioActual.Empresa.Funcionalidad(316).ToEntero
+ Else
+ If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
+ If ObjConta.DtResultados.Rows.Count > 0 Then
+ IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetISRCirculacion").ToString.ToEntero
+ CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetISRCirculacionSIG").ToString.ToEntero
+ End If
+ End If
+ End If
+
+ 'Agregamos el Opuesto del 23 -> 16
+ If importeMovimiento <> 0 Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, importeMovimiento, Referencia, 15, Concepto + If(tipoCambioActual > 1, $" TC: {tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}", ""), FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimiento * tipoCambioActual, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
+ ErrorPrepoliza = True
+ End If
+ End If
+
+ If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioPago} ${importeMovimiento.FormatoNumero(2)}"
+ End If
+ End If
+ Case 16 'Ret ISR X Acreditar
+ If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then
+ If DdlRetISRConcepto.Items.Count > 0 AndAlso DdlRetISRConcepto.SelectedValue.ToEntero = 1 Then
+ importeMovimiento = importeRetISRxAcreditar
+ importeMN = Math.Round(importeMovimiento, 2) * tipoCambioActual * Multiplicador
+ If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}"
+ If CtaProveedorRetISR > 0 Then
+ IdCtaContable = CtaProveedorRetISR
+ CveCuenta = CveCuentaProveedorRetISR
+ ElseIf UsuarioActual.Empresa.Funcionalidad(315).ToEntero > 0 Then
+ IdCtaContable = UsuarioActual.Empresa.Funcionalidad(315).ToEntero
+ Else
+ If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
+ If ObjConta.DtResultados.Rows.Count > 0 Then
+ IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetISRCirculacion").ToString.ToEntero
+ CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetISRCirculacionSIG").ToString.ToEntero
+ End If
+ End If
+ End If
+ End If
+ End If
+ Case 243 'RetISR X Acreditar Terceros y Arrendamiento
+ If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then
+ If DdlRetISRConcepto.Items.Count > 0 AndAlso DdlRetISRConcepto.SelectedValue.ToEntero = 2 Then
+ importeMovimiento = importeRetISRxAcreditar
+ importeMN = Math.Round(importeMovimiento, 2) * tipoCambioPago * Multiplicador
+ If CtaProveedorRetISR > 0 Then
+ IdCtaContable = CtaProveedorRetISR
+ CveCuenta = CveCuentaProveedorRetISR
+ ElseIf UsuarioActual.Empresa.Funcionalidad(317).ToEntero > 0 Then
+ IdCtaContable = UsuarioActual.Empresa.Funcionalidad(317).ToEntero
+ Else
+ If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
+ If ObjConta.DtResultados.Rows.Count > 0 Then
+ IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetISRCirculacion").ToString.ToEntero
+ CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetISRCirculacionSIG").ToString.ToEntero
+ End If
+ End If
+ End If
+
+ If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioPago} ${importeMovimiento.FormatoNumero(2)}"
+ End If
+ End If
+ Case 244 'RetISR Acreditable Terceros y Arrendamiento
+ If Not DdlTipoComprobante.SelectedValue.Contiene("Ant") Then
+ If DdlRetISRConcepto.Items.Count > 0 AndAlso DdlRetISRConcepto.SelectedValue.ToEntero = 2 Then
+ importeMovimiento = importeRetISRAcreditable
+ importeMN = Math.Round(importeMovimiento, 2) * tipoCambioPago * Multiplicador
+ If CtaProveedorRetISR > 0 Then
+ IdCtaContable = CtaProveedorRetISR
+ CveCuenta = CveCuentaProveedorRetISR
+ ElseIf UsuarioActual.Empresa.Funcionalidad(318).ToEntero > 0 Then
+ IdCtaContable = UsuarioActual.Empresa.Funcionalidad(318).ToEntero
+ Else
+ If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
+ If ObjConta.DtResultados.Rows.Count > 0 Then
+ IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetISRCirculacion").ToString.ToEntero
+ CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetISRCirculacionSIG").ToString.ToEntero
+ End If
+ End If
+ End If
+ 'Agregamos el Opuesto del 244 -> 243
+ If importeMovimiento <> 0 Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, importeMovimiento, Referencia, 243, Concepto + If(tipoCambioActual > 1, $" TC: {tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}", ""), FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimiento * tipoCambioActual, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
+ ErrorPrepoliza = True
+ End If
+ End If
+ If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioPago} ${importeMovimiento.FormatoNumero(2)}"
+ End If
+ End If
+ Case 64 'Ganancia
+ If tipoCambioActual <> 1 AndAlso TxtFechaPago.Text <> TxtFecha.Text Then
+ IdCtaContable = UsuarioActual.Empresa.IdCuentaGananciaCambiaria
+ CveCuenta = UsuarioActual.Empresa.CveCuentaGananciaCambiaria
+ If tipoCambioPago < tipoCambioActual Then
+ importeMovimiento = Math.Abs(tipoCambioPago - tipoCambioActual) * importePagoProv
+ importeMovimiento -= Math.Abs(tipoCambioPago - tipoCambioActual) * importeIVAAcreditable
+ importeMovimiento += Math.Abs(tipoCambioPago - tipoCambioActual) * importeRetIVAAcreditable
+ importeMovimiento += Math.Abs(tipoCambioPago - tipoCambioActual) * importeRetISRAcreditable
+ importeMN = importeMovimiento
+ End If
+ Else
+ importeMovimiento = 0
+ End If
+
+ Case 65 'Perdida
+ If tipoCambioActual <> 1 AndAlso TxtFechaPago.Text <> TxtFecha.Text Then
+ IdCtaContable = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria
+ CveCuenta = UsuarioActual.Empresa.CveCuentaPerdidaCambiaria
+ If tipoCambioActual < tipoCambioPago Then
+ importeMovimiento = Math.Abs(tipoCambioPago - tipoCambioActual) * importePagoProv
+ importeMovimiento -= Math.Abs(tipoCambioPago - tipoCambioActual) * importeIVAAcreditable
+ importeMovimiento += Math.Abs(tipoCambioPago - tipoCambioActual) * importeRetIVAAcreditable
+ importeMovimiento += Math.Abs(tipoCambioPago - tipoCambioActual) * importeRetISRAcreditable
+ importeMN = importeMovimiento
+ End If
+ Else
+ importeMovimiento = 0
+ End If
+
+ Case 6 'Compra
+
+ If RBLPago.SelectedValue.ToEntero = 4 Then
+ Exit Select 'Es credito el concepto 6 se agrega en CASE 17
+ End If
+
+ If Not CveCompraRefacturacion > 0 OrElse ChkRefacNC.Checked Then
+ 'AF TipoAF 2 Es para las compras
+ DT = TmpDT.FiltraParametros("ISNULL(TipoAF,0) = 2 AND ISNULL(AplicaCostoIndirecto,0) <> 1")
+ If DT.Rows.Count > 0 AndAlso Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") Then
+ For Each Row2 As DataRow In DT.Rows
+ importeMovimiento = If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, Row2("ImporteSinImpuestos").ToString.ToDecimal, Row2("Total").ToString.ToDecimal)
+ importeMN = importeMovimiento * tipoCambioActual * Multiplicador
+ If ObjConta.GetRetCuenta(49, Row2("CveActivoFijo").ToString.ToEntero) Then
+ If ObjConta.DtResultados.Rows.Count > 0 Then
+ IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCtaContActivoFijo").ToString.ToEntero
+ CveCuenta = ObjConta.DtResultados.Rows(0)("IdCtaContActivoFijoSIG").ToString.ToEntero
+ End If
+ End If
+
+ If importeMovimiento <> 0 Then
+ 'Conta ContPAQ
+ If IdCtaContable = 0 Then
+ CuentasContablesInvalidas.Append(" " & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 49))("ConceptoContable").ToString)
+ idCuentaContabilizacion = 0
+ End If
+ 'Conta SIG
+ If CveCuenta = 0 Then
+ CuentasContablesInvalidasSIG.Append(" " & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 49))("ConceptoContable").ToString)
+ CveCuentaContabilizacion = 0
+ End If
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Row2("CodAF").ToString, 49, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveActivoFijo:=Row2("CveActivoFijo").ToString.ToEntero, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then
ErrorPrepoliza = True
End If
- ObjConta.PrePolizaUnificacion(CvePrePoliza, CvePrePolizaTemp)
End If
Next
End If
- End If
- End If
- importeMovimiento = 0
+ 'LIMPIA
+ importeMovimiento = 0
+ IdCtaContable = 0
+ CveCuenta = 0
- Case 29 'Funcionarios y Empleados
- importeMovimiento = importeFE
- importeMN = importeMovimiento * tipoCambioActual * Multiplicador
- If ObjConta.GetRetCuenta(ConceptoContable, CvePersonal) Then
- If ObjConta.DtResultados.Rows.Count > 0 Then
- IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCtaContPersonal").ToString.ToEntero
- CveCuenta = ObjConta.DtResultados.Rows(0)("IdCtaContPersonalSIG").ToString.ToEntero
- End If
- End If
-
- Case 21 'Anticipo
-
- If ArrAnticipos.Count > 0 Then
-
-
- Dim CtaIvaxAcreditar As Integer = 0
- Dim CtaIvaAcreditable As Integer = 0
- Dim CveCuentaIvaxAcreditar As Integer = 0
- Dim PorcentajeImpuestoAnticipo = PorcentajeIVA
- CtaIvaxAcreditar = If(IdCtaIVAXAcreditar > 0, IdCtaIVAXAcreditar, 0)
- CtaIvaAcreditable = If(IdCtaIVAAcreditable > 0, IdCtaIVAAcreditable, 0)
- If ObjConta.GetRetCuenta(14, UsuarioActual.CveEmpresa) And Not CtaIvaxAcreditar > 0 Then
- If ObjConta.DtResultados.Rows.Count > 0 Then
- CtaIvaxAcreditar = ObjConta.DtResultados.Rows(0)("IdCuentaIVAxAcreditar").ToString.ToEntero
- CveCuentaIvaxAcreditar = ObjConta.DtResultados.Rows(0)("IdCuentaIVAxAcreditarSIG").ToString.ToEntero
- End If
- End If
- If ObjConta.GetRetCuenta(19, UsuarioActual.CveEmpresa) And Not CtaIvaAcreditable > 0 Then
- If ObjConta.DtResultados.Rows.Count > 0 Then
- CtaIvaAcreditable = ObjConta.DtResultados.Rows(0)("IdCuentaIVAAcreditable").ToString.ToEntero
- End If
- End If
-
- '** PRUEBA CUANDO SE AMORTIZA NC ANTES DE QUE SE REGISTRE NO DEBE TENER CONCEPTO 19 ** JMURUAM 01/06/2017 SE HIZO ESTO PARA LA FACTURA HRFA-8012831 DE VIGILANCIA
- 'Dim CtaIvaAcreditable As Integer = 0
- 'If ObjConta.GetRetCuenta(19, UsuarioActual.CveEmpresa) Then
- ' If ObjConta.DtResultados.Rows.Count > 0 Then
- ' CtaIvaAcreditable = ObjConta.DtResultados.Rows(0)("IdCuentaIVAAcreditable").ToString.ToEntero
- ' End If
- 'End If
-
- For Each Ant As Anticipos In ArrAnticipos
-
- Dim ConceptoContableAnticipo, ConceptoContableAnticipoComplementaria As Integer
- Dim CveCompraNC As Integer = CveCompra
-
- Select Case Ant.TipoMovto
- Case "NC", "DEV"
- ConceptoContableAnticipo = 60
- ConceptoContableAnticipoComplementaria = 235
- CveCompraNC = Ant.CveCompra 'cuando es NC, se utiliza la clave de compra de la nota de credito
- IdCtaContable = CtaProveedor
- CveCuenta = CveCuentaProveedor
- Case "Egsc"
- ConceptoContableAnticipo = 21
- IdCtaContable = CtaProveedorAnticipos
- CveCuenta = CveCuentaProveedorAnticipos
-
- Case "DD"
- ConceptoContableAnticipo = 37
- IdCtaContable = CtaProveedorDeudores
- CveCuenta = CveCuentaProveedorDeudores
- Case "Ant"
- ConceptoContableAnticipo = 265
- ConceptoContableAnticipoComplementaria = 266
- CveCompraNC = Ant.CveCompra
- IdCtaContable = CtaProveedorAnticipos
- CveCuenta = CveCuentaProveedorAnticipos
- End Select
-
- importeMovimiento = Ant.Importe
- importeMN = importeMovimiento * tipoCambioActual * Multiplicador
-
- If importeMovimiento <> 0 Then
- 'Conta ContPAQ
- If IdCtaContable = 0 Then
- CuentasContablesInvalidas.Append(" " & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString)
- idCuentaContabilizacion = 0
- End If
- 'Conta SIG
- If CveCuenta = 0 Then
- CuentasContablesInvalidas.Append(" " & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString)
- idCuentaContabilizacion = 0
- End If
-
- 'AMORTIZACIÓN NC ESPECIAL COMPLEMENTARIA
- If ConceptoContableAnticipo.Contiene(60) And DdlMoneda.SelectedValue.ToEntero <> 1 And UsuarioActual.CveEmpresa.Contiene(119) Then
- Dim importeMovimientoNC = Ant.Importe
- Dim importeMNNC = 0.0D
- Dim TipoCambioNC = Ant.TCCompra
-
- importeMNNC = importeMovimientoNC * TipoCambioNC * Multiplicador
- IdCtaContable = CtaProveedorExtranjera
- CveCuenta = CveCuentaProveedorExtranjera
- If ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimientoNC, Referencia, 60, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=Ant.CveCompra, CveCompraAmortizacion:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimientoNC, ImporteME:=importeMovimientoNC, TipoCambio:=TipoCambioNC, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
- IdCtaContable = CtaProveedorComplementaria
- CveCuenta = CveCuentaProveedorComplementaria
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMNNC - importeMovimientoNC, Referencia, 235, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=Ant.CveCompra, CveCompraAmortizacion:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMNNC - importeMovimientoNC, ImporteME:=importeMovimientoNC, TipoCambio:=TipoCambioNC, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
- ErrorPrepoliza = True
- Exit For
- End If
- Else
- ErrorPrepoliza = True
- Exit For
+ 'COSTO ALMACEN
+ Dim DtAlmacenes = GlobalDTAlmacen(UsuarioActual.CveEmpresa)
+ If UsuarioActual.Empresa.UsaInventarios AndAlso Not UsuarioActual.Empresa.Funcionalidad(126) = "1" Then
+ DT = TmpDT.FiltraParametros("ISNULL(TipoAF,0) <> 2 AND ISNULL(CveAlmacen,0) > 0", "", {"CveAlmacen"})
+ 'RECORREMOS PARA DETECTAR LA MODALIDAD DEL ALMACEN, EN CASO DE SER SOLO EXISTENCIA LIMPIAMOS CVEALMACEN
+ For Each Dr As DataRow In DT.Rows
+ If DtAlmacenes.FiltroPrimeroValor("Modalidad", $"CveAlmacen = {Dr("CveAlmacen").ToString.ToEntero}").ToString = "Solo Existencia" Then
+ Dr("CveAlmacen") = 0
End If
+ Dr.AcceptChanges()
+ Next
+ DT.AcceptChanges()
+ DT = DT.FiltraParametros("ISNULL(CveAlmacen,0) > 0")
+ If DT.Rows.Count > 0 AndAlso Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") Then
+ For Each Row2 As DataRow In DT.Rows
- importeMNNC = importeMovimientoNC * tipoCambioActual * Multiplicador
- IdCtaContable = CtaProveedorExtranjera
- CveCuenta = CveCuentaProveedorExtranjera
- If ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMovimientoNC, Referencia, 272, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimientoNC, ImporteME:=importeMovimientoNC, TipoCambio:=tipoCambioActual, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
- IdCtaContable = CtaProveedorComplementaria
- CveCuenta = CveCuentaProveedorComplementaria
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMNNC - importeMovimientoNC, Referencia, 206, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMNNC - importeMovimientoNC, ImporteME:=importeMovimientoNC, TipoCambio:=tipoCambioActual, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
- ErrorPrepoliza = True
- Exit For
+ importeMovimiento = TmpDT.SUM(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total"), $"CveAlmacen = {Row2("CveAlmacen")}").ToString.ToDecimal + TmpDT.SUM("CostoIndirectoAlmacen", $"CveAlmacen = {Row2("CveAlmacen")}").ToString.ToDecimal 'Row2("Total").ToString.ToDecimal + Row2("CostoIndirectoAlmacen").ToString.ToDecimal
+ importeMN = importeMovimiento * tipoCambioActual * Multiplicador
+ If ObjConta.GetRetCuenta(68, GvInv.HeaderRow.FCDropDownList("ddlAlmacen").SelectedValue.ToString.ToEntero) Then
+ If ObjConta.DtResultados.Rows.Count > 0 Then
+ IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCtaContable").ToString.ToEntero
+ CveCuenta = ObjConta.DtResultados.Rows(0)("IdCtaContableSIG").ToString.ToEntero
+ End If
End If
- Else
- ErrorPrepoliza = True
- Exit For
- End If
-
- ' FLUCTUACION CAMBIARIA
- If tipoCambioActual <> TipoCambioNC Then
- importeMovimiento = (importeMovimientoNC * tipoCambioActual) - (importeMovimientoNC * TipoCambioNC)
-
- If importeMovimiento > 0 Then
- ConceptoContable = 64
- TipoMovimiento = True
- IdCtaContable = UsuarioActual.Empresa.IdCuentaGananciaCambiaria
- CveCuenta = UsuarioActual.Empresa.CveCuentaGananciaCambiaria
- ElseIf importeMovimiento < 0 Then
- ConceptoContable = 65
- TipoMovimiento = False
- IdCtaContable = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria
- CveCuenta = UsuarioActual.Empresa.CveCuentaPerdidaCambiaria
- End If
-
- importeMovimiento = importeMovimiento.Abs.RoundSQL()
- importeMN = importeMovimiento
If importeMovimiento <> 0 Then
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Concepto, ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=importeMN, CvePrePolizaOriginal:=CvePrePoliza, ImporteME:=0, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
+ 'Conta ContPAQ
+ If IdCtaContable = 0 Then
+ CuentasContablesInvalidas.Append(" " & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 68))("ConceptoContable").ToString)
+ idCuentaContabilizacion = 0
+ End If
+ 'Conta SIG
+ If CveCuenta = 0 Then
+ CuentasContablesInvalidasSIG.Append(" " & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 68))("ConceptoContable").ToString)
+ CveCuentaContabilizacion = 0
+ End If
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, 68, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CvePersonal:=CvePersonal, CveMovimientoAlmacen:=CveMovimientoInventario, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then
+ ErrorPrepoliza = True
+ End If
+ End If
+ Next
+ End If
+ End If
+
+ 'LIMPIA
+ importeMovimiento = 0
+ IdCtaContable = 0
+ CveCuenta = 0
+
+ ''FLETES
+ 'If UsuarioActual.CveEmpresa.Contiene(119) And UsuarioActual.Empresa.UsaInventarios And DdlTipoComprobante.SelectedValue <> "NC" And Not UsuarioActual.Empresa.Funcionalidad(126) = "1" And CveConceptoContableAlmacen.Contiene(237, 240) Then
+
+ 'End If
+ Dim CostoIndirectoAcum176 As Decimal = 0
+ 'INV [MERCANCIA RECIBIDA POR ADELANTADO (OC) | MERCANCIA PENDIENTE POR RECIBIR (COMPRA) ]
+ If UsuarioActual.CveEmpresa.Contiene(1, 119) And UsuarioActual.Empresa.UsaInventarios And Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") And Not UsuarioActual.Empresa.Funcionalidad(126) = "1" And CveConceptoContableAlmacen.Contiene(205, 176, 237, 240) Then
+
+ importeMovimiento = TmpDT.SUM(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total"), $"ISNULL(TipoAF,0) <> 2 AND ISNULL(CveAlmacen,0) = 0 AND (ISNULL(CveTipoPS,0) = 2 OR (ISNULL(CveTipoPS,0) = 1 AND ISNULL(AplicaCostoIndirecto,0) = 1))").ToString.ToDecimal
+ importeMN = importeMovimiento * tipoCambioActual * Multiplicador
+
+ Dim ConceptoContabilizacion = 205
+ Dim ConceptoContabilizacionME = -1
+ Dim IdCtaContableME = -1
+ Dim ConceptoContabilizacionMEComp = -1
+ Dim IdCtaContableMEComp = -1
+
+ If OCVinculada Or CveConceptoContableAlmacen.Contiene(237, 240) Then
+ ConceptoContabilizacion = CveConceptoContableAlmacen
+ End If
+ Dim UsaComplementariaFleteImportaciones As Boolean = False
+
+ Select Case ConceptoContabilizacion
+ Case 176
+ ConceptoContabilizacionME = 228
+ ConceptoContabilizacionMEComp = 229
+ Case 205
+ ConceptoContabilizacionME = 230
+ ConceptoContabilizacionMEComp = 231
+ Case 237
+ ConceptoContabilizacionME = 238
+ ConceptoContabilizacionMEComp = 239
+ importeMovimiento = TmpDT.SUMD(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total"))
+ importeMN = importeMovimiento * tipoCambioActual * Multiplicador 'TIENE QUE TENER EL IMPORTEMN IGUAL AL IMPORTEMOVIMIENTO PORQUE NO TOMA EN CUENTA SI UN PRODUCTO ES TIPO SERVICIO
+ Case 240
+ ConceptoContabilizacionME = 241
+ ConceptoContabilizacionMEComp = 242
+ importeMovimiento = TmpDT.SUMD(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total"))
+ importeMN = importeMovimiento * tipoCambioActual * Multiplicador 'TIENE QUE TENER EL IMPORTEMN IGUAL AL IMPORTEMOVIMIENTO PORQUE NO TOMA EN CUENTA SI UN PRODUCTO ES TIPO SERVICIO
+ End Select
+
+ If ObjConta.GetRetCuenta(ConceptoContabilizacion, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then
+ IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCtaContable").ToString.ToEntero
+ End If
+
+ If ObjConta.GetRetCuenta(ConceptoContabilizacionME, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then
+ IdCtaContableME = ObjConta.DtResultados.Rows(0)("IdCtaContable").ToString.ToEntero
+ End If
+
+ If ObjConta.GetRetCuenta(ConceptoContabilizacionMEComp, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then
+ IdCtaContableMEComp = ObjConta.DtResultados.Rows(0)("IdCtaContable").ToString.ToEntero
+ End If
+
+
+ 'If importeMovimiento <> 0 Then
+ Select Case ConceptoContabilizacion
+ Case 176
+ Dim SumatoriaOCINV = 0.0D, Importe176 = 0.0D, ImporteME176 = 0.0D, ImporteMN176 = 0.0D, Importe228 = 0.0D, ImporteME228 = 0.0D, ImporteMN228 = 0.0D, Importe229 = 0.0D, ImporteME229 = 0.0D, ImporteMN229 = 0.0D, ImporteCI176 = 0.0D
+ For Each Dr As DataRow In TmpDT.FiltraParametros("ISNULL(TipoAF,0) <> 2 AND ISNULL(CveAlmacen,0) = 0 AND ISNULL(AplicaCostoIndirecto,0) <> 1 AND ISNULL(CveTipoPS,0) = 2").Rows
+ If ObjOC.OrdenesCompraDetalleCostoPP(Dr("CveOrdenCompraDetalle").ToString.ToEntero) AndAlso ObjOC.DtResultados.Rows.Count = 1 Then
+ Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text} OC: {ObjOC.DtResultados.FiltroPrimeroValor("Folio").ToString}"
+ Importe176 = ObjOC.DtResultados.FiltroPrimeroValor("Importe176").ToDecimal * Dr("Cantidad").ToString.ToDecimal : ImporteME176 = ObjOC.DtResultados.FiltroPrimeroValor("ImporteME176").ToDecimal * Dr("Cantidad").ToString.ToDecimal : ImporteMN176 = ObjOC.DtResultados.FiltroPrimeroValor("ImporteMN176").ToDecimal * Dr("Cantidad").ToString.ToDecimal
+ Importe228 = ObjOC.DtResultados.FiltroPrimeroValor("Importe228").ToDecimal * Dr("Cantidad").ToString.ToDecimal : ImporteME228 = ObjOC.DtResultados.FiltroPrimeroValor("ImporteME228").ToDecimal * Dr("Cantidad").ToString.ToDecimal : ImporteMN228 = ObjOC.DtResultados.FiltroPrimeroValor("ImporteMN228").ToDecimal * Dr("Cantidad").ToString.ToDecimal
+ Importe229 = ObjOC.DtResultados.FiltroPrimeroValor("Importe229").ToDecimal * Dr("Cantidad").ToString.ToDecimal : ImporteME229 = ObjOC.DtResultados.FiltroPrimeroValor("ImporteME229").ToDecimal * Dr("Cantidad").ToString.ToDecimal : ImporteMN229 = ObjOC.DtResultados.FiltroPrimeroValor("ImporteMN229").ToDecimal * Dr("Cantidad").ToString.ToDecimal
+ ImporteCI176 = ObjOC.DtResultados.FiltroPrimeroValor("ImporteCI176").ToDecimal
+ Dim TCAjuste As Decimal = ObjOC.DtResultados.FiltroPrimeroValor("TipoCambioAjuste").ToDecimal
+ 'RMF. falta verificar el costo indirecto de la OC
+ If DdlMoneda.SelectedValue.ToEntero <> 1 And UsuarioActual.CveEmpresa.Contiene(119) Then
+ ImporteCI176 = ObjOC.DtResultados.FiltroPrimeroValor("ImporteCI228").ToDecimal
+ CostoIndirectoAcum176 += ImporteCI176
+ 'se considera costoindirecto, para que la factura tiene en un concepto tipo servicio
+ SumatoriaOCINV += (Dr(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total")).ToString.ToDecimal * tipoCambioActual) - (ImporteMN228 + ImporteMN229 - ImporteCI176)
+ If ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, Importe228, Referencia, ConceptoContabilizacionME, Concepto, FechaMovimiento, IdCtaContableME, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=ImporteMN228, ImporteME:=ImporteME228, CveCuenta:=CveCuenta, CveOCDetalle:=Dr("CveOrdenCompraDetalle").ToString.ToEntero, TipoCambio:=TCAjuste, Contabilizable:=SeContabiliza) Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, Importe229, Referencia, ConceptoContabilizacionMEComp, Concepto, FechaMovimiento, IdCtaContableMEComp, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=ImporteMN229, ImporteME:=ImporteME229, CveCuenta:=CveCuenta, CveOCDetalle:=Dr("CveOrdenCompraDetalle").ToString.ToEntero, TipoCambio:=TCAjuste, Contabilizable:=SeContabiliza) Then
+ ErrorPrepoliza = True
+ Exit For
+ End If
+ Else
+ ErrorPrepoliza = True
+ Exit For
+ End If
+ Else
+ CostoIndirectoAcum176 += ImporteCI176
+ 'se considera costoindirecto, para que la factura tiene en un concepto tipo servicio
+ SumatoriaOCINV += (Dr(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total")).ToString.ToDecimal * tipoCambioActual) - (ImporteMN176 - ImporteCI176)
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, Importe176, Referencia, ConceptoContabilizacion, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=ImporteMN176, ImporteME:=ImporteME176, CveCuenta:=CveCuenta, CveOCDetalle:=Dr("CveOrdenCompraDetalle").ToString.ToEntero, Contabilizable:=SeContabiliza) Then
+ ErrorPrepoliza = True
+ Exit For
+ End If
+ End If
+ Else
+ Alert("Ocurrió un error al procesar la mercancia recibida por adelantado. Por favor comuniquese con asistencia SIG", TipoMensaje.MsgError)
+ ErrorPrepoliza = True
+ Exit For
+ End If
+ Next
+ If SumatoriaOCINV.RoundSQL <> 0 Then
+ ' se abona el costo, cambiamos su naturaleza
+ SumatoriaOCINV = -SumatoriaOCINV
+ Dim CveClasificacionCostoOC = TmpDT.FiltroPrimeroValor("CveClasificacion", "ISNULL(TipoAF, 0) <> 2 And ISNULL(CveAlmacen, 0) = 0 And ISNULL(AplicaCostoIndirecto, 0) <> 1 And ISNULL(CveTipoPS, 0) = 2").ToEntero
+ IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaCostos", $"CveClasificacion = {CveClasificacionCostoOC}").ToString.ToEntero
+ CveCuenta = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaGastoSIG", $"CveClasificacion = {CveClasificacionCostoOC}").ToString.ToEntero
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, SumatoriaOCINV, Referencia, 69, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveClasificacion:=CveClasificacionCostoOC, ImporteMX:=SumatoriaOCINV, CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then
ErrorPrepoliza = True
Exit For
End If
End If
+ Case 205, 237, 240
+ Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}"
+ If DdlMoneda.SelectedValue.ToEntero <> 1 AndAlso UsaComplementariaFleteImportaciones Then
+ If ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, ConceptoContabilizacionME, Concepto, FechaMovimiento, IdCtaContableME, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=importeMovimiento, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMN - importeMovimiento, Referencia, ConceptoContabilizacionMEComp, Concepto, FechaMovimiento, IdCtaContableMEComp, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=importeMN - importeMovimiento, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then
+ ErrorPrepoliza = True
+ End If
+ Else
+ ErrorPrepoliza = True
+ End If
+ Else
+
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMN, Referencia, ConceptoContabilizacion, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then
+ ErrorPrepoliza = True
+ End If
+ End If
+ End Select
+ 'End If
+
+ End If
+
+
+ 'NC CON PRODUCTOS - CUENTA PUENTE
+ If UsuarioActual.CveEmpresa.Contiene(119) AndAlso UsuarioActual.Empresa.UsaInventarios AndAlso DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") AndAlso Not UsuarioActual.Empresa.Funcionalidad(126) = "1" Then
+
+ importeMovimiento = TmpDT.SUM(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total"), $"ISNULL(TipoAF,0) <> 2 AND ISNULL(CveAlmacen,0) = 0 AND ISNULL(AplicaCostoIndirecto,0) <> 1 AND ISNULL(CveTipoPS,0) = 2").ToString.ToDecimal
+ importeMN = importeMovimiento * tipoCambioActual * Multiplicador
+
+ Dim ConceptoContabilizacionNC = 225
+
+ If ObjConta.GetRetCuenta(ConceptoContabilizacionNC, UsuarioActual.CveEmpresa) Then
+ If ObjConta.DtResultados.Rows.Count > 0 Then
+ IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCtaContable").ToString.ToEntero
+ End If
+ End If
+
+ Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}"
+
+ If importeMovimiento > 0 Or TxtTotal.Text.ToDecimal = 0 Then
+ 'Conta ContPAQ
+ If IdCtaContable = 0 Then
+ CuentasContablesInvalidas.Append(" " & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 68))("ConceptoContable").ToString)
+ idCuentaContabilizacion = 0
+ End If
+ 'Conta SIG
+ If CveCuenta = 0 Then
+ CuentasContablesInvalidasSIG.Append(" " & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 68))("ConceptoContable").ToString)
+ CveCuentaContabilizacion = 0
End If
- ElseIf ConceptoContableAnticipo.Contiene(265) And DdlMoneda.SelectedValue.ToEntero <> 1 And UsuarioActual.CveEmpresa.Contiene(119) Then
- Dim importeMovimientoNC = Ant.Importe
- Dim importeMNNC = 0.0D
- Dim TipoCambioNC = Ant.TCCompra
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, ConceptoContabilizacionNC, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then
+ ErrorPrepoliza = True
+ End If
- importeMNNC = importeMovimientoNC * TipoCambioNC * Multiplicador
- IdCtaContable = CtaProveedorAnticiposExtranjera
- CveCuenta = CveCuentaProveedorAnticiposExtranjera
- If ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimientoNC, Referencia, 265, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=Ant.CveCompra, CveCompraAmortizacion:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimientoNC, ImporteME:=importeMovimientoNC, TipoCambio:=TipoCambioNC, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
- IdCtaContable = CtaProveedorAnticiposComplementaria
- CveCuenta = CveCuentaProveedorAnticiposComplementaria
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMNNC - importeMovimientoNC, Referencia, 266, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=Ant.CveCompra, CveCompraAmortizacion:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMNNC - importeMovimientoNC, ImporteME:=importeMovimientoNC, TipoCambio:=TipoCambioNC, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
+ End If
+
+ Dim ContienePSNeteoBonif As Boolean = False
+ For Each Dr As DataRow In TmpDT.Rows
+ If Dr("CveClasificacion").ToString.ToEntero.Contiene(20319) Then 'clasificación de Bonificación, no se incluirá en el neteo
+ ContienePSNeteoBonif = True
+ Exit For
+ End If
+ Next
+
+ If ContienePSNeteoBonif Then
+ importeMovimiento = TmpDT.SUM(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total"), $"ISNULL(TipoAF,0) <> 2 AND ISNULL(CveAlmacen,0) = 0 AND ISNULL(AplicaCostoIndirecto,0) <> 1 ").ToString.ToDecimal
+ importeMN = importeMovimiento * tipoCambioActual * Multiplicador
+ Dim IdCtaContableDescCompra As Integer = UsuarioActual.Empresa.Funcionalidad(405).ToEntero
+ If ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimiento, Referencia, 259, Concepto, FechaMovimiento, IdCtaContableDescCompra, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, -importeMovimiento, Referencia, 259, Concepto, FechaMovimiento, IdCtaContableDescCompra, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=-importeMN, ImporteME:=If(tipoCambioActual = 1, 0, -importeMovimiento), CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then
ErrorPrepoliza = True
- Exit For
End If
Else
ErrorPrepoliza = True
- Exit For
+ End If
+ End If
+
+ End If
+
+
+
+ If Not ChkNCInvNC.Checked OrElse Not ListaDocumentos.Count > 0 Then
+ 'GASTO
+ If UsuarioActual.CveEmpresa = 119 Then
+ DT = TmpDT
+ Else
+ DT = TmpDT.FiltraParametros("ISNULL(AplicaCostoIndirecto,0) <> 1")
+ End If
+ 'RECORREMOS PARA DETECTAR LA MODALIDAD DEL ALMACEN, EN CASO DE SER SOLO EXISTENCIA LIMPIAMOS CVEALMACEN
+ For Each Dr As DataRow In DT.Rows
+ If DtAlmacenes.FiltroPrimeroValor("Modalidad", $"CveAlmacen = {Dr("CveAlmacen").ToString.ToEntero}").ToString = "Solo Existencia" Then
+ Dr("CveAlmacen") = 0
+ End If
+ Dr.AcceptChanges()
+ Next
+ DT.AcceptChanges()
+ DtAlmacenes.Dispose()
+
+ 'QUITA 1-[MERCANCIA RECIBIDA POR ADELANTADO (OC) | MERCANCIA PENDIENTE POR RECIBIR (COMPRA)] 2-[NC CON PRODUCTOS]
+ If UsuarioActual.CveEmpresa.Contiene(1, 119) And UsuarioActual.Empresa.UsaInventarios And Not UsuarioActual.Empresa.Funcionalidad(126) = "1" Then
+ DT = DT.FiltraParametros("ISNULL(CveTipoPS,0) <> 2")
+ End If
+
+ Dim DTDistinct = DT.Copy
+ If UsuarioActual.Empresa.Funcionalidad(126) = "1" Then
+ DTDistinct = DTDistinct.FiltraParametros("ISNULL(TipoAF, 0) <> 2", "", {"CveClasificacion", "Clasificacion", "SubProyecto", "CveProyecto", "CveSubProyecto", "CveTipoGasto", "TipoGasto"})
+ Else
+ DTDistinct = DTDistinct.FiltraParametros("ISNULL(TipoAF,0) <> 2 And ISNULL(CveAlmacen,0) = 0 And ISNULL(AplicaCostoIndirecto,0) <> 1", "", {"CveClasificacion", "Clasificacion", "SubProyecto", "CveProyecto", "CveSubProyecto", "CveTipoGasto", "TipoGasto"})
+ End If
+ 'RMF, si es concepto relacionado a flete o importacion, no debe de afectar al gasto
+ If CveFlete > 0 OrElse CveImportacion > 0 Then
+ DTDistinct.Clear()
+ End If
+
+ If DTDistinct.Rows.Count > 0 Then
+ For Each Row2 As DataRow In DTDistinct.Rows
+
+ 'DETERMINA IMPORTE
+ If UsuarioActual.Empresa.Funcionalidad(126) = "1" Then
+ importeMovimiento = DT.SUM(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total"), String.Format("ISNULL(TipoAF,0) <> 2 And CveClasificacion = {0} And CveSubProyecto = {1} And ISNULL(CveTipoGasto,0) = {2}", Row2("CveClasificacion").ToString.ToEntero, Row2("CveSubProyecto").ToString.ToEntero, Row2("CveTipoGasto").ToString.ToEntero)).ToString.ToDecimal
+ Else
+ importeMovimiento = DT.SUM(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total"), String.Format("ISNULL(TipoAF,0) <> 2 And ISNULL(CveAlmacen,0) = 0 And ISNULL(AplicaCostoIndirecto,0) <> 1 And CveClasificacion = {0} And CveSubProyecto = {1} And ISNULL(CveTipoGasto,0) = {2}", Row2("CveClasificacion").ToString.ToEntero, Row2("CveSubProyecto").ToString.ToEntero, Row2("CveTipoGasto").ToString.ToEntero)).ToString.ToDecimal
+ End If
+ 'se debe de restar el costo indirecto, si se recibió por OC sobre el importe del gasto, por si ya está incuido
+ importeMovimiento = importeMovimiento - CostoIndirectoAcum176
+
+ importeMN = importeMovimiento * tipoCambioActual * Multiplicador '[IPP] EL 6 DEBE SER POSITIVO 27/AGOSTO/2018
+
+ 'CLASIFICACION
+ If Row2("CveClasificacion").ToString.ToEntero > 0 Then
+ If ObjConta.GetRetCuenta(6, Row2("CveClasificacion").ToString.ToEntero, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero) Then
+ If ObjConta.DtResultados.Rows.Count > 0 AndAlso ObjConta.DtResultados.Rows(0)("IdCuentaGasto").ToString.ToEntero > 0 Then
+ IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaGasto").ToString.ToEntero
+ CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaGastoSIG").ToString.ToEntero
+ Else
+ IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaGasto", String.Format("CveClasificacion = {0}", Row2("CveClasificacion"))).ToString.ToEntero
+ CveCuenta = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaGastoSIG", String.Format("CveClasificacion = {0}", Row2("CveClasificacion"))).ToString.ToEntero
+ End If
+ End If
+ End If
+
+ 'SEGMENTO DE NEGOCIO
+ Dim IdSegmentoNegocio As Integer = -1
+ Dim drT As DataRow = GlobalDTSubProyectos(-1, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero).FiltroPrimero(String.Format("CveSubProyecto = {0} ", Row2("CveSubProyecto").ToString.ToEntero))
+ If drT IsNot Nothing Then
+ IdSegmentoNegocio = drT("IdSegNeg").ToString.ToEntero
+ End If
+
+ 'AGREGA MOVIMIENTO
+ If importeMovimiento.RoundSQL <> 0 Then
+ 'Conta ContPAQ
+ If IdCtaContable = 0 Then
+ CuentasContablesInvalidas.Append(" " & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 6))("ConceptoContable").ToString)
+ idCuentaContabilizacion = 0
+ End If
+ 'Conta SIG
+ If CveCuenta = 0 Then
+ CuentasContablesInvalidasSIG.Append(" " & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", 6))("ConceptoContable").ToString)
+ CveCuentaContabilizacion = 0
+ End If
+
+ Dim tcvecon As Integer = 6
+ Dim tidctacon As Integer = 6
+ tidctacon = IdCtaContable
+ If DdlTipoComprobante.SelectedValue = "Ant" Then
+ tcvecon = 264
+ tidctacon = ViewState("CtaProveedorAnticipos").ToString.ToEntero
+ If DdlMoneda.SelectedValue = "2" Then
+ tidctacon = ViewState("CtaProveedorAnticiposExtranjera").ToString.ToEntero
+ End If
+ End If
+
+ Dim usacomplementariaProveedor As Boolean = False
+ usacomplementariaProveedor = If(tipoCambioActual > 1 AndAlso UsuarioActual.CveEmpresa.Contiene(1, 119), True, False)
+
+ If usacomplementariaProveedor AndAlso DdlTipoComprobante.SelectedValue = "Ant" Then
+ 'importeMovimiento
+
+ Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}"
+ importeMN = tipoCambioActual * importeMovimiento - importeMovimiento
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, 266, Concepto, FechaMovimiento, tidctacon, IdSegmentoNegocio, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, CveClasificacion:=Row2("CveClasificacion").ToString.ToEntero, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero, ImporteMX:=importeMN, ImporteME:=importeMovimiento, CveCuenta:=CveCuenta, CveTipoGasto:=Row2("CveTipoGasto").ToString.ToEntero, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then
+ ErrorPrepoliza = True
+ End If
+ importeMN = importeMovimiento
+ End If
+
+ Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}"
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, tcvecon, Concepto, FechaMovimiento, tidctacon, IdSegmentoNegocio, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, CveClasificacion:=Row2("CveClasificacion").ToString.ToEntero, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, CveTipoGasto:=Row2("CveTipoGasto").ToString.ToEntero, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then
+ ErrorPrepoliza = True
+ End If
+
+
+
+
+
+ End If
+
+ Next
+ End If
+ End If
+
+
+ 'LIMPIA
+ importeMovimiento = 0
+ IdCtaContable = 0
+ CveCuenta = 0
+ End If
+ Case 5 'Proveedores
+ If Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") Then
+
+ importeMovimiento = importeProv
+ importeMN = importeMovimiento * tipoCambioActual * Multiplicador
+
+ If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}"
+
+ If tipoCambioActual = 1 Then
+ IdCtaContable = CtaProveedor
+ CveCuenta = CveCuentaProveedor
+ Else
+ IdCtaContable = CtaProveedorComplementaria
+ CveCuenta = CveCuentaProveedorComplementaria
+ If importeMovimiento <> 0 AndAlso (IdCtaContable > 0 Or CveCuenta > 0 Or UsuarioActual.CveEmpresa = 119) Then 'Cuando tiene complementaria lo dividimos en dos Then
+ importeMN = importeMovimiento
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, Referencia, 201, Concepto, FechaMovimiento, IdCtaContable, -1, CveIE, CveCompra:=CveCompra, CveProveedor:=CveProveedor, ImporteMX:=importeMovimiento * tipoCambioActual - importeMovimiento, ImporteME:=importeMovimiento, CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then
+ ErrorPrepoliza = True
+ End If
+ End If
+ IdCtaContable = CtaProveedorExtranjera
+ CveCuenta = CveCuentaProveedorExtranjera
+ End If
+ End If
+
+ Case 59 'Documentos
+ importeMovimiento = importeCreditos
+ importeMN = importeMovimiento * tipoCambioActual * Multiplicador
+ If ObjConta.GetRetCuenta(ConceptoContable, CveProveedor) Then
+ If ObjConta.DtResultados.Rows.Count > 0 Then
+ If ObjConta.DtResultados.Rows.Count > 0 Then
+ IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCtaContable").ToString.ToEntero
+ CveCuenta = ObjConta.DtResultados.Rows(0)("IdCtaContableSIG").ToString.ToEntero
+ End If
+ End If
+ End If
+
+ Case 37 'Deudores
+ If RBLTipoDeudor.SelectedValue.ToEntero = 1 Then
+ For Each rw As GridViewRow In GvDeudores.Rows
+ If rw.FCCheckBox("Chk").Checked Then
+ importeMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal
+ importeMN = importeMovimiento * tipoCambioActual * Multiplicador
+ IdCtaContable = CtaProveedorDeudores
+ CveCuenta = CveCuentaProveedorDeudores
+
+ 'Conta ContPAQ
+ If IdCtaContable = 0 Then
+ CuentasContablesInvalidas.Append(" " & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString)
+ idCuentaContabilizacion = 0
+ End If
+ 'Conta SIG
+ If CveCuenta = 0 Then
+ CuentasContablesInvalidasSIG.Append(" " & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString)
+ CveCuentaContabilizacion = 0
End If
- If TxtTotal.Text.ToDouble > 0 Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=rw.DataKey("CveIE").ToString.ToEntero, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
+ ErrorPrepoliza = True
+ End If
+ End If
+ Next
+ Else
+ For Each rw As GridViewRow In GvDeudores.Rows
+ If rw.FCCheckBox("Chk").Checked Then
+ importeMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal
+ importeMN = importeMovimiento * tipoCambioActual * Multiplicador
+ IdCtaContable = CtaProveedorDeudores
+ CveCuenta = CveCuentaProveedorDeudores
+
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, 254, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveIE:=rw.DataKey("CveIE").ToString.ToEntero, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
+ ErrorPrepoliza = True
+ End If
+ End If
+ Next
+ End If
+
+ importeMovimiento = 0
+
+ Case 41 'Acreedores
+ importeMovimiento = importeAcreedores
+ importeMN = importeMovimiento * tipoCambioActual * Multiplicador
+
+ IdCtaContable = CtaProveedorAcreedores
+ CveCuenta = CveCuentaProveedorAcreedores
+
+ Case 42 'Acreedores
+ importeMovimiento = importeAcreedoresTarjeta
+ importeMN = importeMovimiento * tipoCambioActual * Multiplicador
+ IdCtaContable = CtaProveedorAcreedores
+ CveCuenta = CveCuentaProveedorAcreedores
+
+ Case 18 'NC - Notas de Credito
+ importeMovimiento = importeNC
+ importeMN = importeMovimiento * tipoCambioActual * Multiplicador
+ If tipoCambioActual > 1 Then Concepto += $" TC:{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}"
+ IdCtaContable = CtaProveedor
+ CveCuenta = CveCuentaProveedor
+ If DdlMoneda.SelectedValue.ToEntero <> 1 And UsuarioActual.CveEmpresa.Contiene(119) Then
+ IdCtaContable = CtaProveedorExtranjera
+ CveCuenta = CveCuentaProveedorExtranjera
+ End If
+
+ If importeMovimiento <> 0 Then
+ GuardoConcepto18 = True
+ If DdlMoneda.SelectedValue.ToEntero <> 1 And UsuarioActual.CveEmpresa.Contiene(119) Then
+
+ 'PROVISION
+ IdCtaContable = CtaProveedorExtranjera
+ CveCuenta = CveCuentaProveedorExtranjera
+ If ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMovimiento, Referencia, ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimiento, ImporteME:=importeMovimiento, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
+ IdCtaContable = CtaProveedorComplementaria
+ CveCuenta = CveCuentaProveedorComplementaria
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMN - importeMovimiento, Referencia, 234, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMN - importeMovimiento, ImporteME:=importeMovimiento, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
+ ErrorPrepoliza = True
+ Exit Select
+ End If
+ Else
+ ErrorPrepoliza = True
+ Exit Select
+ End If
+
+ 'AMORTIZACIÓN EN EL REGISTRO
+ For Each Gvr As GridViewRow In GvFacturaNC.Rows
+ If Gvr.FCCheckBox("ChkFacturaNC").Checked Then
+ Dim CvePrePolizaTemp = ObjConta.AddPrePolizas("Compras/Registrar-NC", If(EsContado And CvePlantillaPrePoliza = 1, 2, CvePlantillaPrePoliza), ImporteCompra, TxtTotal.Text.ToDouble, DdlMoneda.SelectedValue.ToEntero, TxtFecha.Text.ToDate, ConceptoPoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, FolioFijo:=FolioFijo, ReglaFolioPoliza:=ObjCompras.ObtenerReglaFolio(DdlTipoTransaccion.SelectedValue, DdlTipoTransaccionCaja.SelectedValue, UsuarioActual.CveEmpresa), CveTipoPoliza:=ObjConta.ObtenerTipoPoliza(DdlTipoTransaccion.SelectedValue, DdlTipoTransaccionCaja.SelectedValue, UsuarioActual.CveEmpresa))
+ Dim importeMovimientoNC = Gvr.FCTextBox("TxtImporte").Text.ToDecimal
+ Dim importeMNNC = importeMovimientoNC * tipoCambioActual * Multiplicador
+ Dim TipoCambioFactura = Gvr.DataKey("TipoCambio").ToDecimal
+
+ IdCtaContable = CtaProveedorExtranjera
+ CveCuenta = CveCuentaProveedorExtranjera
+ If ObjConta.AddPrePolizasDetalle(CvePrePolizaTemp, False, importeMovimientoNC, Referencia, 17, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=Gvr.DataKey("CveCompra").ToEntero, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimientoNC, ImporteME:=importeMovimientoNC, TipoCambio:=TipoCambioFactura, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
+ IdCtaContable = CtaProveedorComplementaria
+ CveCuenta = CveCuentaProveedorComplementaria
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaTemp, False, importeMNNC - importeMovimientoNC, Referencia, 206, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=Gvr.DataKey("CveCompra").ToEntero, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMNNC - importeMovimientoNC, ImporteME:=importeMovimientoNC, TipoCambio:=TipoCambioFactura, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
+ ErrorPrepoliza = True
+ Exit For
+ End If
+ Else
+ ErrorPrepoliza = True
+ Exit For
+ End If
+
+
+ importeMNNC = importeMovimientoNC * TipoCambioFactura * Multiplicador
+ IdCtaContable = CtaProveedorExtranjera
+ CveCuenta = CveCuentaProveedorExtranjera
+ If ObjConta.AddPrePolizasDetalle(CvePrePolizaTemp, True, importeMovimientoNC, Referencia, 60, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveCompraAmortizacion:=Gvr.DataKey("CveCompra").ToEntero, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimientoNC, ImporteME:=importeMovimientoNC, TipoCambio:=tipoCambioActual, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
+ IdCtaContable = CtaProveedorComplementaria
+ CveCuenta = CveCuentaProveedorComplementaria
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaTemp, True, importeMNNC - importeMovimientoNC, Referencia, 235, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveCompraAmortizacion:=Gvr.DataKey("CveCompra").ToEntero, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMNNC - importeMovimientoNC, ImporteME:=importeMovimientoNC, TipoCambio:=tipoCambioActual, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
+ ErrorPrepoliza = True
+ Exit For
+ End If
+ Else
+ ErrorPrepoliza = True
+ Exit For
+ End If
+
+ ' FLUCTUACION CAMBIARIA
+ If tipoCambioActual <> TipoCambioFactura Then
+ importeMovimiento = (importeMovimientoNC * TipoCambioFactura) - (importeMovimientoNC * tipoCambioActual)
+
+ If importeMovimiento > 0 Then
+ ConceptoContable = 64
+ TipoMovimiento = True
+ IdCtaContable = UsuarioActual.Empresa.IdCuentaGananciaCambiaria
+ CveCuenta = UsuarioActual.Empresa.CveCuentaGananciaCambiaria
+ ElseIf importeMovimiento < 0 Then
+ ConceptoContable = 65
+ TipoMovimiento = False
+ IdCtaContable = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria
+ CveCuenta = UsuarioActual.Empresa.CveCuentaPerdidaCambiaria
+ End If
+
+ importeMovimiento = importeMovimiento.Abs.RoundSQL()
+ importeMN = importeMovimiento
+ If importeMovimiento <> 0 Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaTemp, TipoMovimiento, importeMovimiento, Concepto, ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=importeMN, CvePrePolizaOriginal:=CvePrePoliza, ImporteME:=0, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
+ ErrorPrepoliza = True
+ Exit For
+ End If
+ End If
+ End If
+
+
+ ObjConta.PrePolizaUnificacion(CvePrePoliza, CvePrePolizaTemp)
+ End If
+ Next
+
+ If ErrorPrepoliza Then
+ Exit Select
+ End If
+
+ Else
+ IdCtaContable = CtaProveedor
+ CveCuenta = CveCuentaProveedor
+
+ If ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMovimiento, Referencia, ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
+ For Each Gvr As GridViewRow In GvFacturaNC.Rows
+ If Gvr.FCCheckBox("ChkFacturaNC").Checked Then
+ Dim CvePrePolizaTemp = ObjConta.AddPrePolizas("Compras/Registrar", If(EsContado And CvePlantillaPrePoliza = 1, 2, CvePlantillaPrePoliza), ImporteCompra, TxtTotal.Text.ToDouble, DdlMoneda.SelectedValue.ToEntero, TxtFecha.Text.ToDate, ConceptoPoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, FolioFijo:=FolioFijo, ReglaFolioPoliza:=ObjCompras.ObtenerReglaFolio(DdlTipoTransaccion.SelectedValue, DdlTipoTransaccionCaja.SelectedValue, UsuarioActual.CveEmpresa), CveTipoPoliza:=ObjConta.ObtenerTipoPoliza(DdlTipoTransaccion.SelectedValue, DdlTipoTransaccionCaja.SelectedValue, UsuarioActual.CveEmpresa))
+ Dim importeMovimientoNC = Gvr.FCTextBox("TxtImporte").Text.ToDecimal
+ Dim importeMNNC = importeMovimientoNC * tipoCambioActual * Multiplicador
+ If ObjConta.AddPrePolizasDetalle(CvePrePolizaTemp, False, importeMovimientoNC, Referencia, 272, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=Gvr.DataKey("CveCompra").ToEntero, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMNNC, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimientoNC), CveCompraAmortizacion:=CveCompra, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaTemp, True, importeMovimientoNC, Referencia, 60, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveCompraAmortizacion:=Gvr.DataKey("CveCompra").ToEntero, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMNNC, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimientoNC), CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
+ ErrorPrepoliza = True
+ End If
+ Else
+ ErrorPrepoliza = True
+ End If
+ ObjConta.PrePolizaUnificacion(CvePrePoliza, CvePrePolizaTemp)
+ End If
+ Next
+ End If
+ End If
+ End If
+
+ importeMovimiento = 0
+
+ Case 29 'Funcionarios y Empleados
+ importeMovimiento = importeFE
+ importeMN = importeMovimiento * tipoCambioActual * Multiplicador
+ If ObjConta.GetRetCuenta(ConceptoContable, CvePersonal) Then
+ If ObjConta.DtResultados.Rows.Count > 0 Then
+ IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCtaContPersonal").ToString.ToEntero
+ CveCuenta = ObjConta.DtResultados.Rows(0)("IdCtaContPersonalSIG").ToString.ToEntero
+ End If
+ End If
+
+ Case 21 'Anticipo
+
+ If ArrAnticipos.Count > 0 Then
+
+
+ Dim CtaIvaxAcreditar As Integer = 0
+ Dim CtaIvaAcreditable As Integer = 0
+ Dim CveCuentaIvaxAcreditar As Integer = 0
+ Dim PorcentajeImpuestoAnticipo = PorcentajeIVA
+ CtaIvaxAcreditar = If(IdCtaIVAXAcreditar > 0, IdCtaIVAXAcreditar, 0)
+ CtaIvaAcreditable = If(IdCtaIVAAcreditable > 0, IdCtaIVAAcreditable, 0)
+ If ObjConta.GetRetCuenta(14, UsuarioActual.CveEmpresa) And Not CtaIvaxAcreditar > 0 Then
+ If ObjConta.DtResultados.Rows.Count > 0 Then
+ CtaIvaxAcreditar = ObjConta.DtResultados.Rows(0)("IdCuentaIVAxAcreditar").ToString.ToEntero
+ CveCuentaIvaxAcreditar = ObjConta.DtResultados.Rows(0)("IdCuentaIVAxAcreditarSIG").ToString.ToEntero
+ End If
+ End If
+ If ObjConta.GetRetCuenta(19, UsuarioActual.CveEmpresa) And Not CtaIvaAcreditable > 0 Then
+ If ObjConta.DtResultados.Rows.Count > 0 Then
+ CtaIvaAcreditable = ObjConta.DtResultados.Rows(0)("IdCuentaIVAAcreditable").ToString.ToEntero
+ End If
+ End If
+
+ '** PRUEBA CUANDO SE AMORTIZA NC ANTES DE QUE SE REGISTRE NO DEBE TENER CONCEPTO 19 ** JMURUAM 01/06/2017 SE HIZO ESTO PARA LA FACTURA HRFA-8012831 DE VIGILANCIA
+ 'Dim CtaIvaAcreditable As Integer = 0
+ 'If ObjConta.GetRetCuenta(19, UsuarioActual.CveEmpresa) Then
+ ' If ObjConta.DtResultados.Rows.Count > 0 Then
+ ' CtaIvaAcreditable = ObjConta.DtResultados.Rows(0)("IdCuentaIVAAcreditable").ToString.ToEntero
+ ' End If
+ 'End If
+
+ For Each Ant As Anticipos In ArrAnticipos
+
+ Dim ConceptoContableAnticipo, ConceptoContableAnticipoComplementaria As Integer
+ Dim CveCompraNC As Integer = CveCompra
+
+ Select Case Ant.TipoMovto
+ Case "NC", "DEV"
+ ConceptoContableAnticipo = 60
+ ConceptoContableAnticipoComplementaria = 235
+ CveCompraNC = Ant.CveCompra 'cuando es NC, se utiliza la clave de compra de la nota de credito
+ IdCtaContable = CtaProveedor
+ CveCuenta = CveCuentaProveedor
+ Case "Egsc"
+ ConceptoContableAnticipo = 21
+ IdCtaContable = CtaProveedorAnticipos
+ CveCuenta = CveCuentaProveedorAnticipos
+
+ Case "DD"
+ ConceptoContableAnticipo = 37
+ IdCtaContable = CtaProveedorDeudores
+ CveCuenta = CveCuentaProveedorDeudores
+ Case "Ant"
+ ConceptoContableAnticipo = 265
+ ConceptoContableAnticipoComplementaria = 266
+ CveCompraNC = Ant.CveCompra
+ IdCtaContable = CtaProveedorAnticipos
+ CveCuenta = CveCuentaProveedorAnticipos
+ End Select
+
+ importeMovimiento = Ant.Importe
+ importeMN = importeMovimiento * tipoCambioActual * Multiplicador
+
+ If importeMovimiento <> 0 Then
+ 'Conta ContPAQ
+ If IdCtaContable = 0 Then
+ CuentasContablesInvalidas.Append(" " & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString)
+ idCuentaContabilizacion = 0
+ End If
+ 'Conta SIG
+ If CveCuenta = 0 Then
+ CuentasContablesInvalidas.Append(" " & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString)
+ idCuentaContabilizacion = 0
+ End If
+
+ 'AMORTIZACIÓN NC ESPECIAL COMPLEMENTARIA
+ If ConceptoContableAnticipo.Contiene(60) And DdlMoneda.SelectedValue.ToEntero <> 1 And UsuarioActual.CveEmpresa.Contiene(119) Then
+ Dim importeMovimientoNC = Ant.Importe
+ Dim importeMNNC = 0.0D
+ Dim TipoCambioNC = Ant.TCCompra
+
+ importeMNNC = importeMovimientoNC * TipoCambioNC * Multiplicador
+ IdCtaContable = CtaProveedorExtranjera
+ CveCuenta = CveCuentaProveedorExtranjera
+ If ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimientoNC, Referencia, 60, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=Ant.CveCompra, CveCompraAmortizacion:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimientoNC, ImporteME:=importeMovimientoNC, TipoCambio:=TipoCambioNC, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
+ IdCtaContable = CtaProveedorComplementaria
+ CveCuenta = CveCuentaProveedorComplementaria
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMNNC - importeMovimientoNC, Referencia, 235, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=Ant.CveCompra, CveCompraAmortizacion:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMNNC - importeMovimientoNC, ImporteME:=importeMovimientoNC, TipoCambio:=TipoCambioNC, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
+ ErrorPrepoliza = True
+ Exit For
+ End If
+ Else
+ ErrorPrepoliza = True
+ Exit For
+ End If
+
importeMNNC = importeMovimientoNC * tipoCambioActual * Multiplicador
- IdCtaContable = CtaProveedorExtranjera ' CtaProveedorAnticiposExtranjera
- CveCuenta = CveCuentaProveedorExtranjera 'CveCuentaProveedorAnticiposExtranjera
- If ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMovimientoNC, Referencia, 272, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimientoNC, ImporteME:=importeMovimientoNC, TipoCambio:=tipoCambioActual, CveCuenta:=CveCuenta, CveCompraAmortizacion:=CveCompraNC, Contabilizable:=SeContabiliza) Then
- IdCtaContable = CtaProveedorExtranjera 'CtaProveedorAnticiposComplementaria
- CveCuenta = CveCuentaProveedorExtranjera 'CveCuentaProveedorAnticiposComplementaria
+ IdCtaContable = CtaProveedorExtranjera
+ CveCuenta = CveCuentaProveedorExtranjera
+ If ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMovimientoNC, Referencia, 272, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimientoNC, ImporteME:=importeMovimientoNC, TipoCambio:=tipoCambioActual, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
+ IdCtaContable = CtaProveedorComplementaria
+ CveCuenta = CveCuentaProveedorComplementaria
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMNNC - importeMovimientoNC, Referencia, 206, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMNNC - importeMovimientoNC, ImporteME:=importeMovimientoNC, TipoCambio:=tipoCambioActual, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
ErrorPrepoliza = True
Exit For
@@ -6781,34 +6721,6 @@ Partial Class Compras_Compras
Exit For
End If
- If Ant.TipoMovto.Contiene("Ant") Then
- Dim PorcentajePagoAnt As Decimal = importeMovimientoNC / If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, TmpDT.SUMD("ImporteConImpuestos"), TxtTotal.Text.ToDecimal)
- Dim ImporteIVA As Decimal = Math.Round(PorcentajePagoAnt * TxtIVA.Text.ToDecimal, 2)
-
- 'Agregamos el 14
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteIVA, Referencia, 14, Concepto, FechaMovimiento, CtaIvaxAcreditar, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=ImporteIVA * tipoCambioActual * Multiplicador, ImporteME:=If(tipoCambioActual = 1, 0, ImporteIVA), CveCuenta:=CveCuentaIvaxAcreditar, PorcentajeImpuesto:=PorcentajeImpuestoAnticipo, Contabilizable:=SeContabiliza) Then
- ErrorPrepoliza = True
- End If
-
- 'Agregamos el 19
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, ImporteIVA, Referencia, 19, Concepto, FechaMovimiento, CtaIvaAcreditable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=ImporteIVA * tipoCambioActual * Multiplicador, ImporteME:=If(tipoCambioActual = 1, 0, ImporteIVA), PorcentajeImpuesto:=PorcentajeImpuestoAnticipo, Contabilizable:=SeContabiliza) Then
- ErrorPrepoliza = True
- End If
-
- Dim ImporteIEPS As Decimal = Math.Round(PorcentajePagoAnt * TxtIEPS.Text.ToDecimal, 2)
-
- 'Agregamos el 25
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteIEPS, Referencia, 25, Concepto, FechaMovimiento, CtaIvaxAcreditar, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=ImporteIVA * tipoCambioActual * Multiplicador, ImporteME:=If(tipoCambioActual = 1, 0, ImporteIVA), CveCuenta:=CveCuentaIvaxAcreditar, PorcentajeImpuesto:=PorcentajeImpuestoAnticipo, Contabilizable:=SeContabiliza) Then
- ErrorPrepoliza = True
- End If
-
- 'Agregamos el 26
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, ImporteIEPS, Referencia, 26, Concepto, FechaMovimiento, CtaIvaAcreditable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=ImporteIVA * tipoCambioActual * Multiplicador, ImporteME:=If(tipoCambioActual = 1, 0, ImporteIVA), PorcentajeImpuesto:=PorcentajeImpuestoAnticipo, Contabilizable:=SeContabiliza) Then
- ErrorPrepoliza = True
- End If
- End If
-
-
' FLUCTUACION CAMBIARIA
If tipoCambioActual <> TipoCambioNC Then
importeMovimiento = (importeMovimientoNC * tipoCambioActual) - (importeMovimientoNC * TipoCambioNC)
@@ -6834,232 +6746,590 @@ Partial Class Compras_Compras
End If
End If
End If
- End If
- Else
+ ElseIf ConceptoContableAnticipo.Contiene(265) And DdlMoneda.SelectedValue.ToEntero <> 1 And UsuarioActual.CveEmpresa.Contiene(119) Then
+ Dim importeMovimientoNC = Ant.Importe
+ Dim importeMNNC = 0.0D
+ Dim TipoCambioNC = Ant.TCCompra
-
- Dim usacomplementariaAnticipo As Boolean = False
- usacomplementariaAnticipo = If(Ant.TCCompra > 1 AndAlso UsuarioActual.CveEmpresa.Contiene(1, 119), True, False)
- Dim TipoCambioAnt = Ant.TCCompra
-
-
- Dim ImporteAnt As Decimal = importeMovimiento
- Dim ImporteAntMN As Decimal = ImporteAnt * TipoCambioAnt
- If usacomplementariaAnticipo Then
- IdCtaContable = CtaProveedorAnticiposComplementaria
- CveCuenta = CveCuentaProveedorAnticiposComplementaria
- ImporteAntMN = TipoCambioAnt * ImporteAnt - ImporteAnt
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteAnt, Referencia, 266, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompraNC, CveCompraAmortizacion:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=ImporteAntMN, ImporteME:=ImporteAnt, TipoCambio:=TipoCambioAnt, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
- ErrorPrepoliza = True
- Exit For
- End If
- ImporteAntMN = ImporteAnt
- End If
-
- If TipoCambioAnt > 1 Then
+ importeMNNC = importeMovimientoNC * TipoCambioNC * Multiplicador
IdCtaContable = CtaProveedorAnticiposExtranjera
CveCuenta = CveCuentaProveedorAnticiposExtranjera
- End If
-
- 'Agregamos el 21/37/60
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteAnt, Referencia, ConceptoContableAnticipo, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompraNC, CveCompraAmortizacion:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=ImporteAntMN, ImporteME:=If(tipoCambioActual = 1, 0, ImporteAnt), TipoCambio:=TipoCambioAnt, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
- ErrorPrepoliza = True
- End If
-
- If TxtTotal.Text.ToDouble > 0 Then
- Dim IdCtaContablePago As Integer = CtaProveedor
- Dim CveCuentaPago As Integer = CveCuentaProveedor
- Dim usacomplementariaProveedor As Boolean = False
- usacomplementariaProveedor = If(tipoCambioActual > 1 AndAlso UsuarioActual.CveEmpresa.Contiene(1, 119), True, False)
- If usacomplementariaProveedor Then
- Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}"
- importeMN = tipoCambioActual * importeMovimiento - importeMovimiento
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, importeMovimiento, Referencia, 201, Concepto, FechaMovimiento, CtaProveedorComplementaria, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuentaProveedorComplementaria, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then
- ErrorPrepoliza = True
- End If
- importeMN = importeMovimiento
- End If
-
- If tipoCambioActual > 1 Then
- IdCtaContablePago = CtaProveedorExtranjera
- CveCuentaPago = CveCuentaProveedorExtranjera
- End If
-
- 'Agregamos el 17
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, importeMovimiento, Referencia, 17, Concepto, FechaMovimiento, IdCtaContablePago, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuentaPago, Contabilizable:=SeContabiliza) Then
- ErrorPrepoliza = True
- End If
-
- End If
- ' FLUCTUACION CAMBIARIA
- If tipoCambioActual <> TipoCambioAnt Then
- Dim importeFluctuacion = (ImporteAnt * tipoCambioActual) - (ImporteAnt * TipoCambioAnt)
-
- If importeFluctuacion > 0 Then
- ConceptoContable = 64
- TipoMovimiento = True
- IdCtaContable = UsuarioActual.Empresa.IdCuentaGananciaCambiaria
- CveCuenta = UsuarioActual.Empresa.CveCuentaGananciaCambiaria
- ElseIf importeFluctuacion < 0 Then
- ConceptoContable = 65
- TipoMovimiento = False
- IdCtaContable = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria
- CveCuenta = UsuarioActual.Empresa.CveCuentaPerdidaCambiaria
- End If
-
- importeFluctuacion = importeFluctuacion.Abs.RoundSQL()
- If importeFluctuacion <> 0 Then
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeFluctuacion, Concepto, ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=importeFluctuacion, CvePrePolizaOriginal:=CvePrePoliza, ImporteME:=0, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
+ If ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimientoNC, Referencia, 265, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=Ant.CveCompra, CveCompraAmortizacion:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimientoNC, ImporteME:=importeMovimientoNC, TipoCambio:=TipoCambioNC, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
+ IdCtaContable = CtaProveedorAnticiposComplementaria
+ CveCuenta = CveCuentaProveedorAnticiposComplementaria
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMNNC - importeMovimientoNC, Referencia, 266, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=Ant.CveCompra, CveCompraAmortizacion:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMNNC - importeMovimientoNC, ImporteME:=importeMovimientoNC, TipoCambio:=TipoCambioNC, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
ErrorPrepoliza = True
Exit For
End If
+ Else
+ ErrorPrepoliza = True
+ Exit For
+ End If
+
+ If TxtTotal.Text.ToDouble > 0 Then
+ importeMNNC = importeMovimientoNC * tipoCambioActual * Multiplicador
+ IdCtaContable = CtaProveedorExtranjera ' CtaProveedorAnticiposExtranjera
+ CveCuenta = CveCuentaProveedorExtranjera 'CveCuentaProveedorAnticiposExtranjera
+ If ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMovimientoNC, Referencia, 272, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimientoNC, ImporteME:=importeMovimientoNC, TipoCambio:=tipoCambioActual, CveCuenta:=CveCuenta, CveCompraAmortizacion:=CveCompraNC, Contabilizable:=SeContabiliza) Then
+ IdCtaContable = CtaProveedorExtranjera 'CtaProveedorAnticiposComplementaria
+ CveCuenta = CveCuentaProveedorExtranjera 'CveCuentaProveedorAnticiposComplementaria
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMNNC - importeMovimientoNC, Referencia, 206, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMNNC - importeMovimientoNC, ImporteME:=importeMovimientoNC, TipoCambio:=tipoCambioActual, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
+ ErrorPrepoliza = True
+ Exit For
+ End If
+ Else
+ ErrorPrepoliza = True
+ Exit For
+ End If
+
+ If Ant.TipoMovto.Contiene("Ant") Then
+ Dim PorcentajePagoAnt As Decimal = importeMovimientoNC / If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, TmpDT.SUMD("ImporteConImpuestos"), TxtTotal.Text.ToDecimal)
+ Dim ImporteIVA As Decimal = Math.Round(PorcentajePagoAnt * TxtIVA.Text.ToDecimal, 2)
+
+ 'Agregamos el 14
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteIVA, Referencia, 14, Concepto, FechaMovimiento, CtaIvaxAcreditar, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=ImporteIVA * tipoCambioActual * Multiplicador, ImporteME:=If(tipoCambioActual = 1, 0, ImporteIVA), CveCuenta:=CveCuentaIvaxAcreditar, PorcentajeImpuesto:=PorcentajeImpuestoAnticipo, Contabilizable:=SeContabiliza) Then
+ ErrorPrepoliza = True
+ End If
+
+ 'Agregamos el 19
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, ImporteIVA, Referencia, 19, Concepto, FechaMovimiento, CtaIvaAcreditable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=ImporteIVA * tipoCambioActual * Multiplicador, ImporteME:=If(tipoCambioActual = 1, 0, ImporteIVA), PorcentajeImpuesto:=PorcentajeImpuestoAnticipo, Contabilizable:=SeContabiliza) Then
+ ErrorPrepoliza = True
+ End If
+
+ Dim ImporteIEPS As Decimal = Math.Round(PorcentajePagoAnt * TxtIEPS.Text.ToDecimal, 2)
+
+ 'Agregamos el 25
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteIEPS, Referencia, 25, Concepto, FechaMovimiento, CtaIvaxAcreditar, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=ImporteIVA * tipoCambioActual * Multiplicador, ImporteME:=If(tipoCambioActual = 1, 0, ImporteIVA), CveCuenta:=CveCuentaIvaxAcreditar, PorcentajeImpuesto:=PorcentajeImpuestoAnticipo, Contabilizable:=SeContabiliza) Then
+ ErrorPrepoliza = True
+ End If
+
+ 'Agregamos el 26
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, ImporteIEPS, Referencia, 26, Concepto, FechaMovimiento, CtaIvaAcreditable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=ImporteIVA * tipoCambioActual * Multiplicador, ImporteME:=If(tipoCambioActual = 1, 0, ImporteIVA), PorcentajeImpuesto:=PorcentajeImpuestoAnticipo, Contabilizable:=SeContabiliza) Then
+ ErrorPrepoliza = True
+ End If
+ End If
+
+
+ ' FLUCTUACION CAMBIARIA
+ If tipoCambioActual <> TipoCambioNC Then
+ importeMovimiento = (importeMovimientoNC * tipoCambioActual) - (importeMovimientoNC * TipoCambioNC)
+
+ If importeMovimiento > 0 Then
+ ConceptoContable = 64
+ TipoMovimiento = True
+ IdCtaContable = UsuarioActual.Empresa.IdCuentaGananciaCambiaria
+ CveCuenta = UsuarioActual.Empresa.CveCuentaGananciaCambiaria
+ ElseIf importeMovimiento < 0 Then
+ ConceptoContable = 65
+ TipoMovimiento = False
+ IdCtaContable = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria
+ CveCuenta = UsuarioActual.Empresa.CveCuentaPerdidaCambiaria
+ End If
+
+ importeMovimiento = importeMovimiento.Abs.RoundSQL()
+ importeMN = importeMovimiento
+ If importeMovimiento <> 0 Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Concepto, ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=importeMN, CvePrePolizaOriginal:=CvePrePoliza, ImporteME:=0, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
+ ErrorPrepoliza = True
+ Exit For
+ End If
+ End If
+ End If
+ End If
+
+ Else
+
+
+ Dim usacomplementariaAnticipo As Boolean = False
+ usacomplementariaAnticipo = If(Ant.TCCompra > 1 AndAlso UsuarioActual.CveEmpresa.Contiene(1, 119), True, False)
+ Dim TipoCambioAnt = Ant.TCCompra
+
+
+ Dim ImporteAnt As Decimal = importeMovimiento
+ Dim ImporteAntMN As Decimal = ImporteAnt * TipoCambioAnt
+ If usacomplementariaAnticipo Then
+ IdCtaContable = CtaProveedorAnticiposComplementaria
+ CveCuenta = CveCuentaProveedorAnticiposComplementaria
+ ImporteAntMN = TipoCambioAnt * ImporteAnt - ImporteAnt
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteAnt, Referencia, 266, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompraNC, CveCompraAmortizacion:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=ImporteAntMN, ImporteME:=ImporteAnt, TipoCambio:=TipoCambioAnt, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
+ ErrorPrepoliza = True
+ Exit For
+ End If
+ ImporteAntMN = ImporteAnt
+ End If
+
+ If TipoCambioAnt > 1 Then
+ IdCtaContable = CtaProveedorAnticiposExtranjera
+ CveCuenta = CveCuentaProveedorAnticiposExtranjera
+ End If
+
+ 'Agregamos el 21/37/60
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteAnt, Referencia, ConceptoContableAnticipo, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompraNC, CveCompraAmortizacion:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=ImporteAntMN, ImporteME:=If(tipoCambioActual = 1, 0, ImporteAnt), TipoCambio:=TipoCambioAnt, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
+ ErrorPrepoliza = True
+ End If
+
+ If TxtTotal.Text.ToDouble > 0 Then
+ Dim IdCtaContablePago As Integer = CtaProveedor
+ Dim CveCuentaPago As Integer = CveCuentaProveedor
+ Dim usacomplementariaProveedor As Boolean = False
+ usacomplementariaProveedor = If(tipoCambioActual > 1 AndAlso UsuarioActual.CveEmpresa.Contiene(1, 119), True, False)
+ If usacomplementariaProveedor Then
+ Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}"
+ importeMN = tipoCambioActual * importeMovimiento - importeMovimiento
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, importeMovimiento, Referencia, 201, Concepto, FechaMovimiento, CtaProveedorComplementaria, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuentaProveedorComplementaria, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then
+ ErrorPrepoliza = True
+ End If
+ importeMN = importeMovimiento
+ End If
+
+ If tipoCambioActual > 1 Then
+ IdCtaContablePago = CtaProveedorExtranjera
+ CveCuentaPago = CveCuentaProveedorExtranjera
+ End If
+
+ 'Agregamos el 17
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, importeMovimiento, Referencia, 17, Concepto, FechaMovimiento, IdCtaContablePago, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuentaPago, Contabilizable:=SeContabiliza) Then
+ ErrorPrepoliza = True
+ End If
+
+ End If
+ ' FLUCTUACION CAMBIARIA
+ If tipoCambioActual <> TipoCambioAnt Then
+ Dim importeFluctuacion = (ImporteAnt * tipoCambioActual) - (ImporteAnt * TipoCambioAnt)
+
+ If importeFluctuacion > 0 Then
+ ConceptoContable = 64
+ TipoMovimiento = True
+ IdCtaContable = UsuarioActual.Empresa.IdCuentaGananciaCambiaria
+ CveCuenta = UsuarioActual.Empresa.CveCuentaGananciaCambiaria
+ ElseIf importeFluctuacion < 0 Then
+ ConceptoContable = 65
+ TipoMovimiento = False
+ IdCtaContable = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria
+ CveCuenta = UsuarioActual.Empresa.CveCuentaPerdidaCambiaria
+ End If
+
+ importeFluctuacion = importeFluctuacion.Abs.RoundSQL()
+ If importeFluctuacion <> 0 Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeFluctuacion, Concepto, ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveIE:=CveIE, ImporteMX:=importeFluctuacion, CvePrePolizaOriginal:=CvePrePoliza, ImporteME:=0, CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza) Then
+ ErrorPrepoliza = True
+ Exit For
+ End If
+ End If
+ End If
+
+
+ End If
+
+
+
+ '** PRUEBA CUANDO SE AMORTIZA NC ANTES DE QUE SE REGISTRE NO DEBE TENER CONCEPTO 19 ** JM 01/06/2017 SE HIZO ESTO PARA LA FACTURA HRFA-8012831 DE VIGILANCIA
+ '[IPP] NC NO DEBE REGISTRAR IMPUESTOS EN AMORTIZACIÓN 27/Agosto/2018
+ If Not Ant.TipoMovto.Contiene("NC", "DEV") Then
+ Dim PorcentajePagoAnt As Decimal = importeMovimiento / If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, TmpDT.SUMD("ImporteConImpuestos"), TxtTotal.Text.ToDecimal)
+ Dim ImporteIVA As Decimal = Math.Round(PorcentajePagoAnt * TxtIVA.Text.ToDecimal, 2)
+
+ 'Agregamos el 14
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteIVA, Referencia, 14, Concepto, FechaMovimiento, CtaIvaxAcreditar, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=ImporteIVA * tipoCambioActual * Multiplicador, ImporteME:=If(tipoCambioActual = 1, 0, ImporteIVA), CveCuenta:=CveCuentaIvaxAcreditar, PorcentajeImpuesto:=PorcentajeImpuestoAnticipo, Contabilizable:=SeContabiliza) Then
+ ErrorPrepoliza = True
+ End If
+
+ 'Agregamos el 19
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, ImporteIVA, Referencia, 19, Concepto, FechaMovimiento, CtaIvaAcreditable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=ImporteIVA * tipoCambioActual * Multiplicador, ImporteME:=If(tipoCambioActual = 1, 0, ImporteIVA), PorcentajeImpuesto:=PorcentajeImpuestoAnticipo, Contabilizable:=SeContabiliza) Then
+ ErrorPrepoliza = True
End If
End If
End If
+ ''Unificacion de PrePolizas
+ 'If UsuarioActual.Empresa.Funcionalidad(219) = "1" Then
+ ' If Not ObjConta.PrePolizaUnificacion(Ant.CvePrePoliza, CvePrePoliza) Then
+ ' ErrorPrepoliza = True
+ ' Alert("No se pudo unificar la prepoliza", TipoMensaje.MsgError)
+ ' End If
+ 'End If
+ ''Simplificacion de PrePolizas
+ 'If UsuarioActual.Empresa.Funcionalidad(220) <> "" Then
+ ' If Not ObjConta.PrePolizaSimplificacion(Ant.CvePrePoliza, UsuarioActual.CveEmpresa) Then
+ ' ErrorPrepoliza = True
+ ' Alert("No se pudo simplificar los movimientos", TipoMensaje.MsgError)
+ ' End If
+ 'End If
- '** PRUEBA CUANDO SE AMORTIZA NC ANTES DE QUE SE REGISTRE NO DEBE TENER CONCEPTO 19 ** JM 01/06/2017 SE HIZO ESTO PARA LA FACTURA HRFA-8012831 DE VIGILANCIA
- '[IPP] NC NO DEBE REGISTRAR IMPUESTOS EN AMORTIZACIÓN 27/Agosto/2018
- If Not Ant.TipoMovto.Contiene("NC", "DEV") Then
- Dim PorcentajePagoAnt As Decimal = importeMovimiento / If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, TmpDT.SUMD("ImporteConImpuestos"), TxtTotal.Text.ToDecimal)
- Dim ImporteIVA As Decimal = Math.Round(PorcentajePagoAnt * TxtIVA.Text.ToDecimal, 2)
+ Next
+ importeMovimiento = 0
- 'Agregamos el 14
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteIVA, Referencia, 14, Concepto, FechaMovimiento, CtaIvaxAcreditar, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=ImporteIVA * tipoCambioActual * Multiplicador, ImporteME:=If(tipoCambioActual = 1, 0, ImporteIVA), CveCuenta:=CveCuentaIvaxAcreditar, PorcentajeImpuesto:=PorcentajeImpuestoAnticipo, Contabilizable:=SeContabiliza) Then
- ErrorPrepoliza = True
- End If
+ End If
+ End Select
- 'Agregamos el 19
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, ImporteIVA, Referencia, 19, Concepto, FechaMovimiento, CtaIvaAcreditable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=ImporteIVA * tipoCambioActual * Multiplicador, ImporteME:=If(tipoCambioActual = 1, 0, ImporteIVA), PorcentajeImpuesto:=PorcentajeImpuestoAnticipo, Contabilizable:=SeContabiliza) Then
- ErrorPrepoliza = True
- End If
- End If
-
-
- End If
-
- ''Unificacion de PrePolizas
- 'If UsuarioActual.Empresa.Funcionalidad(219) = "1" Then
- ' If Not ObjConta.PrePolizaUnificacion(Ant.CvePrePoliza, CvePrePoliza) Then
- ' ErrorPrepoliza = True
- ' Alert("No se pudo unificar la prepoliza", TipoMensaje.MsgError)
- ' End If
- 'End If
-
- ''Simplificacion de PrePolizas
- 'If UsuarioActual.Empresa.Funcionalidad(220) <> "" Then
- ' If Not ObjConta.PrePolizaSimplificacion(Ant.CvePrePoliza, UsuarioActual.CveEmpresa) Then
- ' ErrorPrepoliza = True
- ' Alert("No se pudo simplificar los movimientos", TipoMensaje.MsgError)
- ' End If
- 'End If
-
- Next
- importeMovimiento = 0
-
- End If
- End Select
-
- If ErrorPrepoliza Then
- Exit For
- End If
-
- If importeMovimiento <> 0 Or (ConceptoContable.Contiene(5) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Fac", "Ant")) Or (ConceptoContable.Contiene(18) AndAlso DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") AndAlso Not GuardoConcepto18) Then
- 'Conta ContPAQ
- If IdCtaContable = 0 Then
- CuentasContablesInvalidas.Append(" " & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString)
- idCuentaContabilizacion = 0
- End If
- 'COnta SIG
- If CveCuenta = 0 Then
- CuentasContablesInvalidasSIG.Append(" " & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString)
- CveCuentaContabilizacion = 0
- End If
-
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=Math.Round(importeMN, 2, MidpointRounding.AwayFromZero), ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual, PorcentajeImpuesto:=PorcentajeImpuesto, Contabilizable:=SeContabiliza) Then
- ErrorPrepoliza = True
+ If ErrorPrepoliza Then
Exit For
End If
- End If
+ If importeMovimiento <> 0 Or (ConceptoContable.Contiene(5) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Fac", "Ant")) Or (ConceptoContable.Contiene(18) AndAlso DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") AndAlso Not GuardoConcepto18) Then
+ 'Conta ContPAQ
+ If IdCtaContable = 0 Then
+ CuentasContablesInvalidas.Append(" " & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString)
+ idCuentaContabilizacion = 0
+ End If
+ 'COnta SIG
+ If CveCuenta = 0 Then
+ CuentasContablesInvalidasSIG.Append(" " & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString)
+ CveCuentaContabilizacion = 0
+ End If
- Next
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=Math.Round(importeMN, 2, MidpointRounding.AwayFromZero), ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual, PorcentajeImpuesto:=PorcentajeImpuesto, Contabilizable:=SeContabiliza) Then
+ ErrorPrepoliza = True
+ Exit For
+ End If
- 'EMPIEZA REFACTURACION
- If CveCompraRefacturacion > 0 Then
- ErrorBitacora = GuardaRefacturacion(ObjCompras, ObjEventos, CvePrePoliza)
- If ErrorBitacora Then
- Alert("Ocurrió un error al hacer la Refacturación", TipoMensaje.MsgError)
- End If
- End If
-
- 'Simplificacion de PrePolizas
- If UsuarioActual.Empresa.Funcionalidad(220) <> "" Then
- If Not ObjConta.PrePolizaSimplificacion(CvePrePoliza, UsuarioActual.CveEmpresa) Then
- ErrorPrepolizaDescuadre = True
- End If
- End If
-
- If ObjConta.ValidacionPrePolizaCuadre(CvePrePoliza, 4) Then
- If ObjConta.ValorPolizaDescuadre > 0 Then
- GuardaLogAD($"Compras/Compras-Guardar | Error:{ObjConta.MensajePolizaDescuadre} Diferencia:{ObjConta.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas")
- ErrorPrepolizaDescuadre = True
- End If
- End If
-
- 'Conta ContPAQ
- If ObjContaAC IsNot Nothing AndAlso Not ErrorPrepoliza AndAlso Not ErrorPrepolizaDescuadre AndAlso UsuarioActual.Empresa.Funcionalidad(200).ToString = "1" Then
- If idCuentaContabilizacion > 0 Then
- If ObjConta.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa, ObjConta:=ObjContaAC) Then
- ' Alert(alertaContabilizacion, ModExtensiones.TipoMensaje.MsgInformacion)
- IdPoliza = ObjConta.ContaIdPoliza
- Else
- ErrorPrepoliza = True
- Alert($"Ocurrio un error al contabilizar {ObjConta.AlertaMensaje}", TipoMensaje.MsgAdvertencia)
End If
- Else
- Alert(String.Format("No se puede contabilizar la Prepoliza debido a que las siguientes cuentas son inválidas: {0}", CuentasContablesInvalidas), TipoMensaje.MsgAdvertencia)
- ErrorPrepoliza = True
+
+ Next
+
+ 'EMPIEZA REFACTURACION
+ If CveCompraRefacturacion > 0 Then
+ ErrorBitacora = GuardaRefacturacion(ObjCompras, ObjEventos, CvePrePoliza)
+ If ErrorBitacora Then
+ Alert("Ocurrió un error al hacer la Refacturación", TipoMensaje.MsgError)
+ End If
+ End If
+
+ 'Simplificacion de PrePolizas
+ If UsuarioActual.Empresa.Funcionalidad(220) <> "" Then
+ If Not ObjConta.PrePolizaSimplificacion(CvePrePoliza, UsuarioActual.CveEmpresa) Then
+ ErrorPrepolizaDescuadre = True
+ End If
+ End If
+
+ If ObjConta.ValidacionPrePolizaCuadre(CvePrePoliza, 4) Then
+ If ObjConta.ValorPolizaDescuadre > 0 Then
+ GuardaLogAD($"Compras/Compras-Guardar | Error:{ObjConta.MensajePolizaDescuadre} Diferencia:{ObjConta.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas")
+ ErrorPrepolizaDescuadre = True
+ End If
+ End If
+
+ 'Conta ContPAQ
+ If ObjContaAC IsNot Nothing AndAlso Not ErrorPrepoliza AndAlso Not ErrorPrepolizaDescuadre AndAlso UsuarioActual.Empresa.Funcionalidad(200).ToString = "1" Then
+ If idCuentaContabilizacion > 0 Then
+ If ObjConta.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa, ObjConta:=ObjContaAC) Then
+ ' Alert(alertaContabilizacion, ModExtensiones.TipoMensaje.MsgInformacion)
+ IdPoliza = ObjConta.ContaIdPoliza
+ Else
+ ErrorPrepoliza = True
+ Alert($"Ocurrio un error al contabilizar {ObjConta.AlertaMensaje}", TipoMensaje.MsgAdvertencia)
+ End If
+ Else
+ Alert(String.Format("No se puede contabilizar la Prepoliza debido a que las siguientes cuentas son inválidas: {0}", CuentasContablesInvalidas), TipoMensaje.MsgAdvertencia)
+ ErrorPrepoliza = True
+ End If
End If
End If
- End If
- '' A N T I C I P O S
- If UsuarioActual.Empresa.UsaAC Then
+ '' A N T I C I P O S
+ If UsuarioActual.Empresa.UsaAC Then
+ If ArrAnticipos.Count > 0 Then
+
+ Dim PorcentajePago As Decimal
+ Dim ConceptoRenglon As String
+
+
+ 'si hay una diferencia entre lo amortizado y el total, se registra la diferencia a proveedores y los ivas por acreditar
+ If TxtTotal.Text.ToDouble - ImporteAnticipo > 0 Then
+ PorcentajePago = (TxtTotal.Text.ToDecimal - ImporteAnticipo) / TxtTotal.Text.ToDecimal
+ ConceptoRenglon = String.Format("GE Fact: {0}-{1} {2}", TxtSerie.Text.Trim, TxtFolio.Text.Trim, DdlProveedor.SelectedItem.Text)
+ If Not ObjContaAC.AddMovimiento(IdPoliza, CtaProveedor, True, TxtTotal.Text.ToDouble - ImporteAnticipo, "", ConceptoRenglon, 0, TxtFechaPago.Text.ToDate, "") Then
+ ErrorACMEnsaje.Append(" - si hay una diferencia entre lo amortizado y el total, se registra la diferencia a proveedores y los ivas por acreditar ObjContaAC.AddMovimiento")
+ ErrorAC = True
+ End If
+ End If
+
+ 'una vez amortizado, se generan los movimientos presupuestales
+ If ImporteAnticipo > 0 Then
+ PorcentajePago = ImporteAnticipo / TxtTotal.Text.ToDecimal
+ If ObjCompras.GetPresupuestosCompras(CveCompra) AndAlso ObjCompras.DtResultados.Rows.Count > 0 Then
+ 'DtAC.Merge(ObjConta.DtResultados)
+ For Each dr As DataRow In ObjCompras.DtResultados.Rows
+ Total = dr("TotalPresupuesto").ToString.ToDecimal * PorcentajePago
+ If Total > 0 Then
+
+ 'EJERCIDO
+ If True Then
+ ConceptoRenglon = String.Format("GE {0} F:{1}-{2}", DdlProveedor.SelectedItem.Text, TxtSerie.Text, TxtFolio.Text)
+ If ObjContaAC.AddMovimiento(IdPoliza, dr("IdCuentaEjercido").ToString.ToEntero, False, MultiplicadorNC * Total, "", ConceptoRenglon, 0, TxtFechaPago.Text.ToDate, "") Then
+ 'actualizo el idcuenta del presupuesto
+ If Not ObjContaAC.AddMovimiento(IdPoliza, dr("IdCuentaDevengado").ToString.ToEntero, True, MultiplicadorNC * Total, "", ConceptoRenglon, 0, TxtFechaPago.Text.ToDate, "") Then
+ TieneError = True
+ Exit For
+ End If
+ Else
+ TieneError = True
+ Exit For
+ End If
+ End If
+
+ 'PAGADO
+ ConceptoRenglon = String.Format("GP {0} F:{1}-{2}", DdlProveedor.SelectedItem.Text, TxtSerie.Text, TxtFolio.Text)
+ If ObjContaAC.AddMovimiento(IdPoliza, dr("IdCuentaPagado").ToString.ToEntero, False, MultiplicadorNC * Total, "", ConceptoRenglon, 0, TxtFechaPago.Text.ToDate, "") Then
+ 'actualizo el idcuenta del presupuesto
+ If Not ObjContaAC.AddMovimiento(IdPoliza, dr("IdCuentaEjercido").ToString.ToEntero, True, MultiplicadorNC * Total, "", ConceptoRenglon, 0, TxtFechaPago.Text.ToDate, "") Then
+ TieneError = True
+ Exit For
+ End If
+ Else
+ TieneError = True
+ Exit For
+ End If
+
+ End If
+ Next
+
+ Else
+ ErrorACMEnsaje.Append(" - error al obtener presupuestos ObjCompras.GetPresupuestosCompras")
+ ErrorAC = True
+ End If
+
+ End If
+ End If
+ End If
+
+
+ '' F U N C I O N A R I O S Y E M P L E A D O S
+ If RBLContado.SelectedValue = "2" AndAlso DdlFuncionarioEmpleado.SelectedValue.ToEntero > 0 Then
+ TxtDocumentoImporte.Text = TxtDocumentoImporteFE.Text
+ TxtDocumentoImporteCaja.Text = TxtDocumentoImporteFE.Text
+
+ End If
+
+ Else 'Empresa Prueba
+
+ If RBLPago.SelectedValue.ToEntero = 2 AndAlso (RBLContado.SelectedValue = "1" Or RBLContado.SelectedValue = "6") Then 'Contado - Bancos y Caja Chica
+ 'se agrego un movimiento de pago
+ ' CveIE = ObjIE.AddBancos_IE(DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero, TxtFecha.Text.Trim.ToDate, TxtDocumentoFolio.Text.Trim, DdlProveedor.SelectedItem.Text.Trim, TxtDocumentoImporte.Text.Trim.ToDouble, 1, 0.0, TxtDocumentoObservaciones.Text.Trim, True, True, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
+ If CveIE > 0 Then
+
+ 'inserto los movimientos de la conta para abonar al saldo
+
+ 'Se agregamovimiento de pago de proveedor
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteCompra, " ", CveConceptoAfectacionContado, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle) Then
+ ErrorMovtosCxP = True
+ End If
+
+ 'Compra
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TxtSubTotal2.Text.ToDecimal, " ", 30, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle) Then
+ ErrorMovtosCxP = True
+ End If
+
+ 'IVA por Acreditar . siempre se registra aunque sea cero
+ If Not ErrorMovtosCxP Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, TxtIVA.Text.ToDecimal, " ", 19, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle) Then
+ ErrorMovtosCxP = True
+ End If
+ End If
+
+ If Not ErrorMovtosCxP AndAlso TxtRetIVA.Text.ToDouble > 0 Then
+ 'Agrego el RetIVA
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TxtRetIVA.Text.ToDecimal, " ", 22, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle) Then
+ ErrorMovtosCxP = True
+ End If
+ End If
+
+ If Not ErrorMovtosCxP AndAlso TxtRetISR.Text.ToDouble > 0 Then
+ 'Agrego el RetIVA
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TxtRetISR.Text.ToDecimal, " ", 23, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva) Then
+ ErrorMovtosCxP = True
+ End If
+ End If
+
+
+ Else
+ ErrorMovtosIE = True
+ End If
+
+ End If
+
+
+ 'movimiento de compra
+ '[IPP] PARCHE PROVISIONAL DE CLASIFICACION Y SUBPROYECTO [CveClasificacion:=TmpDT.FiltroPrimeroValor("CveClasificacion").ToString.ToEntero] [CveSubProyecto:=TmpDT.FiltroPrimeroValor("CveSubProyecto").ToString.ToEntero]
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimientoCompra, TxtSubTotal2.Text.ToDecimal, " ", CveConceptoCompra, " ", TxtFechaPago.Text.ToDate, 0, -1, CveClasificacion:=TmpDT.FiltroPrimeroValor("CveClasificacion").ToString.ToEntero, CveSubProyecto:=TmpDT.FiltroPrimeroValor("CveSubProyecto").ToString.ToEntero, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtSubTotal2.Text.ToDecimal) Then
+ ErrorMovtosCxP = True
+ End If
+
+ 'Se agregan las CxP
+ If CveConceptoAfectacion = 37 Then
+ For Each rw As GridViewRow In GvDeudores.Rows
+ If rw.FCCheckBox("Chk").Checked Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimientoCompra, rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal, " ", CveConceptoAfectacion, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=rw.DataKey("CveIE").ToString.ToEntero, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal) Then
+ ErrorMovtosCxP = True
+ End If
+ End If
+ Next
+ Else
+ If ImporteCompra > 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimientoCompra, ImporteCompra, " ", CveConceptoAfectacion, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=ImporteCompra) Then
+ ErrorMovtosCxP = True
+ End If
+ End If
+
+
+ If CvePlantillaPrePoliza = 1 Or CvePlantillaPrePoliza = 60 Then
+
+ 'Siempre: Se agrega IVA aunque sea cero
+ ' If TxtIVA.Text.Replace(", ", "").Trim.ToDouble <> 0 Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimientoImpuestos, TxtIVA.Text.ToDecimal, " ", CveConceptoIVA, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtIVA.Text.ToDecimal) Then
+ ErrorMovtosIVA = True
+ End If
+ 'End If
+
+ 'Se agregan las Ret IVA
+ If TxtRetIVA.Text.ToDouble <> 0 Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimientoImpuestos, TxtRetIVA.Text.ToDecimal, " ", CveConceptoRetIVA, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtRetIVA.Text.ToDecimal) Then
+ ErrorMovtosRetIVA = True
+ End If
+ End If
+
+ 'Se agregan las Ret ISR
+ If TxtRetISR.Text.ToDouble > 0 Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimientoImpuestos, TxtRetISR.Text.ToDecimal, " ", CveConceptoRetISR, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtRetISR.Text.ToDecimal) Then
+ ErrorMovtosRetISR = True
+ End If
+ End If
+
+ If TxtIEPS.Text.ToDouble > 0 Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimientoImpuestos, TxtIEPS.Text.ToDecimal, " ", CveConceptoRetIEPS, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtIEPS.Text.ToDecimal) Then
+ ErrorMovtosRetISR = True
+ End If
+ End If
+
+ If TxtOtrosImpuestos.Text.ToDouble > 0 Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimientoImpuestos, TxtOtrosImpuestos.Text.ToDecimal, " ", CveConceptoRetOtrosImpuestos, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtOtrosImpuestos.Text.ToDecimal) Then
+ ErrorMovtosRetISR = True
+ End If
+ End If
+
+ End If
+
+
+ '' A N T I C I P O S
If ArrAnticipos.Count > 0 Then
+ Dim TotalIVA As Double = TxtIVA.Text.ToDouble
+
+ 'Inserto otra poliza del mo
+ 'Dim CvePrePolizaAnticipo As Integer = ObjConta.AddPrePolizas("Banc", 10, ImporteAnticipo, ImporteAnticipo, DdlMoneda.SelectedValue.ToEntero, TxtFecha.Text.ToDate, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
+
+ ' CveConceptoAfectacion = 21 'Cancelacion Anticipo Proveedores
Dim PorcentajePago As Decimal
+ Dim CveConceptoAnt As Integer = 21
+ Dim CveCompraNC As Integer
+ For Each Ant As Anticipos In ArrAnticipos
+ CveCompraNC = CveCompra
+ Dim CveConceptoPago As Integer = 17
+ Select Case Ant.TipoMovto
+ Case "NC", "DEV"
+ CveConceptoAnt = 60
+ CveCompraNC = Ant.CveCompra ' cuando es NC, se utiliza la clave de compra de la nota de credito
+ CveConceptoPago = 272
+ Case "Egsc"
+ CveConceptoAnt = 21
+ Case "DD"
+ CveConceptoAnt = 37
+
+ End Select
+
+ If ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Ant.Importe, " ", CveConceptoAnt, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompraNC, CveCompraAmortizacion:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=Ant.Importe) Then
+ ' ImporteAnticipo += Ant.Importe ' RESTO DEL IMPORTE POR SI QUEDA DIFERENCIA DE LA SUMA DE LOS ANTICIPOS Y EL PROVEEDOR TIENE QUE PAGAR
+ 'movimiento de pago proveedor, --no se regisra porque no se registra el total de la compra como deuda del proveedor, solo lo que queda a deber
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimientoCompra, Ant.Importe, " ", CveConceptoPago, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=Ant.Importe) Then
+ ErrorMovtosCxP = True
+ End If
+ PorcentajePago = (Ant.Importe) / TxtTotal.Text.ToDecimal
+
+ 'IVA por Acreditar . siempre se registra aunque sea cero
+ If Not ErrorMovtosCxP Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, TxtIVA.Text.ToDecimal * PorcentajePago, " ", 19, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtIVA.Text.ToDecimal * PorcentajePago) Then ErrorMovtosCxP = True
+ End If
+
+ 'Agrego el RetIVA
+ If Not ErrorMovtosCxP AndAlso TxtRetIVA.Text.ToDouble > 0 Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TxtRetIVA.Text.ToDecimal * PorcentajePago, " ", 22, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtRetIVA.Text.ToDecimal * PorcentajePago) Then ErrorMovtosCxP = True
+ End If
+
+ 'Agrego el RetISR
+ If Not ErrorMovtosCxP AndAlso TxtRetISR.Text.ToDouble > 0 Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TxtRetISR.Text.ToDecimal * PorcentajePago, " ", 23, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, ImporteMX:=TxtRetISR.Text.ToDecimal * PorcentajePago) Then ErrorMovtosCxP = True
+ End If
+ Else
+ ErrorMovtosCxP = True
+ End If
+ Next
+
Dim ConceptoRenglon As String
'si hay una diferencia entre lo amortizado y el total, se registra la diferencia a proveedores y los ivas por acreditar
If TxtTotal.Text.ToDouble - ImporteAnticipo > 0 Then
PorcentajePago = (TxtTotal.Text.ToDecimal - ImporteAnticipo) / TxtTotal.Text.ToDecimal
- ConceptoRenglon = String.Format("GE Fact: {0}-{1} {2}", TxtSerie.Text.Trim, TxtFolio.Text.Trim, DdlProveedor.SelectedItem.Text)
- If Not ObjContaAC.AddMovimiento(IdPoliza, CtaProveedor, True, TxtTotal.Text.ToDouble - ImporteAnticipo, "", ConceptoRenglon, 0, TxtFechaPago.Text.ToDate, "") Then
- ErrorACMEnsaje.Append(" - si hay una diferencia entre lo amortizado y el total, se registra la diferencia a proveedores y los ivas por acreditar ObjContaAC.AddMovimiento")
- ErrorAC = True
+ 'Siempre: Se agrega IVA aunque sea cero
+ If TxtIVA.Text.ToDouble <> 0 Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, TxtIVA.Text.ToDecimal * PorcentajePago, " ", CveConceptoIVA, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtIVA.Text.ToDecimal * PorcentajePago) Then
+ ErrorMovtosIVA = True
+ End If
+ End If
+
+ 'Se agregan las Ret IVA
+ If TxtRetIVA.Text.ToDouble <> 0 Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TxtRetIVA.Text.ToDecimal * PorcentajePago, " ", CveConceptoRetIVA, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtRetIVA.Text.ToDecimal * PorcentajePago) Then
+ ErrorMovtosRetIVA = True
+ End If
+ End If
+
+ 'Se agregan las Ret ISR
+ If TxtRetISR.Text.ToDouble > 0 Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TxtRetISR.Text.ToDecimal * PorcentajePago, " ", CveConceptoRetISR, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtRetISR.Text.ToDecimal * PorcentajePago) Then
+ ErrorMovtosRetISR = True
+ End If
+ End If
+
+ If UsuarioActual.Empresa.UsaAC Then
+ If CtaProveedor > 0 Then
+ ConceptoRenglon = String.Format("GD Fact: {0}-{1} {2}", TxtSerie.Text.Trim, TxtFolio.Text.Trim, DdlProveedor.SelectedItem.Text)
+ If Not ObjContaAC.AddMovimiento(IdPoliza, CtaProveedor, True, TxtTotal.Text.ToDouble - ImporteAnticipo, "", ConceptoRenglon, 0, TxtFechaPago.Text.ToDate, "") Then
+ ErrorAC = True
+ ErrorACMEnsaje.Append("- CtaProveedor > 0 ObjContaAC.AddMovimiento")
+ End If
+ Else
+ Alert(" - El proveedor no tiene cuenta contable.", TipoMensaje.MsgAdvertencia)
+
+ ErrorAC = True
+ End If
End If
End If
'una vez amortizado, se generan los movimientos presupuestales
- If ImporteAnticipo > 0 Then
+
+ If UsuarioActual.Empresa.UsaAC AndAlso ImporteAnticipo > 0 Then
+
+
PorcentajePago = ImporteAnticipo / TxtTotal.Text.ToDecimal
+
If ObjCompras.GetPresupuestosCompras(CveCompra) AndAlso ObjCompras.DtResultados.Rows.Count > 0 Then
'DtAC.Merge(ObjConta.DtResultados)
+
For Each dr As DataRow In ObjCompras.DtResultados.Rows
Total = dr("TotalPresupuesto").ToString.ToDecimal * PorcentajePago
+
If Total > 0 Then
'EJERCIDO
If True Then
+
ConceptoRenglon = String.Format("GE {0} F:{1}-{2}", DdlProveedor.SelectedItem.Text, TxtSerie.Text, TxtFolio.Text)
If ObjContaAC.AddMovimiento(IdPoliza, dr("IdCuentaEjercido").ToString.ToEntero, False, MultiplicadorNC * Total, "", ConceptoRenglon, 0, TxtFechaPago.Text.ToDate, "") Then
'actualizo el idcuenta del presupuesto
@@ -7067,6 +7337,7 @@ Partial Class Compras_Compras
TieneError = True
Exit For
End If
+
Else
TieneError = True
Exit For
@@ -7090,634 +7361,365 @@ Partial Class Compras_Compras
Next
Else
- ErrorACMEnsaje.Append(" - error al obtener presupuestos ObjCompras.GetPresupuestosCompras")
+ ErrorACMEnsaje.Append("- error al obtener presupuestos 2")
ErrorAC = True
End If
-
End If
+
End If
- End If
- '' F U N C I O N A R I O S Y E M P L E A D O S
- If RBLContado.SelectedValue = "2" AndAlso DdlFuncionarioEmpleado.SelectedValue.ToEntero > 0 Then
- TxtDocumentoImporte.Text = TxtDocumentoImporteFE.Text
- TxtDocumentoImporteCaja.Text = TxtDocumentoImporteFE.Text
+ '' F U N C I O N A R I O S Y E M P L E A D O S
+ If RBLContado.SelectedValue = "2" AndAlso DdlFuncionarioEmpleado.SelectedValue.ToEntero > 0 Then
+ 'Si es con funcionarios empleados Ya existe un registro en Bancos de Ingresos Egresos
+ TxtDocumentoImporte.Text = TxtDocumentoImporteFE.Text
+ TxtDocumentoImporteCaja.Text = TxtDocumentoImporteFE.Text
- End If
+ Dim ImportePagadoFE As Decimal = 0
+ Dim ImporteAPagarFE As Decimal = TxtDocumentoImporteFE.Text.ToDecimal
+ Dim ImportePagar As Decimal = ImporteAPagarFE
- Else 'Empresa Prueba
-
- If RBLPago.SelectedValue.ToEntero = 2 AndAlso (RBLContado.SelectedValue = "1" Or RBLContado.SelectedValue = "6") Then 'Contado - Bancos y Caja Chica
- 'se agrego un movimiento de pago
- ' CveIE = ObjIE.AddBancos_IE(DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero, TxtFecha.Text.Trim.ToDate, TxtDocumentoFolio.Text.Trim, DdlProveedor.SelectedItem.Text.Trim, TxtDocumentoImporte.Text.Trim.ToDouble, 1, 0.0, TxtDocumentoObservaciones.Text.Trim, True, True, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
- If CveIE > 0 Then
-
- 'inserto los movimientos de la conta para abonar al saldo
-
- 'Se agregamovimiento de pago de proveedor
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteCompra, " ", CveConceptoAfectacionContado, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle) Then
- ErrorMovtosCxP = True
- End If
-
- 'Compra
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TxtSubTotal2.Text.ToDecimal, " ", 30, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle) Then
- ErrorMovtosCxP = True
- End If
-
- 'IVA por Acreditar . siempre se registra aunque sea cero
- If Not ErrorMovtosCxP Then
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, TxtIVA.Text.ToDecimal, " ", 19, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle) Then
+ 'CvePrePoliza = ObjConta.AddPrePolizas("Banc", 2, ImporteAPagarFE, ImporteAPagarFE, DdlMoneda.SelectedValue.ToEntero, TxtFecha.Text.ToDate, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
+ If CvePrePoliza > 0 Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImportePagar, " ", 29, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CvePersonal:=DdlFuncionarioEmpleado.SelectedValue.ToEntero, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveColectiva:=CveColectiva, CveIE:=CveIE, ImporteMX:=ImportePagar) Then
ErrorMovtosCxP = True
End If
- End If
-
- If Not ErrorMovtosCxP AndAlso TxtRetIVA.Text.ToDouble > 0 Then
- 'Agrego el RetIVA
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TxtRetIVA.Text.ToDecimal, " ", 22, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle) Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImportePagar, " ", 17, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CvePersonal:=DdlFuncionarioEmpleado.SelectedValue.ToEntero, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveColectiva:=CveColectiva, CveIE:=CveIE, ImporteMX:=ImportePagar) Then
ErrorMovtosCxP = True
End If
- End If
-
- If Not ErrorMovtosCxP AndAlso TxtRetISR.Text.ToDouble > 0 Then
- 'Agrego el RetIVA
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TxtRetISR.Text.ToDecimal, " ", 23, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva) Then
- ErrorMovtosCxP = True
- End If
- End If
- Else
- ErrorMovtosIE = True
- End If
-
- End If
-
-
- 'movimiento de compra
- '[IPP] PARCHE PROVISIONAL DE CLASIFICACION Y SUBPROYECTO [CveClasificacion:=TmpDT.FiltroPrimeroValor("CveClasificacion").ToString.ToEntero] [CveSubProyecto:=TmpDT.FiltroPrimeroValor("CveSubProyecto").ToString.ToEntero]
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimientoCompra, TxtSubTotal2.Text.ToDecimal, " ", CveConceptoCompra, " ", TxtFechaPago.Text.ToDate, 0, -1, CveClasificacion:=TmpDT.FiltroPrimeroValor("CveClasificacion").ToString.ToEntero, CveSubProyecto:=TmpDT.FiltroPrimeroValor("CveSubProyecto").ToString.ToEntero, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtSubTotal2.Text.ToDecimal) Then
- ErrorMovtosCxP = True
- End If
-
- 'Se agregan las CxP
- If CveConceptoAfectacion = 37 Then
- For Each rw As GridViewRow In GvDeudores.Rows
- If rw.FCCheckBox("Chk").Checked Then
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimientoCompra, rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal, " ", CveConceptoAfectacion, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=rw.DataKey("CveIE").ToString.ToEntero, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal) Then
- ErrorMovtosCxP = True
- End If
- End If
- Next
- Else
- If ImporteCompra > 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimientoCompra, ImporteCompra, " ", CveConceptoAfectacion, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=ImporteCompra) Then
- ErrorMovtosCxP = True
- End If
- End If
-
-
- If CvePlantillaPrePoliza = 1 Or CvePlantillaPrePoliza = 60 Then
-
- 'Siempre: Se agrega IVA aunque sea cero
- ' If TxtIVA.Text.Replace(", ", "").Trim.ToDouble <> 0 Then
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimientoImpuestos, TxtIVA.Text.ToDecimal, " ", CveConceptoIVA, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtIVA.Text.ToDecimal) Then
- ErrorMovtosIVA = True
- End If
- 'End If
-
- 'Se agregan las Ret IVA
- If TxtRetIVA.Text.ToDouble <> 0 Then
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimientoImpuestos, TxtRetIVA.Text.ToDecimal, " ", CveConceptoRetIVA, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtRetIVA.Text.ToDecimal) Then
- ErrorMovtosRetIVA = True
- End If
- End If
-
- 'Se agregan las Ret ISR
- If TxtRetISR.Text.ToDouble > 0 Then
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimientoImpuestos, TxtRetISR.Text.ToDecimal, " ", CveConceptoRetISR, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtRetISR.Text.ToDecimal) Then
- ErrorMovtosRetISR = True
- End If
- End If
-
- If TxtIEPS.Text.ToDouble > 0 Then
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimientoImpuestos, TxtIEPS.Text.ToDecimal, " ", CveConceptoRetIEPS, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtIEPS.Text.ToDecimal) Then
- ErrorMovtosRetISR = True
- End If
- End If
-
- If TxtOtrosImpuestos.Text.ToDouble > 0 Then
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimientoImpuestos, TxtOtrosImpuestos.Text.ToDecimal, " ", CveConceptoRetOtrosImpuestos, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtOtrosImpuestos.Text.ToDecimal) Then
- ErrorMovtosRetISR = True
- End If
- End If
-
- End If
-
-
- '' A N T I C I P O S
- If ArrAnticipos.Count > 0 Then
-
- Dim TotalIVA As Double = TxtIVA.Text.ToDouble
-
- 'Inserto otra poliza del mo
- 'Dim CvePrePolizaAnticipo As Integer = ObjConta.AddPrePolizas("Banc", 10, ImporteAnticipo, ImporteAnticipo, DdlMoneda.SelectedValue.ToEntero, TxtFecha.Text.ToDate, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
-
- ' CveConceptoAfectacion = 21 'Cancelacion Anticipo Proveedores
- Dim PorcentajePago As Decimal
- Dim CveConceptoAnt As Integer = 21
- Dim CveCompraNC As Integer
- For Each Ant As Anticipos In ArrAnticipos
- CveCompraNC = CveCompra
- Dim CveConceptoPago As Integer = 17
- Select Case Ant.TipoMovto
- Case "NC", "DEV"
- CveConceptoAnt = 60
- CveCompraNC = Ant.CveCompra ' cuando es NC, se utiliza la clave de compra de la nota de credito
- CveConceptoPago = 272
- Case "Egsc"
- CveConceptoAnt = 21
- Case "DD"
- CveConceptoAnt = 37
-
- End Select
-
- If ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Ant.Importe, " ", CveConceptoAnt, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompraNC, CveCompraAmortizacion:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=Ant.Importe) Then
- ' ImporteAnticipo += Ant.Importe ' RESTO DEL IMPORTE POR SI QUEDA DIFERENCIA DE LA SUMA DE LOS ANTICIPOS Y EL PROVEEDOR TIENE QUE PAGAR
- 'movimiento de pago proveedor, --no se regisra porque no se registra el total de la compra como deuda del proveedor, solo lo que queda a deber
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimientoCompra, Ant.Importe, " ", CveConceptoPago, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=Ant.Importe) Then
- ErrorMovtosCxP = True
- End If
- PorcentajePago = (Ant.Importe) / TxtTotal.Text.ToDecimal
+ Dim PorcentajePago As Decimal = (ImportePagar) / TxtTotal.Text.ToDecimal
'IVA por Acreditar . siempre se registra aunque sea cero
If Not ErrorMovtosCxP Then
+
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, TxtIVA.Text.ToDecimal * PorcentajePago, " ", 19, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtIVA.Text.ToDecimal * PorcentajePago) Then ErrorMovtosCxP = True
+
End If
- 'Agrego el RetIVA
If Not ErrorMovtosCxP AndAlso TxtRetIVA.Text.ToDouble > 0 Then
+ 'Agrego el RetIVA
+
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TxtRetIVA.Text.ToDecimal * PorcentajePago, " ", 22, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtRetIVA.Text.ToDecimal * PorcentajePago) Then ErrorMovtosCxP = True
+
End If
- 'Agrego el RetISR
If Not ErrorMovtosCxP AndAlso TxtRetISR.Text.ToDouble > 0 Then
+ 'Agrego el RetISR
+
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TxtRetISR.Text.ToDecimal * PorcentajePago, " ", 23, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, ImporteMX:=TxtRetISR.Text.ToDecimal * PorcentajePago) Then ErrorMovtosCxP = True
+
End If
+
+
+ 'sino alcanzo a cubrir se regitran los ivas por acreditar
+ If TxtTotal.Text.ToDouble - ImportePagar > 0 Then
+ PorcentajePago = (TxtTotal.Text.ToDecimal - ImportePagar) / TxtTotal.Text.ToDecimal
+ 'Movimiento, se omite, porque se esta registrando la totalidad de la deuda
+ 'If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TxtTotal.Text.ToDouble - ImporteAnticipo, " ", 5, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle) Then
+ ' ErrorMovtosCxP = True
+ 'End If
+ 'Siempre: Se agrega IVA aunque sea cero
+ If TxtIVA.Text.ToDouble <> 0 Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, TxtIVA.Text.ToDecimal * PorcentajePago, " ", CveConceptoIVA, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtIVA.Text.ToDecimal * PorcentajePago) Then
+ ErrorMovtosIVA = True
+ End If
+ End If
+
+ 'Se agregan las Ret IVA
+ If TxtRetIVA.Text.ToDouble <> 0 Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TxtRetIVA.Text.ToDecimal * PorcentajePago, " ", CveConceptoRetIVA, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtRetIVA.Text.ToDecimal * PorcentajePago) Then
+ ErrorMovtosRetIVA = True
+ End If
+ End If
+
+ 'Se agregan las Ret ISR
+ If TxtRetISR.Text.ToDouble > 0 Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TxtRetISR.Text.ToDecimal * PorcentajePago, " ", CveConceptoRetISR, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtRetISR.Text.ToDecimal * PorcentajePago) Then
+ ErrorMovtosRetISR = True
+ End If
+ End If
+
+ End If
+
Else
ErrorMovtosCxP = True
End If
- Next
-
- Dim ConceptoRenglon As String
- 'si hay una diferencia entre lo amortizado y el total, se registra la diferencia a proveedores y los ivas por acreditar
- If TxtTotal.Text.ToDouble - ImporteAnticipo > 0 Then
- PorcentajePago = (TxtTotal.Text.ToDecimal - ImporteAnticipo) / TxtTotal.Text.ToDecimal
- 'Siempre: Se agrega IVA aunque sea cero
- If TxtIVA.Text.ToDouble <> 0 Then
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, TxtIVA.Text.ToDecimal * PorcentajePago, " ", CveConceptoIVA, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtIVA.Text.ToDecimal * PorcentajePago) Then
- ErrorMovtosIVA = True
- End If
- End If
-
- 'Se agregan las Ret IVA
- If TxtRetIVA.Text.ToDouble <> 0 Then
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TxtRetIVA.Text.ToDecimal * PorcentajePago, " ", CveConceptoRetIVA, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtRetIVA.Text.ToDecimal * PorcentajePago) Then
- ErrorMovtosRetIVA = True
- End If
- End If
-
- 'Se agregan las Ret ISR
- If TxtRetISR.Text.ToDouble > 0 Then
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TxtRetISR.Text.ToDecimal * PorcentajePago, " ", CveConceptoRetISR, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtRetISR.Text.ToDecimal * PorcentajePago) Then
- ErrorMovtosRetISR = True
- End If
- End If
-
- If UsuarioActual.Empresa.UsaAC Then
- If CtaProveedor > 0 Then
- ConceptoRenglon = String.Format("GD Fact: {0}-{1} {2}", TxtSerie.Text.Trim, TxtFolio.Text.Trim, DdlProveedor.SelectedItem.Text)
- If Not ObjContaAC.AddMovimiento(IdPoliza, CtaProveedor, True, TxtTotal.Text.ToDouble - ImporteAnticipo, "", ConceptoRenglon, 0, TxtFechaPago.Text.ToDate, "") Then
- ErrorAC = True
- ErrorACMEnsaje.Append("- CtaProveedor > 0 ObjContaAC.AddMovimiento")
- End If
- Else
- Alert(" - El proveedor no tiene cuenta contable.", TipoMensaje.MsgAdvertencia)
-
- ErrorAC = True
- End If
- End If
End If
- 'una vez amortizado, se generan los movimientos presupuestales
+ End If 'Empresa Prueba
- If UsuarioActual.Empresa.UsaAC AndAlso ImporteAnticipo > 0 Then
+ '************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
-
- PorcentajePago = ImporteAnticipo / TxtTotal.Text.ToDecimal
-
- If ObjCompras.GetPresupuestosCompras(CveCompra) AndAlso ObjCompras.DtResultados.Rows.Count > 0 Then
- 'DtAC.Merge(ObjConta.DtResultados)
-
- For Each dr As DataRow In ObjCompras.DtResultados.Rows
- Total = dr("TotalPresupuesto").ToString.ToDecimal * PorcentajePago
-
- If Total > 0 Then
-
- 'EJERCIDO
- If True Then
-
- ConceptoRenglon = String.Format("GE {0} F:{1}-{2}", DdlProveedor.SelectedItem.Text, TxtSerie.Text, TxtFolio.Text)
- If ObjContaAC.AddMovimiento(IdPoliza, dr("IdCuentaEjercido").ToString.ToEntero, False, MultiplicadorNC * Total, "", ConceptoRenglon, 0, TxtFechaPago.Text.ToDate, "") Then
- 'actualizo el idcuenta del presupuesto
- If Not ObjContaAC.AddMovimiento(IdPoliza, dr("IdCuentaDevengado").ToString.ToEntero, True, MultiplicadorNC * Total, "", ConceptoRenglon, 0, TxtFechaPago.Text.ToDate, "") Then
- TieneError = True
- Exit For
- End If
-
- Else
- TieneError = True
- Exit For
- End If
- End If
-
- 'PAGADO
- ConceptoRenglon = String.Format("GP {0} F:{1}-{2}", DdlProveedor.SelectedItem.Text, TxtSerie.Text, TxtFolio.Text)
- If ObjContaAC.AddMovimiento(IdPoliza, dr("IdCuentaPagado").ToString.ToEntero, False, MultiplicadorNC * Total, "", ConceptoRenglon, 0, TxtFechaPago.Text.ToDate, "") Then
- 'actualizo el idcuenta del presupuesto
- If Not ObjContaAC.AddMovimiento(IdPoliza, dr("IdCuentaEjercido").ToString.ToEntero, True, MultiplicadorNC * Total, "", ConceptoRenglon, 0, TxtFechaPago.Text.ToDate, "") Then
- TieneError = True
- Exit For
- End If
- Else
- TieneError = True
- Exit For
- End If
-
- End If
- Next
-
- Else
- ErrorACMEnsaje.Append("- error al obtener presupuestos 2")
- ErrorAC = True
- End If
- End If
-
- End If
-
-
- '' F U N C I O N A R I O S Y E M P L E A D O S
- If RBLContado.SelectedValue = "2" AndAlso DdlFuncionarioEmpleado.SelectedValue.ToEntero > 0 Then
- 'Si es con funcionarios empleados Ya existe un registro en Bancos de Ingresos Egresos
- TxtDocumentoImporte.Text = TxtDocumentoImporteFE.Text
- TxtDocumentoImporteCaja.Text = TxtDocumentoImporteFE.Text
-
- Dim ImportePagadoFE As Decimal = 0
- Dim ImporteAPagarFE As Decimal = TxtDocumentoImporteFE.Text.ToDecimal
- Dim ImportePagar As Decimal = ImporteAPagarFE
-
- 'CvePrePoliza = ObjConta.AddPrePolizas("Banc", 2, ImporteAPagarFE, ImporteAPagarFE, DdlMoneda.SelectedValue.ToEntero, TxtFecha.Text.ToDate, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
- If CvePrePoliza > 0 Then
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImportePagar, " ", 29, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CvePersonal:=DdlFuncionarioEmpleado.SelectedValue.ToEntero, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveColectiva:=CveColectiva, CveIE:=CveIE, ImporteMX:=ImportePagar) Then
- ErrorMovtosCxP = True
- End If
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImportePagar, " ", 17, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CvePersonal:=DdlFuncionarioEmpleado.SelectedValue.ToEntero, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveColectiva:=CveColectiva, CveIE:=CveIE, ImporteMX:=ImportePagar) Then
- ErrorMovtosCxP = True
- End If
-
-
- Dim PorcentajePago As Decimal = (ImportePagar) / TxtTotal.Text.ToDecimal
-
- 'IVA por Acreditar . siempre se registra aunque sea cero
- If Not ErrorMovtosCxP Then
-
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, TxtIVA.Text.ToDecimal * PorcentajePago, " ", 19, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtIVA.Text.ToDecimal * PorcentajePago) Then ErrorMovtosCxP = True
-
- End If
-
- If Not ErrorMovtosCxP AndAlso TxtRetIVA.Text.ToDouble > 0 Then
- 'Agrego el RetIVA
-
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TxtRetIVA.Text.ToDecimal * PorcentajePago, " ", 22, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtRetIVA.Text.ToDecimal * PorcentajePago) Then ErrorMovtosCxP = True
-
- End If
-
- If Not ErrorMovtosCxP AndAlso TxtRetISR.Text.ToDouble > 0 Then
- 'Agrego el RetISR
-
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TxtRetISR.Text.ToDecimal * PorcentajePago, " ", 23, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, ImporteMX:=TxtRetISR.Text.ToDecimal * PorcentajePago) Then ErrorMovtosCxP = True
-
- End If
-
-
- 'sino alcanzo a cubrir se regitran los ivas por acreditar
- If TxtTotal.Text.ToDouble - ImportePagar > 0 Then
- PorcentajePago = (TxtTotal.Text.ToDecimal - ImportePagar) / TxtTotal.Text.ToDecimal
- 'Movimiento, se omite, porque se esta registrando la totalidad de la deuda
- 'If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TxtTotal.Text.ToDouble - ImporteAnticipo, " ", 5, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle) Then
- ' ErrorMovtosCxP = True
- 'End If
- 'Siempre: Se agrega IVA aunque sea cero
- If TxtIVA.Text.ToDouble <> 0 Then
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, TxtIVA.Text.ToDecimal * PorcentajePago, " ", CveConceptoIVA, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtIVA.Text.ToDecimal * PorcentajePago) Then
- ErrorMovtosIVA = True
- End If
- End If
-
- 'Se agregan las Ret IVA
- If TxtRetIVA.Text.ToDouble <> 0 Then
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TxtRetIVA.Text.ToDecimal * PorcentajePago, " ", CveConceptoRetIVA, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtRetIVA.Text.ToDecimal * PorcentajePago) Then
- ErrorMovtosRetIVA = True
- End If
- End If
-
- 'Se agregan las Ret ISR
- If TxtRetISR.Text.ToDouble > 0 Then
- If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TxtRetISR.Text.ToDecimal * PorcentajePago, " ", CveConceptoRetISR, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=TxtRetISR.Text.ToDecimal * PorcentajePago) Then
- ErrorMovtosRetISR = True
- End If
- End If
-
- End If
-
- Else
- ErrorMovtosCxP = True
- End If
-
-
- End If
-
- End If 'Empresa Prueba
-
- '************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
-
- 'End If
- Else
- ErrorMovtosCxP = True
- End If
-
-
- End If
-
- If HdnVCveOC.Value <> "-1" AndAlso HdnCveEstatusOC.Value <> "-1" Then
- Dim ArrayCveOC As String() = HdnVCveOC.Value.Split(New Char() {","c})
- Dim ArrayCveEstatusOC As String() = HdnCveEstatusOC.Value.Split(New Char() {","c})
-
- If ArrayCveEstatusOC.Count = ArrayCveOC.Count Then
- For i = 0 To ArrayCveEstatusOC.Count - 1
- If Not ObjOC.UpdateOrdenCompraCompletada(ArrayCveEstatusOC(i).ToEntero, ArrayCveOC(i).ToEntero, UsuarioActual.CveUsuario, "Se vinculó Compra", CveCompra) Then
- ErrorOC = True
- Exit For
- End If
- Next
- Else
- ErrorOC = True
- End If
-
- End If
-
- If ChkNCInvNC.Checked Then
- For Each Gvr As GridViewRow In GVNCInv.Rows
- If Gvr.FCTextBox("TxtCantidadNCInv").Text.ToDouble > 0 Then
- If Not ObjCompras.ComprasDetalleDevolucionesAdd(Gvr.DataKey("CveCompraDetalle").ToEntero, CveCompra, Gvr.FCTextBox("TxtCantidadNCInv").Text.ToDouble, UsuarioActual.CveEmpresa) Then
- ErrorMovInv = True
- Exit For
- End If
+ 'End If
+ Else
+ ErrorMovtosCxP = True
End If
- Next
- End If
- 'GUARDA BITACORA TIPO CAMBIO OC
- If Not ErrorOC And TipoCambioOC > 0 Then
- If Not ObjEventos.AddEventoBitacora(String.Format("La vinculación con la orden de compra fue con un tipo de cambio de: ${0}", TipoCambioOC.ToString), "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra:=CveCompra) Then
- ErrorOC = True
- End If
- End If
-
-
- If tDTAcarreos.Rows.Count > 0 Then
- If TotAcarreos = TxtSubTotal.Text.ToDouble Then
- 'ACARREOS
- For Each tDTAcar As DataRow In tDTAcarreos.Rows
- If Not ObjAcar.UpdatePreEstimacion(CInt(tDTAcar("CvePreEstimacion")), CveCompra) Then
- ErrorAddAcarreos = True
- Exit For
- End If
- Next
- Else
- ErrorAddAcarreos = True
- End If
- End If
-
- 'AGREGAR OTROS GASTOS A ORDEN DE CORTE
- If CveOrdenCorte > 0 And UsuarioActual.CveEmpresa = 126 Then
- If ObjCGame.AddCorteGasto(CveOrdenCorte, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, Now, 0, CveCompra) Then
- If Not ObjCGame.AddCorteGastoDetalle(ObjCGame.CveCorteGasto, 32, 1, TxtSubTotal.Text.ToDouble()) Then
- ErrorOtrosGastos = True
- End If
- Else
- ErrorOtrosGastos = True
- End If
- End If
-
- 'CREDITO COMPRA
- Dim CvePrePolizaCredito = 0
- If RBLPago.SelectedValue.ToEntero = 2 AndAlso RBLContado.SelectedValue.ToEntero = 3 AndAlso DdlTipoCredito.SelectedValue.ToEntero = 1 AndAlso DdlCredito.SelectedValue.ToEntero > 0 Then
-
- If Not ObjIE.UpdateCreditosCompra(DdlCredito.SelectedValue.ToEntero, CveCompra, UsuarioActual.CveEmpresa) Then
- ErrorCreditosCompra = True
End If
- If Not ErrorCreditosCompra Then
+ If HdnVCveOC.Value <> "-1" AndAlso HdnCveEstatusOC.Value <> "-1" Then
+ Dim ArrayCveOC As String() = HdnVCveOC.Value.Split(New Char() {","c})
+ Dim ArrayCveEstatusOC As String() = HdnCveEstatusOC.Value.Split(New Char() {","c})
- If ObjIE.GetCreditos(DdlCredito.SelectedValue.ToEntero, -1, -1, -1, -1, UsuarioActual.CveEmpresa) Then
- CvePrePolizaCredito = ObjConta.AddPrePolizas("Compras/RegistrarCredito", -1, ObjIE.TotalFinanciado, ObjIE.TotalFinanciado, 1, TxtFecha.Text.ToDate, "Vinculación crédito con factura", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
- If ObjConta.AddPrePolizasDetalle(CvePrePolizaCredito, False, ObjIE.TotalFinanciado.ToDecimal, "", 17, "Vinculación crédito con factura", TxtFecha.Text.ToDate, CtaProveedor, -1, CveProveedor:=CveProveedor, CveCompra:=CveCompra, ImporteMX:=ObjIE.TotalFinanciado.ToDecimal, CvePrePolizaOriginal:=CvePrePolizaCredito) Then
- If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaCredito, True, ObjIE.TotalFinanciado.ToDecimal, "", 50, "Vinculación crédito con factura", TxtFecha.Text.ToDate, CtaProveedor, -1, CveProveedor:=CveProveedor, CveCompra:=CveCompra, ImporteMX:=ObjIE.TotalFinanciado.ToDecimal, CvePrePolizaOriginal:=CvePrePolizaCredito) Then
- ErrorCreditosCompra = True
+ If ArrayCveEstatusOC.Count = ArrayCveOC.Count Then
+ For i = 0 To ArrayCveEstatusOC.Count - 1
+ If Not ObjOC.UpdateOrdenCompraCompletada(ArrayCveEstatusOC(i).ToEntero, ArrayCveOC(i).ToEntero, UsuarioActual.CveUsuario, "Se vinculó Compra", CveCompra) Then
+ ErrorOC = True
+ Exit For
End If
- Else
- ErrorCreditosCompra = True
- End If
-
- If Not ErrorCreditosCompra Then
- ObjConta.PrePolizaUnificacion(CvePrePoliza, CvePrePolizaCredito)
- End If
-
- End If
- End If
-
- End If
-
-
-
-
- 'VALIDAR ERRORES
- If ErrorAC OrElse ErrorPrepoliza OrElse ErrorPrepolizaDescuadre OrElse ErrorDetalles OrElse ErrorMovDev OrElse ErrorMovtosCxP OrElse ErrorMovtosRetIVA OrElse ErrorMovtosRetISR OrElse ErrorMovtosEstimaciones OrElse ErrorMovtosIE OrElse ErrorMovtosIVA OrElse ErrorMovInv OrElse TieneError OrElse ErrorAF OrElse ErrorOC OrElse ErrorBitacora OrElse ErrorAddAcarreos OrElse ErrorCreditosCompra Then
- If ErrorDetalles Then
- Alert("Ocurrió un Error al agregar un Producto o Servicio a la Factura. Revise su factura y cualquier detalle comuníquese a Soporte Técnico", TipoMensaje.MsgAdvertencia)
- ElseIf ErrorMovtosCxP Then
- Alert("Ocurrió un Error al agregar las CxP. Revise su factura y cualquier detalle comuníquese a Soporte Técnico", TipoMensaje.MsgAdvertencia)
- ElseIf ErrorMovtosRetIVA Then
- Alert("Ocurrió un Error al agregar las Retenciones de IVA. Revise su factura y cualquier detalle comuníquese a Soporte Técnico", TipoMensaje.MsgAdvertencia)
- ElseIf ErrorMovtosRetISR Then
- Alert("Ocurrió un Error al agregar las Retenciones de ISR. Revise su factura y cualquier detalle comuníquese a Soporte Técnico", TipoMensaje.MsgAdvertencia)
- ElseIf ErrorMovtosEstimaciones Then
- Alert("Ocurrió un Error al agregar las Estimaciones. Revise su factura y cualquier detalle comuníquese a Soporte Técnico", TipoMensaje.MsgAdvertencia)
- ElseIf ErrorMovtosIE Then
- Alert("Ocurrió un Error al agregar el movimiento bancario. Revise sus datos y cualquier detalle comuníquese a Soporte Técnico", TipoMensaje.MsgAdvertencia)
- ElseIf ErrorMovtosIVA Then
- Alert("Ocurrió un Error al agregar el IVA. Revise su factura y cualquier detalle comuníquese a Soporte Técnico", TipoMensaje.MsgAdvertencia)
- ElseIf ErrorMovInv Then
- Alert("Ocurrió un Error al agregar el Producto o Servicio al Inventario. Revise su factura y cualquier detalle comuníquese a Soporte Técnico", TipoMensaje.MsgAdvertencia)
- ElseIf TieneError Then
- Alert("El total de los IMPORTES del FINANCIAMIENTO debe ser mayor que 0 y menor o igual al total de la compra", TipoMensaje.MsgAdvertencia)
- ElseIf ErrorAF Then
- Alert("Error al actualizar la vinculacion del Activo Fijo", TipoMensaje.MsgAdvertencia)
- ElseIf ErrorAC Then
- Alert("Ocurrió un Error al insertar los movimientos contables.", TipoMensaje.MsgError)
- GuardaLog($" Error Compras DESCRIPCIÓN DETALLADA: {ErrorACMEnsaje.ToString} {vbCrLf} Usuario={UsuarioActual.CveUsuario}, Empresa={UsuarioActual.CveEmpresa}, CveFactura={CveFactura}, CveProveedor={CveProveedor}")
- ElseIf ErrorPrepolizaDescuadre Then
- Alert(ObjConta.MensajePolizaDescuadre, TipoMensaje.MsgError)
- ElseIf ErrorPrepoliza Then
- Alert("Ocurrió un error al verificar los movimientos contables", TipoMensaje.MsgError)
- ElseIf ErrorOC Then
- Alert("Ocurrió un Error al vincular la Orden(es) de Compra. Por favor vuelva intentar.", TipoMensaje.MsgError)
- ElseIf ErrorBitacora Then
- Alert("Ocurrió un Error al guardar la refacturación.", TipoMensaje.MsgError)
- ElseIf ErrorAddAcarreos Then
- Alert("Ocurrio un Error al momento de agregar los acarreos.", TipoMensaje.MsgError)
- ElseIf ErrorCreditosCompra Then
- Alert("Ocurrió un Error al vincular la compra con el crédito.", TipoMensaje.MsgError)
- ElseIf ErrorOtrosGastos Then
- Alert("Ocurrió un Error al vincular la compra con la orden de corte.", TipoMensaje.MsgError)
- ElseIf ErrorSATPS Then
- Alert("Ocurrió un Error al actualizar el producto/servicio SAT.", TipoMensaje.MsgError)
- ElseIf ErrorSaldosInvComp Then
- Alert("Ocurrió un error al validar la mercancía recibida por adelantado.", TipoMensaje.MsgError)
- End If
-
- ViewState("CveCompra") = -1
- ObjCompras.RollBack()
- If ObjContaAC IsNot Nothing Then ObjContaAC.RollBack()
- CargaProveedor(CveProveedor, "-1")
- Else
- Dim MsgAccionAceptar As String = ""
- Dim Msg As New StringBuilder
- Msg.Append("La compra se registró correctamente")
-
-
- 'ACTUALIZA CVEFACTURA
- If Request("CveFactura") IsNot Nothing Then
-
- If Not ObjCompras.UpdateCompraFactura(CveCompra, Request("CveFactura").ToEntero, TxtSerie.Text.Trim, TxtFolio.Text.Trim) Then
+ Next
+ Else
ErrorOC = True
End If
- If UsuarioActual.Empresa.UsaAC Then
- MsgAccionAceptar = String.Format("window.opener.location.href = window.opener.location.href; window.open(""/Contabilidad/RegPoliza.aspx?IdPoliza={0}""); window.close();", IdPoliza)
- Else
- MsgAccionAceptar = "if (window.opener){window.opener.location.href = window.opener.location.href; window.close();}"
- End If
- Else
- MsgAccionAceptar = "location.href =""Compras.aspx"""
End If
-
-
- 'CUANDO ES REEMBOLSO COMPROBACION Y CAJA CHICA
- If UsuarioActual.CveEmpresa.Contiene(1, 119) AndAlso TxtNumeroReembolso.Text.Trim <> "" AndAlso (DdlPersonalReembolso.SelectedValue.ToEntero > 0 Or DdlCuentaCajaChicaReembolso.SelectedValue.ToEntero > 0) Then
- If ObjCompras.GetComprobacion(DdlPersonalReembolso.SelectedValue.ToEntero, DdlCuentaCajaChicaReembolso.SelectedValue.ToEntero, TxtNumeroReembolso.Text.Trim, UsuarioActual.CveEmpresa) Then
- Dim CvePreComprobacion As Integer
- If ObjCompras.DtResultados.Rows.Count = 0 Then
- 'sino existe, creamos la comprobacion
- Dim tConcepto As String = If(DdlPersonalReembolso.SelectedValue.ToEntero > 0, DdlPersonalReembolso.SelectedItem.Text, DdlCuentaCajaChicaReembolso.SelectedItem.Text)
- tConcepto = String.Format("{0}-{1}", tConcepto, TxtNumeroReembolso.Text.Trim)
-
- CvePreComprobacion = ObjConta.AddPrePolizas("Compras Comproba", 1, 0, 0, 1, TxtFecha.Text.ToDate, tConcepto, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
-
- If ObjCompras.AddComprobacion(DdlPersonalReembolso.SelectedValue.ToEntero, DdlCuentaCajaChicaReembolso.SelectedValue.ToEntero, TxtNumeroReembolso.Text.Trim, CvePreComprobacion, UsuarioActual.CveEmpresa) > 0 Then
-
+ If ChkNCInvNC.Checked Then
+ For Each Gvr As GridViewRow In GVNCInv.Rows
+ If Gvr.FCTextBox("TxtCantidadNCInv").Text.ToDouble > 0 Then
+ If Not ObjCompras.ComprasDetalleDevolucionesAdd(Gvr.DataKey("CveCompraDetalle").ToEntero, CveCompra, Gvr.FCTextBox("TxtCantidadNCInv").Text.ToDouble, UsuarioActual.CveEmpresa) Then
+ ErrorMovInv = True
+ Exit For
End If
- Else
- 'si ya existe, obtenemos la prepóliza
- CvePreComprobacion = ObjCompras.DtResultados.FiltroPrimeroValor("CvePrePoliza").ToEntero
End If
-
- ObjConta.PrePolizaUnificacion(CvePreComprobacion, CvePrePoliza)
- End If
-
- End If
-
-
-
- 'AJUSTA POLIZA
- If IdPoliza > 0 Then
- ObjContaAC.AjustaPoliza(IdPoliza)
- Msg.AppendFormat("
Ver Póliza", IdPoliza)
- End If
-
- If CveMovimientoInventario > 0 Then
- Dim TempParametros = Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoInventario))
- Msg.AppendFormat("Ver Movimiento de Almacen", CveMovimientoInventario)
- Msg.AppendFormat("Imprimir Entrada Almacen", TempParametros)
- End If
-
- ObjCompras.UpdateCompraPrePoliza(TxtFecha.Text.ToDate, PolizaFolio.ToString, IdPoliza, CvePrePoliza, CveCompra, 0)
-
- If EntregaDirecta Then
- Msg.AppendFormat($"Recibir mercancía de entrega directa.")
- End If
-
- ObjCompras.Commit()
- If ObjContaAC IsNot Nothing Then ObjContaAC.Commit()
-
- Dim CveEvaluacionProveedor As Integer = -1
-
- If Me.RequiereEvaluacion Then
- Dim ObjPro As New ClsCompProveedores()
- CveEvaluacionProveedor = ObjPro.AddEvaluacionProveedor(CveProveedor, CveCompra, Now, "", Me.CveUsuarioEvaluador, "", "", UsuarioActual.CveEmpresa)
- ObjPro.Dispose()
- End If
-
- 'ENVIO DE CORREO NOTIFICACION A VENDEDORES DE OC
- MandaCorreoOCVendedores(CveCompra)
- If Not ErrorMovInv Then
- For Each intMovimientoAlmacen As Integer In ListaMovimientosAlmacen
- MandaCorreoOCVendedoresRecepcionAlmacen(CveCompra, intMovimientoAlmacen)
Next
End If
- If CveEvaluacionProveedor > 0 Then
- Msg.Append("
El proveedor tiene evaluaciones pendientes ")
- Msg.Append("¿Desea realizar una evaluacion al proveedor?")
- Msg.AppendFormat($"Evaluar Proveedor.")
+
+ 'GUARDA BITACORA TIPO CAMBIO OC
+ If Not ErrorOC And TipoCambioOC > 0 Then
+ If Not ObjEventos.AddEventoBitacora(String.Format("La vinculación con la orden de compra fue con un tipo de cambio de: ${0}", TipoCambioOC.ToString), "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra:=CveCompra) Then
+ ErrorOC = True
+ End If
End If
- Alert(Msg.ToString, TipoMensaje.MsgInformacion, MsgAccionAceptar)
+ If tDTAcarreos.Rows.Count > 0 Then
+ If TotAcarreos = TxtSubTotal.Text.ToDouble Then
+ 'ACARREOS
+ For Each tDTAcar As DataRow In tDTAcarreos.Rows
+ If Not ObjAcar.UpdatePreEstimacion(CInt(tDTAcar("CvePreEstimacion")), CveCompra) Then
+ ErrorAddAcarreos = True
+ Exit For
+ End If
+ Next
+ Else
+ ErrorAddAcarreos = True
+ End If
+ End If
+
+ 'AGREGAR OTROS GASTOS A ORDEN DE CORTE
+ If CveOrdenCorte > 0 And UsuarioActual.CveEmpresa = 126 Then
+ If ObjCGame.AddCorteGasto(CveOrdenCorte, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, Now, 0, CveCompra) Then
+ If Not ObjCGame.AddCorteGastoDetalle(ObjCGame.CveCorteGasto, 32, 1, TxtSubTotal.Text.ToDouble()) Then
+ ErrorOtrosGastos = True
+ End If
+ Else
+ ErrorOtrosGastos = True
+ End If
+ End If
+
+ 'CREDITO COMPRA
+ Dim CvePrePolizaCredito = 0
+ If RBLPago.SelectedValue.ToEntero = 2 AndAlso RBLContado.SelectedValue.ToEntero = 3 AndAlso DdlTipoCredito.SelectedValue.ToEntero = 1 AndAlso DdlCredito.SelectedValue.ToEntero > 0 Then
+
+ If Not ObjIE.UpdateCreditosCompra(DdlCredito.SelectedValue.ToEntero, CveCompra, UsuarioActual.CveEmpresa) Then
+ ErrorCreditosCompra = True
+ End If
+
+ If Not ErrorCreditosCompra Then
+
+ If ObjIE.GetCreditos(DdlCredito.SelectedValue.ToEntero, -1, -1, -1, -1, UsuarioActual.CveEmpresa) Then
+ CvePrePolizaCredito = ObjConta.AddPrePolizas("Compras/RegistrarCredito", -1, ObjIE.TotalFinanciado, ObjIE.TotalFinanciado, 1, TxtFecha.Text.ToDate, "Vinculación crédito con factura", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
+ If ObjConta.AddPrePolizasDetalle(CvePrePolizaCredito, False, ObjIE.TotalFinanciado.ToDecimal, "", 17, "Vinculación crédito con factura", TxtFecha.Text.ToDate, CtaProveedor, -1, CveProveedor:=CveProveedor, CveCompra:=CveCompra, ImporteMX:=ObjIE.TotalFinanciado.ToDecimal, CvePrePolizaOriginal:=CvePrePolizaCredito) Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaCredito, True, ObjIE.TotalFinanciado.ToDecimal, "", 50, "Vinculación crédito con factura", TxtFecha.Text.ToDate, CtaProveedor, -1, CveProveedor:=CveProveedor, CveCompra:=CveCompra, ImporteMX:=ObjIE.TotalFinanciado.ToDecimal, CvePrePolizaOriginal:=CvePrePolizaCredito) Then
+ ErrorCreditosCompra = True
+ End If
+ Else
+ ErrorCreditosCompra = True
+ End If
+
+ If Not ErrorCreditosCompra Then
+ ObjConta.PrePolizaUnificacion(CvePrePoliza, CvePrePolizaCredito)
+ End If
+
+ End If
+ End If
+
+ End If
+
+
+
+
+ 'VALIDAR ERRORES
+ If ErrorAC OrElse ErrorPrepoliza OrElse ErrorPrepolizaDescuadre OrElse ErrorDetalles OrElse ErrorMovDev OrElse ErrorMovtosCxP OrElse ErrorMovtosRetIVA OrElse ErrorMovtosRetISR OrElse ErrorMovtosEstimaciones OrElse ErrorMovtosIE OrElse ErrorMovtosIVA OrElse ErrorMovInv OrElse TieneError OrElse ErrorAF OrElse ErrorOC OrElse ErrorBitacora OrElse ErrorAddAcarreos OrElse ErrorCreditosCompra Then
+ If ErrorDetalles Then
+ Alert("Ocurrió un Error al agregar un Producto o Servicio a la Factura. Revise su factura y cualquier detalle comuníquese a Soporte Técnico", TipoMensaje.MsgAdvertencia)
+ ElseIf ErrorMovtosCxP Then
+ Alert("Ocurrió un Error al agregar las CxP. Revise su factura y cualquier detalle comuníquese a Soporte Técnico", TipoMensaje.MsgAdvertencia)
+ ElseIf ErrorMovtosRetIVA Then
+ Alert("Ocurrió un Error al agregar las Retenciones de IVA. Revise su factura y cualquier detalle comuníquese a Soporte Técnico", TipoMensaje.MsgAdvertencia)
+ ElseIf ErrorMovtosRetISR Then
+ Alert("Ocurrió un Error al agregar las Retenciones de ISR. Revise su factura y cualquier detalle comuníquese a Soporte Técnico", TipoMensaje.MsgAdvertencia)
+ ElseIf ErrorMovtosEstimaciones Then
+ Alert("Ocurrió un Error al agregar las Estimaciones. Revise su factura y cualquier detalle comuníquese a Soporte Técnico", TipoMensaje.MsgAdvertencia)
+ ElseIf ErrorMovtosIE Then
+ Alert("Ocurrió un Error al agregar el movimiento bancario. Revise sus datos y cualquier detalle comuníquese a Soporte Técnico", TipoMensaje.MsgAdvertencia)
+ ElseIf ErrorMovtosIVA Then
+ Alert("Ocurrió un Error al agregar el IVA. Revise su factura y cualquier detalle comuníquese a Soporte Técnico", TipoMensaje.MsgAdvertencia)
+ ElseIf ErrorMovInv Then
+ Alert("Ocurrió un Error al agregar el Producto o Servicio al Inventario. Revise su factura y cualquier detalle comuníquese a Soporte Técnico", TipoMensaje.MsgAdvertencia)
+ ElseIf TieneError Then
+ Alert("El total de los IMPORTES del FINANCIAMIENTO debe ser mayor que 0 y menor o igual al total de la compra", TipoMensaje.MsgAdvertencia)
+ ElseIf ErrorAF Then
+ Alert("Error al actualizar la vinculacion del Activo Fijo", TipoMensaje.MsgAdvertencia)
+ ElseIf ErrorAC Then
+ Alert("Ocurrió un Error al insertar los movimientos contables.", TipoMensaje.MsgError)
+ GuardaLog($" Error Compras DESCRIPCIÓN DETALLADA: {ErrorACMEnsaje.ToString} {vbCrLf} Usuario={UsuarioActual.CveUsuario}, Empresa={UsuarioActual.CveEmpresa}, CveFactura={CveFactura}, CveProveedor={CveProveedor}")
+ ElseIf ErrorPrepolizaDescuadre Then
+ Alert(ObjConta.MensajePolizaDescuadre, TipoMensaje.MsgError)
+ ElseIf ErrorPrepoliza Then
+ Alert("Ocurrió un error al verificar los movimientos contables", TipoMensaje.MsgError)
+ ElseIf ErrorOC Then
+ Alert("Ocurrió un Error al vincular la Orden(es) de Compra. Por favor vuelva intentar.", TipoMensaje.MsgError)
+ ElseIf ErrorBitacora Then
+ Alert("Ocurrió un Error al guardar la refacturación.", TipoMensaje.MsgError)
+ ElseIf ErrorAddAcarreos Then
+ Alert("Ocurrio un Error al momento de agregar los acarreos.", TipoMensaje.MsgError)
+ ElseIf ErrorCreditosCompra Then
+ Alert("Ocurrió un Error al vincular la compra con el crédito.", TipoMensaje.MsgError)
+ ElseIf ErrorOtrosGastos Then
+ Alert("Ocurrió un Error al vincular la compra con la orden de corte.", TipoMensaje.MsgError)
+ ElseIf ErrorSATPS Then
+ Alert("Ocurrió un Error al actualizar el producto/servicio SAT.", TipoMensaje.MsgError)
+ ElseIf ErrorSaldosInvComp Then
+ Alert("Ocurrió un error al validar la mercancía recibida por adelantado.", TipoMensaje.MsgError)
+ End If
+
+ ViewState("CveCompra") = -1
+ ObjCompras.RollBack()
+ If ObjContaAC IsNot Nothing Then ObjContaAC.RollBack()
+ CargaProveedor(CveProveedor, "-1")
+ Else
+ Dim MsgAccionAceptar As String = ""
+ Dim Msg As New StringBuilder
+ Msg.Append("La compra se registró correctamente")
+
+
+ 'ACTUALIZA CVEFACTURA
+ If Request("CveFactura") IsNot Nothing Then
+
+ If Not ObjCompras.UpdateCompraFactura(CveCompra, Request("CveFactura").ToEntero, TxtSerie.Text.Trim, TxtFolio.Text.Trim) Then
+ ErrorOC = True
+ End If
+
+ If UsuarioActual.Empresa.UsaAC Then
+ MsgAccionAceptar = String.Format("window.opener.location.href = window.opener.location.href; window.open(""/Contabilidad/RegPoliza.aspx?IdPoliza={0}""); window.close();", IdPoliza)
+ Else
+ MsgAccionAceptar = "if (window.opener){window.opener.location.href = window.opener.location.href; window.close();}"
+ End If
+ Else
+ MsgAccionAceptar = "location.href =""Compras.aspx"""
+ End If
+
+
+
+ 'CUANDO ES REEMBOLSO COMPROBACION Y CAJA CHICA
+ If UsuarioActual.CveEmpresa.Contiene(1, 119) AndAlso TxtNumeroReembolso.Text.Trim <> "" AndAlso (DdlPersonalReembolso.SelectedValue.ToEntero > 0 Or DdlCuentaCajaChicaReembolso.SelectedValue.ToEntero > 0) Then
+ If ObjCompras.GetComprobacion(DdlPersonalReembolso.SelectedValue.ToEntero, DdlCuentaCajaChicaReembolso.SelectedValue.ToEntero, TxtNumeroReembolso.Text.Trim, UsuarioActual.CveEmpresa) Then
+ Dim CvePreComprobacion As Integer
+ If ObjCompras.DtResultados.Rows.Count = 0 Then
+ 'sino existe, creamos la comprobacion
+ Dim tConcepto As String = If(DdlPersonalReembolso.SelectedValue.ToEntero > 0, DdlPersonalReembolso.SelectedItem.Text, DdlCuentaCajaChicaReembolso.SelectedItem.Text)
+ tConcepto = String.Format("{0}-{1}", tConcepto, TxtNumeroReembolso.Text.Trim)
+
+ CvePreComprobacion = ObjConta.AddPrePolizas("Compras Comproba", 1, 0, 0, 1, TxtFecha.Text.ToDate, tConcepto, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
+
+ If ObjCompras.AddComprobacion(DdlPersonalReembolso.SelectedValue.ToEntero, DdlCuentaCajaChicaReembolso.SelectedValue.ToEntero, TxtNumeroReembolso.Text.Trim, CvePreComprobacion, UsuarioActual.CveEmpresa) > 0 Then
+
+ End If
+ Else
+ 'si ya existe, obtenemos la prepóliza
+ CvePreComprobacion = ObjCompras.DtResultados.FiltroPrimeroValor("CvePrePoliza").ToEntero
+ End If
+
+ ObjConta.PrePolizaUnificacion(CvePreComprobacion, CvePrePoliza)
+ End If
+
+ End If
+
+
+
+ 'AJUSTA POLIZA
+ If IdPoliza > 0 Then
+ ObjContaAC.AjustaPoliza(IdPoliza)
+ Msg.AppendFormat("
Ver Póliza", IdPoliza)
+ End If
+
+ If CveMovimientoInventario > 0 Then
+ Dim TempParametros = Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoInventario))
+ Msg.AppendFormat("Ver Movimiento de Almacen", CveMovimientoInventario)
+ Msg.AppendFormat("Imprimir Entrada Almacen", TempParametros)
+ End If
+
+ ObjCompras.UpdateCompraPrePoliza(TxtFecha.Text.ToDate, PolizaFolio.ToString, IdPoliza, CvePrePoliza, CveCompra, 0)
+
+ If EntregaDirecta Then
+ Msg.AppendFormat($"Recibir mercancía de entrega directa.")
+ End If
+
+ ObjCompras.Commit()
+ If ObjContaAC IsNot Nothing Then ObjContaAC.Commit()
+
+ Dim CveEvaluacionProveedor As Integer = -1
+
+ If Me.RequiereEvaluacion Then
+ Dim ObjPro As New ClsCompProveedores()
+ CveEvaluacionProveedor = ObjPro.AddEvaluacionProveedor(CveProveedor, CveCompra, Now, "", Me.CveUsuarioEvaluador, "", "", UsuarioActual.CveEmpresa)
+ ObjPro.Dispose()
+ End If
+
+ 'ENVIO DE CORREO NOTIFICACION A VENDEDORES DE OC
+ MandaCorreoOCVendedores(CveCompra)
+ If Not ErrorMovInv Then
+ For Each intMovimientoAlmacen As Integer In ListaMovimientosAlmacen
+ MandaCorreoOCVendedoresRecepcionAlmacen(CveCompra, intMovimientoAlmacen)
+ Next
+ End If
+
+ If CveEvaluacionProveedor > 0 Then
+ Msg.Append("
"--%>
+
+
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 @@
-
-
-
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 @@