diff --git a/App_Code/ClsBancos.vb b/App_Code/ClsBancos.vb index 5f783d5de..dfdc4803e 100644 --- a/App_Code/ClsBancos.vb +++ b/App_Code/ClsBancos.vb @@ -1316,7 +1316,7 @@ Public Class ClsBancos Return Retorno End Function Public Function UpdateBancos_IE(FechaDocumento As DateTime, FechaAplicado As DateTime?, CveIE As Integer, Optional Folio As String = "-1", Optional CveCuentaDeposito As Integer = -1, Optional CveCuenta As Integer = -1, - Optional Observaciones As String = "-1") As Boolean + Optional Observaciones As String = "-1", Optional CveUsuarioModifico As Integer = -1) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Banc_IEUpdate") @@ -1335,9 +1335,9 @@ Public Class ClsBancos .Add("@CveCuentaDeposito", SqlDbType.Int).Value = CveCuentaDeposito .Add("@CveCuenta", SqlDbType.Int).Value = CveCuenta - .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones - - + .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones + + .Add("@CveUsuarioModifico", SqlDbType.Int).Value = CveUsuarioModifico End With diff --git a/App_Code/ClsContabilidad.vb b/App_Code/ClsContabilidad.vb index 4e56c2d74..4ab57dfa8 100644 --- a/App_Code/ClsContabilidad.vb +++ b/App_Code/ClsContabilidad.vb @@ -1,5862 +1,5890 @@ -Option Explicit On -Option Strict On - -Imports System.Data -Imports System.Data.SqlClient -Imports Extensiones -Imports System -Imports System.Configuration - -Public Class ClsContabilidad - Implements IDisposable - -#Region "Campos" - - 'SQL - Private SqlConexion As SqlConnection - Private SqlAdapter As SqlDataAdapter - Private SqlTransacc As SqlTransaction - Private SqlCommand As SqlCommand - Private Data As DataTable - Private DSet As New DataSet - - 'Atributos de la clase - - Private disposedValue As Boolean = False ' Para detectar llamadas redundantes - -#End Region - -#Region " P R O P I E D A D E S" - - Public ReadOnly Property DtResultados() As DataTable - Get - DtResultados = Data - End Get - End Property - Public ReadOnly Property DSResultados() As DataSet - Get - DSResultados = DSet - End Get - End Property - - Private Mensaje As StringBuilder - - Public ReadOnly Property AlertaMensaje As String - Get - AlertaMensaje = Mensaje.ToString - End Get - End Property - - Public Property CvePlantillaPoliza As Integer - Public Property PlantillaPoliza As String - Public Property TipoPlantilla As Integer - Public Property TipoPoliza As Integer - Public Property Orden As Integer - Public Property Estatus As String - Public Property FechaIng As DateTime - Public Property CveUsuario As Integer - Public Property Usuario As String - Public Property CveEmpresa As Integer - Public Property CveTipoPlantillaPoliza As Integer - - Public Property ContaIdPoliza As Integer - Public Property ContaFolio As Integer - - Public Property ValorPolizaDescuadre As Integer - Public Property MensajePolizaDescuadre As String - Public Property ValorDiferencia As String -#End Region - - Public Function IniciaTransacSQL() As SqlTransaction - If SqlTransacc Is Nothing Then SqlTransacc = SqlConexion.BeginTransaction() - Return SqlTransacc - End Function - - Public Sub RollBack() - If SqlTransacc IsNot Nothing Then SqlTransacc.Rollback() - SqlTransacc = Nothing - End Sub - - Public Sub Commit() - If SqlTransacc IsNot Nothing Then SqlTransacc.Commit() - SqlTransacc = Nothing - End Sub - - Sub New(Optional TransaccionCompartida As SqlTransaction = Nothing) - - If TransaccionCompartida Is Nothing Then - SqlConexion = New SqlConnection - SqlConexion.ConnectionString = ConfigurationManager.ConnectionStrings("Conexion").ConnectionString - Try - SqlConexion.Open() - Catch ex As Exception - OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex) - End Try - Else - SqlConexion = TransaccionCompartida.Connection - SqlTransacc = TransaccionCompartida - End If - Mensaje = New StringBuilder - SqlAdapter = New SqlDataAdapter("", SqlConexion) - - End Sub - - Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) - With SqlAdapter.SelectCommand - .Parameters.Clear() - .CommandText = StrSQL - .CommandType = TipoComando - End With - If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc - Data = New DataTable - End Sub - - -#Region " C O N T A B I L I D A D - P R E P O L I Z A" - Public Function ObtenerTipoPoliza(Valor1 As String, Valor2 As String, CveEmpresa As Integer) As Integer - Dim Retorno As Integer = -1 - - Select Case CveEmpresa - - Case 83 - If Valor1 = "2" OrElse Valor2 = "2" Then - Retorno = 3 - End If - - End Select - - Return Retorno - End Function - Public Function AddPrePolizas(Modulo As String, CvePlantillaPoliza As Integer, Cargos As Double, Abonos As Double, CveMoneda As Integer, Fecha As Date, Concepto As String, CveUsuario As Integer, CveEmpresa As Integer, Optional FolioFijo As Integer = 0, Optional ReglaFolioPoliza As String = "", Optional CveTipoPoliza As Integer = -1) As Integer - - Dim Retorno As Integer = -1 - - DataAdapter("PA_Conta_PrePolizasAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Modulo", SqlDbType.VarChar).Value = Modulo - .Add("@CvePlantillaPoliza", SqlDbType.Int).Value = CvePlantillaPoliza - .Add("@CveTipoPoliza", SqlDbType.Int).Value = CveTipoPoliza - .Add("@Concepto", SqlDbType.VarChar).Value = Concepto - .Add("@Cargos", SqlDbType.Money).Value = Cargos - .Add("@Abonos", SqlDbType.Money).Value = Abonos - .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda - .Add("@Fecha", SqlDbType.Date).Value = Fecha - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@FolioFijo", SqlDbType.Int).Value = FolioFijo - .Add("@CvePrePoliza", SqlDbType.Int).Direction = ParameterDirection.Output - .Add("@ReglaFolioPoliza", SqlDbType.VarChar).Value = ReglaFolioPoliza - End With - - Try - SqlAdapter.Fill(Data) - Retorno = SqlAdapter.SelectCommand.Parameters("@CvePrePoliza").Value.ToString.ToEntero - Catch ex As Exception - - If ex.Message.Contains("50015;") Then - OnError("No se puede registrar una póliza en un ejercicio Cerrado", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - Else - OnError("Ocurrió un error al Guardar", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End If - End Try - - Return Retorno - End Function - - ''' - ''' Actualiza la IdPoliza de una PrePoliza - ''' - ''' - ''' - Public Function DesvincularPrePolizaContabilizada(IdPoliza As Integer, CveEmpresa As Integer) As Boolean - - Dim Retorno As Boolean = False - - DataAdapter("PA_Conta_DesvincularPrepolizaContabilizada") - - With SqlAdapter.SelectCommand.Parameters - .Add("@IdPoliza", SqlDbType.Int).Value = IdPoliza - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al desvincular la Prepoliza", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function UpdatePrepolizasDetalle(CvePrePolizaDetalle As Integer, Concepto As String, CveSubProyecto As Integer, IdCtaContable As Integer, TipoMovto As Boolean, ImporteMN As Decimal, Optional CveTipoGasto As Integer = -1, - Optional CveConceptoContable As Integer = -1, Optional CveProveedor As Integer = -1, Optional CveCompra As Integer = -1, Optional CvePersonal As Integer = -1, Optional CveCliente As Integer = -1, Optional CveVenta As Integer = -1, - Optional Referencia As String = "-1") As Boolean - - Dim Retorno As Boolean = False - - DataAdapter("PA_PrePolizaDetalleUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePrePolizaDetalle", SqlDbType.Int).Value = CvePrePolizaDetalle - .Add("@Concepto", SqlDbType.VarChar).Value = Concepto - .Add("@Referencia", SqlDbType.VarChar).Value = Referencia - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@IdCtaContable", SqlDbType.Int).Value = IdCtaContable - .Add("@TipoMovto", SqlDbType.Bit).Value = TipoMovto - .Add("@ImporteMN", SqlDbType.Money).Value = ImporteMN - .Add("@CveTipoGasto", SqlDbType.Int).Value = CveTipoGasto - .Add("@CveConceptoContable", SqlDbType.Int).Value = CveConceptoContable - .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor - .Add("@CveCompra", SqlDbType.Int).Value = CveCompra - .Add("@CvePersonal", SqlDbType.Int).Value = CvePersonal - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al Actualizar la Prepoliza", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function GetProveedorAuxiliar(CveProveedor As Integer, CveCompra As Integer) As Boolean - Dim Retorno As Boolean = False - 'Data = New DataTable - 'SqlAdapter = New SqlDataAdapter("PA_ClienteCxCAuxiliar", SqlConexion) - 'SqlAdapter.SelectCommand.CommandType = CommandType.StoredProcedure - 'SqlAdapter.SelectCommand.Parameters.Add("@CveCliente", SqlDbType.Int).Value = CveCliente - 'SqlAdapter.SelectCommand.Parameters.Add("@CveVenta", SqlDbType.Int).Value = CveVenta - DataAdapter("PA_Conta_ProveedorAuxiliar") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor - .Add("@CveCompra", SqlDbType.Int).Value = CveCompra - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As SqlException - OnError("Ocurrió un error al consultar el Auxiliar Contable del Proveedor.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - - Public Function GetPersonalAuxiliar(CvePersonal As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Conta_PersonalAuxiliar") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePersonal", SqlDbType.Int).Value = CvePersonal - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As SqlException - OnError("Ocurrió un error al consultar el Auxiliar Contable del Personal.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function GetClienteAuxiliarxVenta(CveCliente As Integer, FechaInicio As Date, FechaFin As Date, CveVendedor As Integer, CveSucursal As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Conta_ClienteAuxiliarxVenta") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor - .Add("@CveSucursal", SqlDbType.Int).Value = CveSucursal - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio - .Add("@FechaFin", SqlDbType.Date).Value = FechaFin - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As SqlException - OnError("Ocurrió un error al consultar el Auxiliar de ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function GetClienteAuxiliar(CveCliente As Integer, CveConceptoContable As Integer, FechaInicio As Date, FechaFin As Date, CveEmpresa As Integer, Optional Opcion As Integer = 1) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Conta_ClienteAuxiliar") - - With SqlAdapter.SelectCommand.Parameters - - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveConceptoContable", SqlDbType.Int).Value = CveConceptoContable - - .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio - .Add("@FechaFin", SqlDbType.Date).Value = FechaFin - - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@Opcion", SqlDbType.Int).Value = Opcion - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As SqlException - OnError("Ocurrió un error al consultar el Auxiliar Contable del Personal.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - - Public Function GetProveedoresAuxiliar(CveProveedor As Integer, CveConceptoContable As Integer, FechaInicio As Date, FechaFin As Date, CveEmpresa As Integer, - Optional Opcion As Integer = 1) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Conta_ProveedoresAuxiliar") - - With SqlAdapter.SelectCommand.Parameters - - .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor - .Add("@CveConceptoContable", SqlDbType.Int).Value = CveConceptoContable - .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio - .Add("@FechaFin", SqlDbType.Date).Value = FechaFin - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@Opcion", SqlDbType.Int).Value = Opcion - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As SqlException - OnError("Ocurrió un error al consultar el Auxiliar de Proveedor.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function CancelarPrePolizas(CvePrePoliza As Integer, CveVenta As Integer) As Boolean - - Dim Retorno As Boolean = False - - DataAdapter("PA_Conta_PrePolizasCancelar") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al cancelar los movimientos", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function TraspasarSaldosPrePolizas(CveVenta As Integer, CveVentaNueva As Integer, CvePrePolizaNueva As Integer) As Boolean - - Dim Retorno As Boolean = False - - DataAdapter("PA_Conta_PrePolizasSaldosTraspasar") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveVentaNueva", SqlDbType.Int).Value = CveVentaNueva - .Add("@CvePrePolizaNueva", SqlDbType.Int).Value = CvePrePolizaNueva - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al traspasar el saldo", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - ''' Venta a la que se le van a cancelar los pagos - ''' PrePoliza donde van a quedar los movimientos (No necesariamente la PrePoliza de la venta) - ''' - Public Function PrePolizasCancelarPagos(CveVenta As Integer, CvePrePoliza As Integer) As Boolean - - Dim Retorno As Boolean = False - - DataAdapter("PA_Conta_PrePolizasCancelarPagos") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al traspasar el saldo", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - ''' - ''' [-1 = Cancelación de saldo de la REM] - ''' [1 = Regresa saldo a la REM. Cuando se cancela la factura donde se facturó] - ''' - Public Function TraspasarSaldosRemision(CveRemision As Integer, CvePrePoliza As Integer, CveVenta As Integer, Optional TipoMovimiento As Integer = -1) As Boolean - 'TipoMovimiento: -1 = Cancelacion de saldo de remision - - Dim Retorno As Boolean = False - - DataAdapter("PA_Conta_PrePolizasCancelarSaldoRemision") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveRemision", SqlDbType.Int).Value = CveRemision - .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza - .Add("@TipoMovimiento", SqlDbType.Int).Value = TipoMovimiento - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al traspasar el saldo", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function CancelarPagoCompraConAnticipo(CvePrePoliza As Integer, CveCompra As Integer, CveIE As Integer) As Boolean - - Dim Retorno As Boolean = False - - DataAdapter("PA_Banc_GenerarAnticipoCancelacionCompras") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza - .Add("@CveCompra", SqlDbType.Int).Value = CveCompra - .Add("@CveIE", SqlDbType.Int).Value = CveIE - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al cancelar el movimiento", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function CancelarPagoVentaConAnticipo(CvePrePoliza As Integer, CveVenta As Integer, CveIE As Integer) As Boolean - - Dim Retorno As Boolean = False - - DataAdapter("PA_Banc_GenerarAnticipoCancelacionVentas") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveIE", SqlDbType.Int).Value = CveIE - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al cancelar el movimiento", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function RemovePrePolizas(CvePrePoliza As Integer, CveEmpresa As Integer) As Boolean - - Dim Retorno As Boolean = False - - DataAdapter("PA_Conta_PrePolizasRemove") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - - If ex.Message.Contains("50015;") Then - OnError("No se puede eliminar una póliza en un ejercicio Cerrado", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - Else - OnError("Ocurrió un error al Eliminar", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End If - End Try - - Return Retorno - End Function - - ''' - ''' - ''' - ''' - ''' - ''' - ''' 1:Compra 2:Venta - ''' - Public Function RemovePrePolizasDetalle(CvePrePoliza As Integer, CveConceptoContable As Integer, CveCompraVenta As Integer, TipoMovimiento As Integer) As Boolean - - Dim Retorno As Boolean = False - - DataAdapter("PA_Conta_PrePolizasDetalleRemove") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza - .Add("@CveCompraVenta", SqlDbType.Int).Value = CveCompraVenta - .Add("@CveConceptoContable", SqlDbType.Int).Value = CveConceptoContable - .Add("@TipoMovimiento", SqlDbType.Int).Value = TipoMovimiento - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - If ex.Message.Contains("50015;") Then - OnError("No se puede eliminar una póliza en un ejercicio Cerrado", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - Else - OnError("Ocurrió un error al eliminar el detalle de la prepoliza", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End If - End Try - - Return Retorno - End Function - - Public Function GetMovimientosPoliza(IdPoliza As Integer, CveEmpresa As Integer) As Integer - Dim Retorno As Integer = -1 - - DataAdapter("PA_Conta_MovimientosPolizaGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@IdPoliza", SqlDbType.Int).Value = IdPoliza - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@Movtos", SqlDbType.Int).Direction = ParameterDirection.Output - End With - - Try - SqlAdapter.Fill(Data) - Retorno = SqlAdapter.SelectCommand.Parameters("@Movtos").Value.ToString.ToEntero - Catch ex As Exception - OnError("Ocurrió un error al obtener los movimientos de la poliza", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function DesasociarPoliza(IdPoliza As Integer, CveEmpresa As Integer) As Boolean - - Dim Retorno As Boolean = False - - DataAdapter("PA_Conta_PrePolizasPolizaDesAsociar") - - With SqlAdapter.SelectCommand.Parameters - .Add("@IdPoliza", SqlDbType.Int).Value = IdPoliza - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualiza poliza del movimiento", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - -#End Region - -#Region " C O N T A B I L I D A D - P R E P O L I Z A - D E T A L L E " - - Public Function GetPlantillaConceptos(CveEmpresa As Integer, CvePlantillaPoliza As Integer) As Boolean - - Dim Retorno As Boolean = False - - DataAdapter("PA_Conta_GetPlantilla") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CvePlantillaPoliza", SqlDbType.Int).Value = CvePlantillaPoliza - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex1 As SqlException - OnError("Ocurrió un error al obtener las Plantillas", ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - Catch ex As Exception - OnError("Ocurrió un error al obtener las Plantillas", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function GetPrePolizaOriginal(TipoMovimiento As Integer, CveMovimiento As Integer) As Boolean 'Editado por charlie - - Dim Retorno As Boolean = False - - DataAdapter("PA_Conta_GetPrePolizaOriginal") - - With SqlAdapter.SelectCommand.Parameters - .Add("@TipoMovimiento", SqlDbType.Int).Value = TipoMovimiento - .Add("@CveMovimiento", SqlDbType.Int).Value = CveMovimiento - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex1 As SqlException - OnError("Ocurrió un error al obtener la Poliza Original", ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - Catch ex As Exception - OnError("Ocurrió un error al obtener las Poliza Original", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function PrePolizaUnificacion(CvePrePoliza As Integer, CvePrePolizaVieja As Integer) As Boolean 'Editado por charlie - - Dim Retorno As Boolean = False - - DataAdapter("PA_Conta_PrePolizaUnificacion") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza - .Add("@CvePrePolizaVieja", SqlDbType.Int).Value = CvePrePolizaVieja - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex1 As SqlException - OnError("Ocurrió un error al actualizar la Poliza Original", ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - Catch ex As Exception - OnError("Ocurrió un error al actualizar las Poliza Original", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function PrePolizaSimplificacion(CvePrePoliza As Integer, CveEmpresa As Integer) As Boolean - - Dim Retorno As Boolean = False - - DataAdapter("PA_Conta_PrePolizasSimplificacion") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex1 As SqlException - OnError("Ocurrió un error al simplificar prepolizas", ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - Catch ex As Exception - OnError("Ocurrió un error al simplificar prepolizas", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function GetCuentaPrePoliza(Concepto As Integer, CveEmpresa As Integer, CvePlantillaPoliza As Integer) As Boolean - - Dim Retorno As Boolean = False - - DataAdapter("PA_Conta_IdCuentaPrePolizaGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Concepto", SqlDbType.Int).Value = Concepto - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CvePlantillaPoliza", SqlDbType.Int).Value = CvePlantillaPoliza - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex1 As SqlException - OnError("Ocurrió un error al obtener la Cuenta", ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - Catch ex As Exception - OnError("Ocurrió un error al obtener la Cuenta", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function GetRetCuenta(Concepto As Integer, CveGeneral As Integer, Optional CveSubProyecto As Integer = -1) As Boolean - - Dim Retorno As Boolean = False - - DataAdapter("PA_Conta_RetCuentaGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Concepto", SqlDbType.Int).Value = Concepto - .Add("@CveGeneral", SqlDbType.Int).Value = CveGeneral - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex1 As SqlException - OnError("Ocurrió un error al obtener la Cuenta", ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - Catch ex As Exception - OnError("Ocurrió un error al obtener la Cuenta", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function AddPrePolizasDetalle(CvePrePoliza As Integer, TipoMovimiento As Boolean, Importe As Decimal, Referencia As String, CveConceptoContable As Integer, Concepto As String, FechaVencimiento As Date, IdCtaContable As Integer, IdSegmentoNegocio As Integer, - Optional CveIE As Integer = -1, Optional CveVenta As Integer = -1, Optional CveCompra As Integer = -1, Optional CveSubProyecto As Integer = -1, Optional CveCliente As Integer = -1, Optional CveProveedor As Integer = -1, - Optional CvePersonal As Integer = -1, Optional CveMovimientoAlmacen As Integer = -1, Optional CveActivoFijo As Integer = -1, Optional CveAcreedor As Integer = -1, Optional CveColectiva As Integer = -1, Optional CveCreditoDetalle As Integer = -1, - Optional CveOC As Integer = -1, Optional CveClasificacion As Integer = -1, Optional CveVentaAmortizacion As Integer = -1, Optional CveCompraAmortizacion As Integer = -1, Optional ImporteMX As Decimal = 0, Optional ImporteME As Decimal = 0, - Optional CvePrePolizaOriginal As Integer = -1, Optional CveIEDevolucion As Integer = -1, Optional CveCredito As Integer = -1, Optional CveCuenta As Integer = -1, Optional CveTipoGasto As Integer = -1, Optional Contabilizable As Boolean = True, Optional TipoCambio As Decimal = 1, Optional CveOCDetalle As Integer = -1, Optional TipoCambioPago As Decimal = 1, Optional PorcentajeImpuesto As Decimal = 0) As Boolean - - Dim Retorno As Boolean = False - If CvePrePoliza = 0 Then - OnError("Ocurrió un error al guardar la prepóliza, favor de verificar el movimiento", New Exception, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - Return False - End If - - If CveConceptoContable = 30 AndAlso CveIE < 1 Then - OnError("La ClaveIE es invalidad para este Movimiento", New Exception, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - Return False - End If - - DataAdapter("PA_Conta_PrePolizasDetalleAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza - .Add("@CvePrePolizaOriginal", SqlDbType.Int).Value = CvePrePolizaOriginal - .Add("@TipoMovto", SqlDbType.Bit).Value = TipoMovimiento - .Add("@Importe", SqlDbType.Money).Value = If(CveConceptoContable = 30, Importe, Math.Round(Importe, 2)) - .Add("@ImporteMX", SqlDbType.Money).Value = Math.Round(ImporteMX, 2) - .Add("@ImporteME", SqlDbType.Money).Value = Math.Round(ImporteME, 3) - .Add("@TC", SqlDbType.Float).Value = TipoCambio - .Add("@TCPago", SqlDbType.Float).Value = TipoCambioPago - .Add("@Referencia", SqlDbType.VarChar).Value = Referencia - .Add("@CveConceptoContable", SqlDbType.Int).Value = CveConceptoContable - .Add("@Concepto", SqlDbType.VarChar).Value = Concepto - .Add("@FechaVencimiento", SqlDbType.Date).Value = FechaVencimiento - .Add("@IdCtaContable", SqlDbType.Int).Value = IdCtaContable - .Add("@CveCuenta", SqlDbType.Int).Value = CveCuenta - .Add("@IdSegmentoNegocio", SqlDbType.Int).Value = IdSegmentoNegocio - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveVentaAmortizacion", SqlDbType.Int).Value = CveVentaAmortizacion - .Add("@CveCompra", SqlDbType.Int).Value = CveCompra - .Add("@CveCompraAmortizacion", SqlDbType.Int).Value = CveCompraAmortizacion - .Add("@CveIE", SqlDbType.Int).Value = CveIE - .Add("@CveIEDevolucion", SqlDbType.Int).Value = CveIEDevolucion - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor - .Add("@CvePersonal", SqlDbType.Int).Value = CvePersonal - .Add("@CveMovimientoAlmacen", SqlDbType.Int).Value = CveMovimientoAlmacen - .Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo - .Add("@CveOC", SqlDbType.Int).Value = CveOC - .Add("@CveOCDetalle", SqlDbType.Int).Value = CveOCDetalle - .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion - .Add("@CveCredito", SqlDbType.Int).Value = CveCredito - .Add("@CveTipoGasto", SqlDbType.Int).Value = CveTipoGasto - .Add("@Contabilizable", SqlDbType.Bit).Value = If(Contabilizable, 1, 0) - .Add("@CveAcreedor", SqlDbType.Int).Value = CveAcreedor - .Add("@CveColectiva", SqlDbType.Int).Value = CveColectiva - .Add("@CveCreditoDetalle", SqlDbType.Int).Value = CveCreditoDetalle - .Add("@PorcentajeImpuesto", SqlDbType.Money).Value = PorcentajeImpuesto - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex1 As SqlException - If ex1.Message.Contains("50015;") Then - OnError("No se puede registrar una póliza en un ejercicio Cerrado", ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - Else - OnError("Ocurrió un error al Guardar", ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End If - Catch ex As Exception - If ex.Message.Contains("50015;") Then - OnError("No se puede registrar una póliza en un ejercicio Cerrado", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - Else - OnError("Ocurrió un error al Guardar", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End If - End Try - - Return Retorno - End Function - - Public Function ObtenerConceptoEmpresa(CveEmpresa As Integer, CveConcepto As Integer, NombreComercial As String, SerieFolio As String, FolioBancario As String, Optional Adicional As String = "") As String - Dim Concepto As String = "" - - Select Case CveEmpresa - - Case 83 - - Select Case CveConcepto - - Case 2, 17 'Pago Proveedores - - Case 30 'Bancos - Concepto = FolioBancario - - Case 4, 6 'Compra - - Case 1, 5 'Proveedores - Concepto = SerieFolio - - Case 37 'Deudores - - Case 41 'Acreedores - - Case 42 'Acreedores - - Case 18 'NC - Notas de Credito - - Case 29 'Funcionarios y Empleados - - Case Else - Concepto = $"{NombreComercial} F:{SerieFolio}" - - End Select - - Case 4, 7, 11, 12 - - Select Case CveConcepto - - Case 2, 17 'Pago Proveedores - Concepto = $"{NombreComercial} F:{SerieFolio}" - - Case 30 'Bancos - Concepto = FolioBancario - - Case 4, 6 'Compra - - Case 1, 5 'Proveedores - Concepto = SerieFolio - - Case 37 'Deudores - Concepto = FolioBancario - - Case 41 'Acreedores - Concepto = FolioBancario - - Case 42 'Acreedores - Concepto = FolioBancario - - Case 18 'NC - Notas de Credito - - Case 29 'Funcionarios y Empleados - Concepto = FolioBancario - - - Case Else - Concepto = $"{NombreComercial} F:{SerieFolio}" - - End Select - Case 119 - Select Case CveConcepto - - Case 2, 17 'Pago Proveedores - Concepto = String.Format("{0} F:{1}", NombreComercial, SerieFolio) - - Case 30 'Bancos - Concepto = String.Format("{0} - {1}", NombreComercial, Adicional) - - Case 6 'Compra - - Case 13, 61 'iva ventas - Concepto = SerieFolio - - Case 14, 19 'iva compras - Concepto = SerieFolio - - Case 38, 39 'ieps ventas - Concepto = SerieFolio - - Case 25, 26 'eips compras - Concepto = SerieFolio - - Case 1, 5 'Clientes/Proveedores - Concepto = SerieFolio - - Case 37 'Deudores - Concepto = FolioBancario - - Case 41 'Acreedores - Concepto = FolioBancario - - Case 42 'Acreedores - Concepto = FolioBancario - - Case 18 'NC - Notas de Credito, Compra - Concepto = String.Format("{0} F:{1}", NombreComercial, SerieFolio) - Case 29 'Funcionarios y Empleados - Concepto = FolioBancario - - - Case Else - Concepto = String.Format("{0} F:{1}", NombreComercial, SerieFolio) - - End Select - - - Case Else - Concepto = $"{NombreComercial} F:{SerieFolio}" - End Select - - Return Concepto - End Function - - Public Function GetPrePolizasDetalle(CvePrePoliza As Integer, Optional CveIE As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Conta_PrePolizasDetalleGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza - .Add("@CveIE", SqlDbType.Int).Value = CveIE - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener Movimientos Prepolizas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function UpdatePrePolizasDetalleBloquear(CvePrePoliza As Integer, Bloquear As Boolean) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Conta_PrePolizasDetalleBloquearUpdate") - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza - .Add("@Bloquear", SqlDbType.Bit).Value = Bloquear - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - If ex.Message.Contains("50015;") Then - OnError("No se puede actualizar una póliza en un ejercicio Cerrado", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - Else - OnError("Ocurrió un error al bloquear o desbloquear las prepolizas detalle.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - End Try - Return Retorno - End Function - - - - Public Function ContabilizarPrePoliza(CvePrePoliza As Integer, CveUsuario As Integer, Empresa As Empresa, Optional Fecha As Date = MinFecha, Optional Concepto As String = "", - Optional ObjConta As ClsContPAQi = Nothing, Optional pIDPoliza As Integer = -1) As Boolean - 'Editado Por Charlie - - Dim Retorno As Boolean = False - - 'No modificar esta seccion bajo ninguna circunstancia - '***************************************************** - If Empresa.CvePlataforma = 3 Or (CveUsuario.Contiene(100, 1425) And Empresa.CveEmpresa = 1) Then - Retorno = ContabilizarPrePolizaSIG(CvePrePoliza, CveUsuario, Empresa, Fecha, Concepto) - Return Retorno - End If - '***************************************************** - - If Empresa.UsaArmonizacion Then - DataAdapter("PA_Conta_ContabilizaPrepoliza") - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza - .Add("@CvePoliza", SqlDbType.Int).Direction = ParameterDirection.Output - End With - - Try - SqlAdapter.Fill(Data) - ContaIdPoliza = SqlAdapter.SelectCommand.Parameters("@CvePoliza").Value.ToString.ToEntero - If ContaIdPoliza <> 0 Then - Retorno = True - End If - Catch ex As Exception - OnError("Ocurrió un error al obtener Movimientos Prepolizas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - Else - If CvePrePoliza <= 0 Then Return False - - - Dim OcurrioError As Boolean = False - - Dim ContaCompartida As Boolean = False - - If ObjConta Is Nothing Then - ObjConta = New ClsContPAQi(Empresa) - ObjConta.IniciaTransacSQL() - Else - ContaCompartida = True - End If - - - - - Dim tIdPoliza As Integer - Dim CveTipoPoliza, FolioFijo As Integer - Dim Cargos As Decimal - Dim Abonos As Decimal - Dim NumPoliza As String = "" - Dim CodigoNumeroPoliza As String = "" - Dim TipoPoliza As String - - Dim IdCtaContProveedores As Integer - - Dim ContaFolio As String = "" - Dim ContabilizarCausacion As Boolean - Dim ContabilizarDIOT As Boolean - - 'Dim Periodo As Integer = -1 - 'Dim Ejercicio As Integer = -1 - 'Dim GuidPoliza As String = "-1" - - ' Dim FolioFiscal As String = "" - ' Dim DatosCuentas As New DataTable - ' Dim CveMoneda As Integer = 0 - ' Dim Total As Decimal = 0 - - - - Try - - 'If Empresa.Funcionalidad(522).ToString = "1" AndAlso ObjConta.GetCuentas(-1, "-1", -1) Then - ' DatosCuentas = ObjConta.DtResultados - 'End If - - If GetEncabezadoPrePoliza(CvePrePoliza, Empresa.CveEmpresa) Then - CveTipoPoliza = Data.Rows(0)("CveTipoPoliza").ToString.ToEntero - Cargos = Data.Rows(0)("Cargos").ToString.ToDecimal - Abonos = Data.Rows(0)("Abonos").ToString.ToDecimal - FolioFijo = Data.Rows(0)("FolioFijo").ToString.ToEntero - TipoPoliza = Data.Rows(0)("TipoPoliza").ToString - CodigoNumeroPoliza = Data.Rows(0)("CodigoNumeroPoliza").ToString - - 'FolioFiscal = Data.Rows(0)("FolioFiscal").ToString - 'MetodoPagoSAT = Data.Rows(0)("ClaveSAT").ToString - 'CveMoneda = Data.Rows(0)("CveMoneda").ToString.ToEntero - 'Total = Data.Rows(0)("Total").ToString.ToDecimal - - If FolioFijo > 0 Then CodigoNumeroPoliza = "CHQ" - - 'tiene prioridad el concepto en parametro - If Concepto = "" Then Concepto = Data.Rows(0)("Concepto").ToString - If Fecha = MinFecha Then Fecha = Data.Rows(0)("Fecha").ToString.ToDate - - If pIDPoliza > 0 Then - tIdPoliza = pIDPoliza - 'elimnar movimientos de la póliza para regenerarlos - ObjConta.RemoveAllMovimientos(tIdPoliza) - ObjConta.RemoveCausacionesIVA(-1, tIdPoliza) - ObjConta.RemoveDevolucionesIVA(-1, tIdPoliza) - Else - tIdPoliza = ObjConta.AddPoliza(CveTipoPoliza, Concepto, Cargos, Abonos, CveUsuario, Fecha, FolioFijo.ToString, CodigoNumeroPoliza) - ContaFolio = ObjConta.Folio.ToString - End If - - - - 'If Empresa.Funcionalidad(522).ToString = "1" Then - ' GuidPoliza = ObjConta.DtResultados.Rows(0)("Guid").ToString - ' Periodo = Data.Rows(0)("Fecha").ToString.ToDate.Month - ' Ejercicio = Data.Rows(0)("Fecha").ToString.ToDate.Year - - ' ObjConta.AddASocCFDIs(False, TipoPol, GuidPoliza, FolioFiscal, 0, "-1", Empresa.BDContPAQi, Ejercicio, Periodo, ContaFolio) - - 'End If - - - If tIdPoliza > 0 AndAlso GetContabilizacionDiarioDetalle(CvePrePoliza) Then - Dim tipoMovimiento As Boolean = False - Dim CveConceptoContable As Integer - Dim SigReferencia As String = "" - - For Each dr As DataRow In Data.Rows - - CveConceptoContable = dr("CveConceptoContable").ToString().ToEntero - - Select Case CveConceptoContable - Case 6, 5, 17, 14, 19, 15, 16 - SigReferencia = dr("CveCompra").ToString.ContaReferencia(TipoContaReferencia.Compra) - Case 2, 4, 1, 13, 61, 62, 63, 8, 9 - SigReferencia = dr("CveVenta").ToString.ContaReferencia(TipoContaReferencia.Venta) - Case 30 - SigReferencia = dr("CveIE").ToString.ContaReferencia(TipoContaReferencia.Banco) - - End Select - - Select Case CveConceptoContable - Case 19 ' IVA Acreditable - ContabilizarDIOT = True - Case 61 ' IVA Trasladado - ContabilizarCausacion = True - Case 30 ' Bancos - If dr("Abono").ToString.ToDecimal > 0 Then ContabilizarDIOT = True - If dr("Cargo").ToString.ToDecimal > 0 Then ContabilizarCausacion = True - End Select - - tipoMovimiento = (dr("TipoMovto").ToString = "True") - - 'Si las cuentas contables estan en 0 no se debe contabilizar - If dr("IdCtaContable").ToString.ToEntero > 0 Then - - 'Si ImporteMN es mayor que 0 entonces la compra es en dolares y debemos ingresar la cantidad en pesos - If dr("ImporteMN").ToString.ToDecimal <> 0 Then - - If Not ObjConta.AddMovimiento(tIdPoliza, dr("IdCtaContable").ToString.ToEntero, tipoMovimiento, - dr("ImporteMN").ToString.ToDecimal, dr("Referencia").ToString, dr("Concepto").ToString, dr("IdSegmentoNegocio").ToString.ToEntero, Fecha, SigReferencia, dr("CvePrePolizaDetalle").ToString.ToEntero, ImporteMonedaExtranjera:=dr("ImporteME").ToString.ToDecimal) Then - OcurrioError = True - Exit For - End If - - 'If Empresa.Funcionalidad(522).ToString = "1" Then - ' GuidPoliza = ObjConta.DtResultados.Rows(0)("Guid").ToString - ' Periodo = Data.Rows(0)("Fecha").ToString.ToDate.Month - ' Ejercicio = Data.Rows(0)("Fecha").ToString.ToDate.Year - - ' Dim CodigoCuenta As String = "" - - ' If DatosCuentas.Rows.Count > 0 Then - ' If DatosCuentas.FiltraParametros($"Id = {dr("IdCtaContable").ToString}").Rows.Count > 0 Then 'Filtra primero valorCambiar - ' CodigoCuenta = DatosCuentas.FiltraParametros($"Id = {dr("IdCtaContable").ToString}").Rows(0)("Codigo").ToString - ' If Not ObjConta.AddASocCFDIs(False, TipoPol, GuidPoliza, FolioFiscal, 0, CodigoCuenta, Empresa.BDContPAQi, -1, -1, ContaFolio) Then - ' OcurrioError = True - ' Exit For - ' End If - ' Else - ' OcurrioError = True - ' Exit For - ' End If - ' Else - ' OcurrioError = True - ' Exit For - ' End If - 'End If - - Else - - If Not ObjConta.AddMovimiento(tIdPoliza, dr("IdCtaContable").ToString.ToEntero, tipoMovimiento, - dr("Importe").ToString.ToDecimal, dr("Referencia").ToString, dr("Concepto").ToString, dr("IdSegmentoNegocio").ToString.ToEntero, Fecha, SigReferencia, dr("CvePrePolizaDetalle").ToString.ToEntero, ImporteMonedaExtranjera:=dr("ImporteME").ToString.ToDecimal) Then - OcurrioError = True - Exit For - End If - - - 'If Empresa.Funcionalidad(522).ToString = "1" Then - ' GuidPoliza = ObjConta.DtResultados.Rows(0)("Guid").ToString - ' Periodo = Data.Rows(0)("Fecha").ToString.ToDate.Month - ' Ejercicio = Data.Rows(0)("Fecha").ToString.ToDate.Year - - ' Dim CodigoCuenta As String = "" - - ' If DatosCuentas.Rows.Count > 0 Then - ' If DatosCuentas.FiltraParametros($"Codigo = {dr("IdCtaContable").ToString}").Rows.Count > 0 Then - ' CodigoCuenta = DatosCuentas.FiltraParametros($"Codigo = {dr("IdCtaContable").ToString}").Rows(0)("Codigo").ToString - ' If Not ObjConta.AddASocCFDIs(False, TipoPol, GuidPoliza, FolioFiscal, 0, CodigoCuenta, Empresa.BDContPAQi, -1, -1, ContaFolio) Then - ' OcurrioError = True - ' Exit For - ' End If - ' Else - ' OcurrioError = True - ' Exit For - ' End If - ' Else - ' OcurrioError = True - ' Exit For - ' End If - 'End If - - End If - Else - OcurrioError = True - Mensaje.Append(String.Format("
La cuenta contable {0} es invalida", dr("ConceptoContable"))) - Exit For - End If - - Next - - - 'Obtenemos los valores de la causacion y los agregamos - If Not OcurrioError AndAlso ContabilizarCausacion Then - If GetCausacionesValores(CvePrePoliza) AndAlso Data.Rows.Count > 0 Then - Dim dr As DataRow = Data(0) - If Not ObjConta.AddCausacionesIVA(tIdPoliza, - dr("TotalTasa16").ToString.ToDecimal, - dr("BaseTasa16").ToString.ToDecimal, - dr("IvaTasa16").ToString.ToDecimal, - 0, - dr("ISRRetenido").ToString.ToDecimal, - dr("IVARetenido").ToString.ToDecimal, False) Then - OcurrioError = True - - End If - End If - End If - - 'Obtenemos los valores del DIOT y los agregamos - Dim RFC As String = "" - Dim RazonSocial As String = "" - If Not OcurrioError AndAlso ContabilizarDIOT Then - If GetDIOTValores(CvePrePoliza) AndAlso Data.Rows.Count > 0 Then - Dim IdProveedor As Integer - - For Each dr As DataRow In Data.Rows - RFC = dr("RFC").ToString - RazonSocial = dr("RazonSocial").ToString - IdCtaContProveedores = dr("IdCtaContProveedores").ToString.ToEntero - - If IdCtaContProveedores > 0 Then - - 'busco la clave del proveedor en la contabilidad por su cuenta contable - If ObjConta.GetProveedores(IdCuentaContable:=IdCtaContProveedores) Then - If ObjConta.DtResultados.Rows.Count > 0 Then - Dim drt As DataRow = ObjConta.DtResultados.Rows(0) : IdProveedor = drt("Id").ToString.ToEntero - Else - IdProveedor = 0 - End If - End If - Else - 'busco la clave del proveedor en la contabilidad por su cuenta contable - If ObjConta.GetProveedores(RFC:=RFC) Then - If ObjConta.DtResultados.Rows.Count > 0 Then - Dim drtt As DataRow = ObjConta.DtResultados.Rows(0) : IdProveedor = drtt("Id").ToString.ToEntero - Else - IdProveedor = 0 - End If - Else - 'registro el proveedor generico - Select Case Empresa.CveEmpresa - Case Else : IdProveedor = 0 - End Select - End If - - End If - - - If IdProveedor <= 0 Then - IdProveedor = ObjConta.AddProveedor(IdCtaContProveedores, RFC, RazonSocial, "") - If IdProveedor <= 0 Then - OcurrioError = True - End If - End If - - - If dr("Total").ToString.ToDecimal <> 0.00 Then - If Not ObjConta.AddDevolucionesIVA(tIdPoliza, dr("CuentaBancos").ToString.ToEntero, - IdProveedor, - 16, - dr("SubTotal").ToString.ToDecimal, - dr("IvaAcreditable").ToString.ToDecimal, - dr("IVARetenido").ToString.ToDecimal, - dr("ISRRetenido").ToString.ToDecimal, - Fecha, - ContaFolio, - dr("Serie").ToString.ToString, - dr("Folio").ToString.StrToNum, dr("FolioFiscal").ToString, Empresa.CveEmpresa) Then - OcurrioError = True - Mensaje.Append("La Poliza o la Cuenta no son válidas ") - End If - - - End If - - Next - - End If - End If - - If Not OcurrioError Then - If Not UpdatePrePolizasDetalleBloquear(CvePrePoliza, True) Then - OcurrioError = True - End If - End If - - If Not OcurrioError Then - If Not UpdatePrePoliza(Fecha, ObjConta.Folio, CveTipoPoliza, tIdPoliza, CvePrePoliza, Empresa.CveEmpresa) Then - OcurrioError = True - End If - End If - - - - 'If Empresa.Funcionalidad(522).ToString = "1" And Empresa.UsaContabilidad Then - - ' Dim CodigoPersona As String = "" - ' Dim Bnefciciario As String = "" - - ' If ObjConta.GetPersona(RFC) Then - ' CodigoPersona = ObjConta.DtResultados.FiltroPrimeroValor("CodigoPersona") - ' Bnefciciario = ObjConta.DtResultados.FiltroPrimeroValor("Nombre") - ' Else - - ' OcurrioError = True - ' Mensaje.Append("Se presento un error al obtener los datos de la persona. ") - - ' End If - - - - - ' If TipoPol = 1 Then 'Ingreso - ' Dim IdDocumento As Integer = 0 - ' ' Dim UsuarioSistema As String = "" - ' Dim IdCuentaCheques As Integer = 1 - ' Dim NatBancaria As Integer = 2 - ' Dim Naturaleza As Integer = 1 - ' Dim IdIngreso As Integer - - ' If ObjConta.AddIngreso(1, 34, 42, Ejercicio, Periodo, Fecha, Ejercicio, Periodo, CodigoPersona, Bnefciciario, IdCuentaCheques, NatBancaria, Naturaleza, CveMoneda, 2, 1, Total, "", 0, 0, "", 0, - ' 0, Ejercicio, Periodo, TipoPol, ContaFolio.ToEntero, 0, 0, tIdPoliza, 11, 0, 0, 0, 0, UsuarioSistema, UsuarioSistema, 0, System.Guid.NewGuid().ToString().ToUpper, "", 0, MetodoPagoSAT) Then 'Actualizar Documento IdDocumento despues de Insertarlo - - ' If ObjConta.DtResultados.Rows.Count > 0 Then - ' IdIngreso = ObjConta.DtResultados.Rows(0)("IdIngreso").ToString.ToEntero - - ' If Not ObjConta.AddDocumentoBancario(1, 0, 0, IdIngreso, 0, 0, Fecha, Fecha, 0, 0, IdCuentaCheques) Then - ' OcurrioError = True - ' Mensaje.Append("Se presento un error al guardar el el documento. ") - ' End If - - ' Else - ' OcurrioError = True - ' Mensaje.Append("Se presento un error al guardar el Ingreso. ") - ' End If - ' Else - ' OcurrioError = True - ' Mensaje.Append("Se presento un error al guardar el Ingreso. ") - ' End If - - ' ElseIf TipoPol = 2 Then 'Egreso - - ' Dim IdDocumento As Integer = 0 - ' ' Dim UsuarioSistema As String = "" - ' Dim BancoDestino As String = "" - ' Dim CuentaDestino As String = "" - ' Dim IdCuentaCheques As Integer = 1 - ' Dim NatBancaria As Integer = 0 - ' Dim Naturaleza As Integer = 2 - ' Dim IdEgreso As Integer - - ' If ObjConta.AddEgreso(1, 36, 45, Ejercicio, Periodo, Fecha, Ejercicio, Periodo, CodigoPersona, Bnefciciario, IdCuentaCheques, NatBancaria, Naturaleza, CveMoneda, 2, 1, Total, "", 0, "", 0, 0, Ejercicio, - ' Periodo, TipoPol, NumPoliza, 0, 0, ContaIdPoliza, tIdPoliza, IdDocumento, Ejercicio, Periodo, 0, 0, 0, 0, 0, 0, UsuarioSistema, UsuarioSistema, 0, System.Guid.NewGuid().ToString().ToUpper, - ' CuentaDestino, BancoDestino, MetodoPagoSAT) Then - - ' If ObjConta.DtResultados.Rows.Count > 0 Then - ' IdEgreso = ObjConta.DtResultados.Rows(0)("IdEgreso").ToString.ToEntero - - ' If Not ObjConta.AddDocumentoBancario(1, 0, IdEgreso, 0, 0, 0, Fecha, Fecha, 0, 0, IdCuentaCheques) Then - ' OcurrioError = True - ' Mensaje.Append("Se presento un error al guardar el el documento. ") - ' End If - - ' Else - ' OcurrioError = True - ' Mensaje.Append("Se presento un error al guardar el Egreso. ") - ' End If - ' Else - ' OcurrioError = True - ' Mensaje.Append("Se presento un error al guardar el Egreso") - - ' End If 'Actualizar Documento IdDocumento despues de Insertarlo - - ' End If - - 'End If - - If OcurrioError Then - If Not ContaCompartida Then ObjConta.RollBack() - Else - If Not ContaCompartida Then ObjConta.AjustaPoliza(tIdPoliza) - - Mensaje.Append(String.Format("{1}
", tIdPoliza, ObjConta.Folio)) - If Not ContaCompartida Then ObjConta.Commit() - Retorno = True - _ContaIdPoliza = tIdPoliza - _ContaFolio = ObjConta.Folio - End If - End If - - Else - OcurrioError = True - End If - - - - Catch ex As Exception - ObjConta.RollBack() - OnError("Ocurrió un error al intentar contabilizar la PrePoliza", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - 'Alert("Ocurrió un error al guardar la póliza", TipoMensaje.MsgAdvertencia) - Retorno = False - End Try - - If Not ContaCompartida Then ObjConta.Dispose() - End If - Return Retorno - End Function - - 'No modificar este metodo bajo ninguna circunstancia - Public Function ContabilizarPrePolizaSIG(CvePrePoliza As Integer, CveUsuario As Integer, Empresa As Empresa, Optional Fecha As Date = MinFecha, Optional Concepto As String = "") As Boolean - - If CvePrePoliza <= 0 Then Return False - - Dim Retorno As Boolean = False - Dim OcurrioError As Boolean = False - Dim tCvePoliza As Integer - Dim CveTipoPoliza, FolioFijo As Integer - Dim Cargos As Decimal - Dim Abonos As Decimal - Dim NumPoliza As String = "" - Dim CodigoNumeroPoliza As String = "" - Dim TipoPoliza As String - - Dim ContaFolio As String = "" - Dim ContabilizarCausacion As Boolean - Dim ContabilizarDIOT As Boolean - - Dim ObjConta As New ClsContabilidad - ObjConta.IniciaTransacSQL() - - Try - - If GetEncabezadoPrePoliza(CvePrePoliza, Empresa.CveEmpresa) Then - CveTipoPoliza = Data.Rows(0)("CveTipoPoliza").ToString.ToEntero - Cargos = Data.Rows(0)("Cargos").ToString.ToDecimal - Abonos = Data.Rows(0)("Abonos").ToString.ToDecimal - FolioFijo = Data.Rows(0)("FolioFijo").ToString.ToEntero - TipoPoliza = Data.Rows(0)("TipoPoliza").ToString - CodigoNumeroPoliza = Data.Rows(0)("CodigoNumeroPoliza").ToString - - 'tiene prioridad el concepto en parametro - If Concepto = "" Then Concepto = Data.Rows(0)("Concepto").ToString - If Fecha = MinFecha Then Fecha = Data.Rows(0)("Fecha").ToString.ToDate - - If FolioFijo > 0 Then - CodigoNumeroPoliza = "CHQ" - Else - GetNumeroPoliza(CveTipoPoliza, TipoPoliza, Fecha, Empresa.CveEmpresa) - FolioFijo = Data.Rows(0)("NumPoliza").ToString.ToEntero - End If - - tCvePoliza = ObjConta.AddPoliza(CveTipoPoliza, FolioFijo, Fecha, Concepto, CveUsuario, Empresa.CveEmpresa, CvePrePoliza) - - If tCvePoliza > 0 AndAlso GetContabilizacionDiarioDetalle(CvePrePoliza) Then - Dim tipoMovimiento As Boolean = False - Dim CveConceptoContable As Integer - Dim SigReferencia As String = "" - - For Each dr As DataRow In Data.Rows - - CveConceptoContable = dr("CveConceptoContable").ToString().ToEntero - - Select Case CveConceptoContable - Case 6, 5, 17, 14, 19, 15, 16 - SigReferencia = dr("CveCompra").ToString.ContaReferencia(TipoContaReferencia.Compra) - Case 2, 4, 1, 13, 61, 62, 63, 8, 9 - SigReferencia = dr("CveVenta").ToString.ContaReferencia(TipoContaReferencia.Venta) - Case 30 - SigReferencia = dr("CveIE").ToString.ContaReferencia(TipoContaReferencia.Banco) - - End Select - - Select Case CveConceptoContable - Case 19 ' IVA Acreditable - ContabilizarDIOT = True - Case 61 ' IVA Trasladado - ContabilizarCausacion = True - Case 30 ' Bancos - If dr("Abono").ToString.ToDecimal > 0 Then ContabilizarDIOT = True - If dr("Cargo").ToString.ToDecimal > 0 Then ContabilizarCausacion = True - End Select - - tipoMovimiento = (dr("TipoMovto").ToString = "True") - - 'Si las cuentas contables estan en 0 no se debe contabilizar - If dr("CveCuenta").ToString.ToEntero > 0 Then - - 'Si ImporteMN es mayor que 0 entonces la compra es en dolares y debemos ingresar la cantidad en pesos - If dr("ImporteMN").ToString.ToDecimal <> 0 Then - If Not ObjConta.AddPolizaDetalle(tCvePoliza, dr("CveCuenta").ToString.ToEntero, "", dr("CveSubProyecto").ToString.ToEntero, tipoMovimiento, - dr("ImporteMN").ToString.ToDecimal, dr("Referencia").ToString, dr("Concepto").ToString, Fecha, ImporteMonedaExtranjera:=dr("ImporteME").ToString.ToDecimal, CvePrePolizaDetalle:=dr("CvePrePolizaDetalle").ToString.ToEntero) Then - OcurrioError = True - Exit For - End If - Else - If Not ObjConta.AddPolizaDetalle(tCvePoliza, dr("CveCuenta").ToString.ToEntero, "", dr("CveSubProyecto").ToString.ToEntero, tipoMovimiento, - dr("Importe").ToString.ToDecimal, dr("Referencia").ToString, dr("Concepto").ToString, Fecha, ImporteMonedaExtranjera:=dr("ImporteME").ToString.ToDecimal, CvePrePolizaDetalle:=dr("CvePrePolizaDetalle").ToString.ToEntero) Then - OcurrioError = True - Exit For - End If - End If - - Else - OcurrioError = True - Mensaje.Append(String.Format("
La cuenta contable {0} es invalida", dr("ConceptoContable"))) - Exit For - End If - - Next - - 'Obtenemos los valores de la causacion y los agregamos - 'If Not OcurrioError AndAlso ContabilizarCausacion Then - ' If GetCausacionesValores(CvePrePoliza) AndAlso Data.Rows.Count > 0 Then - ' Dim dr As DataRow = Data(0) - ' If Not ObjConta.AddCausacionesIVA(tIdPoliza, - ' dr("TotalTasa16").ToString.ToDecimal, - ' dr("BaseTasa16").ToString.ToDecimal, - ' dr("IvaTasa16").ToString.ToDecimal, - ' 0, - ' dr("ISRRetenido").ToString.ToDecimal, - ' dr("IVARetenido").ToString.ToDecimal, False) Then - ' OcurrioError = True - - ' End If - ' End If - 'End If - - 'Obtenemos los valores del DIOT y los agregamos - 'If Not OcurrioError AndAlso ContabilizarDIOT Then - ' If GetDIOTValores(CvePrePoliza) AndAlso Data.Rows.Count > 0 Then - ' Dim IdProveedor As Integer - ' Dim RFC, RazonSocial As String - - ' RFC = Data(0)("RFC").ToString - ' RazonSocial = Data(0)("RazonSocial").ToString - ' IdCtaContProveedores = Data(0)("IdCtaContProveedores").ToString.ToEntero - - ' If IdCtaContProveedores > 0 Then - - ' 'busco la clave del proveedor en la contabilidad por su cuenta contable - ' If ObjConta.GetProveedores(IdCuentaContable:=IdCtaContProveedores) Then - ' If ObjConta.DtResultados.Rows.Count > 0 Then - ' Dim dr As DataRow = ObjConta.DtResultados.Rows(0) : IdProveedor = dr("Id").ToString.ToEntero - ' End If - ' End If - ' Else - ' 'busco la clave del proveedor en la contabilidad por su cuenta contable - ' If ObjConta.GetProveedores(RFC:=RFC) Then - ' If ObjConta.DtResultados.Rows.Count > 0 Then - ' Dim dr As DataRow = ObjConta.DtResultados.Rows(0) : IdProveedor = dr("Id").ToString.ToEntero - ' End If - ' Else - ' 'registro el proveedor generico - ' Select Case Empresa.CveEmpresa - ' Case 66 : IdProveedor = 12726 - ' Case Else : IdProveedor = 1 - ' End Select - ' End If - - ' End If - - - ' If IdProveedor <= 0 Then - ' IdProveedor = ObjConta.AddProveedor(IdCtaContProveedores, RFC, RazonSocial, "") - ' If IdProveedor <= 0 Then - ' OcurrioError = True - ' End If - ' End If - - ' For Each dr As DataRow In Data.Rows - ' If dr("Total").ToString.ToDecimal <> 0.00 Then - ' If Not ObjConta.AddDevolucionesIVA(tIdPoliza, dr("CuentaBancos").ToString.ToEntero, - ' IdProveedor, - ' 16, - ' dr("SubTotal").ToString.ToDecimal, - ' dr("IvaAcreditable").ToString.ToDecimal, - ' dr("IVARetenido").ToString.ToDecimal, - ' dr("ISRRetenido").ToString.ToDecimal, - ' Fecha, - ' ContaFolio, - ' dr("Serie").ToString.ToString, - ' dr("Folio").ToString.StrToNum, "") Then - ' OcurrioError = True - ' Mensaje.Append("La Poliza o la Cuenta no son válidas") - ' End If - - - ' End If - - ' Next - - ' End If - 'End If - - If Not OcurrioError Then - Mensaje.Append(String.Format("{1}
", tCvePoliza, FolioFijo)) - ObjConta.Commit() - Retorno = True - _ContaIdPoliza = tCvePoliza - End If - End If - - Else - OcurrioError = True - End If - - - - Catch ex As Exception - ObjConta.RollBack() - OnError("Ocurrió un error al intentar contabilizar la PrePoliza", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - Retorno = False - End Try - - ObjConta.Dispose() - Return Retorno - End Function - - Public Function GetCuentaDobleConta(IdCtaContable As Integer, CveEmpresa As Integer) As Boolean - - Dim Retorno As Boolean = False - - DataAdapter("PA_Conta_CuentaDobleContaGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@IdCtaContable", SqlDbType.Int).Value = IdCtaContable - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener la cuenta doble.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function GetEncabezadoPrePoliza(CvePrePoliza As Integer, CveEmpresa As Integer) As Boolean - - Dim Retorno As Boolean = False - - DataAdapter("PA_Conta_PrePolizaEncabezadoGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex1 As SqlException - OnError("Ocurrió un error al obtener el encabezado de la PrePoliza", ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - Catch ex As Exception - OnError("Ocurrió un error al obtener el encabezado de la PrePoliza", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function GetPrePolizasDetalle2(CvePrePoliza As Integer, Optional CveIE As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Conta_PrePolizasDetalleGet2") - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza - .Add("@CveIE", SqlDbType.Int).Value = CveIE - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener Movimientos Prepolizas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetCausacionesValores(CvePrePoliza As Integer) As Boolean 'Editado por charlie - - Dim Retorno As Boolean = False - - DataAdapter("PA_Conta_CausacionesValoresGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex1 As SqlException - OnError("Ocurrió un error al obtener los valores de la Causacion", ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - Catch ex As Exception - OnError("Ocurrió un error al obtener los valores de la Causacion", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function GetDIOTValores(CvePrePoliza As Integer) As Boolean 'Editado por charlie - - Dim Retorno As Boolean = False - - DataAdapter("PA_Conta_DIOTValoresGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex1 As SqlException - OnError("Ocurrió un error al obtener los valores del DIOT", ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - Catch ex As Exception - OnError("Ocurrió un error al obtener los valores del DIOT", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - - Public Function UpdatePrePoliza(FechaConta As Date, FolioPoliza As Integer, CveTipoPoliza As Integer, IdPoliza As Integer, CvePrePoliza As Integer, CveEmpresa As Integer, Optional Concepto As String = "-1", Optional FechaPoliza As Date = MinFecha, Optional xxx As Integer = -1) As Boolean - - Dim Retorno As Boolean = False - - DataAdapter("PA_Conta_PrePolizasPolizaUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaConta", SqlDbType.Date).Value = FechaConta - .Add("@FechaPoliza", SqlDbType.Date).Value = FechaPoliza - .Add("@FolioPoliza", SqlDbType.Int).Value = FolioPoliza - .Add("@CveTipoPoliza", SqlDbType.Int).Value = CveTipoPoliza - .Add("@IdPoliza", SqlDbType.Int).Value = IdPoliza - .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza - .Add("@Concepto", SqlDbType.VarChar).Value = Concepto - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - - If ex.Message.Contains("50015;") Then - OnError("No se puede actualizar una póliza en un ejercicio Cerrado", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - Else - OnError("Ocurrió un error al actualizar prepoliza del movimiento", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End If - End Try - - Return Retorno - End Function - - Public Function GetPrePoliza(CvePrePoliza As Integer, CveEmpresa As Integer, Optional IdPoliza As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Conta_PrePolizasGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@IdPoliza", SqlDbType.Int).Value = IdPoliza - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener la prepoliza.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - - -#End Region - -#Region " C O N T A B I L I D A D - T I P O - P O L I Z A " - Public Function GetConta_TiposPoliza(CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Conta_TiposPolizasGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Catálogo de Tipo de Pólizas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function AddConta_TiposPoliza(TipoPoliza As String, CveUsuario As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Conta_TiposPolizaAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@TipoPoliza", SqlDbType.VarChar).Value = TipoPoliza - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 2627;") Then - Alert("Ya existe un Tipo de Póliza con el mismo nombre: " & TipoPoliza & ".", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al Guardar el Tipo de Póliza.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - OnError("Ocurrió un error al Guardar el Tipo de Póliza", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function UpdateConta_TiposPoliza(TipoPoliza As String, Estatus As Boolean, CveTipoPoliza As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Conta_TiposPolizaUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@TipoPoliza", SqlDbType.VarChar).Value = TipoPoliza - .Add("@Estatus", SqlDbType.Bit).Value = Estatus - .Add("@CveTipoPoliza", SqlDbType.Int).Value = CveTipoPoliza - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 2627;") Then - Alert("Ya existe un Tipo de Póliza con el mismo nombre: " & TipoPoliza & ".", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al guardar los cambios en el Tipo de Póliza", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - OnError("Ocurrió un error al guardar los cambios en el Tipo Póliza.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function RemoveConta_TipoPoliza(CveTipoPoliza As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Conta_TiposPolizaRemove") - - SqlAdapter.SelectCommand.Parameters.Add("@CveTipoPoliza", SqlDbType.Int).Value = CveTipoPoliza - - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 547;") Then - Alert("El Tipo de Póliza no se pudo eliminar porque está siendo usado por un registro.", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al eliminar el Tipo Póliza.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - Me.OnError("Ocurrió un error al eliminar el Tipo Póliza.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function -#End Region - -#Region " C O N T A B I L I D A D - C O N C E P T O S - C O N T A B L E S " - Public Function GetConta_ConceptosContables() As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Conta_ConceptosContablesGet") - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Catálogo de Concepto Contables.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function AddConta_ConceptosContables(CveConceptoContable As Integer, Tipo As String, ConceptoContable As String, CveUsuario As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Conta_ConceptosContablesAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveConceptoContable", SqlDbType.Int).Value = CveConceptoContable - .Add("@Tipo", SqlDbType.VarChar).Value = Tipo - .Add("@ConceptoContable", SqlDbType.VarChar).Value = ConceptoContable - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 2627;") Then - Alert("Ya existe un Concepto Contable con el mismo nombre: " & Tipo & ".", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al Guardar el Concepto Contable.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - OnError("Ocurrió un error al Guardar el Concepto Contable", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function UpdateConta_ConceptosContables(Tipo As String, ConceptoContable As String, Estado As Boolean, CveConceptoContable As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Conta_ConceptosContablesUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Tipo", SqlDbType.VarChar).Value = Tipo - .Add("@ConceptoContable", SqlDbType.VarChar).Value = ConceptoContable - .Add("@Estado", SqlDbType.Bit).Value = Estado - .Add("@CveConceptoContable", SqlDbType.Int).Value = CveConceptoContable - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 2627;") Then - Alert("Ya existe un Concepto Contable con el mismo nombre: " & Tipo & ".", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al guardar los cambios en el Concepto Contable", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - OnError("Ocurrió un error al guardar los cambios en el Concepto Contable.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function RemoveConta_ConceptosContables(CveConceptoContable As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Conta_ConceptosContablesRemove") - - SqlAdapter.SelectCommand.Parameters.Add("@CveConceptoContable", SqlDbType.Int).Value = CveConceptoContable - - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 547;") Then - Alert("El Concepto Contable no se pudo eliminar porque está siendo usado por un registro.", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al eliminar el Concepto Contable.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - Me.OnError("Ocurrió un error al eliminar el Concepto Contable.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function -#End Region - -#Region " C O N T A B I L I D A D - D I A R I O S " - - Public Function GetContabilizacionDiario(CveEmpresa As Integer, CvePlantilla As Integer, FechaI As Date, FechaF As Date, Optional CveProveedor As Integer = -1, Optional CvePersonal As Integer = -1, Optional CveTipoProveedor As Integer = -1, Optional CveMoneda As Integer = -1, Optional CvePlantillaPoliza As Integer = -1, Optional EstatusContabilizacion As Integer = -1, Optional CveSubProyecto As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Conta_ContabilizacionDiariosGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CvePlantilla", SqlDbType.Int).Value = CvePlantilla - .Add("@FechaI", SqlDbType.Date).Value = FechaI - .Add("@FechaF", SqlDbType.Date).Value = FechaF - .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor - .Add("@CvePersonal", SqlDbType.Int).Value = CvePersonal - .Add("@CveTipoProveedor", SqlDbType.Int).Value = CveTipoProveedor - .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda - .Add("@CvePlantillaPoliza", SqlDbType.Int).Value = CvePlantillaPoliza - .Add("@EstatusContabilizacion", SqlDbType.Int).Value = EstatusContabilizacion - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el diario.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetContabilizacionDiarioDetalle(CvePrePoliza As Integer) As Boolean 'Editado por charlie - Dim Retorno As Boolean = False - DataAdapter("PA_Conta_ContabilizacionDiariosDetalleGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los detalles de las ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetContabilizacionVentas(CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Conta_ContabilizacionVentasGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener las ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetContabilizacionVentasDetalle(CvePrePoliza As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Conta_ContabilizacionVentasDetallesGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los detalles de las ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetContabilizacionPagos(CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Conta_ContabilizacionPagosGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los pagos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetContabilizacionPagosDetalle(CvePrePoliza As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Conta_ContabilizacionPagosDetallesGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los detalles de los pagos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetContabilizacionAnticipos(CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Conta_ContabilizacionAnticiposGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los pagos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetContabilizacionAnticiposDetalle(CvePrePoliza As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Conta_ContabilizacionAnticiposDetallesGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los detalles de los pagos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetContabilizacionAmortizacion(CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Conta_ContabilizacionAmortizacionGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los pagos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetContabilizacionAmortizacionDetalle(CvePrePoliza As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Conta_ContabilizacionAmortizacionDetallesGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los detalles de los pagos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetDiarioVentas(CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Conta_DiarioVentasGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el diario de ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetDiarioCompras(CveProveedor As Integer, FechaInicio As Date, FechaFin As Date, Opcion As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Conta_DiarioComprasGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor - .Add("@FechaI", SqlDbType.Date).Value = FechaInicio - .Add("@FechaF", SqlDbType.Date).Value = FechaFin - .Add("@Opcion", SqlDbType.Int).Value = Opcion - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el diario de compras.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - - 'Public Function GetDiarioPagosCompras(CveProveedor As Integer, FechaInicio As Date, FechaFin As Date, Opcion As Integer, CveEmpresa As Integer) As Boolean - ' Dim Retorno As Boolean = False - ' DataAdapter("PA_Conta_DiarioPagosComprasGet") - - ' With SqlAdapter.SelectCommand.Parameters - ' .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor - ' .Add("@FechaI", SqlDbType.Date).Value = FechaInicio - ' .Add("@FechaF", SqlDbType.Date).Value = FechaFin - ' .Add("@Opcion", SqlDbType.Int).Value = Opcion - ' .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - ' End With - - ' Try - ' SqlAdapter.Fill(Data) - ' Retorno = True - ' Catch ex As Exception - ' OnError("Ocurrió un error al obtener el diario de Pagoss.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - ' End Try - - ' Return Retorno - 'End Function - - - - Public Function GetDiarioPagosCompras(CveProveedor As Integer, FechaInicio As Date, FechaFin As Date, Opcion As Integer, CveCuenta As Integer, CveTipoTransaccion As Integer, CveEmpresa As Integer) As DataSet - Dim Retorno As New DataSet - DataAdapter("PA_Conta_DiarioPagosComprasGet33") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor - .Add("@FechaI", SqlDbType.Date).Value = FechaInicio - .Add("@FechaF", SqlDbType.Date).Value = FechaFin - .Add("@Opcion", SqlDbType.Int).Value = Opcion - .Add("@CveCuenta", SqlDbType.Int).Value = CveCuenta - .Add("@CveTipoTransaccion", SqlDbType.Int).Value = CveTipoTransaccion - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Retorno) - - Catch ex As Exception - OnError("Ocurrió un error al obtener el diario de Pagoss.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - - - Public Function GetDiarioPagos(CveProveedor As Integer, FechaInicio As Date, FechaFin As Date, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Conta_DiarioPagosGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor - .Add("@FechaI", SqlDbType.Date).Value = FechaInicio - .Add("@FechaF", SqlDbType.Date).Value = FechaFin - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el diario de pagos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - - Public Function GetDiarioAmortizacion(CveProveedor As Integer, FechaInicio As Date, FechaFin As Date, Opcion As Integer, CveCuenta As Integer, CveTipoTransaccion As Integer, CveEmpresa As Integer) As DataSet - Dim Retorno As New DataSet - DataAdapter("PA_Conta_DiarioAmortizacion") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor - .Add("@FechaI", SqlDbType.Date).Value = FechaInicio - .Add("@FechaF", SqlDbType.Date).Value = FechaFin - .Add("@Opcion", SqlDbType.Int).Value = Opcion - .Add("@CveCuenta", SqlDbType.Int).Value = CveCuenta - .Add("@CveTipoTransaccion", SqlDbType.Int).Value = CveTipoTransaccion - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Retorno) - - Catch ex As Exception - OnError("Ocurrió un error al obtener el diario de Amortizaciones.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - -#End Region - - -#Region " C O N T A B I L I D A D - P L A N T I L L A S P O L I Z A S " - - Public Function GetConta_PlantillasPolizas(CvePlantillaPoliza As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Conta_PlantillasPolizasGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePlantillaPoliza", SqlDbType.Int).Value = CvePlantillaPoliza - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - Try - SqlAdapter.Fill(Data) - If CvePlantillaPoliza > 0 AndAlso Data IsNot Nothing AndAlso Data.Rows.Count > 0 Then - Me.CvePlantillaPoliza = Data.Rows(0)("CvePlantillaPoliza").ToString.ToEntero - Me.PlantillaPoliza = Data.Rows(0)("PlantillaPoliza").ToString - 'Me.TipoPlantilla = Data.Rows(0)("TipoPlantilla").ToString.ToEntero - Me.TipoPoliza = Data.Rows(0)("TipoPoliza").ToString.ToEntero - 'Me.Orden = Data.Rows(0)("Orden").ToString.ToEnter - Me.Estatus = Data.Rows(0)("Estatus").ToString - Me.FechaIng = Data.Rows(0)("FechaIng").ToString.ToDateTime - Me.CveUsuario = Data.Rows(0)("CveUsuario").ToString.ToEntero - Me.Usuario = Data.Rows(0)("Usuario").ToString - Me.CveEmpresa = Data.Rows(0)("CveEmpresa").ToString.ToEntero - Me.CveTipoPlantillaPoliza = Data.Rows(0)("CveTipoPlantillaPoliza").ToString.ToEntero - End If - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener las plantillas", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetConta_PlantillasPolizasEmpresas(CvePlantillaPoliza As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Conta_PlantillasPolizasEmpresasGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePlantillaPoliza", SqlDbType.Int).Value = CvePlantillaPoliza - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - Try - SqlAdapter.Fill(Data) - If CvePlantillaPoliza > 0 AndAlso Data IsNot Nothing AndAlso Data.Rows.Count > 0 Then - Me.CvePlantillaPoliza = Data.Rows(0)("CvePlantillaPoliza").ToString.ToEntero - Me.PlantillaPoliza = Data.Rows(0)("PlantillaPoliza").ToString - 'Me.TipoPlantilla = Data.Rows(0)("TipoPlantilla").ToString.ToEntero - Me.TipoPoliza = Data.Rows(0)("TipoPoliza").ToString.ToEntero - 'Me.Orden = Data.Rows(0)("Orden").ToString.ToEnter - Me.Estatus = Data.Rows(0)("Estatus").ToString - Me.FechaIng = Data.Rows(0)("FechaIng").ToString.ToDateTime - Me.CveUsuario = Data.Rows(0)("CveUsuario").ToString.ToEntero - Me.Usuario = Data.Rows(0)("Usuario").ToString - Me.CveEmpresa = Data.Rows(0)("CveEmpresa").ToString.ToEntero - Me.CveTipoPlantillaPoliza = Data.Rows(0)("CveTipoPlantillaPoliza").ToString.ToEntero - End If - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener las plantillas", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function AddConta_PlantillasPolizasEmpresas(CvePlantillaPoliza As Integer, TipoPoliza As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean - Dim retorno As Boolean = False - - DataAdapter("PA_Conta_PlantillasPolizasEmpresasAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@TipoPoliza", SqlDbType.Int).Value = TipoPoliza - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CvePlantillaPoliza", SqlDbType.Int).Value = CvePlantillaPoliza - End With - - Try - SqlAdapter.Fill(Data) - retorno = True - Catch Ex As Exception - OnError("Ocurrió un error al agregar la plantilla.", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - Return retorno - End Function - Public Function UpdateConta_PlantillasPolizasEmpresas(CvePlantillaPoliza As Integer, TipoPoliza As Integer, CveEmpresa As Integer) As Boolean - Dim retorno As Boolean = False - - DataAdapter("PA_Conta_PlantillasPolizasEmpresasUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("CvePlantillaPoliza", SqlDbType.Int).Value = CvePlantillaPoliza - .Add("TipoPoliza", SqlDbType.Int).Value = TipoPoliza - .Add("CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - retorno = True - Catch ex As Exception - OnError("Ocurrió un error al guardar los cambios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return retorno - End Function - Public Function AddConta_PlantillasPolizas(CvePlantillaPoliza As Integer, PlantillaPoliza As String, CveTipoPlantillaPoliza As Integer, TipoPoliza As Integer, Estatus As Boolean, FechaIng As String, CveUsuario As Integer, CveEmpresa As Integer) As Boolean - Dim retorno As Boolean = False - - DataAdapter("PA_Conta_PlantillasPolizasAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@PlantillaPoliza", SqlDbType.VarChar).Value = PlantillaPoliza - .Add("@CveTipoPlantillaPoliza", SqlDbType.Int).Value = CveTipoPlantillaPoliza - .Add("@TipoPoliza", SqlDbType.Int).Value = TipoPoliza - .Add("@Estatus", SqlDbType.Bit).Value = Estatus - .Add("@FechaIng", SqlDbType.DateTime).Value = FechaIng - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CvePlantillaPoliza", SqlDbType.Int).Value = CvePlantillaPoliza - End With - - Try - SqlAdapter.Fill(Data) - retorno = True - Me.CvePlantillaPoliza = CvePlantillaPoliza - Catch Ex As SqlException - If Ex.Message.Contains("Número: 2627;") Then - Alert(String.Format("Ya existe un Registro con el mismo nombre: {0}. o con la misma Clave :{1}", PlantillaPoliza, CvePlantillaPoliza), TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al Guardar.", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch Ex As Exception - - End Try - Return retorno - End Function - Public Function UpdateConta_PlantillasPolizas(PlantillaPoliza As String, CveTipoPlantillaPoliza As Integer, TipoPoliza As Integer, Estatus As Boolean, CvePlantillaPoliza As Integer) As Boolean - Dim retorno As Boolean = False - - DataAdapter("PA_Conta_PlantillasPolizasUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("PlantillaPoliza", SqlDbType.VarChar).Value = PlantillaPoliza - '.Add("TipoPlantilla", SqlDbType.Int).Value = TipoPlantilla - .Add("CveTipoPlantillaPoliza", SqlDbType.Int).Value = CveTipoPlantillaPoliza - .Add("TipoPoliza", SqlDbType.Int).Value = TipoPoliza - '.Add("Orden", SqlDbType.Int).Value = Orden - .Add("Estatus", SqlDbType.Bit).Value = Estatus - .Add("CvePlantillaPoliza", SqlDbType.Int).Value = CvePlantillaPoliza - - End With - - Try - SqlAdapter.Fill(Data) - retorno = True - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 2627;") Then - Alert("Ya existe un Registro con el mismo nombre: " & PlantillaPoliza & ".", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al guardar los cambios.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - OnError("Ocurrió un error al guardar los cambios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return retorno - End Function - - Public Function RemoveConta_PlantillasPolizas(CvePlantillaPoliza As Integer, CveEmpresa As Integer) As Boolean - Dim retorno As Boolean = False - - DataAdapter("PA_Conta_PlantillasPolizasRemove") - - With SqlAdapter.SelectCommand.Parameters - .Add("CvePlantillaPoliza", SqlDbType.Int).Value = CvePlantillaPoliza - .Add("CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - retorno = True - Catch ex As Exception - OnError("Ocurrió un error al Eliminar Plantilla Póliza.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return retorno - End Function - - Public Function RemoveConta_PlantillasPolizasDetalle(CvePlantillaPoliza As Integer, Optional CvePlantillaPolizaDetalle As Integer = -1) As Boolean - Dim retorno As Boolean = False - - DataAdapter("PA_Conta_PlantillasPolizasDetalleRemove") - - With SqlAdapter.SelectCommand.Parameters - .Add("CvePlantillaPolizaDetalle", SqlDbType.Int).Value = CvePlantillaPolizaDetalle - .Add("CvePlantillaPoliza", SqlDbType.Int).Value = CvePlantillaPoliza - End With - - Try - SqlAdapter.Fill(Data) - retorno = True - Catch ex As Exception - OnError("Ocurrió un error al Eliminar Plantilla Póliza Detalle.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return retorno - End Function - Public Function GetConta_PlantillasPolizasTipo() As Boolean - Dim retorno As Boolean = False - - DataAdapter("PA_Conta_PlantillasPolizasTipoGet") - - Try - SqlAdapter.Fill(Data) - retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los Tipos de plantillas", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - Return retorno - End Function - -#End Region - -#Region " C O N T A B I L I D A D - P L A N T I L L A S - P O L I Z A S - D E T A L L E S" - Public Function GetConta_PlantillasPolizasDetalle(CvePlantillaPoliza As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Conta_PlantillasPolizasDetalleGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePlantillaPoliza", SqlDbType.Int).Value = CvePlantillaPoliza - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener las plantillas detalle", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function AddConta_PlantillasPolizasDetalles(CvePlantillaPoliza As Integer, CveConcepto As Integer, TipoMovto As Integer, IdCtaContable As Integer, Orden As Integer, CveUsuario As Integer, CveEmpresa As Integer, CveSubProyecto As Integer, CveProveedor As Integer, Optional CvePersonal As Integer = -1) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Conta_PlantillasPolizasDetalleAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePlantillaPoliza", SqlDbType.Int).Value = CvePlantillaPoliza - .Add("@CveConcepto", SqlDbType.Int).Value = CveConcepto - .Add("@IdCtaContable", SqlDbType.Int).Value = IdCtaContable - .Add("@TipoMovto", SqlDbType.Int).Value = TipoMovto - .Add("@Orden", SqlDbType.Int).Value = Orden - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor - .Add("@CvePersonal", SqlDbType.Int).Value = CvePersonal - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex As SqlException - If Ex.Message.Contains("Número: 2627;") Then - Alert("Ya existe un Registro con el mismo nombre: " & PlantillaPoliza & ".", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al Guardar.", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch Ex As Exception - Me.OnError("Ocurrió un error al Guardar.", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - Return Retorno - End Function - Public Function UpdateConta_PlantillasPolizasDetalle(CveConcepto As Integer, TipoMovto As Integer, IdCtaContable As Integer, Orden As Integer, CvePlantillaPolizaDetalle As Integer, CveSubProyecto As Integer, CveProveedor As Integer, Optional CvePersonal As Integer = -1) As Boolean - Dim retorno As Boolean = False - - DataAdapter("PA_Conta_PlantillasPolizasDetalleUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("CveConcepto", SqlDbType.VarChar).Value = CveConcepto - .Add("TipoMovto", SqlDbType.Int).Value = TipoMovto - .Add("IdCtaContable", SqlDbType.Int).Value = IdCtaContable - .Add("Orden", SqlDbType.Int).Value = Orden - .Add("CvePlantillaPolizaDetalle", SqlDbType.Int).Value = CvePlantillaPolizaDetalle - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor - .Add("@CvePersonal", SqlDbType.Int).Value = CvePersonal - End With - - Try - SqlAdapter.Fill(Data) - retorno = True - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 2627;") Then - Alert("Ya existe un Registro con el mismo nombre: " & PlantillaPoliza & ".", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al guardar los cambios.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - OnError("Ocurrió un error al guardar los cambios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return retorno - End Function - - - - Public Function AddConta_PlantillasPolizasTipo(TipoPlantillaPoliza As String, CveUsuario As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Conta_PlantillasPolizasTipoAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@TipoPlantillaPoliza", SqlDbType.VarChar).Value = TipoPlantillaPoliza - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex As Exception - Me.OnError("Ocurrió un error al Agregar.", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - Return Retorno - End Function - - Public Function RemoveConta_PlantillaTipoDetalle(CveTipoPlantillaPoliza As Integer) As Boolean - Dim retorno As Boolean = False - - DataAdapter("PA_Conta_PlantillasTipoRemove") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveTipoPlantillaPoliza", SqlDbType.Int).Value = CveTipoPlantillaPoliza - - End With - Try - SqlAdapter.Fill(Data) - retorno = True - Catch ex As Exception - OnError("Ocurrió un error al Eliminar Plantilla Póliza Tipo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return retorno - End Function - - - - -#End Region - - -#Region "C O N C E P T O S - C O N T A B L E S" - 'Public Function AddConta_ConceptosContables(CveConceptoContable As Integer, Tipo As String, ConceptoContable As String, CveUsuario As Integer) As Boolean - ' Dim Retorno As Boolean = False - - ' DataAdapter("PA_Conta_ConceptosContablesAdd") - - ' With SqlAdapter.SelectCommand.Parameters - ' .Add("@CveConceptoContable", SqlDbType.Int).Value = CveConceptoContable - ' .Add("@Tipo", SqlDbType.VarChar).Value = Tipo - ' .Add("@ConceptoContable", SqlDbType.VarChar).Value = ConceptoContable - ' .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - ' End With - - ' Try - ' SqlAdapter.Fill(Data) - ' Retorno = True - ' Catch Ex1 As SqlException - ' If Ex1.Message.Contains("Número: 2627;") Then - ' Alert("Ya existe un Concepto Contable con el mismo nombre: " & Tipo & ".", TipoMensaje.MsgAdvertencia) - ' Else - ' Me.OnError("Ocurrió un error al Guardar el Concepto Contable.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - ' End If - ' Catch ex As Exception - ' OnError("Ocurrió un error al Guardar el Concepto Contable", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - ' End Try - - ' Return Retorno - 'End Function - - 'Public Function UpdateConta_ConceptosContables(Tipo As String, ConceptoContable As String, Estado As Boolean, CveConceptoContable As Integer) As Boolean - ' Dim Retorno As Boolean = False - - ' DataAdapter("PA_Conta_ConceptosContablesUpdate") - - ' With SqlAdapter.SelectCommand.Parameters - ' .Add("@Tipo", SqlDbType.VarChar).Value = Tipo - ' .Add("@ConceptoContable", SqlDbType.VarChar).Value = ConceptoContable - ' .Add("@Estado", SqlDbType.Bit).Value = Estado - ' .Add("@CveConceptoContable", SqlDbType.Int).Value = CveConceptoContable - ' End With - - ' Try - ' SqlAdapter.Fill(Data) - ' Retorno = True - ' Catch Ex1 As SqlException - ' If Ex1.Message.Contains("Número: 2627;") Then - ' Alert("Ya existe un Concepto Contable con el mismo nombre: " & Tipo & ".", TipoMensaje.MsgAdvertencia) - ' Else - ' Me.OnError("Ocurrió un error al guardar los cambios en el Concepto Contable", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - ' End If - ' Catch ex As Exception - ' OnError("Ocurrió un error al guardar los cambios en el Concepto Contable.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - ' End Try - - ' Return Retorno - 'End Function - - 'Public Function RemoveConta_ConceptosContables(CveConceptoContable As Integer) As Boolean - ' Dim Retorno As Boolean = False - - ' DataAdapter("PA_Conta_ConceptosContablesRemove") - - ' SqlAdapter.SelectCommand.Parameters.Add("@CveConceptoContable", SqlDbType.Int).Value = CveConceptoContable - - - ' Try - ' SqlAdapter.Fill(Data) - ' Retorno = True - ' Catch Ex1 As SqlException - ' If Ex1.Message.Contains("Número: 547;") Then - ' Alert("El Concepto Contable no se pudo eliminar porque está siendo usado por un registro.", TipoMensaje.MsgAdvertencia) - ' Else - ' Me.OnError("Ocurrió un error al eliminar el Concepto Contable.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - ' End If - ' Catch ex As Exception - ' Me.OnError("Ocurrió un error al eliminar el Concepto Contable.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - ' End Try - - ' Return Retorno - 'End Function -#End Region - -#Region " P O L I Z A S - C O M P L E M E N T A R I A S " - Public Function AddPoliza(TipoPol As Integer, Folio As Integer, FechaPoliza As Date, Concepto As String, CveUsuario As Integer, CveEmpresa As Integer, Optional CvePrePoliza As Integer = 0) As Integer - Dim Retorno As Integer = 0 - - DataAdapter("PA_Conta_PolizasAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Folio", SqlDbType.Int).Value = Folio - .Add("@TipoPol", SqlDbType.Int).Value = TipoPol - .Add("@Concepto", SqlDbType.VarChar).Value = Concepto - .Add("@FechaPoliza", SqlDbType.DateTime).Value = FechaPoliza - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza - .Add("@CvePoliza", SqlDbType.Int).Direction = ParameterDirection.Output - End With - - Try - SqlAdapter.Fill(Data) - Retorno = SqlAdapter.SelectCommand.Parameters("@CvePoliza").Value.ToString.ToEntero - ContaFolio = If(Data IsNot Nothing AndAlso Data.Rows.Count > 0, Data.Rows(0)("Folio").ToString.ToEntero, 0) - Catch ex As Exception - OnError("Ocurrió un error al agregar la poliza", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function AjustaPoliza(CvePoliza As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Conta_PolizasAjuste") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePoliza", SqlDbType.Int).Value = CvePoliza - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al realizar el ajuste de la póliza.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function AddPolizaDetalle(CvePoliza As Integer, CveCuenta As Integer, Cuenta As String, CveSubProyecto As Integer, TipoMovto As Boolean, Importe As Double, Referencia As String, - Concepto As String, FechaMovto As Date, Optional ImporteMonedaExtranjera As Double = 0, Optional CvePrePolizaDetalle As Integer = 0) As Boolean - Dim Retorno As Boolean = False - - If CvePoliza <= 0 Or CveCuenta <= 0 Then - Return False - End If - - DataAdapter("PA_Conta_PolizasDetalleAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePoliza", SqlDbType.Int).Value = CvePoliza - .Add("@CveCuenta", SqlDbType.Int).Value = CveCuenta - .Add("@Cuenta", SqlDbType.VarChar).Value = Cuenta - .Add("@TipoMovto", SqlDbType.Int).Value = TipoMovto - .Add("@Importe", SqlDbType.Money).Value = Math.Round(Importe, 2) - .Add("@Referencia", SqlDbType.VarChar).Value = Referencia - .Add("@Concepto", SqlDbType.VarChar).Value = Concepto - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@Fecha", SqlDbType.DateTime).Value = FechaMovto - .Add("@ImporteME", SqlDbType.Money).Value = ImporteMonedaExtranjera - .Add("@CvePrePolizaDetalle", SqlDbType.Int).Value = CvePrePolizaDetalle - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar el movimiento en la póliza.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function AddDevolucionesIVA(IdPoliza As Integer, IdCuenta As Integer, IdProveedor As Integer, PorIVA As Double, - SubTotal As Double, IVA As Double, RetIVA As Double, RetISR As Double, FechaMovto As Date, Referencia As String, Serie As String, Folio As Integer, UUID As String) As Boolean - Dim Retorno As Boolean = False - - If IdPoliza <= 0 Or IdCuenta <= 0 Then - Return False - End If - ' no puede ser menor el subtotal al IVA, para evitar numeros negativos - If SubTotal < IVA Then - Return False - End If - - DataAdapter("PA_Conta_DevolucionesIVAAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePoliza", SqlDbType.Int).Value = IdPoliza - .Add("@CveCuenta", SqlDbType.Int).Value = IdCuenta - .Add("@CveProveedor", SqlDbType.Int).Value = IdProveedor - .Add("@PorIVA", SqlDbType.Float).Value = Math.Round(PorIVA, 2) - .Add("@SubTotal", SqlDbType.Float).Value = Math.Round(SubTotal, 2) - .Add("@IVA", SqlDbType.Float).Value = Math.Round(IVA, 2) - .Add("@RetIVA", SqlDbType.Float).Value = Math.Round(RetIVA, 2) - .Add("@RetISR", SqlDbType.Float).Value = Math.Round(RetISR, 2) - .Add("@FechaMov", SqlDbType.DateTime).Value = FechaMovto - .Add("@Referencia", SqlDbType.VarChar).Value = If(Referencia.Length > 30, Referencia.Substring(1, 30), Referencia) - .Add("@Serie", SqlDbType.VarChar).Value = If(Serie.Length > 15, Serie.Substring(1, 15), Serie) - .Add("@Folio", SqlDbType.Int).Value = If(Len(Folio.ToString) <= 8, Folio, Right(Folio.ToString, 8).ToEntero) ' se limita a 8 digitos, sino le cortan y se toman los ultimos 8, para que guarde e contpaqi - .Add("@UUID", SqlDbType.VarChar).Value = UUID - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un Error al agregar el movimiento de devolucion de egresos en la póliza.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function UpdatePoliza(FechaPoliza As Date, Folio As Integer, CvePoliza As Integer, Concepto As String, TipoPoliza As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Conta_PolizasUpdate") - - - With SqlAdapter.SelectCommand.Parameters - .Add("@Folio", SqlDbType.Int).Value = Folio - .Add("@Concepto", SqlDbType.VarChar).Value = Concepto - .Add("@FechaPoliza", SqlDbType.DateTime).Value = FechaPoliza - .Add("@TipoPoliza", SqlDbType.Int).Value = TipoPoliza - .Add("@CvePoliza", SqlDbType.Int).Value = CvePoliza - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - - Catch ex As SqlException - If ex.Number = 50000 Then - OnError("No se puede registrar la poliza porque ya existe una con el mismo Folio", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - OnError("Ocurrió un error al actualizar la Póliza.", ex) - End Try - - Return Retorno - - End Function - Public Function UpdatePolizaDetalle(CvePolizaDetalle As Integer, IdCuenta As Integer, CveSubProyecto As Integer, TipoMovto As Boolean, Importe As Double, Referencia As String, - Concepto As String) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Conta_PolizasDetalleUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Referencia", SqlDbType.VarChar).Value = Referencia - .Add("@Concepto", SqlDbType.VarChar).Value = Concepto - .Add("@TipoMovto", SqlDbType.Int).Value = TipoMovto - .Add("@Importe", SqlDbType.Money).Value = Math.Round(Importe, 2) - .Add("@IdCuentaNueva", SqlDbType.Int).Value = IdCuenta - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CvePolizaDetalle", SqlDbType.Int).Value = CvePolizaDetalle - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar el Movimiento de la Poliza", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - - End Function - - Public Function RemovePolizaDetalle(CvePolizaDetalle As Integer) As Boolean - Dim Retorno As Boolean = False - - If CvePolizaDetalle <= 0 Then - Return False - End If - - DataAdapter("PA_Conta_PolizasDetalleRemove") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePolizaDetalle", SqlDbType.Int).Value = CvePolizaDetalle - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al eliminar el movimiento en la póliza.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function RemovePoliza(CvePoliza As Integer) As Boolean - Dim Retorno As Boolean = False - - If CvePoliza <= 0 Then - Return False - End If - - DataAdapter("PA_Conta_PolizasRemove") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePoliza", SqlDbType.Int).Value = CvePoliza - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al eliminar el movimiento en la póliza.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetPoliza(CvePoliza As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - If CvePoliza <= 0 Then - Return False - End If - - DataAdapter("PA_Conta_PolizasGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePoliza", SqlDbType.Int).Value = CvePoliza - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener la Poliza.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetPoliza(CveTipoPoliza As Integer, Fecha As Date, Folio As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Conta_PolizasFechaFolioGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveTipoPoliza", SqlDbType.Int).Value = CveTipoPoliza - .Add("@Folio", SqlDbType.Int).Value = Folio - .Add("@Fecha", SqlDbType.Date).Value = Fecha - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener la Poliza.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - - Public Function GetPolizaDetalle(CvePoliza As Integer) As Boolean - Dim Retorno As Boolean = False - - If CvePoliza <= 0 Then - Return False - End If - - DataAdapter("PA_Conta_PolizasDetalleGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePoliza", SqlDbType.Int).Value = CvePoliza - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los detalles de la Póliza.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function -#End Region - - - -#Region "F I N A N C I A M I E N T O - M E T A S" - Public Function AddFinan_Metas(Meta As Decimal, CveCuenta As Integer, Anio As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_Finan_MetasAdd") - With SqlAdapter.SelectCommand.Parameters - .Add("@Meta", SqlDbType.Money).Value = Meta - .Add("@CveCuenta", SqlDbType.Int).Value = CveCuenta - .Add("@Anio", SqlDbType.SmallInt).Value = Anio - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar la Meta", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function UpdateFinan_Metas(Meta As Decimal, CveCuenta As Integer, Anio As Integer, Estatus As Boolean, CveMeta As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Finan_MetasUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Meta", SqlDbType.Money).Value = Meta - .Add("@CveCuenta", SqlDbType.Int).Value = CveCuenta - .Add("@Anio", SqlDbType.SmallInt).Value = Anio - .Add("@Estatus", SqlDbType.Bit).Value = Estatus - .Add("@CveMeta", SqlDbType.Int).Value = CveMeta - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - - Catch ex As SqlException - If ex.Number = 50000 Then - OnError("No se puede registrar la Meta porque ya existe", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - OnError("Ocurrió un error al actualizar la Meta.", ex) - End Try - - Return Retorno - - End Function - - Public Function RemoveFinan_Metas(CveMeta As Integer) As Boolean - Dim Retorno As Boolean = False - - If CveMeta <= 0 Then - Return False - End If - - DataAdapter("PA_Finan_MetasRemove") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveMeta", SqlDbType.Int).Value = CveMeta - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al eliminar el movimiento en la Meta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetFinan_Metas(CveMeta As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - If CveMeta <= 0 Then - Return False - End If - - DataAdapter("PA_Finan_MetasGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveMeta", SqlDbType.Int).Value = CveMeta - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener la Meta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - -#End Region - -#Region "F I N A N C I A M I E N T O - V E N T A S - P R O Y E C C I O N E S" - Public Function AddFinan_VentasProyecciones(CvePS As Integer, Cantidad As Double, PU As Double, Fecha As Date, Anio As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_Finan_MetasAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@Cantidad", SqlDbType.Money).Value = Cantidad - .Add("@PU", SqlDbType.Money).Value = PU - .Add("@Fecha", SqlDbType.DateTime).Value = Fecha - .Add("@Anio", SqlDbType.SmallInt).Value = Anio - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar la Proyección de Venta", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function UpdateFinan_VentasProyecciones(CvePS As Integer, Cantidad As Double, PU As Double, Fecha As Date, CveVentaProyeccion As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Finan_MetasUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@Cantidad", SqlDbType.Money).Value = Cantidad - .Add("@PU", SqlDbType.Money).Value = PU - .Add("@Fecha", SqlDbType.DateTime).Value = Fecha - .Add("@CveVentaProyeccion", SqlDbType.Int).Value = CveVentaProyeccion - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - - Catch ex As SqlException - If ex.Number = 50000 Then - OnError("No se puede registrar la Proyección de Venta porque ya existe", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - OnError("Ocurrió un error al actualizar la Proyección de Venta.", ex) - End Try - - Return Retorno - - End Function - - Public Function RemoveFinan_VentasProyecciones(CveVentaProyeccion As Integer) As Boolean - Dim Retorno As Boolean = False - - If CveVentaProyeccion <= 0 Then - Return False - End If - - DataAdapter("PA_Finan_MetasRemove") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVentaProyeccion", SqlDbType.Int).Value = CveVentaProyeccion - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al eliminar el movimiento en la Proyección de Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetFinan_VentasProyecciones(CveVentaProyeccion As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - If CveVentaProyeccion <= 0 Then - Return False - End If - - DataAdapter("PA_Finan_MetasGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVentaProyeccion", SqlDbType.Int).Value = CveVentaProyeccion - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener la Proyección de Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function -#End Region - -#Region "F I N A N C I A M I E N T O S - C U E N T A S" - Public Function AddFinan_Cuentas(Cuenta As String, IdCtaContable As Integer, TipoInformacion As Integer, TipoCuenta As Integer, CveCuentaPadre As Integer, Orden As Integer, Nivel As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_Finan_CuentasAdd") - With SqlAdapter.SelectCommand.Parameters - .Add("@Cuenta", SqlDbType.Money).Value = Cuenta - .Add("@IdCtaContable", SqlDbType.Int).Value = IdCtaContable - .Add("@TipoInformacion", SqlDbType.TinyInt).Value = TipoInformacion - .Add("@TipoCuenta", SqlDbType.TinyInt).Value = TipoCuenta - .Add("@CveCuentaPadre", SqlDbType.Int).Value = CveCuentaPadre - .Add("@Orden", SqlDbType.Int).Value = Orden - .Add("@Nivel", SqlDbType.Int).Value = Nivel - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar la Cuenta", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function UpdateFinan_Cuentas(Cuenta As Decimal, IdCtaContable As Integer, TipoInformacion As Integer, TipoCuenta As Integer, CveCuentaPadre As Integer, Orden As Integer, Nivel As Integer, CveCuenta As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Finan_CuentasUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Cuenta", SqlDbType.Money).Value = Cuenta - .Add("@IdCtaContable", SqlDbType.Int).Value = IdCtaContable - .Add("@TipoInformacion", SqlDbType.TinyInt).Value = TipoInformacion - .Add("@TipoCuenta", SqlDbType.TinyInt).Value = TipoCuenta - .Add("@CveCuentaPadre", SqlDbType.Int).Value = CveCuentaPadre - .Add("@Orden", SqlDbType.Int).Value = Orden - .Add("@Nivel", SqlDbType.Int).Value = Nivel - .Add("@CveCuenta", SqlDbType.Int).Value = CveCuenta - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - - Catch ex As SqlException - If ex.Number = 50000 Then - OnError("No se puede registrar la Cuenta porque ya existe", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - OnError("Ocurrió un error al actualizar la Cuenta.", ex) - End Try - - Return Retorno - - End Function - Public Function RemoveFinan_Cuentas(CveCuenta As Integer) As Boolean - Dim Retorno As Boolean = False - - If CveCuenta <= 0 Then - Return False - End If - - DataAdapter("PA_Finan_CuentasRemove") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCuenta", SqlDbType.Int).Value = CveCuenta - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al eliminar el movimiento en la Cuenta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function GetFinan_Cuentas(CveCuenta As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - If CveCuenta <= 0 Then - Return False - End If - - DataAdapter("PA_Finan_CuentasGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCuenta", SqlDbType.Int).Value = CveCuenta - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener la Cuenta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - -#End Region - - - - -#Region " CONTABILIDAD SIG " - - -#Region " CUENTAS " - Public Function GetCuentas(CveCuenta As Integer, Codigo As String, Afectable As Integer, CveEmpresa As Integer, Optional RowNum As Integer = 100000, Optional CvePadre As Integer = -1) As Boolean ', Codigo As String, Nombre As String, CveClasificacionCuenta As Integer, TipoCuenta As Integer, Afectable As Integer, Estatus As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_CuentasGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCuenta", SqlDbType.Int).Value = CveCuenta - .Add("@Codigo", SqlDbType.VarChar).Value = Codigo - .Add("@Afectable", SqlDbType.VarChar).Value = Afectable - .Add("@CveEmpresa", SqlDbType.VarChar).Value = CveEmpresa - .Add("@RowNum", SqlDbType.VarChar).Value = RowNum - .Add("@CvePadre", SqlDbType.Int).Value = CvePadre - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al cargar las Cuentas Contables SIG", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetClasificacionesCuentas() As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_ClasificacionesCuentaGet") - With SqlAdapter.SelectCommand.Parameters - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al cargar las Clasificaciones de Cuentas", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function -#End Region - - -#Region " EJERCICIOS " - Public Function GetEjercicios(CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_EjerciciosGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al cargar los Ejercicios", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function AddEjercicio(Ejercicio As String, PeriodoActual As Integer, Estatus As Boolean, CveUsuario As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_EjerciciosAdd") - With SqlAdapter.SelectCommand.Parameters - .Add("@Ejercicio", SqlDbType.VarChar).Value = Ejercicio - .Add("@PeriodoActual", SqlDbType.Int).Value = PeriodoActual - .Add("@Estatus", SqlDbType.Bit).Value = Estatus - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar el Ejercicio", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function UpdateEjercicio(CveEjercicio As Integer, Ejercicio As String, Estatus As Boolean, CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_EjerciciosUpdate") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEjercicio", SqlDbType.Int).Value = CveEjercicio - .Add("@Ejercicio", SqlDbType.VarChar).Value = Ejercicio - .Add("@Estatus", SqlDbType.Bit).Value = Estatus - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar los ejercicios", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function RemoveEjercicio(CveEjercicio As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_EjerciciosRemove") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEjercicio", SqlDbType.Int).Value = CveEjercicio - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar los ejercicios", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function -#End Region - - -#End Region - -#Region "REPORTE DE CONTABILIDAD" - 'Public Function PolizaGet(CvePoliza As Integer) As Boolean - ' Dim Retorno As Boolean = False - - ' 'StrSQL.Clear() - ' 'StrSQL.Append(" SELECT mp.id, mp.IdPoliza, mp.NumMovto, mp.IdCuenta , mp.IdCuenta as CveCuenta, c.CODIGO, c.NOMBRE as Cuenta , T.Codigo as CodigoTipoPoliza, T.Nombre AS TipoPoliza, mp.Folio, mp.Importe, mp.Concepto, mp.Referencia, mp.SIGReferencia, mp.Fecha, mp.IdSegNeg, s.Nombre AS SegNeg, p.Fecha AS FechaPol, p.Cargos, p.Abonos, p.Concepto AS ConceptoPoliza, ") - ' 'StrSQL.Append(" CASE WHEN ISNUMERIC(c.Codigo) = 1 THEN FORMAT(CAST (c.Codigo AS BIGINT),(SELECT REPLACE(Mascarilla,'X','0') FROM Parametros)) ELSE c.Codigo END + ' - ' + c.Nombre + ' ' AS CtaCodigo, ") 'Roberto 8/Nov/2014 - ' 'StrSQL.Append(" SUM (CASE WHEN mp.TipoMovto = 0 THEN mp.Importe ELSE 0 END) AS Cargo, SUM (CASE WHEN mp.TipoMovto = 1 THEN mp.Importe ELSE 0 END) AS Abono, ") - ' 'StrSQL.Append(" SUM (CASE WHEN mp.TipoMovto = 0 THEN mp.ImporteME ELSE 0 END) AS CargoME, SUM (CASE WHEN mp.TipoMovto = 1 THEN mp.ImporteME ELSE 0 END) AS AbonoME, ") - ' 'StrSQL.Append(" mp.TipoMovto, CASE WHEN ISNUMERIC(c.CODIGO) = 1 THEN FORMAT(CAST (c.CODIGO AS BIGINT),(SELECT REPLACE(Mascarilla,'X','0') FROM Parametros)) ELSE c.CODIGO END CuentaFormato, '' as Estado ") - ' 'StrSQL.Append(" FROM MovimientosPoliza mp ") - ' 'StrSQL.Append(" INNER JOIN Polizas p ON mp.IdPoliza = p.Id ") - ' 'StrSQL.Append(" INNER JOIN Cuentas c ON c.Id = mp.IdCuenta ") - ' 'StrSQL.Append(" INNER JOIN TiposPolizas t ON mp.TipoPol = t.Codigo ") - ' 'StrSQL.Append(" LEFT JOIN SegmentosNegocio s ON mp.IdSegNeg = s.id ") - ' 'StrSQL.Append(" WHERE (@IdPoliza = -1 OR mp.IdPoliza = @IdPoliza) ") - ' 'StrSQL.Append(" AND (@Eje = -1 OR mp.Ejercicio = @Eje) ") - ' 'StrSQL.Append(" AND (@Periodo = -1 OR mp.Periodo = @Periodo) ") - ' 'StrSQL.Append(" AND (@TipoPol = -1 OR mp.TipoPol = @TipoPol) ") - ' 'StrSQL.Append(" AND (@NumPol = -1 OR mp.Folio = @NumPol) ") - ' 'StrSQL.Append(" ") - ' 'StrSQL.Append(" GROUP BY mp.id, mp.IdPoliza, mp.NumMovto, mp.IdCuenta, mp.TipoMovto, c.CODIGO, c.NOMBRE, T.Codigo, T.Nombre, mp.Folio, mp.Importe, mp.Concepto, mp.Referencia, mp.SIGReferencia, mp.Fecha, mp.IdSegNeg, s.Nombre, p.Fecha, p.Cargos, p.Abonos, p.Concepto, Afectable ") 'Roberto 8/Nov/2014 campo Afectable - ' 'StrSQL.Append(" ORDER BY mp.NumMovto ") - - ' DataAdapter("PA_Conta_PolizaGet") - - ' 'DataAdapter(StrSQL.ToString, CommandType.Text) - ' With SqlAdapter.SelectCommand.Parameters - ' .Add("@IdPoliza", SqlDbType.Int).Value = CvePoliza - ' '.Add("@Eje", SqlDbType.Int).Value = Ejercicio - ' '.Add("@Periodo", SqlDbType.Int).Value = Periodo - ' '.Add("@TipoPol", SqlDbType.Int).Value = TipoPol - ' '.Add("@NumPol", SqlDbType.Int).Value = NumPol - ' End With - - ' Try - ' SqlAdapter.Fill(Data) - ' Retorno = True - ' Catch ex As Exception - ' OnError("Error al consultar los Movimientos, Auxiliares del Catálogo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - ' End Try - - ' Return Retorno - 'End Function - - Public Function GetBalanceGeneralMensual(ANO As Integer, TipoMovtos As Integer, SubTotales As Integer, CveSubProyecto As String, CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_EstadoResultadosMensual") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Ano", SqlDbType.Int).Value = ANO - .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos - ' .Add("@SubTotales", SqlDbType.Int).Value = SubTotales - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener el Balance General Mensual", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - - - - - Public Function GetBalanceGeneralAnual(ANO As Integer, TipoMovtos As Integer, CveEmpresa As Integer, CveSubProyecto As String) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_BalanceGeneralAnual") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Ano", SqlDbType.Int).Value = ANO - .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener el Balance General Anual", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - - - Public Function GetSituacionFinanciera(FechaI As Date, FechaF As Date, CveEmpresa As Integer, CveSubProyecto As String, TipoMovtos As Integer, Optional SAT As Integer = 0) As Boolean - Dim Retorno = False - - 'SqlAdapter.SelectCommand.t - - DataAdapter("PA_Conta_SituacionFinancieraGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.Date).Value = FechaI - .Add("@FechaF", SqlDbType.Date).Value = FechaF - .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@SAT", SqlDbType.Int).Value = SAT - End With - SqlAdapter.SelectCommand.CommandTimeout = 0 - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener el Estado de Situaci?n de Financiera", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetAnexoCatalogo(IdCuenta As Integer, FechaI As Date, FechaF As Date, OpcionCuentas As Integer, CveSubProyecto As String, CveEmpresa As Integer, Optional TipoMovtos As Integer = -1, Optional SAT As Integer = 0) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_AnexoCatalogoGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.Date).Value = FechaI - .Add("@FechaF", SqlDbType.Date).Value = FechaF - .Add("@IdCuentaPadre", SqlDbType.Int).Value = IdCuenta - .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos - .Add("@OpcionCuentas", SqlDbType.Int).Value = OpcionCuentas - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@SAT", SqlDbType.Int).Value = SAT - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener el Anexo del Catalogo", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - - Public Function GetMovimientosAuxiliaresCatalogo(IdCuenta As Integer, FechaI As Date, FechaF As Date, CveMoneda As Integer, CveSubProyecto As String, CveEmpresa As Integer, TipoReporte As String) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_MovimientosAuxiliaresCatalogoGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.Date).Value = FechaI - .Add("@FechaF", SqlDbType.Date).Value = FechaF - .Add("@IdCuentaPadre", SqlDbType.Int).Value = IdCuenta - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@Tipo", SqlDbType.Int).Value = TipoReporte - End With - SqlAdapter.SelectCommand.CommandTimeout = 0 - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener los Movimientos Auxiliares Catalogo", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function PolizaGet(CvePoliza As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Conta_PolizaNewGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePoliza", SqlDbType.Int).Value = CvePoliza - '.Add("@Eje", SqlDbType.Int).Value = Ejercicio - '.Add("@Periodo", SqlDbType.Int).Value = Periodo - '.Add("@TipoPol", SqlDbType.Int).Value = TipoPol - '.Add("@NumPol", SqlDbType.Int).Value = NumPol - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Error al consultar los Movimientos, Auxiliares del Catálogo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function GetEstadoActividades(FechaI As Date, FechaF As Date, TipoMovtos As Integer, CveSubProyecto As String, CveEmpresa As Integer, Optional SAT As Integer = 0) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_EstadoActividadesGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.Date).Value = FechaI - .Add("@FechaF", SqlDbType.Date).Value = FechaF - .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@SAT", SqlDbType.Int).Value = SAT - End With - - SqlAdapter.SelectCommand.CommandTimeout = 0 - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener el Estado de Actividades", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function GetBalanzaComprobacion(FechaI As Date, FechaF As Date, TipoCuentas As Integer, TipoReporte As Integer, CveSubProyecto As String, CveEmpresa As Integer, Optional Sat As Integer = 0) As Boolean - Dim Retorno = False - - - DataAdapter("PA_Conta_BalanzaComprobacionGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.Date).Value = FechaI - .Add("@FechaF", SqlDbType.Date).Value = FechaF - .Add("@TipoCuentas", SqlDbType.Int).Value = TipoCuentas - .Add("@TipoReporte", SqlDbType.Int).Value = TipoReporte - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@SAT", SqlDbType.Int).Value = Sat - End With - SqlAdapter.SelectCommand.CommandTimeout = 0 - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener Balanza de comprobación", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetCambioSituacionFinanciera(FechaI As Date, FechaF As Date, Unidad As Integer, TipoReporte As Integer, CveSubProyecto As String, CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_RepCambioSituacionFinanciera") - - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.Date).Value = FechaI - .Add("@FechaF", SqlDbType.Date).Value = FechaF - .Add("@Unidad", SqlDbType.Int).Value = Unidad - .Add("@TipoReporte", SqlDbType.Int).Value = TipoReporte - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener el Estado de Cambio de Situacion Financiera.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function GetFlujoEfectivo(FechaI As Date, FechaF As Date, Unidad As Integer, TipoReporte As Integer, CveSubProyecto As String, CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_RepFlujoEfectivo") - - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.Date).Value = FechaI - .Add("@FechaF", SqlDbType.Date).Value = FechaF - .Add("@Unidad", SqlDbType.Int).Value = Unidad - .Add("@TipoReporte", SqlDbType.Int).Value = TipoReporte - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener el Estado de Flujo de Efectivo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function GetOrigenAplicacion(FechaI As String, FechaF As String, TipoReporte As Integer, CveSubProyecto As String, CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_RepOrigenAplicacion") - - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.Date).Value = FechaI - .Add("@FechaF", SqlDbType.Date).Value = FechaF - .Add("@Tipo", SqlDbType.Int).Value = TipoReporte - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener el estado de origen y aplicación.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function GetTiposPoliza(CveTipoPoliza As Integer, TipoPoliza As String, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Conta_TiposPolizasNewGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveTipoPoliza", SqlDbType.Int).Value = CveTipoPoliza - .Add("@TipoPoliza", SqlDbType.Int).Value = TipoPoliza - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener los tipos de Polizas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function GetParametros() As Boolean - Dim Retorno As Boolean = False - - DataAdapter(" SELECT * FROM Parametros ", CommandType.Text) - - Try - SqlAdapter.Fill(Data) - Data.TableName = "Parametros" - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al consultar los parametros.", ex) - End Try - - Return Retorno - End Function - - Public Function GetParametros(CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter(" SELECT * FROM Parametros WHERE IdEmpresa = @CveEmpresa ", CommandType.Text) - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Data.TableName = "Parametros" - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al consultar los parametros.", ex) - End Try - - Return Retorno - End Function - - Public Function GetEstadoResultadosMensual(ANO As Integer, TipoMovtos As Integer, CveSubProyecto As String, CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_EstadoResultadosMensual") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Ano", SqlDbType.Int).Value = ANO - .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener el Estado de Resultados Mensual", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetEstadoResultadosAnual(ANO As Integer, TipoMovtos As Integer, CveSubProyecto As String, CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_EstadoResultadosAnual") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Ano", SqlDbType.Int).Value = ANO - .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener el Estado de Resultados Anual", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function GetOrigenAplicacionMensual(Ejercicio As Integer, TipoMovtos As Integer, CveSubProyecto As String, CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_RepOrigenAplicacionMensual") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Ano", SqlDbType.Int).Value = Ejercicio - .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener el estado de origen y aplicación mensual.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetOrigenAplicacionAnual(Ejercicio As Integer, TipoMovtos As Integer, CveSubProyecto As String, CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_RepOrigenAplicacionAnual") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Ano", SqlDbType.Int).Value = Ejercicio - .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener el estado de origen y aplicación anual.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function GetVariacionHaciendaPublica(FechaI As Date, FechaF As Date, TipoMovtos As Integer, CveSubProyecto As String, CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_RepVariacionHaciendaPublica") - - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.Date).Value = FechaI - .Add("@FechaF", SqlDbType.Date).Value = FechaF - .Add("@TipoMovtos", SqlDbType.Int).Value = TipoMovtos - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener el Estado de Cambio de Hacienda Publica.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function -#End Region - -#Region "I N C O N S I S T E N C I A S" - Public Function GetInconsistencias() As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Sis_InconsistenciasGet") - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener inconsistencias.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - -#End Region - -#Region " REPORTES FINANCIEROS DICIEMBRE 2016 " - Public Function GetBalanceGeneralVertical(Ejercicio As Integer, Periodo As Integer, CveSubProyecto As Integer, TipoMovtos As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_BalanceGeneralVerticalGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Ejercicio", SqlDbType.Int).Value = Ejercicio - .Add("@Periodo", SqlDbType.Int).Value = Periodo - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener el Balance General Vertical", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function GetBalanceGeneralMensualVertical(Ejercicio As Integer, CveSubProyecto As Integer, TipoMovtos As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_BalanceGeneralVerticalMensualGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Ejercicio", SqlDbType.Int).Value = Ejercicio - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener el Balance General Vertical Mensual", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function GetBalanceGeneralAnualVertical(Ejercicio As Integer, CveSubProyecto As Integer, TipoMovtos As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_BalanceGeneralAnualGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Ejercicio", SqlDbType.Int).Value = Ejercicio - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(DSet) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener el Balance General Vertical Anual", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetBalanceGeneralMensualHorizontal(Ejercicio As Integer, CveSubProyecto As Integer, TipoMovtos As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_BalanceGeneralHorizontalMensualGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Ejercicio", SqlDbType.Int).Value = Ejercicio - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener el Balance General Horizontal Mensual", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetBalanceGeneralHorizontalCC(Ejercicio As Integer, Periodo As Integer, CveSubProyecto As Integer, TipoMovtos As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_BalanceGeneralHorizontalCCGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Ejercicio", SqlDbType.Int).Value = Ejercicio - .Add("@Periodo", SqlDbType.Int).Value = Periodo - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(DSet) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener el Balance General Horizontal CC", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function GetEstadoResultadosVertical(Ejercicio As Integer, Periodo As Integer, CveSubProyecto As Integer, TipoMovtos As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_EstadoResultadosVerticalGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Ejercicio", SqlDbType.Int).Value = Ejercicio - .Add("@Periodo", SqlDbType.Int).Value = Periodo - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener el Balance General Vertical", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function GetEstadoResultadoMensualHorizontal(Ejercicio As Integer, CveSubProyecto As Integer, TipoMovtos As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_EstadoResultadosHorizontalMensual") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Ejercicio", SqlDbType.Int).Value = Ejercicio - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener el Estado Resultados Horizontal Mensual", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetEstadoResultadosAnualHorizontal(Ejercicio As Integer, CveSubProyecto As Integer, TipoMovtos As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_EstadoResultadosHorizontalAnual") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Ejercicio", SqlDbType.Int).Value = Ejercicio - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(DSet) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener el Estado Resultados Horizontal Anual", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - - Public Function GetEstadoResultadosHorizontalCC(Ejercicio As Integer, Periodo As Integer, CveSubProyecto As Integer, TipoMovtos As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_EstadoResultadosHorizontalCCGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Ejercicio", SqlDbType.Int).Value = Ejercicio - .Add("@Periodo", SqlDbType.Int).Value = Periodo - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(DSet) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener el Estado Resultados Horizontal CC", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetAnexoCatalogoMensual(CveCuenta As Integer, Ejercicio As Integer, CveSubproyecto As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_AnexoCatalogoMensualGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCuenta", SqlDbType.Int).Value = CveCuenta - .Add("@Ejercicio", SqlDbType.Int).Value = Ejercicio - .Add("@CveSubproyecto", SqlDbType.Int).Value = CveSubproyecto - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener el Estado Resultados Horizontal CC", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function GetAnexoCatalogoAnual(CveCuenta As Integer, Ejercicio As Integer, CveSubproyecto As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_AnexoCatalogoAnualGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCuenta", SqlDbType.Int).Value = CveCuenta - .Add("@Ejercicio", SqlDbType.Int).Value = Ejercicio - .Add("@CveSubproyecto", SqlDbType.Int).Value = CveSubproyecto - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(DSet) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener el Estado Resultados Horizontal CC", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function GetAnexoCatalagoCC(CveCuenta As Integer, Ejercicio As Integer, CveSubproyecto As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_AnexoCatalogoCCGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCuenta", SqlDbType.Int).Value = CveCuenta - .Add("@Ejercicio", SqlDbType.Int).Value = Ejercicio - .Add("@CveSubproyecto", SqlDbType.Int).Value = CveSubproyecto - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(DSet) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener el Estado Resultados Horizontal CC", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function GetRepPresupuestosEgresosSaldosDetalle(MomentoContable As Integer, ProgramaOperativo As Integer, FuenteFinanciamiento As Integer, TipoGasto As Integer, UnidadAdministrativa As Integer, ClasificacionOG As Integer, CodigoOG As String, FechaI As Date, FechaF As Date) As Boolean - Dim Retorno = False - - DataAdapter("PA_PresupuestosEgresosSaldosDetalleRep") - - With SqlAdapter.SelectCommand.Parameters - .Add("@MomentoContable", SqlDbType.Int).Value = MomentoContable - .Add("@ProgramaOperativo", SqlDbType.Int).Value = ProgramaOperativo - .Add("@FuenteFinanciamiento", SqlDbType.Int).Value = FuenteFinanciamiento - .Add("@TipoGasto", SqlDbType.Int).Value = TipoGasto - .Add("@UnidadAdministrativa", SqlDbType.Int).Value = UnidadAdministrativa - .Add("@ClasificacionOG", SqlDbType.Int).Value = ClasificacionOG - .Add("@CodigoOG", SqlDbType.VarChar).Value = CodigoOG - - .Add("@FI", SqlDbType.Date).Value = FechaI - .Add("@FF", SqlDbType.Date).Value = FechaF - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener los Movimientos Auxiliares Presupuestales", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function GetRepPresupuestosIngresosSaldosDetalle(MomentoContable As Integer, FuenteRecaudacion As Integer, RubroIngreso As Integer, FechaI As Date, FechaF As Date, CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_PresupuestosIngresosSaldosDetalleRep") - - With SqlAdapter.SelectCommand.Parameters - .Add("@MomentoContable", SqlDbType.Int).Value = MomentoContable - .Add("@FuenteRecaudacion", SqlDbType.Int).Value = FuenteRecaudacion - .Add("@RubroIngreso", SqlDbType.Int).Value = RubroIngreso - .Add("@FI", SqlDbType.Date).Value = FechaI - .Add("@FF", SqlDbType.Date).Value = FechaF - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener los Movimientos Auxiliares Presupuestales", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function GetPresupuestoIngresosRep(Ejercicio As Integer, Fecha As Date, Gpo As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_PresupuestosIngresosRep") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Ejercicio", SqlDbType.Int).Value = Ejercicio - .Add("@Fecha", SqlDbType.Date).Value = Fecha - .Add("@Gpo", SqlDbType.Int).Value = Gpo - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener el reporte de los presupuestos de ingresos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function GetRepPresupuestosEgresosSaldosMensual(TipoCuenta As String, Ejercicio As Integer, Capitulo As String, CveClasificacion As Integer, CveFuenteFinanciamiento As Integer, CveProgramaOperativo As Integer, CveUnidadAdministrativa As Integer, Gpo As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_PresupuestosEgresosSaldosMensualRep") - - With SqlAdapter.SelectCommand.Parameters - .Add("@TipoCuenta", SqlDbType.VarChar).Value = TipoCuenta - .Add("@Ejercicio", SqlDbType.Int).Value = Ejercicio - .Add("@Capitulo", SqlDbType.VarChar).Value = Capitulo - .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion - .Add("@CveFuenteFinanciamiento", SqlDbType.Int).Value = CveFuenteFinanciamiento - .Add("@CveProgramaOperativo", SqlDbType.Int).Value = CveProgramaOperativo - .Add("@CveUnidadAdministrativa", SqlDbType.Int).Value = CveUnidadAdministrativa - .Add("@GPO", SqlDbType.Int).Value = Gpo - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Reporte de Presupuestos de Egresos Mensual.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function GetPresupuestoIngresosMensualesRep(Ejercicio As Integer, MomentoContable As Integer, CveFuenteRecaudacion As Integer, CveRubroIngreso As Integer, GPO As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_PresupuestosIngresosMensualesRep") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Ejercicio", SqlDbType.Int).Value = Ejercicio - '.Add("@Fecha", SqlDbType.Date).Value = Fecha - .Add("@MomentoContable", SqlDbType.Int).Value = MomentoContable - .Add("@CveFuenteRecaudacion", SqlDbType.Int).Value = CveFuenteRecaudacion - .Add("@CveRubroIngreso", SqlDbType.Int).Value = CveRubroIngreso - .Add("@GPO", SqlDbType.Int).Value = GPO - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener eL reporte de los presupuestos de ingresos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function GetDependenciasUnidadesResponsables(CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_DepUnidadResponsableGET") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener eL reporte de los presupuestos de ingresos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function GetProgramaSubPrograma(CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_ProGSubProgramaGET") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener eL reporte de los presupuestos de ingresos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function GetGrupoVulnerable(CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_GrupoVulnerable") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener eL reporte de los presupuestos de ingresos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function GetTipoGasto(CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_AC_TipoGastoGet") - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener eL reporte de los presupuestos de ingresos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function GetClasificadorOG(CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_AC_ClasificadorOGGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener eL reporte de los presupuestos de ingresos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function GetClasificacion(CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_ClasificacionGET") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener eL reporte de los presupuestos de ingresos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function GetClasificacionEconomica(CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_ClasificacionEconomicaGET") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener eL reporte de los presupuestos de ingresos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function GetFuenteFinanciera(CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_AC_FuentesFinanciamientoGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener eL reporte de los presupuestos de ingresos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function GetMonedas() As Boolean - Dim Retorno As Boolean = False - - DataAdapter(" SELECT * FROM Monedas ".ToString, CommandType.Text) - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al consultar las Monedas.", ex) - End Try - - Return Retorno - End Function - - Public Function GetAgrupadoresSAT(CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter(" SELECT CveAgrupadorSAT, Codigo + REPLICATE(' ', 10 - len(Codigo)) + ' - ' + Nombre AS CodigoNombre FROM AgrupadoresSAT where CveEmpresa= '" & CveEmpresa & "'", CommandType.Text) - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al consultar los Agrupadores SAT.", ex) - End Try - - Return Retorno - - End Function - Public Function UpdateCuenta(CveCuenta As Integer, Nombre As String, Tipo As String, CtaMayor As Integer, CveMoneda As Integer, Optional DigAgrupador As Integer = -1, Optional CveAgrupadorSAT As Integer = -1, Optional NomIdioma As String = "") As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Conta_UpdateCuentas") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCuenta", SqlDbType.Int).Value = CveCuenta - .Add("@Nombre", SqlDbType.VarChar).Value = Nombre - .Add("@Tipo", SqlDbType.VarChar).Value = Tipo - .Add("@CtaMayor", SqlDbType.Int).Value = CtaMayor - .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda - .Add("@DigAgrupador", SqlDbType.Int).Value = DigAgrupador - .Add("@NomIdioma", SqlDbType.VarChar).Value = NomIdioma - .Add("@CveAgrupadorSAT", SqlDbType.Int).Value = CveAgrupadorSAT - - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - Me.OnError("Ocurrió un error al Guardar la cuenta.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - Catch ex As Exception - Me.OnError("Ocurrió un error al Guardar la cuenta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function AddCuenta(CvePadre As Integer, Codigo As String, Nombre As String, Tipo As String, CtaMayor As Integer, CveMoneda As Integer, Optional DigAgrupador As Integer = -1, Optional CveAgrupadorSAT As Integer = -1, Optional NomIdioma As String = "") As Integer - Dim Retorno As Integer = 0 - DataAdapter("PA_Conta_AddCuentas") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePadre", SqlDbType.Int).Value = CvePadre - .Add("@Codigo", SqlDbType.VarChar).Value = Codigo - .Add("@Nombre", SqlDbType.VarChar).Value = Nombre - .Add("@Tipo", SqlDbType.VarChar).Value = Tipo - .Add("@CtaMayor", SqlDbType.Int).Value = CtaMayor - .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda - .Add("@DigAgrupador", SqlDbType.Int).Value = DigAgrupador - .Add("@NomIdioma", SqlDbType.VarChar).Value = NomIdioma - .Add("@CveAgrupadorSAT", SqlDbType.Int).Value = CveAgrupadorSAT - '.Add("@CveCuenta", SqlDbType.Int).Value = 0 - '.Add("@Error", SqlDbType.VarChar).Value = "" - '.Add("@Error", SqlDbType.VarChar).Direction = ParameterDirection.Output - .Add("@CveCuenta", SqlDbType.Int).Direction = ParameterDirection.Output - End With - Try - SqlAdapter.Fill(Data) - Retorno = SqlAdapter.SelectCommand.Parameters("@CveCuenta").Value.ToString.ToEntero - 'Retorno = If(Data IsNot Nothing AndAlso Data.Rows.Count > 0, Data.Rows(0)("CveCuenta").ToString.ToEntero, 0) - Catch Ex1 As SqlException - Me.OnError("Ocurrió un error al Guardar la cuenta.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - Catch ex As Exception - Me.OnError("Ocurrió un error al Guardar la cuenta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function RemoveCuenta(CveCuenta As Integer) As Boolean - Dim Retorno As Boolean = False - - If CveCuenta <= 0 Then - Return False - End If - - DataAdapter("PA_Conta_RemoveCuentas") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCuenta", SqlDbType.Int).Value = CveCuenta - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al eliminar la cuenta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function UpdateCuentaCompaq(CveCuenta As Integer, IdCompaq As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Conta_UpdateCuentasCompaq") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCuenta", SqlDbType.Int).Value = CveCuenta - .Add("@IdCompaq", SqlDbType.Int).Value = IdCompaq - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - Me.OnError("Ocurrió un error al actualizar la cuenta.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - Catch ex As Exception - Me.OnError("Ocurrió un error al actualizar la cuenta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetSaldoCuenta(IdCuenta As Integer, TipoMovto As Integer, Ejercicio As Integer) As Boolean - Dim Retorno As Boolean - - If TipoMovto = 0 Then - DataAdapter(String.Format("SELECT SUM(CASE WHEN TipoMovto = 1 THEN -1 ELSE 1 END * Importe) AS Saldo from Conta_PolizasDetalle CD inner join Conta_Polizas CP on CP.CvePoliza=CD.CvePoliza and year(CP.Fecha)={1} WHERE CveCuenta = {0}", IdCuenta, Ejercicio), CommandType.Text) - Else - DataAdapter(String.Format("SELECT SUM(CASE WHEN TipoMovto = 0 THEN -1 ELSE 1 END * Importe) AS Saldo from Conta_PolizasDetalle CD inner join Conta_Polizas CP on CP.CvePoliza=CD.CvePoliza and year(CP.Fecha)={1} WHERE CveCuenta = {0} ", IdCuenta, Ejercicio), CommandType.Text) - End If - - Try - SqlAdapter.Fill(Data) - 'Retorno = Math.Round(SqlCommand.ExecuteScalar.ToString.ToDouble, 2) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener eL saldo de la cuenta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function GetRepPresupuestosEgresosSaldos(Ejercicio As Integer, Fecha As Date, Capitulo As String, CveClasificacion As Integer, CveFuenteFinanciamiento As Integer, CveProgramaOperativo As Integer, CveUnidadAdministrativa As Integer, CveTipoGasto As Integer, Gpo As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_PresupuestosEgresosSaldosRep") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Ejercicio", SqlDbType.Int).Value = Ejercicio - .Add("@Fecha", SqlDbType.Date).Value = Fecha - .Add("@Capitulo", SqlDbType.VarChar).Value = Capitulo - .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion - .Add("@CveFuenteFinanciamiento", SqlDbType.Int).Value = CveFuenteFinanciamiento - .Add("@CveProgramaOperativo", SqlDbType.Int).Value = CveProgramaOperativo - .Add("@CveUnidadAdministrativa", SqlDbType.Int).Value = CveUnidadAdministrativa - .Add("@CveTipoGasto", SqlDbType.Int).Value = CveTipoGasto - .Add("@GPO", SqlDbType.Int).Value = Gpo - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Reporte de Presupuestos de Egresos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function GetRepPresupuestosEgresosSaldosDetalle(MomentoContable As Integer, ProgramaOperativo As Integer, FuenteFinanciamiento As Integer, TipoGasto As Integer, UnidadAdministrativa As Integer, ClasificacionOG As Integer, CodigoOG As String, FechaI As Date, FechaF As Date, CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_PresupuestosEgresosSaldosDetalleRep") - - With SqlAdapter.SelectCommand.Parameters - .Add("@MomentoContable", SqlDbType.Int).Value = MomentoContable - .Add("@ProgramaOperativo", SqlDbType.Int).Value = ProgramaOperativo - .Add("@FuenteFinanciamiento", SqlDbType.Int).Value = FuenteFinanciamiento - .Add("@TipoGasto", SqlDbType.Int).Value = TipoGasto - .Add("@UnidadAdministrativa", SqlDbType.Int).Value = UnidadAdministrativa - .Add("@ClasificacionOG", SqlDbType.Int).Value = ClasificacionOG - .Add("@CodigoOG", SqlDbType.VarChar).Value = CodigoOG - .Add("@FI", SqlDbType.Date).Value = FechaI - .Add("@FF", SqlDbType.Date).Value = FechaF - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener los Movimientos Auxiliares Presupuestales", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function GetGeneraPolizaPresupuestoEgresos(CveEmpresa As Integer, CveEjercicio As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_GeneraPolizaPresupuestoEgresos") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@Ejercicio", SqlDbType.Int).Value = CveEjercicio - .Add("@Error", SqlDbType.Int).Direction = ParameterDirection.Output - End With - - Try - SqlAdapter.Fill(Data) - If SqlAdapter.SelectCommand.Parameters("@Error").Value.ToString.ToEntero = 0 Then - Retorno = True - Else - Retorno = False - End If - Catch ex As Exception - Me.OnError("Ocurrió un error al generar la poliza de egresos", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function Conta_ContabilizaPrePoliza(CvePrepoliza As Integer, Ejercicio As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_ContabilizaPrepolizas") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePrepoliza", SqlDbType.Int).Value = CvePrepoliza - .Add("@Ejercicio", SqlDbType.Int).Value = Ejercicio - .Add("@Error", SqlDbType.Int).Direction = ParameterDirection.Output - End With - - Try - SqlAdapter.Fill(Data) - If SqlAdapter.SelectCommand.Parameters("@Error").Value.ToString.ToEntero = 0 Then - Retorno = True - Else - Retorno = False - End If - Catch ex As Exception - Me.OnError("Ocurrió un error al contabilizar la prepoliza", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function Conta_CompactaPrePoliza(CvePrepoliza As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_Comp_CompactaPrepoliza") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrepoliza - .Add("@Error", SqlDbType.Int).Direction = ParameterDirection.Output - End With - - Try - SqlAdapter.Fill(Data) - If SqlAdapter.SelectCommand.Parameters("@Error").Value.ToString.ToEntero = 0 Then - Retorno = True - Else - Retorno = False - End If - Catch ex As Exception - Me.OnError("Ocurrió un error al contabilizar la prepoliza", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function Conta_GeneraPptarias(CveCompra As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_GeneraPptarias") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCompra", SqlDbType.Int).Value = CveCompra - .Add("@Error", SqlDbType.Int).Direction = ParameterDirection.Output - End With - - Try - SqlAdapter.Fill(Data) - If SqlAdapter.SelectCommand.Parameters("@Error").Value.ToString.ToEntero = 0 Then - Retorno = True - Else - Retorno = False - End If - Catch ex As Exception - Me.OnError("Ocurrió un error al Generar las Cuentas Presupuestarias", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function AddConta_Poliza(CveTipoPoliza As Integer, CveEjercicio As Integer, Folio As Integer, FechaPoliza As Date, Concepto As String, CveUsuario As Integer, CveEmpresa As Integer) As Integer - Dim Retorno As Integer = 0 - - DataAdapter("PA_Add_Conta_Polizas") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Folio", SqlDbType.Int).Value = Folio - ' .Add("@CveTipoPoliza", SqlDbType.Int).Value = CveTipoPoliza - .Add("@Ejercicio", SqlDbType.Int).Value = CveEjercicio - .Add("@Concepto", SqlDbType.VarChar).Value = Concepto - .Add("@FechaPoliza", SqlDbType.DateTime).Value = FechaPoliza - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CvePoliza", SqlDbType.Int).Direction = ParameterDirection.Output - End With - Try - SqlAdapter.Fill(Data) - Retorno = SqlAdapter.SelectCommand.Parameters("@CvePoliza").Value.ToString.ToEntero - Catch ex As Exception - OnError("Ocurrió un error al agregar la poliza", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function AddConta_PolizaDetalle(CvePoliza As Integer, CveCuenta As Integer, TipoMovto As Boolean, Importe As Double, Referencia As String, - Concepto As String, FechaMovto As Date, CveUsuario As Integer, Optional ImporteMonedaExtranjera As Double = 0) As Boolean - Dim Retorno As Boolean = False - - If CvePoliza <= 0 Or CveCuenta <= 0 Then - Return False - End If - - - DataAdapter("PA_Add_Conta_PolizasDetalles") - 'DataAdapter("PA_Conta_PolizasDetalleAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePoliza", SqlDbType.Int).Value = CvePoliza - .Add("@CveCuenta", SqlDbType.Int).Value = CveCuenta - .Add("@TipoMovto", SqlDbType.Int).Value = TipoMovto - .Add("@Total", SqlDbType.Money).Value = Math.Round(Importe, 2) - .Add("@ImporteME", SqlDbType.Money).Value = ImporteMonedaExtranjera - .Add("@Referencia", SqlDbType.VarChar).Value = Referencia - .Add("@Concepto", SqlDbType.VarChar).Value = Concepto - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@Error", SqlDbType.Int).Direction = ParameterDirection.Output - End With - - Try - SqlAdapter.Fill(Data) - If SqlAdapter.SelectCommand.Parameters("@Error").Value.ToString.ToEntero <> 0 Then - Retorno = False - Else - Retorno = True - End If - Catch ex As Exception - OnError("Ocurrió un error al agregar el movimiento en la póliza.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function GetSaldoCuentaAC(TipoMovto As Integer, CveCuentaAprobado As Integer, CveCuentaDevengado As Integer, Ejercicio As Integer) As Decimal - Dim Retorno As Decimal - DataAdapter("PA_Conta_CalculaSaldo") - With SqlAdapter.SelectCommand.Parameters - .Add("@TipoMovto", SqlDbType.Int).Value = TipoMovto - .Add("@CveCuentaAprobado", SqlDbType.Int).Value = CveCuentaAprobado - .Add("@CveCuentaDevengado", SqlDbType.Int).Value = CveCuentaDevengado - .Add("@Ejercicio", SqlDbType.Int).Value = Ejercicio - .Add("@Saldo", SqlDbType.Money).Direction = ParameterDirection.Output - End With - Try - SqlAdapter.Fill(Data) - Retorno = SqlAdapter.SelectCommand.Parameters("@Saldo").Value.ToString.ToDecimal - 'Retorno = True 'SqlAdapter.SelectCommand.Parameters("@Saldo").Value.ToString.ToEntero - Catch ex As Exception - Retorno = 0 - OnError("Ocurrió un error al obtener el saldo de cuenta", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - Return Retorno - End Function - - Public Function GetSegmentosNegocio(Id As Integer, Codigo As String) As Boolean - Dim Retorno As Boolean = False - Dim StrSQl = New StringBuilder - - StrSQl.Clear() - StrSQl.Append(" SELECT Id, RTRIM (LTRIM (Codigo)) AS Codigo, Nombre, '' AS CveProyecto, '' AS CveSubProyecto ") - StrSQl.Append(" FROM SegmentosNegocio ") - StrSQl.Append(" WHERE (@Id = -1 OR Id = @Id) ") - StrSQl.Append(" AND (@Codigo = '-1' OR Codigo = @Codigo) ") - - DataAdapter(StrSQl.ToString, CommandType.Text) - SqlAdapter.SelectCommand.Parameters.Add("@Id", SqlDbType.Int).Value = Id - SqlAdapter.SelectCommand.Parameters.Add("@Codigo", SqlDbType.VarChar).Value = Codigo - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al consultar los Segmentos de Negocio.", ex) - End Try - - Return Retorno - End Function - - Public Function GetSubProyectos(CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - Dim StrSQl = New StringBuilder - - DataAdapter("PA_Comp_Compras_Pptarias") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - SqlAdapter.Fill(Data) - Retorno = True - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al consultar los Segmentos de Negocio.", ex) - End Try - - Return Retorno - End Function - - Public Function GetNumeroPoliza(CveTipoPoliza As Integer, Tipo As String, Fecha As DateTime, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Conta_GetNumPoliza") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveTipoPoliza", SqlDbType.Int).Value = CveTipoPoliza - .Add("@Tipo", SqlDbType.VarChar).Value = Tipo - .Add("@Fecha", SqlDbType.DateTime).Value = Fecha - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener el número de poliza", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function Compras_Pptarias(CveCompra As Integer, Importe As Decimal, CveConceptoContable As Integer) As Boolean - - Dim Retorno As Boolean = False - - DataAdapter("PA_Comp_Compras_Pptarias") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCompra", SqlDbType.Int).Value = CveCompra - .Add("@Importe", SqlDbType.Decimal).Value = Importe - .Add("@CveConceptoContable", SqlDbType.Int).Value = CveConceptoContable - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex1 As SqlException - OnError("Ocurrió un error al obtener las Plantillas", ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - Catch ex As Exception - OnError("Ocurrió un error al obtener las Plantillas", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function -#End Region - -#Region "FIS IMPUESTOS" - - Public Function GetFisImpuestos(CveImpuesto As Integer, CveImpuestoTipo As Integer, CveProveedor As Integer, Folio As String, CveEmpresa As Integer, FechaInicio As Date, FechaFin As Date) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_FisImpuestosGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveImpuesto", SqlDbType.Int).Value = CveImpuesto - .Add("@CveImpuestoTipo", SqlDbType.Int).Value = CveImpuestoTipo - .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor - .Add("@Folio", SqlDbType.VarChar).Value = Folio - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio - .Add("@FechaFin", SqlDbType.Date).Value = FechaFin - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener el catalogo de impuestos", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetFisImpuestosDetalle(CveImpuesto As Integer, CveImpuestoTipo As Integer, CveProveedor As Integer, Folio As String, CveEmpresa As Integer, FechaInicio As Date, FechaFin As Date) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_FisImpuestosDetalleGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveImpuesto", SqlDbType.Int).Value = CveImpuesto - .Add("@CveImpuestoTipo", SqlDbType.Int).Value = CveImpuestoTipo - .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor - .Add("@Folio", SqlDbType.VarChar).Value = Folio - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio - .Add("@FechaFin", SqlDbType.Date).Value = FechaFin - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener el catalogo de impuestos", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function AddUpdateFisImpuestos(CveImpuesto As Integer, CveImpuestoTipo As Integer, CvePrePoliza As Integer, CveProveedor As Integer, Fecha As Date, Folio As String, Comprobante As String, CveUsuario As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_FisImpuestosAddUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveImpuesto", SqlDbType.Int).Value = CveImpuesto - .Add("@CveImpuestoTipo", SqlDbType.Int).Value = CveImpuestoTipo - .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza - .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor - .Add("@Fecha", SqlDbType.Date).Value = Fecha - '.Add("@Importe", SqlDbType.Money).Value = Importe - '.Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones - '.Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda - .Add("@Folio", SqlDbType.VarChar).Value = Folio - .Add("@Comprobante", SqlDbType.VarChar).Value = Comprobante - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - If CveImpuesto = -1 Then - Me.OnError("Ocurrió un error al agregar el impuesto", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - Else - Me.OnError("Ocurrió un error al actualizar el impuesto", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - - End Try - - Return Retorno - End Function - - 'Public Function RemoveFisImpuestos(CveImpuesto As Integer, CveEmpresa As Integer) As Boolean - ' Dim Retorno = False - - ' DataAdapter("PA_Fis_ImpuestosRemove") - - ' With SqlAdapter.SelectCommand.Parameters - ' .Add("@CveImpuesto", SqlDbType.Int).Value = CveImpuesto - ' .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - ' End With - - ' Try - ' SqlAdapter.Fill(Data) - ' Retorno = True - ' Catch ex As Exception - ' Me.OnError("Ocurrió un error al eliminar el impuesto", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - ' End Try - - ' Return Retorno - 'End Function - - Public Function GetFisImpuestosTipos(Estatus As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_Fis_ImpuestosTiposGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Estatus", SqlDbType.Int).Value = Estatus - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener el catalogo de ", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - -#End Region - -#Region "Contabilidad Electronica" - Public Function GetCuentasElectronica(CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_ContaElectronicaCuentasGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener el catalogo de cuentas", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetBalanzaComprobacion(FechaI As Date, FechaF As Date, CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_ContaElectronicaBalanzaGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.Date).Value = FechaI - .Add("@FechaF", SqlDbType.Date).Value = FechaF - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener la balanza", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function -#End Region - -#Region "Estado de Situacion Financiera" - Public Function GetSituacionFinanciera(FechaI As Date, FechaF As Date, CveEmpresa As Integer, Optional TipoMovtos As Integer = -1) As Boolean - Dim Retorno = False - - DataAdapter("PA_SituacionFinancieraGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.Date).Value = FechaI - .Add("@FechaF", SqlDbType.Date).Value = FechaF - .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrio un error al obtener el Estado de Situacion de Financiera", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetBalanceGeneralMensual(ANO As Integer, TipoMovtos As Integer, SubTotales As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_BalanceGeneralMensual") - - With SqlAdapter.SelectCommand.Parameters - .Add("@ANO", SqlDbType.Int).Value = ANO - .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos - .Add("@SubTotales", SqlDbType.Int).Value = SubTotales - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener el Balance General Mensual", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetBalanceGeneralAnual(ANO As Integer, TipoMovtos As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_BalanceGeneralAnual") - - With SqlAdapter.SelectCommand.Parameters - .Add("@ANO", SqlDbType.Int).Value = ANO - .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener el Balance General Anual", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetBalanzaComprobacion(FechaI As Date, FechaF As Date, TipoCuentas As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_BalanzaComprobacionPymeGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.Date).Value = FechaI - .Add("@FechaF", SqlDbType.Date).Value = FechaF - .Add("@TipoCuentas", SqlDbType.Int).Value = TipoCuentas - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener Balanza de comprobación", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetEstadoActividades(FechaI As Date, FechaF As Date, CveEmpresa As Integer, Optional TipoMovtos As Integer = -1) As Boolean - Dim Retorno = False - - DataAdapter("PA_EstadoActividadesGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.Date).Value = FechaI - .Add("@FechaF", SqlDbType.Date).Value = FechaF - .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener el Estado de Actividades", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetEstadoResultadosMensual(ANO As Integer, TipoMovtos As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_EstadoResultadosMensualPyme") - - With SqlAdapter.SelectCommand.Parameters - .Add("@ANO", SqlDbType.Int).Value = ANO - .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener el Estado de Resultados Mensual", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetEstadoResultadosAnual(ANO As Integer, TipoMovtos As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_EstadoResultadosAnualPyme") - - With SqlAdapter.SelectCommand.Parameters - .Add("@ANO", SqlDbType.Int).Value = ANO - .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener el Estado de Resultados Anual", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function -#End Region - -#Region "A N E X O - D E L - C A T A L O G O" - Public Function GetAnexoCatalogo(IdCuenta As Integer, FechaI As Date, FechaF As Date, OpcionCuentas As Integer, CveEmpresa As Integer, Optional TipoMovtos As Integer = -1) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_AnexoCatalogo") - - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.Date).Value = FechaI - .Add("@FechaF", SqlDbType.Date).Value = FechaF - .Add("@IdCuentaPadre", SqlDbType.Int).Value = IdCuenta - .Add("@OpcionCuentas", SqlDbType.Int).Value = OpcionCuentas - .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener el Anexo del Catalogo", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function GetMovimientosAuxiliaresCatalogo(IdCuenta As Integer, FechaI As Date, FechaF As Date, CveMoneda As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_AuxiliarCatalogo") - - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.Date).Value = FechaI - .Add("@FechaF", SqlDbType.Date).Value = FechaF - .Add("@IdCuentaPadre", SqlDbType.Int).Value = IdCuenta - .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener los Movimientos Auxiliares Catalogo", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function -#End Region - -#Region "Cierre Contable" - Public Function GetCuentasCierre(FechaI As Date, FechaF As Date, CveCuentaCierre As Integer, CveEmpresa As Integer, CveUsuario As Integer) As Integer - Dim Retorno = 0 - - DataAdapter("PA_Conta_CierrePolizaCuentasGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.Date).Value = FechaI - .Add("@FechaF", SqlDbType.Date).Value = FechaF - .Add("@CveCuentaCierre", SqlDbType.Int).Value = CveCuentaCierre - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - End With - - Try - SqlAdapter.Fill(Data) - Retorno = If(Data IsNot Nothing AndAlso Data.Rows.Count > 0, Data.Rows(0)("CvePoliza").ToString.ToEntero, 0) - ContaFolio = If(Data IsNot Nothing AndAlso Data.Rows.Count > 0, Data.Rows(0)("Folio").ToString.ToEntero, 0) - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener las cuentas de cierre", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function -#End Region - - Public Function AddSiguienteCuentaHijo(IdCuentaPadre As Integer, NombreCuenta As String, CveEmpresa As Integer, Optional Tipo As String = "A", Optional CuentaMayor As Integer = 2, Optional IdMoneda As Integer = 1, Optional IdAgrupadorSAT As Integer = -1) As Integer - Dim CodigoCuenta As New StringBuilder - Dim Retorno As Integer = -1 - Dim Segmentos() As String = Nothing - - If GetCuentas(-1, "-1", -1, CveEmpresa, CvePadre:=IdCuentaPadre) Then - - If DtResultados.Rows.Count > 0 Then - 'Cuando ya tiene cuentas hijas - - Segmentos = Split(DtResultados.MAX("CuentaFormato"), "-") - 'recorro inverso para detectar el segmento - For i As Integer = Segmentos.Length - 1 To 0 Step -1 - If Segmentos(i).ToEntero <> 0 Then - Segmentos(i) = (Segmentos(i).ToEntero + 1).ToString.PadLeft(Segmentos(i).Length, "0"c) 'Suma uno en el primer token en el que encuentre algo dif de 0 - Exit For - End If - Next - - Else - 'Cuando es el primero hijo de la cuenta - 'obtengo el codigo del padre - If GetCuentas(IdCuentaPadre, "-1", -1, CveEmpresa) Then - Segmentos = Split(DtResultados.MAX("CuentaFormato"), "-") - 'recorro para poner el primer digito en el siguiente segmento al que halla tenido valor > 0 - For i As Integer = 0 To Segmentos.Length - 1 Step 1 - If Segmentos(i).ToEntero = 0 Then - Segmentos(i) = (Segmentos(i).ToEntero + 1).ToString.PadLeft(Segmentos(i).Length, "0"c) 'Suma uno en el primer token en el que encuentre algo dif de 0 - Exit For - End If - Next - End If - - End If - End If - - - For i As Integer = 0 To Segmentos.Length - 1 - CodigoCuenta.Append(Segmentos(i)) 'une tokens - Next - - Retorno = AddCuenta(IdCuentaPadre, CodigoCuenta.ToString, NombreCuenta, Tipo, CuentaMayor, 0, IdMoneda, CveAgrupadorSAT:=IdAgrupadorSAT) - - Return Retorno - End Function - - - Public Function GetGastosRepCC(FechaInicio As DateTime, FechaFin As DateTime, CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_ReporteGastos") - - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaInicio", SqlDbType.DateTime).Value = FechaInicio - .Add("@FechaFin", SqlDbType.DateTime).Value = FechaFin - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener el Estado Resultados Horizontal CC", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - - Public Function GetEdoResultadosMes(FechaInicio As Date, FechaFin As Date, CveTipoGasto As Integer, CveClasificacion As Integer, CveSubProyecto As Integer, Agrupador As Integer, CveEmpresa As Integer, Unidad As Integer) As DataSet - Dim Retorno = False - Dim ds As New DataSet - DataAdapter("PA_Conta_EdoResultado2") - - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio - .Add("@FechaFin", SqlDbType.Date).Value = FechaFin - .Add("@CveTipoGasto", SqlDbType.Int).Value = CveTipoGasto - .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@Agrupador", SqlDbType.Int).Value = Agrupador - .Add("@Unidad", SqlDbType.Int).Value = If(Unidad = 1, 1, If(Unidad = 2, 1000, 1000000)) - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(ds) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener el Balance General Mensual", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return ds - End Function - - Public Function GetEdoResultadosDetalle(FechaInicio As Date, FechaFin As Date, CveTipoGasto As Integer, CveClasificacion As Integer, CveSubProyecto As Integer, CveEmpresa As Integer, Tipo As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Conta_EdoResultado2Detalle") - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio - .Add("@FechaFin", SqlDbType.Date).Value = FechaFin - .Add("@CveTipoGasto", SqlDbType.Int).Value = CveTipoGasto - .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@Tipo", SqlDbType.Int).Value = Tipo - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Balance General detalle.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - -#Region "IVAS" - Public Function GetRepIVA(FechaInicio As Date, FechaFin As Date, Opcion As Integer, CveUsuarioConsulta As Integer, Conciliado As Integer, CveEmpresa As Integer, TipoCambio As Integer, TCEspecifico As Double) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Conta_RepIVA") - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio - .Add("@FechaFin", SqlDbType.Date).Value = FechaFin - .Add("@Opcion", SqlDbType.Int).Value = Opcion - .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta - .Add("@Conciliado", SqlDbType.Int).Value = Conciliado - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@TipoCambio", SqlDbType.Int).Value = TipoCambio - .Add("@TCEspecifico", SqlDbType.Float).Value = TCEspecifico - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el reporte de IVAS.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - - Public Function GetDIOT(FechaInicio As Date, FechaFin As Date, Conciliado As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Conta_GetDIOT") - With SqlAdapter.SelectCommand.Parameters - - .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio - .Add("@FechaFin", SqlDbType.Date).Value = FechaFin - .Add("@Conciliado", SqlDbType.Int).Value = Conciliado - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el DIOT.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - - Public Function GetRepIVAAcumulado(FechaInicio As Date, FechaFin As Date, Conciliado As Integer, TipoImpuesto As Integer, CveUsuarioConsulta As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Conta_IVAAcumulado") - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio - .Add("@FechaFin", SqlDbType.Date).Value = FechaFin - .Add("@TipoImpuesto", SqlDbType.Int).Value = TipoImpuesto - .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta - .Add("@Conciliado", SqlDbType.Int).Value = Conciliado - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el reporte Acumulado IEPS.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - -#End Region - Public Function GetRepIEPS(FechaInicio As Date, FechaFin As Date, TipoOperacion As String, Modalidad As Integer, Limite As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Conta_RepIEPS") - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio - .Add("@FechaFin", SqlDbType.Date).Value = FechaFin - .Add("@TipoOperacion", SqlDbType.VarChar).Value = TipoOperacion - .Add("@Modalidad", SqlDbType.Int).Value = Modalidad - .Add("@Limite", SqlDbType.Int).Value = Limite - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el reporte de IEPS.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - Public Function GetRepIEPSLayoutAnual(Ano As Integer, Tipo As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Conta_RepIEPSLayoutAnual") - With SqlAdapter.SelectCommand.Parameters - .Add("@Ano", SqlDbType.Int).Value = Ano - .Add("@Tipo", SqlDbType.Int).Value = Tipo - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el layout anual de IEPS.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - - Public Function GetAlmacenContable(FechaInicio As Date, FechaFin As Date, CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_AlmacenRepGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaInicio", SqlDbType.DateTime).Value = FechaInicio - .Add("@FechaFin", SqlDbType.DateTime).Value = FechaFin - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener el almacén contable", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - -#Region " RECONSTRUCCION DE PREPOLIZAS " - Public Function ReconstruirPP_PagoCompra(CvePrePoliza As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_AD_PrePolizaReconstruccionPagoCompra") - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al reconstruir la prepoliza de pago de compra.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function ReconstruirPP_Compra(CveCompra As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_AD_PrePolizaReconstruccionCompra") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCompra", SqlDbType.Int).Value = CveCompra - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al reconstruir la prepoliza de compra.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function ReconstruirPP_PagoVenta(CvePrePoliza As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_AD_PrePolizaReconstruccionPagoVenta") - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al reconstruir la prepoliza de pago de venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function ReconstruirPP_PagoCompraVenta(CveIE As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_AD_PrePolizaReconstruccionPagoCompraVenta") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveIE", SqlDbType.Int).Value = CveIE - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al reconstruir la prepoliza de pago de compra/venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - -#End Region - -#Region "VALIDACION POLIZA DESCUADRADA" - Public Function ValidacionPrePolizaCuadre(CvePrePoliza As Integer, Opcion As Integer, Optional CveVenta As Integer = -1) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_PrePoliza_Validacion") - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@Opcion", SqlDbType.Int).Value = Opcion - .Add("@Valor", SqlDbType.Int).Direction = ParameterDirection.Output - .Add("@MsgSalida", SqlDbType.VarChar, 100).Direction = ParameterDirection.Output - .Add("@Diferencia", SqlDbType.Float).Direction = ParameterDirection.Output - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - ValorPolizaDescuadre = SqlAdapter.SelectCommand.Parameters("@Valor").Value.ToString.ToEntero - MensajePolizaDescuadre = SqlAdapter.SelectCommand.Parameters("@MsgSalida").Value.ToString - ValorDiferencia = SqlAdapter.SelectCommand.Parameters("@Diferencia").Value.ToString - Catch ex As Exception - OnError("Ocurrió un error al validar la PrePoliza.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function -#End Region - -#Region "AUXILIAR PREPOLIZAS" - - Public Function GetAuxiliarPrePolizas(FechaI As Date, FechaF As Date, CveSubProyecto As Integer, CveEmpresa As Integer, CveConceptoContable As String, CvePlantillaPoliza As Integer, CveProyecto As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Conta_AuxiliarPrePolizasGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.Date).Value = FechaI - .Add("@FechaF", SqlDbType.Date).Value = FechaF - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveConceptoContable", SqlDbType.VarChar).Value = CveConceptoContable - .Add("@CvePlantillaPoliza", SqlDbType.Int).Value = CvePlantillaPoliza - .Add("@CveProyecto", SqlDbType.Int).Value = CveProyecto - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el auxiliar de prepolizas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - -#End Region - - -#Region "IDisposable Support" - ' IDisposable - Protected Overridable Sub Dispose(disposing As Boolean) - If Not Me.disposedValue Then - If disposing Then - If Not Data Is Nothing Then Data.Dispose() - If Not SqlAdapter Is Nothing Then SqlAdapter.Dispose() - If Not SqlCommand Is Nothing Then SqlCommand.Dispose() - If Not SqlTransacc Is Nothing Then SqlTransacc.Dispose() - If SqlConexion.State <> ConnectionState.Closed Then SqlConexion.Close() - If Not SqlConexion Is Nothing Then SqlConexion.Dispose() - End If - End If - Me.disposedValue = True - End Sub - Public Sub Dispose() Implements IDisposable.Dispose - Dispose(True) - GC.SuppressFinalize(Me) - End Sub -#End Region -#Region "Periodos Bloqueo Meses" - Public Function GetPeriodosBloqueo(CveEmpresa As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_EmpresasBloqueoMesesGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener el Periodo de Bloqueo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function AddPeriodosBloqueo(CveEmpresa As Integer, Ejercicio As Integer, Mes1 As Integer, Mes2 As Integer, Mes3 As Integer, Mes4 As Integer, Mes5 As Integer, Mes6 As Integer, Mes7 As Integer, Mes8 As Integer, Mes9 As Integer, Mes10 As Integer, Mes11 As Integer, Mes12 As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_EmpresasBloqueoMesesAdd") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@Ejercicio", SqlDbType.Int).Value = Ejercicio - .Add("@Mes1", SqlDbType.Bit).Value = Mes1 - .Add("@Mes2", SqlDbType.Bit).Value = Mes2 - .Add("@Mes3", SqlDbType.Bit).Value = Mes3 - .Add("@Mes4", SqlDbType.Bit).Value = Mes4 - .Add("@Mes5", SqlDbType.Bit).Value = Mes5 - .Add("@Mes6", SqlDbType.Bit).Value = Mes6 - .Add("@Mes7", SqlDbType.Bit).Value = Mes7 - .Add("@Mes8", SqlDbType.Bit).Value = Mes8 - .Add("@Mes9", SqlDbType.Bit).Value = Mes9 - .Add("@Mes10", SqlDbType.Bit).Value = Mes10 - .Add("@Mes11", SqlDbType.Bit).Value = Mes11 - .Add("@Mes12", SqlDbType.Bit).Value = Mes12 - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al agregar el Periodo de Bloqueo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function UpdatePeriodosBloqueo(CveEmpresa As Integer, Ejercicio As Integer, Mes1 As Integer, Mes2 As Integer, Mes3 As Integer, Mes4 As Integer, Mes5 As Integer, Mes6 As Integer, Mes7 As Integer, Mes8 As Integer, Mes9 As Integer, Mes10 As Integer, Mes11 As Integer, Mes12 As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_EmpresasBloqueoMesesUpdate") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@Ejercicio", SqlDbType.Int).Value = Ejercicio - .Add("@Mes1", SqlDbType.Bit).Value = Mes1 - .Add("@Mes2", SqlDbType.Bit).Value = Mes2 - .Add("@Mes3", SqlDbType.Bit).Value = Mes3 - .Add("@Mes4", SqlDbType.Bit).Value = Mes4 - .Add("@Mes5", SqlDbType.Bit).Value = Mes5 - .Add("@Mes6", SqlDbType.Bit).Value = Mes6 - .Add("@Mes7", SqlDbType.Bit).Value = Mes7 - .Add("@Mes8", SqlDbType.Bit).Value = Mes8 - .Add("@Mes9", SqlDbType.Bit).Value = Mes9 - .Add("@Mes10", SqlDbType.Bit).Value = Mes10 - .Add("@Mes11", SqlDbType.Bit).Value = Mes11 - .Add("@Mes12", SqlDbType.Bit).Value = Mes12 - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al actualizar el Periodo de Bloqueo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - Public Function RemovePeriodosBloqueo(CveEmpresa As Integer, Ejercicio As Integer) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_EmpresasBloqueoMesesRemove") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@Ejercicio", SqlDbType.Int).Value = Ejercicio - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al eliminar el Periodo de Bloqueo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function -#End Region +Option Explicit On +Option Strict On + +Imports System.Data +Imports System.Data.SqlClient +Imports Extensiones +Imports System +Imports System.Configuration + +Public Class ClsContabilidad + Implements IDisposable + +#Region "Campos" + + 'SQL + Private SqlConexion As SqlConnection + Private SqlAdapter As SqlDataAdapter + Private SqlTransacc As SqlTransaction + Private SqlCommand As SqlCommand + Private Data As DataTable + Private DSet As New DataSet + + 'Atributos de la clase + + Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + +#End Region + +#Region " P R O P I E D A D E S" + + Public ReadOnly Property DtResultados() As DataTable + Get + DtResultados = Data + End Get + End Property + Public ReadOnly Property DSResultados() As DataSet + Get + DSResultados = DSet + End Get + End Property + + Private Mensaje As StringBuilder + + Public ReadOnly Property AlertaMensaje As String + Get + AlertaMensaje = Mensaje.ToString + End Get + End Property + + Public Property CvePlantillaPoliza As Integer + Public Property PlantillaPoliza As String + Public Property TipoPlantilla As Integer + Public Property TipoPoliza As Integer + Public Property Orden As Integer + Public Property Estatus As String + Public Property FechaIng As DateTime + Public Property CveUsuario As Integer + Public Property Usuario As String + Public Property CveEmpresa As Integer + Public Property CveTipoPlantillaPoliza As Integer + + Public Property ContaIdPoliza As Integer + Public Property ContaFolio As Integer + + Public Property ValorPolizaDescuadre As Integer + Public Property MensajePolizaDescuadre As String + Public Property ValorDiferencia As String +#End Region + + Public Function IniciaTransacSQL() As SqlTransaction + If SqlTransacc Is Nothing Then SqlTransacc = SqlConexion.BeginTransaction() + Return SqlTransacc + End Function + + Public Sub RollBack() + If SqlTransacc IsNot Nothing Then SqlTransacc.Rollback() + SqlTransacc = Nothing + End Sub + + Public Sub Commit() + If SqlTransacc IsNot Nothing Then SqlTransacc.Commit() + SqlTransacc = Nothing + End Sub + + Sub New(Optional TransaccionCompartida As SqlTransaction = Nothing) + + If TransaccionCompartida Is Nothing Then + SqlConexion = New SqlConnection + SqlConexion.ConnectionString = ConfigurationManager.ConnectionStrings("Conexion").ConnectionString + Try + SqlConexion.Open() + Catch ex As Exception + OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex) + End Try + Else + SqlConexion = TransaccionCompartida.Connection + SqlTransacc = TransaccionCompartida + End If + Mensaje = New StringBuilder + SqlAdapter = New SqlDataAdapter("", SqlConexion) + + End Sub + + Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) + With SqlAdapter.SelectCommand + .Parameters.Clear() + .CommandText = StrSQL + .CommandType = TipoComando + End With + If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc + Data = New DataTable + End Sub + + +#Region " C O N T A B I L I D A D - P R E P O L I Z A" + Public Function ObtenerTipoPoliza(Valor1 As String, Valor2 As String, CveEmpresa As Integer) As Integer + Dim Retorno As Integer = -1 + + Select Case CveEmpresa + + Case 83 + If Valor1 = "2" OrElse Valor2 = "2" Then + Retorno = 3 + End If + + End Select + + Return Retorno + End Function + + Public Function AddPrePolizas(Modulo As String, CvePlantillaPoliza As Integer, Cargos As Double, Abonos As Double, CveMoneda As Integer, Fecha As Date, Concepto As String, CveUsuario As Integer, CveEmpresa As Integer, Optional FolioFijo As Integer = 0, Optional ReglaFolioPoliza As String = "", Optional CveTipoPoliza As Integer = -1) As Integer + + Dim Retorno As Integer = -1 + + DataAdapter("PA_Conta_PrePolizasAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Modulo", SqlDbType.VarChar).Value = Modulo + .Add("@CvePlantillaPoliza", SqlDbType.Int).Value = CvePlantillaPoliza + .Add("@CveTipoPoliza", SqlDbType.Int).Value = CveTipoPoliza + .Add("@Concepto", SqlDbType.VarChar).Value = Concepto + .Add("@Cargos", SqlDbType.Money).Value = Cargos + .Add("@Abonos", SqlDbType.Money).Value = Abonos + .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda + .Add("@Fecha", SqlDbType.Date).Value = Fecha + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@FolioFijo", SqlDbType.Int).Value = FolioFijo + .Add("@CvePrePoliza", SqlDbType.Int).Direction = ParameterDirection.Output + .Add("@ReglaFolioPoliza", SqlDbType.VarChar).Value = ReglaFolioPoliza + End With + + Try + SqlAdapter.Fill(Data) + Retorno = SqlAdapter.SelectCommand.Parameters("@CvePrePoliza").Value.ToString.ToEntero + Catch ex As Exception + + If ex.Message.Contains("50015;") Then + OnError("No se puede registrar una póliza en un ejercicio Cerrado", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + Else + OnError("Ocurrió un error al Guardar", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End If + End Try + + Return Retorno + End Function + + ''' + ''' Actualiza la IdPoliza de una PrePoliza + ''' + ''' + ''' + Public Function DesvincularPrePolizaContabilizada(IdPoliza As Integer, CveEmpresa As Integer) As Boolean + + Dim Retorno As Boolean = False + + DataAdapter("PA_Conta_DesvincularPrepolizaContabilizada") + + With SqlAdapter.SelectCommand.Parameters + .Add("@IdPoliza", SqlDbType.Int).Value = IdPoliza + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al desvincular la Prepoliza", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function UpdatePrepolizasDetalle(CvePrePolizaDetalle As Integer, Concepto As String, CveSubProyecto As Integer, IdCtaContable As Integer, TipoMovto As Boolean, ImporteMN As Decimal, Optional CveTipoGasto As Integer = -1, + Optional CveConceptoContable As Integer = -1, Optional CveProveedor As Integer = -1, Optional CveCompra As Integer = -1, Optional CvePersonal As Integer = -1, Optional CveCliente As Integer = -1, Optional CveVenta As Integer = -1, + Optional Referencia As String = "-1") As Boolean + + Dim Retorno As Boolean = False + + DataAdapter("PA_PrePolizaDetalleUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePrePolizaDetalle", SqlDbType.Int).Value = CvePrePolizaDetalle + .Add("@Concepto", SqlDbType.VarChar).Value = Concepto + .Add("@Referencia", SqlDbType.VarChar).Value = Referencia + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@IdCtaContable", SqlDbType.Int).Value = IdCtaContable + .Add("@TipoMovto", SqlDbType.Bit).Value = TipoMovto + .Add("@ImporteMN", SqlDbType.Money).Value = ImporteMN + .Add("@CveTipoGasto", SqlDbType.Int).Value = CveTipoGasto + .Add("@CveConceptoContable", SqlDbType.Int).Value = CveConceptoContable + .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor + .Add("@CveCompra", SqlDbType.Int).Value = CveCompra + .Add("@CvePersonal", SqlDbType.Int).Value = CvePersonal + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al Actualizar la Prepoliza", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + + + Public Function AddPrePolizasNegativa(CvePrePoliza As Integer, CveUsuario As Integer, Concepto As String, CveEmpresa As Integer, Fecha As Date) As Boolean + + Dim Retorno As Boolean = False + + DataAdapter("PA_Conta_PrePolizasNegativaAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@Concepto", SqlDbType.VarChar).Value = Concepto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@Fecha", SqlDbType.Date).Value = Fecha + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al Guardar", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + + End Function + + Public Function GetProveedorAuxiliar(CveProveedor As Integer, CveCompra As Integer) As Boolean + Dim Retorno As Boolean = False + 'Data = New DataTable + 'SqlAdapter = New SqlDataAdapter("PA_ClienteCxCAuxiliar", SqlConexion) + 'SqlAdapter.SelectCommand.CommandType = CommandType.StoredProcedure + 'SqlAdapter.SelectCommand.Parameters.Add("@CveCliente", SqlDbType.Int).Value = CveCliente + 'SqlAdapter.SelectCommand.Parameters.Add("@CveVenta", SqlDbType.Int).Value = CveVenta + DataAdapter("PA_Conta_ProveedorAuxiliar") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor + .Add("@CveCompra", SqlDbType.Int).Value = CveCompra + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As SqlException + OnError("Ocurrió un error al consultar el Auxiliar Contable del Proveedor.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + + Public Function GetPersonalAuxiliar(CvePersonal As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Conta_PersonalAuxiliar") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePersonal", SqlDbType.Int).Value = CvePersonal + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As SqlException + OnError("Ocurrió un error al consultar el Auxiliar Contable del Personal.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function GetClienteAuxiliarxVenta(CveCliente As Integer, FechaInicio As Date, FechaFin As Date, CveVendedor As Integer, CveSucursal As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Conta_ClienteAuxiliarxVenta") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor + .Add("@CveSucursal", SqlDbType.Int).Value = CveSucursal + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio + .Add("@FechaFin", SqlDbType.Date).Value = FechaFin + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As SqlException + OnError("Ocurrió un error al consultar el Auxiliar de ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function GetClienteAuxiliar(CveCliente As Integer, CveConceptoContable As Integer, FechaInicio As Date, FechaFin As Date, CveEmpresa As Integer, Optional Opcion As Integer = 1) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Conta_ClienteAuxiliar") + + With SqlAdapter.SelectCommand.Parameters + + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveConceptoContable", SqlDbType.Int).Value = CveConceptoContable + + .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio + .Add("@FechaFin", SqlDbType.Date).Value = FechaFin + + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@Opcion", SqlDbType.Int).Value = Opcion + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As SqlException + OnError("Ocurrió un error al consultar el Auxiliar Contable del Personal.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + + Public Function GetProveedoresAuxiliar(CveProveedor As Integer, CveConceptoContable As Integer, FechaInicio As Date, FechaFin As Date, CveEmpresa As Integer, + Optional Opcion As Integer = 1) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Conta_ProveedoresAuxiliar") + + With SqlAdapter.SelectCommand.Parameters + + .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor + .Add("@CveConceptoContable", SqlDbType.Int).Value = CveConceptoContable + .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio + .Add("@FechaFin", SqlDbType.Date).Value = FechaFin + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@Opcion", SqlDbType.Int).Value = Opcion + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As SqlException + OnError("Ocurrió un error al consultar el Auxiliar de Proveedor.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function CancelarPrePolizas(CvePrePoliza As Integer, CveVenta As Integer) As Boolean + + Dim Retorno As Boolean = False + + DataAdapter("PA_Conta_PrePolizasCancelar") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al cancelar los movimientos", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function TraspasarSaldosPrePolizas(CveVenta As Integer, CveVentaNueva As Integer, CvePrePolizaNueva As Integer) As Boolean + + Dim Retorno As Boolean = False + + DataAdapter("PA_Conta_PrePolizasSaldosTraspasar") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveVentaNueva", SqlDbType.Int).Value = CveVentaNueva + .Add("@CvePrePolizaNueva", SqlDbType.Int).Value = CvePrePolizaNueva + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al traspasar el saldo", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + ''' Venta a la que se le van a cancelar los pagos + ''' PrePoliza donde van a quedar los movimientos (No necesariamente la PrePoliza de la venta) + ''' + Public Function PrePolizasCancelarPagos(CveVenta As Integer, CvePrePoliza As Integer) As Boolean + + Dim Retorno As Boolean = False + + DataAdapter("PA_Conta_PrePolizasCancelarPagos") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al traspasar el saldo", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + ''' + ''' [-1 = Cancelación de saldo de la REM] + ''' [1 = Regresa saldo a la REM. Cuando se cancela la factura donde se facturó] + ''' + Public Function TraspasarSaldosRemision(CveRemision As Integer, CvePrePoliza As Integer, CveVenta As Integer, Optional TipoMovimiento As Integer = -1) As Boolean + 'TipoMovimiento: -1 = Cancelacion de saldo de remision + + Dim Retorno As Boolean = False + + DataAdapter("PA_Conta_PrePolizasCancelarSaldoRemision") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveRemision", SqlDbType.Int).Value = CveRemision + .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza + .Add("@TipoMovimiento", SqlDbType.Int).Value = TipoMovimiento + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al traspasar el saldo", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function CancelarPagoCompraConAnticipo(CvePrePoliza As Integer, CveCompra As Integer, CveIE As Integer) As Boolean + + Dim Retorno As Boolean = False + + DataAdapter("PA_Banc_GenerarAnticipoCancelacionCompras") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza + .Add("@CveCompra", SqlDbType.Int).Value = CveCompra + .Add("@CveIE", SqlDbType.Int).Value = CveIE + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al cancelar el movimiento", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function CancelarPagoVentaConAnticipo(CvePrePoliza As Integer, CveVenta As Integer, CveIE As Integer) As Boolean + + Dim Retorno As Boolean = False + + DataAdapter("PA_Banc_GenerarAnticipoCancelacionVentas") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveIE", SqlDbType.Int).Value = CveIE + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al cancelar el movimiento", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function RemovePrePolizas(CvePrePoliza As Integer, CveEmpresa As Integer) As Boolean + + Dim Retorno As Boolean = False + + DataAdapter("PA_Conta_PrePolizasRemove") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + + If ex.Message.Contains("50015;") Then + OnError("No se puede eliminar una póliza en un ejercicio Cerrado", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + Else + OnError("Ocurrió un error al Eliminar", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End If + End Try + + Return Retorno + End Function + + ''' + ''' + ''' + ''' + ''' + ''' + ''' 1:Compra 2:Venta + ''' + Public Function RemovePrePolizasDetalle(CvePrePoliza As Integer, CveConceptoContable As Integer, CveCompraVenta As Integer, TipoMovimiento As Integer) As Boolean + + Dim Retorno As Boolean = False + + DataAdapter("PA_Conta_PrePolizasDetalleRemove") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza + .Add("@CveCompraVenta", SqlDbType.Int).Value = CveCompraVenta + .Add("@CveConceptoContable", SqlDbType.Int).Value = CveConceptoContable + .Add("@TipoMovimiento", SqlDbType.Int).Value = TipoMovimiento + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + If ex.Message.Contains("50015;") Then + OnError("No se puede eliminar una póliza en un ejercicio Cerrado", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + Else + OnError("Ocurrió un error al eliminar el detalle de la prepoliza", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End If + End Try + + Return Retorno + End Function + + Public Function GetMovimientosPoliza(IdPoliza As Integer, CveEmpresa As Integer) As Integer + Dim Retorno As Integer = -1 + + DataAdapter("PA_Conta_MovimientosPolizaGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@IdPoliza", SqlDbType.Int).Value = IdPoliza + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@Movtos", SqlDbType.Int).Direction = ParameterDirection.Output + End With + + Try + SqlAdapter.Fill(Data) + Retorno = SqlAdapter.SelectCommand.Parameters("@Movtos").Value.ToString.ToEntero + Catch ex As Exception + OnError("Ocurrió un error al obtener los movimientos de la poliza", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function DesasociarPoliza(IdPoliza As Integer, CveEmpresa As Integer) As Boolean + + Dim Retorno As Boolean = False + + DataAdapter("PA_Conta_PrePolizasPolizaDesAsociar") + + With SqlAdapter.SelectCommand.Parameters + .Add("@IdPoliza", SqlDbType.Int).Value = IdPoliza + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualiza poliza del movimiento", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + +#End Region + +#Region " C O N T A B I L I D A D - P R E P O L I Z A - D E T A L L E " + + Public Function GetPlantillaConceptos(CveEmpresa As Integer, CvePlantillaPoliza As Integer) As Boolean + + Dim Retorno As Boolean = False + + DataAdapter("PA_Conta_GetPlantilla") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CvePlantillaPoliza", SqlDbType.Int).Value = CvePlantillaPoliza + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex1 As SqlException + OnError("Ocurrió un error al obtener las Plantillas", ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + Catch ex As Exception + OnError("Ocurrió un error al obtener las Plantillas", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function GetPrePolizaOriginal(TipoMovimiento As Integer, CveMovimiento As Integer) As Boolean 'Editado por charlie + + Dim Retorno As Boolean = False + + DataAdapter("PA_Conta_GetPrePolizaOriginal") + + With SqlAdapter.SelectCommand.Parameters + .Add("@TipoMovimiento", SqlDbType.Int).Value = TipoMovimiento + .Add("@CveMovimiento", SqlDbType.Int).Value = CveMovimiento + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex1 As SqlException + OnError("Ocurrió un error al obtener la Poliza Original", ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + Catch ex As Exception + OnError("Ocurrió un error al obtener las Poliza Original", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function PrePolizaUnificacion(CvePrePoliza As Integer, CvePrePolizaVieja As Integer) As Boolean 'Editado por charlie + + Dim Retorno As Boolean = False + + DataAdapter("PA_Conta_PrePolizaUnificacion") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza + .Add("@CvePrePolizaVieja", SqlDbType.Int).Value = CvePrePolizaVieja + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex1 As SqlException + OnError("Ocurrió un error al actualizar la Poliza Original", ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + Catch ex As Exception + OnError("Ocurrió un error al actualizar las Poliza Original", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function PrePolizaSimplificacion(CvePrePoliza As Integer, CveEmpresa As Integer) As Boolean + + Dim Retorno As Boolean = False + + DataAdapter("PA_Conta_PrePolizasSimplificacion") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex1 As SqlException + OnError("Ocurrió un error al simplificar prepolizas", ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + Catch ex As Exception + OnError("Ocurrió un error al simplificar prepolizas", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function GetCuentaPrePoliza(Concepto As Integer, CveEmpresa As Integer, CvePlantillaPoliza As Integer) As Boolean + + Dim Retorno As Boolean = False + + DataAdapter("PA_Conta_IdCuentaPrePolizaGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Concepto", SqlDbType.Int).Value = Concepto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CvePlantillaPoliza", SqlDbType.Int).Value = CvePlantillaPoliza + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex1 As SqlException + OnError("Ocurrió un error al obtener la Cuenta", ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + Catch ex As Exception + OnError("Ocurrió un error al obtener la Cuenta", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function GetRetCuenta(Concepto As Integer, CveGeneral As Integer, Optional CveSubProyecto As Integer = -1) As Boolean + + Dim Retorno As Boolean = False + + DataAdapter("PA_Conta_RetCuentaGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Concepto", SqlDbType.Int).Value = Concepto + .Add("@CveGeneral", SqlDbType.Int).Value = CveGeneral + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex1 As SqlException + OnError("Ocurrió un error al obtener la Cuenta", ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + Catch ex As Exception + OnError("Ocurrió un error al obtener la Cuenta", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function AddPrePolizasDetalle(CvePrePoliza As Integer, TipoMovimiento As Boolean, Importe As Decimal, Referencia As String, CveConceptoContable As Integer, Concepto As String, FechaVencimiento As Date, IdCtaContable As Integer, IdSegmentoNegocio As Integer, + Optional CveIE As Integer = -1, Optional CveVenta As Integer = -1, Optional CveCompra As Integer = -1, Optional CveSubProyecto As Integer = -1, Optional CveCliente As Integer = -1, Optional CveProveedor As Integer = -1, + Optional CvePersonal As Integer = -1, Optional CveMovimientoAlmacen As Integer = -1, Optional CveActivoFijo As Integer = -1, Optional CveAcreedor As Integer = -1, Optional CveColectiva As Integer = -1, Optional CveCreditoDetalle As Integer = -1, + Optional CveOC As Integer = -1, Optional CveClasificacion As Integer = -1, Optional CveVentaAmortizacion As Integer = -1, Optional CveCompraAmortizacion As Integer = -1, Optional ImporteMX As Decimal = 0, Optional ImporteME As Decimal = 0, + Optional CvePrePolizaOriginal As Integer = -1, Optional CveIEDevolucion As Integer = -1, Optional CveCredito As Integer = -1, Optional CveCuenta As Integer = -1, Optional CveTipoGasto As Integer = -1, Optional Contabilizable As Boolean = True, Optional TipoCambio As Decimal = 1, Optional CveOCDetalle As Integer = -1, Optional TipoCambioPago As Decimal = 1, Optional PorcentajeImpuesto As Decimal = 0) As Boolean + + Dim Retorno As Boolean = False + If CvePrePoliza = 0 Then + OnError("Ocurrió un error al guardar la prepóliza, favor de verificar el movimiento", New Exception, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + Return False + End If + + If CveConceptoContable = 30 AndAlso CveIE < 1 Then + OnError("La ClaveIE es invalidad para este Movimiento", New Exception, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + Return False + End If + + DataAdapter("PA_Conta_PrePolizasDetalleAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza + .Add("@CvePrePolizaOriginal", SqlDbType.Int).Value = CvePrePolizaOriginal + .Add("@TipoMovto", SqlDbType.Bit).Value = TipoMovimiento + .Add("@Importe", SqlDbType.Money).Value = If(CveConceptoContable = 30, Importe, Math.Round(Importe, 2)) + .Add("@ImporteMX", SqlDbType.Money).Value = Math.Round(ImporteMX, 2) + .Add("@ImporteME", SqlDbType.Money).Value = Math.Round(ImporteME, 3) + .Add("@TC", SqlDbType.Float).Value = TipoCambio + .Add("@TCPago", SqlDbType.Float).Value = TipoCambioPago + .Add("@Referencia", SqlDbType.VarChar).Value = Referencia + .Add("@CveConceptoContable", SqlDbType.Int).Value = CveConceptoContable + .Add("@Concepto", SqlDbType.VarChar).Value = Concepto + .Add("@FechaVencimiento", SqlDbType.Date).Value = FechaVencimiento + .Add("@IdCtaContable", SqlDbType.Int).Value = IdCtaContable + .Add("@CveCuenta", SqlDbType.Int).Value = CveCuenta + .Add("@IdSegmentoNegocio", SqlDbType.Int).Value = IdSegmentoNegocio + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveVentaAmortizacion", SqlDbType.Int).Value = CveVentaAmortizacion + .Add("@CveCompra", SqlDbType.Int).Value = CveCompra + .Add("@CveCompraAmortizacion", SqlDbType.Int).Value = CveCompraAmortizacion + .Add("@CveIE", SqlDbType.Int).Value = CveIE + .Add("@CveIEDevolucion", SqlDbType.Int).Value = CveIEDevolucion + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor + .Add("@CvePersonal", SqlDbType.Int).Value = CvePersonal + .Add("@CveMovimientoAlmacen", SqlDbType.Int).Value = CveMovimientoAlmacen + .Add("@CveActivoFijo", SqlDbType.Int).Value = CveActivoFijo + .Add("@CveOC", SqlDbType.Int).Value = CveOC + .Add("@CveOCDetalle", SqlDbType.Int).Value = CveOCDetalle + .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion + .Add("@CveCredito", SqlDbType.Int).Value = CveCredito + .Add("@CveTipoGasto", SqlDbType.Int).Value = CveTipoGasto + .Add("@Contabilizable", SqlDbType.Bit).Value = If(Contabilizable, 1, 0) + .Add("@CveAcreedor", SqlDbType.Int).Value = CveAcreedor + .Add("@CveColectiva", SqlDbType.Int).Value = CveColectiva + .Add("@CveCreditoDetalle", SqlDbType.Int).Value = CveCreditoDetalle + .Add("@PorcentajeImpuesto", SqlDbType.Money).Value = PorcentajeImpuesto + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex1 As SqlException + If ex1.Message.Contains("50015;") Then + OnError("No se puede registrar una póliza en un ejercicio Cerrado", ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + Else + OnError("Ocurrió un error al Guardar", ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End If + Catch ex As Exception + If ex.Message.Contains("50015;") Then + OnError("No se puede registrar una póliza en un ejercicio Cerrado", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + Else + OnError("Ocurrió un error al Guardar", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End If + End Try + + Return Retorno + End Function + + Public Function ObtenerConceptoEmpresa(CveEmpresa As Integer, CveConcepto As Integer, NombreComercial As String, SerieFolio As String, FolioBancario As String, Optional Adicional As String = "") As String + Dim Concepto As String = "" + + Select Case CveEmpresa + + Case 83 + + Select Case CveConcepto + + Case 2, 17 'Pago Proveedores + + Case 30 'Bancos + Concepto = FolioBancario + + Case 4, 6 'Compra + + Case 1, 5 'Proveedores + Concepto = SerieFolio + + Case 37 'Deudores + + Case 41 'Acreedores + + Case 42 'Acreedores + + Case 18 'NC - Notas de Credito + + Case 29 'Funcionarios y Empleados + + Case Else + Concepto = $"{NombreComercial} F:{SerieFolio}" + + End Select + + Case 4, 7, 11, 12 + + Select Case CveConcepto + + Case 2, 17 'Pago Proveedores + Concepto = $"{NombreComercial} F:{SerieFolio}" + + Case 30 'Bancos + Concepto = FolioBancario + + Case 4, 6 'Compra + + Case 1, 5 'Proveedores + Concepto = SerieFolio + + Case 37 'Deudores + Concepto = FolioBancario + + Case 41 'Acreedores + Concepto = FolioBancario + + Case 42 'Acreedores + Concepto = FolioBancario + + Case 18 'NC - Notas de Credito + + Case 29 'Funcionarios y Empleados + Concepto = FolioBancario + + + Case Else + Concepto = $"{NombreComercial} F:{SerieFolio}" + + End Select + Case 119 + Select Case CveConcepto + + Case 2, 17 'Pago Proveedores + Concepto = String.Format("{0} F:{1}", NombreComercial, SerieFolio) + + Case 30 'Bancos + Concepto = String.Format("{0} - {1}", NombreComercial, Adicional) + + Case 6 'Compra + + Case 13, 61 'iva ventas + Concepto = SerieFolio + + Case 14, 19 'iva compras + Concepto = SerieFolio + + Case 38, 39 'ieps ventas + Concepto = SerieFolio + + Case 25, 26 'eips compras + Concepto = SerieFolio + + Case 1, 5 'Clientes/Proveedores + Concepto = SerieFolio + + Case 37 'Deudores + Concepto = FolioBancario + + Case 41 'Acreedores + Concepto = FolioBancario + + Case 42 'Acreedores + Concepto = FolioBancario + + Case 18 'NC - Notas de Credito, Compra + Concepto = String.Format("{0} F:{1}", NombreComercial, SerieFolio) + Case 29 'Funcionarios y Empleados + Concepto = FolioBancario + + + Case Else + Concepto = String.Format("{0} F:{1}", NombreComercial, SerieFolio) + + End Select + + + Case Else + Concepto = $"{NombreComercial} F:{SerieFolio}" + End Select + + Return Concepto + End Function + + Public Function GetPrePolizasDetalle(CvePrePoliza As Integer, Optional CveIE As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Conta_PrePolizasDetalleGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza + .Add("@CveIE", SqlDbType.Int).Value = CveIE + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener Movimientos Prepolizas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function UpdatePrePolizasDetalleBloquear(CvePrePoliza As Integer, Bloquear As Boolean) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Conta_PrePolizasDetalleBloquearUpdate") + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza + .Add("@Bloquear", SqlDbType.Bit).Value = Bloquear + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + If ex.Message.Contains("50015;") Then + OnError("No se puede actualizar una póliza en un ejercicio Cerrado", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + Else + OnError("Ocurrió un error al bloquear o desbloquear las prepolizas detalle.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + End Try + Return Retorno + End Function + + + + Public Function ContabilizarPrePoliza(CvePrePoliza As Integer, CveUsuario As Integer, Empresa As Empresa, Optional Fecha As Date = MinFecha, Optional Concepto As String = "", + Optional ObjConta As ClsContPAQi = Nothing, Optional pIDPoliza As Integer = -1) As Boolean + 'Editado Por Charlie + + Dim Retorno As Boolean = False + + 'No modificar esta seccion bajo ninguna circunstancia + '***************************************************** + If Empresa.CvePlataforma = 3 Or (CveUsuario.Contiene(100, 1425) And Empresa.CveEmpresa = 1) Then + Retorno = ContabilizarPrePolizaSIG(CvePrePoliza, CveUsuario, Empresa, Fecha, Concepto) + Return Retorno + End If + '***************************************************** + + If Empresa.UsaArmonizacion Then + DataAdapter("PA_Conta_ContabilizaPrepoliza") + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza + .Add("@CvePoliza", SqlDbType.Int).Direction = ParameterDirection.Output + End With + + Try + SqlAdapter.Fill(Data) + ContaIdPoliza = SqlAdapter.SelectCommand.Parameters("@CvePoliza").Value.ToString.ToEntero + If ContaIdPoliza <> 0 Then + Retorno = True + End If + Catch ex As Exception + OnError("Ocurrió un error al obtener Movimientos Prepolizas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Else + If CvePrePoliza <= 0 Then Return False + + + Dim OcurrioError As Boolean = False + + Dim ContaCompartida As Boolean = False + + If ObjConta Is Nothing Then + ObjConta = New ClsContPAQi(Empresa) + ObjConta.IniciaTransacSQL() + Else + ContaCompartida = True + End If + + + + + Dim tIdPoliza As Integer + Dim CveTipoPoliza, FolioFijo As Integer + Dim Cargos As Decimal + Dim Abonos As Decimal + Dim NumPoliza As String = "" + Dim CodigoNumeroPoliza As String = "" + Dim TipoPoliza As String + + Dim IdCtaContProveedores As Integer + + Dim ContaFolio As String = "" + Dim ContabilizarCausacion As Boolean + Dim ContabilizarDIOT As Boolean + + 'Dim Periodo As Integer = -1 + 'Dim Ejercicio As Integer = -1 + 'Dim GuidPoliza As String = "-1" + + ' Dim FolioFiscal As String = "" + ' Dim DatosCuentas As New DataTable + ' Dim CveMoneda As Integer = 0 + ' Dim Total As Decimal = 0 + + + + Try + + 'If Empresa.Funcionalidad(522).ToString = "1" AndAlso ObjConta.GetCuentas(-1, "-1", -1) Then + ' DatosCuentas = ObjConta.DtResultados + 'End If + + If GetEncabezadoPrePoliza(CvePrePoliza, Empresa.CveEmpresa) Then + CveTipoPoliza = Data.Rows(0)("CveTipoPoliza").ToString.ToEntero + Cargos = Data.Rows(0)("Cargos").ToString.ToDecimal + Abonos = Data.Rows(0)("Abonos").ToString.ToDecimal + FolioFijo = Data.Rows(0)("FolioFijo").ToString.ToEntero + TipoPoliza = Data.Rows(0)("TipoPoliza").ToString + CodigoNumeroPoliza = Data.Rows(0)("CodigoNumeroPoliza").ToString + + 'FolioFiscal = Data.Rows(0)("FolioFiscal").ToString + 'MetodoPagoSAT = Data.Rows(0)("ClaveSAT").ToString + 'CveMoneda = Data.Rows(0)("CveMoneda").ToString.ToEntero + 'Total = Data.Rows(0)("Total").ToString.ToDecimal + + If FolioFijo > 0 Then CodigoNumeroPoliza = "CHQ" + + 'tiene prioridad el concepto en parametro + If Concepto = "" Then Concepto = Data.Rows(0)("Concepto").ToString + If Fecha = MinFecha Then Fecha = Data.Rows(0)("Fecha").ToString.ToDate + + If pIDPoliza > 0 Then + tIdPoliza = pIDPoliza + 'elimnar movimientos de la póliza para regenerarlos + ObjConta.RemoveAllMovimientos(tIdPoliza) + ObjConta.RemoveCausacionesIVA(-1, tIdPoliza) + ObjConta.RemoveDevolucionesIVA(-1, tIdPoliza) + Else + tIdPoliza = ObjConta.AddPoliza(CveTipoPoliza, Concepto, Cargos, Abonos, CveUsuario, Fecha, FolioFijo.ToString, CodigoNumeroPoliza) + ContaFolio = ObjConta.Folio.ToString + End If + + + + 'If Empresa.Funcionalidad(522).ToString = "1" Then + ' GuidPoliza = ObjConta.DtResultados.Rows(0)("Guid").ToString + ' Periodo = Data.Rows(0)("Fecha").ToString.ToDate.Month + ' Ejercicio = Data.Rows(0)("Fecha").ToString.ToDate.Year + + ' ObjConta.AddASocCFDIs(False, TipoPol, GuidPoliza, FolioFiscal, 0, "-1", Empresa.BDContPAQi, Ejercicio, Periodo, ContaFolio) + + 'End If + + + If tIdPoliza > 0 AndAlso GetContabilizacionDiarioDetalle(CvePrePoliza) Then + Dim tipoMovimiento As Boolean = False + Dim CveConceptoContable As Integer + Dim SigReferencia As String = "" + + For Each dr As DataRow In Data.Rows + + CveConceptoContable = dr("CveConceptoContable").ToString().ToEntero + + Select Case CveConceptoContable + Case 6, 5, 17, 14, 19, 15, 16 + SigReferencia = dr("CveCompra").ToString.ContaReferencia(TipoContaReferencia.Compra) + Case 2, 4, 1, 13, 61, 62, 63, 8, 9 + SigReferencia = dr("CveVenta").ToString.ContaReferencia(TipoContaReferencia.Venta) + Case 30 + SigReferencia = dr("CveIE").ToString.ContaReferencia(TipoContaReferencia.Banco) + + End Select + + Select Case CveConceptoContable + Case 19 ' IVA Acreditable + ContabilizarDIOT = True + Case 61 ' IVA Trasladado + ContabilizarCausacion = True + Case 30 ' Bancos + If dr("Abono").ToString.ToDecimal > 0 Then ContabilizarDIOT = True + If dr("Cargo").ToString.ToDecimal > 0 Then ContabilizarCausacion = True + End Select + + tipoMovimiento = (dr("TipoMovto").ToString = "True") + + 'Si las cuentas contables estan en 0 no se debe contabilizar + If dr("IdCtaContable").ToString.ToEntero > 0 Then + + 'Si ImporteMN es mayor que 0 entonces la compra es en dolares y debemos ingresar la cantidad en pesos + If dr("ImporteMN").ToString.ToDecimal <> 0 Then + + If Not ObjConta.AddMovimiento(tIdPoliza, dr("IdCtaContable").ToString.ToEntero, tipoMovimiento, + dr("ImporteMN").ToString.ToDecimal, dr("Referencia").ToString, dr("Concepto").ToString, dr("IdSegmentoNegocio").ToString.ToEntero, Fecha, SigReferencia, dr("CvePrePolizaDetalle").ToString.ToEntero, ImporteMonedaExtranjera:=dr("ImporteME").ToString.ToDecimal) Then + OcurrioError = True + Exit For + End If + + 'If Empresa.Funcionalidad(522).ToString = "1" Then + ' GuidPoliza = ObjConta.DtResultados.Rows(0)("Guid").ToString + ' Periodo = Data.Rows(0)("Fecha").ToString.ToDate.Month + ' Ejercicio = Data.Rows(0)("Fecha").ToString.ToDate.Year + + ' Dim CodigoCuenta As String = "" + + ' If DatosCuentas.Rows.Count > 0 Then + ' If DatosCuentas.FiltraParametros($"Id = {dr("IdCtaContable").ToString}").Rows.Count > 0 Then 'Filtra primero valorCambiar + ' CodigoCuenta = DatosCuentas.FiltraParametros($"Id = {dr("IdCtaContable").ToString}").Rows(0)("Codigo").ToString + ' If Not ObjConta.AddASocCFDIs(False, TipoPol, GuidPoliza, FolioFiscal, 0, CodigoCuenta, Empresa.BDContPAQi, -1, -1, ContaFolio) Then + ' OcurrioError = True + ' Exit For + ' End If + ' Else + ' OcurrioError = True + ' Exit For + ' End If + ' Else + ' OcurrioError = True + ' Exit For + ' End If + 'End If + + Else + + If Not ObjConta.AddMovimiento(tIdPoliza, dr("IdCtaContable").ToString.ToEntero, tipoMovimiento, + dr("Importe").ToString.ToDecimal, dr("Referencia").ToString, dr("Concepto").ToString, dr("IdSegmentoNegocio").ToString.ToEntero, Fecha, SigReferencia, dr("CvePrePolizaDetalle").ToString.ToEntero, ImporteMonedaExtranjera:=dr("ImporteME").ToString.ToDecimal) Then + OcurrioError = True + Exit For + End If + + + 'If Empresa.Funcionalidad(522).ToString = "1" Then + ' GuidPoliza = ObjConta.DtResultados.Rows(0)("Guid").ToString + ' Periodo = Data.Rows(0)("Fecha").ToString.ToDate.Month + ' Ejercicio = Data.Rows(0)("Fecha").ToString.ToDate.Year + + ' Dim CodigoCuenta As String = "" + + ' If DatosCuentas.Rows.Count > 0 Then + ' If DatosCuentas.FiltraParametros($"Codigo = {dr("IdCtaContable").ToString}").Rows.Count > 0 Then + ' CodigoCuenta = DatosCuentas.FiltraParametros($"Codigo = {dr("IdCtaContable").ToString}").Rows(0)("Codigo").ToString + ' If Not ObjConta.AddASocCFDIs(False, TipoPol, GuidPoliza, FolioFiscal, 0, CodigoCuenta, Empresa.BDContPAQi, -1, -1, ContaFolio) Then + ' OcurrioError = True + ' Exit For + ' End If + ' Else + ' OcurrioError = True + ' Exit For + ' End If + ' Else + ' OcurrioError = True + ' Exit For + ' End If + 'End If + + End If + Else + OcurrioError = True + Mensaje.Append(String.Format("
La cuenta contable {0} es invalida", dr("ConceptoContable"))) + Exit For + End If + + Next + + + 'Obtenemos los valores de la causacion y los agregamos + If Not OcurrioError AndAlso ContabilizarCausacion Then + If GetCausacionesValores(CvePrePoliza) AndAlso Data.Rows.Count > 0 Then + Dim dr As DataRow = Data(0) + If Not ObjConta.AddCausacionesIVA(tIdPoliza, + dr("TotalTasa16").ToString.ToDecimal, + dr("BaseTasa16").ToString.ToDecimal, + dr("IvaTasa16").ToString.ToDecimal, + 0, + dr("ISRRetenido").ToString.ToDecimal, + dr("IVARetenido").ToString.ToDecimal, False) Then + OcurrioError = True + + End If + End If + End If + + 'Obtenemos los valores del DIOT y los agregamos + Dim RFC As String = "" + Dim RazonSocial As String = "" + If Not OcurrioError AndAlso ContabilizarDIOT Then + If GetDIOTValores(CvePrePoliza) AndAlso Data.Rows.Count > 0 Then + Dim IdProveedor As Integer + + For Each dr As DataRow In Data.Rows + RFC = dr("RFC").ToString + RazonSocial = dr("RazonSocial").ToString + IdCtaContProveedores = dr("IdCtaContProveedores").ToString.ToEntero + + If IdCtaContProveedores > 0 Then + + 'busco la clave del proveedor en la contabilidad por su cuenta contable + If ObjConta.GetProveedores(IdCuentaContable:=IdCtaContProveedores) Then + If ObjConta.DtResultados.Rows.Count > 0 Then + Dim drt As DataRow = ObjConta.DtResultados.Rows(0) : IdProveedor = drt("Id").ToString.ToEntero + Else + IdProveedor = 0 + End If + End If + Else + 'busco la clave del proveedor en la contabilidad por su cuenta contable + If ObjConta.GetProveedores(RFC:=RFC) Then + If ObjConta.DtResultados.Rows.Count > 0 Then + Dim drtt As DataRow = ObjConta.DtResultados.Rows(0) : IdProveedor = drtt("Id").ToString.ToEntero + Else + IdProveedor = 0 + End If + Else + 'registro el proveedor generico + Select Case Empresa.CveEmpresa + Case Else : IdProveedor = 0 + End Select + End If + + End If + + + If IdProveedor <= 0 Then + IdProveedor = ObjConta.AddProveedor(IdCtaContProveedores, RFC, RazonSocial, "") + If IdProveedor <= 0 Then + OcurrioError = True + End If + End If + + + If dr("Total").ToString.ToDecimal <> 0.00 Then + If Not ObjConta.AddDevolucionesIVA(tIdPoliza, dr("CuentaBancos").ToString.ToEntero, + IdProveedor, + 16, + dr("SubTotal").ToString.ToDecimal, + dr("IvaAcreditable").ToString.ToDecimal, + dr("IVARetenido").ToString.ToDecimal, + dr("ISRRetenido").ToString.ToDecimal, + Fecha, + ContaFolio, + dr("Serie").ToString.ToString, + dr("Folio").ToString.StrToNum, dr("FolioFiscal").ToString, Empresa.CveEmpresa) Then + OcurrioError = True + Mensaje.Append("La Poliza o la Cuenta no son válidas ") + End If + + + End If + + Next + + End If + End If + + If Not OcurrioError Then + If Not UpdatePrePolizasDetalleBloquear(CvePrePoliza, True) Then + OcurrioError = True + End If + End If + + If Not OcurrioError Then + If Not UpdatePrePoliza(Fecha, ObjConta.Folio, CveTipoPoliza, tIdPoliza, CvePrePoliza, Empresa.CveEmpresa) Then + OcurrioError = True + End If + End If + + + + 'If Empresa.Funcionalidad(522).ToString = "1" And Empresa.UsaContabilidad Then + + ' Dim CodigoPersona As String = "" + ' Dim Bnefciciario As String = "" + + ' If ObjConta.GetPersona(RFC) Then + ' CodigoPersona = ObjConta.DtResultados.FiltroPrimeroValor("CodigoPersona") + ' Bnefciciario = ObjConta.DtResultados.FiltroPrimeroValor("Nombre") + ' Else + + ' OcurrioError = True + ' Mensaje.Append("Se presento un error al obtener los datos de la persona. ") + + ' End If + + + + + ' If TipoPol = 1 Then 'Ingreso + ' Dim IdDocumento As Integer = 0 + ' ' Dim UsuarioSistema As String = "" + ' Dim IdCuentaCheques As Integer = 1 + ' Dim NatBancaria As Integer = 2 + ' Dim Naturaleza As Integer = 1 + ' Dim IdIngreso As Integer + + ' If ObjConta.AddIngreso(1, 34, 42, Ejercicio, Periodo, Fecha, Ejercicio, Periodo, CodigoPersona, Bnefciciario, IdCuentaCheques, NatBancaria, Naturaleza, CveMoneda, 2, 1, Total, "", 0, 0, "", 0, + ' 0, Ejercicio, Periodo, TipoPol, ContaFolio.ToEntero, 0, 0, tIdPoliza, 11, 0, 0, 0, 0, UsuarioSistema, UsuarioSistema, 0, System.Guid.NewGuid().ToString().ToUpper, "", 0, MetodoPagoSAT) Then 'Actualizar Documento IdDocumento despues de Insertarlo + + ' If ObjConta.DtResultados.Rows.Count > 0 Then + ' IdIngreso = ObjConta.DtResultados.Rows(0)("IdIngreso").ToString.ToEntero + + ' If Not ObjConta.AddDocumentoBancario(1, 0, 0, IdIngreso, 0, 0, Fecha, Fecha, 0, 0, IdCuentaCheques) Then + ' OcurrioError = True + ' Mensaje.Append("Se presento un error al guardar el el documento. ") + ' End If + + ' Else + ' OcurrioError = True + ' Mensaje.Append("Se presento un error al guardar el Ingreso. ") + ' End If + ' Else + ' OcurrioError = True + ' Mensaje.Append("Se presento un error al guardar el Ingreso. ") + ' End If + + ' ElseIf TipoPol = 2 Then 'Egreso + + ' Dim IdDocumento As Integer = 0 + ' ' Dim UsuarioSistema As String = "" + ' Dim BancoDestino As String = "" + ' Dim CuentaDestino As String = "" + ' Dim IdCuentaCheques As Integer = 1 + ' Dim NatBancaria As Integer = 0 + ' Dim Naturaleza As Integer = 2 + ' Dim IdEgreso As Integer + + ' If ObjConta.AddEgreso(1, 36, 45, Ejercicio, Periodo, Fecha, Ejercicio, Periodo, CodigoPersona, Bnefciciario, IdCuentaCheques, NatBancaria, Naturaleza, CveMoneda, 2, 1, Total, "", 0, "", 0, 0, Ejercicio, + ' Periodo, TipoPol, NumPoliza, 0, 0, ContaIdPoliza, tIdPoliza, IdDocumento, Ejercicio, Periodo, 0, 0, 0, 0, 0, 0, UsuarioSistema, UsuarioSistema, 0, System.Guid.NewGuid().ToString().ToUpper, + ' CuentaDestino, BancoDestino, MetodoPagoSAT) Then + + ' If ObjConta.DtResultados.Rows.Count > 0 Then + ' IdEgreso = ObjConta.DtResultados.Rows(0)("IdEgreso").ToString.ToEntero + + ' If Not ObjConta.AddDocumentoBancario(1, 0, IdEgreso, 0, 0, 0, Fecha, Fecha, 0, 0, IdCuentaCheques) Then + ' OcurrioError = True + ' Mensaje.Append("Se presento un error al guardar el el documento. ") + ' End If + + ' Else + ' OcurrioError = True + ' Mensaje.Append("Se presento un error al guardar el Egreso. ") + ' End If + ' Else + ' OcurrioError = True + ' Mensaje.Append("Se presento un error al guardar el Egreso") + + ' End If 'Actualizar Documento IdDocumento despues de Insertarlo + + ' End If + + 'End If + + If OcurrioError Then + If Not ContaCompartida Then ObjConta.RollBack() + Else + If Not ContaCompartida Then ObjConta.AjustaPoliza(tIdPoliza) + + Mensaje.Append(String.Format("{1}
", tIdPoliza, ObjConta.Folio)) + If Not ContaCompartida Then ObjConta.Commit() + Retorno = True + _ContaIdPoliza = tIdPoliza + _ContaFolio = ObjConta.Folio + End If + End If + + Else + OcurrioError = True + End If + + + + Catch ex As Exception + ObjConta.RollBack() + OnError("Ocurrió un error al intentar contabilizar la PrePoliza", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + 'Alert("Ocurrió un error al guardar la póliza", TipoMensaje.MsgAdvertencia) + Retorno = False + End Try + + If Not ContaCompartida Then ObjConta.Dispose() + End If + Return Retorno + End Function + + 'No modificar este metodo bajo ninguna circunstancia + Public Function ContabilizarPrePolizaSIG(CvePrePoliza As Integer, CveUsuario As Integer, Empresa As Empresa, Optional Fecha As Date = MinFecha, Optional Concepto As String = "") As Boolean + + If CvePrePoliza <= 0 Then Return False + + Dim Retorno As Boolean = False + Dim OcurrioError As Boolean = False + Dim tCvePoliza As Integer + Dim CveTipoPoliza, FolioFijo As Integer + Dim Cargos As Decimal + Dim Abonos As Decimal + Dim NumPoliza As String = "" + Dim CodigoNumeroPoliza As String = "" + Dim TipoPoliza As String + + Dim ContaFolio As String = "" + Dim ContabilizarCausacion As Boolean + Dim ContabilizarDIOT As Boolean + + Dim ObjConta As New ClsContabilidad + ObjConta.IniciaTransacSQL() + + Try + + If GetEncabezadoPrePoliza(CvePrePoliza, Empresa.CveEmpresa) Then + CveTipoPoliza = Data.Rows(0)("CveTipoPoliza").ToString.ToEntero + Cargos = Data.Rows(0)("Cargos").ToString.ToDecimal + Abonos = Data.Rows(0)("Abonos").ToString.ToDecimal + FolioFijo = Data.Rows(0)("FolioFijo").ToString.ToEntero + TipoPoliza = Data.Rows(0)("TipoPoliza").ToString + CodigoNumeroPoliza = Data.Rows(0)("CodigoNumeroPoliza").ToString + + 'tiene prioridad el concepto en parametro + If Concepto = "" Then Concepto = Data.Rows(0)("Concepto").ToString + If Fecha = MinFecha Then Fecha = Data.Rows(0)("Fecha").ToString.ToDate + + If FolioFijo > 0 Then + CodigoNumeroPoliza = "CHQ" + Else + GetNumeroPoliza(CveTipoPoliza, TipoPoliza, Fecha, Empresa.CveEmpresa) + FolioFijo = Data.Rows(0)("NumPoliza").ToString.ToEntero + End If + + tCvePoliza = ObjConta.AddPoliza(CveTipoPoliza, FolioFijo, Fecha, Concepto, CveUsuario, Empresa.CveEmpresa, CvePrePoliza) + + If tCvePoliza > 0 AndAlso GetContabilizacionDiarioDetalle(CvePrePoliza) Then + Dim tipoMovimiento As Boolean = False + Dim CveConceptoContable As Integer + Dim SigReferencia As String = "" + + For Each dr As DataRow In Data.Rows + + CveConceptoContable = dr("CveConceptoContable").ToString().ToEntero + + Select Case CveConceptoContable + Case 6, 5, 17, 14, 19, 15, 16 + SigReferencia = dr("CveCompra").ToString.ContaReferencia(TipoContaReferencia.Compra) + Case 2, 4, 1, 13, 61, 62, 63, 8, 9 + SigReferencia = dr("CveVenta").ToString.ContaReferencia(TipoContaReferencia.Venta) + Case 30 + SigReferencia = dr("CveIE").ToString.ContaReferencia(TipoContaReferencia.Banco) + + End Select + + Select Case CveConceptoContable + Case 19 ' IVA Acreditable + ContabilizarDIOT = True + Case 61 ' IVA Trasladado + ContabilizarCausacion = True + Case 30 ' Bancos + If dr("Abono").ToString.ToDecimal > 0 Then ContabilizarDIOT = True + If dr("Cargo").ToString.ToDecimal > 0 Then ContabilizarCausacion = True + End Select + + tipoMovimiento = (dr("TipoMovto").ToString = "True") + + 'Si las cuentas contables estan en 0 no se debe contabilizar + If dr("CveCuenta").ToString.ToEntero > 0 Then + + 'Si ImporteMN es mayor que 0 entonces la compra es en dolares y debemos ingresar la cantidad en pesos + If dr("ImporteMN").ToString.ToDecimal <> 0 Then + If Not ObjConta.AddPolizaDetalle(tCvePoliza, dr("CveCuenta").ToString.ToEntero, "", dr("CveSubProyecto").ToString.ToEntero, tipoMovimiento, + dr("ImporteMN").ToString.ToDecimal, dr("Referencia").ToString, dr("Concepto").ToString, Fecha, ImporteMonedaExtranjera:=dr("ImporteME").ToString.ToDecimal, CvePrePolizaDetalle:=dr("CvePrePolizaDetalle").ToString.ToEntero) Then + OcurrioError = True + Exit For + End If + Else + If Not ObjConta.AddPolizaDetalle(tCvePoliza, dr("CveCuenta").ToString.ToEntero, "", dr("CveSubProyecto").ToString.ToEntero, tipoMovimiento, + dr("Importe").ToString.ToDecimal, dr("Referencia").ToString, dr("Concepto").ToString, Fecha, ImporteMonedaExtranjera:=dr("ImporteME").ToString.ToDecimal, CvePrePolizaDetalle:=dr("CvePrePolizaDetalle").ToString.ToEntero) Then + OcurrioError = True + Exit For + End If + End If + + Else + OcurrioError = True + Mensaje.Append(String.Format("
La cuenta contable {0} es invalida", dr("ConceptoContable"))) + Exit For + End If + + Next + + 'Obtenemos los valores de la causacion y los agregamos + 'If Not OcurrioError AndAlso ContabilizarCausacion Then + ' If GetCausacionesValores(CvePrePoliza) AndAlso Data.Rows.Count > 0 Then + ' Dim dr As DataRow = Data(0) + ' If Not ObjConta.AddCausacionesIVA(tIdPoliza, + ' dr("TotalTasa16").ToString.ToDecimal, + ' dr("BaseTasa16").ToString.ToDecimal, + ' dr("IvaTasa16").ToString.ToDecimal, + ' 0, + ' dr("ISRRetenido").ToString.ToDecimal, + ' dr("IVARetenido").ToString.ToDecimal, False) Then + ' OcurrioError = True + + ' End If + ' End If + 'End If + + 'Obtenemos los valores del DIOT y los agregamos + 'If Not OcurrioError AndAlso ContabilizarDIOT Then + ' If GetDIOTValores(CvePrePoliza) AndAlso Data.Rows.Count > 0 Then + ' Dim IdProveedor As Integer + ' Dim RFC, RazonSocial As String + + ' RFC = Data(0)("RFC").ToString + ' RazonSocial = Data(0)("RazonSocial").ToString + ' IdCtaContProveedores = Data(0)("IdCtaContProveedores").ToString.ToEntero + + ' If IdCtaContProveedores > 0 Then + + ' 'busco la clave del proveedor en la contabilidad por su cuenta contable + ' If ObjConta.GetProveedores(IdCuentaContable:=IdCtaContProveedores) Then + ' If ObjConta.DtResultados.Rows.Count > 0 Then + ' Dim dr As DataRow = ObjConta.DtResultados.Rows(0) : IdProveedor = dr("Id").ToString.ToEntero + ' End If + ' End If + ' Else + ' 'busco la clave del proveedor en la contabilidad por su cuenta contable + ' If ObjConta.GetProveedores(RFC:=RFC) Then + ' If ObjConta.DtResultados.Rows.Count > 0 Then + ' Dim dr As DataRow = ObjConta.DtResultados.Rows(0) : IdProveedor = dr("Id").ToString.ToEntero + ' End If + ' Else + ' 'registro el proveedor generico + ' Select Case Empresa.CveEmpresa + ' Case 66 : IdProveedor = 12726 + ' Case Else : IdProveedor = 1 + ' End Select + ' End If + + ' End If + + + ' If IdProveedor <= 0 Then + ' IdProveedor = ObjConta.AddProveedor(IdCtaContProveedores, RFC, RazonSocial, "") + ' If IdProveedor <= 0 Then + ' OcurrioError = True + ' End If + ' End If + + ' For Each dr As DataRow In Data.Rows + ' If dr("Total").ToString.ToDecimal <> 0.00 Then + ' If Not ObjConta.AddDevolucionesIVA(tIdPoliza, dr("CuentaBancos").ToString.ToEntero, + ' IdProveedor, + ' 16, + ' dr("SubTotal").ToString.ToDecimal, + ' dr("IvaAcreditable").ToString.ToDecimal, + ' dr("IVARetenido").ToString.ToDecimal, + ' dr("ISRRetenido").ToString.ToDecimal, + ' Fecha, + ' ContaFolio, + ' dr("Serie").ToString.ToString, + ' dr("Folio").ToString.StrToNum, "") Then + ' OcurrioError = True + ' Mensaje.Append("La Poliza o la Cuenta no son válidas") + ' End If + + + ' End If + + ' Next + + ' End If + 'End If + + If Not OcurrioError Then + Mensaje.Append(String.Format("{1}
", tCvePoliza, FolioFijo)) + ObjConta.Commit() + Retorno = True + _ContaIdPoliza = tCvePoliza + End If + End If + + Else + OcurrioError = True + End If + + + + Catch ex As Exception + ObjConta.RollBack() + OnError("Ocurrió un error al intentar contabilizar la PrePoliza", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + Retorno = False + End Try + + ObjConta.Dispose() + Return Retorno + End Function + + Public Function GetCuentaDobleConta(IdCtaContable As Integer, CveEmpresa As Integer) As Boolean + + Dim Retorno As Boolean = False + + DataAdapter("PA_Conta_CuentaDobleContaGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@IdCtaContable", SqlDbType.Int).Value = IdCtaContable + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener la cuenta doble.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function GetEncabezadoPrePoliza(CvePrePoliza As Integer, CveEmpresa As Integer) As Boolean + + Dim Retorno As Boolean = False + + DataAdapter("PA_Conta_PrePolizaEncabezadoGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex1 As SqlException + OnError("Ocurrió un error al obtener el encabezado de la PrePoliza", ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + Catch ex As Exception + OnError("Ocurrió un error al obtener el encabezado de la PrePoliza", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function GetPrePolizasDetalle2(CvePrePoliza As Integer, Optional CveIE As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Conta_PrePolizasDetalleGet2") + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza + .Add("@CveIE", SqlDbType.Int).Value = CveIE + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener Movimientos Prepolizas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetCausacionesValores(CvePrePoliza As Integer) As Boolean 'Editado por charlie + + Dim Retorno As Boolean = False + + DataAdapter("PA_Conta_CausacionesValoresGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex1 As SqlException + OnError("Ocurrió un error al obtener los valores de la Causacion", ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + Catch ex As Exception + OnError("Ocurrió un error al obtener los valores de la Causacion", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function GetDIOTValores(CvePrePoliza As Integer) As Boolean 'Editado por charlie + + Dim Retorno As Boolean = False + + DataAdapter("PA_Conta_DIOTValoresGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex1 As SqlException + OnError("Ocurrió un error al obtener los valores del DIOT", ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + Catch ex As Exception + OnError("Ocurrió un error al obtener los valores del DIOT", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + + Public Function UpdatePrePoliza(FechaConta As Date, FolioPoliza As Integer, CveTipoPoliza As Integer, IdPoliza As Integer, CvePrePoliza As Integer, CveEmpresa As Integer, Optional Concepto As String = "-1", Optional FechaPoliza As Date = MinFecha, Optional xxx As Integer = -1) As Boolean + + Dim Retorno As Boolean = False + + DataAdapter("PA_Conta_PrePolizasPolizaUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaConta", SqlDbType.Date).Value = FechaConta + .Add("@FechaPoliza", SqlDbType.Date).Value = FechaPoliza + .Add("@FolioPoliza", SqlDbType.Int).Value = FolioPoliza + .Add("@CveTipoPoliza", SqlDbType.Int).Value = CveTipoPoliza + .Add("@IdPoliza", SqlDbType.Int).Value = IdPoliza + .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza + .Add("@Concepto", SqlDbType.VarChar).Value = Concepto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + + If ex.Message.Contains("50015;") Then + OnError("No se puede actualizar una póliza en un ejercicio Cerrado", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + Else + OnError("Ocurrió un error al actualizar prepoliza del movimiento", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End If + End Try + + Return Retorno + End Function + + Public Function GetPrePoliza(CvePrePoliza As Integer, CveEmpresa As Integer, Optional IdPoliza As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Conta_PrePolizasGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@IdPoliza", SqlDbType.Int).Value = IdPoliza + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener la prepoliza.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + + +#End Region + +#Region " C O N T A B I L I D A D - T I P O - P O L I Z A " + Public Function GetConta_TiposPoliza(CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Conta_TiposPolizasGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Catálogo de Tipo de Pólizas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function AddConta_TiposPoliza(TipoPoliza As String, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Conta_TiposPolizaAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@TipoPoliza", SqlDbType.VarChar).Value = TipoPoliza + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 2627;") Then + Alert("Ya existe un Tipo de Póliza con el mismo nombre: " & TipoPoliza & ".", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al Guardar el Tipo de Póliza.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + OnError("Ocurrió un error al Guardar el Tipo de Póliza", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function UpdateConta_TiposPoliza(TipoPoliza As String, Estatus As Boolean, CveTipoPoliza As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Conta_TiposPolizaUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@TipoPoliza", SqlDbType.VarChar).Value = TipoPoliza + .Add("@Estatus", SqlDbType.Bit).Value = Estatus + .Add("@CveTipoPoliza", SqlDbType.Int).Value = CveTipoPoliza + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 2627;") Then + Alert("Ya existe un Tipo de Póliza con el mismo nombre: " & TipoPoliza & ".", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al guardar los cambios en el Tipo de Póliza", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + OnError("Ocurrió un error al guardar los cambios en el Tipo Póliza.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function RemoveConta_TipoPoliza(CveTipoPoliza As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Conta_TiposPolizaRemove") + + SqlAdapter.SelectCommand.Parameters.Add("@CveTipoPoliza", SqlDbType.Int).Value = CveTipoPoliza + + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 547;") Then + Alert("El Tipo de Póliza no se pudo eliminar porque está siendo usado por un registro.", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al eliminar el Tipo Póliza.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + Me.OnError("Ocurrió un error al eliminar el Tipo Póliza.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +#End Region + +#Region " C O N T A B I L I D A D - C O N C E P T O S - C O N T A B L E S " + Public Function GetConta_ConceptosContables() As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Conta_ConceptosContablesGet") + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Catálogo de Concepto Contables.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function AddConta_ConceptosContables(CveConceptoContable As Integer, Tipo As String, ConceptoContable As String, CveUsuario As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Conta_ConceptosContablesAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveConceptoContable", SqlDbType.Int).Value = CveConceptoContable + .Add("@Tipo", SqlDbType.VarChar).Value = Tipo + .Add("@ConceptoContable", SqlDbType.VarChar).Value = ConceptoContable + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 2627;") Then + Alert("Ya existe un Concepto Contable con el mismo nombre: " & Tipo & ".", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al Guardar el Concepto Contable.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + OnError("Ocurrió un error al Guardar el Concepto Contable", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function UpdateConta_ConceptosContables(Tipo As String, ConceptoContable As String, Estado As Boolean, CveConceptoContable As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Conta_ConceptosContablesUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Tipo", SqlDbType.VarChar).Value = Tipo + .Add("@ConceptoContable", SqlDbType.VarChar).Value = ConceptoContable + .Add("@Estado", SqlDbType.Bit).Value = Estado + .Add("@CveConceptoContable", SqlDbType.Int).Value = CveConceptoContable + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 2627;") Then + Alert("Ya existe un Concepto Contable con el mismo nombre: " & Tipo & ".", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al guardar los cambios en el Concepto Contable", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + OnError("Ocurrió un error al guardar los cambios en el Concepto Contable.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function RemoveConta_ConceptosContables(CveConceptoContable As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Conta_ConceptosContablesRemove") + + SqlAdapter.SelectCommand.Parameters.Add("@CveConceptoContable", SqlDbType.Int).Value = CveConceptoContable + + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 547;") Then + Alert("El Concepto Contable no se pudo eliminar porque está siendo usado por un registro.", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al eliminar el Concepto Contable.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + Me.OnError("Ocurrió un error al eliminar el Concepto Contable.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +#End Region + +#Region " C O N T A B I L I D A D - D I A R I O S " + + Public Function GetContabilizacionDiario(CveEmpresa As Integer, CvePlantilla As Integer, FechaI As Date, FechaF As Date, Optional CveProveedor As Integer = -1, Optional CvePersonal As Integer = -1, Optional CveTipoProveedor As Integer = -1, Optional CveMoneda As Integer = -1, Optional CvePlantillaPoliza As Integer = -1, Optional EstatusContabilizacion As Integer = -1, Optional CveSubProyecto As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Conta_ContabilizacionDiariosGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CvePlantilla", SqlDbType.Int).Value = CvePlantilla + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor + .Add("@CvePersonal", SqlDbType.Int).Value = CvePersonal + .Add("@CveTipoProveedor", SqlDbType.Int).Value = CveTipoProveedor + .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda + .Add("@CvePlantillaPoliza", SqlDbType.Int).Value = CvePlantillaPoliza + .Add("@EstatusContabilizacion", SqlDbType.Int).Value = EstatusContabilizacion + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el diario.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetContabilizacionDiarioDetalle(CvePrePoliza As Integer) As Boolean 'Editado por charlie + Dim Retorno As Boolean = False + DataAdapter("PA_Conta_ContabilizacionDiariosDetalleGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los detalles de las ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetContabilizacionVentas(CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Conta_ContabilizacionVentasGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener las ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetContabilizacionVentasDetalle(CvePrePoliza As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Conta_ContabilizacionVentasDetallesGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los detalles de las ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetContabilizacionPagos(CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Conta_ContabilizacionPagosGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los pagos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetContabilizacionPagosDetalle(CvePrePoliza As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Conta_ContabilizacionPagosDetallesGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los detalles de los pagos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetContabilizacionAnticipos(CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Conta_ContabilizacionAnticiposGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los pagos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetContabilizacionAnticiposDetalle(CvePrePoliza As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Conta_ContabilizacionAnticiposDetallesGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los detalles de los pagos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetContabilizacionAmortizacion(CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Conta_ContabilizacionAmortizacionGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los pagos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetContabilizacionAmortizacionDetalle(CvePrePoliza As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Conta_ContabilizacionAmortizacionDetallesGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los detalles de los pagos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetDiarioVentas(CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Conta_DiarioVentasGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el diario de ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetDiarioCompras(CveProveedor As Integer, FechaInicio As Date, FechaFin As Date, Opcion As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Conta_DiarioComprasGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor + .Add("@FechaI", SqlDbType.Date).Value = FechaInicio + .Add("@FechaF", SqlDbType.Date).Value = FechaFin + .Add("@Opcion", SqlDbType.Int).Value = Opcion + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el diario de compras.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + + 'Public Function GetDiarioPagosCompras(CveProveedor As Integer, FechaInicio As Date, FechaFin As Date, Opcion As Integer, CveEmpresa As Integer) As Boolean + ' Dim Retorno As Boolean = False + ' DataAdapter("PA_Conta_DiarioPagosComprasGet") + + ' With SqlAdapter.SelectCommand.Parameters + ' .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor + ' .Add("@FechaI", SqlDbType.Date).Value = FechaInicio + ' .Add("@FechaF", SqlDbType.Date).Value = FechaFin + ' .Add("@Opcion", SqlDbType.Int).Value = Opcion + ' .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + ' End With + + ' Try + ' SqlAdapter.Fill(Data) + ' Retorno = True + ' Catch ex As Exception + ' OnError("Ocurrió un error al obtener el diario de Pagoss.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + ' End Try + + ' Return Retorno + 'End Function + + + + Public Function GetDiarioPagosCompras(CveProveedor As Integer, FechaInicio As Date, FechaFin As Date, Opcion As Integer, CveCuenta As Integer, CveTipoTransaccion As Integer, CveEmpresa As Integer) As DataSet + Dim Retorno As New DataSet + DataAdapter("PA_Conta_DiarioPagosComprasGet33") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor + .Add("@FechaI", SqlDbType.Date).Value = FechaInicio + .Add("@FechaF", SqlDbType.Date).Value = FechaFin + .Add("@Opcion", SqlDbType.Int).Value = Opcion + .Add("@CveCuenta", SqlDbType.Int).Value = CveCuenta + .Add("@CveTipoTransaccion", SqlDbType.Int).Value = CveTipoTransaccion + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Retorno) + + Catch ex As Exception + OnError("Ocurrió un error al obtener el diario de Pagoss.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + + + Public Function GetDiarioPagos(CveProveedor As Integer, FechaInicio As Date, FechaFin As Date, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Conta_DiarioPagosGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor + .Add("@FechaI", SqlDbType.Date).Value = FechaInicio + .Add("@FechaF", SqlDbType.Date).Value = FechaFin + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el diario de pagos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + + Public Function GetDiarioAmortizacion(CveProveedor As Integer, FechaInicio As Date, FechaFin As Date, Opcion As Integer, CveCuenta As Integer, CveTipoTransaccion As Integer, CveEmpresa As Integer) As DataSet + Dim Retorno As New DataSet + DataAdapter("PA_Conta_DiarioAmortizacion") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor + .Add("@FechaI", SqlDbType.Date).Value = FechaInicio + .Add("@FechaF", SqlDbType.Date).Value = FechaFin + .Add("@Opcion", SqlDbType.Int).Value = Opcion + .Add("@CveCuenta", SqlDbType.Int).Value = CveCuenta + .Add("@CveTipoTransaccion", SqlDbType.Int).Value = CveTipoTransaccion + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Retorno) + + Catch ex As Exception + OnError("Ocurrió un error al obtener el diario de Amortizaciones.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + +#End Region + + +#Region " C O N T A B I L I D A D - P L A N T I L L A S P O L I Z A S " + + Public Function GetConta_PlantillasPolizas(CvePlantillaPoliza As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Conta_PlantillasPolizasGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePlantillaPoliza", SqlDbType.Int).Value = CvePlantillaPoliza + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + If CvePlantillaPoliza > 0 AndAlso Data IsNot Nothing AndAlso Data.Rows.Count > 0 Then + Me.CvePlantillaPoliza = Data.Rows(0)("CvePlantillaPoliza").ToString.ToEntero + Me.PlantillaPoliza = Data.Rows(0)("PlantillaPoliza").ToString + 'Me.TipoPlantilla = Data.Rows(0)("TipoPlantilla").ToString.ToEntero + Me.TipoPoliza = Data.Rows(0)("TipoPoliza").ToString.ToEntero + 'Me.Orden = Data.Rows(0)("Orden").ToString.ToEnter + Me.Estatus = Data.Rows(0)("Estatus").ToString + Me.FechaIng = Data.Rows(0)("FechaIng").ToString.ToDateTime + Me.CveUsuario = Data.Rows(0)("CveUsuario").ToString.ToEntero + Me.Usuario = Data.Rows(0)("Usuario").ToString + Me.CveEmpresa = Data.Rows(0)("CveEmpresa").ToString.ToEntero + Me.CveTipoPlantillaPoliza = Data.Rows(0)("CveTipoPlantillaPoliza").ToString.ToEntero + End If + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener las plantillas", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetConta_PlantillasPolizasEmpresas(CvePlantillaPoliza As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Conta_PlantillasPolizasEmpresasGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePlantillaPoliza", SqlDbType.Int).Value = CvePlantillaPoliza + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + If CvePlantillaPoliza > 0 AndAlso Data IsNot Nothing AndAlso Data.Rows.Count > 0 Then + Me.CvePlantillaPoliza = Data.Rows(0)("CvePlantillaPoliza").ToString.ToEntero + Me.PlantillaPoliza = Data.Rows(0)("PlantillaPoliza").ToString + 'Me.TipoPlantilla = Data.Rows(0)("TipoPlantilla").ToString.ToEntero + Me.TipoPoliza = Data.Rows(0)("TipoPoliza").ToString.ToEntero + 'Me.Orden = Data.Rows(0)("Orden").ToString.ToEnter + Me.Estatus = Data.Rows(0)("Estatus").ToString + Me.FechaIng = Data.Rows(0)("FechaIng").ToString.ToDateTime + Me.CveUsuario = Data.Rows(0)("CveUsuario").ToString.ToEntero + Me.Usuario = Data.Rows(0)("Usuario").ToString + Me.CveEmpresa = Data.Rows(0)("CveEmpresa").ToString.ToEntero + Me.CveTipoPlantillaPoliza = Data.Rows(0)("CveTipoPlantillaPoliza").ToString.ToEntero + End If + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener las plantillas", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function AddConta_PlantillasPolizasEmpresas(CvePlantillaPoliza As Integer, TipoPoliza As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim retorno As Boolean = False + + DataAdapter("PA_Conta_PlantillasPolizasEmpresasAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@TipoPoliza", SqlDbType.Int).Value = TipoPoliza + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CvePlantillaPoliza", SqlDbType.Int).Value = CvePlantillaPoliza + End With + + Try + SqlAdapter.Fill(Data) + retorno = True + Catch Ex As Exception + OnError("Ocurrió un error al agregar la plantilla.", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return retorno + End Function + Public Function UpdateConta_PlantillasPolizasEmpresas(CvePlantillaPoliza As Integer, TipoPoliza As Integer, CveEmpresa As Integer) As Boolean + Dim retorno As Boolean = False + + DataAdapter("PA_Conta_PlantillasPolizasEmpresasUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("CvePlantillaPoliza", SqlDbType.Int).Value = CvePlantillaPoliza + .Add("TipoPoliza", SqlDbType.Int).Value = TipoPoliza + .Add("CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + retorno = True + Catch ex As Exception + OnError("Ocurrió un error al guardar los cambios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return retorno + End Function + Public Function AddConta_PlantillasPolizas(CvePlantillaPoliza As Integer, PlantillaPoliza As String, CveTipoPlantillaPoliza As Integer, TipoPoliza As Integer, Estatus As Boolean, FechaIng As String, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim retorno As Boolean = False + + DataAdapter("PA_Conta_PlantillasPolizasAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@PlantillaPoliza", SqlDbType.VarChar).Value = PlantillaPoliza + .Add("@CveTipoPlantillaPoliza", SqlDbType.Int).Value = CveTipoPlantillaPoliza + .Add("@TipoPoliza", SqlDbType.Int).Value = TipoPoliza + .Add("@Estatus", SqlDbType.Bit).Value = Estatus + .Add("@FechaIng", SqlDbType.DateTime).Value = FechaIng + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CvePlantillaPoliza", SqlDbType.Int).Value = CvePlantillaPoliza + End With + + Try + SqlAdapter.Fill(Data) + retorno = True + Me.CvePlantillaPoliza = CvePlantillaPoliza + Catch Ex As SqlException + If Ex.Message.Contains("Número: 2627;") Then + Alert(String.Format("Ya existe un Registro con el mismo nombre: {0}. o con la misma Clave :{1}", PlantillaPoliza, CvePlantillaPoliza), TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al Guardar.", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch Ex As Exception + + End Try + Return retorno + End Function + Public Function UpdateConta_PlantillasPolizas(PlantillaPoliza As String, CveTipoPlantillaPoliza As Integer, TipoPoliza As Integer, Estatus As Boolean, CvePlantillaPoliza As Integer) As Boolean + Dim retorno As Boolean = False + + DataAdapter("PA_Conta_PlantillasPolizasUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("PlantillaPoliza", SqlDbType.VarChar).Value = PlantillaPoliza + '.Add("TipoPlantilla", SqlDbType.Int).Value = TipoPlantilla + .Add("CveTipoPlantillaPoliza", SqlDbType.Int).Value = CveTipoPlantillaPoliza + .Add("TipoPoliza", SqlDbType.Int).Value = TipoPoliza + '.Add("Orden", SqlDbType.Int).Value = Orden + .Add("Estatus", SqlDbType.Bit).Value = Estatus + .Add("CvePlantillaPoliza", SqlDbType.Int).Value = CvePlantillaPoliza + + End With + + Try + SqlAdapter.Fill(Data) + retorno = True + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 2627;") Then + Alert("Ya existe un Registro con el mismo nombre: " & PlantillaPoliza & ".", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al guardar los cambios.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + OnError("Ocurrió un error al guardar los cambios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return retorno + End Function + + Public Function RemoveConta_PlantillasPolizas(CvePlantillaPoliza As Integer, CveEmpresa As Integer) As Boolean + Dim retorno As Boolean = False + + DataAdapter("PA_Conta_PlantillasPolizasRemove") + + With SqlAdapter.SelectCommand.Parameters + .Add("CvePlantillaPoliza", SqlDbType.Int).Value = CvePlantillaPoliza + .Add("CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + retorno = True + Catch ex As Exception + OnError("Ocurrió un error al Eliminar Plantilla Póliza.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return retorno + End Function + + Public Function RemoveConta_PlantillasPolizasDetalle(CvePlantillaPoliza As Integer, Optional CvePlantillaPolizaDetalle As Integer = -1) As Boolean + Dim retorno As Boolean = False + + DataAdapter("PA_Conta_PlantillasPolizasDetalleRemove") + + With SqlAdapter.SelectCommand.Parameters + .Add("CvePlantillaPolizaDetalle", SqlDbType.Int).Value = CvePlantillaPolizaDetalle + .Add("CvePlantillaPoliza", SqlDbType.Int).Value = CvePlantillaPoliza + End With + + Try + SqlAdapter.Fill(Data) + retorno = True + Catch ex As Exception + OnError("Ocurrió un error al Eliminar Plantilla Póliza Detalle.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return retorno + End Function + Public Function GetConta_PlantillasPolizasTipo() As Boolean + Dim retorno As Boolean = False + + DataAdapter("PA_Conta_PlantillasPolizasTipoGet") + + Try + SqlAdapter.Fill(Data) + retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los Tipos de plantillas", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return retorno + End Function + +#End Region + +#Region " C O N T A B I L I D A D - P L A N T I L L A S - P O L I Z A S - D E T A L L E S" + Public Function GetConta_PlantillasPolizasDetalle(CvePlantillaPoliza As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Conta_PlantillasPolizasDetalleGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePlantillaPoliza", SqlDbType.Int).Value = CvePlantillaPoliza + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener las plantillas detalle", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function AddConta_PlantillasPolizasDetalles(CvePlantillaPoliza As Integer, CveConcepto As Integer, TipoMovto As Integer, IdCtaContable As Integer, Orden As Integer, CveUsuario As Integer, CveEmpresa As Integer, CveSubProyecto As Integer, CveProveedor As Integer, Optional CvePersonal As Integer = -1) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Conta_PlantillasPolizasDetalleAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePlantillaPoliza", SqlDbType.Int).Value = CvePlantillaPoliza + .Add("@CveConcepto", SqlDbType.Int).Value = CveConcepto + .Add("@IdCtaContable", SqlDbType.Int).Value = IdCtaContable + .Add("@TipoMovto", SqlDbType.Int).Value = TipoMovto + .Add("@Orden", SqlDbType.Int).Value = Orden + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor + .Add("@CvePersonal", SqlDbType.Int).Value = CvePersonal + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex As SqlException + If Ex.Message.Contains("Número: 2627;") Then + Alert("Ya existe un Registro con el mismo nombre: " & PlantillaPoliza & ".", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al Guardar.", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch Ex As Exception + Me.OnError("Ocurrió un error al Guardar.", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + Public Function UpdateConta_PlantillasPolizasDetalle(CveConcepto As Integer, TipoMovto As Integer, IdCtaContable As Integer, Orden As Integer, CvePlantillaPolizaDetalle As Integer, CveSubProyecto As Integer, CveProveedor As Integer, Optional CvePersonal As Integer = -1) As Boolean + Dim retorno As Boolean = False + + DataAdapter("PA_Conta_PlantillasPolizasDetalleUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("CveConcepto", SqlDbType.VarChar).Value = CveConcepto + .Add("TipoMovto", SqlDbType.Int).Value = TipoMovto + .Add("IdCtaContable", SqlDbType.Int).Value = IdCtaContable + .Add("Orden", SqlDbType.Int).Value = Orden + .Add("CvePlantillaPolizaDetalle", SqlDbType.Int).Value = CvePlantillaPolizaDetalle + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor + .Add("@CvePersonal", SqlDbType.Int).Value = CvePersonal + End With + + Try + SqlAdapter.Fill(Data) + retorno = True + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 2627;") Then + Alert("Ya existe un Registro con el mismo nombre: " & PlantillaPoliza & ".", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al guardar los cambios.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + OnError("Ocurrió un error al guardar los cambios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return retorno + End Function + + + + Public Function AddConta_PlantillasPolizasTipo(TipoPlantillaPoliza As String, CveUsuario As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Conta_PlantillasPolizasTipoAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@TipoPlantillaPoliza", SqlDbType.VarChar).Value = TipoPlantillaPoliza + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex As Exception + Me.OnError("Ocurrió un error al Agregar.", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + + Public Function RemoveConta_PlantillaTipoDetalle(CveTipoPlantillaPoliza As Integer) As Boolean + Dim retorno As Boolean = False + + DataAdapter("PA_Conta_PlantillasTipoRemove") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveTipoPlantillaPoliza", SqlDbType.Int).Value = CveTipoPlantillaPoliza + + End With + Try + SqlAdapter.Fill(Data) + retorno = True + Catch ex As Exception + OnError("Ocurrió un error al Eliminar Plantilla Póliza Tipo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return retorno + End Function + + + + +#End Region + + +#Region "C O N C E P T O S - C O N T A B L E S" + 'Public Function AddConta_ConceptosContables(CveConceptoContable As Integer, Tipo As String, ConceptoContable As String, CveUsuario As Integer) As Boolean + ' Dim Retorno As Boolean = False + + ' DataAdapter("PA_Conta_ConceptosContablesAdd") + + ' With SqlAdapter.SelectCommand.Parameters + ' .Add("@CveConceptoContable", SqlDbType.Int).Value = CveConceptoContable + ' .Add("@Tipo", SqlDbType.VarChar).Value = Tipo + ' .Add("@ConceptoContable", SqlDbType.VarChar).Value = ConceptoContable + ' .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + ' End With + + ' Try + ' SqlAdapter.Fill(Data) + ' Retorno = True + ' Catch Ex1 As SqlException + ' If Ex1.Message.Contains("Número: 2627;") Then + ' Alert("Ya existe un Concepto Contable con el mismo nombre: " & Tipo & ".", TipoMensaje.MsgAdvertencia) + ' Else + ' Me.OnError("Ocurrió un error al Guardar el Concepto Contable.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + ' End If + ' Catch ex As Exception + ' OnError("Ocurrió un error al Guardar el Concepto Contable", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + ' End Try + + ' Return Retorno + 'End Function + + 'Public Function UpdateConta_ConceptosContables(Tipo As String, ConceptoContable As String, Estado As Boolean, CveConceptoContable As Integer) As Boolean + ' Dim Retorno As Boolean = False + + ' DataAdapter("PA_Conta_ConceptosContablesUpdate") + + ' With SqlAdapter.SelectCommand.Parameters + ' .Add("@Tipo", SqlDbType.VarChar).Value = Tipo + ' .Add("@ConceptoContable", SqlDbType.VarChar).Value = ConceptoContable + ' .Add("@Estado", SqlDbType.Bit).Value = Estado + ' .Add("@CveConceptoContable", SqlDbType.Int).Value = CveConceptoContable + ' End With + + ' Try + ' SqlAdapter.Fill(Data) + ' Retorno = True + ' Catch Ex1 As SqlException + ' If Ex1.Message.Contains("Número: 2627;") Then + ' Alert("Ya existe un Concepto Contable con el mismo nombre: " & Tipo & ".", TipoMensaje.MsgAdvertencia) + ' Else + ' Me.OnError("Ocurrió un error al guardar los cambios en el Concepto Contable", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + ' End If + ' Catch ex As Exception + ' OnError("Ocurrió un error al guardar los cambios en el Concepto Contable.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + ' End Try + + ' Return Retorno + 'End Function + + 'Public Function RemoveConta_ConceptosContables(CveConceptoContable As Integer) As Boolean + ' Dim Retorno As Boolean = False + + ' DataAdapter("PA_Conta_ConceptosContablesRemove") + + ' SqlAdapter.SelectCommand.Parameters.Add("@CveConceptoContable", SqlDbType.Int).Value = CveConceptoContable + + + ' Try + ' SqlAdapter.Fill(Data) + ' Retorno = True + ' Catch Ex1 As SqlException + ' If Ex1.Message.Contains("Número: 547;") Then + ' Alert("El Concepto Contable no se pudo eliminar porque está siendo usado por un registro.", TipoMensaje.MsgAdvertencia) + ' Else + ' Me.OnError("Ocurrió un error al eliminar el Concepto Contable.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + ' End If + ' Catch ex As Exception + ' Me.OnError("Ocurrió un error al eliminar el Concepto Contable.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + ' End Try + + ' Return Retorno + 'End Function +#End Region + +#Region " P O L I Z A S - C O M P L E M E N T A R I A S " + Public Function AddPoliza(TipoPol As Integer, Folio As Integer, FechaPoliza As Date, Concepto As String, CveUsuario As Integer, CveEmpresa As Integer, Optional CvePrePoliza As Integer = 0) As Integer + Dim Retorno As Integer = 0 + + DataAdapter("PA_Conta_PolizasAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Folio", SqlDbType.Int).Value = Folio + .Add("@TipoPol", SqlDbType.Int).Value = TipoPol + .Add("@Concepto", SqlDbType.VarChar).Value = Concepto + .Add("@FechaPoliza", SqlDbType.DateTime).Value = FechaPoliza + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza + .Add("@CvePoliza", SqlDbType.Int).Direction = ParameterDirection.Output + End With + + Try + SqlAdapter.Fill(Data) + Retorno = SqlAdapter.SelectCommand.Parameters("@CvePoliza").Value.ToString.ToEntero + ContaFolio = If(Data IsNot Nothing AndAlso Data.Rows.Count > 0, Data.Rows(0)("Folio").ToString.ToEntero, 0) + Catch ex As Exception + OnError("Ocurrió un error al agregar la poliza", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function AjustaPoliza(CvePoliza As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Conta_PolizasAjuste") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePoliza", SqlDbType.Int).Value = CvePoliza + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al realizar el ajuste de la póliza.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function AddPolizaDetalle(CvePoliza As Integer, CveCuenta As Integer, Cuenta As String, CveSubProyecto As Integer, TipoMovto As Boolean, Importe As Double, Referencia As String, + Concepto As String, FechaMovto As Date, Optional ImporteMonedaExtranjera As Double = 0, Optional CvePrePolizaDetalle As Integer = 0) As Boolean + Dim Retorno As Boolean = False + + If CvePoliza <= 0 Or CveCuenta <= 0 Then + Return False + End If + + DataAdapter("PA_Conta_PolizasDetalleAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePoliza", SqlDbType.Int).Value = CvePoliza + .Add("@CveCuenta", SqlDbType.Int).Value = CveCuenta + .Add("@Cuenta", SqlDbType.VarChar).Value = Cuenta + .Add("@TipoMovto", SqlDbType.Int).Value = TipoMovto + .Add("@Importe", SqlDbType.Money).Value = Math.Round(Importe, 2) + .Add("@Referencia", SqlDbType.VarChar).Value = Referencia + .Add("@Concepto", SqlDbType.VarChar).Value = Concepto + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@Fecha", SqlDbType.DateTime).Value = FechaMovto + .Add("@ImporteME", SqlDbType.Money).Value = ImporteMonedaExtranjera + .Add("@CvePrePolizaDetalle", SqlDbType.Int).Value = CvePrePolizaDetalle + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar el movimiento en la póliza.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function AddDevolucionesIVA(IdPoliza As Integer, IdCuenta As Integer, IdProveedor As Integer, PorIVA As Double, + SubTotal As Double, IVA As Double, RetIVA As Double, RetISR As Double, FechaMovto As Date, Referencia As String, Serie As String, Folio As Integer, UUID As String) As Boolean + Dim Retorno As Boolean = False + + If IdPoliza <= 0 Or IdCuenta <= 0 Then + Return False + End If + ' no puede ser menor el subtotal al IVA, para evitar numeros negativos + If SubTotal < IVA Then + Return False + End If + + DataAdapter("PA_Conta_DevolucionesIVAAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePoliza", SqlDbType.Int).Value = IdPoliza + .Add("@CveCuenta", SqlDbType.Int).Value = IdCuenta + .Add("@CveProveedor", SqlDbType.Int).Value = IdProveedor + .Add("@PorIVA", SqlDbType.Float).Value = Math.Round(PorIVA, 2) + .Add("@SubTotal", SqlDbType.Float).Value = Math.Round(SubTotal, 2) + .Add("@IVA", SqlDbType.Float).Value = Math.Round(IVA, 2) + .Add("@RetIVA", SqlDbType.Float).Value = Math.Round(RetIVA, 2) + .Add("@RetISR", SqlDbType.Float).Value = Math.Round(RetISR, 2) + .Add("@FechaMov", SqlDbType.DateTime).Value = FechaMovto + .Add("@Referencia", SqlDbType.VarChar).Value = If(Referencia.Length > 30, Referencia.Substring(1, 30), Referencia) + .Add("@Serie", SqlDbType.VarChar).Value = If(Serie.Length > 15, Serie.Substring(1, 15), Serie) + .Add("@Folio", SqlDbType.Int).Value = If(Len(Folio.ToString) <= 8, Folio, Right(Folio.ToString, 8).ToEntero) ' se limita a 8 digitos, sino le cortan y se toman los ultimos 8, para que guarde e contpaqi + .Add("@UUID", SqlDbType.VarChar).Value = UUID + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un Error al agregar el movimiento de devolucion de egresos en la póliza.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function UpdatePoliza(FechaPoliza As Date, Folio As Integer, CvePoliza As Integer, Concepto As String, TipoPoliza As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Conta_PolizasUpdate") + + + With SqlAdapter.SelectCommand.Parameters + .Add("@Folio", SqlDbType.Int).Value = Folio + .Add("@Concepto", SqlDbType.VarChar).Value = Concepto + .Add("@FechaPoliza", SqlDbType.DateTime).Value = FechaPoliza + .Add("@TipoPoliza", SqlDbType.Int).Value = TipoPoliza + .Add("@CvePoliza", SqlDbType.Int).Value = CvePoliza + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + + Catch ex As SqlException + If ex.Number = 50000 Then + OnError("No se puede registrar la poliza porque ya existe una con el mismo Folio", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + OnError("Ocurrió un error al actualizar la Póliza.", ex) + End Try + + Return Retorno + + End Function + Public Function UpdatePolizaDetalle(CvePolizaDetalle As Integer, IdCuenta As Integer, CveSubProyecto As Integer, TipoMovto As Boolean, Importe As Double, Referencia As String, + Concepto As String) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Conta_PolizasDetalleUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Referencia", SqlDbType.VarChar).Value = Referencia + .Add("@Concepto", SqlDbType.VarChar).Value = Concepto + .Add("@TipoMovto", SqlDbType.Int).Value = TipoMovto + .Add("@Importe", SqlDbType.Money).Value = Math.Round(Importe, 2) + .Add("@IdCuentaNueva", SqlDbType.Int).Value = IdCuenta + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CvePolizaDetalle", SqlDbType.Int).Value = CvePolizaDetalle + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar el Movimiento de la Poliza", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + + End Function + + Public Function RemovePolizaDetalle(CvePolizaDetalle As Integer) As Boolean + Dim Retorno As Boolean = False + + If CvePolizaDetalle <= 0 Then + Return False + End If + + DataAdapter("PA_Conta_PolizasDetalleRemove") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePolizaDetalle", SqlDbType.Int).Value = CvePolizaDetalle + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar el movimiento en la póliza.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function RemovePoliza(CvePoliza As Integer) As Boolean + Dim Retorno As Boolean = False + + If CvePoliza <= 0 Then + Return False + End If + + DataAdapter("PA_Conta_PolizasRemove") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePoliza", SqlDbType.Int).Value = CvePoliza + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar el movimiento en la póliza.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetPoliza(CvePoliza As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + If CvePoliza <= 0 Then + Return False + End If + + DataAdapter("PA_Conta_PolizasGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePoliza", SqlDbType.Int).Value = CvePoliza + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener la Poliza.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetPoliza(CveTipoPoliza As Integer, Fecha As Date, Folio As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Conta_PolizasFechaFolioGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveTipoPoliza", SqlDbType.Int).Value = CveTipoPoliza + .Add("@Folio", SqlDbType.Int).Value = Folio + .Add("@Fecha", SqlDbType.Date).Value = Fecha + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener la Poliza.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + + Public Function GetPolizaDetalle(CvePoliza As Integer) As Boolean + Dim Retorno As Boolean = False + + If CvePoliza <= 0 Then + Return False + End If + + DataAdapter("PA_Conta_PolizasDetalleGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePoliza", SqlDbType.Int).Value = CvePoliza + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los detalles de la Póliza.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +#End Region + + + +#Region "F I N A N C I A M I E N T O - M E T A S" + Public Function AddFinan_Metas(Meta As Decimal, CveCuenta As Integer, Anio As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_Finan_MetasAdd") + With SqlAdapter.SelectCommand.Parameters + .Add("@Meta", SqlDbType.Money).Value = Meta + .Add("@CveCuenta", SqlDbType.Int).Value = CveCuenta + .Add("@Anio", SqlDbType.SmallInt).Value = Anio + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar la Meta", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function UpdateFinan_Metas(Meta As Decimal, CveCuenta As Integer, Anio As Integer, Estatus As Boolean, CveMeta As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Finan_MetasUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Meta", SqlDbType.Money).Value = Meta + .Add("@CveCuenta", SqlDbType.Int).Value = CveCuenta + .Add("@Anio", SqlDbType.SmallInt).Value = Anio + .Add("@Estatus", SqlDbType.Bit).Value = Estatus + .Add("@CveMeta", SqlDbType.Int).Value = CveMeta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + + Catch ex As SqlException + If ex.Number = 50000 Then + OnError("No se puede registrar la Meta porque ya existe", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + OnError("Ocurrió un error al actualizar la Meta.", ex) + End Try + + Return Retorno + + End Function + + Public Function RemoveFinan_Metas(CveMeta As Integer) As Boolean + Dim Retorno As Boolean = False + + If CveMeta <= 0 Then + Return False + End If + + DataAdapter("PA_Finan_MetasRemove") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveMeta", SqlDbType.Int).Value = CveMeta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar el movimiento en la Meta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetFinan_Metas(CveMeta As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + If CveMeta <= 0 Then + Return False + End If + + DataAdapter("PA_Finan_MetasGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveMeta", SqlDbType.Int).Value = CveMeta + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener la Meta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + +#End Region + +#Region "F I N A N C I A M I E N T O - V E N T A S - P R O Y E C C I O N E S" + Public Function AddFinan_VentasProyecciones(CvePS As Integer, Cantidad As Double, PU As Double, Fecha As Date, Anio As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_Finan_MetasAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@Cantidad", SqlDbType.Money).Value = Cantidad + .Add("@PU", SqlDbType.Money).Value = PU + .Add("@Fecha", SqlDbType.DateTime).Value = Fecha + .Add("@Anio", SqlDbType.SmallInt).Value = Anio + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar la Proyección de Venta", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function UpdateFinan_VentasProyecciones(CvePS As Integer, Cantidad As Double, PU As Double, Fecha As Date, CveVentaProyeccion As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Finan_MetasUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@Cantidad", SqlDbType.Money).Value = Cantidad + .Add("@PU", SqlDbType.Money).Value = PU + .Add("@Fecha", SqlDbType.DateTime).Value = Fecha + .Add("@CveVentaProyeccion", SqlDbType.Int).Value = CveVentaProyeccion + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + + Catch ex As SqlException + If ex.Number = 50000 Then + OnError("No se puede registrar la Proyección de Venta porque ya existe", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + OnError("Ocurrió un error al actualizar la Proyección de Venta.", ex) + End Try + + Return Retorno + + End Function + + Public Function RemoveFinan_VentasProyecciones(CveVentaProyeccion As Integer) As Boolean + Dim Retorno As Boolean = False + + If CveVentaProyeccion <= 0 Then + Return False + End If + + DataAdapter("PA_Finan_MetasRemove") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVentaProyeccion", SqlDbType.Int).Value = CveVentaProyeccion + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar el movimiento en la Proyección de Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetFinan_VentasProyecciones(CveVentaProyeccion As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + If CveVentaProyeccion <= 0 Then + Return False + End If + + DataAdapter("PA_Finan_MetasGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVentaProyeccion", SqlDbType.Int).Value = CveVentaProyeccion + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener la Proyección de Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +#End Region + +#Region "F I N A N C I A M I E N T O S - C U E N T A S" + Public Function AddFinan_Cuentas(Cuenta As String, IdCtaContable As Integer, TipoInformacion As Integer, TipoCuenta As Integer, CveCuentaPadre As Integer, Orden As Integer, Nivel As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_Finan_CuentasAdd") + With SqlAdapter.SelectCommand.Parameters + .Add("@Cuenta", SqlDbType.Money).Value = Cuenta + .Add("@IdCtaContable", SqlDbType.Int).Value = IdCtaContable + .Add("@TipoInformacion", SqlDbType.TinyInt).Value = TipoInformacion + .Add("@TipoCuenta", SqlDbType.TinyInt).Value = TipoCuenta + .Add("@CveCuentaPadre", SqlDbType.Int).Value = CveCuentaPadre + .Add("@Orden", SqlDbType.Int).Value = Orden + .Add("@Nivel", SqlDbType.Int).Value = Nivel + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar la Cuenta", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function UpdateFinan_Cuentas(Cuenta As Decimal, IdCtaContable As Integer, TipoInformacion As Integer, TipoCuenta As Integer, CveCuentaPadre As Integer, Orden As Integer, Nivel As Integer, CveCuenta As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Finan_CuentasUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Cuenta", SqlDbType.Money).Value = Cuenta + .Add("@IdCtaContable", SqlDbType.Int).Value = IdCtaContable + .Add("@TipoInformacion", SqlDbType.TinyInt).Value = TipoInformacion + .Add("@TipoCuenta", SqlDbType.TinyInt).Value = TipoCuenta + .Add("@CveCuentaPadre", SqlDbType.Int).Value = CveCuentaPadre + .Add("@Orden", SqlDbType.Int).Value = Orden + .Add("@Nivel", SqlDbType.Int).Value = Nivel + .Add("@CveCuenta", SqlDbType.Int).Value = CveCuenta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + + Catch ex As SqlException + If ex.Number = 50000 Then + OnError("No se puede registrar la Cuenta porque ya existe", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + OnError("Ocurrió un error al actualizar la Cuenta.", ex) + End Try + + Return Retorno + + End Function + Public Function RemoveFinan_Cuentas(CveCuenta As Integer) As Boolean + Dim Retorno As Boolean = False + + If CveCuenta <= 0 Then + Return False + End If + + DataAdapter("PA_Finan_CuentasRemove") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCuenta", SqlDbType.Int).Value = CveCuenta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar el movimiento en la Cuenta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function GetFinan_Cuentas(CveCuenta As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + If CveCuenta <= 0 Then + Return False + End If + + DataAdapter("PA_Finan_CuentasGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCuenta", SqlDbType.Int).Value = CveCuenta + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener la Cuenta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + +#End Region + + + + +#Region " CONTABILIDAD SIG " + + +#Region " CUENTAS " + Public Function GetCuentas(CveCuenta As Integer, Codigo As String, Afectable As Integer, CveEmpresa As Integer, Optional RowNum As Integer = 100000, Optional CvePadre As Integer = -1) As Boolean ', Codigo As String, Nombre As String, CveClasificacionCuenta As Integer, TipoCuenta As Integer, Afectable As Integer, Estatus As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_CuentasGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCuenta", SqlDbType.Int).Value = CveCuenta + .Add("@Codigo", SqlDbType.VarChar).Value = Codigo + .Add("@Afectable", SqlDbType.VarChar).Value = Afectable + .Add("@CveEmpresa", SqlDbType.VarChar).Value = CveEmpresa + .Add("@RowNum", SqlDbType.VarChar).Value = RowNum + .Add("@CvePadre", SqlDbType.Int).Value = CvePadre + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al cargar las Cuentas Contables SIG", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetClasificacionesCuentas() As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_ClasificacionesCuentaGet") + With SqlAdapter.SelectCommand.Parameters + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al cargar las Clasificaciones de Cuentas", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +#End Region + + +#Region " EJERCICIOS " + Public Function GetEjercicios(CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_EjerciciosGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al cargar los Ejercicios", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function AddEjercicio(Ejercicio As String, PeriodoActual As Integer, Estatus As Boolean, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_EjerciciosAdd") + With SqlAdapter.SelectCommand.Parameters + .Add("@Ejercicio", SqlDbType.VarChar).Value = Ejercicio + .Add("@PeriodoActual", SqlDbType.Int).Value = PeriodoActual + .Add("@Estatus", SqlDbType.Bit).Value = Estatus + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar el Ejercicio", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function UpdateEjercicio(CveEjercicio As Integer, Ejercicio As String, Estatus As Boolean, CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_EjerciciosUpdate") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEjercicio", SqlDbType.Int).Value = CveEjercicio + .Add("@Ejercicio", SqlDbType.VarChar).Value = Ejercicio + .Add("@Estatus", SqlDbType.Bit).Value = Estatus + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar los ejercicios", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function RemoveEjercicio(CveEjercicio As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_EjerciciosRemove") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEjercicio", SqlDbType.Int).Value = CveEjercicio + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar los ejercicios", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +#End Region + + +#End Region + +#Region "REPORTE DE CONTABILIDAD" + 'Public Function PolizaGet(CvePoliza As Integer) As Boolean + ' Dim Retorno As Boolean = False + + ' 'StrSQL.Clear() + ' 'StrSQL.Append(" SELECT mp.id, mp.IdPoliza, mp.NumMovto, mp.IdCuenta , mp.IdCuenta as CveCuenta, c.CODIGO, c.NOMBRE as Cuenta , T.Codigo as CodigoTipoPoliza, T.Nombre AS TipoPoliza, mp.Folio, mp.Importe, mp.Concepto, mp.Referencia, mp.SIGReferencia, mp.Fecha, mp.IdSegNeg, s.Nombre AS SegNeg, p.Fecha AS FechaPol, p.Cargos, p.Abonos, p.Concepto AS ConceptoPoliza, ") + ' 'StrSQL.Append(" CASE WHEN ISNUMERIC(c.Codigo) = 1 THEN FORMAT(CAST (c.Codigo AS BIGINT),(SELECT REPLACE(Mascarilla,'X','0') FROM Parametros)) ELSE c.Codigo END + ' - ' + c.Nombre + ' ' AS CtaCodigo, ") 'Roberto 8/Nov/2014 + ' 'StrSQL.Append(" SUM (CASE WHEN mp.TipoMovto = 0 THEN mp.Importe ELSE 0 END) AS Cargo, SUM (CASE WHEN mp.TipoMovto = 1 THEN mp.Importe ELSE 0 END) AS Abono, ") + ' 'StrSQL.Append(" SUM (CASE WHEN mp.TipoMovto = 0 THEN mp.ImporteME ELSE 0 END) AS CargoME, SUM (CASE WHEN mp.TipoMovto = 1 THEN mp.ImporteME ELSE 0 END) AS AbonoME, ") + ' 'StrSQL.Append(" mp.TipoMovto, CASE WHEN ISNUMERIC(c.CODIGO) = 1 THEN FORMAT(CAST (c.CODIGO AS BIGINT),(SELECT REPLACE(Mascarilla,'X','0') FROM Parametros)) ELSE c.CODIGO END CuentaFormato, '' as Estado ") + ' 'StrSQL.Append(" FROM MovimientosPoliza mp ") + ' 'StrSQL.Append(" INNER JOIN Polizas p ON mp.IdPoliza = p.Id ") + ' 'StrSQL.Append(" INNER JOIN Cuentas c ON c.Id = mp.IdCuenta ") + ' 'StrSQL.Append(" INNER JOIN TiposPolizas t ON mp.TipoPol = t.Codigo ") + ' 'StrSQL.Append(" LEFT JOIN SegmentosNegocio s ON mp.IdSegNeg = s.id ") + ' 'StrSQL.Append(" WHERE (@IdPoliza = -1 OR mp.IdPoliza = @IdPoliza) ") + ' 'StrSQL.Append(" AND (@Eje = -1 OR mp.Ejercicio = @Eje) ") + ' 'StrSQL.Append(" AND (@Periodo = -1 OR mp.Periodo = @Periodo) ") + ' 'StrSQL.Append(" AND (@TipoPol = -1 OR mp.TipoPol = @TipoPol) ") + ' 'StrSQL.Append(" AND (@NumPol = -1 OR mp.Folio = @NumPol) ") + ' 'StrSQL.Append(" ") + ' 'StrSQL.Append(" GROUP BY mp.id, mp.IdPoliza, mp.NumMovto, mp.IdCuenta, mp.TipoMovto, c.CODIGO, c.NOMBRE, T.Codigo, T.Nombre, mp.Folio, mp.Importe, mp.Concepto, mp.Referencia, mp.SIGReferencia, mp.Fecha, mp.IdSegNeg, s.Nombre, p.Fecha, p.Cargos, p.Abonos, p.Concepto, Afectable ") 'Roberto 8/Nov/2014 campo Afectable + ' 'StrSQL.Append(" ORDER BY mp.NumMovto ") + + ' DataAdapter("PA_Conta_PolizaGet") + + ' 'DataAdapter(StrSQL.ToString, CommandType.Text) + ' With SqlAdapter.SelectCommand.Parameters + ' .Add("@IdPoliza", SqlDbType.Int).Value = CvePoliza + ' '.Add("@Eje", SqlDbType.Int).Value = Ejercicio + ' '.Add("@Periodo", SqlDbType.Int).Value = Periodo + ' '.Add("@TipoPol", SqlDbType.Int).Value = TipoPol + ' '.Add("@NumPol", SqlDbType.Int).Value = NumPol + ' End With + + ' Try + ' SqlAdapter.Fill(Data) + ' Retorno = True + ' Catch ex As Exception + ' OnError("Error al consultar los Movimientos, Auxiliares del Catálogo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + ' End Try + + ' Return Retorno + 'End Function + + Public Function GetBalanceGeneralMensual(ANO As Integer, TipoMovtos As Integer, SubTotales As Integer, CveSubProyecto As String, CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_EstadoResultadosMensual") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Ano", SqlDbType.Int).Value = ANO + .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos + ' .Add("@SubTotales", SqlDbType.Int).Value = SubTotales + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener el Balance General Mensual", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + + + + + Public Function GetBalanceGeneralAnual(ANO As Integer, TipoMovtos As Integer, CveEmpresa As Integer, CveSubProyecto As String) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_BalanceGeneralAnual") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Ano", SqlDbType.Int).Value = ANO + .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener el Balance General Anual", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + + + Public Function GetSituacionFinanciera(FechaI As Date, FechaF As Date, CveEmpresa As Integer, CveSubProyecto As String, TipoMovtos As Integer, Optional SAT As Integer = 0) As Boolean + Dim Retorno = False + + 'SqlAdapter.SelectCommand.t + + DataAdapter("PA_Conta_SituacionFinancieraGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@SAT", SqlDbType.Int).Value = SAT + End With + SqlAdapter.SelectCommand.CommandTimeout = 0 + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener el Estado de Situaci?n de Financiera", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetAnexoCatalogo(IdCuenta As Integer, FechaI As Date, FechaF As Date, OpcionCuentas As Integer, CveSubProyecto As String, CveEmpresa As Integer, Optional TipoMovtos As Integer = -1, Optional SAT As Integer = 0) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_AnexoCatalogoGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@IdCuentaPadre", SqlDbType.Int).Value = IdCuenta + .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos + .Add("@OpcionCuentas", SqlDbType.Int).Value = OpcionCuentas + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@SAT", SqlDbType.Int).Value = SAT + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener el Anexo del Catalogo", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + + Public Function GetMovimientosAuxiliaresCatalogo(IdCuenta As Integer, FechaI As Date, FechaF As Date, CveMoneda As Integer, CveSubProyecto As String, CveEmpresa As Integer, TipoReporte As String) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_MovimientosAuxiliaresCatalogoGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@IdCuentaPadre", SqlDbType.Int).Value = IdCuenta + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@Tipo", SqlDbType.Int).Value = TipoReporte + End With + SqlAdapter.SelectCommand.CommandTimeout = 0 + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener los Movimientos Auxiliares Catalogo", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function PolizaGet(CvePoliza As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Conta_PolizaNewGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePoliza", SqlDbType.Int).Value = CvePoliza + '.Add("@Eje", SqlDbType.Int).Value = Ejercicio + '.Add("@Periodo", SqlDbType.Int).Value = Periodo + '.Add("@TipoPol", SqlDbType.Int).Value = TipoPol + '.Add("@NumPol", SqlDbType.Int).Value = NumPol + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Error al consultar los Movimientos, Auxiliares del Catálogo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function GetEstadoActividades(FechaI As Date, FechaF As Date, TipoMovtos As Integer, CveSubProyecto As String, CveEmpresa As Integer, Optional SAT As Integer = 0) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_EstadoActividadesGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@SAT", SqlDbType.Int).Value = SAT + End With + + SqlAdapter.SelectCommand.CommandTimeout = 0 + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener el Estado de Actividades", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function GetBalanzaComprobacion(FechaI As Date, FechaF As Date, TipoCuentas As Integer, TipoReporte As Integer, CveSubProyecto As String, CveEmpresa As Integer, Optional Sat As Integer = 0) As Boolean + Dim Retorno = False + + + DataAdapter("PA_Conta_BalanzaComprobacionGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@TipoCuentas", SqlDbType.Int).Value = TipoCuentas + .Add("@TipoReporte", SqlDbType.Int).Value = TipoReporte + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@SAT", SqlDbType.Int).Value = Sat + End With + SqlAdapter.SelectCommand.CommandTimeout = 0 + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener Balanza de comprobación", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetCambioSituacionFinanciera(FechaI As Date, FechaF As Date, Unidad As Integer, TipoReporte As Integer, CveSubProyecto As String, CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_RepCambioSituacionFinanciera") + + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@Unidad", SqlDbType.Int).Value = Unidad + .Add("@TipoReporte", SqlDbType.Int).Value = TipoReporte + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener el Estado de Cambio de Situacion Financiera.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function GetFlujoEfectivo(FechaI As Date, FechaF As Date, Unidad As Integer, TipoReporte As Integer, CveSubProyecto As String, CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_RepFlujoEfectivo") + + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@Unidad", SqlDbType.Int).Value = Unidad + .Add("@TipoReporte", SqlDbType.Int).Value = TipoReporte + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener el Estado de Flujo de Efectivo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function GetOrigenAplicacion(FechaI As String, FechaF As String, TipoReporte As Integer, CveSubProyecto As String, CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_RepOrigenAplicacion") + + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@Tipo", SqlDbType.Int).Value = TipoReporte + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener el estado de origen y aplicación.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function GetTiposPoliza(CveTipoPoliza As Integer, TipoPoliza As String, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Conta_TiposPolizasNewGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveTipoPoliza", SqlDbType.Int).Value = CveTipoPoliza + .Add("@TipoPoliza", SqlDbType.Int).Value = TipoPoliza + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener los tipos de Polizas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function GetParametros() As Boolean + Dim Retorno As Boolean = False + + DataAdapter(" SELECT * FROM Parametros ", CommandType.Text) + + Try + SqlAdapter.Fill(Data) + Data.TableName = "Parametros" + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al consultar los parametros.", ex) + End Try + + Return Retorno + End Function + + Public Function GetParametros(CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter(" SELECT * FROM Parametros WHERE IdEmpresa = @CveEmpresa ", CommandType.Text) + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Data.TableName = "Parametros" + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al consultar los parametros.", ex) + End Try + + Return Retorno + End Function + + Public Function GetEstadoResultadosMensual(ANO As Integer, TipoMovtos As Integer, CveSubProyecto As String, CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_EstadoResultadosMensual") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Ano", SqlDbType.Int).Value = ANO + .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener el Estado de Resultados Mensual", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetEstadoResultadosAnual(ANO As Integer, TipoMovtos As Integer, CveSubProyecto As String, CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_EstadoResultadosAnual") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Ano", SqlDbType.Int).Value = ANO + .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener el Estado de Resultados Anual", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function GetOrigenAplicacionMensual(Ejercicio As Integer, TipoMovtos As Integer, CveSubProyecto As String, CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_RepOrigenAplicacionMensual") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Ano", SqlDbType.Int).Value = Ejercicio + .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener el estado de origen y aplicación mensual.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetOrigenAplicacionAnual(Ejercicio As Integer, TipoMovtos As Integer, CveSubProyecto As String, CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_RepOrigenAplicacionAnual") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Ano", SqlDbType.Int).Value = Ejercicio + .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener el estado de origen y aplicación anual.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function GetVariacionHaciendaPublica(FechaI As Date, FechaF As Date, TipoMovtos As Integer, CveSubProyecto As String, CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_RepVariacionHaciendaPublica") + + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@TipoMovtos", SqlDbType.Int).Value = TipoMovtos + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener el Estado de Cambio de Hacienda Publica.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +#End Region + +#Region "I N C O N S I S T E N C I A S" + Public Function GetInconsistencias() As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Sis_InconsistenciasGet") + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener inconsistencias.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + +#End Region + +#Region " REPORTES FINANCIEROS DICIEMBRE 2016 " + Public Function GetBalanceGeneralVertical(Ejercicio As Integer, Periodo As Integer, CveSubProyecto As Integer, TipoMovtos As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_BalanceGeneralVerticalGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Ejercicio", SqlDbType.Int).Value = Ejercicio + .Add("@Periodo", SqlDbType.Int).Value = Periodo + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener el Balance General Vertical", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function GetBalanceGeneralMensualVertical(Ejercicio As Integer, CveSubProyecto As Integer, TipoMovtos As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_BalanceGeneralVerticalMensualGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Ejercicio", SqlDbType.Int).Value = Ejercicio + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener el Balance General Vertical Mensual", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function GetBalanceGeneralAnualVertical(Ejercicio As Integer, CveSubProyecto As Integer, TipoMovtos As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_BalanceGeneralAnualGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Ejercicio", SqlDbType.Int).Value = Ejercicio + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(DSet) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener el Balance General Vertical Anual", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetBalanceGeneralMensualHorizontal(Ejercicio As Integer, CveSubProyecto As Integer, TipoMovtos As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_BalanceGeneralHorizontalMensualGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Ejercicio", SqlDbType.Int).Value = Ejercicio + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener el Balance General Horizontal Mensual", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetBalanceGeneralHorizontalCC(Ejercicio As Integer, Periodo As Integer, CveSubProyecto As Integer, TipoMovtos As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_BalanceGeneralHorizontalCCGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Ejercicio", SqlDbType.Int).Value = Ejercicio + .Add("@Periodo", SqlDbType.Int).Value = Periodo + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(DSet) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener el Balance General Horizontal CC", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function GetEstadoResultadosVertical(Ejercicio As Integer, Periodo As Integer, CveSubProyecto As Integer, TipoMovtos As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_EstadoResultadosVerticalGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Ejercicio", SqlDbType.Int).Value = Ejercicio + .Add("@Periodo", SqlDbType.Int).Value = Periodo + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener el Balance General Vertical", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function GetEstadoResultadoMensualHorizontal(Ejercicio As Integer, CveSubProyecto As Integer, TipoMovtos As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_EstadoResultadosHorizontalMensual") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Ejercicio", SqlDbType.Int).Value = Ejercicio + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener el Estado Resultados Horizontal Mensual", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetEstadoResultadosAnualHorizontal(Ejercicio As Integer, CveSubProyecto As Integer, TipoMovtos As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_EstadoResultadosHorizontalAnual") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Ejercicio", SqlDbType.Int).Value = Ejercicio + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(DSet) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener el Estado Resultados Horizontal Anual", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + + Public Function GetEstadoResultadosHorizontalCC(Ejercicio As Integer, Periodo As Integer, CveSubProyecto As Integer, TipoMovtos As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_EstadoResultadosHorizontalCCGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Ejercicio", SqlDbType.Int).Value = Ejercicio + .Add("@Periodo", SqlDbType.Int).Value = Periodo + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(DSet) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener el Estado Resultados Horizontal CC", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetAnexoCatalogoMensual(CveCuenta As Integer, Ejercicio As Integer, CveSubproyecto As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_AnexoCatalogoMensualGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCuenta", SqlDbType.Int).Value = CveCuenta + .Add("@Ejercicio", SqlDbType.Int).Value = Ejercicio + .Add("@CveSubproyecto", SqlDbType.Int).Value = CveSubproyecto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener el Estado Resultados Horizontal CC", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function GetAnexoCatalogoAnual(CveCuenta As Integer, Ejercicio As Integer, CveSubproyecto As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_AnexoCatalogoAnualGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCuenta", SqlDbType.Int).Value = CveCuenta + .Add("@Ejercicio", SqlDbType.Int).Value = Ejercicio + .Add("@CveSubproyecto", SqlDbType.Int).Value = CveSubproyecto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(DSet) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener el Estado Resultados Horizontal CC", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function GetAnexoCatalagoCC(CveCuenta As Integer, Ejercicio As Integer, CveSubproyecto As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_AnexoCatalogoCCGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCuenta", SqlDbType.Int).Value = CveCuenta + .Add("@Ejercicio", SqlDbType.Int).Value = Ejercicio + .Add("@CveSubproyecto", SqlDbType.Int).Value = CveSubproyecto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(DSet) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener el Estado Resultados Horizontal CC", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function GetRepPresupuestosEgresosSaldosDetalle(MomentoContable As Integer, ProgramaOperativo As Integer, FuenteFinanciamiento As Integer, TipoGasto As Integer, UnidadAdministrativa As Integer, ClasificacionOG As Integer, CodigoOG As String, FechaI As Date, FechaF As Date) As Boolean + Dim Retorno = False + + DataAdapter("PA_PresupuestosEgresosSaldosDetalleRep") + + With SqlAdapter.SelectCommand.Parameters + .Add("@MomentoContable", SqlDbType.Int).Value = MomentoContable + .Add("@ProgramaOperativo", SqlDbType.Int).Value = ProgramaOperativo + .Add("@FuenteFinanciamiento", SqlDbType.Int).Value = FuenteFinanciamiento + .Add("@TipoGasto", SqlDbType.Int).Value = TipoGasto + .Add("@UnidadAdministrativa", SqlDbType.Int).Value = UnidadAdministrativa + .Add("@ClasificacionOG", SqlDbType.Int).Value = ClasificacionOG + .Add("@CodigoOG", SqlDbType.VarChar).Value = CodigoOG + + .Add("@FI", SqlDbType.Date).Value = FechaI + .Add("@FF", SqlDbType.Date).Value = FechaF + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener los Movimientos Auxiliares Presupuestales", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function GetRepPresupuestosIngresosSaldosDetalle(MomentoContable As Integer, FuenteRecaudacion As Integer, RubroIngreso As Integer, FechaI As Date, FechaF As Date, CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_PresupuestosIngresosSaldosDetalleRep") + + With SqlAdapter.SelectCommand.Parameters + .Add("@MomentoContable", SqlDbType.Int).Value = MomentoContable + .Add("@FuenteRecaudacion", SqlDbType.Int).Value = FuenteRecaudacion + .Add("@RubroIngreso", SqlDbType.Int).Value = RubroIngreso + .Add("@FI", SqlDbType.Date).Value = FechaI + .Add("@FF", SqlDbType.Date).Value = FechaF + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener los Movimientos Auxiliares Presupuestales", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function GetPresupuestoIngresosRep(Ejercicio As Integer, Fecha As Date, Gpo As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_PresupuestosIngresosRep") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Ejercicio", SqlDbType.Int).Value = Ejercicio + .Add("@Fecha", SqlDbType.Date).Value = Fecha + .Add("@Gpo", SqlDbType.Int).Value = Gpo + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener el reporte de los presupuestos de ingresos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function GetRepPresupuestosEgresosSaldosMensual(TipoCuenta As String, Ejercicio As Integer, Capitulo As String, CveClasificacion As Integer, CveFuenteFinanciamiento As Integer, CveProgramaOperativo As Integer, CveUnidadAdministrativa As Integer, Gpo As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_PresupuestosEgresosSaldosMensualRep") + + With SqlAdapter.SelectCommand.Parameters + .Add("@TipoCuenta", SqlDbType.VarChar).Value = TipoCuenta + .Add("@Ejercicio", SqlDbType.Int).Value = Ejercicio + .Add("@Capitulo", SqlDbType.VarChar).Value = Capitulo + .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion + .Add("@CveFuenteFinanciamiento", SqlDbType.Int).Value = CveFuenteFinanciamiento + .Add("@CveProgramaOperativo", SqlDbType.Int).Value = CveProgramaOperativo + .Add("@CveUnidadAdministrativa", SqlDbType.Int).Value = CveUnidadAdministrativa + .Add("@GPO", SqlDbType.Int).Value = Gpo + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Reporte de Presupuestos de Egresos Mensual.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function GetPresupuestoIngresosMensualesRep(Ejercicio As Integer, MomentoContable As Integer, CveFuenteRecaudacion As Integer, CveRubroIngreso As Integer, GPO As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_PresupuestosIngresosMensualesRep") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Ejercicio", SqlDbType.Int).Value = Ejercicio + '.Add("@Fecha", SqlDbType.Date).Value = Fecha + .Add("@MomentoContable", SqlDbType.Int).Value = MomentoContable + .Add("@CveFuenteRecaudacion", SqlDbType.Int).Value = CveFuenteRecaudacion + .Add("@CveRubroIngreso", SqlDbType.Int).Value = CveRubroIngreso + .Add("@GPO", SqlDbType.Int).Value = GPO + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener eL reporte de los presupuestos de ingresos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function GetDependenciasUnidadesResponsables(CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_DepUnidadResponsableGET") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener eL reporte de los presupuestos de ingresos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function GetProgramaSubPrograma(CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_ProGSubProgramaGET") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener eL reporte de los presupuestos de ingresos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function GetGrupoVulnerable(CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_GrupoVulnerable") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener eL reporte de los presupuestos de ingresos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function GetTipoGasto(CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_AC_TipoGastoGet") + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener eL reporte de los presupuestos de ingresos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function GetClasificadorOG(CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_AC_ClasificadorOGGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener eL reporte de los presupuestos de ingresos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function GetClasificacion(CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_ClasificacionGET") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener eL reporte de los presupuestos de ingresos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function GetClasificacionEconomica(CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_ClasificacionEconomicaGET") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener eL reporte de los presupuestos de ingresos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function GetFuenteFinanciera(CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_AC_FuentesFinanciamientoGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener eL reporte de los presupuestos de ingresos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function GetMonedas() As Boolean + Dim Retorno As Boolean = False + + DataAdapter(" SELECT * FROM Monedas ".ToString, CommandType.Text) + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al consultar las Monedas.", ex) + End Try + + Return Retorno + End Function + + Public Function GetAgrupadoresSAT(CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter(" SELECT CveAgrupadorSAT, Codigo + REPLICATE(' ', 10 - len(Codigo)) + ' - ' + Nombre AS CodigoNombre FROM AgrupadoresSAT where CveEmpresa= '" & CveEmpresa & "'", CommandType.Text) + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al consultar los Agrupadores SAT.", ex) + End Try + + Return Retorno + + End Function + Public Function UpdateCuenta(CveCuenta As Integer, Nombre As String, Tipo As String, CtaMayor As Integer, CveMoneda As Integer, Optional DigAgrupador As Integer = -1, Optional CveAgrupadorSAT As Integer = -1, Optional NomIdioma As String = "") As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Conta_UpdateCuentas") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCuenta", SqlDbType.Int).Value = CveCuenta + .Add("@Nombre", SqlDbType.VarChar).Value = Nombre + .Add("@Tipo", SqlDbType.VarChar).Value = Tipo + .Add("@CtaMayor", SqlDbType.Int).Value = CtaMayor + .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda + .Add("@DigAgrupador", SqlDbType.Int).Value = DigAgrupador + .Add("@NomIdioma", SqlDbType.VarChar).Value = NomIdioma + .Add("@CveAgrupadorSAT", SqlDbType.Int).Value = CveAgrupadorSAT + + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + Me.OnError("Ocurrió un error al Guardar la cuenta.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + Catch ex As Exception + Me.OnError("Ocurrió un error al Guardar la cuenta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function AddCuenta(CvePadre As Integer, Codigo As String, Nombre As String, Tipo As String, CtaMayor As Integer, CveMoneda As Integer, Optional DigAgrupador As Integer = -1, Optional CveAgrupadorSAT As Integer = -1, Optional NomIdioma As String = "") As Integer + Dim Retorno As Integer = 0 + DataAdapter("PA_Conta_AddCuentas") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePadre", SqlDbType.Int).Value = CvePadre + .Add("@Codigo", SqlDbType.VarChar).Value = Codigo + .Add("@Nombre", SqlDbType.VarChar).Value = Nombre + .Add("@Tipo", SqlDbType.VarChar).Value = Tipo + .Add("@CtaMayor", SqlDbType.Int).Value = CtaMayor + .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda + .Add("@DigAgrupador", SqlDbType.Int).Value = DigAgrupador + .Add("@NomIdioma", SqlDbType.VarChar).Value = NomIdioma + .Add("@CveAgrupadorSAT", SqlDbType.Int).Value = CveAgrupadorSAT + '.Add("@CveCuenta", SqlDbType.Int).Value = 0 + '.Add("@Error", SqlDbType.VarChar).Value = "" + '.Add("@Error", SqlDbType.VarChar).Direction = ParameterDirection.Output + .Add("@CveCuenta", SqlDbType.Int).Direction = ParameterDirection.Output + End With + Try + SqlAdapter.Fill(Data) + Retorno = SqlAdapter.SelectCommand.Parameters("@CveCuenta").Value.ToString.ToEntero + 'Retorno = If(Data IsNot Nothing AndAlso Data.Rows.Count > 0, Data.Rows(0)("CveCuenta").ToString.ToEntero, 0) + Catch Ex1 As SqlException + Me.OnError("Ocurrió un error al Guardar la cuenta.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + Catch ex As Exception + Me.OnError("Ocurrió un error al Guardar la cuenta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function RemoveCuenta(CveCuenta As Integer) As Boolean + Dim Retorno As Boolean = False + + If CveCuenta <= 0 Then + Return False + End If + + DataAdapter("PA_Conta_RemoveCuentas") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCuenta", SqlDbType.Int).Value = CveCuenta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar la cuenta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function UpdateCuentaCompaq(CveCuenta As Integer, IdCompaq As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Conta_UpdateCuentasCompaq") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCuenta", SqlDbType.Int).Value = CveCuenta + .Add("@IdCompaq", SqlDbType.Int).Value = IdCompaq + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + Me.OnError("Ocurrió un error al actualizar la cuenta.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + Catch ex As Exception + Me.OnError("Ocurrió un error al actualizar la cuenta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetSaldoCuenta(IdCuenta As Integer, TipoMovto As Integer, Ejercicio As Integer) As Boolean + Dim Retorno As Boolean + + If TipoMovto = 0 Then + DataAdapter(String.Format("SELECT SUM(CASE WHEN TipoMovto = 1 THEN -1 ELSE 1 END * Importe) AS Saldo from Conta_PolizasDetalle CD inner join Conta_Polizas CP on CP.CvePoliza=CD.CvePoliza and year(CP.Fecha)={1} WHERE CveCuenta = {0}", IdCuenta, Ejercicio), CommandType.Text) + Else + DataAdapter(String.Format("SELECT SUM(CASE WHEN TipoMovto = 0 THEN -1 ELSE 1 END * Importe) AS Saldo from Conta_PolizasDetalle CD inner join Conta_Polizas CP on CP.CvePoliza=CD.CvePoliza and year(CP.Fecha)={1} WHERE CveCuenta = {0} ", IdCuenta, Ejercicio), CommandType.Text) + End If + + Try + SqlAdapter.Fill(Data) + 'Retorno = Math.Round(SqlCommand.ExecuteScalar.ToString.ToDouble, 2) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener eL saldo de la cuenta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function GetRepPresupuestosEgresosSaldos(Ejercicio As Integer, Fecha As Date, Capitulo As String, CveClasificacion As Integer, CveFuenteFinanciamiento As Integer, CveProgramaOperativo As Integer, CveUnidadAdministrativa As Integer, CveTipoGasto As Integer, Gpo As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_PresupuestosEgresosSaldosRep") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Ejercicio", SqlDbType.Int).Value = Ejercicio + .Add("@Fecha", SqlDbType.Date).Value = Fecha + .Add("@Capitulo", SqlDbType.VarChar).Value = Capitulo + .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion + .Add("@CveFuenteFinanciamiento", SqlDbType.Int).Value = CveFuenteFinanciamiento + .Add("@CveProgramaOperativo", SqlDbType.Int).Value = CveProgramaOperativo + .Add("@CveUnidadAdministrativa", SqlDbType.Int).Value = CveUnidadAdministrativa + .Add("@CveTipoGasto", SqlDbType.Int).Value = CveTipoGasto + .Add("@GPO", SqlDbType.Int).Value = Gpo + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Reporte de Presupuestos de Egresos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function GetRepPresupuestosEgresosSaldosDetalle(MomentoContable As Integer, ProgramaOperativo As Integer, FuenteFinanciamiento As Integer, TipoGasto As Integer, UnidadAdministrativa As Integer, ClasificacionOG As Integer, CodigoOG As String, FechaI As Date, FechaF As Date, CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_PresupuestosEgresosSaldosDetalleRep") + + With SqlAdapter.SelectCommand.Parameters + .Add("@MomentoContable", SqlDbType.Int).Value = MomentoContable + .Add("@ProgramaOperativo", SqlDbType.Int).Value = ProgramaOperativo + .Add("@FuenteFinanciamiento", SqlDbType.Int).Value = FuenteFinanciamiento + .Add("@TipoGasto", SqlDbType.Int).Value = TipoGasto + .Add("@UnidadAdministrativa", SqlDbType.Int).Value = UnidadAdministrativa + .Add("@ClasificacionOG", SqlDbType.Int).Value = ClasificacionOG + .Add("@CodigoOG", SqlDbType.VarChar).Value = CodigoOG + .Add("@FI", SqlDbType.Date).Value = FechaI + .Add("@FF", SqlDbType.Date).Value = FechaF + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener los Movimientos Auxiliares Presupuestales", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function GetGeneraPolizaPresupuestoEgresos(CveEmpresa As Integer, CveEjercicio As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_GeneraPolizaPresupuestoEgresos") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@Ejercicio", SqlDbType.Int).Value = CveEjercicio + .Add("@Error", SqlDbType.Int).Direction = ParameterDirection.Output + End With + + Try + SqlAdapter.Fill(Data) + If SqlAdapter.SelectCommand.Parameters("@Error").Value.ToString.ToEntero = 0 Then + Retorno = True + Else + Retorno = False + End If + Catch ex As Exception + Me.OnError("Ocurrió un error al generar la poliza de egresos", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function Conta_ContabilizaPrePoliza(CvePrepoliza As Integer, Ejercicio As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_ContabilizaPrepolizas") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePrepoliza", SqlDbType.Int).Value = CvePrepoliza + .Add("@Ejercicio", SqlDbType.Int).Value = Ejercicio + .Add("@Error", SqlDbType.Int).Direction = ParameterDirection.Output + End With + + Try + SqlAdapter.Fill(Data) + If SqlAdapter.SelectCommand.Parameters("@Error").Value.ToString.ToEntero = 0 Then + Retorno = True + Else + Retorno = False + End If + Catch ex As Exception + Me.OnError("Ocurrió un error al contabilizar la prepoliza", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function Conta_CompactaPrePoliza(CvePrepoliza As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_Comp_CompactaPrepoliza") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrepoliza + .Add("@Error", SqlDbType.Int).Direction = ParameterDirection.Output + End With + + Try + SqlAdapter.Fill(Data) + If SqlAdapter.SelectCommand.Parameters("@Error").Value.ToString.ToEntero = 0 Then + Retorno = True + Else + Retorno = False + End If + Catch ex As Exception + Me.OnError("Ocurrió un error al contabilizar la prepoliza", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function Conta_GeneraPptarias(CveCompra As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_GeneraPptarias") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCompra", SqlDbType.Int).Value = CveCompra + .Add("@Error", SqlDbType.Int).Direction = ParameterDirection.Output + End With + + Try + SqlAdapter.Fill(Data) + If SqlAdapter.SelectCommand.Parameters("@Error").Value.ToString.ToEntero = 0 Then + Retorno = True + Else + Retorno = False + End If + Catch ex As Exception + Me.OnError("Ocurrió un error al Generar las Cuentas Presupuestarias", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function AddConta_Poliza(CveTipoPoliza As Integer, CveEjercicio As Integer, Folio As Integer, FechaPoliza As Date, Concepto As String, CveUsuario As Integer, CveEmpresa As Integer) As Integer + Dim Retorno As Integer = 0 + + DataAdapter("PA_Add_Conta_Polizas") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Folio", SqlDbType.Int).Value = Folio + ' .Add("@CveTipoPoliza", SqlDbType.Int).Value = CveTipoPoliza + .Add("@Ejercicio", SqlDbType.Int).Value = CveEjercicio + .Add("@Concepto", SqlDbType.VarChar).Value = Concepto + .Add("@FechaPoliza", SqlDbType.DateTime).Value = FechaPoliza + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CvePoliza", SqlDbType.Int).Direction = ParameterDirection.Output + End With + Try + SqlAdapter.Fill(Data) + Retorno = SqlAdapter.SelectCommand.Parameters("@CvePoliza").Value.ToString.ToEntero + Catch ex As Exception + OnError("Ocurrió un error al agregar la poliza", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function AddConta_PolizaDetalle(CvePoliza As Integer, CveCuenta As Integer, TipoMovto As Boolean, Importe As Double, Referencia As String, + Concepto As String, FechaMovto As Date, CveUsuario As Integer, Optional ImporteMonedaExtranjera As Double = 0) As Boolean + Dim Retorno As Boolean = False + + If CvePoliza <= 0 Or CveCuenta <= 0 Then + Return False + End If + + + DataAdapter("PA_Add_Conta_PolizasDetalles") + 'DataAdapter("PA_Conta_PolizasDetalleAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePoliza", SqlDbType.Int).Value = CvePoliza + .Add("@CveCuenta", SqlDbType.Int).Value = CveCuenta + .Add("@TipoMovto", SqlDbType.Int).Value = TipoMovto + .Add("@Total", SqlDbType.Money).Value = Math.Round(Importe, 2) + .Add("@ImporteME", SqlDbType.Money).Value = ImporteMonedaExtranjera + .Add("@Referencia", SqlDbType.VarChar).Value = Referencia + .Add("@Concepto", SqlDbType.VarChar).Value = Concepto + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@Error", SqlDbType.Int).Direction = ParameterDirection.Output + End With + + Try + SqlAdapter.Fill(Data) + If SqlAdapter.SelectCommand.Parameters("@Error").Value.ToString.ToEntero <> 0 Then + Retorno = False + Else + Retorno = True + End If + Catch ex As Exception + OnError("Ocurrió un error al agregar el movimiento en la póliza.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function GetSaldoCuentaAC(TipoMovto As Integer, CveCuentaAprobado As Integer, CveCuentaDevengado As Integer, Ejercicio As Integer) As Decimal + Dim Retorno As Decimal + DataAdapter("PA_Conta_CalculaSaldo") + With SqlAdapter.SelectCommand.Parameters + .Add("@TipoMovto", SqlDbType.Int).Value = TipoMovto + .Add("@CveCuentaAprobado", SqlDbType.Int).Value = CveCuentaAprobado + .Add("@CveCuentaDevengado", SqlDbType.Int).Value = CveCuentaDevengado + .Add("@Ejercicio", SqlDbType.Int).Value = Ejercicio + .Add("@Saldo", SqlDbType.Money).Direction = ParameterDirection.Output + End With + Try + SqlAdapter.Fill(Data) + Retorno = SqlAdapter.SelectCommand.Parameters("@Saldo").Value.ToString.ToDecimal + 'Retorno = True 'SqlAdapter.SelectCommand.Parameters("@Saldo").Value.ToString.ToEntero + Catch ex As Exception + Retorno = 0 + OnError("Ocurrió un error al obtener el saldo de cuenta", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + + Public Function GetSegmentosNegocio(Id As Integer, Codigo As String) As Boolean + Dim Retorno As Boolean = False + Dim StrSQl = New StringBuilder + + StrSQl.Clear() + StrSQl.Append(" SELECT Id, RTRIM (LTRIM (Codigo)) AS Codigo, Nombre, '' AS CveProyecto, '' AS CveSubProyecto ") + StrSQl.Append(" FROM SegmentosNegocio ") + StrSQl.Append(" WHERE (@Id = -1 OR Id = @Id) ") + StrSQl.Append(" AND (@Codigo = '-1' OR Codigo = @Codigo) ") + + DataAdapter(StrSQl.ToString, CommandType.Text) + SqlAdapter.SelectCommand.Parameters.Add("@Id", SqlDbType.Int).Value = Id + SqlAdapter.SelectCommand.Parameters.Add("@Codigo", SqlDbType.VarChar).Value = Codigo + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al consultar los Segmentos de Negocio.", ex) + End Try + + Return Retorno + End Function + + Public Function GetSubProyectos(CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + Dim StrSQl = New StringBuilder + + DataAdapter("PA_Comp_Compras_Pptarias") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + SqlAdapter.Fill(Data) + Retorno = True + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al consultar los Segmentos de Negocio.", ex) + End Try + + Return Retorno + End Function + + Public Function GetNumeroPoliza(CveTipoPoliza As Integer, Tipo As String, Fecha As DateTime, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Conta_GetNumPoliza") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveTipoPoliza", SqlDbType.Int).Value = CveTipoPoliza + .Add("@Tipo", SqlDbType.VarChar).Value = Tipo + .Add("@Fecha", SqlDbType.DateTime).Value = Fecha + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener el número de poliza", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function Compras_Pptarias(CveCompra As Integer, Importe As Decimal, CveConceptoContable As Integer) As Boolean + + Dim Retorno As Boolean = False + + DataAdapter("PA_Comp_Compras_Pptarias") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCompra", SqlDbType.Int).Value = CveCompra + .Add("@Importe", SqlDbType.Decimal).Value = Importe + .Add("@CveConceptoContable", SqlDbType.Int).Value = CveConceptoContable + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex1 As SqlException + OnError("Ocurrió un error al obtener las Plantillas", ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + Catch ex As Exception + OnError("Ocurrió un error al obtener las Plantillas", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function +#End Region + +#Region "FIS IMPUESTOS" + + Public Function GetFisImpuestos(CveImpuesto As Integer, CveImpuestoTipo As Integer, CveProveedor As Integer, Folio As String, CveEmpresa As Integer, FechaInicio As Date, FechaFin As Date) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_FisImpuestosGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveImpuesto", SqlDbType.Int).Value = CveImpuesto + .Add("@CveImpuestoTipo", SqlDbType.Int).Value = CveImpuestoTipo + .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor + .Add("@Folio", SqlDbType.VarChar).Value = Folio + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio + .Add("@FechaFin", SqlDbType.Date).Value = FechaFin + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener el catalogo de impuestos", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetFisImpuestosDetalle(CveImpuesto As Integer, CveImpuestoTipo As Integer, CveProveedor As Integer, Folio As String, CveEmpresa As Integer, FechaInicio As Date, FechaFin As Date) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_FisImpuestosDetalleGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveImpuesto", SqlDbType.Int).Value = CveImpuesto + .Add("@CveImpuestoTipo", SqlDbType.Int).Value = CveImpuestoTipo + .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor + .Add("@Folio", SqlDbType.VarChar).Value = Folio + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio + .Add("@FechaFin", SqlDbType.Date).Value = FechaFin + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener el catalogo de impuestos", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function AddUpdateFisImpuestos(CveImpuesto As Integer, CveImpuestoTipo As Integer, CvePrePoliza As Integer, CveProveedor As Integer, Fecha As Date, Folio As String, Comprobante As String, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_FisImpuestosAddUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveImpuesto", SqlDbType.Int).Value = CveImpuesto + .Add("@CveImpuestoTipo", SqlDbType.Int).Value = CveImpuestoTipo + .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza + .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor + .Add("@Fecha", SqlDbType.Date).Value = Fecha + '.Add("@Importe", SqlDbType.Money).Value = Importe + '.Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones + '.Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda + .Add("@Folio", SqlDbType.VarChar).Value = Folio + .Add("@Comprobante", SqlDbType.VarChar).Value = Comprobante + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + If CveImpuesto = -1 Then + Me.OnError("Ocurrió un error al agregar el impuesto", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + Else + Me.OnError("Ocurrió un error al actualizar el impuesto", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + + End Try + + Return Retorno + End Function + + 'Public Function RemoveFisImpuestos(CveImpuesto As Integer, CveEmpresa As Integer) As Boolean + ' Dim Retorno = False + + ' DataAdapter("PA_Fis_ImpuestosRemove") + + ' With SqlAdapter.SelectCommand.Parameters + ' .Add("@CveImpuesto", SqlDbType.Int).Value = CveImpuesto + ' .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + ' End With + + ' Try + ' SqlAdapter.Fill(Data) + ' Retorno = True + ' Catch ex As Exception + ' Me.OnError("Ocurrió un error al eliminar el impuesto", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + ' End Try + + ' Return Retorno + 'End Function + + Public Function GetFisImpuestosTipos(Estatus As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_Fis_ImpuestosTiposGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Estatus", SqlDbType.Int).Value = Estatus + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener el catalogo de ", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + +#End Region + +#Region "Contabilidad Electronica" + Public Function GetCuentasElectronica(CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_ContaElectronicaCuentasGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener el catalogo de cuentas", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetBalanzaComprobacion(FechaI As Date, FechaF As Date, CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_ContaElectronicaBalanzaGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener la balanza", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +#End Region + +#Region "Estado de Situacion Financiera" + Public Function GetSituacionFinanciera(FechaI As Date, FechaF As Date, CveEmpresa As Integer, Optional TipoMovtos As Integer = -1) As Boolean + Dim Retorno = False + + DataAdapter("PA_SituacionFinancieraGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrio un error al obtener el Estado de Situacion de Financiera", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetBalanceGeneralMensual(ANO As Integer, TipoMovtos As Integer, SubTotales As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_BalanceGeneralMensual") + + With SqlAdapter.SelectCommand.Parameters + .Add("@ANO", SqlDbType.Int).Value = ANO + .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos + .Add("@SubTotales", SqlDbType.Int).Value = SubTotales + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener el Balance General Mensual", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetBalanceGeneralAnual(ANO As Integer, TipoMovtos As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_BalanceGeneralAnual") + + With SqlAdapter.SelectCommand.Parameters + .Add("@ANO", SqlDbType.Int).Value = ANO + .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener el Balance General Anual", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetBalanzaComprobacion(FechaI As Date, FechaF As Date, TipoCuentas As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_BalanzaComprobacionPymeGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@TipoCuentas", SqlDbType.Int).Value = TipoCuentas + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener Balanza de comprobación", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetEstadoActividades(FechaI As Date, FechaF As Date, CveEmpresa As Integer, Optional TipoMovtos As Integer = -1) As Boolean + Dim Retorno = False + + DataAdapter("PA_EstadoActividadesGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener el Estado de Actividades", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetEstadoResultadosMensual(ANO As Integer, TipoMovtos As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_EstadoResultadosMensualPyme") + + With SqlAdapter.SelectCommand.Parameters + .Add("@ANO", SqlDbType.Int).Value = ANO + .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener el Estado de Resultados Mensual", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetEstadoResultadosAnual(ANO As Integer, TipoMovtos As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_EstadoResultadosAnualPyme") + + With SqlAdapter.SelectCommand.Parameters + .Add("@ANO", SqlDbType.Int).Value = ANO + .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener el Estado de Resultados Anual", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +#End Region + +#Region "A N E X O - D E L - C A T A L O G O" + Public Function GetAnexoCatalogo(IdCuenta As Integer, FechaI As Date, FechaF As Date, OpcionCuentas As Integer, CveEmpresa As Integer, Optional TipoMovtos As Integer = -1) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_AnexoCatalogo") + + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@IdCuentaPadre", SqlDbType.Int).Value = IdCuenta + .Add("@OpcionCuentas", SqlDbType.Int).Value = OpcionCuentas + .Add("@Tipo", SqlDbType.Int).Value = TipoMovtos + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener el Anexo del Catalogo", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function GetMovimientosAuxiliaresCatalogo(IdCuenta As Integer, FechaI As Date, FechaF As Date, CveMoneda As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_AuxiliarCatalogo") + + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@IdCuentaPadre", SqlDbType.Int).Value = IdCuenta + .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener los Movimientos Auxiliares Catalogo", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +#End Region + +#Region "Cierre Contable" + Public Function GetCuentasCierre(FechaI As Date, FechaF As Date, CveCuentaCierre As Integer, CveEmpresa As Integer, CveUsuario As Integer) As Integer + Dim Retorno = 0 + + DataAdapter("PA_Conta_CierrePolizaCuentasGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@CveCuentaCierre", SqlDbType.Int).Value = CveCuentaCierre + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + End With + + Try + SqlAdapter.Fill(Data) + Retorno = If(Data IsNot Nothing AndAlso Data.Rows.Count > 0, Data.Rows(0)("CvePoliza").ToString.ToEntero, 0) + ContaFolio = If(Data IsNot Nothing AndAlso Data.Rows.Count > 0, Data.Rows(0)("Folio").ToString.ToEntero, 0) + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener las cuentas de cierre", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +#End Region + + Public Function AddSiguienteCuentaHijo(IdCuentaPadre As Integer, NombreCuenta As String, CveEmpresa As Integer, Optional Tipo As String = "A", Optional CuentaMayor As Integer = 2, Optional IdMoneda As Integer = 1, Optional IdAgrupadorSAT As Integer = -1) As Integer + Dim CodigoCuenta As New StringBuilder + Dim Retorno As Integer = -1 + Dim Segmentos() As String = Nothing + + If GetCuentas(-1, "-1", -1, CveEmpresa, CvePadre:=IdCuentaPadre) Then + + If DtResultados.Rows.Count > 0 Then + 'Cuando ya tiene cuentas hijas + + Segmentos = Split(DtResultados.MAX("CuentaFormato"), "-") + 'recorro inverso para detectar el segmento + For i As Integer = Segmentos.Length - 1 To 0 Step -1 + If Segmentos(i).ToEntero <> 0 Then + Segmentos(i) = (Segmentos(i).ToEntero + 1).ToString.PadLeft(Segmentos(i).Length, "0"c) 'Suma uno en el primer token en el que encuentre algo dif de 0 + Exit For + End If + Next + + Else + 'Cuando es el primero hijo de la cuenta + 'obtengo el codigo del padre + If GetCuentas(IdCuentaPadre, "-1", -1, CveEmpresa) Then + Segmentos = Split(DtResultados.MAX("CuentaFormato"), "-") + 'recorro para poner el primer digito en el siguiente segmento al que halla tenido valor > 0 + For i As Integer = 0 To Segmentos.Length - 1 Step 1 + If Segmentos(i).ToEntero = 0 Then + Segmentos(i) = (Segmentos(i).ToEntero + 1).ToString.PadLeft(Segmentos(i).Length, "0"c) 'Suma uno en el primer token en el que encuentre algo dif de 0 + Exit For + End If + Next + End If + + End If + End If + + + For i As Integer = 0 To Segmentos.Length - 1 + CodigoCuenta.Append(Segmentos(i)) 'une tokens + Next + + Retorno = AddCuenta(IdCuentaPadre, CodigoCuenta.ToString, NombreCuenta, Tipo, CuentaMayor, 0, IdMoneda, CveAgrupadorSAT:=IdAgrupadorSAT) + + Return Retorno + End Function + + + Public Function GetGastosRepCC(FechaInicio As DateTime, FechaFin As DateTime, CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_ReporteGastos") + + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaInicio", SqlDbType.DateTime).Value = FechaInicio + .Add("@FechaFin", SqlDbType.DateTime).Value = FechaFin + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener el Estado Resultados Horizontal CC", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + + Public Function GetEdoResultadosMes(FechaInicio As Date, FechaFin As Date, CveTipoGasto As Integer, CveClasificacion As Integer, CveSubProyecto As Integer, Agrupador As Integer, CveEmpresa As Integer, Unidad As Integer) As DataSet + Dim Retorno = False + Dim ds As New DataSet + DataAdapter("PA_Conta_EdoResultado2") + + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio + .Add("@FechaFin", SqlDbType.Date).Value = FechaFin + .Add("@CveTipoGasto", SqlDbType.Int).Value = CveTipoGasto + .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@Agrupador", SqlDbType.Int).Value = Agrupador + .Add("@Unidad", SqlDbType.Int).Value = If(Unidad = 1, 1, If(Unidad = 2, 1000, 1000000)) + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(ds) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener el Balance General Mensual", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return ds + End Function + + Public Function GetEdoResultadosDetalle(FechaInicio As Date, FechaFin As Date, CveTipoGasto As Integer, CveClasificacion As Integer, CveSubProyecto As Integer, CveEmpresa As Integer, Tipo As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Conta_EdoResultado2Detalle") + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio + .Add("@FechaFin", SqlDbType.Date).Value = FechaFin + .Add("@CveTipoGasto", SqlDbType.Int).Value = CveTipoGasto + .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@Tipo", SqlDbType.Int).Value = Tipo + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Balance General detalle.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + +#Region "IVAS" + Public Function GetRepIVA(FechaInicio As Date, FechaFin As Date, Opcion As Integer, CveUsuarioConsulta As Integer, Conciliado As Integer, CveEmpresa As Integer, TipoCambio As Integer, TCEspecifico As Double) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Conta_RepIVA") + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio + .Add("@FechaFin", SqlDbType.Date).Value = FechaFin + .Add("@Opcion", SqlDbType.Int).Value = Opcion + .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta + .Add("@Conciliado", SqlDbType.Int).Value = Conciliado + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@TipoCambio", SqlDbType.Int).Value = TipoCambio + .Add("@TCEspecifico", SqlDbType.Float).Value = TCEspecifico + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el reporte de IVAS.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + + Public Function GetDIOT(FechaInicio As Date, FechaFin As Date, Conciliado As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Conta_GetDIOT") + With SqlAdapter.SelectCommand.Parameters + + .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio + .Add("@FechaFin", SqlDbType.Date).Value = FechaFin + .Add("@Conciliado", SqlDbType.Int).Value = Conciliado + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el DIOT.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + + Public Function GetRepIVAAcumulado(FechaInicio As Date, FechaFin As Date, Conciliado As Integer, TipoImpuesto As Integer, CveUsuarioConsulta As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Conta_IVAAcumulado") + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio + .Add("@FechaFin", SqlDbType.Date).Value = FechaFin + .Add("@TipoImpuesto", SqlDbType.Int).Value = TipoImpuesto + .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta + .Add("@Conciliado", SqlDbType.Int).Value = Conciliado + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el reporte Acumulado IEPS.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + +#End Region + Public Function GetRepIEPS(FechaInicio As Date, FechaFin As Date, TipoOperacion As String, Modalidad As Integer, Limite As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Conta_RepIEPS") + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio + .Add("@FechaFin", SqlDbType.Date).Value = FechaFin + .Add("@TipoOperacion", SqlDbType.VarChar).Value = TipoOperacion + .Add("@Modalidad", SqlDbType.Int).Value = Modalidad + .Add("@Limite", SqlDbType.Int).Value = Limite + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el reporte de IEPS.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + Public Function GetRepIEPSLayoutAnual(Ano As Integer, Tipo As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Conta_RepIEPSLayoutAnual") + With SqlAdapter.SelectCommand.Parameters + .Add("@Ano", SqlDbType.Int).Value = Ano + .Add("@Tipo", SqlDbType.Int).Value = Tipo + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el layout anual de IEPS.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + + Public Function GetAlmacenContable(FechaInicio As Date, FechaFin As Date, CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_AlmacenRepGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaInicio", SqlDbType.DateTime).Value = FechaInicio + .Add("@FechaFin", SqlDbType.DateTime).Value = FechaFin + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener el almacén contable", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + +#Region " RECONSTRUCCION DE PREPOLIZAS " + Public Function ReconstruirPP_PagoCompra(CvePrePoliza As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_AD_PrePolizaReconstruccionPagoCompra") + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al reconstruir la prepoliza de pago de compra.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function ReconstruirPP_Compra(CveCompra As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_AD_PrePolizaReconstruccionCompra") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCompra", SqlDbType.Int).Value = CveCompra + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al reconstruir la prepoliza de compra.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function ReconstruirPP_PagoVenta(CvePrePoliza As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_AD_PrePolizaReconstruccionPagoVenta") + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al reconstruir la prepoliza de pago de venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function ReconstruirPP_PagoCompraVenta(CveIE As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_AD_PrePolizaReconstruccionPagoCompraVenta") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveIE", SqlDbType.Int).Value = CveIE + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al reconstruir la prepoliza de pago de compra/venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + +#End Region + +#Region "VALIDACION POLIZA DESCUADRADA" + Public Function ValidacionPrePolizaCuadre(CvePrePoliza As Integer, Opcion As Integer, Optional CveVenta As Integer = -1) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_PrePoliza_Validacion") + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@Opcion", SqlDbType.Int).Value = Opcion + .Add("@Valor", SqlDbType.Int).Direction = ParameterDirection.Output + .Add("@MsgSalida", SqlDbType.VarChar, 100).Direction = ParameterDirection.Output + .Add("@Diferencia", SqlDbType.Float).Direction = ParameterDirection.Output + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + ValorPolizaDescuadre = SqlAdapter.SelectCommand.Parameters("@Valor").Value.ToString.ToEntero + MensajePolizaDescuadre = SqlAdapter.SelectCommand.Parameters("@MsgSalida").Value.ToString + ValorDiferencia = SqlAdapter.SelectCommand.Parameters("@Diferencia").Value.ToString + Catch ex As Exception + OnError("Ocurrió un error al validar la PrePoliza.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function +#End Region + +#Region "AUXILIAR PREPOLIZAS" + + Public Function GetAuxiliarPrePolizas(FechaI As Date, FechaF As Date, CveSubProyecto As Integer, CveEmpresa As Integer, CveConceptoContable As String, CvePlantillaPoliza As Integer, CveProyecto As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Conta_AuxiliarPrePolizasGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveConceptoContable", SqlDbType.VarChar).Value = CveConceptoContable + .Add("@CvePlantillaPoliza", SqlDbType.Int).Value = CvePlantillaPoliza + .Add("@CveProyecto", SqlDbType.Int).Value = CveProyecto + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el auxiliar de prepolizas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + +#End Region + + +#Region "IDisposable Support" + ' IDisposable + Protected Overridable Sub Dispose(disposing As Boolean) + If Not Me.disposedValue Then + If disposing Then + If Not Data Is Nothing Then Data.Dispose() + If Not SqlAdapter Is Nothing Then SqlAdapter.Dispose() + If Not SqlCommand Is Nothing Then SqlCommand.Dispose() + If Not SqlTransacc Is Nothing Then SqlTransacc.Dispose() + If SqlConexion.State <> ConnectionState.Closed Then SqlConexion.Close() + If Not SqlConexion Is Nothing Then SqlConexion.Dispose() + End If + End If + Me.disposedValue = True + End Sub + Public Sub Dispose() Implements IDisposable.Dispose + Dispose(True) + GC.SuppressFinalize(Me) + End Sub +#End Region +#Region "Periodos Bloqueo Meses" + Public Function GetPeriodosBloqueo(CveEmpresa As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_EmpresasBloqueoMesesGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener el Periodo de Bloqueo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function AddPeriodosBloqueo(CveEmpresa As Integer, Ejercicio As Integer, Mes1 As Integer, Mes2 As Integer, Mes3 As Integer, Mes4 As Integer, Mes5 As Integer, Mes6 As Integer, Mes7 As Integer, Mes8 As Integer, Mes9 As Integer, Mes10 As Integer, Mes11 As Integer, Mes12 As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_EmpresasBloqueoMesesAdd") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@Ejercicio", SqlDbType.Int).Value = Ejercicio + .Add("@Mes1", SqlDbType.Bit).Value = Mes1 + .Add("@Mes2", SqlDbType.Bit).Value = Mes2 + .Add("@Mes3", SqlDbType.Bit).Value = Mes3 + .Add("@Mes4", SqlDbType.Bit).Value = Mes4 + .Add("@Mes5", SqlDbType.Bit).Value = Mes5 + .Add("@Mes6", SqlDbType.Bit).Value = Mes6 + .Add("@Mes7", SqlDbType.Bit).Value = Mes7 + .Add("@Mes8", SqlDbType.Bit).Value = Mes8 + .Add("@Mes9", SqlDbType.Bit).Value = Mes9 + .Add("@Mes10", SqlDbType.Bit).Value = Mes10 + .Add("@Mes11", SqlDbType.Bit).Value = Mes11 + .Add("@Mes12", SqlDbType.Bit).Value = Mes12 + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al agregar el Periodo de Bloqueo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function UpdatePeriodosBloqueo(CveEmpresa As Integer, Ejercicio As Integer, Mes1 As Integer, Mes2 As Integer, Mes3 As Integer, Mes4 As Integer, Mes5 As Integer, Mes6 As Integer, Mes7 As Integer, Mes8 As Integer, Mes9 As Integer, Mes10 As Integer, Mes11 As Integer, Mes12 As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_EmpresasBloqueoMesesUpdate") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@Ejercicio", SqlDbType.Int).Value = Ejercicio + .Add("@Mes1", SqlDbType.Bit).Value = Mes1 + .Add("@Mes2", SqlDbType.Bit).Value = Mes2 + .Add("@Mes3", SqlDbType.Bit).Value = Mes3 + .Add("@Mes4", SqlDbType.Bit).Value = Mes4 + .Add("@Mes5", SqlDbType.Bit).Value = Mes5 + .Add("@Mes6", SqlDbType.Bit).Value = Mes6 + .Add("@Mes7", SqlDbType.Bit).Value = Mes7 + .Add("@Mes8", SqlDbType.Bit).Value = Mes8 + .Add("@Mes9", SqlDbType.Bit).Value = Mes9 + .Add("@Mes10", SqlDbType.Bit).Value = Mes10 + .Add("@Mes11", SqlDbType.Bit).Value = Mes11 + .Add("@Mes12", SqlDbType.Bit).Value = Mes12 + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al actualizar el Periodo de Bloqueo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function RemovePeriodosBloqueo(CveEmpresa As Integer, Ejercicio As Integer) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_EmpresasBloqueoMesesRemove") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@Ejercicio", SqlDbType.Int).Value = Ejercicio + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al eliminar el Periodo de Bloqueo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +#End Region End Class \ No newline at end of file diff --git a/Bancos/IE.aspx.vb b/Bancos/IE.aspx.vb index 305f8edcc..e83e9f36d 100644 --- a/Bancos/IE.aspx.vb +++ b/Bancos/IE.aspx.vb @@ -424,32 +424,6 @@ Partial Class Bancos_IE End Property - Private Property CuentaOld As String - Get - Return CType(ViewState("CuentaOld"), String) - End Get - Set(value As String) - ViewState("CuentaOld") = value - End Set - End Property - Private Property FechaOld As String - Get - Return CType(ViewState("FechaOld"), String) - End Get - Set(value As String) - ViewState("FechaOld") = value - End Set - End Property - - Private Property FolioOld As String - Get - Return CType(ViewState("FolioOld"), String) - End Get - Set(value As String) - ViewState("FolioOld") = value - End Set - End Property - #Region "CANCELACIÓN COMPLEMENTO MODAL V2" @@ -1120,13 +1094,9 @@ Partial Class Bancos_IE UpGuardar.Update() - End If - - ' DATOS PARA LA BITACORA - CuentaOld = LblCuenta.Text - FechaOld = TxtFechaDocumento.Text - FolioOld = TxtFolio.Text - + End If + + End If 'If CveIE > 0 Then @@ -3724,45 +3694,23 @@ Partial Class Bancos_IE Dim IE As New ClsBancos IE.IniciaTransacSQL() - Dim ObjGral As New ClsGenerales - ObjGral.IniciaTransacSQL() Dim FechaAplicado As DateTime? = Nothing Dim OcurrioError As Boolean = False Dim CveCuentaDepositoUpdate As Integer = If(DdlCuentaDeposito.SelectedValue.ToEntero.ToEntero = 0, -1, DdlCuentaDeposito.SelectedValue.ToEntero.ToEntero) - If IE.UpdateBancos_IE(TxtFechaDocumento.Text.ToDate, FechaAplicado, CveIE, TxtFolio.Text, CveCuentaDeposito:=CveCuentaDepositoUpdate, CveCuenta:=DdlCuenta.SelectedValue.ToEntero, - Observaciones:=TxtObservaciones.Text) Then - 'Agrega a la Bitacora - If CuentaOld <> DdlCuenta.SelectedItem.Text Then - If Not ObjGral.AddHistorialBitacora(Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, CveIE, DdlCuenta.SelectedItem.Text, CuentaOld, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 0, "Cuenta", "Banco", TxtFolio.Text + " / " + Cuenta) Then - OcurrioError = True - End If - End If - If FechaOld <> TxtFechaDocumento.Text.Trim Then - If Not ObjGral.AddHistorialBitacora(Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, CveIE, TxtFechaDocumento.Text.Trim, FechaOld, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 0, "Fecha", "Banco", TxtFolio.Text + " / " + Cuenta) Then - OcurrioError = True - End If - End If - If FolioOld <> TxtFolio.Text.Trim Then - If Not ObjGral.AddHistorialBitacora(Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, CveIE, TxtFolio.Text.Trim, FolioOld, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 0, "Número", "Banco", TxtFolio.Text + " / " + Cuenta) Then - OcurrioError = True - End If - End If - Else + If Not IE.UpdateBancos_IE(TxtFechaDocumento.Text.ToDate, FechaAplicado, CveIE, TxtFolio.Text, CveCuentaDeposito:=CveCuentaDepositoUpdate, CveCuenta:=DdlCuenta.SelectedValue.ToEntero, + Observaciones:=TxtObservaciones.Text, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then OcurrioError = True End If If OcurrioError Then IE.RollBack() - ObjGral.RollBack() Else IE.Commit() - ObjGral.Commit() Alert("La Actualización del documento se realizó correctamente", TipoMensaje.MsgInformacion, $"document.location.href=""IE.aspx?CveIE={CveIE}""") End If IE.Dispose() - ObjGral.Dispose() End Sub Protected Sub ImgUpdateCuentaDeposito_Click(sender As Object, e As ImageClickEventArgs) @@ -4356,6 +4304,12 @@ Partial Class Bancos_IE End If End If + If Not ErrorCompra Then + If Not ObjConta.UpdatePrePolizasDetalleBloquear(CvePrePoliza, False) Then + ErrorCompra = True + End If + End If + If Not ErrorCompra Then Alert("La poliza ha sido desvinculada y eliminada con exito.", TipoMensaje.MsgInformacion) ObjAC.Commit() @@ -4712,8 +4666,8 @@ Partial Class Bancos_IE ObjGral.Dispose() If Borrar = True Then Dim ObjAC As ClsContPAQi = Nothing - Dim Banc As New ClsBancos - Banc.IniciaTransacSQL() + Dim Banc As New ClsBancos + Dim ObjConta As New ClsContabilidad(Banc.IniciaTransacSQL()) Dim ErrorCompra = False @@ -4732,6 +4686,13 @@ Partial Class Bancos_IE End If End If + If Not ErrorCompra Then + If Not ObjConta.UpdatePrePolizasDetalleBloquear(CvePrePoliza, False) Then + ErrorCompra = True + End If + End If + + If Not ErrorCompra Then If Not Banc.EliminarBancos_IE(UsuarioActual.CveUsuario, CveIE) Then ErrorCompra = True @@ -4750,6 +4711,7 @@ Partial Class Bancos_IE If ObjAC IsNot Nothing Then ObjAC.Dispose() Banc.Dispose() + ObjConta.Dispose() End If Else Alert("Tiene que decir el motivo de su eliminacion.", TipoMensaje.MsgInformacion) @@ -4887,7 +4849,9 @@ Partial Class Bancos_IE e.Row.Cells(4).Text = String.Format("", Encripta(String.Format("OP=CompP&EXT=pdf&SerieFolio={0}&CVECOMPLEMENTOPAGO={1}&CVEIE={2}", e.Row.DBCampo("SerieFolio"), e.Row.DBCampo("CveComplementoPago"), e.Row.DBCampo("CveIE")))) If e.Row.DataKey("Estatus").Contiene("1", "3") Then - e.Row.FCLinkButton("LnkCancelarComplemetno").Visible = True + e.Row.FCLinkButton("LnkCancelarComplemetno").Visible = True + Else + e.Row.FCLinkButton("LnkCancelarComplemetno").Visible = False End If End If diff --git a/Compras/Compras.aspx.vb b/Compras/Compras.aspx.vb index cc75184c1..fea2e0d27 100644 --- a/Compras/Compras.aspx.vb +++ b/Compras/Compras.aspx.vb @@ -7760,6 +7760,7 @@ Partial Class Compras_Compras Dim ObjAC As ClsContPAQi = Nothing Dim Comp As New ClsCompras() Dim ObjEventos As New ClsOIEventos(Comp.IniciaTransacSQL()) + Dim ObjConta As New ClsContabilidad(Comp.IniciaTransacSQL()) Dim ErrorCompra = False @@ -7781,6 +7782,12 @@ Partial Class Compras_Compras Next End If + If Not ErrorCompra Then + If Not ObjConta.UpdatePrePolizasDetalleBloquear(CvePrePoliza, False) Then + ErrorCompra = True + End If + End If + If Not ErrorCompra Then If Not Comp.DeleteCompra(CveCompra, False) Then ErrorCompra = True @@ -7799,6 +7806,7 @@ Partial Class Compras_Compras If ObjAC IsNot Nothing Then ObjAC.Dispose() Comp.Dispose() + ObjConta.Dispose() End Sub Protected Sub BtnAceptarAnticipos_Click(sender As Object, e As System.EventArgs) Handles BtnAceptarAnticipos.Click @@ -12857,6 +12865,12 @@ Partial Class Compras_Compras End If End If + If Not ErrorCompra Then + If Not ObjConta.UpdatePrePolizasDetalleBloquear(CvePrePoliza, False) Then + ErrorCompra = True + End If + End If + If Not ErrorCompra Then Alert("La poliza ha sido desvinculada y eliminada con exito.", TipoMensaje.MsgInformacion) ObjAC.Commit() diff --git a/Contabilidad/PopUpAuxiliar.aspx b/Contabilidad/PopUpAuxiliar.aspx index 047e0473a..fd8deccef 100644 --- a/Contabilidad/PopUpAuxiliar.aspx +++ b/Contabilidad/PopUpAuxiliar.aspx @@ -78,7 +78,10 @@
- + + + + Fecha @@ -142,21 +145,34 @@ + + + + + + + + + - + + + + +
@@ -168,6 +184,66 @@ + + + + + + + + + + + + + + + diff --git a/Contabilidad/PopUpAuxiliar.aspx.vb b/Contabilidad/PopUpAuxiliar.aspx.vb index 1c0755987..e283fc11f 100644 --- a/Contabilidad/PopUpAuxiliar.aspx.vb +++ b/Contabilidad/PopUpAuxiliar.aspx.vb @@ -77,7 +77,8 @@ Partial Class PopUpAuxiliar Private Sub CargaDatos() GVAuxiliar.Columns(10).Visible = UsuarioActual.TienePermisoProceso(94) - 'GVAuxiliar.Columns(11).Visible = UsuarioActual.TienePermisoProceso(94) + 'GVAuxiliar.Columns(11).Visible = UsuarioActual.TienePermisoProceso(94) + GVAuxiliar.Columns(12).Visible = UsuarioActual.TienePermisoProceso(94) Select Case Tipo Case "CxCClientes" @@ -102,6 +103,9 @@ Partial Class PopUpAuxiliar LtlTipo2.Text = "Folio de la Compra" LtlTipo3.Text = "Fecha de la Compra" End Select + + + UpDatos.Update() End Sub Private Sub CargaAuxiliarClienteCxC(CveCliente As Integer, CveVenta As Integer) @@ -158,7 +162,11 @@ Partial Class PopUpAuxiliar GVAuxiliar.DataBind() End Sub - Protected Sub GVAuxiliar_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GVAuxiliar.RowDataBound + Protected Sub GVAuxiliar_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GVAuxiliar.RowDataBound + + + + If e.Row.RowType = DataControlRowType.DataRow Then If e.Row.RowIndex = 0 Then e.Row.BackColor = Drawing.Color.LightGray @@ -171,6 +179,7 @@ Partial Class PopUpAuxiliar e.Row.Cells(6).Visible = False e.Row.Cells(7).Visible = False e.Row.Cells(8).Visible = False + e.Row.Cells(12).Visible = False ElseIf e.Row.RowIndex = 1 Then e.Row.Cells(0).Width = Unit.Pixel(95) e.Row.Cells(1).Width = Unit.Pixel(180) @@ -238,6 +247,12 @@ Partial Class PopUpAuxiliar Dim TieneError = False + If Not TieneError Then + If Not Conta.UpdatePrePolizasDetalleBloquear(ClavePrePoliza, False) Then + TieneError = True + End If + End If + If Not Conta.RemovePrePolizas(ClavePrePoliza, UsuarioActual.CveEmpresa) Then TieneError = True End If @@ -257,6 +272,7 @@ Partial Class PopUpAuxiliar If Not ObjContPaq.RemovePoliza(IdPoliza) Then TieneError = True End If + End If End If End If @@ -350,5 +366,62 @@ Partial Class PopUpAuxiliar Alert("No se encontró información suficiente.", TipoMensaje.MsgAdvertencia) End If - End Sub + End Sub + + Property CvePrePolizaNegativa As Integer + Get + If ViewState("CvePrePolizaNegativa") Is Nothing Then + Return -1 + Else + Return ViewState("CvePrePolizaNegativa").ToString.ToEntero + End If + + End Get + Set(value As Integer) + ViewState("CvePrePolizaNegativa") = value + End Set + End Property + + + + Private Sub AgregaPolizaNegativo(CvePrePoliza As Integer) + + Dim ObjContabilidad As New ClsContabilidad + Dim TieneError As Boolean = False + ObjContabilidad.IniciaTransacSQL() + + If ObjContabilidad.AddPrePolizasNegativa(CvePrePoliza, UsuarioActual.CveUsuario, TxtConceptoCancelacion.Text, UsuarioActual.CveEmpresa, TxtFechaCancelacion.Text.ToDate) Then + Alert("Se agrego polzia negativa correctamente.") + Else + TieneError = True + End If + + If TieneError Then + ObjContabilidad.RollBack() + Else + ObjContabilidad.Commit() + RegistraScript(" $('#DivCancelar').modal('hide'); ") + CargaDatos() + End If + + ObjContabilidad.Dispose() + + + End Sub + + + Protected Sub BtnCancelar_Click(sender As Object, e As EventArgs) + AgregaPolizaNegativo(CvePrePolizaNegativa) + End Sub + + + Protected Sub imgCancelar_Click(sender As Object, e As EventArgs) + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).BindingContainer, GridViewRow) + CvePrePolizaNegativa = GvRow.DataKey("CvePrePoliza").ToString.ToEntero + + RegistraScript(" $('#DivCancelar').modal('show'); ") + End Sub + + + End Class diff --git a/Empresas/137/Formatos/RepClientesCxC.rpt b/Empresas/137/Formatos/RepClientesCxC.rpt new file mode 100644 index 000000000..132388990 Binary files /dev/null and b/Empresas/137/Formatos/RepClientesCxC.rpt differ diff --git a/Empresas/143/Formatos/Remision.rdlc b/Empresas/143/Formatos/Remision.rdlc new file mode 100644 index 000000000..0d407b6b9 --- /dev/null +++ b/Empresas/143/Formatos/Remision.rdlc @@ -0,0 +1,5555 @@ + + + + + + true + + + + + Tipo + + + + + + + Textbox3 + 0.90692in + 5.85473in + 0.5cm + 2.24597in + + + LightGrey + 2pt + 2pt + 2pt + 2pt + + + + true + + + + + Fecha y hora de emisión + + + + + + + + + + + + + + + + Textbox3 + 0.46414in + 5.85473in + 0.5cm + 2.24597in + 1 + + + LightGrey + 2pt + 2pt + 2pt + 2pt + + + + true + + + + + =IIF(Parameters!Serie.Value.ToString="",Parameters!Folio.Value,Parameters!Serie.Value & "-" &Parameters!Folio.Value) + + + + + + + Textbox3 + 0.22455in + 5.85473in + 0.60856cm + 2.24597in + 2 + + + 2pt + 2pt + 2pt + 2pt + + + + true + + + + + =Parameters!TipoDocumento.Value + + + + + + + Textbox3 + 0.07295cm + 5.85473in + 0.5cm + 2.24597in + 3 + + + LightGrey + 2pt + 2pt + 2pt + 2pt + + + + true + + + + + SERVICIOS GASTRONOMICOS DE HERMOSILLO SA DE CV + + + + + + + + + R.F.C SGH1602157P0 + + + + + + + Textbox4 + 1.06055in + 0.51102in + 4.75251in + 4 + + + 2pt + 2pt + 2pt + 2pt + + + + true + + + + + =Parameters!Fecha.Value + + + + + + + Textbox3 + 0.66099in + 5.85473in + 0.25114in + 2.24597in + 5 + + + 2pt + 2pt + 2pt + 2pt + + + + true + + + + + =Parameters!Tipo.Value & Parameters!Ref.Value + + + + + + + Textbox3 + 1.10364in + 5.85473in + 0.25635in + 2.24597in + 6 + + + 2pt + 2pt + 2pt + 2pt + + + + true + + + + + Domicilio Fiscal + + + + + + + + + CALLE LA BILBAINA 60, + + + + + + + + + LA RIOJA RESIDENCIAL, HERMOSILLO, SONORA + + + + + + + Textbox10 + 0.51102in + 1.80776in + 0.65513in + 2.01842in + 7 + + + 2pt + 2pt + 2pt + 2pt + + + + true + + + + + Lugar de Expedición + + + + + + + + + =Parameters!DomicilioSucursal.Value + + + + + + + Textbox10 + 0.52491in + 3.82618in + 0.65513in + 1.98688in + 8 + + + Top + + + + true + true + + + + + Nombre + + + + + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + + + + + =Parameters!ClienteCodigo.Value + " - " + Parameters!ClienteNombre.Value + + + + + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Dirección + + + + + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + + + + + =Parameters!ClienteDireccion.Value + + + + + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Ciudad + + + + + + + + 1.25pt + + 2pt + 2pt + 2pt + 2pt + + + + true + + + + + =Parameters!ClienteLugar.Value + + + + + + + + + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + 1.75416cm + + + 1.66039cm + + + 2.05295cm + + + 1.89126cm + + + 8.33453cm + + + 1.78174cm + + + 2.47543cm + + + + + 0.52063cm + + + + + true + + + + + Cantidad + + + + + + + Textbox34 + + + LightGrey + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + + + + + Unidad + + + + + + + Textbox53 + + + LightGrey + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + SAT UM + + + + + + + Textbox1 + + + LightGrey + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + SAT PS + + + + + + + Textbox8 + + + LightGrey + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Descripción + + + + + + + Textbox15 + + + LightGrey + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + + + + + P. Unitario + + + + + + + Textbox84 + + + LightGrey + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + + + + + Importe + + + + + + + + + + + + + + + LightGrey + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.57355cm + + + + + true + true + + + + + =Fields!Cantidad.Value + + + + + + + Cantidad1 + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!UM.Value + + + + + + + UM1 + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!SATClaveUM.Value + + + + + + + SATClaveUM + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!SATClaveProdServ.Value + + + + + + + SATClaveProdServ + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!PS.Value & " " & Fields!Obs.Value + + + + + + + UnidadMedida + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!PU.Value + + + + + + + PU1 + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Cantidad.Value*Fields!PU.Value + + + + + + + Textbox88 + + + + + + + + + 2pt + 2pt + 2pt + 2pt + es-MX + + + + + + + + 0.20313cm + + + + + true + true + + + + + + + + + Black + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + + + + + Black + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + + + + + Black + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + + + + + Black + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + + + + + Black + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + + + + + Black + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + + + + + Black + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + + + + + + After + + + + + =Fields!PS.Value Is Nothing + + + + Before + + + + DsOC + 4.5569cm + 0.2872cm + 1.29731cm + 19.95046cm + 15 + + + + + + true + + + + + RFC: + + + + =Parameters!ClienteRFC.Value + + + + + + + + + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + External + =Parameters!QR.Value + FitProportional + 0.03297in + 1.3497in + 1.5531in + + + + + + true + true + + + + + Folio Fiscal: + + + + + + + Textbox54 + 0.00077in + 1.63683in + 0.18056in + 4.03672in + 1 + + + + + + + White + + + + + + + + LightGrey + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + No. Serie del Certificado del SAT: + + + + + + + Textbox54 + 0.19522in + 1.63683in + 0.18056in + 4.03672in + 2 + + + LightGrey + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Fecha y Hora de certificación: + + + + + + + Textbox54 + 0.39377in + 1.63683in + 0.19444in + 4.03672in + 3 + + + LightGrey + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Certificado del Contribuyente: + + + + + + + Textbox54 + 0.59938in + 1.63683in + 0.19445in + 4.03672in + 4 + + + LightGrey + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Parameters!FolioFiscal.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Parameters!SerieCertificadoSAT.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Parameters!FechaCertificacion.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Parameters!CertificadoContribuyente.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Regímen: Regímen General de Ley Personas Morales; Condiciones de pago: + + + + =IIF(Parameters!CondicionPago.Value.ToString="","No Identificado",Parameters!CondicionPago.Value) + + + + ; Método de Pago: + + + + =IIF(Parameters!MetodoPago.Value.ToString="","No Identificado",Parameters!MetodoPago.Value) + + + + ; Num. Cta Pago: + + + + =IIF(Parameters!NumCta.Value="0" Orelse Parameters!NumCta.Value="","No Identificado",Parameters!NumCta.Value) + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Éste documento es una representacion impresa de un CFDi + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + true + true + + + + + P A G A R E con Folio + + + + =Parameters!Serie.Value + + + + - + + + + =Parameters!Folio.Value + + + + Por éste pagare prometo (emos) pagar incondicionalmente a la orden de + + + + SERVICIOS GASTRONOMICOS DE HERMOSILLO SA DE CV + + + + , a su vencimiento el + + + + =Parameters!Vencimiento.Value + + + + , en Hermosillo, Sonora o en el domicilio señalado a elección del acreedor o tenedor la cantidad de $ + + + + =Parameters!Total.Value + + + + SON: ( + + + + =Microsoft.VisualBasic.Strings.UCase(Parameters!ImporteLetra.Value) + + + + ). Valor recibido a mi (nuestra) entera satisfacción. la falta de pago de éste documento a su vencimiento dará derecho a + + + + SERVICIOS GASTRONOMICOS DE HERMOSILLO SA DE CV + + + + o tenedor, desde el día siguiente a cobrar el 10% mensual de interes moratorios hasta su total liquidación y los gastos judiciales que se ocasionen. Lugar y Fecha de Suscripción: Hermosillo, Sonora a + + + + =CDATE(Parameters!Fecha.Value).ToString("dd/MM/yyyy") + + + + + + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Nombre: + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Dirección: + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Parameters!ClienteNombre.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Parameters!ClienteDireccion.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Acepto de conformidad + + + + + + 2pt + 2pt + 2pt + 2pt + + + + 0.08375cm + 0cm + 0.57653cm + 6 + + + + + + 0.71971cm + 0cm + 0.57653cm + 7 + + + + + + 1.35545cm + 0cm + 0.57653cm + 8 + + + + + + 1.66152cm + 0cm + 0.57653cm + 9 + + + + + + 2.29748cm + 0cm + 0.57653cm + 10 + + + + + + 2.93322cm + 0cm + 0.57653cm + 11 + + + + + + 3.60266cm + 0cm + 0.57653cm + 12 + + + + + + 4.23862cm + 0cm + 0.57653cm + 13 + + + + + + 4.87436cm + 0cm + 0.57653cm + 14 + + + + + + 5.18043cm + 0cm + 0.57653cm + 15 + + + + + + 5.81639cm + 0cm + 0.57653cm + 16 + + + + + + 6.45213cm + 0cm + 0.57653cm + 17 + + + + + + 7.13239cm + 0cm + 0.57653cm + 18 + + + + + + 7.76835cm + 0cm + 0.57653cm + 19 + + + + + + 8.40409cm + 0cm + 0.57653cm + 20 + + + + + + 8.71016cm + 0cm + 0.57653cm + 21 + + + + + + 9.34612cm + 0cm + 0.57653cm + 22 + + + + + + 9.98186cm + 0cm + 0.57653cm + 23 + + + + + + 14.06281cm + 0cm + 0.57653cm + 24 + + + + + + 14.69877cm + 0cm + 0.57653cm + 25 + + + + + + 15.33451cm + 0cm + 0.57653cm + 26 + + + + + + 15.64058cm + 0cm + 0.57653cm + 27 + + + + + + 16.27654cm + 0cm + 0.57653cm + 28 + + + + + + 16.91228cm + 0cm + 0.57653cm + 29 + + + + + + 10.60588cm + 0cm + 0.57653cm + 30 + + + + + + 11.24184cm + 0cm + 0.57653cm + 31 + + + + + + 11.87758cm + 0cm + 0.57653cm + 32 + + + + + + 12.18365cm + 0cm + 0.57653cm + 33 + + + + + + 12.81961cm + 0cm + 0.57653cm + 34 + + + + + + 13.45535cm + 0cm + 0.57653cm + 35 + + + + + + 18.40663cm + 0cm + 0.57653cm + 36 + + + + + + 19.04259cm + 0cm + 0.57653cm + 37 + + + + + + 17.74353cm + 0cm + 0.57653cm + 38 + + + + + + 3.41069cm + 15.04347cm + 0cm + 4.87315cm + 39 + + + + + + true + 3.64746cm + 3.92471cm + 20.0948cm + 11 + + = (Parameters!AplicaPagare.Value="0" OrElse Parameters!AplicaPagare.Value="") + + + + + + + true + 12.24321cm + 0.13086cm + 7.57217cm + 20.1133cm + 17 + + + + + + + + true + true + + + + + CFDI Relacionados + + + + + + + Textbox5 + 0.30801cm + 0.54004cm + 20.1133cm + + + LightGrey + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Tipo Relación: + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Parameters!TipoRelacionTexto.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Folio Fiscal: + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Parameters!FolioFiscalRelacionado.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + true + 19.92121cm + 0.13086cm + 1.82156cm + 20.1133cm + 18 + + =Microsoft.VisualBasic.Interaction.iif(Parameters!TipoRelacionTexto.Value <> "" Or Parameters!FolioFiscalRelacionado.Value <> "", False, True) + + + + + + + + + + 3.34839cm + + + 10.97948cm + + + + + 0.6cm + + + + + true + true + + + + + =Parameters!Observaciones.Value + + + + + + + Textbox128 + + + 2pt + 2pt + 2pt + 2pt + + + 2 + + + + + + + 0.6cm + + + + + true + true + + + + + Importe con letra: + + + + + + + Textbox126 + + + + + 1pt + + + + 1pt + + + + 1pt + + + + 1pt + + LightGrey + Middle + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + ="SON: " & Microsoft.VisualBasic.Strings.UCase(Parameters!ImporteLetra.Value) + + + + + + + Textbox127 + + + + + 1pt + + + + 1pt + + + + 1pt + + + + 1pt + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.6cm + + + + + true + true + + + + + Forma de pago: + + + + + + + Textbox130 + + + LightGrey + Middle + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!FormaPago.Value + + + + + + + Textbox131 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.6cm + + + + + true + true + + + + + Uso CFDI: + + + + + + + Textbox14 + + + LightGrey + Middle + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!UsoCFDI.Value + + + + + + + Textbox15 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.96667cm + + + + + true + true + + + + + Sello digital del CFDI: + + + + + + + Textbox132 + + + LightGrey + Middle + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!SelloCFDI.Value + + + + + + + Textbox133 + + + Top + 2pt + 2pt + 2pt + 2pt + + + + + + + + 1.09898cm + + + + + true + true + + + + + Sello del SAT: + + + + + + + Textbox134 + + + LightGrey + Middle + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!SelloSAT.Value + + + + + + + Textbox135 + + + Top + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.6cm + + + + + true + true + + + + + Cadena original del complemento de certificación digital del SAT: + + + + + + + Textbox136 + + + LightGrey + Middle + 2pt + 2pt + 2pt + 2pt + + + 2 + + + + + + + 1.11168cm + + + + + true + true + + + + + =Parameters!CadenaOriginal.Value + + + + + + + Textbox138 + + + Top + 2pt + 2pt + 2pt + 2pt + + + 2 + + + + + + + + + + + + + + + + + + + + + + + + + + DsOC + 5.96004cm + 0.21461cm + 6.17733cm + 14.32787cm + 19 + + + + + + + + + 0.82345in + + + 0.70198in + + + 0.70575in + + + + + 0.19645in + + + + + true + true + + + + + Impuesto + + + + + + + Textbox22 + + + LightGrey + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Tasa + + + + + + + Textbox15 + + + LightGrey + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Importe + + + + + + + Textbox29 + + + LightGrey + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.14436in + + + + + true + true + + + + + =Fields!Impuesto.Value + + + + + + + Cantidad1 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!tasa.Value + + + + + + + UM + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Importe.Value + + + + + + + Codigo + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + + After + + + + + + + DataSet3 + 2.65269in + 5.87207in + 0.34081in + 2.23118in + 20 + + + + + + + + + 3.12155cm + + + + + 0.6cm + + + + + true + true + + + + + =Sum(Fields!Importe.Value) + + + + + + + Importe + + + 2pt + 2pt + 2pt + 2pt + es-MX + + + + + + + + + + + + + + + + + + + =Fields!ImpuestoLocal.Value + + + + 2.50276cm + + + true + true + + + + + =Fields!ImpuestoLocal.Value + + + + + + LightGrey + 2pt + 2pt + 2pt + 2pt + + + + + + + + DataSet1 + 5.99532cm + 14.91885cm + 0.6cm + 5.62431cm + 21 + + + + + + 21.83098cm + + LightGrey 2pt 2pt 2pt @@ -47,19 +48,19 @@ - 2.71123cm + 2.36727cm - 2.71123cm + 2.63186cm - 2.71123cm + 2.55248cm - 2.71123cm + 2.12915cm - 2.71123cm + 2.49956cm @@ -77,13 +78,15 @@ =Fields!Cantidad.Value @@ -92,6 +95,7 @@ + =IIF(Fields!Orden.Value = "","CornflowerBlue","Transparent") 2pt 2pt 2pt @@ -111,12 +115,16 @@ =Fields!SubTotal.Value - SubTotal @@ -124,6 +132,7 @@ + =IIF(Fields!Orden.Value = "","CornflowerBlue","Transparent") 2pt 2pt 2pt @@ -143,12 +152,16 @@ =Fields!Descuento.Value - Descuento @@ -156,6 +169,7 @@ + =IIF(Fields!Orden.Value = "","CornflowerBlue","Transparent") 2pt 2pt 2pt @@ -175,12 +189,16 @@ =Fields!IVA.Value - IVA @@ -188,6 +206,7 @@ + =IIF(Fields!Orden.Value = "","CornflowerBlue","Transparent") 2pt 2pt 2pt @@ -207,12 +226,16 @@ =Fields!Total.Value - Total @@ -220,6 +243,7 @@ + =IIF(Fields!Orden.Value = "","CornflowerBlue","Transparent") 2pt 2pt 2pt @@ -260,6 +284,7 @@ DimGray + LightGrey 2pt 2pt 2pt @@ -295,6 +320,7 @@ DimGray + LightGrey 2pt 2pt 2pt @@ -330,6 +356,7 @@ DimGray + LightGrey 2pt 2pt 2pt @@ -365,6 +392,7 @@ DimGray + LightGrey 2pt 2pt 2pt @@ -400,6 +428,7 @@ DimGray + LightGrey 2pt 2pt 2pt @@ -419,13 +448,8 @@ =Fields!GPO.Value - - - =Fields!GPO.Value - - - 5.42245cm + 6.79828cm true @@ -436,7 +460,9 @@ =Fields!GPO.Value @@ -448,6 +474,7 @@ + =IIF(Fields!Orden.Value = "","CornflowerBlue","Transparent") 2pt 2pt 2pt @@ -893,6 +920,10 @@ Total System.Double + + Orden + System.String + DataSet diff --git a/General/SaldosIniciales.aspx.vb b/General/SaldosIniciales.aspx.vb index 47e7f074e..8997c6309 100644 --- a/General/SaldosIniciales.aspx.vb +++ b/General/SaldosIniciales.aspx.vb @@ -1524,20 +1524,28 @@ Partial Class General_SaldosIniciales Dim ObjMovimientos As New ClsInventarios ObjMovimientos.IniciaTransacSQL() Dim OcurrioError As Boolean = False + Dim contadorMovimientos As Integer = 0 + Dim listadoMovimientos As String = "" Try For Each almacenSinRepetir As DataRow In dt.FiltraParametros("", DistinctColumns:={"Almacen"}).Rows Dim almacenActual As String = almacenSinRepetir("Almacen").ToString Dim CveAlmacen As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveAlmacen", $"Almacen = '{almacenActual}'").ToEntero Dim movimientoCabecera As Integer = ObjMovimientos.AddMovimiento(CveAlmacen, 1, 1, Date.Now, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1) + listadoMovimientos += $"movimiento con folio {ObjMovimientos.Folio}
" If CveAlmacen > 0 Then + contadorMovimientos += 1 For Each nuevaEntrada As DataRow In dt.FiltraParametros($"Almacen = '{almacenActual}'").Rows Dim CvePS As Integer = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CvePS", $"Codigo = '{nuevaEntrada("CodigoPS")}'").ToEntero Dim CveUM As Integer = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveUnidadMedida", $"Codigo = '{nuevaEntrada("CodigoPS")}'").ToEntero If CvePS > 0 Then - Dim Cantidad As Decimal = nuevaEntrada("Existencia").ToString.ToDecimal - Dim Valor As Decimal = nuevaEntrada("Valor").ToString.ToDecimal + If CveUM > 0 Then + Dim Cantidad As Decimal = nuevaEntrada("Existencia").ToString.ToDecimal + Dim Valor As Decimal = nuevaEntrada("Valor").ToString.ToDecimal - If Not ObjMovimientos.AddMovimientoDetalle(movimientoCabecera, Cantidad, CveUM, CvePS, (Valor / Cantidad), -1, -1) Then + If Not ObjMovimientos.AddMovimientoDetalle(movimientoCabecera, Cantidad, CveUM, CvePS, (Valor / Cantidad), -1, -1) Then + OcurrioError = True + End If + Else OcurrioError = True End If Else @@ -1559,7 +1567,7 @@ Partial Class General_SaldosIniciales If Not OcurrioError Then ObjMovimientos.Commit() - Alert("Se cargó correctamente #movimientos") + Alert($"Se cargaron correctamente {contadorMovimientos} movimientos

{listadoMovimientos}") Else Alert("Ocurrió un error al cargar las existencias", TipoMensaje.MsgError) ObjMovimientos.RollBack() diff --git a/Inventarios/EntradasSalidas.aspx.vb b/Inventarios/EntradasSalidas.aspx.vb index 5219336c1..cb508eee9 100644 --- a/Inventarios/EntradasSalidas.aspx.vb +++ b/Inventarios/EntradasSalidas.aspx.vb @@ -244,6 +244,14 @@ Partial Class Inventarios_EntradasSalidas ViewState("Tipo") = value End Set End Property + Private Property CvePrePoliza As Integer + Get + Return CType(ViewState("CvePrePoliza"), Integer) + End Get + Set(value As Integer) + ViewState("CvePrePoliza") = value + End Set + End Property #End Region Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load @@ -256,6 +264,7 @@ Partial Class Inventarios_EntradasSalidas EstatusAlmacenCompra = -1 EsConsumoInterno = False EsNuevoMov = False + CvePrePoliza = -1 CreaDT() CargaCombos() @@ -579,6 +588,7 @@ Partial Class Inventarios_EntradasSalidas If DtMov.Rows(0)("CvePrePoliza").ToString.ToEntero > 0 Then HplPrePoliza.Visible = True HplPrePoliza.NavigateUrl = String.Format("/Contabilidad/RegPrePoliza.aspx?CvePrePoliza={0}", DtMov.Rows(0)("CvePrePoliza")) + CvePrePoliza = DtMov.Rows(0)("CvePrePoliza").ToString.ToEntero Else If UsuarioActual.CveRol = 1 Then BtnGeneraPrepoliza.Visible = True @@ -1035,14 +1045,10 @@ Partial Class Inventarios_EntradasSalidas Private Sub BtnRemove_Click(sender As Object, e As EventArgs) Handles BtnRemove.Click Dim Borrar As Boolean = False If Not TxtDescripcion.Text = "" Then - Dim ObjGral As New ClsGenerales - ObjGral.IniciaTransacSQL() - If ObjGral.AddHistorialBitacora(Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, "", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 1, TxtDescripcion.Text, "Inventarios", TxtFolio.Text + " / " + DdlConcepto.SelectedItem.Text) Then - Borrar = True - End If Dim Inv As New ClsInventarios - Inv.IniciaTransacSQL() + Dim Conta As New ClsContabilidad(Inv.IniciaTransacSQL()) + Dim ObjGral As New ClsGenerales(Inv.IniciaTransacSQL()) Dim TieneError = False @@ -1052,6 +1058,9 @@ Partial Class Inventarios_EntradasSalidas ObjConta.IniciaTransacSQL() End If + If ObjGral.AddHistorialBitacora(Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, "", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 1, TxtDescripcion.Text, "Inventarios", TxtFolio.Text + " / " + DdlConcepto.SelectedItem.Text) Then + TieneError = True + End If If Inv.MovimientoRemove(CveMovimiento, UsuarioActual.CveEmpresa) Then If HdnIdPoliza.Value.ToEntero > 0 Then @@ -1063,10 +1072,15 @@ Partial Class Inventarios_EntradasSalidas TieneError = True End If + If Not TieneError Then + If Not Conta.UpdatePrePolizasDetalleBloquear(CvePrePoliza, False) Then + TieneError = True + End If + End If + If Not TieneError Then If ObjConta IsNot Nothing Then ObjConta.Commit() Inv.Commit() - ObjGral.Commit() Alert("Movimientos Eliminado", TipoMensaje.MsgInformacion) RegistraScript(String.Format("$('#{0}').modal('hide');", "divDescripcion")) @@ -1074,7 +1088,6 @@ Partial Class Inventarios_EntradasSalidas Else If ObjConta IsNot Nothing Then ObjConta.RollBack() Inv.RollBack() - ObjGral.RollBack() Alert("Ocurrió un error al eliminar el movimiento. Por favor vuelva a intetar.", TipoMensaje.MsgError) End If @@ -1083,6 +1096,7 @@ Partial Class Inventarios_EntradasSalidas If ObjConta IsNot Nothing Then ObjConta.Dispose() Inv.Dispose() ObjGral.Dispose() + Conta.Dispose() End If End Sub #End Region diff --git a/Inventarios/RecepcionUsados.aspx.vb b/Inventarios/RecepcionUsados.aspx.vb index 01d4b6852..76700abb6 100644 --- a/Inventarios/RecepcionUsados.aspx.vb +++ b/Inventarios/RecepcionUsados.aspx.vb @@ -633,7 +633,7 @@ Partial Class Inventarios_RecepcionUsados Protected Sub BtnEliminar_Click(sender As Object, e As EventArgs) Handles BtnEliminar.Click Dim Inv As New ClsInventarios - Inv.IniciaTransacSQL() + Dim Conta As New ClsContabilidad(Inv.IniciaTransacSQL()) Dim TieneError = False @@ -654,6 +654,12 @@ Partial Class Inventarios_RecepcionUsados TieneError = True End If + 'If Not TieneError Then + ' If Not Conta.UpdatePrePolizasDetalleBloquear(CvePrePoliza, False) Then + ' TieneError = True + ' End If + 'End If + If Not TieneError Then If ObjConta IsNot Nothing Then ObjConta.Commit() Inv.Commit() @@ -670,6 +676,7 @@ Partial Class Inventarios_RecepcionUsados If ObjConta IsNot Nothing Then ObjConta.Dispose() Inv.Dispose() + Conta.Dispose() End Sub #End Region diff --git a/Inventarios/RepNotasSinAlmacen.aspx.vb b/Inventarios/RepNotasSinAlmacen.aspx.vb index 6973d632c..0f7e28329 100644 --- a/Inventarios/RepNotasSinAlmacen.aspx.vb +++ b/Inventarios/RepNotasSinAlmacen.aspx.vb @@ -291,17 +291,17 @@ Partial Class RepNotasSinAlmacen If UsuarioActual.TienePermisoProceso(278) Then Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) - Dim CveCompraDetalle As Integer = GvRow.DataKey("CveCompraDetalle") - Dim CveCompra As Integer = GvRow.DataKey("CveCompra") - Dim CvePS As Integer = GvRow.DataKey("CveCompra") + Dim CveCompraDetalle As Integer = GvRow.DataKey("CveCompraDetalle").ToEntero() + Dim CveCompra As Integer = GvRow.DataKey("CveCompra").ToEntero() + Dim CvePS As Integer = GvRow.DataKey("CvePS").ToEntero() Dim PS = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa).FiltroPrimeroValor("PSCodigo", $"CvePS = {CvePS}") Dim ObjCompras As New ClsCompras Dim ObjEventos As New ClsOIEventos If ObjCompras.UpdateEstatusAlmacenDetalle(CveCompraDetalle, 1) Then - If ObjEventos.AddEventoBitacora(String.Format("Se cambio el estatus de almacen del producto/servicio: {0} a 'No Recibir'", PS), "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra:=CveCompra) Then - Alert("El producto se desmarco correctamente.") + If ObjEventos.AddEventoBitacora(String.Format("El producto: {0} se marcó como no recibido", PS), "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra:=CveCompra) Then + Alert("El producto se marcó como 'no recibido' correctamente.") End If End If ObjCompras.Dispose() diff --git a/Ventas/RepProductosServicios.aspx.vb b/Ventas/RepProductosServicios.aspx.vb index b9125ff52..648d3cfdf 100644 --- a/Ventas/RepProductosServicios.aspx.vb +++ b/Ventas/RepProductosServicios.aspx.vb @@ -476,8 +476,8 @@ Partial Class Ventas_RepProductosServicios 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("FechaInicio", FechaI.ToShortDateString)) - params.Add(New ReportParameter("FechaFin", FechaF.ToShortDateString)) + params.Add(New ReportParameter("FechaInicio", If(txtFechaI.Text <> "", FechaI.ToShortDateString, ""))) + params.Add(New ReportParameter("FechaFin", If(txtFechaF.Text <> "", FechaF.ToShortDateString, ""))) params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa)) params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre)) params.Add(New ReportParameter("FechaImpresion", Now.ToDateTime.ToShortDateString)) diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 7f4141744..f4a9a4008 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -2781,6 +2781,9 @@ Partial Class Ventas If DrContrato("CveSucursalCliente").ToString.ToEntero > 0 Then DdlSucursalCliente.SelectedValueExist(DrContrato("CveSucursalCliente")) + DdlSucursalCliente_SelectedIndexChanged(DdlSucursalCliente, EventArgs.Empty) + DdlSucursalCliente.Enabled = False + DdlSucursalCliente.Attributes.Add("disabled", "") End If Dim CveAlmacenDestino As Integer = DrContrato("CveAlmacenDestino").ToString.ToEntero @@ -13860,778 +13863,784 @@ Partial Class Ventas #End Region #End Region -#Region "M E T O D O S" - Private Sub CargaOtrosConceptos() - Dim ObjVentas As New ClsVentas - If ObjVentas.GetVentaOtrosConceptos(UsuarioActual.CveEmpresa, CveVenta) Then - GVOtrosConceptos.DataSource = ObjVentas.DtResultados - GVOtrosConceptos.DataBind() - UpOtrosConceptos.Update() - End If - ObjVentas.Dispose() - End Sub - Private Function GenerarPolizaAC(ObjAC As ClsContPAQi, factura As Modelos.Factura, Optional CancelacionIngreso As Boolean = False) As Integer - Dim Retorno As Integer = 0 - Dim IDPoliza As Integer = 0 - - Dim ErrorAC As Boolean = False - 'Dim ObjAC As New ClsContPAQi(UsuarioActual.Empresa) : ObjAC.IniciaTransacSQL() - Dim Fecha As Date = factura.Fecha - Dim Concepto As String = String.Format("GD {0}", factura.Cliente.Nombre) - Dim Paridad As Integer = 1 - Dim TipoMovto As Boolean = False - - If CancelacionIngreso Then - Concepto = String.Format("Cancelación GD {0}", factura.Cliente.Nombre) - Paridad = -1 - TipoMovto = True - End If - - Dim TipoPoliza = If(factura.TipoDocto = "OP" Or factura.TipoDocto = "Com", 3, 1) - - IDPoliza = ObjAC.AddPoliza(TipoPoliza, Concepto, factura.Total * 2, factura.Total * 2, factura.CveUsuario, Fecha) - Dim dr As DataRow ' = DTPresupuestoIngresos.FiltroPrimero(String.Format("CvePresupuestoIngreso = {0}", DdlFuenteRecaudacion.SelectedValue)) - 'Dim Importe As Double = TxtTotal.Text.ToDouble - Dim CtaCliente As Integer = factura.Cliente.IdCtaContClientes - Dim CtaISSSTESON As Integer = 643 - Dim CtaISPT As Integer = 1745 - ' Dim NombreCliente As String = ViewState("NombreCliente").ToString - - If IDPoliza > 0 Then - - 'Orden de PAGO - If factura.TipoDocto = "OP" Then - - If DdlOrdenPago.SelectedValue.ToEntero = 1 Then - 'ISSSTESON - - If ObjAC.AddMovimiento(IDPoliza, factura.Cliente.IdCtaContClientes, False, Paridad * factura.Total, "", Concepto, 0, Fecha, "") Then - If Not ObjAC.AddMovimiento(IDPoliza, CtaISSSTESON, True, Paridad * factura.Total, "", Concepto, 0, Fecha, "") Then - ErrorAC = True - End If - Else - ErrorAC = True - End If - - Else - 'ISPT - - If ObjAC.AddMovimiento(IDPoliza, factura.Cliente.IdCtaContClientes, False, Paridad * factura.Total, "", Concepto, 0, Fecha, "") Then - If Not ObjAC.AddMovimiento(IDPoliza, CtaISPT, True, Paridad * factura.Total, "", Concepto, 0, Fecha, "") Then - ErrorAC = True - End If - Else - ErrorAC = True - End If - End If - - ' NORMAL - Else - Dim Detalles = From gvr As GridViewRow In GvPS.Rows.Cast(Of GridViewRow)() - Group gvr By Grp = New With { - Key .CvePresupuestoIngreso = gvr.FCDropDownList("DdlFR").SelectedValue.ToEntero - } Into Group - Select Grp.CvePresupuestoIngreso, - TotalImporte = Group.Sum(Function(r) r.FCLiteral("LtlTotal").Text.ToDouble) - - - 'Select Case TipoComprobante - ' Case "Ing", "Egs" - For Each grp In Detalles - dr = DTPresupuestoIngresos.FiltroPrimero(String.Format("CvePresupuestoIngreso = {0}", grp.CvePresupuestoIngreso)) - Concepto = String.Format("{0} - {1}: {2}", NombreCliente, DdlTipoComprobante.SelectedItem.Text.ToString, TxtFolio.Text) - - If ObjAC.AddMovimiento(IDPoliza, dr("IdCuentaPorEjecutar").ToString.ToEntero, False, Paridad * grp.TotalImporte, "", Concepto, 0, Fecha, "") Then - If ObjAC.AddMovimiento(IDPoliza, dr("IdCuentaDevengado").ToString.ToEntero, True, Paridad * grp.TotalImporte, "", Concepto, 0, Fecha, "") Then - 'CARGO la deuda del cliente - If ObjAC.AddMovimiento(IDPoliza, CtaCliente, TipoMovto, grp.TotalImporte, "", Concepto, 0, Fecha, "") Then - 'abono, - If Not ObjAC.AddMovimiento(IDPoliza, dr("IdCuentaMatriz").ToString.ToEntero, Not TipoMovto, grp.TotalImporte, "", Concepto, 0, Fecha, "") Then - ErrorAC = True - End If - Else - ErrorAC = True - End If - Else - ErrorAC = True - End If - Else - ErrorAC = True - End If - Next - - 'Case "OP", "Com" - ' Dim Importe As Decimal = 0 - ' If ObjAC.AddMovimiento(123456, IDPoliza, CtaCliente, False, Importe, "", Concepto, 0, Fecha, "") Then - ' If ObjAC.AddMovimiento(123456, IDPoliza, CtaCliente, True, Importe, "", Concepto, 0, Fecha, "") Then - - ' End If - ' End If - 'End Select - End If - - Else - ErrorAC = True - - End If - - If Not ErrorAC Then - ObjAC.AjustaPoliza(IDPoliza) - - Retorno = IDPoliza - Else - - Alert("Error al agregar la Póliza de AC.", TipoMensaje.MsgError) - End If - - ' ObjAC.Dispose() - - Return Retorno - - End Function - Private Function GenerarPolizaAC(ObjAC As ClsContPAQi, Optional CancelacionIngreso As Boolean = False) As Integer - Dim Retorno As Integer = 0 - Dim IDPoliza As Integer = 0 - - Dim ErrorAC As Boolean = False - 'Dim ObjAC As New ClsContPAQi(UsuarioActual.Empresa) : ObjAC.IniciaTransacSQL() - Dim Fecha As Date = TxtFecha.Text.ToDate - Dim Concepto As String = String.Format("GD {0}", NombreCliente) - Dim Paridad As Integer = 1 - Dim TipoMovto As Boolean = False - - If CancelacionIngreso Then - Concepto = String.Format("Cancelación GD {0}", NombreCliente) - Paridad = -1 - TipoMovto = True - End If - - Dim TipoPoliza = If(DdlTipoComprobante.SelectedValue.ToString = "OP" Or DdlTipoComprobante.SelectedValue.ToString = "Com", 3, 1) - - IDPoliza = ObjAC.AddPoliza(TipoPoliza, Concepto, TxtTotal.Text.ToDouble * 2, TxtTotal.Text.ToDouble * 2, UsuarioActual.CveUsuario, Fecha) - Dim dr As DataRow ' = DTPresupuestoIngresos.FiltroPrimero(String.Format("CvePresupuestoIngreso = {0}", DdlFuenteRecaudacion.SelectedValue)) - 'Dim Importe As Double = TxtTotal.Text.ToDouble - Dim CtaCliente As Integer = ViewState("IdCtaContClientes").ToString.ToEntero - Dim CtaISSSTESON As Integer = 643 - Dim CtaISPT As Integer = 1745 - ' Dim NombreCliente As String = ViewState("NombreCliente").ToString - - If IDPoliza > 0 Then - - 'Orden de PAGO - If DdlTipoComprobante.SelectedValue.ToString = "OP" Then - - If DdlOrdenPago.SelectedValue.ToEntero = 1 Then - 'ISSSTESON - - If ObjAC.AddMovimiento(IDPoliza, CtaCliente, False, Paridad * TxtTotal.Text.ToDecimal, "", Concepto, 0, Fecha, "") Then - If Not ObjAC.AddMovimiento(IDPoliza, CtaISSSTESON, True, Paridad * TxtTotal.Text.ToDecimal, "", Concepto, 0, Fecha, "") Then - ErrorAC = True - End If - Else - ErrorAC = True - End If - - Else - 'ISPT - - If ObjAC.AddMovimiento(IDPoliza, CtaCliente, False, Paridad * TxtTotal.Text.ToDecimal, "", Concepto, 0, Fecha, "") Then - If Not ObjAC.AddMovimiento(IDPoliza, CtaISPT, True, Paridad * TxtTotal.Text.ToDecimal, "", Concepto, 0, Fecha, "") Then - ErrorAC = True - End If - Else - ErrorAC = True - End If - End If - - ' NORMAL - Else - Dim Detalles = From gvr As GridViewRow In GvPS.Rows.Cast(Of GridViewRow)() - Group gvr By Grp = New With { - Key .CvePresupuestoIngreso = gvr.FCDropDownList("DdlFR").SelectedValue.ToEntero - } Into Group - Select Grp.CvePresupuestoIngreso, - TotalImporte = Group.Sum(Function(r) r.FCLiteral("LtlTotal").Text.ToDouble) - - - 'Select Case TipoComprobante - ' Case "Ing", "Egs" - For Each grp In Detalles - dr = DTPresupuestoIngresos.FiltroPrimero(String.Format("CvePresupuestoIngreso = {0}", grp.CvePresupuestoIngreso)) - Concepto = String.Format("{0} - {1}: {2}", NombreCliente, DdlTipoComprobante.SelectedItem.Text.ToString, TxtFolio.Text) - - If ObjAC.AddMovimiento(IDPoliza, dr("IdCuentaPorEjecutar").ToString.ToEntero, False, Paridad * grp.TotalImporte, "", Concepto, 0, Fecha, "") Then - If ObjAC.AddMovimiento(IDPoliza, dr("IdCuentaDevengado").ToString.ToEntero, True, Paridad * grp.TotalImporte, "", Concepto, 0, Fecha, "") Then - 'CARGO la deuda del cliente - If ObjAC.AddMovimiento(IDPoliza, CtaCliente, TipoMovto, grp.TotalImporte, "", Concepto, 0, Fecha, "") Then - 'abono, - If Not ObjAC.AddMovimiento(IDPoliza, dr("IdCuentaMatriz").ToString.ToEntero, Not TipoMovto, grp.TotalImporte, "", Concepto, 0, Fecha, "") Then - ErrorAC = True - End If - Else - ErrorAC = True - End If - Else - ErrorAC = True - End If - Else - ErrorAC = True - End If - Next - - 'Case "OP", "Com" - ' Dim Importe As Decimal = 0 - ' If ObjAC.AddMovimiento(123456, IDPoliza, CtaCliente, False, Importe, "", Concepto, 0, Fecha, "") Then - ' If ObjAC.AddMovimiento(123456, IDPoliza, CtaCliente, True, Importe, "", Concepto, 0, Fecha, "") Then - - ' End If - ' End If - 'End Select - End If - - Else - ErrorAC = True - - End If - - If Not ErrorAC Then - ObjAC.AjustaPoliza(IDPoliza) - - Retorno = IDPoliza - Else - - Alert("Error al Agregar la Póliza de AC.", TipoMensaje.MsgError) - End If - - ' ObjAC.Dispose() - - Return Retorno - - End Function - Private Sub SetValues() - ViewState("TipoCambio") = 1 - - If UsuarioActual.Empresa.MostrarRetIVA Then TrRetIVA.Style.Add("display", "") - If UsuarioActual.Empresa.MostrarRetISR Then TrRetISR.Style.Add("display", "") - - If UsuarioActual.CveEmpresa.Contiene(72, 80) Then ' agregar en el modal de PS. que forme el código del producto - TxtPS.Enabled = False - DivDdlTipo.Visible = True - DivTxtModelo.Visible = True - DivTxtAdicional.Visible = True - DdlTipo.Attributes.Add("onChange", "CreaDescripcionPS();") - DdlMarcaPSDes.Attributes.Add("onChange", "CreaDescripcionPS();") - TxtModelo.Attributes.Add("onKeyUp ", "CreaDescripcionPS();") - TxtAdicional.Attributes.Add("onKeyUp ", "CreaDescripcionPS();") - - CargaClasificacionesDetalles() - ClasificacionModal() - - End If - - If Not UsuarioActual.CveEmpresa.Contiene(1, 119) Then 'PAGO CON TERMINAL PARA JAM - RBLPago.Items.RemoveAt(2) - End If - - - End Sub - Private Sub SetPermisos() - If CveVenta < 1 Then - 'Puede cotizar - If Not UsuarioActual.TienePermisoProceso(59) Then - DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Cot")) - End If - - 'Puede Hacer NC - If Not UsuarioActual.TienePermisoProceso(175) Then - DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Egs")) - End If - - 'Puede Hacer Devolución - If Not UsuarioActual.TienePermisoProceso(264) Then - DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Dev")) - End If - - 'Puede facturar - If Not UsuarioActual.TienePermisoProceso(60) Then - DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ing")) - DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ant")) - DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Egs")) - DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Dev")) - End If - - 'Puede remisionar - If Not UsuarioActual.TienePermisoProceso(199) Then - DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Rem")) - LnkFacturarRemision.Visible = False - LnkRemisiones.Visible = False - End If - - '[IPP]: FALTA CONFIGURAR Y DAR PERMISO A TODOS LOS QUE TENGAN ACCESO A VENTAS - ''Puede remisionar - 'If Not UsuarioActual.TienePermisoProceso(199) Then - ' DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Rem")) - 'End If - - ''MODO SOLO LECTURA - 'If DdlTipoComprobante.Items.Count = 0 Then - ' DdlTipoComprobante.Items.Insert(0, New ListItem("Solo lectura", "-1")) - ' TrBotones.Visible = False - 'End If - - ConfiguraTipoDocto() - End If - End Sub - Private Sub CalculaTotalesVenta(Optional RecalculaImpuestosLocales As Boolean = True) - - Dim TotalSubTotal As Decimal = TmpDT.SUM("TotalImporte").ToDecimal - Dim TotalDescuentos As Decimal = TmpDT.SUM("Descuento").ToDecimal - Dim TotalAmortizacion As Decimal = LblAmortizacion.Text.ToDecimal - Dim TotalIVA As Decimal = TmpDT.SUM("ImporteIVA").ToDecimal - Dim TotalIEPS As Decimal = TmpDT.SUM("ImporteIEPS").ToDecimal - Dim TotalRetIVA As Decimal = TmpDT.SUM("ImporteRetIVA").ToDecimal - Dim TotalRetISR As Decimal = TmpDT.SUM("ImporteRetISR").ToDecimal - Dim Total As Decimal = 0 - Dim TotalImpuestosLocales As Decimal = 0 - - If TotalAmortizacion > 0 AndAlso TotalSubTotal = TotalAmortizacion Then ' si se amortizó completa la factura, debe de limpiar los impuestos - If DdlTipoAmortizacionAnticipo.SelectedValue.Contiene("3") Then - For Each dr As DataRow In TmpDT.Rows - dr("ImporteIVA") = 0 : dr("ImporteIEPS") = 0 : dr("ImporteRetIVA") = 0 : dr("ImporteRetISR") = 0 : dr("PorcentajeIVA") = 0 : dr("IVA") = 0 - Next - - If TmpDTImpuestos IsNot Nothing Then - For Each dr2 As DataRow In TmpDTImpuestos.Rows - dr2("Importe") = 0 - Next - TmpDTImpuestos.AcceptChanges() - End If - - TmpDT.AcceptChanges() - TotalIVA = TmpDT.SUM("ImporteIVA").ToDecimal - TotalIEPS = TmpDT.SUM("ImporteIEPS").ToDecimal - TotalRetIVA = TmpDT.SUM("ImporteRetIVA").ToDecimal - TotalRetISR = TmpDT.SUM("ImporteRetISR").ToDecimal - TotalImpuestosLocales = TmpDTImpuestos.SUM("Importe").ToDecimal - End If - End If - - If RecalculaImpuestosLocales AndAlso TmpDTImpuestos IsNot Nothing AndAlso TmpDTImpuestos.Rows.Count > 0 Then - If TotalSubTotal <> TotalAmortizacion Then - For Each drt As DataRow In TmpDTImpuestos.Rows - drt("Importe") = drt("Porcentaje").ToString.ToDecimal * TotalSubTotal / 100 - Next - End If - - GvImpuestosLocales2.DataSource = TmpDTImpuestos - GvImpuestosLocales2.DataBind() - End If - - For Each gvr As GridViewRow In GvImpuestosLocales2.Rows - If gvr.RowType = DataControlRowType.DataRow Then - - If gvr.FCTextBox("TxtImpuestoLocalPS").Text.ToDecimal > 0 Then - If gvr.DataKey("TipoImpuesto") = "5" Then ' traslado de imp local - TotalImpuestosLocales -= gvr.FCTextBox("TxtImpuestoLocalPS").Text.ToDecimal - Else - TotalImpuestosLocales += gvr.FCTextBox("TxtImpuestoLocalPS").Text.ToDecimal - End If - End If - End If - Next - - 'If TotalDescuentos > 0 Then GvPS.Columns(ColumnaDescuento).Visible = True : thEncDesc1.Visible = True : thEncDesc2.Visible = True Else GvPS.Columns(ColumnaDescuento).Visible = False : thEncDesc1.Visible = False : thEncDesc2.Visible = False - If TotalIEPS > 0 Then TrIEPS.Visible = True : GvPS.Columns(ColumnaIEPS).Visible = True : thEncIEPS1.Visible = True : thEncIEPS2.Visible = True Else TrIEPS.Visible = False : GvPS.Columns(ColumnaIEPS).Visible = False : thEncIEPS1.Visible = False : thEncIEPS2.Visible = False - If TotalRetIVA > 0 Then GvPS.Columns(ColumnaRetIVA).Visible = True Else GvPS.Columns(ColumnaRetIVA).Visible = False - If TotalRetISR > 0 Then GvPS.Columns(ColumnaRetISR).Visible = True Else GvPS.Columns(ColumnaRetISR).Visible = False - - If DdlTipoAmortizacionAnticipo.SelectedValue.ToEntero.Contiene(2, 1) Then - TotalAmortizacion = 0 - End If - - - Total = (TotalSubTotal - TotalDescuentos - TotalAmortizacion + TotalIVA + TotalIEPS - TotalRetIVA - TotalRetISR - TotalImpuestosLocales) - LblSubTotal1.Text = TotalSubTotal.FormatoNumero(2) - TxtSubTotal.Text = TotalSubTotal.FormatoNumero(2) - LblDescuentos.Text = TotalDescuentos.FormatoNumero - TxtSubTotal2.Text = (TotalSubTotal - TotalDescuentos - TotalAmortizacion).FormatoNumero(2) - TxtRetIVA.Text = TotalRetIVA.FormatoNumero(2) - TxtRetISR.Text = TotalRetISR.FormatoNumero(2) - TxtIVA.Text = TotalIVA.FormatoNumero - TxtIEPS.Text = TotalIEPS.FormatoNumero - TxtTotal.Text = Total.FormatoNumero - - LblAmort.Text = TxtSubTotal.Text - If CveVenta <= 0 OrElse (CveDevolucion > 0 And NuevaFactura = 1) Then - HdnVentaSaldo.Value = Total.ToString - Else - HdnVentaSaldo.Value = SaldoVenta.ToString - End If - HdnIVAOriginal.Value = TxtIVA.Text - - 'JJMQ 20160506: Se agrego para la validacion de pago de contado. - CVImporteContado.ValueToCompare = Total.ToString - - If MensajeCveSAT IsNot Nothing AndAlso MensajeCveSAT.ToString.Length > 0 Then - Alert($"Los siguientes conceptos hace falta especificar clave SAT

{MensajeCveSAT.ToString}", TipoMensaje.MsgAdvertencia) - MensajeCveSAT.Clear() - End If - - Dim view As DataView = New DataView(TmpDT) - view.Sort = "Consec" - GvPS.DataSource = view - GvPS.DataBind() - - 'RECARGA GV INVENTARIO - If Not CveVenta > 0 Then - DtInv = TmpDT.Copy.FiltraParametros("CveTipoPS = 2") - CargaGVInv(DtInv) - End If - - UpContado.Update() - UpPS.Update() - RegistraScript("BorraDescuentos();", "BorraDescuentos") - End Sub - Private Function ValidaAdendaFEMSA() As Boolean - Dim Retorno As Boolean = False - - If Not AplicaFEMSA Then - Retorno = True - Else - If TxtFEMSA_Version.Text.Trim.Length = 0 OrElse Not IsNumeric(TxtFEMSA_Version.Text.Trim) Then - Retorno = False - Alert("La versión de la Adenda es requerida y debe ser numérica. Por favor corrija.", TipoMensaje.MsgAdvertencia) - ElseIf TxtFEMSA_NumSociedad.Text.Trim.Length = 0 Then - Retorno = False - Alert("El número de Sociedad para la Adenda es requerido. Por favor capture uno.", TipoMensaje.MsgAdvertencia) - ElseIf TxtFEMSA_NumProveedor.Text.Trim.Length = 0 Then - Retorno = False - Alert("El número de Proveedor para la Adenda es requerido. Por favor capture uno.", TipoMensaje.MsgAdvertencia) - ElseIf DdlTipoComprobante.SelectedValue = "Ing" AndAlso (TxtFEMSA_NumPedido.Text.Trim.Length = 0 OrElse Not IsNumeric(TxtFEMSA_NumPedido.Text.Trim)) Then - Retorno = False - Alert("El número de Pedido para la Adenda es requerido y debe ser numérico. Por favor corrija.", TipoMensaje.MsgAdvertencia) - ElseIf DdlTipoComprobante.SelectedValue = "Ing" AndAlso (TxtFEMSA_NumEntrada.Text.Trim.Length = 0 OrElse Not IsNumeric(TxtFEMSA_NumEntrada.Text.Trim)) Then - Retorno = False - Alert("El número de Entrada para la Adenda es requerido y debe ser numérico. Por favor corrija.", TipoMensaje.MsgAdvertencia) - ElseIf DdlTipoComprobante.SelectedValue = "Ing" AndAlso TxtFEMSA_NumRemision.Text.Trim.Length = 0 Then - Retorno = False - Alert("El número de Remisión para la Adenda es requerido. Por favor capture uno.", TipoMensaje.MsgAdvertencia) - ElseIf TxtFEMSA_Mail.Text.Trim.Length = 0 Then - Retorno = False - Alert("El Mail para la Adenda es requerido. Por favor capture uno.", TipoMensaje.MsgAdvertencia) - Else - Retorno = True - End If - End If - - Return Retorno - End Function - Private Function ValidaComplementoDetallista() As Boolean - Dim Retorno As Boolean = False - - If Not AplicaDetallista Then - Retorno = True - Else - If TxtDet_OrdenCompra.Text.Trim.Length = 0 OrElse Not IsNumeric(TxtDet_OrdenCompra.Text.Trim) Then - Retorno = False - Alert("El campo Orden de Compra es requerido y debe ser numérico. Por favor corrija.", TipoMensaje.MsgAdvertencia, "") - ElseIf TxtDet_FechaOrdenCompra.Text.Trim.Length = 0 OrElse Not IsDate(TxtDet_FechaOrdenCompra.Text.Trim) Then - Retorno = False - Alert("El campo Fecha de Orden de Compra es requerido y debe de contar con un formato válido de fecha. Por favor corrija.", TipoMensaje.MsgAdvertencia) - ElseIf TxtDet_GLNComprador.Text.Trim.Length = 0 OrElse Not IsNumeric(TxtDet_GLNComprador.Text.Trim) Then - Retorno = False - Alert("El campo GLN-Comprador es requerido y debe ser numérico. Por favor corrija.", TipoMensaje.MsgAdvertencia) - ElseIf TxtDet_Departamento.Text.Trim.Length = 0 Then - Retorno = False - Alert("El campo Departamento es requerido. Por favor ingrese uno.", TipoMensaje.MsgAdvertencia) - ElseIf TxtDet_GLNVendedor.Text.Trim.Length = 0 OrElse Not IsNumeric(TxtDet_GLNVendedor.Text.Trim) Then - Retorno = False - Alert("El campo GLN-Vendedor es requerido y debe ser numérico. Por favor corrija.", TipoMensaje.MsgAdvertencia) - ElseIf TxtDet_NumProv.Text.Trim.Length = 0 Then - Retorno = False - Alert("El campo Número de Proveedor es requerido y debe ser numérico. Por favor corrija.", TipoMensaje.MsgAdvertencia) - Else - Retorno = True - End If - End If - - Return Retorno - End Function - Private Function ValidaComplementoFord() As Boolean - Dim Retorno As Boolean = False - - If Not AplicaFord Then - Retorno = True - Else - If TxtFordGSDB.Text.Trim.Length = 0 Then - Retorno = False - Alert("El campo GSDB es requerido. Por favor corrija.", TipoMensaje.MsgAdvertencia) - Else - If LstFordASN.Items.Count = 0 Then - Retorno = True - 'Alert("El campo ASN es requerido. Por favor corrija.", TipoMensaje.MsgAdvertencia) - Else - Retorno = True - End If - - End If - End If - - Return Retorno - End Function - Private Sub VinculaCotizacionVenta() - Dim ObjVentas As New ClsVentas() - ObjVentas.UpdateVentaCotizacion(CveVenta, Request("CveVenta").ToEntero) - ObjVentas.Dispose() - End Sub - Private Sub GeneraAddenda7Eleven(Archivo As String) - Dim cfdi As String = "" - Dim SB As New StringBuilder - Try - Using sr As New StreamReader(Archivo) - - cfdi = sr.ReadToEnd() - - End Using - Catch e As Exception - Alert("The file could not be read:", TipoMensaje.MsgError) - - End Try - - - cfdi = cfdi.Replace("", "") - - SB.Append(cfdi) - - SB.Append("") - SB.AppendFormat("", Txt7ElevenNumProveedor.Text.Trim) - SB.AppendFormat("", Txt7ElevenFolio.Text.Trim, Txt7ElevenTienda.Text.Trim, Txt7ElevenFecha.Text.Trim.ToDate.ToString("yyyy-MM-dd")) - - For Each Row As DataRow In TmpDT.Rows - - SB.AppendFormat("", Row("Codigo"), Row("PS"), Row("Cantidad").ToString.ToDouble.FormatoNumero(), Row("PU").ToString.ToDouble.FormatoNumero()) - - Next - - SB.Append("") - - - Using outfile As New StreamWriter(Archivo) - outfile.Write(SB.ToString()) - End Using - - 'Exit Sub - - - - 'Dim MyXmlDocument As New XmlDocument() - - 'MyXmlDocument.Load("C:/Temp/aaa.xml") - 'Dim nsmgr = New XmlNamespaceManager(MyXmlDocument.NameTable) - 'nsmgr.AddNamespace("cfdi", "http://www.sat.gob.mx/cfd/3") - 'Dim ParentElement As XmlElement = MyXmlDocument.CreateElement("cfdi:Addenda", "https://edixcfisecure.ekomercio.com/esquemas") - 'ParentElement.SetAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance") - 'ParentElement.SetAttribute("xsi:schemaLocation", "https://edixcfisecure.ekomercio.com/esquemas https:/edixcfdisecure.ekomercio.com/esquemas/7Eleven.xsd") - - 'Dim Prov As XmlElement = MyXmlDocument.CreateElement("cfdi:Proveedor", "") - 'Prov.SetAttribute("Clave", "3125") - - 'Dim ns As String = "cfdi" 'MyXmlDocument.DocumentElement.GetNamespaceOfPrefix("cfdi") - 'Dim Recepciones As XmlElement = MyXmlDocument.CreateElement("cfdi:Recepciones") - 'Recepciones.Prefix = "cfdi" - 'Dim Recepcion As XmlElement = MyXmlDocument.CreateElement("cfdi:Recepcion") - 'Recepcion.SetAttribute("folio", Txt7ElevenFolio.Text.Trim) - 'Recepcion.SetAttribute("tienda", Txt7ElevenTienda.Text.Trim) - 'Recepcion.SetAttribute("fecha", Txt7ElevenFecha.Text.Trim.ToDate.ToString("yyyy-dd-MM")) - - 'Dim Productos As XmlElement = MyXmlDocument.CreateElement("cfdi:Productos") - ''dentro de un ciclo - 'Dim Producto As XmlElement = MyXmlDocument.CreateElement("cfdi:Producto") - 'Producto.SetAttribute("codigo", "cod1") - 'Producto.SetAttribute("descripcion", "prod1") - 'Producto.SetAttribute("cantidad", "99") - 'Producto.SetAttribute("precio", "2000") - 'Productos.AppendChild(Producto) - ''fin de ciclo - - 'Recepcion.AppendChild(Productos) - - 'Recepciones.AppendChild(Recepcion) - - 'ParentElement.AppendChild(Prov) - - 'ParentElement.AppendChild(Recepciones) - - - 'MyXmlDocument.DocumentElement.AppendChild(ParentElement) - 'MyXmlDocument.Save("C:/Temp/aa.xml") - - End Sub - Protected Sub DdlFuenteRecaudacion_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlFuenteRecaudacion.SelectedIndexChanged - For Each dr As DataRow In TmpDT.Rows - dr("CvePresupuestoIngreso") = DdlFuenteRecaudacion.SelectedValue - Next - - GvPS.DataSource = TmpDT - GvPS.DataBind() - - UpPS.Update() - End Sub - Protected Sub DdlFR_SelectedIndexChanged(sender As Object, e As EventArgs) - Dim DdlFR_Gv As DropDownList = CType(sender, DropDownList) - Dim index As Integer = CType(DdlFR_Gv.NamingContainer, GridViewRow).FCLiteral("LtlConsecutivo").Text.ToString.ToEntero - - If UsuarioActual.Empresa.UsaAC Then - TmpDT(index - 1)("CvePresupuestoIngreso") = DdlFR_Gv.SelectedValue - End If - TmpDT.AcceptChanges() - End Sub - Protected Sub LnkASN_Click(sender As Object, e As EventArgs) Handles LnkASN.Click - If TxtFordASN.Text.Trim.Length > 20 Then Alert("Maximo 20 Caracteres", TipoMensaje.MsgAdvertencia) : Exit Sub - LstFordASN.Items.Add(New ListItem(TxtFordASN.Text.Trim)) - TxtFordASN.Text = "" - TxtFordASN.Focus() - End Sub - Protected Sub LnkFordQuitar_Click(sender As Object, e As EventArgs) Handles LnkFordQuitar.Click - LstFordASN.Items.RemoveAt(LstFordASN.SelectedIndex) - - End Sub - Private Sub LnkImprimir_Click(sender As Object, e As EventArgs) Handles LnkImprimir.Click - GeneraPDFCot(TxtFecha.Text.Trim.ToDate, Nothing, VentaFolio, False, False) - End Sub - Protected Sub TxtCodigo_TextChanged(sender As Object, e As System.EventArgs) Handles TxtCodigo.TextChanged - - Dim ObjClientes As New ClsClientes() - - Dim Nombre As String = "-1" - Dim Codigo As String = "-1" - Dim NombreCorto As String = "-1" - Dim RFC As String = "-1" - Dim Telefono As String = "-1" - Dim Mail As String = "-1" - - If TxtCodigo.Text.Trim <> String.Empty Then Codigo = TxtCodigo.Text.Trim - - If Codigo <> "-1" Then - If ObjClientes.GetClientes(-1, Nombre, Codigo, NombreCorto, RFC, Telefono, Mail, -1, UsuarioActual.CveEmpresa, TipoCliente:=-1) Then - If ObjClientes.DtResultados.Rows.Count > 0 Then - If UsuarioActual.CveEmpresa = 2 AndAlso UsuarioActual.CveUsuario = 77 AndAlso Not ObjClientes.CveCliente.Contiene(10450, 10460, 10458) Then - TrEmitir.Visible = False : BtnCrearApartirDe.Enabled = False : LbAgregar.Enabled = False : LnkAgregarPyME.Enabled = False : BtnBuscarCliente.Enabled = False : BtnEmitirImprimir.Visible = False : TrVistaPrevia.Visible = False - UpFacturar.Update() - Exit Sub - ElseIf UsuarioActual.CveEmpresa = 2 AndAlso UsuarioActual.CveUsuario = 21 AndAlso Not ObjClientes.CveCliente.Contiene(27448) Then - TrEmitir.Visible = False : BtnCrearApartirDe.Enabled = False : LbAgregar.Enabled = False : LnkAgregarPyME.Enabled = False : BtnBuscarCliente.Enabled = False : BtnEmitirImprimir.Visible = False : TrVistaPrevia.Visible = False - UpFacturar.Update() - Exit Sub - Else - HdnCveCliente.Value = ObjClientes.CveCliente.ToString - End If - BtnBuscarCliente_Click(sender, e) - Else - Alert("No se encontró el cliente con el código: " & TxtCodigo.Text.Trim & ".", Extensiones.TipoMensaje.MsgAdvertencia) - TxtCodigo.Text = "" - LblCliente.Text = "Cliente" - LblDireccion.Text = "Dirección" - LblColonia.Text = "Colonia" - LblCiudad.Text = "Ciudad" - LblEstado.Text = "Estado" - LblCP.Text = "00000" - LblRFC.Text = "AAA010101AAA" - LblTelefono.Text = "9999999999" - trsucursalciente.Visible = False - End If - End If - ObjClientes.Dispose() - - End If - End Sub - Protected Sub TxtFolio_TextChanged(sender As Object, e As System.EventArgs) Handles TxtFolio.TextChanged - ViewState("EstablecioFolio") = True - End Sub - Private Sub ConfiguraTipoDocto() - - 'Esconde Todo - TdOrdenPago.Visible = False - Tr33.Visible = False - - 'si tiene la funcionalidad que se active independiente del tipo de documento RMF 15-10-2017 - Tr33.Visible = True - - If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant") Then - BtnEmitirImprimir.Text = "Emitir e Imprimir" - 'TdReferencia.Style.Add("display", "none") - ElseIf DdlTipoComprobante.SelectedValue.Contiene("Egs", "Dev") Then - BtnEmitirImprimir.Text = "Emitir e Imprimir" - 'TdReferencia.Style.Remove("display") - ElseIf DdlTipoComprobante.SelectedValue = "Rem" Then - BtnEmitirImprimir.Text = "Registrar" - 'TdReferencia.Style.Add("display", "none") - ElseIf DdlTipoComprobante.SelectedValue.Contiene("Ped", "PeC", "PA", "Pd2") Then - BtnEmitirImprimir.Text = "Registrar" - 'TdReferencia.Style.Add("display", "none") - ElseIf DdlTipoComprobante.SelectedValue = "Cot" Then - BtnEmitirImprimir.Text = "Cotizar" - 'TdReferencia.Style.Add("display", "none") - - 'FACTURACION 3.3 - Tr33.Visible = True - - ElseIf DdlTipoComprobante.SelectedValue = "Com" Then - BtnEmitirImprimir.Text = "Registrar" - 'TdReferencia.Style.Add("display", "none") - ElseIf DdlTipoComprobante.SelectedValue.ToString = "OP" Then - BtnEmitirImprimir.Text = "Registrar" - TdOrdenPago.Visible = True - End If - - UpFacturar.Update() - - End Sub - Private Sub EliminaPoliza() - Dim ObjAC As New ClsContPAQi(UsuarioActual.Empresa) - ObjAC.IniciaTransacSQL() - Dim ObjConta As New ClsContabilidad - ObjConta.IniciaTransacSQL() - - Dim ErrorMovimiento = False - - 'Elimina la poliza - If (UsuarioActual.Empresa.UsaAC Or UsuarioActual.Empresa.UsaContabilidad) AndAlso IdPoliza > 0 Then - If Not ObjAC.RemovePoliza(IdPoliza) Then +#Region "M E T O D O S" + Private Sub CargaOtrosConceptos() + Dim ObjVentas As New ClsVentas + If ObjVentas.GetVentaOtrosConceptos(UsuarioActual.CveEmpresa, CveVenta) Then + GVOtrosConceptos.DataSource = ObjVentas.DtResultados + GVOtrosConceptos.DataBind() + UpOtrosConceptos.Update() + End If + ObjVentas.Dispose() + End Sub + Private Function GenerarPolizaAC(ObjAC As ClsContPAQi, factura As Modelos.Factura, Optional CancelacionIngreso As Boolean = False) As Integer + Dim Retorno As Integer = 0 + Dim IDPoliza As Integer = 0 + + Dim ErrorAC As Boolean = False + 'Dim ObjAC As New ClsContPAQi(UsuarioActual.Empresa) : ObjAC.IniciaTransacSQL() + Dim Fecha As Date = factura.Fecha + Dim Concepto As String = String.Format("GD {0}", factura.Cliente.Nombre) + Dim Paridad As Integer = 1 + Dim TipoMovto As Boolean = False + + If CancelacionIngreso Then + Concepto = String.Format("Cancelación GD {0}", factura.Cliente.Nombre) + Paridad = -1 + TipoMovto = True + End If + + Dim TipoPoliza = If(factura.TipoDocto = "OP" Or factura.TipoDocto = "Com", 3, 1) + + IDPoliza = ObjAC.AddPoliza(TipoPoliza, Concepto, factura.Total * 2, factura.Total * 2, factura.CveUsuario, Fecha) + Dim dr As DataRow ' = DTPresupuestoIngresos.FiltroPrimero(String.Format("CvePresupuestoIngreso = {0}", DdlFuenteRecaudacion.SelectedValue)) + 'Dim Importe As Double = TxtTotal.Text.ToDouble + Dim CtaCliente As Integer = factura.Cliente.IdCtaContClientes + Dim CtaISSSTESON As Integer = 643 + Dim CtaISPT As Integer = 1745 + ' Dim NombreCliente As String = ViewState("NombreCliente").ToString + + If IDPoliza > 0 Then + + 'Orden de PAGO + If factura.TipoDocto = "OP" Then + + If DdlOrdenPago.SelectedValue.ToEntero = 1 Then + 'ISSSTESON + + If ObjAC.AddMovimiento(IDPoliza, factura.Cliente.IdCtaContClientes, False, Paridad * factura.Total, "", Concepto, 0, Fecha, "") Then + If Not ObjAC.AddMovimiento(IDPoliza, CtaISSSTESON, True, Paridad * factura.Total, "", Concepto, 0, Fecha, "") Then + ErrorAC = True + End If + Else + ErrorAC = True + End If + + Else + 'ISPT + + If ObjAC.AddMovimiento(IDPoliza, factura.Cliente.IdCtaContClientes, False, Paridad * factura.Total, "", Concepto, 0, Fecha, "") Then + If Not ObjAC.AddMovimiento(IDPoliza, CtaISPT, True, Paridad * factura.Total, "", Concepto, 0, Fecha, "") Then + ErrorAC = True + End If + Else + ErrorAC = True + End If + End If + + ' NORMAL + Else + Dim Detalles = From gvr As GridViewRow In GvPS.Rows.Cast(Of GridViewRow)() + Group gvr By Grp = New With { + Key .CvePresupuestoIngreso = gvr.FCDropDownList("DdlFR").SelectedValue.ToEntero + } Into Group + Select Grp.CvePresupuestoIngreso, + TotalImporte = Group.Sum(Function(r) r.FCLiteral("LtlTotal").Text.ToDouble) + + + 'Select Case TipoComprobante + ' Case "Ing", "Egs" + For Each grp In Detalles + dr = DTPresupuestoIngresos.FiltroPrimero(String.Format("CvePresupuestoIngreso = {0}", grp.CvePresupuestoIngreso)) + Concepto = String.Format("{0} - {1}: {2}", NombreCliente, DdlTipoComprobante.SelectedItem.Text.ToString, TxtFolio.Text) + + If ObjAC.AddMovimiento(IDPoliza, dr("IdCuentaPorEjecutar").ToString.ToEntero, False, Paridad * grp.TotalImporte, "", Concepto, 0, Fecha, "") Then + If ObjAC.AddMovimiento(IDPoliza, dr("IdCuentaDevengado").ToString.ToEntero, True, Paridad * grp.TotalImporte, "", Concepto, 0, Fecha, "") Then + 'CARGO la deuda del cliente + If ObjAC.AddMovimiento(IDPoliza, CtaCliente, TipoMovto, grp.TotalImporte, "", Concepto, 0, Fecha, "") Then + 'abono, + If Not ObjAC.AddMovimiento(IDPoliza, dr("IdCuentaMatriz").ToString.ToEntero, Not TipoMovto, grp.TotalImporte, "", Concepto, 0, Fecha, "") Then + ErrorAC = True + End If + Else + ErrorAC = True + End If + Else + ErrorAC = True + End If + Else + ErrorAC = True + End If + Next + + 'Case "OP", "Com" + ' Dim Importe As Decimal = 0 + ' If ObjAC.AddMovimiento(123456, IDPoliza, CtaCliente, False, Importe, "", Concepto, 0, Fecha, "") Then + ' If ObjAC.AddMovimiento(123456, IDPoliza, CtaCliente, True, Importe, "", Concepto, 0, Fecha, "") Then + + ' End If + ' End If + 'End Select + End If + + Else + ErrorAC = True + + End If + + If Not ErrorAC Then + ObjAC.AjustaPoliza(IDPoliza) + + Retorno = IDPoliza + Else + + Alert("Error al agregar la Póliza de AC.", TipoMensaje.MsgError) + End If + + ' ObjAC.Dispose() + + Return Retorno + + End Function + Private Function GenerarPolizaAC(ObjAC As ClsContPAQi, Optional CancelacionIngreso As Boolean = False) As Integer + Dim Retorno As Integer = 0 + Dim IDPoliza As Integer = 0 + + Dim ErrorAC As Boolean = False + 'Dim ObjAC As New ClsContPAQi(UsuarioActual.Empresa) : ObjAC.IniciaTransacSQL() + Dim Fecha As Date = TxtFecha.Text.ToDate + Dim Concepto As String = String.Format("GD {0}", NombreCliente) + Dim Paridad As Integer = 1 + Dim TipoMovto As Boolean = False + + If CancelacionIngreso Then + Concepto = String.Format("Cancelación GD {0}", NombreCliente) + Paridad = -1 + TipoMovto = True + End If + + Dim TipoPoliza = If(DdlTipoComprobante.SelectedValue.ToString = "OP" Or DdlTipoComprobante.SelectedValue.ToString = "Com", 3, 1) + + IDPoliza = ObjAC.AddPoliza(TipoPoliza, Concepto, TxtTotal.Text.ToDouble * 2, TxtTotal.Text.ToDouble * 2, UsuarioActual.CveUsuario, Fecha) + Dim dr As DataRow ' = DTPresupuestoIngresos.FiltroPrimero(String.Format("CvePresupuestoIngreso = {0}", DdlFuenteRecaudacion.SelectedValue)) + 'Dim Importe As Double = TxtTotal.Text.ToDouble + Dim CtaCliente As Integer = ViewState("IdCtaContClientes").ToString.ToEntero + Dim CtaISSSTESON As Integer = 643 + Dim CtaISPT As Integer = 1745 + ' Dim NombreCliente As String = ViewState("NombreCliente").ToString + + If IDPoliza > 0 Then + + 'Orden de PAGO + If DdlTipoComprobante.SelectedValue.ToString = "OP" Then + + If DdlOrdenPago.SelectedValue.ToEntero = 1 Then + 'ISSSTESON + + If ObjAC.AddMovimiento(IDPoliza, CtaCliente, False, Paridad * TxtTotal.Text.ToDecimal, "", Concepto, 0, Fecha, "") Then + If Not ObjAC.AddMovimiento(IDPoliza, CtaISSSTESON, True, Paridad * TxtTotal.Text.ToDecimal, "", Concepto, 0, Fecha, "") Then + ErrorAC = True + End If + Else + ErrorAC = True + End If + + Else + 'ISPT + + If ObjAC.AddMovimiento(IDPoliza, CtaCliente, False, Paridad * TxtTotal.Text.ToDecimal, "", Concepto, 0, Fecha, "") Then + If Not ObjAC.AddMovimiento(IDPoliza, CtaISPT, True, Paridad * TxtTotal.Text.ToDecimal, "", Concepto, 0, Fecha, "") Then + ErrorAC = True + End If + Else + ErrorAC = True + End If + End If + + ' NORMAL + Else + Dim Detalles = From gvr As GridViewRow In GvPS.Rows.Cast(Of GridViewRow)() + Group gvr By Grp = New With { + Key .CvePresupuestoIngreso = gvr.FCDropDownList("DdlFR").SelectedValue.ToEntero + } Into Group + Select Grp.CvePresupuestoIngreso, + TotalImporte = Group.Sum(Function(r) r.FCLiteral("LtlTotal").Text.ToDouble) + + + 'Select Case TipoComprobante + ' Case "Ing", "Egs" + For Each grp In Detalles + dr = DTPresupuestoIngresos.FiltroPrimero(String.Format("CvePresupuestoIngreso = {0}", grp.CvePresupuestoIngreso)) + Concepto = String.Format("{0} - {1}: {2}", NombreCliente, DdlTipoComprobante.SelectedItem.Text.ToString, TxtFolio.Text) + + If ObjAC.AddMovimiento(IDPoliza, dr("IdCuentaPorEjecutar").ToString.ToEntero, False, Paridad * grp.TotalImporte, "", Concepto, 0, Fecha, "") Then + If ObjAC.AddMovimiento(IDPoliza, dr("IdCuentaDevengado").ToString.ToEntero, True, Paridad * grp.TotalImporte, "", Concepto, 0, Fecha, "") Then + 'CARGO la deuda del cliente + If ObjAC.AddMovimiento(IDPoliza, CtaCliente, TipoMovto, grp.TotalImporte, "", Concepto, 0, Fecha, "") Then + 'abono, + If Not ObjAC.AddMovimiento(IDPoliza, dr("IdCuentaMatriz").ToString.ToEntero, Not TipoMovto, grp.TotalImporte, "", Concepto, 0, Fecha, "") Then + ErrorAC = True + End If + Else + ErrorAC = True + End If + Else + ErrorAC = True + End If + Else + ErrorAC = True + End If + Next + + 'Case "OP", "Com" + ' Dim Importe As Decimal = 0 + ' If ObjAC.AddMovimiento(123456, IDPoliza, CtaCliente, False, Importe, "", Concepto, 0, Fecha, "") Then + ' If ObjAC.AddMovimiento(123456, IDPoliza, CtaCliente, True, Importe, "", Concepto, 0, Fecha, "") Then + + ' End If + ' End If + 'End Select + End If + + Else + ErrorAC = True + + End If + + If Not ErrorAC Then + ObjAC.AjustaPoliza(IDPoliza) + + Retorno = IDPoliza + Else + + Alert("Error al Agregar la Póliza de AC.", TipoMensaje.MsgError) + End If + + ' ObjAC.Dispose() + + Return Retorno + + End Function + Private Sub SetValues() + ViewState("TipoCambio") = 1 + + If UsuarioActual.Empresa.MostrarRetIVA Then TrRetIVA.Style.Add("display", "") + If UsuarioActual.Empresa.MostrarRetISR Then TrRetISR.Style.Add("display", "") + + If UsuarioActual.CveEmpresa.Contiene(72, 80) Then ' agregar en el modal de PS. que forme el código del producto + TxtPS.Enabled = False + DivDdlTipo.Visible = True + DivTxtModelo.Visible = True + DivTxtAdicional.Visible = True + DdlTipo.Attributes.Add("onChange", "CreaDescripcionPS();") + DdlMarcaPSDes.Attributes.Add("onChange", "CreaDescripcionPS();") + TxtModelo.Attributes.Add("onKeyUp ", "CreaDescripcionPS();") + TxtAdicional.Attributes.Add("onKeyUp ", "CreaDescripcionPS();") + + CargaClasificacionesDetalles() + ClasificacionModal() + + End If + + If Not UsuarioActual.CveEmpresa.Contiene(1, 119) Then 'PAGO CON TERMINAL PARA JAM + RBLPago.Items.RemoveAt(2) + End If + + + End Sub + Private Sub SetPermisos() + If CveVenta < 1 Then + 'Puede cotizar + If Not UsuarioActual.TienePermisoProceso(59) Then + DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Cot")) + End If + + 'Puede Hacer NC + If Not UsuarioActual.TienePermisoProceso(175) Then + DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Egs")) + End If + + 'Puede Hacer Devolución + If Not UsuarioActual.TienePermisoProceso(264) Then + DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Dev")) + End If + + 'Puede facturar + If Not UsuarioActual.TienePermisoProceso(60) Then + DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ing")) + DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ant")) + DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Egs")) + DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Dev")) + End If + + 'Puede remisionar + If Not UsuarioActual.TienePermisoProceso(199) Then + DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Rem")) + LnkFacturarRemision.Visible = False + LnkRemisiones.Visible = False + End If + + '[IPP]: FALTA CONFIGURAR Y DAR PERMISO A TODOS LOS QUE TENGAN ACCESO A VENTAS + ''Puede remisionar + 'If Not UsuarioActual.TienePermisoProceso(199) Then + ' DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Rem")) + 'End If + + ''MODO SOLO LECTURA + 'If DdlTipoComprobante.Items.Count = 0 Then + ' DdlTipoComprobante.Items.Insert(0, New ListItem("Solo lectura", "-1")) + ' TrBotones.Visible = False + 'End If + + ConfiguraTipoDocto() + End If + End Sub + Private Sub CalculaTotalesVenta(Optional RecalculaImpuestosLocales As Boolean = True) + + Dim TotalSubTotal As Decimal = TmpDT.SUM("TotalImporte").ToDecimal + Dim TotalDescuentos As Decimal = TmpDT.SUM("Descuento").ToDecimal + Dim TotalAmortizacion As Decimal = LblAmortizacion.Text.ToDecimal + Dim TotalIVA As Decimal = TmpDT.SUM("ImporteIVA").ToDecimal + Dim TotalIEPS As Decimal = TmpDT.SUM("ImporteIEPS").ToDecimal + Dim TotalRetIVA As Decimal = TmpDT.SUM("ImporteRetIVA").ToDecimal + Dim TotalRetISR As Decimal = TmpDT.SUM("ImporteRetISR").ToDecimal + Dim Total As Decimal = 0 + Dim TotalImpuestosLocales As Decimal = 0 + + If TotalAmortizacion > 0 AndAlso TotalSubTotal = TotalAmortizacion Then ' si se amortizó completa la factura, debe de limpiar los impuestos + If DdlTipoAmortizacionAnticipo.SelectedValue.Contiene("3") Then + For Each dr As DataRow In TmpDT.Rows + dr("ImporteIVA") = 0 : dr("ImporteIEPS") = 0 : dr("ImporteRetIVA") = 0 : dr("ImporteRetISR") = 0 : dr("PorcentajeIVA") = 0 : dr("IVA") = 0 + Next + + If TmpDTImpuestos IsNot Nothing Then + For Each dr2 As DataRow In TmpDTImpuestos.Rows + dr2("Importe") = 0 + Next + TmpDTImpuestos.AcceptChanges() + End If + + TmpDT.AcceptChanges() + TotalIVA = TmpDT.SUM("ImporteIVA").ToDecimal + TotalIEPS = TmpDT.SUM("ImporteIEPS").ToDecimal + TotalRetIVA = TmpDT.SUM("ImporteRetIVA").ToDecimal + TotalRetISR = TmpDT.SUM("ImporteRetISR").ToDecimal + TotalImpuestosLocales = TmpDTImpuestos.SUM("Importe").ToDecimal + End If + End If + + If RecalculaImpuestosLocales AndAlso TmpDTImpuestos IsNot Nothing AndAlso TmpDTImpuestos.Rows.Count > 0 Then + If TotalSubTotal <> TotalAmortizacion Then + For Each drt As DataRow In TmpDTImpuestos.Rows + drt("Importe") = drt("Porcentaje").ToString.ToDecimal * TotalSubTotal / 100 + Next + End If + + GvImpuestosLocales2.DataSource = TmpDTImpuestos + GvImpuestosLocales2.DataBind() + End If + + For Each gvr As GridViewRow In GvImpuestosLocales2.Rows + If gvr.RowType = DataControlRowType.DataRow Then + + If gvr.FCTextBox("TxtImpuestoLocalPS").Text.ToDecimal > 0 Then + If gvr.DataKey("TipoImpuesto") = "5" Then ' traslado de imp local + TotalImpuestosLocales -= gvr.FCTextBox("TxtImpuestoLocalPS").Text.ToDecimal + Else + TotalImpuestosLocales += gvr.FCTextBox("TxtImpuestoLocalPS").Text.ToDecimal + End If + End If + End If + Next + + 'If TotalDescuentos > 0 Then GvPS.Columns(ColumnaDescuento).Visible = True : thEncDesc1.Visible = True : thEncDesc2.Visible = True Else GvPS.Columns(ColumnaDescuento).Visible = False : thEncDesc1.Visible = False : thEncDesc2.Visible = False + If TotalIEPS > 0 Then TrIEPS.Visible = True : GvPS.Columns(ColumnaIEPS).Visible = True : thEncIEPS1.Visible = True : thEncIEPS2.Visible = True Else TrIEPS.Visible = False : GvPS.Columns(ColumnaIEPS).Visible = False : thEncIEPS1.Visible = False : thEncIEPS2.Visible = False + If TotalRetIVA > 0 Then GvPS.Columns(ColumnaRetIVA).Visible = True Else GvPS.Columns(ColumnaRetIVA).Visible = False + If TotalRetISR > 0 Then GvPS.Columns(ColumnaRetISR).Visible = True Else GvPS.Columns(ColumnaRetISR).Visible = False + + If DdlTipoAmortizacionAnticipo.SelectedValue.ToEntero.Contiene(2, 1) Then + TotalAmortizacion = 0 + End If + + + Total = (TotalSubTotal - TotalDescuentos - TotalAmortizacion + TotalIVA + TotalIEPS - TotalRetIVA - TotalRetISR - TotalImpuestosLocales) + LblSubTotal1.Text = TotalSubTotal.FormatoNumero(2) + TxtSubTotal.Text = TotalSubTotal.FormatoNumero(2) + LblDescuentos.Text = TotalDescuentos.FormatoNumero + TxtSubTotal2.Text = (TotalSubTotal - TotalDescuentos - TotalAmortizacion).FormatoNumero(2) + TxtRetIVA.Text = TotalRetIVA.FormatoNumero(2) + TxtRetISR.Text = TotalRetISR.FormatoNumero(2) + TxtIVA.Text = TotalIVA.FormatoNumero + TxtIEPS.Text = TotalIEPS.FormatoNumero + TxtTotal.Text = Total.FormatoNumero + + LblAmort.Text = TxtSubTotal.Text + If CveVenta <= 0 OrElse (CveDevolucion > 0 And NuevaFactura = 1) Then + HdnVentaSaldo.Value = Total.ToString + Else + HdnVentaSaldo.Value = SaldoVenta.ToString + End If + HdnIVAOriginal.Value = TxtIVA.Text + + 'JJMQ 20160506: Se agrego para la validacion de pago de contado. + CVImporteContado.ValueToCompare = Total.ToString + + If MensajeCveSAT IsNot Nothing AndAlso MensajeCveSAT.ToString.Length > 0 Then + Alert($"Los siguientes conceptos hace falta especificar clave SAT

{MensajeCveSAT.ToString}", TipoMensaje.MsgAdvertencia) + MensajeCveSAT.Clear() + End If + + Dim view As DataView = New DataView(TmpDT) + view.Sort = "Consec" + GvPS.DataSource = view + GvPS.DataBind() + + 'RECARGA GV INVENTARIO + If Not CveVenta > 0 Then + DtInv = TmpDT.Copy.FiltraParametros("CveTipoPS = 2") + CargaGVInv(DtInv) + End If + + UpContado.Update() + UpPS.Update() + RegistraScript("BorraDescuentos();", "BorraDescuentos") + End Sub + Private Function ValidaAdendaFEMSA() As Boolean + Dim Retorno As Boolean = False + + If Not AplicaFEMSA Then + Retorno = True + Else + If TxtFEMSA_Version.Text.Trim.Length = 0 OrElse Not IsNumeric(TxtFEMSA_Version.Text.Trim) Then + Retorno = False + Alert("La versión de la Adenda es requerida y debe ser numérica. Por favor corrija.", TipoMensaje.MsgAdvertencia) + ElseIf TxtFEMSA_NumSociedad.Text.Trim.Length = 0 Then + Retorno = False + Alert("El número de Sociedad para la Adenda es requerido. Por favor capture uno.", TipoMensaje.MsgAdvertencia) + ElseIf TxtFEMSA_NumProveedor.Text.Trim.Length = 0 Then + Retorno = False + Alert("El número de Proveedor para la Adenda es requerido. Por favor capture uno.", TipoMensaje.MsgAdvertencia) + ElseIf DdlTipoComprobante.SelectedValue = "Ing" AndAlso (TxtFEMSA_NumPedido.Text.Trim.Length = 0 OrElse Not IsNumeric(TxtFEMSA_NumPedido.Text.Trim)) Then + Retorno = False + Alert("El número de Pedido para la Adenda es requerido y debe ser numérico. Por favor corrija.", TipoMensaje.MsgAdvertencia) + ElseIf DdlTipoComprobante.SelectedValue = "Ing" AndAlso (TxtFEMSA_NumEntrada.Text.Trim.Length = 0 OrElse Not IsNumeric(TxtFEMSA_NumEntrada.Text.Trim)) Then + Retorno = False + Alert("El número de Entrada para la Adenda es requerido y debe ser numérico. Por favor corrija.", TipoMensaje.MsgAdvertencia) + ElseIf DdlTipoComprobante.SelectedValue = "Ing" AndAlso TxtFEMSA_NumRemision.Text.Trim.Length = 0 Then + Retorno = False + Alert("El número de Remisión para la Adenda es requerido. Por favor capture uno.", TipoMensaje.MsgAdvertencia) + ElseIf TxtFEMSA_Mail.Text.Trim.Length = 0 Then + Retorno = False + Alert("El Mail para la Adenda es requerido. Por favor capture uno.", TipoMensaje.MsgAdvertencia) + Else + Retorno = True + End If + End If + + Return Retorno + End Function + Private Function ValidaComplementoDetallista() As Boolean + Dim Retorno As Boolean = False + + If Not AplicaDetallista Then + Retorno = True + Else + If TxtDet_OrdenCompra.Text.Trim.Length = 0 OrElse Not IsNumeric(TxtDet_OrdenCompra.Text.Trim) Then + Retorno = False + Alert("El campo Orden de Compra es requerido y debe ser numérico. Por favor corrija.", TipoMensaje.MsgAdvertencia, "") + ElseIf TxtDet_FechaOrdenCompra.Text.Trim.Length = 0 OrElse Not IsDate(TxtDet_FechaOrdenCompra.Text.Trim) Then + Retorno = False + Alert("El campo Fecha de Orden de Compra es requerido y debe de contar con un formato válido de fecha. Por favor corrija.", TipoMensaje.MsgAdvertencia) + ElseIf TxtDet_GLNComprador.Text.Trim.Length = 0 OrElse Not IsNumeric(TxtDet_GLNComprador.Text.Trim) Then + Retorno = False + Alert("El campo GLN-Comprador es requerido y debe ser numérico. Por favor corrija.", TipoMensaje.MsgAdvertencia) + ElseIf TxtDet_Departamento.Text.Trim.Length = 0 Then + Retorno = False + Alert("El campo Departamento es requerido. Por favor ingrese uno.", TipoMensaje.MsgAdvertencia) + ElseIf TxtDet_GLNVendedor.Text.Trim.Length = 0 OrElse Not IsNumeric(TxtDet_GLNVendedor.Text.Trim) Then + Retorno = False + Alert("El campo GLN-Vendedor es requerido y debe ser numérico. Por favor corrija.", TipoMensaje.MsgAdvertencia) + ElseIf TxtDet_NumProv.Text.Trim.Length = 0 Then + Retorno = False + Alert("El campo Número de Proveedor es requerido y debe ser numérico. Por favor corrija.", TipoMensaje.MsgAdvertencia) + Else + Retorno = True + End If + End If + + Return Retorno + End Function + Private Function ValidaComplementoFord() As Boolean + Dim Retorno As Boolean = False + + If Not AplicaFord Then + Retorno = True + Else + If TxtFordGSDB.Text.Trim.Length = 0 Then + Retorno = False + Alert("El campo GSDB es requerido. Por favor corrija.", TipoMensaje.MsgAdvertencia) + Else + If LstFordASN.Items.Count = 0 Then + Retorno = True + 'Alert("El campo ASN es requerido. Por favor corrija.", TipoMensaje.MsgAdvertencia) + Else + Retorno = True + End If + + End If + End If + + Return Retorno + End Function + Private Sub VinculaCotizacionVenta() + Dim ObjVentas As New ClsVentas() + ObjVentas.UpdateVentaCotizacion(CveVenta, Request("CveVenta").ToEntero) + ObjVentas.Dispose() + End Sub + Private Sub GeneraAddenda7Eleven(Archivo As String) + Dim cfdi As String = "" + Dim SB As New StringBuilder + Try + Using sr As New StreamReader(Archivo) + + cfdi = sr.ReadToEnd() + + End Using + Catch e As Exception + Alert("The file could not be read:", TipoMensaje.MsgError) + + End Try + + + cfdi = cfdi.Replace("", "") + + SB.Append(cfdi) + + SB.Append("") + SB.AppendFormat("", Txt7ElevenNumProveedor.Text.Trim) + SB.AppendFormat("", Txt7ElevenFolio.Text.Trim, Txt7ElevenTienda.Text.Trim, Txt7ElevenFecha.Text.Trim.ToDate.ToString("yyyy-MM-dd")) + + For Each Row As DataRow In TmpDT.Rows + + SB.AppendFormat("", Row("Codigo"), Row("PS"), Row("Cantidad").ToString.ToDouble.FormatoNumero(), Row("PU").ToString.ToDouble.FormatoNumero()) + + Next + + SB.Append("") + + + Using outfile As New StreamWriter(Archivo) + outfile.Write(SB.ToString()) + End Using + + 'Exit Sub + + + + 'Dim MyXmlDocument As New XmlDocument() + + 'MyXmlDocument.Load("C:/Temp/aaa.xml") + 'Dim nsmgr = New XmlNamespaceManager(MyXmlDocument.NameTable) + 'nsmgr.AddNamespace("cfdi", "http://www.sat.gob.mx/cfd/3") + 'Dim ParentElement As XmlElement = MyXmlDocument.CreateElement("cfdi:Addenda", "https://edixcfisecure.ekomercio.com/esquemas") + 'ParentElement.SetAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance") + 'ParentElement.SetAttribute("xsi:schemaLocation", "https://edixcfisecure.ekomercio.com/esquemas https:/edixcfdisecure.ekomercio.com/esquemas/7Eleven.xsd") + + 'Dim Prov As XmlElement = MyXmlDocument.CreateElement("cfdi:Proveedor", "") + 'Prov.SetAttribute("Clave", "3125") + + 'Dim ns As String = "cfdi" 'MyXmlDocument.DocumentElement.GetNamespaceOfPrefix("cfdi") + 'Dim Recepciones As XmlElement = MyXmlDocument.CreateElement("cfdi:Recepciones") + 'Recepciones.Prefix = "cfdi" + 'Dim Recepcion As XmlElement = MyXmlDocument.CreateElement("cfdi:Recepcion") + 'Recepcion.SetAttribute("folio", Txt7ElevenFolio.Text.Trim) + 'Recepcion.SetAttribute("tienda", Txt7ElevenTienda.Text.Trim) + 'Recepcion.SetAttribute("fecha", Txt7ElevenFecha.Text.Trim.ToDate.ToString("yyyy-dd-MM")) + + 'Dim Productos As XmlElement = MyXmlDocument.CreateElement("cfdi:Productos") + ''dentro de un ciclo + 'Dim Producto As XmlElement = MyXmlDocument.CreateElement("cfdi:Producto") + 'Producto.SetAttribute("codigo", "cod1") + 'Producto.SetAttribute("descripcion", "prod1") + 'Producto.SetAttribute("cantidad", "99") + 'Producto.SetAttribute("precio", "2000") + 'Productos.AppendChild(Producto) + ''fin de ciclo + + 'Recepcion.AppendChild(Productos) + + 'Recepciones.AppendChild(Recepcion) + + 'ParentElement.AppendChild(Prov) + + 'ParentElement.AppendChild(Recepciones) + + + 'MyXmlDocument.DocumentElement.AppendChild(ParentElement) + 'MyXmlDocument.Save("C:/Temp/aa.xml") + + End Sub + Protected Sub DdlFuenteRecaudacion_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlFuenteRecaudacion.SelectedIndexChanged + For Each dr As DataRow In TmpDT.Rows + dr("CvePresupuestoIngreso") = DdlFuenteRecaudacion.SelectedValue + Next + + GvPS.DataSource = TmpDT + GvPS.DataBind() + + UpPS.Update() + End Sub + Protected Sub DdlFR_SelectedIndexChanged(sender As Object, e As EventArgs) + Dim DdlFR_Gv As DropDownList = CType(sender, DropDownList) + Dim index As Integer = CType(DdlFR_Gv.NamingContainer, GridViewRow).FCLiteral("LtlConsecutivo").Text.ToString.ToEntero + + If UsuarioActual.Empresa.UsaAC Then + TmpDT(index - 1)("CvePresupuestoIngreso") = DdlFR_Gv.SelectedValue + End If + TmpDT.AcceptChanges() + End Sub + Protected Sub LnkASN_Click(sender As Object, e As EventArgs) Handles LnkASN.Click + If TxtFordASN.Text.Trim.Length > 20 Then Alert("Maximo 20 Caracteres", TipoMensaje.MsgAdvertencia) : Exit Sub + LstFordASN.Items.Add(New ListItem(TxtFordASN.Text.Trim)) + TxtFordASN.Text = "" + TxtFordASN.Focus() + End Sub + Protected Sub LnkFordQuitar_Click(sender As Object, e As EventArgs) Handles LnkFordQuitar.Click + LstFordASN.Items.RemoveAt(LstFordASN.SelectedIndex) + + End Sub + Private Sub LnkImprimir_Click(sender As Object, e As EventArgs) Handles LnkImprimir.Click + GeneraPDFCot(TxtFecha.Text.Trim.ToDate, Nothing, VentaFolio, False, False) + End Sub + Protected Sub TxtCodigo_TextChanged(sender As Object, e As System.EventArgs) Handles TxtCodigo.TextChanged + + Dim ObjClientes As New ClsClientes() + + Dim Nombre As String = "-1" + Dim Codigo As String = "-1" + Dim NombreCorto As String = "-1" + Dim RFC As String = "-1" + Dim Telefono As String = "-1" + Dim Mail As String = "-1" + + If TxtCodigo.Text.Trim <> String.Empty Then Codigo = TxtCodigo.Text.Trim + + If Codigo <> "-1" Then + If ObjClientes.GetClientes(-1, Nombre, Codigo, NombreCorto, RFC, Telefono, Mail, -1, UsuarioActual.CveEmpresa, TipoCliente:=-1) Then + If ObjClientes.DtResultados.Rows.Count > 0 Then + If UsuarioActual.CveEmpresa = 2 AndAlso UsuarioActual.CveUsuario = 77 AndAlso Not ObjClientes.CveCliente.Contiene(10450, 10460, 10458) Then + TrEmitir.Visible = False : BtnCrearApartirDe.Enabled = False : LbAgregar.Enabled = False : LnkAgregarPyME.Enabled = False : BtnBuscarCliente.Enabled = False : BtnEmitirImprimir.Visible = False : TrVistaPrevia.Visible = False + UpFacturar.Update() + Exit Sub + ElseIf UsuarioActual.CveEmpresa = 2 AndAlso UsuarioActual.CveUsuario = 21 AndAlso Not ObjClientes.CveCliente.Contiene(27448) Then + TrEmitir.Visible = False : BtnCrearApartirDe.Enabled = False : LbAgregar.Enabled = False : LnkAgregarPyME.Enabled = False : BtnBuscarCliente.Enabled = False : BtnEmitirImprimir.Visible = False : TrVistaPrevia.Visible = False + UpFacturar.Update() + Exit Sub + Else + HdnCveCliente.Value = ObjClientes.CveCliente.ToString + End If + BtnBuscarCliente_Click(sender, e) + Else + Alert("No se encontró el cliente con el código: " & TxtCodigo.Text.Trim & ".", Extensiones.TipoMensaje.MsgAdvertencia) + TxtCodigo.Text = "" + LblCliente.Text = "Cliente" + LblDireccion.Text = "Dirección" + LblColonia.Text = "Colonia" + LblCiudad.Text = "Ciudad" + LblEstado.Text = "Estado" + LblCP.Text = "00000" + LblRFC.Text = "AAA010101AAA" + LblTelefono.Text = "9999999999" + trsucursalciente.Visible = False + End If + End If + ObjClientes.Dispose() + + End If + End Sub + Protected Sub TxtFolio_TextChanged(sender As Object, e As System.EventArgs) Handles TxtFolio.TextChanged + ViewState("EstablecioFolio") = True + End Sub + Private Sub ConfiguraTipoDocto() + + 'Esconde Todo + TdOrdenPago.Visible = False + Tr33.Visible = False + + 'si tiene la funcionalidad que se active independiente del tipo de documento RMF 15-10-2017 + Tr33.Visible = True + + If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant") Then + BtnEmitirImprimir.Text = "Emitir e Imprimir" + 'TdReferencia.Style.Add("display", "none") + ElseIf DdlTipoComprobante.SelectedValue.Contiene("Egs", "Dev") Then + BtnEmitirImprimir.Text = "Emitir e Imprimir" + 'TdReferencia.Style.Remove("display") + ElseIf DdlTipoComprobante.SelectedValue = "Rem" Then + BtnEmitirImprimir.Text = "Registrar" + 'TdReferencia.Style.Add("display", "none") + ElseIf DdlTipoComprobante.SelectedValue.Contiene("Ped", "PeC", "PA", "Pd2") Then + BtnEmitirImprimir.Text = "Registrar" + 'TdReferencia.Style.Add("display", "none") + ElseIf DdlTipoComprobante.SelectedValue = "Cot" Then + BtnEmitirImprimir.Text = "Cotizar" + 'TdReferencia.Style.Add("display", "none") + + 'FACTURACION 3.3 + Tr33.Visible = True + + ElseIf DdlTipoComprobante.SelectedValue = "Com" Then + BtnEmitirImprimir.Text = "Registrar" + 'TdReferencia.Style.Add("display", "none") + ElseIf DdlTipoComprobante.SelectedValue.ToString = "OP" Then + BtnEmitirImprimir.Text = "Registrar" + TdOrdenPago.Visible = True + End If + + UpFacturar.Update() + + End Sub + Private Sub EliminaPoliza() + Dim ObjAC As New ClsContPAQi(UsuarioActual.Empresa) + ObjAC.IniciaTransacSQL() + Dim ObjConta As New ClsContabilidad + ObjConta.IniciaTransacSQL() + + Dim ErrorMovimiento = False + + 'Elimina la poliza + If (UsuarioActual.Empresa.UsaAC Or UsuarioActual.Empresa.UsaContabilidad) AndAlso IdPoliza > 0 Then + If Not ObjAC.RemovePoliza(IdPoliza) Then + ErrorMovimiento = True + End If + End If + + 'Desasocia la poliza + If Not ErrorMovimiento Then + If Not ObjConta.DesasociarPoliza(IdPoliza, UsuarioActual.CveEmpresa) Then + ErrorMovimiento = True + End If + End If + + If Not ErrorMovimiento Then + If Not ObjConta.UpdatePrePolizasDetalleBloquear(CvePrePoliza, False) Then ErrorMovimiento = True End If - End If - - 'Desasocia la poliza - If Not ErrorMovimiento Then - If Not ObjConta.DesasociarPoliza(IdPoliza, UsuarioActual.CveEmpresa) Then - ErrorMovimiento = True - End If - End If - - If Not ErrorMovimiento Then - Alert("La póliza ha sido desvinculada y eliminada con éxito.", TipoMensaje.MsgInformacion) - ObjAC.Commit() - ObjConta.Commit() - BtnDescontabilizar.Visible = False - Else - Alert("Ocurrió un error al desvincular y/o eliminar la póliza. Por favor intente de nuevo ", TipoMensaje.MsgError) - ObjAC.RollBack() - ObjConta.RollBack() - End If - - ObjAC.Dispose() - ObjConta.Dispose() - - End Sub - Protected Sub DdlPS_SelectedIndexChanged1(sender As Object, e As EventArgs) - Dim Ddl As DropDownList = CType(sender, DropDownList) - Dim gvr As GridViewRow = CType(Ddl.BindingContainer, GridViewRow) - gvr.FCDropDownList("DdlUnidadMedida").DataSource = GlobalDTProductosServiciosEquivalencias(Ddl.SelectedValue.ToEntero, -1) - gvr.FCDropDownList("DdlUnidadMedida").DataBind() - - End Sub - Private Function TraspasoAlmacen(ByRef ObjInventario As ClsInventarios, CveRemision As Integer, ByRef ObjConta As ClsContabilidad, ConSalida As Boolean, ConceptoMovimiento As Integer) As Boolean + End If + + If Not ErrorMovimiento Then + Alert("La póliza ha sido desvinculada y eliminada con éxito.", TipoMensaje.MsgInformacion) + ObjAC.Commit() + ObjConta.Commit() + BtnDescontabilizar.Visible = False + Else + Alert("Ocurrió un error al desvincular y/o eliminar la póliza. Por favor intente de nuevo ", TipoMensaje.MsgError) + ObjAC.RollBack() + ObjConta.RollBack() + End If + + ObjAC.Dispose() + ObjConta.Dispose() + + End Sub + Protected Sub DdlPS_SelectedIndexChanged1(sender As Object, e As EventArgs) + Dim Ddl As DropDownList = CType(sender, DropDownList) + Dim gvr As GridViewRow = CType(Ddl.BindingContainer, GridViewRow) + gvr.FCDropDownList("DdlUnidadMedida").DataSource = GlobalDTProductosServiciosEquivalencias(Ddl.SelectedValue.ToEntero, -1) + gvr.FCDropDownList("DdlUnidadMedida").DataBind() + + End Sub + Private Function TraspasoAlmacen(ByRef ObjInventario As ClsInventarios, CveRemision As Integer, ByRef ObjConta As ClsContabilidad, ConSalida As Boolean, ConceptoMovimiento As Integer) As Boolean Dim OcurrioError As Boolean = False Try Dim DtMovimientos As DataTable @@ -14906,9 +14915,9 @@ Partial Class Ventas Try 'If ValorInventario <> 0 Then If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, False, ValorInventario, ObjFactura.SerieFolio, 69, ObjFactura.SerieFolio, ObjFactura.Fecha, IdCtaContable, -1, CveVenta:=CveVenta, CveCliente:=ObjFactura.CveCliente, CveClasificacion:=RowInv("CveClasificacion").ToString.ToEntero, CveMovimientoAlmacen:=CveMovimientoInventario, ImporteMX:=ValorInventario, CveCuenta:=CveCuenta, CveSubProyecto:=ObjFactura.CveSubProyecto) Then - OcurrioError = True - Exit For - End If + OcurrioError = True + Exit For + End If 'End If Catch ex As Exception OcurrioError = True