diff --git a/App_Code/ClsVentas.vb b/App_Code/ClsVentas.vb index dc07b5d17..448b3e53a 100644 --- a/App_Code/ClsVentas.vb +++ b/App_Code/ClsVentas.vb @@ -1,3875 +1,3879 @@ -Option Explicit On -Option Strict On - -Imports System.Data -Imports System.Data.SqlClient -Imports Extensiones -Imports System -Imports System.Configuration - -Public Class ClsVentas - Implements IDisposable - -#Region "Campos" - - 'SQL - Private SqlConexion As SqlConnection - Private SqlAdapter As SqlDataAdapter - Private SqlCommand As SqlCommand - Private SqlTransacc As SqlTransaction - Private Data As DataTable - Private Dataset As DataSet - - 'Atributos de la clase - Private disposedValue As Boolean = False ' Para detectar llamadas redundantes - -#End Region - -#Region "Propiedades" - Public ReadOnly Property DtResultados() As DataTable - Get - DtResultados = Data - End Get - End Property - Public ReadOnly Property DataSetResultados() As DataSet - Get - DataSetResultados = Dataset - End Get - End Property - - Public Property CveVenta As Integer - Public Property CveVentaDetalle As Integer - Public ReadOnly Property SerieFolio As String - Public ReadOnly Property Serie As String - Public ReadOnly Property Folio As Integer - - Public Property SerieVenta As String - Public Property SubTotalVenta As Double - Public Property SubTotalVentaDolares As Double - Public Property FechaVenta As String - Public Property Costo As Double - Public Property FolioCosto As String - Public Property FechaSalidaCosto As String - - Public Property Utilidad As Double - Public Property PorUtilidad As Double - Public Property Perdida As Double - Public Property PorPerdida As Double - - Public Property Neto As Double - Public Property PorNeto As Double - Public Property CveClasificacionDetalle As Integer - - - -#End Region - - Public Function IniciaTransacSQL() As SqlTransaction - If SqlTransacc Is Nothing Then SqlTransacc = SqlConexion.BeginTransaction() - Return SqlTransacc - End Function - - Public Sub Commit() - SqlTransacc.Commit() - End Sub - Public Sub RollBack() - SqlTransacc.Rollback() - 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 - - SqlAdapter = New SqlDataAdapter("", SqlConexion) - - End Sub - Private Sub DataAdapter(ByVal pStrSQL As String, Optional ByVal TipoComando As CommandType = CommandType.StoredProcedure) - With SqlAdapter.SelectCommand - .Parameters.Clear() - .CommandText = pStrSQL - .CommandType = TipoComando - End With - If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc - Data = New DataTable - End Sub - Public Function GetVenta(CveVenta As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_VentasGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los datos de la Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function GetVentaTerminal(CveVentaTerminal As Integer, Fecha As DateTime, CveSubProyecto As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_VentasGetTerminal") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVentaTerminal", SqlDbType.Int).Value = CveVentaTerminal - .Add("@Fecha", SqlDbType.DateTime).Value = Fecha - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los datos de la Venta, VentaTerminal.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function GetVentas(CveEmpresa As Integer, TipoDocto As String, Serie As String, Folio As Integer, Codigo As String, CveCliente As Integer, - CveSubProyecto As Integer, CveEstatus As Integer, CveUsuario As Integer, FechaI As String, FechaF As String, FolioFiscal As String, Optional CveClienteSucursal As Integer = -1, Optional CvePS As Integer = -1, Optional PedidoContrato As String = "-1", - Optional OrdenCompra As String = "-1", Optional CveUsuarioConsulta As Integer = -1, Optional ClienteRFC As String = "-1", - Optional CveEmpresaCRM As Integer = -1, Optional CveAcercamientoCRM As Integer = -1) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Vta_VentasGetBuscar") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto - .Add("@Serie", SqlDbType.VarChar).Value = Serie - .Add("@Folio", SqlDbType.Int).Value = Folio - .Add("@Codigo", SqlDbType.VarChar).Value = Codigo - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveEstatus", SqlDbType.Int).Value = CveEstatus - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@FechaI", SqlDbType.VarChar).Value = FechaI - .Add("@FechaF", SqlDbType.VarChar).Value = FechaF - .Add("@FolioFiscal", SqlDbType.VarChar).Value = FolioFiscal - .Add("@CveClienteSucursal", SqlDbType.Int).Value = CveClienteSucursal - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@PedidoContrato", SqlDbType.VarChar).Value = PedidoContrato - .Add("@OrdenCompra", SqlDbType.VarChar).Value = OrdenCompra - .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta - .Add("@ClienteRFC", SqlDbType.VarChar).Value = ClienteRFC - .Add("@CveEmpresaCRM", SqlDbType.Int).Value = CveEmpresaCRM - .Add("@CveAcercamientoCRM", SqlDbType.Int).Value = CveAcercamientoCRM - 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 GetVentaComplementos() As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_ComplementosGet") - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los complementos", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function GetVentaOtrosConceptos(CveEmpresa As Integer, Optional CveVenta As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasConceptosGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los conceptos", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function GetVentaImpuestosLocales(CveVenta As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasImpuestosLocalesGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los datos de la Deduccion de la Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function AddVentaImpuestoLocales(CveVenta As Integer, CveVentaDeduccion As Integer, Importe As Double) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasImpuestosLocalesAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveVentaDeduccion", SqlDbType.Int).Value = CveVentaDeduccion - .Add("@Importe", SqlDbType.Money).Value = Importe - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar impuestos locales al documento.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function UpdateVentaImpuestoLocales(CveVenta As Integer, CveVentaDeduccion As Integer, Importe As Double) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasImpuestosLocalesUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveVentaDeduccion", SqlDbType.Int).Value = CveVentaDeduccion - .Add("@Importe", SqlDbType.Money).Value = Importe - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar impuestos locales.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function AddVenta(TipoDocto As String, FolioFact As Integer, CveCliente As Integer, CveClienteSucursal As Integer, SubTotal As Double, Descuento As Double, Amortizacion As Double, IVA As Double, RetIVA As Double, RetISR As Double, Total As Double, - CveMoneda As Integer, TipoCambio As Double, CveMetodoPago As Integer, CondicionesPago As Integer, FormaPago As Integer, FechaVencimiento As DateTime, Fecha As DateTime, MotivoDescuento As String, Observaciones As String, FechaEjecucion As Date, - CveVendedor As Integer, Alfa1 As String, Alfa2 As String, Alfa3 As String, Num1 As Double, Num2 As Double, Num3 As Double, - Fech1 As Date, Fech2 As Date, Fech3 As Date, CveCorte As Integer, CveMesa As Integer, NumeroPersonas As Integer, CvePrePoliza As Integer, CveUsuario As Integer, CveEmpresa As Integer, - Optional Propina As Double = -1, Optional CveVentaTerminal As Integer = -1, Optional AtencionA As String = "-1", Optional CveContrato As Integer = -1, - Optional CveVentaPadre As Integer = -1, Optional Det_OrdenCompra As String = "", Optional Det_FechaOrdenCompra As String = "", Optional otros As Decimal = 0, - Optional Entrega As String = "-1", Optional Vigencia As DateTime = MinFecha, Optional CveAlmacenTraspasoDestino As Integer = -1, Optional CveAlmacenTraspasoOrigen As Integer = -1, Optional CveDireccionEnvio As Integer = -1, - Optional CveOC As Integer = -1, Optional IEPS As Double = 0, Optional Serie As String = "-1", Optional TelefonoGenerico As String = "", Optional CveCondicionEntrega As Integer = -1, Optional PedidoContrato As String = "-1", - Optional ObservacionesAlmacen As String = "", Optional CveSubProyecto As Integer = -1, Optional CveSubProyectoEjecucion As Integer = -1, Optional CveSubProyectoCobranza As Integer = -1, - Optional CveFormaPago33 As Integer = -1, Optional CveMetodoPago33 As Integer = -1, Optional CveUsoCFDI As Integer = -1, Optional OrdenCompra As String = "-1", Optional CveCuentaTerminal As Integer = -1, Optional CveTipoRelacion As Integer = -1, Optional ImpuestoLocal As Double = 0, - Optional CveTipoAmortizacionAnticipo As Integer = -1, Optional CveVentaRelacion As Integer = -1, Optional ImporteRelacion As Decimal = -1, Optional CveEmpresaCRM As Integer = -1, Optional EsInterno As Integer = -1, Optional CveAcercamientoCRM As Integer = -1, - Optional DiasCredito As Integer = 0, Optional EsDiasCreditoFijo As Boolean = False, Optional AnticipoEspecial As Boolean = False) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_VentasAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto - .Add("@FolioFact", SqlDbType.Int).Value = FolioFact - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveClienteSucursal", SqlDbType.Int).Value = CveClienteSucursal - .Add("@SubTotal", SqlDbType.Float).Value = SubTotal - .Add("@Descuento", SqlDbType.Float).Value = Descuento - .Add("@Amortizacion", SqlDbType.Float).Value = Amortizacion - .Add("@IVA", SqlDbType.Float).Value = IVA - .Add("@IEPS", SqlDbType.Float).Value = IEPS - .Add("@RetIVA", SqlDbType.Float).Value = RetIVA - .Add("@RetISR", SqlDbType.Float).Value = RetISR - .Add("@ImpuestoLocal", SqlDbType.Float).Value = ImpuestoLocal - .Add("@Total", SqlDbType.Float).Value = Total - .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda - .Add("@TipoCambio", SqlDbType.Float).Value = TipoCambio - .Add("@CveMetodoPago", SqlDbType.Int).Value = CveMetodoPago - .Add("@CondicionesPago", SqlDbType.Int).Value = CondicionesPago - .Add("@FormaPago", SqlDbType.Int).Value = FormaPago - .Add("@FechaVencimiento", SqlDbType.DateTime).Value = FechaVencimiento - .Add("@Fecha", SqlDbType.DateTime).Value = Fecha - .Add("@MotivoDescuento", SqlDbType.VarChar).Value = MotivoDescuento - .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones - .Add("@FechaEjecucion", SqlDbType.Date).Value = FechaEjecucion - .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor - .Add("@Alfa1", SqlDbType.VarChar).Value = Alfa1 - .Add("@Alfa2", SqlDbType.VarChar).Value = Alfa2 - .Add("@Alfa3", SqlDbType.VarChar).Value = Alfa3 - .Add("@Num1", SqlDbType.Int).Value = Num1 - .Add("@Num2", SqlDbType.Int).Value = Num2 - .Add("@Num3", SqlDbType.Int).Value = Num3 - .Add("@Fech1", SqlDbType.VarChar).Value = IIf(Fech1.ToString.Contiene("1/1/0001 12:00:00 a. m.", "01/01/0001 12:00:00 a. m."), "-1", Fech1.ToString("yyyy/MM/dd")) - .Add("@Fech2", SqlDbType.VarChar).Value = IIf(Fech2.ToString.Contiene("1/1/0001 12:00:00 a. m.", "01/01/0001 12:00:00 a. m."), "-1", Fech2.ToString("yyyy/MM/dd")) - .Add("@Fech3", SqlDbType.VarChar).Value = IIf(Fech3.ToString.Contiene("1/1/0001 12:00:00 a. m.", "01/01/0001 12:00:00 a. m."), "-1", Fech3.ToString("yyyy/MM/dd")) - .Add("@CveCorte", SqlDbType.Int).Value = CveCorte - .Add("@CveMesa", SqlDbType.Int).Value = CveMesa - .Add("@NumeroPersonas", SqlDbType.Int).Value = NumeroPersonas - .Add("@Propina", SqlDbType.Float).Value = Propina - .Add("@CveVentaTerminal", SqlDbType.Int).Value = CveVentaTerminal - .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza - .Add("@AtencionA", SqlDbType.VarChar).Value = AtencionA - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveContrato", SqlDbType.Int).Value = CveContrato - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveVentaPadre", SqlDbType.Int).Value = CveVentaPadre - .Add("@Det_OrdenCompra", SqlDbType.VarChar).Value = Det_OrdenCompra - .Add("@Det_FechaOrdenCompra", SqlDbType.VarChar).Value = Det_FechaOrdenCompra - .Add("@Otros", SqlDbType.Money).Value = otros - '.Add("@Ref", SqlDbType.VarChar).Value = Ref - .Add("@Entrega", SqlDbType.VarChar).Value = Entrega - .Add("@Vigencia", SqlDbType.Date).Value = Vigencia - .Add("@CveAlmacenTraspasoDestino", SqlDbType.Int).Value = CveAlmacenTraspasoDestino - .Add("@CveAlmacenTraspasoOrigen", SqlDbType.Int).Value = CveAlmacenTraspasoOrigen - .Add("@CveDireccionEnvio", SqlDbType.Int).Value = CveDireccionEnvio - .Add("@CveOC", SqlDbType.Int).Value = CveOC - .Add("@Serie", SqlDbType.VarChar).Value = Serie - .Add("@TelefonoGenerico", SqlDbType.VarChar).Value = TelefonoGenerico - .Add("@CveCondicionEntrega", SqlDbType.Int).Value = CveCondicionEntrega - .Add("@PedidoContrato", SqlDbType.VarChar).Value = PedidoContrato - .Add("@ObservacionesAlmacen", SqlDbType.VarChar).Value = ObservacionesAlmacen - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveSubProyectoEjecucion", SqlDbType.Int).Value = CveSubProyectoEjecucion - .Add("@CveSubProyectoCobranza", SqlDbType.Int).Value = CveSubProyectoCobranza - .Add("@CveFormaPago33", SqlDbType.SmallInt).Value = CveFormaPago33 - .Add("@CveMetodoPago33", SqlDbType.SmallInt).Value = CveMetodoPago33 - .Add("@CveUsoCFDI", SqlDbType.SmallInt).Value = CveUsoCFDI - .Add("@OrdenCompra", SqlDbType.VarChar).Value = OrdenCompra - .Add("@CveCuentaTerminal", SqlDbType.VarChar).Value = CveCuentaTerminal - .Add("@CveTipoRelacion", SqlDbType.Int).Value = CveTipoRelacion - - .Add("@CveTipoAmortizacionAnticipo", SqlDbType.Int).Value = CveTipoAmortizacionAnticipo - .Add("@CveVentaRelacion", SqlDbType.Int).Value = CveVentaRelacion - .Add("@ImporteRelacion", SqlDbType.Money).Value = ImporteRelacion - - .Add("@CveEmpresaCRM", SqlDbType.Int).Value = CveEmpresaCRM - .Add("@CveAcercamientoCRM", SqlDbType.Int).Value = CveAcercamientoCRM - .Add("@EsInterno", SqlDbType.Int).Value = EsInterno - - .Add("@DiasCredito", SqlDbType.Int).Value = DiasCredito - .Add("@EsDiasCreditoFijo", SqlDbType.Bit).Value = EsDiasCreditoFijo - .Add("@AnticipoEspecial", SqlDbType.Bit).Value = AnticipoEspecial - - .Add("@RETURN_VALUE", SqlDbType.Int).Direction = ParameterDirection.ReturnValue - End With - 'SqlTypes.SqlDateTime.Null - Try - SqlAdapter.Fill(Data) - CveVenta = SqlAdapter.SelectCommand.Parameters("@RETURN_VALUE").Value.ToString.ToEntero - If Data.Rows.Count > 0 Then _SerieFolio = Data.Rows(0)("vFolio").ToString : _Serie = Data.Rows(0)("Serie").ToString : _Folio = Data.Rows(0)("Folio").ToString.ToEntero - - Retorno = True - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 2627;") And Ex1.Message.Contains("UK_Ventas_TipoDocto_Serie_Folio_CveSubProyecto") Then - Alert(String.Format("el Folio '{0}' ya se encuentra registrado", FolioFact), TipoMensaje.MsgAdvertencia) - GuardaLog(String.Format("el folio ya se encuentra registrado {0}", Ex1.Message)) - Else - Me.OnError("Ocurrió un error al Guardar la Venta.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - OnError("Ocurrió un error al Guardar la Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function UpdateVentas(SubTotal As Double, Descuento As Double, IVA As Double, IEPS As Double, Total As Double, CveMoneda As Integer, TipoCambio As Double, - Fecha As Date, Observaciones As String, CveEmpresa As Integer, CveVenta As Integer, CveMetodoPago As Integer, FormaPago As Integer, - Optional TipoDocto As String = "Cot", Optional Vigencia As Date = MinFecha, Optional CondicionesPago As Integer = -1, - Optional AtencionA As String = "-1", Optional PedidoContrato As String = "-1", Optional CveFormaPago33 As Integer = -1, Optional CveMetodoPago33 As Integer = -1, - Optional CveCliente As Integer = -1, Optional CveClienteSucursal As Integer = -1, Optional OrdenCompra As String = "-1", Optional RetIVA As Double = -1, Optional RetISR As Double = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@SubTotal", SqlDbType.Float).Value = SubTotal - .Add("@Descuento", SqlDbType.Float).Value = Descuento - .Add("@IVA", SqlDbType.Float).Value = IVA - .Add("@IEPS", SqlDbType.Float).Value = IEPS - .Add("@Total", SqlDbType.Float).Value = Total - .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda - .Add("@TipoCambio", SqlDbType.Float).Value = TipoCambio - .Add("@RetIVA", SqlDbType.Float).Value = RetIVA - .Add("@RetISR", SqlDbType.Float).Value = RetISR - .Add("@Fecha", SqlDbType.Date).Value = Fecha - .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto - .Add("@CveMetodoPago", SqlDbType.Int).Value = CveMetodoPago - .Add("@CondicionesPago", SqlDbType.Int).Value = CondicionesPago - .Add("@FormaPago", SqlDbType.Int).Value = FormaPago - .Add("@AtencionA", SqlDbType.VarChar).Value = AtencionA - .Add("@Vigencia", SqlDbType.Date).Value = Vigencia - .Add("@PedidoContrato", SqlDbType.VarChar).Value = PedidoContrato - .Add("@CveFormaPago33", SqlDbType.SmallInt).Value = CveFormaPago33 - .Add("@CveMetodoPago33", SqlDbType.SmallInt).Value = CveMetodoPago33 - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveClienteSucursal", SqlDbType.Int).Value = CveClienteSucursal - .Add("@OrdenCompra", SqlDbType.VarChar).Value = OrdenCompra - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar el documento.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function UpdateFechaVencimientoVenta(CveVenta As Integer, FechaVencimiento As Date) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasFechaVencimientoUpdate") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@FechaVencimiento", SqlDbType.Date).Value = FechaVencimiento - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar la fecha de vencimiento de la venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - Public Function AddVta_VentaPago(CveVenta As Integer, CveMetodoPago As Integer, Importe As Double) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasPagoAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveMetodoPago", SqlDbType.Int).Value = CveMetodoPago - .Add("@Importe", SqlDbType.Float).Value = Importe - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar el Pago de la Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function RemoveVta_VentaPago(CveVenta As Integer, CveMetodoPago As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasPagoRemove") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveMetodoPago", SqlDbType.Int).Value = CveMetodoPago - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al Eliminar el Pago a la Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function EliminarVenta(CveVenta As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_EliminarVenta") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al intentar eliminar la venta. Verifique que el registro no tenga relaciones (Movimientos de almacén, Factura, Anticipos...)", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function UpdateVentaPrePoliza(IDPoliza As Integer, CvePrePoliza As Integer, CveVenta As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentaPrePolizaUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@IDPoliza", SqlDbType.Int).Value = IDPoliza - .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al guardar la poliza de la venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function AddLeyendaFiscal(CveVenta As Integer, CveLeyenda As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_VentasLeyendasFiscalesAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveLeyendaFiscal", SqlDbType.Int).Value = CveLeyenda - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al Guardar la Leyenda Fiscal en la Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function UpdateEstatusFactura(Estatus As Integer, FolioFiscal As String, SelloSAT As String, FechaCancelacion As DateTime, CveVenta As Integer, Optional IdPolizaCancelacion As Integer = -1, Optional CvePAC As Integer = -1, Optional CveEstatusRefacturacion As Integer = 0) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_VentasUpdateEstatus") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEstatusFactura", SqlDbType.Int).Value = Estatus - .Add("@FolioFiscal", SqlDbType.VarChar).Value = FolioFiscal - .Add("@SelloDigitalSAT", SqlDbType.VarChar).Value = SelloSAT - .Add("@FechaCancelacion", SqlDbType.DateTime).Value = FechaCancelacion - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@IdPolizaCancelacion", SqlDbType.Int).Value = IdPolizaCancelacion - .Add("@CvePAC", SqlDbType.SmallInt).Value = CvePAC - .Add("@CveEstatusRefacturacion", SqlDbType.TinyInt).Value = CveEstatusRefacturacion - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar el estatus de la factura.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function UpdateEstatusRefacturacion(CveVenta As Integer, CveEstatusRefacturacion As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_VentasEstatusRefacturacionUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveEstatusRefacturacion", SqlDbType.TinyInt).Value = CveEstatusRefacturacion - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar el estatus de refacturación.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function UpdateEstatusVenta(CveVenta As Integer, CveEstatusFactura As Integer, CveEmpresa As Integer, Optional Num2 As Integer = -1) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Vta_VentasEstatusUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveEstatusFactura", SqlDbType.Int).Value = CveEstatusFactura - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@Num2", SqlDbType.Float).Value = Num2 - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al Guardar el estatus de la Factura.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function UpdateCancelaVenta(CveVenta As Integer, FechaCancelacion As DateTime, SelloCancelacionSAT As String, CveEmpresa As Integer, Optional CvePAC As Integer = -1) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Vta_VentasCancelacion") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@FechaCancelacion", SqlDbType.DateTime).Value = FechaCancelacion - .Add("@SelloDigitalSAT", SqlDbType.VarChar).Value = SelloCancelacionSAT - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CvePAC", SqlDbType.SmallInt).Value = CvePAC - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al Guardar el estatus de cancelacion Factura.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function UpdateVentaMail(Tipo As Integer, CveVenta As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_VentasUpdateMail") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Tipo", SqlDbType.Int).Value = Tipo - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al Guardar el estatus del Mail.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function UpdateVentaTimbre(Timbro As Boolean, CveVenta As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_VentasUpdateTimbre") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Timbre", SqlDbType.Bit).Value = If(Timbro, 1, 0) - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al Guardar el estatus del Timbrado.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - - Return Retorno - End Function - Public Function UpdateVentaFolioFiscal(FolioFiscal As String, CveVenta As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasUpdateFolioFiscal") - - With SqlAdapter.SelectCommand.Parameters - .Add("@FolioFiscal", SqlDbType.VarChar).Value = FolioFiscal - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al Guardar el folio fiscal.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function UpdateVentaCotizacion(CveVenta As Integer, CveCotizacion As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_VentasUpdateCotizacion") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveCotizacion", SqlDbType.Int).Value = CveCotizacion - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al vincular la Venta con la Cotización.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function ObtenerCreditoRestante(CveCliente As Integer, CveSucCliente As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_ClientesLimiteCreditoGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveSucCliente", SqlDbType.Int).Value = CveSucCliente - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el limite de credito.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function ObtenerCreditoRestanteSucursalCliente(CveSucCliente As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_SucClientesLimiteCreditoGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveSucCliente", SqlDbType.Int).Value = CveSucCliente - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el limite de credito.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function ObtenerClienteLimitesVenta(CveCliente As Integer, CveEmpresa As Integer) As Integer - Dim Retorno As Integer = 0 - DataAdapter("PA_Vta_ClientesLimitesVentaGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@Opcion", SqlDbType.Int).Direction = ParameterDirection.Output - .Add("@OpcionMsg", SqlDbType.VarChar, 100).Direction = ParameterDirection.Output - End With - - Try - SqlAdapter.Fill(Data) - SerieVenta = SqlAdapter.SelectCommand.Parameters("@OpcionMsg").Value.ToString - Retorno = SqlAdapter.SelectCommand.Parameters("@Opcion").Value.ToString.ToEntero - - Catch ex As Exception - OnError("Ocurrió un error al obtener el limite de venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function AgregarVentaOCDetalle(CveVentaDetalle As Integer, CveOCDetalle As Integer, Cantidad As Decimal) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_AddVentaOCDetalle") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVentaDetalle", SqlDbType.Int).Value = CveVentaDetalle - .Add("@CveOCDetalle", SqlDbType.Int).Value = CveOCDetalle - .Add("@Cantidad", SqlDbType.Int).Value = Cantidad - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar el detalle de la OC.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function AgregarRemisionDetalle(CveVentaDetalle As Integer, CveVentaDetallePadre As Integer, Cantidad As Decimal) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_AddRemisionDetalle") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVentaDetalle", SqlDbType.Int).Value = CveVentaDetalle - .Add("@CveVentaDetallePadre", SqlDbType.Int).Value = CveVentaDetallePadre - .Add("@Cantidad", SqlDbType.Float).Value = Cantidad - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar el detalle de la Remisión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function VerificarRemisionFacturada(CveVenta As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VerificarRemisionFacturada") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al verificar la remision.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function LiberarRemisionesFacturadas(CveVenta As Integer, Optional CveVentaLiberar As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_LiberarRemisionesFacturadas") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveVentaLiberar", SqlDbType.Int).Value = CveVentaLiberar - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al liberar las remisiones.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function AddRemisionesXCancelar(CveVenta As Integer, CveVentaRemision As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_RemisionesXCancelarAdd") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveVentaRemision", SqlDbType.Int).Value = CveVentaRemision - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar las remisiones x cancelar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - Public Function LiberarCotizacionesFacturadas(CveVenta As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_LiberarCotizacionesFacturadas") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al liberar las cotizaciones.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function LiberarPedidos2Facturados(CveVenta As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_LiberarPedidos2Facturados") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al liberar los pedidos2.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function LiberarOCFacturadas(CveVenta As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_LiberarOCFacturadas") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al liberar las Ordenes de Compra.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function UpdateVentaRemision(CveVenta As Integer, CveVentaFacturada As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_VentasRemisionUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveVentaFacturada", SqlDbType.Int).Value = CveVentaFacturada - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al vincular la Venta con la Remision.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function MarcarRemisionesSinSurtir(CveVenta As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_MarcarRemisionSinSurtir") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al marcar la venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function UpdateVentaCadenaOriginal(CadenaOriginal As String, CveVenta As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_VentasCadenaOriginalAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CadenaOriginal", SqlDbType.VarChar).Value = CadenaOriginal - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al Guardar la Cadena Original.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function UpdateVentaCuentaTerminal(CveCuentaTerminal As Integer, CveVenta As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasCuentaTerminalUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCuentaTerminal", SqlDbType.Int).Value = CveCuentaTerminal - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al Guardar la cuenta terminal.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function GetCadenaOriginal(CveVenta As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_VentasCadenaOriginalGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al Obtener la Cadena Original.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - -#Region "V E N T A - D E T A L L E" - Public Function GetVentaDetalle(CveVenta As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_VentasDetalleGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el detalle de la Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function AddVentaDetalle(CveVenta As Integer, CvePS As Integer, Cantidad As Double, CveUnidadMedida As Integer, PU As Double, IVA As Double, - Total As Double, Observaciones As String, Descuento As Double, TipoDescuento As Integer, CveSubProyecto As Integer, - CvePresupuestoIngreso As Integer, Optional TiempoEntrega As String = "", Optional CveVentaDetallePadre As Integer = -1, - Optional CveContratoDetalle As Integer = -1, Optional PorcentajeIVA As Decimal = 0, Optional IEPS As Double = -1, Optional PorcentajeIEPS As Double = 0, Optional CvePromocionDetalle As Integer = -1, - Optional CveMovimientoDetallePedido As Integer = -1, Optional ImporteRetIVA As Double = 0, Optional PorcentajeRetIVA As Double = 0, - Optional ImporteRetISR As Double = 0, Optional PorcentajeRetISR As Double = 0, Optional CuentaPredial As String = "") As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_VentasDetalleAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@Cantidad", SqlDbType.Float).Value = Cantidad - .Add("@CveUnidadMedida", SqlDbType.Int).Value = CveUnidadMedida - .Add("@PU", SqlDbType.Float).Value = PU - .Add("@IVA", SqlDbType.Float).Value = IVA - .Add("@IEPS", SqlDbType.Float).Value = IEPS - .Add("@ImporteRetIVA", SqlDbType.Float).Value = ImporteRetIVA - .Add("@ImporteRetISR", SqlDbType.Float).Value = ImporteRetISR - .Add("@PorcentajeIVA", SqlDbType.Float).Value = PorcentajeIVA - .Add("@PorcentajeIEPS", SqlDbType.Float).Value = PorcentajeIEPS - .Add("@PorcentajeRetIVA", SqlDbType.Float).Value = PorcentajeRetIVA - .Add("@PorcentajeRetISR", SqlDbType.Float).Value = PorcentajeRetISR - .Add("@Total", SqlDbType.Float).Value = Total - .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones - .Add("@Descuento", SqlDbType.Float).Value = Descuento - .Add("@TipoDescuento", SqlDbType.Int).Value = TipoDescuento - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CvePresupuestoIngreso", SqlDbType.Int).Value = CvePresupuestoIngreso - .Add("@TiempoEntrega", SqlDbType.VarChar).Value = TiempoEntrega - .Add("@CveVentaDetallePadre", SqlDbType.Int).Value = CveVentaDetallePadre - .Add("@CveContratoDetalle", SqlDbType.Int).Value = CveContratoDetalle - .Add("@CvePromocionDetalle", SqlDbType.Int).Value = CvePromocionDetalle - .Add("@CveMovimientoDetallePedido", SqlDbType.Int).Value = CveMovimientoDetallePedido - .Add("@CuentaPredial", SqlDbType.VarChar).Value = CuentaPredial - End With - - Try - SqlAdapter.Fill(Data) - CveVentaDetalle = Data.Rows(0)("CveVentaDetalle").ToString.ToEntero - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar el Producto o Servicio a la Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function AddVentaDetalleCaracteristica(CveVentaDetalle As Integer, CvePS As Integer, CveOpcion As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_VentasDetallesCaracteristicasAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVentaDetalle", SqlDbType.Int).Value = CveVentaDetalle - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@CveOpcion", SqlDbType.Int).Value = CveOpcion - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar la Caracteristica del Producto o Servicio a la Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function UpdateVentaDetalleRemision(CveVenta As Integer, CvePS As Integer, Cantidad As Double, PU As Double, IEPS As Double, Observaciones As String, Optional CveUsuarioModifico As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_VentasDetalleRemisionUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVentaDetalle", SqlDbType.Int).Value = CveVenta - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@Cantidad", SqlDbType.Float).Value = Cantidad - .Add("@PU", SqlDbType.Float).Value = PU - .Add("@IEPS", SqlDbType.Float).Value = IEPS - .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones - .Add("@CveUsuarioModifico", SqlDbType.Int).Value = CveUsuarioModifico - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al editar el Producto o Servicio a la Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function UpdateVentasDevolucionAlmacen(EstatusDevolucion As Integer, CveVenta As Integer) As Boolean - - 'NOTA: - ' - 0: No requiere devolucion - ' - 1: Requiere devolucion - ' - 2: Devolucion ya realizada - - - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasDevolucionAlmacenUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@EstatusDevolucion", SqlDbType.TinyInt).Value = EstatusDevolucion - .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 solicitud de Devolución de Almacén.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function RemoveVentasDetalle(CveVenta As Integer, Optional CveVentaDetalle As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasDetalleRemove") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveVentaDetalle", SqlDbType.Int).Value = CveVentaDetalle - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar el documento.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function -#End Region - -#Region "V E N T A - P R E S U P U E S T O" - Public Function GetPresupuestosVentas(CveVenta As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_AC_PresupuestosVentasGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - ' .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los datos de la venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function -#End Region - -#Region "R E P O R T E S - D E - V E N T A S" - 'Reporte de Ventas - Public Function GetRepVentas(FechaI As Date, FechaF As Date, FechaIEjec As Date, FechaFEjec As Date, CveCliente As Integer, CveSubProyectoEjecucion As Integer, - CveVendedor As String, CveUsuario As Integer, CveEstatus As String, IVA As String, CveEmpresa As Integer, Gpo As Integer, Optional TipoDocto As String = "-1", - Optional CveProyecto As Integer = -1, Optional CveSubProyecto As String = "-1", Optional TipoCambio As Integer = 1, Optional TCEspecifico As Decimal = -1, Optional CveUsuarioConsulta As Integer = -1, - Optional CveClienteClasificacion As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasGetRep") - - With SqlAdapter.SelectCommand.Parameters - '.Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@FechaI", SqlDbType.Date).Value = FechaI - .Add("@FechaF", SqlDbType.Date).Value = FechaF - .Add("@FechaIEjec", SqlDbType.Date).Value = FechaIEjec - .Add("@FechaFEjec", SqlDbType.Date).Value = FechaFEjec - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveSubProyectoEjecucion", SqlDbType.Int).Value = CveSubProyectoEjecucion - .Add("@CveVendedor", SqlDbType.VarChar).Value = CveVendedor - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEstatus", SqlDbType.VarChar).Value = CveEstatus - .Add("@IVA", SqlDbType.VarChar).Value = IVA - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@GPO", SqlDbType.Int).Value = Gpo - .Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto - .Add("@CveSubProyecto", SqlDbType.VarChar).Value = CveSubProyecto - .Add("@CveProyecto", SqlDbType.Int).Value = CveProyecto - .Add("@TipoCambio", SqlDbType.Int).Value = TipoCambio - .Add("@TCEspecifico", SqlDbType.Float).Value = TCEspecifico - .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta - .Add("@CveClienteClasificacion", SqlDbType.Int).Value = CveClienteClasificacion - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Reporte de Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function GetRepTopVenta(GPO As Integer, CveEmpresa As Integer, TipoCambio As Integer, TipoCambioEspecifico As Decimal, CveUsuarioConsulta As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_GetTopRepPS") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@GPO", SqlDbType.Int).Value = GPO - .Add("@TipoCambio", SqlDbType.Int).Value = TipoCambio - .Add("@TCEspecifico", SqlDbType.Int).Value = TipoCambioEspecifico - .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los datos del reporte.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function GetRepTopCompras(GPO As Integer, CveEmpresa As Integer, TipoCambio As Integer, TipoCambioEspecifico As Decimal, CveUsuarioConsulta As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Comp_GetTopRepPS") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@GPO", SqlDbType.Int).Value = GPO - .Add("@TipoCambio", SqlDbType.Int).Value = TipoCambio - .Add("@TCEspecifico", SqlDbType.Int).Value = TipoCambioEspecifico - .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los datos del reporte.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - - 'Reporte de Ventas por Período - Public Function GetRepVentasPeriodos(FechaI As Date, FechaF As Date, FechaIEjec As Date, FechaFEjec As Date, CveCliente As Integer, CveSubProyectoEjecucion As Integer, - CveVendedor As Integer, CveUsuario As Integer, CveEstatus As Integer, IVA As String, CveEmpresa As Integer, Gpo As Integer, Optional TipoDocto As String = "-1", - Optional CveProyecto As Integer = -1, Optional CveSubProyecto As Integer = -1, Optional TipoCambio As Integer = 1, Optional TCEspecifico As Decimal = -1, Optional CveUsuarioConsulta As Integer = -1, Optional VerEn As Integer = -1, - Optional CveClienteClasificacion As Integer = -1) As Boolean - - Dim Retorno As Boolean = False - DataAdapter("PA_VentasGetRepPeriodo") - - With SqlAdapter.SelectCommand.Parameters - '.Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@FechaI", SqlDbType.Date).Value = FechaI - .Add("@FechaF", SqlDbType.Date).Value = FechaF - .Add("@FechaIEjec", SqlDbType.Date).Value = FechaIEjec - .Add("@FechaFEjec", SqlDbType.Date).Value = FechaFEjec - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveSubProyectoEjecucion", SqlDbType.Int).Value = CveSubProyectoEjecucion - .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEstatus", SqlDbType.Int).Value = CveEstatus - .Add("@IVA", SqlDbType.VarChar).Value = IVA - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@GPO", SqlDbType.Int).Value = Gpo - .Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveProyecto", SqlDbType.Int).Value = CveProyecto - .Add("@TipoCambio", SqlDbType.Int).Value = TipoCambio - .Add("@TCEspecifico", SqlDbType.Float).Value = TCEspecifico - .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta - .Add("@VerEn", SqlDbType.Int).Value = VerEn - .Add("@CveClienteClasificacion", SqlDbType.Int).Value = CveClienteClasificacion - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Reporte de Venta por Periodo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - 'Reporte de Ventas - Detalle - Public Function GetRepVentasDetalle(Gpo As Integer, Anio As Integer, Mes As Integer, AnioMes As String, Fecha As String, CveCliente As Integer, IVA As String, - Vendedor As String, CveUsuario As Integer, CveEstatus As String, FechaI As Date, FechaF As Date, CveCorte As Integer, TipoDocto As String, - CveSubProyectoEjecucion As Integer, CveEmpresa As Integer, FechaIEjec As Date, FechaFEjec As Date, Optional CveProyecto As Integer = -1, - Optional CveSubProyecto As String = "-1", Optional TipoCambio As Integer = 1, Optional TCEspecifico As Decimal = -1, Optional CveMoneda As Integer = -1, Optional CveUsuarioConsulta As Integer = -1, - Optional CveClienteClasificacion As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasGetRepDetalle") - - With SqlAdapter.SelectCommand.Parameters - .Add("@GPO", SqlDbType.Int).Value = Gpo - .Add("@Anio", SqlDbType.Int).Value = Anio - .Add("@Mes", SqlDbType.Int).Value = Mes - .Add("@AnioMes", SqlDbType.VarChar).Value = AnioMes - .Add("@Fecha", SqlDbType.VarChar).Value = Fecha - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@IVA", SqlDbType.VarChar).Value = IVA - .Add("@Vendedor", SqlDbType.VarChar).Value = Vendedor - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEstatus", SqlDbType.VarChar).Value = CveEstatus - .Add("@FechaI", SqlDbType.Date).Value = FechaI - .Add("@FechaF", SqlDbType.Date).Value = FechaF - .Add("@FechaIEjec", SqlDbType.Date).Value = FechaIEjec - .Add("@FechaFEjec", SqlDbType.Date).Value = FechaFEjec - .Add("@CveCorte", SqlDbType.Int).Value = CveCorte - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto - .Add("@CveSubProyectoEjecucion", SqlDbType.Int).Value = CveSubProyectoEjecucion - .Add("@CveSubProyecto", SqlDbType.VarChar).Value = CveSubProyecto - .Add("@CveProyecto", SqlDbType.Int).Value = CveProyecto - .Add("@TipoCambio", SqlDbType.Int).Value = TipoCambio - .Add("@TCEspecifico", SqlDbType.Float).Value = TCEspecifico - .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda - .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta - .Add("@CveClienteClasificacion", SqlDbType.Int).Value = CveClienteClasificacion - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Reporte de Venta Detalle.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - - Return Retorno - End Function - - 'Reporte de Ventas - Productos y Servicios - Public Function GetRepProductosServicios(CveProyecto As Integer, CveSubProyecto As Integer, CveCategoria As Integer, CveClasificacion As Integer, CvePS As Integer, - FechaI As Date, FechaF As Date, FechaIEjec As Date, FechaFEjec As Date, CveCliente As Integer, CveSubProyectoEjecucion As Integer, - CveVendedor As Integer, CveUsuario As Integer, CveEstatus As Integer, IVA As String, CveEmpresa As Integer, Gpo As Integer, - Optional TipoCambio As Integer = -1, Optional TCEspecifico As Double = -1, Optional CveUsuarioConsulta As Integer = -1, - Optional TipoDocto As String = "-1", Optional CveClienteClasificacion As Integer = -1, Optional CveProveedorCompra As Integer = -1, Optional CveMarca As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_GetRepPS") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveProyecto", SqlDbType.Int).Value = CveProyecto - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveCategoria", SqlDbType.Int).Value = CveCategoria - .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@FechaI", SqlDbType.Date).Value = FechaI - .Add("@FechaF", SqlDbType.Date).Value = FechaF - .Add("@FechaIEjec", SqlDbType.Date).Value = FechaIEjec - .Add("@FechaFEjec", SqlDbType.Date).Value = FechaFEjec - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveSubProyectoEjecucion", SqlDbType.Int).Value = CveSubProyectoEjecucion - .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEstatus", SqlDbType.Int).Value = CveEstatus - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@GPO", SqlDbType.Int).Value = Gpo - .Add("@TipoCambio", SqlDbType.Int).Value = TipoCambio - .Add("@TCEspecifico", SqlDbType.Float).Value = TCEspecifico - .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta - .Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto - .Add("@CveClienteClasificacion", SqlDbType.Int).Value = CveClienteClasificacion - .Add("@CveProveedorCompra", SqlDbType.Int).Value = CveProveedorCompra - .Add("@CveMarca", SqlDbType.Int).Value = CveMarca - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Reporte de Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function GetRepProductosServiciosDetalle(CveProyecto As Integer, CveSubProyecto As Integer, CveCategoria As Integer, CveClasificacion As Integer, CvePS As Integer, - FechaI As Date, FechaF As Date, Mes As Integer, FechaIEjec As Date, FechaFEjec As Date, MesEjec As Integer, CveCliente As Integer, CveSubProyectoEjecucion As Integer, - CveVendedor As Integer, CveUsuario As Integer, CveEstatus As Integer, CveEmpresa As Integer, Optional CveUsuarioConsulta As Integer = -1, - Optional TipoDocto As String = "-1", Optional GPO As Integer = -1, Optional CveMoneda As Integer = -1, Optional TipoCambio As Integer = -1, - Optional TCEspecifico As Double = 0, Optional CveClienteClasificacion As Integer = -1, Optional CveProveedorCompra As Integer = -1, Optional CveMarca As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_GetRepPSDetalle") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveProyecto", SqlDbType.Int).Value = CveProyecto - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveCategoria", SqlDbType.Int).Value = CveCategoria - .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@FechaI", SqlDbType.Date).Value = FechaI - .Add("@FechaF", SqlDbType.Date).Value = FechaF - .Add("@Mes", SqlDbType.Int).Value = Mes - .Add("@FechaIEjec", SqlDbType.Date).Value = FechaIEjec - .Add("@FechaFEjec", SqlDbType.Date).Value = FechaFEjec - .Add("@MesEjec", SqlDbType.Int).Value = MesEjec - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveSubProyectoEjecucion", SqlDbType.Int).Value = CveSubProyectoEjecucion - .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEstatus", SqlDbType.Int).Value = CveEstatus - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta - .Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto - .Add("@GPO", SqlDbType.Int).Value = GPO - .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda - .Add("@TipoCambio", SqlDbType.Int).Value = TipoCambio - .Add("@TCEspecifico", SqlDbType.Float).Value = TCEspecifico - .Add("@CveClienteClasificacion", SqlDbType.Int).Value = CveClienteClasificacion - .Add("@CveProveedorCompra", SqlDbType.Int).Value = CveProveedorCompra - .Add("@CveMarca", SqlDbType.Int).Value = CveMarca - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Reporte de Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function GetRepNCxAplicar(CveClienteSucursal As Integer, CveSubProyecto As Integer, CveCliente As Integer, FechaInicio As DateTime, FechaFin As DateTime, ConSaldo As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Vta_NotasCreditosGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveClienteSucursal", SqlDbType.Int).Value = CveClienteSucursal - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio - .Add("@FechaFin", SqlDbType.Date).Value = FechaFin - .Add("@ConSaldo", SqlDbType.Int).Value = ConSaldo - .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 Notas de Crédito por Aplicar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - -#End Region - -#Region "V E N T A S - P R E C I O L I S T A S" 'Hecho por Charlie 1/9/2016 - Public Function GetPrecioListas(Optional CveEmpresa As Integer = -1) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Vta_PrecioListaGet") - - 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 Listas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function AddPrecioLista(CveUsuario As Integer, CveEmpresa As Integer, PrecioLista As String, Porcentaje As Double) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Vta_PrecioListaAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@PrecioLista", SqlDbType.VarChar).Value = PrecioLista - .Add("@Porcentaje", SqlDbType.SmallMoney).Value = Porcentaje - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 2627;") Then - Alert("Ya existe una Lista con el mismo Nombre: " & PrecioLista & ".", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al Guardar la Lista.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - OnError("Ocurrió un error al la Lista", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function UpdatePrecioLista(PrecioLista As String, Estatus As Boolean, CveUsuario As Integer, Porcentaje As Double, CvePrecioLista As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Vta_PrecioListaUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@PrecioLista", SqlDbType.VarChar).Value = PrecioLista - .Add("@Estatus", SqlDbType.Bit).Value = Estatus - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@Porcentaje", SqlDbType.SmallMoney).Value = Porcentaje - .Add("@CvePrecioLista", SqlDbType.Int).Value = CvePrecioLista - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 2627;") Then - Alert("Ya existe una Lista con el mismo nombre: " & PrecioLista & ".", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al guardar los cambios en la Lista", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - OnError("Ocurrió un error al guardar los cambios en la Lista.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function RemovePrecioLista(CvePrecioLista As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Vta_PrecioListaRemove") - - SqlAdapter.SelectCommand.Parameters.Add("@CvePrecioLista", SqlDbType.Int).Value = CvePrecioLista - - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 547;") Then - Alert("La Lista no se pudo eliminar porque está siendo usado por un registro.", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al eliminar la Lista.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - Me.OnError("Ocurrió un error al eliminar la Lista.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function -#End Region - -#Region "V E N T A S - M E S A S" - Public Function GetMesas(Optional CveEmpresa As Integer = -1) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Vta_MesasGet") - - 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 Mesas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function AddMesa(Mesa As String, CveUsuario As Integer, CveSubProyecto As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Vta_MesasAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Mesa", SqlDbType.VarChar).Value = Mesa - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .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 Mesa con el mismo nombre: " & Mesa & ".", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al Guardar el Mesa.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - OnError("Ocurrió un error al Guardar el Mesa", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function UpdateMesa(Mesa As String, Estatus As Boolean, CveSubProyecto As Integer, CveMesa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Vta_MesasUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Mesa", SqlDbType.VarChar).Value = Mesa - .Add("@Estatus", SqlDbType.Bit).Value = Estatus - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveMesa", SqlDbType.Int).Value = CveMesa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 2627;") Then - Alert("Ya existe un Mesa con el mismo nombre: " & Mesa & ".", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al guardar los cambios en el Mesa", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - OnError("Ocurrió un error al guardar los cambios en el Mesa.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function RemoveMesa(CveMesa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Vta_MesasRemove") - - SqlAdapter.SelectCommand.Parameters.Add("@CveMesa", SqlDbType.Int).Value = CveMesa - - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - If Ex1.Message.Contains("Número: 547;") Then - Alert("El Mesa no se pudo eliminar porque está siendo usado por un registro.", TipoMensaje.MsgAdvertencia) - Else - Me.OnError("Ocurrió un error al eliminar el Mesa.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End If - Catch ex As Exception - Me.OnError("Ocurrió un error al eliminar el Mesa.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function -#End Region - -#Region "V E N T A S - B I T A C O R A" - Public Function GetVta_Bitacora(CveVenta As Integer, FechaI As String, FechaF As String, CveSubProyecto As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Vta_BitacoraGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@FechaI", SqlDbType.VarChar).Value = FechaI - .Add("@FechaF", SqlDbType.VarChar).Value = FechaF - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .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 la Bitacora de las Ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - - Public Function AddVta_Bitacora(CveVenta As Integer, Fecha As DateTime, Observacion As String, CveUsuario As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Vta_BitacoraAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@Observacion", SqlDbType.VarChar).Value = Observacion - .Add("@Fecha", SqlDbType.DateTime).Value = Fecha - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al Guardar la Bitacora de la Venta", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - -#End Region - -#Region "R E P O R T E S - D E L - P V " - Public Function GetRepVentasPV(FechaI As String, FechaF As String, FechaIEjec As String, FechaFEjec As String, CveCliente As Integer, CveSubProyecto As Integer, CveSubProyectoEjecucion As Integer, - Vendedor As String, CveUsuario As Integer, CveEstatus As Integer, IVA As String, CveEmpresa As Integer, Gpo As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_PV_VentasGetRep") - - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.VarChar).Value = FechaI - .Add("@FechaF", SqlDbType.VarChar).Value = FechaF - .Add("@FechaIEjec", SqlDbType.VarChar).Value = FechaIEjec - .Add("@FechaFEjec", SqlDbType.VarChar).Value = FechaFEjec - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveSubProyectoEjecucion", SqlDbType.Int).Value = CveSubProyectoEjecucion - .Add("@Vendedor", SqlDbType.VarChar).Value = Vendedor - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEstatus", SqlDbType.Int).Value = CveEstatus - .Add("@IVA", SqlDbType.VarChar).Value = IVA - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@GPO", SqlDbType.Int).Value = Gpo - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Reporte de Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function -#End Region - - Public Function GetRepABT(Ejercicio As Integer, Periodo As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_VentasGetRepABT") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Ejercicio", SqlDbType.Int).Value = Ejercicio - .Add("@Periodo", SqlDbType.Int).Value = Periodo - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Reporte ABT.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - -#Region " PROMOCIONES " - Public Function GetPromociones(CvePromocion As Integer, Fecha As String, CveVendedor As Integer, CveCliente As Integer, Estatus As Integer, CveEmpresa As Integer, CveSubProyecto As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_PromocionesGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePromocion", SqlDbType.Int).Value = CvePromocion - .Add("@Fecha", SqlDbType.VarChar).Value = Fecha - .Add("@Estatus", SqlDbType.Int).Value = Estatus - .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener las Promociones.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function AddPromociones(Promocion As String, FechaInicio As Date, FechaFin As Date, CveVendedor As Integer, CveCliente As Integer, Estatus As Boolean, CveMoneda As Integer, CveUsuario As Integer, CveEmpresa As Integer, CveSubProyecto As Integer) As Integer - Dim Retorno = -1 - DataAdapter("PA_Vta_PromocionesAdd") - - - With SqlAdapter.SelectCommand.Parameters - .Add("@Promocion", SqlDbType.VarChar).Value = Promocion - .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio - .Add("@FechaFin", SqlDbType.Date).Value = FechaFin - .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@Estatus", SqlDbType.Bit).Value = Estatus - .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CvePromocion", SqlDbType.Int).Direction = ParameterDirection.Output - End With - - Try - SqlAdapter.Fill(Data) - Retorno = SqlAdapter.SelectCommand.Parameters("@CvePromocion").Value.ToString.ToEntero - Catch ex As Exception - OnError("Ocurrió un error al agregar la Promoción.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function UpdatePromociones(Promocion As String, FechaInicio As Date, FechaFin As Date, CveVendedor As Integer, CveCliente As Integer, Estatus As Boolean, CveMoneda As Integer, CveUsuario As Integer, CvePromocion As Integer, CveSubProyecto As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_PromocionesUpdate") - - - With SqlAdapter.SelectCommand.Parameters - .Add("@Promocion", SqlDbType.VarChar).Value = Promocion - .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio - .Add("@FechaFin", SqlDbType.Date).Value = FechaFin - .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@Estatus", SqlDbType.Bit).Value = Estatus - .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CvePromocion", SqlDbType.Float).Value = CvePromocion - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar la Promoción.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function RemovePromociones(CvePromocion As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_PromocionesRemove") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePromocion", SqlDbType.Int).Value = CvePromocion - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al Eliminar la Promoción.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function -#End Region - -#Region " PROMOCIONES DETALLE " - Public Function GetPromocionesPS(CvePS As Integer, Fecha As DateTime, CveSubProyecto As Integer, CveCliente As Integer, CveVendedor As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_PromocionesPSGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@Fecha", SqlDbType.DateTime).Value = Fecha - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los detalles de las promocion.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function GetPromocionesDetalle(CvePromocion As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_PromocionesDetalleGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePromocion", SqlDbType.Int).Value = CvePromocion - .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 detalles de las promocion.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function AddPromocionesDetalle(CvePromocion As Integer, CvePS As Integer, TipoPromocion As Integer, Promocion As Double, PUAnterior As Double, PUPromocion As Double, AplicaRestriccion As Boolean, AplicaLunes As Boolean, AplicaMartes As Boolean, AplicaMiercoles As Boolean, AplicaJueves As Boolean, AplicaViernes As Boolean, AplicaSabado As Boolean, AplicaDomingo As Boolean, HoraInicio As DateTime, HoraFin As DateTime) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_PromocionesDetalleAdd") - - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePromocion", SqlDbType.Int).Value = CvePromocion - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@TipoPromocion", SqlDbType.Int).Value = TipoPromocion - .Add("@Promocion", SqlDbType.Money).Value = Promocion - .Add("@PUAnterior", SqlDbType.Money).Value = PUAnterior - .Add("@PUPromocion", SqlDbType.Money).Value = PUPromocion - .Add("@AplicaRestriccion", SqlDbType.Bit).Value = AplicaRestriccion - .Add("@AplicaLunes", SqlDbType.Bit).Value = AplicaLunes - .Add("@AplicaMartes", SqlDbType.Bit).Value = AplicaMartes - .Add("@AplicaMiercoles", SqlDbType.Bit).Value = AplicaMiercoles - .Add("@AplicaJueves", SqlDbType.Bit).Value = AplicaJueves - .Add("@AplicaViernes", SqlDbType.Bit).Value = AplicaViernes - .Add("@AplicaSabado", SqlDbType.Bit).Value = AplicaSabado - .Add("@AplicaDomingo", SqlDbType.Bit).Value = AplicaDomingo - .Add("@HoraInicio", SqlDbType.DateTime).Value = HoraInicio - .Add("@HoraFin", SqlDbType.DateTime).Value = HoraFin - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar los detalles de la Promoción.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function UpdatePromocionesDetalle(CvePromocionDetalle As Integer, CvePromocion As Integer, CvePS As Integer, TipoPromocion As Integer, Promocion As Double, PUAnterior As Double, PUPromocion As Double, AplicaRestriccion As Boolean, AplicaLunes As Boolean, AplicaMartes As Boolean, AplicaMiercoles As Boolean, AplicaJueves As Boolean, AplicaViernes As Boolean, AplicaSabado As Boolean, AplicaDomingo As Boolean, HoraInicio As DateTime, HoraFin As DateTime) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_PromocionesDetalleUpdate") - - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePromocion", SqlDbType.Int).Value = CvePromocion - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@TipoPromocion", SqlDbType.Int).Value = TipoPromocion - .Add("@Promocion", SqlDbType.Money).Value = Promocion - .Add("@PUAnterior", SqlDbType.Money).Value = PUAnterior - .Add("@PUPromocion", SqlDbType.Money).Value = PUPromocion - .Add("@AplicaRestriccion", SqlDbType.Bit).Value = AplicaRestriccion - .Add("@AplicaLunes", SqlDbType.Bit).Value = AplicaLunes - .Add("@AplicaMartes", SqlDbType.Bit).Value = AplicaMartes - .Add("@AplicaMiercoles", SqlDbType.Bit).Value = AplicaMiercoles - .Add("@AplicaJueves", SqlDbType.Bit).Value = AplicaJueves - .Add("@AplicaViernes", SqlDbType.Bit).Value = AplicaViernes - .Add("@AplicaSabado", SqlDbType.Bit).Value = AplicaSabado - .Add("@AplicaDomingo", SqlDbType.Bit).Value = AplicaDomingo - .Add("@HoraInicio", SqlDbType.DateTime).Value = HoraInicio - .Add("@HoraFin", SqlDbType.DateTime).Value = HoraFin - .Add("@CvePromocionDetalle", SqlDbType.Int).Value = CvePromocionDetalle - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar los detalles de la Promoción.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function RemovePromocionesDetalle(CvePromocionDetalle As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_PromocionesDetalleRemove") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePromocionDetalle", SqlDbType.Int).Value = CvePromocionDetalle - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al Eliminar la Promoción.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function -#End Region - -#Region "Pruebas" - - Public Function GetDeduccion(CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasDeduccionesGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.VarChar).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los datos de las deducciones.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function AddDeduccion(Deduccion As String, Porcentaje As Double, CveUsuario As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasDeduccionesAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@Deduccion", SqlDbType.VarChar).Value = Deduccion - .Add("@Porcentaje", SqlDbType.VarChar).Value = Porcentaje - .Add("@CveUsuario", SqlDbType.VarChar).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.VarChar).Value = CveEmpresa - - End With - - Try - SqlAdapter.Fill(Data) - - Catch ex As Exception - OnError("Ocurrió un error al tratar de agregar la deducción. ", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - - Public Function RemoveDeduccion(CveVentaDeduccion As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasDeduccionesRemove") - - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVentaDeduccion", SqlDbType.Int).Value = CveVentaDeduccion - - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As SqlException - OnError("Ocurrió un error al tratar de eliminar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - - - End Function - Public Function UpdateDeduccion(CvePrincipal As Integer, Deduccion As String, Porcentaje As Double, CveUsuario As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasDeduccionesUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePrincipal", SqlDbType.VarChar).Value = CvePrincipal - .Add("@Deduccion", SqlDbType.VarChar).Value = Deduccion - .Add("@Porcentaje", SqlDbType.VarChar).Value = Porcentaje - .Add("@CveUsuario", SqlDbType.VarChar).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.VarChar).Value = CveEmpresa - End With - Try - SqlAdapter.Fill(Data) - - Catch ex As Exception - OnError("Ocurrió un error al tratar de Actualizar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - - - - -#End Region - - Public Function GetPrecios(CveClasificacion As Integer, CvePS As Integer, CveEmpresa As Integer, CveSubProyecto As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_ActualizarPreciosGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los precios de los precios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - -#Region "Firmas" - - Public Function GetVentasFirmas(CveVenta As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasFirmasGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener las firmas de las ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - - Public Function AddVentasFirmas(CveVenta As Integer, Titulo As String, Nombre As String, Puesto As String, Lado As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasFirmasAdd") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@Titulo", SqlDbType.VarChar).Value = Titulo - .Add("@Nombre", SqlDbType.VarChar).Value = Nombre - .Add("@Puesto", SqlDbType.VarChar).Value = Puesto - .Add("@Lado", SqlDbType.Bit).Value = Lado - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar las firmas de las ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - - Public Function UpdateVentasFirmas(CveVentaFirma As Integer, CveVenta As Integer, Titulo As String, Nombre As String, Puesto As String, Lado As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasFirmasUpdate") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVentaFirma", SqlDbType.Int).Value = CveVentaFirma - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@Titulo", SqlDbType.VarChar).Value = Titulo - .Add("@Nombre", SqlDbType.VarChar).Value = Nombre - .Add("@Puesto", SqlDbType.VarChar).Value = Puesto - .Add("@Lado", SqlDbType.VarChar).Value = Lado - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar las firmas de las ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - - Public Function RemoveVentasFirmas(CveVentaFirma As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasFirmasRemove") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVentaFirma", SqlDbType.Int).Value = CveVentaFirma - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al eliminar las firmas de las ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - - -#End Region - -#Region " I M P U E S T O S L O C A L E S" - Public Function AddImpuestosLocales(ImpuestoLocal As String, Porcentaje As Double, Orden As Integer, TipoImpuesto As Integer, Estatus As Integer, IdCtaContable As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_ImpuestosLocalesAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@ImpuestoLocal", SqlDbType.VarChar).Value = ImpuestoLocal - .Add("@Porcentaje", SqlDbType.SmallMoney).Value = Porcentaje - .Add("@Orden", SqlDbType.Int).Value = Orden - .Add("@TipoImpuesto", SqlDbType.Int).Value = TipoImpuesto - .Add("@Estatus", SqlDbType.Bit).Value = Estatus - .Add("@IdCtaContable", SqlDbType.Int).Value = IdCtaContable - .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 añadir los impuestos locales.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function GetImpuestosLocales(CveUsuario As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_ImpuestosLocalesGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los impuestos locales.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function UpdateImpuestosLocales(CveImpuestoLocal As Integer, ImpuestoLocal As String, Porcentaje As Double, Orden As Integer, TipoImpuesto As Integer, Estatus As Integer, IdCtaContable As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_ImpuestosLocalesUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveImpuestoLocal", SqlDbType.Int).Value = CveImpuestoLocal - .Add("@ImpuestoLocal", SqlDbType.VarChar).Value = ImpuestoLocal - .Add("@Porcentaje", SqlDbType.SmallMoney).Value = Porcentaje - .Add("@TipoImpuesto", SqlDbType.Int).Value = TipoImpuesto - .Add("@Orden", SqlDbType.Int).Value = Orden - .Add("@Estatus", SqlDbType.Bit).Value = Estatus - .Add("@IdCtaContable", SqlDbType.Int).Value = IdCtaContable - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar los impuestos locales.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function RemoveImpuestosLocales(CveImpuestoLocal As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_ImpuestosLocalesRemove") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveImpuestoLocal", SqlDbType.Int).Value = CveImpuestoLocal - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al eliminar los impuestos locales.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - - End Function - - -#End Region - - -#Region " ANTICIPOS/NOTASCREDITO - VENTAS " - Public Function GetVentasAntNC(CveVenta As Integer, CveVentaNC As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasAntNCGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveVentaNC", SqlDbType.Int).Value = CveVentaNC - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener las NotasCrédito/Anticipos de la venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function -#End Region - - Public Function GetRemisionesSinFacturar(FechaI As String, FechaF As String, CveCliente As Integer, CveContrato As Integer, Tipo As Integer, CveMoneda As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_VentasRemisionesFacturasGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.VarChar).Value = FechaI - .Add("@FechaF", SqlDbType.VarChar).Value = FechaF - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveContrato", SqlDbType.Int).Value = CveContrato - .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda - .Add("@Tipo", SqlDbType.Int).Value = Tipo - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener las remisiones sin facturar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function GetOCSinFacturar(FechaI As String, FechaF As String, CveCliente As Integer, Tipo As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_VentasOrdenesCompraGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.VarChar).Value = FechaI - .Add("@FechaF", SqlDbType.VarChar).Value = FechaF - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@Tipo", SqlDbType.Int).Value = Tipo - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener las ordenes de compra sin facturar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function GetRepRemisionesSinFacturar(FechaI As String, FechaF As String, FechaV As String, CveSubProyecto As String, CveCliente As Integer, CveContrato As Integer, CveVendedor As String, CveEmpresa As Integer, Optional CveUsuarioConsulta As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("Vta_RepRemisionesGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.VarChar).Value = FechaI - .Add("@FechaF", SqlDbType.VarChar).Value = FechaF - .Add("@FechaV", SqlDbType.VarChar).Value = FechaV - .Add("@CveSubProyecto", SqlDbType.VarChar).Value = CveSubProyecto - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveContrato", SqlDbType.Int).Value = CveContrato - .Add("@CveVendedor", SqlDbType.VarChar).Value = CveVendedor - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener las remisiones sin facturar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function GetRepRemisionesSinFacturarDetalle(FechaI As String, FechaF As String, FechaV As String, CveCliente As Integer, CveContrato As Integer, CveVenta As Integer, CveEmpresa As Integer, CveSubProyecto As String, Optional CveUsuarioConsulta As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("Vta_RepRemisionesDetalleGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.VarChar).Value = FechaI - .Add("@FechaF", SqlDbType.VarChar).Value = FechaF - .Add("@FechaV", SqlDbType.VarChar).Value = FechaV - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveContrato", SqlDbType.Int).Value = CveContrato - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveSubProyecto", SqlDbType.VarChar).Value = CveSubProyecto - .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener las remisiones sin facturar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function GetReporteHP(CveEmpresa As Integer, FechaInicio As Date, FechaFin As Date) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Compu_HPRep") - - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio - .Add("@FechaFin", SqlDbType.Date).Value = FechaFin - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el reporte.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function GetReporteVentasUtilidad(CveVendedor As String, CveCliente As Integer, CveSubProyecto As String, FechaInicio As Date, FechaFin As Date, CveEmpresa As Integer, CvePS As Integer, CveClasificacion As Double) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasUtilidadGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.Date).Value = FechaInicio - .Add("@FechaF", SqlDbType.Date).Value = FechaFin - .Add("@CveVendedor", SqlDbType.VarChar).Value = CveVendedor - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveSubProyecto", SqlDbType.VarChar).Value = CveSubProyecto - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion - End With - - Try - SqlAdapter.Fill(Data) - - If Data.Rows.Count > 0 Then _Neto = Data.Rows(0)("Neto").ToString.ToDouble : _PorNeto = Data.Rows(0)("PorNeto").ToString.ToDouble - - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el reporte de utilidad de ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function GetReporteVentasUtilidadDetalle(CveVendedor As String, CveVenta As Integer, CveCliente As Integer, CveSubProyecto As String, FechaInicio As Date, FechaFin As Date, CveEmpresa As Integer, CvePS As Integer, CveClasificacion As Double) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasUtilidadDetalleGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.Date).Value = FechaInicio - .Add("@FechaF", SqlDbType.Date).Value = FechaFin - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveVendedor", SqlDbType.VarChar).Value = CveVendedor - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveSubProyecto", SqlDbType.VarChar).Value = CveSubProyecto - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion - End With - - Try - SqlAdapter.Fill(Data) - If Data.Rows.Count > 1 Then _SerieVenta = Data.Rows(1)("SerieFolio").ToString : _SubTotalVenta = Data.Rows(0)("SubTotal").ToString.ToDouble : _SubTotalVentaDolares = Data.Rows(0)("SubTotalDolares").ToString.ToDouble : _FechaVenta = Data.Rows(1)("FechaVenta").ToString - If Data.Rows.Count > 1 Then _Costo = Data.Rows(0)("CostoVta").ToString.ToDouble : _FolioCosto = Data.Rows(1)("FolioMovto").ToString : _FechaSalidaCosto = Data.Rows(1)("FechaMovto").ToString - - If Data.Rows.Count > 0 Then _Utilidad = Data.Rows(0)("Utilidad").ToString.ToDouble : _PorUtilidad = Data.Rows(0)("PorUtilidad").ToString.ToDouble - If Data.Rows.Count > 0 Then _Perdida = Data.Rows(0)("Perdida").ToString.ToDouble : _PorPerdida = Data.Rows(0)("PorPerdida").ToString.ToDouble - - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el reporte de utilidad de ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function GetReportePadreVentasUtilidad(CveVendedor As String, CveCliente As Integer, CveSubProyecto As String, FechaInicio As Date, FechaFin As Date, CveEmpresa As Integer, Gpo As Integer, CvePS As Integer, CveClasificacion As Double) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_RepVentasUtilidadGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.Date).Value = FechaInicio - .Add("@FechaF", SqlDbType.Date).Value = FechaFin - .Add("@CveVendedor", SqlDbType.VarChar).Value = CveVendedor - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveSubProyecto", SqlDbType.VarChar).Value = CveSubProyecto - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@Gpo", SqlDbType.Int).Value = Gpo - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el reporte de utilidad de ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - - Public Function GetReporteVentasAutorizaciones(CveUsuario As Integer, CveEstatusFactura As Integer, CveSubProyecto As Integer, FechaInicio As Date, FechaFin As Date, CveCliente As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_RepVentasAutorizacionesGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEstatusFactura", SqlDbType.Int).Value = CveEstatusFactura - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@FechaI", SqlDbType.Date).Value = FechaInicio - .Add("@FechaF", SqlDbType.Date).Value = FechaFin - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el reporte de Autorizaciones de Ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - -#Region " Facturas " - - Public Function GetFacturas(CveFactura As Integer, Folio As String, FechaFacturaI As Date, FechaFacturaF As Date, RFC As String, Proveedor As String, FueValidado As Integer, CveResponsable As Integer, CveEmpresa As Integer) As Boolean - Dim OnError As Boolean = False - - - DataAdapter("PA_Vta_FacturasGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@Folio", SqlDbType.VarChar).Value = Folio - .Add("@FechaFacturaI", SqlDbType.Date).Value = FechaFacturaI - .Add("@FechaFacturaF", SqlDbType.Date).Value = FechaFacturaF - .Add("@RFC", SqlDbType.VarChar).Value = RFC - .Add("@Proveedor", SqlDbType.VarChar).Value = Proveedor - .Add("@FueValidado", SqlDbType.Int).Value = FueValidado - .Add("@CveResponsable", SqlDbType.Int).Value = CveResponsable - .Add("@CveFactura", SqlDbType.Int).Value = CveFactura - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - OnError = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener las Facturas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return OnError - End Function - Public Function GetFacturasCanceladasPendientes(FoliosFiscales As String, CveEmpresa As Integer) As Boolean - Dim OnError As Boolean = False - DataAdapter("PA_Vta_FacturasCanceladasPendientesGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@FoliosFiscales", SqlDbType.VarChar).Value = FoliosFiscales - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - OnError = True - Catch ex As Exception - Me.OnError("Ocurrió un error al obtener las facturas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return OnError - End Function - - Public Function UpdateVentaFacturas(CveFactura As Integer, CveVenta As Integer, CveEmpresa As Integer) As Boolean - Dim OnError As Boolean = False - - - DataAdapter("PA_Vta_FacturaVentaUpdate") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveFactura", SqlDbType.Int).Value = CveFactura - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - OnError = True - Catch ex As Exception - Me.OnError("Ocurrió un error al actualizar las Facturas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return OnError - End Function - Public Function ProcesoPrepolizasCancelacion(CveVenta As Integer, CveUsuario As Integer) As Boolean - Dim OnError As Boolean = False - - DataAdapter("PA_Vta_ProcesoPrepolizasCancelacion") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - End With - - Try - SqlAdapter.Fill(Data) - OnError = True - Catch ex As Exception - Me.OnError("Ocurrió un error al crear las prepolizas de cancelación.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return OnError - End Function -#End Region - - -#Region "C O N D I C I O N E S D E E N T R E G A" - Public Function GetCondicionesEntrega(CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_CondicionesEntregaGet") - 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 reporte de utilidad de ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function -#End Region - -#Region " CANCELAR PEDIDO " - Public Function CancelarPedido(CveVenta As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_CancelarPedido") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al cancelar el pedido.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function -#End Region - -#Region "Punto Venta" - - Public Function AddVtaCortesDetalles(CveCorte As Integer, CveMetodoPago As Integer, Importe As Double) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_CortesDetallesAdd") - - - If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCorte", SqlDbType.Int).Value = CveCorte - .Add("@CveMetodoPago", SqlDbType.Int).Value = CveMetodoPago - .Add("@Importe", SqlDbType.Money).Value = Importe - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As SqlException - OnError("Ocurrió un error al guardar el Detalle del Corte de Turno.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function GetCortesDetalleVentasResumen(CveCorte As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Vta_CortesDetalleVentasResumenGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCorte", SqlDbType.Int).Value = CveCorte - .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 detalle de cortes", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - -#End Region - -#Region " CANCELAR ANTE SAT " - Public Function CancelarVentasSAT(StrVentas As String) As String - Dim CveVentas = StrVentas.Split(","c) - Dim CveVentasError As New List(Of Integer) - - If CveVentas IsNot Nothing Then - Dim ObjVentas As New ClsVentas - Dim ObjCancelacion As New Timbrado - Dim ObjUsuario As New ClsSisUsuarios - Dim Usuario As Usuario = Nothing - Dim ObjEmpresa As New ClsSisEmpresas() - - Dim FolioFiscal = "-1" - Dim CveEstatus = -1 - Dim Total = 0.0D - Dim RFCReceptor = "-1" - Dim Nombre = "-1" - Dim DbRowVenta As DataRow - Dim CveUsuario = -1 - Dim pCveEmpresa = -1 - Dim Contraseña = "-1" - - For Each PCveVenta In CveVentas - If ObjVentas.GetVenta(PCveVenta.ToEntero, -1) Then - DbRowVenta = ObjVentas.DtResultados.Rows(0) - - FolioFiscal = DbRowVenta("FolioFiscal").ToString - CveEstatus = DbRowVenta("CveEstatusFactura").ToString.ToEntero - Total = DbRowVenta("Total").ToString.ToDecimal - RFCReceptor = DbRowVenta("ClienteRFC").ToString - CveUsuario = DbRowVenta("CveUsuario").ToString.ToEntero - pCveEmpresa = DbRowVenta("CveEmpresa").ToString.ToEntero - Nombre = DbRowVenta("Nombre").ToString - - If ObjUsuario.GetUsuarios(CveUsuario, -1, -1) Then - Contraseña = ObjUsuario.DtResultados.Rows(0)("Contraseña").ToString - Else - CveVentasError.Add(PCveVenta.ToEntero) - Continue For - End If - Usuario = ObjUsuario.ValidaUsuario(Nombre, Contraseña, IMEI) - - If ObjEmpresa.GetEmpresas(pCveEmpresa, "-1", "-1", "-1", "-1") Then - Usuario.Empresa = ObjEmpresa.Empresa - Usuario.CveEmpresa = ObjEmpresa.Empresa.CveEmpresa - Else - CveVentasError.Add(PCveVenta.ToEntero) - Continue For - End If - - - 'SOLO SI ESTA CANCELADA ANTE SAT EN SIG SE INTENTARA CANCELAR DE NUEVO CONTRA EL SAT - If CveEstatus = 5 Then - If ObjCancelacion.CFDICancelar(Usuario.Empresa, FolioFiscal, Total, RFCReceptor, Usuario.Empresa.RFC) Then - If Not ObjVentas.UpdateEstatusFactura(5, FolioFiscal, ObjCancelacion.CancelacionAcuse, Now, PCveVenta.ToEntero, -1, CvePAC:=Usuario.Empresa.CvePAC) Then - CveVentasError.Add(PCveVenta.ToEntero) - End If - Else - CveVentasError.Add(PCveVenta.ToEntero) - End If - Else - CveVentasError.Add(PCveVenta.ToEntero) - End If - End If - Next - - ObjVentas.Dispose() - ObjUsuario.Dispose() - ObjEmpresa.Dispose() - Else - - End If - - Return "Procesando" - End Function -#End Region - -#Region "Remisiones" - Public Function GetRemisionesRelacionadas(CveVenta As Integer, TipoDocto As String) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_RemisionesRelacionadasGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el reporte de Remisiones/Facturas Relacionadas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - -#End Region - - Public Function VentasSaldar(CveVenta As Integer, CveUsuario As Integer, CveEmpresa As Integer, Optional Amortizacion As Integer = -1, Optional CveVentaAmortizada As Integer = -1, Optional CveContrato As Integer = -1, Optional Fecha As Date = MinFecha) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasSaldar") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@Amortizacion", SqlDbType.Int).Value = Amortizacion - .Add("@CveVentaAmortizada", SqlDbType.Int).Value = CveVentaAmortizada - .Add("@CveContrato", SqlDbType.Int).Value = CveContrato - .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 saldar una venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - -#Region "COTIZACIONES SIN FACTURAR" - - Public Function GetCotizacionesSinFacturar(FechaI As String, FechaF As String, CveCliente As Integer, Tipo As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_VentasCotizacionesFacturasGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.VarChar).Value = FechaI - .Add("@FechaF", SqlDbType.VarChar).Value = FechaF - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@Tipo", SqlDbType.Int).Value = Tipo - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener las remisiones sin facturar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function GetRepCotizacionesSinFacturar(FechaI As String, FechaF As String, FechaV As String, CveSucursal As Integer, CveCliente As Integer, CveContrato As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("Vta_RepCotizacionesGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.VarChar).Value = FechaI - .Add("@FechaF", SqlDbType.VarChar).Value = FechaF - .Add("@FechaV", SqlDbType.VarChar).Value = FechaV - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSucursal - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveContrato", SqlDbType.Int).Value = CveContrato - .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 remisiones sin facturar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function GetRepCotizacionesSinFacturarDetalle(FechaI As String, FechaF As String, FechaV As String, CveSucursal As Integer, CveCliente As Integer, CveContrato As Integer, CveVenta As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("Vta_RepCotizacionesDetalleGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.VarChar).Value = FechaI - .Add("@FechaF", SqlDbType.VarChar).Value = FechaF - .Add("@FechaV", SqlDbType.VarChar).Value = FechaV - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSucursal - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveContrato", SqlDbType.Int).Value = CveContrato - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .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 remisiones sin facturar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - Public Function AgregaCotizacionDetalle(CveVentaDetalle As Integer, CveVentaDetallePadre As Integer, Cantidad As Decimal) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_AddCotizacionDetalle") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVentaDetalle", SqlDbType.Int).Value = CveVentaDetalle - .Add("@CveVentaDetallePadre", SqlDbType.Int).Value = CveVentaDetallePadre - .Add("@Cantidad", SqlDbType.Int).Value = Cantidad - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar el detalle de la Cotización.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - -#End Region - -#Region "C O B R A N Z A V E N T A S" - Public Function UpdateVentaCobranza(CveVenta As Integer, CveCobranzaEstatus As Integer, CveCobranzaEstatusTurno As Integer, FechaCobranza As DateTime, CobranzaObservacion As String) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_VentasCobranzaUpdate") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveCobranzaEstatus", SqlDbType.Int).Value = CveCobranzaEstatus - .Add("@FechaCobranza", SqlDbType.DateTime).Value = FechaCobranza - .Add("@CobranzaObservacion", SqlDbType.VarChar).Value = CobranzaObservacion - .Add("@CveCobranzaEstatusTurno", SqlDbType.Int).Value = CveCobranzaEstatusTurno - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - Me.OnError("Ocurrió un error al intentar Actualizar los datos de la venta.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - Catch ex As Exception - OnError("Ocurrió un error al intentar Actualizar los datos de la venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - Public Function UpdateAsignaVentaCobranza(CveVenta As Integer, CveCobranzaEstatus As Integer, CveUsuarioCobranza As Integer, CveCobranzaEstatusTurno As Integer, CobranzaObservacion As String, FechaCobranza As DateTime) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_AsignaCobranzaUpdate") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveCobranzaEstatus", SqlDbType.Int).Value = CveCobranzaEstatus - .Add("@FechaCobranza", SqlDbType.DateTime).Value = FechaCobranza - .Add("@CveUsuarioCobranza", SqlDbType.Int).Value = CveUsuarioCobranza - .Add("@CobranzaObservacion", SqlDbType.VarChar).Value = CobranzaObservacion - .Add("@CveCobranzaEstatusTurno", SqlDbType.Int).Value = CveCobranzaEstatusTurno - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex1 As SqlException - Me.OnError("Ocurrió un error al intentar Actualizar los datos de la venta.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - Catch ex As Exception - OnError("Ocurrió un error al intentar Actualizar los datos de la venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - Public Function GetCobranzaEstatus(CveCobranzaEstatus As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_EstatusCobranzaGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCobranzaEstatus", SqlDbType.Int).Value = CveCobranzaEstatus - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex As SqlException - Me.OnError("Ocurrió un error al intentar obtener los estatus de cobranza", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - Return Retorno - End Function - Public Function GetCobranzaTurnoEstatus(CveCobranzaEstatusTurno As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_EstatusTurnoCobranzaGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCobranzaEstatusTurno", SqlDbType.Int).Value = CveCobranzaEstatusTurno - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex As SqlException - Me.OnError("Ocurrió un error al intentar obtener los estatus de cobranza", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - Return Retorno - End Function - Public Function GetGestionCobranza(CveCobranzaEstatus As Integer, CveUsuarioCobranza As Integer, CveResponsableCobranza As Integer, CveCobranzaTurno As Integer, TipoPago As String, FechaI As String, FechaF As String, CveEmpresa As Integer, TipoCambio As Integer, TCEspecifico As Double) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_GestionCobranzaGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCobranzaEstatus", SqlDbType.Int).Value = CveCobranzaEstatus - .Add("@CveUsuarioCobranza", SqlDbType.Int).Value = CveUsuarioCobranza - .Add("@CveResponsableCobranza", SqlDbType.Int).Value = CveResponsableCobranza - .Add("@CveCobranzaTurno", SqlDbType.Int).Value = CveCobranzaTurno - .Add("@TipoPago", SqlDbType.VarChar).Value = TipoPago - .Add("@FechaI", SqlDbType.VarChar).Value = FechaI - .Add("@FechaF", SqlDbType.VarChar).Value = FechaF - .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 SqlException - Me.OnError("Ocurrió un error al intentar obtener la gestión de cobranza", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - Return Retorno - End Function - Public Function AddVisitaCobranza(CveVenta As Integer, CveUsuarioCobranza As Integer, FechaCobranza As Date, Observaciones As String) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_VisitaCobranzaAdd") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveUsuarioCobranza", SqlDbType.Int).Value = CveUsuarioCobranza - .Add("@FechaCobranza", SqlDbType.Date).Value = FechaCobranza - .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex As SqlException - Me.OnError("Ocurrió un error al intentar guardar la visita de cobranza", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - Return Retorno - End Function -#End Region - -#Region "C O M P L E M E N T O S" - Public Function UpdateVentasComplementos(CveVenta As Integer, TipoProceso As String, TipoComite As String, IdContabilidad As String) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_UpdateVentaComplementos") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@TipoProceso", SqlDbType.VarChar).Value = TipoProceso - .Add("@TipoComite", SqlDbType.VarChar).Value = TipoComite - .Add("@IdContabilidad", SqlDbType.VarChar).Value = IdContabilidad - - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar los complementos de la venta", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - -#End Region - -#Region " FLETES " - Public Function GetFletes(CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_WT_Viajes") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch Ex As SqlException - Me.OnError("Ocurrió un error al intentar obtener los Fletes", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - Return Retorno - End Function -#End Region - -#Region "Metodos y Forma de Pago" - - Public Function GetFormaPago() As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_FormaPagoGet") - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As SqlException - OnError("Ocurrió un error al obtener Formas de pago", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function GetMetodoPago() As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_MetodoPagoGet") - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As SqlException - OnError("Ocurrió un error al obtener Métodos de Pago.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - -#End Region - - Public Function GetTiposRelacion() As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_TiposRelacionGet") - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As SqlException - OnError("Ocurrió un error al obtener Tipos de relación.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - -#Region "Tipo Documentos" - - Public Function GetTiposDocumentos() As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_TipoDocumentosGet") - With SqlAdapter.SelectCommand.Parameters - - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los tipos de documentos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - -#End Region - -#Region "DEVOLUCIONES" - Public Function AddVentaDetalleDevolucion(pCveVentaDetalle As Integer, CveVentaDetalleDevolucion As Integer, Cantidad As Double) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasDetalleDevolucionAdd") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVentaDetalle", SqlDbType.Int).Value = pCveVentaDetalle - .Add("@CveVentaDetalleDevolucion", SqlDbType.Int).Value = CveVentaDetalleDevolucion - .Add("@Cantidad", SqlDbType.Float).Value = Cantidad - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar la venta devolucion detalle .", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - - Public Function RemoveVentaDetalleDevolucion(CveVenta As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasDetalleDevolucionRemove") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al eliminar la venta devolucion detalle .", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function -#End Region - -#Region "COMISIONES" - - Public Function GetRepComisiones(FechaI As Date, FechaF As Date, CveSubProyecto As Integer, CveVendedor As Integer, CveCliente As Integer, CveUsuario As Integer, CveEmpresa As Integer, TipoSaldo As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_RepComisiones119") - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.Date).Value = FechaI - .Add("@FechaF", SqlDbType.Date).Value = FechaF - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@TipoSaldo", SqlDbType.Int).Value = TipoSaldo - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el reporte de comisiones.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - -#End Region - -#Region "REPORTE DE PRODUCTOS SERVICIOS PERIODO" - - - Public Function GetRepPSPeriodo(FechaI As Date, FechaF As Date, FechaIEjec As Date, FechaFEjec As Date, CveCliente As Integer, CveSubProyectoEjecucion As Integer, - CveVendedor As Integer, CveUsuario As Integer, CveEstatus As Integer, IVA As String, CveEmpresa As Integer, Gpo As Integer, Optional TipoDocto As String = "-1", - Optional CveProyecto As Integer = -1, Optional CveSubProyecto As Integer = -1, Optional TipoCambio As Integer = 1, Optional TCEspecifico As Decimal = -1, - Optional CveUsuarioConsulta As Integer = -1, Optional VerEn As Integer = -1, Optional CvePS As Integer = -1, Optional CveClasificacion As Integer = -1, - Optional CveCategoria As Integer = -1, Optional TipoFecha As Integer = 1, Optional CveClienteClasificacion As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_VentasGetRepPeriodoPS") - With SqlAdapter.SelectCommand.Parameters - '.Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@FechaI", SqlDbType.Date).Value = FechaI - .Add("@FechaF", SqlDbType.Date).Value = FechaF - .Add("@FechaIEjec", SqlDbType.Date).Value = FechaIEjec - .Add("@FechaFEjec", SqlDbType.Date).Value = FechaFEjec - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveSubProyectoEjecucion", SqlDbType.Int).Value = CveSubProyectoEjecucion - .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEstatus", SqlDbType.Int).Value = CveEstatus - .Add("@IVA", SqlDbType.VarChar).Value = IVA - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@GPO", SqlDbType.Int).Value = Gpo - .Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveProyecto", SqlDbType.Int).Value = CveProyecto - .Add("@TipoCambio", SqlDbType.Int).Value = TipoCambio - .Add("@TCEspecifico", SqlDbType.Float).Value = TCEspecifico - .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta - .Add("@VerEn", SqlDbType.Int).Value = VerEn - .Add("@CvePS", SqlDbType.Int).Value = CvePS - .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion - .Add("@CveCategoria", SqlDbType.Int).Value = CveCategoria - .Add("@TipoFecha", SqlDbType.Int).Value = TipoFecha - .Add("@CveClienteClasificacion", SqlDbType.Int).Value = CveClienteClasificacion - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Reporte de Productos Servicios por Periodo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function - -#End Region - -#Region "Ventas Refacturas" - Public Function GetVentaRefacturacion(CveVenta As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentaRefacturacionGet") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener datos de la venta refacturada .", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - Return Retorno - End Function -#End Region - -#Region "REPORTE DE ANTICIPOS - NC - IXC" - - Public Function GetRepAnticiposNCIXC(CveCliente As Integer, CveSubProyecto As Integer, FechaI As Date, FechaF As Date, CveEmpresa As Integer, FechaICorte As Date, FechaFCorte As Date, TipoCambio As Integer, TCEspecifico As Double, Optional CveVendedor As Integer = -1, Optional ConSaldo As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_RepAnt-NC-IXC") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@FechaI", SqlDbType.Date).Value = FechaI - .Add("@FechaF", SqlDbType.Date).Value = FechaF - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@FechaICorte", SqlDbType.Date).Value = FechaICorte - .Add("@FechaFCorte", SqlDbType.Date).Value = FechaFCorte - .Add("@TipoCambio", SqlDbType.Int).Value = TipoCambio - .Add("@TCEspecifico", SqlDbType.Float).Value = TCEspecifico - .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor - .Add("@ConSaldo", SqlDbType.Int).Value = ConSaldo - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el reporte de anticipos - nc - ixc .", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - - Public Function GetRepAnticiposNCIXCDetalle(CveCliente As Integer, CveSubProyecto As Integer, FechaI As Date, FechaF As Date, CveEmpresa As Integer, ConSaldo As Integer, Tipo As Integer, CveMoneda As Integer, FechaICorte As Date, FechaFCorte As Date, TipoCambio As Integer, TCEspecifico As Double, Optional CveVendedor As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_RepAnt-NC-IXCDetalle") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@FechaI", SqlDbType.Date).Value = FechaI - .Add("@FechaF", SqlDbType.Date).Value = FechaF - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@ConSaldo", SqlDbType.Int).Value = ConSaldo - .Add("@Tipo", SqlDbType.Int).Value = Tipo - .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda - .Add("@FechaICorte", SqlDbType.Date).Value = FechaICorte - .Add("@FechaFCorte", SqlDbType.Date).Value = FechaFCorte - .Add("@TipoCambio", SqlDbType.Int).Value = TipoCambio - .Add("@TCEspecifico", SqlDbType.Float).Value = TCEspecifico - .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el reporte de anticipos - nc - ixc detalle .", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - -#End Region - -#Region "BUSCAR OC REGISTRADAS" - Public Function GetOCVentas(CveCliente As Integer, OC As String) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_GetOCVentas") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@OC", SqlDbType.VarChar).Value = OC - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el reporte de Ordenes de compra.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function -#End Region - -#Region "CLASIFICACIONES DETALLE" - Public Function GetClasificacionDetalle(CveEmpresa As Integer, Optional CveClasificacionDetalle As Integer = -1, Optional Estatus As Integer = -1, Optional CveClasificacion As Integer = -1) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_ClasificacionesDetalleGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveClasificacionDetalle", SqlDbType.Int).Value = CveClasificacionDetalle - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@Estatus", SqlDbType.Int).Value = Estatus - .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener las clasificaciones detalle.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - Return Retorno - End Function - - Public Function AddClasificacionDetalle(ClasificacionDetalle As String, CveClasificacion As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_ClasificacionesDetalleAdd") - With SqlAdapter.SelectCommand.Parameters - .Add("@ClasificacionDetalle", SqlDbType.VarChar).Value = ClasificacionDetalle - .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveClasificacionDetalle", SqlDbType.Int).Direction = ParameterDirection.Output - End With - Try - SqlAdapter.Fill(Data) - CveClasificacionDetalle = SqlAdapter.SelectCommand.Parameters("@CveClasificacionDetalle").Value.ToString.ToEntero - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al guardar la clasificacion detalle.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - Return Retorno - End Function - - Public Function UpdateClasificacionDetalle(CveClasificacionDetalle As Integer, ClasificacionDetalle As String, CveClasificacion As Integer, Estatus As Boolean) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_ClasificacionesDetalleUpdate") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveClasificacionDetalle", SqlDbType.Int).Value = CveClasificacionDetalle - .Add("@ClasificacionDetalle", SqlDbType.VarChar).Value = ClasificacionDetalle - .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion - .Add("@Estatus", SqlDbType.Bit).Value = Estatus - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar la clasificacion detalle.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - Return Retorno - End Function - - Public Function RemoveClasificacionDetalle(CveClasificacionDetalle As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_ClasificacionesDetalleRemove") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveClasificacionDetalle", SqlDbType.Int).Value = CveClasificacionDetalle - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al eliminar la clasificacion detalle.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - Return Retorno - End Function -#End Region - -#Region "PEDIDOS2" - - Public Function AddVentaDetallePedido2(CveVentaDetalle As Integer, CveVentaDetallePadre As Integer, Cantidad As Double) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasDetallePedidos2Add") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVentaDetalle", SqlDbType.Int).Value = CveVentaDetalle - .Add("@CveVentaDetallePadre", SqlDbType.Int).Value = CveVentaDetallePadre - .Add("@Cantidad", SqlDbType.Float).Value = Cantidad - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al agregar la venta detalle pedido2.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - Return Retorno - End Function - Public Function GetVentaDetallePedido2SinFacturar(FechaI As String, FechaF As String, CveCliente As Integer, CveMoneda As Integer, Tipo As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasDetallePedidos2SinFacturarGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.VarChar).Value = FechaI - .Add("@FechaF", SqlDbType.VarChar).Value = FechaF - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda - .Add("@Tipo", SqlDbType.Float).Value = Tipo - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los pedidos2 sin facturar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - Return Retorno - End Function - - Public Function GetVentasPedidos2Totales(CveCliente As Integer, Ventas As String, Tipo As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasDetallePedidos2Totales") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@Ventas", SqlDbType.VarChar).Value = Ventas - .Add("@Tipo", SqlDbType.Int).Value = Tipo - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los pedidos2 totales.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - Return Retorno - End Function - - Public Function UpdateVentaPedido2(CveVenta As Integer, CveVentaFacturada As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_VentasPedido2Update") - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveVentaFacturada", SqlDbType.Int).Value = CveVentaFacturada - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al vincular la Venta con el Pedido2.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - - Public Function GetRepPedidos2SinFacturar(FechaI As Date, FechaF As Date, FechaV As Date, CveSubProyecto As String, CveCliente As Integer, CveVendedor As String, CveEmpresa As Integer, CveUsuarioConsulta As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("Vta_RepPedidos2Get") - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.Date).Value = FechaI - .Add("@FechaF", SqlDbType.Date).Value = FechaF - .Add("@FechaV", SqlDbType.Date).Value = FechaV - .Add("@CveSubProyecto", SqlDbType.VarChar).Value = CveSubProyecto - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveVendedor", SqlDbType.VarChar).Value = CveVendedor - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los pedidos2 sin facturar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - - Public Function GetRepPedidos2SinFacturarDetalle(FechaI As Date, FechaF As Date, FechaV As Date, CveCliente As Integer, CveVenta As Integer, CveEmpresa As Integer, CveSubProyecto As String, CveVendedor As String, CveUsuarioConsulta As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("Vta_RepPedidos2DetalleGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.Date).Value = FechaI - .Add("@FechaF", SqlDbType.Date).Value = FechaF - .Add("@FechaV", SqlDbType.Date).Value = FechaV - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveSubProyecto", SqlDbType.VarChar).Value = CveSubProyecto - .Add("@CveVendedor", SqlDbType.VarChar).Value = CveVendedor - .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener los pedidos2 sin facturar detalle.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - -#End Region - -#Region "COSTO PROMEDIO VENTA" - - Public Function RepCostoPromedioVenta(FechaI As Date, FechaF As Date, CveCliente As Integer, CveSubProyecto As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_CostoPromedioVentaRep") - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.Date).Value = FechaI - .Add("@FechaF", SqlDbType.Date).Value = FechaF - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el costo promedio de venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - - Public Function RepVentasNetasResumen(FechaI As Date, FechaF As Date, CveCliente As Integer, CveSubProyecto As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentasNetasResumenRep") - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaI", SqlDbType.Date).Value = FechaI - .Add("@FechaF", SqlDbType.Date).Value = FechaF - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el costo promedio de venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - -#End Region - - Public Function RepIngresos(CveEmpresa As Integer, FechaInicio As Date, FechaFin As Date, TipoDocto As String, CveSubProyecto As Integer) As Boolean - Dim retorno As Boolean = False - DataAdapter("PA_Ventas_RepIngresos", CommandType.StoredProcedure) - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio - .Add("@FechaFin", SqlDbType.Date).Value = FechaFin - .Add("@TipoDoc", SqlDbType.VarChar).Value = TipoDocto - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - Try - SqlAdapter.Fill(Data) - retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Reporte de Ingresos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return retorno - End Function - - Public Function RepIngresosDetalle(CveEmpresa As Integer, FechaInicio As Date, FechaFin As Date, TipoDocto As String, CveSubProyecto As Integer, CveConceptoContable As Integer, CveCuenta As Integer) As Boolean - Dim retorno As Boolean = False - DataAdapter("PA_Ventas_RepIngresosDetalle", CommandType.StoredProcedure) - With SqlAdapter.SelectCommand.Parameters - .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio - .Add("@FechaFin", SqlDbType.Date).Value = FechaFin - .Add("@TipoDoc", SqlDbType.VarChar).Value = TipoDocto - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveConceptoContable", SqlDbType.Int).Value = CveConceptoContable - .Add("@CveCuenta", SqlDbType.Int).Value = CveCuenta - End With - Try - SqlAdapter.Fill(Data) - retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el Reporte de Ingresos Detalle.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return retorno - End Function - -#Region " AUTORIZACION DESCUENTOS " - - Public Function AutorizacionDescuentosGet(CveAutorizacionDescuento As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Vta_AutorizacionDescuentosGet", CommandType.StoredProcedure) - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveAutorizacionDescuento", SqlDbType.Int).Value = CveAutorizacionDescuento - .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 Autorizaciones.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - - End Try - - Return Retorno - End Function - - Public Function AutorizacionDescuentosRemove(CveAutorizacionDescuento As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Vta_AutorizacionDescuentosRemove", CommandType.StoredProcedure) - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveAutorizacionDescuento", SqlDbType.Int).Value = CveAutorizacionDescuento - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - - OnError("Ocurrió un error al eliminar la Autorización.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - - End Try - - Return Retorno - End Function - - Public Function AutorizacionDescuentosAdd(CodigoAutorizacion As String, CveCliente As Integer, PorcentajeDescuento As Double, CveUsuario As Integer, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Vta_AutorizacionDescuentosAdd", CommandType.StoredProcedure) - - With SqlAdapter.SelectCommand.Parameters - - .Add("@CodigoAutorizacion", SqlDbType.VarChar).Value = CodigoAutorizacion - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@PorcentajeDescuento", SqlDbType.SmallMoney).Value = PorcentajeDescuento - .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 Autorización.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - - End Try - - Return Retorno - End Function - - Public Function AutorizacionDescuentosUpdate(CveAutorizacionDescuento As Integer, CodigoAutorizacion As String, CveCliente As Integer, PorcentajeDescuento As Double, CveUsuario As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Vta_AutorizacionDescuentosUpdate", CommandType.StoredProcedure) - - With SqlAdapter.SelectCommand.Parameters - - .Add("@CveAutorizacionDescuento", SqlDbType.Int).Value = CveAutorizacionDescuento - .Add("@CodigoAutorizacion", SqlDbType.VarChar).Value = CodigoAutorizacion - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@PorcentajeDescuento", SqlDbType.SmallMoney).Value = PorcentajeDescuento - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - - OnError("Ocurrió un error al actualizar la Autorización.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - - End Try - - Return Retorno - End Function - - Public Function AutorizacionEstatusUpdate(CveAutorizacionDescuento As Integer, CveVenta As Integer) As Boolean - Dim Retorno As Boolean = False - - DataAdapter("PA_Vta_AutorizacionEstatusUpdate", CommandType.StoredProcedure) - - With SqlAdapter.SelectCommand.Parameters - - .Add("@CveAutorizacionDescuento", SqlDbType.Int).Value = CveAutorizacionDescuento - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - - OnError("Ocurrió un error al actualizar el Estatus de la Autorización.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - - End Try - - Return Retorno - End Function -#End Region - -#Region "CANCELACION REMISION" - - Public Function UpdateCancelaRemision(CveVenta As Integer, SeCancelaRemision As Boolean) As Boolean - Dim retorno As Boolean = False - DataAdapter("PA_Vta_CancelaRemisionUpdate", CommandType.StoredProcedure) - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@SeCancelaRemision", SqlDbType.Bit).Value = SeCancelaRemision - End With - Try - SqlAdapter.Fill(Data) - retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar que la remision sea cancelable.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return retorno - End Function - -#End Region - -#Region "REPORTE PUES SIN PAGO" - - Public Function GetPUESinPago(FI As DateTime, FF As DateTime, CveCliente As Integer, CveSubProyecto As Integer, CveVendedor As Integer, CveEmpresa As Integer, Optional CveUsuario As Integer = -1) As Boolean - Dim retorno As Boolean = False - DataAdapter("PA_Vta_PUESinPagoGet", CommandType.StoredProcedure) - With SqlAdapter.SelectCommand.Parameters - .Add("@FI", SqlDbType.DateTime).Value = FI - .Add("@FF", SqlDbType.DateTime).Value = FF - .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario - End With - Try - SqlAdapter.Fill(Data) - retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener las ventas con método de pago PUE.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return retorno - End Function - -#End Region - - Public Function GetAnticiposEspeciales(FI As DateTime, FF As DateTime, CveSubProyecto As Integer, AnticipoEspecial As Integer, CveEmpresa As Integer) As Boolean - Dim retorno As Boolean = False - DataAdapter("PA_Vta_AnticiposEspecialesGet", CommandType.StoredProcedure) - With SqlAdapter.SelectCommand.Parameters - .Add("@FI", SqlDbType.DateTime).Value = FI - .Add("@FF", SqlDbType.DateTime).Value = FF - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@AnticipoEspecial", SqlDbType.Int).Value = AnticipoEspecial - .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 Anticipo Ficticio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return retorno - End Function - Public Function GetRepArqueos(Anio As Integer, CveSubProyecto As Integer, CveEmpresa As Integer) As Boolean - Dim retorno As Boolean = False - Dataset = New DataSet() - DataAdapter("PA_Vta_RepArqueosGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@Anio", SqlDbType.Int).Value = Anio - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - Try - SqlAdapter.Fill(Dataset) - retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el reporte de arqueos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return retorno - 'compila - End Function - Public Function GetRepArqueosDetalle(Fecha As DateTime, CveSubProyecto As Integer, CveEmpresa As Integer) As Boolean - Dim retorno As Boolean = False - Dataset = New DataSet() - DataAdapter("PA_Vta_RepArqueosDetalleGet") - With SqlAdapter.SelectCommand.Parameters - .Add("@Fecha", SqlDbType.DateTime).Value = Fecha - .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With - Try - SqlAdapter.Fill(Dataset) - retorno = True - Catch ex As Exception - OnError("Ocurrió un error al obtener el reporte de arqueos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return retorno - 'compila - End Function -#Region "Conciliación emitidas SAT" - - Public Function ConciliacionemitidasSATGet(cveEmpresa As Int32) As Boolean - Dim retorno As Boolean = False - DataAdapter("PA_Vta_ConciliacionemitidasSATGet", CommandType.StoredProcedure) - 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 reporte de 'Conciliación emitidas SAT'.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - retorno = False - End Try - Return retorno - End Function -#End Region -#Region "IDisposable Support" - - - ' IDisposable - Protected Overridable Sub Dispose(disposing As Boolean) - If Not Me.disposedValue Then - If disposing Then - ' TODO: dispose managed state (managed objects). - If Not Data Is Nothing Then Data.Dispose() - If Not Dataset Is Nothing Then Dataset.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 - - ' TODO: free unmanaged resources (unmanaged objects) and override Finalize() below. - ' TODO: set large fields to null. - End If - Me.disposedValue = True - End Sub - - ' TODO: override Finalize() only if Dispose(disposing As Boolean) above has code to free unmanaged resources. - 'Protected Overrides Sub Finalize() - ' ' Do not change this code. Put cleanup code in Dispose(disposing As Boolean) above. - ' Dispose(False) - ' MyBase.Finalize() - 'End Sub - - ' This code added by Visual Basic to correctly implement the disposable pattern. - Public Sub Dispose() Implements IDisposable.Dispose - ' Do not change this code. Put cleanup code in Dispose(disposing As Boolean) above. - Dispose(True) - GC.SuppressFinalize(Me) - End Sub -#End Region -End Class - +Option Explicit On +Option Strict On + +Imports System.Data +Imports System.Data.SqlClient +Imports Extensiones +Imports System +Imports System.Configuration + +Public Class ClsVentas + Implements IDisposable + +#Region "Campos" + + 'SQL + Private SqlConexion As SqlConnection + Private SqlAdapter As SqlDataAdapter + Private SqlCommand As SqlCommand + Private SqlTransacc As SqlTransaction + Private Data As DataTable + Private Dataset As DataSet + + 'Atributos de la clase + Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + +#End Region + +#Region "Propiedades" + Public ReadOnly Property DtResultados() As DataTable + Get + DtResultados = Data + End Get + End Property + Public ReadOnly Property DataSetResultados() As DataSet + Get + DataSetResultados = Dataset + End Get + End Property + + Public Property CveVenta As Integer + Public Property CveVentaDetalle As Integer + Public ReadOnly Property SerieFolio As String + Public ReadOnly Property Serie As String + Public ReadOnly Property Folio As Integer + + Public Property SerieVenta As String + Public Property SubTotalVenta As Double + Public Property SubTotalVentaDolares As Double + Public Property FechaVenta As String + Public Property Costo As Double + Public Property FolioCosto As String + Public Property FechaSalidaCosto As String + + Public Property Utilidad As Double + Public Property PorUtilidad As Double + Public Property Perdida As Double + Public Property PorPerdida As Double + + Public Property Neto As Double + Public Property PorNeto As Double + Public Property CveClasificacionDetalle As Integer + + + +#End Region + + Public Function IniciaTransacSQL() As SqlTransaction + If SqlTransacc Is Nothing Then SqlTransacc = SqlConexion.BeginTransaction() + Return SqlTransacc + End Function + + Public Sub Commit() + SqlTransacc.Commit() + End Sub + Public Sub RollBack() + SqlTransacc.Rollback() + 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 + + SqlAdapter = New SqlDataAdapter("", SqlConexion) + + End Sub + Private Sub DataAdapter(ByVal pStrSQL As String, Optional ByVal TipoComando As CommandType = CommandType.StoredProcedure) + With SqlAdapter.SelectCommand + .Parameters.Clear() + .CommandText = pStrSQL + .CommandType = TipoComando + End With + If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc + Data = New DataTable + End Sub + Public Function GetVenta(CveVenta As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_VentasGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los datos de la Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function GetVentaTerminal(CveVentaTerminal As Integer, Fecha As DateTime, CveSubProyecto As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_VentasGetTerminal") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVentaTerminal", SqlDbType.Int).Value = CveVentaTerminal + .Add("@Fecha", SqlDbType.DateTime).Value = Fecha + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los datos de la Venta, VentaTerminal.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function GetVentas(CveEmpresa As Integer, TipoDocto As String, Serie As String, Folio As Integer, Codigo As String, CveCliente As Integer, + CveSubProyecto As Integer, CveEstatus As Integer, CveUsuario As Integer, FechaI As String, FechaF As String, FolioFiscal As String, Optional CveClienteSucursal As Integer = -1, Optional CvePS As Integer = -1, Optional PedidoContrato As String = "-1", + Optional OrdenCompra As String = "-1", Optional CveUsuarioConsulta As Integer = -1, Optional ClienteRFC As String = "-1", + Optional CveEmpresaCRM As Integer = -1, Optional CveAcercamientoCRM As Integer = -1) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_VentasGetBuscar") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto + .Add("@Serie", SqlDbType.VarChar).Value = Serie + .Add("@Folio", SqlDbType.Int).Value = Folio + .Add("@Codigo", SqlDbType.VarChar).Value = Codigo + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveEstatus", SqlDbType.Int).Value = CveEstatus + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@FechaI", SqlDbType.VarChar).Value = FechaI + .Add("@FechaF", SqlDbType.VarChar).Value = FechaF + .Add("@FolioFiscal", SqlDbType.VarChar).Value = FolioFiscal + .Add("@CveClienteSucursal", SqlDbType.Int).Value = CveClienteSucursal + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@PedidoContrato", SqlDbType.VarChar).Value = PedidoContrato + .Add("@OrdenCompra", SqlDbType.VarChar).Value = OrdenCompra + .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta + .Add("@ClienteRFC", SqlDbType.VarChar).Value = ClienteRFC + .Add("@CveEmpresaCRM", SqlDbType.Int).Value = CveEmpresaCRM + .Add("@CveAcercamientoCRM", SqlDbType.Int).Value = CveAcercamientoCRM + 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 GetVentaComplementos() As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_ComplementosGet") + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los complementos", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function GetVentaOtrosConceptos(CveEmpresa As Integer, Optional CveVenta As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasConceptosGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los conceptos", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function GetVentaImpuestosLocales(CveVenta As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasImpuestosLocalesGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los datos de la Deduccion de la Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function AddVentaImpuestoLocales(CveVenta As Integer, CveVentaDeduccion As Integer, Importe As Double) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasImpuestosLocalesAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveVentaDeduccion", SqlDbType.Int).Value = CveVentaDeduccion + .Add("@Importe", SqlDbType.Money).Value = Importe + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar impuestos locales al documento.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function UpdateVentaImpuestoLocales(CveVenta As Integer, CveVentaDeduccion As Integer, Importe As Double) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasImpuestosLocalesUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveVentaDeduccion", SqlDbType.Int).Value = CveVentaDeduccion + .Add("@Importe", SqlDbType.Money).Value = Importe + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar impuestos locales.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function AddVenta(TipoDocto As String, FolioFact As Integer, CveCliente As Integer, CveClienteSucursal As Integer, SubTotal As Double, Descuento As Double, Amortizacion As Double, IVA As Double, RetIVA As Double, RetISR As Double, Total As Double, + CveMoneda As Integer, TipoCambio As Double, CveMetodoPago As Integer, CondicionesPago As Integer, FormaPago As Integer, FechaVencimiento As DateTime, Fecha As DateTime, MotivoDescuento As String, Observaciones As String, FechaEjecucion As Date, + CveVendedor As Integer, Alfa1 As String, Alfa2 As String, Alfa3 As String, Num1 As Double, Num2 As Double, Num3 As Double, + Fech1 As Date, Fech2 As Date, Fech3 As Date, CveCorte As Integer, CveMesa As Integer, NumeroPersonas As Integer, CvePrePoliza As Integer, CveUsuario As Integer, CveEmpresa As Integer, + Optional Propina As Double = -1, Optional CveVentaTerminal As Integer = -1, Optional AtencionA As String = "-1", Optional CveContrato As Integer = -1, + Optional CveVentaPadre As Integer = -1, Optional Det_OrdenCompra As String = "", Optional Det_FechaOrdenCompra As String = "", Optional otros As Decimal = 0, + Optional Entrega As String = "-1", Optional Vigencia As DateTime = MinFecha, Optional CveAlmacenTraspasoDestino As Integer = -1, Optional CveAlmacenTraspasoOrigen As Integer = -1, Optional CveDireccionEnvio As Integer = -1, + Optional CveOC As Integer = -1, Optional IEPS As Double = 0, Optional Serie As String = "-1", Optional TelefonoGenerico As String = "", Optional CveCondicionEntrega As Integer = -1, Optional PedidoContrato As String = "-1", + Optional ObservacionesAlmacen As String = "", Optional CveSubProyecto As Integer = -1, Optional CveSubProyectoEjecucion As Integer = -1, Optional CveSubProyectoCobranza As Integer = -1, + Optional CveFormaPago33 As Integer = -1, Optional CveMetodoPago33 As Integer = -1, Optional CveUsoCFDI As Integer = -1, Optional OrdenCompra As String = "-1", Optional CveCuentaTerminal As Integer = -1, Optional CveTipoRelacion As Integer = -1, Optional ImpuestoLocal As Double = 0, + Optional CveTipoAmortizacionAnticipo As Integer = -1, Optional CveVentaRelacion As Integer = -1, Optional ImporteRelacion As Decimal = -1, Optional CveEmpresaCRM As Integer = -1, Optional EsInterno As Integer = -1, Optional CveAcercamientoCRM As Integer = -1, + Optional DiasCredito As Integer = 0, Optional EsDiasCreditoFijo As Boolean = False, Optional AnticipoEspecial As Boolean = False) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_VentasAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto + .Add("@FolioFact", SqlDbType.Int).Value = FolioFact + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveClienteSucursal", SqlDbType.Int).Value = CveClienteSucursal + .Add("@SubTotal", SqlDbType.Float).Value = SubTotal + .Add("@Descuento", SqlDbType.Float).Value = Descuento + .Add("@Amortizacion", SqlDbType.Float).Value = Amortizacion + .Add("@IVA", SqlDbType.Float).Value = IVA + .Add("@IEPS", SqlDbType.Float).Value = IEPS + .Add("@RetIVA", SqlDbType.Float).Value = RetIVA + .Add("@RetISR", SqlDbType.Float).Value = RetISR + .Add("@ImpuestoLocal", SqlDbType.Float).Value = ImpuestoLocal + .Add("@Total", SqlDbType.Float).Value = Total + .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda + .Add("@TipoCambio", SqlDbType.Float).Value = TipoCambio + .Add("@CveMetodoPago", SqlDbType.Int).Value = CveMetodoPago + .Add("@CondicionesPago", SqlDbType.Int).Value = CondicionesPago + .Add("@FormaPago", SqlDbType.Int).Value = FormaPago + .Add("@FechaVencimiento", SqlDbType.DateTime).Value = FechaVencimiento + .Add("@Fecha", SqlDbType.DateTime).Value = Fecha + .Add("@MotivoDescuento", SqlDbType.VarChar).Value = MotivoDescuento + .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones + .Add("@FechaEjecucion", SqlDbType.Date).Value = FechaEjecucion + .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor + .Add("@Alfa1", SqlDbType.VarChar).Value = Alfa1 + .Add("@Alfa2", SqlDbType.VarChar).Value = Alfa2 + .Add("@Alfa3", SqlDbType.VarChar).Value = Alfa3 + .Add("@Num1", SqlDbType.Int).Value = Num1 + .Add("@Num2", SqlDbType.Int).Value = Num2 + .Add("@Num3", SqlDbType.Int).Value = Num3 + .Add("@Fech1", SqlDbType.VarChar).Value = IIf(Fech1.ToString.Contiene("1/1/0001 12:00:00 a. m.", "01/01/0001 12:00:00 a. m."), "-1", Fech1.ToString("yyyy/MM/dd")) + .Add("@Fech2", SqlDbType.VarChar).Value = IIf(Fech2.ToString.Contiene("1/1/0001 12:00:00 a. m.", "01/01/0001 12:00:00 a. m."), "-1", Fech2.ToString("yyyy/MM/dd")) + .Add("@Fech3", SqlDbType.VarChar).Value = IIf(Fech3.ToString.Contiene("1/1/0001 12:00:00 a. m.", "01/01/0001 12:00:00 a. m."), "-1", Fech3.ToString("yyyy/MM/dd")) + .Add("@CveCorte", SqlDbType.Int).Value = CveCorte + .Add("@CveMesa", SqlDbType.Int).Value = CveMesa + .Add("@NumeroPersonas", SqlDbType.Int).Value = NumeroPersonas + .Add("@Propina", SqlDbType.Float).Value = Propina + .Add("@CveVentaTerminal", SqlDbType.Int).Value = CveVentaTerminal + .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza + .Add("@AtencionA", SqlDbType.VarChar).Value = AtencionA + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveContrato", SqlDbType.Int).Value = CveContrato + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveVentaPadre", SqlDbType.Int).Value = CveVentaPadre + .Add("@Det_OrdenCompra", SqlDbType.VarChar).Value = Det_OrdenCompra + .Add("@Det_FechaOrdenCompra", SqlDbType.VarChar).Value = Det_FechaOrdenCompra + .Add("@Otros", SqlDbType.Money).Value = otros + '.Add("@Ref", SqlDbType.VarChar).Value = Ref + .Add("@Entrega", SqlDbType.VarChar).Value = Entrega + .Add("@Vigencia", SqlDbType.Date).Value = Vigencia + .Add("@CveAlmacenTraspasoDestino", SqlDbType.Int).Value = CveAlmacenTraspasoDestino + .Add("@CveAlmacenTraspasoOrigen", SqlDbType.Int).Value = CveAlmacenTraspasoOrigen + .Add("@CveDireccionEnvio", SqlDbType.Int).Value = CveDireccionEnvio + .Add("@CveOC", SqlDbType.Int).Value = CveOC + .Add("@Serie", SqlDbType.VarChar).Value = Serie + .Add("@TelefonoGenerico", SqlDbType.VarChar).Value = TelefonoGenerico + .Add("@CveCondicionEntrega", SqlDbType.Int).Value = CveCondicionEntrega + .Add("@PedidoContrato", SqlDbType.VarChar).Value = PedidoContrato + .Add("@ObservacionesAlmacen", SqlDbType.VarChar).Value = ObservacionesAlmacen + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveSubProyectoEjecucion", SqlDbType.Int).Value = CveSubProyectoEjecucion + .Add("@CveSubProyectoCobranza", SqlDbType.Int).Value = CveSubProyectoCobranza + .Add("@CveFormaPago33", SqlDbType.SmallInt).Value = CveFormaPago33 + .Add("@CveMetodoPago33", SqlDbType.SmallInt).Value = CveMetodoPago33 + .Add("@CveUsoCFDI", SqlDbType.SmallInt).Value = CveUsoCFDI + .Add("@OrdenCompra", SqlDbType.VarChar).Value = OrdenCompra + .Add("@CveCuentaTerminal", SqlDbType.VarChar).Value = CveCuentaTerminal + .Add("@CveTipoRelacion", SqlDbType.Int).Value = CveTipoRelacion + + .Add("@CveTipoAmortizacionAnticipo", SqlDbType.Int).Value = CveTipoAmortizacionAnticipo + .Add("@CveVentaRelacion", SqlDbType.Int).Value = CveVentaRelacion + .Add("@ImporteRelacion", SqlDbType.Money).Value = ImporteRelacion + + .Add("@CveEmpresaCRM", SqlDbType.Int).Value = CveEmpresaCRM + .Add("@CveAcercamientoCRM", SqlDbType.Int).Value = CveAcercamientoCRM + .Add("@EsInterno", SqlDbType.Int).Value = EsInterno + + .Add("@DiasCredito", SqlDbType.Int).Value = DiasCredito + .Add("@EsDiasCreditoFijo", SqlDbType.Bit).Value = EsDiasCreditoFijo + .Add("@AnticipoEspecial", SqlDbType.Bit).Value = AnticipoEspecial + + .Add("@RETURN_VALUE", SqlDbType.Int).Direction = ParameterDirection.ReturnValue + End With + 'SqlTypes.SqlDateTime.Null + Try + SqlAdapter.Fill(Data) + CveVenta = SqlAdapter.SelectCommand.Parameters("@RETURN_VALUE").Value.ToString.ToEntero + If Data.Rows.Count > 0 Then _SerieFolio = Data.Rows(0)("vFolio").ToString : _Serie = Data.Rows(0)("Serie").ToString : _Folio = Data.Rows(0)("Folio").ToString.ToEntero + + Retorno = True + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 2627;") And Ex1.Message.Contains("UK_Ventas_TipoDocto_Serie_Folio_CveSubProyecto") Then + Alert(String.Format("el Folio '{0}' ya se encuentra registrado", FolioFact), TipoMensaje.MsgAdvertencia) + GuardaLog(String.Format("el folio ya se encuentra registrado {0}", Ex1.Message)) + Else + Me.OnError("Ocurrió un error al Guardar la Venta.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + OnError("Ocurrió un error al Guardar la Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function UpdateVentas(SubTotal As Double, Descuento As Double, IVA As Double, IEPS As Double, Total As Double, CveMoneda As Integer, TipoCambio As Double, + Fecha As Date, Observaciones As String, CveEmpresa As Integer, CveVenta As Integer, CveMetodoPago As Integer, FormaPago As Integer, + Optional TipoDocto As String = "Cot", Optional Vigencia As Date = MinFecha, Optional CondicionesPago As Integer = -1, + Optional AtencionA As String = "-1", Optional PedidoContrato As String = "-1", Optional CveFormaPago33 As Integer = -1, Optional CveMetodoPago33 As Integer = -1, + Optional CveCliente As Integer = -1, Optional CveClienteSucursal As Integer = -1, Optional OrdenCompra As String = "-1", Optional RetIVA As Double = -1, Optional RetISR As Double = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@SubTotal", SqlDbType.Float).Value = SubTotal + .Add("@Descuento", SqlDbType.Float).Value = Descuento + .Add("@IVA", SqlDbType.Float).Value = IVA + .Add("@IEPS", SqlDbType.Float).Value = IEPS + .Add("@Total", SqlDbType.Float).Value = Total + .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda + .Add("@TipoCambio", SqlDbType.Float).Value = TipoCambio + .Add("@RetIVA", SqlDbType.Float).Value = RetIVA + .Add("@RetISR", SqlDbType.Float).Value = RetISR + .Add("@Fecha", SqlDbType.Date).Value = Fecha + .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto + .Add("@CveMetodoPago", SqlDbType.Int).Value = CveMetodoPago + .Add("@CondicionesPago", SqlDbType.Int).Value = CondicionesPago + .Add("@FormaPago", SqlDbType.Int).Value = FormaPago + .Add("@AtencionA", SqlDbType.VarChar).Value = AtencionA + .Add("@Vigencia", SqlDbType.Date).Value = Vigencia + .Add("@PedidoContrato", SqlDbType.VarChar).Value = PedidoContrato + .Add("@CveFormaPago33", SqlDbType.SmallInt).Value = CveFormaPago33 + .Add("@CveMetodoPago33", SqlDbType.SmallInt).Value = CveMetodoPago33 + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveClienteSucursal", SqlDbType.Int).Value = CveClienteSucursal + .Add("@OrdenCompra", SqlDbType.VarChar).Value = OrdenCompra + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar el documento.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function UpdateFechaVencimientoVenta(CveVenta As Integer, FechaVencimiento As Date) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasFechaVencimientoUpdate") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@FechaVencimiento", SqlDbType.Date).Value = FechaVencimiento + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar la fecha de vencimiento de la venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + Public Function AddVta_VentaPago(CveVenta As Integer, CveMetodoPago As Integer, Importe As Double) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasPagoAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveMetodoPago", SqlDbType.Int).Value = CveMetodoPago + .Add("@Importe", SqlDbType.Float).Value = Importe + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar el Pago de la Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function RemoveVta_VentaPago(CveVenta As Integer, CveMetodoPago As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasPagoRemove") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveMetodoPago", SqlDbType.Int).Value = CveMetodoPago + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al Eliminar el Pago a la Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function EliminarVenta(CveVenta As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_EliminarVenta") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al intentar eliminar la venta. Verifique que el registro no tenga relaciones (Movimientos de almacén, Factura, Anticipos...)", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function UpdateVentaPrePoliza(IDPoliza As Integer, CvePrePoliza As Integer, CveVenta As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentaPrePolizaUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@IDPoliza", SqlDbType.Int).Value = IDPoliza + .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al guardar la poliza de la venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function AddLeyendaFiscal(CveVenta As Integer, CveLeyenda As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_VentasLeyendasFiscalesAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveLeyendaFiscal", SqlDbType.Int).Value = CveLeyenda + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al Guardar la Leyenda Fiscal en la Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function UpdateEstatusFactura(Estatus As Integer, FolioFiscal As String, SelloSAT As String, FechaCancelacion As DateTime, CveVenta As Integer, + Optional IdPolizaCancelacion As Integer = -1, Optional CvePAC As Integer = -1, Optional CveEstatusRefacturacion As Integer = 0, + Optional CveUsuarioCambiaEstatus As Integer = -1, Optional FechaCambioEstatus As String = "-1") As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_VentasUpdateEstatus") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEstatusFactura", SqlDbType.Int).Value = Estatus + .Add("@FolioFiscal", SqlDbType.VarChar).Value = FolioFiscal + .Add("@SelloDigitalSAT", SqlDbType.VarChar).Value = SelloSAT + .Add("@FechaCancelacion", SqlDbType.DateTime).Value = FechaCancelacion + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@IdPolizaCancelacion", SqlDbType.Int).Value = IdPolizaCancelacion + .Add("@CvePAC", SqlDbType.SmallInt).Value = CvePAC + .Add("@CveEstatusRefacturacion", SqlDbType.TinyInt).Value = CveEstatusRefacturacion + .Add("@CveUsuarioCambiaEstatus", SqlDbType.Int).Value = CveUsuarioCambiaEstatus + .Add("@FechaCambioEstatus", SqlDbType.VarChar).Value = FechaCambioEstatus + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar el estatus de la factura.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function UpdateEstatusRefacturacion(CveVenta As Integer, CveEstatusRefacturacion As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_VentasEstatusRefacturacionUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveEstatusRefacturacion", SqlDbType.TinyInt).Value = CveEstatusRefacturacion + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar el estatus de refacturación.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function UpdateEstatusVenta(CveVenta As Integer, CveEstatusFactura As Integer, CveEmpresa As Integer, Optional Num2 As Integer = -1) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_VentasEstatusUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveEstatusFactura", SqlDbType.Int).Value = CveEstatusFactura + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@Num2", SqlDbType.Float).Value = Num2 + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al Guardar el estatus de la Factura.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function UpdateCancelaVenta(CveVenta As Integer, FechaCancelacion As DateTime, SelloCancelacionSAT As String, CveEmpresa As Integer, Optional CvePAC As Integer = -1) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_VentasCancelacion") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@FechaCancelacion", SqlDbType.DateTime).Value = FechaCancelacion + .Add("@SelloDigitalSAT", SqlDbType.VarChar).Value = SelloCancelacionSAT + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CvePAC", SqlDbType.SmallInt).Value = CvePAC + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al Guardar el estatus de cancelacion Factura.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function UpdateVentaMail(Tipo As Integer, CveVenta As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_VentasUpdateMail") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Tipo", SqlDbType.Int).Value = Tipo + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al Guardar el estatus del Mail.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function UpdateVentaTimbre(Timbro As Boolean, CveVenta As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_VentasUpdateTimbre") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Timbre", SqlDbType.Bit).Value = If(Timbro, 1, 0) + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al Guardar el estatus del Timbrado.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + + Return Retorno + End Function + Public Function UpdateVentaFolioFiscal(FolioFiscal As String, CveVenta As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasUpdateFolioFiscal") + + With SqlAdapter.SelectCommand.Parameters + .Add("@FolioFiscal", SqlDbType.VarChar).Value = FolioFiscal + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al Guardar el folio fiscal.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function UpdateVentaCotizacion(CveVenta As Integer, CveCotizacion As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_VentasUpdateCotizacion") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveCotizacion", SqlDbType.Int).Value = CveCotizacion + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al vincular la Venta con la Cotización.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function ObtenerCreditoRestante(CveCliente As Integer, CveSucCliente As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_ClientesLimiteCreditoGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveSucCliente", SqlDbType.Int).Value = CveSucCliente + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el limite de credito.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function ObtenerCreditoRestanteSucursalCliente(CveSucCliente As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_SucClientesLimiteCreditoGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveSucCliente", SqlDbType.Int).Value = CveSucCliente + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el limite de credito.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function ObtenerClienteLimitesVenta(CveCliente As Integer, CveEmpresa As Integer) As Integer + Dim Retorno As Integer = 0 + DataAdapter("PA_Vta_ClientesLimitesVentaGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@Opcion", SqlDbType.Int).Direction = ParameterDirection.Output + .Add("@OpcionMsg", SqlDbType.VarChar, 100).Direction = ParameterDirection.Output + End With + + Try + SqlAdapter.Fill(Data) + SerieVenta = SqlAdapter.SelectCommand.Parameters("@OpcionMsg").Value.ToString + Retorno = SqlAdapter.SelectCommand.Parameters("@Opcion").Value.ToString.ToEntero + + Catch ex As Exception + OnError("Ocurrió un error al obtener el limite de venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function AgregarVentaOCDetalle(CveVentaDetalle As Integer, CveOCDetalle As Integer, Cantidad As Decimal) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_AddVentaOCDetalle") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVentaDetalle", SqlDbType.Int).Value = CveVentaDetalle + .Add("@CveOCDetalle", SqlDbType.Int).Value = CveOCDetalle + .Add("@Cantidad", SqlDbType.Int).Value = Cantidad + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar el detalle de la OC.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function AgregarRemisionDetalle(CveVentaDetalle As Integer, CveVentaDetallePadre As Integer, Cantidad As Decimal) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_AddRemisionDetalle") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVentaDetalle", SqlDbType.Int).Value = CveVentaDetalle + .Add("@CveVentaDetallePadre", SqlDbType.Int).Value = CveVentaDetallePadre + .Add("@Cantidad", SqlDbType.Float).Value = Cantidad + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar el detalle de la Remisión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function VerificarRemisionFacturada(CveVenta As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VerificarRemisionFacturada") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al verificar la remision.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function LiberarRemisionesFacturadas(CveVenta As Integer, Optional CveVentaLiberar As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_LiberarRemisionesFacturadas") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveVentaLiberar", SqlDbType.Int).Value = CveVentaLiberar + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al liberar las remisiones.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function AddRemisionesXCancelar(CveVenta As Integer, CveVentaRemision As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_RemisionesXCancelarAdd") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveVentaRemision", SqlDbType.Int).Value = CveVentaRemision + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar las remisiones x cancelar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + Public Function LiberarCotizacionesFacturadas(CveVenta As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_LiberarCotizacionesFacturadas") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al liberar las cotizaciones.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function LiberarPedidos2Facturados(CveVenta As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_LiberarPedidos2Facturados") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al liberar los pedidos2.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function LiberarOCFacturadas(CveVenta As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_LiberarOCFacturadas") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al liberar las Ordenes de Compra.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function UpdateVentaRemision(CveVenta As Integer, CveVentaFacturada As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_VentasRemisionUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveVentaFacturada", SqlDbType.Int).Value = CveVentaFacturada + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al vincular la Venta con la Remision.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function MarcarRemisionesSinSurtir(CveVenta As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_MarcarRemisionSinSurtir") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al marcar la venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function UpdateVentaCadenaOriginal(CadenaOriginal As String, CveVenta As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_VentasCadenaOriginalAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CadenaOriginal", SqlDbType.VarChar).Value = CadenaOriginal + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al Guardar la Cadena Original.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function UpdateVentaCuentaTerminal(CveCuentaTerminal As Integer, CveVenta As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasCuentaTerminalUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCuentaTerminal", SqlDbType.Int).Value = CveCuentaTerminal + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al Guardar la cuenta terminal.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function GetCadenaOriginal(CveVenta As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_VentasCadenaOriginalGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al Obtener la Cadena Original.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + +#Region "V E N T A - D E T A L L E" + Public Function GetVentaDetalle(CveVenta As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_VentasDetalleGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el detalle de la Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function AddVentaDetalle(CveVenta As Integer, CvePS As Integer, Cantidad As Double, CveUnidadMedida As Integer, PU As Double, IVA As Double, + Total As Double, Observaciones As String, Descuento As Double, TipoDescuento As Integer, CveSubProyecto As Integer, + CvePresupuestoIngreso As Integer, Optional TiempoEntrega As String = "", Optional CveVentaDetallePadre As Integer = -1, + Optional CveContratoDetalle As Integer = -1, Optional PorcentajeIVA As Decimal = 0, Optional IEPS As Double = -1, Optional PorcentajeIEPS As Double = 0, Optional CvePromocionDetalle As Integer = -1, + Optional CveMovimientoDetallePedido As Integer = -1, Optional ImporteRetIVA As Double = 0, Optional PorcentajeRetIVA As Double = 0, + Optional ImporteRetISR As Double = 0, Optional PorcentajeRetISR As Double = 0, Optional CuentaPredial As String = "") As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_VentasDetalleAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@Cantidad", SqlDbType.Float).Value = Cantidad + .Add("@CveUnidadMedida", SqlDbType.Int).Value = CveUnidadMedida + .Add("@PU", SqlDbType.Float).Value = PU + .Add("@IVA", SqlDbType.Float).Value = IVA + .Add("@IEPS", SqlDbType.Float).Value = IEPS + .Add("@ImporteRetIVA", SqlDbType.Float).Value = ImporteRetIVA + .Add("@ImporteRetISR", SqlDbType.Float).Value = ImporteRetISR + .Add("@PorcentajeIVA", SqlDbType.Float).Value = PorcentajeIVA + .Add("@PorcentajeIEPS", SqlDbType.Float).Value = PorcentajeIEPS + .Add("@PorcentajeRetIVA", SqlDbType.Float).Value = PorcentajeRetIVA + .Add("@PorcentajeRetISR", SqlDbType.Float).Value = PorcentajeRetISR + .Add("@Total", SqlDbType.Float).Value = Total + .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones + .Add("@Descuento", SqlDbType.Float).Value = Descuento + .Add("@TipoDescuento", SqlDbType.Int).Value = TipoDescuento + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CvePresupuestoIngreso", SqlDbType.Int).Value = CvePresupuestoIngreso + .Add("@TiempoEntrega", SqlDbType.VarChar).Value = TiempoEntrega + .Add("@CveVentaDetallePadre", SqlDbType.Int).Value = CveVentaDetallePadre + .Add("@CveContratoDetalle", SqlDbType.Int).Value = CveContratoDetalle + .Add("@CvePromocionDetalle", SqlDbType.Int).Value = CvePromocionDetalle + .Add("@CveMovimientoDetallePedido", SqlDbType.Int).Value = CveMovimientoDetallePedido + .Add("@CuentaPredial", SqlDbType.VarChar).Value = CuentaPredial + End With + + Try + SqlAdapter.Fill(Data) + CveVentaDetalle = Data.Rows(0)("CveVentaDetalle").ToString.ToEntero + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar el Producto o Servicio a la Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function AddVentaDetalleCaracteristica(CveVentaDetalle As Integer, CvePS As Integer, CveOpcion As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_VentasDetallesCaracteristicasAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVentaDetalle", SqlDbType.Int).Value = CveVentaDetalle + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CveOpcion", SqlDbType.Int).Value = CveOpcion + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar la Caracteristica del Producto o Servicio a la Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function UpdateVentaDetalleRemision(CveVenta As Integer, CvePS As Integer, Cantidad As Double, PU As Double, IEPS As Double, Observaciones As String, Optional CveUsuarioModifico As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_VentasDetalleRemisionUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVentaDetalle", SqlDbType.Int).Value = CveVenta + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@Cantidad", SqlDbType.Float).Value = Cantidad + .Add("@PU", SqlDbType.Float).Value = PU + .Add("@IEPS", SqlDbType.Float).Value = IEPS + .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones + .Add("@CveUsuarioModifico", SqlDbType.Int).Value = CveUsuarioModifico + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al editar el Producto o Servicio a la Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function UpdateVentasDevolucionAlmacen(EstatusDevolucion As Integer, CveVenta As Integer) As Boolean + + 'NOTA: + ' - 0: No requiere devolucion + ' - 1: Requiere devolucion + ' - 2: Devolucion ya realizada + + + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasDevolucionAlmacenUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@EstatusDevolucion", SqlDbType.TinyInt).Value = EstatusDevolucion + .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 solicitud de Devolución de Almacén.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function RemoveVentasDetalle(CveVenta As Integer, Optional CveVentaDetalle As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasDetalleRemove") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveVentaDetalle", SqlDbType.Int).Value = CveVentaDetalle + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar el documento.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function +#End Region + +#Region "V E N T A - P R E S U P U E S T O" + Public Function GetPresupuestosVentas(CveVenta As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AC_PresupuestosVentasGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + ' .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los datos de la venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function +#End Region + +#Region "R E P O R T E S - D E - V E N T A S" + 'Reporte de Ventas + Public Function GetRepVentas(FechaI As Date, FechaF As Date, FechaIEjec As Date, FechaFEjec As Date, CveCliente As Integer, CveSubProyectoEjecucion As Integer, + CveVendedor As String, CveUsuario As Integer, CveEstatus As String, IVA As String, CveEmpresa As Integer, Gpo As Integer, Optional TipoDocto As String = "-1", + Optional CveProyecto As Integer = -1, Optional CveSubProyecto As String = "-1", Optional TipoCambio As Integer = 1, Optional TCEspecifico As Decimal = -1, Optional CveUsuarioConsulta As Integer = -1, + Optional CveClienteClasificacion As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasGetRep") + + With SqlAdapter.SelectCommand.Parameters + '.Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@FechaIEjec", SqlDbType.Date).Value = FechaIEjec + .Add("@FechaFEjec", SqlDbType.Date).Value = FechaFEjec + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveSubProyectoEjecucion", SqlDbType.Int).Value = CveSubProyectoEjecucion + .Add("@CveVendedor", SqlDbType.VarChar).Value = CveVendedor + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEstatus", SqlDbType.VarChar).Value = CveEstatus + .Add("@IVA", SqlDbType.VarChar).Value = IVA + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@GPO", SqlDbType.Int).Value = Gpo + .Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto + .Add("@CveSubProyecto", SqlDbType.VarChar).Value = CveSubProyecto + .Add("@CveProyecto", SqlDbType.Int).Value = CveProyecto + .Add("@TipoCambio", SqlDbType.Int).Value = TipoCambio + .Add("@TCEspecifico", SqlDbType.Float).Value = TCEspecifico + .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta + .Add("@CveClienteClasificacion", SqlDbType.Int).Value = CveClienteClasificacion + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Reporte de Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function GetRepTopVenta(GPO As Integer, CveEmpresa As Integer, TipoCambio As Integer, TipoCambioEspecifico As Decimal, CveUsuarioConsulta As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_GetTopRepPS") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@GPO", SqlDbType.Int).Value = GPO + .Add("@TipoCambio", SqlDbType.Int).Value = TipoCambio + .Add("@TCEspecifico", SqlDbType.Int).Value = TipoCambioEspecifico + .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los datos del reporte.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function GetRepTopCompras(GPO As Integer, CveEmpresa As Integer, TipoCambio As Integer, TipoCambioEspecifico As Decimal, CveUsuarioConsulta As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Comp_GetTopRepPS") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@GPO", SqlDbType.Int).Value = GPO + .Add("@TipoCambio", SqlDbType.Int).Value = TipoCambio + .Add("@TCEspecifico", SqlDbType.Int).Value = TipoCambioEspecifico + .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los datos del reporte.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + + 'Reporte de Ventas por Período + Public Function GetRepVentasPeriodos(FechaI As Date, FechaF As Date, FechaIEjec As Date, FechaFEjec As Date, CveCliente As Integer, CveSubProyectoEjecucion As Integer, + CveVendedor As Integer, CveUsuario As Integer, CveEstatus As Integer, IVA As String, CveEmpresa As Integer, Gpo As Integer, Optional TipoDocto As String = "-1", + Optional CveProyecto As Integer = -1, Optional CveSubProyecto As Integer = -1, Optional TipoCambio As Integer = 1, Optional TCEspecifico As Decimal = -1, Optional CveUsuarioConsulta As Integer = -1, Optional VerEn As Integer = -1, + Optional CveClienteClasificacion As Integer = -1) As Boolean + + Dim Retorno As Boolean = False + DataAdapter("PA_VentasGetRepPeriodo") + + With SqlAdapter.SelectCommand.Parameters + '.Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@FechaIEjec", SqlDbType.Date).Value = FechaIEjec + .Add("@FechaFEjec", SqlDbType.Date).Value = FechaFEjec + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveSubProyectoEjecucion", SqlDbType.Int).Value = CveSubProyectoEjecucion + .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEstatus", SqlDbType.Int).Value = CveEstatus + .Add("@IVA", SqlDbType.VarChar).Value = IVA + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@GPO", SqlDbType.Int).Value = Gpo + .Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveProyecto", SqlDbType.Int).Value = CveProyecto + .Add("@TipoCambio", SqlDbType.Int).Value = TipoCambio + .Add("@TCEspecifico", SqlDbType.Float).Value = TCEspecifico + .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta + .Add("@VerEn", SqlDbType.Int).Value = VerEn + .Add("@CveClienteClasificacion", SqlDbType.Int).Value = CveClienteClasificacion + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Reporte de Venta por Periodo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + 'Reporte de Ventas - Detalle + Public Function GetRepVentasDetalle(Gpo As Integer, Anio As Integer, Mes As Integer, AnioMes As String, Fecha As String, CveCliente As Integer, IVA As String, + Vendedor As String, CveUsuario As Integer, CveEstatus As String, FechaI As Date, FechaF As Date, CveCorte As Integer, TipoDocto As String, + CveSubProyectoEjecucion As Integer, CveEmpresa As Integer, FechaIEjec As Date, FechaFEjec As Date, Optional CveProyecto As Integer = -1, + Optional CveSubProyecto As String = "-1", Optional TipoCambio As Integer = 1, Optional TCEspecifico As Decimal = -1, Optional CveMoneda As Integer = -1, Optional CveUsuarioConsulta As Integer = -1, + Optional CveClienteClasificacion As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasGetRepDetalle") + + With SqlAdapter.SelectCommand.Parameters + .Add("@GPO", SqlDbType.Int).Value = Gpo + .Add("@Anio", SqlDbType.Int).Value = Anio + .Add("@Mes", SqlDbType.Int).Value = Mes + .Add("@AnioMes", SqlDbType.VarChar).Value = AnioMes + .Add("@Fecha", SqlDbType.VarChar).Value = Fecha + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@IVA", SqlDbType.VarChar).Value = IVA + .Add("@Vendedor", SqlDbType.VarChar).Value = Vendedor + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEstatus", SqlDbType.VarChar).Value = CveEstatus + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@FechaIEjec", SqlDbType.Date).Value = FechaIEjec + .Add("@FechaFEjec", SqlDbType.Date).Value = FechaFEjec + .Add("@CveCorte", SqlDbType.Int).Value = CveCorte + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto + .Add("@CveSubProyectoEjecucion", SqlDbType.Int).Value = CveSubProyectoEjecucion + .Add("@CveSubProyecto", SqlDbType.VarChar).Value = CveSubProyecto + .Add("@CveProyecto", SqlDbType.Int).Value = CveProyecto + .Add("@TipoCambio", SqlDbType.Int).Value = TipoCambio + .Add("@TCEspecifico", SqlDbType.Float).Value = TCEspecifico + .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda + .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta + .Add("@CveClienteClasificacion", SqlDbType.Int).Value = CveClienteClasificacion + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Reporte de Venta Detalle.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + + Return Retorno + End Function + + 'Reporte de Ventas - Productos y Servicios + Public Function GetRepProductosServicios(CveProyecto As Integer, CveSubProyecto As Integer, CveCategoria As Integer, CveClasificacion As Integer, CvePS As Integer, + FechaI As Date, FechaF As Date, FechaIEjec As Date, FechaFEjec As Date, CveCliente As Integer, CveSubProyectoEjecucion As Integer, + CveVendedor As Integer, CveUsuario As Integer, CveEstatus As Integer, IVA As String, CveEmpresa As Integer, Gpo As Integer, + Optional TipoCambio As Integer = -1, Optional TCEspecifico As Double = -1, Optional CveUsuarioConsulta As Integer = -1, + Optional TipoDocto As String = "-1", Optional CveClienteClasificacion As Integer = -1, Optional CveProveedorCompra As Integer = -1, Optional CveMarca As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_GetRepPS") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveProyecto", SqlDbType.Int).Value = CveProyecto + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveCategoria", SqlDbType.Int).Value = CveCategoria + .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@FechaIEjec", SqlDbType.Date).Value = FechaIEjec + .Add("@FechaFEjec", SqlDbType.Date).Value = FechaFEjec + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveSubProyectoEjecucion", SqlDbType.Int).Value = CveSubProyectoEjecucion + .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEstatus", SqlDbType.Int).Value = CveEstatus + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@GPO", SqlDbType.Int).Value = Gpo + .Add("@TipoCambio", SqlDbType.Int).Value = TipoCambio + .Add("@TCEspecifico", SqlDbType.Float).Value = TCEspecifico + .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta + .Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto + .Add("@CveClienteClasificacion", SqlDbType.Int).Value = CveClienteClasificacion + .Add("@CveProveedorCompra", SqlDbType.Int).Value = CveProveedorCompra + .Add("@CveMarca", SqlDbType.Int).Value = CveMarca + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Reporte de Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function GetRepProductosServiciosDetalle(CveProyecto As Integer, CveSubProyecto As Integer, CveCategoria As Integer, CveClasificacion As Integer, CvePS As Integer, + FechaI As Date, FechaF As Date, Mes As Integer, FechaIEjec As Date, FechaFEjec As Date, MesEjec As Integer, CveCliente As Integer, CveSubProyectoEjecucion As Integer, + CveVendedor As Integer, CveUsuario As Integer, CveEstatus As Integer, CveEmpresa As Integer, Optional CveUsuarioConsulta As Integer = -1, + Optional TipoDocto As String = "-1", Optional GPO As Integer = -1, Optional CveMoneda As Integer = -1, Optional TipoCambio As Integer = -1, + Optional TCEspecifico As Double = 0, Optional CveClienteClasificacion As Integer = -1, Optional CveProveedorCompra As Integer = -1, Optional CveMarca As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_GetRepPSDetalle") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveProyecto", SqlDbType.Int).Value = CveProyecto + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveCategoria", SqlDbType.Int).Value = CveCategoria + .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@Mes", SqlDbType.Int).Value = Mes + .Add("@FechaIEjec", SqlDbType.Date).Value = FechaIEjec + .Add("@FechaFEjec", SqlDbType.Date).Value = FechaFEjec + .Add("@MesEjec", SqlDbType.Int).Value = MesEjec + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveSubProyectoEjecucion", SqlDbType.Int).Value = CveSubProyectoEjecucion + .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEstatus", SqlDbType.Int).Value = CveEstatus + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta + .Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto + .Add("@GPO", SqlDbType.Int).Value = GPO + .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda + .Add("@TipoCambio", SqlDbType.Int).Value = TipoCambio + .Add("@TCEspecifico", SqlDbType.Float).Value = TCEspecifico + .Add("@CveClienteClasificacion", SqlDbType.Int).Value = CveClienteClasificacion + .Add("@CveProveedorCompra", SqlDbType.Int).Value = CveProveedorCompra + .Add("@CveMarca", SqlDbType.Int).Value = CveMarca + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Reporte de Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function GetRepNCxAplicar(CveClienteSucursal As Integer, CveSubProyecto As Integer, CveCliente As Integer, FechaInicio As DateTime, FechaFin As DateTime, ConSaldo As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_NotasCreditosGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveClienteSucursal", SqlDbType.Int).Value = CveClienteSucursal + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio + .Add("@FechaFin", SqlDbType.Date).Value = FechaFin + .Add("@ConSaldo", SqlDbType.Int).Value = ConSaldo + .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 Notas de Crédito por Aplicar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + +#End Region + +#Region "V E N T A S - P R E C I O L I S T A S" 'Hecho por Charlie 1/9/2016 + Public Function GetPrecioListas(Optional CveEmpresa As Integer = -1) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_PrecioListaGet") + + 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 Listas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function AddPrecioLista(CveUsuario As Integer, CveEmpresa As Integer, PrecioLista As String, Porcentaje As Double) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_PrecioListaAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@PrecioLista", SqlDbType.VarChar).Value = PrecioLista + .Add("@Porcentaje", SqlDbType.SmallMoney).Value = Porcentaje + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 2627;") Then + Alert("Ya existe una Lista con el mismo Nombre: " & PrecioLista & ".", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al Guardar la Lista.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + OnError("Ocurrió un error al la Lista", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function UpdatePrecioLista(PrecioLista As String, Estatus As Boolean, CveUsuario As Integer, Porcentaje As Double, CvePrecioLista As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_PrecioListaUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@PrecioLista", SqlDbType.VarChar).Value = PrecioLista + .Add("@Estatus", SqlDbType.Bit).Value = Estatus + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@Porcentaje", SqlDbType.SmallMoney).Value = Porcentaje + .Add("@CvePrecioLista", SqlDbType.Int).Value = CvePrecioLista + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 2627;") Then + Alert("Ya existe una Lista con el mismo nombre: " & PrecioLista & ".", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al guardar los cambios en la Lista", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + OnError("Ocurrió un error al guardar los cambios en la Lista.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function RemovePrecioLista(CvePrecioLista As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_PrecioListaRemove") + + SqlAdapter.SelectCommand.Parameters.Add("@CvePrecioLista", SqlDbType.Int).Value = CvePrecioLista + + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 547;") Then + Alert("La Lista no se pudo eliminar porque está siendo usado por un registro.", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al eliminar la Lista.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + Me.OnError("Ocurrió un error al eliminar la Lista.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +#End Region + +#Region "V E N T A S - M E S A S" + Public Function GetMesas(Optional CveEmpresa As Integer = -1) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_MesasGet") + + 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 Mesas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function AddMesa(Mesa As String, CveUsuario As Integer, CveSubProyecto As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_MesasAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Mesa", SqlDbType.VarChar).Value = Mesa + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .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 Mesa con el mismo nombre: " & Mesa & ".", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al Guardar el Mesa.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + OnError("Ocurrió un error al Guardar el Mesa", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function UpdateMesa(Mesa As String, Estatus As Boolean, CveSubProyecto As Integer, CveMesa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_MesasUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Mesa", SqlDbType.VarChar).Value = Mesa + .Add("@Estatus", SqlDbType.Bit).Value = Estatus + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveMesa", SqlDbType.Int).Value = CveMesa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 2627;") Then + Alert("Ya existe un Mesa con el mismo nombre: " & Mesa & ".", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al guardar los cambios en el Mesa", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + OnError("Ocurrió un error al guardar los cambios en el Mesa.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function RemoveMesa(CveMesa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_MesasRemove") + + SqlAdapter.SelectCommand.Parameters.Add("@CveMesa", SqlDbType.Int).Value = CveMesa + + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 547;") Then + Alert("El Mesa no se pudo eliminar porque está siendo usado por un registro.", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al eliminar el Mesa.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + Me.OnError("Ocurrió un error al eliminar el Mesa.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +#End Region + +#Region "V E N T A S - B I T A C O R A" + Public Function GetVta_Bitacora(CveVenta As Integer, FechaI As String, FechaF As String, CveSubProyecto As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_BitacoraGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@FechaI", SqlDbType.VarChar).Value = FechaI + .Add("@FechaF", SqlDbType.VarChar).Value = FechaF + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .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 la Bitacora de las Ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function AddVta_Bitacora(CveVenta As Integer, Fecha As DateTime, Observacion As String, CveUsuario As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_BitacoraAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@Observacion", SqlDbType.VarChar).Value = Observacion + .Add("@Fecha", SqlDbType.DateTime).Value = Fecha + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al Guardar la Bitacora de la Venta", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + +#End Region + +#Region "R E P O R T E S - D E L - P V " + Public Function GetRepVentasPV(FechaI As String, FechaF As String, FechaIEjec As String, FechaFEjec As String, CveCliente As Integer, CveSubProyecto As Integer, CveSubProyectoEjecucion As Integer, + Vendedor As String, CveUsuario As Integer, CveEstatus As Integer, IVA As String, CveEmpresa As Integer, Gpo As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_PV_VentasGetRep") + + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.VarChar).Value = FechaI + .Add("@FechaF", SqlDbType.VarChar).Value = FechaF + .Add("@FechaIEjec", SqlDbType.VarChar).Value = FechaIEjec + .Add("@FechaFEjec", SqlDbType.VarChar).Value = FechaFEjec + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveSubProyectoEjecucion", SqlDbType.Int).Value = CveSubProyectoEjecucion + .Add("@Vendedor", SqlDbType.VarChar).Value = Vendedor + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEstatus", SqlDbType.Int).Value = CveEstatus + .Add("@IVA", SqlDbType.VarChar).Value = IVA + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@GPO", SqlDbType.Int).Value = Gpo + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Reporte de Venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function +#End Region + + Public Function GetRepABT(Ejercicio As Integer, Periodo As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_VentasGetRepABT") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Ejercicio", SqlDbType.Int).Value = Ejercicio + .Add("@Periodo", SqlDbType.Int).Value = Periodo + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Reporte ABT.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + +#Region " PROMOCIONES " + Public Function GetPromociones(CvePromocion As Integer, Fecha As String, CveVendedor As Integer, CveCliente As Integer, Estatus As Integer, CveEmpresa As Integer, CveSubProyecto As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_PromocionesGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePromocion", SqlDbType.Int).Value = CvePromocion + .Add("@Fecha", SqlDbType.VarChar).Value = Fecha + .Add("@Estatus", SqlDbType.Int).Value = Estatus + .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener las Promociones.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function AddPromociones(Promocion As String, FechaInicio As Date, FechaFin As Date, CveVendedor As Integer, CveCliente As Integer, Estatus As Boolean, CveMoneda As Integer, CveUsuario As Integer, CveEmpresa As Integer, CveSubProyecto As Integer) As Integer + Dim Retorno = -1 + DataAdapter("PA_Vta_PromocionesAdd") + + + With SqlAdapter.SelectCommand.Parameters + .Add("@Promocion", SqlDbType.VarChar).Value = Promocion + .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio + .Add("@FechaFin", SqlDbType.Date).Value = FechaFin + .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@Estatus", SqlDbType.Bit).Value = Estatus + .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CvePromocion", SqlDbType.Int).Direction = ParameterDirection.Output + End With + + Try + SqlAdapter.Fill(Data) + Retorno = SqlAdapter.SelectCommand.Parameters("@CvePromocion").Value.ToString.ToEntero + Catch ex As Exception + OnError("Ocurrió un error al agregar la Promoción.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function UpdatePromociones(Promocion As String, FechaInicio As Date, FechaFin As Date, CveVendedor As Integer, CveCliente As Integer, Estatus As Boolean, CveMoneda As Integer, CveUsuario As Integer, CvePromocion As Integer, CveSubProyecto As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_PromocionesUpdate") + + + With SqlAdapter.SelectCommand.Parameters + .Add("@Promocion", SqlDbType.VarChar).Value = Promocion + .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio + .Add("@FechaFin", SqlDbType.Date).Value = FechaFin + .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@Estatus", SqlDbType.Bit).Value = Estatus + .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CvePromocion", SqlDbType.Float).Value = CvePromocion + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar la Promoción.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function RemovePromociones(CvePromocion As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_PromocionesRemove") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePromocion", SqlDbType.Int).Value = CvePromocion + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al Eliminar la Promoción.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function +#End Region + +#Region " PROMOCIONES DETALLE " + Public Function GetPromocionesPS(CvePS As Integer, Fecha As DateTime, CveSubProyecto As Integer, CveCliente As Integer, CveVendedor As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_PromocionesPSGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@Fecha", SqlDbType.DateTime).Value = Fecha + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los detalles de las promocion.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function GetPromocionesDetalle(CvePromocion As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_PromocionesDetalleGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePromocion", SqlDbType.Int).Value = CvePromocion + .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 detalles de las promocion.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function AddPromocionesDetalle(CvePromocion As Integer, CvePS As Integer, TipoPromocion As Integer, Promocion As Double, PUAnterior As Double, PUPromocion As Double, AplicaRestriccion As Boolean, AplicaLunes As Boolean, AplicaMartes As Boolean, AplicaMiercoles As Boolean, AplicaJueves As Boolean, AplicaViernes As Boolean, AplicaSabado As Boolean, AplicaDomingo As Boolean, HoraInicio As DateTime, HoraFin As DateTime) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_PromocionesDetalleAdd") + + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePromocion", SqlDbType.Int).Value = CvePromocion + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@TipoPromocion", SqlDbType.Int).Value = TipoPromocion + .Add("@Promocion", SqlDbType.Money).Value = Promocion + .Add("@PUAnterior", SqlDbType.Money).Value = PUAnterior + .Add("@PUPromocion", SqlDbType.Money).Value = PUPromocion + .Add("@AplicaRestriccion", SqlDbType.Bit).Value = AplicaRestriccion + .Add("@AplicaLunes", SqlDbType.Bit).Value = AplicaLunes + .Add("@AplicaMartes", SqlDbType.Bit).Value = AplicaMartes + .Add("@AplicaMiercoles", SqlDbType.Bit).Value = AplicaMiercoles + .Add("@AplicaJueves", SqlDbType.Bit).Value = AplicaJueves + .Add("@AplicaViernes", SqlDbType.Bit).Value = AplicaViernes + .Add("@AplicaSabado", SqlDbType.Bit).Value = AplicaSabado + .Add("@AplicaDomingo", SqlDbType.Bit).Value = AplicaDomingo + .Add("@HoraInicio", SqlDbType.DateTime).Value = HoraInicio + .Add("@HoraFin", SqlDbType.DateTime).Value = HoraFin + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar los detalles de la Promoción.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function UpdatePromocionesDetalle(CvePromocionDetalle As Integer, CvePromocion As Integer, CvePS As Integer, TipoPromocion As Integer, Promocion As Double, PUAnterior As Double, PUPromocion As Double, AplicaRestriccion As Boolean, AplicaLunes As Boolean, AplicaMartes As Boolean, AplicaMiercoles As Boolean, AplicaJueves As Boolean, AplicaViernes As Boolean, AplicaSabado As Boolean, AplicaDomingo As Boolean, HoraInicio As DateTime, HoraFin As DateTime) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_PromocionesDetalleUpdate") + + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePromocion", SqlDbType.Int).Value = CvePromocion + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@TipoPromocion", SqlDbType.Int).Value = TipoPromocion + .Add("@Promocion", SqlDbType.Money).Value = Promocion + .Add("@PUAnterior", SqlDbType.Money).Value = PUAnterior + .Add("@PUPromocion", SqlDbType.Money).Value = PUPromocion + .Add("@AplicaRestriccion", SqlDbType.Bit).Value = AplicaRestriccion + .Add("@AplicaLunes", SqlDbType.Bit).Value = AplicaLunes + .Add("@AplicaMartes", SqlDbType.Bit).Value = AplicaMartes + .Add("@AplicaMiercoles", SqlDbType.Bit).Value = AplicaMiercoles + .Add("@AplicaJueves", SqlDbType.Bit).Value = AplicaJueves + .Add("@AplicaViernes", SqlDbType.Bit).Value = AplicaViernes + .Add("@AplicaSabado", SqlDbType.Bit).Value = AplicaSabado + .Add("@AplicaDomingo", SqlDbType.Bit).Value = AplicaDomingo + .Add("@HoraInicio", SqlDbType.DateTime).Value = HoraInicio + .Add("@HoraFin", SqlDbType.DateTime).Value = HoraFin + .Add("@CvePromocionDetalle", SqlDbType.Int).Value = CvePromocionDetalle + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar los detalles de la Promoción.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function RemovePromocionesDetalle(CvePromocionDetalle As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_PromocionesDetalleRemove") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePromocionDetalle", SqlDbType.Int).Value = CvePromocionDetalle + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al Eliminar la Promoción.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function +#End Region + +#Region "Pruebas" + + Public Function GetDeduccion(CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasDeduccionesGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.VarChar).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los datos de las deducciones.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function AddDeduccion(Deduccion As String, Porcentaje As Double, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasDeduccionesAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Deduccion", SqlDbType.VarChar).Value = Deduccion + .Add("@Porcentaje", SqlDbType.VarChar).Value = Porcentaje + .Add("@CveUsuario", SqlDbType.VarChar).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.VarChar).Value = CveEmpresa + + End With + + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error al tratar de agregar la deducción. ", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + + Public Function RemoveDeduccion(CveVentaDeduccion As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasDeduccionesRemove") + + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVentaDeduccion", SqlDbType.Int).Value = CveVentaDeduccion + + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As SqlException + OnError("Ocurrió un error al tratar de eliminar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + + + End Function + Public Function UpdateDeduccion(CvePrincipal As Integer, Deduccion As String, Porcentaje As Double, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasDeduccionesUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePrincipal", SqlDbType.VarChar).Value = CvePrincipal + .Add("@Deduccion", SqlDbType.VarChar).Value = Deduccion + .Add("@Porcentaje", SqlDbType.VarChar).Value = Porcentaje + .Add("@CveUsuario", SqlDbType.VarChar).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.VarChar).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error al tratar de Actualizar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + + + + +#End Region + + Public Function GetPrecios(CveClasificacion As Integer, CvePS As Integer, CveEmpresa As Integer, CveSubProyecto As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_ActualizarPreciosGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los precios de los precios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + +#Region "Firmas" + + Public Function GetVentasFirmas(CveVenta As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasFirmasGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener las firmas de las ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + + Public Function AddVentasFirmas(CveVenta As Integer, Titulo As String, Nombre As String, Puesto As String, Lado As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasFirmasAdd") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@Titulo", SqlDbType.VarChar).Value = Titulo + .Add("@Nombre", SqlDbType.VarChar).Value = Nombre + .Add("@Puesto", SqlDbType.VarChar).Value = Puesto + .Add("@Lado", SqlDbType.Bit).Value = Lado + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar las firmas de las ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + + Public Function UpdateVentasFirmas(CveVentaFirma As Integer, CveVenta As Integer, Titulo As String, Nombre As String, Puesto As String, Lado As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasFirmasUpdate") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVentaFirma", SqlDbType.Int).Value = CveVentaFirma + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@Titulo", SqlDbType.VarChar).Value = Titulo + .Add("@Nombre", SqlDbType.VarChar).Value = Nombre + .Add("@Puesto", SqlDbType.VarChar).Value = Puesto + .Add("@Lado", SqlDbType.VarChar).Value = Lado + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar las firmas de las ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + + Public Function RemoveVentasFirmas(CveVentaFirma As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasFirmasRemove") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVentaFirma", SqlDbType.Int).Value = CveVentaFirma + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar las firmas de las ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + + +#End Region + +#Region " I M P U E S T O S L O C A L E S" + Public Function AddImpuestosLocales(ImpuestoLocal As String, Porcentaje As Double, Orden As Integer, TipoImpuesto As Integer, Estatus As Integer, IdCtaContable As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_ImpuestosLocalesAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@ImpuestoLocal", SqlDbType.VarChar).Value = ImpuestoLocal + .Add("@Porcentaje", SqlDbType.SmallMoney).Value = Porcentaje + .Add("@Orden", SqlDbType.Int).Value = Orden + .Add("@TipoImpuesto", SqlDbType.Int).Value = TipoImpuesto + .Add("@Estatus", SqlDbType.Bit).Value = Estatus + .Add("@IdCtaContable", SqlDbType.Int).Value = IdCtaContable + .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 añadir los impuestos locales.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function GetImpuestosLocales(CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_ImpuestosLocalesGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los impuestos locales.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function UpdateImpuestosLocales(CveImpuestoLocal As Integer, ImpuestoLocal As String, Porcentaje As Double, Orden As Integer, TipoImpuesto As Integer, Estatus As Integer, IdCtaContable As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_ImpuestosLocalesUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveImpuestoLocal", SqlDbType.Int).Value = CveImpuestoLocal + .Add("@ImpuestoLocal", SqlDbType.VarChar).Value = ImpuestoLocal + .Add("@Porcentaje", SqlDbType.SmallMoney).Value = Porcentaje + .Add("@TipoImpuesto", SqlDbType.Int).Value = TipoImpuesto + .Add("@Orden", SqlDbType.Int).Value = Orden + .Add("@Estatus", SqlDbType.Bit).Value = Estatus + .Add("@IdCtaContable", SqlDbType.Int).Value = IdCtaContable + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar los impuestos locales.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function RemoveImpuestosLocales(CveImpuestoLocal As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_ImpuestosLocalesRemove") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveImpuestoLocal", SqlDbType.Int).Value = CveImpuestoLocal + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar los impuestos locales.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + + End Function + + +#End Region + + +#Region " ANTICIPOS/NOTASCREDITO - VENTAS " + Public Function GetVentasAntNC(CveVenta As Integer, CveVentaNC As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasAntNCGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveVentaNC", SqlDbType.Int).Value = CveVentaNC + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener las NotasCrédito/Anticipos de la venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function +#End Region + + Public Function GetRemisionesSinFacturar(FechaI As String, FechaF As String, CveCliente As Integer, CveContrato As Integer, Tipo As Integer, CveMoneda As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_VentasRemisionesFacturasGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.VarChar).Value = FechaI + .Add("@FechaF", SqlDbType.VarChar).Value = FechaF + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveContrato", SqlDbType.Int).Value = CveContrato + .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda + .Add("@Tipo", SqlDbType.Int).Value = Tipo + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener las remisiones sin facturar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function GetOCSinFacturar(FechaI As String, FechaF As String, CveCliente As Integer, Tipo As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_VentasOrdenesCompraGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.VarChar).Value = FechaI + .Add("@FechaF", SqlDbType.VarChar).Value = FechaF + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@Tipo", SqlDbType.Int).Value = Tipo + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener las ordenes de compra sin facturar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function GetRepRemisionesSinFacturar(FechaI As String, FechaF As String, FechaV As String, CveSubProyecto As String, CveCliente As Integer, CveContrato As Integer, CveVendedor As String, CveEmpresa As Integer, Optional CveUsuarioConsulta As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("Vta_RepRemisionesGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.VarChar).Value = FechaI + .Add("@FechaF", SqlDbType.VarChar).Value = FechaF + .Add("@FechaV", SqlDbType.VarChar).Value = FechaV + .Add("@CveSubProyecto", SqlDbType.VarChar).Value = CveSubProyecto + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveContrato", SqlDbType.Int).Value = CveContrato + .Add("@CveVendedor", SqlDbType.VarChar).Value = CveVendedor + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener las remisiones sin facturar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function GetRepRemisionesSinFacturarDetalle(FechaI As String, FechaF As String, FechaV As String, CveCliente As Integer, CveContrato As Integer, CveVenta As Integer, CveEmpresa As Integer, CveSubProyecto As String, Optional CveUsuarioConsulta As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("Vta_RepRemisionesDetalleGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.VarChar).Value = FechaI + .Add("@FechaF", SqlDbType.VarChar).Value = FechaF + .Add("@FechaV", SqlDbType.VarChar).Value = FechaV + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveContrato", SqlDbType.Int).Value = CveContrato + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveSubProyecto", SqlDbType.VarChar).Value = CveSubProyecto + .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener las remisiones sin facturar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function GetReporteHP(CveEmpresa As Integer, FechaInicio As Date, FechaFin As Date) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Compu_HPRep") + + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio + .Add("@FechaFin", SqlDbType.Date).Value = FechaFin + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el reporte.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function GetReporteVentasUtilidad(CveVendedor As String, CveCliente As Integer, CveSubProyecto As String, FechaInicio As Date, FechaFin As Date, CveEmpresa As Integer, CvePS As Integer, CveClasificacion As Double) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasUtilidadGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.Date).Value = FechaInicio + .Add("@FechaF", SqlDbType.Date).Value = FechaFin + .Add("@CveVendedor", SqlDbType.VarChar).Value = CveVendedor + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveSubProyecto", SqlDbType.VarChar).Value = CveSubProyecto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion + End With + + Try + SqlAdapter.Fill(Data) + + If Data.Rows.Count > 0 Then _Neto = Data.Rows(0)("Neto").ToString.ToDouble : _PorNeto = Data.Rows(0)("PorNeto").ToString.ToDouble + + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el reporte de utilidad de ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function GetReporteVentasUtilidadDetalle(CveVendedor As String, CveVenta As Integer, CveCliente As Integer, CveSubProyecto As String, FechaInicio As Date, FechaFin As Date, CveEmpresa As Integer, CvePS As Integer, CveClasificacion As Double) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasUtilidadDetalleGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.Date).Value = FechaInicio + .Add("@FechaF", SqlDbType.Date).Value = FechaFin + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveVendedor", SqlDbType.VarChar).Value = CveVendedor + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveSubProyecto", SqlDbType.VarChar).Value = CveSubProyecto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion + End With + + Try + SqlAdapter.Fill(Data) + If Data.Rows.Count > 1 Then _SerieVenta = Data.Rows(1)("SerieFolio").ToString : _SubTotalVenta = Data.Rows(0)("SubTotal").ToString.ToDouble : _SubTotalVentaDolares = Data.Rows(0)("SubTotalDolares").ToString.ToDouble : _FechaVenta = Data.Rows(1)("FechaVenta").ToString + If Data.Rows.Count > 1 Then _Costo = Data.Rows(0)("CostoVta").ToString.ToDouble : _FolioCosto = Data.Rows(1)("FolioMovto").ToString : _FechaSalidaCosto = Data.Rows(1)("FechaMovto").ToString + + If Data.Rows.Count > 0 Then _Utilidad = Data.Rows(0)("Utilidad").ToString.ToDouble : _PorUtilidad = Data.Rows(0)("PorUtilidad").ToString.ToDouble + If Data.Rows.Count > 0 Then _Perdida = Data.Rows(0)("Perdida").ToString.ToDouble : _PorPerdida = Data.Rows(0)("PorPerdida").ToString.ToDouble + + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el reporte de utilidad de ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function GetReportePadreVentasUtilidad(CveVendedor As String, CveCliente As Integer, CveSubProyecto As String, FechaInicio As Date, FechaFin As Date, CveEmpresa As Integer, Gpo As Integer, CvePS As Integer, CveClasificacion As Double) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_RepVentasUtilidadGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.Date).Value = FechaInicio + .Add("@FechaF", SqlDbType.Date).Value = FechaFin + .Add("@CveVendedor", SqlDbType.VarChar).Value = CveVendedor + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveSubProyecto", SqlDbType.VarChar).Value = CveSubProyecto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@Gpo", SqlDbType.Int).Value = Gpo + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el reporte de utilidad de ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + + Public Function GetReporteVentasAutorizaciones(CveUsuario As Integer, CveEstatusFactura As Integer, CveSubProyecto As Integer, FechaInicio As Date, FechaFin As Date, CveCliente As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_RepVentasAutorizacionesGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEstatusFactura", SqlDbType.Int).Value = CveEstatusFactura + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@FechaI", SqlDbType.Date).Value = FechaInicio + .Add("@FechaF", SqlDbType.Date).Value = FechaFin + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el reporte de Autorizaciones de Ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + +#Region " Facturas " + + Public Function GetFacturas(CveFactura As Integer, Folio As String, FechaFacturaI As Date, FechaFacturaF As Date, RFC As String, Proveedor As String, FueValidado As Integer, CveResponsable As Integer, CveEmpresa As Integer) As Boolean + Dim OnError As Boolean = False + + + DataAdapter("PA_Vta_FacturasGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@Folio", SqlDbType.VarChar).Value = Folio + .Add("@FechaFacturaI", SqlDbType.Date).Value = FechaFacturaI + .Add("@FechaFacturaF", SqlDbType.Date).Value = FechaFacturaF + .Add("@RFC", SqlDbType.VarChar).Value = RFC + .Add("@Proveedor", SqlDbType.VarChar).Value = Proveedor + .Add("@FueValidado", SqlDbType.Int).Value = FueValidado + .Add("@CveResponsable", SqlDbType.Int).Value = CveResponsable + .Add("@CveFactura", SqlDbType.Int).Value = CveFactura + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + OnError = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener las Facturas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return OnError + End Function + Public Function GetFacturasCanceladasPendientes(FoliosFiscales As String, CveEmpresa As Integer) As Boolean + Dim OnError As Boolean = False + DataAdapter("PA_Vta_FacturasCanceladasPendientesGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@FoliosFiscales", SqlDbType.VarChar).Value = FoliosFiscales + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + OnError = True + Catch ex As Exception + Me.OnError("Ocurrió un error al obtener las facturas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return OnError + End Function + + Public Function UpdateVentaFacturas(CveFactura As Integer, CveVenta As Integer, CveEmpresa As Integer) As Boolean + Dim OnError As Boolean = False + + + DataAdapter("PA_Vta_FacturaVentaUpdate") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveFactura", SqlDbType.Int).Value = CveFactura + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + OnError = True + Catch ex As Exception + Me.OnError("Ocurrió un error al actualizar las Facturas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return OnError + End Function + Public Function ProcesoPrepolizasCancelacion(CveVenta As Integer, CveUsuario As Integer) As Boolean + Dim OnError As Boolean = False + + DataAdapter("PA_Vta_ProcesoPrepolizasCancelacion") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + End With + + Try + SqlAdapter.Fill(Data) + OnError = True + Catch ex As Exception + Me.OnError("Ocurrió un error al crear las prepolizas de cancelación.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return OnError + End Function +#End Region + + +#Region "C O N D I C I O N E S D E E N T R E G A" + Public Function GetCondicionesEntrega(CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_CondicionesEntregaGet") + 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 reporte de utilidad de ventas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function +#End Region + +#Region " CANCELAR PEDIDO " + Public Function CancelarPedido(CveVenta As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_CancelarPedido") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al cancelar el pedido.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function +#End Region + +#Region "Punto Venta" + + Public Function AddVtaCortesDetalles(CveCorte As Integer, CveMetodoPago As Integer, Importe As Double) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_CortesDetallesAdd") + + + If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCorte", SqlDbType.Int).Value = CveCorte + .Add("@CveMetodoPago", SqlDbType.Int).Value = CveMetodoPago + .Add("@Importe", SqlDbType.Money).Value = Importe + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As SqlException + OnError("Ocurrió un error al guardar el Detalle del Corte de Turno.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function GetCortesDetalleVentasResumen(CveCorte As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_CortesDetalleVentasResumenGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCorte", SqlDbType.Int).Value = CveCorte + .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 detalle de cortes", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + +#End Region + +#Region " CANCELAR ANTE SAT " + Public Function CancelarVentasSAT(StrVentas As String) As String + Dim CveVentas = StrVentas.Split(","c) + Dim CveVentasError As New List(Of Integer) + + If CveVentas IsNot Nothing Then + Dim ObjVentas As New ClsVentas + Dim ObjCancelacion As New Timbrado + Dim ObjUsuario As New ClsSisUsuarios + Dim Usuario As Usuario = Nothing + Dim ObjEmpresa As New ClsSisEmpresas() + + Dim FolioFiscal = "-1" + Dim CveEstatus = -1 + Dim Total = 0.0D + Dim RFCReceptor = "-1" + Dim Nombre = "-1" + Dim DbRowVenta As DataRow + Dim CveUsuario = -1 + Dim pCveEmpresa = -1 + Dim Contraseña = "-1" + + For Each PCveVenta In CveVentas + If ObjVentas.GetVenta(PCveVenta.ToEntero, -1) Then + DbRowVenta = ObjVentas.DtResultados.Rows(0) + + FolioFiscal = DbRowVenta("FolioFiscal").ToString + CveEstatus = DbRowVenta("CveEstatusFactura").ToString.ToEntero + Total = DbRowVenta("Total").ToString.ToDecimal + RFCReceptor = DbRowVenta("ClienteRFC").ToString + CveUsuario = DbRowVenta("CveUsuario").ToString.ToEntero + pCveEmpresa = DbRowVenta("CveEmpresa").ToString.ToEntero + Nombre = DbRowVenta("Nombre").ToString + + If ObjUsuario.GetUsuarios(CveUsuario, -1, -1) Then + Contraseña = ObjUsuario.DtResultados.Rows(0)("Contraseña").ToString + Else + CveVentasError.Add(PCveVenta.ToEntero) + Continue For + End If + Usuario = ObjUsuario.ValidaUsuario(Nombre, Contraseña, IMEI) + + If ObjEmpresa.GetEmpresas(pCveEmpresa, "-1", "-1", "-1", "-1") Then + Usuario.Empresa = ObjEmpresa.Empresa + Usuario.CveEmpresa = ObjEmpresa.Empresa.CveEmpresa + Else + CveVentasError.Add(PCveVenta.ToEntero) + Continue For + End If + + + 'SOLO SI ESTA CANCELADA ANTE SAT EN SIG SE INTENTARA CANCELAR DE NUEVO CONTRA EL SAT + If CveEstatus = 5 Then + If ObjCancelacion.CFDICancelar(Usuario.Empresa, FolioFiscal, Total, RFCReceptor, Usuario.Empresa.RFC) Then + If Not ObjVentas.UpdateEstatusFactura(5, FolioFiscal, ObjCancelacion.CancelacionAcuse, Now, PCveVenta.ToEntero, -1, CvePAC:=Usuario.Empresa.CvePAC) Then + CveVentasError.Add(PCveVenta.ToEntero) + End If + Else + CveVentasError.Add(PCveVenta.ToEntero) + End If + Else + CveVentasError.Add(PCveVenta.ToEntero) + End If + End If + Next + + ObjVentas.Dispose() + ObjUsuario.Dispose() + ObjEmpresa.Dispose() + Else + + End If + + Return "Procesando" + End Function +#End Region + +#Region "Remisiones" + Public Function GetRemisionesRelacionadas(CveVenta As Integer, TipoDocto As String) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_RemisionesRelacionadasGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el reporte de Remisiones/Facturas Relacionadas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + +#End Region + + Public Function VentasSaldar(CveVenta As Integer, CveUsuario As Integer, CveEmpresa As Integer, Optional Amortizacion As Integer = -1, Optional CveVentaAmortizada As Integer = -1, Optional CveContrato As Integer = -1, Optional Fecha As Date = MinFecha) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasSaldar") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@Amortizacion", SqlDbType.Int).Value = Amortizacion + .Add("@CveVentaAmortizada", SqlDbType.Int).Value = CveVentaAmortizada + .Add("@CveContrato", SqlDbType.Int).Value = CveContrato + .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 saldar una venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + +#Region "COTIZACIONES SIN FACTURAR" + + Public Function GetCotizacionesSinFacturar(FechaI As String, FechaF As String, CveCliente As Integer, Tipo As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_VentasCotizacionesFacturasGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.VarChar).Value = FechaI + .Add("@FechaF", SqlDbType.VarChar).Value = FechaF + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@Tipo", SqlDbType.Int).Value = Tipo + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener las remisiones sin facturar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function GetRepCotizacionesSinFacturar(FechaI As String, FechaF As String, FechaV As String, CveSucursal As Integer, CveCliente As Integer, CveContrato As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("Vta_RepCotizacionesGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.VarChar).Value = FechaI + .Add("@FechaF", SqlDbType.VarChar).Value = FechaF + .Add("@FechaV", SqlDbType.VarChar).Value = FechaV + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSucursal + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveContrato", SqlDbType.Int).Value = CveContrato + .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 remisiones sin facturar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function GetRepCotizacionesSinFacturarDetalle(FechaI As String, FechaF As String, FechaV As String, CveSucursal As Integer, CveCliente As Integer, CveContrato As Integer, CveVenta As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("Vta_RepCotizacionesDetalleGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.VarChar).Value = FechaI + .Add("@FechaF", SqlDbType.VarChar).Value = FechaF + .Add("@FechaV", SqlDbType.VarChar).Value = FechaV + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSucursal + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveContrato", SqlDbType.Int).Value = CveContrato + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .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 remisiones sin facturar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function AgregaCotizacionDetalle(CveVentaDetalle As Integer, CveVentaDetallePadre As Integer, Cantidad As Decimal) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_AddCotizacionDetalle") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVentaDetalle", SqlDbType.Int).Value = CveVentaDetalle + .Add("@CveVentaDetallePadre", SqlDbType.Int).Value = CveVentaDetallePadre + .Add("@Cantidad", SqlDbType.Int).Value = Cantidad + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar el detalle de la Cotización.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + +#End Region + +#Region "C O B R A N Z A V E N T A S" + Public Function UpdateVentaCobranza(CveVenta As Integer, CveCobranzaEstatus As Integer, CveCobranzaEstatusTurno As Integer, FechaCobranza As DateTime, CobranzaObservacion As String) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_VentasCobranzaUpdate") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveCobranzaEstatus", SqlDbType.Int).Value = CveCobranzaEstatus + .Add("@FechaCobranza", SqlDbType.DateTime).Value = FechaCobranza + .Add("@CobranzaObservacion", SqlDbType.VarChar).Value = CobranzaObservacion + .Add("@CveCobranzaEstatusTurno", SqlDbType.Int).Value = CveCobranzaEstatusTurno + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + Me.OnError("Ocurrió un error al intentar Actualizar los datos de la venta.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + Catch ex As Exception + OnError("Ocurrió un error al intentar Actualizar los datos de la venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + Public Function UpdateAsignaVentaCobranza(CveVenta As Integer, CveCobranzaEstatus As Integer, CveUsuarioCobranza As Integer, CveCobranzaEstatusTurno As Integer, CobranzaObservacion As String, FechaCobranza As DateTime) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_AsignaCobranzaUpdate") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveCobranzaEstatus", SqlDbType.Int).Value = CveCobranzaEstatus + .Add("@FechaCobranza", SqlDbType.DateTime).Value = FechaCobranza + .Add("@CveUsuarioCobranza", SqlDbType.Int).Value = CveUsuarioCobranza + .Add("@CobranzaObservacion", SqlDbType.VarChar).Value = CobranzaObservacion + .Add("@CveCobranzaEstatusTurno", SqlDbType.Int).Value = CveCobranzaEstatusTurno + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + Me.OnError("Ocurrió un error al intentar Actualizar los datos de la venta.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + Catch ex As Exception + OnError("Ocurrió un error al intentar Actualizar los datos de la venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + Public Function GetCobranzaEstatus(CveCobranzaEstatus As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_EstatusCobranzaGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCobranzaEstatus", SqlDbType.Int).Value = CveCobranzaEstatus + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex As SqlException + Me.OnError("Ocurrió un error al intentar obtener los estatus de cobranza", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + Public Function GetCobranzaTurnoEstatus(CveCobranzaEstatusTurno As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_EstatusTurnoCobranzaGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCobranzaEstatusTurno", SqlDbType.Int).Value = CveCobranzaEstatusTurno + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex As SqlException + Me.OnError("Ocurrió un error al intentar obtener los estatus de cobranza", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + Public Function GetGestionCobranza(CveCobranzaEstatus As Integer, CveUsuarioCobranza As Integer, CveResponsableCobranza As Integer, CveCobranzaTurno As Integer, TipoPago As String, FechaI As String, FechaF As String, CveEmpresa As Integer, TipoCambio As Integer, TCEspecifico As Double) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_GestionCobranzaGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCobranzaEstatus", SqlDbType.Int).Value = CveCobranzaEstatus + .Add("@CveUsuarioCobranza", SqlDbType.Int).Value = CveUsuarioCobranza + .Add("@CveResponsableCobranza", SqlDbType.Int).Value = CveResponsableCobranza + .Add("@CveCobranzaTurno", SqlDbType.Int).Value = CveCobranzaTurno + .Add("@TipoPago", SqlDbType.VarChar).Value = TipoPago + .Add("@FechaI", SqlDbType.VarChar).Value = FechaI + .Add("@FechaF", SqlDbType.VarChar).Value = FechaF + .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 SqlException + Me.OnError("Ocurrió un error al intentar obtener la gestión de cobranza", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + Public Function AddVisitaCobranza(CveVenta As Integer, CveUsuarioCobranza As Integer, FechaCobranza As Date, Observaciones As String) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_VisitaCobranzaAdd") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveUsuarioCobranza", SqlDbType.Int).Value = CveUsuarioCobranza + .Add("@FechaCobranza", SqlDbType.Date).Value = FechaCobranza + .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex As SqlException + Me.OnError("Ocurrió un error al intentar guardar la visita de cobranza", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function +#End Region + +#Region "C O M P L E M E N T O S" + Public Function UpdateVentasComplementos(CveVenta As Integer, TipoProceso As String, TipoComite As String, IdContabilidad As String) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_UpdateVentaComplementos") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@TipoProceso", SqlDbType.VarChar).Value = TipoProceso + .Add("@TipoComite", SqlDbType.VarChar).Value = TipoComite + .Add("@IdContabilidad", SqlDbType.VarChar).Value = IdContabilidad + + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar los complementos de la venta", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + +#End Region + +#Region " FLETES " + Public Function GetFletes(CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_WT_Viajes") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex As SqlException + Me.OnError("Ocurrió un error al intentar obtener los Fletes", Ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function +#End Region + +#Region "Metodos y Forma de Pago" + + Public Function GetFormaPago() As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_FormaPagoGet") + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As SqlException + OnError("Ocurrió un error al obtener Formas de pago", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function GetMetodoPago() As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_MetodoPagoGet") + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As SqlException + OnError("Ocurrió un error al obtener Métodos de Pago.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + +#End Region + + Public Function GetTiposRelacion() As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_TiposRelacionGet") + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As SqlException + OnError("Ocurrió un error al obtener Tipos de relación.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + +#Region "Tipo Documentos" + + Public Function GetTiposDocumentos() As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_TipoDocumentosGet") + With SqlAdapter.SelectCommand.Parameters + + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los tipos de documentos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + +#End Region + +#Region "DEVOLUCIONES" + Public Function AddVentaDetalleDevolucion(pCveVentaDetalle As Integer, CveVentaDetalleDevolucion As Integer, Cantidad As Double) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasDetalleDevolucionAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVentaDetalle", SqlDbType.Int).Value = pCveVentaDetalle + .Add("@CveVentaDetalleDevolucion", SqlDbType.Int).Value = CveVentaDetalleDevolucion + .Add("@Cantidad", SqlDbType.Float).Value = Cantidad + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar la venta devolucion detalle .", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function RemoveVentaDetalleDevolucion(CveVenta As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasDetalleDevolucionRemove") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar la venta devolucion detalle .", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function +#End Region + +#Region "COMISIONES" + + Public Function GetRepComisiones(FechaI As Date, FechaF As Date, CveSubProyecto As Integer, CveVendedor As Integer, CveCliente As Integer, CveUsuario As Integer, CveEmpresa As Integer, TipoSaldo As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_RepComisiones119") + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@TipoSaldo", SqlDbType.Int).Value = TipoSaldo + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el reporte de comisiones.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + +#End Region + +#Region "REPORTE DE PRODUCTOS SERVICIOS PERIODO" + + + Public Function GetRepPSPeriodo(FechaI As Date, FechaF As Date, FechaIEjec As Date, FechaFEjec As Date, CveCliente As Integer, CveSubProyectoEjecucion As Integer, + CveVendedor As Integer, CveUsuario As Integer, CveEstatus As Integer, IVA As String, CveEmpresa As Integer, Gpo As Integer, Optional TipoDocto As String = "-1", + Optional CveProyecto As Integer = -1, Optional CveSubProyecto As Integer = -1, Optional TipoCambio As Integer = 1, Optional TCEspecifico As Decimal = -1, + Optional CveUsuarioConsulta As Integer = -1, Optional VerEn As Integer = -1, Optional CvePS As Integer = -1, Optional CveClasificacion As Integer = -1, + Optional CveCategoria As Integer = -1, Optional TipoFecha As Integer = 1, Optional CveClienteClasificacion As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_VentasGetRepPeriodoPS") + With SqlAdapter.SelectCommand.Parameters + '.Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@FechaIEjec", SqlDbType.Date).Value = FechaIEjec + .Add("@FechaFEjec", SqlDbType.Date).Value = FechaFEjec + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveSubProyectoEjecucion", SqlDbType.Int).Value = CveSubProyectoEjecucion + .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEstatus", SqlDbType.Int).Value = CveEstatus + .Add("@IVA", SqlDbType.VarChar).Value = IVA + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@GPO", SqlDbType.Int).Value = Gpo + .Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveProyecto", SqlDbType.Int).Value = CveProyecto + .Add("@TipoCambio", SqlDbType.Int).Value = TipoCambio + .Add("@TCEspecifico", SqlDbType.Float).Value = TCEspecifico + .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta + .Add("@VerEn", SqlDbType.Int).Value = VerEn + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion + .Add("@CveCategoria", SqlDbType.Int).Value = CveCategoria + .Add("@TipoFecha", SqlDbType.Int).Value = TipoFecha + .Add("@CveClienteClasificacion", SqlDbType.Int).Value = CveClienteClasificacion + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Reporte de Productos Servicios por Periodo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + +#End Region + +#Region "Ventas Refacturas" + Public Function GetVentaRefacturacion(CveVenta As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentaRefacturacionGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener datos de la venta refacturada .", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function +#End Region + +#Region "REPORTE DE ANTICIPOS - NC - IXC" + + Public Function GetRepAnticiposNCIXC(CveCliente As Integer, CveSubProyecto As Integer, FechaI As Date, FechaF As Date, CveEmpresa As Integer, FechaICorte As Date, FechaFCorte As Date, TipoCambio As Integer, TCEspecifico As Double, Optional CveVendedor As Integer = -1, Optional ConSaldo As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_RepAnt-NC-IXC") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@FechaICorte", SqlDbType.Date).Value = FechaICorte + .Add("@FechaFCorte", SqlDbType.Date).Value = FechaFCorte + .Add("@TipoCambio", SqlDbType.Int).Value = TipoCambio + .Add("@TCEspecifico", SqlDbType.Float).Value = TCEspecifico + .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor + .Add("@ConSaldo", SqlDbType.Int).Value = ConSaldo + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el reporte de anticipos - nc - ixc .", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + + Public Function GetRepAnticiposNCIXCDetalle(CveCliente As Integer, CveSubProyecto As Integer, FechaI As Date, FechaF As Date, CveEmpresa As Integer, ConSaldo As Integer, Tipo As Integer, CveMoneda As Integer, FechaICorte As Date, FechaFCorte As Date, TipoCambio As Integer, TCEspecifico As Double, Optional CveVendedor As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_RepAnt-NC-IXCDetalle") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@ConSaldo", SqlDbType.Int).Value = ConSaldo + .Add("@Tipo", SqlDbType.Int).Value = Tipo + .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda + .Add("@FechaICorte", SqlDbType.Date).Value = FechaICorte + .Add("@FechaFCorte", SqlDbType.Date).Value = FechaFCorte + .Add("@TipoCambio", SqlDbType.Int).Value = TipoCambio + .Add("@TCEspecifico", SqlDbType.Float).Value = TCEspecifico + .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el reporte de anticipos - nc - ixc detalle .", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + +#End Region + +#Region "BUSCAR OC REGISTRADAS" + Public Function GetOCVentas(CveCliente As Integer, OC As String) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_GetOCVentas") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@OC", SqlDbType.VarChar).Value = OC + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el reporte de Ordenes de compra.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function +#End Region + +#Region "CLASIFICACIONES DETALLE" + Public Function GetClasificacionDetalle(CveEmpresa As Integer, Optional CveClasificacionDetalle As Integer = -1, Optional Estatus As Integer = -1, Optional CveClasificacion As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_ClasificacionesDetalleGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveClasificacionDetalle", SqlDbType.Int).Value = CveClasificacionDetalle + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@Estatus", SqlDbType.Int).Value = Estatus + .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener las clasificaciones detalle.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + + Public Function AddClasificacionDetalle(ClasificacionDetalle As String, CveClasificacion As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_ClasificacionesDetalleAdd") + With SqlAdapter.SelectCommand.Parameters + .Add("@ClasificacionDetalle", SqlDbType.VarChar).Value = ClasificacionDetalle + .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveClasificacionDetalle", SqlDbType.Int).Direction = ParameterDirection.Output + End With + Try + SqlAdapter.Fill(Data) + CveClasificacionDetalle = SqlAdapter.SelectCommand.Parameters("@CveClasificacionDetalle").Value.ToString.ToEntero + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al guardar la clasificacion detalle.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + + Public Function UpdateClasificacionDetalle(CveClasificacionDetalle As Integer, ClasificacionDetalle As String, CveClasificacion As Integer, Estatus As Boolean) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_ClasificacionesDetalleUpdate") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveClasificacionDetalle", SqlDbType.Int).Value = CveClasificacionDetalle + .Add("@ClasificacionDetalle", SqlDbType.VarChar).Value = ClasificacionDetalle + .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion + .Add("@Estatus", SqlDbType.Bit).Value = Estatus + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar la clasificacion detalle.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + + Public Function RemoveClasificacionDetalle(CveClasificacionDetalle As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_ClasificacionesDetalleRemove") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveClasificacionDetalle", SqlDbType.Int).Value = CveClasificacionDetalle + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar la clasificacion detalle.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function +#End Region + +#Region "PEDIDOS2" + + Public Function AddVentaDetallePedido2(CveVentaDetalle As Integer, CveVentaDetallePadre As Integer, Cantidad As Double) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasDetallePedidos2Add") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVentaDetalle", SqlDbType.Int).Value = CveVentaDetalle + .Add("@CveVentaDetallePadre", SqlDbType.Int).Value = CveVentaDetallePadre + .Add("@Cantidad", SqlDbType.Float).Value = Cantidad + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar la venta detalle pedido2.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + Public Function GetVentaDetallePedido2SinFacturar(FechaI As String, FechaF As String, CveCliente As Integer, CveMoneda As Integer, Tipo As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasDetallePedidos2SinFacturarGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.VarChar).Value = FechaI + .Add("@FechaF", SqlDbType.VarChar).Value = FechaF + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda + .Add("@Tipo", SqlDbType.Float).Value = Tipo + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los pedidos2 sin facturar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + + Public Function GetVentasPedidos2Totales(CveCliente As Integer, Ventas As String, Tipo As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasDetallePedidos2Totales") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@Ventas", SqlDbType.VarChar).Value = Ventas + .Add("@Tipo", SqlDbType.Int).Value = Tipo + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los pedidos2 totales.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + + Public Function UpdateVentaPedido2(CveVenta As Integer, CveVentaFacturada As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_VentasPedido2Update") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveVentaFacturada", SqlDbType.Int).Value = CveVentaFacturada + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al vincular la Venta con el Pedido2.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + + Public Function GetRepPedidos2SinFacturar(FechaI As Date, FechaF As Date, FechaV As Date, CveSubProyecto As String, CveCliente As Integer, CveVendedor As String, CveEmpresa As Integer, CveUsuarioConsulta As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("Vta_RepPedidos2Get") + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@FechaV", SqlDbType.Date).Value = FechaV + .Add("@CveSubProyecto", SqlDbType.VarChar).Value = CveSubProyecto + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveVendedor", SqlDbType.VarChar).Value = CveVendedor + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los pedidos2 sin facturar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + + Public Function GetRepPedidos2SinFacturarDetalle(FechaI As Date, FechaF As Date, FechaV As Date, CveCliente As Integer, CveVenta As Integer, CveEmpresa As Integer, CveSubProyecto As String, CveVendedor As String, CveUsuarioConsulta As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("Vta_RepPedidos2DetalleGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@FechaV", SqlDbType.Date).Value = FechaV + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveSubProyecto", SqlDbType.VarChar).Value = CveSubProyecto + .Add("@CveVendedor", SqlDbType.VarChar).Value = CveVendedor + .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los pedidos2 sin facturar detalle.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + +#End Region + +#Region "COSTO PROMEDIO VENTA" + + Public Function RepCostoPromedioVenta(FechaI As Date, FechaF As Date, CveCliente As Integer, CveSubProyecto As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_CostoPromedioVentaRep") + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el costo promedio de venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + + Public Function RepVentasNetasResumen(FechaI As Date, FechaF As Date, CveCliente As Integer, CveSubProyecto As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasNetasResumenRep") + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el costo promedio de venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + +#End Region + + Public Function RepIngresos(CveEmpresa As Integer, FechaInicio As Date, FechaFin As Date, TipoDocto As String, CveSubProyecto As Integer) As Boolean + Dim retorno As Boolean = False + DataAdapter("PA_Ventas_RepIngresos", CommandType.StoredProcedure) + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio + .Add("@FechaFin", SqlDbType.Date).Value = FechaFin + .Add("@TipoDoc", SqlDbType.VarChar).Value = TipoDocto + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Reporte de Ingresos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return retorno + End Function + + Public Function RepIngresosDetalle(CveEmpresa As Integer, FechaInicio As Date, FechaFin As Date, TipoDocto As String, CveSubProyecto As Integer, CveConceptoContable As Integer, CveCuenta As Integer) As Boolean + Dim retorno As Boolean = False + DataAdapter("PA_Ventas_RepIngresosDetalle", CommandType.StoredProcedure) + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio + .Add("@FechaFin", SqlDbType.Date).Value = FechaFin + .Add("@TipoDoc", SqlDbType.VarChar).Value = TipoDocto + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveConceptoContable", SqlDbType.Int).Value = CveConceptoContable + .Add("@CveCuenta", SqlDbType.Int).Value = CveCuenta + End With + Try + SqlAdapter.Fill(Data) + retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Reporte de Ingresos Detalle.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return retorno + End Function + +#Region " AUTORIZACION DESCUENTOS " + + Public Function AutorizacionDescuentosGet(CveAutorizacionDescuento As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_AutorizacionDescuentosGet", CommandType.StoredProcedure) + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveAutorizacionDescuento", SqlDbType.Int).Value = CveAutorizacionDescuento + .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 Autorizaciones.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + + End Try + + Return Retorno + End Function + + Public Function AutorizacionDescuentosRemove(CveAutorizacionDescuento As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_AutorizacionDescuentosRemove", CommandType.StoredProcedure) + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveAutorizacionDescuento", SqlDbType.Int).Value = CveAutorizacionDescuento + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + + OnError("Ocurrió un error al eliminar la Autorización.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + + End Try + + Return Retorno + End Function + + Public Function AutorizacionDescuentosAdd(CodigoAutorizacion As String, CveCliente As Integer, PorcentajeDescuento As Double, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_AutorizacionDescuentosAdd", CommandType.StoredProcedure) + + With SqlAdapter.SelectCommand.Parameters + + .Add("@CodigoAutorizacion", SqlDbType.VarChar).Value = CodigoAutorizacion + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@PorcentajeDescuento", SqlDbType.SmallMoney).Value = PorcentajeDescuento + .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 Autorización.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + + End Try + + Return Retorno + End Function + + Public Function AutorizacionDescuentosUpdate(CveAutorizacionDescuento As Integer, CodigoAutorizacion As String, CveCliente As Integer, PorcentajeDescuento As Double, CveUsuario As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_AutorizacionDescuentosUpdate", CommandType.StoredProcedure) + + With SqlAdapter.SelectCommand.Parameters + + .Add("@CveAutorizacionDescuento", SqlDbType.Int).Value = CveAutorizacionDescuento + .Add("@CodigoAutorizacion", SqlDbType.VarChar).Value = CodigoAutorizacion + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@PorcentajeDescuento", SqlDbType.SmallMoney).Value = PorcentajeDescuento + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + + OnError("Ocurrió un error al actualizar la Autorización.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + + End Try + + Return Retorno + End Function + + Public Function AutorizacionEstatusUpdate(CveAutorizacionDescuento As Integer, CveVenta As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_AutorizacionEstatusUpdate", CommandType.StoredProcedure) + + With SqlAdapter.SelectCommand.Parameters + + .Add("@CveAutorizacionDescuento", SqlDbType.Int).Value = CveAutorizacionDescuento + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + + OnError("Ocurrió un error al actualizar el Estatus de la Autorización.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + + End Try + + Return Retorno + End Function +#End Region + +#Region "CANCELACION REMISION" + + Public Function UpdateCancelaRemision(CveVenta As Integer, SeCancelaRemision As Boolean) As Boolean + Dim retorno As Boolean = False + DataAdapter("PA_Vta_CancelaRemisionUpdate", CommandType.StoredProcedure) + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@SeCancelaRemision", SqlDbType.Bit).Value = SeCancelaRemision + End With + Try + SqlAdapter.Fill(Data) + retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar que la remision sea cancelable.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return retorno + End Function + +#End Region + +#Region "REPORTE PUES SIN PAGO" + + Public Function GetPUESinPago(FI As DateTime, FF As DateTime, CveCliente As Integer, CveSubProyecto As Integer, CveVendedor As Integer, CveEmpresa As Integer, Optional CveUsuario As Integer = -1) As Boolean + Dim retorno As Boolean = False + DataAdapter("PA_Vta_PUESinPagoGet", CommandType.StoredProcedure) + With SqlAdapter.SelectCommand.Parameters + .Add("@FI", SqlDbType.DateTime).Value = FI + .Add("@FF", SqlDbType.DateTime).Value = FF + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + End With + Try + SqlAdapter.Fill(Data) + retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener las ventas con método de pago PUE.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return retorno + End Function + +#End Region + + Public Function GetAnticiposEspeciales(FI As DateTime, FF As DateTime, CveSubProyecto As Integer, AnticipoEspecial As Integer, CveEmpresa As Integer) As Boolean + Dim retorno As Boolean = False + DataAdapter("PA_Vta_AnticiposEspecialesGet", CommandType.StoredProcedure) + With SqlAdapter.SelectCommand.Parameters + .Add("@FI", SqlDbType.DateTime).Value = FI + .Add("@FF", SqlDbType.DateTime).Value = FF + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@AnticipoEspecial", SqlDbType.Int).Value = AnticipoEspecial + .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 Anticipo Ficticio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return retorno + End Function + Public Function GetRepArqueos(Anio As Integer, CveSubProyecto As Integer, CveEmpresa As Integer) As Boolean + Dim retorno As Boolean = False + Dataset = New DataSet() + DataAdapter("PA_Vta_RepArqueosGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@Anio", SqlDbType.Int).Value = Anio + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Dataset) + retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el reporte de arqueos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return retorno + 'compila + End Function + Public Function GetRepArqueosDetalle(Fecha As DateTime, CveSubProyecto As Integer, CveEmpresa As Integer) As Boolean + Dim retorno As Boolean = False + Dataset = New DataSet() + DataAdapter("PA_Vta_RepArqueosDetalleGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@Fecha", SqlDbType.DateTime).Value = Fecha + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Dataset) + retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el reporte de arqueos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return retorno + 'compila + End Function +#Region "Conciliación emitidas SAT" + + Public Function ConciliacionemitidasSATGet(cveEmpresa As Int32) As Boolean + Dim retorno As Boolean = False + DataAdapter("PA_Vta_ConciliacionemitidasSATGet", CommandType.StoredProcedure) + 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 reporte de 'Conciliación emitidas SAT'.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + retorno = False + End Try + Return retorno + End Function +#End Region +#Region "IDisposable Support" + + + ' IDisposable + Protected Overridable Sub Dispose(disposing As Boolean) + If Not Me.disposedValue Then + If disposing Then + ' TODO: dispose managed state (managed objects). + If Not Data Is Nothing Then Data.Dispose() + If Not Dataset Is Nothing Then Dataset.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 + + ' TODO: free unmanaged resources (unmanaged objects) and override Finalize() below. + ' TODO: set large fields to null. + End If + Me.disposedValue = True + End Sub + + ' TODO: override Finalize() only if Dispose(disposing As Boolean) above has code to free unmanaged resources. + 'Protected Overrides Sub Finalize() + ' ' Do not change this code. Put cleanup code in Dispose(disposing As Boolean) above. + ' Dispose(False) + ' MyBase.Finalize() + 'End Sub + + ' This code added by Visual Basic to correctly implement the disposable pattern. + Public Sub Dispose() Implements IDisposable.Dispose + ' Do not change this code. Put cleanup code in Dispose(disposing As Boolean) above. + Dispose(True) + GC.SuppressFinalize(Me) + End Sub +#End Region +End Class + diff --git a/App_Code/Modelos.vb b/App_Code/Modelos.vb index 4d78eadb3..41b6f6116 100644 --- a/App_Code/Modelos.vb +++ b/App_Code/Modelos.vb @@ -1181,13 +1181,14 @@ Namespace Modelos 'Se agregan los PS For Each Row As DataRow In TmpDTDetalle.Rows If Not ObjVentas.AddVentaDetalle(ObjVentas.CveVenta, Row("CvePS").ToString.ToEntero, Row("Cantidad").ToString.ToDouble, Row("CveUM").ToString.ToEntero, - Row("PU").ToString.ToDouble(If(factura.ConvertirPesos, factura.TipoCambio, 1)), Row("IVA").ToString.ToDouble(If(factura.ConvertirPesos, factura.TipoCambio, 1)), Math.Round((Row("Total").ToString.ToDouble(If(factura.ConvertirPesos, factura.TipoCambio, 1)) * (1 + Row("IVA").ToString.ToDouble(If(factura.ConvertirPesos, factura.TipoCambio, 1)))), 6), + Row("PU").ToString.ToDouble(If(factura.ConvertirPesos, factura.TipoCambio, 1)), Row("ImporteIVA").ToString.ToDouble(If(factura.ConvertirPesos, factura.TipoCambio, 1)), Math.Round((Row("Total").ToString.ToDouble(If(factura.ConvertirPesos, factura.TipoCambio, 1)) * (1 + Row("PorcentajeIVA").ToString.ToDouble(If(factura.ConvertirPesos, factura.TipoCambio, 1)))), 6), Row("Obs").ToString, Row("Descuento").ToString.ToDouble(If(factura.ConvertirPesos, factura.TipoCambio, 1)), Row("TipoDescuento").ToString.ToEntero, Row("CveSubProyecto").ToString.ToEntero, Row("CvePresupuestoIngreso").ToString.ToEntero, TiempoEntrega:=Row("TiempoEntrega").ToString, CveVentaDetallePadre:=Row("CveVentaDetalle").ToString.ToEntero, CveContratoDetalle:=Row("CveContratoDetalle").ToString.ToEntero, CvePromocionDetalle:=If(DtPromociones IsNot Nothing, DtPromociones.FiltroPrimeroValor("CvePromocionDetalle", $"CvePS={Row("CvePS").ToString}").ToEntero, -1), IEPS:=Row("ImporteIEPS").ToString.ToDouble, CveMovimientoDetallePedido:=Row("CveMovimientoDetallePedido").ToString.ToEntero, ImporteRetIVA:=Row("ImporteRetIVA").ToString.ToDouble, ImporteRetISR:=Row("ImporteRetISR").ToString.ToDouble, - PorcentajeIEPS:=Row("PorcentajeIEPS").ToString.ToDouble, PorcentajeRetIVA:=Row("PorcentajeRetIVA").ToString.ToDouble, PorcentajeRetISR:=Row("PorcentajeRetISR").ToString.ToDouble, CuentaPredial:=Row("CuentaPredial").ToString) Then + PorcentajeIEPS:=Row("PorcentajeIEPS").ToString.ToDouble, PorcentajeRetIVA:=Row("PorcentajeRetIVA").ToString.ToDouble, PorcentajeRetISR:=Row("PorcentajeRetISR").ToString.ToDouble, CuentaPredial:=Row("CuentaPredial").ToString, + PorcentajeIVA:=Row("PorcentajeIVA").ToString.ToDecimal) Then ErrorList.Add("Ocurrió un error al agregar un Producto o Servicio a la factura.
Revise su factura y cualquier detalle comuníquese a Soporte Técnico") Exit For Else diff --git a/Bancos/PopIECompras.aspx b/Bancos/PopIECompras.aspx index dcc1b2cb0..9d8a06644 100644 --- a/Bancos/PopIECompras.aspx +++ b/Bancos/PopIECompras.aspx @@ -11,7 +11,7 @@   - + diff --git a/Bancos/PopIECompras.aspx.vb b/Bancos/PopIECompras.aspx.vb index 8e42df1f3..683e35fd7 100644 --- a/Bancos/PopIECompras.aspx.vb +++ b/Bancos/PopIECompras.aspx.vb @@ -307,6 +307,8 @@ Partial Class Bancos_PopIECompras Public Class IEMovimiento Public Property SubTotal As Decimal Public Property IVA As Decimal + Public Property IVADeducible As Decimal + Public Property IVANoDeducible As Decimal Public Property RetIVA As Decimal Public Property RetISR As Decimal Public Property Total As Decimal @@ -615,6 +617,8 @@ Partial Class Bancos_PopIECompras MovimientoPagar = New IEMovimiento MovimientoPagar.SubTotal = dr("SubTotal").ToString.ToDecimal MovimientoPagar.IVA = dr("IVA").ToString.ToDecimal + MovimientoPagar.IVADeducible = dr("IVADeducible").ToString.ToDecimal + MovimientoPagar.IVANoDeducible = dr("IVANoDeducible").ToString.ToDecimal MovimientoPagar.RetIVA = dr("RetIVA").ToString.ToDecimal MovimientoPagar.RetISR = dr("RetISR").ToString.ToDecimal MovimientoPagar.Total = dr("Total").ToString.ToDecimal @@ -2250,16 +2254,16 @@ Partial Class Bancos_PopIECompras If TotalImporte = CompraSaldo Then If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then - ImporteMovimiento = MovimientoPagar.IVA + ImporteMovimiento = MovimientoPagar.IVADeducible ImporteMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then - ImporteMovimiento = (MovimientoPagar.IVA) + ImporteMovimiento = (MovimientoPagar.IVADeducible) ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then - ImporteMovimiento = (MovimientoPagar.IVA) + ImporteMovimiento = (MovimientoPagar.IVADeducible) ImporteMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then - ImporteMovimiento = (MovimientoPagar.IVA) + ImporteMovimiento = (MovimientoPagar.IVADeducible) ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) End If ImporteMovimiento = Math.Round(ImporteMovimiento, 2) @@ -2273,16 +2277,92 @@ Partial Class Bancos_PopIECompras End If Else If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then - ImporteMovimiento = MovimientoPagar.IVA * PorcentajePago + ImporteMovimiento = MovimientoPagar.IVADeducible * PorcentajePago ImporteMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then - ImporteMovimiento = (MovimientoPagar.IVA * PorcentajePago) + ImporteMovimiento = (MovimientoPagar.IVADeducible * PorcentajePago) ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then - ImporteMovimiento = (MovimientoPagar.IVA * PorcentajePago) + ImporteMovimiento = (MovimientoPagar.IVADeducible * PorcentajePago) ImporteMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then - ImporteMovimiento = (MovimientoPagar.IVA * PorcentajePago) + ImporteMovimiento = (MovimientoPagar.IVADeducible * PorcentajePago) + ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) + End If + ImporteMovimiento = Math.Round(ImporteMovimiento, 2) + ImporteMX = Math.Round(ImporteMX, 2) + TimpocambioGeneral = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) + + If tipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{tipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}" + End If + + PorcentajeImpuesto = MovimientoPagar.PorcentajeIVA + Dim IdCtaIVAXAcreditar As Integer = 0 + Dim IdCtaIVAAcreditable As Integer = 0 + + If GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows.Count > 0 Then + IdCtaIVAXAcreditar = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("IdCtaIVAXAcreditar").ToString.ToEntero + IdCtaIVAAcreditable = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("IdCtaIVAAcreditable").ToString.ToEntero + End If + + IdCtaContable = If(IdCtaIVAAcreditable > 0, IdCtaIVAAcreditable, 0) + + If ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) And Not IdCtaContable > 0 Then + If ObjMov.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjMov.DtResultados.Rows(0)("IdCuentaIVAAcreditable").ToString.ToEntero + CveCuenta = ObjMov.DtResultados.Rows(0)("IdCuentaIVAAcreditableSIG").ToString.ToEntero + End If + End If + Case 280 'Iva Acreditable No Deducible + If UsuarioActual.Empresa.Funcionalidad(521) = "1" Then + 'funcionalidad que toma el 100% del pago para acreditamiento de iva + Dim TotalImporte As Decimal + + If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then + TotalImporte = ImportePagado.ToString.ToDecimal + ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then + TotalImporte = Math.Round(ImportePagado.ToString.ToDecimal / tipoCambioPago, 2) + ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then + TotalImporte = Math.Round(ImportePagado.ToString.ToDecimal * tipoCambioPago, 2) + ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then + TotalImporte = ImportePagado.ToString.ToDecimal + End If + + If TotalImporte = CompraSaldo Then + If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then + ImporteMovimiento = MovimientoPagar.IVANoDeducible + ImporteMX = ImporteMovimiento + ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then + ImporteMovimiento = (MovimientoPagar.IVANoDeducible) + ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) + ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then + ImporteMovimiento = (MovimientoPagar.IVANoDeducible) + ImporteMX = ImporteMovimiento * tipoCambioCompra + ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then + ImporteMovimiento = (MovimientoPagar.IVANoDeducible) + ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) + End If + ImporteMovimiento = Math.Round(ImporteMovimiento, 2) + ImporteMX = Math.Round(ImporteMX, 2) + TimpocambioGeneral = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) + + If tipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{tipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}" + Else + ImporteMovimiento = 0 + ImporteMX = 0 + End If + Else + If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then + ImporteMovimiento = MovimientoPagar.IVANoDeducible * PorcentajePago + ImporteMX = ImporteMovimiento + ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then + ImporteMovimiento = (MovimientoPagar.IVANoDeducible * PorcentajePago) + ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) + ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then + ImporteMovimiento = (MovimientoPagar.IVANoDeducible * PorcentajePago) + ImporteMX = ImporteMovimiento * tipoCambioCompra + ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then + ImporteMovimiento = (MovimientoPagar.IVANoDeducible * PorcentajePago) ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) End If ImporteMovimiento = Math.Round(ImporteMovimiento, 2) diff --git a/Bancos/PopIEVentas.aspx.vb b/Bancos/PopIEVentas.aspx.vb index 9a60d6198..9715941cf 100644 --- a/Bancos/PopIEVentas.aspx.vb +++ b/Bancos/PopIEVentas.aspx.vb @@ -2062,7 +2062,7 @@ Partial Class Bancos_PopIEVentas IdCtaContable = UsuarioActual.Empresa.IdCuentaGananciaCambiaria CveCuenta = UsuarioActual.Empresa.CveCuentaGananciaCambiaria tipoCambioVentaDiferenciaCambiaria = If(FechaVenta < FechaUltimaFluctuacion, TipoCambioFluctuacion, TipoCambioOriginal) - Dim TCImpuestos As Decimal = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioVenta) + Dim TCImpuestos As Decimal = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioVentaDiferenciaCambiaria) TimpocambioGeneral = TCImpuestos Dim Diferencia As Decimal = ((MovimientoPagar.Total * PorcentajePago) * tipoCambioVentaValuacion) - ((MovimientoPagar.Total * PorcentajePago) * tipoCambioPago) 'Añadimos la diferencia de perdida en la venta @@ -2090,7 +2090,7 @@ Partial Class Bancos_PopIEVentas IdCtaContable = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria CveCuenta = UsuarioActual.Empresa.CveCuentaPerdidaCambiaria tipoCambioVentaDiferenciaCambiaria = If(FechaVenta < FechaUltimaFluctuacion, TipoCambioFluctuacion, TipoCambioOriginal) - Dim TCImpuestos As Decimal = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioVenta) + Dim TCImpuestos As Decimal = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioVentaDiferenciaCambiaria) TimpocambioGeneral = TCImpuestos diff --git a/Bancos/ProveedoresAbonar.aspx b/Bancos/ProveedoresAbonar.aspx index fd65df3b5..dec829379 100644 --- a/Bancos/ProveedoresAbonar.aspx +++ b/Bancos/ProveedoresAbonar.aspx @@ -358,7 +358,7 @@ diff --git a/Bancos/ProveedoresAbonar.aspx.vb b/Bancos/ProveedoresAbonar.aspx.vb index 672ec98f1..38a671b26 100644 --- a/Bancos/ProveedoresAbonar.aspx.vb +++ b/Bancos/ProveedoresAbonar.aspx.vb @@ -310,7 +310,7 @@ Partial Class Bancos_ProveedoresAbonar ViewState("CveCuentaRetISR") = 0 End If - If UsuarioActual.CveEmpresa.Contiene(1, 4, 5, 7, 11, 12, 72, 80, 126, 119, 122,145) Then + If UsuarioActual.CveEmpresa.Contiene(1, 4, 5, 7, 11, 12, 72, 80, 126, 119, 122) Then rowComisiones.Visible = True End If @@ -1506,16 +1506,16 @@ Partial Class Bancos_ProveedoresAbonar 'funcionalidad que toma el 100% del pago para acreditamiento de iva If TotalImporte = gvr.DataKey("Saldo").ToDecimal Then If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then - ImporteMovimiento = gvr.DataKey("IVA").ToDecimal + ImporteMovimiento = gvr.DataKey("IVADeducible").ToDecimal importeMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then - ImporteMovimiento = gvr.DataKey("IVA").ToDecimal - importeMX = gvr.DataKey("IVA").ToDecimal * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) + ImporteMovimiento = gvr.DataKey("IVADeducible").ToDecimal + importeMX = gvr.DataKey("IVADeducible").ToDecimal * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then - ImporteMovimiento = gvr.DataKey("IVA").ToDecimal + ImporteMovimiento = gvr.DataKey("IVADeducible").ToDecimal importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then - ImporteMovimiento = gvr.DataKey("IVA").ToDecimal + ImporteMovimiento = gvr.DataKey("IVADeducible").ToDecimal importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) End If ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero) @@ -1528,16 +1528,79 @@ Partial Class Bancos_ProveedoresAbonar End If Else If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then - ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagar").ToDecimal - (gvr.DataKey("IVA").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagar").ToDecimal, gvr.DataKey("IVA").ToDecimal * PorcentajePago) + ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagarDeducible").ToDecimal - (gvr.DataKey("IVADeducible").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagarDeducible").ToDecimal, gvr.DataKey("IVADeducible").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then - ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagar").ToDecimal - (gvr.DataKey("IVA").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagar").ToDecimal, gvr.DataKey("IVA").ToDecimal * PorcentajePago) + ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagarDeducible").ToDecimal - (gvr.DataKey("IVADeducible").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagarDeducible").ToDecimal, gvr.DataKey("IVADeducible").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then - ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagar").ToDecimal - (gvr.DataKey("IVA").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagar").ToDecimal, gvr.DataKey("IVA").ToDecimal * PorcentajePago) + ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagarDeducible").ToDecimal - (gvr.DataKey("IVADeducible").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagarDeducible").ToDecimal, gvr.DataKey("IVADeducible").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then - ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagar").ToDecimal - (gvr.DataKey("IVA").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagar").ToDecimal, gvr.DataKey("IVA").ToDecimal * PorcentajePago) + ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagarDeducible").ToDecimal - (gvr.DataKey("IVADeducible").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagarDeducible").ToDecimal, gvr.DataKey("IVADeducible").ToDecimal * PorcentajePago) + importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) + End If + ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero) + importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero) + + If TipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{TipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}" + End If + TipoCambioGeneral = If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) + + PorcentajeImpuesto = gvr.DataKey("PorcentajeIVA").ToDecimal + Dim IdCtaIVAXAcreditar As Integer = 0 + Dim IdCtaIVAAcreditable As Integer = 0 + + If GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows.Count > 0 Then + IdCtaIVAXAcreditar = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("IdCtaIVAXAcreditar").ToString.ToEntero + IdCtaIVAAcreditable = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("IdCtaIVAAcreditable").ToString.ToEntero + End If + IdCtaContable = If(IdCtaIVAAcreditable > 0, IdCtaIVAAcreditable, 0) + + If ImporteMovimiento <> 0 AndAlso ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) And Not IdCtaContable > 0 Then + If ObjMov.DtResultados.Rows.Count > 0 Then + IdCtaContable = ObjMov.DtResultados.Rows(0)("IdCuentaIVAAcreditable").ToString.ToEntero + CveCuenta = ObjMov.DtResultados.Rows(0)("IdCuentaIVAAcreditableSIG").ToString.ToEntero + End If + End If + Case 280 'Iva Acreditado No Deducible + Dim TotalImporte As Decimal = gvr.FCTextBox("TxtAbonar").Text.ToDecimal + If UsuarioActual.Empresa.Funcionalidad(521) = "1" Then + 'funcionalidad que toma el 100% del pago para acreditamiento de iva + If TotalImporte = gvr.DataKey("Saldo").ToDecimal Then + If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then + ImporteMovimiento = gvr.DataKey("IVANoDeducible").ToDecimal + importeMX = ImporteMovimiento + ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then + ImporteMovimiento = gvr.DataKey("IVANoDeducible").ToDecimal + importeMX = gvr.DataKey("IVANoDeducible").ToDecimal * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) + ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then + ImporteMovimiento = gvr.DataKey("IVANoDeducible").ToDecimal + importeMX = ImporteMovimiento * tipoCambioCompra + ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then + ImporteMovimiento = gvr.DataKey("IVANoDeducible").ToDecimal + importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) + End If + ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero) + importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero) + + If TipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{TipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}" + Else + ImporteMovimiento = 0 + importeMX = 0 + End If + Else + If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then + ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagarNoDeducible").ToDecimal - (gvr.DataKey("IVANoDeducible").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagarNoDeducible").ToDecimal, gvr.DataKey("IVANoDeducible").ToDecimal * PorcentajePago) + importeMX = ImporteMovimiento + ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then + ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagarNoDeducible").ToDecimal - (gvr.DataKey("IVANoDeducible").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagarNoDeducible").ToDecimal, gvr.DataKey("IVANoDeducible").ToDecimal * PorcentajePago) + importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) + ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then + ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagarNoDeducible").ToDecimal - (gvr.DataKey("IVANoDeducible").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagarNoDeducible").ToDecimal, gvr.DataKey("IVANoDeducible").ToDecimal * PorcentajePago) + importeMX = ImporteMovimiento * tipoCambioCompra + ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then + ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagarNoDeducible").ToDecimal - (gvr.DataKey("IVANoDeducible").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagarNoDeducible").ToDecimal, gvr.DataKey("IVANoDeducible").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) End If ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero) diff --git a/OS/CatTiposOrdenesServicios.aspx b/OS/CatTiposOrdenesServicios.aspx index d14ae3451..b7ccee347 100644 --- a/OS/CatTiposOrdenesServicios.aspx +++ b/OS/CatTiposOrdenesServicios.aspx @@ -3,116 +3,175 @@ + - - - + Catálogo de Tipos de Ordenes de Servicio + + - - - + - - - - - - - - - - - - - - - - - -
- - Tipo de Orden de Servicio - - - - - Estatus - - - - - Fecha Ing. - - - - - Usuario - - - Comandos
- - - -     -
-
-
- - - - - - -   - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -   -
-
- - - -
- - - - - -
- - -
+
  • + +
  • - + + + + + +
    +
    + " style="display: inline-block; margin-right: -20px; width: 150px;" /> + " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> +
    +
    + +
    + + + + + + + +   + + + + + +   + + + + + +   + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    +
    + + +
    +
    + +
    + + \ No newline at end of file diff --git a/OS/CatTiposOrdenesServicios.aspx.vb b/OS/CatTiposOrdenesServicios.aspx.vb index d9f07a516..0ff4c01c3 100644 --- a/OS/CatTiposOrdenesServicios.aspx.vb +++ b/OS/CatTiposOrdenesServicios.aspx.vb @@ -6,179 +6,165 @@ Imports System.Linq Imports Extensiones Partial Class OS_CatTiposOrdenesServicios - Inherits ClsPaginas + Inherits ClsPaginas - Public Property PuedeEditar As Boolean - Get - Return CBool(ViewState("PuedeEditar")) - End Get - Set(value As Boolean) - ViewState("PuedeEditar") = value - End Set - End Property + Private Property CveOrdenServicioTipo As Integer + Get + If Not ViewState("CveOrdenServicioTipo") Is Nothing Then + Return ViewState("CveOrdenServicioTipo").ToString.ToEntero + Else + Return -1 + End If - Public Property PuedeEliminar As Boolean - Get - Return CBool(ViewState("PuedeEditar")) - End Get - Set(value As Boolean) - ViewState("PuedeEditar") = value - End Set - End Property + End Get + Set(value As Integer) + ViewState("CveOrdenServicioTipo") = value + End Set - Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load - If Not Page.IsPostBack Then - ViewState("Orden") = "" - CargaDatos() - End If - End Sub + End Property - Public Sub CargaDatos() - Dim ObjSubTipoOrdenServicios As New ClsOS + Private Property Actualizar As Boolean + Get + If Not ViewState("Actualizar") Is Nothing Then + Return DirectCast(ViewState("Actualizar"), Boolean) + Else + Return False + End If + End Get + Set(value As Boolean) + ViewState("Actualizar") = value + End Set + End Property + + + Private Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load + + If Not Page.IsPostBack Then + CargadatosGvTiposOS() + End If + + End Sub + + Private Sub CargadatosGvTiposOS() + + Dim ObjSubTipoOrdenServicios As New ClsOS If ObjSubTipoOrdenServicios.GetTipoOrdenesServicios(-1) Then - ViewState("DTTipoOrdenServicios") = ObjSubTipoOrdenServicios.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) + GvTiposOS.DataSource = ObjSubTipoOrdenServicios.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) GlobalDTSubTipoOrdenServicios = ObjSubTipoOrdenServicios.DtResultados Else - Me.GvDatos.DataSource = Nothing + GvTiposOS.DataSource = Nothing End If - ObjSubTipoOrdenServicios.Dispose() + ObjSubTipoOrdenServicios.Dispose() - If ViewState("Orden").ToString() <> String.Empty Then - CargaGrid(ViewState("Orden").ToString()) - Else - CargaGrid("") - End If - End Sub + GvTiposOS.DataBind() + UpGral.Update() - Protected Sub LbAgregar_Click(sender As Object, e As System.EventArgs) Handles LbAgregar.Click - Dim ObjTipoOrdenServicios As New ClsOS - If ObjTipoOrdenServicios.AddTipoOrdenServicio(TxtTipoOrdenServicio.Text.Trim, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then - TxtTipoOrdenServicio.Text = "" - Alert("El nuevo Tipo de Orden de Servicio se guardó correctamente.", TipoMensaje.MsgInformacion) - UpTitulos.Update() - ViewState("DTTipoOrdenServicios") = ObjTipoOrdenServicios.DtResultados '.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) - 'GlobalDTTipoOrdenServicios(-1) = ObjTipoOrdenServicios.DtResultados + End Sub - If ViewState("Orden").ToString() <> String.Empty Then - CargaGrid(ViewState("Orden").ToString()) - Else - CargaGrid("") - End If - End If - ObjTipoOrdenServicios.Dispose() - End Sub + Protected Sub BtnAgregarTiposOS_Click(sender As Object, e As EventArgs) Handles BtnAgregarTiposOS.Click + LtlTituloModalTiposOS.Text = "Agregar Tipo de Orden de Servicio" + BtnAgregarTiposOSModal.Text = "Agregar" + DivEstatus.Visible = False -#Region "G V D A T O S" - Protected Sub GvDatos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvDatos.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - If e.Row.RowIndex = 0 Then - e.Row.Cells(0).Width = Unit.Pixel(250) - e.Row.Cells(1).Width = Unit.Pixel(100) - e.Row.Cells(2).Width = Unit.Pixel(100) - e.Row.Cells(3).Width = Unit.Pixel(100) - e.Row.Cells(4).Width = Unit.Pixel(100) - e.Row.Cells(5).Width = Unit.Pixel(61) + TxtTiposOS.Text = "" + + Actualizar = False + UpGral.Update() + RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarTiposOS")) + + End Sub + + Protected Sub BtnAgregarTiposOSModal_Click(sender As Object, e As EventArgs) Handles BtnAgregarTiposOSModal.Click + + Dim ObjTipoOrdenServicios As New ClsOS + + If Not Actualizar Then + If ObjTipoOrdenServicios.AddTipoOrdenServicio(TxtTiposOS.Text.Trim, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then + + TxtTiposOS.Text = "" + ChkEstatus.Checked = True + + CargadatosGvTiposOS() + + RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarTiposOS"), "jsHideModalTiposOS") + 'GeneraGlobalDT() + UpGral.Update() + + Alert("Tipo de Orden de Servicio Agregado Correctamente", TipoMensaje.MsgInformacion) + Else + Alert("Ocurrio un error al guardar el Tipo de Orden de Servicio", TipoMensaje.MsgError) End If - e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Left - e.Row.Cells(1).HorizontalAlign = HorizontalAlign.Center - e.Row.Cells(2).HorizontalAlign = HorizontalAlign.Center - e.Row.Cells(3).HorizontalAlign = HorizontalAlign.Center - e.Row.Cells(4).HorizontalAlign = HorizontalAlign.Center - e.Row.Cells(5).HorizontalAlign = HorizontalAlign.Center - End If - End Sub - - Protected Sub GvDatos_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvDatos.RowDeleting - Dim ObjTipoOrdenServicios As New ClsOS - If ObjTipoOrdenServicios.RemoveTipoOrdenServicio(GvDatos.DataKeys(e.RowIndex).Value.ToString.ToEntero) Then - GvDatos.EditIndex = -1 - ViewState("DTTipoOrdenServicios") = ObjTipoOrdenServicios.DtResultados '.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) - 'GlobalDTTipoOrdenServicios(-1) = ObjTipoOrdenServicios.DtResultados - Alert("El Tipo de Orden de Servicio se eliminó correctamente.", TipoMensaje.MsgInformacion) - End If - ObjTipoOrdenServicios.Dispose() - If ViewState("Orden").ToString() <> String.Empty Then - CargaGrid(ViewState("Orden").ToString()) Else - CargaGrid("") - End If - End Sub + If ObjTipoOrdenServicios.UpdateTipoOrdenServicio(TxtTiposOS.Text.Trim, False, ChkEstatus.Checked, CveOrdenServicioTipo) Then - Protected Sub GvDatos_RowCancelingEdit(sender As Object, e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles GvDatos.RowCancelingEdit - GvDatos.EditIndex = -1 - If ViewState("Orden").ToString() <> String.Empty Then - CargaGrid(ViewState("Orden").ToString()) - Else - CargaGrid("") - End If - End Sub + TxtTiposOS.Text = "" + ChkEstatus.Checked = True - Protected Sub GvDatos_RowUpdating(sender As Object, e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GvDatos.RowUpdating - Dim ObjTipoOrdenServicios As New ClsOS - Dim TipoOrdenServicio As String = DirectCast(GvDatos.Rows(e.RowIndex).FindControl("TxtTipoOrdenServicio"), TextBox).Text.Trim - Dim Estatus As Boolean = GvDatos.Rows(e.RowIndex).FCCheckBox("ChkEstatus").Checked - Dim CveTipoOrdenServicio As Integer = GvDatos.DataKeys(e.RowIndex).Value.ToString.ToEntero + CargadatosGvTiposOS() + 'GeneraGlobalDT() + UpModalTiposOS.Update() - If ObjTipoOrdenServicios.UpdateTipoOrdenServicio(TipoOrdenServicio, False, Estatus, CveTipoOrdenServicio) Then - GvDatos.EditIndex = -1 - ViewState("DTTipoOrdenServicios") = ObjTipoOrdenServicios.DtResultados '.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) - 'GlobalDTTipoOrdenServicios(-1) = ObjTipoOrdenServicios.DtResultados - Alert("Los cambios se guardaron correctamente.", TipoMensaje.MsgInformacion) + RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarTiposOS"), "jsHideModalTiposOS") + + UpGral.Update() + Alert("Tipo de Orden de Servicio Actualizado Correctamente", TipoMensaje.MsgInformacion) + Else + Alert("Ocurrio un error al Actualizar el Tipo de Orden de Servicio", TipoMensaje.MsgError) + End If End If + + CveOrdenServicioTipo = -1 + Actualizar = False + ObjTipoOrdenServicios.Dispose() - If ViewState("Orden").ToString() <> String.Empty Then - CargaGrid(ViewState("Orden").ToString()) - Else - CargaGrid("") - End If End Sub - Protected Sub GvDatos_RowEditing(sender As Object, e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GvDatos.RowEditing - GvDatos.EditIndex = e.NewEditIndex - If ViewState("Orden").ToString() <> String.Empty Then - CargaGrid(ViewState("Orden").ToString()) + Public Sub Remove_ClickTiposOS(sender As Object, e As EventArgs) + + Dim ObjTipoOrdenServicios As New ClsOS + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + Dim activo As Boolean = False + CveOrdenServicioTipo = GvRow.DataKey("CveOrdenServicioTipo").ToEntero + + If ObjTipoOrdenServicios.RemoveTipoOrdenServicio(CveOrdenServicioTipo) Then + CargadatosGvTiposOS() + 'GeneraGlobalDT() + + Alert("El Tipo de Orden de Servicio se eliminó Correctamente ", TipoMensaje.MsgInformacion) Else - CargaGrid("") + Alert("Ocurrio un error al Eliminar el Tipo de Orden de Servicio", TipoMensaje.MsgError) End If - End Sub -#End Region -#Region "O R D E N A M I E N T O" - Protected Sub LbOrden_Click(ByVal sender As Object, ByVal e As EventArgs) - Dim Orden As String = "" - Dim Campo As String = "" - Dim Literal As Literal = Nothing - Const OrdenInicial As String = "" - Dim Arg(2) As String + ObjTipoOrdenServicios.Dispose() - Arg = CType(sender, LinkButton).CommandArgument().ToString.Split(";"c) - Campo = Arg(0) - Literal = CType(CType(sender, LinkButton).NamingContainer.FindControl("Img" & Campo.Replace(",", "_")), Literal) + CargadatosGvTiposOS() + + CveOrdenServicioTipo = -1 - If ViewState(String.Format("O{0}", Campo)) IsNot Nothing AndAlso ViewState(String.Format("O{0}", Campo)).ToString = String.Format("{0} DESC", Campo) Then - ViewState(String.Format("O{0}", Campo)) = String.Format("{0} ASC", Campo) - Literal.Text = String.Format("") - Else - ViewState(String.Format("O{0}", Campo)) = String.Format("{0} DESC", Campo) - Literal.Text = String.Format("") - End If - Orden = OrdenInicial & ViewState(String.Format("O{0}", Campo)).ToString - ViewState("Orden") = Orden - CargaGrid(Orden) End Sub - Private Sub CargaGrid(Orden As String) - If Orden <> String.Empty Then - Dim DV As New DataView(CType(ViewState("DTTipoOrdenServicios"), DataTable), "", Orden, DataViewRowState.CurrentRows) - GvDatos.DataSource = DV.ToTable() - DV.Dispose() - Else - GvDatos.DataSource = CType(ViewState("DTTipoOrdenServicios"), DataTable) - End If - GvDatos.DataBind() - UpDatos.Update() + Public Sub Edit_ClickTiposOS(sender As Object, e As EventArgs) + + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + Dim activo As Boolean = False + + LtlTituloModalTiposOS.Text = "Editar Tipo de Orden de Servicio" + Actualizar = True + DivEstatus.Visible = True + + CveOrdenServicioTipo = GvRow.DataKey("CveOrdenServicioTipo").ToEntero + + TxtTiposOS.Text = GvRow.DataKey("OrdenServicioTipo") + ChkEstatus.Checked = If(GvRow.DataKey("Estatus") = "Activo", True, False) + + BtnAgregarTiposOSModal.Text = "Actualizar" + + UpModalTiposOS.Update() + + RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarTiposOS")) + End Sub -#End Region -End Class + +End Class \ No newline at end of file diff --git a/OS/OrdenesServicios.aspx b/OS/OrdenesServicios.aspx index 850f62121..610f5a755 100644 --- a/OS/OrdenesServicios.aspx +++ b/OS/OrdenesServicios.aspx @@ -86,7 +86,7 @@
    -
    +
    Fecha Recibido:
    @@ -106,7 +106,7 @@
    - +
    Sucursal del Cliente: @@ -152,6 +152,8 @@
    + +
    diff --git a/Ventas/RepVentasUtilidad.aspx b/Ventas/RepVentasUtilidad.aspx index 5c58d537d..adf3f6615 100644 --- a/Ventas/RepVentasUtilidad.aspx +++ b/Ventas/RepVentasUtilidad.aspx @@ -87,10 +87,10 @@
  • - Generar PDF + PDF
  • - Generar Excel + Excel
  • @@ -164,9 +164,8 @@ Cliente:
    - - - + +
    @@ -232,8 +231,8 @@
    - - + +
    VentaCostoVentaCosto Utilidad/Pérdida
    @@ -250,6 +249,9 @@ + + + diff --git a/Ventas/RepVentasUtilidad.aspx.vb b/Ventas/RepVentasUtilidad.aspx.vb index 706a1bd43..9b9a2dabf 100644 --- a/Ventas/RepVentasUtilidad.aspx.vb +++ b/Ventas/RepVentasUtilidad.aspx.vb @@ -38,8 +38,15 @@ Partial Class Ventas_RepVentasUtilidad txtFechaF.Text = Now.LastDayOfMonth.ToShortDateString 'Carga Clientes - DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa) - DdlClientes.DataBind() + Dim EsWS = If(UsuarioActual.Empresa.Funcionalidad(105) = "1" Or UsuarioActual.Empresa.Funcionalidad(141) = "1", True, False) + If EsWS Then + DdlClientes.setEsWebService(True) + Else + DdlClientes.setEsWebService(False) + DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa, -1) + DdlClientes.DataBind() + DdlClientes.ddl.Items.Insert(0, New ListItem("Todos", "-1")) + End If 'CargaSubProyectos DdlSubProyecto.DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa) @@ -84,7 +91,10 @@ Partial Class Ventas_RepVentasUtilidad DdlSubProyecto.SelectedValuesIfExistM(CveSubProyecto) DdlVendedor.SelectedValuesIfExistM(CveVendedor) - DdlClientes.SelectedValueExist(CveCliente) + If CveCliente <> "-1" Then + DdlClientes.SelectedValue = CveCliente + DdlClientes.SelectedText = GlobalDTCliente(UsuarioActual.CveEmpresa).FiltraParametros($"CveCliente = {CveCliente}").FiltroPrimeroValor("Nombre") + End If DdlClasificacion.SelectedValueExist(CveClasificacion) DdlPS.SelectedValue = CvePS If CvePS.ToEntero > 0 AndAlso GlobalDTPS(UsuarioActual.CveEmpresa, CvePS.ToEntero).Rows.Count > 0 Then @@ -184,17 +194,25 @@ Partial Class Ventas_RepVentasUtilidad End If + + If e.Row.DBCampo("CveVenta") = "" Then + e.Row.Cells(6).Text = "" + e.Row.Cells(7).Text = "" + e.Row.Cells(8).Text = "" + e.Row.Cells(10).Text = "" + End If + If e.Row.DBCampo("CveMovimiento") = "" Then - e.Row.Cells(3).Text = "" + e.Row.Cells(7).Text = "" + e.Row.Cells(8).Text = "" + e.Row.Cells(10).Text = "" End If If e.Row.DBCampo("CveVenta") = "" Then e.Row.CssClass = "Totales" End If - If e.Row.DBCampo("CveVenta") = "" Then - e.Row.Cells(7).Text = "" - End If + Dim Liga As String = String.Format("/Ventas/RepVentasUtilidadDetalle.aspx?CveVenta={0}&CveVendedor={1}&FechaI={2:d}&FechaF={3:d}&CveCliente={4}&Orden={5}&CveSubProyecto={6}&CvePS={7}&CveClasificacion={8}", @@ -249,7 +267,7 @@ Partial Class Ventas_RepVentasUtilidad If txtFechaI.Text = "" Then FechaI = MinFecha If txtFechaF.Text = "" Then FechaF = MaxFecha - Dim Cliente = If(DdlClientes.SelectedValue = "", "", $" Cliente: {DdlClientes.SelectedItem.Text}") + Dim Cliente = If(DdlClientes.SelectedValue = "", "", $" Cliente: {DdlClientes.SelectedText}") Dim Sucursal = If(DdlSubProyecto.GetSelectedText = "", "", $" Sucursal: {DdlSubProyecto.GetSelectedText}") Dim Vendedor = If(DdlVendedor.GetSelectedText = "", "", $" Vendedor: {DdlVendedor.GetSelectedText}") Dim PS = If(DdlPS.SelectedValue = "-1", "", $" P.S.: {DdlPS.SelectedText}") @@ -305,7 +323,7 @@ Partial Class Ventas_RepVentasUtilidad Dim Sucursal = If(DdlSubProyecto.GetSelectedText = "", "", $" Sucursal: {DdlSubProyecto.GetSelectedText}") Dim FechaIn As String = $" Fecha Inicio: {txtFechaI.Text}" Dim FechaFn As String = $" Fecha Fin: {txtFechaF.Text}" - Dim Cliente = If(DdlClientes.SelectedValue = "-1", "", $" Cliente: {DdlClientes.SelectedItem.Text}") + Dim Cliente = If(DdlClientes.SelectedValue = "-1", "", $" Cliente: {DdlClientes.SelectedText}") Dim Vendedor = If(DdlVendedor.GetSelectedText = "", "", $" Vendedor: {DdlVendedor.GetSelectedText}") Dim PS = If(DdlPS.SelectedValue = "-1", "", $" P.S.: {DdlPS.SelectedText}") Dim Clasificacion = If(DdlClasificacion.SelectedValue = "-1", "", $" Clasificacion: {DdlClasificacion.SelectedItem.Text}") diff --git a/Ventas/RepVentasUtilidadPadre.aspx b/Ventas/RepVentasUtilidadPadre.aspx index ce2769774..290095da5 100644 --- a/Ventas/RepVentasUtilidadPadre.aspx +++ b/Ventas/RepVentasUtilidadPadre.aspx @@ -139,9 +139,7 @@ Cliente:
    - - - +
    Vendedor: diff --git a/Ventas/RepVentasUtilidadPadre.aspx.vb b/Ventas/RepVentasUtilidadPadre.aspx.vb index 2cecd644f..83458643a 100644 --- a/Ventas/RepVentasUtilidadPadre.aspx.vb +++ b/Ventas/RepVentasUtilidadPadre.aspx.vb @@ -44,8 +44,14 @@ Partial Class Ventas_RepVentasUtilidadPadre txtFechaF.Text = Now.LastDayOfMonth.ToShortDateString 'Carga Clientes - DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa) - DdlClientes.DataBind() + If UsuarioActual.CveEmpresa = 119 Then + DdlClientesWS.setEsWebService(True) + Else + DdlClientesWS.setEsWebService(False) + DdlClientesWS.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa, -1) + DdlClientesWS.DataBind() + DdlClientesWS.ddl.Items.Insert(0, New ListItem("Todos", "-1")) + End If 'CargaSubProyectos DdlSubProyecto.DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa) @@ -100,7 +106,7 @@ Partial Class Ventas_RepVentasUtilidadPadre Private Sub CargaDatos() Dim ObjVentas As New ClsVentas - If ObjVentas.GetReportePadreVentasUtilidad(If(DdlVendedor.GetSelectedValuesM = "", "-1", DdlVendedor.GetSelectedValuesM), DdlClientes.SelectedValue.ToEntero, + If ObjVentas.GetReportePadreVentasUtilidad(If(DdlVendedor.GetSelectedValuesM = "", "-1", DdlVendedor.GetSelectedValuesM), DdlClientesWS.SelectedValue.ToEntero, If(DdlSubProyecto.GetSelectedValuesM = "", "-1", DdlSubProyecto.GetSelectedValuesM), txtFechaI.Text.ToDate, txtFechaF.Text.ToDate, UsuarioActual.CveEmpresa, DdlGrupo.SelectedValue.ToEntero, DdlPS.SelectedValue.ToEntero, DdlClasificacion.SelectedValue.ToEntero) Then GvDatos.DataSource = ObjVentas.DtResultados @@ -211,10 +217,10 @@ Partial Class Ventas_RepVentasUtilidadPadre If txtFechaI.Text <> "" Then StrFiltro.AppendFormat(" Fecha Inicio : {0}", txtFechaI.Text.ToDate.ToShortDateString) If txtFechaF.Text <> "" Then StrFiltro.AppendFormat(" Fecha Fin : {0}", txtFechaF.Text.ToDate.ToShortDateString) If DdlSubProyecto.GetSelectedText <> "" Then StrFiltro.AppendFormat(" SubProyecto: {0}", DdlSubProyecto.GetSelectedText) - If DdlClientes.SelectedValue <> "-1" Then StrFiltro.AppendFormat(" Cliente: {0}", DdlClientes.SelectedItem.Text) + If DdlClientesWS.SelectedValue <> "-1" Then StrFiltro.AppendFormat(" Cliente: {0}", DdlClientesWS.SelectedText) If DdlPS.SelectedValue <> "-1" Then StrFiltro.AppendFormat(" P.S.: {0}", DdlPS.SelectedText) If DdlClasificacion.SelectedValue <> "-1" Then StrFiltro.AppendFormat(" Clasificación: {0}", DdlClasificacion.SelectedItem.Text) - If DdlClientes.SelectedValue <> "-1" Then StrFiltro.AppendFormat(" Cliente: {0}", DdlClientes.SelectedItem.Text) + If DdlClientesWS.SelectedValue <> "-1" Then StrFiltro.AppendFormat(" Cliente: {0}", DdlClientesWS.SelectedText) If DdlVendedor.GetSelectedText <> "" Then StrFiltro.AppendFormat(" Vendedor: {0}", DdlVendedor.GetSelectedText) Dim params As List(Of ReportParameter) = New List(Of ReportParameter)() Dim Imagen As System.IO.FileInfo = New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta)) diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx index a10e3267b..83040ea12 100644 --- a/Ventas/Ventas.aspx +++ b/Ventas/Ventas.aspx @@ -1,7004 +1,7004 @@ -<%@ Page Title="Ventas - Facturación" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="Ventas.aspx.vb" Inherits="Ventas" EnableEventValidation="false" %> - -<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> -<%--Necesario para el modal que no se cierra--%> - - - - - - - - - - -
  • - Agregar Concepto -
  • -
  • - -
  • -
  • - Descargar XML -
  • -
  • - Imprimir PDF -
  • -
  • - Imprimir Acuse Cancelación -
  • -
  • - -
  • - - - <%--INICIA: CANCELAR - NC - DEVOLUCION [OLD]--%> - -
  • - -
  • - <%--
  • - -
  • --%> -
  • - -
  • -
  • - -
  • - <%--TERMINA: CANCELAR - NC - DEVOLUCION [OLD]--%> - - - <%--INICIA: CANCELAR - NC - DEVOLUCION [NEW]--%> -
  • - -
  • -
  • - -
  • - <%--TERMINA: CANCELAR - NC - DEVOLUCION [NEW]--%> - - -
  • - Generar Requisición -
  • -
  • - Genera O. S. -
  • -
  • - Autorizar Cotización -
  • - -
  • - Buscar Precio -
  • -
  • - Facturar Remision -
  • -
  • - Remisiones sin facturar -
  • -
  • - Pedidos sin facturar -
  • -
  • - Cotizaciones sin facturar -
  • - -
  • - Ordenes de Compra sin facturar -
  • -
  • - Estado de Caja -
  • - -
  • - Ingreso de Efectivo -
  • -
  • - Retiro de Efectivo -
  • - - -
  • - -
  • - - -
  • - Imprimir -
  • -
    - - - -
  • - -
  • - - - - <%--
  • - Descargar Formato -
  • --%> -
  • - Cargar Concepto -
  • -
  • - <%----%> - Saldar -
  • - - - -
  • - -
  • -
  • - -
  • - -
    - - - -
    - -
  • - Fletes -
  • - -
  • - Pagar -
  • -
  • - -
  • -
  • - -
  • -
  • - -
  • - -
  • - Asignar Cuenta de Terminal -
  • -
  • - Asignar Folio Fiscal -
  • -
  • - Imprimir Formato Cicovisa -
  • -
    - - - - - - <%-- --%> - -
    -
    - - - - - - - -
    - - -
    -
    - - - Cliente: - - - -
    -
    -
    -
    -
    - -
    - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Nombre:  - Enviar Mail: -
    Sucursal : - - -
    Dirección:  - Colonia: -
    Ciudad, Edo:  - , C.P.: -
    RFC:  - - - Teléfono: -
    Folio OP:  - - -  
    Enviar a otra dirección: - - - - - - - - - -
    -
    Atención A: - - Telefono: - - Vigencia: -
    - - - - - - - - - - -
    -
    -
    -
    -
    -
    - - - -
    -
    - - EMPRESA CRM -
    -
    - -
    -
    -
    -
    - - - - - - - - - - - - - - -
    Empresa:  -
    RFC:  -
    Medio de Captación::  -
    -
    -
    -
    -
    - - - -
    -
    - - DATOS DE EMISIÓN - -
    -
    -
    -
    -
    - -
    - -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <%----%> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Tipo: - - - - <%----%> - - -
    - - - - - - - - - - - - - -
    -
    Factura: - - - - -
    Sucursal: -
    Serie - Folio: - - - - - - - -
    Folio Fiscal: - -
    Refacturada en: - -
    Fecha: -
    - - - - - - - - - - -
    -
    Vendedor:  - - - - - - - -
    Crédito Disponible:  - - - - - -
    Limite Al:  - - - - - -
    - - - - - - -
    - - - - - - - - - -
    - - - - - - - -
    Anticipo Especial:  - - - - - -
    Sin existencia:  - - - - - -
    -
    -
    -
    - - - -
    -
    -
    - - Estatus: - -
    -
    -
    -
    -
    - -
    - -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Corte:  - -
    Saldo:  - <%--   --%> - - -
    Estatus:  - - <%-- - - -
    Contabilizada: - - - <%-- --%> - <%----%> -
    Se timbró:  -
    Envió Mail:  -
    Usuario creó:  -
    Fecha registró:  -
    - -
    -
    -
    - -
    -
    -
    - - - - - - - - - - - - - - - -
    - Presupuesto de Ingreso: - - - - - - -
    -
    -
    - -
    - -
    - - -
    - - <%----%> - - <%--width="100%"--%> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <%----%> - - - -
    #CantUnidad -
    - Clasificación
    - Producto o Servicio - -
    -
    - Código de Barras
    -
    - -
    ObservaciónTiempo
    - Entrega -
    Cantidad
    - Facturada
    Cantidad
    - Facturada
    -
    -
    P.U. Desc - Predial - IVA - IEPS - Poliza - Total Comandos
    -   - - - - - - - - <%-- --%> - - - - - - -
    - - - - <%----%> - - - - - - - - - - - - - - - - -
    - - - <%----%> - <%----%> -
    -
    -
    - -
    - Barras -
    Serie  
    - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -

    - -

    -
    -
    - -
    - <%--
    --%> - - - - <%--0--%> - - -   - - - <%--1--%> - - - - - - - - - - - - - - - - <%--2--%> - - - - - - - - - - - - - <%--3--%> - - - - - -
    - -
    - - - - - - - <%----%> - <%----%> - -
    - <%--4--%> - - - - - - - - - <%--5--%> - - - - - - - - - <%--6--%> - - - - - - <%--7 POR SI SE EMPIEZAN A METER MUCHOS SIMILARES SE PUSO PARA TODOS - MANEJO EN EL GvPS_RowDataBound--%> - - - - - - <%--8--%> - - - - - - - - - - - - - - <%--9--%> - - - - - - - - - - - - - - - <%--10--%> - - - - - - - - - - - - - - <%--11--%> - - - - - - - - - <%--12--%> - - -
    - -
    -
    - <%----%> - <%--13--%> - - -
    - -
    -
    - <%----%> - <%--14--%> - - <%--15--%> - - <%--16--%> - - - - - - <%--17--%> - - -
    - -   - -
    -
    - - - - -
    - <%--18--%> - - - - - - <%--19--%> - - - - - - <%--20--%> - - - - - - - - - <%--21--%> - - - - - -
    - - - -
    -
    - -
    - -
    -
    - - -
    - - - - Factura - - - - - - -
    -
    -
    - - - - -
    - - - - - Factura - - - - - - - - - - - - - - Factura - - - - - - - - - - -
    -
    -
    - - -
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <%----%> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    SubTotal: -   - -
    - -   - - <%----%>
    Amort. Ant.: -   -
    SubTotal 2: - -
    IVA: - - 8% - 16% - 0% - -
    - - - - - - - - - - - - - - - - - - - IEPS: -
    - - - - - - - - - - - - - - -
    Total: - - - - - - - - - - - - - Moneda: - -
    - - Conv. Pesos: - T.C.: - - - - -
    - - Conv. Dlls: - T.C.: - - - -
    -
    -
    - - -
    -
    -
    - -
    -
    - - - - - <%-- - -
    -
    -
    -
    -
    - Devolución Almacén -
    -
    - -
    -
    -
    -
    -
    - Requiere Devolución: -
    -
    - - - - -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    -
    -
    --%> - - - -
    -
    -
    - Salida Almacen -
    -
    - -
    -
    -
    -
    - -
    -
    -
    - Almacén: - -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - Producto - - - - - - - - - - - - - - -
    -
    -
    -
    -
    -
    -
    - - - - -
    -
    -
    - Entrada Almacen -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - Producto o Servicio - - - - - - P.U. - - - - - <%-- - Total - - - - --%> - - - -
    -
    - -
    -
    -
    - -
    -
    - - - - - -
    -
    -
    -
    - - Generales - -
    -
    -
    -
    -
    - -
    - -
    -
    -
    -
    - - - - - - - - - - - - - - - - <%-- - - - --%> - - -
    Fecha Ejecución: -
    - - - - -
    - - - - - - -   -
    Sucursal de Ejecución:  - - -
    Sucursal Cobranza:  - - -
    Entrega:  - -
    Vendedor:  - - - -
    -
    -
    -
    - - - -
    -
    -
    - - Conceptos Definidos - -
    -
    -
    -
    -
    - -
    - -
    -
    -
    -
    -
    - Conceptos -
    - - - - - -
    Descripción: -
    - - - - - -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - -
    - - -
    -
    - - -
    -
    -
    -
    -
    -
    -
    - Firmas -
    - - - - - - - - - - - - - - - - - - - -
    Titulo: -
    - - - - - -
    -
    Nombre: -
    - - - - -
    -
    Puesto: -
    - - -
    -
    Posición: - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - -
    -
    - - -
    -
    - -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    -
    -
    - - - - - - - - - - - -
    - -
    -
    -
    - - FEMSA - -
    -
    -
    -
    -
    - -
    - -
    -
    - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Versión:  -
    - -
    - <%--Validar--%> -
    Número de Sociedad:  -
    - -
    -
    Número de Proveedor:  -
    - -
    -
    Número de Pedido:  -
    - -
    -
    Número de Entrada:  -
    - -
    - <%--Validar Numerico--%> -
    Número de Remisión:  -
    - -
    -
    Número de Socio:  -
    - -
    -
    Centro de Costo:  -
    - -
    -
    Inicio Periodo Liquidación:  -
    - -
    -
    Fin Periodo Liquidación:  -
    - -
    -
    Código Retención 1:  -
    - -
    -
    Código Retención 2:  -
    - -
    -
    Mail:  -
    - -
    -
    -
    -
    -
    -
    - -
    -
    -
    - - Detallista - -
    -
    -
    -
    -
    - -
    - -
    -
    - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Orden de Compra:  -
    - -
    -
    Fecha de Orden de Compra:  -
    - - - - - - - - - -
    -
    Contra Recibo:  -
    - -
    -
    GLN-Comprador:  -
    - -
    -
    Departamento:  -
    - -
    -
    GLN-Vendedor:  -
    - -
    -
    Número de Proveedor:  -
    - -
    -
    -
    -
    -
    -
    - -
    -
    -
    - - 7Eleven - -
    -
    -
    -
    -
    - -
    - -
    -
    - -
    -
    - - - - - - - - - - - - - - - - - -
    Proveedor:  -
    - -
    -
    Folio:  -
    - -
    -
    Tienda:  -
    - -
    - <%----%> -
    Fecha:  - -
    - - - - - - - - -
    -
    -
    -
    -
    -
    -
    -
    - - FORD - -
    -
    -
    -
    -
    - -
    - -
    -
    -
    -
    - - - - - - - - - - - - - -
    GSDB:   -
    - -
    -
    ASN :   -
    - -
    -   - - -
    - - -
    -
    -
    -
    -
    -
    -
    -
    - - COMERCIO EXTERIOR -
    -
    -
    -
    -
    - -
    - -
    -
    -
    - - -
    -
    - -
    - - <%----%> -
    - -
    - - <%----%> -
    -
    -
    - -
    - - -
    -
    -
    - -
    - -
    - -
    - -
    - <%-- -
    -
    --%> -
    -
    -
    - - -
    - -
    Nombre:
    - -
    - -
    - -
    -
    - -
    Calle:
    - -
    - -
    -
    Núm.
    -
    - -
    -
    CP.
    -
    - -
    -
    -
    -
    Pais:
    - -
    - - -
    - - -
    Estado:
    - -
    - - -
    - -
    -
    -
    Municipio:
    - -
    - - -
    - -
    Colonia:
    - -
    - - -
    - -
    - -
    - -
    - -
    -
    -
    -
    -
    - Convertir a unidad Aduana - - - - - - - - - - - - - - - - - <%-- - - - - - - - - - --%> - - - - - - - - - - - - -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - - - - - - - - - -
    -
    -
    - Venta de Activos Fijos - - - - -
    -
    -
    -
    -
    -
    -
    -
    - - - - - - - -
    - Contrato: - - - - - - - - - - - - Contrato/Partida/Productos y Servicios - - - - - - - - Importe ($) - - - - - - - - - - - -
    - -
    - -
    -
    -
    -
    - -
    -
    - -
    -
    - Saldo: $ -
    -
    -
    -
    - Tipo: -
    -
    - - - - <%----%> - -
    -
    - Total: $ - Mínimo: $ - Máximo: $ -
    -
    -
    -
    - -
    -
    - " style="display: inline-block; margin-right: -20px; width: 150px;" /> - " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> -
    -
    - - - - - OC Cliente - - - - - - Cant. Disp. - - - - - - Unidad - - - - - - Clave Interna - - - - - - Producto o Servicio - - - - - - - P.U. - - - - - - - Cant - - - - - - - - - - - - Total - - - - - - - - - - - - - -
    -
    -
    - - -
    -
    - -
    -
    - -
    -
    -
    -
    -
    - -
    - -
    -
    -
    - - - -
    -
    - - Condiciones de Pago -
    -
    -
    -
    -
    -
    - -
    -
    -
    - - - - - - -
    -
    - - - -
    -
    - - - - - - - - - - - - - - - - - <%-- - - - --%> - - - - - - - - - - - - - -
    Forma de entrega: - - - -
    Uso CFDI: - - - - - - -
    Método de Pago: - - - - - -
    Forma de Pago: - - - - - - -
    Tipo Relación - - - -
    -
    -
    Num. Cta. Pago: - -
    Fecha de Pago: -
    - - - - - - - - - - -
    -
    - -
    - -
    -
    - - Crédito - Contado - Terminal - -
    -
    - - <%-- ******************** Punto de Venta *****************************************************************************************************************************--%> - - - -
    - - -
    -
    -
    -
    - -
    - $ - - -
    -
    - - - -
    -
    -
    - -
    -
    - -
    - $ - - -
    -
    - - - -
    -
    -
    -
    -
    - -
    - $ - - -
    -
    - - - -
    -
    -
    -
    -
    - -
    - $ - - -
    -
    - - - -
    -
    -
    -
    -
    - -
    - $ - - -
    -
    - - - -
    -
    -
    -
    -
    -
    -
    - -
    - $ - - - - - - -

    -
    -
    -
    -
    -
    - -
    - -
    -
    - -
    -
    - -
    - -
    -
    - - - - - - - - - - - - - - -
    -
    -
    -
    - -
    -
    - - <%-- **************************************************************************************************************************************************************** --%> - - <%-- Terminal --%> - - -
    -
    - - <%----%> - -
    -
    -
    -
    - <%-- --%> - -
    Tipo Relación: -
    -
    -
    -
    -
    -
    - - -
    - - -
    -
    - - Observaciones -
    -
    -
    -
    -
    -
    - -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - -
    Observaciones Generales: 
    -
    Orden de Compra:   - - - -
    Pedido:   -
    Observaciones Almacén: 
    -
    -
    -
    -
    -
    - -
    - - - - - - -
    -
    - - Acciones -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    - -
    - - - - - - - - - - - -
    - -
    - -
    - - -
    - - -
    - - - - - - - - - - - - - - - - - -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - <%-- ******************************************** Corte de Caja *************************************************************************************************************************************** --%> - -
    - - - - +<%@ Page Title="Ventas - Facturación" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="Ventas.aspx.vb" Inherits="Ventas" EnableEventValidation="false" %> + +<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> +<%--Necesario para el modal que no se cierra--%> + + + + + + + + + + +
  • + Agregar Concepto +
  • +
  • + +
  • +
  • + Descargar XML +
  • +
  • + Imprimir PDF +
  • +
  • + Imprimir Acuse Cancelación +
  • +
  • + +
  • + + + <%--INICIA: CANCELAR - NC - DEVOLUCION [OLD]--%> + +
  • + +
  • + <%--
  • + +
  • --%> +
  • + +
  • +
  • + +
  • + <%--TERMINA: CANCELAR - NC - DEVOLUCION [OLD]--%> + + + <%--INICIA: CANCELAR - NC - DEVOLUCION [NEW]--%> +
  • + +
  • +
  • + +
  • + <%--TERMINA: CANCELAR - NC - DEVOLUCION [NEW]--%> + + +
  • + Generar Requisición +
  • +
  • + Genera O. S. +
  • +
  • + Autorizar Cotización +
  • + +
  • + Buscar Precio +
  • +
  • + Facturar Remision +
  • +
  • + Remisiones sin facturar +
  • +
  • + Pedidos sin facturar +
  • +
  • + Cotizaciones sin facturar +
  • + +
  • + Ordenes de Compra sin facturar +
  • +
  • + Estado de Caja +
  • + +
  • + Ingreso de Efectivo +
  • +
  • + Retiro de Efectivo +
  • + + +
  • + +
  • + + +
  • + Imprimir +
  • +
    + + + +
  • + +
  • + + + + <%--
  • + Descargar Formato +
  • --%> +
  • + Cargar Concepto +
  • +
  • + <%----%> + Saldar +
  • + + + +
  • + +
  • +
  • + +
  • + +
    + + + +
    + +
  • + Fletes +
  • + +
  • + Pagar +
  • +
  • + +
  • +
  • + +
  • +
  • + +
  • + +
  • + Asignar Cuenta de Terminal +
  • +
  • + Asignar Folio Fiscal +
  • +
  • + Imprimir Formato Cicovisa +
  • +
    + + + + + + <%-- --%> + +
    +
    + + + + + + + +
    + + +
    +
    + + + Cliente: + + + +
    +
    +
    +
    +
    + +
    + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Nombre:  + Enviar Mail: +
    Sucursal : + + +
    Dirección:  + Colonia: +
    Ciudad, Edo:  + , C.P.: +
    RFC:  + + + Teléfono: +
    Folio OP:  + + +  
    Enviar a otra dirección: + + + + + + + + + +
    +
    Atención A: + + Telefono: + + Vigencia: +
    + + + + + + + + + + +
    +
    +
    +
    +
    +
    + + + +
    +
    + + EMPRESA CRM +
    +
    + +
    +
    +
    +
    + + + + + + + + + + + + + + +
    Empresa:  +
    RFC:  +
    Medio de Captación::  +
    +
    +
    +
    +
    + + + +
    +
    + + DATOS DE EMISIÓN + +
    +
    +
    +
    +
    + +
    + +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%----%> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Tipo: + + + + <%----%> + + +
    + + + + + + + + + + + + + +
    +
    Factura: + + + + +
    Sucursal: +
    Serie - Folio: + - + + + + + +
    Folio Fiscal: + +
    Refacturada en: + +
    Fecha: +
    + + + + + + + + + + +
    +
    Vendedor:  + + + + + + + +
    Crédito Disponible:  + + + + + +
    Limite Al:  + + + + + +
    + + + + + + +
    + + + + + + + + + +
    + + + + + + + +
    Anticipo Especial:  + + + + + +
    Sin existencia:  + + + + + +
    +
    +
    +
    + + + +
    +
    +
    + + Estatus: + +
    +
    +
    +
    +
    + +
    + +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Corte:  + +
    Saldo:  + <%--   --%> + + +
    Estatus:  + + <%-- + + +
    Contabilizada: + + + <%-- --%> + <%----%> +
    Se timbró:  +
    Envió Mail:  +
    Usuario creó:  +
    Fecha registró:  +
    + +
    +
    +
    + +
    +
    +
    + + + + + + + + + + + + + + + +
    + Presupuesto de Ingreso: + + + + + + +
    +
    +
    + +
    + +
    + + +
    + + <%----%> + + <%--width="100%"--%> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%----%> + + + +
    #CantUnidad +
    + Clasificación
    + Producto o Servicio + +
    +
    + Código de Barras
    +
    + +
    ObservaciónTiempo
    + Entrega +
    Cantidad
    + Facturada
    Cantidad
    + Facturada
    +
    +
    P.U. Desc + Predial + IVA + IEPS + Poliza + Total Comandos
    +   + + + + + + + + <%-- --%> + + + + + + +
    + + + + <%----%> + + + + + + + + + + + + + + + + +
    + + + <%----%> + <%----%> +
    +
    +
    + +
    + Barras +
    Serie  
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +

    + +

    +
    +
    + +
    + <%--
    --%> + + + + <%--0--%> + + +   + + + <%--1--%> + + + + + + + + + + + + + + + + <%--2--%> + + + + + + + + + + + + + <%--3--%> + + + + + +
    + +
    + + + + + + + <%----%> + <%----%> + +
    + <%--4--%> + + + + + + + + + <%--5--%> + + + + + + + + + <%--6--%> + + + + + + <%--7 POR SI SE EMPIEZAN A METER MUCHOS SIMILARES SE PUSO PARA TODOS - MANEJO EN EL GvPS_RowDataBound--%> + + + + + + <%--8--%> + + + + + + + + + + + + + + <%--9--%> + + + + + + + + + + + + + + + <%--10--%> + + + + + + + + + + + + + + <%--11--%> + + + + + + + + + <%--12--%> + + +
    + +
    +
    + <%----%> + <%--13--%> + + +
    + +
    +
    + <%----%> + <%--14--%> + + <%--15--%> + + <%--16--%> + + + + + + <%--17--%> + + +
    + +   + +
    +
    + + + + +
    + <%--18--%> + + + + + + <%--19--%> + + + + + + <%--20--%> + + + + + + + + + <%--21--%> + + + + + +
    + + + +
    +
    + +
    + +
    +
    + + +
    + + + + Factura + + + + + + +
    +
    +
    + + + + +
    + + + + + Factura + + + + + + + + + + + + + + Factura + + + + + + + + + + +
    +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%----%> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    SubTotal: +   + +
    + +   + + <%----%>
    Amort. Ant.: +   +
    SubTotal 2: + +
    IVA: + + 8% + 16% + 0% + +
    + + + + + + + + + + + + + + + + + + + IEPS: +
    + + + + + + + + + + + + + + +
    Total: + + + + + + + + + + + + + Moneda: + +
    + + Conv. Pesos: + T.C.: + + + + +
    + + Conv. Dlls: + T.C.: + + + +
    +
    +
    + + +
    +
    +
    + +
    +
    + + + + + <%-- + +
    +
    +
    +
    +
    + Devolución Almacén +
    +
    + +
    +
    +
    +
    +
    + Requiere Devolución: +
    +
    + + + + +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    +
    +
    --%> + + + +
    +
    +
    + Salida Almacen +
    +
    + +
    +
    +
    +
    + +
    +
    +
    + Almacén: + +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + Producto + + + + + + + + + + + + + + +
    +
    +
    +
    +
    +
    +
    + + + + +
    +
    +
    + Entrada Almacen +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + Producto o Servicio + + + + + + P.U. + + + + + <%-- + Total + + + + --%> + + + +
    +
    + +
    +
    +
    + +
    +
    + + + + + +
    +
    +
    +
    + + Generales + +
    +
    +
    +
    +
    + +
    + +
    +
    +
    +
    + + + + + + + + + + + + + + + + <%-- + + + --%> + + +
    Fecha Ejecución: +
    + + + + +
    + + + + + + +   +
    Sucursal de Ejecución:  + + +
    Sucursal Cobranza:  + + +
    Entrega:  + +
    Vendedor:  + + + +
    +
    +
    +
    + + + +
    +
    +
    + + Conceptos Definidos + +
    +
    +
    +
    +
    + +
    + +
    +
    +
    +
    +
    + Conceptos +
    + + + + + +
    Descripción: +
    + + + + + +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    + + +
    +
    + + +
    +
    +
    +
    +
    +
    +
    + Firmas +
    + + + + + + + + + + + + + + + + + + + +
    Titulo: +
    + + + + + +
    +
    Nombre: +
    + + + + +
    +
    Puesto: +
    + + +
    +
    Posición: + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + +
    +
    + + +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + + +
    + +
    +
    +
    + + FEMSA + +
    +
    +
    +
    +
    + +
    + +
    +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Versión:  +
    + +
    + <%--Validar--%> +
    Número de Sociedad:  +
    + +
    +
    Número de Proveedor:  +
    + +
    +
    Número de Pedido:  +
    + +
    +
    Número de Entrada:  +
    + +
    + <%--Validar Numerico--%> +
    Número de Remisión:  +
    + +
    +
    Número de Socio:  +
    + +
    +
    Centro de Costo:  +
    + +
    +
    Inicio Periodo Liquidación:  +
    + +
    +
    Fin Periodo Liquidación:  +
    + +
    +
    Código Retención 1:  +
    + +
    +
    Código Retención 2:  +
    + +
    +
    Mail:  +
    + +
    +
    +
    +
    +
    +
    + +
    +
    +
    + + Detallista + +
    +
    +
    +
    +
    + +
    + +
    +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Orden de Compra:  +
    + +
    +
    Fecha de Orden de Compra:  +
    + + + + + + + + + +
    +
    Contra Recibo:  +
    + +
    +
    GLN-Comprador:  +
    + +
    +
    Departamento:  +
    + +
    +
    GLN-Vendedor:  +
    + +
    +
    Número de Proveedor:  +
    + +
    +
    +
    +
    +
    +
    + +
    +
    +
    + + 7Eleven + +
    +
    +
    +
    +
    + +
    + +
    +
    + +
    +
    + + + + + + + + + + + + + + + + + +
    Proveedor:  +
    + +
    +
    Folio:  +
    + +
    +
    Tienda:  +
    + +
    + <%----%> +
    Fecha:  + +
    + + + + + + + + +
    +
    +
    +
    +
    +
    +
    +
    + + FORD + +
    +
    +
    +
    +
    + +
    + +
    +
    +
    +
    + + + + + + + + + + + + + +
    GSDB:   +
    + +
    +
    ASN :   +
    + +
    +   + + +
    + + +
    +
    +
    +
    +
    +
    +
    +
    + + COMERCIO EXTERIOR +
    +
    +
    +
    +
    + +
    + +
    +
    +
    + + +
    +
    + +
    + + <%----%> +
    + +
    + + <%----%> +
    +
    +
    + +
    + + +
    +
    +
    + +
    + +
    + +
    + +
    + <%-- +
    +
    --%> +
    +
    +
    + + +
    + +
    Nombre:
    + +
    + +
    + +
    +
    + +
    Calle:
    + +
    + +
    +
    Núm.
    +
    + +
    +
    CP.
    +
    + +
    +
    +
    +
    Pais:
    + +
    + + +
    + + +
    Estado:
    + +
    + + +
    + +
    +
    +
    Municipio:
    + +
    + + +
    + +
    Colonia:
    + +
    + + +
    + +
    + +
    + +
    + +
    +
    +
    +
    +
    + Convertir a unidad Aduana + + + + + + + + + + + + + + + + + <%-- + + + + + + + + + --%> + + + + + + + + + + + + +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + +
    +
    +
    + Venta de Activos Fijos + + + + +
    +
    +
    +
    +
    +
    +
    +
    + + + + + + + +
    + Contrato: + + + + + + + + + + + + Contrato/Partida/Productos y Servicios + + + + + + + + Importe ($) + + + + + + + + + + + +
    + +
    + +
    +
    +
    +
    + +
    +
    + +
    +
    + Saldo: $ +
    +
    +
    +
    + Tipo: +
    +
    + + + + <%----%> + +
    +
    + Total: $ + Mínimo: $ + Máximo: $ +
    +
    +
    +
    + +
    +
    + " style="display: inline-block; margin-right: -20px; width: 150px;" /> + " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> +
    +
    + + + + + OC Cliente + + + + + + Cant. Disp. + + + + + + Unidad + + + + + + Clave Interna + + + + + + Producto o Servicio + + + + + + + P.U. + + + + + + + Cant + + + + + + + + + + + + Total + + + + + + + + + + + + + +
    +
    +
    + + +
    +
    + +
    +
    + +
    +
    +
    +
    +
    + +
    + +
    +
    +
    + + + +
    +
    + + Condiciones de Pago +
    +
    +
    +
    +
    +
    + +
    +
    +
    + + + + + + +
    +
    + + + +
    +
    + + + + + + + + + + + + + + + + + <%-- + + + --%> + + + + + + + + + + + + + +
    Forma de entrega: + + + +
    Uso CFDI: + + + + + + +
    Método de Pago: + + + + + +
    Forma de Pago: + + + + + + +
    Tipo Relación + + + +
    +
    +
    Num. Cta. Pago: + +
    Fecha de Pago: +
    + + + + + + + + + + +
    +
    + +
    + +
    +
    + + Crédito + Contado + Terminal + +
    +
    + + <%-- ******************** Punto de Venta *****************************************************************************************************************************--%> + + + +
    + + +
    +
    +
    +
    + +
    + $ + + +
    +
    + + + +
    +
    +
    + +
    +
    + +
    + $ + + +
    +
    + + + +
    +
    +
    +
    +
    + +
    + $ + + +
    +
    + + + +
    +
    +
    +
    +
    + +
    + $ + + +
    +
    + + + +
    +
    +
    +
    +
    + +
    + $ + + +
    +
    + + + +
    +
    +
    +
    +
    +
    +
    + +
    + $ + + + + + + +

    +
    +
    +
    +
    +
    + +
    + +
    +
    + +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + +
    +
    +
    +
    + +
    +
    + + <%-- **************************************************************************************************************************************************************** --%> + + <%-- Terminal --%> + + +
    +
    + + <%----%> + +
    +
    +
    +
    + <%-- --%> + +
    Tipo Relación: +
    +
    +
    +
    +
    +
    + + +
    + + +
    +
    + + Observaciones +
    +
    +
    +
    +
    +
    + +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + +
    Observaciones Generales: 
    +
    Orden de Compra:   + + + +
    Pedido:   +
    Observaciones Almacén: 
    +
    +
    +
    +
    +
    + +
    + + + + + + +
    +
    + + Acciones +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    + +
    + + + + + + + + + + + +
    + +
    + +
    + + +
    + + +
    + + + + + + + + + + + + + + + + + +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + <%-- ******************************************** Corte de Caja *************************************************************************************************************************************** --%> + +
    + + + + diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 68c76c68c..1aa78c8f2 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -9,7 +9,6 @@ Imports Microsoft.Reporting.WebForms Imports System.Security.Cryptography.X509Certificates Imports System.Globalization - Partial Class Ventas Inherits ClsPaginas @@ -4318,9 +4317,7 @@ Partial Class Ventas DdlMetodoPago33.DataBind() DdlMetodoPago33.SelectedValue = "3" - - CargaFormaPago(DdlMetodoPago33.SelectedValue.ToEntero) - + CargaFormaPago(DdlMetodoPago33.SelectedValue.ToEntero) 'End If @@ -6559,7 +6556,7 @@ Partial Class Ventas 'ContPAQ El movimiento 1 es el de Venta Dim AutoConta As Boolean = UsuarioActual.Empresa.Funcionalidad(200) = "1" - If UsuarioActual.CveEmpresa = 119 AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ant", "Rem", "Cot", "Ped", "Pd2", "PA") Then + If UsuarioActual.CveEmpresa = 119 AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ant", "Rem", "Cot", "Ped", "Pd2", "PA", "NC") Then AutoConta = False End If @@ -8803,7 +8800,7 @@ Partial Class Ventas 'Se agregan los PS For Each Row As DataRow In TmpDTDetalle.Rows If Not ObjVentas.AddVentaDetalle(ObjVentas.CveVenta, Row("CvePS").ToString.ToEntero, Row("Cantidad").ToString.ToDouble, Row("CveUM").ToString.ToEntero, - Row("PU").ToString.ToDouble(If(factura.ConvertirPesos, factura.TipoCambio, 1)), Row("IVA").ToString.ToDouble, Math.Round((Row("Total").ToString.ToDouble(If(factura.ConvertirPesos, factura.TipoCambio, 1)) * (1 + Row("IVA").ToString.ToDouble(If(factura.ConvertirPesos, factura.TipoCambio, 1)))), 6), + Row("PU").ToString.ToDouble(If(factura.ConvertirPesos, factura.TipoCambio, 1)), Row("ImporteIVA").ToString.ToDouble, Math.Round((Row("Total").ToString.ToDouble(If(factura.ConvertirPesos, factura.TipoCambio, 1)) * (1 + Row("PorcentajeIVA").ToString.ToDouble(If(factura.ConvertirPesos, factura.TipoCambio, 1)))), 6), Row("Obs").ToString, Row("Descuento").ToString.ToDouble(If(factura.ConvertirPesos, factura.TipoCambio, 1)), Row("TipoDescuento").ToString.ToEntero, Row("CveSubProyecto").ToString.ToEntero, Row("CvePresupuestoIngreso").ToString.ToEntero, TiempoEntrega:=Row("TiempoEntrega").ToString, CveVentaDetallePadre:=Row("CveVentaDetalle").ToString.ToEntero, CveContratoDetalle:=Row("CveContratoDetalle").ToString.ToEntero, CvePromocionDetalle:=If(DtPromociones IsNot Nothing, DtPromociones.FiltroPrimeroValor("CvePromocionDetalle", $"CvePS={Row("CvePS").ToString}").ToEntero, -1), IEPS:=Row("ImporteIEPS").ToString.ToDouble, CveMovimientoDetallePedido:=Row("CveMovimientoDetallePedido").ToString.ToEntero, @@ -9352,7 +9349,7 @@ Partial Class Ventas ImporteMN251 = Dr("Importe").ToString.ToDecimal * TCFluctuacion ElseIf DdlMoneda.SelectedValue.ToEntero = 1 AndAlso Dr("TCCambioValuacion").ToString.ToDecimal > 1 Then ImporteMN251 = Dr("Importe").ToString.ToDecimal / TipoCambioNC - Else + Else ImporteMN251 = Dr("Importe").ToString.ToDecimal End If @@ -10191,8 +10188,8 @@ Partial Class Ventas End If End If - 'REGRESA SALDO A LAS REMISIONES QUE SE FACTURARON EN EL INGRESO QUE SE ESTA CANCELANDO - If ObjFactura.TipoDocto = "Ing" And ValorMultiplicador = -1 AndAlso NuevaFactura <> 1 AndAlso Not SeCancelaRemisionProceso Then ' se debe de excluir cuando es refacturación + 'REGRESA SALDO A LAS REMISIONES QUE SE FACTURARON EN EL INGRESO QUE SE ESTA CANCELANDO + If ObjFactura.TipoDocto = "Ing" And ValorMultiplicador = -1 AndAlso NuevaFactura <> 1 AndAlso Not SeCancelaRemisionProceso Then ' se debe de excluir cuando es refacturación If ObjVentas.GetRemisionesRelacionadas(ObjFactura.CveVenta, ObjFactura.TipoDocto) AndAlso ObjVentas.DtResultados.Rows.Count > 0 Then For Each Dr As DataRow In ObjVentas.DtResultados.Rows Dim Selecciono As Boolean = False @@ -14408,7 +14405,7 @@ Partial Class Ventas 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("ImporteIVA") = 0 : dr("ImporteIEPS") = 0 : dr("ImporteRetIVA") = 0 : dr("ImporteRetISR") = 0 : dr("PorcentajeIVA") = 0 : dr("IVA") = 0 Next If TmpDTImpuestos IsNot Nothing Then @@ -15823,7 +15820,7 @@ Partial Class Ventas End If Else If Not ObjVentas.AddVentaDetalle(CveVenta, Row("CvePS").ToString.ToEntero, Row("Cantidad").ToString.ToDouble, Row("CveUM").ToString.ToEntero, - Row("PU").ToString.ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)), Row("IVA").ToString.ToDouble, Math.Round((Row("Total").ToString.ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)) * (1 + Row("IVA").ToString.ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)))), 6), + Row("PU").ToString.ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)), Row("ImporteIVA").ToString.ToDouble, Math.Round((Row("Total").ToString.ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)) * (1 + Row("PorcentajeIVA").ToString.ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)))), 6), Row("Obs").ToString, Row("Descuento").ToString.ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)), Row("TipoDescuento").ToString.ToEntero, Row("CveSubProyecto").ToString.ToEntero, Row("CvePresupuestoIngreso").ToString.ToEntero, PorcentajeIVA:=Row("PorcentajeIVA").ToString.ToDecimal, IEPS:=Row("IEPS").ToString.ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)), PorcentajeIEPS:=Row("PorcentajeIEPS").ToString.ToDouble, TiempoEntrega:=Row("TiempoEntrega").ToString, CveVentaDetallePadre:=Row("CveVentaDetalle").ToString.ToEntero, CveContratoDetalle:=Row("CveContratoDetalle").ToString.ToEntero, CvePromocionDetalle:=If(DtPromociones IsNot Nothing, DtPromociones.FiltroPrimeroValor("CvePromocionDetalle", $"CvePS={Row("CvePS").ToString}").ToEntero, -1), ImporteRetIVA:=Row("ImporteRetIVA").ToString.ToDouble, ImporteRetISR:=Row("ImporteRetISR").ToString.ToDouble, PorcentajeRetIVA:=Row("PorcentajeRetIVA").ToString.ToDouble, PorcentajeRetISR:=Row("PorcentajeRetISR").ToString.ToDouble, CuentaPredial:=Row("CuentaPredial").ToString) Then @@ -16086,7 +16083,7 @@ Partial Class Ventas Alert("El producto no fue encontrado.", TipoMensaje.MsgAdvertencia) End If End Sub - Private Sub DdlMoneda_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlMoneda.SelectedIndexChanged + Private Sub DdlMoneda_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlMoneda.SelectedIndexChanged CambiaMoneda() End Sub Private Sub CambiaMoneda() @@ -18330,7 +18327,9 @@ Partial Class Ventas End If End If - If Not ObjVentas.UpdateEstatusFactura(CveEstatus, FolioFiscal, CancelacionAcuse, CancelacionFecha, CveVenta, IDPoliza, CvePAC:=CvePACCancelacion, CveEstatusRefacturacion:=CveEstatusRefacturacion) Then + + If Not ObjVentas.UpdateEstatusFactura(CveEstatus, FolioFiscal, CancelacionAcuse, CancelacionFecha, CveVenta, IDPoliza, CvePAC:=CvePACCancelacion, CveEstatusRefacturacion:=CveEstatusRefacturacion, + CveUsuarioCambiaEstatus:=UsuarioActual.CveUsuario, FechaCambioEstatus:=Now.ToString("yyyy-MM-dd hh:mm:ss.mmm")) Then ErrorCancelar = True MensajeError = "Ocurrió un error al guardar el estatus de cancelación." End If @@ -20879,7 +20878,7 @@ Partial Class Ventas If AplicaNCMasiva Then For Each Gvr As GridViewRow In GvCxC.Rows If Gvr.FCCheckBox("ChkCxC").Checked Then - DtImpuestos.Merge(CargaDtImpuestosNC(Gvr.DataKey("CveVenta").ToString.ToEntero, Gvr.FCTextBox("TxtImporte").Text.ToString.ToDecimal)) + DtImpuestos.Merge(CargaDtImpuestosNC(Gvr.DataKey("CveVenta").ToString.ToEntero, Gvr.FCTextBox("TxtImporte").Text.ToString.ToDecimal), True, MissingSchemaAction.Ignore) 'CARGA FACTURA A LA CUAL SE APLICA LA NC CargaNCDT(Gvr.DataKey("CveVenta").ToString.ToEntero, Gvr.FCTextBox("TxtImporte").Text.ToString.ToDecimal) End If @@ -21753,7 +21752,8 @@ Partial Class Ventas CambiaMetodoPago33() End Sub Private Sub CambiaMetodoPago33() - CargaFormaPago(DdlMetodoPago33.SelectedValue.ToEntero) + CargaFormaPago(DdlMetodoPago33.SelectedValue.ToEntero) + End Sub #End Region @@ -21883,7 +21883,7 @@ Partial Class Ventas 'RE-INSERTA DETALLES For Each Row As DataRow In TmpDT.Rows If Not ObjVentas.AddVentaDetalle(CveVenta, Row("CvePS").ToString.ToEntero, Row("Cantidad").ToString.ToDouble, Row("CveUM").ToString.ToEntero, - Row("PU").ToString.ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)), Row("IVA").ToString.ToDouble, Math.Round((Row("Total").ToString.ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)) * (1 + Row("IVA").ToString.ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)))), 6), + Row("PU").ToString.ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)), Row("ImporteIVA").ToString.ToDouble, Math.Round((Row("Total").ToString.ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)) * (1 + Row("PorcentajeIVA").ToString.ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)))), 6), Row("Obs").ToString, Row("Descuento").ToString.ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)), Row("TipoDescuento").ToString.ToEntero, Row("CveSubProyecto").ToString.ToEntero, Row("CvePresupuestoIngreso").ToString.ToEntero, PorcentajeIVA:=Row("PorcentajeIVA").ToString.ToDecimal, IEPS:=Row("IEPS").ToString.ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)), PorcentajeIEPS:=Row("PorcentajeIEPS").ToString.ToDouble, TiempoEntrega:=Row("TiempoEntrega").ToString) Then MensajeError = "Ocurrió un error al guardar las partidas de la cotización"